Преглед на файлове

fix(web): 统一清单次行字号和合同金额样式

sy преди 3 дни
родител
ревизия
d6fcec5450

+ 15 - 0
web-scaffold/src/components/ContractLedgerAmountCell.tsx

@@ -0,0 +1,15 @@
+import { Tri } from "./triState";
+import { WORD_FETCH_FAILED, WORD_UNCONFIGURED } from "../lib/api/lockedCopy";
+import type { ContractRowView } from "../lib/contract-demo";
+
+export function ContractLedgerAmountCell({ contract }: {
+  contract: Pick<ContractRowView, "amount" | "amountState" | "serviceMonths" | "serviceMonthsState">;
+}) {
+  const { amount, amountState, serviceMonths, serviceMonthsState } = contract;
+  return <td className="contract-ledger-amount">
+    {amountState === "val" ? <span className="ops-money">¥{amount.toLocaleString("zh-CN")}</span>
+      : <Tri tone={amountState === "fail" ? "fail" : "missing"} text={amountState === "fail" ? WORD_FETCH_FAILED : WORD_UNCONFIGURED} />}
+    <small>{serviceMonthsState === "val" ? `服务期 ${serviceMonths} 个月`
+      : <Tri tone={serviceMonthsState === "fail" ? "fail" : "missing"} text={serviceMonthsState === "fail" ? WORD_FETCH_FAILED : WORD_UNCONFIGURED} />}</small>
+  </td>;
+}

+ 2 - 1
web-scaffold/src/pages/ContractManagementPage.tsx

@@ -1,6 +1,7 @@
 import { useDetailLinkState } from "../lib/detail-navigation";
 import { FilterSelect } from "../components/ui/filter-select";
 import { PageIntro } from "../components/PageIntro";
+import { ContractLedgerAmountCell } from "../components/ContractLedgerAmountCell";
 import { useEffect, useMemo, useState } from "react";
 import { Plus, Search, Trash2, X, CalendarClock } from "lucide-react";
 import { useNavigate, useSearchParams } from "react-router";
