用户金币流水日期查询 修复

(cherry picked from commit 53713b4201d5f43684f402b7c93b01965b0b9ebb)
This commit is contained in:
tianfeng 2026-06-01 16:14:14 +08:00
parent 6950aa1b40
commit 89b748a69c

View File

@ -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')