Skip to content

Commit 8714368

Browse files
luckyCaoa631807682
authored andcommitted
Cascader: add sets default values when lazy is true (ElemeFE#16420)
1 parent 3189e43 commit 8714368

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

packages/cascader-panel/src/cascader-panel.vue

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ export default {
109109
checkedNodePaths: [],
110110
store: [],
111111
menus: [],
112-
activePath: []
112+
activePath: [],
113+
loadCount: 0
113114
};
114115
},
115116
@@ -294,6 +295,28 @@ export default {
294295
dataList && dataList.length && this.store.appendNodes(dataList, parent);
295296
node.loading = false;
296297
node.loaded = true;
298+
299+
// dispose default value on lazy load mode
300+
if (Array.isArray(this.checkedValue)) {
301+
const nodeValue = this.checkedValue[this.loadCount++];
302+
const valueKey = this.config.value;
303+
const leafKey = this.config.leaf;
304+
305+
if (Array.isArray(dataList) && dataList.filter(item => item[valueKey] === nodeValue).length > 0) {
306+
const checkedNode = this.store.getNodeByValue(nodeValue);
307+
308+
if (!checkedNode.data[leafKey]) {
309+
this.lazyLoad(checkedNode, () => {
310+
this.handleExpand(checkedNode);
311+
});
312+
}
313+
314+
if (this.loadCount === this.checkedValue.length) {
315+
this.$parent.computePresentText();
316+
}
317+
}
318+
}
319+
297320
onFullfiled && onFullfiled(dataList);
298321
};
299322
config.lazyLoad(node, resolve);

0 commit comments

Comments
 (0)