@@ -159,7 +160,7 @@ export function ContractManagementPage() {
           <td title={item.extNo || undefined}>{item.extNo ? <span className="ops-mono">{item.extNo}</span> : <span className="table-placeholder">—</span>}</td>
           <td>{state ? <OpsStatus tone={contractStatusTone[state]}>{state}</OpsStatus> : <Tri tone={item.periodState === "fail" ? "fail" : "missing"} text={item.periodState === "fail" ? WORD_FETCH_FAILED : WORD_UNCONFIGURED} title="缺少生效日或结束日,状态不可判" />}{expiringRow && <OpsStatus tone="warning">快到期 · {expiringLabel(item.end)}</OpsStatus>}<small>{item.periodState === "val" ? `${d(item.start)} 至 ${d(item.end)}` : <Tri tone={item.periodState === "fail" ? "fail" : "missing"} text={item.periodState === "fail" ? WORD_FETCH_FAILED : WORD_UNCONFIGURED} />}</small></td>
           <td>{item.opened === undefined || item.opened === null ? <Tri tone={item.opened === undefined ? "fail" : "missing"} text={item.opened === undefined ? WORD_FETCH_FAILED : WORD_UNCONFIGURED} title="是否已开通取关联工单回填,取数失败只坏本列" /> : <OpsStatus tone={item.opened ? "success" : "warning"}>{item.opened ? "已开通" : "未开通"}</OpsStatus>}<small>实际开通日 {item.openedOn ? d(item.openedOn) : <span className="table-placeholder">未回填</span>}</small></td>
-          <td>{item.amountState === "val" ? <span className="ops-money">¥{item.amount.toLocaleString("zh-CN")}</span> : <Tri tone={item.amountState === "fail" ? "fail" : "missing"} text={item.amountState === "fail" ? WORD_FETCH_FAILED : WORD_UNCONFIGURED} />}<small>{item.serviceMonthsState === "val" ? `服务期 ${item.serviceMonths} 个月` : <Tri tone={item.serviceMonthsState === "fail" ? "fail" : "missing"} text={item.serviceMonthsState === "fail" ? WORD_FETCH_FAILED : WORD_UNCONFIGURED} />}</small></td>
+          <ContractLedgerAmountCell contract={item} />
           <td><strong><TableValueText>{item.agent || WORD_UNCONFIGURED}</TableValueText></strong><small><TableValueText>{item.agentPhone || WORD_UNCONFIGURED}</TableValueText></small></td>
 <td><div className="ops-inline-actions"><button type="button" onClick={(event) => { event.stopPropagation(); navigate(`/contracts/${link}`, { state: linkState }); }}>详情</button>{!view.readOnly && <OpsResponsiveActions expanded={expandedActions} items={[
             ...(expiringRow && renewContractId ? [{ label: "续签合同", shortLabel: "续签", icon: <CalendarClock size={15} />, title: "按旧合同带入金额、服务期、服务条目与新的生效日(旧止期次日),生成新合同;不替换原订阅", onSelect: () => navigate(`/contracts/new?renew=${encodeURIComponent(renewContractId)}`, { state: linkState }) }] : []),

+ 3 - 4
web-scaffold/src/pages/PartyViewPages.tsx

@@ -20,6 +20,7 @@
  */
 import { Children, useCallback, useEffect, useRef, useState, type ReactNode } from "react";
 import { PageIntro } from "../components/PageIntro";
+import { ContractLedgerAmountCell } from "../components/ContractLedgerAmountCell";
 import { SettlementLedgerHead, useSettlementLedgerTable, type SettlementLedgerColumn } from "../components/SettlementLedger";
 import { ArrowDown, ArrowLeft, ArrowRight, CalendarClock, CalendarDays, Download, Info, Search, X } from "lucide-react";
 import { Link, useLocation, useParams, useSearchParams } from "react-router";
@@ -54,7 +55,7 @@ import type {
 } from "../lib/api/types";
 import { WORD_FETCH_FAILED, WORD_NOT_PROVIDED, WORD_UNCONFIGURED } from "../lib/api/lockedCopy";
 import { ACCT_STATUS, PAY_CYCLE, SUBJECT_TYPE, label } from "../lib/api/labels";
-import { contractStatusOf, contractStatusTone } from "../lib/contract-demo";
+import { contractFromRow, contractStatusOf, contractStatusTone } from "../lib/contract-demo";
 import { EXPIRING_SOON_DAYS } from "../lib/expiring-soon";
 import { settleTextFromSnapshot } from "../lib/settle-text";
 import { lastClosedMonth } from "../lib/recon";
@@ -787,7 +788,6 @@ export function PartyContractListPage({ kind }: { kind: "partner" | "operator" }
         const end = row.end_date?.slice(0, 10);
         const lifecycle = start && end ? contractStatusOf(start, end) : null;
         const planNames = contractPlanNames(row);
-        const amount = row.contract_amount_cents ?? row.amount_cents;
         return <tr key={row.contract_id}>
           <td><span className="table-cell-title" title={row.contract_no}>{row.contract_no}</span><small title={row.customer_name}>{row.customer_name || <span className="table-placeholder">—</span>}</small></td>
           <td className="ops-mono" title={row.external_no || undefined}>{row.external_no || <span className="table-placeholder">—</span>}</td>
@@ -797,8 +797,7 @@ export function PartyContractListPage({ kind }: { kind: "partner" | "operator" }
           <td>{row.opened == null
             ? row.opened_state === "error" || row.opened_state === "failed" ? <Tri tone="fail" text={WORD_FETCH_FAILED} /> : <span className="table-placeholder">—</span>
             : <OpsStatus tone={row.opened ? "success" : "warning"}>{row.opened ? "已开通" : "未开通"}</OpsStatus>}</td>
-          <td className="settlement-ledger-number">{amount == null ? <span className="table-placeholder">—</span> : <span className="ops-money">{moneyFromCents(amount)}</span>}
-            <small>{row.service_months == null ? <span className="table-placeholder">—</span> : `服务期 ${row.service_months} 个月`}</small></td>
+          <ContractLedgerAmountCell contract={contractFromRow(row)} />
           <td className="settlement-ledger-action"><Link className="ops-table-action" to={`${prefix}/contract/${encodeURIComponent(row.contract_id)}`} state={linkState}>详情<ArrowRight size={14} aria-hidden="true" /></Link></td>
         </tr>;
       })}

+ 16 - 0
web-scaffold/src/pages/__tests__/party-ledger-navigation.test.tsx

@@ -86,3 +86,19 @@ it("运营商客户清单使用共享筛选和本方客户详情链接", async (
   await waitFor(() => expect(customerGetList).toHaveBeenLastCalledWith({ page: 0, page_size: 20, subject_type: "enterprise", keyword: undefined, status: undefined }));
   expect((await screen.findByRole("link", { name: "详情" })).getAttribute("href")).toBe("/bos/ov/customer/KL-001");
 });
+
+it("合同清单沿用运营侧的金额格式与服务期单元格", async () => {
+  vi.mocked(contractGetList).mockResolvedValue({ total: 1, items: [{
+    contract_id: "CT-001", contract_no: "CT-001", customer_id: "KL-001", external_no: null,
+    status: "active", contract_amount_cents: 123450, service_months: 12, start_date: null, end_date: null,
+    agent_name: null, agent_mobile: null, agent_handover_on: null, agent_org: null,
+    attachment_url: null, created_at: "2026-10-01", row_version: "1",
+  }] });
+  render(<MemoryRouter initialEntries={["/bos/ov/contract"]}>
+    <PartyContractListPage kind="operator" />
+  </MemoryRouter>);
+
+  const cell = (await screen.findByText("¥1,234.5")).closest("td");
+  expect(cell?.classList.contains("contract-ledger-amount")).toBe(true);
+  expect(cell?.querySelector("small")?.textContent).toBe("服务期 12 个月");
+});

+ 2 - 1
web-scaffold/src/styles/operations.css

@@ -177,7 +177,8 @@ table td :is(.ops-tag, .ops-status)[data-expired] {
 .ops-page--contracts .ops-table col:nth-child(11) { width: 214px; }
 .ops-page--contracts .ops-table th:nth-child(5),
 .ops-page--contracts .ops-table td:nth-child(5) { background: var(--primary-soft); }
-.ops-page--contracts .ops-table td:nth-child(5) .ops-money { color: var(--primary); }
+.ops-table td.contract-ledger-amount { text-align: right; }
+.ops-table td.contract-ledger-amount .ops-money { color: var(--primary); font-weight: 650; }
 .ops-page--contracts .ops-table tbody tr:hover td:nth-child(5) { background: var(--primary-soft); }
 .ops-clickable-table tbody tr { cursor: pointer; }
 .ops-clickable-table tbody tr:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }

+ 1 - 1
web-scaffold/src/styles/settlement-records.css

@@ -257,7 +257,7 @@
   white-space: nowrap;
 }
 .settlement-ledger .table-cell-title { display: block; }
-.party-ledger td > small { margin-block-start: 3px; overflow: hidden; text-overflow: ellipsis; }
+.ops-table.party-ledger td > small { margin-block-start: 3px; font-size: var(--type-meta); overflow: hidden; text-overflow: ellipsis; }
 .settlement-ledger-holder-type { margin-top: 3px; }
 .settlement-ledger .settlement-ledger-number { text-align: right; font-variant-numeric: tabular-nums; }
 .settlement-ledger .settlement-ledger-unit { color: var(--muted-foreground); font-size: var(--type-meta); }