From 72c1b36d6d2ece497e032c8434641d6576590f9d Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期日, 03 七月 2022 00:44:36 +0800 Subject: [PATCH] 优化对讲逻辑 --- web_src/src/components/dialog/chooseChannelForCatalog.vue | 54 +++++++++++++++++++++++++++++++++++------------------- 1 files changed, 35 insertions(+), 19 deletions(-) diff --git a/web_src/src/components/dialog/chooseChannelForCatalog.vue b/web_src/src/components/dialog/chooseChannelForCatalog.vue index 2d87bdd..a0cb98c 100644 --- a/web_src/src/components/dialog/chooseChannelForCatalog.vue +++ b/web_src/src/components/dialog/chooseChannelForCatalog.vue @@ -7,21 +7,23 @@ empty-text="鏈煡鑺傜偣" node-key="id" default-expand-all - :highlight-current="true" + :highlight-current="false" :expand-on-click-node="false" :props="props" :load="loadNode" @node-contextmenu="contextmenuEventHandler" + @node-click="nodeClickHandler" lazy> <span class="custom-tree-node" slot-scope="{ node, data }" style="width: 100%"> - <el-radio v-if="node.data.type === 0" style="margin-right: 0" v-model="chooseId" :label="node.data.id">{{''}}</el-radio> + <el-radio v-if="node.data.type === 0 || node.data.type === -1" style="margin-right: 0" v-model="chooseId" :label="node.data.id">{{''}}</el-radio> + <span v-if="node.data.type === -1 && node.level === 1" style="font-size: 12px" class="iconfont icon-ziyuan"></span> <span v-if="node.data.type === 0 && node.level === 1" class="el-icon-s-home"></span> <span v-if="node.data.type === 0 && node.level > 1" class="el-icon-folder-opened"></span> <span v-if="node.data.type === 1" class="iconfont icon-shexiangtou"></span> <span v-if="node.data.type === 2" class="iconfont icon-zhibo"></span> - <span style="padding-left: 1px">{{ node.label }}</span> + <span style=" padding-left: 1px">{{ node.label }}</span> <span> - <i style="margin-left: 5rem; color: #9d9d9d; padding-right: 20px" v-if="node.data.id === defaultCatalogId">榛樿</i> + <i style="margin-left: 5rem; color: #9d9d9d; padding-right: 20px" v-if="node.data.id === defaultCatalogIdSign">榛樿</i> </span> </span> </el-tree> @@ -38,9 +40,11 @@ name: 'chooseChannelForCatalog', props: ['platformId', 'platformName', 'defaultCatalogId', 'catalogIdChange'], created() { + this.chooseId = this.defaultCatalogId; + this.defaultCatalogIdSign = this.defaultCatalogId; this.initData(); setTimeout(()=>{ - if (this.catalogIdChange)this.catalogIdChange(this.defaultCatalogId); + if (this.catalogIdChange)this.catalogIdChange(this.defaultCatalogId, this.platformName); }, 100) }, @@ -54,8 +58,10 @@ children: 'children', isLeaf: 'leaf' }, + defaultCatalogIdSign: null, chooseNode: null, - chooseId: this.defaultCatalogId, + chooseId: "", + chooseName: "", catalogTree: null, contextmenuShow: false @@ -65,10 +71,6 @@ platformId(newData, oldData){ console.log(newData) this.initData() - }, - chooseId(newData, oldData){ - console.log("鍙戦�侊細 " + newData) - if (this.catalogIdChange)this.catalogIdChange(newData); }, }, methods: { @@ -120,9 +122,12 @@ editCatalog: function (data, node){ let that = this; // 鎵撳紑娣诲姞寮圭獥 - that.$refs.catalogEdit.openDialog(true, data.id, data.name, data.parentId, (data)=>{ + that.$refs.catalogEdit.openDialog(true, data.id, data.name, data.parentId, (newData)=>{ node.parent.loaded = false node.parent.expand(); + if (data.id === this.chooseId && newData.name !== data.name) { + if (this.catalogIdChange)this.catalogIdChange(this.chooseId, newData.name); + } }); }, @@ -141,7 +146,7 @@ node.parent.loaded = false node.parent.expand(); if (res.data.data) { - this.defaultCatalogId = res.data.data; + this.defaultCatalogIdSign = res.data.data; } } }) @@ -160,7 +165,7 @@ }) .then((res)=> { if (res.data.code === 0) { - this.defaultCatalogId = id; + this.defaultCatalogIdSign = id; } }) .catch(function (error) { @@ -169,11 +174,17 @@ }, loadNode: function(node, resolve){ if (node.level === 0) { - resolve([{ - name: this.platformName, - id: this.platformId, - type: 0 - }]); + resolve([ + { + name: "鏈垎閰�", + id: null, + type: -1 + },{ + name: this.platformName, + id: this.platformId, + type: 0 + } + ]); } if (node.level >= 1){ this.getCatalog(node.data.id, resolve) @@ -254,7 +265,7 @@ { label: "璁句负榛樿", icon: "el-icon-folder-checked", - disabled: node.data.id === this.defaultCatalogId, + disabled: node.data.id === this.defaultCatalogIdSign, onClick: () => { this.setDefaultCatalog(data.id) }, @@ -288,6 +299,11 @@ return false; }, + nodeClickHandler: function (data, node, tree){ + this.chooseId = data.id; + this.chooseName = data.name; + if (this.catalogIdChange)this.catalogIdChange(this.chooseId, this.chooseName); + } } }; </script> -- Gitblit v1.8.0