用户金币流水日期查询 修复
(cherry picked from commit 53713b4201d5f43684f402b7c93b01965b0b9ebb)
This commit is contained in:
parent
6950aa1b40
commit
89b748a69c
@ -20,7 +20,7 @@
|
||||
:start-placeholder="$t('pages.goldRunningWater.filter.startDate')"
|
||||
:end-placeholder="$t('pages.goldRunningWater.filter.endDate')"
|
||||
:clearable="false"
|
||||
@change="renderData"
|
||||
@change="handleDateChange"
|
||||
/>
|
||||
</div>
|
||||
<div class="gold-running-water-content">
|
||||
@ -129,7 +129,6 @@
|
||||
</template>
|
||||
<script>
|
||||
import { listGoldRunningWater } from '@/api/purchase'
|
||||
import { beforeDateObject, datePlusDays, getMonthLastDate } from '@/utils'
|
||||
export default {
|
||||
name: 'RunningWaterPreviewTabs',
|
||||
props: {
|
||||
@ -142,8 +141,6 @@ export default {
|
||||
return {
|
||||
listLoading: false,
|
||||
list: [],
|
||||
notProccessRangeDate: false,
|
||||
beforeIntervalDays: 1,
|
||||
rangeDate: [],
|
||||
listQuery: {
|
||||
userId: '',
|
||||
@ -154,43 +151,56 @@ export default {
|
||||
notMore: false,
|
||||
pickerOptions: {
|
||||
disabledDate(date) {
|
||||
return date.getTime() > datePlusDays(new Date(), 1).getTime()
|
||||
const tomorrow = new Date()
|
||||
tomorrow.setDate(tomorrow.getDate() + 1)
|
||||
tomorrow.setHours(23, 59, 59, 999)
|
||||
return date.getTime() > tomorrow.getTime()
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
// 先初始化默认时间范围(今天 00:00:00 ~ 23:59:59)
|
||||
const defaultRangeTime = this.defaultRangeTimestamp()
|
||||
this.rangeDate = defaultRangeTime
|
||||
this.listQuery.startTime = defaultRangeTime[0]
|
||||
this.listQuery.endTime = defaultRangeTime[1]
|
||||
// 再初始化 userId,最后触发一次加载
|
||||
if (this.userId) {
|
||||
this.listQuery.userId = this.userId
|
||||
this.renderData()
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
userId: {
|
||||
handler(newVal) {
|
||||
if (newVal) {
|
||||
this.listQuery.userId = newVal
|
||||
this.renderData()
|
||||
}
|
||||
},
|
||||
immediate: true
|
||||
},
|
||||
rangeDate: {
|
||||
immediate: true,
|
||||
deep: true,
|
||||
handler(newVal) {
|
||||
if (this.notProccessRangeDate === true) {
|
||||
this.notProccessRangeDate = false
|
||||
return
|
||||
}
|
||||
if (newVal && newVal.length > 0) {
|
||||
this.listQuery.startTime = newVal[0]
|
||||
this.listQuery.endTime = newVal[1]
|
||||
return
|
||||
}
|
||||
this.notProccessRangeDate = true
|
||||
userId(newVal) {
|
||||
if (newVal) {
|
||||
this.listQuery.userId = newVal
|
||||
this.resetAndLoad()
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 日期选择器 change 事件:直接从事件参数取值,避免 watch 异步延迟问题
|
||||
handleDateChange(val) {
|
||||
if (val && val.length === 2) {
|
||||
this.listQuery.startTime = val[0]
|
||||
this.listQuery.endTime = val[1]
|
||||
} else {
|
||||
// 清空时恢复默认
|
||||
const defaultRangeTime = this.defaultRangeTimestamp()
|
||||
this.rangeDate = defaultRangeTime
|
||||
this.listQuery.startTime = defaultRangeTime[0]
|
||||
this.listQuery.endTime = defaultRangeTime[1]
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
this.resetAndLoad()
|
||||
},
|
||||
// 换条件时必须调此方法,重置游标和列表后再加载
|
||||
resetAndLoad() {
|
||||
this.list = []
|
||||
this.listQuery.lastId = ''
|
||||
this.notMore = false
|
||||
this.renderData()
|
||||
},
|
||||
renderData() {
|
||||
const that = this
|
||||
if (!that.listQuery.userId) {
|
||||
@ -214,31 +224,15 @@ export default {
|
||||
console.error(er)
|
||||
})
|
||||
},
|
||||
// 默认时间范围:今天 00:00:00 ~ 今天 23:59:59
|
||||
defaultRangeTimestamp() {
|
||||
const defStartDate = beforeDateObject(this.beforeIntervalDays)
|
||||
const mDate = datePlusDays(new Date(), 1)
|
||||
mDate.setHours(23)
|
||||
mDate.setMinutes(59)
|
||||
mDate.setSeconds(59)
|
||||
const monthLastDate = getMonthLastDate()
|
||||
monthLastDate.setHours(23)
|
||||
monthLastDate.setMinutes(59)
|
||||
monthLastDate.setSeconds(59)
|
||||
const nowDate = mDate.getMonth() !== monthLastDate.getMonth() ? monthLastDate : mDate
|
||||
const startDate = new Date()
|
||||
startDate.setHours(0, 0, 0, 0)
|
||||
|
||||
if (nowDate.getMonth() !== defStartDate.getMonth()) {
|
||||
// 最近两小时
|
||||
const startDate = nowDate.getTime() - 60 * 60 * 1000 * 2
|
||||
const endDate = new Date()
|
||||
endDate.setHours(23, 59, 59, 0)
|
||||
|
||||
if (startDate.getMonth() !== nowDate.getMonth()) {
|
||||
// 最近2分钟
|
||||
return [nowDate.getTime() - 60 * 1000 * 2, nowDate.getTime()]
|
||||
}
|
||||
|
||||
return [defStartDate.getTime(), nowDate.getTime()]
|
||||
}
|
||||
|
||||
return [defStartDate.getTime(), nowDate.getTime()]
|
||||
return [startDate.getTime(), endDate.getTime()]
|
||||
},
|
||||
handleClose() {
|
||||
this.$emit('close')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user