优化左侧

master
fanluyan 1 year ago
parent e85790effb
commit 0f262b5b9d

@ -41,7 +41,7 @@
<span class="custom-tree-node" slot-scope="{ node, data }"> <span class="custom-tree-node" slot-scope="{ node, data }">
<span v-if="node.level === 1"> <span v-if="node.level === 1">
<span class="iconfont icon-dianli" style="margin-right: 6px"></span> <span class="iconfont icon-dianli" style="margin-right: 6px"></span>
<!-- <span>{{ node.label }} </span> --> <!--<span>{{ node.label }} </span>-->
<span>捕鱼达人</span> <span>捕鱼达人</span>
</span> </span>
<span v-else-if="node.level === 2"> <span v-else-if="node.level === 2">
@ -76,7 +76,7 @@
</div> </div>
</template> </template>
<script> <script>
import { getdyTreeListJoggle } from "@/utils/api/index"; import { getdyTreeListJoggle, getzzdyTreeList } from "@/utils/api/index";
export default { export default {
data() { data() {
return { return {
@ -99,6 +99,7 @@ export default {
}, },
currentData: {}, // currentData: {}, //
currentNodekey: "", //, currentNodekey: "", //,
role: "",
}; };
}, },
watch: { watch: {
@ -133,47 +134,110 @@ export default {
}, },
// //
getLineTreeList() { getLineTreeList() {
this.role = localStorage.getItem("role");
console.log(this.role);
this.treeLoading = true; this.treeLoading = true;
getdyTreeListJoggle({ type: -1 }) if (this.role == 2) {
.then((res) => { getzzdyTreeList({
this.lineTreeData = res.data.list; type: -1,
this.treeLoading = false; lineid: [
this.currentData = JSON.parse(localStorage.getItem("currentData")); "234",
this.lineTreeData.forEach((node) => { "238",
if (node.list) { "253",
node.list.forEach((child) => { "242",
this.defaultExpandedKeys.push(child.id); "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 { } 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); //
});
})
.catch((err) => {
console.log(err); //
}); });
this.defaultExpandedKeys = } else {
JSON.parse(localStorage.getItem("defaultKey")) !== null getdyTreeListJoggle({ type: -1 })
? JSON.parse(localStorage.getItem("defaultKey")) .then((res) => {
: this.defaultExpandedKeys; //defaultKey ; 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); //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[0]; //
this.currentNodekey = this.lineTreeData[0].id; // this.currentNodekey = this.lineTreeData[0].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); //
});
})
.catch((err) => {
console.log(err); //
}); });
}) }
.catch((err) => {
console.log(err); //
});
}, },
//treenode //treenode
handleNodeClick(data) { handleNodeClick(data) {

@ -204,3 +204,12 @@ export function getSearchInfo(data) {
data, data,
}); });
} }
//郑州左侧树状结构接口
export function getzzdyTreeList(data) {
return request({
url: "/api/getzzdyTreeList",
method: "post",
data,
});
}

@ -170,6 +170,7 @@ export default {
this.loading = true; this.loading = true;
this.$set(this.formdata, "pageindex", this.page); this.$set(this.formdata, "pageindex", this.page);
this.$set(this.formdata, "pagesize", this.pageSize); this.$set(this.formdata, "pagesize", this.pageSize);
console.log(this.formdata);
getLineListJoggle(this.formdata) getLineListJoggle(this.formdata)
.then((res) => { .then((res) => {
this.lineTableData = res.data.list; this.lineTableData = res.data.list;

Loading…
Cancel
Save