浏览代码

Merge branch 'feature_调研宝0324' of zhangs/surveyMaker into develop

wangs 5 年之前
父节点
当前提交
c1c2f60c20

+ 3 - 2
src/views/previewPage/previewPage.html

@@ -2,7 +2,7 @@
   <div @click="xxxxx" class="dowload"> 下载到本地 </div>
   <div id="pdfDom" class="pdfContent">
     <div class="pHeader">
-      <div class="projectTitle">项目答题数据</div>
+      <div class="projectTitle">{{projectName}}项目答题数据</div>
       <div class="testList"> <span v-for="(item, index) in options" :key="index">【{{item.label}}】</span></div>
       <div class="tip">截止到{{currentDate}},问卷共{{answerData.answerJoin || 0}}人参与,完成全部题目的有{{answerData.answerAll || 0}}人。
       </div>
@@ -65,7 +65,7 @@
     </div>
     <div v-if="isCrossAnalyse" class="crossAnalyse">
       <div class="crossAnalyseTable" v-for="(item, index) in crossAnalyse" :key="index">
-        <div class="crossAnalyseTitle">题目{{index+1}}:{{item.name}}</div>
+        <div class="crossAnalyseTitle">题目{{index+1}}:{{item.subName == "" ? item.name : item.subName}}</span></div>
         <div class="crossAnalyseChart">
           <HistogramHorizontals :id="'c2'" :chartId="'caaaaa'+index" :chart-data="item.data">
           </HistogramHorizontals>
@@ -85,6 +85,7 @@
             <div class="tabkeRow" style="width: 100px;">{{items.value[0]}}</div>
           </div>
         </div>
+        <div class="analyseDesc" v-if="item.desc">洞察描述:{{item.desc}}</div>
       </div>
     </div>
   </div>

+ 23 - 11
src/views/previewPage/previewPage.js

@@ -16,21 +16,33 @@ export default {
       isShowTable: null,
       isCrossAnalyse: null,
       crossAnalyse: null,
+      projectName: ""
     }
   },
   created() {
-    this.chartData = this.$route.params.chartData
-    this.currentDate = this.$route.params.currentDate
-    this.answerData = this.$route.params.answerData
-    this.options = this.$route.params.options
-    this.filterStr = this.$route.params.filterStr
-    this.isShowTable = this.$route.params.isShowTable
-    this.isCrossAnalyse = this.$route.params.isCrossAnalyse
-    this.crossAnalyse = this.$route.params.crossAnalyse
-    console.log("xXXXX", this.$route.params);
 
-    const routerParams = this.$route.query.filterStr;
-    console.log("接受的pdf的值:", routerParams);
+
+    const routerParams = window.localStorage.getItem('PreviewPagePDF')
+    let params = JSON.parse(decodeURIComponent(routerParams))
+    console.log("接受的pdf的值:", params)
+    this.chartData = params.chartData
+    this.currentDate = params.currentDate
+    this.answerData = params.answerData
+    this.options = params.options
+    this.filterStr = params.filterStr
+    this.isShowTable = params.isShowTable
+    this.isCrossAnalyse = params.isCrossAnalyse
+    this.crossAnalyse = params.crossAnalyse
+
+    var projectName = ""
+    for (let index = 0; index < this.options.length; index++) {
+      const element = this.options[index];
+      for (let j = 0; j < element.houseNameList.length; j++) {
+        const houseName = element.houseNameList[j];
+        projectName += houseName + "、"
+      }
+    }
+    this.projectName = projectName.substr(0, projectName.length - 1)
   },
   methods: {
     xxxxx() {

+ 10 - 0
src/views/previewPage/previewPage.scss

@@ -305,6 +305,7 @@
       }
     }
     .crossAnalyseTable {
+      border-bottom: 1px dashed #E8E8E8;
       .crossAnalyseTitle {
         font-size:18px;
         font-family:PingFangSC-Medium,PingFang SC;
@@ -356,6 +357,15 @@
         }
         
       }
+      .analyseDesc {
+        font-size:16px;
+        font-family:PingFangSC-Regular,PingFang SC;
+        font-weight:400;
+        color:rgba(51,51,51,1);
+        line-height:24px;
+        margin-top: 20px;
+        margin-bottom: 20px;
+      }
     }
   }
 }

+ 13 - 5
src/views/testData/testData.html

@@ -57,7 +57,7 @@
             </el-dropdown>
           </div>
           <div class="analyseBagList">
