Commit ab62739fd135f25df3b25c1b764f607d836c7371
Committed by
GitHub
1 parent
b70fade5
`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>
Showing
1 changed file
with
11 additions
and
6 deletions
src/components/Form/src/components/ApiSelect.vue
1 | 1 | <template> |
2 | 2 | <Select |
3 | - @dropdownVisibleChange="handleFetch" | |
3 | + @dropdown-visible-change="handleFetch" | |
4 | 4 | v-bind="$attrs" |
5 | 5 | @change="handleChange" |
6 | 6 | :options="getOptions" |
... | ... | @@ -57,6 +57,7 @@ |
57 | 57 | labelField: propTypes.string.def('label'), |
58 | 58 | valueField: propTypes.string.def('value'), |
59 | 59 | immediate: propTypes.bool.def(true), |
60 | + alwaysLoad: propTypes.bool.def(false), | |
60 | 61 | }, |
61 | 62 | emits: ['options-change', 'change'], |
62 | 63 | setup(props, { emit }) { |
... | ... | @@ -87,7 +88,7 @@ |
87 | 88 | }); |
88 | 89 | |
89 | 90 | watchEffect(() => { |
90 | - props.immediate && fetch(); | |
91 | + props.immediate && !props.alwaysLoad && fetch(); | |
91 | 92 | }); |
92 | 93 | |
93 | 94 | watch( |
... | ... | @@ -121,10 +122,14 @@ |
121 | 122 | } |
122 | 123 | } |
123 | 124 | |
124 | - async function handleFetch() { | |
125 | - if (!props.immediate && unref(isFirstLoad)) { | |
126 | - await fetch(); | |
127 | - isFirstLoad.value = false; | |
125 | + async function handleFetch(visible) { | |
126 | + if (visible) { | |
127 | + if (props.alwaysLoad) { | |
128 | + await fetch(); | |
129 | + } else if (!props.immediate && unref(isFirstLoad)) { | |
130 | + await fetch(); | |
131 | + isFirstLoad.value = false; | |
132 | + } | |
128 | 133 | } |
129 | 134 | } |
130 | 135 | ... | ... |