mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 23:31:52 +08:00
refactor: Xtable
This commit is contained in:
parent
f2d2dc4d9e
commit
8488933ec4
@ -7,12 +7,7 @@
|
||||
<span>字典分类</span>
|
||||
</div>
|
||||
</template>
|
||||
<vxe-grid
|
||||
ref="xTypeGrid"
|
||||
v-bind="typeGridOptions"
|
||||
@cell-click="cellClickEvent"
|
||||
class="xtable-scrollbar"
|
||||
>
|
||||
<XTable @register="registerType" @cell-click="cellClickEvent">
|
||||
<!-- 操作:新增类型 -->
|
||||
<template #toolbar_buttons>
|
||||
<XButton
|
||||
@ -39,7 +34,7 @@
|
||||
@click="handleTypeDelete(row.id)"
|
||||
/>
|
||||
</template>
|
||||
</vxe-grid>
|
||||
</XTable>
|
||||
<!-- @星语:分页和列表重叠在一起了 -->
|
||||
</el-card>
|
||||
<!-- ====== 字典数据 ====== -->
|
||||
@ -55,7 +50,7 @@
|
||||
</div>
|
||||
<div v-if="tableTypeSelect">
|
||||
<!-- 列表 -->
|
||||
<vxe-grid ref="xDataGrid" v-bind="dataGridOptions" class="xtable-scrollbar">
|
||||
<XTable @register="registerData">
|
||||
<!-- 操作:新增数据 -->
|
||||
<template #toolbar_buttons>
|
||||
<XButton
|
||||
@ -82,7 +77,7 @@
|
||||
@click="handleDataDelete(row.id)"
|
||||
/>
|
||||
</template>
|
||||
</vxe-grid>
|
||||
</XTable>
|
||||
</div>
|
||||
</el-card>
|
||||
<XModal id="dictModel" v-model="dialogVisible" :title="dialogTitle">
|
||||
@ -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<VxeGridInstance>() // 列表 Grid Ref
|
||||
const {
|
||||
gridOptions: typeGridOptions,
|
||||
getList: typeGetList,
|
||||
deleteData: typeDeleteData
|
||||
} = useVxeGrid<DictTypeVO>({
|
||||
const [registerType, { reload: typeGetList, deleteData: typeDeleteData }] = useXTable({
|
||||
allSchemas: DictTypeSchemas.allSchemas,
|
||||
getListApi: DictTypeApi.getDictTypePageApi,
|
||||
deleteApi: DictTypeApi.deleteDictTypeApi
|
||||
})
|
||||
|
||||
const xDataGrid = ref<VxeGridInstance>() // 列表 Grid Ref
|
||||
const queryParams = reactive({
|
||||
dictType: null
|
||||
})
|
||||
const {
|
||||
gridOptions: dataGridOptions,
|
||||
getList: dataGetList,
|
||||
deleteData: dataDeleteData
|
||||
} = useVxeGrid<DictDataVO>({
|
||||
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()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user