From 563eb8ba906a93b5acdfadd392dc1269f780e174 Mon Sep 17 00:00:00 2001 From: xingyuv Date: Thu, 9 Feb 2023 18:41:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96post=E7=95=8C?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/system/post/PostForm.vue | 37 +++++++++---------- .../src/views/system/post/index.vue | 5 ++- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/yudao-ui-admin-vue3/src/views/system/post/PostForm.vue b/yudao-ui-admin-vue3/src/views/system/post/PostForm.vue index 8b0c646ae..ab3a23afc 100644 --- a/yudao-ui-admin-vue3/src/views/system/post/PostForm.vue +++ b/yudao-ui-admin-vue3/src/views/system/post/PostForm.vue @@ -39,7 +39,7 @@ const emit = defineEmits(['success']) // 弹窗相关的变量 const modelVisible = ref(false) // 是否显示弹出层 -const modelTitle = ref('edit') // 弹出层标题 +const modelTitle = ref('update') // 弹出层标题 const modelLoading = ref(false) // 弹出层loading const actionType = ref('') // 操作按钮的类型 const actionLoading = ref(false) // 按钮 Loading @@ -67,26 +67,25 @@ const openModal = async (type: string, rowId?: number) => { const submitForm = async () => { const elForm = unref(formRef)?.getElFormRef() if (!elForm) return - elForm.validate(async (valid) => { - if (valid) { - actionLoading.value = true - // 提交请求 - try { - const data = unref(formRef)?.formModel as PostApi.PostVO - if (actionType.value === 'create') { - await PostApi.createPostApi(data) - message.success(t('common.createSuccess')) - } else { - await PostApi.updatePostApi(data) - message.success(t('common.updateSuccess')) - } - modelVisible.value = false - emit('success') - } finally { - actionLoading.value = false + const valid = await elForm.validate() + if (valid) { + actionLoading.value = true + // 提交请求 + try { + const data = unref(formRef)?.formModel as PostApi.PostVO + if (actionType.value === 'create') { + await PostApi.createPostApi(data) + message.success(t('common.createSuccess')) + } else { + await PostApi.updatePostApi(data) + message.success(t('common.updateSuccess')) } + modelVisible.value = false + emit('success') + } finally { + actionLoading.value = false } - }) + } } defineExpose({ openModal: openModal }) diff --git a/yudao-ui-admin-vue3/src/views/system/post/index.vue b/yudao-ui-admin-vue3/src/views/system/post/index.vue index 4e61d4a7b..92d4f83cf 100644 --- a/yudao-ui-admin-vue3/src/views/system/post/index.vue +++ b/yudao-ui-admin-vue3/src/views/system/post/index.vue @@ -51,7 +51,7 @@ import { allSchemas } from './post.data' import PostForm from './PostForm.vue' const { t } = useI18n() // 国际化 -const modalRef = ref() + // 列表相关的变量 const [registerTable, { reload, deleteData, exportList }] = useXTable({ allSchemas: allSchemas, @@ -59,7 +59,8 @@ const [registerTable, { reload, deleteData, exportList }] = useXTable({ deleteApi: PostApi.deletePostApi, exportListApi: PostApi.exportPostApi }) - +// 表单相关的变量 +const modalRef = ref() const openModal = (type: string, rowId?: number) => { modalRef.value.openModal(type, rowId) }