Commit 414c191472f3713380db3c483ffeea0ff70c7fa5

Authored by xingyu4j
1 parent d2a4eb92

perf: post

yudao-ui-admin-vue3/src/views/system/dict/index.vue
... ... @@ -113,19 +113,21 @@
113 113 </Table>
114 114 </div>
115 115 </el-card>
116   - <Dialog v-model="dialogVisible" :title="dialogTitle">
117   - <Form
118   - v-if="['typeCreate', 'typeUpdate'].includes(actionType)"
119   - :schema="DictTypeSchemas.allSchemas.formSchema"
120   - :rules="DictTypeSchemas.dictTypeRules"
121   - ref="typeFormRef"
122   - />
123   - <Form
124   - v-if="['dataCreate', 'dataUpdate'].includes(actionType)"
125   - :schema="DictDataSchemas.allSchemas.formSchema"
126   - :rules="DictDataSchemas.dictDataRules"
127   - ref="dataFormRef"
128   - />
  116 + <XModal id="dictModel" v-model="dialogVisible" :title="dialogTitle">
  117 + <template #default>
  118 + <Form
  119 + v-if="['typeCreate', 'typeUpdate'].includes(actionType)"
  120 + :schema="DictTypeSchemas.allSchemas.formSchema"
  121 + :rules="DictTypeSchemas.dictTypeRules"
  122 + ref="typeFormRef"
  123 + />
  124 + <Form
  125 + v-if="['dataCreate', 'dataUpdate'].includes(actionType)"
  126 + :schema="DictDataSchemas.allSchemas.formSchema"
  127 + :rules="DictDataSchemas.dictDataRules"
  128 + ref="dataFormRef"
  129 + />
  130 + </template>
129 131 <!-- 操作按钮 -->
130 132 <template #footer>
131 133 <XButton
... ... @@ -144,7 +146,7 @@
144 146 />
145 147 <XButton :title="t('dialog.close')" @click="dialogVisible = false" />
146 148 </template>
147   - </Dialog>
  149 + </XModal>
148 150 </div>
149 151 </template>
150 152 <script setup lang="ts">
... ...
yudao-ui-admin-vue3/src/views/system/post/index.vue
... ... @@ -79,35 +79,31 @@ import { rules, allSchemas } from &#39;./post.data&#39;
79 79 import { useI18n } from '@/hooks/web/useI18n'
80 80 import { useMessage } from '@/hooks/web/useMessage'
81 81 import { useVxeGrid } from '@/hooks/web/useVxeGrid'
82   -import { VxeFormEvents, VxeGridInstance } from 'vxe-table'
  82 +import { VxeGridInstance } from 'vxe-table'
83 83 import { FormExpose } from '@/components/Form'
84 84  
85 85 const { t } = useI18n() // 国际化
86 86 const message = useMessage() // 消息弹窗
87   -const xGrid = ref<VxeGridInstance>()
88   -const formRef = ref<FormExpose>() // 表单 Ref
89 87 const dialogVisible = ref(false) // 是否显示弹出层
90 88 const dialogTitle = ref('edit') // 弹出层标题
91 89 const actionType = ref('') // 操作按钮的类型
92 90 const actionLoading = ref(false) // 按钮Loading
  91 +const xGrid = ref<VxeGridInstance>() // grid Ref
  92 +const formRef = ref<FormExpose>() // 表单 Ref
  93 +const detailRef = ref() // 详情 Ref
93 94  
94 95 const { gridOptions } = useVxeGrid<PostVO>({
95 96 allSchemas: allSchemas,
96 97 getListApi: PostApi.getPostPageApi
97 98 })
  99 +
98 100 // 设置标题
99 101 const setDialogTile = (type: string) => {
100 102 dialogTitle.value = t('action.' + type)
101 103 actionType.value = type
102 104 dialogVisible.value = true
103 105 }
104   -// ========== 详情相关 ==========
105   -const detailRef = ref() // 详情 Ref
106   -// 详情操作
107   -const handleDetail = (row: PostVO) => {
108   - setDialogTile('detail')
109   - detailRef.value = row
110   -}
  106 +
111 107 // 新增操作
112 108 const handleCreate = () => {
113 109 setDialogTile('create')
... ... @@ -115,6 +111,12 @@ const handleCreate = () =&gt; {
115 111 unref(formRef)?.getElFormRef()?.resetFields()
116 112 }
117 113  
  114 +// 详情操作
  115 +const handleDetail = (row: PostVO) => {
  116 + setDialogTile('detail')
  117 + detailRef.value = row
  118 +}
  119 +
118 120 // 修改操作
119 121 const handleUpdate = async (rowId: number) => {
120 122 setDialogTile('update')
... ... @@ -122,6 +124,7 @@ const handleUpdate = async (rowId: number) =&gt; {
122 124 const res = await PostApi.getPostApi(rowId)
123 125 unref(formRef)?.setValues(res)
124 126 }
  127 +
125 128 // 删除操作
126 129 const handleDelete = async (rowId: number) => {
127 130 message
... ... @@ -134,8 +137,9 @@ const handleDelete = async (rowId: number) =&gt; {
134 137 xGrid.value?.commitProxy('query')
135 138 })
136 139 }
  140 +
137 141 // 提交按钮
138   -const submitForm: VxeFormEvents.Submit = async () => {
  142 +const submitForm = async () => {
139 143 const elForm = unref(formRef)?.getElFormRef()
140 144 if (!elForm) return
141 145 elForm.validate(async (valid) => {
... ... @@ -151,7 +155,6 @@ const submitForm: VxeFormEvents.Submit = async () =&gt; {
151 155 await PostApi.updatePostApi(data)
152 156 message.success(t('common.updateSuccess'))
153 157 }
154   - // 操作成功,重新加载列表
155 158 dialogVisible.value = false
156 159 } finally {
157 160 actionLoading.value = false
... ...
yudao-ui-admin-vue3/src/views/system/post/post.data.ts
1 1 import { reactive } from 'vue'
2 2 import { useI18n } from '@/hooks/web/useI18n'
3 3 import { required } from '@/utils/formRules'
4   -import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas'
5 4 import { DICT_TYPE } from '@/utils/dict'
  5 +import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas'
6 6 const { t } = useI18n() // 国际化
7 7  
8 8 // 表单校验
... ...