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