소스 검색

提交数据初步处理

reaper 4 년 전
부모
커밋
fd759a0b01
1개의 변경된 파일116개의 추가작업 그리고 1개의 파일을 삭제
  1. 116 1
      src/components/knowledgeExtra/AddAssess/index.vue

+ 116 - 1
src/components/knowledgeExtra/AddAssess/index.vue

@@ -380,7 +380,7 @@ export default {
             textType: 11
           }
         ],
-        modifier: "string"
+        modifier: "0"
       },
       toolbars: [
         [
@@ -496,6 +496,121 @@ export default {
       //   }
       // });
       console.log("/one/", this.scaleData);
+      // 提交数据的处理 start....
+      // 1. 新建一个整体对象
+      const obj = {
+        conceptId: 0,
+        klScaleParent: [],
+        modifier: "0"
+      };
+      // 2. 遍历数据
+      this.scaleData.klScaleParent.forEach((table, tableIndex) => {
+        // 3. 将第一层数据格式顺序放进新对象(对应一个表格的数据)
+        obj.klScaleParent.push({
+          ...table,
+          klScaleSaveGroup: []
+        });
+        // 4. 建立一个新数组  用于后边赋值  obj.klScaleParent[tableIndex].klScaleSaveGroup = groupArr;
+        let groupArr = [];
+        // 5. 遍历数据 添加组、问题、以及选项。
+        table.klScaleSaveGroup.forEach((group, groupIndex) => {
+          const groupFindIndex = groupArr.findIndex(
+            (item) => item.groupNum === group.groupId
+          );
+          // 6. 查看数组中有没有同组的,如果没有同组的,直接push
+          if (groupFindIndex === -1) {
+            groupArr.push({
+              groupNum: group.groupId,
+              klScaleSub: [
+                {
+                  issueId: group.issueId,
+                  constant: group.two_constant,
+                  content: group.two_content,
+                  factor: group.two_factor,
+                  orderNo: group.two_orderNo,
+                  remark: group.two_remark,
+                  resultType: group.two_resultType,
+                  ruleCode: group.two_ruleCode,
+                  score: group.two_score,
+                  selectType: group.two_selectType,
+                  status: group.two_status,
+                  textType: group.two_textType,
+                  klScaleDetail: [
+                    {
+                      content: group.content,
+                      orderNo: group.orderNo,
+                      pushInfo: group.pushInfo,
+                      remark: group.remark,
+                      result: group.result,
+                      ruleCode: group.ruleCode,
+                      score: group.score,
+                      status: group.status,
+                      textType: group.textType
+                    }
+                  ]
+                }
+              ]
+            });
+          } else {
+            // 7. 查看数组中有没有同组的,如果有,则判断同组的是否有issueId相同的
+            const issueIdFindIndex = groupArr[
+              groupFindIndex
+            ].klScaleSub.findIndex(
+              (issItem) => issItem.issueId === group.issueId
+            );
+            if (issueIdFindIndex === -1) {
+              // 8. 如果没有相同的issueId,则在该组中添加当前项的问题
+              groupArr[groupFindIndex].klScaleSub.push({
+                issueId: group.issueId,
+                constant: group.two_constant,
+                content: group.two_content,
+                factor: group.two_factor,
+                orderNo: group.two_orderNo,
+                remark: group.two_remark,
+                resultType: group.two_resultType,
+                ruleCode: group.two_ruleCode,
+                score: group.two_score,
+                selectType: group.two_selectType,
+                status: group.two_status,
+                textType: group.two_textType,
+                klScaleDetail: [
+                  {
+                    content: group.content,
+                    orderNo: group.orderNo,
+                    pushInfo: group.pushInfo,
+                    remark: group.remark,
+                    result: group.result,
+                    ruleCode: group.ruleCode,
+                    score: group.score,
+                    status: group.status,
+                    textType: group.textType
+                  }
+                ]
+              });
+            } else {
+              // 9. 如果有相同的issueId,则在该组的该问题中,添加一个新的选项
+              groupArr[groupFindIndex].klScaleSub[
+                issueIdFindIndex
+              ].klScaleDetail.push({
+                content: group.content,
+                orderNo: group.orderNo,
+                pushInfo: group.pushInfo,
+                remark: group.remark,
+                result: group.result,
+                ruleCode: group.ruleCode,
+                score: group.score,
+                status: group.status,
+                textType: group.textType
+              });
+            }
+          }
+        });
+        // 将groupArr赋值到提交数据中
+        obj.klScaleParent[tableIndex].klScaleSaveGroup = groupArr;
+      });
+
+      console.dir(obj);
+      // 提交数据的处理 end....
     },
     /**
      * 增/删/得分结果表格