瀏覽代碼

perf: post

xingyu4j 2 年之前
父節點
當前提交
414c191472

+ 16 - 14
yudao-ui-admin-vue3/src/views/system/dict/index.vue

@@ -113,19 +113,21 @@
         </Table>
         </Table>
       </div>
       </div>
     </el-card>
     </el-card>
-    <Dialog v-model="dialogVisible" :title="dialogTitle">
-      <Form
-        v-if="['typeCreate', 'typeUpdate'].includes(actionType)"
-        :schema="DictTypeSchemas.allSchemas.formSchema"
-        :rules="DictTypeSchemas.dictTypeRules"
-        ref="typeFormRef"
-      />
-      <Form
-        v-if="['dataCreate', 'dataUpdate'].includes(actionType)"
-        :schema="DictDataSchemas.allSchemas.formSchema"
-        :rules="DictDataSchemas.dictDataRules"
-        ref="dataFormRef"
-      />
+    <XModal id="dictModel" v-model="dialogVisible" :title="dialogTitle">
+      <template #default>
+        <Form
+          v-if="['typeCreate', 'typeUpdate'].includes(actionType)"
+          :schema="DictTypeSchemas.allSchemas.formSchema"
+          :rules="DictTypeSchemas.dictTypeRules"
+          ref="typeFormRef"
+        />
+        <Form
+          v-if="['dataCreate', 'dataUpdate'].includes(actionType)"
+          :schema="DictDataSchemas.allSchemas.formSchema"
+          :rules="DictDataSchemas.dictDataRules"
+          ref="dataFormRef"
+        />
+      </template>
       <!-- 操作按钮 -->
       <!-- 操作按钮 -->
       <template #footer>
       <template #footer>
         <XButton
         <XButton
@@ -144,7 +146,7 @@
         />
         />
         <XButton :title="t('dialog.close')" @click="dialogVisible = false" />
         <XButton :title="t('dialog.close')" @click="dialogVisible = false" />
       </template>
       </template>
-    </Dialog>
+    </XModal>
   </div>
   </div>
 </template>
 </template>
 <script setup lang="ts">
 <script setup lang="ts">

+ 15 - 12
yudao-ui-admin-vue3/src/views/system/post/index.vue

@@ -79,35 +79,31 @@ import { rules, allSchemas } from './post.data'
 import { useI18n } from '@/hooks/web/useI18n'
 import { useI18n } from '@/hooks/web/useI18n'
 import { useMessage } from '@/hooks/web/useMessage'
 import { useMessage } from '@/hooks/web/useMessage'
 import { useVxeGrid } from '@/hooks/web/useVxeGrid'
 import { useVxeGrid } from '@/hooks/web/useVxeGrid'
-import { VxeFormEvents, VxeGridInstance } from 'vxe-table'
+import { VxeGridInstance } from 'vxe-table'
 import { FormExpose } from '@/components/Form'
 import { FormExpose } from '@/components/Form'
 
 
 const { t } = useI18n() // 国际化
 const { t } = useI18n() // 国际化
 const message = useMessage() // 消息弹窗
 const message = useMessage() // 消息弹窗
-const xGrid = ref<VxeGridInstance>()
-const formRef = ref<FormExpose>() // 表单 Ref
 const dialogVisible = ref(false) // 是否显示弹出层
 const dialogVisible = ref(false) // 是否显示弹出层
 const dialogTitle = ref('edit') // 弹出层标题
 const dialogTitle = ref('edit') // 弹出层标题
 const actionType = ref('') // 操作按钮的类型
 const actionType = ref('') // 操作按钮的类型
 const actionLoading = ref(false) // 按钮Loading
 const actionLoading = ref(false) // 按钮Loading
+const xGrid = ref<VxeGridInstance>() // grid Ref
+const formRef = ref<FormExpose>() // 表单 Ref
+const detailRef = ref() // 详情 Ref
 
 
 const { gridOptions } = useVxeGrid<PostVO>({
 const { gridOptions } = useVxeGrid<PostVO>({
   allSchemas: allSchemas,
   allSchemas: allSchemas,
   getListApi: PostApi.getPostPageApi
   getListApi: PostApi.getPostPageApi
 })
 })
+
 // 设置标题
 // 设置标题
 const setDialogTile = (type: string) => {
 const setDialogTile = (type: string) => {
   dialogTitle.value = t('action.' + type)
   dialogTitle.value = t('action.' + type)
   actionType.value = type
   actionType.value = type
   dialogVisible.value = true
   dialogVisible.value = true
 }
 }
-// ========== 详情相关 ==========
-const detailRef = ref() // 详情 Ref
-// 详情操作
-const handleDetail = (row: PostVO) => {
-  setDialogTile('detail')
-  detailRef.value = row
-}
+
 // 新增操作
 // 新增操作
 const handleCreate = () => {
 const handleCreate = () => {
   setDialogTile('create')
   setDialogTile('create')
@@ -115,6 +111,12 @@ const handleCreate = () => {
   unref(formRef)?.getElFormRef()?.resetFields()
   unref(formRef)?.getElFormRef()?.resetFields()
 }
 }
 
 
+// 详情操作
+const handleDetail = (row: PostVO) => {
+  setDialogTile('detail')
+  detailRef.value = row
+}
+
 // 修改操作
 // 修改操作
 const handleUpdate = async (rowId: number) => {
 const handleUpdate = async (rowId: number) => {
   setDialogTile('update')
   setDialogTile('update')
@@ -122,6 +124,7 @@ const handleUpdate = async (rowId: number) => {
   const res = await PostApi.getPostApi(rowId)
   const res = await PostApi.getPostApi(rowId)
   unref(formRef)?.setValues(res)
   unref(formRef)?.setValues(res)
 }
 }
+
 // 删除操作
 // 删除操作
 const handleDelete = async (rowId: number) => {
 const handleDelete = async (rowId: number) => {
   message
   message
@@ -134,8 +137,9 @@ const handleDelete = async (rowId: number) => {
       xGrid.value?.commitProxy('query')
       xGrid.value?.commitProxy('query')
     })
     })
 }
 }
+
 // 提交按钮
 // 提交按钮
-const submitForm: VxeFormEvents.Submit = async () => {
+const submitForm = async () => {
   const elForm = unref(formRef)?.getElFormRef()
   const elForm = unref(formRef)?.getElFormRef()
   if (!elForm) return
   if (!elForm) return
   elForm.validate(async (valid) => {
   elForm.validate(async (valid) => {
@@ -151,7 +155,6 @@ const submitForm: VxeFormEvents.Submit = async () => {
           await PostApi.updatePostApi(data)
           await PostApi.updatePostApi(data)
           message.success(t('common.updateSuccess'))
           message.success(t('common.updateSuccess'))
         }
         }
-        // 操作成功,重新加载列表
         dialogVisible.value = false
         dialogVisible.value = false
       } finally {
       } finally {
         actionLoading.value = false
         actionLoading.value = false

+ 1 - 1
yudao-ui-admin-vue3/src/views/system/post/post.data.ts

@@ -1,8 +1,8 @@
 import { reactive } from 'vue'
 import { reactive } from 'vue'
 import { useI18n } from '@/hooks/web/useI18n'
 import { useI18n } from '@/hooks/web/useI18n'
 import { required } from '@/utils/formRules'
 import { required } from '@/utils/formRules'
-import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas'
 import { DICT_TYPE } from '@/utils/dict'
 import { DICT_TYPE } from '@/utils/dict'
+import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas'
 const { t } = useI18n() // 国际化
 const { t } = useI18n() // 国际化
 
 
 // 表单校验
 // 表单校验