From 8488933ec40731d0e33e3baf6661d5fe3aeb9e8a Mon Sep 17 00:00:00 2001 From: xingyu Date: Tue, 3 Jan 2023 16:35:07 +0800 Subject: [PATCH] refactor: Xtable --- .../src/views/system/dict/index.vue | 43 ++++++------------- 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/yudao-ui-admin-vue3/src/views/system/dict/index.vue b/yudao-ui-admin-vue3/src/views/system/dict/index.vue index 2f0a83243..82bdb3f01 100644 --- a/yudao-ui-admin-vue3/src/views/system/dict/index.vue +++ b/yudao-ui-admin-vue3/src/views/system/dict/index.vue @@ -7,12 +7,7 @@ 字典分类 - + - + @@ -55,7 +50,7 @@
- + - +
@@ -130,8 +125,8 @@ import { ref, unref, reactive } from 'vue' import { useI18n } from '@/hooks/web/useI18n' import { useMessage } from '@/hooks/web/useMessage' -import { useVxeGrid } from '@/hooks/web/useVxeGrid' -import { VxeGridInstance, VxeTableEvents } from 'vxe-table' +import { useXTable } from '@/hooks/web/useXTable' +import { VxeTableEvents } from 'vxe-table' import { FormExpose } from '@/components/Form' import { ElInput, ElTag, ElCard } from 'element-plus' import * as DictTypeSchemas from './dict.type' @@ -143,28 +138,18 @@ import { DictDataVO, DictTypeVO } from '@/api/system/dict/types' const { t } = useI18n() // 国际化 const message = useMessage() // 消息弹窗 -const xTypeGrid = ref() // 列表 Grid Ref -const { - gridOptions: typeGridOptions, - getList: typeGetList, - deleteData: typeDeleteData -} = useVxeGrid({ +const [registerType, { reload: typeGetList, deleteData: typeDeleteData }] = useXTable({ allSchemas: DictTypeSchemas.allSchemas, getListApi: DictTypeApi.getDictTypePageApi, deleteApi: DictTypeApi.deleteDictTypeApi }) -const xDataGrid = ref() // 列表 Grid Ref const queryParams = reactive({ dictType: null }) -const { - gridOptions: dataGridOptions, - getList: dataGetList, - deleteData: dataDeleteData -} = useVxeGrid({ +const [registerData, { reload: dataGetList, deleteData: dataDeleteData }] = useXTable({ allSchemas: DictDataSchemas.allSchemas, - queryParams: queryParams, + params: queryParams, getListApi: DictDataApi.getDictDataPageApi, deleteApi: DictDataApi.deleteDictDataApi }) @@ -199,7 +184,7 @@ const tableTypeSelect = ref(false) const cellClickEvent: VxeTableEvents.CellClick = async ({ row }) => { tableTypeSelect.value = true queryParams.dictType = row['type'] - await dataGetList(xDataGrid) + await dataGetList() parentType.value = row['type'] } // 弹出框 @@ -219,11 +204,11 @@ const setDialogTile = (type: string) => { // 删除操作 const handleTypeDelete = async (rowId: number) => { - await typeDeleteData(xTypeGrid, rowId) + await typeDeleteData(rowId) } const handleDataDelete = async (rowId: number) => { - await dataDeleteData(xDataGrid, rowId) + await dataDeleteData(rowId) } // 提交按钮 @@ -247,7 +232,7 @@ const submitTypeForm = async () => { dialogVisible.value = false } finally { actionLoading.value = false - typeGetList(xTypeGrid) + typeGetList() } } }) @@ -272,7 +257,7 @@ const submitDataForm = async () => { dialogVisible.value = false } finally { actionLoading.value = false - dataGetList(xDataGrid) + dataGetList() } } })