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

145 lines
5.4 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="请选择类型">
<el-option v-for="item in getLogType()" :key="item.value" :label="item.label" :value="item.value"/>
</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>
<el-button type="primary" icon="Search" @click="queryData(queryParams)">查询</el-button>
<el-button icon="Refresh" @click="queryParams = {}">重置</el-button>
</div>
<div class="button-part" style="justify-content: space-between;">
<el-button icon="Delete" @click="removeData()">删除</el-button>
<TableAbility @searchBtn="isSearch = !isSearch" @refreshBtn="queryData({})"
@downloadBtn="exportData('日志数据', tableData)"></TableAbility>
</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"/>
<el-table-column property="type" label="类型" width="120" align="center"/>
<el-table-column property="title" label="标题" width="120" align="center"/>
<el-table-column property="ip" label="IP地址" width="120" align="center"/>
<el-table-column property="requestMethod" label="请求方式" width="120" align="center"/>
<el-table-column label="请求时间" width="220" align="center">
<template #default="scope">{{ dateFormater('yyyy-MM-dd HH:mm:ss', scope.row.requestTime) }}</template>
</el-table-column>
<el-table-column property="operator" label="操作人" width="120" align="center"/>
<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">
<CommonPagination :total="100" @paginationChange="paginationChange"/>
</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-10 09:25:33 +08:00
import {onMounted, reactive, ref, toRefs, watch} from 'vue'
import {ElMessage, ElMessageBox} from 'element-plus'
import {useRouter, useRoute} from 'vue-router'
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'
2024-04-10 09:25:33 +08:00
import {tableRemoveRow, exportData} from '@/utils/table-util'
import {getLogType} from '@/static-data/core'
import {dateFormater, getEndOfMonth} from '@/utils/date-util'
import * as logManageApi from '@/api/log-manage'
2023-12-26 17:11:15 +08:00
const router = useRouter()
const route = useRoute()
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-10 09:25:33 +08:00
queryData({type: '正常'})
2023-12-25 17:57:18 +08:00
2023-12-26 17:11:15 +08:00
function queryData(e: any) {
2024-04-10 09:25:33 +08:00
loading.value = true
tableData.value = []
setTimeout(() => {
while (tableData.value.length < 10) {
tableData.value.push({
type: e.type || '正常',
title: e.title || '测试',
ip: '127.0.0.1',
requestMethod: 'post',
requestTime: new Date(),
operator: 'admin'
})
}
loading.value = false
}, 200);
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()
logFormRef.value.formData = JSON.parse(JSON.stringify(e))
}, 0)
2023-12-26 17:11:15 +08:00
}
const removeData = (e?: any) => {
2024-04-10 09:25:33 +08:00
const selectRow = e || tableRef.value.getSelectionRows()
tableRemoveRow({data: selectRow}, (res: boolean) => {
if (res) {
// console.log('调用删除', selectRow)
}
})
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
}
const paginationChange = (page: number, size: number) => {
}
2024-04-10 09:25:33 +08:00
function getMonthlyLogCount(startTime: string, endTime: string) {
logManageApi.getMonthlyLogCount(startTime, endTime);
}
onMounted(() => {
const month = dateFormater('yyyy-MM');
const startTime = month + '-01'
const endTime = month + '-' + getEndOfMonth(new Date().getFullYear(), new Date().getMonth() + 1);
getMonthlyLogCount(startTime, endTime);
})
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>