pull/229/head
xiaojunnuo 2024-10-24 12:10:20 +08:00
parent d782655cb4
commit a3ef3fb5cf
1 changed files with 27 additions and 15 deletions

View File

@ -12,10 +12,10 @@
@update:value="emit('update:value', $event)"
/>
<div class="ml-5">
<fs-button title="刷新选项" icon="ion:refresh-outline" @click="refreshOptions"></fs-button>
<fs-button :loading="loading" title="刷新选项" icon="ion:refresh-outline" @click="refreshOptions"></fs-button>
</div>
</div>
<div class="helper error">
<div class="helper" :class="{ error: hasError }">
{{ message }}
</div>
</div>
@ -42,8 +42,13 @@ const attrs = useAttrs();
const optionsRef = ref([]);
const message = ref("");
const hasError = ref(false);
const loading = ref(false);
const getOptions = async () => {
message.value = "";
hasError.value = false;
loading.value = true;
try {
const res = await doRequest(
{
type: props.type,
@ -53,12 +58,19 @@ const getOptions = async () => {
},
{
onError(err: any) {
hasError.value = true;
message.value = `获取选项出错:${err.message}`;
},
showErrorNotify: false
}
);
if (res && res.length > 0) {
message.value = "获取数据成功,请从下拉框中选择";
}
return res;
} finally {
loading.value = false;
}
};
const filterOption = (input: string, option: any) => {