Commit 9ee2fedd authored by luckyCao's avatar luckyCao Committed by hetech

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

parent 418ac5bf
...@@ -109,7 +109,8 @@ export default { ...@@ -109,7 +109,8 @@ export default {
checkedNodePaths: [], checkedNodePaths: [],
store: [], store: [],
menus: [], menus: [],
activePath: [] activePath: [],
loadCount: 0
}; };
}, },
...@@ -294,6 +295,28 @@ export default { ...@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment