old mode 100644
new mode 100755
|  |  |  | 
|---|
|  |  |  | 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> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | <catalogEdit ref="catalogEdit" :platformId="platformId"></catalogEdit> | 
|---|
|  |  |  | <catalogEdit ref="catalogEdit" :platformId="platformId" :platformDeviceId="platformDeviceId"></catalogEdit> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | </template> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | import catalogEdit from './catalogEdit.vue' | 
|---|
|  |  |  | export default { | 
|---|
|  |  |  | name: 'chooseChannelForCatalog', | 
|---|
|  |  |  | props: ['platformId', 'platformName', 'defaultCatalogId', 'catalogIdChange'], | 
|---|
|  |  |  | props: ['platformId', 'platformDeviceId', '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) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | 
|---|
|  |  |  | children: 'children', | 
|---|
|  |  |  | isLeaf: 'leaf' | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | defaultCatalogIdSign: null, | 
|---|
|  |  |  | chooseNode: null, | 
|---|
|  |  |  | chooseId: this.defaultCatalogId, | 
|---|
|  |  |  | chooseId: "", | 
|---|
|  |  |  | chooseName: "", | 
|---|
|  |  |  | catalogTree: null, | 
|---|
|  |  |  | contextmenuShow: false | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | platformId(newData, oldData){ | 
|---|
|  |  |  | console.log(newData) | 
|---|
|  |  |  | this.initData() | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | chooseId(newData, oldData){ | 
|---|
|  |  |  | console.log("发送: " + newData) | 
|---|
|  |  |  | if (this.catalogIdChange)this.catalogIdChange(newData); | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | methods: { | 
|---|
|  |  |  | 
|---|
|  |  |  | platformId: that.platformId, | 
|---|
|  |  |  | parentId: parentId | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | .then((res)=> { | 
|---|
|  |  |  | }).then((res)=> { | 
|---|
|  |  |  | if (res.data.code === 0) { | 
|---|
|  |  |  | if (typeof(callback) === 'function') { | 
|---|
|  |  |  | callback(res.data.data) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // if (typeof (this.$refs.tree.setCurrentKey) == "undefined") { | 
|---|
|  |  |  | //   this.$refs.tree.setCurrentKey(this.defaultCatalogId) | 
|---|
|  |  |  | //   let data = this.$refs.tree.getCurrentNode() | 
|---|
|  |  |  | //   if (data != null && data.id === this.defaultCatalogId) { | 
|---|
|  |  |  | //     this.currentCatalogChange(data, this.$refs.tree.getNode(data.id)) | 
|---|
|  |  |  | //   } | 
|---|
|  |  |  | // } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | .catch(function (error) { | 
|---|
|  |  |  | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | addCatalog: function (parentId, node){ | 
|---|
|  |  |  | let that = this; | 
|---|
|  |  |  | console.log(this.platformId) | 
|---|
|  |  |  | console.log(parentId) | 
|---|
|  |  |  | // 打开添加弹窗 | 
|---|
|  |  |  | that.$refs.catalogEdit.openDialog(false, null, null, parentId, ()=>{ | 
|---|
|  |  |  | that.$refs.catalogEdit.openDialog(false, null, null, parentId, node.level, ()=>{ | 
|---|
|  |  |  | node.loaded = false | 
|---|
|  |  |  | node.expand(); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | 
|---|
|  |  |  | let node = this.$refs.tree.getNode(id); | 
|---|
|  |  |  | this.refreshCatalog(node); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // if (nodeIds !== null) { | 
|---|
|  |  |  | //   let refreshNode = {} | 
|---|
|  |  |  | //   for (let i = 0; i < nodeIds.length; i++) { | 
|---|
|  |  |  | //     let node = this.$refs.tree.getNode(nodeIds[i]); | 
|---|
|  |  |  | //     refreshNode[node.parent.data.id] = node.parent | 
|---|
|  |  |  | //   } | 
|---|
|  |  |  | //   if (Object.values(refreshNode).length > 0) { | 
|---|
|  |  |  | //     for (let j = 0; j < Object.values(refreshNode).length; j++) { | 
|---|
|  |  |  | //       this.refreshCatalog(Object.values(refreshNode)[j]); | 
|---|
|  |  |  | //     } | 
|---|
|  |  |  | //   } | 
|---|
|  |  |  | // } | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | 
|---|
|  |  |  | url:`/api/platform/catalog/del`, | 
|---|
|  |  |  | params: { | 
|---|
|  |  |  | id: id, | 
|---|
|  |  |  | platformId: this.platformId, | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | .then((res) => { | 
|---|
|  |  |  | }).then((res) => { | 
|---|
|  |  |  | if (res.data.code === 0) { | 
|---|
|  |  |  | console.log("移除成功") | 
|---|
|  |  |  | node.parent.loaded = false | 
|---|
|  |  |  | node.parent.expand(); | 
|---|
|  |  |  | if (res.data.data) { | 
|---|
|  |  |  | this.defaultCatalogIdSign = res.data.data; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | .catch(function (error) { | 
|---|
|  |  |  | 
|---|
|  |  |  | platformId: this.platformId, | 
|---|
|  |  |  | catalogId: id, | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | .then((res)=> { | 
|---|
|  |  |  | }).then((res)=> { | 
|---|
|  |  |  | if (res.data.code === 0) { | 
|---|
|  |  |  | this.defaultCatalogId = id; | 
|---|
|  |  |  | this.defaultCatalogIdSign = id; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | .catch(function (error) { | 
|---|
|  |  |  | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | loadNode: function(node, resolve){ | 
|---|
|  |  |  | console.log("this.platformDeviceId: " + this.platformDeviceId) | 
|---|
|  |  |  | if (node.level === 0) { | 
|---|
|  |  |  | resolve([{ | 
|---|
|  |  |  | name: this.platformName, | 
|---|
|  |  |  | id:  this.platformId, | 
|---|
|  |  |  | type:  0 | 
|---|
|  |  |  | }]); | 
|---|
|  |  |  | resolve([ | 
|---|
|  |  |  | { | 
|---|
|  |  |  | name: "未分配", | 
|---|
|  |  |  | id:  null, | 
|---|
|  |  |  | type:  -1 | 
|---|
|  |  |  | },{ | 
|---|
|  |  |  | name: this.platformName, | 
|---|
|  |  |  | id:   this.platformDeviceId, | 
|---|
|  |  |  | type:  0 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ]); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (node.level >= 1){ | 
|---|
|  |  |  | this.getCatalog(node.data.id, resolve) | 
|---|
|  |  |  | 
|---|
|  |  |  | disabled: node.level === 1, | 
|---|
|  |  |  | divided: true, | 
|---|
|  |  |  | onClick: () => { | 
|---|
|  |  |  | this.removeCatalog(data.id, node) | 
|---|
|  |  |  | this.$confirm('确定删除?', '提示', { | 
|---|
|  |  |  | confirmButtonText: '确定', | 
|---|
|  |  |  | cancelButtonText: '取消', | 
|---|
|  |  |  | type: 'warning' | 
|---|
|  |  |  | }).then(() => { | 
|---|
|  |  |  | this.removeCatalog(data.id, node) | 
|---|
|  |  |  | }).catch(() => { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | { | 
|---|
|  |  |  | label: "设为默认", | 
|---|
|  |  |  | icon: "el-icon-folder-checked", | 
|---|
|  |  |  | disabled: node.data.id === this.defaultCatalogId, | 
|---|
|  |  |  | disabled: node.data.id === this.defaultCatalogIdSign, | 
|---|
|  |  |  | onClick: () => { | 
|---|
|  |  |  | this.setDefaultCatalog(data.id) | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | nodeClickHandler: function (data, node, tree){ | 
|---|
|  |  |  | console.log(data) | 
|---|
|  |  |  | console.log(node) | 
|---|
|  |  |  | this.chooseId = data.id; | 
|---|
|  |  |  | this.chooseName = data.name; | 
|---|
|  |  |  | if (this.catalogIdChange)this.catalogIdChange(this.chooseId, this.chooseName); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | </script> | 
|---|