This commit is contained in:
zlwu committed 2026-06-16 10:11:25 +08:00
1 parent eaf7d490ec
commit 5679d7981c
52 files changed
+7606 -4839

No files matched your search

@@ -0,0 +1,157 @@
export type PaymentFlowStepKey =
| 'receipt-submit'
| 'finance-receipt'
| 'refund-submit'
| 'finance-refund'
export type PaymentFlowStepState = 'pending' | 'done' | 'current'
export interface PaymentFlowStepField {
label: string
value: string
multiline?: boolean
slot?: 'attachments'
attachmentUrls?: string
}
export interface PaymentFlowStep {
key: PaymentFlowStepKey
title: string
state: PaymentFlowStepState
time: string
fields: PaymentFlowStepField[]
}
function dash(v: unknown) {
if (v == null || v === '') return '—'
return String(v)
}
function formatAmount(v: unknown) {
if (v == null || v === '') return '—'
const n = Number(v)
if (Number.isNaN(n)) return '—'
return `¥${n.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`
}
function hasReceiptSubmit(detail: Record<string, unknown>) {
const status = String(detail.payStatus || '')
return ['jfqrz', 'yjf', 'tfqrz', 'ytf'].includes(status)
}
function hasFinanceReceipt(detail: Record<string, unknown>) {
const status = String(detail.payStatus || '')
return ['yjf', 'tfqrz', 'ytf'].includes(status) || Boolean(detail.financeConfirmTime)
}
function hasRefundSubmit(detail: Record<string, unknown>) {
const status = String(detail.payStatus || '')
return ['tfqrz', 'ytf'].includes(status) || Boolean(detail.refundApplyTime)
}
function hasFinanceRefund(detail: Record<string, unknown>) {
const status = String(detail.payStatus || '')
return status === 'ytf' || Boolean(detail.refundFinanceConfirmTime)
}
function resolveStepState(
key: PaymentFlowStepKey,
detail: Record<string, unknown>,
activeStepKey?: PaymentFlowStepKey
): PaymentFlowStepState {
if (activeStepKey === key) return 'current'
const doneMap: Record<PaymentFlowStepKey, boolean> = {
'receipt-submit': hasReceiptSubmit(detail),
'finance-receipt': hasFinanceReceipt(detail),
'refund-submit': hasRefundSubmit(detail),
'finance-refund': hasFinanceRefund(detail)
}
if (doneMap[key]) {
if (activeStepKey === key) return 'current'
return 'done'
}
return 'pending'
}
function receiptSubmitTime(detail: Record<string, unknown>) {
const status = String(detail.payStatus || '')
if (status === 'jfqrz') return dash(detail.updateTime)
if (hasFinanceReceipt(detail) && detail.transferTime) return dash(detail.transferTime)
return '—'
}
export function buildPaymentFlowSteps(
detail: Record<string, unknown> | null | undefined,
activeStepKey?: PaymentFlowStepKey
): PaymentFlowStep[] {
const d = detail || {}
const steps: PaymentFlowStep[] = [
{
key: 'receipt-submit',
title: '缴费确认信息',
state: resolveStepState('receipt-submit', d, activeStepKey),
time: receiptSubmitTime(d),
fields: [
{ label: '缴费金额(元)', value: formatAmount(d.paymentAmount ?? d.amount) },
{ label: '备注', value: dash(d.remark), multiline: true },
{
label: '转账凭证',
value: '',
slot: 'attachments',
attachmentUrls: String(d.transferAttachments || '')
}
]
},
{
key: 'finance-receipt',
title: '缴费财务确认信息',
state: resolveStepState('finance-receipt', d, activeStepKey),
time: dash(d.financeConfirmTime),
fields: [
{ label: '财务备注', value: dash(d.financeRemark), multiline: true },
{
label: '财务确认附件',
value: '',
slot: 'attachments',
attachmentUrls: String(d.financeConfirmAttachments || '')
}
]
},
{
key: 'refund-submit',
title: '退费确认信息',
state: resolveStepState('refund-submit', d, activeStepKey),
time: dash(d.refundApplyTime),
fields: [
{ label: '退费金额(元)', value: formatAmount(d.refundAmount) },
{ label: '退费备注', value: dash(d.refundRemark), multiline: true },
{
label: '退费附件',
value: '',
slot: 'attachments',
attachmentUrls: String(d.refundAttachments || '')
}
]
},
{
key: 'finance-refund',
title: '退费财务确认信息',
state: resolveStepState('finance-refund', d, activeStepKey),
time: dash(d.refundFinanceConfirmTime),
fields: [
{ label: '财务备注', value: dash(d.refundFinanceRemark), multiline: true },
{
label: '财务确认附件',
value: '',
slot: 'attachments',
attachmentUrls: String(d.refundFinanceConfirmAttachments || '')
}
]
}
]
return steps
}
@@ -0,0 +1,185 @@
import {
type PaymentFlowStep,
type PaymentFlowStepKey,
type PaymentFlowStepState
} from '@/utils/clinical-payment-flow-steps'
import { transferTypeLabel } from '@/utils/protocol-payment-labels'
export type { PaymentFlowStep, PaymentFlowStepKey, PaymentFlowStepState }
function dash(v: unknown) {
if (v == null || v === '') return '—'
return String(v)
}
function formatAmount(v: unknown) {
if (v == null || v === '') return '—'
const n = Number(v)
if (Number.isNaN(n)) return '—'
return `¥${n.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`
}
function resolveAttachmentUrls(
detail: Record<string, unknown>,
urlField: string,
filesField: string
): string {
const urls = String(detail[urlField] || '')
if (urls.trim()) return urls
const files = detail[filesField]
if (!Array.isArray(files)) return ''
return files
.map((f) => String((f as Record<string, unknown>).fileUrl || '').trim())
.filter(Boolean)
.join(',')
}
function hasReceiptSubmit(detail: Record<string, unknown>) {
const status = String(detail.payStatus || '')
return ['jfqrz', 'yjf', 'tfqrz', 'ytf'].includes(status)
}
function hasFinanceReceipt(detail: Record<string, unknown>) {
const status = String(detail.payStatus || '')
return ['yjf', 'tfqrz', 'ytf'].includes(status)
}
function hasRefundSubmit(detail: Record<string, unknown>) {
const status = String(detail.payStatus || '')
return ['tfqrz', 'ytf'].includes(status)
}
function hasFinanceRefund(detail: Record<string, unknown>) {
const status = String(detail.payStatus || '')
return status === 'ytf'
}
function resolveStepState(
key: PaymentFlowStepKey,
detail: Record<string, unknown>,
activeStepKey?: PaymentFlowStepKey
): PaymentFlowStepState {
if (activeStepKey === key) return 'current'
const doneMap: Record<PaymentFlowStepKey, boolean> = {
'receipt-submit': hasReceiptSubmit(detail),
'finance-receipt': hasFinanceReceipt(detail),
'refund-submit': hasRefundSubmit(detail),
'finance-refund': hasFinanceRefund(detail)
}
if (doneMap[key]) return 'done'
return 'pending'
}
function receiptSubmitTime(detail: Record<string, unknown>) {
const status = String(detail.payStatus || '')
if (status === 'jfqrz') return dash(detail.updateTime)
if (hasFinanceReceipt(detail) && detail.transferTime) return dash(detail.transferTime)
return '—'
}
function financeReceiptTime(detail: Record<string, unknown>) {
const status = String(detail.payStatus || '')
if (status === 'jfqrz' || status === 'dfj') return '—'
return dash(detail.financeConfirmTime || detail.updateTime)
}
function refundSubmitTime(detail: Record<string, unknown>) {
const status = String(detail.payStatus || '')
if (!['tfqrz', 'ytf'].includes(status)) return '—'
if (status === 'tfqrz') return dash(detail.updateTime)
return dash(detail.refundApplyTime || detail.updateTime)
}
function refundFinanceTime(detail: Record<string, unknown>) {
const status = String(detail.payStatus || '')
if (status !== 'ytf') return '—'
return dash(detail.refundFinanceConfirmTime || detail.updateTime)
}
export function buildProtocolPaymentFlowSteps(
detail: Record<string, unknown> | null | undefined,
activeStepKey?: PaymentFlowStepKey
): PaymentFlowStep[] {
const d = detail || {}
const transferUrls = resolveAttachmentUrls(d, 'transferAttachments', 'attachments')
const financeUrls = resolveAttachmentUrls(
d,
'financeConfirmAttachments',
'financeConfirmAttachmentFiles'
)
const refundUrls = resolveAttachmentUrls(d, 'refundAttachments', 'refundAttachmentFiles')
const refundFinanceUrls = resolveAttachmentUrls(
d,
'refundFinanceConfirmAttachments',
'refundFinanceConfirmAttachmentFiles'
)
return [
{
key: 'receipt-submit',
title: '缴费确认信息',
state: resolveStepState('receipt-submit', d, activeStepKey),
time: receiptSubmitTime(d),
fields: [
{ label: '转账方式', value: transferTypeLabel(String(d.transferType || '')) || '—' },
{ label: '实缴金额(元)', value: formatAmount(d.transferAmount) },
{ label: '转账时间', value: dash(d.transferTime) },
{ label: '备注', value: dash(d.remark), multiline: true },
{
label: '转账凭证',
value: '',
slot: 'attachments',
attachmentUrls: transferUrls
}
]
},
{
key: 'finance-receipt',
title: '缴费财务确认信息',
state: resolveStepState('finance-receipt', d, activeStepKey),
time: financeReceiptTime(d),
fields: [
{ label: '财务备注', value: dash(d.financeRemark), multiline: true },
{
label: '财务确认附件',
value: '',
slot: 'attachments',
attachmentUrls: financeUrls
}
]
},
{
key: 'refund-submit',
title: '退费确认信息',
state: resolveStepState('refund-submit', d, activeStepKey),
time: refundSubmitTime(d),
fields: [
{ label: '退费金额(元)', value: formatAmount(d.refundAmount) },
{ label: '退费备注', value: dash(d.refundRemark), multiline: true },
{
label: '退费附件',
value: '',
slot: 'attachments',
attachmentUrls: refundUrls
}
]
},
{
key: 'finance-refund',
title: '退费财务确认信息',
state: resolveStepState('finance-refund', d, activeStepKey),
time: refundFinanceTime(d),
fields: [
{ label: '财务备注', value: dash(d.refundFinanceRemark), multiline: true },
{
label: '财务确认附件',
value: '',
slot: 'attachments',
attachmentUrls: refundFinanceUrls
}
]
}
]
}