Compare commits

..

3 Commits

Author SHA1 Message Date
67e58660ff feat(iot): 设备列表增加所属产品筛选功能
- 在设备列表页面和设备卡片页面添加所属产品筛选条件
- 更新设备列表数据结构,增加所属产品字段- 修改设备卡片组件,显示所属产品信息
2025-02-21 21:48:34 +08:00
b3e4a11a7b refactor(system): 优化日志列表组件
- 移除自定义 ID 列,使用 Arco Design 的 rowSelection 功能替代- 添加 rowSelection 配置,实现全选和单选功能- 优化代码结构,提高可维护性
2025-02-21 21:34:24 +08:00
ab6c1c63cd feat(system): 添加操作日志管理功能
- 新增操作日志列表页面,包含查询、重置、批量删除等功能
- 添加日志详情和日志批量删除接口
- 更新菜单管理页面,修改面包屑导航
- 新增操作日志管理路由模块
2025-02-20 20:11:56 +08:00
10 changed files with 356 additions and 52 deletions

31
src/api/log.ts Normal file
View File

@ -0,0 +1,31 @@
import axios from 'axios';
export interface LogsRecord {
moduleType?: string;
functionType?: string;
publishTimeBegin?: string;
publishTimeEnd?: string;
current: number;
size: number;
}
// 日志分页查询
export function queryLogList(data: LogsRecord) {
return axios({
url: '/api/rest/log',
method: 'get',
params: data,
});
}
// 日志详情
export function queryLogDetail(id: number) {
return axios.get(`/api/rest/log/${id}`);
}
// 日志批量删除
export function deleteLogs(ids: number[]) {
return axios.delete(`/api/rest/log/batch`, {
data: ids,
});
}

View File

@ -72,11 +72,22 @@ const SYSTEM: AppRouteRecordRaw = {
name: 'Menu', name: 'Menu',
component: () => import('@/views/system/menu/index.vue'), component: () => import('@/views/system/menu/index.vue'),
meta: { meta: {
locale: '权限管理',
title: '菜单管理', title: '菜单管理',
requiresAuth: true, requiresAuth: true,
permissions: ['system:menu'], permissions: ['system:menu'],
}, },
}, },
{
path: 'log',
name: 'Log',
component: () => import('@/views/system/log/index.vue'),
meta: {
title: '操作日志管理',
requiresAuth: true,
permissions: ['system:menu'],
},
},
], ],
}; };

View File

@ -30,6 +30,16 @@
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="9"> <a-col :span="9">
<a-form-item field="status" label="所属产品">
<a-select
v-model="formModel.productName"
style="width: 360px"
placeholder="请选择所属产品"
:options="productOptions"
/>
</a-form-item>
</a-col>
<a-col :span="10">
<a-form-item field="isOnline" label="在线"> <a-form-item field="isOnline" label="在线">
<a-select <a-select
v-model="formModel.isOnline" v-model="formModel.isOnline"
@ -222,6 +232,7 @@
name: '', name: '',
status: '', status: '',
isOnline: '', isOnline: '',
productName: '',
}; };
}; };
@ -252,6 +263,10 @@
title: '名称', title: '名称',
dataIndex: 'name', dataIndex: 'name',
}, },
{
title: '所属产品',
dataIndex: 'productName',
},
{ {
title: '状态', title: '状态',
dataIndex: 'state', dataIndex: 'state',
@ -281,6 +296,14 @@
value: 'false', value: 'false',
}, },
]); ]);
const productOptions = computed(() => {
return [
{
label: '全部',
value: '',
},
];
});
// //
const fetchData = async (params = { size: 10, current: 1 }) => { const fetchData = async (params = { size: 10, current: 1 }) => {

View File

@ -14,8 +14,8 @@
</template> </template>
<template #description> <template #description>
<a-descriptions :column="1"> <a-descriptions :column="1">
<a-descriptions-item label="创建人"> <a-descriptions-item label="所属产品">
{{ createBy }} {{ productName }}
</a-descriptions-item> </a-descriptions-item>
<a-descriptions-item label="创建时间"> <a-descriptions-item label="创建时间">
{{ dayjs(createTime).format('YYYY-MM-DD HH:mm:ss') }} {{ dayjs(createTime).format('YYYY-MM-DD HH:mm:ss') }}
@ -68,7 +68,7 @@
type: Number, type: Number,
default: -1, default: -1,
}, },
createBy: { productName: {
type: String, type: String,
default: '', default: '',
}, },

View File

