Commit 83c8cfbd by 张杰

优化树展示

1 parent 267d3abf
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
</div> </div>
<div class="tree_box"> <div class="tree_box">
<el-scrollbar class="el_scroll"> <el-scrollbar class="el_scroll">
<el-tree :data="vehicleList" :props="treeProps" :default-checked-keys="checkKeys" :loading="ajaxloding" show-checkbox lazy node-key="id" :load="loadNode" :render-content="renderTreeContent" @check="onCheckChange"> <el-tree :data="vehicleList" :props="treeProps" :default-checked-keys="checkKeys" v-loading="treeLoading" show-checkbox lazy node-key="id" :load="loadNode" :render-content="renderTreeContent" @check="onCheckChange">
</el-tree> </el-tree>
</el-scrollbar> </el-scrollbar>
</div> </div>
...@@ -81,7 +81,7 @@ import { ...@@ -81,7 +81,7 @@ import {
SAVE_USER_ASSIGN_INFO, SAVE_USER_ASSIGN_INFO,
GET_USER_ASSIGN_INFO, GET_USER_ASSIGN_INFO,
} from "@/services/user"; } from "@/services/user";
import { deepClone, showToast,broadcast } from "@/utils/util"; import { deepClone, showToast, broadcast } from "@/utils/util";
export default { export default {
name: "SelectInfo", name: "SelectInfo",
props: { props: {
...@@ -114,13 +114,17 @@ export default { ...@@ -114,13 +114,17 @@ export default {
showPopover: false, showPopover: false,
resultList: [], resultList: [],
placeholderText: "请输入至少两个关键字", placeholderText: "请输入至少两个关键字",
treeLoading: true,
}; };
}, },
mounted() { mounted() {
let list = this.$store.state.userVehicleTree; let list = this.$store.state.userVehicleTree;
this.vehicleList = list; this.vehicleList = list;
if (!list || list.length <= 0) { if (!list || list.length <= 0) {
this.getList(); this.getList();
} else {
this.treeLoading = false;
} }
this.handleScroll(); this.handleScroll();
this.getInfo(); this.getInfo();
...@@ -129,6 +133,7 @@ export default { ...@@ -129,6 +133,7 @@ export default {
// 获取车辆树 // 获取车辆树
getList() { getList() {
GET_VEHICLE_TREE().then((res) => { GET_VEHICLE_TREE().then((res) => {
this.treeLoading = false;
this.vehicleList = res.data || []; this.vehicleList = res.data || [];
this.$store.commit("updateUserOrganizationTree", res.data || []); this.$store.commit("updateUserOrganizationTree", res.data || []);
}); });
...@@ -154,9 +159,10 @@ export default { ...@@ -154,9 +159,10 @@ export default {
}); });
return resolve(list); return resolve(list);
}); });
return false;
} }
return resolve(_cur); return resolve([]);
}, },
// 自定义展示数节点 // 自定义展示数节点
...@@ -190,21 +196,24 @@ export default { ...@@ -190,21 +196,24 @@ export default {
let idx = checkKeys.findIndex((k) => k == data.id); let idx = checkKeys.findIndex((k) => k == data.id);
let checked = idx >= 0 ? true : false; let checked = idx >= 0 ? true : false;
_this.ajaxloding = true;
// 直接勾选车辆 // 直接勾选车辆
if(data.leaf){ if (data.leaf) {
_this.setList(data, [data], checked); _this.setList(data, [data], checked);
_this.ajaxloding = false;
return false; return false;
} }
// 如果是用户 // 如果是用户
if (data.origin.type == "u") { if (data.origin.type == "u") {
GET_USER_VEHICLE_LIST({ uIds: data.id }).then((res) => { GET_USER_VEHICLE_LIST({ uIds: data.id }).then((res) => {
_this.ajaxloding = false;
let list = res.data || []; let list = res.data || [];
_this.setList(data, list, checked); _this.setList(data, list, checked);
}); });
return false; return false;
} }
_this.ajaxloding = true;
// 取消勾选,不查询接口 // 取消勾选,不查询接口
if (!checked) { if (!checked) {
_this.setList(data, [], checked); _this.setList(data, [], checked);
...@@ -348,7 +357,7 @@ export default { ...@@ -348,7 +357,7 @@ export default {
showToast({ showToast({
message: "请选择数据", message: "请选择数据",
}); });
this.$emit('cancel-loading') this.$emit("cancel-loading");
return false; return false;
} }
...@@ -359,8 +368,9 @@ export default { ...@@ -359,8 +368,9 @@ export default {
let oParams = {}; let oParams = {};
oParams.receiverId = this.id; oParams.receiverId = this.id;
oParams.vehicleIds = arr; oParams.vehicleIds = arr;
SAVE_USER_ASSIGN_INFO(oParams).then((res) => { SAVE_USER_ASSIGN_INFO(oParams)
broadcast('cancel-loading') .then((res) => {
broadcast("cancel-loading");
if (res.code == 200) { if (res.code == 200) {
showToast({ showToast({
message: "保存成功", message: "保存成功",
...@@ -368,8 +378,9 @@ export default { ...@@ -368,8 +378,9 @@ export default {
}); });
broadcast("assign-success"); broadcast("assign-success");
} }
}).catch(error => { })
broadcast('cancel-loading') .catch((error) => {
broadcast("cancel-loading");
}); });
}, },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!