|
@@ -1,7 +1,7 @@
|
|
|
import { Fragment, 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, ChevronDown, CircleAlert, FolderOpen,
|
|
ArrowLeft, ArrowRight, Check, ChevronDown, CircleAlert, FolderOpen,
|
|
|
- Info, Link2, Plus, RefreshCcw, ShieldAlert, TriangleAlert, X,
|
|
|
|
|
|
|
+ Info, Link2, Plus, RefreshCcw, ShieldAlert, Ticket, 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";
|
|
@@ -20,6 +20,7 @@ import { ScanFieldButton } from "../components/work-order/ScanFieldButton";
|
|
|
import { EvidencePhotoField, type EvidencePhoto } from "../components/work-order/EvidencePhotoField";
|
|
import { EvidencePhotoField, type EvidencePhoto } from "../components/work-order/EvidencePhotoField";
|
|
|
import { ApprovedExitSelect, alignApprovedExit } from "../components/work-order/ApprovedExitSelect";
|
|
import { ApprovedExitSelect, alignApprovedExit } from "../components/work-order/ApprovedExitSelect";
|
|
|
import { OpsNotice } from "../components/OperationsKit";
|
|
import { OpsNotice } from "../components/OperationsKit";
|
|
|
|
|
+import { RecordTabs } from "../components/RecordTabs";
|
|
|
import {
|
|
import {
|
|
|
completionGenerate, completionReceipt, completionReject, isYes, messageConfirmConflict, ticketAssign, ticketBackfill,
|
|
completionGenerate, completionReceipt, completionReject, isYes, messageConfirmConflict, ticketAssign, ticketBackfill,
|
|
|
ticketBackfillDraft,
|
|
ticketBackfillDraft,
|
|
@@ -1064,7 +1065,16 @@ export function TicketActionSheet({ action, detail, onClose, onDone, focus, onRe
|
|
|
/** @deprecated 内部别名:详情页仍用 ActionSheet 名,导出名见 TicketActionSheet。 */
|
|
/** @deprecated 内部别名:详情页仍用 ActionSheet 名,导出名见 TicketActionSheet。 */
|
|
|
const ActionSheet = TicketActionSheet;
|
|
const ActionSheet = TicketActionSheet;
|
|
|
|
|
|
|
|
-/** 工单详情(真接口:`/ticket/detail@v1` + 11 动作位)。 */
|
|
|
|
|
|
|
+const WORK_ORDER_RECORD_TABS = [
|
|
|
|
|
+ { id: "overview", label: "工单概况" },
|
|
|
|
|
+ { id: "guide", label: "施工指导" },
|
|
|
|
|
+ { id: "delivery", label: "交付与回执" },
|
|
|
|
|
+ { id: "references", label: "关联资料" },
|
|
|
|
|
+] as const;
|
|
|
|
|
+
|
|
|
|
|
+type WorkOrderRecordTab = (typeof WORK_ORDER_RECORD_TABS)[number]["id"];
|
|
|
|
|
+
|
|
|
|
|
+/** 工单详情(`/ticket/detail@v1`)。 */
|
|
|
export function WorkOrderRecordPage() {
|
|
export function WorkOrderRecordPage() {
|
|
|
const { id } = useParams();
|
|
const { id } = useParams();
|
|
|
const navigate = useNavigate();
|
|
const navigate = useNavigate();
|
|
@@ -1076,6 +1086,7 @@ 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("");
|
|
|
|
|
+ const [selectedTab, setSelectedTab] = useState<{ ticketId: string; tab: WorkOrderRecordTab } | null>(null);
|
|
|
/** 材料登记改为抽屉(原型 v3):常驻表单会把过程材料卡撑到 300px,抽屉里填完即走。 */
|
|
/** 材料登记改为抽屉(原型 v3):常驻表单会把过程材料卡撑到 300px,抽屉里填完即走。 */
|
|
|
const [materialOpen, setMaterialOpen] = useState(false);
|
|
const [materialOpen, setMaterialOpen] = useState(false);
|
|
|
/** 右栏参考卡的弹窗栈:客户档案 → 名下订阅 → …,栈顶即当前抽屉内容。 */
|
|
/** 右栏参考卡的弹窗栈:客户档案 → 名下订阅 → …,栈顶即当前抽屉内容。 */
|
|
@@ -1161,6 +1172,10 @@ export function WorkOrderRecordPage() {
|
|
|
|
|
|
|
|
const t = d.ticket;
|
|
const t = d.ticket;
|
|
|
const can = d.actions;
|
|
const can = d.actions;
|
|
|
|
|
+ const tabs = WORK_ORDER_RECORD_TABS.filter(({ id: tab }) => tab !== "guide" || d.construction_guide);
|
|
|
|
|
+ const activeTab = selectedTab?.ticketId === id && tabs.some(({ id: tab }) => tab === selectedTab.tab)
|
|
|
|
|
+ ? selectedTab.tab
|
|
|
|
|
+ : "overview";
|
|
|
/**
|
|
/**
|
|
|
* 流转阶段条:阶段派生收在 `lib/work-order-steps.ts`(纯函数,有测试兜)。
|
|
* 流转阶段条:阶段派生收在 `lib/work-order-steps.ts`(纯函数,有测试兜)。
|
|
|
* 这里只负责把状态与类型喂进去,⛔ 在 JSX 里再手写一遍「哪段正在发生」。
|
|
* 这里只负责把状态与类型喂进去,⛔ 在 JSX 里再手写一遍「哪段正在发生」。
|
|
@@ -1373,11 +1388,9 @@ export function WorkOrderRecordPage() {
|
|
|
const backfillMaterials = [...byKind("backfill_evidence"), ...byKind(MANUAL_MATERIAL_KIND)];
|
|
const backfillMaterials = [...byKind("backfill_evidence"), ...byKind(MANUAL_MATERIAL_KIND)];
|
|
|
const completionMaterials = byKind("completion_pdf");
|
|
const completionMaterials = byKind("completion_pdf");
|
|
|
/** 非主线单(故障/售后)没有回填段 ⇒ 过程材料单独成段,否则这些单上看不到任何材料。 */
|
|
/** 非主线单(故障/售后)没有回填段 ⇒ 过程材料单独成段,否则这些单上看不到任何材料。 */
|
|
|
- const hasBackfillSeg = !!(d.backfill || can.backfill);
|
|
|
|
|
|
|
+ const hasBackfillSeg = Boolean(d.backfill?.backfill_id || can.backfill || d.backfill?.ext);
|
|
|
/** 客户视角不放置下载入口:后端 `material_grant` 对客户身份只放行 `submit_evidence`。 */
|
|
/** 客户视角不放置下载入口:后端 `material_grant` 对客户身份只放行 `submit_evidence`。 */
|
|
|
const canDownloadMaterial = !clientView;
|
|
const canDownloadMaterial = !clientView;
|
|
|
- /** 「交付事实」里实际渲染了几段(段有数据或本单还能补时才计数,空段不占位)。 */
|
|
|
|
|
- const factsCount = [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 receiptState = d.completion
|
|
const receiptState = d.completion
|
|
|
? d.completion.receipt_at && d.completion.receipt_valid !== "0" ? { text: "回执已确认", tone: "ok" as const }
|
|
? d.completion.receipt_at && d.completion.receipt_valid !== "0" ? { text: "回执已确认", tone: "ok" as const }
|
|
|
: d.completion.receipt_at ? { text: "回执已失效", tone: "warn" as const }
|
|
: d.completion.receipt_at ? { text: "回执已失效", tone: "warn" as const }
|
|
@@ -1391,14 +1404,18 @@ export function WorkOrderRecordPage() {
|
|
|
return <section className={`ops-record-page${clientView ? " customer-record-view" : ""}`}>
|
|
return <section className={`ops-record-page${clientView ? " customer-record-view" : ""}`}>
|
|
|
<Button className="ops-record-back" variant="ghost" size="sm" onClick={goBack}><ArrowLeft size={16} />{back.label}</Button>
|
|
<Button className="ops-record-back" variant="ghost" size="sm" onClick={goBack}><ArrowLeft size={16} />{back.label}</Button>
|
|
|
{notice && <OpsNotice message={notice} onClose={() => setNotice("")} />}
|
|
{notice && <OpsNotice message={notice} onClose={() => setNotice("")} />}
|
|
|
- {/* 页首一卡收口:工单号+类型+状态、唯一主 CTA、元信息与细进度条。
|
|
|
|
|
- 原「指标条」5 格并进这一行,状态只出现一次;其余动作收进「更多操作」。 */}
|
|
|
|
|
<header className="work-order-head">
|
|
<header className="work-order-head">
|
|
|
<div className="work-order-head-top">
|
|
<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} type={t.ticket_type} />
|
|
|
|
|
|
|
+ <div className="work-order-head-main">
|
|
|
|
|
+ <div className="work-order-head-icon" aria-hidden="true"><Ticket size={25} /></div>
|
|
|
|
|
+ <div className="work-order-head-copy">
|
|
|
|
|
+ <span className="work-order-head-no">{t.ticket_no}</span>
|
|
|
|
|
+ <h1 className="work-order-head-title">{t.title}</h1>
|
|
|
|
|
+ <div className="work-order-head-tags">
|
|
|
|
|
+ <TypeTag type={t.ticket_type} />
|
|
|
|
|
+ <StatusTag status={t.status} type={t.ticket_type} />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
<div className="work-order-head-actions">
|
|
<div className="work-order-head-actions">
|
|
|
{nextStep && !viewerReadOnly && <Button onClick={runNextStep}>{nextStep.label}<ArrowRight size={16} /></Button>}
|
|
{nextStep && !viewerReadOnly && <Button onClick={runNextStep}>{nextStep.label}<ArrowRight size={16} /></Button>}
|
|
@@ -1417,7 +1434,6 @@ export function WorkOrderRecordPage() {
|
|
|
</details>}
|
|
</details>}
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
- <h1 className="work-order-head-title">{t.title}</h1>
|
|
|
|
|
<div className="work-order-head-meta">
|
|
<div className="work-order-head-meta">
|
|
|
<span>客户 <b>{refCustomer?.customer_name ?? "—"}</b></span><i>·</i>
|
|
<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.assignee_name ?? t.assignee_snapshot_name ?? "待分派"}</b></span><i>·</i>
|
|
@@ -1439,29 +1455,30 @@ export function WorkOrderRecordPage() {
|
|
|
<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>
|
|
<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>
|
|
</header>
|
|
|
{todoNodes.length > 0 && <div className="work-order-todo">{todoNodes}</div>}
|
|
{todoNodes.length > 0 && <div className="work-order-todo">{todoNodes}</div>}
|
|
|
- <div className="work-order-layout"><div className="work-order-sections">
|
|
|
|
|
- {/* 工单内容=正文主角:一句话内容 + 来源/外部单号/关联订阅;客户档案收到页尾参考区。 */}
|
|
|
|
|
- <section className="work-order-section work-order-section-lead">
|
|
|
|
|
- <p className="work-order-ticket-lead">{t.detail || "建单时未填写详细描述。"}</p>
|
|
|
|
|
|
|
+ <div className="work-order-layout"><div className="record-tabs-frame work-order-tabs-frame">
|
|
|
|
|
+ <RecordTabs prefix="work-order" label="工单详情视图" tabs={tabs} active={activeTab}
|
|
|
|
|
+ onChange={(tab) => setSelectedTab({ ticketId: id, tab })} />
|
|
|
|
|
+ <section className="record-tab-panel work-order-record-panel work-order-overview-panel" id="work-order-panel-overview"
|
|
|
|
|
+ role="tabpanel" aria-labelledby="work-order-tab-overview" hidden={activeTab !== "overview"} tabIndex={0}>
|
|
|
|
|
+ <p className="work-order-ticket-lead" data-empty={!t.detail || undefined}>{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.carrier_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>
|
|
<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.carrier_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`),就放在建单来源这一屏。 */}
|
|
{/* 客户建单时上传的图片/语音随建单同事务登记(`submit_evidence`),就放在建单来源这一屏。 */}
|
|
|
- {submitMaterials.length > 0 && <>
|
|
|
|
|
|
|
+ {submitMaterials.length > 0 && <div className="work-order-submit-materials">
|
|
|
<h4 className="work-order-subhead">客户提交材料</h4>
|
|
<h4 className="work-order-subhead">客户提交材料</h4>
|
|
|
<MaterialList ticketId={t.ticket_id} items={submitMaterials} empty="无" allowDownload={canDownloadMaterial} />
|
|
<MaterialList ticketId={t.ticket_id} items={submitMaterials} empty="无" allowDownload={canDownloadMaterial} />
|
|
|
- </>}
|
|
|
|
|
|
|
+ </div>}
|
|
|
</section>
|
|
</section>
|
|
|
|
|
|
|
|
{d.construction_guide && (
|
|
{d.construction_guide && (
|
|
|
- <section className="work-order-section">
|
|
|
|
|
|
|
+ <section className="record-tab-panel work-order-record-panel" id="work-order-panel-guide"
|
|
|
|
|
+ role="tabpanel" aria-labelledby="work-order-tab-guide" hidden={activeTab !== "guide"} tabIndex={0}>
|
|
|
<ConstructionGuidePanel guide={d.construction_guide} />
|
|
<ConstructionGuidePanel guide={d.construction_guide} />
|
|
|
</section>
|
|
</section>
|
|
|
)}
|
|
)}
|
|
|
|
|
|
|
|
- {/* 交付事实:按段折叠。段头摘要行给关键数字(结论/日期/条数),折叠也不丢信息;
|
|
|
|
|
- 只有与本单状态相关的一段默认展开,其余收起,避免六张明细表把正文拉成几屏长。 */}
|
|
|
|
|
- <section className="work-order-section work-order-facts">
|
|
|
|
|
- <header className="work-order-facts-head"><h2>交付事实</h2><span>{factsCount} 段 · 默认只展开与本单状态相关的一段</span></header>
|
|
|
|
|
- {(d.backfill?.backfill_id || can.backfill || d.backfill?.ext) && <FactSeg title="施工回填" open={openSeg === "backfill"}
|
|
|
|
|
|
|
+ <section className="record-tab-panel work-order-record-panel work-order-facts" id="work-order-panel-delivery"
|
|
|
|
|
+ role="tabpanel" aria-labelledby="work-order-tab-delivery" hidden={activeTab !== "delivery"} tabIndex={0}>
|
|
|
|
|
+ {hasBackfillSeg && <FactSeg title="施工回填" open={openSeg === "backfill"}
|
|
|
summary={d.backfill?.backfill_id ? `${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 ?? 0} 条 / 境外 IP ${d.backfill.ips?.length ?? 0} 条` : "尚未回填 · 缺 线路与路由、执行结论与凭证"}
|
|
summary={d.backfill?.backfill_id ? `${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 ?? 0} 条 / 境外 IP ${d.backfill.ips?.length ?? 0} 条` : "尚未回填 · 缺 线路与路由、执行结论与凭证"}
|
|
|
badge={d.backfill?.backfill_id ? "已回填" : "待回填"} tone={d.backfill?.backfill_id ? "ok" : "warn"}>
|
|
badge={d.backfill?.backfill_id ? "已回填" : "待回填"} tone={d.backfill?.backfill_id ? "ok" : "warn"}>
|
|
|
{d.backfill?.backfill_id ? <>
|
|
{d.backfill?.backfill_id ? <>
|
|
@@ -1533,9 +1550,9 @@ export function WorkOrderRecordPage() {
|
|
|
</FactSeg>}
|
|
</FactSeg>}
|
|
|
</section>
|
|
</section>
|
|
|
|
|
|
|
|
- {/* 参考信息移到正文底部:宽度由主列决定,与上方卡片天然对齐;右栏腾给「处理记录」专席。 */}
|
|
|
|
|
- <div className="work-order-refs">
|
|
|
|
|
- <section className="work-order-section">
|
|
|
|
|
|
|
+ <div className="record-tab-panel work-order-record-panel work-order-refs" id="work-order-panel-references"
|
|
|
|
|
+ role="tabpanel" aria-labelledby="work-order-tab-references" hidden={activeTab !== "references"} tabIndex={0}>
|
|
|
|
|
+ <section className="work-order-reference-group">
|
|
|
<h2>客户与订阅</h2>
|
|
<h2>客户与订阅</h2>
|
|
|
{refCustomer ? <>
|
|
{refCustomer ? <>
|
|
|
<div className="work-order-trace"><span>客户名称</span><strong>{refCustomer.customer_name
|
|
<div className="work-order-trace"><span>客户名称</span><strong>{refCustomer.customer_name
|
|
@@ -1562,7 +1579,7 @@ export function WorkOrderRecordPage() {
|
|
|
{/* P1(D-2/D-7):并单成员订阅**平铺**列出,附加成员只标「叠加于 SUB-xxx」,⛔ 折叠成树。 */}
|
|
{/* P1(D-2/D-7):并单成员订阅**平铺**列出,附加成员只标「叠加于 SUB-xxx」,⛔ 折叠成树。 */}
|
|
|
{(d.subscriptions ?? []).length > 0 && <div className="work-order-trace"><span>并单成员订阅({(d.subscriptions ?? []).length})</span><div className="work-order-member-list">{(d.subscriptions ?? []).map((member) => <div key={member.subscription_id} className="work-order-member-row"><button type="button" className="work-order-trace-link" onClick={() => openRef({ kind: "order", id: member.subscription_id, name: member.plan_name ?? null })}>{member.plan_name ?? member.subscription_id}</button><small>{member.subscription_id}{member.plan_family ? ` · ${label(PLAN_FAMILY, member.plan_family)}` : ""}{member.status ? ` · ${label(ORDER_STATUS, member.status)}` : ""}</small>{member.parent_subscription_id && <small className="order-parent-mark">叠加于 {member.parent_subscription_id}</small>}</div>)}</div></div>}
|
|
{(d.subscriptions ?? []).length > 0 && <div className="work-order-trace"><span>并单成员订阅({(d.subscriptions ?? []).length})</span><div className="work-order-member-list">{(d.subscriptions ?? []).map((member) => <div key={member.subscription_id} className="work-order-member-row"><button type="button" className="work-order-trace-link" onClick={() => openRef({ kind: "order", id: member.subscription_id, name: member.plan_name ?? null })}>{member.plan_name ?? member.subscription_id}</button><small>{member.subscription_id}{member.plan_family ? ` · ${label(PLAN_FAMILY, member.plan_family)}` : ""}{member.status ? ` · ${label(ORDER_STATUS, member.status)}` : ""}</small>{member.parent_subscription_id && <small className="order-parent-mark">叠加于 {member.parent_subscription_id}</small>}</div>)}</div></div>}
|
|
|
</section>
|
|
</section>
|
|
|
- <section className="work-order-section">
|
|
|
|
|
|
|
+ <section className="work-order-reference-group">
|
|
|
<h2>追溯与关联</h2>
|
|
<h2>追溯与关联</h2>
|
|
|
{t.ticket_type === "renewal" && (t.renew_from_contract_id || t.renew_from_contract_no) && (
|
|
{t.ticket_type === "renewal" && (t.renew_from_contract_id || t.renew_from_contract_no) && (
|
|
|
<div className="work-order-trace"><span>续签来源合同</span><strong>{t.renew_from_contract_no ?? t.renew_from_contract_id}</strong>
|
|
<div className="work-order-trace"><span>续签来源合同</span><strong>{t.renew_from_contract_no ?? t.renew_from_contract_id}</strong>
|