@chenchaolong/plugin-trade-compliance-workbench 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -1
- package/dist/assets/branding/yuneec-logo.png +0 -0
- package/dist/assets/templates/CI.xlsx +0 -0
- package/dist/assets/templates/CUSTOMS_DECLARATION.xlsx +0 -0
- package/dist/assets/templates/PI.xlsx +0 -0
- package/dist/assets/templates/PL.xlsx +0 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/adapters/file-storage.d.ts +4 -2
- package/dist/lib/adapters/file-storage.d.ts.map +1 -1
- package/dist/lib/adapters/file-storage.js +25 -10
- package/dist/lib/adapters/file-storage.js.map +1 -1
- package/dist/lib/adapters/hsbianma.provider.d.ts +1 -0
- package/dist/lib/adapters/hsbianma.provider.d.ts.map +1 -1
- package/dist/lib/adapters/hsbianma.provider.js +32 -3
- package/dist/lib/adapters/hsbianma.provider.js.map +1 -1
- package/dist/lib/adapters/translation.provider.d.ts +3 -0
- package/dist/lib/adapters/translation.provider.d.ts.map +1 -1
- package/dist/lib/adapters/translation.provider.js +15 -6
- package/dist/lib/adapters/translation.provider.js.map +1 -1
- package/dist/lib/constants.d.ts +3 -2
- package/dist/lib/constants.d.ts.map +1 -1
- package/dist/lib/constants.js +3 -2
- package/dist/lib/constants.js.map +1 -1
- package/dist/lib/demo-data.definitions.d.ts +28 -0
- package/dist/lib/demo-data.definitions.d.ts.map +1 -0
- package/dist/lib/demo-data.definitions.js +236 -0
- package/dist/lib/demo-data.definitions.js.map +1 -0
- package/dist/lib/demo-data.entity.d.ts +9 -0
- package/dist/lib/demo-data.entity.d.ts.map +1 -0
- package/dist/lib/demo-data.entity.js +24 -0
- package/dist/lib/demo-data.entity.js.map +1 -0
- package/dist/lib/demo-data.ids.d.ts +4 -0
- package/dist/lib/demo-data.ids.d.ts.map +1 -0
- package/dist/lib/demo-data.ids.js +19 -0
- package/dist/lib/demo-data.ids.js.map +1 -0
- package/dist/lib/demo-data.service.d.ts +26 -0
- package/dist/lib/demo-data.service.d.ts.map +1 -0
- package/dist/lib/demo-data.service.js +124 -0
- package/dist/lib/demo-data.service.js.map +1 -0
- package/dist/lib/domain/default-settings.d.ts +1 -0
- package/dist/lib/domain/default-settings.d.ts.map +1 -1
- package/dist/lib/domain/default-settings.js +1 -0
- package/dist/lib/domain/default-settings.js.map +1 -1
- package/dist/lib/domain/risk-notice.d.ts +59 -0
- package/dist/lib/domain/risk-notice.d.ts.map +1 -0
- package/dist/lib/domain/risk-notice.js +30 -0
- package/dist/lib/domain/risk-notice.js.map +1 -0
- package/dist/lib/entities/catalog.entity.d.ts.map +1 -1
- package/dist/lib/entities/catalog.entity.js +4 -2
- package/dist/lib/entities/catalog.entity.js.map +1 -1
- package/dist/lib/entities/customer.entity.d.ts +9 -2
- package/dist/lib/entities/customer.entity.d.ts.map +1 -1
- package/dist/lib/entities/customer.entity.js +29 -1
- package/dist/lib/entities/customer.entity.js.map +1 -1
- package/dist/lib/entities/index.d.ts +2 -2
- package/dist/lib/entities/index.d.ts.map +1 -1
- package/dist/lib/entities/index.js +2 -2
- package/dist/lib/entities/index.js.map +1 -1
- package/dist/lib/entities/procurement.entity.d.ts +6 -4
- package/dist/lib/entities/procurement.entity.d.ts.map +1 -1
- package/dist/lib/entities/procurement.entity.js +9 -1
- package/dist/lib/entities/procurement.entity.js.map +1 -1
- package/dist/lib/entities/settings.entity.d.ts +12 -2
- package/dist/lib/entities/settings.entity.d.ts.map +1 -1
- package/dist/lib/entities/settings.entity.js +40 -0
- package/dist/lib/entities/settings.entity.js.map +1 -1
- package/dist/lib/entities/shared.entity.d.ts +10 -5
- package/dist/lib/entities/shared.entity.d.ts.map +1 -1
- package/dist/lib/entities/shared.entity.js +22 -1
- package/dist/lib/entities/shared.entity.js.map +1 -1
- package/dist/lib/remote-components/trade-compliance-workbench/app.css +1 -0
- package/dist/lib/remote-components/trade-compliance-workbench/app.js +63 -277
- package/dist/lib/remote-ui/analytics-contracts.d.ts +106 -0
- package/dist/lib/remote-ui/analytics-contracts.d.ts.map +1 -0
- package/dist/lib/remote-ui/analytics-contracts.js +4 -0
- package/dist/lib/remote-ui/analytics-contracts.js.map +1 -0
- package/dist/lib/remote-ui/app-source.d.ts +2 -0
- package/dist/lib/remote-ui/app-source.d.ts.map +1 -0
- package/dist/lib/remote-ui/app-source.js +753 -0
- package/dist/lib/remote-ui/app-source.js.map +1 -0
- package/dist/lib/remote-ui/bridge.d.ts +36 -0
- package/dist/lib/remote-ui/bridge.d.ts.map +1 -0
- package/dist/lib/remote-ui/bridge.js +159 -0
- package/dist/lib/remote-ui/bridge.js.map +1 -0
- package/dist/lib/remote-ui/components/data-grid.d.ts +34 -0
- package/dist/lib/remote-ui/components/data-grid.d.ts.map +1 -0
- package/dist/lib/remote-ui/components/data-grid.js +59 -0
- package/dist/lib/remote-ui/components/data-grid.js.map +1 -0
- package/dist/lib/remote-ui/components/forms.d.ts +63 -0
- package/dist/lib/remote-ui/components/forms.d.ts.map +1 -0
- package/dist/lib/remote-ui/components/forms.js +117 -0
- package/dist/lib/remote-ui/components/forms.js.map +1 -0
- package/dist/lib/remote-ui/components/layout.d.ts +34 -0
- package/dist/lib/remote-ui/components/layout.d.ts.map +1 -0
- package/dist/lib/remote-ui/components/layout.js +89 -0
- package/dist/lib/remote-ui/components/layout.js.map +1 -0
- package/dist/lib/remote-ui/contract-import.d.ts +82 -0
- package/dist/lib/remote-ui/contract-import.d.ts.map +1 -0
- package/dist/lib/remote-ui/contract-import.js +102 -0
- package/dist/lib/remote-ui/contract-import.js.map +1 -0
- package/dist/lib/remote-ui/contracts.d.ts +257 -0
- package/dist/lib/remote-ui/contracts.d.ts.map +1 -0
- package/dist/lib/remote-ui/contracts.js +12 -0
- package/dist/lib/remote-ui/contracts.js.map +1 -0
- package/dist/lib/remote-ui/customer-contract-contracts.d.ts +227 -0
- package/dist/lib/remote-ui/customer-contract-contracts.d.ts.map +1 -0
- package/dist/lib/remote-ui/customer-contract-contracts.js +10 -0
- package/dist/lib/remote-ui/customer-contract-contracts.js.map +1 -0
- package/dist/lib/remote-ui/model.d.ts +31 -0
- package/dist/lib/remote-ui/model.d.ts.map +1 -0
- package/dist/lib/remote-ui/model.js +248 -0
- package/dist/lib/remote-ui/model.js.map +1 -0
- package/dist/lib/remote-ui/pages/analytics.d.ts +12 -0
- package/dist/lib/remote-ui/pages/analytics.d.ts.map +1 -0
- package/dist/lib/remote-ui/pages/analytics.js +123 -0
- package/dist/lib/remote-ui/pages/analytics.js.map +1 -0
- package/dist/lib/remote-ui/pages/catalogs.d.ts +225 -0
- package/dist/lib/remote-ui/pages/catalogs.d.ts.map +1 -0
- package/dist/lib/remote-ui/pages/catalogs.js +572 -0
- package/dist/lib/remote-ui/pages/catalogs.js.map +1 -0
- package/dist/lib/remote-ui/pages/contracts.d.ts +80 -0
- package/dist/lib/remote-ui/pages/contracts.d.ts.map +1 -0
- package/dist/lib/remote-ui/pages/contracts.js +396 -0
- package/dist/lib/remote-ui/pages/contracts.js.map +1 -0
- package/dist/lib/remote-ui/pages/files.d.ts +31 -0
- package/dist/lib/remote-ui/pages/files.d.ts.map +1 -0
- package/dist/lib/remote-ui/pages/files.js +64 -0
- package/dist/lib/remote-ui/pages/files.js.map +1 -0
- package/dist/lib/remote-ui/pages/home.d.ts +71 -0
- package/dist/lib/remote-ui/pages/home.d.ts.map +1 -0
- package/dist/lib/remote-ui/pages/home.js +136 -0
- package/dist/lib/remote-ui/pages/home.js.map +1 -0
- package/dist/lib/remote-ui/pages/procurement.d.ts +36 -0
- package/dist/lib/remote-ui/pages/procurement.d.ts.map +1 -0
- package/dist/lib/remote-ui/pages/procurement.js +370 -0
- package/dist/lib/remote-ui/pages/procurement.js.map +1 -0
- package/dist/lib/remote-ui/pages/sales.d.ts +12 -0
- package/dist/lib/remote-ui/pages/sales.d.ts.map +1 -0
- package/dist/lib/remote-ui/pages/sales.js +106 -0
- package/dist/lib/remote-ui/pages/sales.js.map +1 -0
- package/dist/lib/remote-ui/pages/settings.d.ts +34 -0
- package/dist/lib/remote-ui/pages/settings.d.ts.map +1 -0
- package/dist/lib/remote-ui/pages/settings.js +259 -0
- package/dist/lib/remote-ui/pages/settings.js.map +1 -0
- package/dist/lib/remote-ui/procurement-contracts.d.ts +177 -0
- package/dist/lib/remote-ui/procurement-contracts.d.ts.map +1 -0
- package/dist/lib/remote-ui/procurement-contracts.js +2 -0
- package/dist/lib/remote-ui/procurement-contracts.js.map +1 -0
- package/dist/lib/remote-ui/sales-contracts.d.ts +133 -0
- package/dist/lib/remote-ui/sales-contracts.d.ts.map +1 -0
- package/dist/lib/remote-ui/sales-contracts.js +2 -0
- package/dist/lib/remote-ui/sales-contracts.js.map +1 -0
- package/dist/lib/remote-ui/settings-contracts.d.ts +114 -0
- package/dist/lib/remote-ui/settings-contracts.d.ts.map +1 -0
- package/dist/lib/remote-ui/settings-contracts.js +6 -0
- package/dist/lib/remote-ui/settings-contracts.js.map +1 -0
- package/dist/lib/remote-ui/upload-policy.d.ts +18 -0
- package/dist/lib/remote-ui/upload-policy.d.ts.map +1 -0
- package/dist/lib/remote-ui/upload-policy.js +56 -0
- package/dist/lib/remote-ui/upload-policy.js.map +1 -0
- package/dist/lib/runtime-validation.d.ts +61 -0
- package/dist/lib/runtime-validation.d.ts.map +1 -0
- package/dist/lib/runtime-validation.js +243 -0
- package/dist/lib/runtime-validation.js.map +1 -0
- package/dist/lib/sales-file.service.d.ts +54 -6
- package/dist/lib/sales-file.service.d.ts.map +1 -1
- package/dist/lib/sales-file.service.js +278 -33
- package/dist/lib/sales-file.service.js.map +1 -1
- package/dist/lib/trade-compliance.config.d.ts +32 -0
- package/dist/lib/trade-compliance.config.d.ts.map +1 -1
- package/dist/lib/trade-compliance.config.js +16 -4
- package/dist/lib/trade-compliance.config.js.map +1 -1
- package/dist/lib/types.d.ts +253 -1
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/types.js +24 -0
- package/dist/lib/types.js.map +1 -1
- package/dist/lib/workbench-view.provider.d.ts +675 -38
- package/dist/lib/workbench-view.provider.d.ts.map +1 -1
- package/dist/lib/workbench-view.provider.js +411 -40
- package/dist/lib/workbench-view.provider.js.map +1 -1
- package/dist/lib/workbench.middleware.d.ts +70 -19
- package/dist/lib/workbench.middleware.d.ts.map +1 -1
- package/dist/lib/workbench.middleware.js +5 -1
- package/dist/lib/workbench.middleware.js.map +1 -1
- package/dist/lib/workbench.plugin.d.ts.map +1 -1
- package/dist/lib/workbench.plugin.js +6 -4
- package/dist/lib/workbench.plugin.js.map +1 -1
- package/dist/lib/workbench.service.d.ts +629 -48
- package/dist/lib/workbench.service.d.ts.map +1 -1
- package/dist/lib/workbench.service.js +1818 -300
- package/dist/lib/workbench.service.js.map +1 -1
- package/package.json +15 -4
- package/scripts/seed-demo-data.mjs +138 -0
|
@@ -0,0 +1,572 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { DataGrid, FilterPanel, InfoNotice } from '../components/data-grid.js';
|
|
4
|
+
import { ConfirmDialog, FieldGrid, FormField, Modal, ReviewSplit, UploadZone } from '../components/forms.js';
|
|
5
|
+
import { getConfiguredUploadPolicy } from '../upload-policy.js';
|
|
6
|
+
const PAGE_SIZE = 20;
|
|
7
|
+
const ACCEPTED_CATALOG_FILES = '.pdf,.doc,.docx,.xls,.xlsx,.png,.jpg,.jpeg,.webp';
|
|
8
|
+
const formatNotice = () => `支持 PDF、DOC、DOCX、XLS、XLSX、PNG、JPEG、WEBP,单文件最大 ${getConfiguredUploadPolicy().maxUploadMb} MB。`;
|
|
9
|
+
const catalogTypeLabels = {
|
|
10
|
+
DUAL_USE: '军民两用物资',
|
|
11
|
+
OVERSEAS_SANCTION: '海外制裁'
|
|
12
|
+
};
|
|
13
|
+
const sourceTypeLabels = {
|
|
14
|
+
FILE_IMPORT: '文件导入',
|
|
15
|
+
MANUAL_ENTRY: '手工新增'
|
|
16
|
+
};
|
|
17
|
+
const controlledGoodsFilters = [
|
|
18
|
+
{ type: 'select', key: 'catalogType', label: '目录类型', options: options(catalogTypeLabels) },
|
|
19
|
+
{ type: 'text', key: 'sourceFileName', label: '来源文件', placeholder: '请输入来源文件名称' },
|
|
20
|
+
{ type: 'text', key: 'productName', label: '商品名称' },
|
|
21
|
+
{ type: 'text', key: 'hsCode', label: '海关编码' }
|
|
22
|
+
];
|
|
23
|
+
const sanctionedCompanyFilters = [
|
|
24
|
+
{ type: 'text', key: 'sourceFileName', label: '来源文件', placeholder: '请输入来源文件名称' },
|
|
25
|
+
{ type: 'text', key: 'companyName', label: '公司名称' },
|
|
26
|
+
{ type: 'text', key: 'countryOrRegion', label: '国家或地区' },
|
|
27
|
+
{ type: 'text', key: 'sanctionListSource', label: '制裁名单来源' },
|
|
28
|
+
{ type: 'date-range', key: 'effectiveDate', label: '生效日期' }
|
|
29
|
+
];
|
|
30
|
+
export const controlledGoodsFilterMappings = {
|
|
31
|
+
catalogType: { type: 'exact', accessor: 'catalogType' },
|
|
32
|
+
sourceFileName: { type: 'fuzzy', accessor: 'sourceFileName' },
|
|
33
|
+
productName: { type: 'fuzzy', accessor: 'productName' },
|
|
34
|
+
hsCode: { type: 'fuzzy', accessor: 'hsCode' }
|
|
35
|
+
};
|
|
36
|
+
export const sanctionedCompanyFilterMappings = {
|
|
37
|
+
sourceFileName: { type: 'fuzzy', accessor: 'sourceFileName' },
|
|
38
|
+
companyName: { type: 'fuzzy', accessor: 'companyName' },
|
|
39
|
+
countryOrRegion: { type: 'fuzzy', accessor: 'countryOrRegion' },
|
|
40
|
+
sanctionListSource: { type: 'fuzzy', accessor: 'sanctionListSource' },
|
|
41
|
+
effectiveDate: { type: 'range', accessor: 'effectiveDate' }
|
|
42
|
+
};
|
|
43
|
+
export function createCatalogActionApi({ onAction, onFileAction, onRefresh }) {
|
|
44
|
+
const mutate = async (actionKey, input) => {
|
|
45
|
+
const response = await onAction(actionKey, input);
|
|
46
|
+
assertActionSucceeded(response);
|
|
47
|
+
await onRefresh();
|
|
48
|
+
return response;
|
|
49
|
+
};
|
|
50
|
+
const mutateFile = async (actionKey, file, input) => {
|
|
51
|
+
const response = await onFileAction(actionKey, file, input);
|
|
52
|
+
assertActionSucceeded(response);
|
|
53
|
+
return response;
|
|
54
|
+
};
|
|
55
|
+
return {
|
|
56
|
+
uploadControlledCatalog: (file, input) => mutateFile('upload_controlled_catalog', file, input),
|
|
57
|
+
uploadSanctionCatalog: (file, input) => mutateFile('upload_sanction_catalog', file, input),
|
|
58
|
+
saveControlledGoods: (input) => mutate('save_controlled_goods', { ...input, sourceType: 'MANUAL_ENTRY' }),
|
|
59
|
+
updateControlledGoods: (input) => mutate('update_controlled_goods', input),
|
|
60
|
+
saveSanctionedCompany: (input) => mutate('save_sanctioned_company', { ...input, sourceType: 'MANUAL_ENTRY' }),
|
|
61
|
+
updateSanctionedCompany: (input) => mutate('update_sanctioned_company', input),
|
|
62
|
+
deleteEntity: (entityType, id) => mutate('delete_entity', { entityType, id }),
|
|
63
|
+
searchHsCode: (keywords, page = 1) => onAction('search_hs_code', { keywords, page }),
|
|
64
|
+
getHsCodeDetail: (input) => onAction('get_hs_code_detail', input),
|
|
65
|
+
downloadImportIssues: async (documentType, batchId) => {
|
|
66
|
+
const response = await onAction('download_import_issues', { documentType, batchId });
|
|
67
|
+
assertActionSucceeded(response);
|
|
68
|
+
return response;
|
|
69
|
+
},
|
|
70
|
+
retryImportTask: (taskId) => onAction('retry_import_task', { taskId })
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
const ACTIVE_IMPORT_STATUSES = new Set(['QUEUED', 'EXTRACTING', 'AI_PARSING', 'VALIDATING', 'AWAITING_REVIEW', 'PERSISTING']);
|
|
74
|
+
const MAX_IMPORT_TIMEOUT_MS = 20 * 60 * 1000;
|
|
75
|
+
export class CatalogImportError extends Error {
|
|
76
|
+
constructor(message, task) {
|
|
77
|
+
super(message);
|
|
78
|
+
this.task = task;
|
|
79
|
+
this.name = 'CatalogImportError';
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export async function runCatalogImportOrchestration({ start, invokeClientCommand, markCommandDispatched, pollTask, refresh, wait = delay, now = Date.now }) {
|
|
83
|
+
assertActionSucceeded(start);
|
|
84
|
+
if (!isCatalogImportStartData(start.data))
|
|
85
|
+
throw new Error('上传响应缺少解析任务信息');
|
|
86
|
+
if (!start.data.task.commandDispatchedAt) {
|
|
87
|
+
let marked = false;
|
|
88
|
+
for (const command of start.data.commands) {
|
|
89
|
+
await invokeClientCommand(command.commandKey, command.payload);
|
|
90
|
+
if (!marked) {
|
|
91
|
+
await markCommandDispatched(start.data.task.id);
|
|
92
|
+
marked = true;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const timeoutMs = Math.min(MAX_IMPORT_TIMEOUT_MS, Math.max(1, start.data.polling.timeoutMs));
|
|
97
|
+
const intervalMs = Math.max(1, start.data.polling.intervalMs);
|
|
98
|
+
const deadline = now() + timeoutMs;
|
|
99
|
+
while (now() < deadline) {
|
|
100
|
+
await wait(intervalMs);
|
|
101
|
+
const completion = await pollTask(start.data.task.id);
|
|
102
|
+
const status = completion.task.status;
|
|
103
|
+
if (status === 'SUCCEEDED') {
|
|
104
|
+
if (!completion.batch)
|
|
105
|
+
throw new Error('导入成功但未返回批次汇总');
|
|
106
|
+
await refresh();
|
|
107
|
+
return completion;
|
|
108
|
+
}
|
|
109
|
+
if (status === 'FAILED' || status === 'TIMED_OUT')
|
|
110
|
+
throw new CatalogImportError(completion.task.errorMessage || (status === 'TIMED_OUT' ? '目录解析超时,请重新解析' : '目录解析失败,请重新解析'), completion.task);
|
|
111
|
+
if (!ACTIVE_IMPORT_STATUSES.has(status))
|
|
112
|
+
throw new Error(`不支持的导入任务状态:${status}`);
|
|
113
|
+
}
|
|
114
|
+
throw new CatalogImportError('目录解析超过 20 分钟,请重新解析', { ...start.data.task, status: 'TIMED_OUT', errorMessage: '目录解析超过 20 分钟,请重新解析' });
|
|
115
|
+
}
|
|
116
|
+
export function findActiveCatalogImportTask(items) {
|
|
117
|
+
return items
|
|
118
|
+
.filter((task) => (task.documentType === 'CONTROLLED_CATALOG' || task.documentType === 'SANCTION_CATALOG') && ACTIVE_IMPORT_STATUSES.has(task.status) && Boolean(task.executionCommand))
|
|
119
|
+
.sort((left, right) => String(right.updatedAt ?? '').localeCompare(String(left.updatedAt ?? '')))[0] ?? null;
|
|
120
|
+
}
|
|
121
|
+
export function findLatestFailedCatalogImportTask(items, documentType) {
|
|
122
|
+
const retriedTaskIds = new Set(items.map((task) => task.retryOfTaskId).filter((id) => Boolean(id)));
|
|
123
|
+
return items
|
|
124
|
+
.filter((task) => task.documentType === documentType && (task.status === 'FAILED' || task.status === 'TIMED_OUT') && !retriedTaskIds.has(task.id))
|
|
125
|
+
.sort((left, right) => String(right.updatedAt ?? '').localeCompare(String(left.updatedAt ?? '')))[0] ?? null;
|
|
126
|
+
}
|
|
127
|
+
export function createCatalogQueryScheduler(query, debounceMs = 300) {
|
|
128
|
+
let timer = null;
|
|
129
|
+
const cancel = () => { if (timer)
|
|
130
|
+
clearTimeout(timer); timer = null; };
|
|
131
|
+
const flush = (filters) => { cancel(); query(filters); };
|
|
132
|
+
return {
|
|
133
|
+
schedule(type, filters) {
|
|
134
|
+
cancel();
|
|
135
|
+
if (type !== 'text') {
|
|
136
|
+
query(filters);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
timer = setTimeout(() => { timer = null; query(filters); }, debounceMs);
|
|
140
|
+
},
|
|
141
|
+
flush,
|
|
142
|
+
cancel
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
export const initialCatalogUploadState = { catalogType: '', replaceBatchId: '', file: null, error: '', confirming: false, submitting: false };
|
|
146
|
+
export function catalogUploadReducer(state, action) {
|
|
147
|
+
if (action.type === 'reset')
|
|
148
|
+
return initialCatalogUploadState;
|
|
149
|
+
if (action.type === 'select-catalog-type')
|
|
150
|
+
return { ...state, catalogType: action.catalogType, replaceBatchId: '', error: '' };
|
|
151
|
+
if (action.type === 'select-batch')
|
|
152
|
+
return { ...state, replaceBatchId: action.batchId };
|
|
153
|
+
if (action.type === 'select-file')
|
|
154
|
+
return { ...state, file: action.file, error: '' };
|
|
155
|
+
if (action.type === 'set-error')
|
|
156
|
+
return { ...state, error: action.error };
|
|
157
|
+
if (action.type === 'confirm-replace')
|
|
158
|
+
return { ...state, confirming: true };
|
|
159
|
+
if (action.type === 'cancel-replace')
|
|
160
|
+
return { ...state, confirming: false };
|
|
161
|
+
return { ...state, submitting: action.submitting };
|
|
162
|
+
}
|
|
163
|
+
export function shouldShowCatalogUploadForm(open, state) {
|
|
164
|
+
return open && !state.confirming;
|
|
165
|
+
}
|
|
166
|
+
export function attachBatchFileNames(rows, batches) {
|
|
167
|
+
const fileNames = new Map(batches.map((batch) => [batch.id, batch.sourceFileName]));
|
|
168
|
+
return rows.map((row) => ({ ...row, sourceFileName: row.batchId && fileNames.has(row.batchId) ? fileNames.get(row.batchId) : row.sourceFileName }));
|
|
169
|
+
}
|
|
170
|
+
export async function loadCatalogImportIssues(onIssueQuery, query) {
|
|
171
|
+
try {
|
|
172
|
+
return { collection: await onIssueQuery(query), error: '' };
|
|
173
|
+
}
|
|
174
|
+
catch (cause) {
|
|
175
|
+
return { collection: { items: [], page: query.page, pageSize: query.pageSize }, error: `加载导入问题明细失败:${errorMessage(cause, '未知错误')}` };
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
export function createCatalogIssueRequestController(commit) {
|
|
179
|
+
let requestSequence = 0;
|
|
180
|
+
let mounted = true;
|
|
181
|
+
let open = false;
|
|
182
|
+
return {
|
|
183
|
+
mount() { mounted = true; },
|
|
184
|
+
async load(onIssueQuery, query) {
|
|
185
|
+
const requestId = ++requestSequence;
|
|
186
|
+
open = true;
|
|
187
|
+
if (mounted)
|
|
188
|
+
commit({ batchId: query.batchId, issueType: query.issueType, collection: { items: [], page: query.page, pageSize: query.pageSize }, loading: true, error: '' });
|
|
189
|
+
const result = await loadCatalogImportIssues(onIssueQuery, query);
|
|
190
|
+
if (mounted && open && requestId === requestSequence)
|
|
191
|
+
commit({ batchId: query.batchId, issueType: query.issueType, collection: result.collection, loading: false, error: result.error });
|
|
192
|
+
},
|
|
193
|
+
close() { open = false; requestSequence += 1; },
|
|
194
|
+
dispose() { mounted = false; open = false; requestSequence += 1; }
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
export function ControlledGoodsPage(props) {
|
|
198
|
+
const [filters, setFilters] = React.useState({});
|
|
199
|
+
const [uploadOpen, setUploadOpen] = React.useState(false);
|
|
200
|
+
const [form, setForm] = React.useState(null);
|
|
201
|
+
const [deleteItem, setDeleteItem] = React.useState(null);
|
|
202
|
+
const [hsQuery, setHsQuery] = React.useState(null);
|
|
203
|
+
const [summary, setSummary] = React.useState(null);
|
|
204
|
+
const [issueState, setIssueState] = React.useState(null);
|
|
205
|
+
const issueControllerRef = React.useRef();
|
|
206
|
+
if (!issueControllerRef.current)
|
|
207
|
+
issueControllerRef.current = createCatalogIssueRequestController(setIssueState);
|
|
208
|
+
const api = React.useMemo(() => createCatalogActionApi(props), [props.onAction, props.onFileAction, props.onRefresh]);
|
|
209
|
+
const rows = attachBatchFileNames(props.collection.items, props.batches);
|
|
210
|
+
const pagination = collectionPagination(props.collection);
|
|
211
|
+
React.useEffect(() => {
|
|
212
|
+
if (props.command === 'upload')
|
|
213
|
+
setUploadOpen(true);
|
|
214
|
+
if (props.command === 'create')
|
|
215
|
+
setForm({ mode: 'create', item: null });
|
|
216
|
+
if (props.command)
|
|
217
|
+
props.onCommandHandled?.();
|
|
218
|
+
}, [props.command, props.onCommandHandled]);
|
|
219
|
+
const query = React.useCallback((page, nextFilters) => props.onQuery({ page, pageSize: PAGE_SIZE, filters: nextFilters }), [props.onQuery]);
|
|
220
|
+
const scheduler = React.useMemo(() => createCatalogQueryScheduler((nextFilters) => void query(1, nextFilters)), [query]);
|
|
221
|
+
React.useEffect(() => () => scheduler.cancel(), [scheduler]);
|
|
222
|
+
React.useEffect(() => { issueControllerRef.current?.mount(); return () => issueControllerRef.current?.dispose(); }, []);
|
|
223
|
+
const changeFilter = (key, value) => {
|
|
224
|
+
const nextFilters = { ...filters, [key]: value };
|
|
225
|
+
setFilters(nextFilters);
|
|
226
|
+
scheduler.schedule(controlledGoodsFilters.find((definition) => definition.key === key)?.type ?? 'text', nextFilters);
|
|
227
|
+
};
|
|
228
|
+
const queryIssues = async (batchId, issueType, page = 1) => {
|
|
229
|
+
if (!props.onIssueQuery)
|
|
230
|
+
return;
|
|
231
|
+
await issueControllerRef.current?.load(props.onIssueQuery, { documentType: 'CONTROLLED_CATALOG', batchId, issueType, page, pageSize: PAGE_SIZE });
|
|
232
|
+
};
|
|
233
|
+
const displayedSummary = summary ?? (props.importCompletion?.task.documentType === 'CONTROLLED_CATALOG' ? props.importCompletion.batch ?? null : null);
|
|
234
|
+
const columns = [
|
|
235
|
+
{ type: 'custom', key: 'productName', header: '商品名称', width: 180, render: (_, row) => _jsx(LinkButton, { title: "\u6309\u5546\u54C1\u540D\u79F0\u67E5\u8BE2\u6D77\u5173\u7F16\u7801", onClick: () => setHsQuery(hsLookupQuery(row, 'productName')), children: row.productName || '—' }) },
|
|
236
|
+
{ type: 'custom', key: 'hsCode', header: '海关编码', width: 130, render: (_, row) => row.hsCode ? _jsx(LinkButton, { title: "\u6309\u7F16\u7801\u67E5\u8BE2\u6D77\u5173\u7F16\u7801", onClick: () => setHsQuery(hsLookupQuery(row, 'hsCode')), children: row.hsCode }) : '—' },
|
|
237
|
+
{ type: 'text', key: 'catalogType', header: '目录类型', width: 130, format: (value) => labelFor(value, catalogTypeLabels) },
|
|
238
|
+
{ type: 'ellipsis', key: 'controlDescription', header: '管控说明', width: 220, maxWidth: 220 },
|
|
239
|
+
{ type: 'text', key: 'sourceType', header: '来源类型', width: 110, format: (value) => labelFor(value, sourceTypeLabels) },
|
|
240
|
+
{ type: 'ellipsis', key: 'sourceFileName', header: '来源文件', width: 190, maxWidth: 190 },
|
|
241
|
+
{ type: 'text', key: 'updatedAt', header: '更新时间', width: 170 }
|
|
242
|
+
];
|
|
243
|
+
return (_jsxs("section", { className: "tcw-catalog-page", "aria-label": "\u7BA1\u63A7\u5546\u54C1\u76EE\u5F55", children: [_jsx(FilterPanel, { definitions: controlledGoodsFilters, values: filters, onChange: changeFilter, onQuery: () => scheduler.flush(filters), onReset: () => { setFilters({}); scheduler.flush({}); } }), _jsx(InfoNotice, { children: formatNotice() }), props.importFailure?.documentType === 'CONTROLLED_CATALOG' && _jsx(CatalogImportStatusNotice, { task: props.importFailure, busy: props.busy, onRetry: (taskId) => props.onRetryImport?.(taskId) ?? Promise.resolve() }), displayedSummary && _jsx(CatalogImportSummaryNotice, { documentType: "CONTROLLED_CATALOG", batch: displayedSummary, busy: props.busy, onDownload: (documentType, batchId) => api.downloadImportIssues(documentType, batchId), onView: (batchId, issueType) => queryIssues(batchId, issueType) }), _jsx(DataGrid, { columns: columns, rows: rows, rowKey: "id", actions: (row) => _jsxs(_Fragment, { children: [_jsx("button", { type: "button", disabled: props.busy, onClick: () => setForm({ mode: 'review', item: row }), children: "\u5BA1\u6838" }), _jsx("button", { type: "button", className: "is-danger", disabled: props.busy, onClick: () => setDeleteItem(row), children: "\u5220\u9664" })] }), pagination: pagination, onPageChange: (nextPage) => { scheduler.cancel(); void query(nextPage, filters); }, emptyText: "\u6682\u65E0\u7BA1\u63A7\u5546\u54C1\u6570\u636E" }), _jsx(CatalogUploadDialog, { open: uploadOpen, kind: "controlled", batches: props.batches, busy: props.busy, onClose: () => setUploadOpen(false), onUpload: async (file, input) => {
|
|
244
|
+
const response = await api.uploadControlledCatalog(file, input);
|
|
245
|
+
const completion = asImportCompletion(response.data);
|
|
246
|
+
if (completion.batch)
|
|
247
|
+
setSummary(completion.batch);
|
|
248
|
+
setUploadOpen(false);
|
|
249
|
+
} }), _jsx(ControlledGoodsFormDialog, { open: Boolean(form), mode: form?.mode ?? 'create', item: form?.item ?? null, busy: props.busy, onClose: () => setForm(null), onSave: async (input) => { form?.mode === 'review' && form.item ? await api.updateControlledGoods({ ...input, id: form.item.id }) : await api.saveControlledGoods(input); setForm(null); } }), _jsx(ConfirmDialog, { open: Boolean(deleteItem), title: "\u786E\u8BA4\u5220\u9664\u7BA1\u63A7\u5546\u54C1", message: `删除“${deleteItem?.productName ?? ''}”后,该记录将被逻辑删除。`, confirmText: "\u786E\u8BA4\u5220\u9664", danger: true, onCancel: () => setDeleteItem(null), onConfirm: () => { if (deleteItem)
|
|
250
|
+
void api.deleteEntity('controlledGoods', deleteItem.id).then(() => setDeleteItem(null)); } }), _jsx(HsCodeLookupDialog, { open: hsQuery !== null, initialQuery: hsQuery ?? '', onAction: props.onAction, onClose: () => setHsQuery(null) }), _jsx(CatalogImportIssuesDialog, { open: Boolean(issueState), documentType: "CONTROLLED_CATALOG", batchId: issueState?.batchId ?? '', issueType: issueState?.issueType ?? 'DUPLICATE', collection: issueState?.collection ?? { items: [] }, loading: issueState?.loading ?? false, error: issueState?.error ?? '', busy: props.busy, onClose: () => { issueControllerRef.current?.close(); setIssueState(null); }, onIssueTypeChange: (issueType) => { if (issueState)
|
|
251
|
+
void queryIssues(issueState.batchId, issueType); }, onPageChange: (page) => { if (issueState)
|
|
252
|
+
void queryIssues(issueState.batchId, issueState.issueType, page); }, onRetry: () => { if (issueState)
|
|
253
|
+
void queryIssues(issueState.batchId, issueState.issueType, Number(issueState.collection.page) || 1); } })] }));
|
|
254
|
+
}
|
|
255
|
+
export function SanctionedCompaniesPage(props) {
|
|
256
|
+
const [filters, setFilters] = React.useState({});
|
|
257
|
+
const [uploadOpen, setUploadOpen] = React.useState(false);
|
|
258
|
+
const [form, setForm] = React.useState(null);
|
|
259
|
+
const [deleteItem, setDeleteItem] = React.useState(null);
|
|
260
|
+
const [summary, setSummary] = React.useState(null);
|
|
261
|
+
const [issueState, setIssueState] = React.useState(null);
|
|
262
|
+
const issueControllerRef = React.useRef();
|
|
263
|
+
if (!issueControllerRef.current)
|
|
264
|
+
issueControllerRef.current = createCatalogIssueRequestController(setIssueState);
|
|
265
|
+
const api = React.useMemo(() => createCatalogActionApi(props), [props.onAction, props.onFileAction, props.onRefresh]);
|
|
266
|
+
const rows = attachBatchFileNames(props.collection.items, props.batches);
|
|
267
|
+
const pagination = collectionPagination(props.collection);
|
|
268
|
+
React.useEffect(() => {
|
|
269
|
+
if (props.command === 'upload')
|
|
270
|
+
setUploadOpen(true);
|
|
271
|
+
if (props.command === 'create')
|
|
272
|
+
setForm({ mode: 'create', item: null });
|
|
273
|
+
if (props.command)
|
|
274
|
+
props.onCommandHandled?.();
|
|
275
|
+
}, [props.command, props.onCommandHandled]);
|
|
276
|
+
const query = React.useCallback((page, nextFilters) => props.onQuery({ page, pageSize: PAGE_SIZE, filters: nextFilters }), [props.onQuery]);
|
|
277
|
+
const scheduler = React.useMemo(() => createCatalogQueryScheduler((nextFilters) => void query(1, nextFilters)), [query]);
|
|
278
|
+
React.useEffect(() => () => scheduler.cancel(), [scheduler]);
|
|
279
|
+
React.useEffect(() => { issueControllerRef.current?.mount(); return () => issueControllerRef.current?.dispose(); }, []);
|
|
280
|
+
const changeFilter = (key, value) => {
|
|
281
|
+
const nextFilters = { ...filters, [key]: value };
|
|
282
|
+
setFilters(nextFilters);
|
|
283
|
+
scheduler.schedule(sanctionedCompanyFilters.find((definition) => definition.key === key)?.type ?? 'text', nextFilters);
|
|
284
|
+
};
|
|
285
|
+
const queryIssues = async (batchId, issueType, page = 1) => {
|
|
286
|
+
if (!props.onIssueQuery)
|
|
287
|
+
return;
|
|
288
|
+
await issueControllerRef.current?.load(props.onIssueQuery, { documentType: 'SANCTION_CATALOG', batchId, issueType, page, pageSize: PAGE_SIZE });
|
|
289
|
+
};
|
|
290
|
+
const displayedSummary = summary ?? (props.importCompletion?.task.documentType === 'SANCTION_CATALOG' ? props.importCompletion.batch ?? null : null);
|
|
291
|
+
const columns = [
|
|
292
|
+
{ type: 'custom', key: 'companyName', header: '公司名称', width: 210, render: (_, row) => _jsx(LinkButton, { title: "\u67E5\u770B\u5236\u88C1\u516C\u53F8\u8BE6\u60C5", onClick: () => setForm({ mode: 'detail', item: row }), children: row.companyName || '—' }) },
|
|
293
|
+
{ type: 'text', key: 'countryOrRegion', header: '国家或地区', width: 120 },
|
|
294
|
+
{ type: 'ellipsis', key: 'sanctionListSource', header: '制裁名单来源', width: 190, maxWidth: 190 },
|
|
295
|
+
{ type: 'text', key: 'effectiveDate', header: '生效日期', width: 120 },
|
|
296
|
+
{ type: 'ellipsis', key: 'sanctionReason', header: '制裁原因', width: 220, maxWidth: 220 },
|
|
297
|
+
{ type: 'text', key: 'sourceType', header: '来源类型', width: 110, format: (value) => labelFor(value, sourceTypeLabels) },
|
|
298
|
+
{ type: 'ellipsis', key: 'sourceFileName', header: '来源文件', width: 190, maxWidth: 190 },
|
|
299
|
+
{ type: 'text', key: 'updatedAt', header: '更新时间', width: 170 }
|
|
300
|
+
];
|
|
301
|
+
return (_jsxs("section", { className: "tcw-catalog-page", "aria-label": "\u516C\u53F8\u5236\u88C1\u76EE\u5F55", children: [_jsx(FilterPanel, { definitions: sanctionedCompanyFilters, values: filters, onChange: changeFilter, onQuery: () => scheduler.flush(filters), onReset: () => { setFilters({}); scheduler.flush({}); } }), _jsx(InfoNotice, { children: formatNotice() }), props.importFailure?.documentType === 'SANCTION_CATALOG' && _jsx(CatalogImportStatusNotice, { task: props.importFailure, busy: props.busy, onRetry: (taskId) => props.onRetryImport?.(taskId) ?? Promise.resolve() }), displayedSummary && _jsx(CatalogImportSummaryNotice, { documentType: "SANCTION_CATALOG", batch: displayedSummary, busy: props.busy, onDownload: (documentType, batchId) => api.downloadImportIssues(documentType, batchId), onView: (batchId, issueType) => queryIssues(batchId, issueType) }), _jsx(DataGrid, { columns: columns, rows: rows, rowKey: "id", actions: (row) => _jsxs(_Fragment, { children: [_jsx("button", { type: "button", disabled: props.busy, onClick: () => setForm({ mode: 'review', item: row }), children: "\u5BA1\u6838" }), _jsx("button", { type: "button", className: "is-danger", disabled: props.busy, onClick: () => setDeleteItem(row), children: "\u5220\u9664" })] }), pagination: pagination, onPageChange: (nextPage) => { scheduler.cancel(); void query(nextPage, filters); }, emptyText: "\u6682\u65E0\u5236\u88C1\u516C\u53F8\u6570\u636E" }), _jsx(CatalogUploadDialog, { open: uploadOpen, kind: "sanction", batches: props.batches, busy: props.busy, onClose: () => setUploadOpen(false), onUpload: async (file, input) => {
|
|
302
|
+
const response = await api.uploadSanctionCatalog(file, input);
|
|
303
|
+
const completion = asImportCompletion(response.data);
|
|
304
|
+
if (completion.batch)
|
|
305
|
+
setSummary(completion.batch);
|
|
306
|
+
setUploadOpen(false);
|
|
307
|
+
} }), _jsx(SanctionedCompanyDialog, { open: Boolean(form), mode: form?.mode ?? 'create', item: form?.item ?? null, busy: props.busy, onClose: () => setForm(null), onSave: async (input) => { form?.mode === 'review' && form.item ? await api.updateSanctionedCompany({ ...input, id: form.item.id }) : await api.saveSanctionedCompany(input); setForm(null); } }), _jsx(ConfirmDialog, { open: Boolean(deleteItem), title: "\u786E\u8BA4\u5220\u9664\u5236\u88C1\u516C\u53F8", message: `删除“${deleteItem?.companyName ?? ''}”后,该记录将被逻辑删除。`, confirmText: "\u786E\u8BA4\u5220\u9664", danger: true, onCancel: () => setDeleteItem(null), onConfirm: () => { if (deleteItem)
|
|
308
|
+
void api.deleteEntity('sanctionedCompany', deleteItem.id).then(() => setDeleteItem(null)); } }), _jsx(CatalogImportIssuesDialog, { open: Boolean(issueState), documentType: "SANCTION_CATALOG", batchId: issueState?.batchId ?? '', issueType: issueState?.issueType ?? 'DUPLICATE', collection: issueState?.collection ?? { items: [] }, loading: issueState?.loading ?? false, error: issueState?.error ?? '', busy: props.busy, onClose: () => { issueControllerRef.current?.close(); setIssueState(null); }, onIssueTypeChange: (issueType) => { if (issueState)
|
|
309
|
+
void queryIssues(issueState.batchId, issueType); }, onPageChange: (page) => { if (issueState)
|
|
310
|
+
void queryIssues(issueState.batchId, issueState.issueType, page); }, onRetry: () => { if (issueState)
|
|
311
|
+
void queryIssues(issueState.batchId, issueState.issueType, Number(issueState.collection.page) || 1); } })] }));
|
|
312
|
+
}
|
|
313
|
+
export function CatalogCommands({ busy, onUpload, onCreate }) {
|
|
314
|
+
return _jsxs(_Fragment, { children: [_jsxs("button", { type: "button", className: "tcw-button tcw-button--primary", disabled: busy, onClick: onUpload, children: [_jsx("i", { className: "ri-upload-cloud-2-line", "aria-hidden": "true" }), "\u4E0A\u4F20\u76EE\u5F55\u6587\u4EF6"] }), _jsxs("button", { type: "button", className: "tcw-button tcw-button--secondary", disabled: busy, onClick: onCreate, children: [_jsx("i", { className: "ri-add-line", "aria-hidden": "true" }), "\u624B\u5DE5\u65B0\u589E"] })] });
|
|
315
|
+
}
|
|
316
|
+
export function CatalogUploadDialog({ open, kind, batches, busy = false, onClose, onUpload }) {
|
|
317
|
+
const [state, dispatch] = React.useReducer(catalogUploadReducer, initialCatalogUploadState);
|
|
318
|
+
const disabled = busy || state.submitting;
|
|
319
|
+
React.useEffect(() => {
|
|
320
|
+
if (!open)
|
|
321
|
+
dispatch({ type: 'reset' });
|
|
322
|
+
}, [open, kind]);
|
|
323
|
+
const matchingBatches = kind === 'controlled' && state.catalogType ? batches.filter((batch) => batch.catalogType === state.catalogType) : batches;
|
|
324
|
+
const selectedBatch = matchingBatches.find((batch) => batch.id === state.replaceBatchId);
|
|
325
|
+
const input = () => kind === 'controlled'
|
|
326
|
+
? { documentType: 'CONTROLLED_CATALOG', catalogType: state.catalogType, ...(state.replaceBatchId ? { replaceBatchId: state.replaceBatchId } : {}) }
|
|
327
|
+
: { documentType: 'SANCTION_CATALOG', ...(state.replaceBatchId ? { replaceBatchId: state.replaceBatchId } : {}) };
|
|
328
|
+
const upload = async () => {
|
|
329
|
+
if (!state.file)
|
|
330
|
+
return;
|
|
331
|
+
dispatch({ type: 'set-submitting', submitting: true });
|
|
332
|
+
try {
|
|
333
|
+
await onUpload(state.file, input());
|
|
334
|
+
dispatch({ type: 'reset' });
|
|
335
|
+
}
|
|
336
|
+
catch (cause) {
|
|
337
|
+
dispatch({ type: 'set-error', error: errorMessage(cause, '目录上传失败') });
|
|
338
|
+
dispatch({ type: 'cancel-replace' });
|
|
339
|
+
}
|
|
340
|
+
finally {
|
|
341
|
+
dispatch({ type: 'set-submitting', submitting: false });
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
const submit = async () => {
|
|
345
|
+
if (kind === 'controlled' && !state.catalogType) {
|
|
346
|
+
dispatch({ type: 'set-error', error: '请选择目录类型' });
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
if (!state.file) {
|
|
350
|
+
dispatch({ type: 'set-error', error: '请选择目录文件' });
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
if (state.replaceBatchId) {
|
|
354
|
+
dispatch({ type: 'confirm-replace' });
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
await upload();
|
|
358
|
+
};
|
|
359
|
+
return (_jsxs(_Fragment, { children: [_jsx(Modal, { open: shouldShowCatalogUploadForm(open, state), title: kind === 'controlled' ? '上传管控商品目录' : '上传公司制裁目录', onClose: onClose, footer: _jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "tcw-button tcw-button--secondary", disabled: disabled, onClick: onClose, children: "\u53D6\u6D88" }), _jsx("button", { type: "button", className: "tcw-button tcw-button--primary", disabled: disabled, onClick: () => void submit(), children: "\u4E0A\u4F20\u76EE\u5F55" })] }), children: _jsxs(FieldGrid, { columns: 1, children: [kind === 'controlled' && _jsx(FormField, { label: "\u9009\u62E9\u76EE\u5F55\u7C7B\u578B", required: true, children: _jsxs("select", { value: state.catalogType, disabled: disabled, onChange: (event) => dispatch({ type: 'select-catalog-type', catalogType: event.target.value }), children: [_jsx("option", { value: "", children: "\u8BF7\u9009\u62E9\u76EE\u5F55\u7C7B\u578B" }), options(catalogTypeLabels).map((option) => _jsx("option", { value: option.value, children: option.label }, option.value))] }) }), _jsx(FormField, { label: "\u8986\u76D6\u5386\u53F2\u6279\u6B21", hint: "\u4E0D\u9009\u62E9\u65F6\u6309\u65B0\u589E\u6279\u6B21\u5BFC\u5165", children: _jsxs("select", { value: state.replaceBatchId, disabled: disabled || kind === 'controlled' && !state.catalogType, onChange: (event) => dispatch({ type: 'select-batch', batchId: event.target.value }), children: [_jsx("option", { value: "", children: "\u4E0D\u8986\u76D6\uFF0C\u65B0\u589E\u6279\u6B21" }), matchingBatches.map((batch) => _jsxs("option", { value: batch.id, children: [batch.sourceFileName || batch.id, "\uFF08", batch.totalCount ?? 0, " \u6761\uFF09"] }, batch.id))] }) }), _jsx(UploadZone, { accept: ACCEPTED_CATALOG_FILES, disabled: disabled, onFile: (file) => dispatch({ type: 'select-file', file }), onError: (error) => dispatch({ type: 'set-error', error }) }), state.file && _jsxs("p", { children: ["\u5DF2\u9009\u62E9\uFF1A", _jsx("strong", { children: state.file.name })] }), state.error && _jsx("p", { role: "alert", children: state.error })] }) }), _jsx(CatalogReplaceConfirmDialog, { open: state.confirming, kind: kind, batch: selectedBatch ?? null, fileName: state.file?.name ?? '', busy: disabled, onCancel: () => dispatch({ type: 'cancel-replace' }), onConfirm: () => void upload() })] }));
|
|
360
|
+
}
|
|
361
|
+
export function CatalogReplaceConfirmDialog({ open, kind, batch, fileName, busy = false, onCancel, onConfirm }) {
|
|
362
|
+
const typeLabel = batch?.catalogType ? catalogTypeLabels[batch.catalogType] : '公司制裁目录';
|
|
363
|
+
return (_jsx(ConfirmDialog, { open: open, title: kind === 'controlled' ? '确认覆盖历史目录?' : '确认覆盖历史制裁目录?', danger: true, confirmText: "\u786E\u8BA4\u4E0A\u4F20\u5E76\u8986\u76D6", confirmDisabled: busy, onCancel: onCancel, onConfirm: onConfirm, message: _jsxs(_Fragment, { children: [_jsx("span", { className: "tcw-notice tcw-notice--risk", children: "\u53EA\u6709\u65B0\u6587\u4EF6\u89E3\u6790\u6210\u529F\u5E76\u901A\u8FC7\u57FA\u7840\u6821\u9A8C\u540E\uFF0C\u65E7\u6279\u6B21\u53CA\u5176\u8BB0\u5F55\u624D\u4F1A\u88AB\u903B\u8F91\u5220\u9664\u3002" }), _jsxs("span", { children: ["\u76EE\u5F55\u7C7B\u578B\uFF1A", typeLabel, _jsx("br", {}), "\u88AB\u8986\u76D6\u6587\u4EF6\uFF1A", batch?.sourceFileName || '—', _jsx("br", {}), "\u73B0\u6709\u8BB0\u5F55\u6570\u91CF\uFF1A", batch?.totalCount ?? 0, _jsx("br", {}), "\u6700\u8FD1\u66F4\u65B0\u65F6\u95F4\uFF1A", batch?.updatedAt || batch?.createdAt || '—', _jsx("br", {}), "\u65B0\u4E0A\u4F20\u6587\u4EF6\uFF1A", fileName || '—'] })] }) }));
|
|
364
|
+
}
|
|
365
|
+
export function ControlledGoodsFormDialog({ open, mode, item, busy = false, onClose, onSave }) {
|
|
366
|
+
const [form, setForm] = React.useState(() => controlledForm(item));
|
|
367
|
+
const [error, setError] = React.useState('');
|
|
368
|
+
React.useEffect(() => { if (open) {
|
|
369
|
+
setForm(controlledForm(item));
|
|
370
|
+
setError('');
|
|
371
|
+
} }, [open, item]);
|
|
372
|
+
const editor = _jsx(ControlledGoodsFields, { value: form, onChange: setForm });
|
|
373
|
+
const save = async () => {
|
|
374
|
+
if (!form.catalogType || !form.productName.trim()) {
|
|
375
|
+
setError('目录类型和商品名称为必填项');
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
try {
|
|
379
|
+
await onSave({ ...form, productName: form.productName.trim(), hsCode: form.hsCode?.trim(), controlDescription: form.controlDescription?.trim() });
|
|
380
|
+
}
|
|
381
|
+
catch (cause) {
|
|
382
|
+
setError(errorMessage(cause, '管控商品保存失败'));
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
const withEvidence = mode === 'review' && item?.sourceType === 'FILE_IMPORT';
|
|
386
|
+
return (_jsx(Modal, { open: open, title: mode === 'create' ? '新增管控商品' : '审核管控商品', size: withEvidence ? 'wide' : 'normal', onClose: onClose, footer: _jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "tcw-button tcw-button--secondary", onClick: onClose, children: "\u53D6\u6D88" }), _jsx("button", { type: "button", className: "tcw-button tcw-button--primary", disabled: busy, onClick: () => void save(), children: "\u4FDD\u5B58" })] }), children: withEvidence ? _jsx(ReviewSplit, { editor: _jsxs(_Fragment, { children: [editor, error && _jsx("p", { role: "alert", children: error })] }), source: _jsx(SourceEvidence, { item: item }), sourceTitle: "\u6765\u6E90\u8BC1\u636E" }) : _jsxs(_Fragment, { children: [mode === 'create' && _jsx("p", { children: "\u6765\u6E90\u7C7B\u578B\uFF1A\u624B\u5DE5\u65B0\u589E" }), editor, error && _jsx("p", { role: "alert", children: error })] }) }));
|
|
387
|
+
}
|
|
388
|
+
function ControlledGoodsFields({ value, onChange }) {
|
|
389
|
+
return _jsxs(FieldGrid, { columns: 1, children: [_jsx(FormField, { label: "\u76EE\u5F55\u7C7B\u578B", required: true, children: _jsx("select", { value: value.catalogType, onChange: (event) => onChange({ ...value, catalogType: event.target.value }), children: options(catalogTypeLabels).map((option) => _jsx("option", { value: option.value, children: option.label }, option.value)) }) }), _jsx(FormField, { label: "\u5546\u54C1\u540D\u79F0", required: true, children: _jsx("input", { value: value.productName, onChange: (event) => onChange({ ...value, productName: event.target.value }) }) }), _jsx(FormField, { label: "\u6D77\u5173\u7F16\u7801", children: _jsx("input", { value: value.hsCode ?? '', onChange: (event) => onChange({ ...value, hsCode: event.target.value }) }) }), _jsx(FormField, { label: "\u7BA1\u63A7\u8BF4\u660E", children: _jsx("textarea", { rows: 5, value: value.controlDescription ?? '', onChange: (event) => onChange({ ...value, controlDescription: event.target.value }) }) })] });
|
|
390
|
+
}
|
|
391
|
+
export function SanctionedCompanyDialog({ open, mode, item, busy = false, onClose, onSave }) {
|
|
392
|
+
const [form, setForm] = React.useState(() => sanctionedForm(item));
|
|
393
|
+
const [error, setError] = React.useState('');
|
|
394
|
+
React.useEffect(() => { if (open) {
|
|
395
|
+
setForm(sanctionedForm(item));
|
|
396
|
+
setError('');
|
|
397
|
+
} }, [open, item]);
|
|
398
|
+
const editor = _jsx(SanctionedCompanyFields, { value: form, disabled: mode === 'detail', onChange: setForm });
|
|
399
|
+
const save = async () => {
|
|
400
|
+
if (!form.companyName.trim()) {
|
|
401
|
+
setError('公司名称为必填项');
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
try {
|
|
405
|
+
await onSave({ ...form, companyName: form.companyName.trim() });
|
|
406
|
+
}
|
|
407
|
+
catch (cause) {
|
|
408
|
+
setError(errorMessage(cause, '制裁公司保存失败'));
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
const title = mode === 'create' ? '新增制裁公司' : mode === 'review' ? '审核制裁公司' : '制裁公司详情';
|
|
412
|
+
const footer = mode === 'detail'
|
|
413
|
+
? _jsx("button", { type: "button", className: "tcw-button tcw-button--primary", onClick: onClose, children: "\u5173\u95ED" })
|
|
414
|
+
: _jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "tcw-button tcw-button--secondary", onClick: onClose, children: "\u53D6\u6D88" }), _jsx("button", { type: "button", className: "tcw-button tcw-button--primary", disabled: busy, onClick: () => void save(), children: "\u4FDD\u5B58" })] });
|
|
415
|
+
const withEvidence = mode !== 'create' && item?.sourceType === 'FILE_IMPORT';
|
|
416
|
+
return (_jsx(Modal, { open: open, title: title, size: withEvidence ? 'wide' : 'normal', onClose: onClose, footer: footer, children: withEvidence ? _jsx(ReviewSplit, { editor: _jsxs(_Fragment, { children: [editor, error && _jsx("p", { role: "alert", children: error })] }), source: _jsx(SourceEvidence, { item: item }), sourceTitle: "\u6765\u6E90\u8BC1\u636E" }) : _jsxs(_Fragment, { children: [mode === 'create' && _jsx("p", { children: "\u6765\u6E90\u7C7B\u578B\uFF1A\u624B\u5DE5\u65B0\u589E" }), editor, error && _jsx("p", { role: "alert", children: error })] }) }));
|
|
417
|
+
}
|
|
418
|
+
function SanctionedCompanyFields({ value, disabled, onChange }) {
|
|
419
|
+
return _jsxs(FieldGrid, { columns: 1, children: [_jsx(FormField, { label: "\u516C\u53F8\u540D\u79F0", required: true, children: _jsx("input", { disabled: disabled, value: value.companyName, onChange: (event) => onChange({ ...value, companyName: event.target.value }) }) }), _jsx(FormField, { label: "\u56FD\u5BB6\u6216\u5730\u533A", children: _jsx("input", { disabled: disabled, value: value.countryOrRegion ?? '', onChange: (event) => onChange({ ...value, countryOrRegion: event.target.value }) }) }), _jsx(FormField, { label: "\u5236\u88C1\u540D\u5355\u6765\u6E90", children: _jsx("input", { disabled: disabled, value: value.sanctionListSource ?? '', onChange: (event) => onChange({ ...value, sanctionListSource: event.target.value }) }) }), _jsx(FormField, { label: "\u53D1\u5E03/\u751F\u6548\u65E5\u671F", children: _jsx("input", { type: "date", disabled: disabled, value: value.effectiveDate ?? '', onChange: (event) => onChange({ ...value, effectiveDate: event.target.value }) }) }), _jsx(FormField, { label: "\u5236\u88C1\u539F\u56E0", children: _jsx("textarea", { disabled: disabled, rows: 4, value: value.sanctionReason ?? '', onChange: (event) => onChange({ ...value, sanctionReason: event.target.value }) }) }), _jsx(FormField, { label: "\u5907\u6CE8", children: _jsx("textarea", { disabled: disabled, rows: 3, value: value.remarks ?? '', onChange: (event) => onChange({ ...value, remarks: event.target.value }) }) })] });
|
|
420
|
+
}
|
|
421
|
+
function SourceEvidence({ item }) {
|
|
422
|
+
return _jsxs(FieldGrid, { columns: 1, children: [_jsx(FormField, { label: "\u6765\u6E90\u7C7B\u578B", children: _jsx("input", { disabled: true, value: labelFor(item?.sourceType, sourceTypeLabels) }) }), _jsx(FormField, { label: "\u6765\u6E90\u6587\u4EF6", children: _jsx("input", { disabled: true, value: item?.sourceFileName ?? '—' }) }), _jsx(FormField, { label: "\u6765\u6E90\u4F4D\u7F6E", children: _jsx("input", { disabled: true, value: item?.sourceLocation ?? '—' }) }), _jsx(FormField, { label: "\u6765\u6E90\u539F\u6587", children: _jsx("textarea", { disabled: true, rows: 12, value: item?.sourceContent ?? '—' }) })] });
|
|
423
|
+
}
|
|
424
|
+
export function CatalogImportSummaryNotice({ documentType, batch, busy, onDownload, onView }) {
|
|
425
|
+
const issueCount = (batch.duplicateCount ?? 0) + (batch.invalidCount ?? 0);
|
|
426
|
+
const initialIssueType = (batch.duplicateCount ?? 0) > 0 ? 'DUPLICATE' : 'INVALID';
|
|
427
|
+
return _jsxs(InfoNotice, { children: [_jsxs("span", { children: ["\u5BFC\u5165\u5B8C\u6210\uFF1A\u603B\u6570 ", batch.totalCount ?? 0, "\uFF0C\u6210\u529F ", batch.successCount ?? 0, "\uFF0C\u91CD\u590D ", batch.duplicateCount ?? 0, "\uFF0C\u65E0\u6548 ", batch.invalidCount ?? 0, "\u3002"] }), issueCount > 0 && _jsxs(_Fragment, { children: [_jsxs("button", { type: "button", className: "tcw-button tcw-button--secondary", disabled: busy || !onView, onClick: () => void onView?.(batch.id, initialIssueType), children: [_jsx("i", { className: "ri-list-check-2", "aria-hidden": "true" }), "\u67E5\u770B\u660E\u7EC6"] }), _jsxs("button", { type: "button", className: "tcw-button tcw-button--secondary", disabled: busy, onClick: () => void onDownload(documentType, batch.id), children: [_jsx("i", { className: "ri-download-line", "aria-hidden": "true" }), "\u4E0B\u8F7D Excel"] })] })] });
|
|
428
|
+
}
|
|
429
|
+
export function CatalogImportStatusNotice({ task, busy, onRetry }) {
|
|
430
|
+
if (task.status !== 'FAILED' && task.status !== 'TIMED_OUT')
|
|
431
|
+
return null;
|
|
432
|
+
return _jsxs("div", { className: "tcw-catalog-import-failure", role: "alert", children: [_jsxs("div", { children: [_jsx("strong", { children: task.status === 'TIMED_OUT' ? '目录解析超时' : '目录解析失败' }), _jsx("p", { children: task.errorMessage || '解析任务未完成,请重新解析。' })] }), _jsxs("button", { type: "button", className: "tcw-button tcw-button--primary", disabled: busy, onClick: () => void onRetry(task.id).catch(() => undefined), children: [_jsx("i", { className: "ri-restart-line", "aria-hidden": "true" }), "\u91CD\u65B0\u89E3\u6790"] })] });
|
|
433
|
+
}
|
|
434
|
+
export function CatalogImportIssuesDialog({ open, documentType, batchId, issueType, collection, loading, error, busy, onClose, onIssueTypeChange, onPageChange, onRetry }) {
|
|
435
|
+
const columns = [
|
|
436
|
+
{ type: 'text', key: 'issueType', header: '问题类型', width: 100, format: (value) => value === 'DUPLICATE' ? '重复' : '无效' },
|
|
437
|
+
{ type: 'text', key: 'sourceSequence', header: '来源序号', width: 100 },
|
|
438
|
+
{ type: 'ellipsis', key: 'sourceLocation', header: '来源位置', width: 160, maxWidth: 160 },
|
|
439
|
+
{ type: 'ellipsis', key: 'sourceContent', header: '来源原文', width: 260, maxWidth: 260 },
|
|
440
|
+
{ type: 'ellipsis', key: 'message', header: '问题说明', width: 220, maxWidth: 220 }
|
|
441
|
+
];
|
|
442
|
+
return _jsxs(Modal, { open: open, title: "\u5BFC\u5165\u95EE\u9898\u660E\u7EC6", size: "wide", onClose: onClose, footer: _jsx("button", { type: "button", className: "tcw-button tcw-button--primary", onClick: onClose, children: "\u5173\u95ED" }), children: [_jsxs("div", { className: "tcw-catalog-issue-toolbar", "data-document-type": documentType, "data-batch-id": batchId, children: [_jsx("button", { type: "button", className: issueType === 'DUPLICATE' ? 'is-active' : '', disabled: busy || loading, onClick: () => onIssueTypeChange('DUPLICATE'), children: "\u91CD\u590D" }), _jsx("button", { type: "button", className: issueType === 'INVALID' ? 'is-active' : '', disabled: busy || loading, onClick: () => onIssueTypeChange('INVALID'), children: "\u65E0\u6548" })] }), loading && _jsx("p", { className: "tcw-catalog-issue-status", role: "status", children: "\u6B63\u5728\u52A0\u8F7D\u5BFC\u5165\u95EE\u9898\u660E\u7EC6..." }), error && _jsxs("div", { className: "tcw-catalog-issue-error", role: "alert", children: [_jsx("span", { children: error }), _jsx("button", { type: "button", className: "tcw-button tcw-button--secondary", disabled: busy || loading, onClick: onRetry, children: "\u91CD\u65B0\u52A0\u8F7D" })] }), !loading && !error && _jsx(DataGrid, { columns: columns, rows: collection.items, rowKey: "id", pagination: collectionPagination(collection), onPageChange: onPageChange, emptyText: issueType === 'DUPLICATE' ? '暂无重复数据' : '暂无无效数据' })] });
|
|
443
|
+
}
|
|
444
|
+
export function HsCodeLookupDialog({ open, initialQuery, onAction, onClose }) {
|
|
445
|
+
const [query, setQuery] = React.useState(initialQuery);
|
|
446
|
+
const [page, setPage] = React.useState(1);
|
|
447
|
+
const [results, setResults] = React.useState([]);
|
|
448
|
+
const [detail, setDetail] = React.useState(null);
|
|
449
|
+
const [error, setError] = React.useState('');
|
|
450
|
+
const [loading, setLoading] = React.useState(false);
|
|
451
|
+
const search = React.useCallback(async (keywords, nextPage = 1) => {
|
|
452
|
+
const normalized = keywords.trim();
|
|
453
|
+
if (!normalized) {
|
|
454
|
+
setError('请输入商品名称或海关编码');
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
setLoading(true);
|
|
458
|
+
setError('');
|
|
459
|
+
setDetail(null);
|
|
460
|
+
try {
|
|
461
|
+
const response = await onAction('search_hs_code', { keywords: normalized, page: nextPage });
|
|
462
|
+
if (response.success === false)
|
|
463
|
+
throw new Error(response.message || '海关编码查询失败');
|
|
464
|
+
const data = isHsSearchData(response.data) ? response.data : { results: [] };
|
|
465
|
+
setResults(data.results);
|
|
466
|
+
setPage(nextPage);
|
|
467
|
+
}
|
|
468
|
+
catch (cause) {
|
|
469
|
+
setError(errorMessage(cause, '海关编码查询失败'));
|
|
470
|
+
setResults([]);
|
|
471
|
+
}
|
|
472
|
+
finally {
|
|
473
|
+
setLoading(false);
|
|
474
|
+
}
|
|
475
|
+
}, [onAction]);
|
|
476
|
+
React.useEffect(() => {
|
|
477
|
+
if (!open)
|
|
478
|
+
return;
|
|
479
|
+
setQuery(initialQuery);
|
|
480
|
+
setPage(1);
|
|
481
|
+
void search(initialQuery, 1);
|
|
482
|
+
}, [open, initialQuery, search]);
|
|
483
|
+
const showDetail = async (result) => {
|
|
484
|
+
setLoading(true);
|
|
485
|
+
setError('');
|
|
486
|
+
try {
|
|
487
|
+
const response = await onAction('get_hs_code_detail', { code: result.code, ...(result.detailUrl ? { detailUrl: result.detailUrl } : {}) });
|
|
488
|
+
if (response.success === false)
|
|
489
|
+
throw new Error(response.message || '海关编码详情查询失败');
|
|
490
|
+
setDetail(isRecord(response.data) ? response.data : {});
|
|
491
|
+
}
|
|
492
|
+
catch (cause) {
|
|
493
|
+
setError(errorMessage(cause, '海关编码详情查询失败'));
|
|
494
|
+
}
|
|
495
|
+
finally {
|
|
496
|
+
setLoading(false);
|
|
497
|
+
}
|
|
498
|
+
};
|
|
499
|
+
const columns = [
|
|
500
|
+
{ type: 'text', key: 'code', header: '海关编码', width: 130 },
|
|
501
|
+
{ type: 'ellipsis', key: 'name', header: '商品名称', width: 220, maxWidth: 220 },
|
|
502
|
+
{ type: 'ellipsis', key: 'englishName', header: '英文名称', width: 220, maxWidth: 220 },
|
|
503
|
+
{ type: 'text', key: 'unit', header: '单位', width: 90 },
|
|
504
|
+
{ type: 'text', key: 'taxRefundRate', header: '退税率', width: 90 }
|
|
505
|
+
];
|
|
506
|
+
return (_jsxs(Modal, { open: open, title: "\u6D77\u5173\u7F16\u7801\u67E5\u8BE2", size: "wide", onClose: onClose, footer: _jsx("button", { type: "button", className: "tcw-button tcw-button--primary", onClick: onClose, children: "\u5173\u95ED" }), children: [_jsx("form", { onSubmit: (event) => { event.preventDefault(); void search(query, 1); }, children: _jsxs(FieldGrid, { columns: 2, children: [_jsx(FormField, { label: "\u5546\u54C1\u540D\u79F0\u6216\u6D77\u5173\u7F16\u7801", required: true, children: _jsx("input", { value: query, onChange: (event) => setQuery(event.target.value) }) }), _jsx("div", { children: _jsxs("button", { type: "submit", className: "tcw-button tcw-button--primary", disabled: loading, children: [_jsx("i", { className: "ri-search-line", "aria-hidden": "true" }), "\u67E5\u8BE2"] }) })] }) }), error && _jsx("p", { role: "alert", children: error }), detail ? _jsx(HsCodeDetail, { detail: detail, onBack: () => setDetail(null) }) : _jsxs(_Fragment, { children: [_jsx(DataGrid, { columns: columns, rows: results, rowKey: (row) => row.code, actions: (row) => _jsx("button", { type: "button", onClick: () => void showDetail(row), children: "\u8BE6\u60C5" }), emptyText: loading ? '查询中' : '暂无海关编码结果' }), results.length > 0 && _jsxs("div", { className: "tcw-page-commands", children: [_jsx("button", { type: "button", className: "tcw-button tcw-button--secondary", disabled: loading || page <= 1, onClick: () => void search(query, page - 1), children: "\u4E0A\u4E00\u9875" }), _jsxs("span", { children: ["\u7B2C ", page, " \u9875"] }), _jsx("button", { type: "button", className: "tcw-button tcw-button--secondary", disabled: loading, onClick: () => void search(query, page + 1), children: "\u4E0B\u4E00\u9875" })] })] })] }));
|
|
507
|
+
}
|
|
508
|
+
function HsCodeDetail({ detail, onBack }) {
|
|
509
|
+
return _jsxs("section", { children: [_jsxs("button", { type: "button", className: "tcw-button tcw-button--secondary", onClick: onBack, children: [_jsx("i", { className: "ri-arrow-left-line", "aria-hidden": "true" }), "\u8FD4\u56DE\u67E5\u8BE2\u7ED3\u679C"] }), _jsxs("h3", { children: [detail.code || '—', " ", detail.name || detail.title || ''] }), _jsxs("p", { children: [_jsx("strong", { children: "\u67E5\u8BE2\u65F6\u95F4\uFF1A" }), detail.queriedAt || '—'] }), detail.sourceUrl && _jsxs("p", { children: [_jsx("strong", { children: "\u6570\u636E\u6765\u6E90\uFF1A" }), _jsx("a", { href: detail.sourceUrl, target: "_blank", rel: "noreferrer", children: detail.sourceUrl })] }), detail.sections?.map((section, index) => _jsxs("section", { children: [_jsx("h4", { children: section.title || '详情' }), section.rows?.map((row, rowIndex) => _jsxs("p", { children: [_jsxs("strong", { children: [row.label || '字段', "\uFF1A"] }), row.value || '—'] }, `${row.label ?? 'row'}-${rowIndex}`))] }, `${section.title ?? 'detail'}-${index}`))] });
|
|
510
|
+
}
|
|
511
|
+
export function hsLookupQuery(row, field) {
|
|
512
|
+
return String(row[field] ?? '').trim();
|
|
513
|
+
}
|
|
514
|
+
function controlledForm(item) {
|
|
515
|
+
return {
|
|
516
|
+
catalogType: item?.catalogType ?? 'DUAL_USE',
|
|
517
|
+
productName: item?.productName ?? '',
|
|
518
|
+
hsCode: item?.hsCode ?? '',
|
|
519
|
+
controlDescription: item?.controlDescription ?? ''
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
function sanctionedForm(item) {
|
|
523
|
+
return {
|
|
524
|
+
companyName: item?.companyName ?? '',
|
|
525
|
+
countryOrRegion: item?.countryOrRegion ?? '',
|
|
526
|
+
sanctionListSource: item?.sanctionListSource ?? '',
|
|
527
|
+
effectiveDate: item?.effectiveDate ?? '',
|
|
528
|
+
sanctionReason: item?.sanctionReason ?? '',
|
|
529
|
+
remarks: item?.remarks ?? ''
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
function LinkButton({ children, title, onClick }) {
|
|
533
|
+
return _jsx("span", { className: "tcw-row-actions", children: _jsx("button", { type: "button", title: title, onClick: onClick, children: children }) });
|
|
534
|
+
}
|
|
535
|
+
function options(labels) {
|
|
536
|
+
return Object.entries(labels).map(([value, label]) => ({ value, label: String(label) }));
|
|
537
|
+
}
|
|
538
|
+
function labelFor(value, labels) {
|
|
539
|
+
return typeof value === 'string' && value in labels ? labels[value] : value ? String(value) : '—';
|
|
540
|
+
}
|
|
541
|
+
function isHsSearchData(value) {
|
|
542
|
+
return isRecord(value) && Array.isArray(value.results) && value.results.every((item) => isRecord(item) && typeof item.code === 'string');
|
|
543
|
+
}
|
|
544
|
+
function isRecord(value) {
|
|
545
|
+
return Boolean(value && typeof value === 'object' && !Array.isArray(value));
|
|
546
|
+
}
|
|
547
|
+
function errorMessage(value, fallback) {
|
|
548
|
+
return value instanceof Error ? value.message : fallback;
|
|
549
|
+
}
|
|
550
|
+
function assertActionSucceeded(response) {
|
|
551
|
+
if (response.success === false)
|
|
552
|
+
throw new Error(typeof response.message === 'string' && response.message ? response.message : '操作失败');
|
|
553
|
+
}
|
|
554
|
+
function collectionPagination(collection) {
|
|
555
|
+
const pageSize = Number(collection.pageSize) > 0 ? Number(collection.pageSize) : PAGE_SIZE;
|
|
556
|
+
const total = Number(collection.total) >= 0 ? Number(collection.total) : collection.items.length;
|
|
557
|
+
const pageCount = Math.max(1, Math.ceil(total / pageSize));
|
|
558
|
+
const page = Math.min(pageCount, Math.max(1, Number(collection.page) || 1));
|
|
559
|
+
return { page, pageSize, total, pageCount };
|
|
560
|
+
}
|
|
561
|
+
function asImportCompletion(value) {
|
|
562
|
+
if (!isRecord(value) || !isRecord(value.task))
|
|
563
|
+
throw new Error('上传完成响应缺少任务信息');
|
|
564
|
+
return value;
|
|
565
|
+
}
|
|
566
|
+
function isCatalogImportStartData(value) {
|
|
567
|
+
return isRecord(value) && isRecord(value.task) && typeof value.task.id === 'string' && typeof value.task.documentType === 'string' && typeof value.task.status === 'string' && Array.isArray(value.commands) && value.commands.every((command) => isRecord(command) && typeof command.commandKey === 'string' && isRecord(command.payload)) && isRecord(value.polling) && Number.isFinite(value.polling.intervalMs) && Number.isFinite(value.polling.timeoutMs);
|
|
568
|
+
}
|
|
569
|
+
function delay(milliseconds) {
|
|
570
|
+
return new Promise((resolve) => setTimeout(resolve, milliseconds));
|
|
571
|
+
}
|
|
572
|
+
//# sourceMappingURL=catalogs.js.map
|