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