Commit f726d4cc authored by 罗林杰's avatar 罗林杰

修改点击量时间搜索

parent 64011e10
...@@ -122,7 +122,8 @@ export default { ...@@ -122,7 +122,8 @@ export default {
{ required: true, message: '请输入用户id', trigger: 'blur' } { required: true, message: '请输入用户id', trigger: 'blur' }
] ]
}, },
dateRange: [] dateRange: [],
nowDayRange: []
} }
}, },
computed: { computed: {
...@@ -131,6 +132,7 @@ export default { ...@@ -131,6 +132,7 @@ export default {
} }
}, },
created() { created() {
this.getNowDayRange()
this.getList() // 列表查询 this.getList() // 列表查询
}, },
methods: { methods: {
...@@ -138,7 +140,7 @@ export default { ...@@ -138,7 +140,7 @@ export default {
getList() { getList() {
this.loading = true this.loading = true
const form = { ...this.queryParams } const form = { ...this.queryParams }
if (this.dateRange.length > 0) { if (this.dateRange && this.dateRange.length > 0) {
form.beginTime = this.dateRange[0] form.beginTime = this.dateRange[0]
form.endTime = this.dateRange[1] form.endTime = this.dateRange[1]
} }
...@@ -150,6 +152,22 @@ export default { ...@@ -150,6 +152,22 @@ export default {
} }
) )
}, },
getNowDayRange() {
const date = new Date()
// 克隆一个新的日期对象以避免修改原始日期
const lastDate = new Date(date.getTime() - 3600 * 1000 * 24)
// 格式化日期为 yyyy-mm-dd
function formatDate(d) {
const year = d.getFullYear()
const month = String(d.getMonth() + 1).padStart(2, '0') // 月份从0开始,需加1
const day = String(d.getDate()).padStart(2, '0')
return `${year}-${month}-${day}`
}
// 将日期格式化为 yyyy-mm-dd
this.nowDayRange = [formatDate(lastDate), formatDate(date)]
this.dateRange = this.nowDayRange
console.log('11111111111', this.nowDayRange)
},
// 取消按钮 // 取消按钮
cancel() { cancel() {
this.open = false this.open = false
...@@ -179,7 +197,7 @@ export default { ...@@ -179,7 +197,7 @@ export default {
memTraffic: undefined, memTraffic: undefined,
flag: '' flag: ''
} }
this.dateRange = [] this.dateRange = this.nowDayRange
this.handleQuery() this.handleQuery()
} }
} }
......
...@@ -150,7 +150,7 @@ export default { ...@@ -150,7 +150,7 @@ export default {
getList() { getList() {
this.loading = true this.loading = true
const form = { ...this.queryParams } const form = { ...this.queryParams }
if (this.dateRange.length > 0) { if (this.dateRange && this.dateRange.length > 0) {
form.beginTime = this.dateRange[0] form.beginTime = this.dateRange[0]
form.endTime = this.dateRange[1] form.endTime = this.dateRange[1]
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment