给日志查询设置默认一个月的时间范围

This commit is contained in:
jishenghua 2024-04-09 22:24:46 +08:00
parent da876d8543
commit 8580f21ade
2 changed files with 42 additions and 3 deletions

View File

@ -530,6 +530,24 @@ export function getNowFormatStr() {
return year +''+ month +''+ strDate +''+ strHours +''+ strMinutes +''+ strSeconds; return year +''+ month +''+ strDate +''+ strHours +''+ strMinutes +''+ strSeconds;
} }
/**
* js获取N天前的日期 格式yyyy-MM-dd
*/
export function getBeforeFormatDate(day) {
let currentDate = new Date();
let thirtyDaysAgo = new Date(currentDate.getTime() - day * 24 * 60 * 60 * 1000);
let seperator1 = "-";
let month = thirtyDaysAgo.getMonth() + 1;
let strDate = thirtyDaysAgo.getDate();
if (month >= 1 && month <= 9) {
month = "0" + month;
}
if (strDate >= 0 && strDate <= 9) {
strDate = "0" + strDate;
}
return thirtyDaysAgo.getFullYear() + seperator1 + month + seperator1 + strDate
}
/** /**
* JS中根据指定值删除数组中的元素 * JS中根据指定值删除数组中的元素
* @param arrylist * @param arrylist

View File

@ -20,7 +20,7 @@
<a-form-item label="创建时间" :labelCol="labelCol" :wrapperCol="wrapperCol"> <a-form-item label="创建时间" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-range-picker <a-range-picker
style="width: 100%" style="width: 100%"
v-model="queryParam.createTimeRange" v-model="defaultTimeStr"
format="YYYY-MM-DD" format="YYYY-MM-DD"
:placeholder="['开始时间', '结束时间']" :placeholder="['开始时间', '结束时间']"
@change="onDateChange" @change="onDateChange"
@ -93,7 +93,9 @@
<script> <script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin' import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import JEllipsis from '@/components/jeecg/JEllipsis' import JEllipsis from '@/components/jeecg/JEllipsis'
import { getBeforeFormatDate } from '@/utils/util'
import {getAction } from '@/api/manage' import {getAction } from '@/api/manage'
import moment from 'moment'
export default { export default {
name: "LogList", name: "LogList",
@ -107,12 +109,16 @@
queryParam: { queryParam: {
operation:'', operation:'',
content:'', content:'',
createTimeRange:[],
userInfo: '', userInfo: '',
clientIp:'', clientIp:'',
tenantLoginName:'', tenantLoginName:'',
tenantType:'' tenantType:'',
beginTime: getBeforeFormatDate(30),
endTime: moment().format('YYYY-MM-DD'),
}, },
dateFormat: 'YYYY-MM-DD',
currentDay: moment().format('YYYY-MM-DD'),
defaultTimeStr: '',
tabKey: "1", tabKey: "1",
isManage: false, isManage: false,
// 表头 // 表头
@ -154,6 +160,7 @@
}, },
created() { created() {
this.initUserInfo() this.initUserInfo()
this.defaultTimeStr = [moment(getBeforeFormatDate(30), this.dateFormat), moment(this.currentDay, this.dateFormat)]
}, },
methods: { methods: {
onDateChange: function (value, dateString) { onDateChange: function (value, dateString) {
@ -164,6 +171,20 @@
onDateOk(value) { onDateOk(value) {
console.log(value); console.log(value);
}, },
searchReset() {
this.queryParam = {
operation:'',
content:'',
userInfo: '',
clientIp:'',
tenantLoginName:'',
tenantType:'',
beginTime: getBeforeFormatDate(30),
endTime: moment().format('YYYY-MM-DD')
}
this.defaultTimeStr = [moment(getBeforeFormatDate(30), this.dateFormat), moment(this.currentDay, this.dateFormat)]
this.loadData(1);
},
initUserInfo() { initUserInfo() {
getAction('/user/getUserSession').then((res)=>{ getAction('/user/getUserSession').then((res)=>{
if(res.code === 200){ if(res.code === 200){