diff --git a/src/components/GiTable/index.vue b/src/components/GiTable/index.vue
index 0a54317..ce96717 100644
--- a/src/components/GiTable/index.vue
+++ b/src/components/GiTable/index.vue
@@ -18,11 +18,7 @@
-
-{{
- item.label
- }}
-
+ {{ item.label }}
{
}
type PaginationParams = { page: number, size: number }
-type Api = (params: PaginationParams) => Promise>>
+type Api = (params: PaginationParams) => Promise>> | Promise>
export function useTable(api: Api, options?: Options) {
const { formatResult, onSuccess, immediate, rowKey } = options || {}
- // eslint-disable-next-line ts/no-use-before-define
const { pagination, setTotal } = usePagination(() => getTableData())
const loading = ref(false)
const tableData = ref([])
- const getTableData = async () => {
+ async function getTableData() {
try {
loading.value = true
const res = await api({ page: pagination.current, size: pagination.pageSize })
- tableData.value = formatResult ? formatResult(res.data.list) : res.data.list
- setTotal(res.data.total)
+ const data = !Array.isArray(res.data) ? res.data.list : res.data
+ tableData.value = formatResult ? formatResult(data) : data
+ const total = !Array.isArray(res.data) ? res.data.total : data.length
+ setTotal(total)
onSuccess && onSuccess()
} finally {
loading.value = false
}
}
- // 是否立即出发
+ // 是否立即触发
const isImmediate = immediate ?? true
isImmediate && getTableData()
@@ -67,9 +68,9 @@ export function useTable(api: Api, options?: Options) {
selectedKeys.value = []
getTableData()
}
- return true
+ return res.success
} catch (error) {
- return true
+ return false
}
}
const flag = options?.showModal ?? true // 是否显示对话框
diff --git a/src/views/monitor/log/login/index.vue b/src/views/monitor/log/login/index.vue
index 925cbc0..1eef21b 100644
--- a/src/views/monitor/log/login/index.vue
+++ b/src/views/monitor/log/login/index.vue
@@ -69,18 +69,6 @@ const {
search
} = 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[] = [
{
title: '序号',
@@ -118,6 +106,18 @@ const columns: TableInstanceColumns[] = [
{ 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) => {
try {
diff --git a/src/views/monitor/log/operation/index.vue b/src/views/monitor/log/operation/index.vue
index af7e93c..484faf8 100644
--- a/src/views/monitor/log/operation/index.vue
+++ b/src/views/monitor/log/operation/index.vue
@@ -80,19 +80,6 @@ const {
search
} = 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[] = [
{
title: '序号',
@@ -130,6 +117,19 @@ const columns: TableInstanceColumns[] = [
{ 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) => {
try {
diff --git a/src/views/monitor/online/index.vue b/src/views/monitor/online/index.vue
index 816266a..a0bead7 100644
--- a/src/views/monitor/online/index.vue
+++ b/src/views/monitor/online/index.vue
@@ -69,13 +69,6 @@ const {
search
} = useTable((p) => listOnlineUser({ ...queryForm, page: p.page, size: p.size }), { immediate: true })
-// 重置
-const reset = () => {
- queryForm.nickname = undefined
- queryForm.loginTime = undefined
- search()
-}
-
const columns: TableInstanceColumns[] = [
{
title: '序号',
@@ -98,6 +91,13 @@ const columns: TableInstanceColumns[] = [
}
]
+// 重置
+const reset = () => {
+ queryForm.nickname = undefined
+ queryForm.loginTime = undefined
+ search()
+}
+
// 强退
const handleKickout = (token: string) => {
kickout(token).then(() => {
diff --git a/src/views/system/dept/index.vue b/src/views/system/dept/index.vue
index 85d778d..70a128e 100644
--- a/src/views/system/dept/index.vue
+++ b/src/views/system/dept/index.vue
@@ -55,21 +55,15 @@
修改
新增
-
-
- 删除
-
-
+ 删除
+
@@ -80,12 +74,11 @@
diff --git a/src/views/system/dict/index.vue b/src/views/system/dict/index.vue
index 46cda5a..beeabe4 100644
--- a/src/views/system/dict/index.vue
+++ b/src/views/system/dict/index.vue
@@ -13,17 +13,17 @@
@refresh="search"
>
-
-
- 新增
-
-
-
重置
+
+
+
+ 新增
+
+
是
否
@@ -74,12 +74,6 @@ const {
handleDelete
} = useTable((p) => listDict({ ...queryForm, page: p.page, size: p.size }), { immediate: true })
-// 重置
-const reset = () => {
- queryForm.description = undefined
- search()
-}
-
const columns: TableInstanceColumns[] = [
{
title: '序号',
@@ -105,6 +99,12 @@ const columns: TableInstanceColumns[] = [
}
]
+// 重置
+const reset = () => {
+ queryForm.description = undefined
+ search()
+}
+
// 删除
const onDelete = (item: DictResp) => {
return handleDelete(() => deleteDict(item.id), { content: `是否确定删除字典 [${item.name}]?`, showModal: true })
diff --git a/src/views/system/dict/item/index.vue b/src/views/system/dict/item/index.vue
index e340b47..90d1ee2 100644
--- a/src/views/system/dict/item/index.vue
+++ b/src/views/system/dict/item/index.vue
@@ -22,17 +22,17 @@
@refresh="search"
>
-
-
- 新增
-
-
-
重置
+
+
+
+ 新增
+
+
{{ record.label }}
@@ -41,17 +41,14 @@
-
-
-
- 修改
+ 修改
- 删除
+ 删除
@@ -68,12 +65,12 @@ import { type DictItemQuery, type DictItemResp, deleteDictItem, listDictItem } f
import type { TableInstanceColumns } from '@/components/GiTable/type'
import { useTable } from '@/hooks'
import { isMobile } from '@/utils'
+import has from '@/utils/has'
const { width } = useWindowSize()
-const dictId = ref('')
-
const queryForm = reactive({
+ dictId: '',
sort: ['createTime,desc']
})
@@ -83,16 +80,7 @@ const {
pagination,
search,
handleDelete
-} = useTable((p) => listDictItem({ ...queryForm, dictId: dictId.value, page: p.page, size: p.size }), {
- immediate: true
-})
-
-// 重置
-const reset = () => {
- queryForm.description = undefined
- queryForm.status = undefined
- search()
-}
+} = useTable((p) => listDictItem({ ...queryForm, page: p.page, size: p.size }), { immediate: true })
const columns: TableInstanceColumns[] = [
{
@@ -119,15 +107,29 @@ const columns: TableInstanceColumns[] = [
{ title: '创建时间', dataIndex: 'createTime', width: 180 },
{ title: '修改人', dataIndex: 'updateUserString', ellipsis: true, tooltip: true, 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 visible = ref(false)
// 打开
const open = (id: string, code: string) => {
dataList.value = []
- dictId.value = id
+ queryForm.dictId = id
dictCode.value = code
visible.value = true
search()
@@ -142,7 +144,7 @@ const onDelete = (item: DictItemResp) => {
const DictItemAddModalRef = ref>()
// 新增
const onAdd = () => {
- DictItemAddModalRef.value?.onAdd(dictId.value)
+ DictItemAddModalRef.value?.onAdd(queryForm.dictId)
}
// 修改
diff --git a/src/views/system/menu/index.vue b/src/views/system/menu/index.vue
index 60184ce..4a65e00 100644
--- a/src/views/system/menu/index.vue
+++ b/src/views/system/menu/index.vue
@@ -74,14 +74,7 @@
新增
-
- 删除
-
+ 删除
@@ -92,7 +85,6 @@
diff --git a/src/views/system/notice/index.vue b/src/views/system/notice/index.vue
index b0868bd..acc72f8 100644
--- a/src/views/system/notice/index.vue
+++ b/src/views/system/notice/index.vue
@@ -83,13 +83,6 @@ const {
handleDelete
} = useTable((p) => listNotice({ ...queryForm, page: p.page, size: p.size }), { immediate: true })
-// 重置
-const reset = () => {
- queryForm.title = undefined
- queryForm.type = undefined
- search()
-}
-
const columns: TableInstanceColumns[] = [
{
title: '序号',
@@ -114,6 +107,13 @@ const columns: TableInstanceColumns[] = [
}
]
+// 重置
+const reset = () => {
+ queryForm.title = undefined
+ queryForm.type = undefined
+ search()
+}
+
// 删除
const onDelete = (item: NoticeResp) => {
return handleDelete(() => deleteNotice(item.id), {
diff --git a/src/views/system/role/index.vue b/src/views/system/role/index.vue
index 6d1ae74..b28d106 100644
--- a/src/views/system/role/index.vue
+++ b/src/views/system/role/index.vue
@@ -82,12 +82,6 @@ const {
handleDelete
} = useTable((p) => listRole({ ...queryForm, page: p.page, size: p.size }), { immediate: true })
-// 重置
-const reset = () => {
- queryForm.description = undefined
- search()
-}
-
const columns: TableInstanceColumns[] = [
{
title: '序号',
@@ -115,9 +109,15 @@ const columns: TableInstanceColumns[] = [
}
]
+// 重置
+const reset = () => {
+ queryForm.description = undefined
+ search()
+}
+
// 删除
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>()
diff --git a/src/views/system/storage/index.vue b/src/views/system/storage/index.vue
index 8eaeb5d..e3fdfd6 100644
--- a/src/views/system/storage/index.vue
+++ b/src/views/system/storage/index.vue
@@ -93,13 +93,6 @@ const {
handleDelete
} = useTable((p) => listStorage({ ...queryForm, page: p.page, size: p.size }), { immediate: true })
-// 重置
-const reset = () => {
- queryForm.description = undefined
- queryForm.status = undefined
- search()
-}
-
const columns: TableInstanceColumns[] = [
{
title: '序号',
@@ -130,6 +123,13 @@ const columns: TableInstanceColumns[] = [
}
]
+// 重置
+const reset = () => {
+ queryForm.description = undefined
+ queryForm.status = undefined
+ search()
+}
+
// 删除
const onDelete = (item: StorageResp) => {
return handleDelete(() => deleteStorage(item.id), { content: `是否确定删除存储 [${item.name}]?`, showModal: true })
diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue
index 2eca35d..ca1b334 100644
--- a/src/views/system/user/index.vue
+++ b/src/views/system/user/index.vue
@@ -131,14 +131,7 @@ const {
pagination,
search,
handleDelete
-} = useTable((p) => listUser({ ...queryForm, page: p.page, size: p.size }), { immediate: false })
-
-// 重置
-const reset = () => {
- queryForm.description = undefined
- queryForm.status = undefined
- search()
-}
+} = useTable((p) => listUser({ ...queryForm, page: p.page, size: p.size }), { immediate: true })
const columns: TableInstanceColumns[] = [
{
@@ -178,10 +171,17 @@ const columns: TableInstanceColumns[] = [
}
]
+// 重置
+const reset = () => {
+ queryForm.description = undefined
+ queryForm.status = undefined
+ search()
+}
+
// 删除
const onDelete = (item: UserResp) => {
return handleDelete(() => deleteUser(item.id), {
- content: `是否确定删除用户 [${item.nickname}(${item.username})]?`,
+ content: `是否确定删除 [${item.nickname}(${item.username})]?`,
showModal: true
})
}