guoshilong
2022-09-23 3909a52d26dca085a6ead5d0fbaca0ce512e27f7
数据统计人员统计
4 files modified
3 files added
232 ■■■■■ changed files
src/api/userstatistics/repairtask.js 14 ●●●●● patch | view | raw | blame | history
src/util/date.js 42 ●●●●● patch | view | raw | blame | history
src/views/taskinfo/taskinfo.vue 8 ●●●● patch | view | raw | blame | history
src/views/taskinfo/taskinfoPlan.vue 7 ●●●● patch | view | raw | blame | history
src/views/taskinfo/taskplanUser.vue 2 ●●● patch | view | raw | blame | history
src/views/userstatistics/repairtask.vue 132 ●●●●● patch | view | raw | blame | history
src/views/userstatistics/userstatistics.vue 27 ●●●●● patch | view | raw | blame | history
src/api/userstatistics/repairtask.js
New file
@@ -0,0 +1,14 @@
import request from "@/router/axios";
export const getUserStatistics = (current, size,startTime,endTime) =>{
  return request({
    url: '/api/userstatistics/userstatistics/getRepairTask',
    method: 'post',
    params: {
      startTime,
      endTime,
      current,
      size,
    }
  })
}
src/util/date.js
@@ -56,3 +56,45 @@
export function dateNow() {
  return dateFormat(new Date(), "yyyyMMddhhmmss");
}
/**
 * 获取本月1号时间
 */
export function getMonthStart(){
  var myDate = new Date();
  var year = myDate.getFullYear();
  //获取当前月份(0-11,0代表1月,所以要加1);
  var month = myDate.getMonth() + 1;
  //获取当前日(1-31)
  var day = myDate.getDate();
  if (month < 10) {
    month = "0" + month;
  }
  if (day >= 0 && day <= 9) {
    day = "0" + day;
  }
  var firstDay = year + "-" + month + "-01";
  // this.query['startTime'] = firstDay;
  return firstDay;
}
/**
 * 获取本月当前日的时间
 */
export function getMonthEnd(){
  var myDate = new Date();
  var year = myDate.getFullYear();
  //获取当前月份(0-11,0代表1月,所以要加1);
  var month = myDate.getMonth() + 1;
  //获取当前日(1-31)
  var day = myDate.getDate();
  if (month < 10) {
    month = "0" + month;
  }
  if (day >= 0 && day <= 9) {
    day = "0" + day;
  }
  var thisDay = year + "-" + month + "-" + day;
  // this.query['endTime'] = thisDay;
  return thisDay;
}
src/views/taskinfo/taskinfo.vue
@@ -163,13 +163,7 @@
          });
      },
      beforeOpen(done, type) {
        if (["edit", "view"].includes(type)) {
          getDetail(this.form.id).then(res => {
            this.form = res.data.data;
            console.log( this.form.routeRange,123456)
            // this.form.routeRange = '\'' + this.form.routeRange + '\''
          });
        } else {
        if (["add"].includes(type)) {
          const date = new Date()
          const year = date.getFullYear()
          const month = date.getMonth() + 1
src/views/taskinfo/taskinfoPlan.vue
@@ -177,12 +177,7 @@
          });
      },
      beforeOpen(done, type) {
        if (["edit", "view"].includes(type)) {
          // getDetail(this.form.id).then(res => {
          //   this.form = res.data.data;
          //   // this.form.routeRange = '\'' + this.form.routeRange + '\''
          // });
        } else {
        if (["add"].includes(type)) {
          this.form.status = 2
        }
        done();
src/views/taskinfo/taskplanUser.vue
@@ -200,7 +200,7 @@
          this.data = data.records;
          this.loading = false;
          this.selectionClear();
          this.getUserList();
        });
      },
      getUserList(){
src/views/userstatistics/repairtask.vue
New file
@@ -0,0 +1,132 @@
<template>
  <basic-container>
    <avue-crud ref="crud"
               :option="option"
               :page.sync="page"
               :table-loading="loading"
               @row-update="rowUpdate"
               @row-save="rowSave"
               @row-del="rowDel"
               @refresh-change="refreshChange"
               @search-reset="searchChange"
               @search-change="searchChange"
               v-model="form"
               :data="data">
    </avue-crud>
  </basic-container>
</template>
<script>
import {getUserStatistics} from "@/api/userstatistics/repairtask";
import {getMonthStart,getMonthEnd} from "@/util/date";
export default {
  name: "repairtask",
  data() {
    return {
      option: {
        border: true,
        stripe: false,
        addBtn: false,
        header: false,
        menu: false,
        searchShow: true,
        searchMenuSpan: 6,
        height: 520,
        menuWidth: 200,
        menuAlign: "center",
        align: "center",
        selection: false,
        showSummary: true,
        indexFixed: false,
        selectionFixed: false,
        expandFixed: false,
        menuFixed: false,
        column: [
          {
            label: "姓名",
            prop: "name",
          },
          {
            label: "维修待完成",
            prop: "wxDaiNum"
          },
          {
            label: "维修已完成",
            prop: "wxOkNum"
          },
          {
            label: "任务待完成",
            prop: "skDaiNum"
          },
          {
            label: "任务已完成",
            prop: "skOkNum"
          }, {
            label: "筛选时间段",
            prop: "releaseTimeRange",
            span: 12,
            hide: true,
            search: true,
            searchSpan: 7,
            searchLabelWidth: 110,
            searchRange: true,
            searchValue: [getMonthStart(), getMonthEnd()],
            type: "date",
            format: "yyyy-MM-dd",
            valueFormat: "yyyy-MM-dd",
            rules: [
              {
                required: true,
                message: "请选择时间",
                trigger: "click",
              },
            ],
          }
        ]
      },
      page:{
        pageSize: 10,
        currentPage: 1,
        total: 0,
      },
      form:{},
      query:{},
      data:[]
    }
  },
  created() {
  },
  mounted() {
    this.query.startTime = getMonthStart()
    this.query.endTime = getMonthEnd()
    this.onLoad()
  },
  methods: {
    searchReset() {
      this.query = {};
      this.onLoad();
    },
    searchChange(params, done) {
      this.query.startTime = params.releaseTimeRange[0];
      this.query.endTime =  params.releaseTimeRange[1];
      this.onLoad();
      this.query={}
      done();
    },
    onLoad() {
        getUserStatistics(this.page.currentPage,this.page.pageSize,this.query.startTime,this.query.endTime).then(res=>{
          if (res.data.code == 200){
            var data = res.data.data
            this.data = data.records
          }
        })
    }
  }
}
</script>
<style scoped>
</style>
src/views/userstatistics/userstatistics.vue
New file
@@ -0,0 +1,27 @@
<template>
  <div class="statistics-body">
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <!-- 人员统计 -->
      <el-tab-pane label="人员统计" name="tab1">
        <repairtask></repairtask>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
<script>
import Repairtask from "@/views/userstatistics/repairtask";
export default {
  name: "userstatistics",
  components: {Repairtask},
  data() {
    return {
      activeName: "tab1",
    };
  },
}
</script>
<style scoped>
</style>