Commit ceeeec1cfdcaf25256bb7bf762ac1bf64d9e2e70

Authored by YunaiV
1 parent c6a445c4

vue3:测试 notice 模块,通过

yudao-ui-admin-vue3/src/views/system/notice/index.vue
1 1 <template>
2 2 <ContentWrap>
  3 + <!-- 列表 -->
3 4 <vxe-grid ref="xGrid" v-bind="gridOptions" class="xtable-scrollbar">
  5 + <!-- 操作:新增 -->
4 6 <template #toolbar_buttons>
5 7 <XButton
6 8 type="primary"
... ... @@ -11,18 +13,21 @@
11 13 />
12 14 </template>
13 15 <template #actionbtns_default="{ row }">
  16 + <!-- 操作:修改 -->
14 17 <XTextButton
15 18 preIcon="ep:edit"
16 19 :title="t('action.edit')"
17 20 v-hasPermi="['system:notice:update']"
18 21 @click="handleUpdate(row.id)"
19 22 />
  23 + <!-- 操作:详情 -->
20 24 <XTextButton
21 25 preIcon="ep:view"
22 26 :title="t('action.detail')"
23 27 v-hasPermi="['system:notice:update']"
24 28 @click="handleDetail(row.id)"
25 29 />
  30 + <!-- 操作:删除 -->
26 31 <XTextButton
27 32 preIcon="ep:delete"
28 33 :title="t('action.del')"
... ... @@ -32,6 +37,7 @@
32 37 </template>
33 38 </vxe-grid>
34 39 </ContentWrap>
  40 + <!-- 弹窗 -->
35 41 <XModal id="noticeModel" v-model="dialogVisible" :title="dialogTitle">
36 42 <template #default>
37 43 <!-- 对话框(添加 / 修改) -->
... ... @@ -48,8 +54,8 @@
48 54 :data="detailRef"
49 55 />
50 56 </template>
51   - <!-- 操作按钮 -->
52 57 <template #footer>
  58 + <!-- 按钮:保存 -->
53 59 <XButton
54 60 v-if="['create', 'update'].includes(actionType)"
55 61 type="primary"
... ... @@ -57,34 +63,36 @@
57 63 :loading="actionLoading"
58 64 @click="submitForm"
59 65 />
  66 + <!-- 按钮:关闭 -->
60 67 <XButton :loading="actionLoading" :title="t('dialog.close')" @click="dialogVisible = false" />
61 68 </template>
62 69 </XModal>
63 70 </template>
64 71 <script setup lang="ts">
  72 +// 全局相关的 import
65 73 import { ref, unref } from 'vue'
66 74 import { useI18n } from '@/hooks/web/useI18n'
67 75 import { useMessage } from '@/hooks/web/useMessage'
68 76 import { useVxeGrid } from '@/hooks/web/useVxeGrid'
69 77 import { VxeGridInstance } from 'vxe-table'
70 78 import { FormExpose } from '@/components/Form'
71   -
  79 +// 业务相关的 import
72 80 import * as NoticeApi from '@/api/system/notice'
73 81 import { rules, allSchemas } from './notice.data'
74 82  
75 83 const { t } = useI18n() // 国际化
76 84 const message = useMessage() // 消息弹窗
77   -
78   -const xGrid = ref<VxeGridInstance>() // grid Ref
  85 +// 列表相关的变量
  86 +const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
79 87 const { gridOptions } = useVxeGrid<NoticeApi.NoticeVO>({
80 88 allSchemas: allSchemas,
81 89 getListApi: NoticeApi.getNoticePageApi
82 90 })
83   -
  91 +// 弹窗相关的变量
84 92 const dialogVisible = ref(false) // 是否显示弹出层
85 93 const dialogTitle = ref('edit') // 弹出层标题
86 94 const actionType = ref('') // 操作按钮的类型
87   -const actionLoading = ref(false) // 按钮Loading
  95 +const actionLoading = ref(false) // 按钮 Loading
88 96 const formRef = ref<FormExpose>() // 表单 Ref
89 97 const detailRef = ref() // 详情 Ref
90 98  
... ... @@ -127,11 +135,12 @@ const handleDelete = async (rowId: number) =&gt; {
127 135 message.success(t('common.delSuccess'))
128 136 })
129 137 .finally(() => {
  138 + // 刷新列表
130 139 xGrid.value?.commitProxy('query')
131 140 })
132 141 }
133 142  
134   -// 提交按钮
  143 +// 提交新增/修改的表单
135 144 const submitForm = async () => {
136 145 const elForm = unref(formRef)?.getElFormRef()
137 146 if (!elForm) return
... ... @@ -151,6 +160,7 @@ const submitForm = async () =&gt; {
151 160 dialogVisible.value = false
152 161 } finally {
153 162 actionLoading.value = false
  163 + // 刷新列表
154 164 xGrid.value?.commitProxy('query')
155 165 }
156 166 }
... ...