chore: improve loading state management in ToolFormDrawer
Some checks are pending
sync2gitee / repo-sync (push) Waiting to run
Typos Check / Spell Check with Typos (push) Waiting to run

--bug=1062445 --user=刘瑞斌 【工具】创建工具完成后,在抽屉收起前可以再次点击创建,导致可重复创建工具 https://www.tapd.cn/62980211/s/1781953
This commit is contained in:
CaptainB 2025-10-09 11:10:13 +08:00
parent 9406a2c1da
commit 36636f2707

View File

@ -415,9 +415,10 @@ const submit = async (formEl: FormInstance | undefined) => {
if (!formEl) return
await formEl.validate((valid: any) => {
if (valid) {
loading.value = true
if (isEdit.value) {
loadSharedApi({ type: 'tool', systemType: apiType.value })
.putTool(form.value?.id as string, form.value, loading)
.putTool(form.value?.id as string, form.value)
.then((res: any) => {
MsgSuccess(t('common.editSuccess'))
emit('refresh', res.data)
@ -426,13 +427,16 @@ const submit = async (formEl: FormInstance | undefined) => {
.then(() => {
visible.value = false
})
.finally(() => {
loading.value = false
})
} else {
const obj = {
folder_id: folder.currentFolder?.id,
...form.value,
}
loadSharedApi({ type: 'tool', systemType: apiType.value })
.postTool(obj, loading)
.postTool(obj)
.then((res: any) => {
MsgSuccess(t('common.createSuccess'))
emit('refresh')
@ -441,6 +445,9 @@ const submit = async (formEl: FormInstance | undefined) => {
.then(() => {
visible.value = false
})
.finally(() => {
loading.value = false
})
}
}
})