临时提交

This commit is contained in:
648540858
2024-07-25 18:02:22 +08:00
parent 5a812e7f08
commit a2b00a4f4e
13 changed files with 646 additions and 78 deletions

View File

@@ -10,49 +10,73 @@
</div>
</div>
</div>
<vue-easy-tree
ref="veTree"
node-key="id"
height="72vh"
style="height: 78vh"
:loadNode="loadNode"
:data="treeData"
:props="props"
></vue-easy-tree>
<div >
<vue-easy-tree
ref="veTree"
node-key="id"
height="72vh"
lazy
style="height: 78vh; padding: 2rem"
:load="loadNode"
:data="treeData"
@node-contextmenu="contextmenuEventHandler"
@node-click="nodeClickHandler"
>
<span class="custom-tree-node" slot-scope="{ node, data }">
<span v-if="node.data.type === 0" style="color: #409EFF" class="iconfont icon-bianzubeifen3"></span>
<span v-if="node.data.type === 1" style="color: #409EFF" class="iconfont icon-file-stream2"></span>
<span style=" padding-left: 1px">{{ node.label }}</span>
</span>
</vue-easy-tree>
</div>
<regionCode ref="regionCode"></regionCode>
</div>
</template>
<script>
import VueEasyTree from "@wchbrad/vue-easy-tree";
import regionCode from './../dialog/regionCode'
let treeData = []
export default {
name: 'DeviceTree',
components: {
VueEasyTree
VueEasyTree, regionCode
},
data() {
return {
props: {
label: "name",
},
searchSrt: "",
// props: {
// label: "name",
// },
treeData: [],
}
},
props: ['edit', 'clickEvent', 'contextMenuEvent'],
created() {
this.$axios({
method: 'get',
url: `/api/region/tree/list`,
}).then((res)=> {
if (res.data.code === 0) {
this.treeData.push(res.data.data)
}
}).catch(function (error) {
console.log(error);
});
// this.$axios({
// method: 'get',
// url: `/api/region/tree/list`,
// }).then((res)=> {
// if (res.data.code === 0) {
//
// for (let i = 0; i < res.data.data.length; i++) {
// let item = res.data.data[i]
// console.log(item)
// this.treeData.push({
// id: item.deviceId,
// label: item.name,
// children: [],
// isLeaf: false,
// })
// }
//
// }
//
// }).catch(function (error) {
// console.log(error);
// });
},
methods: {
onClick(evt, treeId, treeNode) {
@@ -63,6 +87,9 @@ export default {
},
handleCreated(ztreeObj) {
},
search() {
},
handleNodeClick(data, node, element) {
let deviceNode = this.$refs.gdTree.getNode(data.userData.deviceId)
@@ -78,13 +105,27 @@ export default {
}
},
loadNode: function (node, resolve) {
console.log(22222)
console.log(node)
if (node.level === 0) {
} else {
if (node.level === 0 || node.data.id.length < 8) {
this.$axios({
method: 'get',
url: `/api/region/tree/list`,
params: {
query: this.searchSrt,
parent: node.data.id
}
}).then((res)=> {
if (res.data.code === 0) {
resolve(res.data.data);
}
}).catch(function (error) {
console.log(error);
});
}else {
resolve([]);
}
},
channelDataHandler: function (data, resolve) {
if (data.length > 0) {
@@ -134,6 +175,131 @@ export default {
},
reset: function () {
this.$forceUpdate();
},
contextmenuEventHandler: function (event,data,node,element){
if (node.data.type === 1) {
data.parentId = node.parent.data.id;
this.$contextmenu({
items: [
{
label: "移除通道",
icon: "el-icon-delete",
disabled: false,
onClick: () => {
this.$axios({
method:"delete",
url:"/api/platform/catalog/relation/del",
data: data
}).then((res)=>{
console.log("移除成功")
node.parent.loaded = false
node.parent.expand();
}).catch(function (error) {
console.log(error);
});
}
}
],
event, // 鼠标事件信息
customClass: "custom-class", // 自定义菜单 class
zIndex: 3000, // 菜单样式 z-index
});
}else if (node.data.type === 0){
this.$contextmenu({
items: [
{
label: "刷新节点",
icon: "el-icon-refresh",
disabled: false,
onClick: () => {
this.refreshNode(node);
}
},
{
label: "新建节点",
icon: "el-icon-plus",
disabled: false,
onClick: () => {
this.addRegion(data.id, node);
}
},
{
label: "修改节点",
icon: "el-icon-edit",
disabled: false,
onClick: () => {
this.editCatalog(data, node);
}
},
{
label: "删除节点",
icon: "el-icon-delete",
disabled: false,
onClick: () => {
this.$confirm('确定删除?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.removeCatalog(data.id, node)
}).catch(() => {
});
}
},
// {
// label: "导出",
// icon: "el-icon-download",
// disabled: false,
// children: [
// {
// label: "导出到文件",
// onClick: () => {
//
// },
// },
// {
// label: "导出到其他平台",
// onClick: () => {
//
// },
// }
// ]
// },
],
event, // 鼠标事件信息
customClass: "custom-class", // 自定义菜单 class
zIndex: 3000, // 菜单样式 z-index
});
}
return false;
},
refreshNode: function (node){
node.loaded = false
node.expand();
},
addRegion: function (id, node){
console.log(node)
this.$refs.regionCode.openDialog(code=>{
console.log(this.form)
console.log("code===> " + code)
this.form.gbDeviceId = code;
console.log("code22===> " + code)
node.loaded = false
node.expand();
}, id);
},
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);
}
},
destroyed() {