|
@@ -48,11 +48,14 @@
|
|
|
<div v-if="isResetFun" class="hc-formula-reset-fun mb-14px">
|
|
|
<hc-body split padding="0">
|
|
|
<template #left>
|
|
|
- <hc-card class="reset-fun-left-card">
|
|
|
+ <hc-card class="reset-fun-left-card" scrollbar :loading="treeResetFunLoading">
|
|
|
<template #header>
|
|
|
<hc-search-input v-model="resetFunTree" @search="resetFunTreeSearch" />
|
|
|
</template>
|
|
|
- 自定义左边的区域
|
|
|
+ <el-tree
|
|
|
+ ref="treeResetFunLazyRef" :default-expanded-keys="treeResetFunLazyExpanded" node-key="id" :props="defaultProps"
|
|
|
+ :expand-on-click-node="false" highlight-current lazy :load="treeResetFunLazyLoad" @node-click="treeResetFunLazyClick"
|
|
|
+ />
|
|
|
</hc-card>
|
|
|
</template>
|
|
|
<hc-card class="reset-fun-right-card">
|
|
@@ -73,10 +76,11 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { ref, watch } from 'vue'
|
|
|
-import { deepClone, getObjValue, isNullES } from 'js-fast-way'
|
|
|
+import { nextTick, ref, watch } from 'vue'
|
|
|
+import { deepClone, getArrValue, getObjValue, isNullES } from 'js-fast-way'
|
|
|
import mainApi from '~api/project/formula'
|
|
|
import eleApi from '~api/project/element'
|
|
|
+import priApi from '~api/wbs/private'
|
|
|
|
|
|
const props = defineProps({
|
|
|
data: {
|
|
@@ -186,6 +190,64 @@ const resetFunClick = () => {
|
|
|
isScrollBar.value = !isResetFun.value
|
|
|
}
|
|
|
|
|
|
+//tree树配置
|
|
|
+const defaultProps = {
|
|
|
+ label: 'title',
|
|
|
+ children: 'children',
|
|
|
+ isLeaf: (data) => {
|
|
|
+ return !data.hasChildren
|
|
|
+ },
|
|
|
+}
|
|
|
+
|
|
|
+//重置函数懒加载树
|
|
|
+const treeResetFunLazyRef = ref(null)
|
|
|
+const treeResetFunLazyExpanded = ref([])
|
|
|
+
|
|
|
+//获取重置函数懒加载树的数据
|
|
|
+const treeResetFunLoading = ref(false)
|
|
|
+const treeResetFunLazyLoad = async (node, resolve) => {
|
|
|
+ const { level, data } = node
|
|
|
+ let parentId = level !== 0 ? data.id : 12345678910
|
|
|
+ const { eleType, node: dataNode, tableType } = getObjValue(dataInfo.value)
|
|
|
+ const treeNode = getObjValue(dataNode)
|
|
|
+ if (level === 0) treeResetFunLoading.value = true
|
|
|
+ if (!eleType) {
|
|
|
+ //获取接口数据
|
|
|
+ const { data } = await priApi.tabTypeLazyTreeAll({
|
|
|
+ parentId,
|
|
|
+ current: 1,
|
|
|
+ size: 99999,
|
|
|
+ hasPartFormula: treeNode.hasPartFormula,
|
|
|
+ })
|
|
|
+ const res = getArrValue(data.records)
|
|
|
+ treeResetFunLoading.value = false
|
|
|
+ resolve(res)
|
|
|
+ //处理返回的数据
|
|
|
+ await nextTick()
|
|
|
+ //处理展开
|
|
|
+ try {
|
|
|
+ const expandId = tableType ? Number(treeNode.tableType) - 1 : Number(treeNode.parentId) - 1
|
|
|
+ if (!isNullES(expandId) && expandId >= 0) node.childNodes[expandId].expand()
|
|
|
+ } catch { /* empty */ }
|
|
|
+ //处理选中
|
|
|
+ try {
|
|
|
+ const paramsId = treeNode.initTableId
|
|
|
+ if (!isNullES(paramsId)) {
|
|
|
+ treeResetFunLazyRef.value?.setCurrentKey(paramsId)
|
|
|
+ }
|
|
|
+ } catch { /* empty */ }
|
|
|
+
|
|
|
+ } else if (eleType) {
|
|
|
+ resolve([])
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//重置函数懒加载树点击
|
|
|
+const treeResetFunLazyClick = () => {
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
//重置函数树搜索
|
|
|
const resetFunTree = ref('')
|
|
|
const resetFunTreeSearch = () => {
|