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