feature (other): 本次提交处理登录日志crud

pull/2/head
dxx 2021-03-21 23:36:32 +08:00
parent 6526a2da95
commit 6e76f42534
4 changed files with 33 additions and 31 deletions

View File

@ -3,7 +3,7 @@ import request from '@/utils/request'
// 查询登录日志列表 // 查询登录日志列表
export function list(query) { export function list(query) {
return request({ return request({
url: '/monitor/logininfor/list', url: '/admin/system/logininfor/',
method: 'get', method: 'get',
params: query params: query
}) })
@ -12,7 +12,7 @@ export function list(query) {
// 删除登录日志 // 删除登录日志
export function delLogininfor(infoId) { export function delLogininfor(infoId) {
return request({ return request({
url: '/monitor/logininfor/' + infoId, url: `/admin/system/logininfor/${infoId}/`,
method: 'delete' method: 'delete'
}) })
} }
@ -20,7 +20,7 @@ export function delLogininfor(infoId) {
// 清空登录日志 // 清空登录日志
export function cleanLogininfor() { export function cleanLogininfor() {
return request({ return request({
url: '/monitor/logininfor/clean', url: '/admin/system/logininfor/clean',
method: 'delete' method: 'delete'
}) })
} }
@ -28,8 +28,8 @@ export function cleanLogininfor() {
// 导出登录日志 // 导出登录日志
export function exportLogininfor(query) { export function exportLogininfor(query) {
return request({ return request({
url: '/monitor/logininfor/export', url: '/admin/system/logininfor/export',
method: 'get', method: 'get',
params: query params: query
}) })
} }

View File

@ -55,14 +55,10 @@ export function resetForm(refName) {
// 添加日期范围 // 添加日期范围
export function addDateRange(params, dateRange, propName) { export function addDateRange(params, dateRange, propName) {
var search = params; let search = JSON.parse(JSON.stringify(params));
if (null != dateRange && '' != dateRange) { if (dateRange.length !== 0) {
// create_datetime__range = this.dateRange
var dateTime=new Date();
search.as = JSON.stringify({create_datetime__range : dateRange}); search.as = JSON.stringify({create_datetime__range : dateRange});
} }
console.log(11,search)
return search; return search;
} }
@ -70,7 +66,8 @@ export function addDateRange(params, dateRange, propName) {
export function selectDictLabel(datas, value) { export function selectDictLabel(datas, value) {
var actions = []; var actions = [];
Object.keys(datas).some((key) => { Object.keys(datas).some((key) => {
if (String(datas[key].dictValue) === ('' + value)) { if (String(datas[key].dictValue) === ('' + String(value))) {
actions.push(datas[key].dictLabel);
actions.push(datas[key].dictLabel); actions.push(datas[key].dictLabel);
return true; return true;
} }

View File

@ -2,7 +2,7 @@
<div class="login"> <div class="login">
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form"> <el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form">
<h3 class="title">{{ title }}</h3> <h3 class="title">{{ title }}</h3>
<el-form-item prop="username"> <el-form-item prop="username" >
<el-input v-model="loginForm.username" type="text" auto-complete="off" placeholder="账号"> <el-input v-model="loginForm.username" type="text" auto-complete="off" placeholder="账号">
<svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" /> <svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" />
</el-input> </el-input>
@ -69,7 +69,7 @@
username: "admin", username: "admin",
password: "123456", password: "123456",
rememberMe: false, rememberMe: false,
code: "", code: "1",
uuid: "" uuid: ""
}, },
loginRules: { loginRules: {

View File

@ -42,11 +42,12 @@
v-model="dateRange" v-model="dateRange"
size="small" size="small"
style="width: 240px" style="width: 240px"
value-format="yyyy-MM-dd" value-format="yyyy-MM-dd HH:mm:ss"
type="daterange" type="daterange"
range-separator="-" range-separator="-"
start-placeholder="开始日期" start-placeholder="开始日期"
end-placeholder="结束日期" end-placeholder="结束日期"
:default-time="['00:00:00', '23:59:59']"
></el-date-picker> ></el-date-picker>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
@ -64,7 +65,7 @@
size="mini" size="mini"
:disabled="multiple" :disabled="multiple"
@click="handleDelete" @click="handleDelete"
v-hasPermi="['monitor:logininfor:remove']" v-hasPermi="['admin:system:logininfor:{id}:delete']"
>删除</el-button> >删除</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
@ -74,7 +75,7 @@
icon="el-icon-delete" icon="el-icon-delete"
size="mini" size="mini"
@click="handleClean" @click="handleClean"
v-hasPermi="['monitor:logininfor:remove']" v-hasPermi="['admin:system:logininfor:clean:delete']"
>清空</el-button> >清空</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
@ -84,7 +85,7 @@
icon="el-icon-download" icon="el-icon-download"
size="mini" size="mini"
@click="handleExport" @click="handleExport"
v-hasPermi="['system:logininfor:export']" v-hasPermi="['admin:system:logininfor:export:get']"
>导出</el-button> >导出</el-button>
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
@ -92,17 +93,17 @@
<el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange"> <el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" /> <el-table-column type="selection" width="55" align="center" />
<el-table-column label="访问编号" align="center" prop="infoId" /> <el-table-column label="访问编号" align="center" prop="id" />
<el-table-column label="用户名称" align="center" prop="userName" /> <el-table-column label="用户名称" align="center" prop="creator_name" />
<el-table-column label="登录地址" align="center" prop="ipaddr" width="130" :show-overflow-tooltip="true" /> <el-table-column label="登录地址" align="center" prop="ipaddr" width="130" :show-overflow-tooltip="true" />
<el-table-column label="登录地点" align="center" prop="loginLocation" :show-overflow-tooltip="true" /> <el-table-column label="登录地点" align="center" prop="loginLocation" :show-overflow-tooltip="true" />
<el-table-column label="浏览器" align="center" prop="browser" /> <el-table-column label="浏览器" align="center" prop="browser" />
<el-table-column label="操作系统" align="center" prop="os" /> <el-table-column label="操作系统" align="center" prop="os" />
<el-table-column label="登录状态" align="center" prop="status" :formatter="statusFormat" /> <el-table-column label="登录状态" align="center" prop="status" :formatter="statusFormat"/>
<el-table-column label="操作信息" align="center" prop="msg" /> <el-table-column label="操作信息" align="center" prop="msg" />
<el-table-column label="登录日期" align="center" prop="loginTime" width="180"> <el-table-column label="登录日期" align="center" prop="create_datetime" width="180">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ parseTime(scope.row.loginTime) }}</span> <span>{{ parseTime(scope.row.create_datetime) }}</span>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -137,9 +138,11 @@ export default {
// //
list: [], list: [],
// //
statusOptions: [], statusOptions:[{dictLabel: '成功', dictValue: true}, {dictLabel: '失败', dictValue: false}],
// //
dateRange: [], dateRange: [],
form: {},
// //
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
@ -152,17 +155,18 @@ export default {
}, },
created() { created() {
this.getList(); this.getList();
this.getDicts("sys_common_status").then(response => { // this.getDicts("sys_common_status").then(response => {
this.statusOptions = response.data; // this.statusOptions = response.data;
}); // });
}, },
methods: { methods: {
/** 查询登录日志列表 */ /** 查询登录日志列表 */
getList() { getList() {
this.loading = true; this.loading = true;
list(this.addDateRange(this.queryParams, this.dateRange)).then(response => { list(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
this.list = response.rows; this.list = response.data.results;
this.total = response.total; this.total = response.data.count;
this.loading = false; this.loading = false;
} }
); );
@ -174,6 +178,7 @@ export default {
/** 搜索按钮操作 */ /** 搜索按钮操作 */
handleQuery() { handleQuery() {
this.queryParams.pageNum = 1; this.queryParams.pageNum = 1;
console.log(this.queryParams)
this.getList(); this.getList();
}, },
/** 重置按钮操作 */ /** 重置按钮操作 */
@ -184,12 +189,12 @@ export default {
}, },
// //
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.ids = selection.map(item => item.infoId) this.ids = selection.map(item => item.id)
this.multiple = !selection.length this.multiple = !selection.length
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const infoIds = row.infoId || this.ids; const infoIds = row.id || this.ids;
this.$confirm('是否确认删除访问编号为"' + infoIds + '"的数据项?', "警告", { this.$confirm('是否确认删除访问编号为"' + infoIds + '"的数据项?', "警告", {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",