Kaynağa Gözat

技术人员工资年度月平均工资删除功能

ljb 11 ay önce
ebeveyn
işleme
ebca89aaec

+ 6 - 0
package-lock.json

@@ -13,6 +13,7 @@
         "babel-polyfill": "^6.26.0",
         "classlist-polyfill": "^1.2.0",
         "crypto-js": "^4.0.0",
+        "decimal.js": "^10.5.0",
         "element-ui": "^2.15.6",
         "js-base64": "^2.5.1",
         "js-cookie": "^2.2.0",
@@ -5697,6 +5698,11 @@
         "node": ">=0.10.0"
       }
     },
+    "node_modules/decimal.js": {
+      "version": "10.5.0",
+      "resolved": "https://registry.npmmirror.com/decimal.js/-/decimal.js-10.5.0.tgz",
+      "integrity": "sha512-8vDa8Qxvr/+d94hSh5P3IJwI5t8/c0KsMp+g8bNw9cY2icONa5aPfvKeieW1WlG0WQYwwhJ7mjui2xtiePQSXw=="
+    },
     "node_modules/decode-uri-component": {
       "version": "0.2.2",
       "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.2.tgz",

+ 1 - 0
package.json

@@ -16,6 +16,7 @@
     "babel-polyfill": "^6.26.0",
     "classlist-polyfill": "^1.2.0",
     "crypto-js": "^4.0.0",
+    "decimal.js": "^10.5.0",
     "element-ui": "^2.15.6",
     "js-base64": "^2.5.1",
     "js-cookie": "^2.2.0",

+ 2 - 2
src/api/technicianMonthAvgSales.js

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

+ 5 - 2
src/mixins/crud.js

@@ -147,6 +147,9 @@ export default (app, option = {}) => {
           })
         }
       },
+      getBatchDelParams() {
+        return this.ids;
+      },
       handleDelete() {
         if (this.selectionList.length === 0) {
           this.$message.warning("请选择至少一条数据");
@@ -158,10 +161,10 @@ export default (app, option = {}) => {
           type: "warning"
         })
           .then(() => {
-            this.api[option.del || 'remove'](this.ids).then((data) => {
+            this.api[option.del || 'remove'](this.getBatchDelParams()).then((data) => {
               this.getList();
               if (this.delMultiAfter) {
-                this.delMultiAfter(data, this.ids);
+                this.delMultiAfter(data, this.getBatchDelParams());
               } else {
                 this.$message.success('删除成功');
               }

+ 26 - 7
src/views/technician-month-avg-sales/index.vue

@@ -191,7 +191,16 @@ export default window.$crudCommon({
       callback && callback();
     },
     getDelParams(row) {
-      return { yearAndMonth: this.params.yearAndMonth, number: row.number, identityCard: row.identityCard }
+      return [{ yearAndMonth: this.params.yearAndMonth, number: row.number, identityCard: row.identityCard }]
+    },
+    getBatchDelParams() {
+      let delArr = [];
+      this.data.forEach(item => {
+        if (this.ids.indexOf(item.id) > -1) {
+          delArr.push({ yearAndMonth: this.params.yearAndMonth, number: item.number, identityCard: item.identityCard });
+        }
+      });
+      return delArr;
     },
     handleImport() {
       this.excelBox = true;
@@ -245,12 +254,22 @@ export default window.$crudCommon({
   name: 'technicianMonthAvgSales',
   res: ({ data }) => {
     data.records = data.records.map(item => {
-      let pensionInsurance = new Decimal(item.pensionInsurance || 0);
-      let medicalInsurance = new Decimal(item.medicalInsurance || 0);
-      let unemploymentInsurance = new Decimal(item.unemploymentInsurance || 0);
-      let injuryInsurance = new Decimal(item.injuryInsurance || 0);
-      let maternityInsurance = new Decimal(item.maternityInsurance || 0);
-      let providentFund = new Decimal(item.providentFund || 0);
+      // 处理id为空的时候,批量清除数据无法获取数据的问题
+      item.id = !item.id ? (item.number || item.identityCard) : item.id;
+      item.averageMonthlySalary = item.averageMonthlySalary === -1 ? "0.00" : item.averageMonthlySalary;
+      item.pensionInsurance = item.pensionInsurance === -1 ? "0.00" : item.pensionInsurance;
+      item.medicalInsurance = item.medicalInsurance === -1 ? "0.00" : item.medicalInsurance;
+      item.unemploymentInsurance = item.unemploymentInsurance === -1 ? "0.00" : item.unemploymentInsurance;
+      item.injuryInsurance = item.injuryInsurance === -1 ? "0.00" : item.injuryInsurance;
+      item.maternityInsurance = item.maternityInsurance === -1 ? "0.00" : item.maternityInsurance;
+      item.providentFund = item.providentFund === -1 ? "0.00" : item.providentFund;
+
+      let pensionInsurance = new Decimal(item.pensionInsurance);
+      let medicalInsurance = new Decimal(item.medicalInsurance);
+      let unemploymentInsurance = new Decimal(item.unemploymentInsurance);
+      let injuryInsurance = new Decimal(item.injuryInsurance);
+      let maternityInsurance = new Decimal(item.maternityInsurance);
+      let providentFund = new Decimal(item.providentFund);
 
       // 社保合计
       let socialInsurance = pensionInsurance.add(medicalInsurance).add(unemploymentInsurance).add(injuryInsurance).add(maternityInsurance);