Procházet zdrojové kódy

feat(web): 新增工单追溯与关联页签

sy před 3 dny
rodič
revize
75406f2c32

+ 18 - 1
web-scaffold/src/pages/WorkOrderRecordPage.tsx

@@ -1050,6 +1050,7 @@ const WORK_ORDER_RECORD_TABS = [
   { id: "materials", label: "工单材料" },
   { id: "messages", label: "运营商报文" },
   { id: "references", label: "客户与订阅" },
+  { id: "trace", label: "追溯与关联" },
 ] as const;
 
 type WorkOrderRecordTab = (typeof WORK_ORDER_RECORD_TABS)[number]["id"];
@@ -1245,6 +1246,7 @@ export function WorkOrderRecordPage() {
   const refOrder = d.order;
   const refSubscriptionId = refOrder?.subscription_id ?? t.subscription_id;
   const memberSubscriptions = d.subscriptions ?? [];
+  const submitterLabel = t.submitter_type === "customer" ? "客户侧提交" : t.submitter_type === "reporter" ? "报障人提交" : "运营侧代报";
 
   /**
    * 「下一步」=详情页唯一的主动作。
@@ -1378,6 +1380,7 @@ export function WorkOrderRecordPage() {
     materials: materialCount > 0 || canAddMaterials,
     messages: d.messages.length > 0,
     references: true,
+    trace: true,
   } satisfies Record<WorkOrderRecordTab, boolean>;
   const tabs = WORK_ORDER_RECORD_TABS.filter(({ id: tab }) => tabVisible[tab]).map((tab) => ({
     ...tab,
@@ -1458,7 +1461,7 @@ export function WorkOrderRecordPage() {
         </section>
         <section className="work-order-overview-context">
           <h2 className="work-order-panel-title">建单与关联</h2>
-          <div className="work-order-trace"><span>建单来源</span><strong>{t.submitter_type === "customer" ? "客户侧提交" : t.submitter_type === "reporter" ? "报障人提交" : "运营侧代报"}</strong></div>
+          <div className="work-order-trace"><span>建单来源</span><strong>{submitterLabel}</strong></div>
           <div className="work-order-trace"><span>外部单号</span><strong>{recordValue(t.carrier_order_no)}</strong></div>
           <div className="work-order-trace"><span>关联订阅</span><strong>{t.subscription_id ? <button type="button" className="work-order-trace-link" onClick={() => openRef({ kind: "order", id: t.subscription_id!, name: refOrder?.plan_name })}>{t.subscription_id}</button> : recordValue(null)}</strong>{refOrder?.plan_name && <small>{refOrder.plan_name}</small>}</div>
           {t.deferred_until && <div className="work-order-trace"><span>延期至</span><strong>{fmtDate(t.deferred_until)}</strong></div>}
@@ -1696,7 +1699,21 @@ export function WorkOrderRecordPage() {
             </div>}
           </dl>
         </section>}
+      </WorkOrderPanel>
 
+      <WorkOrderPanel tab="trace" active={activeTab} className="work-order-refs">
+        <section className="record-summary-panel">
+          <dl className="ops-record-summary">
+            <div><dt>本单来源</dt><dd>{t.source_message_id ? "运营商报文触发" : submitterLabel}</dd></div>
+            {t.source_message_id && <div><dt>来源报文</dt><dd>{t.source_message_id}</dd></div>}
+            {t.ticket_type === "renewal" && (t.renew_from_contract_id || t.renew_from_contract_no) && <>
+              <div><dt>续签来源合同</dt><dd>{t.renew_from_contract_no ?? t.renew_from_contract_id}</dd></div>
+              {t.renew_from_end_date && <div><dt>原合同到期日</dt><dd>{fmtDate(t.renew_from_end_date)}</dd></div>}
+              {(t.renew_contract_no || t.renew_contract_id) && <div><dt>新合同</dt><dd>{t.renew_contract_no ?? t.renew_contract_id}</dd></div>}
+            </>}
+            {d.messages.length > 0 && <div className="work-order-reference-wide"><dt>关联报文</dt><dd>{d.messages.map((m) => m.carrier_order_no ?? m.message_id).join("、")}</dd></div>}
+          </dl>
+        </section>
       </WorkOrderPanel>
     </div>
     <aside className="work-order-side">

+ 16 - 2
web-scaffold/src/pages/__tests__/work-order-record-tabs.test.tsx

@@ -50,7 +50,7 @@ it("概况默认显示,支持键盘切换,各页签共用处理入口和处
   expect(within(screen.getByRole("tabpanel", { name: "施工指导" })).getByText(detail.construction_guide.hint)).toBeTruthy();
 
   fireEvent.keyDown(guide, { key: "End" });
-  expect(screen.getAllByRole("tabpanel")).toEqual([screen.getByRole("tabpanel", { name: "客户与订阅" })]);
+  expect(screen.getAllByRole("tabpanel")).toEqual([screen.getByRole("tabpanel", { name: "追溯与关联" })]);
   expect(screen.getByRole("heading", { name: "处理记录" })).toBeTruthy();
   expect(screen.getAllByRole("button", { name: "条目核对" }).length).toBeGreaterThan(0);
 });
@@ -113,7 +113,7 @@ it("客户与订阅页签显示客户和订阅字段,并保留对应档案入
   });
   fireEvent.click(screen.getByRole("tab", { name: "客户与订阅" }));
   const related = within(screen.getByRole("tabpanel", { name: "客户与订阅" }));
-  expect(related.queryByRole("heading", { name: "来源与追溯" })).toBeNull();
+  expect(related.queryByText("本单来源")).toBeNull();
   const customer = within(related.getByRole("heading", { name: "客户资料" }).closest("section")!);
   expect(customer.getByText("联系电话").tagName).toBe("DT");
   expect(customer.getByText("138****0000").tagName).toBe("DD");
@@ -126,3 +126,17 @@ it("客户与订阅页签显示客户和订阅字段,并保留对应档案入
   fireEvent.click(subscription.getByRole("button", { name: "跨境办公专线" }));
   expect(vi.mocked(ReferenceDrawer).mock.lastCall?.[0].stack.at(-1)).toMatchObject({ kind: "order", id: "SUB-1" });
 });
+
+it("追溯与关联独立展示工单来源、续签合同和关联报文", () => {
+  renderRecord({
+    ticket: { ...detail.ticket, ticket_type: "renewal", renew_from_contract_no: "HT-OLD", renew_contract_no: "HT-NEW", source_message_id: "MSG-1" },
+    messages: [{ message_id: "MSG-1", carrier_order_no: "CARRIER-1" }],
+  });
+  fireEvent.click(screen.getByRole("tab", { name: "追溯与关联" }));
+  const trace = within(screen.getByRole("tabpanel", { name: "追溯与关联" }));
+  expect(trace.getByText("运营商报文触发")).toBeTruthy();
+  expect(trace.getByText("MSG-1")).toBeTruthy();
+  expect(trace.getByText("HT-OLD")).toBeTruthy();
+  expect(trace.getByText("HT-NEW")).toBeTruthy();
+  expect(trace.getByText("CARRIER-1")).toBeTruthy();
+});