WorkOrderManagementPage.tsx 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. import { useHorizontalOverflow } from "../lib/use-horizontal-overflow";
  2. import { PageIntro } from "../components/PageIntro";
  3. import { OpsNotice, OpsTableColumns } from "../components/OperationsKit";
  4. import { FilterSelect } from "../components/ui/filter-select";
  5. import { DateRangeFilter } from "../components/ui/date-range-filter";
  6. import { TicketState } from "../components/ticketState";
  7. import { TicketStatusTag, TicketTypeTag } from "../components/work-order/TicketBadges";
  8. import { useEffect, useRef, useState, type FormEvent, type ReactNode } from "react";
  9. import {
  10. Check, Clock3, Info, Plus, Search, X,
  11. } from "lucide-react";
  12. import { Button } from "../components/ui/button";
  13. import { Input } from "../components/ui/input";
  14. import { SearchInput } from "../components/ui/search-input";
  15. import { FieldHint } from "../components/ui/field-hint";
  16. import { Link, useLocation, useNavigate, useSearchParams } from "react-router";
  17. import { customerGetList, orderGetList, rowsOf } from "../lib/api/bos";
  18. import {
  19. ticketCreate,
  20. TICKET_STATUSES, TICKET_TYPES, typeLabel, statusFilterLabel,
  21. } from "../lib/api/ticket";
  22. import { classifyTicketError, fmtTime, TICKET_PAGE_SIZE, useTicketList, useTodoCounts } from "../lib/ticket";
  23. import { useTicketStatusCounts } from "../lib/work-order-counts";
  24. import { nextStepOf } from "../lib/work-order-next-step";
  25. import { todoRowDueOn } from "../lib/work-order-todo-row";
  26. import { useSubmit } from "../lib/useLoad";
  27. import { fetchAllPages } from "../lib/fetch-all-pages";
  28. import { LIST_PAGE_SIZE } from "../lib/list-paging";
  29. import { useDemoIdentity } from "../lib/demo-session";
  30. import { ServerListPager } from "../components/ListPager";
  31. import "../styles/operations.css";
  32. import "../styles/work-orders.css";
  33. /** 状态 Tab 的次序(与参考界面「阶段即导航」一致):终态放最后且不显示计数。 */
  34. const TAB_ORDER = ["unassigned", "pending", "processing", "completed", "rejected", "settled", "terminated"] as const;
  35. /** 只对「在办 + 待回执」取计数:已办结/已作废数量无运营意义,且会多打两次接口。 */
  36. const COUNTED_STATUSES = ["unassigned", "pending", "processing", "completed", "rejected"] as const;
  37. /**
  38. * `completed` 在跨类型视图(状态 Tab/筛选器/当前视图 chip)里只写短名「待确认」
  39. * (业主 2026-11-18 二次定案:两半全名拼起来撑破 Tab 行):两类行内叫法
  40. * 「已完成待确认」(主线,等运营商回执)/「已处理待确认」(故障、售后,等提交方确认)
  41. * 留在徽标与这行悬停说明里,⛔ 在筛选维度上只写其中一半。
  42. */
  43. const COMPLETED_SCOPE_HINT = "同一状态码 completed,两类都不是终态:主线=已完成待确认(等运营商回执);故障/售后=已处理待确认(等提交方确认)";
  44. function Drawer({ title, subtitle, onClose, children }: { title: string; subtitle: string; onClose: () => void; children: ReactNode }) {
  45. const ref = useRef<HTMLDialogElement>(null);
  46. useEffect(() => {
  47. const dialog = ref.current;
  48. if (!dialog) return;
  49. const previous = document.activeElement as HTMLElement | null;
  50. const overflow = document.body.style.overflow;
  51. document.body.style.overflow = "hidden";
  52. dialog.showModal();
  53. return () => { dialog.close(); document.body.style.overflow = overflow; previous?.focus(); };
  54. }, []);
  55. return <dialog ref={ref} className="work-order-drawer" aria-labelledby="work-order-drawer-title" onCancel={onClose} onClick={(event) => { if (event.target === event.currentTarget) onClose(); }}>
  56. <header><div><p>{subtitle}</p><h2 id="work-order-drawer-title">{title}</h2></div><Button variant="ghost" size="icon" aria-label="关闭抽屉" onClick={onClose}><X size={19} /></Button></header>
  57. {children}
  58. </dialog>;
  59. }
  60. /**
  61. * 代客建单(`/ticket/create@v1`)。
  62. *
  63. * 客户与订阅都从真接口选(⛔ 手输 ID:建单口的 `customer_id` 要过可见性判定,
  64. * 手输别人的客户只会拿到 `11104`)。建单口只收故障/售后两类(create.rs `CREATE_TYPES`),
  65. * 开户/到期停机/服务开通由对应业务动作生成,在此提交会被服务端拒。
  66. */
  67. const CREATABLE: ["fault" | "after_sale", string][] = [["fault", "故障报修"], ["after_sale", "售后服务"]];
  68. function Editor({ onClose, onCreated }: { onClose: () => void; onCreated: (message: string) => void }) {
  69. const submit = useSubmit();
  70. const [ticketType, setTicketType] = useState<"fault" | "after_sale">("fault");
  71. const [keyword, setKeyword] = useState("");
  72. const [customerId, setCustomerId] = useState("");
  73. const [orderId, setOrderId] = useState("");
  74. const [title, setTitle] = useState("");
  75. const [detail, setDetail] = useState("");
  76. const [customers, setCustomers] = useState<{ customer_id: string; customer_name: string | null }[]>([]);
  77. const [orders, setSubs] = useState<{ subscription_id: string; plan_name: string | null; contract_no: string | null }[]>([]);
  78. const [tip, setTip] = useState("");
  79. function pickCustomer(id: string) { setCustomerId(id); setOrderId(""); }
  80. useEffect(() => {
  81. let alive = true;
  82. const timer = window.setTimeout(async () => {
  83. try {
  84. const r = await customerGetList({ page: 0, page_size: 20, keyword: keyword.trim() || undefined });
  85. if (alive) setCustomers(rowsOf(r).map((c) => ({ customer_id: c.customer_id, customer_name: c.customer_name })));
  86. } catch { if (alive) setCustomers([]); }
  87. }, 300);
  88. return () => { alive = false; window.clearTimeout(timer); };
  89. }, [keyword]);
  90. useEffect(() => {
  91. if (!customerId) { setSubs([]); return; }
  92. let alive = true;
  93. fetchAllPages((page, page_size) => orderGetList({ customer_id: customerId, page, page_size }), { pageSize: LIST_PAGE_SIZE })
  94. .then((r) => { if (alive) setSubs(rowsOf(r.items).map((s) => ({ subscription_id: s.subscription_id, plan_name: s.plan_name, contract_no: s.contract_no ?? null }))); })
  95. .catch(() => { if (alive) setSubs([]); });
  96. return () => { alive = false; };
  97. }, [customerId]);
  98. async function submitForm(event: FormEvent<HTMLFormElement>) {
  99. event.preventDefault();
  100. setTip("");
  101. if (!customerId) { setTip("请选择归属客户。"); return; }
  102. if (title.trim().length < 2) { setTip("请填写事项标题(≥2 字)。"); return; }
  103. const ok = await submit.run(() => ticketCreate({
  104. ticket_type: ticketType,
  105. customer_id: customerId,
  106. title: title.trim(),
  107. detail: detail.trim() || undefined,
  108. subscription_id: orderId || undefined,
  109. }).then((r) => onCreated(`工单 ${r.ticket_no} 已创建。`)));
  110. if (ok) return;
  111. }
  112. const failure = submit.error ? classifyTicketError(submit.error) : null;
  113. return <Drawer title="新建工单" subtitle="工单与任务 / 代客建单" onClose={onClose}>
  114. <form className="work-order-editor" onSubmit={submitForm}>
  115. <p className="work-order-editor-note"><Info size={17} />此处受理故障报修/售后服务。开户、到期停机、服务开通由对应业务动作生成工单,不得在此独立新建。</p>
  116. <section><h3><span>01</span>事项类型</h3><div className="work-order-form-grid"><label>工单类型 <em>*</em><select value={ticketType} onChange={(event) => setTicketType(event.target.value as "fault" | "after_sale")}>{CREATABLE.map(([code, name]) => <option key={code} value={code}>{name}</option>)}</select></label></div></section>
  117. <section><h3><span>02</span>归属客户与订阅</h3>
  118. <div className="work-order-form-grid">
  119. <label>客户检索<Input autoFocus maxLength={50} placeholder="输入客户名称或编号" value={keyword} onChange={(event) => setKeyword(event.target.value)} /></label>
  120. <label>归属客户 <em>*</em><FieldHint label="归属客户说明">候选只含当前身份可见的客户;订阅随客户联动。</FieldHint><select value={customerId} onChange={(event) => pickCustomer(event.target.value)}><option value="">请选择</option>{customers.map((c) => <option key={c.customer_id} value={c.customer_id}>{c.customer_name ?? c.customer_id}</option>)}</select></label>
  121. <label className="wide">关联订阅 <FieldHint label="关联订阅说明">不关联=通用故障/售后;选择订阅后工单会挂到该订阅,便于按订阅追溯处理。</FieldHint><select value={orderId} onChange={(event) => setOrderId(event.target.value)}><option value="">不关联</option>{orders.map((s) => <option key={s.subscription_id} value={s.subscription_id}>{s.plan_name ?? s.subscription_id}{s.contract_no ? ` · ${s.contract_no}` : ""}</option>)}</select></label>
  122. </div>
  123. </section>
  124. <section><h3><span>03</span>事项内容</h3>
  125. <label>事项标题 <em>*</em><Input required maxLength={100} placeholder="一句话说明诉求" value={title} onChange={(event) => setTitle(event.target.value)} /></label>
  126. <label>详细描述<FieldHint label="详细描述说明">现象、影响范围、期望完成时间;建单后进入待分派/待处理,过程材料在详情内直传。</FieldHint><textarea maxLength={1000} rows={5} placeholder="现象、影响范围、期望完成时间" value={detail} onChange={(event) => setDetail(event.target.value)} /></label>
  127. </section>
  128. {tip && <p className="work-order-form-error" role="alert">{tip}</p>}
  129. {failure && <p className="work-order-form-error" role="alert">{failure.message}</p>}
  130. {submit.busy && <p className="work-order-editor-note">提交中…</p>}
  131. <footer><Button variant="outline" type="button" onClick={onClose}>取消</Button><Button type="submit" disabled={submit.busy}><Check size={16} />创建工单</Button></footer>
  132. </form>
  133. </Drawer>;
  134. }
  135. /** 逗号分隔的多值参数(`type`/`status` 支持多选;Tab 与下拉框都写这一份)。 */
  136. function multiOf(params: URLSearchParams, key: string): string[] {
  137. return (params.get(key) ?? "").split(",").map((v) => v.trim()).filter(Boolean);
  138. }
  139. /** 全部工单台账(真接口:`/ticket/list@v1` 服务端分页+`/ticket/todo_counts@v1`)。 */
  140. export function WorkOrderLedgerPage() {
  141. const tableOverflow = useHorizontalOverflow();
  142. /** 九列:序号、工单/客户、类型、状态、责任人/团队、截止、下一步、创建时间、操作。 */
  143. const minimumWidths = [56, 230, 110, 116, 150, 112, 168, 128, 84];
  144. const tableWidth = Math.max(1320, tableOverflow.width);
  145. const columnAt = (minimum: number, index: number, level: number) => [0, 1, 8].includes(index) ? minimum : Math.max(minimum, level * (index === 1 ? 1.3 : 1));
  146. let lower = 0, upper = tableWidth;
  147. for (let step = 0; step < 32; step++) {
  148. const level = (lower + upper) / 2;
  149. if (minimumWidths.reduce((total, minimum, index) => total + columnAt(minimum, index, level), 0) > tableWidth) upper = level;
  150. else lower = level;
  151. }
  152. const columnWidths = minimumWidths.map((minimum, index) => columnAt(minimum, index, lower));
  153. const identity = useDemoIdentity();
  154. /**
  155. * 客户角色(enterprise/sub)在**路由层**就被 `/workspace/progress` 接走(`app/App.tsx`
  156. * 的 `CustomerTicketListOnly`):客户的工单列表只有一张,⛔ 在运营台账上再裁一份。
  157. * 下面的分支是第二道防线(旧深链/守卫被绕过时不把责任人、团队、下一步、待办计数摊给客户)。
  158. */
  159. const clientView = identity?.role === "enterprise" || identity?.role === "sub";
  160. const [params, setParams] = useSearchParams();
  161. const location = useLocation();
  162. const navigate = useNavigate();
  163. const [editorOpen, setEditorOpen] = useState(false);
  164. const [notice, setNotice] = useState("");
  165. const query = params.get("q") ?? "";
  166. const types = multiOf(params, "type");
  167. const statuses = multiOf(params, "status");
  168. const from = params.get("from") ?? "";
  169. const to = params.get("to") ?? "";
  170. const [startDate, endDate] = from && to && from > to ? [to, from] : [from, to];
  171. const page = Math.max(1, Number(params.get("page")) || 1);
  172. const list = useTicketList(
  173. {
  174. keyword: query.trim() || undefined,
  175. ticket_types: types.length ? types : undefined,
  176. statuses: statuses.length ? statuses : undefined,
  177. date_from: startDate || undefined,
  178. date_to: endDate || undefined,
  179. },
  180. page,
  181. );
  182. /**
  183. * Wave F:主列表先占 UDS;待办计数/状态 Tab 角标 idle 后再拉(改前=进页并行
  184. * list+todo_counts+5×status count,争用把单次 list 顶到数百 ms)。
  185. * 客户角色不发 todo_counts(服务端 60058)。
  186. */
  187. const [deferSecondary, setDeferSecondary] = useState(false);
  188. useEffect(() => {
  189. const win = window as Window & { requestIdleCallback?: (cb: () => void, opts?: { timeout: number }) => number; cancelIdleCallback?: (id: number) => void };
  190. if (typeof win.requestIdleCallback === "function") {
  191. const id = win.requestIdleCallback(() => setDeferSecondary(true), { timeout: 800 });
  192. return () => win.cancelIdleCallback?.(id);
  193. }
  194. const t = window.setTimeout(() => setDeferSecondary(true), 0);
  195. return () => window.clearTimeout(t);
  196. }, []);
  197. const counts = useTodoCounts(!clientView && deferSecondary);
  198. const statusCounts = useTicketStatusCounts(deferSecondary && !clientView ? COUNTED_STATUSES : []);
  199. const reloadAll = () => { list.reload(); counts.reload(); statusCounts.reload(); };
  200. useEffect(() => {
  201. const ticket = params.get("ticket");
  202. if (ticket) navigate(`/work-orders/${encodeURIComponent(ticket)}`, { replace: true, state: { from: location.pathname + location.search } });
  203. }, [navigate, params, location.pathname]);
  204. /** 写多值参数:空数组=删键;`keepPage=false` 时回到第 1 页(换筛选必须回首页)。 */
  205. function setMulti(key: string, values: string[], keepPage = false) {
  206. const next = new URLSearchParams(params);
  207. next.delete(key);
  208. if (values.length) next.set(key, values.join(","));
  209. if (!keepPage) next.delete("page");
  210. setParams(next);
  211. }
  212. function patchParams(key: string, values: string[]) {
  213. const next = new URLSearchParams(params);
  214. next.delete(key);
  215. values.forEach((value) => { if (value) next.append(key, value); });
  216. if (key !== "page") next.delete("page");
  217. setParams(next);
  218. }
  219. const rows = list.data?.rows ?? [];
  220. const total = list.data?.total ?? 0;
  221. const pages = Math.max(1, Math.ceil(total / TICKET_PAGE_SIZE));
  222. const currentPage = Math.min(page, pages);
  223. const fail = list.error ? classifyTicketError(list.error) : null;
  224. const summary = counts.data;
  225. const messagePending = summary?.item_4_message_pending ?? 0;
  226. const activeTab = statuses.length === 1 ? statuses[0] : "";
  227. const filtered = Boolean(query || types.length || statuses.length || from || to);
  228. const countOf = (status: string) => statusCounts.data?.[status];
  229. return <section className="work-order-page work-order-ledger-page page-fill page-fill-window">
  230. <header className="work-order-heading">
  231. <div><p className="work-order-eyebrow"><span /> SERVICE OPERATIONS / 业务执行</p><h1>{clientView ? "工单进度" : "全部工单"}</h1><PageIntro>{clientView ? "跟进已提交的服务申请或故障报修,了解处理到了哪一步。" : "从派单到完工,随时查到每张工单由谁处理、进行到了哪一步。"}</PageIntro></div>
  232. {!clientView && <Button onClick={() => setEditorOpen(true)}><Plus size={17} />代客建单</Button>}
  233. </header>
  234. {/* 三张卡都是入口:⛔ 只出数字不给去处。报文卡原先开弹窗,现改跳「交付与回执」的报文 Tab。 */}
  235. {/* 客户角色不渲染(口径与去处都属运营侧):见 `useTodoCounts(!clientView)` 注释。 */}
  236. {!clientView && <div className="work-order-ledger-alerts" aria-label="工单待办计数">
  237. <Link className="work-order-alert-link" to="/work-orders/overview" title="开户/到期停机/服务停用/变更协议尚未回填出开停事实,期限日已过(开通类按订阅服务开始日、次日起计;停机类按建单日+7、当天计)"><span>超期未处理完</span><strong>{summary ? summary.item_1_pending_exec_overdue : "—"}</strong><small>开停类逾期未回填 · 去总览</small></Link>
  238. <Link className="work-order-alert-link" to="/work-orders?type=service_open&status=unassigned,pending,processing" title="超期的开通单(待派单/待处理/处理中)"><span>服务开通在办</span><strong>{summary ? summary.item_2_service_open_incomplete : "—"}</strong><small>超期开通单 · 去筛选</small></Link>
  239. <Link className={`work-order-alert-link${messagePending > 0 ? " is-danger" : ""}`} to="/work-orders/delivery?tab=messages" title={messagePending > 0 ? "有未归属或待确认的运营商报文,去交付与回执处置" : "当前没有待处置报文"}><span>待处置报文</span><strong>{summary ? summary.item_4_message_pending : "—"}</strong><small>{messagePending > 0 ? "未归集或待确认 · 去处置" : "未归集或待确认"}</small></Link>
  240. </div>}
  241. <div className="work-order-list-shell list-shell-fill">
  242. {/* 状态=横向 Tab(阶段即导航):点一下就是一次筛选,计数取服务端 total。 */}
  243. <div className="work-order-tabs" role="tablist" aria-label="按状态筛选">
  244. <button type="button" role="tab" aria-selected={!activeTab} className={!activeTab ? "active" : ""} onClick={() => setMulti("status", [])}>全部</button>
  245. {TAB_ORDER.map((status) => {
  246. const counted = (COUNTED_STATUSES as readonly string[]).includes(status);
  247. const value = counted ? countOf(status) : undefined;
  248. return <button key={status} type="button" role="tab" aria-selected={activeTab === status} className={activeTab === status ? "active" : ""} title={status === "completed" ? COMPLETED_SCOPE_HINT : undefined} onClick={() => setMulti("status", activeTab === status ? [] : [status])}>
  249. {statusFilterLabel(status)}{value !== undefined && <span>{statusCounts.loading ? "…" : value}</span>}
  250. </button>;
  251. })}
  252. </div>
  253. <div className="work-order-ledger-filters">
  254. <label className="work-order-ledger-search"><Search size={17} /><SearchInput aria-label="搜索工单" placeholder="搜索工单号、工单ID、标题或客户" value={query} onCommit={(value) => patchParams("q", [value])} />{query && <button type="button" aria-label="清空搜索" onClick={() => patchParams("q", [])}><X size={15} /></button>}</label>
  255. <FilterSelect icon="type" aria-label="工单类型筛选" value={types.length === 1 ? types[0] : ""} onChange={(event) => setMulti("type", event.target.value ? [...new Set([...types, event.target.value])] : [])}>
  256. <option value="">{types.length > 1 ? `已选 ${types.length} 个类型` : "全部类型"}</option>
  257. {TICKET_TYPES.map((t) => <option key={t} value={t}>{typeLabel(t)}</option>)}
  258. </FilterSelect>
  259. <FilterSelect icon="status" aria-label="工单状态筛选" value={activeTab} onChange={(event) => setMulti("status", event.target.value ? [event.target.value] : [])}>
  260. <option value="">{statuses.length > 1 ? `已选 ${statuses.length} 个状态` : "全部状态"}</option>
  261. {TICKET_STATUSES.map((s) => <option key={s} value={s} title={s === "completed" ? COMPLETED_SCOPE_HINT : undefined}>{statusFilterLabel(s)}</option>)}
  262. </FilterSelect>
  263. <DateRangeFilter label="创建时间" from={from} to={to} onChange={(key, value) => patchParams(key, [value])} />
  264. {filtered && <Button variant="ghost" size="sm" onClick={() => setParams(new URLSearchParams())}>重置筛选</Button>}
  265. </div>
  266. {/* 多值时下拉框只能显示"已选 N 个",被选中的到底是哪几个必须逐项可见、可单独摘掉。 */}
  267. {(types.length > 1 || statuses.length > 1) && <div className="work-order-view-chips" aria-label="当前筛选视图">
  268. <span>当前视图</span>
  269. {types.map((t) => <button key={`t-${t}`} type="button" onClick={() => setMulti("type", types.filter((v) => v !== t))}>{typeLabel(t)}<X size={13} /></button>)}
  270. {statuses.map((s) => <button key={`s-${s}`} type="button" onClick={() => setMulti("status", statuses.filter((v) => v !== s))}>{statusFilterLabel(s)}<X size={13} /></button>)}
  271. <button type="button" className="is-clear" onClick={() => { const next = new URLSearchParams(); setParams(next); }}>清除全部</button>
  272. </div>}
  273. <div ref={tableOverflow.ref} className={`measured-table-scroll work-order-table-wrap ticket-ledger-scroll${tableOverflow.overflow ? " has-horizontal-overflow" : ""}${tableOverflow.width >= 640 ? " can-pin-identity" : ""}${tableOverflow.canScrollLeft ? " can-scroll-left" : ""}${tableOverflow.canScrollRight ? " can-scroll-right" : ""}`} role="region" aria-label="工单列表,可横向滚动查看字段" tabIndex={0}><table className="work-order-ledger-table ticket-ledger"><OpsTableColumns widths={columnWidths} /><thead><tr><th>序号</th><th>工单 / 客户</th><th>类型</th><th>状态</th><th>责任人 / 团队</th><th>截止</th><th>下一步</th><th>创建时间</th><th>操作</th></tr></thead><tbody>{rows.map((item, index) => {
  274. const step = nextStepOf(item);
  275. const late = item.overdue_7d;
  276. // 截止列与「我的待办」同源:有延期显示延期后的生效期限(⛔ 原始 `expected_done_date`,
  277. // 否则同一张单在两页给出两个日期,而「超期/临期」按服务端真布尔并不亮)。
  278. const due = todoRowDueOn(item);
  279. const detailHref = `/work-orders/${encodeURIComponent(item.ticket_id)}${step.action ? `?act=${step.action}` : ""}`;
  280. return <tr key={item.ticket_id} className={late ? "is-overdue" : undefined}>
  281. <td className="table-number">{item.seq_no ?? (currentPage - 1) * TICKET_PAGE_SIZE + index + 1}</td>
  282. <td><strong className="work-order-ticket-number" title={item.ticket_no ?? ""}>{item.ticket_no ?? "-"}</strong><small title={item.customer_name ?? ""}>{item.customer_name ?? "-"}</small></td>
  283. <td><TicketTypeTag type={item.ticket_type} /></td>
  284. <td><TicketStatusTag status={item.status} type={item.ticket_type} /></td>
  285. <td><strong title={item.assignee_name ?? "待分派"}>{item.assignee_name ?? "待分派"}</strong><small title={item.team_name ?? "未分派团队"}>{item.team_name ?? "未分派团队"}</small></td>
  286. <td><span className={`work-order-date${late ? " is-late" : ""}`}>{due ?? "—"}</span>{item.deferred_until && <small title={`原期限 ${item.expected_done_date?.slice(0, 10) ?? "—"}`}>已延期</small>}{late && <small className="work-order-overdue-text">超期/临期</small>}</td>
  287. <td className="work-order-next-step-cell">
  288. {step.label
  289. ? <Link className={`work-order-next-step tone-${step.tone}`} to={detailHref} state={{ from: location.pathname + location.search }}>{step.label}</Link>
  290. : <span className={`work-order-next-step is-passive tone-${step.tone}`}>—</span>}
  291. <small>{step.hint}</small>
  292. </td>
  293. <td>{fmtTime(item.created_at)}</td>
  294. <td><Link className="ops-table-action" to={`/work-orders/${encodeURIComponent(item.ticket_id)}`} state={{ from: location.pathname + location.search }}>详情</Link></td>
  295. </tr>;
  296. })}</tbody></table>
  297. {list.loading && <div className="work-order-empty"><Search size={27} /><h3>正在读取工单台账…</h3></div>}
  298. {fail && <TicketState fail={fail} onRetry={list.reload} />}
  299. {!list.loading && !fail && !rows.length && <div className="work-order-empty"><Search size={27} /><h3>{filtered ? "当前筛选没有匹配的工单" : "还没有工单"}</h3><p>{filtered ? "筛选条件可能过窄:试着只保留状态,或清空其余条件。" : "开户、服务开通、到期停机等由业务动作自动建单;故障与售后可在此代客建单。"}</p>{filtered && <Button variant="ghost" size="sm" onClick={() => setParams(new URLSearchParams())}>清除全部筛选</Button>}</div>}
  300. </div>
  301. <ServerListPager total={total} page={currentPage} pageSize={TICKET_PAGE_SIZE} unit="张" className="list-pager work-order-ledger-pager" onPageChange={(next) => patchParams("page", [String(next)])} />
  302. </div>
  303. {summary && summary.item_1_pending_exec_overdue > 0 && <div className="work-order-reminder"><Clock3 size={19} /><div><strong>{summary.item_1_pending_exec_overdue} 件开户/停机类工单已过期限日仍未回填出开停事实</strong><p>只提醒负责团队,不自动改变账户状态或计费。</p></div></div>}
  304. {notice && <OpsNotice message={notice} onClose={() => setNotice("")} />}
  305. {editorOpen && <Editor onClose={() => setEditorOpen(false)} onCreated={(message) => { setEditorOpen(false); setNotice(message); reloadAll(); }} />}
  306. </section>;
  307. }