lsc 2 سال پیش
والد
کامیت
9b3ea69211
1فایلهای تغییر یافته به همراه80 افزوده شده و 31 حذف شده
  1. 80 31
      src/components/components/answerData2.vue

+ 80 - 31
src/components/components/answerData2.vue

@@ -132,43 +132,92 @@ export default {
       });
     },
   },
+  // watch: {
+  //   problemJson(val) {
+
+  //   },
+  // },
   watch: {
-    problemJson(val) {
-      this.ooption = {
-        xdata: [],
-        sdata: [],
-      };
-      this.person = []
-      for (var i = 0; i < this.problemJson.length; i++) {
-        this.ooption.xdata.push(i + 1);
-        this.ooption.sdata.push(0);
-      }
-      let count = 0;
-      for (var i = 0; i < this.people.length; i++) {
-        let el = this.people[i].works.split(",");
-        let count2 = 0;
-        this.person[i] = []
-        for (var j = 0; j < this.problemJson.length; j++) {
-          if (this.problemJson[j] == el[j]) {
-            this.person[i].push(this.people[i].sName)
-            this.ooption.sdata[j]++;
-            count2++;
+    people: {
+      immediate: true,
+      deep: true,
+      handler(newValue, oldValue) {
+        this.ooption = {
+          xdata: [],
+          sdata: [],
+        };
+        this.person = []
+        for (var i = 0; i < this.problemJson.length; i++) {
+          this.ooption.xdata.push(i + 1);
+          this.ooption.sdata.push(0);
+        }
+        let count = 0;
+        for (var i = 0; i < this.people.length; i++) {
+          let el = this.people[i].works.split(",");
+          let count2 = 0;
+          this.person[i] = []
+          for (var j = 0; j < this.problemJson.length; j++) {
+            if (this.problemJson[j] == el[j]) {
+              this.person[i].push(this.people[i].sName)
+              this.ooption.sdata[j]++;
+              count2++;
+            }
+          }
+          if (count2 == this.problemJson.length) {
+            count++;
           }
         }
-        if (count2 == this.problemJson.length) {
-          count++;
+        this.count = count;
+        if (!this.chartObj) {
+          this.setChart(this.ooption);
+        } else {
+          this.option.yAxis.data = this.ooption.xdata;
+          this.option.series[0].data = this.ooption.sdata;
+          this.chartObj.setOption(this.option);
         }
+        this.$forceUpdate();
       }
-      this.count = count;
-      if (!this.chartObj) {
-        this.setChart(this.ooption);
-      } else {
-        this.option.yAxis.data = this.ooption.xdata;
-        this.option.series[0].data = this.ooption.sdata;
-        this.chartObj.setOption(this.option);
-      }
-      this.$forceUpdate();
     },
+    problemJson: {
+      immediate: true,
+      deep: true,
+      handler(newValue, oldValue) {
+        this.ooption = {
+          xdata: [],
+          sdata: [],
+        };
+        this.person = []
+        for (var i = 0; i < this.problemJson.length; i++) {
+          this.ooption.xdata.push(i + 1);
+          this.ooption.sdata.push(0);
+        }
+        let count = 0;
+        for (var i = 0; i < this.people.length; i++) {
+          let el = this.people[i].works.split(",");
+          let count2 = 0;
+          this.person[i] = []
+          for (var j = 0; j < this.problemJson.length; j++) {
+            if (this.problemJson[j] == el[j]) {
+              this.person[i].push(this.people[i].sName)
+              this.ooption.sdata[j]++;
+              count2++;
+            }
+          }
+          if (count2 == this.problemJson.length) {
+            count++;
+          }
+        }
+        this.count = count;
+        if (!this.chartObj) {
+          this.setChart(this.ooption);
+        } else {
+          this.option.yAxis.data = this.ooption.xdata;
+          this.option.series[0].data = this.ooption.sdata;
+          this.chartObj.setOption(this.option);
+        }
+        this.$forceUpdate();
+      }
+    }
   },
   mounted() {
     this.ooption = {