|
@@ -39,11 +39,11 @@
|
|
</div>
|
|
</div>
|
|
<div class="body relative">
|
|
<div class="body relative">
|
|
<template v-for="(item, index) in resultFormula" :key="index">
|
|
<template v-for="(item, index) in resultFormula" :key="index">
|
|
- <span class="element-class text-26px" :class="item.selected ? 'is-cur' : ''" @click="resultFormulaItem(item)">{{ item.name }}</span>
|
|
|
|
|
|
+ <span class="element-class text-26px" :class="item.selected ? 'is-cur' : ''" @click="resultFormulaItem(item, index)">{{ item.name }}</span>
|
|
</template>
|
|
</template>
|
|
<span class="ml-10px mr-10px text-26px">=</span>
|
|
<span class="ml-10px mr-10px text-26px">=</span>
|
|
<template v-for="(item, index) in processFormula" :key="index">
|
|
<template v-for="(item, index) in processFormula" :key="index">
|
|
- <span class="element-class text-26px" :class="item.selected ? 'is-cur' : ''" @click="processFormulaItem(item)">{{ item.name }}</span>
|
|
|
|
|
|
+ <span class="element-class text-26px" :class="item.selected ? 'is-cur' : ''" @click="processFormulaItem(item, index)">{{ item.name }}</span>
|
|
</template>
|
|
</template>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@@ -548,22 +548,38 @@ const getWbsFormElementData = async () => {
|
|
}]
|
|
}]
|
|
}
|
|
}
|
|
|
|
|
|
-//被点击
|
|
|
|
-const resultFormulaItem = (item) => {
|
|
|
|
|
|
+//左边被点击
|
|
|
|
+const processIndex = ref(-1)
|
|
|
|
+const processType = ref('')
|
|
|
|
+const resultFormulaItem = (item, index) => {
|
|
|
|
+ //清除左边的选中
|
|
|
|
+ resultFormula.value.forEach((obj) => {
|
|
|
|
+ obj.selected = false
|
|
|
|
+ })
|
|
//清除右边的选中
|
|
//清除右边的选中
|
|
processFormula.value.forEach((obj) => {
|
|
processFormula.value.forEach((obj) => {
|
|
obj.selected = false
|
|
obj.selected = false
|
|
})
|
|
})
|
|
- //遍历左边的选中
|
|
|
|
- const arr = resultFormula.value
|
|
|
|
- for (let i = 0; i < arr.length; i++) {
|
|
|
|
- if (item.index === arr[i].index) {
|
|
|
|
- arr[i].selected = !arr[i].selected
|
|
|
|
- } else {
|
|
|
|
- arr[i].selected = false
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- resultFormula.value = arr
|
|
|
|
|
|
+ //设置当前选中
|
|
|
|
+ processIndex.value = index
|
|
|
|
+ processType.value = 'resultFormula'
|
|
|
|
+ item.selected = true
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//右边被点击
|
|
|
|
+const processFormulaItem = (item, index) => {
|
|
|
|
+ //清除左边的选中
|
|
|
|
+ resultFormula.value.forEach((obj) => {
|
|
|
|
+ obj.selected = false
|
|
|
|
+ })
|
|
|
|
+ //清除右边的选中
|
|
|
|
+ processFormula.value.forEach((obj) => {
|
|
|
|
+ obj.selected = false
|
|
|
|
+ })
|
|
|
|
+ //设置当前选中
|
|
|
|
+ processIndex.value = index
|
|
|
|
+ processType.value = 'processFormula'
|
|
|
|
+ item.selected = true
|
|
}
|
|
}
|
|
|
|
|
|
//是否重置函数
|
|
//是否重置函数
|
|
@@ -1049,24 +1065,6 @@ const setProcessFormula = () => {
|
|
isScrollBar.value = true
|
|
isScrollBar.value = true
|
|
}
|
|
}
|
|
|
|
|
|
-//右边被点击
|
|
|
|
-const processFormulaItem = (item) => {
|
|
|
|
- //清除左边边的选中
|
|
|
|
- resultFormula.value.forEach((obj) => {
|
|
|
|
- obj.selected = false
|
|
|
|
- })
|
|
|
|
- //遍历右边的选中
|
|
|
|
- const arr = processFormula.value
|
|
|
|
- for (let i = 0; i < arr.length; i++) {
|
|
|
|
- if (item.index === arr[i].index) {
|
|
|
|
- arr[i].selected = !arr[i].selected
|
|
|
|
- } else {
|
|
|
|
- arr[i].selected = false
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- processFormula.value = arr
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
//获取项目数据
|
|
//获取项目数据
|
|
const projectId = ref('')
|
|
const projectId = ref('')
|
|
const projectList = ref([])
|
|
const projectList = ref([])
|
|
@@ -1191,6 +1189,15 @@ const handWritEleClose = () => {
|
|
handWritEleMap.value = {}
|
|
handWritEleMap.value = {}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+const findNumber = (array) => {
|
|
|
|
+ for (const item of array) {
|
|
|
|
+ if (!item.children) continue
|
|
|
|
+ const child = item.children.find(child => child.number)
|
|
|
|
+ if (child) return child.number
|
|
|
|
+ }
|
|
|
|
+ return ''
|
|
|
|
+}
|
|
|
|
+
|
|
//保存
|
|
//保存
|
|
const submitLoading = ref(false)
|
|
const submitLoading = ref(false)
|
|
const submitClick = async () => {
|
|
const submitClick = async () => {
|
|
@@ -1199,6 +1206,7 @@ const submitClick = async () => {
|
|
setProcessFormula()
|
|
setProcessFormula()
|
|
} else {
|
|
} else {
|
|
//允许偏差值范围
|
|
//允许偏差值范围
|
|
|
|
+ submitLoading.value = true
|
|
const result = deviationRangeResult.value
|
|
const result = deviationRangeResult.value
|
|
deviationRangeObj.value = {
|
|
deviationRangeObj.value = {
|
|
symbol: deviationRangeSymbol.value,
|
|
symbol: deviationRangeSymbol.value,
|
|
@@ -1212,68 +1220,44 @@ const submitClick = async () => {
|
|
let deviationRangeText = rangeToString(deviationRangeObj.value, obj.eleMap)
|
|
let deviationRangeText = rangeToString(deviationRangeObj.value, obj.eleMap)
|
|
obj.eleMap.deviationRangeJson = JSON.stringify(deviationRangeObj.value)
|
|
obj.eleMap.deviationRangeJson = JSON.stringify(deviationRangeObj.value)
|
|
//特殊公式会有number
|
|
//特殊公式会有number
|
|
- let number = ''
|
|
|
|
- for (let i = 0; i < process.length; i++) {
|
|
|
|
- if (process[i].children) {
|
|
|
|
- for (let j = 0; j < process[i].children.length; j++) {
|
|
|
|
- if (process[i].children[j].number) {
|
|
|
|
- number = process[i].children[j].number
|
|
|
|
- break
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (number) {
|
|
|
|
- break
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (number === '') {
|
|
|
|
- for (let i = 0; i < results.length; i++) {
|
|
|
|
- if (results[i].children) {
|
|
|
|
- for (let j = 0; j < results[i].children.length; j++) {
|
|
|
|
- if (results[i].children[j].number) {
|
|
|
|
- number = results[i].children[j].number
|
|
|
|
- break
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (number) {
|
|
|
|
- break
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ let number = findNumber(process) || findNumber(results)
|
|
//发起请求
|
|
//发起请求
|
|
const { eleId, globalType, nodeId, pid } = getObjValue(dataInfo.value)
|
|
const { eleId, globalType, nodeId, pid } = getObjValue(dataInfo.value)
|
|
|
|
+ const formData = {
|
|
|
|
+ formula: obj.text,
|
|
|
|
+ remark: '',
|
|
|
|
+ nodeId: nodeId,
|
|
|
|
+ elementId: eleId,
|
|
|
|
+ scale: isRetain.value ? retainNum.value : '',
|
|
|
|
+ number: number,
|
|
|
|
+ map: JSON.stringify(obj.eleMap),
|
|
|
|
+ scope: globalType,
|
|
|
|
+ projectId: projectId.value || pid,
|
|
|
|
+ dev: deviationRangeText,
|
|
|
|
+ }
|
|
|
|
+ let res = {}
|
|
if (isNullES(formulaId.value)) {
|
|
if (isNullES(formulaId.value)) {
|
|
//新增
|
|
//新增
|
|
- const { code } = await formulaApi.save({
|
|
|
|
- formula:obj.text,
|
|
|
|
- remark:'',
|
|
|
|
- nodeId:nodeId,
|
|
|
|
- elementId:eleId,
|
|
|
|
- scale:isRetain.value ? retainNum.value : '',
|
|
|
|
- number:number,
|
|
|
|
- map:JSON.stringify(obj.eleMap),
|
|
|
|
- scope:globalType,
|
|
|
|
- projectId:projectId.value || pid,
|
|
|
|
- dev:deviationRangeText,
|
|
|
|
- ver:1,
|
|
|
|
- })
|
|
|
|
|
|
+ res = await formulaApi.save({ ...formData, ver:1 })
|
|
} else {
|
|
} else {
|
|
//更新
|
|
//更新
|
|
- const { code } = await formulaApi.update({
|
|
|
|
- id: formulaId.value,
|
|
|
|
- formula:obj.text,
|
|
|
|
- remark:'',
|
|
|
|
- nodeId:nodeId,
|
|
|
|
- elementId:eleId,
|
|
|
|
- scale:isRetain.value ? retainNum.value : '',
|
|
|
|
- number:number,
|
|
|
|
- map:JSON.stringify(obj.eleMap),
|
|
|
|
- scope:globalType,
|
|
|
|
- projectId:projectId.value || pid,
|
|
|
|
- dev:deviationRangeText,
|
|
|
|
- })
|
|
|
|
|
|
+ res = await formulaApi.update({ id: formulaId.value, ...formData })
|
|
|
|
+ }
|
|
|
|
+ const { code, msg, data } = getObjValue(res)
|
|
|
|
+ if (code !== 200) {
|
|
|
|
+ submitLoading.value = false
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ let msgStr = '保存成功'
|
|
|
|
+ if (msg === '公式已删除') {
|
|
|
|
+ formulaId.value = ''
|
|
|
|
+ msgStr = msg
|
|
|
|
+ } else if (!isNullES(data)) {
|
|
|
|
+ formulaId.value = data
|
|
}
|
|
}
|
|
|
|
+ window?.$message.success(msgStr)
|
|
|
|
+ getFormulaStringToArrayApi()
|
|
|
|
+ submitLoading.value = false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|