From 3d4171a7f711f4b6dd587e43784e537ca41eb55c Mon Sep 17 00:00:00 2001 From: Donald Yang Date: Tue, 8 Oct 2024 20:47:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E8=87=AA=E5=8A=A8=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E4=BC=98=E5=8C=96=20(#435)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../edit/modules/contentModule/SavePanel.vue | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/web/src/management/pages/edit/modules/contentModule/SavePanel.vue b/web/src/management/pages/edit/modules/contentModule/SavePanel.vue index 59044bf8..345515b9 100644 --- a/web/src/management/pages/edit/modules/contentModule/SavePanel.vue +++ b/web/src/management/pages/edit/modules/contentModule/SavePanel.vue @@ -8,7 +8,7 @@ {{ saveText }} - + @@ -99,20 +99,23 @@ const triggerAutoSave = () => { isShowAutoSave.value = true nextTick(async () => { try { - const res: any = await handleSave() - if (res.code === 200) { - autoSaveStatus.value = 'succeed' - } else { - autoSaveStatus.value = 'failed' + const res: any = await doSave() + if (res !== undefined) { + if (res.code === 200) { + autoSaveStatus.value = 'succeed' + } else { + autoSaveStatus.value = 'failed' + } + isShowAutoSave.value = true } - + } catch (err) { + autoSaveStatus.value = 'failed' + isShowAutoSave.value = true + } finally { setTimeout(() => { isShowAutoSave.value = false timerHandle.value = null }, 300) - } catch (err) { - autoSaveStatus.value = 'failed' - isShowAutoSave.value = true } }) }, 2000) @@ -120,6 +123,17 @@ const triggerAutoSave = () => { } const handleSave = async () => { + const res: any = await doSave() + if (res !== undefined && res.code === 200) { + ElMessage.success('保存成功') + } +} + +/** + * 保存问卷 + * @return 无返回时说明保存失败并由函数内部完成统一提示,有返回时,code为200为保存成功,不为200时,使用errmsg由外部实现错误信息展示 + */ +const doSave = async () => { if (isSaving.value) { return } @@ -141,7 +155,6 @@ const handleSave = async () => { return } if (res.code === 200) { - ElMessage.success('保存成功') return res } else if (res.code === 3006) { ElMessageBox.alert(res.errmsg, '提示', {