Эх сурвалжийг харах

merge(web): 合并待分派与交付回执台账样式

sy 3 өдөр өмнө
parent
commit
79267d8f0c

+ 48 - 18
web-scaffold/src/components/work-order/MessageInboxPanel.tsx

@@ -12,18 +12,21 @@
  * ⛔ 让运维成员点一下才吃一个 `60058`,也⛔ 把"能看见"当成"能处置"(服务端仍是唯一控制)。
  */
 import { useState } from "react";
-import { Check, Inbox, Search, X } from "lucide-react";
+import { Check, Inbox, X } from "lucide-react";
 import { Button } from "../ui/button";
 import { Input } from "../ui/input";
-import { ServerListPager } from "../ListPager";
+import { ListPager } from "../ListPager";
+import { OpsStatus, OpsTableColumns } from "../OperationsKit";
 import { TicketState } from "../ticketState";
 import {
   messageAttach, messageConfirmConflict, messageRematch, messageVoid, ticketTrace,
 } from "../../lib/api/ticket";
 import { classifyTicketError, fmtTime, TICKET_PAGE_SIZE, useMessagePending } from "../../lib/ticket";
 import { useSubmit } from "../../lib/useLoad";
+import { useHorizontalOverflow } from "../../lib/use-horizontal-overflow";
 
 export function MessageInboxPanel({ canDispose, onChanged }: { canDispose: boolean; onChanged?: () => void }) {
+  const tableOverflow = useHorizontalOverflow();
   const [page, setPage] = useState(1);
   const inbox = useMessagePending(page);
   const submit = useSubmit();
@@ -77,22 +80,49 @@ export function MessageInboxPanel({ canDispose, onChanged }: { canDispose: boole
   const rows = inbox.data?.rows ?? [];
   const total = inbox.data?.total ?? 0;
 
+  const fallback = inbox.loading
+    ? <div className="order-empty" role="status">正在读取待处置报文…</div>
+    : fail
+      ? <TicketState fail={fail} onRetry={inbox.reload} />
+      : !rows.length ? <div className="order-empty"><Inbox size={26} aria-hidden="true" /><h3>暂无待处置报文</h3></div> : null;
+  const minWidth = canDispose ? 980 : 880;
+  const bodyWidth = Math.max(tableOverflow.width, minWidth) - (canDispose ? 96 : 0);
+  const columnWidths = [.28, .22, .13, .19, .18].map((weight) => bodyWidth * weight);
+  if (canDispose) columnWidths.push(96);
+  const activeMessage = rows.find((row) => row.message_id === openId);
+
   return <div className="work-order-message-panel">
-    <p className="work-order-message-note">只列<strong>未归属</strong>与<strong>与现状冲突</strong>的报文;归属成功的报文当轮即生效,不在此排队。挂接与作废限团队主账号、总运营、运营主/子账号,冲突确认限该单责任人。</p>
-    {inbox.loading && <div className="work-order-empty"><Search size={27} /><h3>正在读取报文待处置清单…</h3></div>}
-    {fail && <TicketState fail={fail} onRetry={inbox.reload} />}
-    {!inbox.loading && !fail && !rows.length && <div className="work-order-empty"><Inbox size={27} /><h3>没有待处置报文</h3><p>当前范围内报文均已归属或已作废。</p></div>}
-    {!inbox.loading && !fail && rows.length > 0 && <div className="work-order-message-table-wrap"><table className="work-order-message-table"><thead><tr><th>运营商单号</th><th>动作</th><th>状态</th><th>报文要素</th><th>接收时间</th>{canDispose && <th><span className="sr-only">操作</span></th>}</tr></thead><tbody>
-      {rows.map((m) => <tr key={m.message_id}>
-        <td><strong>{m.carrier_order_no ?? "(无单号)"}</strong>{m.reported_ticket_no && <small>受理单号 {m.reported_ticket_no}</small>}</td>
-        <td>{m.action ?? "-"}</td>
-        <td><span className={`work-order-status status-${m.status === "conflict" ? "pending" : "doing"}`}><i />{m.status === "conflict" ? "冲突" : "未匹配"}</span>{m.conflict_note && <small>{m.conflict_note}</small>}</td>
-        <td><strong>{m.customer_name ?? <span className="table-placeholder">未识别客户</span>}</strong><small>{[m.contact_name, m.contact_phone, m.network_account_name].filter(Boolean).join(" · ") || <span className="table-placeholder">报文未带要素</span>}</small></td>
-        <td><strong className="work-order-date">{fmtTime(m.received_at)}</strong></td>
-        {canDispose && <td><Button variant="ghost" size="sm" onClick={() => { setOpenId(openId === m.message_id ? null : m.message_id); setTip(""); setTicketNo(""); setReason(""); }}>{openId === m.message_id ? "收起" : "处置"}</Button></td>}
-      </tr>)}
-    </tbody></table></div>}
-    {openId && canDispose && <form className="work-order-process-form" onSubmit={(e) => e.preventDefault()}>
+    <p className="work-order-delivery-note">这里只显示未归属或与现状冲突的报文。</p>
+    <div
+      ref={tableOverflow.ref}
+      className={`measured-table-scroll order-ledger-scroll work-order-message-scroll${tableOverflow.overflow ? " has-horizontal-overflow" : ""}${tableOverflow.canScrollLeft ? " can-scroll-left" : ""}${tableOverflow.canScrollRight ? " can-scroll-right" : ""}`}
+      role="region"
+      aria-label="待处置报文,可横向滚动查看字段"
+      tabIndex={0}
+    >
+      {fallback}
+      <table className="order-table order-ledger" hidden={Boolean(fallback)} style={{ minWidth }}>
+        <OpsTableColumns widths={columnWidths} />
+        <thead><tr><th scope="col">客户 / 报文要素</th><th scope="col">运营商单号</th><th scope="col">动作</th><th scope="col">状态</th><th scope="col">接收时间</th>{canDispose && <th scope="col">操作</th>}</tr></thead>
+        <tbody>
+          {!fallback && rows.map((m) => {
+            const elements = [m.contact_name, m.contact_phone, m.network_account_name].filter(Boolean).join(" · ");
+            return (
+              <tr key={m.message_id}>
+                <td><strong className="table-cell-title" title={m.customer_name ?? undefined}>{m.customer_name || <span className="table-placeholder">未识别客户</span>}</strong><small title={elements || undefined}>{elements || <span className="table-placeholder">报文未带要素</span>}</small></td>
+                <td><strong className="table-cell-title" title={m.carrier_order_no ?? undefined}>{m.carrier_order_no || <span className="table-placeholder">无单号</span>}</strong>{m.reported_ticket_no && <small title={m.reported_ticket_no}>受理单号 {m.reported_ticket_no}</small>}</td>
+                <td title={m.action ?? undefined}>{m.action || <span className="table-placeholder">—</span>}</td>
+                <td><OpsStatus tone={m.status === "conflict" ? "warning" : "info"}>{m.status === "conflict" ? "冲突" : "未匹配"}</OpsStatus>{m.conflict_note && <small title={m.conflict_note}>{m.conflict_note}</small>}</td>
+                <td className="order-date">{m.received_at ? fmtTime(m.received_at) : <span className="table-placeholder">—</span>}</td>
+                {canDispose && <td><button type="button" className="ops-table-action" aria-expanded={openId === m.message_id} onClick={() => { setOpenId(openId === m.message_id ? null : m.message_id); setTip(""); setTicketNo(""); setReason(""); }}>{openId === m.message_id ? "收起" : "处置"}</button></td>}
+              </tr>
+            );
+          })}
+        </tbody>
+      </table>
+    </div>
+    {activeMessage && canDispose && <form className="work-order-process-form" onSubmit={(e) => e.preventDefault()}>
+      <h2>处置报文{activeMessage.carrier_order_no ? ` · ${activeMessage.carrier_order_no}` : ""}</h2>
       <div className="work-order-form-grid">
         <label>关联/改挂到工单号<Input maxLength={40} placeholder="输入工单号后点右侧按钮" value={ticketNo} onChange={(e) => setTicketNo(e.target.value)} /></label>
         <label>作废原因<Input maxLength={200} placeholder="作废时必填" value={reason} onChange={(e) => setReason(e.target.value)} /></label>
@@ -107,6 +137,6 @@ export function MessageInboxPanel({ canDispose, onChanged }: { canDispose: boole
       {tip && <p className="work-order-form-error" role="alert">{tip}</p>}
       {submit.error && !tip && <p className="work-order-form-error" role="alert">{submit.error.message}</p>}
     </form>}
-    {!inbox.loading && !fail && total > TICKET_PAGE_SIZE && <ServerListPager total={total} page={page} pageSize={TICKET_PAGE_SIZE} unit="条" className="list-pager" onPageChange={setPage} />}
+    {!inbox.loading && !fail && <ListPager total={total} page={page - 1} pageSize={TICKET_PAGE_SIZE} unit="条" onPageChange={(next) => { setOpenId(null); setPage(next + 1); }} />}
   </div>;
 }

+ 57 - 20
web-scaffold/src/components/work-order/WorkOrderLedgerList.tsx

@@ -9,13 +9,19 @@ import { useHorizontalOverflow } from "../../lib/use-horizontal-overflow";
 import { nextStepOf } from "../../lib/work-order-next-step";
 import { todoRowDueOn } from "../../lib/work-order-todo-row";
 
-function TicketLedgerRow({ item, from, clientView, mobile = false }: {
+type OwnerColumn = "assignee" | "team" | "none";
+type DateColumn = "created_at" | "completed_at";
+
+function TicketLedgerRow({ item, from, ownerColumn, dateColumn, showNextStep, extraAction, mobile = false }: {
   item: TicketListItem;
   from: string;
-  clientView: boolean;
+  ownerColumn: OwnerColumn;
+  dateColumn: DateColumn;
+  showNextStep: boolean;
+  extraAction?: ReactNode;
   mobile?: boolean;
 }) {
-  const step = clientView ? null : nextStepOf(item);
+  const step = showNextStep ? nextStepOf(item) : null;
   const href = `/work-orders/${encodeURIComponent(item.ticket_id)}`;
   const state = { from };
   const due = todoRowDueOn(item);
@@ -26,7 +32,8 @@ function TicketLedgerRow({ item, from, clientView, mobile = false }: {
   const owner = item.assignee_name || <span className="table-placeholder">待分派</span>;
   const team = item.team_name || <span className="table-placeholder">未分派团队</span>;
   const deadline = due ? due.replaceAll("-", ".") : <span className="table-placeholder">—</span>;
-  const createdAt = item.created_at ? fmtTime(item.created_at) : <span className="table-placeholder">—</span>;
+  const dateValue = item[dateColumn];
+  const date = dateValue ? fmtTime(dateValue) : <span className="table-placeholder">—</span>;
   const status = <TicketStatusTag status={item.status} type={item.ticket_type} />;
   const type = <TicketTypeTag type={item.ticket_type} />;
   const action = step?.label
@@ -34,6 +41,10 @@ function TicketLedgerRow({ item, from, clientView, mobile = false }: {
     : <span className="table-placeholder">—</span>;
   const detail = <Link className="ops-table-action" to={href} state={state} aria-label={`查看工单 ${number} 详情`}>详情<ArrowRight size={14} aria-hidden="true" /></Link>;
 
+  const actions = <div className="ops-inline-actions">{extraAction}{detail}</div>;
+  const ownerLabel = ownerColumn === "team" ? "负责团队" : "责任人 / 团队";
+  const dateLabel = dateColumn === "completed_at" ? "完成时间" : "创建时间";
+
   if (mobile) {
     return (
       <article className="order-mobile-card work-order-ledger-mobile-card">
@@ -42,12 +53,12 @@ function TicketLedgerRow({ item, from, clientView, mobile = false }: {
         <p>{title || <span className="table-placeholder">未填写标题</span>}</p>
         <dl>
           <div><dt>工单类型</dt><dd>{type}</dd></div>
-          {!clientView && <div><dt>责任人 / 团队</dt><dd>{owner}<small>{team}</small></dd></div>}
+          {ownerColumn !== "none" && <div><dt>{ownerLabel}</dt><dd>{ownerColumn === "team" ? team : <>{owner}<small>{team}</small></>}</dd></div>}
           <div><dt>截止日期</dt><dd>{deadline}{item.deferred_until && <small>已延期</small>}{item.overdue_7d && <small className="work-order-overdue-text">超期/临期</small>}</dd></div>
-          <div><dt>创建时间</dt><dd>{createdAt}</dd></div>
+          <div><dt>{dateLabel}</dt><dd>{date}</dd></div>
           {step && <div><dt>下一步</dt><dd>{action}<small>{step.hint}</small></dd></div>}
         </dl>
-        <div className="ops-inline-actions">{detail}</div>
+        {actions}
       </article>
     );
   }
@@ -59,33 +70,59 @@ function TicketLedgerRow({ item, from, clientView, mobile = false }: {
         <strong className="table-cell-title" title={title}>{title || <span className="table-placeholder">未填写标题</span>}</strong>
         <div className="work-order-ledger-type">{type}</div>
       </td>
-      {!clientView && <td><strong className="table-cell-title" title={item.assignee_name || undefined}>{owner}</strong><small title={item.team_name || undefined}>{team}</small></td>}
+      {ownerColumn === "assignee" && <td><strong className="table-cell-title" title={item.assignee_name || undefined}>{owner}</strong><small title={item.team_name || undefined}>{team}</small></td>}
+      {ownerColumn === "team" && <td title={item.team_name || undefined}>{team}</td>}
       <td>
         <strong className="order-date">{deadline}</strong>
         {item.deferred_until && <small title={`原期限 ${item.expected_done_date?.slice(0, 10) ?? "—"}`}>已延期</small>}
         {item.overdue_7d && <small className="work-order-overdue-text">超期/临期</small>}
       </td>
-      <td className="order-date" title={item.created_at || undefined}>{createdAt}</td>
+      <td className="order-date" title={dateValue || undefined}>{date}</td>
       {step && <td>{action}<small title={step.hint}>{step.hint}</small></td>}
       <td>{status}</td>
-      <td><div className="ops-inline-actions">{detail}</div></td>
+      <td>{actions}</td>
     </tr>
   );
 }
 
-export function WorkOrderLedgerList({ rows, from, label, fallback, clientView = false }: {
-  rows: readonly TicketListItem[];
+export function WorkOrderLedgerList<T extends TicketListItem>({
+  rows,
+  from,
+  label,
+  fallback,
+  clientView = false,
+  ownerColumn = clientView ? "none" : "assignee",
+  dateColumn = "created_at",
+  showNextStep = !clientView,
+  renderRowAction,
+}: {
+  rows: readonly T[];
   from: string;
   label: string;
   fallback?: ReactNode;
   clientView?: boolean;
+  ownerColumn?: OwnerColumn;
+  dateColumn?: DateColumn;
+  showNextStep?: boolean;
+  renderRowAction?: (item: T) => ReactNode;
 }) {
   const tableOverflow = useHorizontalOverflow();
-  const columns = clientView
-    ? ["客户 / 工单编号", "工单标题 / 类型", "截止日期", "创建时间", "状态", "操作"]
-    : ["客户 / 工单编号", "工单标题 / 类型", "责任人 / 团队", "截止日期", "创建时间", "下一步", "状态", "操作"];
-  const bodyWidth = Math.max(clientView ? 980 : 1280, tableOverflow.width) - 232;
-  const columnWidths = (clientView ? [.31, .33, .16, .20] : [.18, .24, .16, .12, .14, .16]).map((weight) => bodyWidth * weight).concat(140, 92);
+  const infoColumns = [
+    { label: "客户 / 工单编号", weight: 18 },
+    { label: "工单标题 / 类型", weight: 24 },
+    ...(ownerColumn === "none" ? [] : [{ label: ownerColumn === "team" ? "负责团队" : "责任人 / 团队", weight: 16 }]),
+    { label: "截止日期", weight: 12 },
+    { label: dateColumn === "completed_at" ? "完成时间" : "创建时间", weight: 14 },
+    ...(showNextStep ? [{ label: "下一步", weight: 16 }] : []),
+  ];
+  const columns = [...infoColumns.map((column) => column.label), "状态", "操作"];
+  const minWidth = clientView ? 980 : showNextStep ? 1280 : ownerColumn === "none" ? 980 : 1120;
+  const actionWidth = renderRowAction ? 172 : 92;
+  const bodyWidth = Math.max(minWidth, tableOverflow.width) - 140 - actionWidth;
+  const totalWeight = infoColumns.reduce((sum, column) => sum + column.weight, 0);
+  const columnWidths = infoColumns.map((column) => bodyWidth * column.weight / totalWeight).concat(140, actionWidth);
+  const rowOptions = { from, ownerColumn, dateColumn, showNextStep };
+
   return (
     <>
       <div
@@ -96,16 +133,16 @@ export function WorkOrderLedgerList({ rows, from, label, fallback, clientView =
         tabIndex={0}
       >
         {fallback}
-        <table hidden={Boolean(fallback)} className={`order-table order-ledger${clientView ? " is-client-view" : ""}`}>
+        <table hidden={Boolean(fallback)} className="order-table order-ledger" style={{ minWidth }}>
           <OpsTableColumns widths={columnWidths} />
           <thead><tr>{columns.map((column) => <th key={column} scope="col">{column}</th>)}</tr></thead>
           <tbody>
-            {!fallback && rows.map((item) => <TicketLedgerRow key={item.ticket_id} item={item} from={from} clientView={clientView} />)}
+            {!fallback && rows.map((item) => <TicketLedgerRow key={item.ticket_id} item={item} {...rowOptions} extraAction={renderRowAction?.(item)} />)}
           </tbody>
         </table>
       </div>
       <div className="order-mobile-list" aria-label={label}>
-        {fallback || rows.map((item) => <TicketLedgerRow key={item.ticket_id} item={item} from={from} clientView={clientView} mobile />)}
+        {fallback || rows.map((item) => <TicketLedgerRow key={item.ticket_id} item={item} {...rowOptions} extraAction={renderRowAction?.(item)} mobile />)}
       </div>
     </>
   );

+ 57 - 42
web-scaffold/src/pages/TeamQueuePage.tsx

@@ -12,29 +12,35 @@
  * ⛔ 复制两份队列实现——分派口径与候选人口径必须是一把尺子。
  */
 import { useState } from "react";
-import { ArrowRight, Check, Clock3, Info, Shuffle, UserRoundCheck } from "lucide-react";
+import { ArrowRight, Check, ClipboardList, Clock3, Search, Shuffle, UserRoundCheck, UsersRound, X } from "lucide-react";
 import { Link, useLocation, useSearchParams } from "react-router";
 import { Button } from "../components/ui/button";
 import { FilterSelect } from "../components/ui/filter-select";
 import { FieldHint } from "../components/ui/field-hint";
-import { OpsDrawer, OpsNotice, OpsTag } from "../components/OperationsKit";
-import { WorkspaceEmpty, WorkspaceHeading, WorkspacePanel, WorkspaceSearch } from "../components/RoleWorkspaceKit";
+import { OpsDrawer, OpsNotice } from "../components/OperationsKit";
+import { WorkspaceEmpty, WorkspaceHeading } from "../components/RoleWorkspaceKit";
+import { SearchInput } from "../components/ui/search-input";
+import { TicketState } from "../components/ticketState";
+import { WorkOrderLedgerList } from "../components/work-order/WorkOrderLedgerList";
 import { useDemoIdentity } from "../lib/demo-session";
-import { classifyTicketError, fmtTime, TICKET_PAGE_SIZE, usePendingQueue } from "../lib/ticket";
+import { classifyTicketError, TICKET_PAGE_SIZE, usePendingQueue } from "../lib/ticket";
 import {
-  TICKET_TYPES, statusLabel, ticketAssign, ticketDispatchAuto, ticketPendingQueue, typeLabel,
+  TICKET_TYPES, ticketAssign, ticketDispatchAuto, ticketPendingQueue, typeLabel,
   type AssignCandidate, type DispatchResult, type PendingQueueItem,
 } from "../lib/api/ticket";
 import { useSubmit } from "../lib/useLoad";
-import { ServerListPager } from "../components/ListPager";
+import { ListPager } from "../components/ListPager";
+import "../styles/operations.css";
+import "../styles/orders.css";
 import "../styles/work-orders.css";
+import "../styles/work-order-ledger.css";
 
 export function TeamQueuePage() {
   const identity = useDemoIdentity();
   if (identity?.role !== "teamLead" || !identity.maintenanceTeamId) {
     return <WorkspaceEmpty title="请切换到运维团队主账号" description="待分派队列与分派操作由团队主在服务端权限内使用。" />;
   }
-  return <section className="role-workspace page-fill">
+  return <section className="role-workspace order-page work-order-ledger page-fill">
     <WorkspaceHeading title="待分派工单" description={`为 ${identity.name} 的待分派工单安排接单人,候选人按工单类型、负责范围和账号状态筛选。`} aside={<Link className="workspace-link" to="/work-orders">查看团队工单 <ArrowRight size={15} /></Link>} />
     <QueueBoard teamId={identity.maintenanceTeamId} teamName={identity.name} canAutoDispatch />
   </section>;
@@ -66,7 +72,8 @@ export function QueueBoard({ teamId, teamName, showTeamColumn = false, canAutoDi
   const total = queue.data?.total ?? 0;
   const fail = queue.error ? classifyTicketError(queue.error) : null;
   const lateCount = rows.filter((item) => item.overdue_7d).length;
-  const teams = [...new Set(rows.map((row) => row.team_name ?? "未分派团队"))];
+  const teams = new Set(rows.map((row) => row.assign_team_id).filter(Boolean)).size;
+  const from = location.pathname + location.search;
 
   const submit = useSubmit();
   const [action, setAction] = useState<PendingQueueItem | "auto" | null>(null);
@@ -125,53 +132,61 @@ export function QueueBoard({ teamId, teamName, showTeamColumn = false, canAutoDi
   }
   const failure = submit.error ? classifyTicketError(submit.error) : null;
 
+  const metrics = [
+    { title: "待分派工单", value: total, description: q || type ? "符合当前筛选" : teamName || "账号可见范围", icon: ClipboardList },
+    { title: "超期 / 临期", value: lateCount, description: "当前页 · 7 日内到期或已超期", icon: Clock3, tone: lateCount ? "warning" : undefined },
+    ...(showTeamColumn ? [{ title: "涉及团队", value: teams, description: "当前页 · 已归属团队", icon: UsersRound }] : []),
+  ];
+  const fallback = queue.loading
+    ? <div className="order-empty" role="status">正在读取待分派队列…</div>
+    : fail
+      ? <TicketState fail={fail} onRetry={queue.reload} />
+      : !rows.length ? <div className="order-empty"><h3>{q || type ? "没有匹配的待分派工单" : "暂无待分派工单"}</h3></div> : null;
+
   return <>
-    <div className="workspace-metrics">
-      <div className="workspace-metric"><span>待分派工单</span><strong>{queue.loading ? "—" : fail ? "—" : total}</strong><small>{teamName ? `${teamName} · 未指定责任人` : "权限范围内 · 未指定责任人"}</small></div>
-      <div className={`workspace-metric ${lateCount ? "warning" : ""}`}><span>超期/临期</span><strong>{queue.loading ? "—" : fail ? "—" : lateCount}</strong><small>7 日内到期或已超期 · 当页口径</small></div>
-      {showTeamColumn && <div className="workspace-metric"><span>涉及团队</span><strong>{queue.loading ? "—" : fail ? "—" : teams.length}</strong><small>当页口径</small></div>}
+    <div className="work-order-ledger-summary work-order-queue-summary" role="group" aria-label="待分派队列统计" data-count={metrics.length}>
+      {metrics.map(({ title, value, description, icon: Icon, tone }, index) => (
+        <div className={`work-order-metric${index === 0 ? " work-order-metric-total" : ""}`} key={title} data-tone={tone}>
+          <span className="work-order-metric-icon"><Icon size={18} aria-hidden="true" /></span>
+          <span className="work-order-metric-body"><span>{title}</span><strong>{queue.loading ? "…" : fail ? "—" : value.toLocaleString("zh-CN")}</strong><small>{description}</small></span>
+        </div>
+      ))}
     </div>
-    {!!lateCount && <div className="workspace-alert"><Clock3 size={17} /><span>有 {lateCount} 张待分派工单已超期或 7 日内到期,请优先安排。</span></div>}
-    <section className="workspace-panel work-order-list-shell list-shell-fill" aria-label="待分派队列">
-      <header className="work-order-list-heading">
-        <Button variant="outline" disabled={queue.loading || !total || !canAutoDispatch} title={canAutoDispatch ? "按未完成数量平均分派本团队待分派工单" : "自动平均分派按团队执行,仅团队主账号可用"} onClick={() => { setAction("auto"); setTip(""); setSummary(null); }}><Shuffle size={16} />按未完成数量平均分派</Button>
-      </header>
-      <div className="workspace-toolbar">
-        <WorkspaceSearch placeholder="搜索工单号、工单ID或标题" value={q} onChange={(value) => filter("q", value)} />
+    <section className="order-list-shell list-shell-fill" aria-label="待分派队列">
+      <div className="ops-toolbar order-filters work-order-queue-filters">
+        <label className="ops-search order-search">
+          <Search size={17} aria-hidden="true" />
+          <SearchInput aria-label="搜索待分派工单" placeholder="搜索工单号、工单ID或标题" value={q} onCommit={(value) => filter("q", value)} />
+          {q && <button type="button" aria-label="清空搜索" onClick={() => filter("q", "")}><X size={15} /></button>}
+        </label>
         <FilterSelect icon="type" aria-label="工单类型" value={type} onChange={(event) => filter("type", event.target.value)}>
           <option value="">全部类型</option>
           {TICKET_TYPES.map((t) => <option key={t} value={t}>{typeLabel(t)}</option>)}
         </FilterSelect>
         {(q || type) && <Button variant="ghost" size="sm" onClick={() => setParams({})}>重置筛选</Button>}
+        <Button className="work-order-queue-auto" size="sm" variant="outline" disabled={queue.loading || !total || !canAutoDispatch} title={canAutoDispatch ? "分派本团队全部待分派工单,不受当前筛选影响" : "仅团队主账号可自动平均分派"} onClick={() => { setAction("auto"); setTip(""); setSummary(null); }}><Shuffle size={15} />自动平均分派</Button>
       </div>
-      <div className="measured-table-scroll workspace-table-wrap"><table className="workspace-table">
-        <thead><tr><th>工单 / 客户</th><th>类型与状态</th>{showTeamColumn && <th>团队</th>}<th>事项摘要</th><th>创建时间</th><th>操作</th></tr></thead>
-        <tbody>
-          {rows.map((item) => <tr key={item.ticket_id}>
-            <td><Link className="workspace-link" to={`/work-orders/${encodeURIComponent(item.ticket_id)}`} state={{ from: location.pathname + location.search }}>{item.ticket_no ?? "未编号"}</Link><small>{item.customer_name ?? "-"}</small></td>
-            <td><OpsTag tone="brand">{typeLabel(item.ticket_type)}</OpsTag><small>{statusLabel(item.status, item.ticket_type)}</small></td>
-            {showTeamColumn && <td>{item.team_name ?? <span className="table-placeholder">未分派团队</span>}</td>}
-            <td className="wrap"><span>{item.title ?? "-"}</span>{item.overdue_7d && <small className="workspace-danger">超期/临期(7 日内)</small>}</td>
-            <td>{fmtTime(item.created_at)}</td>
-            <td><div className="workspace-actions"><button className="workspace-link" onClick={() => void openAssign(item)}><UserRoundCheck size={15} />指定成员</button><Link className="workspace-link" to={`/work-orders/${encodeURIComponent(item.ticket_id)}`} state={{ from: location.pathname + location.search }}>详情</Link></div></td>
-          </tr>)}
-        </tbody>
-      </table>
-        {queue.loading && <div className="workspace-empty"><h3>正在读取待分派队列…</h3></div>}
-        {fail && <div className="workspace-empty"><Clock3 size={26} aria-hidden /><h3>{fail.kind === "wiring" ? "接口待后端接线" : fail.kind === "permission" ? "当前账号无权查看" : "队列读取失败"}</h3><p>{fail.message}</p></div>}
-        {!queue.loading && !fail && !rows.length && <WorkspaceEmpty title="当前队列已清空" description="已分派的工单可在全部工单中继续跟进。" />}
-      </div>
-      <ServerListPager total={total} page={page} pageSize={TICKET_PAGE_SIZE} unit="张" className="list-pager work-order-ledger-pager" onPageChange={(next) => setParams((cur) => { const u = new URLSearchParams(cur); u.set("page", String(next)); return u; }, { replace: true })} />
-      <p className="workspace-note"><Info size={15} />共 {total} 张待分派,当页显示 {rows.length} 张。自动平均分派作用于团队全部待分派工单,不受列表筛选影响;无符合条件成员的工单留在队列。</p>
+      <WorkOrderLedgerList
+        rows={rows}
+        from={from}
+        label="待分派工单"
+        fallback={fallback}
+        ownerColumn={showTeamColumn ? "team" : "none"}
+        showNextStep={false}
+        renderRowAction={(item) => <button type="button" className="ops-table-action" onClick={() => void openAssign(item)}><UserRoundCheck size={15} />指定成员</button>}
+      />
+      {!queue.loading && !fail && <ListPager total={total} page={page - 1} pageSize={TICKET_PAGE_SIZE} unit="张" onPageChange={(next) => setParams((current) => {
+        const updated = new URLSearchParams(current);
+        if (next) updated.set("page", String(next + 1));
+        else updated.delete("page");
+        return updated;
+      }, { replace: true })} />}
     </section>
-    <WorkspacePanel title="候选人接单负荷" description="点「指定成员」时按该工单现算候选人与未完成数;自动分派仍按服务端最少者优先。">
-      <p className="workspace-note"><Info size={15} />首屏不再预装全页候选人(避免十余次 UDS);打开指定成员抽屉即可看到该单可接人选与手头量。</p>
-    </WorkspacePanel>
     {action && <OpsDrawer title={action === "auto" ? "确认自动平均分派" : "指定接单成员"} subtitle={teamName ?? "权限范围内"} onClose={() => setAction(null)}>
       <div className="workspace-form">
         {action === "auto" ? <>
           <Shuffle size={28} className="text-primary" />
-          <h3>分派本团队的 {total} 张待分派工单</h3>
+          <h3>分派本团队的待分派工单</h3>
           <p className="text-sm leading-7 text-muted-foreground">服务端每张选择符合类型与可派条件的成员,优先分给未完成工单最少者;没有合适成员的工单留在队列。若团队分派方式不是「自动平均分派」,服务端会拒绝并说明原因。</p>
           {summary && <p className="text-sm leading-7">上轮回执:分派 {summary.dispatched.length} 张 / 扫描 {summary.scanned} 张 / 跳过 {summary.skipped.length} 张。</p>}
         </> : <>

+ 57 - 61
web-scaffold/src/pages/WorkOrderDeliveryPage.tsx

@@ -9,19 +9,21 @@
  * 页面只做「分发到处置」:回执、重推、报文处置的可用性一律由详情页服务端 `actions` 决定,
  * ⛔ 在这里按状态臆断按钮能不能点。
  */
-import { Link, Navigate, useSearchParams } from "react-router";
+import { Link, Navigate, useLocation, useSearchParams } from "react-router";
 import { PageIntro } from "../components/PageIntro";
-import { ArrowRight, Inbox, PackageCheck, Search, TriangleAlert } from "lucide-react";
-import { ServerListPager } from "../components/ListPager";
+import { ArrowRight, PackageCheck, TriangleAlert } from "lucide-react";
+import { ListPager } from "../components/ListPager";
 import { TicketState } from "../components/ticketState";
 import { MessageInboxPanel } from "../components/work-order/MessageInboxPanel";
-import { TicketTypeTag } from "../components/work-order/TicketBadges";
-import { classifyTicketError, fmtTime, TICKET_PAGE_SIZE, useTicketList, useTodoCounts } from "../lib/ticket";
+import { WorkOrderLedgerList } from "../components/work-order/WorkOrderLedgerList";
+import { classifyTicketError, TICKET_PAGE_SIZE, useTicketList, useTodoCounts } from "../lib/ticket";
 import { isMainlineTicketType } from "../lib/api/ticket";
 import { useTicketStatusCounts } from "../lib/work-order-counts";
 import { useDemoIdentity } from "../lib/demo-session";
 import "../styles/operations.css";
+import "../styles/orders.css";
 import "../styles/work-orders.css";
+import "../styles/work-order-ledger.css";
 
 type DeliveryTab = "receipt" | "rejected" | "messages";
 const TABS: { id: DeliveryTab; title: string }[] = [
@@ -47,9 +49,9 @@ export function WorkOrderDeliveryPage() {
 
   if (identity && !DELIVERY_ROLES.includes(identity.role)) return <Navigate to="/work-orders/mine" replace />;
 
-  const completedCount = counts.data?.completed;
-  const rejectedCount = counts.data?.rejected;
-  const messageCount = todo.data?.item_4_message_pending;
+  const completedCount = counts.error ? undefined : counts.data?.completed;
+  const rejectedCount = counts.error ? undefined : counts.data?.rejected;
+  const messageCount = todo.error ? undefined : todo.data?.item_4_message_pending;
 
   const canDispose = Boolean(identity && DISPOSE_ROLES.includes(identity.role));
 
@@ -61,82 +63,76 @@ export function WorkOrderDeliveryPage() {
 
   const reloadCounts = () => { counts.reload(); if (tab === "messages") todo.reload(); };
 
-  return <section className="work-order-page work-order-delivery-page page-fill page-fill-window">
-    <header className="work-order-heading">
+  return <section className="order-page work-order-ledger page-fill page-fill-window">
+    <header className="order-heading">
       <div>
-        <p className="work-order-eyebrow"><span /> DELIVERY / 交付与回执</p>
         <h1>交付与回执</h1>
-        <PageIntro>工单竣工后在这里确认回执,跟进驳回重推和运营商报文。</PageIntro>
+        <PageIntro>查看待确认的工单、处理竣工驳回和待归属的运营商报文。</PageIntro>
       </div>
     </header>
 
-    <div className="work-order-tabs" role="tablist" aria-label="交付环节">
-      {TABS.map((item) => {
-        const value = item.id === "receipt" ? completedCount : item.id === "rejected" ? rejectedCount : messageCount;
-        return <button key={item.id} type="button" role="tab" aria-selected={tab === item.id} className={tab === item.id ? "active" : ""} onClick={() => goto(item.id)}>
-          {item.title}{(counts.loading && item.id !== "messages") || (tab === "messages" && todo.loading && item.id === "messages") ? <span>…</span> : value !== undefined ? <span>{value}</span> : null}
-        </button>;
-      })}
-    </div>
-
-    <div className="work-order-list-shell list-shell-fill">
+    <div className="order-list-shell list-shell-fill">
+      <div className="order-tabs" role="group" aria-label="交付环节">
+        {TABS.map((item) => {
+          const value = item.id === "receipt" ? completedCount : item.id === "rejected" ? rejectedCount : messageCount;
+          const loading = item.id === "messages" ? tab === "messages" && todo.loading : counts.loading;
+          const showCount = item.id !== "messages" || tab === "messages" || value !== undefined;
+          return (
+            <button key={item.id} type="button" aria-pressed={tab === item.id} className={tab === item.id ? "active" : ""} onClick={() => goto(item.id)}>
+              {item.title}{showCount && <span>{loading ? "…" : value?.toLocaleString("zh-CN") ?? "—"}</span>}
+            </button>
+          );
+        })}
+      </div>
       {tab === "messages"
         ? <MessageInboxPanel canDispose={canDispose} onChanged={reloadCounts} />
         : <DeliveryList
             key={tab}
             tab={tab}
             page={page}
-            onPageChange={(next) => { const p = new URLSearchParams(params); p.set("page", String(next)); setParams(p, { replace: true }); }}
+            onPageChange={(next) => {
+              const updated = new URLSearchParams(params);
+              if (next > 1) updated.set("page", String(next)); else updated.delete("page");
+              setParams(updated, { replace: true });
+            }}
           />}
     </div>
   </section>;
 }
 
 function DeliveryList({ tab, page, onPageChange }: { tab: Exclude<DeliveryTab, "messages">; page: number; onPageChange: (page: number) => void }) {
-  const status = tab === "receipt" ? "completed" : "rejected";
-  const list = useTicketList({ statuses: [status] }, page);
+  const receipt = tab === "receipt";
+  const location = useLocation();
+  const from = location.pathname + location.search;
+  const list = useTicketList({ statuses: [receipt ? "completed" : "rejected"] }, page);
   const fail = list.error ? classifyTicketError(list.error) : null;
   const rows = list.data?.rows ?? [];
   const total = list.data?.total ?? 0;
-  const pages = Math.max(1, Math.ceil(total / TICKET_PAGE_SIZE));
-  const currentPage = Math.min(page, pages);
+  const fallback = list.loading
+    ? <div className="order-empty" role="status">正在读取工单…</div>
+    : fail
+      ? <TicketState fail={fail} onRetry={list.reload} />
+      : !rows.length ? <div className="order-empty"><h3>{receipt ? "暂无待回执工单" : "暂无已驳回工单"}</h3></div> : null;
 
   return <>
     <div className="work-order-delivery-note">
-      {tab === "receipt"
-        ? <><PackageCheck size={16} /><span>竣工已回传、等待回执:「已完成待确认」的主线单确认回执后闭环;若运营商驳回,请到「已驳回」重推。回执确认仅总运营与承接团队主账号可执行。⚠️ 本段也收故障/售后停在「已处理待确认」的单——那类等的是提交方确认(或超时自动闭环),不做回执确认。</span></>
-        : <><TriangleAlert size={16} /><span>竣工被驳回:本态只开「同号覆盖重推」,按当前回填重新回传、不新发竣工号;确需改回填的,先退回重办(总运营或本团队主账号,回到「处理中」)。驳回期间期限日不重置,超期判定扣掉外部等待。</span></>}
-    </div>
-    <div className="measured-table-scroll work-order-table-wrap"><table className="work-order-table work-order-delivery-table">
-      <thead><tr><th>工单 / 客户</th><th>类型</th><th>责任人</th><th>团队</th><th>完成时间</th><th>预期完成</th><th>下一步</th><th>操作</th></tr></thead>
-      <tbody>{rows.map((row) => {
-        // 待回执段收的是 `status=completed` 的两类单,**动手的人不同**:
-        // 主线是本方录回执(服务端 `confirm_receipt` 要求有竣工行);故障/售后没有竣工件,
-        // 只能等提交方在门户确认或超时自动闭环 ⇒ ⛔ 给「去确认回执」,那是开不出来的抽屉。
-        const mainline = isMainlineTicketType(row.ticket_type);
-        return <tr key={row.ticket_id}>
-        <td><Link className="work-order-ticket-link" to={`/work-orders/${encodeURIComponent(row.ticket_id)}`} state={{ from: `/work-orders/delivery?tab=${tab}` }}>{row.ticket_no ?? "-"}</Link><small>{row.customer_name ?? "-"}</small></td>
-        <td><TicketTypeTag type={row.ticket_type} /></td>
-        <td>{row.assignee_name ?? "待分派"}</td>
-        <td>{row.team_name ?? <span className="table-placeholder">未分派团队</span>}</td>
-        <td>{fmtTime(row.completed_at)}</td>
-        <td><span>{row.expected_done_date ? row.expected_done_date.slice(0, 10) : <span className="table-placeholder">—</span>}</span>{row.overdue_7d && <small className="work-order-overdue-text">超期/临期</small>}</td>
-        <td>{tab === "receipt" ? (mainline ? "确认后闭环" : "等客户确认") : "同号覆盖重推"}</td>
-        <td>{tab === "receipt"
-          ? mainline
-            ? <Link className="work-order-next-step tone-todo" to={`/work-orders/${encodeURIComponent(row.ticket_id)}?act=receipt`} state={{ from: `/work-orders/delivery?tab=${tab}` }}>去确认回执<ArrowRight size={14} /></Link>
-            : <Link className="work-order-next-step tone-waiting" to={`/work-orders/${encodeURIComponent(row.ticket_id)}`} state={{ from: `/work-orders/delivery?tab=${tab}` }}>查看<ArrowRight size={14} /></Link>
-          : <Link className="work-order-next-step tone-urgent" to={`/work-orders/${encodeURIComponent(row.ticket_id)}`} state={{ from: `/work-orders/delivery?tab=${tab}` }}>去重推<ArrowRight size={14} /></Link>}</td>
-      </tr>})}</tbody>
-    </table>
-      {list.loading && <div className="work-order-empty"><Search size={27} /><h3>正在读取{tab === "receipt" ? "待回执" : "已驳回"}工单…</h3></div>}
-      {fail && <TicketState fail={fail} onRetry={list.reload} />}
-      {!list.loading && !fail && !rows.length && <div className="work-order-empty">
-        {tab === "receipt" ? <PackageCheck size={27} /> : <Inbox size={27} />}
-        <h3>{tab === "receipt" ? "没有等待回执的工单" : "没有被驳回的工单"}</h3>
-        <p>{tab === "receipt" ? "主线单回填齐备并生成竣工后才会出现在这里。" : "竣工被驳回后会进入此列表,处置完自动移出。"}</p>
-      </div>}
+      {receipt
+        ? <><PackageCheck size={16} aria-hidden="true" /><span>交付工单等待回执,故障和售后工单等待提交方确认。</span></>
+        : <><TriangleAlert size={16} aria-hidden="true" /><span>可按原竣工号重推。需要修改施工结果时,请先退回重办。</span></>}
     </div>
-    <ServerListPager total={total} page={currentPage} pageSize={TICKET_PAGE_SIZE} unit="张" className="list-pager work-order-ledger-pager" onPageChange={onPageChange} />
+    <WorkOrderLedgerList
+      rows={rows}
+      from={from}
+      label={receipt ? "待回执工单" : "已驳回工单"}
+      dateColumn="completed_at"
+      showNextStep={false}
+      fallback={fallback}
+      renderRowAction={(row) => {
+        if (receipt && !isMainlineTicketType(row.ticket_type)) return null;
+        const href = `/work-orders/${encodeURIComponent(row.ticket_id)}`;
+        return <Link className="ops-table-action" to={receipt ? `${href}?act=receipt` : href} state={{ from }}>{receipt ? "确认回执" : "去重推"}<ArrowRight size={14} aria-hidden="true" /></Link>;
+      }}
+    />
+    {!list.loading && !fail && <ListPager total={total} page={page - 1} pageSize={TICKET_PAGE_SIZE} unit="张" onPageChange={(next) => onPageChange(next + 1)} />}
   </>;
 }

+ 2 - 5
web-scaffold/src/pages/WorkOrderQueuePage.tsx

@@ -10,7 +10,6 @@
  */
 import { Navigate } from "react-router";
 import { PageIntro } from "../components/PageIntro";
-import { Info } from "lucide-react";
 import { QueueBoard } from "./TeamQueuePage";
 import { useDemoIdentity } from "../lib/demo-session";
 import "../styles/operations.css";
@@ -23,10 +22,9 @@ export function WorkOrderQueuePage() {
   if (identity && !QUEUE_ROLES.includes(identity.role)) return <Navigate to="/work-orders/mine" replace />;
   const teamLead = identity?.role === "teamLead" && identity.maintenanceTeamId ? identity : null;
 
-  return <section className="work-order-page work-order-queue-page page-fill">
-    <header className="work-order-heading">
+  return <section className="order-page work-order-ledger page-fill page-fill-window">
+    <header className="order-heading">
       <div>
-        <p className="work-order-eyebrow"><span /> DISPATCH / 待分派</p>
         <h1>待分派</h1>
         <PageIntro>{teamLead
           ? `为 ${teamLead.name} 的待分派工单找合适的接单人,候选人按工单类型、负责范围和账号状态筛选。`
@@ -39,6 +37,5 @@ export function WorkOrderQueuePage() {
       showTeamColumn={!teamLead}
       canAutoDispatch={Boolean(teamLead)}
     />
-    {!teamLead && <p className="work-order-block-note"><Info size={13} />自动平均分派以「团队」为作用域:服务端要求 `team_id` 且团队分派方式为自动平均。总部视角请到运维团队页切换分派方式,或在此逐张指定成员。</p>}
   </section>;
 }

+ 13 - 2
web-scaffold/src/styles/work-order-ledger.css

@@ -51,8 +51,6 @@
 
 .work-order-ledger .order-tabs button:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }
 .work-order-ledger .work-order-view-chips { flex: none; }
-.work-order-ledger .order-table.order-ledger { min-width: 1280px; }
-.work-order-ledger .order-table.order-ledger.is-client-view { min-width: 980px; }
 .work-order-ledger .order-ledger :is(th, td):nth-child(5):not(:last-child) { text-align: left; }
 .work-order-ledger .order-ledger .ops-inline-actions { justify-content: flex-end; }
 .work-order-ledger .order-table td small { margin-top: 4px; font-size: var(--type-meta); }
@@ -60,11 +58,24 @@
 .work-order-ledger :is(.work-order-status, .work-order-type) { padding: 3px 9px; border-radius: 999px; font-size: var(--type-meta); font-weight: 500; line-height: 1.55; }
 .work-order-ledger .work-order-status i { width: 5px; height: 5px; }
 
+.work-order-ledger-summary.work-order-queue-summary[data-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
+.work-order-ledger-summary.work-order-queue-summary[data-count="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
+.work-order-queue-filters .work-order-queue-auto { margin-inline-start: auto; }
+.work-order-ledger .work-order-delivery-note { flex: none; }
+.work-order-ledger .work-order-message-panel { flex: 1 1 auto; gap: 0; min-width: 0; padding: 0; }
+.work-order-message-panel .work-order-message-scroll { flex: 1 1 240px; min-height: 240px; overflow-y: auto; }
+.work-order-message-panel .work-order-process-form { flex: none; margin: 12px 24px; }
+.work-order-message-panel .work-order-process-form h2 { font-size: var(--type-body); font-weight: 600; overflow-wrap: anywhere; }
+
 @media (max-width: 1150px) {
   .work-order-ledger-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
 }
 
 @media (max-width: 640px) {
+  .work-order-ledger-summary.work-order-queue-summary[data-count="3"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
+  .work-order-ledger-summary.work-order-queue-summary[data-count="3"] > :first-child { grid-column: 1 / -1; }
+  .work-order-queue-filters .work-order-queue-auto { margin-inline-start: 0; }
+  .work-order-message-panel .work-order-process-form { margin-inline: 16px; }
   .work-order-metric { align-items: flex-start; gap: 8px; padding: 10px; }
   .work-order-metric-icon { width: 26px; height: 26px; }
   .work-order-metric-icon svg { width: 15px; height: 15px; }