From 4ea899f874b30fd7e59c064cd61e98ec963f0369 Mon Sep 17 00:00:00 2001 From: JiangQiming <291854119@qq.com> Date: Tue, 31 Jan 2023 14:24:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=80=9A=E7=9F=A5=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=BC=96=E8=BE=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/notice/Config/Detail/index.vue | 47 +++++++++++++++--------- src/views/notice/Template/index.vue | 4 +- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/src/views/notice/Config/Detail/index.vue b/src/views/notice/Config/Detail/index.vue index 700c6d89..abfc22a5 100644 --- a/src/views/notice/Config/Detail/index.vue +++ b/src/views/notice/Config/Detail/index.vue @@ -311,31 +311,42 @@ const msgType = ref([ // 表单数据 const formData = ref({ configuration: { - appKey: '', - appSecret: '', + host: '', + port: 25, + ssl: false, + sender: '', + username: '', + password: '', }, description: '', name: '', - provider: 'dingTalkMessage', - type: 'dingTalk', + provider: 'embedded', + type: 'email', }); // 根据通知方式展示对应的字段 watch( () => formData.value.type, (val) => { - // formData.value.configuration = Object.values(CONFIG_FIELD_MAP[val])[0]; msgType.value = MSG_TYPE[val]; formData.value.provider = msgType.value[0].value; + + formData.value.configuration = + CONFIG_FIELD_MAP[val][formData.value.provider]; + + clearValid(); }, ); -computed(() => - Object.assign( - formData.value.configuration, - CONFIG_FIELD_MAP[formData.value.type][formData.value.provider], - ), +watch( + () => formData.value.provider, + (val) => { + formData.value.configuration = + CONFIG_FIELD_MAP[formData.value.type][val]; + + clearValid(); + }, ); // 验证规则 @@ -405,15 +416,15 @@ const { resetFields, validate, validateInfos, clearValidate } = useForm( formData.value, formRules.value, ); -watch( - () => formData.value.type, - () => { + +const clearValid = () => { + setTimeout(() => { clearValidate(); - }, - { deep: true }, -); + }, 200); +}; const getDetail = async () => { + if (route.params.id === ':id') return; const res = await configApi.detail(route.params.id as string); // console.log('res: ', res); formData.value = res.result; @@ -441,10 +452,12 @@ const handleSubmit = () => { message.success('保存成功'); router.back(); } - btnLoading.value = false; }) .catch((err) => { console.log('err: ', err); + }) + .finally(() => { + btnLoading.value = false; }); }; diff --git a/src/views/notice/Template/index.vue b/src/views/notice/Template/index.vue index 7af08260..87c20444 100644 --- a/src/views/notice/Template/index.vue +++ b/src/views/notice/Template/index.vue @@ -256,7 +256,7 @@ const getMethodTxt = (type: string) => { * 新增 */ const handleAdd = () => { - router.push(`/notice/Config/detail/:id`); + router.push(`/notice/Template/detail/:id`); }; /** @@ -323,7 +323,7 @@ const getActions = ( onClick: () => { // visible.value = true; // current.value = data; - router.push(`/notice/Config/detail/${data.id}`); + router.push(`/notice/Template/detail/${data.id}`); }, }, {