|
@@ -1,7 +1,7 @@
|
|
|
-import { useEffect, useRef, useState, type FormEvent, type ReactNode } from "react";
|
|
|
|
|
|
|
+import { Fragment, useEffect, useRef, useState, type FormEvent, type ReactNode } from "react";
|
|
|
import {
|
|
import {
|
|
|
- ArrowLeft, ArrowRight, Check, CircleAlert, ClipboardList, FolderOpen,
|
|
|
|
|
- Info, Link2, PackageCheck, Plus, RefreshCcw, ShieldAlert, TriangleAlert, UserCog, X,
|
|
|
|
|
|
|
+ ArrowLeft, ArrowRight, Check, ChevronDown, CircleAlert, FolderOpen,
|
|
|
|
|
+ Info, Link2, Plus, RefreshCcw, ShieldAlert, TriangleAlert, 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";
|
|
@@ -11,12 +11,14 @@ import { TicketStatusTag, TicketTypeTag } from "../components/work-order/TicketB
|
|
|
import {
|
|
import {
|
|
|
completionGenerate, completionReceipt, completionReject, isYes, messageConfirmConflict, ticketAssign, ticketBackfill,
|
|
completionGenerate, completionReceipt, completionReject, isYes, messageConfirmConflict, ticketAssign, ticketBackfill,
|
|
|
ticketCheckDone, ticketClose, ticketDefer, ticketDelegate, ticketMarkDone, ticketOpenPrepSave,
|
|
ticketCheckDone, ticketClose, ticketDefer, ticketDelegate, ticketMarkDone, ticketOpenPrepSave,
|
|
|
- ticketMaterialAttach, ticketMaterialGrant, ticketPendingQueue, ticketRevert, ticketWithdraw,
|
|
|
|
|
|
|
+ ticketMaterialAttach, ticketMaterialDownload, ticketMaterialGrant, ticketPendingQueue, ticketRevert, ticketWithdraw,
|
|
|
REJECT_REASONS, REJECT_REASON_MAX, rejectPrimaryReason,
|
|
REJECT_REASONS, REJECT_REASON_MAX, rejectPrimaryReason,
|
|
|
- statusLabel, type AssignCandidate, type TicketDetail,
|
|
|
|
|
|
|
+ type AssignCandidate, type TicketDetail, type TicketMaterial,
|
|
|
} from "../lib/api/ticket";
|
|
} from "../lib/api/ticket";
|
|
|
|
|
+import { uploadTicketMaterial } from "../lib/api/oss-upload";
|
|
|
import { classifyTicketError, fmtDate, fmtTime, numText, submitErrorText, useTicketDetail } from "../lib/ticket";
|
|
import { classifyTicketError, fmtDate, fmtTime, numText, submitErrorText, useTicketDetail } from "../lib/ticket";
|
|
|
import { missingGroupsOf } from "../lib/ticket-gaps";
|
|
import { missingGroupsOf } from "../lib/ticket-gaps";
|
|
|
|
|
+import { workOrderSteps } from "../lib/work-order-steps";
|
|
|
import { ACCT_STATUS, label, PLAN_KIND, ORDER_STATUS, USE_CATEGORY } from "../lib/api/labels";
|
|
import { ACCT_STATUS, label, PLAN_KIND, ORDER_STATUS, USE_CATEGORY } from "../lib/api/labels";
|
|
|
import {
|
|
import {
|
|
|
APP_CATEGORIES, BANDWIDTH_TIERS, IP_ROW_FIELDS, IP_TYPES, OVERSEAS_IP_MAX_ROWS,
|
|
APP_CATEGORIES, BANDWIDTH_TIERS, IP_ROW_FIELDS, IP_TYPES, OVERSEAS_IP_MAX_ROWS,
|
|
@@ -36,11 +38,32 @@ import "../styles/operations.css";
|
|
|
import "../styles/work-orders.css";
|
|
import "../styles/work-orders.css";
|
|
|
import "../styles/work-order-record.css";
|
|
import "../styles/work-order-record.css";
|
|
|
|
|
|
|
|
-/** 状态在 `ops-action-bar` 上的配色(沿用原型 tone 词表)。 */
|
|
|
|
|
-const BAR_TONE: Record<string, string> = {
|
|
|
|
|
- unassigned: "assigned", pending: "assigned", processing: "processing", completed: "settled", rejected: "processing", settled: "settled", terminated: "closed",
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * 「更多操作」菜单里每个动作的一行说明(原型 v3:菜单项=名称+一句用途)。
|
|
|
|
|
+ * 只用于菜单文案,⛔ 参与可用性判断——能不能点仍只看服务端 `actions`。
|
|
|
|
|
+ */
|
|
|
|
|
+const ACTION_HINTS: Record<string, string> = {
|
|
|
|
|
+ assign: "选择本单处理人", open_prep_save: "声明四项+五类应用数量", backfill: "结论、线路与境外 IP",
|
|
|
|
|
+ check_done: "清单核对与实际开通日", mark_done: "非主线单确认处理完毕",
|
|
|
|
|
+ delegate: "换同事代管", defer_open_stop: "顺延开停记录提醒", defer_ticket: "顺延本单期限",
|
|
|
|
|
+ withdraw: "撤回并关闭本单", close: "作废工单(需填原因)",
|
|
|
|
|
+ reject_completion: "登记运营商驳回", revert: "总运营受控回退",
|
|
|
|
|
+ generate_completion: "生成竣工并回传运营商", confirm_receipt: "运营商已回执,确认闭环",
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+/** 材料五类的中文名(与后端 `ticket_material.kind` 的 CHECK 集一一对应,⛔ 页面显示物理枚举)。 */
|
|
|
|
|
+const MATERIAL_KIND: Record<string, string> = {
|
|
|
|
|
+ submit_evidence: "客户提交材料",
|
|
|
|
|
+ handover: "开通准备资料",
|
|
|
|
|
+ backfill_evidence: "回填凭证",
|
|
|
|
|
+ completion_pdf: "竣工回传",
|
|
|
|
|
+ construct_material: "补充过程材料",
|
|
|
|
|
+};
|
|
|
|
|
+const materialKindName = (k: string | null) => (k ? MATERIAL_KIND[k] ?? k : "—");
|
|
|
|
|
+
|
|
|
|
|
+/** 唯一允许在详情页手工登记的材料类别(其余四类由各自业务动作在同一事务内登记)。 */
|
|
|
|
|
+const MANUAL_MATERIAL_KIND = "construct_material";
|
|
|
|
|
+
|
|
|
/** 闭环口径的五组缺口(组名以服务端 `domain::GROUP_*` 为准,旧短键保留作兜底)。 */
|
|
/** 闭环口径的五组缺口(组名以服务端 `domain::GROUP_*` 为准,旧短键保留作兜底)。 */
|
|
|
const GROUP_NAMES: Record<string, string> = {
|
|
const GROUP_NAMES: Record<string, string> = {
|
|
|
"标识与定位/线路与路由配置": "线路与路由", "IP 分配与接入凭据": "境外 IP/接入凭据",
|
|
"标识与定位/线路与路由配置": "线路与路由", "IP 分配与接入凭据": "境外 IP/接入凭据",
|
|
@@ -140,29 +163,149 @@ function rejectReasonNames(raw: string | null | undefined): string {
|
|
|
return codes.map((c) => REJECT_REASONS.find((r) => r.code === c)?.name ?? String(c)).join("、");
|
|
return codes.map((c) => REJECT_REASONS.find((r) => r.code === c)?.name ?? String(c)).join("、");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/** 主时间线(处理记录,`process_logs`)。 */
|
|
|
|
|
-function LogTimeline({ logs }: { logs: TicketDetail["process_logs"] }) {
|
|
|
|
|
- const ACTION_NAMES: Record<string, string> = {
|
|
|
|
|
- create: "建单", assign: "分派", dispatch_auto: "自动分派", delegate: "转交代管", start: "开始处理",
|
|
|
|
|
- backfill: "施工回填", check_done: "条目核对", mark_done: "标记完成",
|
|
|
|
|
- close: "关闭", withdraw: "客户撤回", confirm_close: "闭环确认", defer: "延期提醒", revert: "受控回退",
|
|
|
|
|
- generate_completion: "竣工回传", receipt: "回执确认", completion_reject: "竣工驳回",
|
|
|
|
|
- message_attach: "报文关联", message_void: "报文作废",
|
|
|
|
|
- message_rematch: "报文改挂", message_conflict: "冲突确认", material: "材料登记",
|
|
|
|
|
- };
|
|
|
|
|
- if (!logs.length) return <p className="work-order-detail-text">暂无处理记录。</p>;
|
|
|
|
|
- /**
|
|
|
|
|
- * 署名口径:⚠️ 主体号⛔ 单独顶格显示(客户侧看到的是一串 18 位平台用户 ID,
|
|
|
|
|
- * 既读不懂又是可枚举的稳定主键)。⇒ 姓名优先,作业行落「系统」,主体号只在
|
|
|
|
|
- * 运营侧出参里拿得到(客户侧服务端已置 `null`),拿不到就不拼进分隔符。
|
|
|
|
|
- */
|
|
|
|
|
- const signature = (log: TicketDetail["process_logs"][number]) => [
|
|
|
|
|
|
|
+/** 处理记录的 `action` → 中文动作名(未登记的 action 原样显示)。 */
|
|
|
|
|
+const LOG_ACTION_NAMES: Record<string, string> = {
|
|
|
|
|
+ create: "建单", assign: "分派", dispatch_auto: "自动分派", delegate: "转交代管", start: "开始处理",
|
|
|
|
|
+ backfill: "施工回填", check_done: "条目核对", mark_done: "标记完成",
|
|
|
|
|
+ close: "关闭", withdraw: "客户撤回", confirm_close: "闭环确认", defer: "延期提醒", revert: "受控回退",
|
|
|
|
|
+ generate_completion: "竣工回传", receipt: "回执确认", completion_reject: "竣工驳回",
|
|
|
|
|
+ message_attach: "报文关联", message_void: "报文作废",
|
|
|
|
|
+ message_rematch: "报文改挂", message_conflict: "冲突确认", material: "材料登记",
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 署名口径:⚠️ 主体号⛔ 单独顶格显示(客户侧看到的是一串 18 位平台用户 ID,
|
|
|
|
|
+ * 既读不懂又是可枚举的稳定主键)。⇒ 姓名优先,作业行落「系统」,主体号只在
|
|
|
|
|
+ * 运营侧出参里拿得到(客户侧服务端已置 `null`),拿不到就不拼进分隔符。
|
|
|
|
|
+ */
|
|
|
|
|
+function logSignature(log: TicketDetail["process_logs"][number]): string {
|
|
|
|
|
+ return [
|
|
|
fmtTime(log.at),
|
|
fmtTime(log.at),
|
|
|
log.actor_role,
|
|
log.actor_role,
|
|
|
log.actor_name ?? (log.actor_user_id === "0" ? "系统" : null),
|
|
log.actor_name ?? (log.actor_user_id === "0" ? "系统" : null),
|
|
|
log.actor_user_id && log.actor_user_id !== "0" ? log.actor_user_id : null,
|
|
log.actor_user_id && log.actor_user_id !== "0" ? log.actor_user_id : null,
|
|
|
].filter(Boolean).join(" · ");
|
|
].filter(Boolean).join(" · ");
|
|
|
- return <div className="ops-record-timeline">{logs.map((log) => <div key={log.log_id} data-tone={logTone(log.action)}><span><Check size={15} /></span><div><strong>{ACTION_NAMES[log.action ?? ""] ?? log.action}</strong><p>{log.note || "服务端未附说明"}</p><small>{signature(log)}</small></div></div>)}</div>;
|
|
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 右栏处理记录面板(原型 v3:最新在上、全部条目不截断;条数超出时面板内部滚动)。
|
|
|
|
|
+ *
|
|
|
|
|
+ * ⛔ 再给「展开更多」之类的截断:处理记录是运维盯单的专席,半年后回看的也是这几条,
|
|
|
|
|
+ * 面板高度随窗口自适应,滚动条由 CSS 处理(`.work-order-logs-scroll`)。
|
|
|
|
|
+ */
|
|
|
|
|
+function LogPanel({ logs }: { logs: TicketDetail["process_logs"] }) {
|
|
|
|
|
+ const railRef = useRef<HTMLOListElement>(null);
|
|
|
|
|
+ const flowRef = useRef<HTMLSpanElement>(null);
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 时间轴光带(原型 v3):光点沿轴自下而上走、收在最新一条,指明「新的往哪里进」。
|
|
|
|
|
+ * 轴长按首尾圆点**实测**:条数、字号、换行都会改轴长,⛔ 写死像素值。
|
|
|
|
|
+ */
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ const rail = railRef.current;
|
|
|
|
|
+ const flow = flowRef.current;
|
|
|
|
|
+ if (!rail || !flow) return;
|
|
|
|
|
+ const sync = () => {
|
|
|
|
|
+ const dots = rail.querySelectorAll<HTMLElement>(".work-order-tl-dot");
|
|
|
|
|
+ // 只有一条时没有「方向」可言,光带收起。
|
|
|
|
|
+ if (dots.length < 2) { flow.hidden = true; return; }
|
|
|
|
|
+ const base = rail.getBoundingClientRect().top;
|
|
|
|
|
+ const first = dots[0].getBoundingClientRect();
|
|
|
|
|
+ const last = dots[dots.length - 1].getBoundingClientRect();
|
|
|
|
|
+ const top = first.top + 15 - base;
|
|
|
|
|
+ const railH = Math.max(0, Math.round(last.top - 3 - base - top));
|
|
|
|
|
+ if (railH < 24) { flow.hidden = true; return; }
|
|
|
|
|
+ flow.hidden = false;
|
|
|
|
|
+ flow.style.top = `${Math.round(top)}px`;
|
|
|
|
|
+ flow.style.height = `${railH}px`;
|
|
|
|
|
+ // 扫过速度与轴长对齐,但夹在 2.2~4.2s:短轴不会慢得像静止。
|
|
|
|
|
+ rail.style.setProperty("--rail-h", `${railH}px`);
|
|
|
|
|
+ rail.style.setProperty("--comet-dur", `${Math.min(4.2, Math.max(2.2, railH / 150)).toFixed(2)}s`);
|
|
|
|
|
+ };
|
|
|
|
|
+ sync();
|
|
|
|
|
+ // 字体落位/面板内滚动条出现都会改几何,早一帧量会偏 ⇒ 再量一次并跟随容器尺寸。
|
|
|
|
|
+ const frame = requestAnimationFrame(sync);
|
|
|
|
|
+ const observer = new ResizeObserver(sync);
|
|
|
|
|
+ observer.observe(rail);
|
|
|
|
|
+ window.addEventListener("resize", sync);
|
|
|
|
|
+ return () => { cancelAnimationFrame(frame); observer.disconnect(); window.removeEventListener("resize", sync); };
|
|
|
|
|
+ }, [logs.length]);
|
|
|
|
|
+ if (!logs.length) return <p className="work-order-logs-empty">暂无处理记录。</p>;
|
|
|
|
|
+ // 服务端按发生顺序升序下发,面板要「最新在上」⇒ 仅在呈现处反转,⛔ 改数据。
|
|
|
|
|
+ return <ol className="work-order-tl" ref={railRef}>
|
|
|
|
|
+ <span className="work-order-tl-flow" aria-hidden="true" ref={flowRef}><i className="work-order-tl-comet" /></span>
|
|
|
|
|
+ {[...logs].reverse().map((log) => <li key={log.log_id} data-tone={logTone(log.action)}>
|
|
|
|
|
+ <span className="work-order-tl-dot" aria-hidden="true" />
|
|
|
|
|
+ <b>{LOG_ACTION_NAMES[log.action ?? ""] ?? log.action}</b>
|
|
|
|
|
+ <p>{log.note || "服务端未附说明"}</p>
|
|
|
|
|
+ <small>{logSignature(log)}</small>
|
|
|
|
|
+ </li>)}
|
|
|
|
|
+ </ol>;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 交付事实里的一段折叠(原型 v3 `details.seg`)。
|
|
|
|
|
+ *
|
|
|
|
|
+ * 摘要行给关键数字(结论/日期/条数),折叠也不丢信息;只有与本单当前状态相关的
|
|
|
|
|
+ * 那一段默认展开,其余收起来,避免六张明细表把正文拉成几屏长。
|
|
|
|
|
+ */
|
|
|
|
|
+function FactSeg({ title, summary, badge, tone, open, children }: {
|
|
|
|
|
+ title: string; summary: string; badge: string; tone?: "ok" | "warn"; open: boolean; children: ReactNode;
|
|
|
|
|
+}) {
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 展开态由本组件持有:`open` 只作为初值/本单状态变化后的落点。
|
|
|
|
|
+ * ⛔ 直接把 `open` 绑到 `details`:页面因提示条、刷新等重渲染时会把用户手动展开的段收回,
|
|
|
|
|
+ * 一次折叠就白点了。
|
|
|
|
|
+ */
|
|
|
|
|
+ const [expanded, setExpanded] = useState(open);
|
|
|
|
|
+ useEffect(() => { setExpanded(open); }, [open]);
|
|
|
|
|
+ return <details className="work-order-seg" open={expanded} onToggle={(e) => setExpanded(e.currentTarget.open)}>
|
|
|
|
|
+ <summary>
|
|
|
|
|
+ <span className="work-order-seg-title">{title}</span>
|
|
|
|
|
+ <span className="work-order-seg-summary">{summary}</span>
|
|
|
|
|
+ <span className={`work-order-seg-badge${tone ? ` ${tone}` : ""}`}>{badge}</span>
|
|
|
|
|
+ <ChevronDown className="work-order-seg-chev" size={16} />
|
|
|
|
|
+ </summary>
|
|
|
|
|
+ <div className="work-order-seg-body">{children}</div>
|
|
|
|
|
+ </details>;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 一组已登记材料的清单(原型 v3:材料跟着产生它的流程段走,⛔ 再单开一张「过程材料」卡)。
|
|
|
|
|
+ *
|
|
|
|
|
+ * 下载按 `material_id` 现签(`detail@v1` 刻意不下发对象键);`readonly` 只关下载按钮,
|
|
|
|
|
+ * 不影响清单本身——工单进终态后材料仍需可查。
|
|
|
|
|
+ */
|
|
|
|
|
+function MaterialList({ ticketId, items, empty, allowDownload = true }: {
|
|
|
|
|
+ ticketId: string; items: TicketMaterial[]; empty: string; allowDownload?: boolean;
|
|
|
|
|
+}) {
|
|
|
|
|
+ const [busy, setBusy] = useState<string | null>(null);
|
|
|
|
|
+ const [tip, setTip] = useState("");
|
|
|
|
|
+ if (!items.length) return <p className="work-order-seg-foot">{empty}</p>;
|
|
|
|
|
+ const download = async (m: TicketMaterial) => {
|
|
|
|
|
+ setTip(""); setBusy(m.material_id);
|
|
|
|
|
+ try {
|
|
|
|
|
+ const g = await ticketMaterialDownload({ ticket_id: ticketId, kind: m.kind ?? MANUAL_MATERIAL_KIND, material_id: m.material_id });
|
|
|
|
|
+ window.open(g.download_url, "_blank", "noopener");
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ setTip(submitErrorText(e, "下载地址获取失败"));
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ setBusy(null);
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+ return <>
|
|
|
|
|
+ <div className="work-order-table-wrap compact"><table>
|
|
|
|
|
+ <thead><tr><th>文件名</th><th>类型</th><th>大小</th><th>登记人</th><th>登记时间</th>{allowDownload && <th><span className="sr-only">操作</span></th>}</tr></thead>
|
|
|
|
|
+ <tbody>{items.map((m) => <tr key={m.material_id}>
|
|
|
|
|
+ <td>{m.file_name ?? m.material_id}</td>
|
|
|
|
|
+ <td>{materialKindName(m.kind)}</td>
|
|
|
|
|
+ <td>{numText(m.size_bytes, " B")}</td>
|
|
|
|
|
+ <td>{m.uploaded_by ?? "-"}</td>
|
|
|
|
|
+ <td>{fmtTime(m.uploaded_at)}</td>
|
|
|
|
|
+ {allowDownload && <td><Button variant="ghost" size="sm" type="button" disabled={busy === m.material_id} onClick={() => void download(m)}>下载</Button></td>}
|
|
|
|
|
+ </tr>)}</tbody>
|
|
|
|
|
+ </table></div>
|
|
|
|
|
+ {tip && <p className="work-order-form-error" role="alert">{tip}</p>}
|
|
|
|
|
+ </>;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -570,6 +713,8 @@ export function WorkOrderRecordPage() {
|
|
|
/** 抽屉内滚到哪一段(缺口「去处理」带的落点;正常打开抽屉时为 undefined)。 */
|
|
/** 抽屉内滚到哪一段(缺口「去处理」带的落点;正常打开抽屉时为 undefined)。 */
|
|
|
const [sheetFocus, setSheetFocus] = useState<GapFocus | undefined>(undefined);
|
|
const [sheetFocus, setSheetFocus] = useState<GapFocus | undefined>(undefined);
|
|
|
const [notice, setNotice] = useState("");
|
|
const [notice, setNotice] = useState("");
|
|
|
|
|
+ /** 材料登记改为抽屉(原型 v3):常驻表单会把过程材料卡撑到 300px,抽屉里填完即走。 */
|
|
|
|
|
+ const [materialOpen, setMaterialOpen] = useState(false);
|
|
|
/** 右栏参考卡的弹窗栈:客户档案 → 名下订阅 → …,栈顶即当前抽屉内容。 */
|
|
/** 右栏参考卡的弹窗栈:客户档案 → 名下订阅 → …,栈顶即当前抽屉内容。 */
|
|
|
const [refStack, setRefStack] = useState<RefTarget[]>([]);
|
|
const [refStack, setRefStack] = useState<RefTarget[]>([]);
|
|
|
const openRef = (target: RefTarget) => setRefStack((stack) => [...stack, target]);
|
|
const openRef = (target: RefTarget) => setRefStack((stack) => [...stack, target]);
|
|
@@ -625,15 +770,16 @@ export function WorkOrderRecordPage() {
|
|
|
const can = d.actions;
|
|
const can = d.actions;
|
|
|
// 正文分区序号:开通准备资料只在开户单出现,缺段时后续序号自动前移,避免出现 01 → 03 的空号。
|
|
// 正文分区序号:开通准备资料只在开户单出现,缺段时后续序号自动前移,避免出现 01 → 03 的空号。
|
|
|
const prep = d.open_prep;
|
|
const prep = d.open_prep;
|
|
|
- const prepNo = prep ? "02" : null;
|
|
|
|
|
- const backfillNo = d.backfill ? (prep ? "03" : "02") : null;
|
|
|
|
|
- const steps = [
|
|
|
|
|
- { label: "建单受理", state: "done" as const },
|
|
|
|
|
- { label: t.ticket_type === "fault" ? "受理指派" : "运维分派", state: t.status === "unassigned" ? "current" as const : "done" as const },
|
|
|
|
|
- { label: "受理处理", state: ["unassigned", "pending"].includes(t.status) ? "todo" as const : t.status === "processing" ? "current" as const : "done" as const },
|
|
|
|
|
- { label: t.status === "terminated" ? "作废关闭" : "回填确认", state: t.status === "terminated" ? "current" as const : ["completed", "settled"].includes(t.status) ? "done" as const : ["unassigned", "pending", "processing"].includes(t.status) ? "todo" as const : "done" as const },
|
|
|
|
|
- { label: "闭环归档", state: t.status === "settled" ? "done" as const : t.status === "terminated" ? "skipped" as const : "todo" as const },
|
|
|
|
|
- ];
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 流转阶段条:阶段派生收在 `lib/work-order-steps.ts`(纯函数,有测试兜)。
|
|
|
|
|
+ * 这里只负责把状态与类型喂进去,⛔ 在 JSX 里再手写一遍「哪段正在发生」。
|
|
|
|
|
+ */
|
|
|
|
|
+ const steps = workOrderSteps({ status: t.status, ticketType: t.ticket_type });
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 连线「已走过」到哪一格=最后一个不是 `todo` 的阶段(当前段/已完成段/作废收口都算走过)。
|
|
|
|
|
+ * ⚠️ 只按 current 判会让闭环单出现「六段全绿、连线全灰」的自相矛盾。
|
|
|
|
|
+ */
|
|
|
|
|
+ const reachedStepIndex = steps.reduce((reached, step, index) => (step.state !== "todo" ? index : reached), -1);
|
|
|
|
|
|
|
|
const primaryActions: [string, string, string][] = [];
|
|
const primaryActions: [string, string, string][] = [];
|
|
|
if (can.assign) primaryActions.push(["assign", "分派工单", "assign"]);
|
|
if (can.assign) primaryActions.push(["assign", "分派工单", "assign"]);
|
|
@@ -704,10 +850,17 @@ export function WorkOrderRecordPage() {
|
|
|
*/
|
|
*/
|
|
|
const execLocked = !!t.execution_locked;
|
|
const execLocked = !!t.execution_locked;
|
|
|
const execNotBefore = t.execution_not_before ? t.execution_not_before.slice(0, 10) : null;
|
|
const execNotBefore = t.execution_not_before ? t.execution_not_before.slice(0, 10) : null;
|
|
|
- const nextHint = execLocked && !can.assign && !can.open_prep_save
|
|
|
|
|
|
|
+ /** 计划执行日只在「还没执行」的三种状态下当期限展示;已完成/驳回/闭环后再挂它只会误读。 */
|
|
|
|
|
+ const showExecDate = !!execNotBefore && ["unassigned", "pending", "processing"].includes(t.status);
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 首屏提示的顺序:驳回态先说驳回出口(这是本单唯一的出路),再退到执行锁与常规推进;
|
|
|
|
|
+ * ⛔ 让「未到计划执行日」盖住驳回原因——驳回单的执行日早已过去了。
|
|
|
|
|
+ */
|
|
|
|
|
+ const nextHint = t.status === "rejected"
|
|
|
|
|
+ ? (can.backfill ? "竣工被驳回:改回填后同号覆盖重推。" : can.generate_completion ? "竣工被驳回:按当前回填同号覆盖重推(改回填需先受控回退)。" : "竣工被驳回:等待总运营受控回退后再处理。")
|
|
|
|
|
+ : execLocked && !can.assign && !can.open_prep_save
|
|
|
? `未到计划执行日(服务开始日 ${execNotBefore ? fmtDate(execNotBefore) : "待定"}):当天才可施工回填/核对竣工,此前可先分派与准备。` :
|
|
? `未到计划执行日(服务开始日 ${execNotBefore ? fmtDate(execNotBefore) : "待定"}):当天才可施工回填/核对竣工,此前可先分派与准备。` :
|
|
|
!nextStep ? "" :
|
|
!nextStep ? "" :
|
|
|
- t.status === "rejected" ? (can.backfill ? "竣工被驳回:改回填后同号覆盖重推。" : can.generate_completion ? "竣工被驳回:按当前回填同号覆盖重推(改回填需先受控回退)。" : "竣工被驳回:等待总运营受控回退后再处理。") :
|
|
|
|
|
can.assign ? "尚未指定责任人,分派后才能开始处理。" :
|
|
can.assign ? "尚未指定责任人,分派后才能开始处理。" :
|
|
|
can.open_prep_save ? "开通准备资料是开户单回填的前置。" :
|
|
can.open_prep_save ? "开通准备资料是开户单回填的前置。" :
|
|
|
can.backfill ? "登记执行结论、线路与凭证,保存即推进。" :
|
|
can.backfill ? "登记执行结论、线路与凭证,保存即推进。" :
|
|
@@ -722,159 +875,310 @@ export function WorkOrderRecordPage() {
|
|
|
};
|
|
};
|
|
|
/** 最近一次驳回(流水按 `reject_seq` 升序,取末尾=最新)。 */
|
|
/** 最近一次驳回(流水按 `reject_seq` 升序,取末尾=最新)。 */
|
|
|
const lastReject = t.status === "rejected" && d.completion_rejects?.length ? d.completion_rejects[d.completion_rejects.length - 1] : null;
|
|
const lastReject = t.status === "rejected" && d.completion_rejects?.length ? d.completion_rejects[d.completion_rejects.length - 1] : null;
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 期限的剩余口径(页首 meta 行)。⛔ 自行编造 SLA 天数:只有拿到日期才算,
|
|
|
|
|
+ * 计划执行日(服务开始日)另给「还剩几天可执行」的说法,避免被读成竣工期限。
|
|
|
|
|
+ */
|
|
|
|
|
+ const dueNote = (() => {
|
|
|
|
|
+ const due = (showExecDate ? execNotBefore : null) ?? (t.expected_done_date ? t.expected_done_date.slice(0, 10) : null);
|
|
|
|
|
+ if (!due) return "";
|
|
|
|
|
+ const days = Math.ceil((new Date(`${due}T00:00:00`).getTime() - new Date(`${new Date().toISOString().slice(0, 10)}T00:00:00`).getTime()) / 86_400_000);
|
|
|
|
|
+ if (t.overdue) return days < 0 ? `已超期 ${-days} 天` : "已超期";
|
|
|
|
|
+ if (days > 0) return showExecDate ? `还剩 ${days} 天可执行` : `剩 ${days} 天`;
|
|
|
|
|
+ return showExecDate ? "今日可执行" : "今日到期";
|
|
|
|
|
+ })();
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 首屏「待办区」:只在本单需要动作时出现(原型 v3 的 `.todo`)。
|
|
|
|
|
+ * 驳回横幅全页只保留这一处——⛔ 再在右栏或竣工段重复一遍同样的原因。
|
|
|
|
|
+ */
|
|
|
|
|
+ const todoNodes: ReactNode[] = [];
|
|
|
|
|
+ if (lastReject) todoNodes.push(<div className="work-order-banner danger" role="alert" key="reject">
|
|
|
|
|
+ <div><strong><TriangleAlert size={17} />竣工第 {lastReject.reject_seq} 次被驳回</strong><p>{rejectReasonNames(lastReject.reason_codes)}{lastReject.reason_text ? `:${lastReject.reason_text}` : ""}</p><small>{fmtTime(lastReject.rejected_at)} · {lastReject.channel === "human" ? "人工登记" : lastReject.channel}</small></div>
|
|
|
|
|
+ {can.backfill
|
|
|
|
|
+ ? <Button onClick={() => openSheet("backfill", "conclusion")}><RefreshCcw size={16} />改回填后同号重推</Button>
|
|
|
|
|
+ : can.generate_completion
|
|
|
|
|
+ ? <Button onClick={() => void quick("generate_completion")}><RefreshCcw size={16} />同号覆盖重推</Button>
|
|
|
|
|
+ : null}
|
|
|
|
|
+ </div>);
|
|
|
|
|
+ if (d.gaps.length > 0) todoNodes.push(<div className="work-order-gaps" key="gaps">
|
|
|
|
|
+ <div className="work-order-gaps-head"><strong>闭环还缺 {d.gaps.length} 项</strong><span>缺口由服务端判定,不可人工放行竣工</span></div>
|
|
|
|
|
+ <ul>{d.gaps.map((g) => {
|
|
|
|
|
+ const target = gapTarget(g, can);
|
|
|
|
|
+ return <li key={g}><div><b>{groupLabel(g)}</b><p>{gapHint(g)}</p></div>{target && !viewerReadOnly && <Button variant="outline" size="sm" onClick={() => openSheet(target.action, target.focus)}>{target.label}<ArrowRight size={14} /></Button>}</li>;
|
|
|
|
|
+ })}</ul>
|
|
|
|
|
+ <p className="work-order-detail-footnote"><Info size={15} />缺口清单由服务端判定,不得在此人工放行竣工;{can.generate_completion ? "可生成竣工" : "生成竣工入口保持关闭"}。</p>
|
|
|
|
|
+ </div>);
|
|
|
|
|
+ if (t.status === "terminated" && t.close_reason) todoNodes.push(<div className="work-order-void" key="void"><X size={18} /><div><strong>作废原因</strong><p>{t.close_reason}</p></div></div>);
|
|
|
|
|
+ if (viewerReadOnly && !hasActions) todoNodes.push(<div className="work-order-view-only" key="readonly"><ShieldAlert size={18} /><div><strong>只读视图</strong><p>你可以查看工单信息与处理记录,处理动作由运维团队执行。</p></div></div>);
|
|
|
|
|
+ {/* 门户进度(第 5 册 §14.1.9):驳回态对客户**只说**"待补充资料后重新提交",
|
|
|
|
|
+ ⛔ 出现「竣工驳回」字样与内部归因——门户口径是"对方还在处理",不是"你做错了"。 */}
|
|
|
|
|
+ if (clientView && !hasActions && t.status !== "settled" && t.status !== "terminated") todoNodes.push(
|
|
|
|
|
+ <div className="work-order-client-progress" key="client-progress">{t.status === "rejected" ? "待补充资料后重新提交" : t.status === "completed" ? "竣工回传已提交,等待回执" : "等待运维处理"}</div>);
|
|
|
|
|
+ if (!todoNodes.length && t.status === "settled") todoNodes.push(
|
|
|
|
|
+ <div className="work-order-done-strip" key="settled">本单已闭环 · 全程 {d.process_logs.length} 条留痕、{d.materials.length} 份材料 · 只读可追溯</div>);
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 「交付事实」默认展开的那一段=与本单当前状态最相关的一段(原型 v3:其余收起)。
|
|
|
|
|
+ * 展开哪段只用已判定过的 `can.*`/驳回态,⛔ 前端再推一遍状态机。
|
|
|
|
|
+ */
|
|
|
|
|
+ const openSeg: string = lastReject || can.generate_completion || can.confirm_receipt ? "completion"
|
|
|
|
|
+ : can.open_prep_save ? "prep"
|
|
|
|
|
+ : can.backfill ? "backfill"
|
|
|
|
|
+ : can.check_done ? "checklist" : "";
|
|
|
|
|
+ const prepAppCount = prep?.apps.reduce((sum, a) => sum + (Number(a.qty) > 0 ? Number(a.qty) : 0), 0) ?? 0;
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 材料按 `kind` 归位(2026-11-17 原型 v3):五类材料各有唯一产出方,页面上就各自回到那一段。
|
|
|
|
|
+ * ⛔ 再单开一张「过程材料」平表——那样用户看不出某一份材料属于哪一步。
|
|
|
|
|
+ */
|
|
|
|
|
+ const byKind = (kind: string) => d.materials.filter((m) => m.kind === kind);
|
|
|
|
|
+ const submitMaterials = byKind("submit_evidence");
|
|
|
|
|
+ const prepMaterials = byKind("handover");
|
|
|
|
|
+ /** 回填段:回填时自动归档的凭证 + 现场补传的过程材料(后者是这一段唯一的写入口)。 */
|
|
|
|
|
+ const backfillMaterials = [...byKind("backfill_evidence"), ...byKind(MANUAL_MATERIAL_KIND)];
|
|
|
|
|
+ const completionMaterials = byKind("completion_pdf");
|
|
|
|
|
+ /** 非主线单(故障/售后)没有回填段 ⇒ 过程材料单独成段,否则这些单上看不到任何材料。 */
|
|
|
|
|
+ const hasBackfillSeg = !!(d.backfill || can.backfill);
|
|
|
|
|
+ /** 客户视角不放置下载入口:后端 `material_grant` 对客户身份只放行 `submit_evidence`。 */
|
|
|
|
|
+ const canDownloadMaterial = !clientView;
|
|
|
|
|
+ /** 「交付事实」里实际渲染了几段(段有数据或本单还能补时才计数,空段不占位)。 */
|
|
|
|
|
+ const factsCount = [!!prep, hasBackfillSeg, d.service_items.length > 0, (d.open_stop?.accounts.length ?? 0) > 0, showCompletion, d.messages.length > 0, !hasBackfillSeg && backfillMaterials.length > 0].filter(Boolean).length;
|
|
|
|
|
+ const checkedItems = d.service_items.filter((i) => i.check_result === "done").length;
|
|
|
|
|
+ const receiptState = d.completion
|
|
|
|
|
+ ? d.completion.receipt_at && d.completion.receipt_valid !== "0" ? { text: "回执已确认", tone: "ok" as const }
|
|
|
|
|
+ : d.completion.receipt_at ? { text: "回执已失效", tone: "warn" as const }
|
|
|
|
|
+ : { text: "已回传待回执", tone: "warn" as const }
|
|
|
|
|
+ : { text: "未生成", tone: "warn" as const };
|
|
|
|
|
+ const copyLink = async () => {
|
|
|
|
|
+ try { await navigator.clipboard.writeText(window.location.href); setNotice("本单链接已复制。"); }
|
|
|
|
|
+ catch { setNotice("复制失败:浏览器拒绝了剪贴板访问。"); }
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
return <section className={`ops-record-page${clientView ? " customer-record-view" : ""}`}>
|
|
return <section className={`ops-record-page${clientView ? " customer-record-view" : ""}`}>
|
|
|
- <header className="ops-record-hero work-order-record-hero"><div><Button className="ops-record-back" variant="ghost" size="sm" onClick={goBack}><ArrowLeft size={16} />返回工单列表</Button><div className="ops-record-title-line"><h1>{t.ticket_no}</h1><TypeTag type={t.ticket_type} /></div><p>{t.title}</p><small>{[fmtTime(t.created_at), `建单人:${t.creator_name ?? t.creator_user_id ?? "-"}`].filter(Boolean).join(" · ")}</small></div><div className="ops-record-status work-order-hero-status"><StatusTag status={t.status} /><span>{execNotBefore ? `计划执行(服务开始日) ${fmtDate(execNotBefore)}` : t.expected_done_date ? `预期完成 ${fmtDate(t.expected_done_date)}` : "按 SLA 计算完成时间"}{t.overdue ? " · 已超期" : ""}</span>{nextStep && !viewerReadOnly && <Button className="work-order-hero-cta" onClick={runNextStep}><ArrowRight size={16} />{nextStep.label}</Button>}{nextHint && !viewerReadOnly && <small className="work-order-hero-hint">{nextHint}</small>}</div></header>
|
|
|
|
|
|
|
+ <Button className="ops-record-back" variant="ghost" size="sm" onClick={goBack}><ArrowLeft size={16} />返回工单列表</Button>
|
|
|
{notice && <div className="work-order-notice" role="status"><Check size={17} />{notice}<button type="button" aria-label="关闭提示" onClick={() => setNotice("")}><X size={15} /></button></div>}
|
|
{notice && <div className="work-order-notice" role="status"><Check size={17} />{notice}<button type="button" aria-label="关闭提示" onClick={() => setNotice("")}><X size={15} /></button></div>}
|
|
|
- <div className="ops-record-stats work-order-record-stats"><div><span>工单状态</span><strong>{statusLabel(t.status)}</strong></div><div><span>承接团队</span><strong>{t.assign_team_name ?? "未分派"}</strong></div><div><span>责任人</span><strong>{t.assignee_name ?? t.assignee_snapshot_name ?? "待分派"}</strong></div><div><span>创建时间</span><strong>{fmtTime(t.created_at)}</strong></div><div><span>{t.status === "terminated" ? "作废时间" : "闭环时间"}</span><strong>{fmtTime(t.status === "terminated" ? t.closed_at : t.settled_at ?? t.completed_at)}</strong></div></div>
|
|
|
|
|
- {/* 驳回态:首屏就要看到原因与出口(⛔ 让运维翻到右栏才发现被驳回)。 */}
|
|
|
|
|
- {lastReject && <div className="work-order-reject-banner" role="alert">
|
|
|
|
|
- <div><TriangleAlert size={19} /><div><strong>竣工第 {lastReject.reject_seq} 次被驳回</strong><p>{rejectReasonNames(lastReject.reason_codes)}{lastReject.reason_text ? `:${lastReject.reason_text}` : ""}</p><small>{fmtTime(lastReject.rejected_at)} · {lastReject.channel === "human" ? "人工登记" : lastReject.channel}</small></div></div>
|
|
|
|
|
- {can.backfill
|
|
|
|
|
- ? <Button onClick={() => openSheet("backfill", "conclusion")}><RefreshCcw size={16} />改回填后同号重推</Button>
|
|
|
|
|
- : can.generate_completion
|
|
|
|
|
- ? <Button onClick={() => void quick("generate_completion")}><RefreshCcw size={16} />同号覆盖重推</Button>
|
|
|
|
|
- : null}
|
|
|
|
|
- </div>}
|
|
|
|
|
- <div className="work-order-flow" aria-label="工单流转进度">{steps.map((step, index) => <div className="work-order-flow-step" key={step.label}><b className={step.state}>{index + 1}</b><span>{step.label}</span>{index < steps.length - 1 && <i className={steps[index + 1].state === "done" || steps[index + 1].state === "skipped" ? "passed" : ""} />}</div>)}</div>
|
|
|
|
|
|
|
+ {/* 页首一卡收口:工单号+类型+状态、唯一主 CTA、元信息与细进度条。
|
|
|
|
|
+ 原「指标条」5 格并进这一行,状态只出现一次;其余动作收进「更多操作」。 */}
|
|
|
|
|
+ <header className="work-order-head">
|
|
|
|
|
+ <div className="work-order-head-top">
|
|
|
|
|
+ <div className="work-order-head-id">
|
|
|
|
|
+ <span className="work-order-head-no">{t.ticket_no}</span>
|
|
|
|
|
+ <TypeTag type={t.ticket_type} />
|
|
|
|
|
+ <StatusTag status={t.status} />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div className="work-order-head-actions">
|
|
|
|
|
+ {nextStep && !viewerReadOnly && <Button onClick={runNextStep}>{nextStep.label}<ArrowRight size={16} /></Button>}
|
|
|
|
|
+ {!clientView && <details className="work-order-more">
|
|
|
|
|
+ <summary className="work-order-more-trigger">更多操作<ChevronDown size={14} /></summary>
|
|
|
|
|
+ <div className="work-order-more-menu">
|
|
|
|
|
+ {primaryActions.filter(([action]) => action !== nextStep?.action).map(([action, label]) => <button key={action} type="button" onClick={() => openSheet(action)}><span>{label}</span><small>{ACTION_HINTS[action] ?? "打开处理表单"}</small></button>)}
|
|
|
|
|
+ {opsActions.map(([action, label]) => <button key={action} type="button" onClick={() => openSheet(action)}><span>{label}</span><small>{ACTION_HINTS[action] ?? "执行本动作"}</small></button>)}
|
|
|
|
|
+ {(primaryActions.length > 0 || opsActions.length > 0) && <hr />}
|
|
|
|
|
+ <button type="button" onClick={() => void copyLink()}><span>复制链接</span><small>复制本单地址</small></button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </details>}
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <h1 className="work-order-head-title">{t.title}</h1>
|
|
|
|
|
+ <div className="work-order-head-meta">
|
|
|
|
|
+ <span>客户 <b>{refCustomer?.customer_name ?? "—"}</b></span><i>·</i>
|
|
|
|
|
+ <span>责任人 <b>{t.assignee_name ?? t.assignee_snapshot_name ?? "待分派"}</b></span><i>·</i>
|
|
|
|
|
+ <span>承接团队 <b>{t.assign_team_name ?? "未分派"}</b></span><i>·</i>
|
|
|
|
|
+ <span>建单人 <b>{t.creator_name ?? t.creator_user_id ?? "—"}</b></span><i>·</i>
|
|
|
|
|
+ <span>创建 <b className="mono">{fmtTime(t.created_at)}</b></span><i>·</i>
|
|
|
|
|
+ <span className={`work-order-head-due${t.overdue ? " overdue" : ""}`}>{showExecDate && execNotBefore ? `计划执行(服务开始日)` : "期限"} <b className="mono">{showExecDate && execNotBefore ? fmtDate(execNotBefore) : t.expected_done_date ? fmtDate(t.expected_done_date) : "按 SLA 计算"}</b>{dueNote ? `(${dueNote})` : ""}</span>
|
|
|
|
|
+ {t.status === "settled" && t.settled_at && <><i>·</i><span>闭环 <b className="mono">{fmtTime(t.settled_at)}</b></span></>}
|
|
|
|
|
+ {t.status === "terminated" && <><i>·</i><span>作废 <b className="mono">{fmtTime(t.closed_at)}</b></span></>}
|
|
|
|
|
+ </div>
|
|
|
|
|
+ {nextHint && !viewerReadOnly && <div className="work-order-head-hint">{nextHint}</div>}
|
|
|
|
|
+ <div className="work-order-steps" aria-label="工单流转进度">{steps.map((step, index) => <Fragment key={step.label}>{index > 0 && <i aria-hidden="true" className={index <= reachedStepIndex ? "on" : undefined} />}<span className={`work-order-step ${step.state === "current" ? "cur" : step.state}`} aria-current={step.state === "current" ? "step" : undefined}><b>{index + 1}</b>{step.label}</span></Fragment>)}</div>
|
|
|
|
|
+ </header>
|
|
|
|
|
+ {todoNodes.length > 0 && <div className="work-order-todo">{todoNodes}</div>}
|
|
|
<div className="work-order-layout"><div className="work-order-sections">
|
|
<div className="work-order-layout"><div className="work-order-sections">
|
|
|
- {/* 工单内容是详情页的主角:客户、合同、订阅只作参考,统一收到右栏「客户与订阅」。 */}
|
|
|
|
|
- <section className="work-order-section work-order-section-lead"><div className="work-order-section-head"><div><p>01 / 工单内容</p><h2>事项内容、来源与完成条件</h2></div><span>{d.messages.length ? `关联报文 ${d.messages.length} 条` : "无关联报文"}</span></div>
|
|
|
|
|
|
|
+ {/* 工单内容=正文主角:一句话内容 + 来源/外部单号/关联订阅;客户档案收到页尾参考区。 */}
|
|
|
|
|
+ <section className="work-order-section work-order-section-lead">
|
|
|
<p className="work-order-ticket-lead">{t.detail || "建单时未填写详细描述。"}</p>
|
|
<p className="work-order-ticket-lead">{t.detail || "建单时未填写详细描述。"}</p>
|
|
|
- <div className="work-order-summary-grid"><div><span>建单来源</span><strong>{t.submitter_type === "customer" ? "客户侧提交" : t.submitter_type === "reporter" ? "报障人提交" : "运营侧代报"}</strong></div><div><span>外部单号</span><strong>{t.unicom_order_no ?? "无"}</strong></div><div><span>{execNotBefore ? "计划执行(服务开始日)" : "预期完成"}</span><strong>{execNotBefore ? fmtDate(execNotBefore) : t.expected_done_date ? fmtDate(t.expected_done_date) : "按 SLA 计算"}{t.overdue && <em className="work-order-overdue-text"> · 已超期</em>}</strong></div>{t.deferred_until && <div><span>延期至</span><strong>{fmtDate(t.deferred_until)}</strong></div>}{t.confirm_deadline && <div><span>闭环确认期限</span><strong>{fmtDate(t.confirm_deadline)}</strong></div>}{t.close_reason && <div className="wide"><span>关闭原因</span><strong>{t.close_reason}</strong></div>}</div>
|
|
|
|
|
|
|
+ <div className="work-order-summary-grid"><div><span>建单来源</span><strong>{t.submitter_type === "customer" ? "客户侧提交" : t.submitter_type === "reporter" ? "报障人提交" : "运营侧代报"}</strong></div><div><span>外部单号</span><strong>{t.unicom_order_no ?? "无"}</strong></div><div><span>关联订阅</span><strong>{t.subscription_id ? <button type="button" className="work-order-trace-link" onClick={() => openRef({ kind: "order", id: t.subscription_id!, name: refOrder?.plan_name })}>{t.subscription_id}</button> : "无"}{refOrder?.plan_name ? ` · ${refOrder.plan_name}` : ""}</strong></div>{t.deferred_until && <div><span>延期至</span><strong>{fmtDate(t.deferred_until)}</strong></div>}{t.confirm_deadline && <div><span>闭环确认期限</span><strong>{fmtDate(t.confirm_deadline)}</strong></div>}</div>
|
|
|
|
|
+ {/* 客户建单时上传的图片/语音随建单同事务登记(`submit_evidence`),就放在建单来源这一屏。 */}
|
|
|
|
|
+ {submitMaterials.length > 0 && <>
|
|
|
|
|
+ <h4 className="work-order-subhead">客户提交材料</h4>
|
|
|
|
|
+ <MaterialList ticketId={t.ticket_id} items={submitMaterials} empty="无" allowDownload={canDownloadMaterial} />
|
|
|
|
|
+ </>}
|
|
|
</section>
|
|
</section>
|
|
|
- {prep && <section className="work-order-section"><div className="work-order-section-head"><div><p>{prepNo} / 开通准备资料</p><h2>出境合规声明与开通应用</h2></div><span>{prep.submitted ? "已提交" : "草稿"}</span></div>
|
|
|
|
|
- <div className="work-order-summary-grid"><div><span>声明人</span><strong>{prep.declarant_name ?? "-"}</strong></div><div><span>声明单位</span><strong>{prep.declarant_org ?? "-"}</strong></div><div><span>联系方式</span><strong>{prep.declarant_contact ?? "-"}</strong></div><div><span>提交时间</span><strong>{fmtTime(prep.submitted_at)}</strong></div><div className="wide"><span>声明内容</span><strong>{prep.declaration_text ?? "-"}</strong></div></div>
|
|
|
|
|
- {prep.apps.length > 0 && <><h3 className="work-order-table-title">开通应用及数量</h3><div className="work-order-table-wrap compact"><table><thead><tr><th>应用类别</th><th>开通账号数</th></tr></thead><tbody>{prep.apps.map((a) => <tr key={a.app_id}><td>{APP_CATEGORIES.find((c) => c.code === a.app_category)?.label ?? a.app_category ?? "-"}</td><td>{numText(a.qty)}</td></tr>)}</tbody></table></div></>}
|
|
|
|
|
- <p className="work-order-detail-footnote"><Info size={15} />境外 IP 不在本区块登记:实际分配的境外 IP 见「施工回填」的境外出口 IP 明细。</p>
|
|
|
|
|
- {can.open_prep_save && <p className="work-order-detail-footnote"><Info size={15} />重复保存=整体覆盖(冲突时回 KLT-G20417,请重新读取)。</p>}
|
|
|
|
|
- </section>}
|
|
|
|
|
- {d.backfill && <section className="work-order-section"><div className="work-order-section-head"><div><p>{backfillNo} / 施工回填</p><h2>网络配置、境外出口与凭证</h2></div><span>{CONCLUSION_NAMES[d.backfill.exec_conclusion ?? ""] ?? d.backfill.exec_conclusion ?? "-"} · 规则 v{d.backfill.ip_rule_version}</span></div>
|
|
|
|
|
- <div className="work-order-summary-grid"><div><span>实际开通日期</span><strong>{d.backfill.actual_opened_date ? fmtDate(d.backfill.actual_opened_date) : "-"}</strong></div><div><span>停机完成日期</span><strong>{d.backfill.stop_done_date ? fmtDate(d.backfill.stop_done_date) : "-"}</strong></div><div><span>回填次数</span><strong>{numText(d.backfill.attempt_count)} 次</strong></div><div><span>线路 / 出口 IP</span><strong>{d.backfill.routes.length} 条 / {d.backfill.ips.length} 条</strong></div><div className="wide"><span>结论说明</span><strong>{d.backfill.conclusion_note ?? "-"}</strong></div><div className="wide"><span>凭证与佐证</span><strong>{d.backfill.evidence_text ?? "-"}</strong></div></div>
|
|
|
|
|
- {d.backfill.routes.length > 0 && <><h3 className="work-order-table-title">网络线路回填</h3><div className="work-order-table-wrap compact"><table><thead><tr><th>网络账户名</th><th>内网 IP</th><th>源端点</th><th>目的端点</th><th>出口 PoP</th><th>带宽</th></tr></thead><tbody>{d.backfill.routes.map((r) => <tr key={r.id}><td>{r.network_account_name ?? "-"}</td><td>{[r.intranet_ip, r.subnet_mask].filter(Boolean).join(" / ") || "-"}</td><td>{r.src_endpoint ?? "-"}</td><td>{r.dst_endpoint ?? "-"}</td><td>{r.egress_pop ?? "-"}</td><td>{[r.down_mbps && `↓${r.down_mbps}`, r.up_mbps && `↑${r.up_mbps}`].filter(Boolean).join(" / ") || "-"}</td></tr>)}</tbody></table></div></>}
|
|
|
|
|
- {d.backfill.ips.length > 0 && <><h3 className="work-order-table-title">境外出口 IP</h3><div className="work-order-table-wrap compact"><table><thead><tr><th>行号</th><th>出口</th><th>IP</th><th>类型</th><th>带宽</th><th>PIN/CPID</th></tr></thead><tbody>{d.backfill.ips.map((r) => <tr key={r.id}><td>{r.row_no}</td><td>{r.egress ?? "-"}</td><td>{r.overseas_ip ?? "-"}</td><td>{r.ip_type ?? "-"}</td><td>{numText(r.bandwidth_mbps, "M")}</td><td>{isYes(r.pin_registered) ? "PIN 已登记" : "—"} / {isYes(r.cpid_registered) ? "CPID 已登记" : "—"}</td></tr>)}</tbody></table></div><p className="work-order-detail-footnote"><Info size={15} />库内仅存 PIN/CPID 密文,此处只显示「是否登记」。</p></>}
|
|
|
|
|
- </section>}
|
|
|
|
|
- {d.service_items.length > 0 && <section className="work-order-section"><div className="work-order-section-head"><div><p>服务清单</p><h2>条目核对</h2></div><span>{d.service_items.filter((i) => i.check_result === "done").length} / {d.service_items.length} 已核对{checklistGated ? "" : " · 不阻断本单闭环"}</span></div>
|
|
|
|
|
- {/* 升降配单的清单带「原值/新值」两列(2026-11-17 补列);其余类型仍是一列规格。 */}
|
|
|
|
|
- <div className="work-order-table-wrap compact"><table><thead><tr><th>序号</th><th>条目</th>{t.ticket_type === "updown" ? <><th>原值</th><th>新值</th></> : <th>规格</th>}<th>数量</th><th>核对结果</th><th>核对时间</th></tr></thead><tbody>{d.service_items.map((item) => <tr key={item.item_id}><td>{item.seq_no}</td><td><strong>{item.item_name ?? "-"}</strong>{t.ticket_type !== "updown" && item.spec_text && <small>{item.spec_text}</small>}</td>{t.ticket_type === "updown" ? <><td>{item.spec_before ?? "-"}</td><td>{item.spec_after ?? "-"}</td></> : <td>{item.spec_text ?? "-"}</td>}<td>{numText(item.expect_qty)}</td><td>{item.check_result === "done" ? <span className="ops-state tone-valid">已核对</span> : item.check_result === "absent" ? <span className="ops-state tone-invalid">缺项</span> : <span className="ops-state tone-invalid">未核对</span>}</td><td>{fmtTime(item.checked_at)}</td></tr>)}</tbody></table></div>
|
|
|
|
|
- {t.ticket_type === "updown" && <><h3 className="work-order-table-title">参数对照(原档 → 新档)</h3><div className="work-order-table-wrap compact"><table><thead><tr><th>条目</th><th>原值</th><th>新值</th></tr></thead><tbody>{d.service_items.map((item) => <tr key={`cmp-${item.item_id}`}><td><strong>{item.item_name ?? "-"}</strong></td><td>{item.spec_before ?? "-"}</td><td>{item.spec_after ?? "-"}</td></tr>)}</tbody></table></div></>}
|
|
|
|
|
- <p className="work-order-detail-footnote"><Info size={15} />{checklistNote}</p></section>}
|
|
|
|
|
- {(d.open_stop || d.backfill) && <section className="work-order-section"><div className="work-order-section-head"><div><p>账号清单</p><h2>本单交付的加速账号</h2></div><span>{d.open_stop?.accounts.length ?? 0} 个账号</span></div>
|
|
|
|
|
- {(d.open_stop?.accounts.length ?? 0) > 0 ? <div className="work-order-table-wrap compact"><table><thead><tr><th>显示名</th><th>网络账户名</th><th>停机前 → 生效后</th><th>生效日</th><th>来源</th></tr></thead><tbody>{d.open_stop!.accounts.map((a) => <tr key={a.id}><td>{a.display_name ?? "-"}</td><td>{a.net_account ?? "-"}</td><td>{label(ACCT_STATUS, a.before_status) || "-"} → {label(ACCT_STATUS, a.after_status) || "-"}</td><td>{a.effective_date ? fmtDate(a.effective_date) : "-"}</td><td>{a.source ?? "-"}</td></tr>)}</tbody></table></div> : <p className="work-order-detail-text">尚未产生账号级生效记录(回填生效后写入)。</p>}
|
|
|
|
|
- {d.open_stop && <p className="work-order-detail-footnote"><Info size={15} />开停记录:{d.open_stop.action ? (OPEN_STOP_ACTION_NAMES[d.open_stop.action] ?? d.open_stop.action) : "-"} / {d.open_stop.exec_status ? (EXEC_STATUS_NAMES[d.open_stop.exec_status] ?? d.open_stop.exec_status) : "-"} / 生效账号 {numText(d.open_stop.effective_account_count)} 个{d.open_stop.exec_status === "pending" ? "(待生效)" : ""}{isYes(d.open_stop.closed_flag) ? " · 已随工单关闭" : ""}。</p>}
|
|
|
|
|
- </section>}
|
|
|
|
|
- {showCompletion && <section className="work-order-section"><div className="work-order-section-head"><div><p>竣工回传与回执</p><h2>运营商对接留痕</h2></div><span>{d.completion ? (d.completion.receipt_at && d.completion.receipt_valid !== "0" ? "回执已确认" : d.completion.receipt_at ? "回执已随回退失效" : "已回传待回执") : "未生成"}</span></div>
|
|
|
|
|
- {d.completion ? <div className="work-order-summary-grid"><div><span>竣工单号</span><strong>{d.completion.completion_no ?? "-"}</strong></div><div><span>动作</span><strong>{d.completion.action ? (OPEN_STOP_ACTION_NAMES[d.completion.action] ?? d.completion.action) : "-"}</strong></div><div><span>执行结论</span><strong>{d.completion.exec_conclusion ? (CONCLUSION_NAMES[d.completion.exec_conclusion] ?? d.completion.exec_conclusion) : "-"}</strong></div><div><span>回传方式</span><strong>{d.completion.mode === "auto" ? "自动" : "手工"}</strong></div><div><span>回传时间</span><strong>{fmtTime(d.completion.pushed_at)}</strong></div><div><span>回执时间</span><strong>{fmtTime(d.completion.receipt_at)}</strong></div><div className="wide"><span>回执说明</span><strong>{d.completion.receipt_remark ?? "-"}</strong></div></div> : <p className="work-order-detail-text">{d.gaps.length ? `缺口未清,竣工暂不可生成:${d.gaps.map(groupLabel).join(" / ")}` : conclusionBlocksCompletion(d.backfill?.exec_conclusion) ? "回填结论为失败,须重新回填成功/部分成功后才可生成竣工并回传。" : "缺口已齐,可生成竣工并回传。"}</p>}
|
|
|
|
|
- </section>}
|
|
|
|
|
- {d.messages.length > 0 && <section className="work-order-section"><div className="work-order-section-head"><div><p>关联报文</p><h2>运营商报文与处置状态</h2></div><span>{d.messages.length} 条</span></div><div className="work-order-table-wrap compact"><table><thead><tr><th>外部单号</th><th>动作</th><th>状态</th><th>接收时间</th><th>生效时间</th><th>说明</th><th><span className="sr-only">操作</span></th></tr></thead><tbody>{d.messages.map((m) => <tr key={m.message_id}><td>{m.unicom_order_no ?? "-"}</td><td>{m.action ?? "-"}</td><td>{m.status ?? "-"}</td><td>{fmtTime(m.received_at)}</td><td>{fmtTime(m.effective_at)}</td><td>{m.conflict_note ?? m.void_reason ?? "-"}</td><td>{m.status === "conflict" && !clientView && <Button variant="ghost" size="sm" onClick={() => void (async () => { const ok = await submit.run(() => messageConfirmConflict({ message_id: m.message_id, disposition: "as_is" })); if (ok) { setNotice("冲突已按现状归档。"); detail.reload(); } })()}>按现状归档</Button>}</td></tr>)}</tbody></table></div></section>}
|
|
|
|
|
- <section className="work-order-section"><div className="work-order-section-head"><div><p>处理记录</p><h2>主时间线</h2></div><span>{d.process_logs.length} 条留痕</span></div><LogTimeline logs={d.process_logs} /></section>
|
|
|
|
|
- <section className="work-order-section"><div className="work-order-section-head"><div><p>过程材料</p><h2>本单登记的材料</h2></div><span>{d.materials.length} 份</span></div>
|
|
|
|
|
- {d.materials.length ? <div className="work-order-table-wrap compact"><table><thead><tr><th>文件名</th><th>类型</th><th>大小</th><th>登记人</th><th>登记时间</th></tr></thead><tbody>{d.materials.map((m) => <tr key={m.material_id}><td>{m.file_name ?? m.material_id}</td><td>{m.kind ?? "-"}</td><td>{numText(m.size_bytes, " B")}</td><td>{m.uploaded_by ?? "-"}</td><td>{fmtTime(m.uploaded_at)}</td></tr>)}</tbody></table></div> : <p className="work-order-detail-text">本单暂无材料。</p>}
|
|
|
|
|
- {!clientView && (materialLocked
|
|
|
|
|
- ? <p className="work-order-detail-footnote"><Info size={15} />工单已{t.status === "terminated" ? "作废" : "闭环"},材料清单只读:终态不再提供任何追加入口(服务端同样拒绝,KLT-G20401)。</p>
|
|
|
|
|
- : <MaterialForm ticketId={t.ticket_id} onDone={(m) => { setNotice(m); detail.reload(); }} />)}
|
|
|
|
|
|
|
+
|
|
|
|
|
+ {/* 交付事实:按段折叠。段头摘要行给关键数字(结论/日期/条数),折叠也不丢信息;
|
|
|
|
|
+ 只有与本单状态相关的一段默认展开,其余收起,避免六张明细表把正文拉成几屏长。 */}
|
|
|
|
|
+ <section className="work-order-section work-order-facts">
|
|
|
|
|
+ <header className="work-order-facts-head"><h2>交付事实</h2><span>{factsCount} 段 · 默认只展开与本单状态相关的一段</span></header>
|
|
|
|
|
+ {prep && <FactSeg title="开通准备资料" open={openSeg === "prep"}
|
|
|
|
|
+ summary={prep.submitted ? `${prep.declarant_name ?? "—"} · 应用 ${prep.apps.length} 类 / ${prepAppCount} 个账号` : "未登记"}
|
|
|
|
|
+ badge={prep.submitted ? "已提交" : "待登记"} tone={prep.submitted ? "ok" : "warn"}>
|
|
|
|
|
+ <div className="work-order-summary-grid"><div><span>声明人</span><strong>{prep.declarant_name ?? "-"}</strong></div><div><span>声明单位</span><strong>{prep.declarant_org ?? "-"}</strong></div><div><span>联系方式</span><strong>{prep.declarant_contact ?? "-"}</strong></div><div><span>提交时间</span><strong>{fmtTime(prep.submitted_at)}</strong></div><div className="wide"><span>合规声明</span><strong>{prep.declaration_text ?? "-"}</strong></div></div>
|
|
|
|
|
+ {prep.apps.length > 0 && <><h4 className="work-order-subhead">开通应用及数量</h4><div className="work-order-table-wrap compact"><table><thead><tr><th>应用类别</th><th>开通账号数</th></tr></thead><tbody>{prep.apps.map((a) => <tr key={a.app_id}><td>{APP_CATEGORIES.find((c) => c.code === a.app_category)?.label ?? a.app_category ?? "-"}</td><td>{numText(a.qty)}</td></tr>)}</tbody></table></div></>}
|
|
|
|
|
+ {prepMaterials.length > 0 && <><h4 className="work-order-subhead">资料影像({prepMaterials.length} 份)</h4>
|
|
|
|
|
+ <MaterialList ticketId={t.ticket_id} items={prepMaterials} empty="无" allowDownload={canDownloadMaterial} /></>}
|
|
|
|
|
+ <p className="work-order-seg-foot">境外 IP 不在本区块登记:实际分配的境外 IP 见「施工回填」的境外出口 IP 明细。</p>
|
|
|
|
|
+ {can.open_prep_save && <p className="work-order-seg-foot">重复保存=整体覆盖(冲突时回 KLT-G20417,请重新读取)。</p>}
|
|
|
|
|
+ </FactSeg>}
|
|
|
|
|
+ {(d.backfill || can.backfill) && <FactSeg title="施工回填" open={openSeg === "backfill"}
|
|
|
|
|
+ summary={d.backfill ? `${CONCLUSION_NAMES[d.backfill.exec_conclusion ?? ""] ?? d.backfill.exec_conclusion ?? "—"} · 实际开通 ${d.backfill.actual_opened_date ? fmtDate(d.backfill.actual_opened_date) : "—"} · 线路 ${d.backfill.routes.length} 条 / 境外 IP ${d.backfill.ips.length} 条` : "尚未回填 · 缺 线路与路由、执行结论与凭证"}
|
|
|
|
|
+ badge={d.backfill ? "已回填" : "待回填"} tone={d.backfill ? "ok" : "warn"}>
|
|
|
|
|
+ {d.backfill ? <>
|
|
|
|
|
+ <div className="work-order-summary-grid"><div><span>执行结论</span><strong>{CONCLUSION_NAMES[d.backfill.exec_conclusion ?? ""] ?? d.backfill.exec_conclusion ?? "-"}</strong></div><div><span>实际开通日期</span><strong>{d.backfill.actual_opened_date ? fmtDate(d.backfill.actual_opened_date) : "-"}</strong></div><div><span>停机完成日期</span><strong>{d.backfill.stop_done_date ? fmtDate(d.backfill.stop_done_date) : "-"}</strong></div><div><span>回填次数</span><strong>{numText(d.backfill.attempt_count)} 次</strong></div><div className="wide"><span>结论说明</span><strong>{d.backfill.conclusion_note ?? "-"}</strong></div><div className="wide"><span>凭证与佐证</span><strong>{d.backfill.evidence_text ?? "-"}</strong></div></div>
|
|
|
|
|
+ {d.backfill.routes.length > 0 && <><h4 className="work-order-subhead">网络线路</h4><div className="work-order-table-wrap compact"><table><thead><tr><th>网络账户名</th><th>内网 IP / 掩码</th><th>端点(源 → 目的)</th><th>出口 PoP</th><th>带宽</th></tr></thead><tbody>{d.backfill.routes.map((r) => <tr key={r.id}><td>{r.network_account_name ?? "-"}</td><td>{[r.intranet_ip, r.subnet_mask].filter(Boolean).join(" / ") || "-"}</td><td>{r.src_endpoint ?? "-"} → {r.dst_endpoint ?? "-"}</td><td>{r.egress_pop ?? "-"}</td><td>{[r.down_mbps && `↓${r.down_mbps}`, r.up_mbps && `↑${r.up_mbps}`].filter(Boolean).join(" / ") || "-"}</td></tr>)}</tbody></table></div></>}
|
|
|
|
|
+ {d.backfill.ips.length > 0 && <><h4 className="work-order-subhead">境外出口 IP</h4><div className="work-order-table-wrap compact"><table><thead><tr><th>出口</th><th>IP</th><th>类型</th><th>带宽</th><th>凭据</th></tr></thead><tbody>{d.backfill.ips.map((r) => <tr key={r.id}><td>{r.egress ?? "-"}</td><td>{r.overseas_ip ?? "-"}</td><td>{r.ip_type ?? "-"}</td><td>{numText(r.bandwidth_mbps, "M")}</td><td>PIN {isYes(r.pin_registered) ? "✓" : "—"} / CPID {isYes(r.cpid_registered) ? "✓" : "—"}</td></tr>)}</tbody></table></div></>}
|
|
|
|
|
+ <p className="work-order-seg-foot">库内仅存 PIN/CPID 密文,此处只显示「是否登记」;IP 规则 v{d.backfill.ip_rule_version}。</p>
|
|
|
|
|
+ </> : <>
|
|
|
|
|
+ <p className="work-order-seg-foot">登记执行结论、实际开通日期、线路与境外 IP;保存即推进工单。</p>
|
|
|
|
|
+ <p className="work-order-seg-foot">建单人取当前登录身份,无需手填。</p>
|
|
|
|
|
+ </>}
|
|
|
|
|
+ {/* 材料跟着这一段走:回填时自动归档的凭证 + 现场补传的过程材料(后者是本段唯一的写入口)。 */}
|
|
|
|
|
+ <h4 className="work-order-subhead">凭证与过程材料({backfillMaterials.length} 份)</h4>
|
|
|
|
|
+ <MaterialList ticketId={t.ticket_id} items={backfillMaterials} empty="暂无材料:回填保存时凭证清单里的文档名会自动归档到这里。" allowDownload={canDownloadMaterial} />
|
|
|
|
|
+ {!clientView && (materialLocked
|
|
|
|
|
+ ? <p className="work-order-seg-foot"><Info size={15} />工单已{t.status === "terminated" ? "作废" : "闭环"},材料只读:终态不再提供任何追加入口(服务端同样拒绝,KLT-G20401)。</p>
|
|
|
|
|
+ : <div className="work-order-materials-actions"><Button variant="outline" size="sm" type="button" onClick={() => setMaterialOpen(true)}><FolderOpen size={15} />补充过程材料</Button></div>)}
|
|
|
|
|
+ </FactSeg>}
|
|
|
|
|
+ {d.service_items.length > 0 && <FactSeg title="服务清单" open={openSeg === "checklist"}
|
|
|
|
|
+ summary={`${checkedItems} / ${d.service_items.length} 已核对${checklistGated ? "" : " · 不阻断本单闭环"}`}
|
|
|
|
|
+ badge={checkedItems === d.service_items.length ? "已核对" : "待核对"} tone={checkedItems === d.service_items.length ? "ok" : "warn"}>
|
|
|
|
|
+ {/* 升降配单的「原值 → 新值」并成一列(原型 v3),⛔ 再单独渲染一张参数对照表。 */}
|
|
|
|
|
+ <div className="work-order-table-wrap compact"><table><thead><tr><th>序号</th><th>条目</th>{t.ticket_type === "updown" ? <th>原值 → 新值</th> : <th>规格</th>}<th>数量</th><th>核对结果</th><th>核对时间</th></tr></thead><tbody>{d.service_items.map((item) => <tr key={item.item_id}><td>{item.seq_no}</td><td><strong>{item.item_name ?? "-"}</strong></td>{t.ticket_type === "updown" ? <td>{item.spec_before ?? "-"} → {item.spec_after ?? "-"}</td> : <td>{item.spec_text ?? "-"}</td>}<td>{numText(item.expect_qty)}</td><td>{item.check_result === "done" ? <span className="ops-state tone-valid">已核对</span> : item.check_result === "absent" ? <span className="ops-state tone-invalid">缺项</span> : <span className="ops-state tone-invalid">未核对</span>}</td><td>{fmtTime(item.checked_at)}</td></tr>)}</tbody></table></div>
|
|
|
|
|
+ <p className="work-order-seg-foot">{checklistNote}</p>
|
|
|
|
|
+ </FactSeg>}
|
|
|
|
|
+ {(d.open_stop?.accounts.length ?? 0) > 0 && <FactSeg title="账号清单" open={openSeg === "accounts"}
|
|
|
|
|
+ summary={`${d.open_stop!.accounts.length} 个账号 · ${d.open_stop!.exec_status === "pending" ? "待生效" : "已生效"}`}
|
|
|
|
|
+ badge={d.open_stop!.exec_status === "pending" ? "待生效" : "已生效"} tone={d.open_stop!.exec_status === "pending" ? "warn" : "ok"}>
|
|
|
|
|
+ <div className="work-order-table-wrap compact"><table><thead><tr><th>显示名</th><th>网络账户名</th><th>停机前 → 生效后</th><th>生效日</th><th>来源</th></tr></thead><tbody>{d.open_stop!.accounts.map((a) => <tr key={a.id}><td>{a.display_name ?? "-"}</td><td>{a.net_account ?? "-"}</td><td>{label(ACCT_STATUS, a.before_status) || "-"} → {label(ACCT_STATUS, a.after_status) || "-"}</td><td>{a.effective_date ? fmtDate(a.effective_date) : "-"}</td><td>{a.source ?? "-"}</td></tr>)}</tbody></table></div>
|
|
|
|
|
+ {d.open_stop && <p className="work-order-seg-foot">开停记录:{d.open_stop.action ? (OPEN_STOP_ACTION_NAMES[d.open_stop.action] ?? d.open_stop.action) : "-"} / {d.open_stop.exec_status ? (EXEC_STATUS_NAMES[d.open_stop.exec_status] ?? d.open_stop.exec_status) : "-"} / 生效账号 {numText(d.open_stop.effective_account_count)} 个{d.open_stop.exec_status === "pending" ? "(待生效)" : ""}{isYes(d.open_stop.closed_flag) ? " · 已随工单关闭" : ""}。</p>}
|
|
|
|
|
+ </FactSeg>}
|
|
|
|
|
+ {showCompletion && <FactSeg title="竣工与回执" open={openSeg === "completion"}
|
|
|
|
|
+ summary={d.completion ? `${d.completion.completion_no ?? "—"} · ${receiptState.text}` : "未生成 · 缺口齐备后可生成"}
|
|
|
|
|
+ badge={receiptState.text} tone={receiptState.tone}>
|
|
|
|
|
+ {d.completion ? <div className="work-order-summary-grid"><div><span>竣工单号</span><strong>{d.completion.completion_no ?? "-"}</strong></div><div><span>动作</span><strong>{d.completion.action ? (OPEN_STOP_ACTION_NAMES[d.completion.action] ?? d.completion.action) : "-"}</strong></div><div><span>执行结论</span><strong>{d.completion.exec_conclusion ? (CONCLUSION_NAMES[d.completion.exec_conclusion] ?? d.completion.exec_conclusion) : "-"}</strong></div><div><span>回传方式</span><strong>{d.completion.mode === "auto" ? "自动" : "手工"}</strong></div><div><span>回传时间</span><strong>{fmtTime(d.completion.pushed_at)}</strong></div><div><span>回执时间</span><strong>{fmtTime(d.completion.receipt_at)}</strong></div><div className="wide"><span>回执说明</span><strong>{d.completion.receipt_remark ?? "-"}</strong></div></div> : <p className="work-order-seg-foot">{d.gaps.length ? `缺口未清,竣工暂不可生成:${d.gaps.map(groupLabel).join(" / ")}` : conclusionBlocksCompletion(d.backfill?.exec_conclusion) ? "回填结论为失败,须重新回填成功/部分成功后才可生成竣工并回传。" : "缺口已齐,可生成竣工并回传。"}</p>}
|
|
|
|
|
+ {/* 等待回执:出口是回执确认;权限不足时说明谁可执行——⛔ 给一个点了会被服务端拒的按钮。 */}
|
|
|
|
|
+ {d.completion && !d.completion.receipt_at && t.status !== "rejected" && (viewerReadOnly || !can.confirm_receipt
|
|
|
|
|
+ ? <p className="work-order-seg-foot"><ShieldAlert size={15} />回执确认仅总运营与该团队主账号可执行。</p>
|
|
|
|
|
+ : <div className="work-order-seg-actions"><Button onClick={() => void quick("confirm_receipt")}><Check size={15} />回执确认闭环</Button></div>)}
|
|
|
|
|
+ {/* 驳回历史(工单§5.5.3):⚠️ 只读运维视角——客户门户对驳回原因⛔ 展示(门户口径=
|
|
|
|
|
+ "待补充资料后重新提交"),且出参本身就没有 `external_reject_no` 这一列。 */}
|
|
|
|
|
+ {!clientView && !!d.completion_rejects?.length && <>
|
|
|
|
|
+ <h4 className="work-order-subhead">驳回历史({d.completion_rejects.length} 次{d.reject_pending ? " · 外部等待中" : ""})</h4>
|
|
|
|
|
+ <div className="work-order-table-wrap compact"><table><thead><tr><th>次数</th><th>件号</th><th>理由</th><th>时间</th></tr></thead><tbody>{d.completion_rejects.map((r) => <tr key={r.reject_seq}><td>第 {r.reject_seq} 次</td><td>{r.completion_no}</td><td>{rejectReasonNames(r.reason_codes)}{r.reason_text ? `:${r.reason_text}` : ""}</td><td>{fmtTime(r.rejected_at)} · {r.channel === "human" ? "人工登记" : r.channel}{r.pushed_at ? ` · 回传于 ${fmtDate(r.pushed_at)}` : ""}</td></tr>)}</tbody></table></div>
|
|
|
|
|
+ <p className="work-order-seg-foot">驳回期间期限日不重置,超期判定扣掉这段外部等待;出口=同号覆盖重推(驳回态即可执行)或总运营受控回退到处理中后再改回填。</p>
|
|
|
|
|
+ </>}
|
|
|
|
|
+ <p className="work-order-seg-foot">回执确认后完成日改写为当天;开停记录的执行日不变。</p>
|
|
|
|
|
+ {/* 竣工件=生成竣工时同事务归档的 PDF;终态后仍可下载(需求 §7.8 竣工材料事后仍可导出)。 */}
|
|
|
|
|
+ <h4 className="work-order-subhead">竣工材料({completionMaterials.length} 份)</h4>
|
|
|
|
|
+ <MaterialList ticketId={t.ticket_id} items={completionMaterials} empty="生成竣工单时自动归档,无需手工上传。" allowDownload={canDownloadMaterial} />
|
|
|
|
|
+ </FactSeg>}
|
|
|
|
|
+
|
|
|
|
|
+ {d.messages.length > 0 && <FactSeg title="关联报文" open={openSeg === "messages"}
|
|
|
|
|
+ summary={`${d.messages.length} 条 · 运营商报文与处置状态`} badge={`${d.messages.length} 条`}>
|
|
|
|
|
+ <div className="work-order-table-wrap compact"><table><thead><tr><th>外部单号</th><th>动作</th><th>状态</th><th>接收时间</th><th>生效时间</th><th>说明</th><th><span className="sr-only">操作</span></th></tr></thead><tbody>{d.messages.map((m) => <tr key={m.message_id}><td>{m.unicom_order_no ?? "-"}</td><td>{m.action ?? "-"}</td><td>{m.status ?? "-"}</td><td>{fmtTime(m.received_at)}</td><td>{fmtTime(m.effective_at)}</td><td>{m.conflict_note ?? m.void_reason ?? "-"}</td><td>{m.status === "conflict" && !clientView && <Button variant="ghost" size="sm" onClick={() => void (async () => { const ok = await submit.run(() => messageConfirmConflict({ message_id: m.message_id, disposition: "as_is" })); if (ok) { setNotice("冲突已按现状归档。"); detail.reload(); } })()}>按现状归档</Button>}</td></tr>)}</tbody></table></div>
|
|
|
|
|
+ </FactSeg>}
|
|
|
|
|
+ {/* 非主线单(故障/售后)没有施工回填段 ⇒ 过程材料单独成段:这些单上它就是主证据,不是某段的补充。
|
|
|
|
|
+ ⚠️ 空清单不给 warn 色调:照片明确定义为「不是完成门槛」(需求 §7.5),不能读成缺项。 */}
|
|
|
|
|
+ {!hasBackfillSeg && <FactSeg title="过程材料" open={openSeg === "materials"}
|
|
|
|
|
+ summary={backfillMaterials.length ? `${backfillMaterials.length} 份 · 现场照片与佐证` : "暂无材料 · 可补充现场照片"}
|
|
|
|
|
+ badge={backfillMaterials.length ? `${backfillMaterials.length} 份` : "可补充"} tone={backfillMaterials.length ? "ok" : undefined}>
|
|
|
|
|
+ <MaterialList ticketId={t.ticket_id} items={backfillMaterials} empty="暂无材料:可在此补充现场照片、处理截图等过程留痕。" allowDownload={canDownloadMaterial} />
|
|
|
|
|
+ {!clientView && (materialLocked
|
|
|
|
|
+ ? <p className="work-order-seg-foot"><Info size={15} />工单已{t.status === "terminated" ? "作废" : "闭环"},材料只读:终态不再提供任何追加入口(服务端同样拒绝,KLT-G20401)。</p>
|
|
|
|
|
+ : <div className="work-order-materials-actions"><Button variant="outline" size="sm" type="button" onClick={() => setMaterialOpen(true)}><FolderOpen size={15} />补充过程材料</Button></div>)}
|
|
|
|
|
+ </FactSeg>}
|
|
|
</section>
|
|
</section>
|
|
|
|
|
+
|
|
|
|
|
+ {/* 参考信息移到正文底部:宽度由主列决定,与上方卡片天然对齐;右栏腾给「处理记录」专席。 */}
|
|
|
|
|
+ <div className="work-order-refs">
|
|
|
|
|
+ <section className="work-order-section">
|
|
|
|
|
+ <h2>客户与订阅<span>点击查看详情</span></h2>
|
|
|
|
|
+ {refCustomer ? <>
|
|
|
|
|
+ <div className="work-order-trace"><span>客户名称</span><strong>{refCustomer.customer_name
|
|
|
|
|
+ ? <button type="button" className="work-order-trace-link" onClick={() => openRef({ kind: "customer", id: refCustomer.customer_id, name: refCustomer.customer_name })}>{refCustomer.customer_name}</button>
|
|
|
|
|
+ : "-"}</strong></div>
|
|
|
|
|
+ <div className="work-order-trace"><span>客户编号</span><strong>{refCustomer.customer_code || refCustomer.customer_id
|
|
|
|
|
+ ? <button type="button" className="work-order-trace-link" onClick={() => openRef({ kind: "customer", id: refCustomer.customer_id, name: refCustomer.customer_name })}>{refCustomer.customer_code ?? refCustomer.customer_id}</button>
|
|
|
|
|
+ : "-"}</strong></div>
|
|
|
|
|
+ <div className="work-order-trace"><span>联系人 / 电话</span><strong>{[refCustomer.contact_name, refCustomer.contact_mobile].filter(Boolean).join(" / ") || "-"}</strong></div>
|
|
|
|
|
+ <div className="work-order-trace"><span>通信地址</span><strong>{refCustomer.address ?? "-"}</strong></div>
|
|
|
|
|
+ </> : <p className="work-order-reference-empty">该单未关联客户档案。</p>}
|
|
|
|
|
+ {refOrder && <div className="work-order-trace"><span>关联订阅</span><strong><button type="button" className="work-order-trace-link" onClick={() => openRef({ kind: "order", id: refOrder.subscription_id, name: refOrder.plan_name })}>{refOrder.plan_name ?? refOrder.subscription_id}</button></strong><small>{[refOrder.subscription_id, label(PLAN_KIND, refOrder.plan_kind), label(USE_CATEGORY, refOrder.use_category), label(ORDER_STATUS, refOrder.status), refOrder.actual_opened_at ? `实际开通 ${fmtDate(refOrder.actual_opened_at)}` : null].filter(Boolean).join(" · ")}</small></div>}
|
|
|
|
|
+ </section>
|
|
|
|
|
+ <section className="work-order-section">
|
|
|
|
|
+ <h2>追溯与关联</h2>
|
|
|
|
|
+ <div className="work-order-trace"><span>本单来源</span><strong>{t.source_message_id ? "运营商报文触发" : t.submitter_type === "customer" ? "客户侧提交" : "运营侧代报"}</strong></div>
|
|
|
|
|
+ {d.messages.length > 0 && <div className="work-order-trace"><span>关联报文</span><strong>{d.messages.map((m) => m.unicom_order_no ?? m.message_id).join("、")}</strong></div>}
|
|
|
|
|
+ {t.source_message_id && <div className="work-order-trace"><span>来源报文</span><strong>{t.source_message_id}</strong></div>}
|
|
|
|
|
+ {t.subscription_id && <div className="work-order-trace"><span>关联订单号</span><strong><button type="button" className="work-order-trace-link" onClick={() => openRef({ kind: "order", id: t.subscription_id!, name: refOrder?.plan_name })}>{t.subscription_id}</button></strong></div>}
|
|
|
|
|
+ </section>
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
- <aside className="work-order-side"><div className="work-order-side-main">
|
|
|
|
|
- <div className="work-order-action-bar" data-status={BAR_TONE[t.status]}><div><span>处理状态</span><strong>{statusLabel(t.status)}</strong></div><p>{t.status === "unassigned" ? "指派责任运维后即进入待处理。" : t.status === "pending" ? "已分派给责任人;打开详情或修改工单即自动进入处理中(工单§4.1.4)。" : t.status === "processing" ? d.gaps.length ? `闭环还缺:${d.gaps.map(groupLabel).join(" / ")}` : conclusionBlocksCompletion(d.backfill?.exec_conclusion) ? "回填结论为失败:请重新回填成功后再生成竣工。" : "回填已齐,可出竣工。" : t.status === "completed" ? "主线单生成竣工并回传后等待回执;非主线单等待客户侧确认。" : t.status === "rejected" ? "竣工回传被驳回:本态只开「同号覆盖重推」,按当前回填重新回传;确需改回填的,先由总运营受控回退到「处理中」。本态⛔ 录入回执。" : t.status === "settled" ? "工单闭环,记录保持可追溯。" : "工单已作废,不再进入处理流程。"}</p></div>
|
|
|
|
|
- {t.status === "terminated" && t.close_reason && <div className="work-order-void"><X size={18} /><div><strong>作废原因</strong><p>{t.close_reason}</p></div></div>}
|
|
|
|
|
- {hasActions && <div className="work-order-action-panel"><div><p>当前可执行</p><h2>工单处理</h2></div><div className="work-order-action-group"><span>主操作</span><div>{primaryActions.map(([action, label]) => <Button key={action} onClick={() => openSheet(action)}><i className={`work-order-action-icon action-${action}`}><ClipboardList size={15} /></i><span>{label}</span></Button>)}</div></div>
|
|
|
|
|
- {opsActions.length > 0 && <div className="work-order-action-group"><span>操作与状态</span><div>{opsActions.map(([action, label]) => <Button key={action} variant="outline" onClick={() => openSheet(action)}><i className={`work-order-action-icon action-${action}`}>{action.startsWith("defer") ? <RefreshCcw size={15} /> : action === "delegate" ? <UserCog size={15} /> : action === "revert" ? <ShieldAlert size={15} /> : <X size={15} />}</i><span>{label}</span></Button>)}</div></div>}
|
|
|
|
|
- </div>}
|
|
|
|
|
- {d.gaps.length > 0 && <div className="work-order-gap-panel"><div><p>闭环缺口</p><h2>{d.gaps.length} 项未满足</h2><span>{d.required_groups.map(groupLabel).join(" / ")}</span></div><ul>{d.gaps.map((g) => {
|
|
|
|
|
- const target = gapTarget(g, can);
|
|
|
|
|
- return <li key={g}><span><CircleAlert size={15} /></span><div><strong>{groupLabel(g)}</strong><p>{gapHint(g)}</p></div>{target && !viewerReadOnly && <Button className="work-order-gap-action" variant="outline" size="sm" onClick={() => openSheet(target.action, target.focus)}>{target.label}<ArrowRight size={14} /></Button>}</li>;
|
|
|
|
|
- })}</ul><p className="work-order-detail-footnote">缺口清单由服务端判定,不得在此人工放行竣工;{can.generate_completion ? "可生成竣工" : "生成竣工入口保持关闭"}。</p></div>}
|
|
|
|
|
- {/* 驳回态⛔ 出现"等待回执"面板(批复②):该态的唯一出路是改回填后同号覆盖重推。 */}
|
|
|
|
|
- {d.completion && !d.completion.receipt_at && t.status !== "rejected" && <div className="work-order-receipt-panel"><div><p>回执确认</p><h2>等待回执</h2></div><p>{d.completion.completion_no} 已回传。回执确认后即可闭环。</p>{!viewerReadOnly && can.confirm_receipt && <Button onClick={() => void quick("confirm_receipt")}><Check size={15} />回执确认闭环</Button>}{!can.confirm_receipt && <p className="work-order-detail-footnote"><ShieldAlert size={15} />回执确认仅总运营与该团队主账号可执行。</p>}</div>}
|
|
|
|
|
- {/* 入口判据完全交给服务端 `can.generate_completion`(=回执仍有效才拦):⛔ 再叠一层
|
|
|
|
|
- `!d.completion`——受控回退⛔ 碰竣工行,回退后重推正是同号覆盖那条正门(P-45(b))。 */}
|
|
|
|
|
- {!viewerReadOnly && can.generate_completion && <div className="work-order-receipt-panel"><div><p>竣工回传</p><h2>{t.status === "rejected" ? "驳回后重新回传" : d.completion ? "重新生成并回传" : "生成并回传"}</h2></div><p>{t.status === "rejected" ? `竣工件 ${d.completion?.completion_no ?? ""} 已被驳回,按当前回填重新回传将同号覆盖(不新发竣工号)。` : d.completion ? `本单已有竣工件 ${d.completion.completion_no ?? ""},重新回传将同号覆盖并清空原回执。` : "缺口已齐,可生成竣工记录并回传运营商。"}</p><Button onClick={() => void quick("generate_completion")}><PackageCheck size={15} />生成竣工</Button></div>}
|
|
|
|
|
- {/* 驳回流水(工单§5.5.3):⚠️ 只读运维视角——客户门户对驳回原因⛔ 展示(门户口径=
|
|
|
|
|
- "待补充资料后重新提交"),且出参本身就没有 `external_reject_no` 这一列。 */}
|
|
|
|
|
- {!clientView && !!d.completion_rejects?.length && <section className="work-order-detail-section">
|
|
|
|
|
- <h3>竣工驳回记录 <span>{d.completion_rejects.length} 次{d.reject_pending ? " · 外部等待中" : ""}</span></h3>
|
|
|
|
|
- <div className="work-order-subtable">{d.completion_rejects.map((r) => <div key={r.reject_seq}>
|
|
|
|
|
- <span>第 {r.reject_seq} 次 · 件号 {r.completion_no}</span>
|
|
|
|
|
- <p>{rejectReasonNames(r.reason_codes)}{r.reason_text ? `:${r.reason_text}` : ""}</p>
|
|
|
|
|
- <small>{fmtTime(r.rejected_at)} · {r.channel === "human" ? "人工登记" : r.channel}{r.pushed_at ? ` · 回传于 ${fmtDate(r.pushed_at)}` : ""}</small>
|
|
|
|
|
- </div>)}</div>
|
|
|
|
|
- <p className="work-order-detail-footnote"><Info size={15} />驳回期间期限日不重置,超期判定扣掉这段外部等待;出口=同号覆盖重推(通路 10,驳回态即可执行)或总运营受控回退到处理中后再改回填。</p>
|
|
|
|
|
- </section>}
|
|
|
|
|
- {/* 门户进度条(第 5 册 §14.1.9):驳回态对客户**只说**"待补充资料后重新提交",
|
|
|
|
|
- ⛔ 出现「竣工驳回」字样与内部归因——门户口径是"对方还在处理",不是"你做错了"。 */}
|
|
|
|
|
- {clientView && !hasActions && t.status !== "settled" && t.status !== "terminated" && <div className="work-order-flow"><div className="work-order-flow-step"><b className="current">{t.status === "completed" ? "2" : "1"}</b><span>{t.status === "rejected" ? "待补充资料后重新提交" : t.status === "completed" ? "竣工回传已提交,等待回执" : "等待运维处理"}</span></div></div>}
|
|
|
|
|
- {viewerReadOnly && !hasActions && <div className="work-order-view-only"><ShieldAlert size={18} /><div><strong>只读视图</strong><p>你可以查看工单信息与处理记录,处理动作由运维团队执行。</p></div></div>}
|
|
|
|
|
- </div>
|
|
|
|
|
- <div className="work-order-side-aux">
|
|
|
|
|
- {/* 客户、合同、订阅只作参考:放在右栏辅助区,不占正文视觉主线;摘要可点开完整档案。 */}
|
|
|
|
|
- <section className="work-order-reference"><h2>客户与订阅<span>点击查看详情</span></h2>
|
|
|
|
|
- {refCustomer ? <>
|
|
|
|
|
- <div className="work-order-trace"><span>客户名称</span><strong>{refCustomer.customer_name
|
|
|
|
|
- ? <button type="button" className="work-order-trace-link" onClick={() => openRef({ kind: "customer", id: refCustomer.customer_id, name: refCustomer.customer_name })}>{refCustomer.customer_name}</button>
|
|
|
|
|
- : "-"}</strong></div>
|
|
|
|
|
- <div className="work-order-trace"><span>客户编号</span><strong>{refCustomer.customer_code || refCustomer.customer_id
|
|
|
|
|
- ? <button type="button" className="work-order-trace-link" onClick={() => openRef({ kind: "customer", id: refCustomer.customer_id, name: refCustomer.customer_name })}>{refCustomer.customer_code ?? refCustomer.customer_id}</button>
|
|
|
|
|
- : "-"}</strong></div>
|
|
|
|
|
- <div className="work-order-trace"><span>联系人 / 电话</span><strong>{[refCustomer.contact_name, refCustomer.contact_mobile].filter(Boolean).join(" / ") || "-"}</strong></div>
|
|
|
|
|
- <div className="work-order-trace"><span>通信地址</span><strong>{refCustomer.address ?? "-"}</strong></div>
|
|
|
|
|
- </> : <p className="work-order-reference-empty">该单未关联客户档案。</p>}
|
|
|
|
|
- {refOrder && <div className="work-order-trace"><span>关联订阅</span><strong><button type="button" className="work-order-trace-link" onClick={() => openRef({ kind: "order", id: refOrder.subscription_id, name: refOrder.plan_name })}>{refOrder.plan_name ?? refOrder.subscription_id}</button></strong><small>{[refOrder.subscription_id, label(PLAN_KIND, refOrder.plan_kind), label(USE_CATEGORY, refOrder.use_category), label(ORDER_STATUS, refOrder.status), refOrder.actual_opened_at ? `实际开通 ${fmtDate(refOrder.actual_opened_at)}` : null].filter(Boolean).join(" · ")}</small></div>}
|
|
|
|
|
|
|
+ <aside className="work-order-side">
|
|
|
|
|
+ {/* 右栏=处理记录专席:面板高度随窗口自适应、条数超出时面板内滚动,页面本身不变长。 */}
|
|
|
|
|
+ <section className="work-order-logs-panel">
|
|
|
|
|
+ <header><h2>处理记录</h2><span>{d.process_logs.length} 条 · 最新在上</span></header>
|
|
|
|
|
+ <div className="work-order-logs-scroll"><LogPanel logs={d.process_logs} /></div>
|
|
|
</section>
|
|
</section>
|
|
|
- <section><h2>追溯与关联</h2><div className="work-order-trace"><span>本单来源</span><strong>{t.source_message_id ? "运营商报文触发" : t.submitter_type === "customer" ? "客户侧提交" : "运营侧代报"}</strong></div>{d.messages.length > 0 && <div className="work-order-trace"><span>关联报文</span><strong>{d.messages.map((m) => m.unicom_order_no ?? m.message_id).join("、")}</strong></div>}{t.source_message_id && <div className="work-order-trace"><span>来源报文</span><strong>{t.source_message_id}</strong></div>}{t.subscription_id && <div className="work-order-trace"><span>关联订单号</span><strong><button type="button" className="work-order-trace-link" onClick={() => openRef({ kind: "order", id: t.subscription_id!, name: refOrder?.plan_name })}>{t.subscription_id}</button></strong></div>}</section>
|
|
|
|
|
- </div>
|
|
|
|
|
- </aside></div>
|
|
|
|
|
- <footer className="work-order-record-footer"><Button variant="outline" onClick={detail.reload}><RefreshCcw size={16} />刷新</Button><Button variant="outline" onClick={goBack}><ArrowLeft size={16} />返回列表</Button></footer>
|
|
|
|
|
|
|
+ </aside>
|
|
|
|
|
+ </div>
|
|
|
{/* 窄屏(≤900px)底部固定条:主按钮与返回不随正文滚走。桌面隐藏,见 CSS。 */}
|
|
{/* 窄屏(≤900px)底部固定条:主按钮与返回不随正文滚走。桌面隐藏,见 CSS。 */}
|
|
|
{nextStep && !viewerReadOnly && <div className="work-order-sticky-bar"><Button variant="outline" onClick={goBack}><ArrowLeft size={16} />返回</Button><Button className="work-order-sticky-next" onClick={runNextStep}><ArrowRight size={16} />{nextStep.label}</Button></div>}
|
|
{nextStep && !viewerReadOnly && <div className="work-order-sticky-bar"><Button variant="outline" onClick={goBack}><ArrowLeft size={16} />返回</Button><Button className="work-order-sticky-next" onClick={runNextStep}><ArrowRight size={16} />{nextStep.label}</Button></div>}
|
|
|
|
|
+ {materialOpen && <Sheet title="补充过程材料" subtitle="现场照片、处理截图等过程留痕" onClose={() => setMaterialOpen(false)}><MaterialForm ticketId={t.ticket_id} onDone={(m) => { setMaterialOpen(false); setNotice(m); detail.reload(); }} /></Sheet>}
|
|
|
{sheet && <ActionSheet action={sheet} detail={d} focus={sheetFocus} onReload={detail.reload} onClose={() => { setSheet(null); setSheetFocus(undefined); }} onDone={(message) => { setSheet(null); setSheetFocus(undefined); setNotice(message); detail.reload(); }} />}
|
|
{sheet && <ActionSheet action={sheet} detail={d} focus={sheetFocus} onReload={detail.reload} onClose={() => { setSheet(null); setSheetFocus(undefined); }} onDone={(message) => { setSheet(null); setSheetFocus(undefined); setNotice(message); detail.reload(); }} />}
|
|
|
{refStack.length > 0 && <ReferenceDrawer stack={refStack} onPush={openRef} onBack={() => setRefStack((stack) => stack.slice(0, -1))} onClose={() => setRefStack([])} />}
|
|
{refStack.length > 0 && <ReferenceDrawer stack={refStack} onPush={openRef} onBack={() => setRefStack((stack) => stack.slice(0, -1))} onClose={() => setRefStack([])} />}
|
|
|
</section>;
|
|
</section>;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 材料登记(`material_grant` → 直传 → `material_attach`)。
|
|
|
|
|
|
|
+ * 补充过程材料(`material_grant` → 直传 → `material_attach`)。
|
|
|
|
|
+ *
|
|
|
|
|
+ * 类别**固定** `construct_material`:其余四类各有唯一产出方(回填/竣工/开通准备/建单)
|
|
|
|
|
+ * 且在各自的业务事务内登记,⛔ 从这个表单开可选入口——放开选择等于给它们开第二条写入路径
|
|
|
|
|
+ * (后端 `SERVER_ONLY_KINDS` 会拒)。
|
|
|
*
|
|
*
|
|
|
- * 直传需平台 OSS 签名,浏览器不持有凭证 ⇒ 这里只负责「申请凭证」与「登记已直传对象」,
|
|
|
|
|
- * ⛔ 伪造上传成功。
|
|
|
|
|
|
|
+ * 键由服务端派生(工单§5.8.1 的封闭前缀集),浏览器只负责把文件直传到那把键上,
|
|
|
|
|
+ * ⛔ 自造键、⛔ 伪造上传成功。
|
|
|
*/
|
|
*/
|
|
|
function MaterialForm({ ticketId, onDone }: { ticketId: string; onDone: (m: string) => void }) {
|
|
function MaterialForm({ ticketId, onDone }: { ticketId: string; onDone: (m: string) => void }) {
|
|
|
const submit = useSubmit();
|
|
const submit = useSubmit();
|
|
|
- const [kind, setKind] = useState("report");
|
|
|
|
|
|
|
+ const [file, setFile] = useState<File | null>(null);
|
|
|
const [fileName, setFileName] = useState("");
|
|
const [fileName, setFileName] = useState("");
|
|
|
- const [ossKey, setOssKey] = useState("");
|
|
|
|
|
- const [grant, setGrant] = useState("");
|
|
|
|
|
const [tip, setTip] = useState("");
|
|
const [tip, setTip] = useState("");
|
|
|
|
|
|
|
|
- async function applyGrant() {
|
|
|
|
|
- setTip(""); setGrant("");
|
|
|
|
|
- const ok = await submit.run(() => ticketMaterialGrant({ ticket_id: ticketId, kind, file_name: fileName.trim() || undefined }).then((g) => {
|
|
|
|
|
- setGrant(`endpoint=${g.presign_endpoint}\nbucket=${g.bucket}\nprefix=${g.prefix}\noss_key=${g.oss_key}\n上限=${g.next_step}`);
|
|
|
|
|
- setOssKey(g.oss_key);
|
|
|
|
|
- }));
|
|
|
|
|
- if (!ok) setTip(submit.error?.message ?? "申请凭证失败");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- async function attach(e: FormEvent<HTMLFormElement>) {
|
|
|
|
|
|
|
+ async function upload(e: FormEvent<HTMLFormElement>) {
|
|
|
e.preventDefault();
|
|
e.preventDefault();
|
|
|
setTip("");
|
|
setTip("");
|
|
|
- if (!ossKey.trim()) { setTip("请先申请直传凭证,或填入已直传对象的 oss_key。"); return; }
|
|
|
|
|
- const ok = await submit.run(() => ticketMaterialAttach({ ticket_id: ticketId, kind, oss_key: ossKey.trim(), file_name: fileName.trim() || undefined }).then(() => onDone("材料已登记。")));
|
|
|
|
|
- if (!ok) setTip(submit.error?.message ?? "登记失败");
|
|
|
|
|
|
|
+ const name = (fileName.trim() || file?.name || "").trim();
|
|
|
|
|
+ if (!file) { setTip("请选择要上传的文件。"); return; }
|
|
|
|
|
+ if (!name) { setTip("请填写文件名。"); return; }
|
|
|
|
|
+ const ok = await submit.run(async () => {
|
|
|
|
|
+ // ① 服务端派生本单本类别的前缀与对象键
|
|
|
|
|
+ const g = await ticketMaterialGrant({
|
|
|
|
|
+ ticket_id: ticketId, kind: MANUAL_MATERIAL_KIND, file_name: name, purpose: "upload",
|
|
|
|
|
+ });
|
|
|
|
|
+ if (g.purpose !== "upload") throw new Error("材料凭证通道返回值异常(期望上传凭证)");
|
|
|
|
|
+ // ② 浏览器直传平台桶(键=服务端刚派生的那把,⛔ 自拼)
|
|
|
|
|
+ await uploadTicketMaterial(file, g.oss_key);
|
|
|
|
|
+ // ③ 登记(attach 会复核键是否命中本单该类别的前缀)
|
|
|
|
|
+ await ticketMaterialAttach({
|
|
|
|
|
+ ticket_id: ticketId, kind: MANUAL_MATERIAL_KIND, oss_key: g.oss_key,
|
|
|
|
|
+ file_name: name, size_bytes: file.size,
|
|
|
|
|
+ });
|
|
|
|
|
+ onDone("过程材料已上传并登记。");
|
|
|
|
|
+ });
|
|
|
|
|
+ if (!ok) setTip(submit.error?.message ?? "上传失败");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return <form className="work-order-process-form" onSubmit={attach}>
|
|
|
|
|
|
|
+ return <form className="work-order-process-form" onSubmit={upload}>
|
|
|
<div className="work-order-form-grid">
|
|
<div className="work-order-form-grid">
|
|
|
- <label>材料类型<select value={kind} onChange={(e) => setKind(e.target.value)}><option value="report">故障报告</option><option value="recording">通话录音</option><option value="image">现场图片</option><option value="file">其他附件</option></select></label>
|
|
|
|
|
- <label>文件名<Input maxLength={200} value={fileName} onChange={(e) => setFileName(e.target.value)} /></label>
|
|
|
|
|
- <label className="wide">直传对象 oss_key<Input maxLength={300} placeholder="申请凭证后自动填入,可手工改成已直传对象" value={ossKey} onChange={(e) => setOssKey(e.target.value)} /></label>
|
|
|
|
|
|
|
+ <label>文件<input type="file" onChange={(e) => { const f = e.target.files?.[0] ?? null; setFile(f); if (f) setFileName(f.name); }} /></label>
|
|
|
|
|
+ <label>展示文件名<Input maxLength={200} value={fileName} onChange={(e) => setFileName(e.target.value)} placeholder="默认取所选文件名" /></label>
|
|
|
</div>
|
|
</div>
|
|
|
- {grant && <pre className="work-order-detail-text work-order-grant-box">{grant}</pre>}
|
|
|
|
|
{tip && <p className="work-order-form-error" role="alert">{tip}</p>}
|
|
{tip && <p className="work-order-form-error" role="alert">{tip}</p>}
|
|
|
<div className="work-order-inbox-actions">
|
|
<div className="work-order-inbox-actions">
|
|
|
- <Button variant="outline" size="sm" type="button" disabled={submit.busy} onClick={() => void applyGrant()}><FolderOpen size={15} />申请直传凭证</Button>
|
|
|
|
|
- <Button size="sm" type="submit" disabled={submit.busy}><Link2 size={15} />登记材料</Button>
|
|
|
|
|
|
|
+ <Button size="sm" type="submit" disabled={submit.busy}><Link2 size={15} />上传并登记</Button>
|
|
|
</div>
|
|
</div>
|
|
|
- <p className="work-order-detail-footnote"><Info size={15} />直传由平台签名网关完成,此处仅申请凭证并登记对象;不在此模拟上传结果。</p>
|
|
|
|
|
|
|
+ <p className="work-order-detail-footnote"><Info size={15} />回填凭证与竣工 PDF 由回填/竣工动作自动生成,无需在此上传;单件上限与格式随平台桶策略。</p>
|
|
|
</form>;
|
|
</form>;
|
|
|
}
|
|
}
|