|
@@ -39,9 +39,12 @@
|
|
|
</div>
|
|
|
<div class="body relative">
|
|
|
<template v-for="(item, index) in resultFormula" :key="index">
|
|
|
- <span class="element-class text-26px" :class="item.selected ? 'is-cur' : ''" @click="resultFormulaItem(item, index)">{{ item.name }}</span>
|
|
|
+ <span class="element-class text-26px" :class="item.selected ? 'is-cur' : ''" @click="resultFormulaItem(item)">{{ item.name }}</span>
|
|
|
</template>
|
|
|
<span class="ml-10px mr-10px text-26px">=</span>
|
|
|
+ <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>
|
|
|
+ </template>
|
|
|
</div>
|
|
|
</div>
|
|
|
<!-- 重置函数 -->
|
|
@@ -237,9 +240,21 @@ const getWbsFormElementData = async () => {
|
|
|
}
|
|
|
|
|
|
//被点击
|
|
|
-const resultFormulaItem = (item, index) => {
|
|
|
- item.selected = !item.selected
|
|
|
- console.log(item, index)
|
|
|
+const resultFormulaItem = (item) => {
|
|
|
+ //清除右边的选中
|
|
|
+ processFormula.value.forEach((obj) => {
|
|
|
+ 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
|
|
|
}
|
|
|
|
|
|
//是否重置函数
|
|
@@ -491,8 +506,50 @@ const selectEleFormulaItem = (item) => {
|
|
|
//保存
|
|
|
const submitLoading = ref(false)
|
|
|
const submitClick = async () => {
|
|
|
+ if (isResetFun.value) {
|
|
|
+ setProcessFormula()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//赋值给等号右边的数组
|
|
|
+const processFormula = ref([])
|
|
|
+const setProcessFormula = () => {
|
|
|
const arr = selectEleFormula.value
|
|
|
- console.log(arr)
|
|
|
+ let leftNum = 0, rightNum = 0
|
|
|
+ arr.forEach(({ type, name }) => {
|
|
|
+ if (type === 'Brackets') {
|
|
|
+ if (name === '(') {
|
|
|
+ leftNum++
|
|
|
+ } else if (name === ')') {
|
|
|
+ rightNum++
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (leftNum !== rightNum) {
|
|
|
+ window?.$message.warning('左右括号数量不相等,请先检查是否正确')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ processFormula.value = deepClone(arr)
|
|
|
+ isResetFun.value = false
|
|
|
+ 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
|
|
|
}
|
|
|
|
|
|
//关闭抽屉
|