FlowPacs/yudao-admin-ui/src/views/system/loginlog/index.vue
YunaiV 4a23a696f4 1. 修复“登陆”=》“登录”
2. 增加社交平台的绑定与解绑
2021-10-06 09:33:21 +08:00

142 lines
5.2 KiB
Vue

<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="登录地址" prop="userIp">
<el-input v-model="queryParams.userIp" placeholder="请输入登录地址" clearable style="width: 240px;" size="small"
@keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="用户名称" prop="username">
<el-input v-model="queryParams.username" placeholder="请输入用户名称" clearable style="width: 240px;" size="small"
@keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select v-model="queryParams.status" placeholder="结果" clearable size="small" style="width: 240px">
<el-option :key="true" label="成功" :value="true"/>
<el-option :key="false" label="失败" :value="false"/>
</el-select>
</el-form-item>
<el-form-item label="登录时间">
<el-date-picker v-model="dateRange" size="small" style="width: 240px" value-format="yyyy-MM-dd"
type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="warning" icon="el-icon-download" size="mini" @click="handleExport"
v-hasPermi="['system:login-log:export']">导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="list">
<el-table-column label="访问编号" align="center" prop="id" />
<el-table-column label="日志类型" align="center" prop="logType">
<template slot-scope="scope">
<span>{{ getDictDataLabel(DICT_TYPE.SYS_LOGIN_TYPE, scope.row.logType) }}</span>
</template>
</el-table-column>
<el-table-column label="用户名称" align="center" prop="username" />
<el-table-column label="登录地址" align="center" prop="userIp" width="130" :show-overflow-tooltip="true" />
<el-table-column label="userAgent" align="center" prop="userAgent" width="400" :show-overflow-tooltip="true" />
<el-table-column label="结果" align="center" prop="status">
<template slot-scope="scope">
<span v-if="scope.row.result === 0">成功</span>
<span v-if="scope.row.result > 0">失败:{{ getDictDataLabel(DICT_TYPE.SYS_LOGIN_RESULT, scope.row.result) }} </span>
</template>
</el-table-column>
<el-table-column label="登录日期" align="center" prop="loginTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
</el-table>
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
@pagination="getList"/>
</div>
</template>
<script>
import { list, exportLoginLog } from "@/api/system/loginlog";
export default {
name: "Logininfor",
data() {
return {
// 遮罩层
loading: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 表格数据
list: [],
// 状态数据字典
statusOptions: [],
// 日期范围
dateRange: [],
// 查询参数
queryParams: {
pageNo: 1,
pageSize: 10,
userIp: undefined,
username: undefined,
status: undefined
}
};
},
created() {
this.getList();
},
methods: {
/** 查询登录日志列表 */
getList() {
this.loading = true;
list(this.addDateRange(this.queryParams, [
this.dateRange[0] ? this.dateRange[0] + ' 00:00:00' : undefined,
this.dateRange[1] ? this.dateRange[1] + ' 23:59:59' : undefined,
])).then(response => {
this.list = response.data.list;
this.total = response.data.total;
this.loading = false;
}
);
},
// 登录状态字典翻译
statusFormat(row, column) {
return this.selectDictLabel(this.statusOptions, row.status);
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNo = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.dateRange = [];
this.resetForm("queryForm");
this.handleQuery();
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有操作日志数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return exportLoginLog(queryParams);
}).then(response => {
this.downloadExcel(response, '登录日志.xls');
})
}
}
};
</script>