This commit is contained in:
zlwu committed 2026-05-17 12:36:40 +08:00
1 parent 62cfb8fbbf
commit 135dd550b6
2 files changed
+48

No files matched your search

@@ -43,6 +43,37 @@ export function formatPaymentDueDate(d: unknown) {
return s
}
/** 分期应缴预警天数(与分期预警规则一致:应缴日在当天起未来 N 天内,含逾期) */
export const PAYMENT_DUE_WARN_DAYS = 15
function parsePaymentDueYmd(ymd: unknown): Date | null {
const raw = String(ymd || '').replace(/\D/g, '')
if (raw.length !== 8) return null
const y = Number(raw.slice(0, 4))
const m = Number(raw.slice(4, 6)) - 1
const d = Number(raw.slice(6, 8))
const dt = new Date(y, m, d)
if (dt.getFullYear() !== y || dt.getMonth() !== m || dt.getDate() !== d) return null
return dt
}
function startOfLocalDay(d: Date) {
return new Date(d.getFullYear(), d.getMonth(), d.getDate())
}
/** 应缴日是否不晚于「今天 + warnDays」(含当天与已逾期) */
export function isPaymentDueWithinWarnWindow(
installmentDueDate: unknown,
warnDays = PAYMENT_DUE_WARN_DAYS
) {
const due = parsePaymentDueYmd(installmentDueDate)
if (!due) return false
const today = startOfLocalDay(new Date())
const limit = new Date(today)
limit.setDate(limit.getDate() + warnDays)
return due.getTime() <= limit.getTime()
}
export function formatPaymentAmount(v: unknown) {
if (v == null || v === '') return '-'
const n = Number(v)
@@ -89,6 +89,7 @@
v-loading="loading"
stripe
row-key="id"
:row-class-name="paymentRowClassName"
@selection-change="handleSelectionChange"
>
<el-table-column
@@ -431,6 +432,7 @@
} from '@/api/collection-protocol'
import { fetchUploadAttachment } from '@/api/business'
import { maskIdCard } from '@/utils/mask-sensitive'
import { isPaymentDueWithinWarnWindow } from '@/utils/protocol-payment-labels'
defineOptions({ name: 'CellStoragePaymentInfo' })
@@ -548,6 +550,12 @@
return `${d.slice(0, 4)}-${d.slice(4, 6)}-${d.slice(6, 8)}`
}
function paymentRowClassName({ row }: { row: Record<string, unknown> }) {
if (activeTab.value !== 'dfj') return ''
if (String(row.payStatus || '') !== 'dfj') return ''
return isPaymentDueWithinWarnWindow(row.installmentDueDate) ? 'row-due-soon' : ''
}
function formatAmount(v: unknown) {
if (v == null || v === '') return '-'
const n = Number(v)
@@ -885,4 +893,13 @@
color: #ef4444;
}
}
.list-table :deep(tr.row-due-soon > td.el-table__cell) {
background-color: #fca5a5 !important;
color: #7f1d1d;
}
.list-table :deep(tr.row-due-soon:hover > td.el-table__cell) {
background-color: #f87171 !important;
}
</style>