Explorar el Código

修改群体报告对比的bug--当还未录入人员的时候对比时出现NaN

plg hace 2 días
padre
commit
1d9409f192

+ 57 - 37
src/components/ComparePlanProfession.vue

@@ -1,7 +1,7 @@
 <template>
   <div style="width: 100%; display: flex; flex-direction: column">
     <div slot="title">
-      <p class="title">专业报告对比</p>
+      <p class="title">群体报告对比</p>
     </div>
     <div class="c_wrap">
       <el-form :inline="true" class="demo-form-inline">
@@ -364,9 +364,9 @@ export default {
       this.options = {
         legend: {},
         tooltip: {
-          trigger:'axis',
-          axisPointer:{
-            type:'shadow'
+          trigger: "axis",
+          axisPointer: {
+            type: "shadow",
           },
           formatter: function (params) {
             var relVal = params[0].name;
@@ -376,7 +376,7 @@ export default {
                 params[i].marker +
                 params[i].seriesName +
                 " : " +
-                params[i].value[i+1] +
+                params[i].value[i + 1] +
                 "%";
             }
             return relVal;
@@ -450,7 +450,6 @@ export default {
               position: "top",
               color: "#FE7A28",
               formatter: function (params) {
-                console.log(params);
                 return parseInt(params.data[2]) + "%";
               },
             },
@@ -512,7 +511,6 @@ export default {
     },
     //计划下---组织改变--触发的方法
     orgChangeOne(val) {
-      console.log(val);
       //设置该处选择的对象
       //设置当前选择的对象
       //获取val 为ID
@@ -609,23 +607,30 @@ export default {
         (res) => {
           let dimension = res.data;
           this[`dimensionList${i}`] = res.data;
-          this.options["dataset"]["source"][1][i] = parseInt(
-            (this[`unComplete${i}`] /
-              (this[`completeNum${i}`] + this[`unComplete${i}`])) *
-              100
-          );
-          this.options.dataset.source[2][i] = parseInt(
-            (dimension[0]["焦虑"] / this[`completeNum${i}`]) * 100
-          );
-          this.options.dataset.source[3][i] = parseInt(
-            (dimension[1]["抑郁"] / this[`completeNum${i}`]) * 100
-          );
-          this.options.dataset.source[4][i] = parseInt(
-            (dimension[2]["压力"] / this[`completeNum${i}`]) * 100
-          );
-          this.options.dataset.source[5][i] = parseInt(
-            (dimension[3]["视觉整合能力"] / this[`completeNum${i}`]) * 100
-          );
+          this.options["dataset"]["source"][1][i] =
+            this[`completeNum${i}`] + this[`unComplete${i}`] == 0
+              ? 100
+              : parseInt(
+                  (this[`unComplete${i}`] /
+                    (this[`completeNum${i}`] + this[`unComplete${i}`])) *
+                    100
+                );
+          this.options.dataset.source[2][i] =
+            this[`completeNum${i}`] == 0
+              ? 0
+              : parseInt((dimension[0]["焦虑"] / this[`completeNum${i}`]) * 100);
+          this.options.dataset.source[3][i] =
+            this[`completeNum${i}`] == 0
+              ? 0
+              : parseInt((dimension[1]["抑郁"] / this[`completeNum${i}`]) * 100);
+          this.options.dataset.source[4][i] =
+            this[`completeNum${i}`] == 0
+              ? 0
+              : parseInt((dimension[2]["压力"] / this[`completeNum${i}`]) * 100);
+          this.options.dataset.source[5][i] =
+            this[`completeNum${i}`] == 0
+              ? 0
+              : parseInt((dimension[3]["视觉整合能力"] / this[`completeNum${i}`]) * 100);
           this.isAbnormal(id, n, i);
         }
       );
@@ -637,7 +642,7 @@ export default {
       this.$http.get(url, {}, (res) => {
         if (res.code == 200) {
           this[`unHealthNum${i}`] = res.data;
-          this.options.dataset.source[6][i] = parseInt(
+          this.options.dataset.source[6][i] =this[`completeNum${i}`]==0?0: parseInt(
             (res.data / this[`completeNum${i}`]) * 100
           );
           this.getTableData();
@@ -767,6 +772,7 @@ export default {
     // 组织表格数据
     getTableData() {
       let temp = JSON.parse(JSON.stringify(this.options.dataset.source));
+
       this.compareTableDate = temp.splice(1, 6);
     },
 
@@ -775,6 +781,7 @@ export default {
       // return false
       //先判断两个是否相同
       //如果相同的话
+
       if (this.compareTableDate[i][1] == this.compareTableDate[i][2]) {
         return false;
       } else {
@@ -787,11 +794,31 @@ export default {
 
     // 未完成占比计算
     getUnCompleteRate(i) {
-      let rate = parseInt(
-        (this[`unComplete${i}`] / (this[`unComplete${i}`] + this[`completeNum${i}`])) *
-          100
-      );
-      return rate > 0 ? `${rate}%` : rate;
+      // let rate=''
+      //当总数为0时需要  设置未完成为100%
+      // if((this[`unComplete${i}`] + this[`completeNum${i}`])==0){
+      //   return 100 +'%'
+      // }else{
+      //   rate = parseInt(
+      //   (this[`unComplete${i}`] / (this[`unComplete${i}`] + this[`completeNum${i}`])) *
+      //     100
+      // );
+      // }
+      let rate =
+        this[`unComplete${i}`] + this[`completeNum${i}`] == 0
+          ? 100
+          : parseInt(
+              (this[`unComplete${i}`] /
+                (this[`unComplete${i}`] + this[`completeNum${i}`])) *
+                100
+            );
+
+      // rate = parseInt(
+      //   (this[`unComplete${i}`] / (this[`unComplete${i}`] + this[`completeNum${i}`])) *
+      //     100
+      // );
+
+      return rate > 0 ? `${rate}%` : rate + "%";
     },
 
     // 健康异常占比计算
@@ -814,13 +841,6 @@ export default {
         this[`completeNum${i}`] == 0
           ? 0
           : parseInt((tempNum / this[`completeNum${i}`]) * 100);
-      // if (rate > 0 && rate <= 50) {
-      //   rate = `<span>${rate}%</span>`
-      // } else if (rate > 50 && rate <= 75) {
-      //   rate = `<span style='color: orange'>${rate}%</span>`
-      // } else if (rate > 75) {
-      //   rate = `<span style='color: red'>${rate}%</span>`
-      // }
       return rate > 0 ? `${rate}%` : `${rate}%`;
     },
   },

+ 52 - 17
src/views/manage/channelManagement/contract.vue

@@ -223,36 +223,70 @@
               </div>
             </template>
           </el-table-column>
-          <el-table-column label="操作" width="300px" align="center">
+          <el-table-column label="操作" width="420px" align="center">
             <template slot-scope="scope">
               <div
                 style="display: flex; align-items: center; justify-content: flex-start"
               >
                 <div
                   class="detail_button_out"
-                  v-if="(userInfo.roleType=='5'&&scope.row.planStatus == '3')||(!isUser && scope.row.planStatus == '3'&&scope.row.enable=='1')"
+                  v-if="
+                    (userInfo.roleType == '5' && scope.row.planStatus == '3') ||
+                    (!isUser && scope.row.planStatus == '3' && scope.row.enable == '1')
+                  "
                 >
                   <div class="detail_button" @click="compareReport(scope.row)">
                     <img src="../../../assets/img/table/search.png" />
-                    <span>报告对比 </span>
+                    <span>群体报告对比 </span>
                   </div>
                 </div>
                 <div
                   class="detail_button_out_dis"
-                  v-if="!((userInfo.roleType=='5'&&scope.row.planStatus == '3')||(!isUser && scope.row.planStatus == '3'&&scope.row.enable=='1'))"
+                  v-if="
+                    !(
+                      (userInfo.roleType == '5' && scope.row.planStatus == '3') ||
+                      (!isUser && scope.row.planStatus == '3' && scope.row.enable == '1')
+                    )
+                  "
                 >
-                  <div
-                    class="detail_button_dis"
-                 
-                    :title="titleFormatter(scope.row)"
-                  >
+                  <div class="detail_button_dis" :title="titleFormatter(scope.row)">
                     <img src="../../../assets/img/table/search_dis.png" />
-                    <span>报告对比 </span>
+                    <span>群体报告对比 </span>
                   </div>
                 </div>
                 <div
                   class="detail_button_out"
-                  v-if="(userInfo.roleType=='5'&&scope.row.planStatus == '3')||(!isUser && scope.row.planStatus == '3'&&scope.row.enable=='1')"
+                  v-if="
+                    (userInfo.roleType == '5' && scope.row.planStatus == '3') ||
+                    (!isUser && scope.row.planStatus == '3' && scope.row.enable == '1')
+                  "
+                >
+                  <div class="detail_button" @click="compareReport(scope.row)">
+                    <img src="../../../assets/img/table/search.png" />
+                    <span>群体报告统计 </span>
+                  </div>
+                </div>
+                <div
+                  class="detail_button_out_dis"
+                  v-if="
+                    !(
+                      (userInfo.roleType == '5' && scope.row.planStatus == '3') ||
+                      (!isUser && scope.row.planStatus == '3' && scope.row.enable == '1')
+                    )
+                  "
+                >
+                  <div class="detail_button_dis" :title="titleFormatter(scope.row)">
+                    <img src="../../../assets/img/table/search_dis.png" />
+                    <span>群体报告统计 </span>
+                  </div>
+                </div>
+
+                <div
+                  class="detail_button_out"
+                  v-if="
+                    (userInfo.roleType == '5' && scope.row.planStatus == '3') ||
+                    (!isUser && scope.row.planStatus == '3' && scope.row.enable == '1')
+                  "
                 >
                   <div class="detail_button" @click="planUser(scope.row)">
                     <img src="../../../assets/img/table/search.png" />
@@ -261,13 +295,14 @@
                 </div>
                 <div
                   class="detail_button_out_dis"
-                  v-if="!((userInfo.roleType=='5'&&scope.row.planStatus == '3')||(!isUser && scope.row.planStatus == '3'&&scope.row.enable=='1'))"
+                  v-if="
+                    !(
+                      (userInfo.roleType == '5' && scope.row.planStatus == '3') ||
+                      (!isUser && scope.row.planStatus == '3' && scope.row.enable == '1')
+                    )
+                  "
                 >
-                  <div
-                    class="detail_button_dis"
-                  
-                    :title="titleFormatter(scope.row)"
-                  >
+                  <div class="detail_button_dis" :title="titleFormatter(scope.row)">
                     <img src="../../../assets/img/table/search_dis.png" />
                     <span> 个人报告对比</span>
                   </div>