一、nginx配置

  1. location ~ /staservice/ {
  2. proxy_pass http://localhost:8008;
  3. }

二、前端页面实现

1、创建api

创建src/api/sta.js

  1. import request from '@/utils/request'
  2. const api_name = '/admin/statistics/daily'
  3. export default {
  4. createStatistics(day) {
  5. return request({
  6. url: `${api_name}/${day}`,
  7. method: 'post'
  8. })
  9. }
  10. }

2、增加路由

src/router/index.js

  1. {
  2. path: '/statistics/daily',
  3. component: Layout,
  4. redirect: '/statistics/daily/create',
  5. name: 'Statistics',
  6. meta: { title: '统计分析', icon: 'chart' },
  7. children: [
  8. {
  9. path: 'create',
  10. name: 'StatisticsDailyCreate',
  11. component: () => import('@/views/statistics/daily/create'),
  12. meta: { title: '生成统计' }
  13. }
  14. ]
  15. },

3、创建组件

src/views/statistics/daily/create.vue
模板部分

<template>
  <div class="app-container">
    <!--表单-->
    <el-form :inline="true" class="demo-form-inline">


      <el-form-item label="日期">
        <el-date-picker
          v-model="day"
          type="date"
          placeholder="选择要统计的日期"
          value-format="yyyy-MM-dd" />
      </el-form-item>


      <el-button
        :disabled="btnDisabled"
        type="primary"
        @click="create()">生成</el-button>
    </el-form>


  </div>

</template>

script部分


<script>
import daily from '@/api/sta'
export default {
  data() {
    return {
      day: '',
      btnDisabled: false
    }
  },


  methods: {
    create() {
      this.btnDisabled = true
      daily.createStatistics(this.day).then(response => {
        this.btnDisabled = false
        this.$message({
          type: 'success',
          message: '生成成功'
        })
      })
    }
  }

}
</script>