Browse Source

考勤信息接口联调

ljb 10 months ago
parent
commit
54bbf28958

+ 7 - 15
src/api/yfCostManage/basicDataSetting/attenInfo.js

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

+ 39 - 0
src/api/yfCostManage/basicDataSetting/workHoursRecords.js

@@ -0,0 +1,39 @@
+import request from '@/router/axios';
+
+export const getList = (current, size, params) => {
+  return request({
+    url: '/api/kd-scientific/attendance/page',
+    method: 'get',
+    params: {
+      ...params,
+      current,
+      size,
+    }
+  })
+}
+
+export const add = (row) => {
+  return request({
+    url: '/api/kd-scientific/attendance/submit',
+    method: 'post',
+    data: row
+  })
+}
+
+
+export const update = (row) => {
+  return request({
+    url: '/api/kd-scientific/attendance/submit',
+    method: 'post',
+    data: row
+  })
+}
+
+
+export const remove = (data) => {
+  return request({
+    url: '/api/kd-scientific/attendance/remove',
+    method: 'post',
+    data
+  })
+}

+ 8 - 27
src/option/yfCostManage/basicDataSetting/attenInfo.js

@@ -6,10 +6,12 @@ export default {
   searchMenuSpan: 6,
   border: true,
   index: true,
+  addBtn: false,
+  delBtnText: '清除考勤数据',
   selection: true,
   searchLabelWidth: 140,
   labelWidth: 100,
-  menuWidth: 140,
+  menuWidth: 180,
   dialogClickModal: false,
   dialogWidth: 500,
   dialogType: "drawer",
@@ -20,31 +22,10 @@ export default {
       span: 24,
       search: true,
       width: 90,
-      cell: true,
       align: 'center',
-      type: 'select',
+      type: 'input',
       showOverflowTooltip: true,
-      dicUrl: '',
-      dicFlag: true,
-      dicFormatter:(res)=>{     
-        return res.data.records
-      },
-      dicQuery: {
-        current: 1,
-        size: 99999,
-        yearAndMonth: ''
-      },
-      props: {
-        label: 'name',
-        value: 'id',
-      },
-      rules: [
-        {
-          required: true,
-          message: '请选择技术人员',
-          trigger: 'blur',
-        },
-      ],
+      disabled: true,
     },
     {
       label: '工号',
@@ -54,8 +35,8 @@ export default {
       width: 90,
       align: 'center',
       search: true,
-      disabled: true,
       showOverflowTooltip: true,
+      disabled: true,
     },
     {
       label: '身份证号',
@@ -63,10 +44,10 @@ export default {
       type: 'input',
       span: 24,
       search: true,
-      disabled: true,
       width: 150,
       align: 'center',
       showOverflowTooltip: true,
+      disabled: true,
     },
     {
       label: '科研人员类别',
@@ -76,13 +57,13 @@ export default {
       width: 100,
       align: 'center',
       search: true,
-      disabled: true,
       dicUrl: '/api/kd-system/dict-biz/dictionary?code=renyuanleixing',
       props: {
         label: 'dictValue',
         value: 'dictKey',
       },
       showOverflowTooltip: true,
+      disabled: true,
     },
   ],
 };

+ 88 - 0
src/option/yfCostManage/basicDataSetting/workHoursRecords.js

@@ -0,0 +1,88 @@
+export default {
+  height: 'auto',
+  calcHeight: 30,
+  tip: false,
+  searchShow: true,
+  searchMenuSpan: 6,
+  border: true,
+  index: true,
+  selection: true,
+  searchLabelWidth: 140,
+  labelWidth: 100,
+  menuWidth: 140,
+  dialogClickModal: false,
+  dialogWidth: 500,
+  dialogType: "drawer",
+  column: [
+    {
+      label: '姓名',
+      prop: 'name',
+      span: 24,
+      search: true,
+      width: 90,
+      cell: true,
+      align: 'center',
+      type: 'select',
+      showOverflowTooltip: true,
+      dicUrl: '',
+      dicFlag: true,
+      dicFormatter:(res)=>{     
+        return res.data.records
+      },
+      dicQuery: {
+        current: 1,
+        size: 99999,
+        yearAndMonth: ''
+      },
+      props: {
+        label: 'name',
+        value: 'id',
+      },
+      rules: [
+        {
+          required: true,
+          message: '请选择技术人员',
+          trigger: 'blur',
+        },
+      ],
+    },
+    {
+      label: '工号',
+      prop: 'number',
+      type: 'input',
+      span: 24,
+      width: 90,
+      align: 'center',
+      search: true,
+      display: false,
+      showOverflowTooltip: true,
+    },
+    {
+      label: '身份证号',
+      prop: 'identityCard',
+      type: 'input',
+      span: 24,
+      search: true,
+      display: false,
+      width: 150,
+      align: 'center',
+      showOverflowTooltip: true,
+    },
+    {
+      label: '科研人员类别',
+      prop: 'personnelType',
+      type: 'select',
+      span: 24,
+      width: 100,
+      align: 'center',
+      search: true,
+      display: false,
+      dicUrl: '/api/kd-system/dict-biz/dictionary?code=renyuanleixing',
+      props: {
+        label: 'dictValue',
+        value: 'dictKey',
+      },
+      showOverflowTooltip: true,
+    },
+  ],
+};

+ 81 - 19
src/views/yf-cost-manage/basic-data-setting/atten-info.vue

@@ -11,6 +11,15 @@
     >
       <template slot="menuLeft">
         <el-button
+          type="danger"
+          size="small"
+          icon="el-icon-delete"
+          plain
+          @click="handleDelete"
+        >
+          清除考勤数据
+        </el-button>
+        <el-button
           type="warning"
           size="small"
           plain
@@ -26,14 +35,17 @@
         </div>
       </template>
 
-      <!-- 使用工时 -->
+      <!-- <template slot="technicianId" slot-scope="{ row }">
+        <span>{{ row.name }}</span>
+      </template>
+
       <template slot="gsTotalSearch">
         <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>
         </div>
-      </template>
+      </template> -->
       
     </avue-crud>
 
@@ -81,51 +93,92 @@ export default window.$crudCommon({
   },
   async created() {
     this.defaultColumns = deepClone(this.option.column);
-    console.log(this.option.column)
     this.refreshTableCol(this.params.yearAndMonth);
   },
   beforeDestroy() {
     this.option.column = deepClone(this.defaultColumns);
   },
   methods: {
+    // handleBeforeOpen(done, type) {
+    //   this.option.column.forEach(item => {
+    //     if (item.prop == "technicianId") {
+    //       item.dicUrl = '/api/kd-scientific/technician/page';
+    //       item.dicQuery.yearAndMonth = this.params.yearAndMonth;
+    //     }
+    //   });
+    //   done();
+    // },
     refreshTableCol(yearAndMonth) {
       let yearMonth = moment(yearAndMonth).format("YYYY-MM").split("-");
       const monthDays = getMonthDatesWithMarkers(Number(yearMonth[0]), Number(yearMonth[1]));
-      console.log(monthDays)
 
       let newColumns = deepClone(this.defaultColumns);
 
-       monthDays.forEach(item => {
+      monthDays.forEach((item) => {
         let col = {
-          label: item.dayName.replace(/周/g, ''),
+          prop: moment(item.dateString).format('yyyyMMDD'),
+          label: item.dayName + "" + item.day.toString(),
+          type: 'number',
+          precision: 1,
+          min: 0,
+          width: 45,
           align: 'center',
-          children: [{
-            prop: item.day.toString(),
-            label: item.day,
-            type: 'number',
-            min: 0,
-            width: 40,
-            align: 'center',
-            isWorkDay: ChineseHoliday.isWorkday(item.dateString)
-          }],
-          
-        };
+          isWorkDay: ChineseHoliday.isWorkday(item.dateString),
+          showOverflowTooltip: true,
+        }
+
         if (!ChineseHoliday.isWorkday(item.dateString)) {
           col.labelClassName = 'red';
-          col.children[0].labelClassName = 'red';
+          col.labelClassName = 'red';
         }
         newColumns.push(col);
       });
+      newColumns.push({
+        prop: "monthlyHours",
+        label: "本月出勤/小时",
+        type: 'number',
+        precision: 1,
+        min: 0,
+        width: 70,
+        align: 'center',
+        showOverflowTooltip: true,
+      }, {
+        prop: "monthlyDays",
+        label: "本月出勤/天",
+        type: 'number',
+        precision: 1,
+        min: 0,
+        width: 70,
+        align: 'center',
+        showOverflowTooltip: true,
+      });
 
       this.option.column = newColumns;
     },
+    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;
+    },
     /**
      * 打印表格
      * @param isLandscape 是否横向打印
      */
     printTable(isLandscape) {
       this.wideTableColumns = this.$refs.crud.columnOption;
-      this.printTitle = `仪器设备工时记录表${this.params.yearAndMonth}`;
+      this.printTitle = `考勤信息${this.params.yearAndMonth}`;
       this.$nextTick(() => {
         this.$refs.printWideTable.printTable(isLandscape);
       })
@@ -141,6 +194,15 @@ export default window.$crudCommon({
   // 模块路径
   name: 'yfCostManage/basicDataSetting/attenInfo',
   res: ({ data }) => {
+    let newList = [];
+    data.records.forEach((item) => {
+      let objData = { ...item, id: item.technicianId };
+      item.dailyAttendances.forEach(hourItem => {
+        objData[hourItem.workDate] = (hourItem.workHours || 0).toFixed(1);
+      });
+      newList.push(objData);
+    });
+    data.records = newList;
     return data;
   },
 });

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

@@ -81,7 +81,6 @@ export default window.$crudCommon({
   },
   async created() {
     this.defaultColumns = deepClone(this.option.column);
-    console.log(this.option.column)
     this.refreshTableCol(this.params.yearAndMonth);
   },
   beforeDestroy() {
@@ -91,28 +90,24 @@ export default window.$crudCommon({
     refreshTableCol(yearAndMonth) {
       let yearMonth = moment(yearAndMonth).format("YYYY-MM").split("-");
       const monthDays = getMonthDatesWithMarkers(Number(yearMonth[0]), Number(yearMonth[1]));
-      console.log(monthDays)
 
       let newColumns = deepClone(this.defaultColumns);
 
        monthDays.forEach(item => {
         let col = {
-          label: item.dayName.replace(/周/g, ''),
+          prop: moment(item.dateString).format('yyyyMMDD'),
+          label:  item.dayName + "" + item.day.toString(),
+          type: 'number',
+          precision: 1,
+          min: 0,
+          width: 45,
           align: 'center',
-          children: [{
-            prop: item.day.toString(),
-            label: item.day,
-            type: 'number',
-            min: 0,
-            width: 40,
-            align: 'center',
-            isWorkDay: ChineseHoliday.isWorkday(item.dateString)
-          }],
-          
+          isWorkDay: ChineseHoliday.isWorkday(item.dateString),
+          showOverflowTooltip: true,
         };
         if (!ChineseHoliday.isWorkday(item.dateString)) {
           col.labelClassName = 'red';
-          col.children[0].labelClassName = 'red';
+          col.labelClassName = 'red';
         }
         newColumns.push(col);
       });
@@ -139,7 +134,7 @@ export default window.$crudCommon({
   },
 }, {
   // 模块路径
-  name: 'yfCostManage/basicDataSetting/attenInfo',
+  name: 'yfCostManage/basicDataSetting/workHoursRecords',
   res: ({ data }) => {
     return data;
   },