页面
v-model="partyOrganId"
:placeholder="partyOrganName"
:props="prop"
:show-all-levels="false"
class="font_pla"
>
data() {
return {
partyOrganId: [],
prop: {
lazy: true,
lazyLoad(node, resolve) {
setTimeout(() => {
if (node.level == 0) {
axios({
method: "get", //请求方式
url: "/api/commonUser/findByChildRegion", //请求地址
params: {
regionCode: "330000"
}
})
.then(res => {
const cities = res.data.data.map((value, i) => ({
value: value.regionCode,
label: value.regionName,
leaf: node.level >= 2
}));
// 通过调用resolve将子节点数据返回,通知组件数据加载完成
resolve(cities);
})
.catch(err => {
console.log(err);
});
}
if (node.level == 1) {
axios({
method: "get", //请求方式
url: "/api/commonUser/findByChildRegion", //请求地址
params: {
regionCode: node.value
}
})
.then(res => {
const areas = res.data.data.map((value, i) => ({
value: value.regionCode,
label: value.regionName,
leaf: node.level >= 2
}));
// 通过调用resolve将子节点数据返回,通知组件数据加载完成
resolve(areas);
})
.catch(err => {
console.log(err);
});
} else if (node.level == 2) {
axios({
method: "get", //请求方式
url: "/api/commonPartyOrgan/getPartyOrganInfo", //请求地址
params: {
cityCode: node.path[0],
areaCode: node.path[1]
}
})
.then(res => {
const partys = res.data.data.map((value, i) => ({
value: value.id,
label: value.name,
leaf: node.level >= 2
}));
// 通过调用resolve将子节点数据返回,通知组件数据加载完成
resolve(partys);
})
.catch(err => {
console.log(err);
});
}
}, 1000);
}
}
};
},