@ -30,6 +30,16 @@
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="9"> <a-col :span="9">
<a-form-item field="status" label="所属产品">
<a-select
v-model="formModel.productName"
style="width: 360px"
placeholder="请选择所属产品"
:options="productOptions"
/>
</a-form-item>
</a-col>
<a-col :span="10">
<a-form-item field="isOnline" label="在线"> <a-form-item field="isOnline" label="在线">
<a-select <a-select
v-model="formModel.isOnline" v-model="formModel.isOnline"
@ -78,7 +88,7 @@
:loading="loading" :loading="loading"
:id="item.id" :id="item.id"
:title="item.name" :title="item.name"
:createBy="item.createBy" :productName="item.productName"
:createTime="item.createTime" :createTime="item.createTime"
open-txt="详情" open-txt="详情"
> >
@ -94,25 +104,6 @@
</CardWrap> </CardWrap>
</a-col> </a-col>
<DeviceEdit ref="createUserRef" :is-create="true" /> <DeviceEdit ref="createUserRef" :is-create="true" />
<!-- <a-col-->
<!-- :xs="12"-->
<!-- :sm="12"-->
<!-- :md="12"-->
<!-- :lg="6"-->
<!-- :xl="6"-->
<!-- :xxl="6"-->
<!-- class="list-col"-->
<!-- >-->
<!-- <div class="card-wrap empty-wrap">-->
<!-- <a-card :bordered="false" hoverable>-->
<!-- <a-result :status="null" title="点击创建设备">-->
<!-- <template #icon>-->
<!-- <icon-plus style="font-size: 20px" />-->
<!-- </template>-->
<!-- </a-result>-->
<!-- </a-card>-->
<!-- </div>-->
<!-- </a-col>-->
</a-row> </a-row>
</div> </div>
<a-pagination <a-pagination
@ -166,6 +157,15 @@
value: 'false', value: 'false',
}, },
]); ]);
const productOptions = computed(() => {
return [
{
label: '全部',
value: '',
},
];
});
// //
const fetchData = async (params = { size: 10, current: 1 }) => { const fetchData = async (params = { size: 10, current: 1 }) => {
@ -207,26 +207,6 @@
formModel.value = generateFormModel(); formModel.value = generateFormModel();
}; };
// //
// function openDetail(id:number): void{
// const url = router.resolve({
// name: 'deviceDetail',
// params: {id}
// }).href;
// router.push(url);
// }
// //
// const handleDelete = async (id: number) => {
// const res = await deleteDevice(id);
// if (res.status === 200) {
// Message.success({
// content: '',
// duration: 5 * 1000,
// });
// search();
// }
// };
onMounted(() => { onMounted(() => {
search(); search();
}); });

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="container"> <div class="container">
<Breadcrumb :items="['系统管理', '权限管理']" /> <Breadcrumb :items="['系统管理', '操作日志管理']" />
<a-card class="general-card" title=" "> <a-card class="general-card" title=" ">
<a-row> <a-row>
<a-col :flex="1"> <a-col :flex="1">

View File

@ -0,0 +1,5 @@
<script setup lang="ts"></script>
<template> </template>
<style scoped lang="less"></style>

View File