-            <el-cascader v-model="analyseValue" :options="analyseOptions"
+            <el-cascader v-if="analyseCommandSel!='全部'" v-model="analyseValue" :options="analyseOptions"
               :props="{ checkStrictly: analyseCommandSel== '区域' ? true : false }"
               @change="handleAnalyseChange(analyseValue)">
             </el-cascader>
@@ -75,10 +75,10 @@
       <div class="filter">
         <img v-if="isFilter" class="filterIcon"
           src="https://dm.static.elab-plus.com/diaoyanbao/%E5%8F%96%E6%B6%88%E7%AD%9B%E9%80%89%E6%8C%89%E9%92%AE@2x.png"
-          alt="" @click="isFilter=false">
+          alt="" @click="isShowFilter(false)">
         <img v-if="!isFilter" class="filterIcon"
           src="https://dm.static.elab-plus.com/diaoyanbao/%E7%AD%9B%E9%80%89%E6%8C%89%E9%92%AE@2x.png" alt=""
-          @click="isFilter=true">
+          @click="isShowFilter(true)">
         <div class="rightFilter">
           <div class="rightFilterItem" :class="{ rightFilterItemSel: !isShowTable}" @click="isShowTable=false">图形</div>
           <div class="rightFilterItem" :class="{ rightFilterItemSel: isShowTable}" @click="isShowTable=true">表格</div>
@@ -173,7 +173,7 @@
           <div><span class="crossFilterTitle">自变量 X</span><span
               class="crossFilterSubTitle">(一般为样本属性,例如性别,年龄等。限2题)</span></div>
           <div style="margin-top: 8px;" v-for="(items, indexs) in filterXList" :key="indexs">
-            <el-cascader v-model="optionsXValue[indexs]" :options="optionsX"
+            <el-cascader v-model="optionsXValue[indexs]" :options="optionsX" :show-all-levels="false"
               @change="handleChangeX(optionsXValue[indexs],indexs)">
             </el-cascader>
           </div>
@@ -186,7 +186,7 @@
         <div class="xyFilter" style="margin-left: 40px;">
           <div><span class="crossFilterTitle">因变量 Y</span><span class="crossFilterSubTitle">(您要分析的目标题目)</span></div>
           <div style="margin-top: 8px;" v-for="(items, indexs) in filterYList" :key="indexs">
-            <el-cascader v-model="optionsYValue[indexs]" :options="optionsY"
+            <el-cascader v-model="optionsYValue[indexs]" :options="optionsY" :show-all-levels="false"
               @change="handleChangeY(optionsYValue[indexs],indexs)">
             </el-cascader>
           </div>
@@ -203,6 +203,10 @@
       </div>
       <div class="crossAnalyseTable" v-for="(item, index) in crossAnalyse" :key="index">
         <div class="crossAnalyseTitle">题目{{index+1}}:{{item.name}}</div>
+        <div class="crossAnalyseSubTitle">
+          <el-input v-model="item.subName" v-lable="index" placeholder="点击添加图表名称">
+          </el-input>
+        </div>
         <div class="crossAnalyseChart">
           <HistogramHorizontals :id="'c2'" :chartId="'caaaaa'+index" :chart-data="item.data">
           </HistogramHorizontals>
@@ -222,6 +226,10 @@
             <div class="tabkeRow" style="width: 100px;">{{items.value[0]}}</div>
           </div>
         </div>
+        <div class="crossAnalyseDesc">
+          <el-input type="textarea" :rows="2" placeholder="点击添加洞察描述" v-model="item.desc">
+          </el-input>
+        </div>
       </div>
     </div>
   </div>

+ 87 - 44
src/views/testData/testData.js

@@ -5,6 +5,7 @@ import api from '../../api/test'
 import editorApi from '../../api/editor'
 import timeFormat from '../../util/time'
 import { format } from "util";
