Browse Source

修改时的数据处理

reaper 4 years ago
parent
commit
45c6227194

+ 131 - 5
src/components/knowledgeExtra/AddAssess/index.vue

@@ -349,6 +349,11 @@ const defaultTable = {
 };
 export default {
   components: { ScaleTable, quillEditor, ScoreResultsTable },
+  props: {
+    childScaleData: {
+      default: null
+    }
+  },
   data() {
     return {
       rules: rules,
@@ -515,6 +520,8 @@ export default {
       console.dir(this.formtParams());
     },
     formtParams() {
+      console.log('this.scaleData.klScaleParent');
+      console.dir(this.scaleData.klScaleParent);
       // 提交数据的处理 start....
       // 1. 新建一个整体对象
       const params = {
@@ -534,13 +541,15 @@ export default {
           let groupArr = [];
           // 5. 遍历数据 添加组、问题、以及选项。
           table.klScaleSaveGroup.forEach((group, groupIndex) => {
-            const groupFindIndex = groupArr.findIndex(
-              (item) => item.groupNum === group.groupId
-            );
+            const groupFindIndex = groupArr.findIndex((item) => {
+              console.log(item.groupNum, group.groupId);
+              return item.groupNum === group.groupId;
+            });
+            console.log('groupFindIndex',groupFindIndex);
             // 6. 查看数组中有没有同组的,如果没有同组的,直接push
             if (groupFindIndex === -1) {
               groupArr.push({
-                groupNum: 0,
+                groupNum: group.groupId,
                 klScaleSub: [
                   {
                     issueId: group.issueId,
@@ -947,6 +956,122 @@ export default {
         console.log("监听");
       },
       deep: true
+    },
+    childScaleData() {
+      console.log("child Mounted");
+      console.dir(this.childScaleData);
+      if (this.childScaleData) {
+        // 修改时的默认数据赋值 逻辑:遍历接口数据 赋值给结构体数据
+        let obj = {
+          ...this.data,
+          klScaleParent: []
+        };
+        delete obj.klScaleDetail;
+        let scoreresults = {
+          scoreresultsdatas: []
+        };
+
+        this.childScaleData.klScaleDetail.forEach((table, tableIndex) => {
+          if (table.textType === 13) {
+            // 计算结果
+            scoreresults.scoreresultsdatas = table.subMenuList[0].subMenuList;
+            scoreresults.scoreresultsdatas.forEach((item) => {
+              item.content = JSON.parse(item.content);
+            });
+          } else if (table.textType === 11) {
+            // 选项
+            obj.klScaleParent.push({
+              constant: table.constant,
+              content: table.content,
+              factor: table.factor,
+              orderNo: table.orderNo,
+              remark: table.remark,
+              resultType: table.resultType,
+              ruleCode: table.ruleCode,
+              score: table.score,
+              status: table.status,
+              textType: table.textType,
+              klScaleSaveGroup: []
+            });
+
+            table.subMenuList.forEach((issueItem, issueIndex) => {
+              const arr = issueItem.subMenuList.map(
+                (optionItem, optionIndex) => {
+                  return {
+                    groupId: issueItem.groupNum,
+                    issueId: optionItem.parentId,
+                    two_constant: issueItem.constant,
+                    two_content: issueItem.content,
+                    two_factor: issueItem.factor,
+                    two_orderNo: issueItem.orderNo,
+                    two_remark: issueItem.remark,
+                    two_resultType: issueItem.resultType,
+                    two_ruleCode: issueItem.ruleCode,
+                    two_score: issueItem.score,
+                    two_selectType: issueItem.selectType,
+                    two_status: issueItem.status,
+                    two_textType: issueItem.textType,
+                    content: optionItem.content,
+                    orderNo: optionItem.orderNo,
+                    pushInfo: optionItem.pushInfo,
+                    remark: optionItem.remark,
+                    result: optionItem.result,
+                    ruleCode: optionItem.ruleCode,
+                    score: optionItem.score,
+                    status: optionItem.status,
+                    textType: optionItem.textType
+                  };
+                }
+              );
+              obj.klScaleParent[tableIndex].klScaleSaveGroup.push(...arr);
+            });
+          } else if (table.textType === 12) {
+            // 文本
+            obj.klScaleParent.push({
+              constant: table.constant,
+              content: table.content,
+              factor: table.factor,
+              orderNo: table.orderNo,
+              remark: table.remark,
+              resultType: table.resultType,
+              ruleCode: table.ruleCode,
+              score: table.score,
+              status: table.status,
+              textType: table.textType,
+              klScaleSaveGroup: [
+                {
+                  two_constant: null,
+                  two_content: null,
+                  two_factor: null,
+                  two_orderNo: null,
+                  two_remark: null,
+                  two_resultType: null,
+                  two_ruleCode: null,
+                  two_score: null,
+                  two_selectType: null,
+                  two_status: null,
+                  two_textType: null,
+                  content: table.subMenuList[0].content,
+                  orderNo: table.subMenuList[0].groupNum,
+                  pushInfo: table.subMenuList[0].pushInfo,
+                  remark: table.subMenuList[0].remark,
+                  result: table.subMenuList[0].result,
+                  ruleCode: table.subMenuList[0].ruleCode,
+                  score: table.subMenuList[0].score,
+                  status: table.subMenuList[0].status,
+                  textType: table.subMenuList[0].textType
+                }
+              ]
+            });
+          }
+        });
+        console.log("??????????");
+        console.dir(obj);
+        console.dir(scoreresults);
+
+        this.scaleData = obj;
+        this.scoreresults = scoreresults;
+      }
     }
   },
   computed: {
@@ -964,6 +1089,7 @@ export default {
   created() {
     this.editorOption.modules.toolbar.container =
       this.toolbars[this.toolbarMode];
-  }
+  },
+  mounted() {}
 };
 </script>

+ 1 - 0
src/components/knowledgeExtra/AddAssess/scale-table.vue

@@ -593,6 +593,7 @@ export default {
   watch: {
     tableData: {
       handler() {
+        console.log('哈哈哈哈',this.tableData);
         this.getSpanArr(this.tableData);
       },
       deep: true

+ 13 - 4
src/components/knowledgeExtra/AddDevKnow.vue

@@ -138,8 +138,8 @@
             </el-form>
           </div>
         </el-tab-pane>
-        <el-tab-pane label="评估内容" name="two">
-          <AddAssess ref="assessRef" />
+        <el-tab-pane v-if="AssesComSHow" label="评估内容" name="two">
+          <AddAssess :childScaleData="scaleData" ref="assessRef" />
         </el-tab-pane>
       </el-tabs>
       <div class="btn">
@@ -169,7 +169,9 @@ export default {
   },
   data() {
     return {
+      AssesComSHow: false,
       toAssesTermId: null,
+      scaleData: null,
       isFixedTop: true,
       isEdit: false,
       isCopy: false,
@@ -250,7 +252,7 @@ export default {
       editCount: -1, // 页面会否被编辑 >0被编辑   =0 未编辑
       startCount: -1,
       isSaveSuccess: false, // 是否保存成功
-      tabActive: "two"
+      tabActive: "one"
     };
   },
   watch: {
@@ -290,6 +292,8 @@ export default {
         .then((res) => {
           if (res.data.code == "0") {
             const data = res.data.data;
+            console.log("datadata", data);
+            this.scaleData = data.scale;
             if (this.form.typeId === 82 || this.form.typeId === 83) {
               // console.log('data',data)
               this.form.fileList =
@@ -409,6 +413,11 @@ export default {
     changeWord(newVal) {
       // console.log(newVal, '选中');
       console.log("newVal", newVal);
+      if (newVal.typeName == "量表") {
+        this.AssesComSHow = true;
+      } else {
+        this.AssesComSHow = false;
+      }
       this.toAssesTermId = newVal.id;
       this.showType = newVal.type || -1;
       const name = newVal.name;
@@ -704,7 +713,7 @@ export default {
       const assessParam = this.$refs.assessRef.formtParams();
       param.scale = assessParam;
       param.scale.conceptId = this.toAssesTermId;
-      param.scale.modifier = '';  //fix lei 字段暂时未知
+      param.scale.modifier = ""; //fix lei 字段暂时未知
       console.log("param-------");
       console.dir(param);
       if (!this.isEdit) {