Commit df8a0768ea0a734d0ee84e18e4e2badea90e94fe
1 parent
f352c4d9
feat: vue3 代码生成
Showing
1 changed file
with
7 additions
and
9 deletions
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm
| 1 | 1 | <template> |
| 2 | 2 | <ContentWrap> |
| 3 | 3 | <!-- 列表 --> |
| 4 | - <vxe-grid ref="xGrid" v-bind="gridOptions" class="xtable-scrollbar"> | |
| 4 | + <XTable @register="registerTable"> | |
| 5 | 5 | <template #toolbar_buttons> |
| 6 | 6 | <!-- 操作:新增 --> |
| 7 | 7 | <XButton |
| ... | ... | @@ -43,7 +43,7 @@ |
| 43 | 43 | @click="handleDelete(row.id)" |
| 44 | 44 | /> |
| 45 | 45 | </template> |
| 46 | - </vxe-grid> | |
| 46 | + </XTable> | |
| 47 | 47 | </ContentWrap> |
| 48 | 48 | <!-- 弹窗 --> |
| 49 | 49 | <XModal id="${classNameVar}Model" :loading="modelLoading" v-model="modelVisible" :title="modelTitle"> |
| ... | ... | @@ -79,8 +79,7 @@ |
| 79 | 79 | import { ref, unref } from 'vue' |
| 80 | 80 | import { useI18n } from '@/hooks/web/useI18n' |
| 81 | 81 | import { useMessage } from '@/hooks/web/useMessage' |
| 82 | -import { useVxeGrid } from '@/hooks/web/useVxeGrid' | |
| 83 | -import { VxeGridInstance } from 'vxe-table' | |
| 82 | +import { useXTable } from '@/hooks/web/useXTable' | |
| 84 | 83 | import { FormExpose } from '@/components/Form' |
| 85 | 84 | // 业务相关的 import |
| 86 | 85 | import { rules, allSchemas } from './${classNameVar}.data' |
| ... | ... | @@ -90,8 +89,7 @@ const { t } = useI18n() // 国际化 |
| 90 | 89 | const message = useMessage() // 消息弹窗 |
| 91 | 90 | |
| 92 | 91 | // 列表相关的变量 |
| 93 | -const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref | |
| 94 | -const { gridOptions, getList, deleteData, exportList } = useVxeGrid<${simpleClassName}Api.${simpleClassName}VO>({ | |
| 92 | +const [registerTable, { reload, deleteData, exportList }] = useXTable({ | |
| 95 | 93 | allSchemas: allSchemas, |
| 96 | 94 | getListApi: ${simpleClassName}Api.get${simpleClassName}PageApi, |
| 97 | 95 | deleteApi: ${simpleClassName}Api.delete${simpleClassName}Api, |
| ... | ... | @@ -123,7 +121,7 @@ const handleCreate = () => { |
| 123 | 121 | |
| 124 | 122 | // 导出操作 |
| 125 | 123 | const handleExport = async () => { |
| 126 | - await exportList(xGrid, '${table.classComment}.xls') | |
| 124 | + await exportList('${table.classComment}.xls') | |
| 127 | 125 | } |
| 128 | 126 | |
| 129 | 127 | // 修改操作 |
| ... | ... | @@ -145,7 +143,7 @@ const handleDetail = async (rowId: number) => { |
| 145 | 143 | |
| 146 | 144 | // 删除操作 |
| 147 | 145 | const handleDelete = async (rowId: number) => { |
| 148 | - await deleteData(xGrid, rowId) | |
| 146 | + await deleteData(rowId) | |
| 149 | 147 | } |
| 150 | 148 | |
| 151 | 149 | // 提交按钮 |
| ... | ... | @@ -169,7 +167,7 @@ const submitForm = async () => { |
| 169 | 167 | } finally { |
| 170 | 168 | actionLoading.value = false |
| 171 | 169 | // 刷新列表 |
| 172 | - await getList(xGrid) | |
| 170 | + await reload() | |
| 173 | 171 | } |
| 174 | 172 | } |
| 175 | 173 | }) | ... | ... |