登录日志 优化代码

ywj_dev
CTP 2 years ago
parent 82f3c5b229
commit d2b76cfe40

@ -1,6 +1,13 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="mini" :inline="true" v-show="showSearch" label-width="68px"> <el-form
:model="queryParams"
ref="queryForm"
size="mini"
:inline="true"
v-show="showSearch"
label-width="68px"
>
<!-- <el-form-item label="登录地址:" prop="ipaddr" label-width="80px">--> <!-- <el-form-item label="登录地址:" prop="ipaddr" label-width="80px">-->
<!-- <el-input--> <!-- <el-input-->
<!-- v-model="queryParams.ipaddr"--> <!-- v-model="queryParams.ipaddr"-->
@ -34,79 +41,136 @@
<!--</el-form-item>--> <!--</el-form-item>-->
<el-form-item> <el-form-item>
<el-button-group> <el-button-group>
<el-button type="primary" icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button> <el-button
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button> type="primary"
icon="el-icon-refresh"
size="mini"
@click="resetQuery"
>重置</el-button
>
<el-button
type="primary"
icon="el-icon-search"
size="mini"
@click="handleQuery"
>搜索</el-button
>
</el-button-group> </el-button-group>
</el-form-item> </el-form-item>
</el-form> </el-form>
<!-- <el-row :gutter="10" class="mb8">--> <!-- <el-row :gutter="10" class="mb8">
<!-- <el-col :span="1.5">--> <el-col :span="1.5">
<!-- <el-button--> <el-button
<!-- type="danger"--> type="danger"
<!-- plain--> plain
<!-- icon="el-icon-delete"--> icon="el-icon-delete"
<!-- size="mini"--> size="mini"
<!-- :disabled="multiple"--> :disabled="multiple"
<!-- @click="handleDelete"--> @click="handleDelete"
<!-- v-hasPermi="['monitor:logininfor:remove']"--> v-hasPermi="['monitor:logininfor:remove']"
<!-- >删除--> >删除
<!-- </el-button>--> </el-button>
<!-- </el-col>--> </el-col>
<!-- <el-col :span="1.5">--> <el-col :span="1.5">
<!-- <el-button--> <el-button
<!-- type="danger"--> type="danger"
<!-- plain--> plain
<!-- icon="el-icon-delete"--> icon="el-icon-delete"
<!-- size="mini"--> size="mini"
<!-- @click="handleClean"--> @click="handleClean"
<!-- v-hasPermi="['monitor:logininfor:remove']"--> v-hasPermi="['monitor:logininfor:remove']"
<!-- >清空--> >清空
<!-- </el-button>--> </el-button>
<!-- </el-col>--> </el-col>
<!-- <el-col :span="1.5">--> <el-col :span="1.5">
<!-- <el-button--> <el-button
<!-- type="primary"--> type="primary"
<!-- plain--> plain
<!-- icon="el-icon-unlock"--> icon="el-icon-unlock"
<!-- size="mini"--> size="mini"
<!-- :disabled="single"--> :disabled="single"
<!-- @click="handleUnlock"--> @click="handleUnlock"
<!-- v-hasPermi="['monitor:logininfor:unlock']"--> v-hasPermi="['monitor:logininfor:unlock']"
<!-- >解锁--> >解锁
<!-- </el-button>--> </el-button>
<!-- </el-col>--> </el-col>
<!-- <el-col :span="1.5">--> <el-col :span="1.5">
<!-- <el-button--> <el-button
<!-- type="warning"--> type="warning"
<!-- plain--> plain
<!-- icon="el-icon-download"--> icon="el-icon-download"
<!-- size="mini"--> size="mini"
<!-- @click="handleExport"--> @click="handleExport"
<!-- v-hasPermi="['monitor:logininfor:export']"--> v-hasPermi="['monitor:logininfor:export']"
<!-- >导出--> >导出
<!-- </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>
<!-- </el-row>--> </el-row> -->
<el-table ref="tables" v-loading="loading" :data="list" @selection-change="handleSelectionChange" border <!-- <el-table
:default-sort="defaultSort" @sort-change="handleSortChange"> ref="tables"
<el-table-column type="selection" width="55" align="center"/> v-loading="loading"
:data="list"
@selection-change="handleSelectionChange"
border
:default-sort="defaultSort"
@sort-change="handleSortChange"
> -->
<el-table
ref="tables"
v-loading="loading"
:data="list"
border
:default-sort="defaultSort"
>
<!-- <el-table-column type="selection" width="55" align="center" /> -->
<el-table-column label="序号" type="index"></el-table-column> <el-table-column label="序号" type="index"></el-table-column>
<el-table-column label="用户名称" align="center" prop="userName" :show-overflow-tooltip="true" sortable="custom" <el-table-column
:sort-orders="['descending', 'ascending']"/> label="用户名称"
<el-table-column label="登录地址" align="center" prop="ipaddr" width="130" :show-overflow-tooltip="true"/> align="center"
<el-table-column label="登录地点" align="center" prop="loginLocation" :show-overflow-tooltip="true"/> prop="userName"
<el-table-column label="浏览器" align="center" prop="browser" :show-overflow-tooltip="true"/> :show-overflow-tooltip="true"
<el-table-column label="操作系统" align="center" prop="os" show-overflow-tooltip/> :sort-orders="['descending', 'ascending']"
/>
<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="browser"
:show-overflow-tooltip="true"
/>
<el-table-column
label="操作系统"
align="center"
prop="os"
show-overflow-tooltip
/>
<!--<el-table-column label="登录状态" align="center" prop="status">--> <!--<el-table-column label="登录状态" align="center" prop="status">-->
<!-- <template slot-scope="scope">--> <!-- <template slot-scope="scope">-->
<!-- <dict-tag :options="dict.type.sys_common_status" :value="scope.row.status"/>--> <!-- <dict-tag :options="dict.type.sys_common_status" :value="scope.row.status"/>-->
<!-- </template>--> <!-- </template>-->
<!--</el-table-column>--> <!--</el-table-column>-->
<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="loginTime"
width="180"
>
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ parseTime(scope.row.loginTime) }}</span> <span>{{ parseTime(scope.row.loginTime) }}</span>
</template> </template>
@ -117,7 +181,7 @@
</el-table> </el-table>
<pagination <pagination
v-show="total>0" v-show="total > 0"
:total="total" :total="total"
:page.sync="queryParams.page" :page.sync="queryParams.page"
:limit.sync="queryParams.limit" :limit.sync="queryParams.limit"
@ -127,11 +191,11 @@
</template> </template>
<script> <script>
import {list, delLogininfor, cleanLogininfor, unlockLogininfor} from "@/api/monitor/logininfor"; import { list } from "@/api/monitor/logininfor";
export default { export default {
name: "Logininfor", name: "Logininfor",
dicts: ['sys_common_status'], dicts: ["sys_common_status"],
data() { data() {
return { return {
// //
@ -153,15 +217,15 @@ export default {
// //
dateRange: [], dateRange: [],
// //
defaultSort: {prop: 'loginTime', order: 'descending'}, defaultSort: { prop: "loginTime", order: "descending" },
// //
queryParams: { queryParams: {
page: 1, page: 1,
limit: 10, limit: 10,
ipaddr: undefined, ipaddr: undefined,
userName: undefined, userName: undefined,
status: undefined status: undefined,
} },
}; };
}, },
created() { created() {
@ -171,7 +235,8 @@ export default {
/** 查询登录日志列表 */ /** 查询登录日志列表 */
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.data.list; this.list = response.data.list;
this.total = response.data.total; this.total = response.data.total;
this.loading = false; this.loading = false;
@ -187,60 +252,72 @@ export default {
resetQuery() { resetQuery() {
this.dateRange = []; this.dateRange = [];
this.resetForm("queryForm"); this.resetForm("queryForm");
this.$refs.tables.sort(this.defaultSort.prop, this.defaultSort.order) this.$refs.tables.sort(this.defaultSort.prop, this.defaultSort.order);
this.handleQuery(); this.handleQuery();
}, },
/** 多选框选中数据 */ /** 多选框选中数据 */
handleSelectionChange(selection) { /* handleSelectionChange(selection) {
this.ids = selection.map(item => item.infoId) this.ids = selection.map((item) => item.infoId);
this.single = selection.length != 1 this.single = selection.length != 1;
this.multiple = !selection.length this.multiple = !selection.length;
this.selectName = selection.map(item => item.userName); this.selectName = selection.map((item) => item.userName);
}, }, */
/** 排序触发事件 */ /** 排序触发事件 */
handleSortChange(column, prop, order) { /* handleSortChange(column, prop, order) {
this.queryParams.orderByColumn = column.prop; this.queryParams.orderByColumn = column.prop;
this.queryParams.isAsc = column.order; this.queryParams.isAsc = column.order;
this.getList(); this.getList();
}, }, */
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { /* handleDelete(row) {
const infoIds = row.infoId || this.ids; const infoIds = row.infoId || this.ids;
this.$modal.confirm('是否确认删除访问编号为"' + infoIds + '"的数据项?').then(function () { this.$modal
return delLogininfor(infoIds); .confirm('是否确认删除访问编号为"' + infoIds + '"的数据项?')
}).then(() => { .then(function () {
this.getList(); return delLogininfor(infoIds);
this.$modal.msgSuccess("删除成功"); })
}).catch(() => { .then(() => {
}); this.getList();
}, this.$modal.msgSuccess("删除成功");
})
.catch(() => {});
}, */
/** 清空按钮操作 */ /** 清空按钮操作 */
handleClean() { /* handleClean() {
this.$modal.confirm('是否确认清空所有登录日志数据项?').then(function () { this.$modal
return cleanLogininfor(); .confirm("是否确认清空所有登录日志数据项?")
}).then(() => { .then(function () {
this.getList(); return cleanLogininfor();
this.$modal.msgSuccess("清空成功"); })
}).catch(() => { .then(() => {
}); this.getList();
}, this.$modal.msgSuccess("清空成功");
})
.catch(() => {});
}, */
/** 解锁按钮操作 */ /** 解锁按钮操作 */
handleUnlock() { /* handleUnlock() {
const username = this.selectName; const username = this.selectName;
this.$modal.confirm('是否确认解锁用户"' + username + '"数据项?').then(function () { this.$modal
return unlockLogininfor(username); .confirm('是否确认解锁用户"' + username + '"数据项?')
}).then(() => { .then(function () {
this.$modal.msgSuccess("用户" + username + "解锁成功"); return unlockLogininfor(username);
}).catch(() => { })
}); .then(() => {
}, this.$modal.msgSuccess("用户" + username + "解锁成功");
})
.catch(() => {});
}, */
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { /* handleExport() {
this.download('monitor/logininfor/export', { this.download(
...this.queryParams "monitor/logininfor/export",
}, `logininfor_${new Date().getTime()}.xlsx`) {
} ...this.queryParams,
} },
`logininfor_${new Date().getTime()}.xlsx`
);
}, */
},
}; };
</script> </script>

@ -17,21 +17,42 @@
></el-input> ></el-input>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button-group style="margin-left: 10px;display:flex;"> <el-button-group style="margin-left: 10px; display: flex">
<el-button type="primary" icon="el-icon-refresh" @click="onReset"></el-button> <el-button type="primary" icon="el-icon-refresh" @click="onReset"
<el-button type="primary" icon="el-icon-search" @click="search"></el-button> >重置</el-button
<el-button type="primary" icon="el-icon-plus" @click="handleAddClick"></el-button> >
<el-button type="primary" icon="el-icon-search" @click="search"
>查询</el-button
>
<el-button
type="primary"
icon="el-icon-plus"
@click="handleAddClick"
>新增</el-button
>
</el-button-group> </el-button-group>
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-table v-loading="loading" :data="list" style="width: 100%" border highlight-current-row> <el-table
v-loading="loading"
:data="list"
style="width: 100%"
border
highlight-current-row
>
<el-table-column label="序号" type="index" width="60"></el-table-column> <el-table-column label="序号" type="index" width="60"></el-table-column>
<el-table-column label="业务单" prop="originName"></el-table-column> <el-table-column label="业务单" prop="originName"></el-table-column>
<el-table-column label="出入库单" header-align="center"> <el-table-column label="出入库单" header-align="center">
<el-table-column label="目标出入库单" prop="targetName"></el-table-column> <el-table-column
<el-table-column label="时间间隔(h)" prop="beforeTime"></el-table-column> label="目标出入库单"
prop="targetName"
></el-table-column>
<el-table-column
label="时间间隔(h)"
prop="beforeTime"
></el-table-column>
<el-table-column label="单据状态" prop="auditStatus"> <el-table-column label="单据状态" prop="auditStatus">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ orderStatus[scope.row.auditStatus] }}</span> <span>{{ orderStatus[scope.row.auditStatus] }}</span>
@ -40,8 +61,14 @@
</el-table-column> </el-table-column>
<el-table-column label="业务单" header-align="center"> <el-table-column label="业务单" header-align="center">
<el-table-column label="目标业务单" prop="targetBusName"></el-table-column> <el-table-column
<el-table-column label="时间间隔(h)" prop="busBeforeTime"></el-table-column> label="目标业务单"
prop="targetBusName"
></el-table-column>
<el-table-column
label="时间间隔(h)"
prop="busBeforeTime"
></el-table-column>
<el-table-column label="单据状态" prop="busAuditStatus"> <el-table-column label="单据状态" prop="busAuditStatus">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ orderStatus[scope.row.busAuditStatus] }}</span> <span>{{ orderStatus[scope.row.busAuditStatus] }}</span>
@ -60,22 +87,19 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="备注" prop="remark"></el-table-column> <el-table-column label="备注" prop="remark"></el-table-column>
<el-table-column label="操作"> <el-table-column label="操作" width="120" fixed="right">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
type="text" type="text"
@click.native.stop="handleModifyClick(scope.row)" @click.native.stop="handleModifyClick(scope.row)"
>编辑 >编辑
</el-button </el-button>
>
<el-button <el-button
type="text" type="text"
@click.native.stop="deleteDialog(scope.row.id)" @click.native.stop="deleteDialog(scope.row.id)"
>删除 >删除
</el-button </el-button>
>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -92,18 +116,14 @@
<modifyDialog :inputQuery="inputQuery"></modifyDialog> <modifyDialog :inputQuery="inputQuery"></modifyDialog>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" size="small" @click="onAddSubmit" <el-button type="primary" size="small" @click="onAddSubmit"
>提交 >提交
</el-button </el-button>
> <el-button size="small" @click="cancelDialog"> </el-button>
<el-button size="small" @click="cancelDialog"
>取消
</el-button
>
</div> </div>
</el-dialog> </el-dialog>
<pagination <pagination
v-show="total>0" v-show="total > 0"
:total="total" :total="total"
:limit.sync="filterQuery.limit" :limit.sync="filterQuery.limit"
:page.sync="filterQuery.page" :page.sync="filterQuery.page"
@ -113,13 +133,13 @@
</div> </div>
</template> </template>
<script> <script>
import {isBlank} from "@/utils/strUtil"; import { isBlank } from "@/utils/strUtil";
import modifyDialog from "@/views/system/param/busTypeChangeModify.vue"; import modifyDialog from "@/views/system/param/busTypeChangeModify.vue";
import { import {
getBusTypeChangeList, getBusTypeChangeList,
updateBusTypeChange, updateBusTypeChange,
addBusTypeChange, addBusTypeChange,
deleteBusTypeChange deleteBusTypeChange,
} from "@/api/basic/busTypeChange"; } from "@/api/basic/busTypeChange";
export default { export default {
@ -141,7 +161,7 @@ export default {
name: null, name: null,
enable: null, enable: null,
type: null, type: null,
remark: null remark: null,
}, },
enableMap: { enableMap: {
false: "禁用", false: "禁用",
@ -154,21 +174,19 @@ export default {
2: "产品申购", 2: "产品申购",
3: "采购计划", 3: "采购计划",
4: "盘点转单", 4: "盘点转单",
5: "采购订单" 5: "采购订单",
}, },
orderStatus: { orderStatus: {
1: "草稿", 1: "草稿",
2: "待审核", 2: "待审核",
3: "已审核" 3: "已审核",
}, },
formMap: { formMap: {
add: "新增单据生成设置", add: "新增单据生成设置",
edit: "编辑单据生成设置", edit: "编辑单据生成设置",
}, },
formName: null, formName: null,
}; };
}, },
@ -188,7 +206,6 @@ export default {
cancelDialog() { cancelDialog() {
this.getList(); this.getList();
this.modifyDialogVisible = false; this.modifyDialogVisible = false;
}, },
search() { search() {
this.filterQuery.page = 1; this.filterQuery.page = 1;
@ -219,7 +236,7 @@ export default {
onAddSubmit() { onAddSubmit() {
if (isBlank(this.inputQuery.originName)) { if (isBlank(this.inputQuery.originName)) {
this.$message.error("单据类型名称不能为空!") this.$message.error("单据类型名称不能为空!");
return; return;
} }
if (isBlank(this.inputQuery.originAction)) { if (isBlank(this.inputQuery.originAction)) {
@ -240,41 +257,45 @@ export default {
} }
if (this.formName === "add") { if (this.formName === "add") {
let numRegExp = '^[0-9]*$'; let numRegExp = "^[0-9]*$";
let numReg = new RegExp(numRegExp); let numReg = new RegExp(numRegExp);
if (numReg.test(this.inputQuery.name)) { if (numReg.test(this.inputQuery.name)) {
this.$message.error("单据类型名称不得为纯数字类型!"); this.$message.error("单据类型名称不得为纯数字类型!");
return; return;
} }
addBusTypeChange(this.inputQuery).then((res) => { addBusTypeChange(this.inputQuery)
if (res.code === 20000) { .then((res) => {
this.cancelDialog(); if (res.code === 20000) {
this.cancelDialog();
this.loading = false;
this.getList();
}
})
.catch((error) => {
this.loading = false; this.loading = false;
this.getList(); });
}
}).catch((error) => {
this.loading = false;
});
} else { } else {
updateBusTypeChange(this.inputQuery).then((res) => { updateBusTypeChange(this.inputQuery)
if (res.code === 20000) { .then((res) => {
if (res.code === 20000) {
this.loading = false;
this.cancelDialog();
this.getList();
} else {
this.$message.error(res.message);
}
})
.catch((error) => {
this.loading = false; this.loading = false;
this.$message.error(error.message);
this.cancelDialog(); this.cancelDialog();
this.getList(); });
} else {
this.$message.error(res.message);
}
}).catch((error) => {
this.loading = false;
this.$message.error(error.message);
this.cancelDialog();
});
} }
}, },
handleAddClick() { handleAddClick() {
this.formName = 'add'; this.formName = "add";
this.inputQuery = { this.inputQuery = {
id: null, id: null,
originName: null, originName: null,
@ -290,7 +311,7 @@ export default {
}, },
handleModifyClick(row) { handleModifyClick(row) {
this.formName = 'edit'; this.formName = "edit";
this.inputQuery = row; this.inputQuery = row;
this.modifyDialogVisible = true; this.modifyDialogVisible = true;
}, },
@ -302,7 +323,7 @@ export default {
type: "warning", type: "warning",
}) })
.then(() => { .then(() => {
let params = {id: rowId}; let params = { id: rowId };
deleteBusTypeChange(params).then((res) => { deleteBusTypeChange(params).then((res) => {
if (res.code === 20000) { if (res.code === 20000) {
this.$message.success("删除成功!"); this.$message.success("删除成功!");
@ -310,14 +331,13 @@ export default {
} else { } else {
this.$message.error(res.message); this.$message.error(res.message);
} }
}) });
}) })
.catch(() => { .catch(() => {});
});
}, },
}, },
components: { components: {
modifyDialog modifyDialog,
}, },
created() { created() {
this.getList(); this.getList();

Loading…
Cancel
Save