mirror of
https://github.com/continew-org/continew-admin-ui.git
synced 2025-09-09 18:59:26 +08:00
refactor: 优化系统日志、在线用户、存储管理、部门管理相关代码
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import http from '@/utils/http'
|
||||
import type * as Monitor from './type'
|
||||
|
||||
const BASE_URL = '/monitor/online/user'
|
||||
const BASE_URL = '/monitor/online'
|
||||
|
||||
/** @desc 查询在线用户列表 */
|
||||
export function listOnlineUser(query: Monitor.OnlineUserQuery) {
|
||||
|
@@ -22,7 +22,7 @@
|
||||
</template>
|
||||
<template #custom-right>
|
||||
<a-tooltip content="导出">
|
||||
<a-button @click="onExport">
|
||||
<a-button v-permission="['monitor:log:export']" @click="onExport">
|
||||
<template #icon>
|
||||
<icon-download />
|
||||
</template>
|
||||
@@ -109,6 +109,17 @@ const {
|
||||
search
|
||||
} = useTable((p) => listLog({ ...queryForm, page: p.page, size: p.size }), { immediate: true })
|
||||
|
||||
// 过滤查询
|
||||
const filterChange = (dataIndex, filteredValues) => {
|
||||
try {
|
||||
const slotName = columns[dataIndex.split('_').pop()].slotName as string
|
||||
queryForm[slotName] = filteredValues.join(',')
|
||||
search()
|
||||
} catch (error) {
|
||||
search()
|
||||
}
|
||||
}
|
||||
|
||||
// 重置
|
||||
const reset = () => {
|
||||
queryForm.ip = undefined
|
||||
@@ -125,17 +136,6 @@ const reset = () => {
|
||||
const onExport = () => {
|
||||
useDownload(() => exportLoginLog(queryForm))
|
||||
}
|
||||
|
||||
// 过滤查询
|
||||
const filterChange = (dataIndex, filteredValues) => {
|
||||
try {
|
||||
const slotName = columns[dataIndex.split('_').pop()].slotName as string
|
||||
queryForm[slotName] = filteredValues.join(',')
|
||||
search()
|
||||
} catch (error) {
|
||||
search()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
|
@@ -82,14 +82,14 @@ const getDataDetail = async () => {
|
||||
}
|
||||
|
||||
const visible = ref(false)
|
||||
// 打开详情
|
||||
const open = async (id: string) => {
|
||||
// 详情
|
||||
const onDetail = async (id: string) => {
|
||||
dataId.value = id
|
||||
await getDataDetail()
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
defineExpose({ onDetail })
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
@@ -23,7 +23,7 @@
|
||||
</template>
|
||||
<template #custom-right>
|
||||
<a-tooltip content="导出">
|
||||
<a-button @click="onExport">
|
||||
<a-button v-permission="['monitor:log:export']" @click="onExport">
|
||||
<template #icon>
|
||||
<icon-download />
|
||||
</template>
|
||||
@@ -31,7 +31,7 @@
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<template #createTime="{ record }">
|
||||
<a-link @click="openDetail(record)">{{ record.createTime }}</a-link>
|
||||
<a-link @click="onDetail(record)">{{ record.createTime }}</a-link>
|
||||
</template>
|
||||
<template #status="{ record }">
|
||||
<a-tag v-if="record.status === 1" color="green">
|
||||
@@ -57,9 +57,9 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { listLog, exportOperationLog, type LogResp } from '@/apis'
|
||||
import OperationLogDetailDrawer from './OperationLogDetailDrawer.vue'
|
||||
import type { TableInstanceColumns } from '@/components/GiTable/type'
|
||||
import DateRangePicker from '@/components/DateRangePicker/index.vue'
|
||||
import OperationLogDetailDrawer from './OperationLogDetailDrawer.vue'
|
||||
import { useTable, useDownload } from '@/hooks'
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
@@ -121,7 +121,18 @@ const {
|
||||
search
|
||||
} = useTable((p) => listLog({ ...queryForm, page: p.page, size: p.size }), { immediate: true })
|
||||
|
||||
// 重置查询
|
||||
// 过滤查询
|
||||
const filterChange = (dataIndex, filteredValues) => {
|
||||
try {
|
||||
const slotName = columns[dataIndex.split('_').pop()].slotName as string
|
||||
queryForm[slotName] = filteredValues.join(',')
|
||||
search()
|
||||
} catch (error) {
|
||||
search()
|
||||
}
|
||||
}
|
||||
|
||||
// 重置
|
||||
const reset = () => {
|
||||
queryForm.description = undefined
|
||||
queryForm.ip = undefined
|
||||
@@ -139,21 +150,10 @@ const onExport = () => {
|
||||
useDownload(() => exportOperationLog(queryForm))
|
||||
}
|
||||
|
||||
// 过滤查询
|
||||
const filterChange = (dataIndex, filteredValues) => {
|
||||
try {
|
||||
const slotName = columns[dataIndex.split('_').pop()].slotName as string
|
||||
queryForm[slotName] = filteredValues.join(',')
|
||||
search()
|
||||
} catch (error) {
|
||||
search()
|
||||
}
|
||||
}
|
||||
|
||||
const OperationLogDetailDrawerRef = ref<InstanceType<typeof OperationLogDetailDrawer>>()
|
||||
// 查询详情
|
||||
const openDetail = (item: LogResp) => {
|
||||
OperationLogDetailDrawerRef.value?.open(item.id)
|
||||
// 详情
|
||||
const onDetail = (item: LogResp) => {
|
||||
OperationLogDetailDrawerRef.value?.onDetail(item.id)
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@@ -28,6 +28,7 @@
|
||||
@ok="handleKickout(record.token)"
|
||||
>
|
||||
<a-link
|
||||
v-permission="['monitor:online:kickout']"
|
||||
status="danger"
|
||||
:title="currentToken === record.token ? '不能强退自己' : '强退'"
|
||||
:disabled="currentToken === record.token"
|
||||
@@ -50,9 +51,12 @@ import DateRangePicker from '@/components/DateRangePicker/index.vue'
|
||||
import { useUserStore } from '@/stores'
|
||||
import { useTable } from '@/hooks'
|
||||
import { isMobile } from '@/utils'
|
||||
import has from '@/utils/has'
|
||||
|
||||
defineOptions({ name: 'MonitorOnline' })
|
||||
|
||||
const userStore = useUserStore()
|
||||
const currentToken = userStore.token
|
||||
const columns: TableInstanceColumns[] = [
|
||||
{
|
||||
title: '序号',
|
||||
@@ -66,7 +70,13 @@ const columns: TableInstanceColumns[] = [
|
||||
{ title: '浏览器', dataIndex: 'browser', ellipsis: true, tooltip: true },
|
||||
{ title: '终端系统', dataIndex: 'os', ellipsis: true, tooltip: true },
|
||||
{ title: '登录时间', dataIndex: 'loginTime', width: 180 },
|
||||
{ title: '操作', slotName: 'action', align: 'center', fixed: !isMobile() ? 'right' : undefined }
|
||||
{
|
||||
title: '操作',
|
||||
slotName: 'action',
|
||||
align: 'center',
|
||||
fixed: !isMobile() ? 'right' : undefined,
|
||||
show: has.hasPermOr(['monitor:online:kickout'])
|
||||
}
|
||||
]
|
||||
|
||||
const queryForm = reactive({
|
||||
@@ -89,8 +99,6 @@ const reset = () => {
|
||||
search()
|
||||
}
|
||||
|
||||
const userStore = useUserStore()
|
||||
const currentToken = userStore.token
|
||||
// 强退
|
||||
const handleKickout = (token: string) => {
|
||||
kickout(token).then(() => {
|
||||
|
@@ -84,10 +84,10 @@ import DeptAddModal from './DeptAddModal.vue'
|
||||
import { Message } from '@arco-design/web-vue'
|
||||
import type GiTable from '@/components/GiTable/index.vue'
|
||||
import type { TableInstanceColumns } from '@/components/GiTable/type'
|
||||
import { DisEnableStatusList } from '@/constant/common'
|
||||
import { useDownload } from '@/hooks'
|
||||
import { isMobile } from '@/utils'
|
||||
import has from '@/utils/has'
|
||||
import { DisEnableStatusList } from '@/constant/common'
|
||||
|
||||
defineOptions({ name: 'SystemDept' })
|
||||
|
||||
|
@@ -4,7 +4,7 @@
|
||||
:title="title"
|
||||
:mask-closable="false"
|
||||
:esc-to-close="false"
|
||||
:width="width >= 580 ? 580 : '100%'"
|
||||
:width="width >= 600 ? 600 : '100%'"
|
||||
@before-ok="save"
|
||||
@close="reset"
|
||||
>
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<a-drawer v-model:visible="visible" title="角色详情" :width="width >= 580 ? 580 : '100%'" :footer="false">
|
||||
<a-drawer v-model:visible="visible" title="角色详情" :width="width >= 600 ? 600 : '100%'" :footer="false">
|
||||
<a-descriptions title="基础信息" :column="2" size="large" class="general-description">
|
||||
<a-descriptions-item label="ID" :span="2">{{ dataDetail?.id }}</a-descriptions-item>
|
||||
<a-descriptions-item label="名称">{{ dataDetail?.name }}</a-descriptions-item>
|
||||
|
@@ -4,7 +4,7 @@
|
||||
:title="title"
|
||||
:mask-closable="false"
|
||||
:esc-to-close="false"
|
||||
:width="width >= 580 ? 580 : '100%'"
|
||||
:width="width >= 600 ? 600 : '100%'"
|
||||
@before-ok="save"
|
||||
@close="reset"
|
||||
>
|
||||
|
@@ -51,7 +51,7 @@
|
||||
<a-link
|
||||
v-permission="['system:storage:delete']"
|
||||
status="danger"
|
||||
:title="record.isDefault ? '默认存储库不能删除' : undefined"
|
||||
:title="record.isDefault ? '默认存储不能删除' : undefined"
|
||||
:disabled="record.disabled"
|
||||
@click="onDelete(record)"
|
||||
>
|
||||
@@ -104,9 +104,9 @@ const columns: TableInstanceColumns[] = [
|
||||
title: '操作',
|
||||
slotName: 'action',
|
||||
width: 130,
|
||||
show: has.hasPermOr(['system:storage:update', 'system:storage:delete']),
|
||||
align: 'center',
|
||||
fixed: !isMobile() ? 'right' : undefined
|
||||
fixed: !isMobile() ? 'right' : undefined,
|
||||
show: has.hasPermOr(['system:storage:update', 'system:storage:delete'])
|
||||
}
|
||||
]
|
||||
|
||||
|
@@ -4,7 +4,7 @@
|
||||
:title="title"
|
||||
:mask-closable="false"
|
||||
:esc-to-close="false"
|
||||
:width="width >= 580 ? 580 : '100%'"
|
||||
:width="width >= 600 ? 600 : '100%'"
|
||||
@before-ok="save"
|
||||
@close="reset"
|
||||
>
|
||||
@@ -160,6 +160,7 @@ const onUpdate = async (id: string) => {
|
||||
|
||||
// 保存
|
||||
const save = async () => {
|
||||
const rawPassword = form.password
|
||||
try {
|
||||
const isInvalid = await formRef.value?.validate()
|
||||
if (isInvalid) return false
|
||||
@@ -167,19 +168,16 @@ const save = async () => {
|
||||
await updateUser(form, dataId.value)
|
||||
Message.success('修改成功')
|
||||
} else {
|
||||
const rawPassword = form.password
|
||||
if (rawPassword) {
|
||||
form.password = encryptByRsa(rawPassword) || ''
|
||||
}
|
||||
await addUser(form).catch(() => {
|
||||
form.password = rawPassword
|
||||
return false
|
||||
})
|
||||
await addUser(form)
|
||||
Message.success('新增成功')
|
||||
}
|
||||
emit('save-success')
|
||||
return true
|
||||
} catch (error) {
|
||||
form.password = rawPassword
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<a-drawer v-model:visible="visible" title="用户详情" :width="width >= 580 ? 580 : '100%'" :footer="false">
|
||||
<a-drawer v-model:visible="visible" title="用户详情" :width="width >= 600 ? 600 : '100%'" :footer="false">
|
||||
<a-descriptions :column="2" size="large" class="general-description">
|
||||
<a-descriptions-item label="ID" :span="2">{{ dataDetail?.id }}</a-descriptions-item>
|
||||
<a-descriptions-item label="用户名">{{ dataDetail?.username }}</a-descriptions-item>
|
||||
|
Reference in New Issue
Block a user