Browse Source

研发工时接口联调

ljb 10 months ago
parent
commit
046f6a39bc

+ 4 - 4
src/api/yfCostManage/basicDataSetting/workHoursRecords.js

@@ -2,7 +2,7 @@ import request from '@/router/axios';
 
 
 export const getList = (current, size, params) => {
 export const getList = (current, size, params) => {
   return request({
   return request({
-    url: '/api/kd-scientific/attendance/page',
+    url: '/api/kd-scientific/xm/technician/hours/page',
     method: 'get',
     method: 'get',
     params: {
     params: {
       ...params,
       ...params,
@@ -14,7 +14,7 @@ export const getList = (current, size, params) => {
 
 
 export const add = (row) => {
 export const add = (row) => {
   return request({
   return request({
-    url: '/api/kd-scientific/attendance/submit',
+    url: '/api/kd-scientific/xm/technician/hours/submit/batch',
     method: 'post',
     method: 'post',
     data: row
     data: row
   })
   })
@@ -23,7 +23,7 @@ export const add = (row) => {
 
 
 export const update = (row) => {
 export const update = (row) => {
   return request({
   return request({
-    url: '/api/kd-scientific/attendance/submit',
+    url: '/api/kd-scientific/xm/technician/hours/submit/batch',
     method: 'post',
     method: 'post',
     data: row
     data: row
   })
   })
@@ -32,7 +32,7 @@ export const update = (row) => {
 
 
 export const remove = (data) => {
 export const remove = (data) => {
   return request({
   return request({
-    url: '/api/kd-scientific/attendance/remove',
+    url: '/api/kd-scientific/xm/technician/hours/clear/batch',
     method: 'post',
     method: 'post',
     data
     data
   })
   })

+ 2 - 1
src/option/yfCostManage/basicDataSetting/workHoursRecords.js

@@ -7,9 +7,10 @@ export default {
   border: true,
   border: true,
   index: true,
   index: true,
   selection: true,
   selection: true,
+  delBtnText: '清除工时数据',
   searchLabelWidth: 140,
   searchLabelWidth: 140,
   labelWidth: 100,
   labelWidth: 100,
-  menuWidth: 140,
+  menuWidth: 190,
   dialogClickModal: false,
   dialogClickModal: false,
   dialogWidth: 500,
   dialogWidth: 500,
   dialogType: "drawer",
   dialogType: "drawer",

+ 100 - 7
src/views/yf-cost-manage/basic-data-setting/working-hours-records.vue

@@ -11,6 +11,15 @@
     >
     >
       <template slot="menuLeft">
       <template slot="menuLeft">
         <el-button
         <el-button
+          type="danger"
+          size="small"
+          icon="el-icon-delete"
+          plain
+          @click="handleDelete"
+        >
+          清除工时数据
+        </el-button>
+        <el-button
           type="warning"
           type="warning"
           size="small"
           size="small"
           plain
           plain
@@ -26,17 +35,20 @@
         </div>
         </div>
       </template>
       </template>
 
 
-      <!-- 使用工时 -->
-      <template slot="gsTotalSearch">
+
+      <template slot="monthlyHoursSearch">
         <div style="display: flex; align-items: center;">
         <div style="display: flex; align-items: center;">
-          <avue-input-number v-model="params.gsTotalStart" :min="0"></avue-input-number>
-          <span style="width: 70px; text-align: center;">至</span>
-          <avue-input-number v-model="params.gsTotalEnd" :min="0"></avue-input-number>
+          <span>使用工时/小时:</span>
+          <avue-input-number v-model="params.monthlyHoursStart" :min="0" style="width: 100px !important;"></avue-input-number>
+          <span style="width: 20px; text-align: center;">至</span>
+          <avue-input-number v-model="params.monthlyHoursEnd" :min="0" style="width: 100px !important;"></avue-input-number>
         </div>
         </div>
       </template>
       </template>
       
       
     </avue-crud>
     </avue-crud>
 
 
+    <upload-excel-dialog ref="uploadExcelDialog" :uploadAfter="uploadAfter"/>
+
     <WideTablePrinter
     <WideTablePrinter
       ref="printWideTable"
       ref="printWideTable"
       :columns="wideTableColumns"
       :columns="wideTableColumns"
@@ -51,6 +63,9 @@
 <script>
 <script>
 import YearMonthSelect from "@/components/year-month-select";
 import YearMonthSelect from "@/components/year-month-select";
 import UploadExcelDialog from "@/components/upload-excel-dialog";
 import UploadExcelDialog from "@/components/upload-excel-dialog";
+import {exportBlob} from "@/api/common";
+import {getToken} from "@/util/auth";
+import {downloadXls} from "@/util/util";
 import { deepClone, getMonthDatesWithMarkers } from "@/util/util";
 import { deepClone, getMonthDatesWithMarkers } from "@/util/util";
 import moment from "moment";
 import moment from "moment";
 import ChineseHoliday from "@chnlib/chinese-holiday";
 import ChineseHoliday from "@chnlib/chinese-holiday";
@@ -87,7 +102,6 @@ export default window.$crudCommon({
     this.option.column = deepClone(this.defaultColumns);
     this.option.column = deepClone(this.defaultColumns);
   },
   },
   methods: {
   methods: {
-    loadData() {},
     refreshTableCol(yearAndMonth) {
     refreshTableCol(yearAndMonth) {
       let yearMonth = moment(yearAndMonth).format("YYYY-MM").split("-");
       let yearMonth = moment(yearAndMonth).format("YYYY-MM").split("-");
       const monthDays = getMonthDatesWithMarkers(Number(yearMonth[0]), Number(yearMonth[1]));
       const monthDays = getMonthDatesWithMarkers(Number(yearMonth[0]), Number(yearMonth[1]));
@@ -113,15 +127,80 @@ export default window.$crudCommon({
         newColumns.push(col);
         newColumns.push(col);
       });
       });
 
 
+      newColumns.push({
+        prop: "monthlyHours",
+        label: "研发出勤/小时",
+        type: 'number',
+        precision: 1,
+        min: 0,
+        width: 70,
+        align: 'center',
+        showOverflowTooltip: true,
+        display: false,
+        search: true,
+      }, {
+        prop: "monthlyDays",
+        label: "研发出勤/天",
+        type: 'number',
+        precision: 1,
+        min: 0,
+        width: 70,
+        align: 'center',
+        showOverflowTooltip: true,
+        display: false,
+      });
+
       this.option.column = newColumns;
       this.option.column = newColumns;
     },
     },
+    handleImport() {
+      let excelParams = { yearAndMonth: this.params.yearAndMonth };
+      this.$refs.uploadExcelDialog.open('/api/kd-scientific/xm/technician/hours/import', excelParams);
+    },
+    uploadAfter() {
+      this.page.currentPage = 1;
+      this.getList(this.page);
+    },
+    getFormData() {
+      const newFormData = { ...this.form, yearAndMonth: this.params.yearAndMonth  };
+      let dailyAttendances = [];
+      Object.keys(this.form).forEach(key => {
+        if (key.indexOf(this.params.yearAndMonth) > -1) {
+          if (this.form[key]) {
+            dailyAttendances.push({
+              workDate: key,
+              workHours: this.form[key]
+            });
+          }
+          delete newFormData[key];
+        }
+      });
+      newFormData.dailyAttendances = dailyAttendances;
+      return newFormData;
+    },
+    getDelParams(row) {
+      return [{ yearAndMonth: this.params.yearAndMonth, unicode: row.unicode }]
+    },
+    getBatchDelParams() {
+      let delArr = [];
+      this.data.forEach(item => {
+        if (this.ids.indexOf(item.id) > -1) {
+          delArr.push({ yearAndMonth: this.params.yearAndMonth, unicode: item.unicode });
+        }
+      });
+      return delArr;
+    },
+    handleExport() {
+      exportBlob(`/api/kd-scientific/xm/technician/hours/export?${this.website.tokenHeader}=${getToken()}`, this.params).then(res => {
+        downloadXls(res.data, `${this.params.yearAndMonth}研发人员工时记录表.xlsx`);
+      });
+    },
     /**
     /**
      * 打印表格
      * 打印表格
      * @param isLandscape 是否横向打印
      * @param isLandscape 是否横向打印
      */
      */
     printTable(isLandscape) {
     printTable(isLandscape) {
       this.wideTableColumns = this.$refs.crud.columnOption;
       this.wideTableColumns = this.$refs.crud.columnOption;
-      this.printTitle = `仪器设备工时记录表${this.params.yearAndMonth}`;
+      this.printTitle = `${this.params.yearAndMonth}研发人员工时记录表`;
       this.$nextTick(() => {
       this.$nextTick(() => {
         this.$refs.printWideTable.printTable(isLandscape);
         this.$refs.printWideTable.printTable(isLandscape);
       })
       })
@@ -137,6 +216,20 @@ export default window.$crudCommon({
   // 模块路径
   // 模块路径
   name: 'yfCostManage/basicDataSetting/workHoursRecords',
   name: 'yfCostManage/basicDataSetting/workHoursRecords',
   res: ({ data }) => {
   res: ({ data }) => {
+    let newList = [];
+    data.records.forEach((item) => {
+      let objData = {
+        ...item,
+        id: item.unicode,
+        monthlyHours: (item.monthlyHours || 0).toFixed(1),
+        monthlyDays: (item.monthlyDays || 0).toFixed(1)
+      };
+      item.dailyAttendances.forEach(hourItem => {
+        objData[hourItem.workDate] = (hourItem.workHours || 0).toFixed(1);
+      });
+      newList.push(objData);
+    });
+    data.records = newList;
     return data;
     return data;
   },
   },
 });
 });