diff --git a/src/pages/work/bill/creditInstallmentHistory/list.vue b/src/pages/work/bill/creditInstallmentHistory/list.vue index b176f3d..a238624 100644 --- a/src/pages/work/bill/creditInstallmentHistory/list.vue +++ b/src/pages/work/bill/creditInstallmentHistory/list.vue @@ -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 { diff --git a/src/pages/work/bill/onlineLendHistory/list.vue b/src/pages/work/bill/onlineLendHistory/list.vue index 6e7e1fb..bed95f8 100644 --- a/src/pages/work/bill/onlineLendHistory/list.vue +++ b/src/pages/work/bill/onlineLendHistory/list.vue @@ -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 {