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