瀏覽代碼

feat(web): 移动端直接展示完整工单详情

sy 2 天之前
父節點
當前提交
e5441c0cee

+ 98 - 43
web-scaffold/src/pages/WorkOrderRecordPage.tsx

@@ -1,7 +1,7 @@
 import { Fragment, useEffect, useRef, useState, type FormEvent, type ReactNode } from "react";
 import {
   ArrowLeft, ArrowRight, Check, ChevronDown, CircleAlert, ClipboardCheck, FolderOpen,
-  FileUp, Image, Info, Plus, RefreshCcw, ShieldAlert, Ticket, TriangleAlert, X,
+  FileUp, Image, Info, MapPin, Phone, Plus, RefreshCcw, ShieldAlert, Ticket, TriangleAlert, X,
 } from "lucide-react";
 import { Button } from "../components/ui/button";
 import { Input } from "../components/ui/input";
@@ -33,6 +33,7 @@ import { uploadTicketMaterial } from "../lib/api/oss-upload";
 import { classifyTicketError, fmtDate, fmtTime, numText, submitErrorText, useTicketDetail } from "../lib/ticket";
 import { missingGroupsOf } from "../lib/ticket-gaps";
 import { workOrderSteps } from "../lib/work-order-steps";
+import { todoRowDeadline } from "../lib/work-order-todo-row";
 import { ACCT_STATUS, label, PLAN_FAMILY, PLAN_KIND, ORDER_STATUS } from "../lib/api/labels";
 import {
   BANDWIDTH_TIERS, IP_TYPES, PATH_CPE_FIELDS, PATH_TUNNEL_FIELDS,
@@ -206,7 +207,7 @@ function stripNoteDate(note: string): string {
  * ⛔ 再给「展开更多」之类的截断:处理记录是运维盯单的专席,半年后回看的也是这几条,
  * 面板高度随窗口自适应,滚动条由 CSS 处理(`.work-order-logs-scroll`)。
  */
-export function LogPanel({ logs }: { logs: TicketDetail["process_logs"] }) {
+function LogPanel({ logs }: { logs: TicketDetail["process_logs"] }) {
   const railRef = useRef<HTMLOListElement>(null);
   const flowRef = useRef<HTMLSpanElement>(null);
   /**
@@ -1153,8 +1154,24 @@ function WorkOrderPanel({ tab, active, className = "", children }: {
   </section>;
 }
 
+function MobileSiteInfo({ customer, customerId }: { customer: TicketDetail["customer"]; customerId: string | null }) {
+  const phone = customer?.contact_mobile_full?.trim();
+  return <section className="field-panel field-site">
+    <h2><MapPin size={17} aria-hidden="true" />现场信息</h2>
+    <dl>
+      <div><dt>客户</dt><dd>{customer?.customer_name || customerId || "未登记"}</dd></div>
+      <div><dt>施工地址</dt><dd>{customer?.address || "未登记"}</dd></div>
+      <div><dt>联系人</dt><dd>{customer?.contact_name || "未登记"}
+        {phone && /^[+\d][\d ()-]+$/.test(phone)
+          ? <a className="field-phone" href={`tel:${phone.replace(/[ ()-]/g, "")}`}><Phone size={15} aria-hidden="true" />{phone}</a>
+          : customer?.contact_mobile && <span className="field-contact">{customer.contact_mobile}</span>}
+      </dd></div>
+    </dl>
+  </section>;
+}
+
 /** 工单详情(`/ticket/detail@v1`)。 */
-export function WorkOrderRecordPage() {
+export function WorkOrderRecordPage({ mobile = false }: { mobile?: boolean }) {
   const { id } = useParams();
   const navigate = useNavigate();
   const location = useLocation();
@@ -1164,7 +1181,7 @@ export function WorkOrderRecordPage() {
   const [sheet, setSheet] = useState<string | null>(null);
   /** 缺口入口打开对话框时的定位目标。 */
   const [sheetFocus, setSheetFocus] = useState<GapFocus | undefined>(undefined);
-  const [notice, setNotice] = useState("");
+  const [notice, setNotice] = useState<string>(() => mobile && typeof location.state?.notice === "string" ? location.state.notice : "");
   const [selectedTab, setSelectedTab] = useState<{ ticketId: string; tab: WorkOrderRecordTab } | null>(null);
   const [materialOpen, setMaterialOpen] = useState(false);
   /** 关联资料对话框的浏览栈,栈顶为当前档案。 */
@@ -1173,6 +1190,19 @@ export function WorkOrderRecordPage() {
   const detail = useTicketDetail(id ?? "", !clientView);
   const submit = useSubmit();
   const openSheet = (action: string, focus?: GapFocus) => {
+    if (mobile && action === "backfill" && id) {
+      const params = new URLSearchParams(location.search);
+      const fromActionLink = params.has("act");
+      params.delete("act");
+      const query = params.toString();
+      const origin = location.pathname + (query ? `?${query}` : "") + location.hash;
+      const returnState = { ...location.state, notice: undefined, workOrderTab: selectedTab?.tab ?? location.state?.workOrderTab };
+      navigate(`/m/work-orders/${encodeURIComponent(id)}/backfill`, {
+        replace: fromActionLink,
+        state: { ...detailLinkState(origin, returnState), backfillFocus: focus },
+      });
+      return;
+    }
     setSheetFocus(focus);
     if (action === "backfill") {
       // 缓存已有回填时立即打开表单,并在后台刷新。
@@ -1220,9 +1250,13 @@ export function WorkOrderRecordPage() {
   useEffect(() => {
     if (!d || !actParam || autoAct.current === actParam) return;
     autoAct.current = actParam;
-    const action = actParam === "receipt" ? "confirm_receipt" : actParam;
-    const allowed = (d.actions as Record<string, boolean>)[action];
-    if (allowed) openSheet(action);
+    const mobileBackfill = mobile && (actParam === "backfill" || actParam === "check_and_backfill");
+    const action = mobileBackfill ? "backfill" : actParam === "receipt" ? "confirm_receipt" : actParam;
+    const allowed = mobileBackfill ? d.actions.backfill || d.actions.check_and_backfill : (d.actions as Record<string, boolean>)[action];
+    if (allowed) {
+      openSheet(action);
+      if (mobileBackfill) return;
+    }
     // 深链动作不在服务端 `actions` 内(例如驳回态的 `backfill`):⛔ 静默吞掉参数,给一句为什么。
     else setNotice("该动作当前不可执行(服务端未开放),请按右栏「当前可执行」推进本单。");
     const next = new URLSearchParams(searchParams);
@@ -1239,7 +1273,7 @@ export function WorkOrderRecordPage() {
     else setNotice(submitErrorText(submit.errorRef.current, "操作失败"));
   }
 
-  const backLink = <Link to={back.to} state={back.state} className="ops-back-link"><ArrowLeft size={16} />{back.label}</Link>;
+  const backLink = mobile ? null : <Link to={back.to} state={back.state} className="ops-back-link"><ArrowLeft size={16} />{back.label}</Link>;
   if (!id) return <Navigate to={back.to} state={back.state} replace />;
   if (detail.loading) return <section className="ops-record-page">{backLink}<div className="work-order-empty"><Info size={27} /><h3>正在读取工单详情…</h3></div></section>;
   if (fail || !d) return <section className="ops-record-page">{backLink}{fail && <TicketState fail={fail} onRetry={detail.reload} />}</section>;
@@ -1423,19 +1457,25 @@ export function WorkOrderRecordPage() {
    * 客户既没有回填与竣工入口,也无从补齐这些组,面板只会误导成「我做错了什么」;
    * 门户口径是「等待运维处理/对方还在处理」(本册 §14.1.9)。⇒ `clientView` 整块不渲染。
    */
-  if (!clientView && d.gaps.length > 0) todoNodes.push(<div className="work-order-gaps" key="gaps">
-    <div className="work-order-gaps-head"><strong>闭环还缺 {d.gaps.length} 项</strong><span>缺口由服务端判定,不可人工放行竣工</span></div>
-    <ul>{d.gaps.map((g) => {
-      const target = gapTarget(g, can);
-      const usesSoftButton = target?.focus === "routes" || target?.focus === "conclusion";
-      return <li key={g}><div><b>{groupLabel(g)}</b><p>{gapHint(g)}</p></div>
-        {target && !viewerReadOnly && <Button size="sm" variant={usesSoftButton ? "ghost" : "outline"}
-          className={usesSoftButton ? "org-button org-button-compact org-button-scope" : undefined}
-          onClick={() => openSheet(target.action, target.focus)}>{target.label}<ArrowRight size={14} aria-hidden="true" /></Button>}
-      </li>;
-    })}</ul>
-    <p className="work-order-detail-footnote"><Info size={15} />缺口清单由服务端判定,不得在此人工放行竣工;{can.generate_completion ? "可生成竣工" : "生成竣工入口保持关闭"}。</p>
-  </div>);
+  if (!clientView && d.gaps.length > 0) {
+    const gapDetails = <div className="work-order-gaps" key="gaps">
+      <div className="work-order-gaps-head"><strong>闭环还缺 {d.gaps.length} 项</strong><span>缺口由服务端判定,不可人工放行竣工</span></div>
+      <ul>{d.gaps.map((g) => {
+        const target = gapTarget(g, can);
+        const usesSoftButton = target?.focus === "routes" || target?.focus === "conclusion";
+        return <li key={g}><div><b>{groupLabel(g)}</b><p>{gapHint(g)}</p></div>
+          {target && (!viewerReadOnly || (mobile && target.action === "backfill")) && <Button size="sm" variant={usesSoftButton ? "ghost" : "outline"}
+            className={usesSoftButton ? "org-button org-button-compact org-button-scope" : undefined}
+            onClick={() => openSheet(target.action, target.focus)}>{target.label}<ArrowRight size={14} aria-hidden="true" /></Button>}
+        </li>;
+      })}</ul>
+      <p className="work-order-detail-footnote"><Info size={15} />缺口清单由服务端判定,不得在此人工放行竣工;{can.generate_completion ? "可生成竣工" : "生成竣工入口保持关闭"}。</p>
+    </div>;
+    todoNodes.push(mobile ? <details key="gaps" className="field-ticket-gaps">
+      <summary>待补资料 <span>{d.gaps.length} 项</span><ChevronDown size={16} aria-hidden="true" /></summary>
+      {gapDetails}
+    </details> : gapDetails);
+  }
   if (t.status === "terminated" && t.close_reason) todoNodes.push(<div className="work-order-void" key="void"><X size={18} /><div><strong>作废原因</strong><p>{t.close_reason}</p></div></div>);
   // 只读视图提示只给「运营侧但无动作权的身份」(运维人员只管本人单、运营商只读等):
   // ⚠️ 2026-11-18 客户侧改走下面那条门户口径进度条,⛔ 两条同时出现。
@@ -1485,6 +1525,28 @@ export function WorkOrderRecordPage() {
     catch { setNotice("复制失败:浏览器拒绝了剪贴板访问。"); }
   };
 
+  const headerDetails = <>
+    <div className="work-order-head-meta">
+      <span>客户 <b>{refCustomer?.customer_name ?? "—"}</b></span><i>·</i>
+      <span>责任人 <b>{t.assignee_name ?? t.assignee_snapshot_name ?? "待分派"}</b></span><i>·</i>
+      <span>承接团队 <b>{t.assign_team_name ?? "未分派"}</b></span><i>·</i>
+      <span>建单人 <b>{t.creator_name ?? t.creator_user_id ?? "—"}</b></span><i>·</i>
+      <span>创建 <b className="mono">{fmtTime(t.created_at)}</b></span><i>·</i>
+      {/* 工单 ID=审计流水 `resource_id` 的原值(审计页对象列小字就是它),只给运营侧看:
+          客户门户⛔ 出现内部主键(工单§10 负向登记:客户侧 URL/响应体只该有 `ticket_no`)。 */}
+      {!clientView && <><span>工单ID <b className="mono">{t.ticket_id}</b></span><i>·</i></>}
+      {finished
+        ? t.status === "completed" && t.completed_at
+          ? <span>完成 <b className="mono">{fmtTime(t.completed_at)}</b></span>
+          : null
+        : <span className={`work-order-head-due${t.overdue ? " overdue" : ""}`}>{showExecDate && execNotBefore ? `计划执行(服务开始日)` : "期限"} <b className="mono">{showExecDate && execNotBefore ? fmtDate(execNotBefore) : t.expected_done_date ? fmtDate(t.expected_done_date) : "按 SLA 计算"}</b>{dueNote ? `(${dueNote})` : ""}</span>}
+      {t.status === "settled" && t.settled_at && <span>办结 <b className="mono">{fmtTime(t.settled_at)}</b></span>}
+      {t.status === "terminated" && <span>作废 <b className="mono">{fmtTime(t.closed_at)}</b></span>}
+    </div>
+    {nextHint && !viewerReadOnly && <div className="work-order-head-hint">{nextHint}</div>}
+    <div className="work-order-steps" aria-label="工单流转进度">{steps.map((step, index) => <Fragment key={step.label}>{index > 0 && <i aria-hidden="true" className={index <= reachedStepIndex ? "on" : undefined} />}<span className={`work-order-step ${step.state === "current" ? "cur" : step.state}`} aria-current={step.state === "current" ? "step" : undefined}><b>{index + 1}</b>{step.label}</span></Fragment>)}</div>
+  </>;
+  const deadline = mobile && !finished ? todoRowDeadline(t) : null;
   return <section className={`ops-record-page${clientView ? " customer-record-view" : ""}`}>
     {backLink}
     {notice && <OpsNotice message={notice} onClose={() => setNotice("")} />}
@@ -1494,7 +1556,9 @@ export function WorkOrderRecordPage() {
           <div className="work-order-head-icon" aria-hidden="true"><Ticket size={25} /></div>
           <div className="work-order-head-copy">
             <span className="work-order-head-no">{t.ticket_no}</span>
-            <h1 className="work-order-head-title">{t.title}</h1>
+            {mobile
+              ? <h2 className="work-order-head-title">{t.title || refCustomer?.customer_name || "工单详情"}</h2>
+              : <h1 className="work-order-head-title">{t.title}</h1>}
             <div className="work-order-head-tags">
               <TypeTag type={t.ticket_type} />
               <StatusTag status={t.status} type={t.ticket_type} />
@@ -1502,7 +1566,7 @@ export function WorkOrderRecordPage() {
           </div>
         </div>
         <div className="work-order-head-actions">
-          {nextStep && !viewerReadOnly && <Button onClick={runNextStep}>{nextStep.label}<ArrowRight size={16} /></Button>}
+          {!mobile && nextStep && !viewerReadOnly && <Button onClick={runNextStep}>{nextStep.label}<ArrowRight size={16} /></Button>}
           {/* 客户侧两个动作=列表行内同款(门户册 9 §7.5.1):撤回(填原因)/确认完成关闭。
               判据来自 `customerLiveTicketActions`,⛔ 在这里另写状态机。 */}
           {clientView && canClientWithdraw && <Button variant="outline" onClick={() => openSheet("withdraw")}><X size={16} />撤回</Button>}
@@ -1518,25 +1582,13 @@ export function WorkOrderRecordPage() {
           </details>}
         </div>
       </div>
-      <div className="work-order-head-meta">
-        <span>客户 <b>{refCustomer?.customer_name ?? "—"}</b></span><i>·</i>
-        <span>责任人 <b>{t.assignee_name ?? t.assignee_snapshot_name ?? "待分派"}</b></span><i>·</i>
-        <span>承接团队 <b>{t.assign_team_name ?? "未分派"}</b></span><i>·</i>
-        <span>建单人 <b>{t.creator_name ?? t.creator_user_id ?? "—"}</b></span><i>·</i>
-        <span>创建 <b className="mono">{fmtTime(t.created_at)}</b></span><i>·</i>
-        {/* 工单 ID=审计流水 `resource_id` 的原值(审计页对象列小字就是它),只给运营侧看:
-            客户门户⛔ 出现内部主键(工单§10 负向登记:客户侧 URL/响应体只该有 `ticket_no`)。 */}
-        {!clientView && <><span>工单ID <b className="mono">{t.ticket_id}</b></span><i>·</i></>}
-        {finished
-          ? t.status === "completed" && t.completed_at
-            ? <span>完成 <b className="mono">{fmtTime(t.completed_at)}</b></span>
-            : null
-          : <span className={`work-order-head-due${t.overdue ? " overdue" : ""}`}>{showExecDate && execNotBefore ? `计划执行(服务开始日)` : "期限"} <b className="mono">{showExecDate && execNotBefore ? fmtDate(execNotBefore) : t.expected_done_date ? fmtDate(t.expected_done_date) : "按 SLA 计算"}</b>{dueNote ? `(${dueNote})` : ""}</span>}
-        {t.status === "settled" && t.settled_at && <span>办结 <b className="mono">{fmtTime(t.settled_at)}</b></span>}
-        {t.status === "terminated" && <span>作废 <b className="mono">{fmtTime(t.closed_at)}</b></span>}
-      </div>
-      {nextHint && !viewerReadOnly && <div className="work-order-head-hint">{nextHint}</div>}
-      <div className="work-order-steps" aria-label="工单流转进度">{steps.map((step, index) => <Fragment key={step.label}>{index > 0 && <i aria-hidden="true" className={index <= reachedStepIndex ? "on" : undefined} />}<span className={`work-order-step ${step.state === "current" ? "cur" : step.state}`} aria-current={step.state === "current" ? "step" : undefined}><b>{index + 1}</b>{step.label}</span></Fragment>)}</div>
+      {mobile ? <>
+        {deadline?.date && <div className="field-date"><span>{{ planned: "计划执行", deferred: "延期至", due: "截止日期" }[deadline.kind]}</span><time dateTime={deadline.date}>{fmtDate(deadline.date)}</time></div>}
+        <details className="field-ticket-meta">
+          <summary>流转进度与责任人<ChevronDown size={16} aria-hidden="true" /></summary>
+          {headerDetails}
+        </details>
+      </> : headerDetails}
     </header>
     {todoNodes.length > 0 && <div className="work-order-todo">{todoNodes}</div>}
     <div className="work-order-layout"><div className="record-tabs-frame work-order-tabs-frame">
@@ -1544,6 +1596,7 @@ export function WorkOrderRecordPage() {
         onChange={(tab) => setSelectedTab({ ticketId: id, tab })} />
       <WorkOrderPanel tab="overview" active={activeTab}>
         <div className="work-order-overview-card">
+          {mobile && <MobileSiteInfo customer={refCustomer} customerId={t.customer_id} />}
           <p className="work-order-ticket-lead" data-empty={!t.detail || undefined}>{t.detail || "建单时未填写详细描述。"}</p>
           <dl className="work-order-overview-fields work-order-overview-context">
             <div><dt>建单来源</dt><dd>{submitterLabel}</dd></div>
@@ -1817,7 +1870,9 @@ export function WorkOrderRecordPage() {
     </aside>
   </div>
     {/* 窄屏(≤900px)底部固定条:主按钮与返回不随正文滚走。桌面隐藏,见 CSS。 */}
-    {nextStep && !viewerReadOnly && <div className="work-order-sticky-bar"><Button variant="outline" onClick={goBack}><ArrowLeft size={16} />返回</Button><Button className="work-order-sticky-next" onClick={runNextStep}><ArrowRight size={16} />{nextStep.label}</Button></div>}
+    {nextStep && (!viewerReadOnly || (mobile && nextStep.action === "backfill")) &&
+      (mobile ? <footer className="field-bar"><Button className="field-primary" onClick={runNextStep}>{nextStep.label}<ArrowRight size={17} /></Button></footer>
+        : <div className="work-order-sticky-bar"><Button variant="outline" onClick={goBack}><ArrowLeft size={16} />返回</Button><Button className="work-order-sticky-next" onClick={runNextStep}><ArrowRight size={16} />{nextStep.label}</Button></div>)}
     {materialOpen && <MaterialDialog ticketId={t.ticket_id} ticketNo={t.ticket_no} onClose={() => setMaterialOpen(false)}
       onDone={(message) => { setMaterialOpen(false); setNotice(message); detail.reload(); }} />}
     {sheet && <TicketActionSheet key={sheet} action={sheet} detail={d} focus={sheetFocus}

+ 20 - 0
web-scaffold/src/pages/__tests__/work-order-record-tabs.test.tsx

@@ -3,6 +3,7 @@ import { MemoryRouter, Route, Routes } from "react-router";
 import { afterEach, expect, it, vi } from "vitest";
 import { ReferenceDrawer } from "../../components/ReferenceDrawer";
 import { WorkOrderRecordPage } from "../WorkOrderRecordPage";
+import { MobileWorkOrderDetailPage } from "../mobile/MobileWorkOrderPages";
 
 const { useTicketDetail } = vi.hoisted(() => {
   vi.stubGlobal("__SEO_CTX__", undefined);
@@ -38,6 +39,25 @@ function renderRecord(overrides: object = {}) {
 
 afterEach(cleanup);
 
+it("移动详情可直接查看交付材料和竣工回执,已办结工单不显示回填入口", () => {
+  useTicketDetail.mockReturnValue({ data: {
+    ...detail, ticket: { ...detail.ticket, status: "settled" }, actions: {},
+    materials: [{ material_id: "P1", kind: "construct_material", file_name: "现场凭证.jpg" }],
+    completion: { completion_no: "COMP-01", receipt_at: "2026-12-02", receipt_valid: "1" },
+    customer: { customer_name: "现场客户", contact_mobile: "138****0000" },
+  } });
+  render(<MemoryRouter initialEntries={["/m/work-orders/1001"]}>
+    <Routes><Route path="/m/work-orders/:id" element={<MobileWorkOrderDetailPage />} /></Routes>
+  </MemoryRouter>);
+  expect(screen.queryByRole("link", { name: /完整详情/ })).toBeNull();
+  expect(screen.queryByRole("link", { name: /138/ })).toBeNull();
+  expect(screen.queryByRole("button", { name: "施工回填" })).toBeNull();
+  fireEvent.click(screen.getByRole("tab", { name: "交付事实" }));
+  expect(within(screen.getByRole("tabpanel", { name: "交付事实" })).getByText("现场凭证.jpg")).toBeTruthy();
+  fireEvent.click(screen.getByRole("tab", { name: "竣工回执" }));
+  expect(within(screen.getByRole("tabpanel", { name: "竣工回执" })).getByText("COMP-01")).toBeTruthy();
+});
+
 it("概况默认显示,支持键盘切换,各页签共用处理入口和处理记录", () => {
   renderRecord();
   expect(screen.getByRole("link", { name: "返回工单列表" }).getAttribute("href")).toBe("/work-orders");

+ 11 - 51
web-scaffold/src/pages/mobile/MobileWorkOrderPages.tsx

@@ -1,17 +1,16 @@
 import { useLayoutEffect, useRef, type ReactNode } from "react";
 import { Link, Navigate, useLocation, useNavigate, useParams, useSearchParams } from "react-router";
-import { ArrowLeft, ArrowRight, CalendarDays, CheckCircle2, ChevronDown, ChevronRight, ClipboardCheck, Clock3, MapPin, Monitor, Phone, Smartphone } from "lucide-react";
+import { ArrowLeft, CalendarDays, ChevronRight, ClipboardCheck, Clock3, Monitor, Smartphone } from "lucide-react";
 import { Button } from "../../components/ui/button";
 import { TicketStatusTag, TicketTypeTag } from "../../components/work-order/TicketBadges";
-import { ConstructionGuidePanel } from "../../components/work-order/ConstructionGuidePanel";
 import { classifyTicketError, useTicketDetail, useTicketList } from "../../lib/ticket";
 import { nextStepOf } from "../../lib/work-order-next-step";
 import { businessToday } from "../../lib/business-date";
 import { groupTodoRows, todoRowDeadline, todoRowSummary } from "../../lib/work-order-todo-row";
 import { useDemoIdentity } from "../../lib/demo-session";
-import { detailBack, detailLinkState, useDetailLinkState } from "../../lib/detail-navigation";
+import { detailBack, detailLinkState } from "../../lib/detail-navigation";
 import { TicketState } from "../../components/ticketState";
-import { LogPanel, TicketActionSheet } from "../WorkOrderRecordPage";
+import { TicketActionSheet, WorkOrderRecordPage } from "../WorkOrderRecordPage";
 import "../../styles/work-order-guide.css";
 import "../../styles/work-orders.css";
 import "../../styles/work-order-record.css";
@@ -104,52 +103,9 @@ export function MobileWorkOrderDetailPage() {
   if (identity && !MINE_ROLES.includes(identity.role)) return <Navigate to="/work-orders" replace />;
   if (!id) return <Navigate to="/m/work-orders/mine" replace />;
   const back = detailBack(location.state, "/m/work-orders/mine", "返回移动端待办");
-  return <MobileDetailInner key={id} id={id} backLabel={back.label} onBack={() => navigate(back.to, { state: back.state })} />;
-}
-
-function MobileDetailInner({ id, backLabel, onBack }: { id: string; backLabel: string; onBack: () => void }) {
-  const linkState = useDetailLinkState();
-  const location = useLocation();
-  const detail = useTicketDetail(id, true);
-  const d = detail.data;
-  const t = d?.ticket;
-  const canBackfill = d?.actions.backfill || d?.actions.check_and_backfill;
-  const deadline = t && todoRowDeadline(t);
-  const fullPhone = d?.customer?.contact_mobile_full?.trim();
-  return <main className="field-page">
-    <MobileHeader title="工单详情" backLabel={backLabel} onBack={onBack} />
-    <div className="field-content">
-      {location.state?.notice && <p className="field-notice" role="status"><CheckCircle2 size={17} />{location.state.notice}</p>}
-      {detail.loading && <p className="field-state" role="status">正在读取工单…</p>}
-      {detail.error && <TicketState fail={classifyTicketError(detail.error)} onRetry={detail.reload} />}
-      {t && d && !detail.error && <>
-        <section className="field-ticket">
-          <div className="field-row-meta"><TicketTypeTag type={t.ticket_type} /><TicketStatusTag status={t.status} type={t.ticket_type} /></div>
-          <h2>{t.title || d.customer?.customer_name || "工单详情"}</h2>
-          <p className="field-serial">{t.ticket_no}</p>
-          {deadline?.date && <p className="field-date"><CalendarDays size={16} />{deadlineLabels[deadline.kind]}<time dateTime={deadline.date}>{deadline.date}</time></p>}
-        </section>
-        <section className="field-panel"><h2><MapPin size={17} />现场信息</h2>
-          <dl><div><dt>客户</dt><dd>{d.customer?.customer_name || t.customer_id || "—"}</dd></div>
-            <div><dt>施工地址</dt><dd>{d.customer?.address || "未登记"}</dd></div>
-            <div><dt>联系人</dt><dd>{d.customer?.contact_name || "未登记"}
-              {fullPhone && /^[+\d][\d ()-]+$/.test(fullPhone)
-                ? <a className="field-phone" href={`tel:${fullPhone.replace(/[ ()-]/g, "")}`}><Phone size={15} />{fullPhone}</a>
-                : d.customer?.contact_mobile && <span className="field-contact">{d.customer.contact_mobile}</span>}
-            </dd></div></dl>
-        </section>
-        {t.detail && <section className="field-panel"><h2>事项描述</h2><p className="field-description">{t.detail}</p></section>}
-        {d.construction_guide && <details className="field-fold"><summary>施工指导<ChevronDown size={17} /></summary><ConstructionGuidePanel guide={d.construction_guide} /></details>}
-        <details className="field-fold"><summary>处理记录 <small>{d.process_logs.length} 条</small><ChevronDown size={17} /></summary>
-          {d.process_logs.length ? <LogPanel logs={d.process_logs} /> : <p className="field-meta">暂无处理记录</p>}
-        </details>
-      </>}
-    </div>
-    {d && !detail.error && <footer className="field-bar">
-      <Link className={canBackfill ? "field-secondary" : "field-primary"} to={`/work-orders/${encodeURIComponent(id)}`} state={linkState}>打开完整详情</Link>
-      {canBackfill && <Link className="field-primary" to={`/m/work-orders/${encodeURIComponent(id)}/backfill`} state={linkState}>
-        {d.actions.check_and_backfill ? "核对并回填" : "施工回填"}<ArrowRight size={17} /></Link>}
-    </footer>}
+  return <main className="field-page field-record">
+    <MobileHeader title="工单详情" backLabel={back.label} onBack={() => navigate(back.to, { state: back.state })} />
+    <WorkOrderRecordPage key={id} mobile />
   </main>;
 }
 
@@ -167,11 +123,15 @@ export function MobileWorkOrderBackfillPage() {
 }
 
 function MobileBackfillInner({ id, onLeave }: { id: string; onLeave: (msg?: string) => void }) {
+  const { state } = useLocation();
+  const focus = state?.backfillFocus;
   const detail = useTicketDetail(id, true);
   const d = detail.data;
   if (d && !detail.error && (d.actions.backfill || d.actions.check_and_backfill)) {
     return <main className="field-page wo-m-backfill-host">
-      <TicketActionSheet action="backfill" detail={d} presentation="page" onReload={detail.reload} onClose={() => onLeave()} onDone={onLeave} />
+      <TicketActionSheet action="backfill" detail={d} presentation="page"
+        focus={focus === "routes" || focus === "ips" || focus === "conclusion" ? focus : undefined}
+        onReload={detail.reload} onClose={() => onLeave()} onDone={onLeave} />
     </main>;
   }
   return <main className="field-page">

+ 48 - 21
web-scaffold/src/styles/mobile-work-orders.css

@@ -16,7 +16,7 @@
 }
 .field-page h1 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -.025em; }
 .field-top > button, .field-page .work-order-drawer--page > header > button { width: 44px; height: 44px; margin-left: -9px; }
-.field-desktop, .field-phone, .field-secondary, .field-primary {
+.field-desktop, .field-phone, .field-primary {
   display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; text-decoration: none;
 }
 .field-desktop { margin-inline-start: auto; color: var(--text-secondary); font-size: 14px; }
@@ -37,15 +37,15 @@
 .field-group h2::before { content: ""; width: 3px; height: 14px; border-radius: 3px; background: var(--primary); }
 .field-group[data-tone="urgent"] h2::before { background: var(--warning); }
 .field-group[data-tone="waiting"] h2::before { background: var(--muted-foreground); }
-.field-group h2 small, .field-fold summary small { color: var(--muted-foreground); font-size: 13px; font-weight: 500; }
-.field-group ul, .field-panel, .field-ticket, .field-fold, .field-empty {
+.field-group h2 small { color: var(--muted-foreground); font-size: 13px; font-weight: 500; }
+.field-group ul, .field-empty {
   margin: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--card);
 }
 .field-group ul { list-style: none; padding: 0 15px; }
 .field-group li + li { border-top: 1px solid var(--border-subtle); }
 .field-group li a { display: grid; gap: 5px; padding-block: 15px; color: inherit; text-decoration: none; }
 .field-group li a:active { background: var(--primary-soft); }
-.field-row-meta, .field-row-title, .field-row-foot, .field-row-foot span, .field-date, .field-notice { display: flex; align-items: center; gap: 7px; }
+.field-row-meta, .field-row-title, .field-row-foot, .field-row-foot span, .field-date { display: flex; align-items: center; gap: 7px; }
 .field-row-meta { justify-content: space-between; flex-wrap: wrap; }
 .field-row-title { justify-content: space-between; }
 .field-row-title strong { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-size: 17px; font-weight: 600; line-height: 1.5; }
@@ -60,13 +60,10 @@
 .field-empty p { color: var(--text-secondary); font-size: 14px; }
 .field-pager { display: flex; align-items: center; justify-content: space-between; }
 .field-pager button { min-height: 44px; }
-.field-ticket { padding: 18px; background: linear-gradient(150deg,var(--primary-soft),var(--card) 75%); }
-.field-ticket h2 { margin: 12px 0 5px; font-size: clamp(22px,5vw,28px); line-height: 1.35; font-weight: 600; }
 .field-serial { color: var(--text-secondary); user-select: all; }
 .field-date { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 14px; }
 .field-date time { margin-inline-start: auto; font-variant-numeric: tabular-nums; color: var(--primary); }
-.field-panel { padding: 16px; }
-.field-panel h2, .field-fold summary { display: flex; align-items: center; gap: 7px; font-size: 16px; font-weight: 600; }
+.field-panel h2 { display: flex; align-items: center; gap: 7px; font-size: 16px; font-weight: 600; }
 .field-panel h2 svg, .field-phone { color: var(--primary); }
 .field-panel dl { margin: 10px 0 0; }
 .field-panel dl > div { display: grid; grid-template-columns: 5em minmax(0,1fr); gap: 8px; padding-block: 10px; }
@@ -75,23 +72,53 @@
 .field-panel dd { margin: 0; font-size: 16px; line-height: 1.5; }
 .field-panel dl > div:last-child { padding-bottom: 0; }
 .field-phone, .field-contact { display: flex; width: fit-content; }
-.field-description { margin-top: 8px; white-space: pre-line; font-size: 16px; line-height: 1.65; }
-.field-fold summary { min-height: 50px; padding: 0 16px; cursor: pointer; list-style: none; }
-.field-fold summary::-webkit-details-marker { display: none; }
-.field-fold summary svg { margin-inline-start: auto; }
-.field-fold[open] summary svg { transform: rotate(180deg); }
-.field-fold > :not(summary) { margin: 0; padding: 12px 16px; border-top: 1px solid var(--border-subtle); }
-.field-fold .wo-guide > h3 { display: none; }
-.field-fold .work-order-summary-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
-.field-fold .work-order-tl { margin-inline: 12px; }
-.field-notice { padding: 12px; background: var(--primary-soft); color: var(--primary-soft-foreground); border-radius: 8px; }
-.field-page:has(.field-bar) { display: flex; flex-direction: column; }
-.field-page:has(.field-bar) > .field-content { flex: 1; align-content: start; }
+.field-record > .ops-record-page {
+  padding: 14px var(--field-gap) calc(16px + env(safe-area-inset-bottom));
+}
+.field-record .work-order-head { gap: 8px; padding: 16px 16px 0; background: linear-gradient(140deg,var(--primary-soft),var(--card) 65%); }
+.field-record .work-order-head-top { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 6px; }
+.field-record .work-order-head-main, .field-record .work-order-head-copy { display: contents; }
+.field-record .work-order-head-no { grid-area: 1 / 1; }
+.field-record .work-order-head-title { grid-area: 2 / 1 / 3 / -1; font-size: 21px; line-height: 1.35; }
+.field-record .work-order-head-tags { grid-area: 3 / 1 / 4 / -1; }
+.field-record .work-order-head-icon { display: none; }
+.field-record .work-order-head-actions { grid-area: 1 / 2; width: auto; }
+.field-record .work-order-more-trigger { min-height: 44px; padding: 0 4px; border: 0; background: transparent; color: var(--text-secondary); }
+.field-record .work-order-more-menu { min-width: min(230px, 72vw); }
+.field-record .work-order-more-menu button { min-height: 44px; }
+.field-record .field-date { margin-top: 5px; padding-top: 10px; }
+.field-ticket-meta { border-top: 1px solid var(--border-subtle); }
+.field-ticket-meta summary, .field-ticket-gaps summary {
+  display: flex; align-items: center; gap: 8px; min-height: 44px; list-style: none; cursor: pointer; font-size: 14px;
+}
+.field-record summary::-webkit-details-marker { display: none; }
+.field-ticket-meta summary svg, .field-ticket-gaps summary svg { margin-inline-start: auto; }
+.field-ticket-meta[open] > summary svg, .field-ticket-gaps[open] > summary svg { transform: rotate(180deg); }
+.field-ticket-meta .work-order-head-meta { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
+.field-ticket-meta .work-order-head-meta i { display: none; }
+.field-ticket-meta .work-order-head-meta span { display: grid; gap: 2px; }
+.field-ticket-meta .work-order-head-hint, .field-ticket-meta .work-order-steps { margin-block: 10px; }
+.field-ticket-gaps { border: 1px solid var(--warning-border); border-radius: 10px; background: var(--warning-soft); }
+.field-ticket-gaps summary { padding-inline: 14px; }
+.field-ticket-gaps summary span { font-weight: 600; color: var(--warning); }
+.field-ticket-gaps .work-order-gaps { padding-top: 0; border: 0; }
+.field-record .work-order-layout { grid-template-columns: minmax(0, 1fr); }
+.field-record .work-order-record-tabs { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 2px; padding: 4px; }
+.field-record .work-order-record-tabs button { justify-content: center; gap: 3px; min-height: 44px; padding: 0 2px; line-height: 1.35; font-size: 13px; }
+.field-record .record-tab-count { min-width: 0; padding-inline: 3px; }
+@media (max-width: 374px) {
+  .field-record .work-order-record-tabs { grid-template-columns: repeat(3,minmax(0,1fr)); }
+}
+.field-record .work-order-record-panel { padding: 16px; }
+.field-record .work-order-table-wrap { position: relative; max-width: 100%; overscroll-behavior-x: contain; }
+.field-record .work-order-side { position: static; }
+.field-record .work-order-logs-panel { height: auto; max-height: none; }
+.field-record .work-order-logs-scroll { overflow: visible; }
+.field-record .field-bar { margin: 14px calc(-1 * var(--field-gap)) calc(-16px - env(safe-area-inset-bottom)); }
 .field-bar, .field-page .work-order-drawer--page .work-order-editor > footer {
   position: sticky; bottom: 0; z-index: 4; display: flex; align-items: center; gap: 12px;
   padding: 10px var(--field-gap) calc(10px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--border);
 }
-.field-secondary { color: var(--text-secondary); padding-inline: 6px; font-size: 14px; }
 .field-primary { flex: 1; border-radius: 8px; color: var(--primary-foreground); background: var(--primary); font-size: 16px; font-weight: 550; }
 .field-page :is(button, a, input, textarea, select, summary) { scroll-margin-block: 80px 100px; }
 .field-page :is(a,button,summary):focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }