添加收藏夹功能

wp1.0
fanluyan 1 year ago
parent ce1b533423
commit c6c82dc570

@ -170,7 +170,7 @@ export default {
console.log(this.role); console.log(this.role);
this.getRadio(); //线线 this.getRadio(); //线线
this.getLineTreeList(); // this.getLineTreeList(); //
this.treeStatustimer = setInterval(this.getLineTreeStatus, 60000); // 10 this.treeStatustimer = setInterval(this.getLineTreeStatus, 60000); // 60
EventBus.$on("treelist", this.getLineTreeStatus); EventBus.$on("treelist", this.getLineTreeStatus);
}, },
methods: { methods: {
@ -188,27 +188,60 @@ export default {
if (this.filterText !== "") { if (this.filterText !== "") {
this.$refs.tree.filter(this.filterText); this.$refs.tree.filter(this.filterText);
} else { } else {
getdyTreeListJoggle({ type: this.zzradio }) if (this.role == 4) {
.then((res) => { getzzdyTreeList({ type: this.zzradio, lineid: 127 })
console.log(res); .then((res) => {
this.lineTreeData = res.data.list; console.log(res);
this.isfavorList = res.data.favorlist; this.lineTreeData = res.data.list;
this.lineTreeData.unshift({ this.onlineNum = res.data.onlineNum;
id: 0, this.totalNum = res.data.totalNum;
name: "收藏夹", if (this.zzradio == 0) {
bsManufacturer: "收藏夹", console.log("装置为离线");
list: this.isfavorList, this.$nextTick(() => {
console.log(this.lineTreeData);
this.currentData = this.lineTreeData[0];
console.log(this.currentData);
this.handleNodeClick(this.currentData);
this.$nextTick(() => {
this.$refs.tree.setCurrentKey(this.currentData.id); //
this.scrollView();
});
});
} else {
this.$nextTick(() => {
this.$refs.tree.setCurrentKey(this.currentData.id); //
this.scrollView();
});
}
})
.catch((err) => {
console.log(err); //
}); });
this.onlineNum = res.data.onlineNum; } else {
this.totalNum = res.data.totalNum; getdyTreeListJoggle({ type: this.zzradio })
this.currentData = JSON.parse(localStorage.getItem("currentData")); .then((res) => {
this.$nextTick(() => { console.log(res);
this.$refs.tree.setCurrentKey(this.currentData.id); // this.lineTreeData = res.data.list;
this.isfavorList = res.data.favorlist;
this.lineTreeData.unshift({
id: 0,
name: "收藏夹",
bsManufacturer: "收藏夹",
list: this.isfavorList,
});
this.onlineNum = res.data.onlineNum;
this.totalNum = res.data.totalNum;
this.currentData = JSON.parse(
localStorage.getItem("currentData")
);
this.$nextTick(() => {
this.$refs.tree.setCurrentKey(this.currentData.id); //
});
})
.catch((err) => {
console.log(err); //
}); });
}) }
.catch((err) => {
console.log(err); //
});
} }
}, },
handleFilter() { handleFilter() {
@ -231,55 +264,100 @@ export default {
// //
getLineTreeList() { getLineTreeList() {
console.log(this.zzradio); console.log(this.zzradio);
getdyTreeListJoggle({ type: this.zzradio }) if (this.role == 4) {
.then((res) => { getzzdyTreeList({ type: this.zzradio, lineid: 127 })
this.lineTreeData = res.data.list; .then((res) => {
this.isfavorList = res.data.favorlist; this.lineTreeData = res.data.list;
this.lineTreeData.unshift({ this.onlineNum = res.data.onlineNum;
id: 0, this.totalNum = res.data.totalNum;
name: "收藏夹", this.currentData = JSON.parse(localStorage.getItem("currentData"));
bsManufacturer: "收藏夹", this.lineTreeData.forEach((node) => {
list: this.isfavorList, if (node.list) {
}); node.list.forEach((child) => {
this.onlineNum = res.data.onlineNum; this.defaultExpandedKeys.push(child.id);
this.totalNum = res.data.totalNum; });
this.currentData = JSON.parse(localStorage.getItem("currentData")); } else {
this.lineTreeData.forEach((node) => { this.defaultExpandedKeys.push(node.id);
if (node.list) { }
node.list.forEach((child) => { });
this.defaultExpandedKeys.push(child.id); this.defaultExpandedKeys =
}); JSON.parse(localStorage.getItem("defaultKey")) !== null
? JSON.parse(localStorage.getItem("defaultKey"))
: []; //defaultKey ;
console.log(this.defaultExpandedKeys);
if (this.lineTreeData[0].list[0].list.length > 0) {
}
if (
this.currentData !== null &&
Object.keys(this.currentData).length !== 0
) {
this.currentNodekey = this.currentData.id;
this.handleNodeClick(this.currentData);
} else { } else {
this.defaultExpandedKeys.push(node.id); this.currentData = this.lineTreeData[0]; //
this.currentNodekey = this.lineTreeData[0].id; //
this.handleNodeClick(this.currentData);
} }
this.$nextTick(() => {
this.$refs.tree.setCurrentKey(this.currentNodekey); //
this.scrollView();
});
})
.catch((err) => {
console.log(err); //
}); });
this.defaultExpandedKeys = } else {
JSON.parse(localStorage.getItem("defaultKey")) !== null getdyTreeListJoggle({ type: this.zzradio })
? JSON.parse(localStorage.getItem("defaultKey")) .then((res) => {
: this.defaultExpandedKeys; //defaultKey ; this.lineTreeData = res.data.list;
this.isfavorList = res.data.favorlist;
this.lineTreeData.unshift({
id: 0,
name: "收藏夹",
bsManufacturer: "收藏夹",
list: this.isfavorList,
});
this.onlineNum = res.data.onlineNum;
this.totalNum = res.data.totalNum;
this.currentData = JSON.parse(localStorage.getItem("currentData"));
this.lineTreeData.forEach((node) => {
if (node.list) {
node.list.forEach((child) => {
this.defaultExpandedKeys.push(child.id);
});
} else {
this.defaultExpandedKeys.push(node.id);
}
});
this.defaultExpandedKeys =
JSON.parse(localStorage.getItem("defaultKey")) !== null
? JSON.parse(localStorage.getItem("defaultKey"))
: this.defaultExpandedKeys; //defaultKey ;
console.log(this.defaultExpandedKeys); console.log(this.defaultExpandedKeys);
// if (this.lineTreeData[0].list[0].list.length > 0) { // if (this.lineTreeData[0].list[0].list.length > 0) {
// } // }
if ( if (
this.currentData !== null && this.currentData !== null &&
Object.keys(this.currentData).length !== 0 Object.keys(this.currentData).length !== 0
) { ) {
this.currentNodekey = this.currentData.id; this.currentNodekey = this.currentData.id;
this.handleNodeClick(this.currentData); this.handleNodeClick(this.currentData);
} else { } else {
this.currentData = this.lineTreeData[0]; // this.currentData = this.lineTreeData[1]; //
this.currentNodekey = this.lineTreeData[0].id; // this.currentNodekey = this.lineTreeData[1].id; //
this.handleNodeClick(this.currentData); this.handleNodeClick(this.currentData);
} }
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.tree.setCurrentKey(this.currentNodekey); // this.$refs.tree.setCurrentKey(this.currentNodekey); //
this.scrollView(); this.scrollView();
});
})
.catch((err) => {
console.log(err); //
}); });
}) }
.catch((err) => {
console.log(err); //
});
}, },
//treenode //treenode

Loading…
Cancel
Save