diff --git a/jshERP-web/src/utils/util.js b/jshERP-web/src/utils/util.js index 4024016e..85501b3a 100644 --- a/jshERP-web/src/utils/util.js +++ b/jshERP-web/src/utils/util.js @@ -530,6 +530,24 @@ export function getNowFormatStr() { 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中根据指定值删除数组中的元素 * @param arrylist diff --git a/jshERP-web/src/views/system/LogList.vue b/jshERP-web/src/views/system/LogList.vue index 869aead8..e14da5c2 100644 --- a/jshERP-web/src/views/system/LogList.vue +++ b/jshERP-web/src/views/system/LogList.vue @@ -20,7 +20,7 @@ import { JeecgListMixin } from '@/mixins/JeecgListMixin' import JEllipsis from '@/components/jeecg/JEllipsis' + import { getBeforeFormatDate } from '@/utils/util' import {getAction } from '@/api/manage' + import moment from 'moment' export default { name: "LogList", @@ -107,12 +109,16 @@ queryParam: { operation:'', content:'', - createTimeRange:[], userInfo: '', clientIp:'', 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", isManage: false, // 表头 @@ -154,6 +160,7 @@ }, created() { this.initUserInfo() + this.defaultTimeStr = [moment(getBeforeFormatDate(30), this.dateFormat), moment(this.currentDay, this.dateFormat)] }, methods: { onDateChange: function (value, dateString) { @@ -164,6 +171,20 @@ onDateOk(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() { getAction('/user/getUserSession').then((res)=>{ if(res.code === 200){