ZaiZai 2 kuukautta sitten
vanhempi
commit
72b3e07bfd

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

@@ -317,3 +317,21 @@
         height: 100%;
     }
 }
+
+//选择元素
+.hc-formula-card-select-ele-dialog .hc-new-main-body_content {
+    padding: 0 12px 12px !important;
+    .hc-div-new-card-box.hc-formula-card-range-select-left-card .el-scrollbar__bar.is-vertical {
+        right: -8px;
+    }
+    .hc-div-new-card-box.hc-formula-card-range-select-right-card .body {
+        position: relative;
+        .el-button {
+            margin-right: 10px;
+            margin-bottom: 10px;
+        }
+        .el-button + .el-button {
+            margin-left: 0;
+        }
+    }
+}

+ 64 - 8
src/views/project/list/edit-formula.vue

@@ -334,7 +334,7 @@
                                                         <el-input v-else v-model="item.arguments[indexs]" placeholder="请输入内容" class="w-200px" size="small" />
                                                     </template>
                                                     <el-link type="primary" class="ml-12px" @click="enterTextClick(item, indexs)">输入文本</el-link>
-                                                    <el-link type="primary" class="ml-12px" @click="selectingElements(item, indexs)">选择元素</el-link>
+                                                    <el-link type="primary" class="ml-12px" @click="selectingElements(index, indexs)">选择元素</el-link>
                                                     <el-link type="primary" class="ml-12px" @click="setCurElement(item, index, indexs)">当前元素</el-link>
                                                 </div>
                                             </template>
@@ -368,6 +368,40 @@
                 <el-button hc-btn type="primary" @click="handWritTransform">转换</el-button>
             </template>
         </hc-dialog>
+        <!-- 选择元素 -->
+        <hc-dialog v-model="isSelectElementShow" is-table widths="1200px" title="选择元素" :footer="false" @close="selectElementClose">
+            <hc-body split class="hc-formula-card-select-ele-dialog">
+                <template #left>
+                    <hc-card class="hc-formula-card-range-select-left-card" scrollbar :loading="treeResetFunLoading">
+                        <template #header>
+                            <hc-search-input v-model="resetFunTree" @search="resetFunTreeSearch" />
+                        </template>
+                        <el-tree
+                            v-if="isResetFunTreeLazy" ref="treeRangeSelectLazyRef"
+                            :default-expanded-keys="treeResetFunLazyExpanded" node-key="id"
+                            :props="defaultProps" :expand-on-click-node="false" lazy highlight-current
+                            :load="treeResetFunLazyLoad"
+                            @node-click="treeResetFunLazyClick"
+                        />
+                        <el-tree
+                            v-else ref="treeRangeSelectAllRef" :data="resetFunTreeAll" :props="defaultProps" node-key="id"
+                            :expand-on-click-node="false" @node-click="treeResetFunLazyClick"
+                        />
+                    </hc-card>
+                </template>
+                <hc-card scrollbar class="hc-formula-card-range-select-right-card">
+                    <template #header>
+                        <hc-search-input v-model="resetFunEle" placeholder="请输入你想搜索的元素字段" @search="resetFunEleSearch" />
+                    </template>
+                    <div v-loading="isResetFunEleLoading" class="body h-full">
+                        <template v-for="(item, index) in resetFunEleData" :key="index">
+                            <el-button v-if="item.k" type="primary" plain size="small" @click="setSelectElement(item)">{{ item.name }}</el-button>
+                            <el-button v-else type="primary" plain size="small" @click="setSelectElement(item)">{{ item.eName }}</el-button>
+                        </template>
+                    </div>
+                </hc-card>
+            </hc-body>
+        </hc-dialog>
     </hc-drawer>
 </template>
 
@@ -375,8 +409,8 @@
 import { nextTick, ref, watch } from 'vue'
 import { useClick } from 'hc-vue3-ui'
 import {
-    arrIndex, deepClone, getArrValue, getObjVal,
-    getObjValue, getRandom, isArray, isNullES, isString,
+    arrIndex, deepClone, getArrValue, getObjVal, getObjValue,
+    getRandom, isArray, isNullES, isString,
 } from 'js-fast-way'
 import { ElMessageBox } from 'element-plus'
 import { VueTagsInput } from '@vojtechlanka/vue-tags-input'
@@ -1380,12 +1414,34 @@ const enterTextClick = (item, indexs) => {
 }
 
 //选择元素
-const elementsArgumenItem = ref({})
-const selectingElements = (item, indexs) => {
-    elementsArgumenItem.value = {
-        arguments: item.arguments,
-        index: indexs,
+const elementsIndex = ref({})
+const isSelectElementShow = ref(false)
+const selectingElements = (index, indexs) => {
+    elementsIndex.value = { indexs: indexs, index: index }
+    isSelectElementShow.value = true
+}
+
+//选择了元素
+const setSelectElement = (item) => {
+    const { index, indexs } = elementsIndex.value
+    try {
+        const elementKey = item['tableElementKey'].replace('_key', ':key')
+        equationSelectEle.value.children[index].arguments[indexs] = {
+            id: item.id,
+            type: 'Element',
+            selected: false,
+            tableElementKey: elementKey,
+            name: item.k ? item.name : item.eName,
+        }
+    } catch (error) {
+        console.log(error)
     }
+    selectElementClose()
+}
+
+//选择元素 关闭
+const selectElementClose = () => {
+    isSelectElementShow.value = false
 }
 
 //当前元素