From 28240d3cfb356844899ab6cb3a42262883c707fc Mon Sep 17 00:00:00 2001 From: tianyongbao Date: Tue, 10 Feb 2026 08:24:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B4=B7=E6=AC=BE=E8=B4=A6=E5=8D=95?= =?UTF-8?q?=E5=92=8C=E4=BF=A1=E7=94=A8=E5=8D=A1=E8=B4=A6=E5=8D=95=EF=BC=8C?= =?UTF-8?q?=E6=9C=AA=E7=BB=93=E6=B8=85=E6=8E=92=E5=BA=8F=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../work/bill/creditInstallmentHistory/list.vue | 16 +++++++++++++++- src/pages/work/bill/onlineLendHistory/list.vue | 15 ++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) 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 {