Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Cascader: add sets default values when lazy is true (#16420)
  • Loading branch information
luckyCao authored and ziyoung committed Jul 22, 2019
1 parent 418ac5b commit 9ee2fed
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion packages/cascader-panel/src/cascader-panel.vue
Expand Up @@ -109,7 +109,8 @@ export default {
checkedNodePaths: [],
store: [],
menus: [],
activePath: []
activePath: [],
loadCount: 0
};
},
Expand Down Expand Up @@ -294,6 +295,28 @@ export default {
dataList && dataList.length && this.store.appendNodes(dataList, parent);
node.loading = false;
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);
};
config.lazyLoad(node, resolve);
Expand Down

0 comments on commit 9ee2fed

Please sign in to comment.