Tang 3 年 前
コミット
400832b1d9

+ 32 - 24
src/views/Marketing/order/offlineOrder/batchRecord/secondStep/index.vue

@@ -227,6 +227,11 @@ export default {
     this.getHeightData();
     this.getSujectList();
   },
+  watch:{
+    tableData(val){
+      this.merage()
+    }
+  },
   computed: {
     compay: function () {
       return function (data, int) {
@@ -281,15 +286,14 @@ export default {
         return arr;
       };
     },
-    filterData:function(){
-      return function(list){
-        let ary = []
-        ary = list.filter(item => {
-          return !item.success
-        })
-        console.log(ary,66)
-        return ary
-      }
+    filterData: function () {
+      return function (list) {
+        let ary = [];
+        ary = list.filter((item) => {
+          return !item.success;
+        });
+        return ary;
+      };
     },
   },
   methods: {
@@ -375,7 +379,6 @@ export default {
         arr.splice(index, 0, ...list);
         this.tableData = arr;
       }
-      this.merage();
     },
     /**
      * 选择班级
@@ -449,7 +452,11 @@ export default {
     },
     merage() {
       this.merageInit(); // 前文的初始化数据函数
-      for (let i = 0; i < this.tableData.length; i += 1) {
+      let arys = [];
+      arys = this.tableData.filter((item) => {
+        return !item.success;
+      });
+      for (let i = 0; i < arys.length; i += 1) {
         if (i === 0) {
           // 第一行必须存在
           this.typeNameArr.push(1);
@@ -464,7 +471,7 @@ export default {
           // 判断当前元素与上一个元素是否相同,eg:this.typeNamePos 是 this.typeNameArr序号
           // 第一列 下面的是eslint的不限制语法
           // eslint-disable-next-line no-lonely-if
-          if (this.tableData[i].realname === this.tableData[i - 1].realname) {
+          if (arys[i].realname === arys[i - 1].realname) {
             this.typeNameArr[this.typeNamePos] += 1;
             this.typeNameArr.push(0);
           } else {
@@ -473,8 +480,8 @@ export default {
           }
           // 第二列
           if (
-            this.tableData[i].idCard === this.tableData[i - 1].idCard &&
-            this.tableData[i].realname === this.tableData[i - 1].realname
+            arys[i].idCard === arys[i - 1].idCard &&
+            arys[i].realname === arys[i - 1].realname
           ) {
             this.storeArr[this.storePos] += 1;
             this.storeArr.push(0);
@@ -484,9 +491,9 @@ export default {
           }
           // 第三列
           if (
-            this.tableData[i].telphone === this.tableData[i - 1].telphone &&
-            this.tableData[i].idCard === this.tableData[i - 1].idCard &&
-            this.tableData[i].realname === this.tableData[i - 1].realname
+           arys[i].telphone === arys[i - 1].telphone &&
+           arys[i].idCard === arys[i - 1].idCard &&
+           arys[i].realname === arys[i - 1].realname
           ) {
             this.feeArr[this.feePos] += 1;
             this.feeArr.push(0);
@@ -496,10 +503,10 @@ export default {
           }
           // 第四列
           if (
-            this.tableData[i].telphone === this.tableData[i - 1].telphone &&
-            this.tableData[i].idCard === this.tableData[i - 1].idCard &&
-            this.tableData[i].realname === this.tableData[i - 1].realname &&
-            this.tableData[i].subjectId === this.tableData[i - 1].subjectId
+            arys[i].telphone === arys[i - 1].telphone &&
+            arys[i].idCard === arys[i - 1].idCard &&
+            arys[i].realname === arys[i - 1].realname &&
+            arys[i].subjectId === arys[i - 1].subjectId
           ) {
             this.fourArr[this.fourPos] += 1;
             this.fourArr.push(0);
@@ -568,7 +575,9 @@ export default {
               for (let i = 0; i < item.subjectIds.length; i++) {
                 for (let j = 0; j < res.rows.length; j++) {
                   if (res.rows[j].subjectId == item.subjectIds[i]) {
-                    var arys = JSON.parse(JSON.stringify(res.rows[j].goodsList));
+                    var arys = JSON.parse(
+                      JSON.stringify(res.rows[j].goodsList)
+                    );
                     let ary = arys.sort((a, b) => {
                       return a.goodsType - b.goodsType;
                     });
@@ -627,7 +636,6 @@ export default {
         }
       });
       this.tableData = arrays;
-      this.merage();
     },
     backToPage() {
       this.$alert(
@@ -827,7 +835,7 @@ export default {
       var errorList = this.tableData.filter((item) => {
         return item.checked && item.errmsg;
       });
-      console.log(this.toData,'this.toData')
+      console.log(this.toData, "this.toData");
       this.$parent.changePage2("third", successList, errorList, this.toData);
       this.disabledBtn = false;
       this.loading = false;