rax-medical/src/views/logs-manage/logs-manage.vue

172 lines
5.7 KiB
Vue
Raw Normal View History

2023-12-25 17:57:18 +08:00
<template>
2024-04-10 09:25:33 +08:00
<div class="table-page custom-table-table">
<h3 class="main-color" style="font-size: 25px;line-height: 1;padding: 8px 0;">近30天登陆汇总</h3>
<div style="width: 100%;height: 35%;">
<LoginChart/>
</div>
<div class="search-part" v-show="isSearch">
<div class="search-cell">
<span class="label">类型</span>
<el-select v-model="queryParams.type" placeholder="请选择类型">
2024-04-30 17:31:20 +08:00
<el-option v-for="item in Object.keys(logType)" :key="item" :label="logType[item]" :value="item"/>
2024-04-10 09:25:33 +08:00
</el-select>
</div>
<div class="search-cell">
<span class="label">请求时间</span>
<el-date-picker v-model="queryParams.time" type="datetimerange" range-separator="-" start-placeholder="开始时间"
end-placeholder="结束时间"/>
</div>
2024-04-30 17:31:20 +08:00
<el-button type="primary" icon="Search" @click="search">查询</el-button>
<el-button icon="Refresh" @click="resetSearch">重置</el-button>
2024-04-10 09:25:33 +08:00
</div>
<div class="button-part" style="justify-content: space-between;">
<el-button icon="Delete" @click="removeData()">删除</el-button>
2024-04-30 17:31:20 +08:00
<TableAbility @searchBtn="isSearch = !isSearch" @refreshBtn="init"
@downloadBtn="exportMultiData('日志数据', tableData)"></TableAbility>
2024-04-10 09:25:33 +08:00
</div>
<div class="table-part">
<el-table ref="tableRef" v-loading="loading" :data="tableData" height="100%" border show-overflow-tooltip
2023-12-26 17:11:15 +08:00
@row-click="tableRowClick">
2024-04-10 09:25:33 +08:00
<el-table-column type="selection" width="55"/>
<el-table-column type="index" label="#" width="55" align="center"/>
2024-04-30 17:31:20 +08:00
<el-table-column property="logType" label="类型" width="120" align="center">
<template #default="scope">{{ logType[scope.row.logType] }}</template>
</el-table-column>
2024-04-10 09:25:33 +08:00
<el-table-column property="title" label="标题" width="120" align="center"/>
2024-04-30 17:31:20 +08:00
<el-table-column property="remoteAddr" label="IP地址" width="120" align="center"/>
<el-table-column property="method" label="请求方式" width="120" align="center"/>
2024-04-10 09:25:33 +08:00
<el-table-column label="请求时间" width="220" align="center">
2024-04-30 17:31:20 +08:00
<template #default="scope">{{ scope.row.createTime }}</template>
2024-04-10 09:25:33 +08:00
</el-table-column>
2024-04-30 17:31:20 +08:00
<el-table-column property="createBy" label="操作人" width="120" align="center"/>
2024-04-10 09:25:33 +08:00
<el-table-column label="操作" align="center">
<template #default="scope">
2023-12-26 17:11:15 +08:00
<span @click.stop>
<el-button link icon="EditPen" @click="viewData(scope.row)">详情</el-button>
<el-button link icon="Delete" @click="removeData(scope.row)">删除</el-button>
</span>
2024-04-10 09:25:33 +08:00
</template>
</el-table-column>
</el-table>
2023-12-25 17:57:18 +08:00
</div>
2024-04-10 09:25:33 +08:00
<div class="pagination-part">
2024-04-30 17:31:20 +08:00
<CommonPagination :total="total" @paginationChange="paginationChange"/>
2024-04-10 09:25:33 +08:00
</div>
</div>
<el-dialog v-model="isFormDialog" :title="formDialogTitle" width="40%">
<LogForm ref="logFormRef" :type="formDialogTitle === '详情' ? 'view' : 'edit'" @close="isFormDialog = false"/>
</el-dialog>
2023-12-25 17:57:18 +08:00
</template>
<script lang='ts' setup>
2024-04-30 17:31:20 +08:00
import {onMounted, ref} from 'vue'
2023-12-26 17:11:15 +08:00
import LoginChart from './chart/login-chart.vue'
import CommonPagination from '@/components/common-pagination.vue'
import LogForm from './form/log-form.vue'
import {exportData, exportMultiData, tableRemoveRow} from '@/utils/table-util'
2024-04-30 17:31:20 +08:00
import {dateFormater} from '@/utils/date-util'
2024-04-10 09:25:33 +08:00
import * as logManageApi from '@/api/log-manage'
2024-04-30 17:31:20 +08:00
import {ElMessage} from "element-plus";
2023-12-26 17:11:15 +08:00
2024-04-30 17:31:20 +08:00
const logType: any = {
"0": '正常',
"1": '添加',
"2": '删除',
"3": '修改',
"4": '异常'
}
2023-12-26 17:11:15 +08:00
const tableRef = ref()
const logFormRef = ref()
2023-12-27 16:49:37 +08:00
const isSearch = ref(true)
const loading = ref(true)
2023-12-26 17:11:15 +08:00
const isFormDialog = ref(false)
const formDialogTitle = ref('')
const queryParams = ref({} as any)
const tableData = ref([] as any)
2024-04-30 17:31:20 +08:00
let current = 0;
let size = 10;
const total = ref(0);
onMounted(() => {
init();
})
2023-12-26 17:11:15 +08:00
2024-04-30 17:31:20 +08:00
function init() {
loading.value = true;
2024-05-17 12:06:29 +08:00
current = 0;
total.value = 0;
2024-04-30 17:31:20 +08:00
getList();
loading.value = false;
}
2023-12-25 17:57:18 +08:00
2024-04-30 17:31:20 +08:00
function getList() {
logManageApi.getPage(current, size, {
timeInterval: queryParams.value.timeStr,
logType: queryParams.value.type
}).then((res: any) => {
if (res.code == 0) {
total.value = res.data.total
tableData.value = res.data.records
2024-04-10 09:25:33 +08:00
}
2024-04-30 17:31:20 +08:00
})
}
function search() {
queryParams.value.timeStr = [dateFormater("yyyy-MM-dd", queryParams.value.time[0]),
dateFormater("yyyy-MM-dd", queryParams.value.time[1])]
init();
}
function resetSearch() {
queryParams.value = {};
init();
2023-12-26 17:11:15 +08:00
}
const viewData = (e: any) => {
2024-04-10 09:25:33 +08:00
isFormDialog.value = true
formDialogTitle.value = '详情'
setTimeout(() => {
logFormRef.value.resetData()
console.log(e)
2024-04-10 09:25:33 +08:00
logFormRef.value.formData = JSON.parse(JSON.stringify(e))
}, 0)
2023-12-26 17:11:15 +08:00
}
const removeData = (e?: any) => {
2024-04-30 17:31:20 +08:00
const selectRow = e ? [e] : tableRef.value.getSelectionRows()
2024-04-10 09:25:33 +08:00
tableRemoveRow({data: selectRow}, (res: boolean) => {
if (res) {
2024-04-30 17:31:20 +08:00
const ids: string[] = [];
selectRow.forEach((row: any) => {
ids.push(row.id);
})
logManageApi.deleteByIds(ids).then((res: any) => {
if (res.code == 0) {
ElMessage.success("删除成功");
init();
} else {
ElMessage.error(res.msg ? res.msg : "删除失败");
}
})
2024-04-10 09:25:33 +08:00
}
})
2023-12-26 17:11:15 +08:00
}
const tableRowClick = (row: any) => {
2024-04-10 09:25:33 +08:00
tableRef.value.toggleRowSelection(row)
2023-12-26 17:11:15 +08:00
}
2024-04-10 09:25:33 +08:00
2024-04-30 17:31:20 +08:00
const paginationChange = (page: number, s: number) => {
current = page
size = s
getList()
2024-04-10 09:25:33 +08:00
}
2023-12-25 17:57:18 +08:00
</script>
<style lang='scss' scoped>
2023-12-26 17:11:15 +08:00
.table-page.custom-table-table {
2024-04-10 09:25:33 +08:00
.table-part {
height: calc(65% - 230px);
}
2023-12-26 17:11:15 +08:00
}
2023-12-25 17:57:18 +08:00
</style>