mirror of
https://github.com/continew-org/continew-admin-ui.git
synced 2025-11-03 22:57:09 +08:00
feat: useTable 支持 “无分页” 列表
This commit is contained in:
@@ -18,11 +18,7 @@
|
|||||||
</a-button>
|
</a-button>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<template #content>
|
<template #content>
|
||||||
<a-doption v-for="item in sizeList" :key="item.value" :value="item.value" :active="item.value === size">
|
<a-doption v-for="item in sizeList" :key="item.value" :value="item.value" :active="item.value === size">{{ item.label }}</a-doption>
|
||||||
{{
|
|
||||||
item.label
|
|
||||||
}}
|
|
||||||
</a-doption>
|
|
||||||
</template>
|
</template>
|
||||||
</a-dropdown>
|
</a-dropdown>
|
||||||
<a-popover
|
<a-popover
|
||||||
|
|||||||
@@ -10,28 +10,29 @@ interface Options<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type PaginationParams = { page: number, size: number }
|
type PaginationParams = { page: number, size: number }
|
||||||
type Api<T> = (params: PaginationParams) => Promise<ApiRes<PageRes<T[]>>>
|
type Api<T> = (params: PaginationParams) => Promise<ApiRes<PageRes<T[]>>> | Promise<ApiRes<T[]>>
|
||||||
|
|
||||||
export function useTable<T>(api: Api<T>, options?: Options<T>) {
|
export function useTable<T>(api: Api<T>, options?: Options<T>) {
|
||||||
const { formatResult, onSuccess, immediate, rowKey } = options || {}
|
const { formatResult, onSuccess, immediate, rowKey } = options || {}
|
||||||
// eslint-disable-next-line ts/no-use-before-define
|
|
||||||
const { pagination, setTotal } = usePagination(() => getTableData())
|
const { pagination, setTotal } = usePagination(() => getTableData())
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const tableData = ref<T[]>([])
|
const tableData = ref<T[]>([])
|
||||||
|
|
||||||
const getTableData = async () => {
|
async function getTableData() {
|
||||||
try {
|
try {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
const res = await api({ page: pagination.current, size: pagination.pageSize })
|
const res = await api({ page: pagination.current, size: pagination.pageSize })
|
||||||
tableData.value = formatResult ? formatResult(res.data.list) : res.data.list
|
const data = !Array.isArray(res.data) ? res.data.list : res.data
|
||||||
setTotal(res.data.total)
|
tableData.value = formatResult ? formatResult(data) : data
|
||||||
|
const total = !Array.isArray(res.data) ? res.data.total : data.length
|
||||||
|
setTotal(total)
|
||||||
onSuccess && onSuccess()
|
onSuccess && onSuccess()
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 是否立即出发
|
// 是否立即触发
|
||||||
const isImmediate = immediate ?? true
|
const isImmediate = immediate ?? true
|
||||||
isImmediate && getTableData()
|
isImmediate && getTableData()
|
||||||
|
|
||||||
@@ -67,9 +68,9 @@ export function useTable<T>(api: Api<T>, options?: Options<T>) {
|
|||||||
selectedKeys.value = []
|
selectedKeys.value = []
|
||||||
getTableData()
|
getTableData()
|
||||||
}
|
}
|
||||||
return true
|
return res.success
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return true
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const flag = options?.showModal ?? true // 是否显示对话框
|
const flag = options?.showModal ?? true // 是否显示对话框
|
||||||
|
|||||||
@@ -69,18 +69,6 @@ const {
|
|||||||
search
|
search
|
||||||
} = useTable((p) => listLog({ ...queryForm, page: p.page, size: p.size }), { immediate: true })
|
} = useTable((p) => listLog({ ...queryForm, page: p.page, size: p.size }), { immediate: true })
|
||||||
|
|
||||||
// 重置
|
|
||||||
const reset = () => {
|
|
||||||
queryForm.ip = undefined
|
|
||||||
queryForm.createUserString = undefined
|
|
||||||
queryForm.createTime = [
|
|
||||||
dayjs().subtract(6, 'day').startOf('day').format('YYYY-MM-DD HH:mm:ss'),
|
|
||||||
dayjs().endOf('day').format('YYYY-MM-DD HH:mm:ss')
|
|
||||||
]
|
|
||||||
queryForm.status = undefined
|
|
||||||
search()
|
|
||||||
}
|
|
||||||
|
|
||||||
const columns: TableInstanceColumns[] = [
|
const columns: TableInstanceColumns[] = [
|
||||||
{
|
{
|
||||||
title: '序号',
|
title: '序号',
|
||||||
@@ -118,6 +106,18 @@ const columns: TableInstanceColumns[] = [
|
|||||||
{ title: '终端系统', dataIndex: 'os', ellipsis: true, tooltip: true }
|
{ title: '终端系统', dataIndex: 'os', ellipsis: true, tooltip: true }
|
||||||
]
|
]
|
||||||
|
|
||||||
|
// 重置
|
||||||
|
const reset = () => {
|
||||||
|
queryForm.ip = undefined
|
||||||
|
queryForm.createUserString = undefined
|
||||||
|
queryForm.createTime = [
|
||||||
|
dayjs().subtract(6, 'day').startOf('day').format('YYYY-MM-DD HH:mm:ss'),
|
||||||
|
dayjs().endOf('day').format('YYYY-MM-DD HH:mm:ss')
|
||||||
|
]
|
||||||
|
queryForm.status = undefined
|
||||||
|
search()
|
||||||
|
}
|
||||||
|
|
||||||
// 过滤查询
|
// 过滤查询
|
||||||
const filterChange = (dataIndex, filteredValues) => {
|
const filterChange = (dataIndex, filteredValues) => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -80,19 +80,6 @@ const {
|
|||||||
search
|
search
|
||||||
} = useTable((p) => listLog({ ...queryForm, page: p.page, size: p.size }), { immediate: true })
|
} = useTable((p) => listLog({ ...queryForm, page: p.page, size: p.size }), { immediate: true })
|
||||||
|
|
||||||
// 重置
|
|
||||||
const reset = () => {
|
|
||||||
queryForm.description = undefined
|
|
||||||
queryForm.ip = undefined
|
|
||||||
queryForm.createUserString = undefined
|
|
||||||
queryForm.createTime = [
|
|
||||||
dayjs().subtract(6, 'day').startOf('day').format('YYYY-MM-DD HH:mm:ss'),
|
|
||||||
dayjs().endOf('day').format('YYYY-MM-DD HH:mm:ss')
|
|
||||||
]
|
|
||||||
queryForm.status = undefined
|
|
||||||
search()
|
|
||||||
}
|
|
||||||
|
|
||||||
const columns: TableInstanceColumns[] = [
|
const columns: TableInstanceColumns[] = [
|
||||||
{
|
{
|
||||||
title: '序号',
|
title: '序号',
|
||||||
@@ -130,6 +117,19 @@ const columns: TableInstanceColumns[] = [
|
|||||||
{ title: '终端系统', dataIndex: 'os', ellipsis: true, tooltip: true }
|
{ title: '终端系统', dataIndex: 'os', ellipsis: true, tooltip: true }
|
||||||
]
|
]
|
||||||
|
|
||||||
|
// 重置
|
||||||
|
const reset = () => {
|
||||||
|
queryForm.description = undefined
|
||||||
|
queryForm.ip = undefined
|
||||||
|
queryForm.createUserString = undefined
|
||||||
|
queryForm.createTime = [
|
||||||
|
dayjs().subtract(6, 'day').startOf('day').format('YYYY-MM-DD HH:mm:ss'),
|
||||||
|
dayjs().endOf('day').format('YYYY-MM-DD HH:mm:ss')
|
||||||
|
]
|
||||||
|
queryForm.status = undefined
|
||||||
|
search()
|
||||||
|
}
|
||||||
|
|
||||||
// 过滤查询
|
// 过滤查询
|
||||||
const filterChange = (dataIndex, filteredValues) => {
|
const filterChange = (dataIndex, filteredValues) => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -69,13 +69,6 @@ const {
|
|||||||
search
|
search
|
||||||
} = useTable((p) => listOnlineUser({ ...queryForm, page: p.page, size: p.size }), { immediate: true })
|
} = useTable((p) => listOnlineUser({ ...queryForm, page: p.page, size: p.size }), { immediate: true })
|
||||||
|
|
||||||
// 重置
|
|
||||||
const reset = () => {
|
|
||||||
queryForm.nickname = undefined
|
|
||||||
queryForm.loginTime = undefined
|
|
||||||
search()
|
|
||||||
}
|
|
||||||
|
|
||||||
const columns: TableInstanceColumns[] = [
|
const columns: TableInstanceColumns[] = [
|
||||||
{
|
{
|
||||||
title: '序号',
|
title: '序号',
|
||||||
@@ -98,6 +91,13 @@ const columns: TableInstanceColumns[] = [
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
// 重置
|
||||||
|
const reset = () => {
|
||||||
|
queryForm.nickname = undefined
|
||||||
|
queryForm.loginTime = undefined
|
||||||
|
search()
|
||||||
|
}
|
||||||
|
|
||||||
// 强退
|
// 强退
|
||||||
const handleKickout = (token: string) => {
|
const handleKickout = (token: string) => {
|
||||||
kickout(token).then(() => {
|
kickout(token).then(() => {
|
||||||
|
|||||||
@@ -55,21 +55,15 @@
|
|||||||
<a-space>
|
<a-space>
|
||||||
<a-link v-permission="['system:dept:update']" @click="onUpdate(record)">修改</a-link>
|
<a-link v-permission="['system:dept:update']" @click="onUpdate(record)">修改</a-link>
|
||||||
<a-link v-permission="['system:dept:add']" @click="onAdd(record.id)">新增</a-link>
|
<a-link v-permission="['system:dept:add']" @click="onAdd(record.id)">新增</a-link>
|
||||||
<a-popconfirm
|
<a-link
|
||||||
type="warning"
|
v-permission="['system:dept:delete']"
|
||||||
content="是否确定删除该条数据?"
|
status="danger"
|
||||||
:ok-button-props="{ status: 'danger' }"
|
:title="record.isSystem ? '系统内置数据不能删除' : undefined"
|
||||||
@ok="onDelete(record)"
|
:disabled="record.disabled"
|
||||||
|
@click="onDelete(record)"
|
||||||
>
|
>
|
||||||
<a-link
|
删除
|
||||||
v-permission="['system:dept:delete']"
|
</a-link>
|
||||||
status="danger"
|
|
||||||
:title="record.isSystem ? '系统内置数据不能删除' : undefined"
|
|
||||||
:disabled="record.disabled"
|
|
||||||
>
|
|
||||||
删除
|
|
||||||
</a-link>
|
|
||||||
</a-popconfirm>
|
|
||||||
</a-space>
|
</a-space>
|
||||||
</template>
|
</template>
|
||||||
</GiTable>
|
</GiTable>
|
||||||
@@ -80,12 +74,11 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Message } from '@arco-design/web-vue'
|
|
||||||
import DeptAddModal from './DeptAddModal.vue'
|
import DeptAddModal from './DeptAddModal.vue'
|
||||||
import { type DeptQuery, type DeptResp, deleteDept, exportDept, listDept } from '@/apis'
|
import { type DeptQuery, type DeptResp, deleteDept, exportDept, listDept } from '@/apis'
|
||||||
import type GiTable from '@/components/GiTable/index.vue'
|
import type GiTable from '@/components/GiTable/index.vue'
|
||||||
import type { TableInstanceColumns } from '@/components/GiTable/type'
|
import type { TableInstanceColumns } from '@/components/GiTable/type'
|
||||||
import { useDownload } from '@/hooks'
|
import { useDownload, useTable } from '@/hooks'
|
||||||
import { isMobile } from '@/utils'
|
import { isMobile } from '@/utils'
|
||||||
import has from '@/utils/has'
|
import has from '@/utils/has'
|
||||||
import { DisEnableStatusList } from '@/constant/common'
|
import { DisEnableStatusList } from '@/constant/common'
|
||||||
@@ -116,27 +109,20 @@ const queryForm = reactive<DeptQuery>({
|
|||||||
sort: ['parentId,asc', 'sort,asc', 'createTime,desc']
|
sort: ['parentId,asc', 'sort,asc', 'createTime,desc']
|
||||||
})
|
})
|
||||||
|
|
||||||
const dataList = ref<DeptResp[]>([])
|
|
||||||
const loading = ref(false)
|
|
||||||
const tableRef = ref<InstanceType<typeof GiTable>>()
|
const tableRef = ref<InstanceType<typeof GiTable>>()
|
||||||
// 查询列表数据
|
const {
|
||||||
const getDataList = async (query: DeptQuery = { ...queryForm }) => {
|
tableData: dataList,
|
||||||
try {
|
loading,
|
||||||
loading.value = true
|
search,
|
||||||
const res = await listDept(query)
|
handleDelete
|
||||||
dataList.value = res.data
|
} = useTable(() => listDept(queryForm), {
|
||||||
await nextTick(() => {
|
immediate: true,
|
||||||
|
onSuccess: () => {
|
||||||
|
nextTick(() => {
|
||||||
tableRef.value?.tableRef?.expandAll(true)
|
tableRef.value?.tableRef?.expandAll(true)
|
||||||
})
|
})
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
// 查询
|
|
||||||
const search = () => {
|
|
||||||
getDataList()
|
|
||||||
}
|
|
||||||
|
|
||||||
// 重置
|
// 重置
|
||||||
const reset = () => {
|
const reset = () => {
|
||||||
@@ -146,10 +132,11 @@ const reset = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 删除
|
// 删除
|
||||||
const onDelete = async (item: DeptResp) => {
|
const onDelete = (item: DeptResp) => {
|
||||||
await deleteDept(item.id)
|
return handleDelete(() => deleteDept(item.id), {
|
||||||
Message.success('删除成功')
|
content: `是否确定删除 [${item.name}]?`,
|
||||||
search()
|
showModal: true
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 导出
|
// 导出
|
||||||
@@ -167,10 +154,6 @@ const onAdd = (parentId?: string) => {
|
|||||||
const onUpdate = (item: DeptResp) => {
|
const onUpdate = (item: DeptResp) => {
|
||||||
DeptAddModalRef.value?.onUpdate(item.id)
|
DeptAddModalRef.value?.onUpdate(item.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
search()
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped></style>
|
<style lang="scss" scoped></style>
|
||||||
|
|||||||
@@ -13,17 +13,17 @@
|
|||||||
@refresh="search"
|
@refresh="search"
|
||||||
>
|
>
|
||||||
<template #custom-left>
|
<template #custom-left>
|
||||||
<a-button v-permission="['system:dict:add']" type="primary" @click="onAdd">
|
|
||||||
<template #icon><icon-plus /></template>
|
|
||||||
<span>新增</span>
|
|
||||||
</a-button>
|
|
||||||
</template>
|
|
||||||
<template #custom-right>
|
|
||||||
<a-input v-model="queryForm.description" placeholder="请输入关键词" allow-clear @change="search">
|
<a-input v-model="queryForm.description" placeholder="请输入关键词" allow-clear @change="search">
|
||||||
<template #prefix><icon-search /></template>
|
<template #prefix><icon-search /></template>
|
||||||
</a-input>
|
</a-input>
|
||||||
<a-button @click="reset">重置</a-button>
|
<a-button @click="reset">重置</a-button>
|
||||||
</template>
|
</template>
|
||||||
|
<template #custom-right>
|
||||||
|
<a-button v-permission="['system:dict:add']" type="primary" @click="onAdd">
|
||||||
|
<template #icon><icon-plus /></template>
|
||||||
|
<span>新增</span>
|
||||||
|
</a-button>
|
||||||
|
</template>
|
||||||
<template #isSystem="{ record }">
|
<template #isSystem="{ record }">
|
||||||
<a-tag v-if="record.isSystem" color="red">是</a-tag>
|
<a-tag v-if="record.isSystem" color="red">是</a-tag>
|
||||||
<a-tag v-else color="arcoblue">否</a-tag>
|
<a-tag v-else color="arcoblue">否</a-tag>
|
||||||
@@ -74,12 +74,6 @@ const {
|
|||||||
handleDelete
|
handleDelete
|
||||||
} = useTable((p) => listDict({ ...queryForm, page: p.page, size: p.size }), { immediate: true })
|
} = useTable((p) => listDict({ ...queryForm, page: p.page, size: p.size }), { immediate: true })
|
||||||
|
|
||||||
// 重置
|
|
||||||
const reset = () => {
|
|
||||||
queryForm.description = undefined
|
|
||||||
search()
|
|
||||||
}
|
|
||||||
|
|
||||||
const columns: TableInstanceColumns[] = [
|
const columns: TableInstanceColumns[] = [
|
||||||
{
|
{
|
||||||
title: '序号',
|
title: '序号',
|
||||||
@@ -105,6 +99,12 @@ const columns: TableInstanceColumns[] = [
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
// 重置
|
||||||
|
const reset = () => {
|
||||||
|
queryForm.description = undefined
|
||||||
|
search()
|
||||||
|
}
|
||||||
|
|
||||||
// 删除
|
// 删除
|
||||||
const onDelete = (item: DictResp) => {
|
const onDelete = (item: DictResp) => {
|
||||||
return handleDelete(() => deleteDict(item.id), { content: `是否确定删除字典 [${item.name}]?`, showModal: true })
|
return handleDelete(() => deleteDict(item.id), { content: `是否确定删除字典 [${item.name}]?`, showModal: true })
|
||||||
|
|||||||
@@ -22,17 +22,17 @@
|
|||||||
@refresh="search"
|
@refresh="search"
|
||||||
>
|
>
|
||||||
<template #custom-left>
|
<template #custom-left>
|
||||||
<a-button type="primary" @click="onAdd">
|
|
||||||
<template #icon><icon-plus /></template>
|
|
||||||
<span>新增</span>
|
|
||||||
</a-button>
|
|
||||||
</template>
|
|
||||||
<template #custom-right>
|
|
||||||
<a-input v-model="queryForm.description" placeholder="请输入关键词" allow-clear @change="search">
|
<a-input v-model="queryForm.description" placeholder="请输入关键词" allow-clear @change="search">
|
||||||
<template #prefix><icon-search /></template>
|
<template #prefix><icon-search /></template>
|
||||||
</a-input>
|
</a-input>
|
||||||
<a-button @click="reset">重置</a-button>
|
<a-button @click="reset">重置</a-button>
|
||||||
</template>
|
</template>
|
||||||
|
<template #custom-right>
|
||||||
|
<a-button v-permission="['system:dict:item:add']" type="primary" @click="onAdd">
|
||||||
|
<template #icon><icon-plus /></template>
|
||||||
|
<span>新增</span>
|
||||||
|
</a-button>
|
||||||
|
</template>
|
||||||
<template #label="{ record }">
|
<template #label="{ record }">
|
||||||
<a-tag :color="record.color">{{ record.label }}</a-tag>
|
<a-tag :color="record.color">{{ record.label }}</a-tag>
|
||||||
</template>
|
</template>
|
||||||
@@ -41,17 +41,14 @@
|
|||||||
</template>
|
</template>
|
||||||
<template #action="{ record }">
|
<template #action="{ record }">
|
||||||
<a-space>
|
<a-space>
|
||||||
<template #split>
|
<a-link v-permission="['system:dict:item:update']" @click="onUpdate(record)">修改</a-link>
|
||||||
<a-divider direction="vertical" :margin="0" />
|
|
||||||
</template>
|
|
||||||
<a-link @click="onUpdate(record)">修改</a-link>
|
|
||||||
<a-popconfirm
|
<a-popconfirm
|
||||||
type="warning"
|
type="warning"
|
||||||
content="是否确定删除该条数据?"
|
content="是否确定删除该条数据?"
|
||||||
:ok-button-props="{ status: 'danger' }"
|
:ok-button-props="{ status: 'danger' }"
|
||||||
@ok="onDelete(record)"
|
@ok="onDelete(record)"
|
||||||
>
|
>
|
||||||
<a-link status="danger">删除</a-link>
|
<a-link v-permission="['system:dict:item:delete']" status="danger">删除</a-link>
|
||||||
</a-popconfirm>
|
</a-popconfirm>
|
||||||
</a-space>
|
</a-space>
|
||||||
</template>
|
</template>
|
||||||
@@ -68,12 +65,12 @@ import { type DictItemQuery, type DictItemResp, deleteDictItem, listDictItem } f
|
|||||||
import type { TableInstanceColumns } from '@/components/GiTable/type'
|
import type { TableInstanceColumns } from '@/components/GiTable/type'
|
||||||
import { useTable } from '@/hooks'
|
import { useTable } from '@/hooks'
|
||||||
import { isMobile } from '@/utils'
|
import { isMobile } from '@/utils'
|
||||||
|
import has from '@/utils/has'
|
||||||
|
|
||||||
const { width } = useWindowSize()
|
const { width } = useWindowSize()
|
||||||
|
|
||||||
const dictId = ref('')
|
|
||||||
|
|
||||||
const queryForm = reactive<DictItemQuery>({
|
const queryForm = reactive<DictItemQuery>({
|
||||||
|
dictId: '',
|
||||||
sort: ['createTime,desc']
|
sort: ['createTime,desc']
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -83,16 +80,7 @@ const {
|
|||||||
pagination,
|
pagination,
|
||||||
search,
|
search,
|
||||||
handleDelete
|
handleDelete
|
||||||
} = useTable((p) => listDictItem({ ...queryForm, dictId: dictId.value, page: p.page, size: p.size }), {
|
} = useTable((p) => listDictItem({ ...queryForm, page: p.page, size: p.size }), { immediate: true })
|
||||||
immediate: true
|
|
||||||
})
|
|
||||||
|
|
||||||
// 重置
|
|
||||||
const reset = () => {
|
|
||||||
queryForm.description = undefined
|
|
||||||
queryForm.status = undefined
|
|
||||||
search()
|
|
||||||
}
|
|
||||||
|
|
||||||
const columns: TableInstanceColumns[] = [
|
const columns: TableInstanceColumns[] = [
|
||||||
{
|
{
|
||||||
@@ -119,15 +107,29 @@ const columns: TableInstanceColumns[] = [
|
|||||||
{ title: '创建时间', dataIndex: 'createTime', width: 180 },
|
{ title: '创建时间', dataIndex: 'createTime', width: 180 },
|
||||||
{ title: '修改人', dataIndex: 'updateUserString', ellipsis: true, tooltip: true, show: false },
|
{ title: '修改人', dataIndex: 'updateUserString', ellipsis: true, tooltip: true, show: false },
|
||||||
{ title: '修改时间', dataIndex: 'updateTime', width: 180, show: false },
|
{ title: '修改时间', dataIndex: 'updateTime', width: 180, show: false },
|
||||||
{ title: '操作', slotName: 'action', width: 130, align: 'center', fixed: !isMobile() ? 'right' : undefined }
|
{
|
||||||
|
title: '操作',
|
||||||
|
slotName: 'action',
|
||||||
|
width: 130,
|
||||||
|
align: 'center',
|
||||||
|
fixed: !isMobile() ? 'right' : undefined,
|
||||||
|
show: has.hasPermOr(['system:dict:item:update', 'system:dict:item:delete'])
|
||||||
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
// 重置
|
||||||
|
const reset = () => {
|
||||||
|
queryForm.description = undefined
|
||||||
|
queryForm.status = undefined
|
||||||
|
search()
|
||||||
|
}
|
||||||
|
|
||||||
const dictCode = ref('')
|
const dictCode = ref('')
|
||||||
const visible = ref(false)
|
const visible = ref(false)
|
||||||
// 打开
|
// 打开
|
||||||
const open = (id: string, code: string) => {
|
const open = (id: string, code: string) => {
|
||||||
dataList.value = []
|
dataList.value = []
|
||||||
dictId.value = id
|
queryForm.dictId = id
|
||||||
dictCode.value = code
|
dictCode.value = code
|
||||||
visible.value = true
|
visible.value = true
|
||||||
search()
|
search()
|
||||||
@@ -142,7 +144,7 @@ const onDelete = (item: DictItemResp) => {
|
|||||||
const DictItemAddModalRef = ref<InstanceType<typeof DictItemAddModal>>()
|
const DictItemAddModalRef = ref<InstanceType<typeof DictItemAddModal>>()
|
||||||
// 新增
|
// 新增
|
||||||
const onAdd = () => {
|
const onAdd = () => {
|
||||||
DictItemAddModalRef.value?.onAdd(dictId.value)
|
DictItemAddModalRef.value?.onAdd(queryForm.dictId)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改
|
// 修改
|
||||||
|
|||||||
@@ -74,14 +74,7 @@
|
|||||||
<a-link v-if="[1, 2].includes(record.type)" v-permission="['system:menu:add']" @click="onAdd(record.id)">
|
<a-link v-if="[1, 2].includes(record.type)" v-permission="['system:menu:add']" @click="onAdd(record.id)">
|
||||||
新增
|
新增
|
||||||
</a-link>
|
</a-link>
|
||||||
<a-popconfirm
|
<a-link v-permission="['system:menu:delete']" status="danger" @click="onDelete(record)">删除</a-link>
|
||||||
type="warning"
|
|
||||||
content="是否确定删除该条数据?"
|
|
||||||
:ok-button-props="{ status: 'danger' }"
|
|
||||||
@ok="onDelete(record)"
|
|
||||||
>
|
|
||||||
<a-link v-permission="['system:menu:delete']" status="danger">删除</a-link>
|
|
||||||
</a-popconfirm>
|
|
||||||
</a-space>
|
</a-space>
|
||||||
</template>
|
</template>
|
||||||
</GiTable>
|
</GiTable>
|
||||||
@@ -92,7 +85,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Message } from '@arco-design/web-vue'
|
|
||||||
import MenuAddModal from './MenuAddModal.vue'
|
import MenuAddModal from './MenuAddModal.vue'
|
||||||
import { type MenuQuery, type MenuResp, deleteMenu, listMenu } from '@/apis'
|
import { type MenuQuery, type MenuResp, deleteMenu, listMenu } from '@/apis'
|
||||||
import type GiTable from '@/components/GiTable/index.vue'
|
import type GiTable from '@/components/GiTable/index.vue'
|
||||||
@@ -100,9 +92,21 @@ import type { TableInstanceColumns } from '@/components/GiTable/type'
|
|||||||
import { DisEnableStatusList } from '@/constant/common'
|
import { DisEnableStatusList } from '@/constant/common'
|
||||||
import { isMobile } from '@/utils'
|
import { isMobile } from '@/utils'
|
||||||
import has from '@/utils/has'
|
import has from '@/utils/has'
|
||||||
|
import { useTable } from '@/hooks'
|
||||||
|
|
||||||
defineOptions({ name: 'SystemMenu' })
|
defineOptions({ name: 'SystemMenu' })
|
||||||
|
|
||||||
|
const queryForm = reactive<MenuQuery>({
|
||||||
|
sort: ['parentId,asc', 'sort,asc', 'createTime,desc']
|
||||||
|
})
|
||||||
|
|
||||||
|
const {
|
||||||
|
tableData: dataList,
|
||||||
|
loading,
|
||||||
|
search,
|
||||||
|
handleDelete
|
||||||
|
} = useTable(() => listMenu(queryForm), { immediate: true })
|
||||||
|
|
||||||
const columns: TableInstanceColumns[] = [
|
const columns: TableInstanceColumns[] = [
|
||||||
{ title: '菜单标题', dataIndex: 'title', slotName: 'title', width: 170, fixed: !isMobile() ? 'left' : undefined },
|
{ title: '菜单标题', dataIndex: 'title', slotName: 'title', width: 170, fixed: !isMobile() ? 'left' : undefined },
|
||||||
{ title: '类型', slotName: 'type', align: 'center' },
|
{ title: '类型', slotName: 'type', align: 'center' },
|
||||||
@@ -129,28 +133,6 @@ const columns: TableInstanceColumns[] = [
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
const queryForm = reactive<MenuQuery>({
|
|
||||||
sort: ['parentId,asc', 'sort,asc', 'createTime,desc']
|
|
||||||
})
|
|
||||||
|
|
||||||
const dataList = ref<MenuResp[]>([])
|
|
||||||
const loading = ref(false)
|
|
||||||
// 查询列表数据
|
|
||||||
const getDataList = async (query: MenuQuery = { ...queryForm }) => {
|
|
||||||
try {
|
|
||||||
loading.value = true
|
|
||||||
const res = await listMenu(query)
|
|
||||||
dataList.value = res.data
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查询
|
|
||||||
const search = () => {
|
|
||||||
getDataList()
|
|
||||||
}
|
|
||||||
|
|
||||||
// 重置
|
// 重置
|
||||||
const reset = () => {
|
const reset = () => {
|
||||||
queryForm.title = undefined
|
queryForm.title = undefined
|
||||||
@@ -159,10 +141,11 @@ const reset = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 删除
|
// 删除
|
||||||
const onDelete = async (item: MenuResp) => {
|
const onDelete = (item: MenuResp) => {
|
||||||
await deleteMenu(item.id)
|
return handleDelete(() => deleteMenu(item.id), {
|
||||||
Message.success('删除成功')
|
content: `是否确定删除 [${item.title}]?`,
|
||||||
search()
|
showModal: true
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const isExpanded = ref(false)
|
const isExpanded = ref(false)
|
||||||
@@ -183,10 +166,6 @@ const onAdd = (parentId?: string) => {
|
|||||||
const onUpdate = (item: MenuResp) => {
|
const onUpdate = (item: MenuResp) => {
|
||||||
MenuAddModalRef.value?.onUpdate(item.id)
|
MenuAddModalRef.value?.onUpdate(item.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
search()
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped></style>
|
<style lang="scss" scoped></style>
|
||||||
|
|||||||
@@ -83,13 +83,6 @@ const {
|
|||||||
handleDelete
|
handleDelete
|
||||||
} = useTable((p) => listNotice({ ...queryForm, page: p.page, size: p.size }), { immediate: true })
|
} = useTable((p) => listNotice({ ...queryForm, page: p.page, size: p.size }), { immediate: true })
|
||||||
|
|
||||||
// 重置
|
|
||||||
const reset = () => {
|
|
||||||
queryForm.title = undefined
|
|
||||||
queryForm.type = undefined
|
|
||||||
search()
|
|
||||||
}
|
|
||||||
|
|
||||||
const columns: TableInstanceColumns[] = [
|
const columns: TableInstanceColumns[] = [
|
||||||
{
|
{
|
||||||
title: '序号',
|
title: '序号',
|
||||||
@@ -114,6 +107,13 @@ const columns: TableInstanceColumns[] = [
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
// 重置
|
||||||
|
const reset = () => {
|
||||||
|
queryForm.title = undefined
|
||||||
|
queryForm.type = undefined
|
||||||
|
search()
|
||||||
|
}
|
||||||
|
|
||||||
// 删除
|
// 删除
|
||||||
const onDelete = (item: NoticeResp) => {
|
const onDelete = (item: NoticeResp) => {
|
||||||
return handleDelete(() => deleteNotice(item.id), {
|
return handleDelete(() => deleteNotice(item.id), {
|
||||||
|
|||||||
@@ -82,12 +82,6 @@ const {
|
|||||||
handleDelete
|
handleDelete
|
||||||
} = useTable((p) => listRole({ ...queryForm, page: p.page, size: p.size }), { immediate: true })
|
} = useTable((p) => listRole({ ...queryForm, page: p.page, size: p.size }), { immediate: true })
|
||||||
|
|
||||||
// 重置
|
|
||||||
const reset = () => {
|
|
||||||
queryForm.description = undefined
|
|
||||||
search()
|
|
||||||
}
|
|
||||||
|
|
||||||
const columns: TableInstanceColumns[] = [
|
const columns: TableInstanceColumns[] = [
|
||||||
{
|
{
|
||||||
title: '序号',
|
title: '序号',
|
||||||
@@ -115,9 +109,15 @@ const columns: TableInstanceColumns[] = [
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
// 重置
|
||||||
|
const reset = () => {
|
||||||
|
queryForm.description = undefined
|
||||||
|
search()
|
||||||
|
}
|
||||||
|
|
||||||
// 删除
|
// 删除
|
||||||
const onDelete = (item: RoleResp) => {
|
const onDelete = (item: RoleResp) => {
|
||||||
return handleDelete(() => deleteRole(item.id), { content: `是否确定删除角色 [${item.name}]?`, showModal: true })
|
return handleDelete(() => deleteRole(item.id), { content: `是否确定删除 [${item.name}]?`, showModal: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
const RoleAddModalRef = ref<InstanceType<typeof RoleAddModal>>()
|
const RoleAddModalRef = ref<InstanceType<typeof RoleAddModal>>()
|
||||||
|
|||||||
@@ -93,13 +93,6 @@ const {
|
|||||||
handleDelete
|
handleDelete
|
||||||
} = useTable((p) => listStorage({ ...queryForm, page: p.page, size: p.size }), { immediate: true })
|
} = useTable((p) => listStorage({ ...queryForm, page: p.page, size: p.size }), { immediate: true })
|
||||||
|
|
||||||
// 重置
|
|
||||||
const reset = () => {
|
|
||||||
queryForm.description = undefined
|
|
||||||
queryForm.status = undefined
|
|
||||||
search()
|
|
||||||
}
|
|
||||||
|
|
||||||
const columns: TableInstanceColumns[] = [
|
const columns: TableInstanceColumns[] = [
|
||||||
{
|
{
|
||||||
title: '序号',
|
title: '序号',
|
||||||
@@ -130,6 +123,13 @@ const columns: TableInstanceColumns[] = [
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
// 重置
|
||||||
|
const reset = () => {
|
||||||
|
queryForm.description = undefined
|
||||||
|
queryForm.status = undefined
|
||||||
|
search()
|
||||||
|
}
|
||||||
|
|
||||||
// 删除
|
// 删除
|
||||||
const onDelete = (item: StorageResp) => {
|
const onDelete = (item: StorageResp) => {
|
||||||
return handleDelete(() => deleteStorage(item.id), { content: `是否确定删除存储 [${item.name}]?`, showModal: true })
|
return handleDelete(() => deleteStorage(item.id), { content: `是否确定删除存储 [${item.name}]?`, showModal: true })
|
||||||
|
|||||||
@@ -131,14 +131,7 @@ const {
|
|||||||
pagination,
|
pagination,
|
||||||
search,
|
search,
|
||||||
handleDelete
|
handleDelete
|
||||||
} = useTable((p) => listUser({ ...queryForm, page: p.page, size: p.size }), { immediate: false })
|
} = useTable((p) => listUser({ ...queryForm, page: p.page, size: p.size }), { immediate: true })
|
||||||
|
|
||||||
// 重置
|
|
||||||
const reset = () => {
|
|
||||||
queryForm.description = undefined
|
|
||||||
queryForm.status = undefined
|
|
||||||
search()
|
|
||||||
}
|
|
||||||
|
|
||||||
const columns: TableInstanceColumns[] = [
|
const columns: TableInstanceColumns[] = [
|
||||||
{
|
{
|
||||||
@@ -178,10 +171,17 @@ const columns: TableInstanceColumns[] = [
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
// 重置
|
||||||
|
const reset = () => {
|
||||||
|
queryForm.description = undefined
|
||||||
|
queryForm.status = undefined
|
||||||
|
search()
|
||||||
|
}
|
||||||
|
|
||||||
// 删除
|
// 删除
|
||||||
const onDelete = (item: UserResp) => {
|
const onDelete = (item: UserResp) => {
|
||||||
return handleDelete(() => deleteUser(item.id), {
|
return handleDelete(() => deleteUser(item.id), {
|
||||||
content: `是否确定删除用户 [${item.nickname}(${item.username})]?`,
|
content: `是否确定删除 [${item.nickname}(${item.username})]?`,
|
||||||
showModal: true
|
showModal: true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user