ApiSelect Add alwaysLoad option (#1461)

* fix(modal): 取消全屏功能后关闭图标颜色异常

* chore: move to pnpm

* fix: RangePicekr在表单项中占满分配的宽度

* chore: comment format

* Revert "fix: RangePicekr在表单项中占满分配的宽度"

This reverts commit cd70e41dac294329383be3d2f0a393dc26b7f140.

* feat(ApiSelect): 新增每次加载选项

Co-authored-by: liushiman <smliu@gk-estor.com>
This commit is contained in:
1sm 2021-12-12 22:08:42 +08:00 committed by GitHub
parent b70fade587
commit ab62739fd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,6 @@
<template>
<Select
@dropdownVisibleChange="handleFetch"
@dropdown-visible-change="handleFetch"
v-bind="$attrs"
@change="handleChange"
:options="getOptions"
@ -57,6 +57,7 @@
labelField: propTypes.string.def('label'),
valueField: propTypes.string.def('value'),
immediate: propTypes.bool.def(true),
alwaysLoad: propTypes.bool.def(false),
},
emits: ['options-change', 'change'],
setup(props, { emit }) {
@ -87,7 +88,7 @@
});
watchEffect(() => {
props.immediate && fetch();
props.immediate && !props.alwaysLoad && fetch();
});
watch(
@ -121,10 +122,14 @@
}
}
async function handleFetch() {
if (!props.immediate && unref(isFirstLoad)) {
await fetch();
isFirstLoad.value = false;
async function handleFetch(visible) {
if (visible) {
if (props.alwaysLoad) {
await fetch();
} else if (!props.immediate && unref(isFirstLoad)) {
await fetch();
isFirstLoad.value = false;
}
}
}