Browse Source

第一层bug

laiguoran 3 years ago
parent
commit
ffea884875
1 changed files with 13 additions and 3 deletions
  1. 13 3
      app/view/datacollect/index.ejs

+ 13 - 3
app/view/datacollect/index.ejs

@@ -1232,10 +1232,19 @@
                 } else {
                     for (const cc1 of chart_category_data.data1) {
                         const sameObject = _.intersectionWith(t.category, cc1, _.isEqual);
-                        const index = sameObject[0] ? _.findIndex(cc1, { cid: sameObject[0].cid, value: sameObject[0].value }) : -1;
-                        if (index !== -1) {
-                            chart_option5_data.data1[index].value = ZhCalc.add(chart_option5_data.data1[index].value, (t.total_price ? t.total_price : 0));
+                        if(sameObject.length === 1) {
+                            const index = _.findIndex(chart_category_data.data1, function (item) {
+                                return _.isEqual(item, sameObject);
+                            });
+                            if (index !== -1) {
+                                chart_option5_data.data1[index].value = ZhCalc.add(chart_option5_data.data1[index].value, (t.total_price ? t.total_price : 0));
+                            }
                         }
+                        // const index = sameObject[0] ? _.findIndex(cc1, { cid: sameObject[0].cid, value: sameObject[0].value }) : -1;
+                        // console.log(cc1, chart_category_data.data1, index);
+                        // if (index !== -1) {
+                        //     chart_option5_data.data1[index].value = ZhCalc.add(chart_option5_data.data1[index].value, (t.total_price ? t.total_price : 0));
+                        // }
                     }
                     for (const cc2 of chart_category_data.data2) {
                         const sameObject = _.intersectionWith(t.category, cc2, _.isEqual);
@@ -1262,6 +1271,7 @@
                 }
             }
             const option5 = myChart5.getOption();
+            console.log(chart_option5_data);
             option5.series[0].data = _.filter(chart_option5_data.data1, function (item) {
                 return item.value !== 0;
             });