Cascader: add sets default values when lazy is true (#16420)

pull/16687/head
luckyCao 2019-07-22 18:33:14 +08:00 committed by hetech
parent 418ac5bf79
commit 9ee2fedde7
1 changed files with 24 additions and 1 deletions

View File

@ -109,7 +109,8 @@ export default {
checkedNodePaths: [], checkedNodePaths: [],
store: [], store: [],
menus: [], menus: [],
activePath: [] activePath: [],
loadCount: 0
}; };
}, },
@ -294,6 +295,28 @@ export default {
dataList && dataList.length && this.store.appendNodes(dataList, parent); dataList && dataList.length && this.store.appendNodes(dataList, parent);
node.loading = false; node.loading = false;
node.loaded = true; node.loaded = true;
// dispose default value on lazy load mode
if (Array.isArray(this.checkedValue)) {
const nodeValue = this.checkedValue[this.loadCount++];
const valueKey = this.config.value;
const leafKey = this.config.leaf;
if (Array.isArray(dataList) && dataList.filter(item => item[valueKey] === nodeValue).length > 0) {
const checkedNode = this.store.getNodeByValue(nodeValue);
if (!checkedNode.data[leafKey]) {
this.lazyLoad(checkedNode, () => {
this.handleExpand(checkedNode);
});
}
if (this.loadCount === this.checkedValue.length) {
this.$parent.computePresentText();
}
}
}
onFullfiled && onFullfiled(dataList); onFullfiled && onFullfiled(dataList);
}; };
config.lazyLoad(node, resolve); config.lazyLoad(node, resolve);