ZaiZai před 10 měsíci
rodič
revize
43180fde3a
1 změnil soubory, kde provedl 46 přidání a 7 odebrání
  1. 46 7
      src/views/project/list/edit-formula.vue

+ 46 - 7
src/views/project/list/edit-formula.vue

@@ -321,8 +321,8 @@
 import { nextTick, ref, watch } from 'vue'
 import { useClick } from 'hc-vue3-ui'
 import {
-    arrIndex, deepClone, getArrValue,
-    getObjValue, getRandom, isNullES,
+    arrIndex, deepClone, getArrValue, getObjValue,
+    getRandom, isArray, isNullES, isString,
 } from 'js-fast-way'
 import { ElMessageBox } from 'element-plus'
 import { VueTagsInput } from '@vojtechlanka/vue-tags-input'
@@ -376,10 +376,10 @@ const isScrollBar = ref(true)
 //获取数据
 const getDataApi = async () => {
     console.log(dataInfo.value)
-    getTypeMapApi().then()
-    getWbsFormElementData().then()
+    await getTypeMapApi()
+    await getWbsFormElementData()
+    await getFormulaStringToArrayApi()
     getProjectDataApi().then()
-    getFormulaStringToArrayApi().then()
 }
 
 //保留位数
@@ -389,10 +389,11 @@ const retainNum = ref(2)
 //把公式文本还原数组
 const rightDict = ref([])
 const formulaId = ref('')
+const deviationRangeObj = ref({})
 const getFormulaStringToArrayApi = async () => {
     const { eleId, globalType, nodeId, pid } = getObjValue(dataInfo.value)
     const { code, data } = await formulaApi.detail({
-        projectId: projectId.value || pid,
+        projectId: pid,
         elementId: eleId,
         nodeId: nodeId,
         scope: globalType,
@@ -411,8 +412,24 @@ const getFormulaStringToArrayApi = async () => {
         formulaId.value = res.id
         //把公式字符串还原成数组
         let formula = formulaStringToArray(res.formula, res.map, formulaMenuMap.value)
-        console.log('formula', formula)
         processFormula.value = getArrValue(formula?.processFormula)
+        const results = resultFormula.value
+        formula.resultFormula[0].id = results[0].id
+        formula.resultFormula[0].name = results[0].name
+        formula.resultFormula[0].tableElementKey = results[0].tableElementKey
+        resultFormula.value[0].children = formula.resultFormula[0].children
+        //允许偏差值范围
+        let mapObj = JSON.parse(res.map)
+        if (mapObj.deviationRangeJson) {
+            deviationRangeObj.value = JSON.parse(mapObj.deviationRangeJson)
+        }
+    }
+    if (res.scale >= 0) {
+        isRetain.value = true
+        retainNum.value = res.scale
+    } else {
+        isRetain.value = false
+        retainNum.value = 2
     }
 }
 
@@ -426,7 +443,29 @@ const setDeviationRange = () => {
     const val = !deviationRangeShow.value
     deviationRangeShow.value = val
     if (val) {
+        const { symbol, model, arguments1, arguments2 } = deviationRangeObj.value
+        deviationRangeSymbol.value = symbol
+        deviationRangeResult.value = model
         curRangeFocusIndex.value = 1
+        //公式
+        if (isArray(arguments1) && arguments1.length > 1 || isArray(arguments2) && arguments2.length > 1) {
+            //selectEleFormula.value = arguments1
+            selectEleFormula3.value = arguments1
+            selectEleFormula4.value = arguments2
+            return
+        }
+        //参数1
+        if (isString(arguments1)) {
+            deviationRangeTag1.value = arguments1
+        } else {
+            deviationRangeTags1.value = arguments1
+        }
+        //参数2
+        if (isString(arguments2)) {
+            deviationRangeTag2.value = arguments2
+        } else {
+            deviationRangeTags2.value = arguments2
+        }
     } else {
         curRangeFocusIndex.value = 0
     }