|
@@ -6,12 +6,12 @@
|
|
|
* `plan_names`,后端 JOIN customer_region_mount+ops_team+order)⇒ 本页一次列表口即够,⛔ 逐行补详情;
|
|
* `plan_names`,后端 JOIN customer_region_mount+ops_team+order)⇒ 本页一次列表口即够,⛔ 逐行补详情;
|
|
|
* * 所属区域:列表口只给挂载节点 ID,路径由 `/region/tree@v1` 的 `nodes[].path_name` 字典解析,解析不到标「后端未下发」;
|
|
* * 所属区域:列表口只给挂载节点 ID,路径由 `/region/tree@v1` 的 `nodes[].path_name` 字典解析,解析不到标「后端未下发」;
|
|
|
* * 合伙人/套餐:字段已下发,`null`/空数组=业务上的「未绑定/无在用订阅」,⛔ 混作「后端未下发」;
|
|
* * 合伙人/套餐:字段已下发,`null`/空数组=业务上的「未绑定/无在用订阅」,⛔ 混作「后端未下发」;
|
|
|
- * * `/import_batch/get_list@v1` [实] ⛔ 下发文件名,计数为字符串,`batch_no` 当前恒 null;
|
|
|
|
|
- * * `/import_batch/template_download@v1` [实] 只回 `{format,columns,max_rows}`,⛔ `column_names`;
|
|
|
|
|
- * * 激活码导出的 `user_ids` 由 `/account/get_list@v1` [实](主体=customer 的成员账号)按批次行的
|
|
|
|
|
- * `business_id` 收窄得到;`/import_batch/export_codes@v1` [实] 已接平台 `bootstrap_credential/export@v1`,
|
|
|
|
|
- * 回 `items[]` 激活码**明文**清单(明文只随本次应答回显一次、平台侧不落库)⇒ 详情弹窗如实渲染明文与
|
|
|
|
|
- * 写操作/审计留痕提示,⛔ 把 `total=0` 说成导出成功。
|
|
|
|
|
|
|
+ * * `/import_batch/get_list@v1` [实] ⛔ 下发文件名,计数为字符串;台账「文件」列三态标「后端未下发」;
|
|
|
|
|
+ * * `/import_batch/template_download@v1` [实] 回 `{format,columns,column_names,sample_row,max_rows,fill_notes}`(GET/POST);
|
|
|
|
|
+ * * `/import_batch/resume@v1` 只认 `batch_no`(⛔ 只传 batch_id ⇒ 60004);
|
|
|
|
|
+ * * 导出客户/激活码的 `user_ids` 由 `/account/get_list@v1` [实](主体=customer 的成员账号)按批次行的
|
|
|
|
|
+ * `business_id` 收窄得到;无候选时⛔ 发请求,直接给空态;
|
|
|
|
|
+ * * 写入口(提交/续传)仅 admin/opsMain;opsSub 可读台账与导出;其余角色 URL 直达给出入口拒绝文案。
|
|
|
*/
|
|
*/
|
|
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
|
import { PageIntro } from "../components/PageIntro";
|
|
import { PageIntro } from "../components/PageIntro";
|
|
@@ -28,7 +28,7 @@ import { matchesRegionPath, regionPathTree } from "../lib/region-tree";
|
|
|
import { useLoad } from "../lib/useLoad";
|
|
import { useLoad } from "../lib/useLoad";
|
|
|
import { ApiError } from "../lib/api/http";
|
|
import { ApiError } from "../lib/api/http";
|
|
|
import { importBatchRowToDemo, importBatchToneOf, importRowDetailsToDemo, submitRowsToDemo, useCustomerDirectory, type DemoCustomer, type DemoImportBatch, type ImportRowResult } from "../lib/customer-demo";
|
|
import { importBatchRowToDemo, importBatchToneOf, importRowDetailsToDemo, submitRowsToDemo, useCustomerDirectory, type DemoCustomer, type DemoImportBatch, type ImportRowResult } from "../lib/customer-demo";
|
|
|
-import { IMPORT_HEADERS } from "../lib/import-batch-store";
|
|
|
|
|
|
|
+import { IMPORT_HEADERS, IMPORT_SAMPLE } from "../lib/import-batch-store";
|
|
|
import type { ExportResult, ImportRow } from "../lib/api/types";
|
|
import type { ExportResult, ImportRow } from "../lib/api/types";
|
|
|
import { accountGetList, importBatchExportCodes, importBatchExportCustomers, importBatchGet, importBatchGetList, importBatchResume, importBatchSubmit, importBatchTemplateDownload } from "../lib/api/bos";
|
|
import { accountGetList, importBatchExportCodes, importBatchExportCustomers, importBatchGet, importBatchGetList, importBatchResume, importBatchSubmit, importBatchTemplateDownload } from "../lib/api/bos";
|
|
|
import { claimExportUserIds, codeExportCell, codeExportView } from "../lib/customer-claim-export";
|
|
import { claimExportUserIds, codeExportCell, codeExportView } from "../lib/customer-claim-export";
|
|
@@ -37,8 +37,13 @@ import { invalidateCustomerList } from "../lib/customer-list-store";
|
|
|
import { fetchAllPages } from "../lib/fetch-all-pages";
|
|
import { fetchAllPages } from "../lib/fetch-all-pages";
|
|
|
import { ListPager } from "../components/ListPager";
|
|
import { ListPager } from "../components/ListPager";
|
|
|
import { slicePage, useLocalPage } from "../lib/list-paging";
|
|
import { slicePage, useLocalPage } from "../lib/list-paging";
|
|
|
|
|
+import { readWorkbookRows, sheetRowsToCsv, textWorkbook } from "../lib/xlsx-export";
|
|
|
|
|
+import { useSession } from "../auth/session";
|
|
|
import "../styles/operations.css";
|
|
import "../styles/operations.css";
|
|
|
|
|
|
|
|
|
|
+/** TC-CU-26:非总运营/区域运营主账号 URL 直达时的入口拒绝文案。 */
|
|
|
|
|
+const IMPORT_DENY = "只有总运营和区域运营可以批量导入客户。";
|
|
|
|
|
+
|
|
|
const d = (value: string) => value.replaceAll("-", ".");
|
|
const d = (value: string) => value.replaceAll("-", ".");
|
|
|
const MISSING = "后端未下发";
|
|
const MISSING = "后端未下发";
|
|
|
const FAILED = "取数失败";
|
|
const FAILED = "取数失败";
|
|
@@ -182,7 +187,7 @@ function CustomerDetail({ item, onClose }: { item: DemoCustomer; onClose: () =>
|
|
|
|
|
|
|
|
/* ══ 批量导入 ══════════════════════════════════════════════════════ */
|
|
/* ══ 批量导入 ══════════════════════════════════════════════════════ */
|
|
|
|
|
|
|
|
-/** 中文表头 → `ImportRow` 键(后端 14 列的对象键,⛔ 数组下标)。 */
|
|
|
|
|
|
|
+/** 中文表头 → `ImportRow` 键(现行 11 列;主账号两列暂不在模板内)。 */
|
|
|
const HEADER_TO_KEY: Record<string, keyof ImportRow> = {
|
|
const HEADER_TO_KEY: Record<string, keyof ImportRow> = {
|
|
|
客户名称: "customer_name",
|
|
客户名称: "customer_name",
|
|
|
主体类型: "subject_type",
|
|
主体类型: "subject_type",
|
|
@@ -194,8 +199,6 @@ const HEADER_TO_KEY: Record<string, keyof ImportRow> = {
|
|
|
运营商: "operator_name",
|
|
运营商: "operator_name",
|
|
|
合伙人: "partner_name",
|
|
合伙人: "partner_name",
|
|
|
运维团队: "ops_team_names",
|
|
运维团队: "ops_team_names",
|
|
|
- 主账号登录名: "primary_username",
|
|
|
|
|
- 主账号手机号: "primary_mobile",
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
function splitCsvLine(line: string): string[] {
|
|
function splitCsvLine(line: string): string[] {
|
|
@@ -253,6 +256,11 @@ function parseImportRows(text: string): { rows: ImportRow[]; skipCount: number;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export function ImportBatchPage() {
|
|
export function ImportBatchPage() {
|
|
|
|
|
+ const { ctx } = useSession();
|
|
|
|
|
+ /** 写入口与后端 submit/resume 允许集一致:仅 Admin/OpsMain(opsSub 可读+导出,⛔ 写入)。 */
|
|
|
|
|
+ const canImportWrite = ctx?.role_code === "admin" || ctx?.role_code === "opsMain";
|
|
|
|
|
+ /** 台账可读:Admin/OpsMain/OpsSub(与服务角色层一致);其余角色 URL 直达只给拒绝文案。 */
|
|
|
|
|
+ const canImportView = canImportWrite || ctx?.role_code === "opsSub";
|
|
|
const tableOverflow = useHorizontalOverflow();
|
|
const tableOverflow = useHorizontalOverflow();
|
|
|
const flexibleWidth = Math.max(1060, tableOverflow.width) - 300;
|
|
const flexibleWidth = Math.max(1060, tableOverflow.width) - 300;
|
|
|
const columnWidths = [flexibleWidth * .38, flexibleWidth * .27, 80, flexibleWidth * .35, 120, 100];
|
|
const columnWidths = [flexibleWidth * .38, flexibleWidth * .27, 80, flexibleWidth * .35, 120, 100];
|
|
@@ -260,6 +268,7 @@ export function ImportBatchPage() {
|
|
|
const list = useLoad(
|
|
const list = useLoad(
|
|
|
() => fetchAllPages((page, page_size) => importBatchGetList({ page, page_size })),
|
|
() => fetchAllPages((page, page_size) => importBatchGetList({ page, page_size })),
|
|
|
[tick],
|
|
[tick],
|
|
|
|
|
+ canImportView,
|
|
|
);
|
|
);
|
|
|
const records = useMemo(() => (list.data?.items ?? []).map(importBatchRowToDemo), [list.data]);
|
|
const records = useMemo(() => (list.data?.items ?? []).map(importBatchRowToDemo), [list.data]);
|
|
|
const [search, setSearch] = useState("");
|
|
const [search, setSearch] = useState("");
|
|
@@ -269,33 +278,71 @@ export function ImportBatchPage() {
|
|
|
const [notice, setNotice] = useState("");
|
|
const [notice, setNotice] = useState("");
|
|
|
const selected = records.find((item) => item.id === selectedId) ?? null;
|
|
const selected = records.find((item) => item.id === selectedId) ?? null;
|
|
|
const statusOptions = useMemo(() => [...new Set(records.map((item) => item.status).filter((v): v is string => Boolean(v)))], [records]);
|
|
const statusOptions = useMemo(() => [...new Set(records.map((item) => item.status).filter((v): v is string => Boolean(v)))], [records]);
|
|
|
- const filtered = useMemo(() => records.filter((item) =>
|
|
|
|
|
- (!status || item.status === status) &&
|
|
|
|
|
- `${item.id} ${item.batchNo ?? ""} ${item.importer ?? ""}`.toLowerCase().includes(search.trim().toLowerCase()),
|
|
|
|
|
- ), [records, status, search]);
|
|
|
|
|
|
|
+ const filtered = useMemo(() => {
|
|
|
|
|
+ const q = search.trim().toLowerCase();
|
|
|
|
|
+ return records.filter((item) => {
|
|
|
|
|
+ if (status && item.status !== status) return false;
|
|
|
|
|
+ if (!q) return true;
|
|
|
|
|
+ const at = item.createdAt ?? "";
|
|
|
|
|
+ const dateHay = `${at} ${at.replaceAll("-", ".")} ${at.slice(0, 10)} ${at.slice(0, 10).replaceAll("-", ".")}`;
|
|
|
|
|
+ const hay = `${item.id} ${item.batchNo ?? ""} ${item.importer ?? ""} ${item.customerNames ?? ""} ${dateHay}`.toLowerCase();
|
|
|
|
|
+ return hay.includes(q);
|
|
|
|
|
+ });
|
|
|
|
|
+ }, [records, status, search]);
|
|
|
const paging = useLocalPage(filtered.length);
|
|
const paging = useLocalPage(filtered.length);
|
|
|
- const pageRows = slicePage(filtered, paging.safePage);
|
|
|
|
|
|
|
+ const pageRows = slicePage(filtered, paging.safePage, paging.pageSize);
|
|
|
const hasFilter = Boolean(status || search);
|
|
const hasFilter = Boolean(status || search);
|
|
|
function reset() { setStatus(""); setSearch(""); paging.resetPage(); }
|
|
function reset() { setStatus(""); setSearch(""); paging.resetPage(); }
|
|
|
|
|
+ function refreshLedger() { setTick((t) => t + 1); }
|
|
|
|
|
|
|
|
- /** 模板口只回 `{format,columns,max_rows}`;`column_names` ⛔ 下发时以本地已约定的表头出文件并如实说明。 */
|
|
|
|
|
|
|
+ /** 模板:优先用后端 `column_names`/`sample_row`;按 `format` 落地 xlsx 或 csv,通知条与落盘文件口径一致。 */
|
|
|
async function downloadTemplate() {
|
|
async function downloadTemplate() {
|
|
|
try {
|
|
try {
|
|
|
const spec = await importBatchTemplateDownload();
|
|
const spec = await importBatchTemplateDownload();
|
|
|
const headers = spec.column_names?.length ? spec.column_names : IMPORT_HEADERS;
|
|
const headers = spec.column_names?.length ? spec.column_names : IMPORT_HEADERS;
|
|
|
- const csv = "\uFEFF" + headers.join(",") + "\r\n";
|
|
|
|
|
- const url = URL.createObjectURL(new Blob([csv], { type: "text/csv;charset=utf-8" }));
|
|
|
|
|
|
|
+ const sample = spec.sample_row?.length === headers.length ? spec.sample_row : IMPORT_SAMPLE.slice(0, headers.length);
|
|
|
|
|
+ const format = (spec.format || "xlsx").toLowerCase();
|
|
|
|
|
+ const ext = format === "xlsx" ? "xlsx" : format === "csv" ? "csv" : format;
|
|
|
const link = document.createElement("a");
|
|
const link = document.createElement("a");
|
|
|
- link.href = url; link.download = `客户批量导入模板.${spec.format === "xlsx" ? "csv" : spec.format}`; link.click();
|
|
|
|
|
- URL.revokeObjectURL(url);
|
|
|
|
|
- setNotice(`模板口径:格式 ${spec.format}/列数 ${spec.columns}/单批上限 ${spec.max_rows} 行。${spec.column_names?.length ? "列名由后端下发。" : `${MISSING}:模板列名由后端 template_download 接口下发,当前未下发,下载文件按前端约定表头生成。`}`);
|
|
|
|
|
|
|
+ if (ext === "xlsx") {
|
|
|
|
|
+ const bytes = textWorkbook([headers, sample], "客户导入");
|
|
|
|
|
+ const url = URL.createObjectURL(new Blob([bytes as BlobPart], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" }));
|
|
|
|
|
+ link.href = url;
|
|
|
|
|
+ link.download = "客户批量导入模板.xlsx";
|
|
|
|
|
+ link.click();
|
|
|
|
|
+ URL.revokeObjectURL(url);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ const csv = "\uFEFF" + [headers, sample].map((row) => row.map((cell) => {
|
|
|
|
|
+ const v = String(cell ?? "");
|
|
|
|
|
+ return /[",\n\r]/.test(v) ? `"${v.replaceAll("\"", "\"\"")}"` : v;
|
|
|
|
|
+ }).join(",")).join("\r\n") + "\r\n";
|
|
|
|
|
+ const url = URL.createObjectURL(new Blob([csv], { type: "text/csv;charset=utf-8" }));
|
|
|
|
|
+ link.href = url;
|
|
|
|
|
+ link.download = `客户批量导入模板.${ext}`;
|
|
|
|
|
+ link.click();
|
|
|
|
|
+ URL.revokeObjectURL(url);
|
|
|
|
|
+ }
|
|
|
|
|
+ const notes = (spec.fill_notes ?? []).filter(Boolean);
|
|
|
|
|
+ setNotice([
|
|
|
|
|
+ `模板口径:格式 ${spec.format}/列数 ${spec.columns}/单批上限 ${spec.max_rows} 行。`,
|
|
|
|
|
+ spec.column_names?.length ? "列名由后端下发。" : `${MISSING}:模板列名由后端 template_download 接口下发,当前未下发,下载文件按前端约定表头生成。`,
|
|
|
|
|
+ "含示例行(行编号=示例,上传时自动跳过)。",
|
|
|
|
|
+ notes.length ? `填写注意:${notes.join(";")}` : "",
|
|
|
|
|
+ ].filter(Boolean).join(""));
|
|
|
} catch (e) {
|
|
} catch (e) {
|
|
|
setNotice((e as ApiError).message ?? FAILED);
|
|
setNotice((e as ApiError).message ?? FAILED);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if (!canImportView) {
|
|
|
|
|
+ return <section className="ops-page ops-page--imports page-fill">
|
|
|
|
|
+ <header className="ops-heading"><div><p className="ops-eyebrow"><span /> IMPORT BATCHES / 客户与订阅</p><h1>批量导入</h1></div></header>
|
|
|
|
|
+ <div className="ops-empty" role="status"><Info size={27} /><h3>无法批量导入</h3><p>{IMPORT_DENY}</p></div>
|
|
|
|
|
+ </section>;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return <section className="ops-page ops-page--imports page-fill">
|
|
return <section className="ops-page ops-page--imports page-fill">
|
|
|
- <header className="ops-heading"><div><p className="ops-eyebrow"><span /> IMPORT BATCHES / 客户与订阅</p><h1>批量导入</h1><PageIntro>用模板一次录入多家客户,导入后按批次核对成功和失败记录。</PageIntro></div><div className="ops-head-actions"><Button variant="outline" onClick={() => void downloadTemplate()}><Download size={16} />下载导入模板</Button><Button onClick={() => setFlow({ mode: "new" })}><Upload size={16} />批量导入客户</Button></div></header>
|
|
|
|
|
|
|
+ <header className="ops-heading"><div><p className="ops-eyebrow"><span /> IMPORT BATCHES / 客户与订阅</p><h1>批量导入</h1><PageIntro>用模板一次录入多家客户,导入后按批次核对成功和失败记录。</PageIntro></div><div className="ops-head-actions"><Button variant="outline" onClick={() => void downloadTemplate()}><Download size={16} />下载导入模板</Button>{canImportWrite ? <Button onClick={() => setFlow({ mode: "new" })}><Upload size={16} />批量导入客户</Button> : <p className="ops-import-note" role="status">{IMPORT_DENY}</p>}</div></header>
|
|
|
<div className="ops-list-shell list-shell-fill">
|
|
<div className="ops-list-shell list-shell-fill">
|
|
|
<LoadFail error={list.error} onRetry={list.reload} />
|
|
<LoadFail error={list.error} onRetry={list.reload} />
|
|
|
<Toolbar search={search} onSearch={(value) => { setSearch(value); paging.resetPage(); }}>
|
|
<Toolbar search={search} onSearch={(value) => { setSearch(value); paging.resetPage(); }}>
|
|
@@ -303,23 +350,23 @@ export function ImportBatchPage() {
|
|
|
{hasFilter && <Button variant="ghost" size="sm" onClick={reset}>重置筛选</Button>}
|
|
{hasFilter && <Button variant="ghost" size="sm" onClick={reset}>重置筛选</Button>}
|
|
|
</Toolbar>
|
|
</Toolbar>
|
|
|
<div ref={tableOverflow.ref} tabIndex={0} role="region" aria-label="导入批次台账,可横向滚动查看字段" className={`measured-table-scroll ops-table-wrap import-ledger-scroll${tableOverflow.overflow ? " has-horizontal-overflow" : ""}${tableOverflow.width >= 640 ? " can-pin-identity" : ""}${tableOverflow.canScrollLeft ? " can-scroll-left" : ""}${tableOverflow.canScrollRight ? " can-scroll-right" : ""}`}><table className="ops-table import-ledger"><OpsTableColumns widths={columnWidths} /><thead><tr><th>批次号 / 文件</th><th>导入时间 / 导入人</th><th>总行数</th><th>成功 / 失败</th><th>状态</th><th>操作</th></tr></thead><tbody>{pageRows.map((item) => <tr key={item.id}>
|
|
<div ref={tableOverflow.ref} tabIndex={0} role="region" aria-label="导入批次台账,可横向滚动查看字段" className={`measured-table-scroll ops-table-wrap import-ledger-scroll${tableOverflow.overflow ? " has-horizontal-overflow" : ""}${tableOverflow.width >= 640 ? " can-pin-identity" : ""}${tableOverflow.canScrollLeft ? " can-scroll-left" : ""}${tableOverflow.canScrollRight ? " can-scroll-right" : ""}`}><table className="ops-table import-ledger"><OpsTableColumns widths={columnWidths} /><thead><tr><th>批次号 / 文件</th><th>导入时间 / 导入人</th><th>总行数</th><th>成功 / 失败</th><th>状态</th><th>操作</th></tr></thead><tbody>{pageRows.map((item) => <tr key={item.id}>
|
|
|
- <td><strong title={item.id}>{item.batchNo ?? item.id}</strong><small title={item.id}>{item.id}</small></td>
|
|
|
|
|
|
|
+ <td><strong title={item.id}>{item.batchNo ?? item.id}</strong><small title={item.file ?? undefined}>{item.file ?? <Tri tone="missing" text={MISSING} title={`${MISSING}:本批次未回 file_name(历史批次或提交时未传)`} />}</small></td>
|
|
|
<td><strong className="ops-money">{item.createdAt ? d(item.createdAt) : <Tri tone="missing" text={MISSING} />}</strong><small title={item.importer ?? undefined}>{item.importer ?? <Tri tone="missing" text={MISSING} />}</small></td>
|
|
<td><strong className="ops-money">{item.createdAt ? d(item.createdAt) : <Tri tone="missing" text={MISSING} />}</strong><small title={item.importer ?? undefined}>{item.importer ?? <Tri tone="missing" text={MISSING} />}</small></td>
|
|
|
<td><span className="ops-money">{item.total ?? <Tri tone="missing" text={MISSING} />}</span></td>
|
|
<td><span className="ops-money">{item.total ?? <Tri tone="missing" text={MISSING} />}</span></td>
|
|
|
<td><div className="ops-import-count"><strong>{item.ok ?? <Tri tone="missing" text={MISSING} />} 成功</strong><span>{item.fail ?? <Tri tone="missing" text={MISSING} />} 失败</span></div><div className="ops-import-meter" role="img" aria-label={`成功 ${item.ok ?? 0} 行,失败 ${item.fail ?? 0} 行`}><i style={{ width: `${item.total && item.ok !== null ? item.ok / item.total * 100 : 0}%` }} /></div></td>
|
|
<td><div className="ops-import-count"><strong>{item.ok ?? <Tri tone="missing" text={MISSING} />} 成功</strong><span>{item.fail ?? <Tri tone="missing" text={MISSING} />} 失败</span></div><div className="ops-import-meter" role="img" aria-label={`成功 ${item.ok ?? 0} 行,失败 ${item.fail ?? 0} 行`}><i style={{ width: `${item.total && item.ok !== null ? item.ok / item.total * 100 : 0}%` }} /></div></td>
|
|
|
<td>{item.status ? <OpsStatus tone={importBatchToneOf(item.status)}>{item.status}</OpsStatus> : <Tri tone="missing" text={MISSING} />}</td>
|
|
<td>{item.status ? <OpsStatus tone={importBatchToneOf(item.status)}>{item.status}</OpsStatus> : <Tri tone="missing" text={MISSING} />}</td>
|
|
|
<td><div className="ops-inline-actions"><button type="button" onClick={() => setSelectedId(item.id)}>详情</button></div></td>
|
|
<td><div className="ops-inline-actions"><button type="button" onClick={() => setSelectedId(item.id)}>详情</button></div></td>
|
|
|
</tr>)}</tbody></table></div>
|
|
</tr>)}</tbody></table></div>
|
|
|
- <ListPager total={filtered.length} page={paging.safePage} pageSize={paging.pageSize} onPageChange={paging.setPage} unit="条" />
|
|
|
|
|
|
|
+ <ListPager total={filtered.length} page={paging.safePage} pageSize={paging.pageSize} onPageChange={paging.setPage} onPageSizeChange={paging.setPageSize} unit="条" />
|
|
|
{!filtered.length && !list.loading && <Empty reset={reset} />}
|
|
{!filtered.length && !list.loading && <Empty reset={reset} />}
|
|
|
</div>
|
|
</div>
|
|
|
- {selected && <BatchDetailDialog item={selected} onClose={() => setSelectedId(null)} onResume={() => { const batch = selected; setSelectedId(null); setFlow({ mode: "resume", batch }); }} onReload={() => setTick((t) => t + 1)} />}
|
|
|
|
|
- {flow && <ImportBatchFlow resume={flow.mode === "resume" ? flow.batch : null} onClose={() => setFlow(null)} onDone={() => { setTick((t) => t + 1); setFlow(null); }} onTemplate={() => void downloadTemplate()} />}
|
|
|
|
|
|
|
+ {selected && <BatchDetailDialog item={selected} canWrite={canImportWrite} onClose={() => setSelectedId(null)} onResume={() => { const batch = selected; setSelectedId(null); setFlow({ mode: "resume", batch }); }} onReload={refreshLedger} />}
|
|
|
|
|
+ {flow && canImportWrite && <ImportBatchFlow resume={flow.mode === "resume" ? flow.batch : null} onClose={() => { refreshLedger(); setFlow(null); }} onDone={() => { refreshLedger(); setFlow(null); }} onTemplate={() => void downloadTemplate()} />}
|
|
|
{notice && <OpsNotice message={notice} onClose={() => setNotice("")} />}
|
|
{notice && <OpsNotice message={notice} onClose={() => setNotice("")} />}
|
|
|
</section>;
|
|
</section>;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/** 三阶段流程:上传/粘贴 → 提交校验(`/import_batch/submit@v1`)→ 确认写入(`/import_batch/resume@v1`)。 */
|
|
|
|
|
|
|
+/** 三阶段流程:上传/粘贴 → 提交校验(`/import_batch/submit@v1`)→ 确认写入(`/import_batch/resume@v1`,入参 `batch_no`)。 */
|
|
|
function ImportBatchFlow({ resume, onClose, onDone, onTemplate }: {
|
|
function ImportBatchFlow({ resume, onClose, onDone, onTemplate }: {
|
|
|
resume: DemoImportBatch | null;
|
|
resume: DemoImportBatch | null;
|
|
|
onClose: () => void;
|
|
onClose: () => void;
|
|
@@ -332,24 +379,47 @@ function ImportBatchFlow({ resume, onClose, onDone, onTemplate }: {
|
|
|
const [error, setError] = useState("");
|
|
const [error, setError] = useState("");
|
|
|
const [rows, setRows] = useState<ImportRow[]>([]);
|
|
const [rows, setRows] = useState<ImportRow[]>([]);
|
|
|
const [skipCount, setSkipCount] = useState(0);
|
|
const [skipCount, setSkipCount] = useState(0);
|
|
|
- const [batchId, setBatchId] = useState("");
|
|
|
|
|
|
|
+ const [batchNo, setBatchNo] = useState(resume?.batchNo ?? "");
|
|
|
const [checked, setChecked] = useState<ImportRowResult[]>([]);
|
|
const [checked, setChecked] = useState<ImportRowResult[]>([]);
|
|
|
const [pendingNote, setPendingNote] = useState("");
|
|
const [pendingNote, setPendingNote] = useState("");
|
|
|
const [busy, setBusy] = useState(false);
|
|
const [busy, setBusy] = useState(false);
|
|
|
const [done, setDone] = useState<{ text: string } | null>(null);
|
|
const [done, setDone] = useState<{ text: string } | null>(null);
|
|
|
|
|
+ const textWinsOverFile = Boolean(text.trim() && file);
|
|
|
|
|
+
|
|
|
|
|
+ async function fileToCsvText(picked: File): Promise<string> {
|
|
|
|
|
+ if (/\.xlsx$/i.test(picked.name) || picked.type.includes("spreadsheetml")) {
|
|
|
|
|
+ const rows = await readWorkbookRows(await picked.arrayBuffer());
|
|
|
|
|
+ return sheetRowsToCsv(rows);
|
|
|
|
|
+ }
|
|
|
|
|
+ return picked.text();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
async function runParse() {
|
|
async function runParse() {
|
|
|
setError("");
|
|
setError("");
|
|
|
- const source = text.trim() ? text : (file ? await file.text() : "");
|
|
|
|
|
|
|
+ let source = "";
|
|
|
|
|
+ let sourceName = "";
|
|
|
|
|
+ try {
|
|
|
|
|
+ if (text.trim()) {
|
|
|
|
|
+ source = text;
|
|
|
|
|
+ sourceName = "粘贴录入";
|
|
|
|
|
+ } else if (file) {
|
|
|
|
|
+ source = await fileToCsvText(file);
|
|
|
|
|
+ sourceName = file.name;
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ setError(e instanceof Error ? e.message : "文件解析失败。");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
if (!source) { setError("请先选择文件或粘贴表格内容。"); return; }
|
|
if (!source) { setError("请先选择文件或粘贴表格内容。"); return; }
|
|
|
const outcome = parseImportRows(source);
|
|
const outcome = parseImportRows(source);
|
|
|
if (outcome.error) { setError(outcome.error); return; }
|
|
if (outcome.error) { setError(outcome.error); return; }
|
|
|
setBusy(true);
|
|
setBusy(true);
|
|
|
try {
|
|
try {
|
|
|
- const result = await importBatchSubmit({ rows: outcome.rows });
|
|
|
|
|
|
|
+ const result = await importBatchSubmit({ rows: outcome.rows, file_name: sourceName || undefined });
|
|
|
setRows(outcome.rows);
|
|
setRows(outcome.rows);
|
|
|
setSkipCount(outcome.skipCount);
|
|
setSkipCount(outcome.skipCount);
|
|
|
- setBatchId(resume?.id ?? result.batch_id);
|
|
|
|
|
|
|
+ // 续传必须带原批次 `batch_no`(⛔ 回落到本次 submit 新批次号);新建取 submit 回执。
|
|
|
|
|
+ setBatchNo(resume ? (resume.batchNo ?? "") : (result.batch_no || ""));
|
|
|
setChecked(submitRowsToDemo(result.rows));
|
|
setChecked(submitRowsToDemo(result.rows));
|
|
|
setPendingNote([
|
|
setPendingNote([
|
|
|
result.region_match_note,
|
|
result.region_match_note,
|
|
@@ -368,15 +438,15 @@ function ImportBatchFlow({ resume, onClose, onDone, onTemplate }: {
|
|
|
const failCount = checked.length - okCount;
|
|
const failCount = checked.length - okCount;
|
|
|
|
|
|
|
|
async function confirm() {
|
|
async function confirm() {
|
|
|
- if (!batchId) { setError(`${MISSING}:submit 未回 batch_id,无法写入。`); return; }
|
|
|
|
|
|
|
+ if (!batchNo) { setError(`${MISSING}:submit 未回 batch_no,无法写入。`); return; }
|
|
|
setBusy(true);
|
|
setBusy(true);
|
|
|
setError("");
|
|
setError("");
|
|
|
try {
|
|
try {
|
|
|
const target = resume ? rows : rows.filter((_, index) => checked[index]?.ok);
|
|
const target = resume ? rows : rows.filter((_, index) => checked[index]?.ok);
|
|
|
- const result = resume ? await importBatchResume({ batch_id: batchId, rows }) : await importBatchResume({ batch_id: batchId, rows: target });
|
|
|
|
|
|
|
+ const result = await importBatchResume({ batch_no: batchNo, rows: resume ? rows : target });
|
|
|
const summary = result.summary ?? { status: "", total_rows: "", success_rows: "", fail_rows: "" };
|
|
const summary = result.summary ?? { status: "", total_rows: "", success_rows: "", fail_rows: "" };
|
|
|
setDone({
|
|
setDone({
|
|
|
- text: `批次 ${result.batch_no || batchId} 写入完成:本次更新 ${result.updated_rows ?? 0} 行、新增 ${result.inserted_rows ?? 0} 行、沿用已导入 ${result.already_imported_rows ?? 0} 行;库内汇总 状态 ${summary.status || MISSING}/总 ${summary.total_rows || MISSING}/成功 ${summary.success_rows || MISSING}/失败 ${summary.fail_rows || MISSING}。`,
|
|
|
|
|
|
|
+ text: `批次 ${result.batch_no || batchNo} 写入完成:本次更新 ${result.updated_rows ?? 0} 行、新增 ${result.inserted_rows ?? 0} 行、沿用已导入 ${result.already_imported_rows ?? 0} 行;库内汇总 状态 ${summary.status || MISSING}/总 ${summary.total_rows || MISSING}/成功 ${summary.success_rows || MISSING}/失败 ${summary.fail_rows || MISSING}。`,
|
|
|
});
|
|
});
|
|
|
// 批量导入会新建客户 ⇒ 共享快照作废,客户台账下次读取真重取(缺口清单 C-8)。
|
|
// 批量导入会新建客户 ⇒ 共享快照作废,客户台账下次读取真重取(缺口清单 C-8)。
|
|
|
invalidateCustomerList();
|
|
invalidateCustomerList();
|
|
@@ -390,14 +460,16 @@ function ImportBatchFlow({ resume, onClose, onDone, onTemplate }: {
|
|
|
|
|
|
|
|
return <div className="ops-confirm-backdrop" role="presentation" onMouseDown={onClose}>
|
|
return <div className="ops-confirm-backdrop" role="presentation" onMouseDown={onClose}>
|
|
|
<div className="ops-import-dialog" role="dialog" aria-modal="true" aria-labelledby="import-flow-title" onMouseDown={(event) => event.stopPropagation()}>
|
|
<div className="ops-import-dialog" role="dialog" aria-modal="true" aria-labelledby="import-flow-title" onMouseDown={(event) => event.stopPropagation()}>
|
|
|
- <header><div><p>批量导入 / {phase === "preview" ? "校验预览" : phase === "done" ? "提交结果" : "客户建档"}</p><h2 id="import-flow-title">{resume ? `续传批次 ${resume.id}` : phase === "done" ? "导入完成" : "批量导入客户"}</h2></div>{phase !== "done" && <Button variant="ghost" size="icon" aria-label="关闭" onClick={onClose}><X size={18} /></Button>}</header>
|
|
|
|
|
|
|
+ <header><div><p>批量导入 / {phase === "preview" ? "校验预览" : phase === "done" ? "提交结果" : "客户建档"}</p><h2 id="import-flow-title">{resume ? `续传批次 ${resume.batchNo ?? resume.id}` : phase === "done" ? "导入完成" : "批量导入客户"}</h2></div>{phase !== "done" && <Button variant="ghost" size="icon" aria-label="关闭" onClick={onClose}><X size={18} /></Button>}</header>
|
|
|
<div className="ops-import-dialog-body">
|
|
<div className="ops-import-dialog-body">
|
|
|
{phase === "input" && <>
|
|
{phase === "input" && <>
|
|
|
- <p className="ops-import-note">按模板填写后上传文件,或直接粘贴表格内容(首行为表头)。{resume ? `本次为批次 ${resume.id} 的续传:按行编号覆盖原行重新校验。` : "一次上传一个文件生成一个批次,批次号由后端返回。"}</p>
|
|
|
|
|
- <p className="ops-import-note">表头列名须与模板一致(前端约定):{IMPORT_HEADERS.join(" / ")}。行编号为「示例」的行自动跳过;「运维团队」只可填 1 支团队名(必填,不得用「;」填多支),多填或漏填的行前端逐行拦下不提交。单批上限由后端 <code>template_download</code> 下发。</p>
|
|
|
|
|
|
|
+ <p className="ops-import-note">按模板填写后上传文件,或直接粘贴表格内容(首行为表头)。{resume ? `本次为批次 ${resume.batchNo ?? resume.id} 的续传:按行编号覆盖原行重新校验。` : "一次上传一个文件生成一个批次,批次号由后端返回。"}</p>
|
|
|
|
|
+ <p className="ops-import-note">表头列名须与模板一致(现行 11 列):{IMPORT_HEADERS.join(" / ")}。行编号为「示例」的行自动跳过;「运维团队」只可填 1 支团队名(必填,不得用「;」填多支),多填或漏填的行前端逐行拦下不提交;「所挂区域」可填区域中文名或 node_id。主账号开通不在批量导入模板内(平台建号通路阻塞,见 18 册)。单批上限由后端 <code>template_download</code> 下发。可直接上传 .xlsx/.csv/.txt,或粘贴表格内容。</p>
|
|
|
<div><Button variant="outline" size="sm" onClick={onTemplate}><Download size={15} />下载导入模板</Button></div>
|
|
<div><Button variant="outline" size="sm" onClick={onTemplate}><Download size={15} />下载导入模板</Button></div>
|
|
|
- <label className="ops-import-pick">选择文件(按 CSV 解析)<input type="file" accept=".csv,.txt" onChange={(event) => { const next = event.target.files?.[0]; event.target.value = ""; setFile(next ?? null); }} /></label>
|
|
|
|
|
|
|
+ <label className="ops-import-pick">选择文件(.xlsx/.csv/.txt)<input type="file" accept=".xlsx,.csv,.txt,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,text/csv,text/plain" onChange={(event) => { const next = event.target.files?.[0]; event.target.value = ""; setFile(next ?? null); }} /></label>
|
|
|
<label className="ops-import-note">或粘贴表格内容(首行为表头)<textarea className="ops-import-text" rows={7} value={text} onChange={(event) => setText(event.target.value)} placeholder={`${IMPORT_HEADERS.slice(0, 6).join(",")}…`} /></label>
|
|
<label className="ops-import-note">或粘贴表格内容(首行为表头)<textarea className="ops-import-text" rows={7} value={text} onChange={(event) => setText(event.target.value)} placeholder={`${IMPORT_HEADERS.slice(0, 6).join(",")}…`} /></label>
|
|
|
|
|
+ {textWinsOverFile && <p className="ops-import-note" role="status">已粘贴文本时以文本为准,所选文件「{file?.name}」本次不参与解析;若要用文件请先清空文本框。</p>}
|
|
|
|
|
+ {file && !text.trim() && <p className="ops-import-note">已选文件:{file.name}</p>}
|
|
|
{error && <p className="ops-form-error" role="alert">{error}</p>}
|
|
{error && <p className="ops-form-error" role="alert">{error}</p>}
|
|
|
</>}
|
|
</>}
|
|
|
{phase === "preview" && <>
|
|
{phase === "preview" && <>
|
|
@@ -426,17 +498,24 @@ function ImportBatchFlow({ resume, onClose, onDone, onTemplate }: {
|
|
|
</div>;
|
|
</div>;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/** 终态状态:非终态时有限次轮询(关闭即取消,⛔ 常驻轮询)。 */
|
|
|
|
|
-const TERMINAL_STATUS = ["completed", "success", "finished", "failed", "partial", "done"];
|
|
|
|
|
|
|
+/** 终态状态:非终态时有限次轮询(关闭即取消,⛔ 常驻轮询)。含 `failed_pending`(部分成功)。 */
|
|
|
|
|
+const TERMINAL_STATUS = ["completed", "success", "finished", "failed", "partial", "done", "failed_pending"];
|
|
|
const POLL_INTERVAL_MS = 4000;
|
|
const POLL_INTERVAL_MS = 4000;
|
|
|
const POLL_MAX = 5;
|
|
const POLL_MAX = 5;
|
|
|
|
|
|
|
|
-function BatchDetailDialog({ item, onClose, onResume, onReload }: { item: DemoImportBatch; onClose: () => void; onResume: () => void; onReload: () => void }) {
|
|
|
|
|
|
|
+function BatchDetailDialog({ item, canWrite, onClose, onResume, onReload }: {
|
|
|
|
|
+ item: DemoImportBatch;
|
|
|
|
|
+ canWrite: boolean;
|
|
|
|
|
+ onClose: () => void;
|
|
|
|
|
+ onResume: () => void;
|
|
|
|
|
+ onReload: () => void;
|
|
|
|
|
+}) {
|
|
|
const [error, setError] = useState("");
|
|
const [error, setError] = useState("");
|
|
|
const [detail, setDetail] = useState<DemoImportBatch | null>(null);
|
|
const [detail, setDetail] = useState<DemoImportBatch | null>(null);
|
|
|
const [rows, setRows] = useState<ImportRowResult[] | null>(null);
|
|
const [rows, setRows] = useState<ImportRowResult[] | null>(null);
|
|
|
const [customerIds, setCustomerIds] = useState<string[]>([]);
|
|
const [customerIds, setCustomerIds] = useState<string[]>([]);
|
|
|
const [codesBusy, setCodesBusy] = useState(false);
|
|
const [codesBusy, setCodesBusy] = useState(false);
|
|
|
|
|
+ const [customersBusy, setCustomersBusy] = useState(false);
|
|
|
const [codesDone, setCodesDone] = useState("");
|
|
const [codesDone, setCodesDone] = useState("");
|
|
|
/** 导出应答(含明文清单)与 `user_id`→登录名对照:明文只随本次应答回显一次,关闭弹窗即丢。 */
|
|
/** 导出应答(含明文清单)与 `user_id`→登录名对照:明文只随本次应答回显一次,关闭弹窗即丢。 */
|
|
|
const [codes, setCodes] = useState<ExportResult | null>(null);
|
|
const [codes, setCodes] = useState<ExportResult | null>(null);
|
|
@@ -477,13 +556,32 @@ function BatchDetailDialog({ item, onClose, onResume, onReload }: { item: DemoIm
|
|
|
const view = detail ?? item;
|
|
const view = detail ?? item;
|
|
|
const shownRows = rows ?? item.rows;
|
|
const shownRows = rows ?? item.rows;
|
|
|
|
|
|
|
|
|
|
+ /** 批次行 business_id → 账号列表收窄 user_ids;无候选时返回空数组(调用方⛔ 发导出请求)。 */
|
|
|
|
|
+ async function resolveExportUserIds(): Promise<string[]> {
|
|
|
|
|
+ if (!customerIds.length) return [];
|
|
|
|
|
+ const accounts = await fetchAllPages((page, page_size) => accountGetList({ page, page_size, subject_type: "customer" }));
|
|
|
|
|
+ return claimExportUserIds(accounts.items, customerIds);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
async function exportCustomers() {
|
|
async function exportCustomers() {
|
|
|
setError("");
|
|
setError("");
|
|
|
|
|
+ if (!customerIds.length) {
|
|
|
|
|
+ setError("本批次暂无可导出的已建档客户(行明细未回客户主体号)。");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ setCustomersBusy(true);
|
|
|
try {
|
|
try {
|
|
|
- const res = await importBatchExportCustomers({ batch_id: item.id });
|
|
|
|
|
|
|
+ const userIds = await resolveExportUserIds();
|
|
|
|
|
+ if (!userIds.length) {
|
|
|
|
|
+ setError(`本批次暂无可导出的已建档客户:${customerIds.length} 家客户在账号列表中没有可导出的成员账号。`);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ const res = await importBatchExportCustomers({ batch_id: item.id, user_ids: userIds });
|
|
|
if (!saveExport(res)) setError(`${MISSING}:/import_batch/export_customers@v1 未回 download_url 或 content_base64。`);
|
|
if (!saveExport(res)) setError(`${MISSING}:/import_batch/export_customers@v1 未回 download_url 或 content_base64。`);
|
|
|
} catch (e) {
|
|
} catch (e) {
|
|
|
setError((e as ApiError).message ?? FAILED);
|
|
setError((e as ApiError).message ?? FAILED);
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ setCustomersBusy(false);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -492,12 +590,12 @@ function BatchDetailDialog({ item, onClose, onResume, onReload }: { item: DemoIm
|
|
|
setError("");
|
|
setError("");
|
|
|
setCodesDone("");
|
|
setCodesDone("");
|
|
|
setCodes(null);
|
|
setCodes(null);
|
|
|
- if (!customerIds.length) { setError(`${MISSING}:本批次未回行级客户主体号,无法确定导出账号范围。`); return; }
|
|
|
|
|
|
|
+ if (!customerIds.length) { setError("本批次暂无可导出的已建档客户(行明细未回客户主体号)。"); return; }
|
|
|
setCodesBusy(true);
|
|
setCodesBusy(true);
|
|
|
try {
|
|
try {
|
|
|
const accounts = await fetchAllPages((page, page_size) => accountGetList({ page, page_size, subject_type: "customer" }));
|
|
const accounts = await fetchAllPages((page, page_size) => accountGetList({ page, page_size, subject_type: "customer" }));
|
|
|
const userIds = claimExportUserIds(accounts.items, customerIds);
|
|
const userIds = claimExportUserIds(accounts.items, customerIds);
|
|
|
- if (!userIds.length) { setError(`本批次 ${customerIds.length} 家客户在账号列表中没有可导出的成员账号。`); return; }
|
|
|
|
|
|
|
+ if (!userIds.length) { setError(`本批次暂无可导出的已建档客户:${customerIds.length} 家客户在账号列表中没有可导出的成员账号。`); return; }
|
|
|
setCodeOwners(new Map(accounts.items.map((account) => [account.user_id, account.username])));
|
|
setCodeOwners(new Map(accounts.items.map((account) => [account.user_id, account.username])));
|
|
|
// scope 由服务端派生(end_user +项目空间 ID),⛔ 前端传;validity 固定 valid=只导仍有效的码
|
|
// scope 由服务端派生(end_user +项目空间 ID),⛔ 前端传;validity 固定 valid=只导仍有效的码
|
|
|
// (平台合法值;⛔ active),expired/all 会先作废再换新码。
|
|
// (平台合法值;⛔ active),expired/all 会先作废再换新码。
|
|
@@ -521,14 +619,14 @@ function BatchDetailDialog({ item, onClose, onResume, onReload }: { item: DemoIm
|
|
|
<div className="ops-batch-dialog" role="dialog" aria-modal="true" aria-labelledby="batch-detail-title" onMouseDown={(event) => event.stopPropagation()}>
|
|
<div className="ops-batch-dialog" role="dialog" aria-modal="true" aria-labelledby="batch-detail-title" onMouseDown={(event) => event.stopPropagation()}>
|
|
|
<header><div><p>导入批次 / 批次详情</p><h2 id="batch-detail-title">{view.batchNo ?? view.id}</h2></div><Button variant="ghost" size="icon" aria-label="关闭" onClick={onClose}><X size={18} /></Button></header>
|
|
<header><div><p>导入批次 / 批次详情</p><h2 id="batch-detail-title">{view.batchNo ?? view.id}</h2></div><Button variant="ghost" size="icon" aria-label="关闭" onClick={onClose}><X size={18} /></Button></header>
|
|
|
<div className="ops-batch-dialog-body">{error && <p role="alert" className="ops-form-error">{error}</p>}
|
|
<div className="ops-batch-dialog-body">{error && <p role="alert" className="ops-form-error">{error}</p>}
|
|
|
- <p className="ops-import-note">批次 id <code>{view.id}</code> · 文件 {view.file ?? <Tri tone="missing" text={MISSING} title={`${MISSING}:/import_batch/get_list@v1 与 /get@v1 均不下发文件名`} />} · 导入人 {view.importer ?? <Tri tone="missing" text={MISSING} />} · {view.createdAt ? d(view.createdAt) : <Tri tone="missing" text={MISSING} />} · 总 {view.total ?? <Tri tone="missing" text={MISSING} />} 行,成功 {view.ok ?? <Tri tone="missing" text={MISSING} />} 行、失败 {view.fail ?? <Tri tone="missing" text={MISSING} />} 行 · 状态 {view.status ? <OpsStatus tone={importBatchToneOf(view.status)}>{view.status}</OpsStatus> : <Tri tone="missing" text={MISSING} />}</p>
|
|
|
|
|
|
|
+ <p className="ops-import-note">批次 id <code>{view.id}</code> · 文件 {view.file ?? <Tri tone="missing" text={MISSING} title={`${MISSING}:本批次未回 file_name(历史批次或提交时未传)`} />} · 导入人 {view.importer ?? <Tri tone="missing" text={MISSING} />} · {view.createdAt ? d(view.createdAt) : <Tri tone="missing" text={MISSING} />} · 总 {view.total ?? <Tri tone="missing" text={MISSING} />} 行,成功 {view.ok ?? <Tri tone="missing" text={MISSING} />} 行、失败 {view.fail ?? <Tri tone="missing" text={MISSING} />} 行 · 状态 {view.status ? <OpsStatus tone={importBatchToneOf(view.status)}>{view.status}</OpsStatus> : <Tri tone="missing" text={MISSING} />}</p>
|
|
|
{statusCounts.length > 0 && <p className="ops-import-note">校验态分布:{statusCounts.map((s) => `${s.validate_status} ${s.count}`).join(" / ")}</p>}
|
|
{statusCounts.length > 0 && <p className="ops-import-note">校验态分布:{statusCounts.map((s) => `${s.validate_status} ${s.count}`).join(" / ")}</p>}
|
|
|
{!polls && !shownRows && <p className="ops-import-note">行级明细加载中…</p>}
|
|
{!polls && !shownRows && <p className="ops-import-note">行级明细加载中…</p>}
|
|
|
<div className="ops-table-wrap"><table className="ops-table" style={{ minWidth: 560 }}><thead><tr><th>行编号</th><th>校验态</th><th>业务号</th><th>说明</th></tr></thead><tbody>{(shownRows ?? []).map((row) => <tr key={row.no}>
|
|
<div className="ops-table-wrap"><table className="ops-table" style={{ minWidth: 560 }}><thead><tr><th>行编号</th><th>校验态</th><th>业务号</th><th>说明</th></tr></thead><tbody>{(shownRows ?? []).map((row) => <tr key={row.no}>
|
|
|
<td><span className="ops-mono">{row.no}</span></td>
|
|
<td><span className="ops-mono">{row.no}</span></td>
|
|
|
<td>{row.status ? <OpsStatus tone={row.ok ? "success" : "danger"}>{row.status}</OpsStatus> : <Tri tone="missing" text={MISSING} />}</td>
|
|
<td>{row.status ? <OpsStatus tone={row.ok ? "success" : "danger"}>{row.status}</OpsStatus> : <Tri tone="missing" text={MISSING} />}</td>
|
|
|
- <td><span title="后端行明细下发 business_id(建档后的客户主体号),本表按映射后的行数据展示,该值用于收窄激活码导出范围">{MISSING}</span></td>
|
|
|
|
|
- <td className="ops-detail-note-cell">{row.reason ?? (row.ok ? "校验通过" : MISSING)}</td>
|
|
|
|
|
|
|
+ <td>{row.businessId ? <span className="ops-mono" title="行明细 business_id(建档后的客户主体号),用于收窄导出账号范围">{row.businessId}</span> : <Tri tone="missing" text={MISSING} title={row.ok ? "该行已导入但未下发 business_id" : "未建档成功的行无客户主体号"} />}</td>
|
|
|
|
|
+ <td className="ops-detail-note-cell">{row.reason ?? (row.ok ? (row.status === "已导入" ? "已导入" : "校验通过") : "无失败原因")}</td>
|
|
|
</tr>)}{!shownRows?.length && <OpsTableEmpty colSpan={4}>{error ? "行级明细取数失败。" : "后端未回行级明细。"}</OpsTableEmpty>}</tbody></table></div>
|
|
</tr>)}{!shownRows?.length && <OpsTableEmpty colSpan={4}>{error ? "行级明细取数失败。" : "后端未回行级明细。"}</OpsTableEmpty>}</tbody></table></div>
|
|
|
<p className="ops-import-note">行级明细来自 <code>POST /import_batch/get@v1</code>(不回传原始 14 列,只给校验态与错误清单)。续传按原行编号覆盖重导;批次不删除、不撤销。激活码清单按行明细下发的客户主体号,经 <code>/account/get_list@v1</code> 收窄账号范围后由 <code>/import_batch/export_codes@v1</code> 导出。</p>
|
|
<p className="ops-import-note">行级明细来自 <code>POST /import_batch/get@v1</code>(不回传原始 14 列,只给校验态与错误清单)。续传按原行编号覆盖重导;批次不删除、不撤销。激活码清单按行明细下发的客户主体号,经 <code>/account/get_list@v1</code> 收窄账号范围后由 <code>/import_batch/export_codes@v1</code> 导出。</p>
|
|
|
{codesDone && <p className="ops-import-note" role="status">{codesDone}</p>}
|
|
{codesDone && <p className="ops-import-note" role="status">{codesDone}</p>}
|
|
@@ -538,10 +636,10 @@ function BatchDetailDialog({ item, onClose, onResume, onReload }: { item: DemoIm
|
|
|
</>}
|
|
</>}
|
|
|
</div>
|
|
</div>
|
|
|
<footer className="ops-batch-dialog-footer">
|
|
<footer className="ops-batch-dialog-footer">
|
|
|
- <Button variant="outline" onClick={() => void exportCustomers()}>导出本批次客户信息</Button>
|
|
|
|
|
|
|
+ <Button variant="outline" disabled={customersBusy} onClick={() => void exportCustomers()}>{customersBusy ? "导出中…" : "导出本批次客户信息"}</Button>
|
|
|
<Button variant="outline" disabled={codesBusy} title="按本批次行明细的客户主体号收窄账号范围后导出;明文只随本次应答回显一次" onClick={() => void exportCodes()}><KeyRound size={15} />{codesBusy ? "导出中…" : "导出本批次激活码明文"}</Button>
|
|
<Button variant="outline" disabled={codesBusy} title="按本批次行明细的客户主体号收窄账号范围后导出;明文只随本次应答回显一次" onClick={() => void exportCodes()}><KeyRound size={15} />{codesBusy ? "导出中…" : "导出本批次激活码明文"}</Button>
|
|
|
<Button variant="outline" onClick={onReload}>刷新台账</Button>
|
|
<Button variant="outline" onClick={onReload}>刷新台账</Button>
|
|
|
- <Button onClick={onResume}>按本批次续传</Button>
|
|
|
|
|
|
|
+ {canWrite ? <Button onClick={onResume}>按本批次续传</Button> : null}
|
|
|
</footer>
|
|
</footer>
|
|
|
</div>
|
|
</div>
|
|
|
</div>;
|
|
</div>;
|