소스 검색

更换树

ZaiZai 2 년 전
부모
커밋
6a898a553c
2개의 변경된 파일23개의 추가작업 그리고 4개의 파일을 삭제
  1. 23 3
      src/views/tentative/collect/test.vue
  2. 0 1
      src/views/tentative/laboratory/print.vue

+ 23 - 3
src/views/tentative/collect/test.vue

@@ -12,8 +12,7 @@
             </div>
             <div class="hc-tree-box">
                 <el-scrollbar>
-                    <WbsTree :autoExpandKeys="treeAutoExpandKeys" :classifyType="classifyType" :contractId="contractId"
-                             :projectId="projectId" isColor @nodeTap="wbsElTreeClick"/>
+                    <HcLazyTree :autoExpandKeys="treeAutoExpandKeys" isType @load="treeLoadNode" @nodeTap="wbsElTreeClick"/>
                 </el-scrollbar>
             </div>
             <!--左右拖动-->
@@ -84,7 +83,8 @@
 <script setup>
 import {ref, watch, onMounted} from "vue";
 import {useAppStore} from "~src/store";
-import WbsTree from "../../data-fill/components/WbsTree.vue"
+import queryApi from '~api/data-fill/query';
+import {getArrValue, getObjValue} from "js-fast-way";
 import {getStoreValue, setStoreValue} from '~src/utils/storage'
 
 //变量
@@ -122,6 +122,26 @@ const primaryKeyId = ref('')
 const nodeItemInfo = ref({})
 const nodeDataInfo = ref({})
 
+//懒加载的数据
+const treeLoadNode = async ({node, item, level},resolve) => {
+    let contractIdRelation = '', parentId = '', primaryKeyId = '';
+    if (level !== 0) {
+        const nodeData = getObjValue(item);
+        contractIdRelation = nodeData?.contractIdRelation || ''
+        parentId = contractIdRelation ? nodeData?.primaryKeyId : nodeData?.id
+        primaryKeyId = nodeData?.id || ''
+    }
+    //获取数据
+    const {data} = await queryApi.queryWbsTreeData({
+        contractId: contractId.value || '',
+        contractIdRelation,
+        primaryKeyId,
+        parentId,
+        classifyType: classifyType.value
+    })
+    resolve(getArrValue(data))
+}
+
 //树被点击
 const wbsElTreeClick = ({node, data, keys}) => {
     nodeItemInfo.value = node

+ 0 - 1
src/views/tentative/laboratory/print.vue

@@ -54,7 +54,6 @@
 <script setup>
 import {ref, watch, onMounted} from "vue";
 import {useAppStore} from "~src/store";
-import WbsTree from "../../data-fill/components/WbsTree.vue"
 import TestTree from "../material/components/TestTree.vue"
 import {getStoreValue, setStoreValue} from '~src/utils/storage'
 import dataApi from "~api/tentative/laboratory/print"