mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-26 17:21:53 +08:00
refactor: Xtable
This commit is contained in:
parent
f2d2dc4d9e
commit
8488933ec4
@ -7,12 +7,7 @@
|
|||||||
<span>字典分类</span>
|
<span>字典分类</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<vxe-grid
|
<XTable @register="registerType" @cell-click="cellClickEvent">
|
||||||
ref="xTypeGrid"
|
|
||||||
v-bind="typeGridOptions"
|
|
||||||
@cell-click="cellClickEvent"
|
|
||||||
class="xtable-scrollbar"
|
|
||||||
>
|
|
||||||
<!-- 操作:新增类型 -->
|
<!-- 操作:新增类型 -->
|
||||||
<template #toolbar_buttons>
|
<template #toolbar_buttons>
|
||||||
<XButton
|
<XButton
|
||||||
@ -39,7 +34,7 @@
|
|||||||
@click="handleTypeDelete(row.id)"
|
@click="handleTypeDelete(row.id)"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</vxe-grid>
|
</XTable>
|
||||||
<!-- @星语:分页和列表重叠在一起了 -->
|
<!-- @星语:分页和列表重叠在一起了 -->
|
||||||
</el-card>
|
</el-card>
|
||||||
<!-- ====== 字典数据 ====== -->
|
<!-- ====== 字典数据 ====== -->
|
||||||
@ -55,7 +50,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div v-if="tableTypeSelect">
|
<div v-if="tableTypeSelect">
|
||||||
<!-- 列表 -->
|
<!-- 列表 -->
|
||||||
<vxe-grid ref="xDataGrid" v-bind="dataGridOptions" class="xtable-scrollbar">
|
<XTable @register="registerData">
|
||||||
<!-- 操作:新增数据 -->
|
<!-- 操作:新增数据 -->
|
||||||
<template #toolbar_buttons>
|
<template #toolbar_buttons>
|
||||||
<XButton
|
<XButton
|
||||||
@ -82,7 +77,7 @@
|
|||||||
@click="handleDataDelete(row.id)"
|
@click="handleDataDelete(row.id)"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</vxe-grid>
|
</XTable>
|
||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
<XModal id="dictModel" v-model="dialogVisible" :title="dialogTitle">
|
<XModal id="dictModel" v-model="dialogVisible" :title="dialogTitle">
|
||||||
@ -130,8 +125,8 @@
|
|||||||
import { ref, unref, reactive } from 'vue'
|
import { ref, unref, reactive } from 'vue'
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
import { useI18n } from '@/hooks/web/useI18n'
|
||||||
import { useMessage } from '@/hooks/web/useMessage'
|
import { useMessage } from '@/hooks/web/useMessage'
|
||||||
import { useVxeGrid } from '@/hooks/web/useVxeGrid'
|
import { useXTable } from '@/hooks/web/useXTable'
|
||||||
import { VxeGridInstance, VxeTableEvents } from 'vxe-table'
|
import { VxeTableEvents } from 'vxe-table'
|
||||||
import { FormExpose } from '@/components/Form'
|
import { FormExpose } from '@/components/Form'
|
||||||
import { ElInput, ElTag, ElCard } from 'element-plus'
|
import { ElInput, ElTag, ElCard } from 'element-plus'
|
||||||
import * as DictTypeSchemas from './dict.type'
|
import * as DictTypeSchemas from './dict.type'
|
||||||
@ -143,28 +138,18 @@ import { DictDataVO, DictTypeVO } from '@/api/system/dict/types'
|
|||||||
const { t } = useI18n() // 国际化
|
const { t } = useI18n() // 国际化
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
|
|
||||||
const xTypeGrid = ref<VxeGridInstance>() // 列表 Grid Ref
|
const [registerType, { reload: typeGetList, deleteData: typeDeleteData }] = useXTable({
|
||||||
const {
|
|
||||||
gridOptions: typeGridOptions,
|
|
||||||
getList: typeGetList,
|
|
||||||
deleteData: typeDeleteData
|
|
||||||
} = useVxeGrid<DictTypeVO>({
|
|
||||||
allSchemas: DictTypeSchemas.allSchemas,
|
allSchemas: DictTypeSchemas.allSchemas,
|
||||||
getListApi: DictTypeApi.getDictTypePageApi,
|
getListApi: DictTypeApi.getDictTypePageApi,
|
||||||
deleteApi: DictTypeApi.deleteDictTypeApi
|
deleteApi: DictTypeApi.deleteDictTypeApi
|
||||||
})
|
})
|
||||||
|
|
||||||
const xDataGrid = ref<VxeGridInstance>() // 列表 Grid Ref
|
|
||||||
const queryParams = reactive({
|
const queryParams = reactive({
|
||||||
dictType: null
|
dictType: null
|
||||||
})
|
})
|
||||||
const {
|
const [registerData, { reload: dataGetList, deleteData: dataDeleteData }] = useXTable({
|
||||||
gridOptions: dataGridOptions,
|
|
||||||
getList: dataGetList,
|
|
||||||
deleteData: dataDeleteData
|
|
||||||
} = useVxeGrid<DictDataVO>({
|
|
||||||
allSchemas: DictDataSchemas.allSchemas,
|
allSchemas: DictDataSchemas.allSchemas,
|
||||||
queryParams: queryParams,
|
params: queryParams,
|
||||||
getListApi: DictDataApi.getDictDataPageApi,
|
getListApi: DictDataApi.getDictDataPageApi,
|
||||||
deleteApi: DictDataApi.deleteDictDataApi
|
deleteApi: DictDataApi.deleteDictDataApi
|
||||||
})
|
})
|
||||||
@ -199,7 +184,7 @@ const tableTypeSelect = ref(false)
|
|||||||
const cellClickEvent: VxeTableEvents.CellClick = async ({ row }) => {
|
const cellClickEvent: VxeTableEvents.CellClick = async ({ row }) => {
|
||||||
tableTypeSelect.value = true
|
tableTypeSelect.value = true
|
||||||
queryParams.dictType = row['type']
|
queryParams.dictType = row['type']
|
||||||
await dataGetList(xDataGrid)
|
await dataGetList()
|
||||||
parentType.value = row['type']
|
parentType.value = row['type']
|
||||||
}
|
}
|
||||||
// 弹出框
|
// 弹出框
|
||||||
@ -219,11 +204,11 @@ const setDialogTile = (type: string) => {
|
|||||||
|
|
||||||
// 删除操作
|
// 删除操作
|
||||||
const handleTypeDelete = async (rowId: number) => {
|
const handleTypeDelete = async (rowId: number) => {
|
||||||
await typeDeleteData(xTypeGrid, rowId)
|
await typeDeleteData(rowId)
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleDataDelete = async (rowId: number) => {
|
const handleDataDelete = async (rowId: number) => {
|
||||||
await dataDeleteData(xDataGrid, rowId)
|
await dataDeleteData(rowId)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 提交按钮
|
// 提交按钮
|
||||||
@ -247,7 +232,7 @@ const submitTypeForm = async () => {
|
|||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
} finally {
|
} finally {
|
||||||
actionLoading.value = false
|
actionLoading.value = false
|
||||||
typeGetList(xTypeGrid)
|
typeGetList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -272,7 +257,7 @@ const submitDataForm = async () => {
|
|||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
} finally {
|
} finally {
|
||||||
actionLoading.value = false
|
actionLoading.value = false
|
||||||
dataGetList(xDataGrid)
|
dataGetList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user