CustomerWorkspacePage.tsx 67 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898
  1. /**
  2. * 客户档案(工作台)—— 真源=klt-bos 接口,⛔ localStorage 与演示行。
  3. *
  4. * 读:`POST /customer/get@v1`(主体资料与归属)+ `POST /account/get_list@v1`(客户主账号与激活码
  5. *  生命周期)+ `POST /sub_account/get_list@v1`(分账号)+ `POST /customer/history@v1`(变更记录);
  6. *  区域名经 `/region/tree@v1`(`lib/organization-demo`)解析。
  7. * 写:`POST /customer/attribution_update@v1`(运营商/合伙人)+ `POST /customer/move_region@v1`(挂载区域,
  8. *  可带 `ops_team_ids`)+ `POST /customer/update@v1`(仅改运维团队时)+ `POST /sub_account/update@v1`。
  9. *
  10. * 后端边界(页面如实呈现,⛔ 造数填补):
  11. * * 激活码明文⛔ 读路由(仅开通/重置当次回执一次性下发)⇒ 主账号面板只回显激活码生命周期,
  12. *   明文只在「重置激活码」当次回显一次(手册 P2:激活码过期或遗失由运营在本页重置);
  13. * * `/sub_account/*` ⛔ 新增与删除路由 ⇒ 分账号只可改名与网络侧账号名;
  14. * * ⛔ `/customer/acct_status/update@v1` 封装 ⇒ 停用/恢复入口置灰;
  15. * * 登记材料(营业执照影像):读口一次给全 `license{file_name, status, view_url, view_url_expires_at}`;
  16. *  补传/替换由浏览器直传平台 `unified-oss` 后调 `POST /customer/update@v1` 回报对象键(⛔ 经本系统传字节);
  17. * * ⛔ 合同文档上传路由 ⇒ 合同文档区只给应备项说明。
  18. */
  19. import { useEffect, useMemo, useRef, useState, type FormEvent, type KeyboardEvent as ReactKeyboardEvent, type ReactNode } from "react";
  20. import { ArrowLeft, Building2, CalendarPlus, Check, FileSignature, FileText, Gauge, LoaderCircle, MapPin, PencilLine, RefreshCcw, RefreshCw, ScrollText, Upload, UsersRound, Wrench, X } from "lucide-react";
  21. import { Link, useLocation, useParams } from "react-router";
  22. import { Button } from "../components/ui/button";
  23. import { Input } from "../components/ui/input";
  24. import { OpsMore, OpsNotice, OpsStatus, OpsTableColumns, OpsTableEmpty, OpsTag, type OpsMoreItem } from "../components/OperationsKit";
  25. import { OrderEditor } from "../components/OrderChangeDialogs";
  26. import { CustomerServiceStopAction } from "../components/CustomerServiceStopAction";
  27. import { DeliveryStatusTable } from "../components/DeliveryStatusTable";
  28. import { RecordTabs } from "../components/RecordTabs";
  29. import { ListPager } from "../components/ListPager";
  30. import { orderView, type OrderView } from "../lib/order-demo";
  31. import { FetchError } from "../components/fetchError";
  32. import { Tri } from "../components/triState";
  33. import { TreeSelect } from "../components/ui/tree-select";
  34. import { CustomerTeamSelect } from "../components/CustomerTeamSelect";
  35. import { ACCT_STATUS, ACTIVATION_STATUS, PLAN_KIND, SUBJECT_TYPE, label } from "../lib/api/labels";
  36. import { typeLabel } from "../lib/api/ticket";
  37. import type { ApiError } from "../lib/api/http";
  38. import { accountGetList, accountResetCode, customerAttributionUpdate, customerGet, customerHistory, customerMoveRegion, customerUpdate, subAccountGetList, subAccountUpdate, orderGetList, contractGetList } from "../lib/api/bos";
  39. import { uploadCustomerLicense } from "../lib/api/oss-upload";
  40. import { contractAttachmentLabel } from "../lib/contract-attachments";
  41. import { invalidateCustomerList } from "../lib/customer-list-store";
  42. import type { SubAccountRow } from "../lib/api/types";
  43. import { isSeatPlaceholder, seatDisplayName } from "../lib/customer-subaccounts";
  44. import { useLoad } from "../lib/useLoad";
  45. import { LIST_PAGE_SIZE, clampPage } from "../lib/list-paging";
  46. import { regionComparablePath, regionMountPath, useOrganizationData } from "../lib/organization-demo";
  47. import { lockIfCandidate, operationsTeamDisplay, regionAncestorChain, teamsCoveringRegion } from "../lib/region-ownership";
  48. import { regionTreeNodes } from "../lib/region-tree";
  49. import { isImeComposing } from "../lib/ime";
  50. import { customerMaterials } from "../lib/customer-records";
  51. import { detailBack, detailLinkState } from "../lib/detail-navigation";
  52. import { useBusinessView } from "../lib/use-business-view";
  53. import "../styles/operations.css";
  54. import "../styles/customer-onboarding.css";
  55. const MISSING = "后端未下发";
  56. /**
  57. * 客户工作台的页签(讨论稿 §7.7:01–07 七个区块全部改为页签,并新增「交付现状」)。
  58. * `#workspace-service` 锚点落在「全部订阅」页签上(保留旧链接的落点)。
  59. */
  60. type WorkspaceTab = "profile" | "attribution" | "primary" | "subscriptions" | "subaccounts" | "materials" | "history" | "delivery";
  61. const WORKSPACE_TABS: { id: WorkspaceTab; label: string }[] = [
  62. { id: "profile", label: "主体资料" },
  63. { id: "attribution", label: "归属关系" },
  64. { id: "primary", label: "客户主账号" },
  65. { id: "subscriptions", label: "全部订阅" },
  66. { id: "subaccounts", label: "分账号" },
  67. { id: "materials", label: "登记材料与合同文档" },
  68. { id: "history", label: "历史记录" },
  69. { id: "delivery", label: "交付现状" },
  70. ];
  71. /** 客户建档/更正只收这三个主体码(后端 `60004` 会拦下主体类型字典里的其余历史码)。 */
  72. const CUSTOMER_SUBJECT_CODES = ["enterprise", "individual", "sole_proprietor"] as const;
  73. const NO_ACCOUNT_FOUND = "未查到该客户的主账号记录:可能尚未开通,或该账号不在当前登录账号的可见范围(/account/get_list@v1 按 subject_id 查询为空)";
  74. const CONTRACT_DOC_NOTE = "合同文档随合同登记上传(合同详情 → 附件),本页只读汇总";
  75. const NO_ACTIVATION_CODE_READ = "激活码仅在后端开通/重置写口回执中一次性下发,读完即失效 ⇒ 无读路由,不回显明文";
  76. const CODE_RESET_ONCE_NOTE = "新激活码明文只随本次应答回显一次,请立即分发或安全保存;关闭后无法再查。";
  77. const CODE_RESET_ACTIVATED_NOTE = "该账号已激活:不可重置激活码(手册 P2「要知道的」)⇒ 换人接手请走客户自助改密或运营换绑手机号";
  78. /** 订阅表仍按中文状态上色(订阅域由 `lib/order-store` 下发,⛔ 在本页改写状态文案)。 */
  79. const statusTone = (status: string) => status === "在用" || status === "生效中" ? "success" : status === "停用" || status === "提前停机" ? "danger" : "neutral";
  80. const money = (value: string) => `¥${Number(value).toLocaleString("zh-CN", { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
  81. /** 账号状态色调只看后端原值,中文一律取自 `labels.ACCT_STATUS`。 */
  82. const acctTone = (raw: string) => raw === "stopped" || raw === "disabled" ? "danger" : raw === "active" || raw === "normal" || raw === "in_use" ? "success" : "neutral";
  83. /** 激活态色调:已激活绿、待激活/发放中黄、未发放灰。 */
  84. const activationTone = (raw: string) => raw === "activated" ? "success" : raw === "issued" || raw === "issuing" ? "warning" : "neutral";
  85. /** 缺列单元格:⛔ 用「—」「未知」或 0 冒充后端没给的列。 */
  86. function TextCell({ value, note }: { value: string | number | null | undefined; note?: string }) {
  87. const text = value === null || value === undefined ? "" : String(value).trim();
  88. return text ? <>{text}</> : <Tri tone="missing" text={MISSING} title={note ?? MISSING} />;
  89. }
  90. /** 可空资料单元格:读口已回该字段但值为空 ⇒「未登记」,⛔ 与「后端未下发」混为一谈。 */
  91. function OptionalCell({ value, note = "该字段未登记" }: { value: string | number | null | undefined; note?: string }) {
  92. const text = value === null || value === undefined ? "" : String(value).trim();
  93. return text ? <>{text}</> : <span className="ops-muted" title={note}>未登记</span>;
  94. }
  95. /** 账号状态单元格:后端未回状态 ≠ 「未开通」,两者分列。 */
  96. function AcctCell({ raw }: { raw: string | null | undefined }) {
  97. const text = raw ? label(ACCT_STATUS, raw) : "";
  98. return text ? <OpsStatus tone={acctTone(raw ?? "")}>{text}</OpsStatus> : <Tri tone="missing" text={MISSING} title={MISSING + ":acct_status"} />;
  99. }
  100. function metricCount(value: number | undefined, loading: boolean, error: ApiError | null) {
  101. if (error) return <Tri tone="fail" text="取数失败" title={error.message} />;
  102. if (loading) return <span className="customer-record-metric-loading">读取中</span>;
  103. return <TextCell value={value} />;
  104. }
  105. function CustomerMaterialCard({ children }: { children: ReactNode }) {
  106. return <div className="customer-material-card">
  107. <span className="customer-file-thumb" aria-hidden="true"><FileText size={20} /></span>
  108. <div className="customer-material-description">{children}</div>
  109. </div>;
  110. }
  111. /**
  112. * 详情里的单个可编辑项(与合同详情同一交互):非编辑态只渲染值,鼠标移入才显出铅笔;点铅笔切到输入态。
  113. * 改完点对号(或按 Enter)即提交**该项**:客户写口按字段可选,⛔ 攒到底部统一保存。
  114. */
  115. type InlineFieldProps = {
  116. id: string;
  117. label: string;
  118. value: string;
  119. editing: boolean;
  120. writable: boolean;
  121. /** 该项正在提交:锁住对号/取消,避免重复提交。 */
  122. busy?: boolean;
  123. onStart: () => void;
  124. onChange: (value: string) => void;
  125. onDone: () => void;
  126. onCancel: () => void;
  127. type?: "text" | "date" | "number";
  128. inputMode?: "decimal" | "numeric" | "text";
  129. placeholder?: string;
  130. display?: ReactNode;
  131. emptyText?: string;
  132. invalid?: boolean;
  133. error?: ReactNode;
  134. selectOptions?: readonly { value: string; label: string }[];
  135. /** 自定义编辑控件(区域树、运维团队下拉):给定时替代默认输入/下拉。 */
  136. editor?: ReactNode;
  137. };
  138. function InlineField({ id, label, value, editing, writable, busy = false, onStart, onChange, onDone, onCancel, type = "text", inputMode, placeholder, display, emptyText = MISSING, invalid, error, selectOptions, editor }: InlineFieldProps) {
  139. const shown = display ?? (value ? value : emptyText);
  140. if (!writable) return <span className="customer-inline-readonly">{shown}</span>;
  141. if (!editing) return <span className="customer-inline-field">
  142. <span className="customer-inline-value">{shown}</span>
  143. <button type="button" className="customer-inline-edit" aria-label={`编辑${label}`} title={`编辑${label}`} onClick={onStart}><PencilLine size={14} /></button>
  144. </span>;
  145. const onKeyDown = (event: ReactKeyboardEvent) => {
  146. // 输入法上屏用的 Enter/Esc ⛔ 当成「保存/取消」,否则拼音选字就被提交了。
  147. if (isImeComposing(event)) return;
  148. if (event.key === "Enter") { event.preventDefault(); onDone(); }
  149. if (event.key === "Escape") { event.preventDefault(); onCancel(); }
  150. };
  151. return <span className="customer-inline-editor">
  152. {editor ?? (selectOptions ? (
  153. <select id={id} aria-label={label} autoFocus disabled={busy} value={value} onChange={(event) => onChange(event.target.value)} onKeyDown={onKeyDown}>
  154. {selectOptions.map((option) => <option key={option.value} value={option.value}>{option.label}</option>)}
  155. </select>
  156. ) : (
  157. <Input id={id} aria-label={label} autoFocus disabled={busy} type={type} inputMode={inputMode} placeholder={placeholder} aria-invalid={invalid || undefined} value={value} onChange={(event) => onChange(event.target.value)} onKeyDown={onKeyDown} />
  158. ))}
  159. <button type="button" className="customer-inline-ok" aria-label={busy ? "正在保存" : "保存该项"} title={busy ? "正在保存…" : "保存该项(Enter)"} disabled={busy} onClick={onDone}>{busy ? <LoaderCircle aria-hidden="true" className="animate-spin" size={14} /> : <Check size={14} />}</button>
  160. <button type="button" className="customer-inline-cancel" aria-label="取消编辑" title="取消(Escape)" disabled={busy} onClick={onCancel}><X size={14} /></button>
  161. {error}
  162. </span>;
  163. }
  164. /** 客户档案的草稿:身份号只存「本次新填」的明文(读口只下脱敏值)。 */
  165. type ProfileDraft = {
  166. name: string; subject: string; idNo: string; contact: string; phone: string; address: string;
  167. regionId: string; operatorId: string; partnerId: string; teamId: string;
  168. };
  169. export function CustomerWorkspacePage() {
  170. const { no } = useParams();
  171. const location = useLocation();
  172. const outgoingState = detailLinkState(location.pathname, location.state);
  173. const organization = useOrganizationData(["regions", "operators", "partners", "operationsTeams", "maintenanceTeams"]);
  174. /** 页签=本页唯一的浏览轴(讨论稿 §7.7);`#workspace-service` 仍落在「全部订阅」。 */
  175. const [tab, setTab] = useState<WorkspaceTab>(() => (location.hash === "#workspace-service" ? "subscriptions" : "profile"));
  176. useEffect(() => {
  177. if (location.hash === "#workspace-service") setTab("subscriptions");
  178. }, [location.hash]);
  179. /** 详情侧栏列表:默认每页 20,page/page_size 下推服务端(⛔ 一次拉 200)。 */
  180. const [ordersPage, setOrdersPage] = useState(0);
  181. const [ordersPageSize, setOrdersPageSize] = useState(LIST_PAGE_SIZE);
  182. const [accountsPage, setAccountsPage] = useState(0);
  183. const [accountsPageSize, setAccountsPageSize] = useState(LIST_PAGE_SIZE);
  184. const [historyPage, setHistoryPage] = useState(0);
  185. const [historyPageSize, setHistoryPageSize] = useState(LIST_PAGE_SIZE);
  186. const [contractsPage, setContractsPage] = useState(0);
  187. const [contractsPageSize, setContractsPageSize] = useState(LIST_PAGE_SIZE);
  188. const detail = useLoad(() => (no ? customerGet({ customer_id: no }) : Promise.resolve(null)), [no]);
  189. // 主账号读口:按绑定主体直取(`subject_id`=客户号),一次取回启停态与激活码生命周期。
  190. const primaryAccountLoad = useLoad(() => (no ? accountGetList({ subject_id: no, page: 0, page_size: LIST_PAGE_SIZE }) : Promise.resolve(null)), [no]);
  191. const accounts = useLoad(
  192. () => (no ? subAccountGetList({ customer_id: no, page: accountsPage, page_size: accountsPageSize }) : Promise.resolve(null)),
  193. [no, accountsPage, accountsPageSize],
  194. );
  195. const changes = useLoad(
  196. () => (no ? customerHistory({ customer_id: no, page: historyPage, page_size: historyPageSize }) : Promise.resolve(null)),
  197. [no, historyPage, historyPageSize],
  198. );
  199. const ordersLoad = useLoad(
  200. () => (no ? orderGetList({ customer_id: no, page: ordersPage, page_size: ordersPageSize }) : Promise.resolve(null)),
  201. [no, ordersPage, ordersPageSize],
  202. );
  203. /** 页头「服务停用」:单独取 1 条生效中订阅,⛔ 依赖当前订阅页是否碰巧含生效行。 */
  204. const activeOrderProbe = useLoad(
  205. () => (no ? orderGetList({ customer_id: no, status: "active", page: 0, page_size: 1 }) : Promise.resolve(null)),
  206. [no],
  207. );
  208. const contractsLoad = useLoad(
  209. () => (no ? contractGetList({ customer_id: no, page: contractsPage, page_size: contractsPageSize }) : Promise.resolve(null)),
  210. [no, contractsPage, contractsPageSize],
  211. );
  212. const customer = detail.data?.customer ?? null;
  213. const primaryAccount = useMemo(() => {
  214. const rows = primaryAccountLoad.data?.items ?? [];
  215. // 客户主账号=role_code=enterprise 且绑定客户主体;兼容历史绑定口径时退回首行。
  216. return rows.find((row) => row.role_code === "enterprise" || row.subject_type === "customer") ?? rows[0] ?? null;
  217. }, [primaryAccountLoad.data]);
  218. /** 主账号读取失败/未查到时的统一说明(⛔ 把「无账号」当「后端未下发」)。 */
  219. const primaryAccountMissing = primaryAccountLoad.error
  220. ? MISSING + ":/account/get_list@v1 取数失败(" + primaryAccountLoad.error.message + ")"
  221. : primaryAccountLoad.loading
  222. ? "主账号信息读取中…"
  223. : NO_ACCOUNT_FOUND;
  224. const mount = detail.data?.region_mounts?.[0];
  225. const teamIds = detail.data?.team_ids ?? [];
  226. const accountRows = accounts.data?.items ?? [];
  227. const accountsTotal = Number(accounts.data?.total ?? 0);
  228. const changeRows = changes.data?.items ?? [];
  229. const historyTotal = Number(changes.data?.total ?? 0);
  230. const orders = ordersLoad.data?.items ?? [];
  231. const ordersTotal = Number(ordersLoad.data?.total ?? 0);
  232. const contracts = contractsLoad.data?.items ?? [];
  233. const contractsTotal = Number(contractsLoad.data?.total ?? 0);
  234. const safeOrdersPage = clampPage(ordersPage, ordersTotal, ordersPageSize);
  235. const safeAccountsPage = clampPage(accountsPage, accountsTotal, accountsPageSize);
  236. const safeHistoryPage = clampPage(historyPage, historyTotal, historyPageSize);
  237. const safeContractsPage = clampPage(contractsPage, contractsTotal, contractsPageSize);
  238. useEffect(() => { if (ordersPage !== safeOrdersPage) setOrdersPage(safeOrdersPage); }, [ordersPage, safeOrdersPage]);
  239. useEffect(() => { if (accountsPage !== safeAccountsPage) setAccountsPage(safeAccountsPage); }, [accountsPage, safeAccountsPage]);
  240. useEffect(() => { if (historyPage !== safeHistoryPage) setHistoryPage(safeHistoryPage); }, [historyPage, safeHistoryPage]);
  241. useEffect(() => { if (contractsPage !== safeContractsPage) setContractsPage(safeContractsPage); }, [contractsPage, safeContractsPage]);
  242. const contractFiles = contracts.flatMap((contract) =>
  243. (contract.attachment_url
  244. ? [{
  245. // 单值附件两形态(外部链接/平台桶对象键):对象键末段是随机串 ⇒ 按后缀显示,
  246. // ⛔ 把随机串当文件名糊给用户;下载地址只在合同详情读口现签。
  247. name: contractAttachmentLabel(contract.attachment_url),
  248. contractNo: contract.contract_id,
  249. kind: contract.attachment_kind ?? "other",
  250. }]
  251. : []));
  252. /**
  253. * 登记材料摘要(客户§3.5)——`status ∈ none/viewable/expired` **由后端一次给全**:
  254. * 页面⛔ 为影像另发请求、⛔ 拿对象键自拼地址(对象键不在响应体里)。
  255. * 只看主体类型决定面板形态:个人/个体工商户恒「不适用」(⛔ 渲染控件)。
  256. */
  257. const license = detail.data?.license ?? null;
  258. const licenseApplicable = customer?.subject_type === "enterprise";
  259. const customerListTitle = "客户管理";
  260. const back = detailBack(location.state, "/customers", `返回${customerListTitle}`);
  261. const view = useBusinessView([]);
  262. /** 详情即编辑:可写角色才挂铅笔;只读身份(团队长/运维等)看到的是同一页的只读态。 */
  263. const writable = !view.readOnly;
  264. /**
  265. * 草稿基线=`/customer/get@v1` 的实际值。
  266. * 识别号读口只下发脱敏值 ⇒ 草稿的 `idNo` 恒从空串起,只有用户主动填入完整新号才提交(⛔ 回填脱敏串)。
  267. */
  268. const serverBaseline = useMemo<ProfileDraft | null>(() => {
  269. if (!detail.data?.customer) return null;
  270. const c = detail.data.customer;
  271. const mounted = detail.data.region_mounts?.[0]?.parent_node_id ?? "";
  272. const teams = detail.data.team_ids ?? [];
  273. return {
  274. name: c.customer_name ?? "",
  275. subject: c.subject_type ?? "",
  276. idNo: "",
  277. contact: c.contact_name ?? "",
  278. phone: c.contact_mobile ?? "",
  279. address: c.address ?? "",
  280. regionId: mounted,
  281. operatorId: c.operator_id ?? "",
  282. partnerId: c.partner_id ?? "",
  283. teamId: teams.length === 1 ? teams[0] : "",
  284. };
  285. }, [detail.data]);
  286. const [draft, setDraft] = useState<ProfileDraft | null>(null);
  287. const [editingField, setEditingField] = useState<keyof ProfileDraft | null>(null);
  288. /**
  289. * 提交成功后的乐观基线:在 `/customer/get@v1` 重读落定前先用它,
  290. * 否则「提交已完成、基线还是旧值」会把刚保存的值再判成未提交,甚至被后台重读回退。
  291. */
  292. const [baselineOverride, setBaselineOverride] = useState<ProfileDraft | null>(null);
  293. /** 读口重读落定 ⇒ 丢弃乐观基线,回到服务端真源。 */
  294. useEffect(() => { setBaselineOverride(null); }, [serverBaseline]);
  295. const baseline = baselineOverride ?? serverBaseline;
  296. useEffect(() => {
  297. // 正在编辑时不覆盖草稿:后台重读落定可能发生在输入过程中;退出编辑后由提交/取消各自对齐。
  298. if (!editingField) setDraft(baseline);
  299. }, [baseline]);
  300. /** 显示用草稿:数据刚到、state 还没跟上时直接用基线,⛔ 先闪一帧空值。 */
  301. const form = draft ?? baseline;
  302. const [fieldError, setFieldError] = useState<{ key: keyof ProfileDraft; message: string } | null>(null);
  303. const [notice, setNotice] = useState("");
  304. /** 识别号更正依据(写口 `change_basis`,选填):只在改识别号时随该项提交,由后端留存。 */
  305. const [idBasis, setIdBasis] = useState("");
  306. const [busy, setBusy] = useState(false);
  307. /** 登记材料补传/替换:直传状态与错误(⛔ 与建档页共用 state——两页生命周期独立)。 */
  308. const [licenseBusy, setLicenseBusy] = useState(false);
  309. const [licenseError, setLicenseError] = useState("");
  310. const [editingSub, setEditingSub] = useState<SubAccountRow | null>(null);
  311. const [orderDraft, setSubDraft] = useState({ displayName: "", netAccount: "" });
  312. const [orderError, setSubError] = useState("");
  313. const orderDialogRef = useRef<HTMLDialogElement>(null);
  314. /** 升降配/叠加:本页「04 全部订阅」行内「更多」直接办理,⛔ 逼用户先跳菜单「全部订阅」页再点一次。 */
  315. const [changeTarget, setChangeTarget] = useState<OrderView | null>(null);
  316. /** D-03:叠加=打开新建订阅弹窗(create@v1),⛔ 就地改结束日。 */
  317. const [createOpen, setCreateOpen] = useState(false);
  318. /* ── 主账号激活码重置(手册 P2:激活码过期或遗失 ⇒ 运营在本页重置,新明文只回显一次) ── */
  319. const [resetBusy, setResetBusy] = useState(false);
  320. const [resetError, setResetError] = useState("");
  321. const [freshCode, setFreshCode] = useState<{ code: string; expireDate: string } | null>(null);
  322. const primaryActivated = primaryAccount?.activation_status === "activated";
  323. async function resetPrimaryCode() {
  324. const userId = primaryAccount?.user_id;
  325. if (!userId) {
  326. setResetError("后端未下发 user_id,无法调用 /account/reset_code@v1。");
  327. return;
  328. }
  329. setResetBusy(true);
  330. setResetError("");
  331. setFreshCode(null);
  332. try {
  333. const res = await accountResetCode({ user_id: userId });
  334. const code = String(res?.plaintext_once ?? "").trim();
  335. // 平台「作废+发新码」三跳未接通时后端如实回 `capability_pending`+`reason`(本地只复位状态)
  336. // ⇒ 如实将原因呈现给运营,⛔ 把「已重置」说成「已发新码」、⛔ 前端造码。
  337. if (code) setFreshCode({ code, expireDate: String((res as { expire_date?: string | null })?.expire_date ?? "").trim() });
  338. else setResetError(res?.reason
  339. ? `本地状态已复位(旧码失效、可重新走导出交付),但本次未发新码:${res.reason}`
  340. : "应答未回激活码明文(plaintext_once 为空)⇒ 本次没有可分发的新码。");
  341. primaryAccountLoad.reload();
  342. } catch (e) {
  343. setResetError((e as ApiError)?.message || "重置激活码失败");
  344. } finally {
  345. setResetBusy(false);
  346. }
  347. }
  348. useEffect(() => {
  349. const dialog = orderDialogRef.current;
  350. if (!dialog) return;
  351. if (editingSub && !dialog.open) dialog.showModal();
  352. if (!editingSub && dialog.open) dialog.close();
  353. }, [editingSub]);
  354. const regionTree = useMemo(() => regionTreeNodes(organization.regions, organization.regions.map((item) => item.id)), [organization]);
  355. const mountedRegionPath = regionMountPath(organization, mount);
  356. const teamNames = teamIds.map((id) => organization.maintenanceTeams.find((item) => item.id === id)?.name ?? id);
  357. /** 后端当期回显 2 支以上=历史脏数据(运维团队单支定案)⇒ 按实呈现并提示改派,⛔ 前端截断成一支假装正常。 */
  358. const staleTeamHint = teamIds.length > 1 ? `历史脏数据:后端当期回显 ${teamIds.length} 支运维团队,按单支定案需改派为 1 支` : "";
  359. const subjectText = customer?.subject_type ? label(SUBJECT_TYPE, customer.subject_type) : "";
  360. const customerName = customer?.customer_name ?? "";
  361. const subjectOptions = CUSTOMER_SUBJECT_CODES.map((code) => ({ value: code, label: SUBJECT_TYPE[code] ?? code }));
  362. /** 草稿态展示名:改过的归属按草稿现算,没改过沿用读口原值(⛔ 用旧名字冒充新选择)。 */
  363. const draftRegionDisplay = form && baseline && form.regionId !== baseline.regionId
  364. ? regionComparablePath(organization, form.regionId) || form.regionId
  365. : mountedRegionPath;
  366. const draftOperatorName = form
  367. ? organization.operators.find((item) => item.id === form.operatorId)?.name ?? (form.operatorId === baseline?.operatorId ? customer?.operator_name ?? "" : "")
  368. : "";
  369. const draftPartnerName = form
  370. ? organization.partners.find((item) => item.id === form.partnerId)?.name ?? (form.partnerId === baseline?.partnerId ? customer?.partner_name ?? "" : "")
  371. : "";
  372. const draftTeamName = form
  373. ? organization.maintenanceTeams.find((item) => item.id === form.teamId)?.name ?? (form.teamId === baseline?.teamId ? teamNames.join("、") : "")
  374. : "";
  375. /** 运营团队=按挂载区域实时反查(⛔ 档案快照);身份命中候选时优先展示本队。 */
  376. const operationsTeamView = useMemo(() => {
  377. const regionId = form?.regionId || mount?.parent_node_id || "";
  378. if (!regionId) return { text: "请先挂载所属区域", note: "运营团队按所挂区域实时反查,客户档案不存快照" as string | undefined };
  379. const candidates = teamsCoveringRegion(organization.operationsTeams, regionAncestorChain(organization.regions, regionId));
  380. const lockedId = lockIfCandidate(view.identity?.operationsTeamId, candidates);
  381. return operationsTeamDisplay(candidates, lockedId);
  382. }, [form?.regionId, mount?.parent_node_id, organization.operationsTeams, organization.regions, view.identity?.operationsTeamId]);
  383. /** 主体类型由企业改为其他:后端会同时撤销已留存的营业执照影像(非企业不采集证件影像)。 */
  384. const subjectRevokesLicense = Boolean(baseline && baseline.subject === "enterprise" && form && form.subject !== "enterprise");
  385. if (detail.error) {
  386. return <section className="ops-page">
  387. <Link to={back.to} state={back.state} className="ops-back-link"><ArrowLeft size={16} />{back.label}</Link>
  388. <div className="ops-empty"><h1>取数失败</h1><FetchError message={detail.error.message} onRetry={detail.reload} /></div>
  389. </section>;
  390. }
  391. const invalidOf = (key: keyof ProfileDraft) => (fieldError?.key === key ? true : undefined);
  392. const errorOf = (key: keyof ProfileDraft) => (fieldError?.key === key ? <span className="ops-field-error">{fieldError.message}</span> : null);
  393. const patch = <K extends keyof ProfileDraft>(key: K, value: ProfileDraft[K]) => {
  394. setDraft((current) => (current ? { ...current, [key]: value } : current));
  395. setFieldError((current) => (current?.key === key ? null : current));
  396. };
  397. /** 点铅笔进入该项编辑:切走时把上一项未提交的草稿退回基线,⛔ 留下看不见的脏值。 */
  398. const startField = (key: keyof ProfileDraft) => {
  399. if (busy) return;
  400. if (editingField && editingField !== key && baseline) {
  401. setDraft((current) => (current ? { ...current, [editingField]: baseline[editingField] } : current));
  402. }
  403. setEditingField(key);
  404. setFieldError(null);
  405. setIdBasis("");
  406. };
  407. const cancelField = (key: keyof ProfileDraft) => {
  408. if (busy) return;
  409. if (baseline) setDraft((current) => (current ? { ...current, [key]: baseline[key] } : current));
  410. setEditingField(null);
  411. setFieldError(null);
  412. setIdBasis("");
  413. };
  414. /** 该字段的草稿值是否与基线一致(文本按去首尾空白比较;识别号读口只有脱敏值 ⇒ 从空串起算)。 */
  415. const sameAsBaseline = (key: keyof ProfileDraft, current: ProfileDraft) => {
  416. if (!baseline) return true;
  417. if (key === "name" || key === "contact" || key === "phone" || key === "address") {
  418. return String(current[key]).trim() === String(baseline[key]).trim();
  419. }
  420. return current[key] === baseline[key];
  421. };
  422. /**
  423. * 提交**单个**可编辑项(点对号/Enter 触发):改一项就写一项,⛔ 攒到底部统一保存。
  424. *
  425. * - 只送该项对应的写口:档案字段走 `customer/update@v1`,归属走 `attribution/update`,
  426. * 挂载区域走 `move_region`,运维团队走 `customer/update` 的 `ops_team_ids`;
  427. * - 失败保留输入态与草稿,错误行内呈现,可改后重试或取消;
  428. * - 成功后退出编辑并重读详情与变更历史。
  429. */
  430. /** 详情口下发的乐观锁版本;行内 `customer/update` 必须原样带回(D-12/R-2)。 */
  431. const rowVersion = (() => {
  432. const raw = customer?.row_version as number | string | null | undefined;
  433. if (typeof raw === "number" && Number.isFinite(raw)) return raw;
  434. if (typeof raw === "string" && raw.trim() !== "") {
  435. const n = Number(raw);
  436. return Number.isFinite(n) ? n : undefined;
  437. }
  438. return undefined;
  439. })();
  440. async function commitField(key: keyof ProfileDraft) {
  441. if (!no || !draft || !baseline || busy) return;
  442. const current = draft;
  443. if (key === "name" && !current.name.trim()) { setFieldError({ key, message: "请填写客户名称" }); return; }
  444. if (key === "subject" && !current.subject) { setFieldError({ key, message: "请选择主体类型" }); return; }
  445. if (key === "regionId" && !current.regionId) { setFieldError({ key, message: "请选择挂载区域" }); return; }
  446. if (key === "operatorId" && !current.operatorId) { setFieldError({ key, message: "请选择运营商" }); return; }
  447. // 运维团队单支定案:客户固定挂 1 支,⛔ 提交空数组清空归属。
  448. if (key === "teamId" && !current.teamId) { setFieldError({ key, message: "请选择 1 支运维团队(客户固定挂 1 支,不可清空)" }); return; }
  449. const idNo = key === "idNo" ? current.idNo.trim().replace(/[\s-]/g, "").toUpperCase() : "";
  450. // 识别号读口只下发脱敏值:留空=该项未改,直接退出编辑,⛔ 提交脱敏串。
  451. if (key === "idNo" && !idNo) { setEditingField(null); setFieldError(null); setIdBasis(""); return; }
  452. if (key === "idNo" && !/^[A-Z0-9]{18}$|^\d{15}$/.test(idNo)) { setFieldError({ key, message: "识别号格式不符:应为 18 位统一社会信用代码/组织代码,或 15 位旧营业执照号" }); return; }
  453. // 值没变:不写接口、不留痕,直接退出编辑。
  454. if (sameAsBaseline(key, current)) { setEditingField(null); setFieldError(null); setIdBasis(""); return; }
  455. const needsRowVersion = key === "name" || key === "subject" || key === "idNo" || key === "contact" || key === "phone" || key === "address" || key === "teamId";
  456. if (needsRowVersion && rowVersion === undefined) {
  457. setFieldError({ key, message: "详情未下发 row_version,无法带版本提交;请刷新页面后重试。" });
  458. return;
  459. }
  460. setBusy(true);
  461. setFieldError(null);
  462. try {
  463. switch (key) {
  464. case "name":
  465. await customerUpdate({ customer_id: no, customer_name: current.name.trim(), row_version: rowVersion });
  466. break;
  467. case "subject":
  468. await customerUpdate({ customer_id: no, subject_type: current.subject, row_version: rowVersion });
  469. break;
  470. case "idNo":
  471. await customerUpdate({ customer_id: no, id_code: idNo, row_version: rowVersion, ...(idBasis.trim() ? { change_basis: idBasis.trim() } : {}) });
  472. break;
  473. case "contact":
  474. await customerUpdate({ customer_id: no, contact_name: current.contact.trim(), row_version: rowVersion });
  475. break;
  476. case "phone":
  477. await customerUpdate({ customer_id: no, contact_mobile: current.phone.trim(), row_version: rowVersion });
  478. break;
  479. case "address":
  480. await customerUpdate({ customer_id: no, address: current.address.trim(), row_version: rowVersion });
  481. break;
  482. case "operatorId":
  483. case "partnerId":
  484. // `partner_id` 传空串=清空合伙人(后端约定),⛔ 用 undefined 冒充「不改」。
  485. await customerAttributionUpdate({ customer_id: no, operator_id: current.operatorId, partner_id: current.partnerId });
  486. break;
  487. case "regionId":
  488. await customerMoveRegion({ customer_id: no, new_region_node_id: current.regionId });
  489. break;
  490. case "teamId":
  491. await customerUpdate({ customer_id: no, ops_team_ids: [current.teamId], row_version: rowVersion });
  492. break;
  493. }
  494. invalidateCustomerList();
  495. // 乐观基线:重读落定前,本次提交的值已视为基线,⛔ 让「刚保存」又被判成未提交。
  496. const committed = { ...current, name: current.name.trim(), contact: current.contact.trim(), phone: current.phone.trim(), address: current.address.trim() };
  497. setDraft(committed);
  498. setBaselineOverride(committed);
  499. setEditingField(null);
  500. setIdBasis("");
  501. setNotice("该项修改已保存,变更记录已写入历史。");
  502. // 成功后重读详情拿新 row_version,⛔ 同页二次提交旧版本。
  503. await detail.reloadAsync();
  504. changes.reload();
  505. } catch (e) {
  506. setFieldError({ key, message: (e as ApiError)?.message || "保存失败,请稍后重试。" });
  507. } finally {
  508. setBusy(false);
  509. }
  510. }
  511. function openSub(row: SubAccountRow) {
  512. if (false) return;
  513. setSubDraft({ displayName: row.display_name ?? "", netAccount: row.net_account ?? "" });
  514. setSubError("");
  515. setEditingSub(row);
  516. }
  517. async function saveSub(event: FormEvent<HTMLFormElement>) {
  518. event.preventDefault();
  519. if (false || !editingSub || busy) return;
  520. if (!orderDraft.displayName.trim()) { setSubError("请填写账号姓名。"); return; }
  521. setBusy(true);
  522. setSubError("");
  523. try {
  524. await subAccountUpdate({
  525. sub_account_id: editingSub.sub_account_id,
  526. display_name: orderDraft.displayName.trim(),
  527. network_account_name: orderDraft.netAccount.trim() || undefined,
  528. });
  529. setEditingSub(null);
  530. // 列表口的 `sub_account_count` 随分账号变化 ⇒ 共享快照一并作废(缺口清单 C-8)。
  531. invalidateCustomerList();
  532. accounts.reload();
  533. } catch (e) {
  534. setSubError((e as ApiError)?.message || "分账号修改失败。");
  535. } finally {
  536. setBusy(false);
  537. }
  538. }
  539. /**
  540. * 营业执照影像补传/替换(设计写入口只在本分区):选中即直传平台对象存储,
  541. * 成功后调 `POST /customer/update@v1` 写回对象键,再重读详情(拿新签名)。
  542. */
  543. async function replaceLicense(file: File | null) {
  544. if (!file || !no) return;
  545. if (rowVersion === undefined) {
  546. setLicenseError("详情未下发 row_version,无法带版本提交;请刷新页面后重试。");
  547. return;
  548. }
  549. setLicenseError("");
  550. setLicenseBusy(true);
  551. try {
  552. const uploaded = await uploadCustomerLicense(file);
  553. await customerUpdate({ customer_id: no, license: uploaded, row_version: rowVersion });
  554. invalidateCustomerList();
  555. await detail.reloadAsync();
  556. } catch (e) {
  557. setLicenseError((e as ApiError)?.message || "影像上传失败。");
  558. } finally {
  559. setLicenseBusy(false);
  560. }
  561. }
  562. const displayName = customerName || no || "";
  563. /** 页头停用入口:取探针首条生效中订阅;多条时行内仍可分别发起。 */
  564. const heroStopSub = activeOrderProbe.data?.items?.[0] ?? null;
  565. return <section className="ops-page ops-record-page customer-workspace record-detail">
  566. <Link to={back.to} state={back.state} className="ops-back-link"><ArrowLeft size={16} />{back.label}</Link>
  567. <header className="customer-record-masthead">
  568. <div className="customer-hero-symbol" aria-hidden="true"><Building2 size={26} /></div>
  569. <div className="customer-hero-copy">
  570. <p className="customer-record-id">CUSTOMER <span aria-hidden="true">·</span> <span>{no}</span></p>
  571. <h1 className="customer-record-title">{displayName}</h1>
  572. <div className="customer-record-tags">
  573. {subjectText && <OpsTag tone="brand">{subjectText}</OpsTag>}
  574. <AcctCell raw={customer?.acct_status} />
  575. <span className="customer-record-meta"><MapPin size={14} aria-hidden="true" /><span><TextCell value={mountedRegionPath} note="未取到该客户的区域挂载信息" /></span></span>
  576. <span className="customer-record-meta"><Building2 size={14} aria-hidden="true" /><span>运营商 <TextCell value={customer?.operator_name} /></span></span>
  577. <span className="customer-record-meta">
  578. <Wrench size={14} aria-hidden="true" />
  579. <span>运维团队 <TextCell value={teamNames.join("、")} note="未取到该客户的运维团队信息" />
  580. {staleTeamHint && <> <Tri tone="fail" text="需改派单支" title={staleTeamHint} /></>}
  581. </span>
  582. </span>
  583. </div>
  584. </div>
  585. <div className="ops-hero-actions customer-record-actions">
  586. {/* D-11:手册「客户/订阅详情页」均可发起服务停用;停用挂具体订阅(工单§3.2.1)。 */}
  587. {writable && heroStopSub ? <CustomerServiceStopAction
  588. customerId={no || ""}
  589. customerName={displayName}
  590. orderId={heroStopSub.subscription_id}
  591. orderLabel={heroStopSub.status_display?.label ?? orderView(heroStopSub).statusLabel ?? "生效中"}
  592. /> : null}
  593. <Button variant="outline" onClick={detail.reload}><RefreshCcw size={15} />刷新</Button>
  594. </div>
  595. </header>
  596. <dl className="customer-record-metrics" aria-label="客户业务摘要">
  597. <div>
  598. <dt><UsersRound size={16} aria-hidden="true" />分账号</dt>
  599. <dd>
  600. <strong>{metricCount(accountsTotal, accounts.loading, accounts.error)}</strong>
  601. <small>
  602. 在用分账号{accountsTotal > accountRows.length ? "(已加载)" : ""}{" "}
  603. <span className="customer-record-active-count">
  604. {metricCount(accounts.data ? accountRows.filter((row) => row.status === "in_use").length : undefined, accounts.loading, accounts.error)}
  605. </span>
  606. </small>
  607. </dd>
  608. </div>
  609. <div>
  610. <dt><Gauge size={16} aria-hidden="true" />订阅额度</dt>
  611. <dd>
  612. <strong><TextCell value={customer?.quota_cents != null ? `${customer.quota_cents} 个` : undefined} /></strong>
  613. <small>汇总在用订阅席位,生效或终止时自动更新。明细见订阅详情。</small>
  614. </dd>
  615. </div>
  616. <div>
  617. <dt><ScrollText size={16} aria-hidden="true" />全部订阅</dt>
  618. <dd><strong>{metricCount(ordersTotal, ordersLoad.loading, ordersLoad.error)}</strong><small>含历史订阅</small></dd>
  619. </div>
  620. <div>
  621. <dt><FileSignature size={16} aria-hidden="true" />关联合同</dt>
  622. <dd><strong>{metricCount(contractsTotal, contractsLoad.loading, contractsLoad.error)}</strong><small>当前客户名下</small></dd>
  623. </div>
  624. </dl>
  625. <div className="record-tabs-frame">
  626. <RecordTabs prefix="customer" label="客户工作台视图" active={tab} onChange={setTab}
  627. tabs={WORKSPACE_TABS.map((item) => item.id === "subscriptions"
  628. ? { ...item, count: ordersLoad.error ? "—" : ordersTotal, panelId: "workspace-service" }
  629. : item.id === "subaccounts" ? { ...item, count: accounts.error ? "—" : accountsTotal } : item)}
  630. />
  631. <section className="ops-record-card customer-workspace-panel" id="customer-panel-profile" role="tabpanel" aria-labelledby="customer-tab-profile" hidden={tab !== "profile"}>
  632. <dl className="ops-record-summary">
  633. <div><dt>客户编号</dt><dd>{no}</dd></div>
  634. <div><dt>客户名称</dt><dd><InlineField id="customer-name" label="客户名称" value={form?.name ?? ""} editing={editingField === "name"} writable={writable} busy={busy} onStart={() => startField("name")} onChange={(value) => patch("name", value)} onDone={() => void commitField("name")} onCancel={() => cancelField("name")} emptyText={MISSING} invalid={invalidOf("name")} error={errorOf("name")} /></dd></div>
  635. <div><dt>主体类型</dt><dd><InlineField id="customer-subject" label="主体类型" value={form?.subject ?? ""} editing={editingField === "subject"} writable={writable} busy={busy} onStart={() => startField("subject")} onChange={(value) => patch("subject", value)} onDone={() => void commitField("subject")} onCancel={() => cancelField("subject")} display={form?.subject ? label(SUBJECT_TYPE, form.subject) : undefined} emptyText={MISSING} selectOptions={subjectOptions} invalid={invalidOf("subject")} error={errorOf("subject")} /></dd></div>
  636. <div><dt>识别号 / 统一社会信用代码</dt><dd><InlineField id="customer-id-no" label="客户识别号" value={form?.idNo ?? ""} editing={editingField === "idNo"} writable={writable} busy={busy} onStart={() => startField("idNo")} onChange={(value) => patch("idNo", value)} onDone={() => void commitField("idNo")} onCancel={() => cancelField("idNo")} display={form?.idNo ? form.idNo : customer?.identity_no_masked ?? undefined} emptyText="未登记识别号" invalid={invalidOf("idNo")} error={errorOf("idNo")} editor={<>
  637. <Input id="customer-id-no" aria-label="客户识别号" autoFocus disabled={busy} placeholder="填入完整识别号(留空=不改动)" value={form?.idNo ?? ""} onChange={(event) => patch("idNo", event.target.value)} onKeyDown={(event) => { if (isImeComposing(event)) return; if (event.key === "Enter") { event.preventDefault(); void commitField("idNo"); } if (event.key === "Escape") { event.preventDefault(); cancelField("idNo"); } }} />
  638. <Input aria-label="识别号变更依据" disabled={busy} placeholder="变更依据(选填,随变更日志留存)" value={idBasis} onChange={(event) => setIdBasis(event.target.value)} onKeyDown={(event) => { if (isImeComposing(event)) return; if (event.key === "Enter") { event.preventDefault(); void commitField("idNo"); } if (event.key === "Escape") { event.preventDefault(); cancelField("idNo"); } }} />
  639. </>} /></dd></div>
  640. <div><dt>联系人</dt><dd><InlineField id="customer-contact" label="联系人" value={form?.contact ?? ""} editing={editingField === "contact"} writable={writable} busy={busy} onStart={() => startField("contact")} onChange={(value) => patch("contact", value)} onDone={() => void commitField("contact")} onCancel={() => cancelField("contact")} emptyText="未登记" placeholder="客户方联系人,个人客户填本人" /></dd></div>
  641. <div><dt>联系电话</dt><dd><InlineField id="customer-phone" label="联系电话" value={form?.phone ?? ""} editing={editingField === "phone"} writable={writable} busy={busy} onStart={() => startField("phone")} onChange={(value) => patch("phone", value)} onDone={() => void commitField("phone")} onCancel={() => cancelField("phone")} emptyText="未登记" inputMode="numeric" placeholder="支持固定电话或手机号" /></dd></div>
  642. <div><dt>地址</dt><dd><InlineField id="customer-address" label="地址" value={form?.address ?? ""} editing={editingField === "address"} writable={writable} busy={busy} onStart={() => startField("address")} onChange={(value) => patch("address", value)} onDone={() => void commitField("address")} onCancel={() => cancelField("address")} emptyText="未登记" placeholder="完整地址,包括楼栋与房间号" /></dd></div>
  643. <div><dt>建档时间</dt><dd><TextCell value={customer?.created_at} /></dd></div>
  644. </dl>
  645. <p className="customer-form-note">识别号只能更正、不能读取明文(后端只下发脱敏值):点铅笔后填入完整新号码并点对号才会提交,留空或未改动=不提交。{staleTeamHint && <>运维团队{staleTeamHint}。</>}</p>
  646. {subjectRevokesLicense && <p className="customer-form-note">提交后主体类型将改为「{label(SUBJECT_TYPE, form?.subject ?? "")}」,系统会同时撤销该客户已留存的营业执照影像(非企业不采集证件影像),之后如需恢复只能按企业主体重新上传。</p>}
  647. </section>
  648. <section className="ops-record-card customer-workspace-panel" id="customer-panel-attribution" role="tabpanel" aria-labelledby="customer-tab-attribution" hidden={tab !== "attribution"}>
  649. <dl className="ops-record-summary">
  650. <div><dt>所属区域</dt><dd><InlineField id="customer-region" label="所属区域" value={form?.regionId ?? ""} editing={editingField === "regionId"} writable={writable} busy={busy} onStart={() => startField("regionId")} onChange={(value) => patch("regionId", value)} onDone={() => void commitField("regionId")} onCancel={() => cancelField("regionId")} display={draftRegionDisplay || undefined} emptyText={MISSING} editor={<TreeSelect treeData={regionTree} value={form?.regionId ?? ""} onChange={(value) => patch("regionId", value)} ariaLabel="所属区域" placeholder="请选择区域节点" name="customer-region" />} invalid={invalidOf("regionId")} error={errorOf("regionId")} /></dd></div>
  651. <div><dt>运营商</dt><dd><InlineField id="customer-operator" label="运营商" value={form?.operatorId ?? ""} editing={editingField === "operatorId"} writable={writable} busy={busy} onStart={() => startField("operatorId")} onChange={(value) => patch("operatorId", value)} onDone={() => void commitField("operatorId")} onCancel={() => cancelField("operatorId")} display={draftOperatorName || undefined} emptyText={MISSING} selectOptions={[{ value: "", label: "请选择运营商" }, ...organization.operators.map((item) => ({ value: item.id, label: item.name }))]} invalid={invalidOf("operatorId")} error={errorOf("operatorId")} /></dd></div>
  652. {/* 合伙人选填(至多 1 个):`partner_id` 为空=业务上的「未绑定」,⛔ 与「后端未下发」混为一谈。 */}
  653. <div><dt>合伙人</dt><dd><InlineField id="customer-partner" label="合伙人" value={form?.partnerId ?? ""} editing={editingField === "partnerId"} writable={writable} busy={busy} onStart={() => startField("partnerId")} onChange={(value) => patch("partnerId", value)} onDone={() => void commitField("partnerId")} onCancel={() => cancelField("partnerId")} display={form ? (form.partnerId ? draftPartnerName || form.partnerId : "未绑定合伙人") : undefined} emptyText="未绑定合伙人" selectOptions={[{ value: "", label: "不绑定" }, ...organization.partners.map((item) => ({ value: item.id, label: item.name }))]} /></dd></div>
  654. <div><dt>运营团队</dt><dd><span className="customer-inline-readonly" title={operationsTeamView.note}>{operationsTeamView.text}{operationsTeamView.note ? <span className="ops-muted"> {operationsTeamView.note}</span> : null}</span></dd></div>
  655. <div><dt>运维团队</dt><dd><InlineField id="customer-team" label="运维团队" value={form?.teamId ?? ""} editing={editingField === "teamId"} writable={writable} busy={busy} onStart={() => startField("teamId")} onChange={(value) => patch("teamId", value)} onDone={() => void commitField("teamId")} onCancel={() => cancelField("teamId")} display={draftTeamName || undefined} emptyText={MISSING} editor={<CustomerTeamSelect options={organization.maintenanceTeams.map((item) => ({ id: item.id, name: item.name, hint: (item.ticketTypes ?? []).map(typeLabel).join("、") }))} value={form?.teamId ?? ""} onChange={(id) => patch("teamId", id)} />} invalid={invalidOf("teamId")} error={errorOf("teamId")} /></dd></div>
  656. </dl>
  657. <p className="customer-form-note">挂载区域、运营商、合伙人与运维团队(客户固定挂 1 支)的变更由后端留存记录;运营团队按所挂区域实时反查、不写入客户档案。区域与运营商省份不一致会被后端拦下。每项点对号即提交。{staleTeamHint && <>{staleTeamHint};改派前本次不提交运维团队。</>}</p>
  658. </section>
  659. <section className="ops-record-card customer-workspace-panel" id="customer-panel-primary" role="tabpanel" aria-labelledby="customer-tab-primary" hidden={tab !== "primary"}>
  660. <div className="customer-panel-grid">
  661. <div className="customer-panel"><dl>
  662. <div><dt>登录名</dt><dd>{primaryAccount ? <TextCell value={primaryAccount.username} /> : <Tri tone={primaryAccountLoad.error ? "fail" : "missing"} text={MISSING} title={primaryAccountMissing} />}</dd></div>
  663. <div><dt>绑定手机号</dt><dd>{primaryAccount ? <OptionalCell value={primaryAccount.mobile} note="该主账号未登记手机号" /> : <Tri tone={primaryAccountLoad.error ? "fail" : "missing"} text={MISSING} title={primaryAccountMissing} />}</dd></div>
  664. <div><dt>账号状态</dt><dd>{primaryAccount ? <AcctCell raw={primaryAccount.status} /> : <Tri tone={primaryAccountLoad.error ? "fail" : "missing"} text={MISSING} title={primaryAccountMissing} />}</dd></div>
  665. <div><dt>首次登录改密</dt><dd>{primaryAccount ? (primaryAccount.pwd_set_at ? <>已改密<br /><span className="ops-muted">{primaryAccount.pwd_set_at}</span></> : <span className="ops-muted">未改密</span>) : <Tri tone={primaryAccountLoad.error ? "fail" : "missing"} text={MISSING} title={primaryAccountMissing} />}</dd></div>
  666. </dl></div>
  667. <div className="customer-panel"><h3>当前激活信息</h3><dl>
  668. <div><dt>激活状态</dt><dd>{primaryAccount ? (primaryAccount.activation_status
  669. ? <OpsStatus tone={activationTone(primaryAccount.activation_status)}>{label(ACTIVATION_STATUS, primaryAccount.activation_status)}</OpsStatus>
  670. /* 三态(巡检 P1-D2):非主账号(入口/分账号)本就不产生激活码,⛔ 写成「后端未下发」。 */
  671. : primaryAccount.account_kind !== "primary"
  672. ? <span className="ops-muted" title={`account_kind=${primaryAccount.account_kind}:入口/分账号不产生激活码,bos_account_ext 不会为其建行`}>不适用(非主账号,不产生激活码)</span>
  673. : <Tri tone="missing" text={MISSING} title="bos_account_ext 未生成该账号的激活码扩展行" />) : <Tri tone={primaryAccountLoad.error ? "fail" : "missing"} text={MISSING} title={primaryAccountMissing} />}</dd></div>
  674. <div><dt>激活码发送日</dt><dd>{primaryAccount ? <OptionalCell value={primaryAccount.delivered_at} note="尚未交付激活码" /> : <Tri tone={primaryAccountLoad.error ? "fail" : "missing"} text={MISSING} title={primaryAccountMissing} />}</dd></div>
  675. <div><dt>激活截止日</dt><dd>{primaryAccount ? <OptionalCell value={primaryAccount.expire_date} note="无未消费激活码(已激活或已过期)" /> : <Tri tone={primaryAccountLoad.error ? "fail" : "missing"} text={MISSING} title={primaryAccountMissing} />}</dd></div>
  676. <div><dt>激活码</dt><dd>{freshCode ? <><code className="ops-code-plain">{freshCode.code}</code>{freshCode.expireDate ? <span className="ops-muted"> 有效期至 {freshCode.expireDate}</span> : null}</> : primaryActivated ? <span className="ops-muted" title={NO_ACTIVATION_CODE_READ}>已激活,不可查看</span> : <Tri tone="missing" text={MISSING} title={NO_ACTIVATION_CODE_READ} />}</dd></div>
  677. <div><dt>重置激活码</dt><dd><div className="ops-entity-actions">{primaryActivated
  678. ? <span className="ops-muted" title={CODE_RESET_ACTIVATED_NOTE}>已激活,不提供重置入口</span>
  679. : <Button type="button" variant="outline" disabled={resetBusy || !primaryAccount} onClick={resetPrimaryCode} title={!primaryAccount ? NO_ACCOUNT_FOUND : "作废旧码并发新码(仅未激活账号),新明文只回显一次"}>{resetBusy ? "正在重置…" : "重置激活码"}</Button>}</div></dd></div>
  680. </dl></div>
  681. </div>
  682. {resetError ? <p className="ops-form-error" role="alert">{resetError}</p> : null}
  683. {freshCode ? <p className="customer-form-note">{CODE_RESET_ONCE_NOTE}</p> : null}
  684. <p className="customer-form-note">账号状态取 <code>bos_user_binding.status</code>(启停),激活状态取 <code>bos_account_ext.status</code>(激活码生命周期),两者正交:账号可用性只决定能否登录。激活码明文仅开通/重置当次回执一次性下发,本页「重置激活码」后的新码同样只在上方回显一次。</p>
  685. </section>
  686. <section className="ops-record-card customer-workspace-panel" id="workspace-service" role="tabpanel" aria-labelledby="customer-tab-subscriptions" hidden={tab !== "subscriptions"}>
  687. <div className="ops-table-wrap record-table-scroll" role="region" aria-label="全部订阅列表" tabIndex={0}>{ordersLoad.error ? <div className="ops-empty"><FetchError message={ordersLoad.error.message} onRetry={ordersLoad.reload} /></div> :
  688. <table className="ops-table record-subscriptions-table"><OpsTableColumns widths={[170, 90, 90, 110, 130, 170, 80, 110, 90, 80]} /><OpsTableHead columns={["套餐", "类型", "变更类型", "关联订阅", "合同", "服务期限", "分账号", "月缴金额", "状态", "操作"]} />
  689. <tbody>{orders.length ? orders.map((sub: any) => {
  690. const row = orderView(sub);
  691. const rowStatus = sub.status_display?.label ?? row.statusLabel;
  692. /** 只有生效中的订阅可替换(升降配)或叠加新建并存订阅;只读身份不挂入口。 */
  693. const orderMore: OpsMoreItem[] = writable && rowStatus === "生效中" ? [
  694. { label: "升降配", icon: <RefreshCw size={15} />, onSelect: () => setChangeTarget(row) },
  695. // D-03:叠加=新建并存订阅,⛔ 就地改结束日。
  696. { label: "叠加", icon: <CalendarPlus size={15} />, onSelect: () => setCreateOpen(true) },
  697. ] : [];
  698. return <tr key={sub.subscription_id}>
  699. <td><Link className="contract-ref-link" to={`/orders/${encodeURIComponent(sub.subscription_id)}`} state={outgoingState}>{sub.plan_name ?? sub.plan_id}</Link><small>{sub.subscription_id}</small></td>
  700. <td>{sub.plan_kind ? label(PLAN_KIND, sub.plan_kind) : "-"}</td>
  701. <td title="由替换关系派生:有 replaces_subscription_id=升降配,否则新签">{sub.replaces_subscription_id ? "升降配" : "新签"}</td>
  702. <td title="由替换关系派生:有 replaces_subscription_id=升降配,否则新签">{sub.replaces_subscription_id ? <TextCell value={sub.replaces_subscription_id} /> : <span className="ops-muted">—(新签,无前序订阅)</span>}</td>
  703. <td>{sub.contract_no ?? sub.contract_id ?? "-"}</td>
  704. <td>{sub.start_date ?? "—"} 至 {sub.end_date ?? "—"}</td>
  705. <td>{sub.quota_slots ?? 0} 个</td>
  706. <td>{sub.monthly_settle_cents ? money(String(sub.monthly_settle_cents / 100)) : <Tri tone="missing" text={MISSING} title={MISSING + ":monthly_settle_cents 未下发"} />}</td>
  707. <td><OpsStatus tone={statusTone(sub.status_display?.label ?? sub.status)}>{sub.status_display?.label ?? sub.status ?? MISSING}</OpsStatus>{sub.editable === false && sub.reason ? `(${sub.reason.replace(/([^()]*)$/, "").replace(/[,。;]$/, "")})` : ""}</td>
  708. <td><div className="ops-inline-actions">
  709. {writable && rowStatus === "生效中" ? <CustomerServiceStopAction customerId={no || ""} customerName={displayName} orderId={sub.subscription_id} orderLabel={rowStatus} /> : null}
  710. <OpsMore items={orderMore} placeholder />
  711. </div></td>
  712. </tr>;
  713. }) : <OpsTableEmpty colSpan={10}>该客户暂无套餐订阅记录</OpsTableEmpty>}</tbody>
  714. </table>}</div>
  715. <ListPager total={ordersTotal} page={safeOrdersPage} pageSize={ordersPageSize} onPageChange={setOrdersPage} onPageSizeChange={(size) => { setOrdersPageSize(size); setOrdersPage(0); }} unit="条" />
  716. </section>
  717. <section className="ops-record-card customer-workspace-panel" id="customer-panel-subaccounts" role="tabpanel" aria-labelledby="customer-tab-subaccounts" hidden={tab !== "subaccounts"}>
  718. <div className="ops-table-wrap record-table-scroll" role="region" aria-label="分账号列表" tabIndex={0}><table className="ops-table record-accounts-table"><OpsTableColumns widths={[60, 130, 110, 170, 90, 110, 110, 80]} /><OpsTableHead columns={["序号", "账号名", "姓名", "网络侧账号名", "账号状态", "开通日", "停用日", "操作"]} />
  719. <tbody>{accounts.error ? <tr><td colSpan={8}><Tri tone="fail" text="取数失败" title={accounts.error.message} /></td></tr>
  720. : accountRows.length ? accountRows.map((row, index) => <tr key={row.sub_account_id}>
  721. <td>{safeAccountsPage * accountsPageSize + index + 1}</td>
  722. {/* 三态(巡检 P1-D2):未开通/已停用的席位没有账号名属正常态,⛔ 标「后端未下发」。 */}
  723. <td>{row.username?.trim()
  724. ? <TextCell value={row.username} />
  725. : row.status === "not_opened"
  726. ? <span className="ops-muted" title="该席位尚未开通,账号名在开通后登记">未开通</span>
  727. : row.status === "stopped"
  728. ? <span className="ops-muted" title="该席位已停用,账号名随停用不再展示">已停用</span>
  729. : <OptionalCell value={row.username} note="后端未登记该席位的账号名(sub_account.username 已下发、值为空)" />}</td>
  730. <td><TextCell value={seatDisplayName(row)} note={isSeatPlaceholder(row) ? "系统按套餐额度自动补建的席位(需求§4.2):姓名留空,此处按登录名尾号「席位 n」占位显示,不作为真实姓名落库" : undefined} /></td>
  731. {/*
  732. P1-D2:空值分三档,⛔ 一律标「后端未下发」——
  733. `not_opened`=席位尚未开通(回填后才登记);已开通但 `net_account` 为空=
  734. 开户回填未登记(字段已下发、值为空);有值=原样显示。
  735. */}
  736. <td>{row.net_account?.trim()
  737. ? row.net_account
  738. : row.status === "not_opened"
  739. ? <span className="ops-muted" title="该席位尚未开通,网络侧账号名在开户回填后登记">未开通</span>
  740. : <OptionalCell value={row.net_account} note="开户回填未登记该席位的网络侧账号名(sub_account.net_account 已下发、值为空)" />}</td>
  741. <td><AcctCell raw={row.status} /></td>
  742. <td><TextCell value={row.created_at} /></td>
  743. <td>{row.stopped_at ? <TextCell value={row.stopped_at} /> : <span className="ops-muted">—(未停用)</span>}</td>
  744. <td><Button variant="ghost" onClick={() => openSub(row)}>编辑</Button></td>
  745. </tr>) : <OpsTableEmpty colSpan={8}>该客户暂无分账号</OpsTableEmpty>}
  746. </tbody>
  747. </table></div>
  748. <ListPager total={accountsTotal} page={safeAccountsPage} pageSize={accountsPageSize} onPageChange={setAccountsPage} onPageSizeChange={(size) => { setAccountsPageSize(size); setAccountsPage(0); }} unit="个" />
  749. <p className="customer-form-note">网络侧账号名由客户提供,仅用于与本系统账号对照,系统不为其做唯一性或格式校验。分账号的开通与停发:{MISSING} —— <code>/sub_account/*</code> 只有读列表与改姓名两个口,无新增与删除路由。</p>
  750. </section>
  751. <section className="ops-record-card customer-workspace-panel" id="customer-panel-materials" role="tabpanel" aria-labelledby="customer-tab-materials" hidden={tab !== "materials"}>
  752. <div className="customer-panel customer-material-panel">
  753. <h3>登记材料 · 营业执照影像</h3>
  754. <CustomerMaterialCard>
  755. {!licenseApplicable ? <>
  756. <strong>不适用</strong>
  757. <p>个人和个体工商户无需登记营业执照影像。</p>
  758. </> : license?.status === "viewable" ? <>
  759. <div className="customer-license-filename"><strong>{license.file_name ?? "营业执照影像"}</strong><OpsStatus tone="success">已登记</OpsStatus></div>
  760. <p>{license.view_url ? "查看链接短期有效,失效后请刷新页面。" : "查看链接暂不可用,请刷新页面。"}</p>
  761. {license.view_url && <div className="customer-material-links">
  762. <a href={license.view_url} target="_blank" rel="noopener noreferrer">查看影像</a>
  763. <a href={license.view_url} download={license.file_name ?? ""} target="_blank" rel="noopener noreferrer">下载</a>
  764. </div>}
  765. </> : license?.status === "expired" ? <>
  766. <strong>已超期</strong>
  767. <p>影像留存期已满,无法查看或下载。</p>
  768. </> : <>
  769. <strong>{license ? "未登记影像" : MISSING}</strong>
  770. <p>{license ? "营业执照影像为选填材料,可在此补传。" : "暂未获取影像登记状态。"}</p>
  771. </>}
  772. {licenseApplicable && license?.status !== "expired" && <div className="customer-license-upload">
  773. <label className="customer-upload-button customer-license-button">
  774. <Upload size={15} aria-hidden="true" />
  775. {licenseBusy ? "正在上传…" : license?.status === "viewable" ? "替换影像" : "上传影像"}
  776. <input
  777. aria-label="上传营业执照影像"
  778. aria-describedby="customer-license-upload-note"
  779. type="file"
  780. disabled={licenseBusy || busy}
  781. onChange={(event) => {
  782. const file = event.target.files?.[0] ?? null;
  783. event.target.value = "";
  784. void replaceLicense(file);
  785. }}
  786. />
  787. </label>
  788. <small id="customer-license-upload-note">格式和大小以平台限制为准。替换影像后,留存期限仍从建档日起算。</small>
  789. </div>}
  790. </CustomerMaterialCard>
  791. {licenseError && <p className="ops-form-error" role="alert">{licenseError}</p>}
  792. </div>
  793. <div className="customer-panel customer-material-panel">
  794. <h3>合同文档</h3>
  795. {contractsLoad.error ? <CustomerMaterialCard>
  796. <strong>合同文档读取失败</strong>
  797. <FetchError message={contractsLoad.error.message} onRetry={contractsLoad.reload} />
  798. </CustomerMaterialCard> : contractsLoad.loading ? <CustomerMaterialCard>
  799. <strong>正在读取合同文档…</strong>
  800. </CustomerMaterialCard> : contractFiles.length ? <div className="customer-material-list">
  801. {contractFiles.map((document) => <CustomerMaterialCard key={`${document.contractNo}-${document.name}`}>
  802. <strong>{document.name}</strong>
  803. <p>{document.contractNo}</p>
  804. <div className="customer-material-links">
  805. <Link to={`/contracts/${encodeURIComponent(document.contractNo)}?download=${encodeURIComponent(document.name)}`} state={outgoingState}>预览</Link>
  806. </div>
  807. </CustomerMaterialCard>)}
  808. </div> : <CustomerMaterialCard>
  809. <strong>暂无合同文档</strong>
  810. <p>文档随合同登记上传。</p>
  811. </CustomerMaterialCard>}
  812. <ListPager total={contractsTotal} page={safeContractsPage} pageSize={contractsPageSize} onPageChange={setContractsPage} onPageSizeChange={(size) => { setContractsPageSize(size); setContractsPage(0); }} unit="份" />
  813. </div>
  814. <p className="customer-form-note">应备材料(按主体类型):{subjectText ? customerMaterials(subjectText as "企业" | "个体工商户" | "个人") : <Tri tone="missing" text={MISSING} title={MISSING + ":subject_type"} />};合同文档:{CONTRACT_DOC_NOTE}。按合同分页取回(默认每页 {LIST_PAGE_SIZE} 份)。</p>
  815. </section>
  816. <section className="ops-record-card customer-workspace-panel" id="customer-panel-history" role="tabpanel" aria-labelledby="customer-tab-history" hidden={tab !== "history"}>
  817. <div className="ops-table-wrap record-table-scroll" role="region" aria-label="客户历史记录列表" tabIndex={0}><table className="ops-table record-history-table"><OpsTableColumns widths={[150, 140, 320, 150]} /><OpsTableHead columns={["时间", "变更项", "变化前 → 变化后", "操作人"]} />
  818. <tbody>{changes.error ? <tr><td colSpan={4}><Tri tone="fail" text="取数失败" title={changes.error.message} /></td></tr>
  819. : changeRows.length ? changeRows.map((row, index) => <tr key={`${row.changed_at ?? "h"}-${safeHistoryPage}-${index}`}>
  820. <td><TextCell value={row.changed_at} /></td>
  821. <td><TextCell value={row.field_key} /></td>
  822. <td>{row.old_value || row.new_value ? <div className="ops-change-diff"><span>{row.old_value?.trim() || "(空)"}</span><span>{row.new_value?.trim() || "(已清空)"}</span></div> : <Tri tone="missing" text={MISSING} title={MISSING + ":/customer/history@v1 未回该项的新旧值"} />}</td>
  823. <td><TextCell value={row.operator} />{row.source ? <><br /><span className="ops-muted">{row.source}</span></> : null}</td>
  824. </tr>) : <OpsTableEmpty colSpan={4}>后端未返回该客户的变更记录</OpsTableEmpty>}
  825. </tbody>
  826. </table></div>
  827. <ListPager total={historyTotal} page={safeHistoryPage} pageSize={historyPageSize} onPageChange={setHistoryPage} onPageSizeChange={(size) => { setHistoryPageSize(size); setHistoryPage(0); }} unit="条" />
  828. </section>
  829. {/* 交付现状(讨论稿 §7.7):按需挂载——不进该页签就不发 `/delivery/list@v1`。 */}
  830. <section className="ops-record-card customer-workspace-panel" id="customer-panel-delivery" role="tabpanel" aria-labelledby="customer-tab-delivery" hidden={tab !== "delivery"}>
  831. {tab === "delivery" && no ? <DeliveryStatusTable customerId={no} /> : null}
  832. </section>
  833. </div>
  834. {notice && <OpsNotice message={notice} onClose={() => setNotice("")} />}
  835. {editingSub && <dialog ref={orderDialogRef} onClose={() => setEditingSub(null)} className="ops-dialog" aria-labelledby="sub-account-edit-title">
  836. <form method="dialog" className="ops-entity-form" onSubmit={saveSub}>
  837. <h2 id="sub-account-edit-title">编辑分账号</h2>
  838. <label><span className="ops-field-title">所属客户</span><Input disabled value={displayName} /></label>
  839. <label><span className="ops-field-title">账号名</span><Input disabled value={editingSub.username ?? ""} placeholder={MISSING} /></label>
  840. <label><span className="ops-field-title">姓名<b>*</b></span><Input value={orderDraft.displayName} autoComplete="off" aria-invalid={Boolean(orderError)} onChange={(event) => setSubDraft((value) => ({ ...value, displayName: event.target.value }))} /></label>
  841. <label><span className="ops-field-title">网络侧账号名</span><Input value={orderDraft.netAccount} autoComplete="off" placeholder="客户网络系统中的账号名" onChange={(event) => setSubDraft((value) => ({ ...value, netAccount: event.target.value }))} /></label>
  842. <div><span className="ops-field-title">当前状态</span><div style={{ paddingTop: 6 }}><AcctCell raw={editingSub.status} /></div></div>
  843. {orderError && <p className="ops-form-error" role="alert">{orderError}</p>}
  844. <div className="ops-entity-actions"><Button type="submit" disabled={busy}>保存</Button><Button type="button" variant="outline" disabled={busy} onClick={() => setEditingSub(null)}>取消</Button></div>
  845. </form>
  846. </dialog>}
  847. {changeTarget && <OrderEditor key={`updown-${changeTarget.no}`} customerId={changeTarget.customerId || no || ""} customerName={displayName} context={{ mode: "updown", record: changeTarget }} onClose={() => setChangeTarget(null)} onSaved={(message) => { setChangeTarget(null); setNotice(message); ordersLoad.reload(); detail.reload(); }} />}
  848. {createOpen && <OrderEditor key="stack-new" customerId={no || ""} customerName={displayName} context={{ mode: "new" }} onClose={() => setCreateOpen(false)} onSaved={(message) => { setCreateOpen(false); setNotice(message); ordersLoad.reload(); detail.reload(); }} />}
  849. </section>;
  850. }
  851. /** 表头(列宽比例由 OpsTableColumns 组件下发,⛔ 在本页硬编码像素宽)。 */
  852. function OpsTableHead({ columns }: { columns: string[] }) {
  853. return <thead><tr>{columns.map((title, index) => <th key={`${title}-${index}`}>{title}</th>)}</tr></thead>;
  854. }