fix: 贷款账单和信用卡账单,未结清排序功能优化。
This commit is contained in:
@@ -118,6 +118,7 @@ import {
|
||||
} from '@/api/invest/installmentHistory'
|
||||
import { getDicts } from '@/api/system/dict/data.js'
|
||||
import { listAccounts } from '@/api/invest/accounts'
|
||||
import dayjs from 'dayjs'
|
||||
import {onLoad,onShow} from "@dcloudio/uni-app";
|
||||
// 计算属性与监听属性是在vue中而非uniap中 需要注意!!!
|
||||
import {reactive ,toRefs,ref,computed }from "vue";
|
||||
@@ -167,7 +168,20 @@ function loadmore() {
|
||||
function getList() {
|
||||
status.value = 'loading'
|
||||
listInstallmentHistory({ pageSize: 10, pageNum: pageNum.value, ...queryParams.value }).then(res => {
|
||||
listData.value = listData.value.concat(res.rows)
|
||||
let rows = res.rows || []
|
||||
// 如果查询条件是 state='0',按还款日距离当前时间最近的排序
|
||||
if (queryParams.value.state === '0' && rows.length > 0) {
|
||||
const now = dayjs().startOf('day')
|
||||
rows = rows.sort((a, b) => {
|
||||
const dateA = a.repaymentDate ? dayjs(a.repaymentDate).startOf('day') : now
|
||||
const dateB = b.repaymentDate ? dayjs(b.repaymentDate).startOf('day') : now
|
||||
// 计算与当前日期的差值(绝对值),差值小的排在前面
|
||||
const diffA = Math.abs(dateA.diff(now, 'day'))
|
||||
const diffB = Math.abs(dateB.diff(now, 'day'))
|
||||
return diffA - diffB
|
||||
})
|
||||
}
|
||||
listData.value = listData.value.concat(rows)
|
||||
if (listData.value.length < res.total) {
|
||||
status.value = 'loadmore'
|
||||
} else {
|
||||
|
||||
@@ -169,7 +169,20 @@ function loadmore() {
|
||||
function getList() {
|
||||
status.value = 'loading'
|
||||
listInstallmentHistory({ pageSize: 10, pageNum: pageNum.value, ...queryParams.value }).then(res => {
|
||||
listData.value = listData.value.concat(res.rows)
|
||||
let rows = res.rows || []
|
||||
// 如果查询条件是 state='0',按还款日距离当前时间最近的排序
|
||||
if (queryParams.value.state === '0' && rows.length > 0) {
|
||||
const now = dayjs().startOf('day')
|
||||
rows = rows.sort((a, b) => {
|
||||
const dateA = a.repaymentDate ? dayjs(a.repaymentDate).startOf('day') : now
|
||||
const dateB = b.repaymentDate ? dayjs(b.repaymentDate).startOf('day') : now
|
||||
// 计算与当前日期的差值(绝对值),差值小的排在前面
|
||||
const diffA = Math.abs(dateA.diff(now, 'day'))
|
||||
const diffB = Math.abs(dateB.diff(now, 'day'))
|
||||
return diffA - diffB
|
||||
})
|
||||
}
|
||||
listData.value = listData.value.concat(rows)
|
||||
if (listData.value.length < res.total) {
|
||||
status.value = 'loadmore'
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user