ソースを参照

feat: 考核连调结束

haifeng.zhang 3 週間 前
コミット
f514552c37

+ 64 - 4
src/utils/business.ts

@@ -60,7 +60,67 @@ export const formulaParamsChange = (addmanyChange: any = {}) => {
 };
 
 // 公式设置-多条件公式,转换数据结构,从接口返回数据后回显
-// export const echoParamsChange = (echoChange: any = {}) => {
-//   const obj = {}
-//   // echoChange.
-// }
+const removeParentheses = (str = "") => {
+  let newStr = str || "";
+  if (str) {
+    if (str.indexOf("(") > -1) {
+      newStr = newStr.replace("(", "");
+    }
+    if (str.indexOf(")") > -1) {
+      newStr = newStr.replace(")", "");
+    }
+  }
+  return newStr;
+};
+export const echoParamsChange = (echoChange: any = []) => {
+  const obj = {
+    outerConditionValue: "",
+    outerConditionValueExpress: "",
+    innerConditionExpression: []
+  };
+  if (echoChange.length) {
+    obj.outerConditionValue = removeParentheses(
+      echoChange[0].conditionalValues
+    );
+    echoChange.forEach(item => {
+      const iObj: any = {
+        startValue: removeParentheses(item.currentFormulaOne),
+        endValue: removeParentheses(item.currentFormulaThree),
+        select: item.currentFormulaType,
+        comparisonStart: item.operatorOne,
+        comparisonEnd: item.operatorTwo,
+        innerScore: item.score || ""
+      };
+      const voObj = {
+        innerConditionValue: "",
+        innerConditionValueExpress: null,
+        scoreRules: []
+      };
+      if (item.nextFormatParams && item.nextFormatParams.length) {
+        voObj.innerConditionValue = removeParentheses(
+          item.nextFormatParams[0].conditionalValues
+        );
+        let scoreRules = [];
+        item.nextFormatParams.forEach(el => {
+          scoreRules.push({
+            score: el.score,
+            scoreExpress: null,
+            select: el.currentFormulaType,
+            startValue: removeParentheses(el.currentFormulaOne),
+            endValue: removeParentheses(el.currentFormulaThree),
+            comparisonStart: el.operatorOne,
+            comparisonEnd: el.operatorTwo,
+            startExpress: null,
+            endExpress: null
+          });
+        });
+        voObj.scoreRules = scoreRules;
+        iObj.scoreRuleMoreInnerVO = [voObj];
+      } else {
+        iObj.scoreRuleMoreInnerVO = [];
+      }
+      obj.innerConditionExpression.push(iObj);
+    });
+  }
+  return obj;
+};

+ 4 - 4
src/views/evaluate/children/change/mould/editIndex.vue

@@ -13,7 +13,7 @@ import {
 import { conditionVerify } from "@/api/formula";
 import jishuanqi from "@/views/evaluate/children/change/components/jishuanqi.vue";
 import manyFormula from "@/components/formula/manyFormula.vue";
-import { formulaParamsChange } from "@/utils/business";
+import { formulaParamsChange, echoParamsChange } from "@/utils/business";
 const emit = defineEmits(["updateDialog", "getAssessmentQuotaDetailsApi"]);
 const formRef = ref();
 const drawer = ref(false);
@@ -46,13 +46,13 @@ const formLabelAlign = reactive({
 const open = row => {
   console.log(row, "------");
   Object.assign(formLabelAlign, JSON.parse(JSON.stringify(row)));
-  let dataJSon = "";
+  let dataJSon = null;
   if (row.formulaType === 0) {
     dataJSon = row.formula;
   } else if (row.formulaType === 1) {
-    dataJSon = row.formulaParamsList;
+    dataJSon = echoParamsChange(row.formulaParamsList);
   }
-  formulaOne.value = dataJSon;
+  formulaOne.value = dataJSon || "";
   drawer.value = true;
   showData.value = true;
 };