fix: 通知管理新增编辑优化

This commit is contained in:
JiangQiming 2023-01-31 14:24:54 +08:00
parent 0189595c99
commit 4ea899f874
2 changed files with 32 additions and 19 deletions

View File

@ -311,31 +311,42 @@ const msgType = ref([
// //
const formData = ref<ConfigFormData>({ const formData = ref<ConfigFormData>({
configuration: { configuration: {
appKey: '', host: '',
appSecret: '', port: 25,
ssl: false,
sender: '',
username: '',
password: '',
}, },
description: '', description: '',
name: '', name: '',
provider: 'dingTalkMessage', provider: 'embedded',
type: 'dingTalk', type: 'email',
}); });
// //
watch( watch(
() => formData.value.type, () => formData.value.type,
(val) => { (val) => {
// formData.value.configuration = Object.values<any>(CONFIG_FIELD_MAP[val])[0];
msgType.value = MSG_TYPE[val]; msgType.value = MSG_TYPE[val];
formData.value.provider = msgType.value[0].value; formData.value.provider = msgType.value[0].value;
formData.value.configuration =
CONFIG_FIELD_MAP[val][formData.value.provider];
clearValid();
}, },
); );
computed(() => watch(
Object.assign( () => formData.value.provider,
formData.value.configuration, (val) => {
CONFIG_FIELD_MAP[formData.value.type][formData.value.provider], formData.value.configuration =
), CONFIG_FIELD_MAP[formData.value.type][val];
clearValid();
},
); );
// //
@ -405,15 +416,15 @@ const { resetFields, validate, validateInfos, clearValidate } = useForm(
formData.value, formData.value,
formRules.value, formRules.value,
); );
watch(
() => formData.value.type, const clearValid = () => {
() => { setTimeout(() => {
clearValidate(); clearValidate();
}, }, 200);
{ deep: true }, };
);
const getDetail = async () => { const getDetail = async () => {
if (route.params.id === ':id') return;
const res = await configApi.detail(route.params.id as string); const res = await configApi.detail(route.params.id as string);
// console.log('res: ', res); // console.log('res: ', res);
formData.value = res.result; formData.value = res.result;
@ -441,10 +452,12 @@ const handleSubmit = () => {
message.success('保存成功'); message.success('保存成功');
router.back(); router.back();
} }
btnLoading.value = false;
}) })
.catch((err) => { .catch((err) => {
console.log('err: ', err); console.log('err: ', err);
})
.finally(() => {
btnLoading.value = false;
}); });
}; };
</script> </script>

View File

@ -256,7 +256,7 @@ const getMethodTxt = (type: string) => {
* 新增 * 新增
*/ */
const handleAdd = () => { const handleAdd = () => {
router.push(`/notice/Config/detail/:id`); router.push(`/notice/Template/detail/:id`);
}; };
/** /**
@ -323,7 +323,7 @@ const getActions = (
onClick: () => { onClick: () => {
// visible.value = true; // visible.value = true;
// current.value = data; // current.value = data;
router.push(`/notice/Config/detail/${data.id}`); router.push(`/notice/Template/detail/${data.id}`);
}, },
}, },
{ {