|
@@ -62,6 +62,7 @@ export function WorkOrderMinePage() {
|
|
|
function WorkOrderMineInner() {
|
|
function WorkOrderMineInner() {
|
|
|
const linkState = useDetailLinkState();
|
|
const linkState = useDetailLinkState();
|
|
|
const location = useLocation();
|
|
const location = useLocation();
|
|
|
|
|
+ const navigate = useNavigate();
|
|
|
const params = new URLSearchParams(location.search);
|
|
const params = new URLSearchParams(location.search);
|
|
|
const activeQueue = MINE_QUEUES.find(({ id }) => id === params.get("view")) ?? MINE_QUEUES[0];
|
|
const activeQueue = MINE_QUEUES.find(({ id }) => id === params.get("view")) ?? MINE_QUEUES[0];
|
|
|
|
|
|
|
@@ -73,23 +74,30 @@ function WorkOrderMineInner() {
|
|
|
const today = businessToday();
|
|
const today = businessToday();
|
|
|
const groups = groupTodoRows(rows, today);
|
|
const groups = groupTodoRows(rows, today);
|
|
|
const displayedGroups = activeQueue.id === "all" ? groups : groups.filter(({ id }) => id === activeQueue.id);
|
|
const displayedGroups = activeQueue.id === "all" ? groups : groups.filter(({ id }) => id === activeQueue.id);
|
|
|
|
|
+ const displayedRows = displayedGroups.flatMap((group) => group.rows);
|
|
|
|
|
+ const selection = params.get("selected");
|
|
|
|
|
+ const selected = displayedRows.find((row) => row.ticket_id === selection) ?? displayedRows[0];
|
|
|
const loaded = !list.loading && !fail;
|
|
const loaded = !list.loading && !fail;
|
|
|
|
|
|
|
|
- // 开通类计划执行日当天可以执行,是否超期以服务端字段为准。
|
|
|
|
|
- const overdue = rows.filter((row) => row.status !== "completed" && row.overdue_7d === true).length;
|
|
|
|
|
const counts = { all: rows.length, due: 0, rest: 0, waiting: 0 };
|
|
const counts = { all: rows.length, due: 0, rest: 0, waiting: 0 };
|
|
|
for (const group of groups) counts[group.id] = group.rows.length;
|
|
for (const group of groups) counts[group.id] = group.rows.length;
|
|
|
- const metrics = [
|
|
|
|
|
- { label: "当前待办", value: rows.length },
|
|
|
|
|
- { label: "已超期", value: overdue, warning: overdue > 0 },
|
|
|
|
|
- { label: "待对方确认", value: counts.waiting },
|
|
|
|
|
- ];
|
|
|
|
|
|
|
+
|
|
|
|
|
+ function locationWith(next: URLSearchParams) {
|
|
|
|
|
+ return { pathname: location.pathname, search: next.toString(), hash: location.hash };
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
function queueUrl(view: MineView) {
|
|
function queueUrl(view: MineView) {
|
|
|
const next = new URLSearchParams(params);
|
|
const next = new URLSearchParams(params);
|
|
|
if (view === "all") next.delete("view");
|
|
if (view === "all") next.delete("view");
|
|
|
else next.set("view", view);
|
|
else next.set("view", view);
|
|
|
- return { pathname: location.pathname, search: next.toString(), hash: location.hash };
|
|
|
|
|
|
|
+ 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 });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return <section className="order-page work-order-mine-page page-fill page-fill-window">
|
|
return <section className="order-page work-order-mine-page page-fill page-fill-window">
|
|
@@ -111,17 +119,9 @@ function WorkOrderMineInner() {
|
|
|
{loaded && <small className="work-order-mine-view-count" data-priority={id === "due" && counts[id] > 0}>{counts[id]}</small>}
|
|
{loaded && <small className="work-order-mine-view-count" data-priority={id === "due" && counts[id] > 0}>{counts[id]}</small>}
|
|
|
</Link>)}
|
|
</Link>)}
|
|
|
</nav>
|
|
</nav>
|
|
|
- <div className="work-order-mine-toolbar-side">
|
|
|
|
|
- <dl className="work-order-mine-summary" aria-label="当前待办统计">
|
|
|
|
|
- {metrics.map(({ label, value, warning }) => <div key={label} data-warning={warning || undefined}>
|
|
|
|
|
- <dt>{label}</dt>
|
|
|
|
|
- <dd>{list.loading ? "…" : fail ? "—" : value.toLocaleString("zh-CN")}</dd>
|
|
|
|
|
- </div>)}
|
|
|
|
|
- </dl>
|
|
|
|
|
- <div className="work-order-mine-links">
|
|
|
|
|
- <MobileEntryHint />
|
|
|
|
|
- <Link className="work-order-mine-all" to="/work-orders">全部工单<ArrowRight size={15} aria-hidden="true" /></Link>
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+ <div className="work-order-mine-links">
|
|
|
|
|
+ <MobileEntryHint />
|
|
|
|
|
+ <Link className="ops-table-action" to="/work-orders">全部工单<ArrowRight size={14} aria-hidden="true" /></Link>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
@@ -135,23 +135,25 @@ function WorkOrderMineInner() {
|
|
|
{!rows.length && <p>分派给你的工单会出现在这里。</p>}
|
|
{!rows.length && <p>分派给你的工单会出现在这里。</p>}
|
|
|
</div> : <div className="ops-table-wrap work-order-mine-scroll" role="region" aria-label="待办工单清单" tabIndex={0}>
|
|
</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="我的待办工单">
|
|
<table className="ops-table work-order-mine-table" aria-label="我的待办工单">
|
|
|
- <OpsTableColumns widths={[345, 205, 180, 270]} />
|
|
|
|
|
|
|
+ <OpsTableColumns widths={[330, 190, 150, 190, 140]} />
|
|
|
<thead><tr>
|
|
<thead><tr>
|
|
|
<th scope="col">工单 / 客户</th>
|
|
<th scope="col">工单 / 客户</th>
|
|
|
<th scope="col">进度</th>
|
|
<th scope="col">进度</th>
|
|
|
<th scope="col">期限</th>
|
|
<th scope="col">期限</th>
|
|
|
<th scope="col">办理</th>
|
|
<th scope="col">办理</th>
|
|
|
|
|
+ <th scope="col">操作</th>
|
|
|
</tr></thead>
|
|
</tr></thead>
|
|
|
{displayedGroups.map((group) => <tbody key={group.id}>
|
|
{displayedGroups.map((group) => <tbody key={group.id}>
|
|
|
{activeQueue.id === "all" && <tr className="work-order-mine-group" data-tone={group.tone}>
|
|
{activeQueue.id === "all" && <tr className="work-order-mine-group" data-tone={group.tone}>
|
|
|
- <th colSpan={4} scope="rowgroup" title={group.hint}>
|
|
|
|
|
|
|
+ <th colSpan={5} scope="rowgroup" title={group.hint}>
|
|
|
<span className="work-order-mine-group-label">
|
|
<span className="work-order-mine-group-label">
|
|
|
{MINE_QUEUES.find(({ id }) => id === group.id)?.label}
|
|
{MINE_QUEUES.find(({ id }) => id === group.id)?.label}
|
|
|
</span>
|
|
</span>
|
|
|
<span className="work-order-mine-group-count">{group.rows.length}</span>
|
|
<span className="work-order-mine-group-count">{group.rows.length}</span>
|
|
|
</th>
|
|
</th>
|
|
|
</tr>}
|
|
</tr>}
|
|
|
- {group.rows.map((row) => <MineQueueRow key={row.ticket_id} row={row} today={today} linkState={linkState} onUrged={list.reload} />)}
|
|
|
|
|
|
|
+ {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>)}
|
|
</tbody>)}
|
|
|
</table>
|
|
</table>
|
|
|
</div>}
|
|
</div>}
|
|
@@ -174,21 +176,20 @@ function mineDeadline(row: TicketListItem, today: string) {
|
|
|
return { date, label, shortLabel, relative, late: left !== null && left < (planned ? 0 : 1) };
|
|
return { date, label, shortLabel, relative, late: left !== null && left < (planned ? 0 : 1) };
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-function MineQueueRow({ row, today, linkState, onUrged }: {
|
|
|
|
|
- row: TicketListItem; today: string; linkState: DetailLinkState; onUrged: () => void;
|
|
|
|
|
|
|
+function MineQueueRow({ row, today, selected, onSelect, linkState, onUrged }: {
|
|
|
|
|
+ row: TicketListItem; today: string; selected: boolean; onSelect: () => void; linkState: DetailLinkState; onUrged: () => void;
|
|
|
}) {
|
|
}) {
|
|
|
- const navigate = useNavigate();
|
|
|
|
|
const summary = todoRowSummary(row);
|
|
const summary = todoRowSummary(row);
|
|
|
const step = nextStepOf(row);
|
|
const step = nextStepOf(row);
|
|
|
const deadline = mineDeadline(row, today);
|
|
const deadline = mineDeadline(row, today);
|
|
|
const ticketPath = `/work-orders/${encodeURIComponent(row.ticket_id)}`;
|
|
const ticketPath = `/work-orders/${encodeURIComponent(row.ticket_id)}`;
|
|
|
|
|
|
|
|
- return <tr className="work-order-mine-row" onClick={(event) => {
|
|
|
|
|
|
|
+ return <tr className="work-order-mine-row" data-selected={selected || undefined} onClick={(event) => {
|
|
|
if (event.target instanceof Element && event.target.closest("a, button")) return;
|
|
if (event.target instanceof Element && event.target.closest("a, button")) return;
|
|
|
- navigate(ticketPath, { state: linkState });
|
|
|
|
|
|
|
+ onSelect();
|
|
|
}}>
|
|
}}>
|
|
|
<td>
|
|
<td>
|
|
|
- <Link className="work-order-mine-ticket-link" to={ticketPath} state={linkState} title={summary.title}>{summary.title}</Link>
|
|
|
|
|
|
|
+ <button type="button" className="work-order-mine-ticket-button" onClick={onSelect} title={summary.title} aria-pressed={selected}>{summary.title}</button>
|
|
|
{summary.meta && <small className="work-order-mine-meta" title={summary.meta}>{summary.meta}</small>}
|
|
{summary.meta && <small className="work-order-mine-meta" title={summary.meta}>{summary.meta}</small>}
|
|
|
</td>
|
|
</td>
|
|
|
<td><div className="work-order-mine-badges">
|
|
<td><div className="work-order-mine-badges">
|
|
@@ -214,6 +215,11 @@ function MineQueueRow({ row, today, linkState, onUrged }: {
|
|
|
<UrgeControl row={row} onSent={onUrged} />
|
|
<UrgeControl row={row} onSent={onUrged} />
|
|
|
</div>
|
|
</div>
|
|
|
</td>
|
|
</td>
|
|
|
|
|
+ <td>
|
|
|
|
|
+ <Link className="ops-table-action" to={ticketPath} state={linkState} aria-label={`查看工单 ${row.ticket_no || row.ticket_id} 详情`}>
|
|
|
|
|
+ 详情<ArrowRight size={14} aria-hidden="true" />
|
|
|
|
|
+ </Link>
|
|
|
|
|
+ </td>
|
|
|
</tr>;
|
|
</tr>;
|
|
|
}
|
|
}
|
|
|
|
|
|