diff --git a/backend/app/services/oa_related_approval.py b/backend/app/services/oa_related_approval.py index 7fb1fd0a..b7ab4e50 100644 --- a/backend/app/services/oa_related_approval.py +++ b/backend/app/services/oa_related_approval.py @@ -116,6 +116,17 @@ def _format_value(typ: str, raw: Any) -> Tuple[str, bool]: if isinstance(raw, dict): return str(raw.get("name") or "").strip(), False return "", False + if typ == "money": + if raw is None or raw == "": + return "", False + try: + if isinstance(raw, bool): + return "", False + v = float(str(raw).replace(",", "").strip()) + except (TypeError, ValueError): + return str(raw), False + text = f"{v:,.2f}" + return text, False if isinstance(raw, list): text = "、".join(str(x) for x in raw if x is not None and str(x) != "") elif isinstance(raw, dict): diff --git a/web-admin/src/utils/oa-approval-print.ts b/web-admin/src/utils/oa-approval-print.ts index a8ce8acf..3a77f969 100644 --- a/web-admin/src/utils/oa-approval-print.ts +++ b/web-admin/src/utils/oa-approval-print.ts @@ -13,6 +13,8 @@ import { } from '@/utils/oa-approval-print-related' import { formatProgressPersonLines } from '@/utils/oa-progress-person-lines' import { formatDeptDisplay } from '@/utils/oa-dept-value' +import { formatMoneyDisplay } from '@/utils/money-format' +import { toRmbUpper } from '@/utils/rmb-upper' export const OA_PRINT_COMPANY_NAME = '安徽中科兴皖医学研究有限公司' @@ -244,6 +246,27 @@ async function walkRules( continue } + if (type === 'money') { + const showUpper = rule.props?.showUpper !== false + const n = + value == null || value === '' + ? null + : typeof value === 'number' + ? value + : Number(String(value).replace(/,/g, '')) + if (n == null || !Number.isFinite(n)) { + out.push({ label, text: '-' }) + continue + } + const numText = formatMoneyDisplay(n, 2) + const upper = showUpper ? toRmbUpper(n) : '' + out.push({ + label, + text: upper ? `${numText}(${upper})` : numText + }) + continue + } + if (UPLOAD_TYPES.has(type) || String(rule.name || '').toLowerCase().includes('upload')) { const urls = extractUrls(value) out.push({ label, urls: urls.length ? urls : [], text: urls.length ? undefined : '-' })