Browse Source

技术人员工资明细增加修改功能和清除工资数据功能

ljb 11 months ago
parent
commit
352eb985cc

+ 2 - 4
src/api/technicianMonthAvgSales.js

@@ -30,13 +30,11 @@ export const update = (row) => {
 }
 
 
-export const remove = (ids) => {
+export const remove = (params) => {
   return request({
     url: '/api/kd-scientific/salary/remove',
     method: 'post',
-    params: {
-      ids,
-    }
+    params
   })
 }
 

+ 9 - 3
src/mixins/crud.js

@@ -75,10 +75,13 @@ export default (app, option = {}) => {
         }
         callback();
       },
+      getFormData() {
+        return this.form;
+      },
       rowSave(row, done, loading) {
         const callback = () => {
           delete this.form.params;
-          this.api[option.add || 'add'](this.form).then((data) => {
+          this.api[option.add || 'add'](this.getFormData()).then((data) => {
             this.getList();
             if (this.addAfter) {
               this.addAfter(data);
@@ -99,7 +102,7 @@ export default (app, option = {}) => {
       rowUpdate(row, index, done, loading) {
         const callback = () => {
           delete this.form.params;
-          this.api[option.update || 'update'](this.form).then((data) => {
+          this.api[option.update || 'update'](this.getFormData()).then((data) => {
             this.getList();
             if (this.updateAfter) {
               this.updateAfter(data);
@@ -117,9 +120,12 @@ export default (app, option = {}) => {
         }
         callback();
       },
+      getDelParams(row) {
+        return row[this.rowKey];
+      },
       rowDel(row, index) {
         const callback = () => {
-          this.api[option.del || 'remove'](row[this.rowKey], row).then((data) => {
+          this.api[option.del || 'remove'](this.getDelParams(row), row).then((data) => {
             this.getList();
             if (this.delAfter) {
               this.delAfter(data, row, index)

+ 20 - 20
src/option/technicianMonthAvgSales.js

@@ -7,11 +7,11 @@ export default {
   border: true,
   index: true,
   viewBtn: true,
-  editBtn: false,
+  delBtnText: '清除工资数据',
   selection: true,
   searchLabelWidth: 140,
-  labelWidth: 255,
-  menuWidth: 220,
+  labelWidth: 200,
+  menuWidth: 260,
   dialogClickModal: false,
   dialogWidth: 500,
   dialogType: "drawer",
@@ -99,92 +99,92 @@ export default {
       showOverflowTooltip: true,
     },
     {
-      label: '上一年度月均工资(元)',
+      label: '月均工资(元)',
       prop: 'averageMonthlySalary',
       type: 'number',
       min: 0,
       precision: 2,
       span: 24,
-      width: 90,
+      minWidth: 90,
       align: 'center',
       showOverflowTooltip: true,
     },
     {
-      label: '上一年度月均单位承担部分养老保险',
+      label: '月均单位承担部分养老保险',
       prop: 'pensionInsurance',
       type: 'number',
       min: 0,
       precision: 2,
       span: 24,
-      width: 100,
+      minWidth: 100,
       align: 'center',
       showOverflowTooltip: true,
     },
     {
-      label: '上一年度月均单位承担部分医疗保险',
+      label: '月均单位承担部分医疗保险',
       prop: 'medicalInsurance',
       type: 'number',
       min: 0,
       precision: 2,
       span: 24,
-      width: 90,
+      minWidth: 90,
       align: 'center',
       showOverflowTooltip: true,
     },
     {
-      label: '上一年度月均单位承担部分失业保险',
+      label: '月均单位承担部分失业保险',
       prop: 'unemploymentInsurance',
       type: 'number',
       min: 0,
       precision: 2,
       span: 24,
-      width: 90,
+      minWidth: 90,
       align: 'center',
       showOverflowTooltip: true,
     },
     {
-      label: '上一年度月均单位承担部分工伤保险',
+      label: '月均单位承担部分工伤保险',
       prop: 'injuryInsurance',
       type: 'number',
       min: 0,
       precision: 2,
       span: 24,
-      width: 90,
+      minWidth: 90,
       align: 'center',
       showOverflowTooltip: true,
     },
     {
-      label: '上一年度月均单位承担部分生育保险',
+      label: '月均单位承担部分生育保险',
       prop: 'maternityInsurance',
       type: 'number',
       min: 0,
       precision: 2,
       span: 24,
-      width: 90,
+      minWidth: 90,
       align: 'center',
       showOverflowTooltip: true,
     },
     {
-      label: '上一年度月均单位承担部分社保合计(元)',
+      label: '月均单位承担部分社保合计(元)',
       prop: 'socialInsurance',
       type: 'number',
       min: 0,
       precision: 2,
       span: 24,
-      width: 90,
+      minWidth: 90,
       align: 'center',
       addDisplay: false,
       editDisplay: false,
       showOverflowTooltip: true,
     },
     {
-      label: '上一年度月均单位承担部分公积金(元)',
+      label: '月均单位承担部分公积金(元)',
       prop: 'providentFund',
       type: 'number',
       min: 0,
       precision: 2,
       span: 24,
-      width: 90,
+      minWidth: 90,
       align: 'center',
       showOverflowTooltip: true,
     },
@@ -195,7 +195,7 @@ export default {
       min: 0,
       precision: 2,
       span: 24,
-      width: 100,
+      minWidth: 100,
       align: 'center',
       addDisplay: false,
       editDisplay: false,

+ 4 - 0
src/option/technicianRoster.js

@@ -127,6 +127,7 @@ export default {
       span: 12,
       width: 140,
       search: true,
+      align: 'center',
       showOverflowTooltip: true,
       rules: [
         {
@@ -143,6 +144,7 @@ export default {
       span: 12,
       width: 140,
       search: true,
+      align: 'center',
       showOverflowTooltip: true,
       rules: [
         {
@@ -176,6 +178,7 @@ export default {
       span: 12,
       width: 100,
       search: true,
+      align: 'center',
       showOverflowTooltip: true,
       rules: [
         {
@@ -275,6 +278,7 @@ export default {
       type: 'input',
       span: 12,
       width: 160,
+      align: 'center',
       showOverflowTooltip: true,
       rules: [
         {

+ 34 - 2
src/views/technician-month-avg-sales/index.vue

@@ -16,7 +16,7 @@
           plain
           @click="handleDelete"
         >
-          删 除
+          清除工资数据
         </el-button>
         <el-button
           type="success"
@@ -90,6 +90,11 @@ export default window.$crudCommon({
       },
       excelBox: false,
       excelForm: {},
+
+      operateType: '',
+      watchUpdateKey: ["averageMonthlySalary", "pensionInsurance", "medicalInsurance", "unemploymentInsurance", "injuryInsurance", "maternityInsurance", "providentFund"],
+      beforeUpdatedData: {},
+      updatedFormData: {},
     };
   },
   watch: {
@@ -103,6 +108,7 @@ export default window.$crudCommon({
       return {
         submitBtn: false,
         emptyBtn: false,
+        
         column: [
           {
             label: '模板上传',
@@ -153,6 +159,8 @@ export default window.$crudCommon({
   },
   methods: {
     handleBeforeOpen(done, type) {
+      this.operateType = type;
+      this.beforeUpdatedData = { ...this.form };
       this.option.column.forEach(item => {
         if (item.prop == "name") {
           item.dicUrl = '/api/kd-scientific/technician/page';
@@ -161,6 +169,30 @@ export default window.$crudCommon({
       });
       done();
     },
+    getFormData() {
+      if (this.operateType === 'edit') {
+        return this.updatedFormData
+      }
+      return this.form;
+    },
+    updateBefore(loading, callback) {
+      let updatedData = {};
+      this.watchUpdateKey.forEach(key => {
+        if (Number(this.form[key]) != Number(this.beforeUpdatedData[key])) {
+          updatedData[key] = this.form[key];
+        }
+      });
+      this.updatedFormData = {
+        number: this.form.number,
+        identityCard: this.form.identityCard,
+        yearAndMonth: this.params.yearAndMonth,
+        ...updatedData
+      };
+      callback && callback();
+    },
+    getDelParams(row) {
+      return { yearAndMonth: this.params.yearAndMonth, number: row.number, identityCard: row.identityCard }
+    },
     handleImport() {
       this.excelBox = true;
       this.excelForm.yearAndMonth = this.params.yearAndMonth;
@@ -179,7 +211,7 @@ export default window.$crudCommon({
       }).then(() => {
         NProgress.start();
         exportBloByPost(`/api/kd-scientific/salary/export-salary?${this.website.tokenHeader}=${getToken()}`, this.params).then(res => {
-          downloadXls(res.data, `技术人员上一年度平均工资${this.params.yearAndMonth}.xlsx`);
+          downloadXls(res.data, `技术人员${this.params.yearAndMonth}年度平均工资.xlsx`);
           NProgress.done();
         })
       });