Explorar el Código

feat(oa): format money fields in print and related-approval summary

Show formatted amount with optional uppercase on print; summary uses numeric text.

Co-authored-by: Cursor <cursoragent@cursor.com>
zlwu hace 3 meses
padre
commit
b5c4ba4c4f

+ 11 - 0
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):

+ 23 - 0
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 : '-' })