feat(LogTable): 添加日志导出功能并优化日期处理
- 新增导出按钮及导出功能实现 - 默认设置查询时间为昨天0点到今天23:59:59 - 优化表格高度适应页面 - 重置功能现在保留coilId并重置为默认时间范围
This commit is contained in:
@@ -27,10 +27,11 @@
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="getLogList">查询</el-button>
|
||||
<el-button @click="resetParams">重置</el-button>
|
||||
<el-button @click="exportLog">导出</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-table v-loading="logLoading" :data="logList" style="width: 100%" border stripe>
|
||||
<el-table v-loading="logLoading" :data="logList" height="calc(100vh - 200px)" style="width: 100%" border stripe>
|
||||
<el-table-column prop="createTime" label="操作时间" width="180">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.createTime }}
|
||||
@@ -115,13 +116,36 @@ export default {
|
||||
RawMaterialInfo,
|
||||
},
|
||||
data() {
|
||||
// 计算昨天和今天的日期
|
||||
const today = new Date();
|
||||
const yesterday = new Date();
|
||||
yesterday.setDate(yesterday.getDate() - 1);
|
||||
|
||||
// 昨天设置为0点0分0秒
|
||||
yesterday.setHours(0, 0, 0, 0);
|
||||
// 今天设置为23点59分59秒
|
||||
today.setHours(23, 59, 59, 999);
|
||||
|
||||
// 格式化日期为 yyyy-MM-dd HH:mm:ss
|
||||
const formatDate = (date) => {
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
const hours = String(date.getHours()).padStart(2, '0');
|
||||
const minutes = String(date.getMinutes()).padStart(2, '0');
|
||||
const seconds = String(date.getSeconds()).padStart(2, '0');
|
||||
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
||||
};
|
||||
|
||||
return {
|
||||
logList: [],
|
||||
total: 0,
|
||||
logParams: {
|
||||
coilId: null,
|
||||
startTime: "",
|
||||
endTime: "",
|
||||
// startTime: yesterday,
|
||||
// endTime: today,
|
||||
startTime: formatDate(yesterday),
|
||||
endTime: formatDate(today),
|
||||
operationType: null,
|
||||
inOutType: null,
|
||||
pageNum: 1,
|
||||
@@ -201,11 +225,40 @@ export default {
|
||||
.catch((err) => { this.$message.error("删除失败:" + err.message); });
|
||||
})
|
||||
},
|
||||
exportLog() {
|
||||
this.download('/wms/coilWarehouseOperationLog/exportByWarehouseAndTime', {
|
||||
...this.logParams,
|
||||
}, '日志导出.xlsx')
|
||||
},
|
||||
// 重置筛选条件
|
||||
resetParams() {
|
||||
// 计算昨天和今天的日期
|
||||
const today = new Date();
|
||||
const yesterday = new Date();
|
||||
yesterday.setDate(yesterday.getDate() - 1);
|
||||
|
||||
// 昨天设置为0点0分0秒
|
||||
yesterday.setHours(0, 0, 0, 0);
|
||||
// 今天设置为23点59分59秒
|
||||
today.setHours(23, 59, 59, 999);
|
||||
|
||||
// 格式化日期为 yyyy-MM-dd HH:mm:ss
|
||||
const formatDate = (date) => {
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
const hours = String(date.getHours()).padStart(2, '0');
|
||||
const minutes = String(date.getMinutes()).padStart(2, '0');
|
||||
const seconds = String(date.getSeconds()).padStart(2, '0');
|
||||
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
||||
};
|
||||
|
||||
this.logParams = {
|
||||
startTime: "",
|
||||
endTime: "",
|
||||
coilId: this.coilId,
|
||||
// startTime: yesterday,
|
||||
// endTime: today,
|
||||
startTime: formatDate(yesterday),
|
||||
endTime: formatDate(today),
|
||||
operationType: null,
|
||||
inOutType: null,
|
||||
pageNum: 1,
|
||||
|
||||
Reference in New Issue
Block a user