@ -0,0 +1,257 @@
<template>
<div class="container">
<Breadcrumb :items="['系统管理', '操作日志']" />
<a-card class="general-card" title=" ">
<a-row>
<a-col :flex="1">
<a-form
:model="formModel"
:label-col-props="{ span: 6 }"
:wrapper-col-props="{ span: 18 }"
label-align="right"
>
<a-row :gutter="18">
<a-col :span="9">
<a-form-item field="moduleType" label="模块类型">
<a-input
v-model="formModel.moduleType"
style="width: 360px"
placeholder="请输入模块类型"
/>
</a-form-item>
</a-col>
<a-col :span="10">
<a-form-item field="Time" label="时间">
<a-range-picker
show-time
format="YYYY-MM-DD HH:mm"
@ok="timeRang"
/>
</a-form-item>
</a-col>
<a-col :span="9">
<a-form-item field="functionType" label="功能类型">
<a-input
v-model="formModel.functionType"
style="width: 360px"
placeholder="请输入功能类型"
/>
</a-form-item>
</a-col>
</a-row>
</a-form>
</a-col>
<a-divider style="height: 84px" direction="vertical" />
<a-col :flex="'86px'" style="text-align: right">
<a-space direction="vertical" :size="18">
<a-button type="primary" @click="search">
<template #icon>
<icon-search />
</template>
查询
</a-button>
<a-button @click="reset">
<template #icon>
<icon-refresh />
</template>
重置
</a-button>
</a-space>
</a-col>
</a-row>
<a-divider style="margin-top: 0" />
<a-row>
<a-col :span="12">
<a-space>
<a-button
type="primary"
status="danger"
@click="deleteLog(selectedIds)"
>
<template #icon><icon-delete /></template>
批量删除
</a-button>
</a-space>
</a-col>
<a-col
:span="12"
style="
display: flex;
align-items: center;
justify-content: end;
padding-bottom: 20px;
"
>
<a-tooltip content="刷新">
<div class="action-icon" @click="search">
<icon-refresh size="18" />
</div>
</a-tooltip>
</a-col>
</a-row>
<a-table
row-key="id"
:loading="loading"
:pagination="false"
:columns="(cloneColumns as TableColumnData[])"
:data="renderData"
:bordered="false"
:size="size"
:row-selection="rowSelection"
style="margin-bottom: 40px"
@select="select"
@page-change="onPageChange"
>
<template #operationTime="{ record }">
{{ dayjs(record.operationTime).format('YYYY-MM-DD HH:mm') }}
</template>
</a-table>
<a-pagination
style="float: right; position: relative; right: 1px; bottom: 25px"
:total="pagination.total"
:size="size"
show-total
show-jumper
show-page-size
@page-size-change="onSizeChange"
@change="onPageChange"
/>
</a-card>
</div>
</template>
<script lang="ts" setup>
import { computed, onMounted, reactive, ref, watch } from 'vue';
import useLoading from '@/hooks/loading';
import type { TableColumnData } from '@arco-design/web-vue/es/table/interface';
import useTableOption from '@/hooks/table-option';
import usePagination from '@/hooks/pagination';
import dayjs from 'dayjs';
import { LogsRecord, queryLogList, deleteLogs } from '@/api/log';
import { Message } from '@arco-design/web-vue';
const generateFormModel = () => {
return {
moduleType: '',
functionType: '',
publishTimeBegin: '',
publishTimeEnd: '',
};
};
const { pagination, setPagination } = usePagination();
const { loading, setLoading } = useLoading(true);
const renderData = ref<any[]>([]);
const formModel = ref(generateFormModel());
const selectedIds = ref<number[]>([]);
const { cloneColumns, size, deepClone } = useTableOption();
const columns = computed<TableColumnData[]>(() => [
{
title: '模块类型',
dataIndex: 'moduleType',
},
{
title: '功能类型',
dataIndex: 'functionType',
},
{
title: '操作时间',
dataIndex: 'operationTime',
slotName: 'operationTime',
sortable: {
sortDirections: ['ascend', 'descend'],
},
},
{
title: '操作内容',
dataIndex: 'content',
},
// {
// title: '',
// dataIndex: 'operation',
// },
]);
const rowSelection = {
type: 'checkbox',
showCheckedAll: true, // ID
};
const select= (selectedRowKeys: number[]) => {
selectedIds.value = selectedRowKeys;
};
//
const fetchData = async (params = { size: 10, current: 1 }) => {
setLoading(true);
try {
const res: any = await queryLogList(params);
renderData.value = res.data.records;
setPagination(res.data);
} catch (err) {
// you can report use errorHandler or other
} finally {
setLoading(false);
}
};
//
const search = () => {
fetchData({
...pagination.value,
...formModel.value,
} as unknown as LogsRecord);
selectedIds.value = [];
};
//
const onPageChange = (current: number) => {
pagination.value.page = current;
pagination.value.current = current;
search();
};
//
const timeRang = (dateString: string[]) => {
// eslint-disable-next-line prefer-destructuring
formModel.value.publishTimeBegin = dateString[0];
// eslint-disable-next-line prefer-destructuring
formModel.value.publishTimeEnd = dateString[1];
};
//
const onSizeChange = (Size: number) => {
pagination.value.size = Size;
search();
};
//
const reset = () => {
formModel.value = generateFormModel();
};
//
const deleteLog = async (ids: number[]) => {
if (ids.length === 0) {
//
Message.warning('请选择要删除的日志');
return;
}
try {
//
await deleteLogs(ids);
Message.success('日志删除成功');
//
search();
} catch (error) {
Message.error('日志删除失败');
}
};
onMounted(() => {
search();
});
watch(() => columns.value, deepClone, { deep: true, immediate: true });
</script>

View File

@ -68,12 +68,7 @@
> >
<a-input v-model="formData.path" placeholder="请输入路径" /> <a-input v-model="formData.path" placeholder="请输入路径" />
</a-form-item> </a-form-item>
<a-form-item <a-form-item field="icon" label="图标">
field="icon"
label="图标"
:validate-trigger="['change', 'input']"
:rules="[{ required: true, message: '请输入图标' }]"
>
<a-input v-model="formData.icon" placeholder="请输入图标" /> <a-input v-model="formData.icon" placeholder="请输入图标" />
</a-form-item> </a-form-item>
<a-form-item <a-form-item
@ -104,7 +99,10 @@
:validate-trigger="['change', 'input']" :validate-trigger="['change', 'input']"
:rules="[{ required: true, message: '请选择菜单排序' }]" :rules="[{ required: true, message: '请选择菜单排序' }]"
> >
<a-input v-model="formData.menuOrder" placeholder="请输入菜单排序" /> <a-input
:model-value="String(formData.menuOrder)"
placeholder="请输入菜单排序"
/>
</a-form-item> </a-form-item>
<a-form-item <a-form-item
field="permissions" field="permissions"

View File

@ -133,7 +133,6 @@
<!-- 编辑 --> <!-- 编辑 -->
<MenuEdit <MenuEdit
ref="editRef" ref="editRef"
:menu="record"
:id="record.id" :id="record.id"
:menuData="renderData" :menuData="renderData"
:is-create="false" :is-create="false"