Browse Source

技术人员花名册bug修改

ljb 11 months ago
parent
commit
93ce208c77
3 changed files with 26 additions and 8 deletions
  1. 10 1
      src/api/common.js
  2. 1 1
      src/api/technicianRoster.js
  3. 15 6
      src/views/technician-roster/index.vue

+ 10 - 1
src/api/common.js

@@ -10,6 +10,15 @@ export const exportBlob = (url, params) => {
     url: url,
     params: params,
     method: 'get',
-    responseType: 'blob'
+    responseType: 'blob',
+  })
+}
+
+export const exportBloByPost = (url, data) => {
+  return request({
+    url: url,
+    data,
+    method: 'post',
+    responseType: 'blob',
   })
 }

+ 1 - 1
src/api/technicianRoster.js

@@ -42,7 +42,7 @@ export const remove = (ids) => {
 
 export const getLastMonthData = params => {
   return request({
-    url: '/api/kd-scientific/technician/page',
+    url: '/kd-scientific/technician/fetchLastMonthData',
     method: 'get',
     params: {
       ...params,

+ 15 - 6
src/views/technician-roster/index.vue

@@ -57,7 +57,8 @@
     <el-dialog title="技术人员花名册导入"
       append-to-body
       :visible.sync="excelBox"
-      width="555px">
+      width="555px"
+    >
       <avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter">
         <template slot="excelTemplate">
           <el-button type="primary" @click="handleTemplate">
@@ -71,7 +72,7 @@
 
 <script>
 import { getLastMonthData } from "@/api/technicianRoster";
-import {exportBlob} from "@/api/common";
+import {exportBloByPost} from "@/api/common";
 import YearMonthSelect from "@/components/year-month-select";
 import moment from "moment";
 import NProgress from 'nprogress';
@@ -116,16 +117,16 @@ export default window.$crudCommon({
       };
     },
     excelOption() {
+      console.log(this.excelForm)
       return {
         submitBtn: false,
         emptyBtn: false,
         column: [
           {
             label: '上传月份',
-            props: 'yearAndMonth',
+            prop: 'yearAndMonth',
             type: 'input',
             span: 24,
-            value: this.params.yearAndMonth,
             disabled: true,
           },
           {
@@ -178,6 +179,7 @@ export default window.$crudCommon({
     },
     handleImport() {
       this.excelBox = true;
+      this.excelForm.yearAndMonth = this.params.yearAndMonth;
     },
     uploadAfter(res, done, loading, column) {
       this.excelBox = false;
@@ -192,7 +194,7 @@ export default window.$crudCommon({
         type: "warning"
       }).then(() => {
         NProgress.start();
-        exportBlob(`/api/kd-scientific/technician/export?${this.website.tokenHeader}=${getToken()}&yearAndMonth=${this.params.yearAndMonth}`).then(res => {
+        exportBloByPost(`/api/kd-scientific/technician/export?${this.website.tokenHeader}=${getToken()}}`, this.params).then(res => {
           downloadXls(res.data, `技术人员花名册${this.params.yearAndMonth}.xlsx`);
           NProgress.done();
         })
@@ -224,6 +226,13 @@ export default window.$crudCommon({
   },
 }, {
   // 模块路径
-  name: 'technicianRoster'
+  name: 'technicianRoster',
+  res: ({ data }) => {
+    data.records = data.records.map(item => {
+      item.gender = item.gender ? String(item.gender) : '';
+      return item;
+    });
+    return data;
+  },
 });
 </script>