database 模块日期筛选,默认一周

This commit is contained in:
任珮宇 2023-11-03 19:05:45 +08:00
parent a6cb982a0f
commit cf92cf8d73

View File

@ -34,6 +34,7 @@
<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { deleteAction, getAction } from '../../api/manage'
import dateFormat from '@/components/jeecg/JEasyCron/format-date'
const columns = [
{
@ -169,8 +170,8 @@ export default {
this.columns = columns
return {
queryParam: {
station: '',
detector: '',
collectStart: this.getBeforeDate(6),
collectStop: dateFormat(new Date(), 'yyyy-MM-dd hh:mm:ss'),
},
delParams: {
sampleData: true,
@ -185,10 +186,33 @@ export default {
}
},
created() {
// this.queryParam.collectStart = this.getBeforeDate(6)
this.getStationList()
this.getDetectorList()
},
methods: {
// n
getBeforeDate(n) {
var n = n
var d = new Date()
var year = d.getFullYear()
var mon = d.getMonth() + 1
var day = d.getDate()
if (day <= n) {
if (mon > 1) {
mon = mon - 1
} else {
year = year - 1
mon = 12
}
}
d.setDate(d.getDate() - n)
year = d.getFullYear()
mon = d.getMonth() + 1
day = d.getDate()
var s = year + '-' + (mon < 10 ? '0' + mon : mon) + '-' + (day < 10 ? '0' + day : day) + ' 00:00:00'
return s
},
async getStationList() {
try {
const { success, result, message } = await getAction('/gardsStations/findPage', {