Browse Source

决策大屏更改月份截止本期数据统计方法

ellisran 1 year ago
parent
commit
5384924c79
1 changed files with 49 additions and 0 deletions
  1. 49 0
      app/view/datacollect/index4GY18Y.ejs

+ 49 - 0
app/view/datacollect/index4GY18Y.ejs

@@ -921,8 +921,11 @@
                             yearmonth: s.yearmonth,
                             ys_tp: s.end_yf_tp,
                             yf_tp: 0,
+                            had_ys: true,
+                            had_yf: false,
                         });
                     } else {
+                        yingsf_option_data[index].had_ys = true;
                         yingsf_option_data[index].ys_tp = ZhCalc.add(yingsf_option_data[index].ys_tp, s.end_yf_tp);
                     }
                     if (yiIndex === -1) {
@@ -930,8 +933,11 @@
                             yearmonth: s.yearmonth,
                             ys_tp: s.end_sf_tp,
                             yf_tp: 0,
+                            had_ys: true,
+                            had_yf: false,
                         });
                     } else {
+                        yisf_option_data[yiIndex].had_ys = true;
                         yisf_option_data[yiIndex].ys_tp = ZhCalc.add(yisf_option_data[yiIndex].ys_tp, s.end_sf_tp);
                     }
                 }
@@ -987,8 +993,11 @@
                             yearmonth: s.yearmonth,
                             ys_tp: 0,
                             yf_tp: s.end_yf_tp,
+                            had_ys: false,
+                            had_yf: true,
                         });
                     } else {
+                        yingsf_option_data[index].had_yf = true;
                         yingsf_option_data[index].yf_tp = ZhCalc.add(yingsf_option_data[index].yf_tp, s.end_yf_tp);
                     }
                     if (yiIndex === -1) {
@@ -996,8 +1005,11 @@
                             yearmonth: s.yearmonth,
                             ys_tp: 0,
                             yf_tp: s.end_sf_tp,
+                            had_ys: false,
+                            had_yf: true,
                         });
                     } else {
+                        yisf_option_data[index].had_yf = true;
                         yisf_option_data[yiIndex].yf_tp = ZhCalc.add(yisf_option_data[yiIndex].yf_tp, s.end_sf_tp);
                     }
                 }
@@ -1025,7 +1037,25 @@
                 const new_yingsf_option_data = _.sortBy(yingsf_option_data, 'yearmonth');
                 for (const c4 of new_yingsf_option_data) {
                     show_yingsf_option_data.yearmonth.push(c4.yearmonth);
+                    if (!c4.had_ys) {
+                        const hadYsDatas = _.filter(new_yingsf_option_data, function (item) {
+                            return item.had_ys && item.yearmonth < c4.yearmonth;
+                        });
+                        // 找出最近的一个had_ys为true值
+                        if (hadYsDatas.length > 0) {
+                            c4.ys_tp = hadYsDatas[hadYsDatas.length - 1].ys_tp;
+                        }
+                    }
                     show_yingsf_option_data.ys_tp.push(c4.ys_tp);
+                    if (!c4.had_yf) {
+                        const hadYfDatas = _.filter(new_yingsf_option_data, function (item) {
+                            return item.had_yf && item.yearmonth < c4.yearmonth;
+                        });
+                        // 找出最近的一个had_yf为true值
+                        if (hadYfDatas.length > 0) {
+                            c4.yf_tp = hadYfDatas[hadYfDatas.length - 1].yf_tp;
+                        }
+                    }
                     show_yingsf_option_data.yf_tp.push(c4.yf_tp);
                 }
             }
@@ -1050,10 +1080,29 @@
                 const new_yisf_option_data = _.sortBy(yisf_option_data, 'yearmonth');
                 for (const c4 of new_yisf_option_data) {
                     show_yisf_option_data.yearmonth.push(c4.yearmonth);
+                    if (!c4.had_ys) {
+                        const hadYsDatas = _.filter(new_yisf_option_data, function (item) {
+                            return item.had_ys && item.yearmonth < c4.yearmonth;
+                        });
+                        // 找出最近的一个had_ys为true值
+                        if (hadYsDatas.length > 0) {
+                            c4.ys_tp = hadYsDatas[hadYsDatas.length - 1].ys_tp;
+                        }
+                    }
                     show_yisf_option_data.ys_tp.push(c4.ys_tp);
+                    if (!c4.had_yf) {
+                        const hadYfDatas = _.filter(new_yisf_option_data, function (item) {
+                            return item.had_yf && item.yearmonth < c4.yearmonth;
+                        });
+                        // 找出最近的一个had_yf为true值
+                        if (hadYfDatas.length > 0) {
+                            c4.yf_tp = hadYfDatas[hadYfDatas.length - 1].yf_tp;
+                        }
+                    }
                     show_yisf_option_data.yf_tp.push(c4.yf_tp);
                 }
             }
+            console.log(yingsf_option_data, yisf_option_data);
             const yisf_option = yisfChart.getOption();
             yisf_option.dataZoom[0].start = 0;
             yisf_option.dataZoom[0].end = computedPosition(show_yisf_option_data.yearmonth.length);