Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
ujia
/
uj-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 4f2a3c71
authored
Nov 18, 2026
by
chenwq
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
重构报告管理页面,新增查询功能和数据表格展示
1 parent
e941562e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
198 additions
and
4 deletions
apps/web/subapps/usedcar/src/pages/Reports/index.tsx
apps/web/subapps/usedcar/src/pages/Reports/index.tsx
View file @
4f2a3c7
import { RoutePlaceholder } from '@/features/shared/RoutePlaceholder';
import { useMemo, useState } from 'react';
import { useQuery } from '@tanstack/react-query';
/** menu_code 1002609 · 报告管理 · usedcar:report:view */
import type { Dayjs } from 'dayjs';
import { UAlert, UButton, UCard, UImage, UResult, UTag } from '@uj/ui';
import { downloadCenter } from '@uj/platform-sdk';
import {
DataTable,
PageShell,
SearchForm,
type FieldSchema,
type RowActionSchema,
} from '@/components';
import { checkReportApi } from '@/api';
import { useAccess } from '@/access';
import { UC } from '@/permissions/codes';
import { errorDetail } from '@/utils/error';
type Filters = Record<string, unknown> & {
queryUser?: string;
vin?: string;
reportType?: string;
status?: string;
dateValue?: [Dayjs, Dayjs];
};
type Row = Record<string, unknown> & {
id: string | number;
status?: string | number;
reportUrl?: string;
};
type Result = { records: Row[]; total: number };
const text = (v: unknown) => (v === undefined || v === null || v === '' ? '-' : String(v));
const STATUS = [
{ value: '0', label: '生成中' },
{ value: '1', label: '生成成功' },
{ value: '2', label: '生成失败' },
];
const TYPES = [
{ value: '0', label: '事故报告' },
{ value: '1', label: '维保报告' },
];
const label = (arr: typeof STATUS, v: unknown) =>
arr.find((x) => x.value === String(v))?.label ?? '-';
function paramsOf(f: Filters) {
const { dateValue, ...rest } = f;
return {
...rest,
...(dateValue
? {
queryTimeStart: dateValue[0].format('YYYY-MM-DD HH:mm:ss'),
queryTimeEnd: dateValue[1].format('YYYY-MM-DD HH:mm:ss'),
}
: {}),
};
}
export default function Reports() {
export default function Reports() {
return <RoutePlaceholder title="报告管理" route="/usedcar/reports" />;
const { canPoint } = useAccess();
const [f, setF] = useState<Filters>({});
const [p, setP] = useState({ current: 1, size: 10 });
const [selected, setSelected] = useState<React.Key[]>([]);
const params = useMemo(() => paramsOf(f), [f]);
const q = useQuery({
queryKey: ['check-report', params, p],
queryFn: () =>
checkReportApi.getcheckReportList<Result>({
currentPage: p.current,
pageSize: p.size,
t: params,
}),
enabled: canPoint(UC.REPORT_VIEW),
});
const fields: FieldSchema<Filters>[] = [
{
name: 'queryUser',
label: '查询人',
type: 'input',
essential: true,
inputProps: { maxLength: 20 },
},
{
name: 'vin',
label: '车架号',
type: 'input',
essential: true,
inputProps: { maxLength: 20 },
normalize: (v) =>
String(v ?? '')
.replace(/[^\x20-\x7E]/g, '')
.slice(0, 20),
},
{ name: 'dateValue', label: '查询时间', type: 'dateRange' },
{ name: 'reportType', label: '报告类型', type: 'select', options: TYPES },
{ name: 'status', label: '报告状态', type: 'select', options: STATUS },
];
const columns = [
{ title: '查询流水号', dataIndex: 'checkno', width: 176, line: 1, render: text },
{
title: '报告类型',
dataIndex: 'reportType',
width: 110,
render: (v: unknown) => label(TYPES, v),
},
{ title: '车架号', dataIndex: 'vin', width: 150, line: 1, render: text },
{
title: '报告状态',
dataIndex: 'status',
width: 120,
render: (v: unknown) => <UTag>{label(STATUS, v)}</UTag>,
},
{
title: '行驶证凭证',
dataIndex: 'licenseUrl',
width: 138,
render: (v: unknown) =>
typeof v === 'string' ? <UImage src={v} width={110} height={54} /> : '-',
},
{ title: '查询人', dataIndex: 'queryUser', width: 120, line: 1, render: text },
{ title: '查询时间', dataIndex: 'queryTime', width: 170, line: 1, render: text },
];
const rows: RowActionSchema<Row>[] = [
{
label: '详情',
permission: UC.REPORT_DETAIL,
visible: (r) => String(r.status) === '1' && Boolean(r.reportUrl),
onClick: (r) => {
if (r.reportUrl) window.open(r.reportUrl, '_blank', 'noopener,noreferrer');
},
},
];
if (!canPoint(UC.REPORT_VIEW))
return (
<UResult status="403" title="无访问报告管理的权限" subTitle="请联系管理员开通访问权限。" />
);
return (
<PageShell fill title="报告管理">
<UCard className="uj-filter-card" size="small">
<SearchForm
fields={fields}
onSearch={(v) => {
setF(v);
setP((x) => ({ ...x, current: 1 }));
}}
onReset={() => setF({})}
/>
</UCard>
{q.isError ? (
<UAlert
type="error"
showIcon
title="报告列表加载失败"
description={errorDetail(q.error)}
action={
<UButton type="link" onClick={() => void q.refetch()}>
重试
</UButton>
}
/>
) : null}
<UCard size="small" fill>
<DataTable<Row>
rowKey="id"
fillHeight
columns={columns}
dataSource={q.data?.records ?? []}
loading={q.isPending || q.isFetching}
rowSelection={{ selectedRowKeys: selected, onChange: setSelected }}
rowActions={rows}
actions={
canPoint(UC.REPORT_EXPORT)
? [
{
label: '导出',
tone: 'export',
onClick: () =>
downloadCenter.asyncExport({
source: 'usedcar',
sourceLabel: '二手车管理 / 报告管理',
label: '报告管理',
method: '/checkReport/export',
params: {
...params,
idsStr: selected.join(','),
server_provider_type: 'gsc',
server_provider_name: 'gsc-vcp-web-facade',
},
dedupeKey: 'check-report-export',
}),
},
]
: []
}
pagination={{
current: p.current,
pageSize: p.size,
total: q.data?.total ?? 0,
onChange: (current, size) => setP({ current, size }),
}}
/>
</UCard>
</PageShell>
);
}
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment