fix: harden real backend admin workflows and ui

This commit is contained in:
hectorzhao
2026-07-03 19:29:56 +08:00
parent dd09d91c1e
commit 8cca361441
71 changed files with 5111 additions and 4439 deletions
+26 -10
View File
@@ -13,12 +13,12 @@ const statusMeta: Record<string, { label: string; tone: 'neutral' | 'info' | 'su
failed: { label: '有失败', tone: 'danger' },
};
function ReceiptImportModal({ onClose, onSubmit }: { onClose: () => void; onSubmit: (fileName: string, remark: string) => void }) {
const [fileName, setFileName] = useState('');
function ReceiptImportModal({ onClose, onSubmit }: { onClose: () => void; onSubmit: (file: File, remark: string) => void }) {
const [file, setFile] = useState<File | null>(null);
const [remark, setRemark] = useState('');
return (
<Modal
footer={<><Button onClick={onClose} variant="ghost"></Button><Button disabled={!fileName} onClick={() => onSubmit(fileName, remark)}></Button></>}
footer={<><Button onClick={onClose} variant="ghost"></Button><Button disabled={!file} onClick={() => file && onSubmit(file, remark)}></Button></>}
onClose={onClose}
open
size="xl"
@@ -27,9 +27,14 @@ function ReceiptImportModal({ onClose, onSubmit }: { onClose: () => void; onSubm
<div className="report-receipt-modal">
<label className="report-upload-drop">
<FileUp size={38} />
<strong>{fileName || '选择回执文件'}</strong>
<span> ExcelCSVPDF </span>
<input onChange={(event) => setFileName(event.target.files?.[0]?.name ?? '')} style={{ display: 'none' }} type="file" />
<strong>{file?.name || '选择回执文件'}</strong>
<span> CSVTSVTXT /</span>
<input
accept=".csv,.tsv,.txt,text/csv,text/plain"
onChange={(event) => setFile(event.target.files?.[0] ?? null)}
style={{ display: 'none' }}
type="file"
/>
</label>
<Textarea label="导入备注" onChange={(event) => setRemark(event.target.value)} placeholder="记录回执来源、运营商工单号或人工处理说明" rows={4} value={remark} />
</div>
@@ -87,20 +92,31 @@ export function AdminReportTasksPage() {
.catch((failure: Error) => setError(failure.message || '报备任务导出失败'));
}
function importReceipt(fileName: string, remark: string) {
function importReceipt(file: File, remark: string) {
if (!receiptTask) return;
adminApi.importReportReceipt(receiptTask.id, { fileName, reason: remark, statusAfter: 'partial' })
const delimiter = file.name.toLowerCase().endsWith('.tsv') ? '\t' : ',';
Promise.all([
adminApi.uploadFileObject(file, { purpose: 'report_receipt', prefix: `report-receipts/${receiptTask.id}` }),
file.text(),
])
.then(([fileObject, fileContent]) => adminApi.importReportReceipt(receiptTask.id, {
fileObjectId: fileObject.id,
fileName: file.name,
fileContent,
delimiter,
reason: remark,
}))
.then(() => {
setReceiptTask(null);
loadData();
})
.catch((failure: Error) => setError(failure.message));
.catch((failure: Error) => setError(failure.message || '报备回执导入失败'));
}
const columns: Array<TableColumn<ReportTask>> = [
{ key: 'id', title: '任务编号', width: '190px', render: (record) => <strong className="admin-task-id">{record.id}</strong> },
{ key: 'scope', title: '通道/签名', width: '280px', render: (record) => <div className="admin-task-enterprise"><strong>{record.channel?.name ?? record.channelId}</strong><span>{record.signature?.name ?? record.signatureId}</span></div> },
{ key: 'status', title: '状态', width: '110px', render: (record) => <Tag tone={(statusMeta[record.status] ?? { tone: 'info' as const }).tone}>{(statusMeta[record.status] ?? { label: record.status }).label}</Tag> },
{ key: 'status', title: '状态', width: '130px', render: (record) => <Tag tone={(statusMeta[record.status] ?? { tone: 'info' as const }).tone}>{(statusMeta[record.status] ?? { label: record.status }).label}</Tag> },
{ key: 'time', title: '创建时间', width: '190px', render: (record) => record.createdAt ?? '-' },
{
key: 'actions',