Browse Source

资料查询树接口增加参数

duy 2 years ago
parent
commit
18bcfe859b

+ 34 - 3
src/views/data-fill/components/WbsTree.vue

@@ -85,6 +85,10 @@ const props = defineProps({
         type: Boolean,
         default: false
     },
+     classifyType: {
+        type: String,
+       
+    },
 })
 
 //变量
@@ -104,6 +108,7 @@ const projectId = ref(props.projectId);
 const contractId = ref(props.contractId);
 const idPrefix = ref(props.idPrefix);
 const isSubmitCounts = ref(props.submitCounts);
+const classifyTypedata=ref(props.classifyType)
 
 //监听
 watch(() => [
@@ -115,7 +120,8 @@ watch(() => [
     props.contractId,
     props.idPrefix,
     props.submitCounts,
-], ([menus, isMark, AutoKeys, expandKeys, UserProjectId, UserContractId, UserIdPrefix, submitCounts]) => {
+    props.classifyType
+], ([menus, isMark, AutoKeys, expandKeys, UserProjectId, UserContractId, UserIdPrefix, submitCounts,ClassifyType]) => {
     menusData.value = menus
     menuMark.value = isMark
     isAutoKeys.value = AutoKeys
@@ -124,6 +130,7 @@ watch(() => [
     contractId.value = UserContractId
     idPrefix.value = UserIdPrefix
     isSubmitCounts.value = submitCounts
+    classifyTypedata.value=ClassifyType
 })
 
 //事件
@@ -131,9 +138,13 @@ const emit = defineEmits(['menuTap','nodeTap', 'nodeLoading'])
 
 //树形结构异步加载数据
 const defaultExpandedCids = ref([])
+const rootNode=ref({})
+const rootResolve=ref(null)
 const ElTreeLoadNode = async (node, resolve) => {
     let contractIdRelation = '', parentId = '', primaryKeyId = '';
     if (node.level !== 0) {
+       rootNode.value = node
+       rootResolve.value = resolve
         const nodeData = getObjValue(node?.data);
         contractIdRelation = nodeData?.contractIdRelation || ''
         parentId = contractIdRelation ? nodeData?.primaryKeyId : nodeData?.id
@@ -144,7 +155,8 @@ const ElTreeLoadNode = async (node, resolve) => {
         contractId: contractId.value || '',
         contractIdRelation,
         primaryKeyId,
-        parentId
+        parentId,
+        classifyType:classifyTypedata.value
     })
     //处理数据
     if (!error && code === 200) {
@@ -185,7 +197,25 @@ const ElTreeLoadNode = async (node, resolve) => {
         resolve([])
     }
 }
+ // 刷新tree
+  const  resetNode=async()=>{
+      const theChildren = rootNode?.value.childNodes
+      theChildren?.splice(0, theChildren.length)
+        nextTick(()=>{
+         ElTreeLoadNode(rootNode.value, rootResolve.value)
+        })
+ }
+
+watch(classifyTypedata, (val) => {
+    if(val){
+        classifyTypedata.value=val
+    }
+   
+},
+
+{immediate:true}
 
+)
 //节点被点击
 const ElTreeClick = async (data,node) => {
     if (isAutoKeys.value) {
@@ -272,7 +302,8 @@ const removeElTreeNode = (key) => {
 // 暴露出去
 defineExpose({
     setElTreeMenuMark,
-    removeElTreeNode
+    removeElTreeNode,
+    resetNode
 })
 </script>
 

+ 19 - 3
src/views/data-fill/query.vue

@@ -29,7 +29,16 @@
                                 />
                             </template>
                             <template v-else>
-                                <WbsTree :autoExpandKeys="treeAutoExpandKeys" :projectId="projectId" :contractId="contractId" :submitCounts="true" isColor @nodeTap="wbsElTreeClick"/>
+                                <WbsTree 
+                                :autoExpandKeys="treeAutoExpandKeys" 
+                                :projectId="projectId" 
+                                :contractId="contractId" 
+                                :submitCounts="true" 
+                                isColor 
+                                @nodeTap="wbsElTreeClick"
+                                :classifyType="contractTypeTabKey"
+                                ref="wbstree"
+                                />
                             </template>
                         </KeepAlive>
                     </el-scrollbar>
@@ -188,6 +197,8 @@ const contractId = ref(useAppState.getContractId);
 const projectInfo = ref(useAppState.getProjectInfo);
 const contractInfo = ref(useAppState.getContractInfo);
 const isCollapse = ref(useAppState.getCollapse)
+//变量
+const wbstree = ref(null)
 //树搜索
 const isSearchTree = ref(false)
 //监听
@@ -341,7 +352,8 @@ const contractTypeTab = ref([
 ]);
 const contractTypeTabChange = (item) => {
     contractTypeTabKey.value = item?.key;
-    searchClick()
+    //   window?.location?.reload()  //刷新页面
+        searchClick()
 }
 
 //获取合同段类型
@@ -376,7 +388,11 @@ const keyUpEvent = (e) => {
 //搜索
 const searchClick = () => {
     searchForm.value.current = 1;
-    getTableData()
+    // getTableData()
+     wbstree.value.resetNode().then((res)=>{
+     getTableData()
+ })
+
 }
 
 //分页被点击

+ 26 - 3
src/views/data-fill/wbs.vue

@@ -120,7 +120,21 @@
                                      />
                                 </template>
                                 <template v-else>
-                                    <WbsTree :submitCounts="false" :menus="ElTreeMenu" :isMark="TreeMark" :autoExpandKeys="TreeAutoExpandKeys" :projectId="projectId" :contractId="contractId" isColor @nodeTap="wbsElTreeClick" @menuTap="ElTreeMenuClick" @nodeLoading="ElTreeNodeLoading" />
+                                    <WbsTree
+                                     :submitCounts="false" 
+                                     :menus="ElTreeMenu" 
+                                     :isMark="TreeMark" 
+                                     :autoExpandKeys="TreeAutoExpandKeys" 
+                                     :projectId="projectId" 
+                                     :contractId="contractId" 
+                                     :classifyType="authBtnTabKey"
+                                     isColor 
+                                     @nodeTap="wbsElTreeClick" 
+                                     @menuTap="ElTreeMenuClick"
+                                      @nodeLoading="ElTreeNodeLoading"
+                                      ref="wbstree"
+
+                                       />
                                 </template>
                             </KeepAlive>
                         </el-scrollbar>
@@ -458,12 +472,17 @@ onMounted(()=> {
 
 //身份按钮切换数据
 const authBtnTabKey = ref('1')
+
+//变量
+const wbstree = ref(null)
 const authBtnTabClick = (val) => {
     if (!primaryKeyId.value) {
         window?.$message?.warning('请先在左侧项目树选择一个节点')
     } else if (val['key'] !== authBtnTabKey.value) {
         authBtnTabKey.value = val['key']
         getTableDataAll()
+      
+        
     }
 }
 //contractType,  1施工,2监理
@@ -477,8 +496,12 @@ const setContractType = (contractType) => {
 }
 
 const getTableDataAll = () => {
-    searchNodeAllTable()
-    queryNodeStatus()
+    wbstree.value.resetNode().then((res)=>{
+      searchNodeAllTable()
+      queryNodeStatus()
+ })
+ 
+   
 }
 
 //结构类型tab数据和相关处理