Browse Source

计算bug

lrf402788946 5 years ago
parent
commit
c2e165d659
1 changed files with 16 additions and 15 deletions
  1. 16 15
      src/views/new-plan/arrange/school-arrange.vue

+ 16 - 15
src/views/new-plan/arrange/school-arrange.vue

@@ -376,17 +376,18 @@ export default {
             i.daterange = daterange;
             //改变上报时间格式
             i = this.changeRange(i);
-            arrange.map(p => {
-              let { termid, term, batchid, batch, number, carnum, _id } = p;
-              let obj = {};
-              obj[this.proAffix(batchid, 'term_batch')] = termid;
-              obj[this.proAffix(batchid, 'batch')] = batch;
-              obj[this.proAffix(batchid, 'batch_total')] = number;
-              obj[this.proAffix(batchid, 'car_total')] = carnum;
-              obj[this.proAffix(termid, 'term')] = term;
-              obj[this.proAffix(batchid, 'arrange_id')] = _id;
-              i = { ...i, ...obj };
-            });
+            if (arrange)
+              arrange.map(p => {
+                let { termid, term, batchid, batch, number, carnum, _id } = p;
+                let obj = {};
+                obj[this.proAffix(batchid, 'term_batch')] = termid;
+                obj[this.proAffix(batchid, 'batch')] = batch;
+                obj[this.proAffix(batchid, 'batch_total')] = number;
+                obj[this.proAffix(batchid, 'car_total')] = carnum;
+                obj[this.proAffix(termid, 'term')] = term;
+                obj[this.proAffix(batchid, 'arrange_id')] = _id;
+                i = { ...i, ...obj };
+              });
             i.plan = plan;
           }
           return i;
@@ -581,10 +582,10 @@ export default {
       let dl = _.cloneDeep(this.list);
       let arr = dt.map(t => {
         t.batchnum.map(b => {
-          let { batchid, remaining } = b;
-          let num = dl.reduce((prev, next) => prev + next[this.proAffix(batchid, 'batch_total')] * 1, 0);
-          let remainder = remaining - num;
-          b.remaining = remainder >= 0 ? remainder : 0;
+          let { batchid, remaining, bpt } = b;
+          let num = dl.reduce((prev, next) => prev + (next[this.proAffix(batchid, 'batch_total')] * 1 || 0), 0);
+          let remainder = bpt - num;
+          b.remaining = remainder;
           return b;
         });
         return t;