ZaiZai 10 meses atrás
pai
commit
e4806ae80b

+ 8 - 0
src/styles/view/project/edit-formula.scss

@@ -120,6 +120,14 @@
                 height: calc((100% - 40% ) - 36px);
                 padding-top: 8px;
                 font-size: 14px;
+                .element-class {
+                    cursor: pointer;
+                    padding: 0 3px;
+                    user-select: none;
+                    &.is-cur {
+                        color: #f0720a;
+                    }
+                }
             }
         }
     }

+ 34 - 2
src/views/project/list/edit-formula.vue

@@ -107,7 +107,9 @@
                                     </div>
                                 </div>
                                 <div class="input-box">
-                                    123123
+                                    <template v-for="(item, index) in selectEleFormula" :key="item.id">
+                                        <span class="element-class text-14px" :class="item.selected ? 'is-cur' : ''" @click="selectEleFormulaItem(item, index)">{{ item.name }}</span>
+                                    </template>
                                 </div>
                             </div>
                         </hc-card>
@@ -332,8 +334,33 @@ const getNodeDetailApi = async (item) => {
 }
 
 //重置函数 元素字段被点击
+const selectEleFormula = ref([])
 const resetFunEleTagClick = (item) => {
-    console.log(item)
+    const arr = selectEleFormula.value
+    let { type, name } = getObjValue(arr[arr.length - 1])
+    if (type === 'Text') {
+        window?.$message.warning('元素无法连续出现在输入值后面')
+        return
+    }
+    if (type === 'Brackets' && name === ')') {
+        window?.$message.warning('元素无法连续出现在右括号后面')
+        return
+    }
+    if (arr.length === 0 || ['Operator', 'Brackets'].includes(type) || name === '(') {
+        //元素
+        if (!isNullES(item.tableElementKey)) {
+            selectEleFormula.value.push({
+                type: 'Element',
+                name: item.eName,
+                id: item.id,
+                selected: false,
+                tableElementKey: item.tableElementKey,
+                children: [],
+            })
+        }
+    } else {
+        window?.$message.warning('当前操作不符合要求')
+    }
 }
 
 //重置函数 输入值
@@ -361,6 +388,11 @@ const resetFunClear = () => {
 
 }
 
+//被点击
+const selectEleFormulaItem = (item, index) => {
+    item.selected = !item.selected
+}
+
 //保存
 const submitLoading = ref(false)
 const submitClick = async () => {