|
@@ -7,7 +7,7 @@ import { TicketState } from "../components/ticketState";
|
|
|
import { TicketStatusTag, TicketTypeTag } from "../components/work-order/TicketBadges";
|
|
import { TicketStatusTag, TicketTypeTag } from "../components/work-order/TicketBadges";
|
|
|
import { useEffect, useRef, useState, type FormEvent, type ReactNode } from "react";
|
|
import { useEffect, useRef, useState, type FormEvent, type ReactNode } from "react";
|
|
|
import {
|
|
import {
|
|
|
- Check, Clock3, Info, Plus, Search, X,
|
|
|
|
|
|
|
+ ArrowRight, Check, ClipboardCheck, ClipboardList, Clock3, Inbox, Info, Plus, Search, X,
|
|
|
} from "lucide-react";
|
|
} from "lucide-react";
|
|
|
import { Button } from "../components/ui/button";
|
|
import { Button } from "../components/ui/button";
|
|
|
import { Input } from "../components/ui/input";
|
|
import { Input } from "../components/ui/input";
|
|
@@ -17,7 +17,7 @@ import { Link, useLocation, useNavigate, useSearchParams } from "react-router";
|
|
|
import { customerGetList, orderGetList, rowsOf } from "../lib/api/bos";
|
|
import { customerGetList, orderGetList, rowsOf } from "../lib/api/bos";
|
|
|
import {
|
|
import {
|
|
|
ticketCreate,
|
|
ticketCreate,
|
|
|
- TICKET_STATUSES, TICKET_TYPES, typeLabel, statusFilterLabel,
|
|
|
|
|
|
|
+ TICKET_STATUSES, TICKET_TYPES, typeLabel, statusFilterLabel, type TicketListItem,
|
|
|
} from "../lib/api/ticket";
|
|
} from "../lib/api/ticket";
|
|
|
import { classifyTicketError, fmtTime, TICKET_PAGE_SIZE, useTicketList, useTodoCounts } from "../lib/ticket";
|
|
import { classifyTicketError, fmtTime, TICKET_PAGE_SIZE, useTicketList, useTodoCounts } from "../lib/ticket";
|
|
|
import { useTicketStatusCounts } from "../lib/work-order-counts";
|
|
import { useTicketStatusCounts } from "../lib/work-order-counts";
|
|
@@ -27,14 +27,14 @@ import { useSubmit } from "../lib/useLoad";
|
|
|
import { fetchAllPages } from "../lib/fetch-all-pages";
|
|
import { fetchAllPages } from "../lib/fetch-all-pages";
|
|
|
import { LIST_PAGE_SIZE } from "../lib/list-paging";
|
|
import { LIST_PAGE_SIZE } from "../lib/list-paging";
|
|
|
import { useDemoIdentity } from "../lib/demo-session";
|
|
import { useDemoIdentity } from "../lib/demo-session";
|
|
|
-import { ServerListPager } from "../components/ListPager";
|
|
|
|
|
|
|
+import { ListPager } from "../components/ListPager";
|
|
|
import "../styles/operations.css";
|
|
import "../styles/operations.css";
|
|
|
|
|
+import "../styles/orders.css";
|
|
|
import "../styles/work-orders.css";
|
|
import "../styles/work-orders.css";
|
|
|
|
|
+import "../styles/work-order-ledger.css";
|
|
|
|
|
|
|
|
-/** 状态 Tab 的次序(与参考界面「阶段即导航」一致):终态放最后且不显示计数。 */
|
|
|
|
|
|
|
+/** 状态页签按处理阶段排列,终态放最后。 */
|
|
|
const TAB_ORDER = ["unassigned", "pending", "processing", "completed", "rejected", "settled", "terminated"] as const;
|
|
const TAB_ORDER = ["unassigned", "pending", "processing", "completed", "rejected", "settled", "terminated"] as const;
|
|
|
-/** 只对「在办 + 待回执」取计数:已办结/已作废数量无运营意义,且会多打两次接口。 */
|
|
|
|
|
-const COUNTED_STATUSES = ["unassigned", "pending", "processing", "completed", "rejected"] as const;
|
|
|
|
|
/**
|
|
/**
|
|
|
* `completed` 在跨类型视图(状态 Tab/筛选器/当前视图 chip)里只写短名「待确认」
|
|
* `completed` 在跨类型视图(状态 Tab/筛选器/当前视图 chip)里只写短名「待确认」
|
|
|
* (业主 2026-11-18 二次定案:两半全名拼起来撑破 Tab 行):两类行内叫法
|
|
* (业主 2026-11-18 二次定案:两半全名拼起来撑破 Tab 行):两类行内叫法
|
|
@@ -147,20 +147,73 @@ function multiOf(params: URLSearchParams, key: string): string[] {
|
|
|
return (params.get(key) ?? "").split(",").map((v) => v.trim()).filter(Boolean);
|
|
return (params.get(key) ?? "").split(",").map((v) => v.trim()).filter(Boolean);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function TicketLedgerRow({ item, from, clientView, mobile = false }: {
|
|
|
|
|
+ item: TicketListItem;
|
|
|
|
|
+ from: string;
|
|
|
|
|
+ clientView: boolean;
|
|
|
|
|
+ mobile?: boolean;
|
|
|
|
|
+}) {
|
|
|
|
|
+ const step = clientView ? null : nextStepOf(item);
|
|
|
|
|
+ const href = `/work-orders/${encodeURIComponent(item.ticket_id)}`;
|
|
|
|
|
+ const state = { from };
|
|
|
|
|
+ const due = todoRowDueOn(item);
|
|
|
|
|
+ const number = item.ticket_no || item.ticket_id;
|
|
|
|
|
+ const title = item.title?.trim();
|
|
|
|
|
+ const customer = item.customer_name?.trim();
|
|
|
|
|
+ const customerName = customer || <span className="table-placeholder">未关联客户</span>;
|
|
|
|
|
+ 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 status = <TicketStatusTag status={item.status} type={item.ticket_type} />;
|
|
|
|
|
+ const type = <TicketTypeTag type={item.ticket_type} />;
|
|
|
|
|
+ const action = step?.label
|
|
|
|
|
+ ? <Link className={`work-order-next-step tone-${step.tone}`} to={step.action ? `${href}?act=${step.action}` : href} state={state}>{step.label}</Link>
|
|
|
|
|
+ : <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>;
|
|
|
|
|
+
|
|
|
|
|
+ if (mobile) {
|
|
|
|
|
+ return (
|
|
|
|
|
+ <article className="order-mobile-card work-order-ledger-mobile-card">
|
|
|
|
|
+ <div className="work-order-ledger-mobile-meta"><small>{number}</small>{status}</div>
|
|
|
|
|
+ <h3>{customerName}</h3>
|
|
|
|
|
+ <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>}
|
|
|
|
|
+ <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>
|
|
|
|
|
+ {step && <div><dt>下一步</dt><dd>{action}<small>{step.hint}</small></dd></div>}
|
|
|
|
|
+ </dl>
|
|
|
|
|
+ <div className="ops-inline-actions">{detail}</div>
|
|
|
|
|
+ </article>
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return (
|
|
|
|
|
+ <tr>
|
|
|
|
|
+ <td><strong className="table-cell-title" title={customer}>{customerName}</strong><small title={number}>{number}</small></td>
|
|
|
|
|
+ <td>
|
|
|
|
|
+ <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>}
|
|
|
|
|
+ <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>
|
|
|
|
|
+ {step && <td>{action}<small title={step.hint}>{step.hint}</small></td>}
|
|
|
|
|
+ <td>{status}</td>
|
|
|
|
|
+ <td><div className="ops-inline-actions">{detail}</div></td>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ );
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
/** 全部工单台账(真接口:`/ticket/list@v1` 服务端分页+`/ticket/todo_counts@v1`)。 */
|
|
/** 全部工单台账(真接口:`/ticket/list@v1` 服务端分页+`/ticket/todo_counts@v1`)。 */
|
|
|
export function WorkOrderLedgerPage() {
|
|
export function WorkOrderLedgerPage() {
|
|
|
const tableOverflow = useHorizontalOverflow();
|
|
const tableOverflow = useHorizontalOverflow();
|
|
|
- /** 九列:序号、工单/客户、类型、状态、责任人/团队、截止、下一步、创建时间、操作。 */
|
|
|
|
|
- const minimumWidths = [56, 230, 110, 116, 150, 112, 168, 128, 84];
|
|
|
|
|
- const tableWidth = Math.max(1320, tableOverflow.width);
|
|
|
|
|
- const columnAt = (minimum: number, index: number, level: number) => [0, 1, 8].includes(index) ? minimum : Math.max(minimum, level * (index === 1 ? 1.3 : 1));
|
|
|
|
|
- let lower = 0, upper = tableWidth;
|
|
|
|
|
- for (let step = 0; step < 32; step++) {
|
|
|
|
|
- const level = (lower + upper) / 2;
|
|
|
|
|
- if (minimumWidths.reduce((total, minimum, index) => total + columnAt(minimum, index, level), 0) > tableWidth) upper = level;
|
|
|
|
|
- else lower = level;
|
|
|
|
|
- }
|
|
|
|
|
- const columnWidths = minimumWidths.map((minimum, index) => columnAt(minimum, index, lower));
|
|
|
|
|
const identity = useDemoIdentity();
|
|
const identity = useDemoIdentity();
|
|
|
/**
|
|
/**
|
|
|
* 客户角色(enterprise/sub)在**路由层**就被 `/workspace/progress` 接走(`app/App.tsx`
|
|
* 客户角色(enterprise/sub)在**路由层**就被 `/workspace/progress` 接走(`app/App.tsx`
|
|
@@ -168,6 +221,11 @@ export function WorkOrderLedgerPage() {
|
|
|
* 下面的分支是第二道防线(旧深链/守卫被绕过时不把责任人、团队、下一步、待办计数摊给客户)。
|
|
* 下面的分支是第二道防线(旧深链/守卫被绕过时不把责任人、团队、下一步、待办计数摊给客户)。
|
|
|
*/
|
|
*/
|
|
|
const clientView = identity?.role === "enterprise" || identity?.role === "sub";
|
|
const clientView = identity?.role === "enterprise" || identity?.role === "sub";
|
|
|
|
|
+ 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 [params, setParams] = useSearchParams();
|
|
const [params, setParams] = useSearchParams();
|
|
|
const location = useLocation();
|
|
const location = useLocation();
|
|
|
const navigate = useNavigate();
|
|
const navigate = useNavigate();
|
|
@@ -208,7 +266,7 @@ export function WorkOrderLedgerPage() {
|
|
|
return () => window.clearTimeout(t);
|
|
return () => window.clearTimeout(t);
|
|
|
}, []);
|
|
}, []);
|
|
|
const counts = useTodoCounts(!clientView && deferSecondary);
|
|
const counts = useTodoCounts(!clientView && deferSecondary);
|
|
|
- const statusCounts = useTicketStatusCounts(deferSecondary && !clientView ? COUNTED_STATUSES : []);
|
|
|
|
|
|
|
+ const statusCounts = useTicketStatusCounts(deferSecondary && !clientView ? TAB_ORDER : []);
|
|
|
const reloadAll = () => { list.reload(); counts.reload(); statusCounts.reload(); };
|
|
const reloadAll = () => { list.reload(); counts.reload(); statusCounts.reload(); };
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
@@ -216,12 +274,12 @@ export function WorkOrderLedgerPage() {
|
|
|
if (ticket) navigate(`/work-orders/${encodeURIComponent(ticket)}`, { replace: true, state: { from: location.pathname + location.search } });
|
|
if (ticket) navigate(`/work-orders/${encodeURIComponent(ticket)}`, { replace: true, state: { from: location.pathname + location.search } });
|
|
|
}, [navigate, params, location.pathname]);
|
|
}, [navigate, params, location.pathname]);
|
|
|
|
|
|
|
|
- /** 写多值参数:空数组=删键;`keepPage=false` 时回到第 1 页(换筛选必须回首页)。 */
|
|
|
|
|
- function setMulti(key: string, values: string[], keepPage = false) {
|
|
|
|
|
|
|
+ /** 更新多值筛选并回到第 1 页。 */
|
|
|
|
|
+ function setMulti(key: string, values: string[]) {
|
|
|
const next = new URLSearchParams(params);
|
|
const next = new URLSearchParams(params);
|
|
|
next.delete(key);
|
|
next.delete(key);
|
|
|
if (values.length) next.set(key, values.join(","));
|
|
if (values.length) next.set(key, values.join(","));
|
|
|
- if (!keepPage) next.delete("page");
|
|
|
|
|
|
|
+ next.delete("page");
|
|
|
setParams(next);
|
|
setParams(next);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -238,38 +296,72 @@ export function WorkOrderLedgerPage() {
|
|
|
const pages = Math.max(1, Math.ceil(total / TICKET_PAGE_SIZE));
|
|
const pages = Math.max(1, Math.ceil(total / TICKET_PAGE_SIZE));
|
|
|
const currentPage = Math.min(page, pages);
|
|
const currentPage = Math.min(page, pages);
|
|
|
const fail = list.error ? classifyTicketError(list.error) : null;
|
|
const fail = list.error ? classifyTicketError(list.error) : null;
|
|
|
- const summary = counts.data;
|
|
|
|
|
- const messagePending = summary?.item_4_message_pending ?? 0;
|
|
|
|
|
|
|
+ const summary = counts.error ? null : counts.data;
|
|
|
|
|
+ const visibleCounts = statusCounts.error ? null : statusCounts.data;
|
|
|
|
|
+ const overdue = typeof summary?.item_1_pending_exec_overdue === "number" && typeof summary.item_2_service_open_incomplete === "number"
|
|
|
|
|
+ ? summary.item_1_pending_exec_overdue + summary.item_2_service_open_incomplete
|
|
|
|
|
+ : undefined;
|
|
|
|
|
+ const messagePending = summary?.item_4_message_pending;
|
|
|
const activeTab = statuses.length === 1 ? statuses[0] : "";
|
|
const activeTab = statuses.length === 1 ? statuses[0] : "";
|
|
|
const filtered = Boolean(query || types.length || statuses.length || from || to);
|
|
const filtered = Boolean(query || types.length || statuses.length || from || to);
|
|
|
- const countOf = (status: string) => statusCounts.data?.[status];
|
|
|
|
|
|
|
+ const fromList = location.pathname + location.search;
|
|
|
|
|
+ const numberOf = (value: number | undefined, loading: boolean) =>
|
|
|
|
|
+ typeof value === "number" && Number.isSafeInteger(value) && value >= 0
|
|
|
|
|
+ ? value.toLocaleString("zh-CN")
|
|
|
|
|
+ : loading ? "…" : "—";
|
|
|
|
|
+ const allCount = numberOf(visibleCounts?.total, statusCounts.loading);
|
|
|
|
|
+ const listState = list.loading ? (
|
|
|
|
|
+ <div className="order-empty" role="status">正在读取工单台账…</div>
|
|
|
|
|
+ ) : fail ? (
|
|
|
|
|
+ <TicketState fail={fail} onRetry={list.reload} />
|
|
|
|
|
+ ) : !rows.length ? (
|
|
|
|
|
+ <div className="order-empty">
|
|
|
|
|
+ <Search size={26} aria-hidden="true" />
|
|
|
|
|
+ <h3>{filtered ? "没有匹配的工单" : "暂无工单"}</h3>
|
|
|
|
|
+ {filtered && <Button variant="ghost" size="sm" onClick={() => setParams(new URLSearchParams())}>重置筛选</Button>}
|
|
|
|
|
+ </div>
|
|
|
|
|
+ ) : null;
|
|
|
|
|
|
|
|
- return <section className="work-order-page work-order-ledger-page page-fill page-fill-window">
|
|
|
|
|
- <header className="work-order-heading">
|
|
|
|
|
- <div><p className="work-order-eyebrow"><span /> SERVICE OPERATIONS / 业务执行</p><h1>{clientView ? "工单进度" : "全部工单"}</h1><PageIntro>{clientView ? "跟进已提交的服务申请或故障报修,了解处理到了哪一步。" : "从派单到完工,随时查到每张工单由谁处理、进行到了哪一步。"}</PageIntro></div>
|
|
|
|
|
|
|
+ return <section className="order-page work-order-ledger page-fill page-fill-window">
|
|
|
|
|
+ <header className="order-heading">
|
|
|
|
|
+ <div><h1>{clientView ? "工单进度" : "全部工单"}</h1><PageIntro>{clientView ? "跟进已提交的服务申请或故障报修,了解处理到了哪一步。" : "查询工单进度、责任团队和处理期限,从列表进入下一步办理。"}</PageIntro></div>
|
|
|
{!clientView && <Button onClick={() => setEditorOpen(true)}><Plus size={17} />代客建单</Button>}
|
|
{!clientView && <Button onClick={() => setEditorOpen(true)}><Plus size={17} />代客建单</Button>}
|
|
|
</header>
|
|
</header>
|
|
|
- {/* 三张卡都是入口:⛔ 只出数字不给去处。报文卡原先开弹窗,现改跳「交付与回执」的报文 Tab。 */}
|
|
|
|
|
- {/* 客户角色不渲染(口径与去处都属运营侧):见 `useTodoCounts(!clientView)` 注释。 */}
|
|
|
|
|
- {!clientView && <div className="work-order-ledger-alerts" aria-label="工单待办计数">
|
|
|
|
|
- <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>
|
|
|
|
|
- <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>
|
|
|
|
|
- <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>
|
|
|
|
|
|
|
+ {!clientView && <div className="work-order-ledger-summary" role="group" aria-label="当前账号可见范围内的工单统计">
|
|
|
|
|
+ <div className="work-order-metric work-order-metric-total">
|
|
|
|
|
+ <span className="work-order-metric-icon"><ClipboardList size={19} aria-hidden="true" /></span>
|
|
|
|
|
+ <span className="work-order-metric-body"><span>工单总量</span><strong>{allCount}</strong><small>当前账号可见范围</small></span>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <Link className="work-order-metric" to="/work-orders/overview" data-tone={overdue ? "warning" : undefined}>
|
|
|
|
|
+ <span className="work-order-metric-icon"><Clock3 size={18} aria-hidden="true" /></span>
|
|
|
|
|
+ <span className="work-order-metric-body"><span>超期未完成</span><strong>{numberOf(overdue, counts.loading)}</strong><small>开停未回填及超期开通单</small></span>
|
|
|
|
|
+ <ArrowRight className="work-order-metric-arrow" size={14} aria-hidden="true" />
|
|
|
|
|
+ </Link>
|
|
|
|
|
+ <button className="work-order-metric" type="button" onClick={() => setMulti("status", ["completed"])} aria-pressed={activeTab === "completed"}>
|
|
|
|
|
+ <span className="work-order-metric-icon"><ClipboardCheck size={18} aria-hidden="true" /></span>
|
|
|
|
|
+ <span className="work-order-metric-body"><span>待确认</span><strong>{numberOf(visibleCounts?.completed, statusCounts.loading)}</strong><small>等运营商回执或提交方确认</small></span>
|
|
|
|
|
+ <ArrowRight className="work-order-metric-arrow" size={14} aria-hidden="true" />
|
|
|
|
|
+ </button>
|
|
|
|
|
+ <Link className="work-order-metric" to="/work-orders/delivery?tab=messages" data-tone={messagePending ? "danger" : undefined}>
|
|
|
|
|
+ <span className="work-order-metric-icon"><Inbox size={18} aria-hidden="true" /></span>
|
|
|
|
|
+ <span className="work-order-metric-body"><span>待处置报文</span><strong>{numberOf(messagePending, counts.loading)}</strong><small>未归集或待确认</small></span>
|
|
|
|
|
+ <ArrowRight className="work-order-metric-arrow" size={14} aria-hidden="true" />
|
|
|
|
|
+ </Link>
|
|
|
</div>}
|
|
</div>}
|
|
|
- <div className="work-order-list-shell list-shell-fill">
|
|
|
|
|
- {/* 状态=横向 Tab(阶段即导航):点一下就是一次筛选,计数取服务端 total。 */}
|
|
|
|
|
- <div className="work-order-tabs" role="tablist" aria-label="按状态筛选">
|
|
|
|
|
- <button type="button" role="tab" aria-selected={!activeTab} className={!activeTab ? "active" : ""} onClick={() => setMulti("status", [])}>全部</button>
|
|
|
|
|
- {TAB_ORDER.map((status) => {
|
|
|
|
|
- const counted = (COUNTED_STATUSES as readonly string[]).includes(status);
|
|
|
|
|
- const value = counted ? countOf(status) : undefined;
|
|
|
|
|
- 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])}>
|
|
|
|
|
- {statusFilterLabel(status)}{value !== undefined && <span>{statusCounts.loading ? "…" : value}</span>}
|
|
|
|
|
- </button>;
|
|
|
|
|
- })}
|
|
|
|
|
|
|
+ <div className="order-list-shell list-shell-fill">
|
|
|
|
|
+ <div className="order-tabs" role="group" aria-label="按工单状态筛选" aria-describedby={clientView ? undefined : "work-order-count-scope"}>
|
|
|
|
|
+ {!clientView && <span id="work-order-count-scope" className="sr-only">角标为当前账号可见范围内的工单数,列表筛选结果以分页总数为准。</span>}
|
|
|
|
|
+ <button type="button" aria-pressed={!statuses.length} className={!statuses.length ? "active" : ""} onClick={() => setMulti("status", [])}>
|
|
|
|
|
+ 全部状态{!clientView && <span>{allCount}</span>}
|
|
|
|
|
+ </button>
|
|
|
|
|
+ {TAB_ORDER.map((status) => (
|
|
|
|
|
+ <button key={status} type="button" aria-pressed={activeTab === status} className={activeTab === status ? "active" : ""} title={status === "completed" ? COMPLETED_SCOPE_HINT : undefined} onClick={() => setMulti("status", [status])}>
|
|
|
|
|
+ {statusFilterLabel(status)}{!clientView && <span>{numberOf(visibleCounts?.[status], statusCounts.loading)}</span>}
|
|
|
|
|
+ </button>
|
|
|
|
|
+ ))}
|
|
|
</div>
|
|
</div>
|
|
|
- <div className="work-order-ledger-filters">
|
|
|
|
|
- <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>
|
|
|
|
|
|
|
+ <div className="ops-toolbar order-filters">
|
|
|
|
|
+ <label className="ops-search order-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>
|
|
|
<FilterSelect icon="type" aria-label="工单类型筛选" value={types.length === 1 ? types[0] : ""} onChange={(event) => setMulti("type", event.target.value ? [...new Set([...types, event.target.value])] : [])}>
|
|
<FilterSelect icon="type" aria-label="工单类型筛选" value={types.length === 1 ? types[0] : ""} onChange={(event) => setMulti("type", event.target.value ? [...new Set([...types, event.target.value])] : [])}>
|
|
|
<option value="">{types.length > 1 ? `已选 ${types.length} 个类型` : "全部类型"}</option>
|
|
<option value="">{types.length > 1 ? `已选 ${types.length} 个类型` : "全部类型"}</option>
|
|
|
{TICKET_TYPES.map((t) => <option key={t} value={t}>{typeLabel(t)}</option>)}
|
|
{TICKET_TYPES.map((t) => <option key={t} value={t}>{typeLabel(t)}</option>)}
|
|
@@ -288,37 +380,28 @@ export function WorkOrderLedgerPage() {
|
|
|
{statuses.map((s) => <button key={`s-${s}`} type="button" onClick={() => setMulti("status", statuses.filter((v) => v !== s))}>{statusFilterLabel(s)}<X size={13} /></button>)}
|
|
{statuses.map((s) => <button key={`s-${s}`} type="button" onClick={() => setMulti("status", statuses.filter((v) => v !== s))}>{statusFilterLabel(s)}<X size={13} /></button>)}
|
|
|
<button type="button" className="is-clear" onClick={() => { const next = new URLSearchParams(); setParams(next); }}>清除全部</button>
|
|
<button type="button" className="is-clear" onClick={() => { const next = new URLSearchParams(); setParams(next); }}>清除全部</button>
|
|
|
</div>}
|
|
</div>}
|
|
|
- <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) => {
|
|
|
|
|
- const step = nextStepOf(item);
|
|
|
|
|
- const late = item.overdue_7d;
|
|
|
|
|
- // 截止列与「我的待办」同源:有延期显示延期后的生效期限(⛔ 原始 `expected_done_date`,
|
|
|
|
|
- // 否则同一张单在两页给出两个日期,而「超期/临期」按服务端真布尔并不亮)。
|
|
|
|
|
- const due = todoRowDueOn(item);
|
|
|
|
|
- const detailHref = `/work-orders/${encodeURIComponent(item.ticket_id)}${step.action ? `?act=${step.action}` : ""}`;
|
|
|
|
|
- return <tr key={item.ticket_id} className={late ? "is-overdue" : undefined}>
|
|
|
|
|
- <td className="table-number">{item.seq_no ?? (currentPage - 1) * TICKET_PAGE_SIZE + index + 1}</td>
|
|
|
|
|
- <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>
|
|
|
|
|
- <td><TicketTypeTag type={item.ticket_type} /></td>
|
|
|
|
|
- <td><TicketStatusTag status={item.status} type={item.ticket_type} /></td>
|
|
|
|
|
- <td><strong title={item.assignee_name ?? "待分派"}>{item.assignee_name ?? "待分派"}</strong><small title={item.team_name ?? "未分派团队"}>{item.team_name ?? <span className="table-placeholder">未分派团队</span>}</small></td>
|
|
|
|
|
- <td><span className={`work-order-date${late ? " is-late" : ""}`}>{due ?? <span className="table-placeholder">—</span>}</span>{item.deferred_until && <small title={`原期限 ${item.expected_done_date?.slice(0, 10) ?? "—"}`}>已延期</small>}{late && <small className="work-order-overdue-text">超期/临期</small>}</td>
|
|
|
|
|
- <td className="work-order-next-step-cell">
|
|
|
|
|
- {step.label
|
|
|
|
|
- ? <Link className={`work-order-next-step tone-${step.tone}`} to={detailHref} state={{ from: location.pathname + location.search }}>{step.label}</Link>
|
|
|
|
|
- : <span className={`work-order-next-step is-passive tone-${step.tone}`}>—</span>}
|
|
|
|
|
- <small>{step.hint}</small>
|
|
|
|
|
- </td>
|
|
|
|
|
- <td>{fmtTime(item.created_at)}</td>
|
|
|
|
|
- <td><Link className="ops-table-action" to={`/work-orders/${encodeURIComponent(item.ticket_id)}`} state={{ from: location.pathname + location.search }}>详情</Link></td>
|
|
|
|
|
- </tr>;
|
|
|
|
|
- })}</tbody></table>
|
|
|
|
|
- {list.loading && <div className="work-order-empty"><Search size={27} /><h3>正在读取工单台账…</h3></div>}
|
|
|
|
|
- {fail && <TicketState fail={fail} onRetry={list.reload} />}
|
|
|
|
|
- {!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>}
|
|
|
|
|
|
|
+ <div
|
|
|
|
|
+ ref={tableOverflow.ref}
|
|
|
|
|
+ className={`measured-table-scroll order-table-wrap order-ledger-scroll work-order-ledger-scroll${tableOverflow.overflow ? " has-horizontal-overflow" : ""}${tableOverflow.canScrollLeft ? " can-scroll-left" : ""}${tableOverflow.canScrollRight ? " can-scroll-right" : ""}`}
|
|
|
|
|
+ role="region"
|
|
|
|
|
+ aria-label="工单列表,可横向滚动查看字段"
|
|
|
|
|
+ tabIndex={0}
|
|
|
|
|
+ >
|
|
|
|
|
+ <table className={`order-table order-ledger${clientView ? " is-client-view" : ""}`}>
|
|
|
|
|
+ <OpsTableColumns widths={columnWidths} />
|
|
|
|
|
+ <thead><tr>{columns.map((column) => <th key={column} scope="col">{column}</th>)}</tr></thead>
|
|
|
|
|
+ <tbody>
|
|
|
|
|
+ {listState ? <tr><td colSpan={columns.length}>{listState}</td></tr> : rows.map((item) => (
|
|
|
|
|
+ <TicketLedgerRow key={item.ticket_id} item={item} from={fromList} clientView={clientView} />
|
|
|
|
|
+ ))}
|
|
|
|
|
+ </tbody>
|
|
|
|
|
+ </table>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div className="order-mobile-list" aria-label="工单列表">
|
|
|
|
|
+ {listState || rows.map((item) => <TicketLedgerRow key={item.ticket_id} item={item} from={fromList} clientView={clientView} mobile />)}
|
|
|
</div>
|
|
</div>
|
|
|
- <ServerListPager total={total} page={currentPage} pageSize={TICKET_PAGE_SIZE} unit="张" className="list-pager work-order-ledger-pager" onPageChange={(next) => patchParams("page", [String(next)])} />
|
|
|
|
|
|
|
+ {!list.loading && !fail && <ListPager total={total} page={currentPage - 1} pageSize={TICKET_PAGE_SIZE} unit="张" onPageChange={(next) => patchParams("page", [String(next + 1)])} />}
|
|
|
</div>
|
|
</div>
|
|
|
- {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>}
|
|
|
|
|
{notice && <OpsNotice message={notice} onClose={() => setNotice("")} />}
|
|
{notice && <OpsNotice message={notice} onClose={() => setNotice("")} />}
|
|
|
{editorOpen && <Editor onClose={() => setEditorOpen(false)} onCreated={(message) => { setEditorOpen(false); setNotice(message); reloadAll(); }} />}
|
|
{editorOpen && <Editor onClose={() => setEditorOpen(false)} onCreated={(message) => { setEditorOpen(false); setNotice(message); reloadAll(); }} />}
|
|
|
</section>;
|
|
</section>;
|