|
|
@@ -15,8 +15,8 @@
|
|
|
*/
|
|
|
import { useDetailLinkState, type DetailLinkState } from "../lib/detail-navigation";
|
|
|
import { Link, Navigate, useLocation, useNavigate } from "react-router";
|
|
|
-import { useRef, useState } from "react";
|
|
|
-import { ArrowRight, Building2, CalendarClock, CalendarDays, ClipboardCheck, ClipboardList, Hourglass, LoaderCircle, PanelRight, TriangleAlert, Wrench } from "lucide-react";
|
|
|
+import { useState } from "react";
|
|
|
+import { ArrowRight, CalendarDays, ClipboardCheck, ClipboardList, Hourglass, LoaderCircle, TriangleAlert, Wrench } from "lucide-react";
|
|
|
import { OpsTableColumns } from "../components/OperationsKit";
|
|
|
import { TicketState } from "../components/ticketState";
|
|
|
import { TicketStatusTag, TicketTypeTag } from "../components/work-order/TicketBadges";
|
|
|
@@ -62,8 +62,6 @@ export function WorkOrderMinePage() {
|
|
|
function WorkOrderMineInner() {
|
|
|
const linkState = useDetailLinkState();
|
|
|
const location = useLocation();
|
|
|
- const navigate = useNavigate();
|
|
|
- const preview = useRef<HTMLElement>(null);
|
|
|
const params = new URLSearchParams(location.search);
|
|
|
const activeQueue = MINE_QUEUES.find(({ id }) => id === params.get("view")) ?? MINE_QUEUES[0];
|
|
|
|
|
|
@@ -75,10 +73,7 @@ function WorkOrderMineInner() {
|
|
|
const today = businessToday();
|
|
|
const groups = groupTodoRows(rows, today);
|
|
|
const displayedGroups = activeQueue.id === "all" ? groups : groups.filter(({ id }) => id === activeQueue.id);
|
|
|
- const displayedRows = displayedGroups.flatMap((group) => group.rows);
|
|
|
const loaded = !list.loading && !fail;
|
|
|
- const selection = params.get("selected");
|
|
|
- const selected = loaded ? displayedRows.find((row) => row.ticket_id === selection) ?? displayedRows[0] : undefined;
|
|
|
|
|
|
// 开通类计划执行日当天可以执行,是否超期以服务端字段为准。
|
|
|
const overdue = rows.filter((row) => row.status !== "completed" && row.overdue_7d === true).length;
|
|
|
@@ -90,23 +85,11 @@ function WorkOrderMineInner() {
|
|
|
{ label: "待对方确认", value: counts.waiting },
|
|
|
];
|
|
|
|
|
|
- function locationWith(next: URLSearchParams) {
|
|
|
- return { pathname: location.pathname, search: next.toString(), hash: location.hash };
|
|
|
- }
|
|
|
-
|
|
|
function queueUrl(view: MineView) {
|
|
|
const next = new URLSearchParams(params);
|
|
|
if (view === "all") next.delete("view");
|
|
|
else next.set("view", view);
|
|
|
- if (view !== activeQueue.id) next.delete("selected");
|
|
|
- return locationWith(next);
|
|
|
- }
|
|
|
-
|
|
|
- function selectTicket(id: string) {
|
|
|
- const next = new URLSearchParams(params);
|
|
|
- next.set("selected", id);
|
|
|
- navigate(locationWith(next), { replace: true, state: location.state, preventScrollReset: true });
|
|
|
- if (window.matchMedia?.("(max-width: 1170px)")?.matches) preview.current?.scrollIntoView?.({ block: "nearest" });
|
|
|
+ return { pathname: location.pathname, search: next.toString(), hash: location.hash };
|
|
|
}
|
|
|
|
|
|
return <section className="order-page work-order-mine-page page-fill page-fill-window">
|
|
|
@@ -142,47 +125,41 @@ function WorkOrderMineInner() {
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
- <div className="work-order-mine-desk">
|
|
|
- <section className="order-list-shell work-order-mine-queue list-shell-fill" aria-label={activeQueue.label}>
|
|
|
- {list.loading ? <div className="order-empty work-order-mine-empty" role="status">
|
|
|
- <LoaderCircle size={23} className="work-order-mine-loading" aria-hidden="true" />正在读取待办…
|
|
|
- </div> : fail ? <TicketState fail={fail} onRetry={list.reload} />
|
|
|
- : !displayedRows.length ? <div className="order-empty work-order-mine-empty">
|
|
|
- <ClipboardCheck size={27} aria-hidden="true" />
|
|
|
- <h3>{rows.length ? "这一组暂无工单" : "暂无待办工单"}</h3>
|
|
|
- {!rows.length && <p>分派给你的工单会出现在这里。</p>}
|
|
|
- </div> : <div className="ops-table-wrap work-order-mine-scroll" role="region" aria-label="待办工单清单" tabIndex={0}>
|
|
|
- <table className="ops-table work-order-mine-table" aria-label="我的待办工单">
|
|
|
- <OpsTableColumns widths={[345, 205, 180, 270]} />
|
|
|
- <thead><tr>
|
|
|
- <th scope="col">工单 / 客户</th>
|
|
|
- <th scope="col">进度</th>
|
|
|
- <th scope="col">期限</th>
|
|
|
- <th scope="col">办理</th>
|
|
|
- </tr></thead>
|
|
|
- {displayedGroups.map((group) => <tbody key={group.id}>
|
|
|
- {activeQueue.id === "all" && <tr className="work-order-mine-group" data-tone={group.tone}>
|
|
|
- <th colSpan={4} scope="rowgroup" title={group.hint}>
|
|
|
- <span className="work-order-mine-group-label">
|
|
|
- {MINE_QUEUES.find(({ id }) => id === group.id)?.label}
|
|
|
- </span>
|
|
|
- <span className="work-order-mine-group-count">{group.rows.length}</span>
|
|
|
- </th>
|
|
|
- </tr>}
|
|
|
- {group.rows.map((row) => <MineQueueRow key={row.ticket_id} row={row} today={today} linkState={linkState}
|
|
|
- selected={selected?.ticket_id === row.ticket_id} onSelect={() => selectTicket(row.ticket_id)} onUrged={list.reload} />)}
|
|
|
- </tbody>)}
|
|
|
- </table>
|
|
|
- </div>}
|
|
|
- {loaded && total > rows.length && <footer className="work-order-mine-footer">
|
|
|
- <span>展示前 {rows.length} 张待办,共 {total.toLocaleString("zh-CN")} 张。各分组按当前展示的工单统计。</span>
|
|
|
- <Link className="ops-table-action" to="/work-orders">去全部工单<ArrowRight size={14} aria-hidden="true" /></Link>
|
|
|
- </footer>}
|
|
|
- </section>
|
|
|
- {selected && <aside className="work-order-mine-preview" id="mine-preview" aria-label="工单预览" ref={preview}>
|
|
|
- <MineTicketPreview row={selected} today={today} linkState={linkState} />
|
|
|
- </aside>}
|
|
|
- </div>
|
|
|
+ <section className="order-list-shell list-shell-fill" aria-label={activeQueue.label}>
|
|
|
+ {list.loading ? <div className="order-empty work-order-mine-empty" role="status">
|
|
|
+ <LoaderCircle size={23} className="work-order-mine-loading" aria-hidden="true" />正在读取待办…
|
|
|
+ </div> : fail ? <TicketState fail={fail} onRetry={list.reload} />
|
|
|
+ : !displayedGroups.length ? <div className="order-empty work-order-mine-empty">
|
|
|
+ <ClipboardCheck size={27} aria-hidden="true" />
|
|
|
+ <h3>{rows.length ? "这一组暂无工单" : "暂无待办工单"}</h3>
|
|
|
+ {!rows.length && <p>分派给你的工单会出现在这里。</p>}
|
|
|
+ </div> : <div className="ops-table-wrap work-order-mine-scroll" role="region" aria-label="待办工单清单" tabIndex={0}>
|
|
|
+ <table className="ops-table work-order-mine-table" aria-label="我的待办工单">
|
|
|
+ <OpsTableColumns widths={[345, 205, 180, 270]} />
|
|
|
+ <thead><tr>
|
|
|
+ <th scope="col">工单 / 客户</th>
|
|
|
+ <th scope="col">进度</th>
|
|
|
+ <th scope="col">期限</th>
|
|
|
+ <th scope="col">办理</th>
|
|
|
+ </tr></thead>
|
|
|
+ {displayedGroups.map((group) => <tbody key={group.id}>
|
|
|
+ {activeQueue.id === "all" && <tr className="work-order-mine-group" data-tone={group.tone}>
|
|
|
+ <th colSpan={4} scope="rowgroup" title={group.hint}>
|
|
|
+ <span className="work-order-mine-group-label">
|
|
|
+ {MINE_QUEUES.find(({ id }) => id === group.id)?.label}
|
|
|
+ </span>
|
|
|
+ <span className="work-order-mine-group-count">{group.rows.length}</span>
|
|
|
+ </th>
|
|
|
+ </tr>}
|
|
|
+ {group.rows.map((row) => <MineQueueRow key={row.ticket_id} row={row} today={today} linkState={linkState} onUrged={list.reload} />)}
|
|
|
+ </tbody>)}
|
|
|
+ </table>
|
|
|
+ </div>}
|
|
|
+ {loaded && total > rows.length && <footer className="work-order-mine-footer">
|
|
|
+ <span>展示前 {rows.length} 张待办,共 {total.toLocaleString("zh-CN")} 张。各分组按当前展示的工单统计。</span>
|
|
|
+ <Link className="ops-table-action" to="/work-orders">去全部工单<ArrowRight size={14} aria-hidden="true" /></Link>
|
|
|
+ </footer>}
|
|
|
+ </section>
|
|
|
</section>;
|
|
|
}
|
|
|
|
|
|
@@ -197,21 +174,21 @@ function mineDeadline(row: TicketListItem, today: string) {
|
|
|
return { date, label, shortLabel, relative, late: left !== null && left < (planned ? 0 : 1) };
|
|
|
}
|
|
|
|
|
|
-function MineQueueRow({ row, today, selected, onSelect, linkState, onUrged }: {
|
|
|
- row: TicketListItem; today: string; selected: boolean; onSelect: () => void; linkState: DetailLinkState; onUrged: () => void;
|
|
|
+function MineQueueRow({ row, today, linkState, onUrged }: {
|
|
|
+ row: TicketListItem; today: string; linkState: DetailLinkState; onUrged: () => void;
|
|
|
}) {
|
|
|
+ const navigate = useNavigate();
|
|
|
const summary = todoRowSummary(row);
|
|
|
const step = nextStepOf(row);
|
|
|
const deadline = mineDeadline(row, today);
|
|
|
const ticketPath = `/work-orders/${encodeURIComponent(row.ticket_id)}`;
|
|
|
|
|
|
- return <tr className="work-order-mine-row" data-selected={selected || undefined} onClick={(event) => {
|
|
|
+ return <tr className="work-order-mine-row" onClick={(event) => {
|
|
|
if (event.target instanceof Element && event.target.closest("a, button")) return;
|
|
|
- onSelect();
|
|
|
+ navigate(ticketPath, { state: linkState });
|
|
|
}}>
|
|
|
<td>
|
|
|
- <button type="button" className="work-order-mine-ticket-button" onClick={onSelect} title={summary.title}
|
|
|
- aria-controls="mine-preview" aria-pressed={selected}>{summary.title}</button>
|
|
|
+ <Link className="work-order-mine-ticket-link" to={ticketPath} state={linkState} title={summary.title}>{summary.title}</Link>
|
|
|
{summary.meta && <small className="work-order-mine-meta" title={summary.meta}>{summary.meta}</small>}
|
|
|
</td>
|
|
|
<td><div className="work-order-mine-badges">
|
|
|
@@ -240,50 +217,6 @@ function MineQueueRow({ row, today, selected, onSelect, linkState, onUrged }: {
|
|
|
</tr>;
|
|
|
}
|
|
|
|
|
|
-function MineTicketPreview({ row, today, linkState }: { row: TicketListItem; today: string; linkState: DetailLinkState }) {
|
|
|
- const { title } = todoRowSummary(row);
|
|
|
- const deadline = mineDeadline(row, today);
|
|
|
- const step = nextStepOf(row);
|
|
|
- const ticketPath = `/work-orders/${encodeURIComponent(row.ticket_id)}`;
|
|
|
- return <>
|
|
|
- <div className="work-order-mine-preview-head">
|
|
|
- <span><PanelRight size={16} aria-hidden="true" />工单预览</span>
|
|
|
- <Link to={ticketPath} state={linkState}>查看详情<ArrowRight size={14} aria-hidden="true" /></Link>
|
|
|
- </div>
|
|
|
- <div className="work-order-mine-preview-body">
|
|
|
- <div className="work-order-mine-preview-heading">
|
|
|
- <div className="work-order-mine-preview-meta">
|
|
|
- {row.ticket_no && <p className="work-order-mine-number">{row.ticket_no}</p>}
|
|
|
- <TicketStatusTag status={row.status} type={row.ticket_type} />
|
|
|
- </div>
|
|
|
- <h2 aria-live="polite">{title}</h2>
|
|
|
- <TicketTypeTag type={row.ticket_type} />
|
|
|
- </div>
|
|
|
- <dl className="work-order-mine-facts">
|
|
|
- {row.customer_name && <div className="work-order-mine-customer">
|
|
|
- <dt><Building2 size={15} aria-hidden="true" />客户</dt><dd>{row.customer_name}</dd>
|
|
|
- </div>}
|
|
|
- <div className="work-order-mine-deadline" data-late={deadline.late || undefined}>
|
|
|
- <dt><CalendarClock size={16} aria-hidden="true" />{deadline.label}</dt>
|
|
|
- <dd>
|
|
|
- {deadline.date ? <time dateTime={deadline.date}>{fmtDate(deadline.date)}</time> : "按 SLA"}
|
|
|
- {deadline.relative && <small>{deadline.relative}</small>}
|
|
|
- </dd>
|
|
|
- </div>
|
|
|
- </dl>
|
|
|
- <div className="work-order-mine-inspect-next">
|
|
|
- <p>下一步</p>
|
|
|
- {step.label
|
|
|
- ? <Link to={step.action ? `${ticketPath}?act=${step.action}` : ticketPath} state={linkState} className="work-order-mine-preview-action">
|
|
|
- {step.label}<ArrowRight size={15} aria-hidden="true" />
|
|
|
- </Link>
|
|
|
- : <div className="work-order-mine-passive">{passiveParts(step)}</div>}
|
|
|
- {step.hint && <small>{step.hint}</small>}
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </>;
|
|
|
-}
|
|
|
-
|
|
|
/**
|
|
|
* 只读态文案的渲染片段:把对家**人名**套一层 `<strong>`(业主 2026-11-18 裁定:人名要加粗)。
|
|
|
*
|