+import { json } from "body-parser";
 export default {
   components: {
     HeaderData, HistogramHorizontal, HistogramHorizontals
@@ -234,7 +235,7 @@ export default {
             }
             children.push({ value: question.questionId, label: question.content, disabled: disabled })
           }
-          var element = { value: item._id, label: item.title, children: children, id: item._id };
+          var element = { value: item._id, label: item.title, children: children, id: item._id, houseNameList: item.houseNameList };
           this.options.push(element);
           this.questionList.push(questionList);
         } else {
@@ -309,7 +310,7 @@ export default {
         for (var j = 0; j < questionList.length; j++) {
           if (value[1] == questionList[j].questionId) {
             if (this.oldValue.length >= index + 1) {
-              console.log("XXXXXXXXXXXXX");
+              // console.log("XXXXXXXXXXXXX");
               this.setOptionsDisabled(this.oldValue[index], false);
             }
             this.questionListSel[index] = questionList[j];
@@ -324,13 +325,20 @@ export default {
       this.questionChilds.splice(index, 1, []);
     },
     handleChangeX(value, index) {
-      console.log("handleChangeX", value, index, this.optionsXOldValue);
+      console.log("handleChangeX-0", value, index, this.optionsXOldValue);
+
       for (var i = 0; i < this.questionList.length; i++) {
-        if (value[1] == this.questionList[i].questionId) {
-          if (this.optionsXOldValue.length >= index + 1) {
-            console.log("XXXXXXXXXXXXX");
-            this.setOptionsDisabledXY(this.optionsXOldValue[index], false, 0);
-            this.setOptionsDisabledXY(this.optionsYOldValue[index], false, 1);
+        var questionList = this.questionList[i];
+        console.log("handleChangeXOld-1", questionList, value[1]);
+        for (var j = 0; j < questionList.length; j++) {
+
+          if (value[1] == questionList[j].questionId) {
+            console.log("handleChangeXOld-2", this.optionsXOldValue.length, index + 1);
+            if (this.optionsXOldValue.length >= index + 1) {
+              console.log("handleChangeXOld", this.optionsXOldValue[index]);
+              this.setOptionsDisabledXY(this.optionsXOldValue[index], false, 0);
+              this.setOptionsDisabledXY(this.optionsXOldValue[index], false, 1);
+            }
           }
         }
       }
@@ -368,23 +376,27 @@ export default {
     },
     handleAnalyseChange(value) {
       console.log(value);
+      this.getCrossAnalyse();
     },
     setOptionsDisabledXY(value, disabled, type = 0) {
+      if (value === undefined) { return }
       var newOptions = [];
-      console.log("XXXXXXX", value)
+      console.log("setOptionsDisabledXY--0", value, disabled, type);
       var options = type == 0 ? this.optionsX : this.optionsY;
       for (var i = 0; i < options.length; i++) {
         var item = options[i];
-        if (item.value == value[0]) {
-          for (var j = 0; j < options[i].children.length; j++) {
-            var children = []
-            var element = options[i].children[j];
-            if (element.value == value[1]) {
-              element.disabled = disabled
-            }
-            children.push(element)
+        // console.log("setOptionsDisabledXY--1", value, disabled, type, item);
+        // if (item.value == value[0]) {
+        for (var j = 0; j < options[i].children.length; j++) {
+          var children = []
+          var element = options[i].children[j];
+          // console.log("setOptionsDisabledXY--2", value, disabled, type, item, element.value, value[1]);
+          if (element.value == value[1]) {
+            element.disabled = disabled
           }
+          children.push(element)
         }
+        // }
         newOptions.push(item)
       }
       if (type == 0) {
@@ -396,19 +408,22 @@ export default {
     },
     setOptionsDisabled(value, disabled) {
       var newOptions = [];
-      console.log("XXXXXXX", value)
+      // console.log("setOptionsDisabled--0", value, disabled);
       for (var i = 0; i < this.options.length; i++) {
         var item = this.options[i];
-        if (item.value == value[0]) {
-          for (var j = 0; j < this.options[i].children.length; j++) {
-            var children = []
-            var element = this.options[i].children[j];
-            if (element.value == value[1]) {
-              element.disabled = disabled
-            }
-            children.push(element)
+        // console.log("setOptionsDisabledXY--1", value, disabled, item);
+        // if (item.value == value[0]) {
+        for (var j = 0; j < this.options[i].children.length; j++) {
+          var children = []
+          var element = this.options[i].children[j];
+          // console.log("setOptionsDisabledXY--2", value, disabled, item, element.value, value[1]);
+          if (element.value == value[1]) {
+            element.disabled = disabled
           }
+          children.push(element)
         }
+        // }
+        // console.log("XXXXXXX", item);
         newOptions.push(item)
       }
       this.options = newOptions;
@@ -429,6 +444,25 @@ export default {
       this.questionChilds.splice(index, 1);
       this.checkList.splice(index, 1);
     },
+    isShowFilter(isShow) {
+      console.log("XXXXX", isShow)
+      this.isFilter = isShow
+      if (!isShow) {
+        for (let index = 0; index < this.value.length; index++) {
+          if (this.value[index]) {
+            this.setOptionsDisabled(this.value[index], false);
+          }
+        }
+
+        this.filterList = [""];
+        this.value = [];
+        this.questionListSel = [];
+        this.questionChilds = [];
+        this.checkList = [];
+
+        this.getAnswerData()
+      }
+    },
     projectCommand(command) {
       if (this.houseList.indexOf(command) == -1) {
         console.log("不存在");
@@ -443,6 +477,7 @@ export default {
       console.log("XXXXXXX", command)
       if (command == -1) {
         this.analyseCommandSel = "全部";
+        this.getCrossAnalyse();
       } else if (command == 0) {
         this.analyseCommandSel = "数据包";
       } else {
@@ -591,6 +626,7 @@ export default {
           api.saveAnalyseBag(param).then(res => {
             if (res.success) {
               this.$message.success("保存成功");
+              this.getCondition();
             } else {
               this.$message.error("数据加载失败,请重试");
             }
@@ -630,13 +666,19 @@ export default {
           for (var m = 0; m < this.optionsXValue.length; m++) {
             var element = this.optionsXValue[m];
             if (item[j].questionId == element[1]) {
-              xlist.push(item[j]);
+              const found = xlist.find(element => element.questionId == item[j].questionId);
+              if (found === undefined) {
+                xlist.push(item[j]);
+              }
             }
           }
           for (var n = 0; n < this.optionsYValue.length; n++) {
             var element = this.optionsYValue[n];
             if (item[j].questionId == element[1]) {
-              ylist.push(item[j]);
+              const found = ylist.find(element => element.questionId == item[j].questionId);
+              if (found === undefined) {
+                ylist.push(item[j]);
+              }
             }
           }
         }
@@ -680,7 +722,7 @@ export default {
             for (var q = 0; q < qqq.length; q++) {
               sss.push({ name: rowArr[q], title: qqq[q].name, value: qqq[q].value })
             }
-            this.crossAnalyse.push({ table: sss, data: [], question: null, name: null });
+            this.crossAnalyse.push({ table: sss, data: [], question: null, name: null, subName: "", desc: "" });
           }
           // console.log("SSSSS", this.crossAnalyse);
 
@@ -724,22 +766,23 @@ export default {
       });
     },
     goToPreviewPage() {
-
-      this.$router.push({
-        name: 'previewPage',
-        params: {
-          chartData: this.chartData,
-          answerData: this.answerData,
-          currentDate: this.currentDate,
-          options: this.options,
-          filterStr: this.filterStr,
-          isShowTable: this.isShowTable,
-          isCrossAnalyse: this.isCrossAnalyse,
-          crossAnalyse: this.crossAnalyse
-        }
+      let params = {
+        chartData: this.chartData,
+        answerData: this.answerData,
+        currentDate: this.currentDate,
+        options: this.options,
+        filterStr: this.filterStr,
+        isShowTable: this.isShowTable,
+        isCrossAnalyse: this.isCrossAnalyse,
+        crossAnalyse: this.crossAnalyse
+      }
+      let ed = encodeURIComponent(JSON.stringify(params))
+      window.localStorage.setItem('PreviewPagePDF', ed)
+      const { href } = this.$router.resolve({
+        path: '/previewPage',
       })
-    }
-
+      window.open(href, '_blank')
 
+    }
   },
 }

+ 33 - 0
src/views/testData/testData.scss

@@ -574,6 +574,39 @@
         line-height:25px;
         margin-top: 32px;
       }
+      .crossAnalyseSubTitle {
+        margin: 8px 0px;
+        .el-input {
+          width:244px;
+          height:30px;
+          .el-input__inner {
+            height: 30px;
+            line-height: 30px;
+            font-size:14px;
+            font-family:PingFangSC-Regular,PingFang SC;
+            font-weight:400;
+            color:rgba(100,107,129,1);
+            line-height:20px;
+            background:rgba(241,241,241,1);
+            border:1px solid rgba(227,227,227,1);
+          }
+        }
+      }
+      .crossAnalyseDesc {
+        margin: 8px 0px;
+        .el-textarea {
+          width:100%;
+          .el-textarea__inner {
+            font-size:14px;
+            font-family:PingFangSC-Regular,PingFang SC;
+            font-weight:400;
+            color:rgba(100,107,129,1);
+            line-height:20px;
+            background:rgba(241,241,241,1);
+            border:1px solid rgba(227,227,227,1);
+          }
+        }
+      }
       .crossAnalyseChart {
         width: 100%;
         margin: 8px 0px;