Ver código fonte

更换树形控件组件

duy 2 anos atrás
pai
commit
0d0d255b04
1 arquivos alterados com 34 adições e 3 exclusões
  1. 34 3
      src/views/tentative/detect/test.vue

+ 34 - 3
src/views/tentative/detect/test.vue

@@ -19,6 +19,12 @@
                         :wbsTempId="projectInfo?.referenceWbsTemplateIdTrial"
                         :wbsType="2"
                         @nodeTap="wbsElTreeClick"/>
+                        <!-- <HcLazyTree
+                                :isType="false"
+                                :autoExpandKeys="treeAutoExpandKeys"
+                                @load="treeLoadNode"
+                                @nodeTap="wbsElTreeClick"
+                        /> -->
                 </el-scrollbar>
             </div>
             <!--左右拖动-->
@@ -210,7 +216,7 @@
 </template>
 
 <script setup>
-import {ref, watch, onMounted} from "vue";
+import {ref, watch, onMounted,onActivated} from "vue";
 import {useRouter} from 'vue-router'
 import {useAppStore} from "~src/store";
 import TestTree from "../material/components/TestTree.vue"
@@ -220,7 +226,9 @@ import dataApi from "~api/tentative/detect/test";
 import {getDictionary} from "~api/other";
 import {eVisaTaskCheckApi} from "~api/other"
 import wbsApi from "~api/data-fill/wbs"
-import {getArrValue, arrKeyValue, isString, arrToId} from "js-fast-way"
+import samplingApi from "~api/tentative/material/sampling"
+import {getArrValue, arrKeyValue, isString, arrToId,getObjValue} from "js-fast-way"
+
 import {Loading} from "element-plus/es/components/loading/src/service";
 import notableform from '~src/assets/view/notableform.svg';
 import {delMessage} from "~uti/tools";
@@ -261,12 +269,35 @@ onMounted(() => {
     getCategoryData()
 
 })
-
+//缓存被激活时,重新获取表格数据
+onActivated(() => {
+    // setMountOnEventKey()
+    getTableData()
+})
 const qualifiedData = ref([
     {label: '不合格', value: '0'},
     {label: '合格', value: '1'}
 ])
 
+//加载树形结构数据
+const treeLoadNode = async ({node, item, level},resolve) => {
+    let contractIdRelation = '', parentId = '0', primaryKeyId = '';
+    if (level !== 0) {
+        const nodeData = getObjValue(item);
+        contractIdRelation = nodeData?.contractIdRelation || ''
+        parentId =nodeData?.id
+        primaryKeyId = nodeData?.id || ''
+    }
+    //获取数据
+    const {data} = await samplingApi.queryLazyTree({
+        wbsId: projectInfo.value?.referenceWbsTemplateIdTrial,
+        tenantId: userInfo.value?.tenant_id,
+        projectId: projectId.value,
+        parentId,
+        wbsType: 2
+    })
+    resolve(getArrValue(data))
+}
 //获取检测类别类型
 const categoryData = ref([])
 const getCategoryData = async () => {