Commit 83c8cfbd by 张杰

优化树展示

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