|
|
|
@ -41,7 +41,7 @@
|
|
|
|
|
<span class="custom-tree-node" slot-scope="{ node, data }">
|
|
|
|
|
<span v-if="node.level === 1">
|
|
|
|
|
<span class="iconfont icon-dianli" style="margin-right: 6px"></span>
|
|
|
|
|
<!-- <span>{{ node.label }} </span> -->
|
|
|
|
|
<!--<span>{{ node.label }} </span>-->
|
|
|
|
|
<span>捕鱼达人</span>
|
|
|
|
|
</span>
|
|
|
|
|
<span v-else-if="node.level === 2">
|
|
|
|
@ -76,7 +76,7 @@
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<script>
|
|
|
|
|
import { getdyTreeListJoggle } from "@/utils/api/index";
|
|
|
|
|
import { getdyTreeListJoggle, getzzdyTreeList } from "@/utils/api/index";
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
@ -99,6 +99,7 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
currentData: {}, //当前选中的数据
|
|
|
|
|
currentNodekey: "", //默认选中的节点树,
|
|
|
|
|
role: "",
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
@ -133,7 +134,69 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
//获取树状图列表
|
|
|
|
|
getLineTreeList() {
|
|
|
|
|
this.role = localStorage.getItem("role");
|
|
|
|
|
console.log(this.role);
|
|
|
|
|
this.treeLoading = true;
|
|
|
|
|
if (this.role == 2) {
|
|
|
|
|
getzzdyTreeList({
|
|
|
|
|
type: -1,
|
|
|
|
|
lineid: [
|
|
|
|
|
"234",
|
|
|
|
|
"238",
|
|
|
|
|
"253",
|
|
|
|
|
"242",
|
|
|
|
|
"233",
|
|
|
|
|
"231",
|
|
|
|
|
"243",
|
|
|
|
|
"235",
|
|
|
|
|
"248",
|
|
|
|
|
"230",
|
|
|
|
|
"236",
|
|
|
|
|
"239",
|
|
|
|
|
"257",
|
|
|
|
|
"255",
|
|
|
|
|
],
|
|
|
|
|
})
|
|
|
|
|
.then((res) => {
|
|
|
|
|
this.lineTreeData = res.data.list;
|
|
|
|
|
this.treeLoading = false;
|
|
|
|
|
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);
|
|
|
|
|
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 {
|
|
|
|
|
this.currentData = this.lineTreeData[0]; //第一个选中的数据
|
|
|
|
|
this.currentNodekey = this.lineTreeData[0].id; //第一个数据
|
|
|
|
|
this.handleNodeClick(this.currentData);
|
|
|
|
|
}
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
this.$refs.tree.setCurrentKey(this.currentNodekey); //一定要加这个选中了否则样式没有出来
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
console.log(err); //代码错误、请求失败捕获
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
getdyTreeListJoggle({ type: -1 })
|
|
|
|
|
.then((res) => {
|
|
|
|
|
this.lineTreeData = res.data.list;
|
|
|
|
@ -174,6 +237,7 @@ export default {
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
console.log(err); //代码错误、请求失败捕获
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
//点击当前选中的treenode
|
|
|
|
|
handleNodeClick(data) {
|
|
|
|
|