From bab64d0b2147a3e619e53d7417e40b5bd45fcfdb Mon Sep 17 00:00:00 2001 From: lyh <925863403@qq.com> Date: 星期三, 19 三月 2025 13:43:47 +0800 Subject: [PATCH] 修改产品结构树 增加流程修改 --- src/views/dnc/base/modules/DeviceStructure/DeviceStructureTree.vue | 47 ++++++++++++++++++++++++++++++++--------------- 1 files changed, 32 insertions(+), 15 deletions(-) diff --git a/src/views/dnc/base/modules/DeviceStructure/DeviceStructureTree.vue b/src/views/dnc/base/modules/DeviceStructure/DeviceStructureTree.vue index 1caf639..11ff894 100644 --- a/src/views/dnc/base/modules/DeviceStructure/DeviceStructureTree.vue +++ b/src/views/dnc/base/modules/DeviceStructure/DeviceStructureTree.vue @@ -59,6 +59,7 @@ treeDataSource: [], selectedKeys: [], expandedKeys: [], + beforeSearchExpandedKeys: [], searchValue: '', dataList: [], autoExpandParent: true, @@ -77,10 +78,15 @@ this.$bus.$on('treeMenuItemMethodTrigger', this.triggerCorrespondingMethod) this.$bus.$on('handleSwitchDeviceDocClassCode', this.setCurrentDeviceDocClassCode) }, + beforeDestroy() { + this.$bus.$off('treeMenuItemMethodTrigger', this.triggerCorrespondingMethod) + this.$bus.$off('handleSwitchDeviceDocClassCode', this.setCurrentDeviceDocClassCode) + }, methods: { getTreeDataByApi() { this.loading = true this.cardLoading = true + this.treeDataSource = [] dncApi.getDeviceTreeDataApi() .then(res => { if (res.success) { @@ -88,8 +94,8 @@ this.allTreeKeys = [] this.treeDataSource = res.result this.generateList(this.treeDataSource) - this.expandedKeys = this.allTreeKeys - this.$bus.$emit('sendCurrentTreeNodeInfo', this.treeDataSource[0]) + this.expandedKeys = this.beforeSearchExpandedKeys = this.allTreeKeys + this.$bus.$emit('sendDeviceTreeNodeInfo', this.treeDataSource[0]) } else { this.$message.warn(res.message) } @@ -113,9 +119,10 @@ handleTreeSelect(selectedKeys, { node }) { let record = node.dataRef this.currentSelected = Object.assign({}, record) - this.selectedKeys = selectedKeys // 鍚戝彸渚х埗绾х粍浠跺彂閫佸綋鍓嶉�変腑鏍戣妭鐐逛俊鎭� - this.$bus.$emit('sendCurrentTreeNodeInfo', this.currentSelected) + this.$bus.$emit('sendDeviceTreeNodeInfo', this.currentSelected) + if (selectedKeys.length === 0) return + this.selectedKeys = selectedKeys }, /** @@ -135,27 +142,37 @@ * @param expandedKeys 灞曞紑椤筴ey */ handleTreeExpand(expandedKeys) { - this.expandedKeys = expandedKeys + this.expandedKeys = this.beforeSearchExpandedKeys = expandedKeys + console.log('beforeSearchExpandedKeys', this.beforeSearchExpandedKeys) this.autoExpandParent = false }, /* 杈撳叆鏌ヨ鍐呭鍙樺寲鏃惰Е鍙� */ handleSearchInputChange() { let search = this.searchInput - let expandedKeys = this.dataList - .map(item => { - if (item.title != null) { - if (item.title.indexOf(search) > -1) { - return this.getParentKey(item.key, this.treeDataSource) + let expandedKeys + let autoExpandParent + if (search !== '') { + expandedKeys = this.dataList + .map(item => { + if (item.title != null) { + if (item.title.indexOf(search) > -1) { + return this.getParentKey(item.key, this.treeDataSource) + } + return null } - return null - } - }) - .filter((item, i, self) => item && self.indexOf(item) === i) + }) + .filter((item, i, self) => item && self.indexOf(item) === i) + autoExpandParent = true + } else { + expandedKeys = this.beforeSearchExpandedKeys + autoExpandParent = false + } + Object.assign(this, { expandedKeys, searchValue: search, - autoExpandParent: true + autoExpandParent }) }, -- Gitblit v1.9.3