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 9af59b70
authored
Nov 18, 2026
by
chenwq
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
新增车况信息页面及相关样式和配置
1 parent
6b00df2c
Pipeline
#521
for
9af59b70
failed
in 0 seconds
Changes
5
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
1551 additions
and
3 deletions
apps/web/subapps/usedcar/src/App.tsx
apps/web/subapps/usedcar/src/pages/Condition/ConditionDetail.tsx
apps/web/subapps/usedcar/src/pages/Condition/condition.css
apps/web/subapps/usedcar/src/pages/Condition/conditionConfig.ts
apps/web/subapps/usedcar/src/pages/Condition/index.tsx
apps/web/subapps/usedcar/src/App.tsx
View file @
9af59b7
...
@@ -26,6 +26,7 @@ import Ledger from './pages/Ledger';
...
@@ -26,6 +26,7 @@ import Ledger from './pages/Ledger';
import Handover from './pages/Handover';
import Handover from './pages/Handover';
import Reports from './pages/Reports';
import Reports from './pages/Reports';
import Condition from './pages/Condition';
import Condition from './pages/Condition';
import ConditionDetail from './pages/Condition/ConditionDetail';
import CustomerGroup from './pages/CustomerGroup';
import CustomerGroup from './pages/CustomerGroup';
import type { PageParams, RouteDef } from './routes';
import type { PageParams, RouteDef } from './routes';
import { matchRoute } from './routes';
import { matchRoute } from './routes';
...
@@ -55,6 +56,7 @@ const ROUTES: RouteDef[] = [
...
@@ -55,6 +56,7 @@ const ROUTES: RouteDef[] = [
{ path: 'handover', Page: Handover },
{ path: 'handover', Page: Handover },
{ path: 'reports', Page: Reports },
{ path: 'reports', Page: Reports },
{ path: 'condition', Page: Condition },
{ path: 'condition', Page: Condition },
{ path: 'condition/:id', Page: ConditionDetail },
{ path: 'customer-group', Page: CustomerGroup },
{ path: 'customer-group', Page: CustomerGroup },
];
];
...
...
apps/web/subapps/usedcar/src/pages/Condition/ConditionDetail.tsx
0 → 100644
View file @
9af59b7
import { useEffect, useMemo, useState } from 'react';
import dayjs from 'dayjs';
import { useQuery } from '@tanstack/react-query';
import {
UAlert,
UButton,
UCheckbox,
UDatePicker,
UForm,
UImage,
UInput,
UModal,
UResult,
USelect,
useUMessage,
} from '@uj/ui';
import { CombiForm } from '@/components';
import { PageShell } from '@/components';
import { carConditionApi, commonApi } from '@/api';
import { useAccess } from '@/access';
import { UC } from '@/permissions/codes';
import { errorDetail } from '@/utils/error';
import type { PageParams } from '@/routes';
import { goTo } from '../Leads/navigate';
import { BASE_FIELDS, colorLabel, PRICE_FIELDS, type ConditionValues } from './conditionConfig';
type Row = Record<string, unknown> & {
id: string | number;
carConditionCode?: string;
status?: number;
};
type Detail = Row & {
imageList?: Array<Record<string, unknown>>;
photos?: Array<Record<string, unknown>>;
};
const DATE_FIELDS = new Set([
'registrationDate',
'productionDate',
'compulsoryInsuranceExpiry',
'annualInspectionExpiry',
'commercialInsuranceExpiry',
]);
const PHOTO_SLOTS = [
['左前45度', 'leftFrontImgUrl', 11],
['主驾驶全景', 'driverSeatImgUrl', 12],
['中控台全景', 'centerConsoleImgUrl', 15],
['右后45度', 'rightFrontImgUrl', 16],
['仪表盘', 'mileageImgUrl', 13],
['行驶证', 'drivingLicenseImgUrl', 21],
['铭牌', 'nameplateImgUrl', 17],
['后排座椅', 'rearSeatImgUrl', 14],
['其他细节', 'otherDetailImgUrl', 41],
] as const;
const SOURCE_LABEL: Record<string, string> = {
'1': '展业助手 App',
'2': '生意助手员工版小程序',
'3': '车生活助手小程序',
};
const text = (value: unknown) =>
value === undefined || value === null || value === '' ? '-' : String(value);
const dateValue = (value: unknown) => (value ? dayjs(String(value).slice(0, 10)) : undefined);
function sourcePhotos(
data: Detail,
): Array<{ url: string; caption: string; subtype: number; video: boolean }> {
const list = Array.isArray(data.imageList)
? data.imageList
: Array.isArray(data.photos)
? data.photos
: [];
return PHOTO_SLOTS.flatMap(([caption, key, subtype]) => {
const image = list.find((item) => Number(item.fileSubtype) === subtype);
const url = String(data[key] ?? image?.fileUrl ?? image?.url ?? '');
if (subtype === 41 && !url) return [];
return [
{
url,
caption,
subtype,
video: subtype === 41 && /\.(mp4|webm|ogg|mov|m4v)(?:[?#]|$)/i.test(url),
},
];
});
}
function unwrap(data: unknown): Record<string, unknown> {
let result = (data && typeof data === 'object' && !Array.isArray(data) ? data : {}) as Record<
string,
unknown
>;
for (const key of ['data', 'carCondition', 'detail', 'record', 'vo', 'result', 'baseInfo']) {
const nested = result[key];
if (nested && typeof nested === 'object' && !Array.isArray(nested))
result = { ...result, ...nested };
}
const aliases: Record<string, string[]> = {
brandModel: ['carBrand', 'modelName', 'carModelText', 'vehicleModelName'],
engineNumber: ['engineNo', 'motorNumber', 'engineNum'],
displayMileage: ['evaOrderMileage'],
productionDate: ['manufactureDate', 'factoryDate'],
guidePrice: ['msrp', 'listPrice'],
previousOwnerPhone: ['ownerPhone', 'mobilePhone'],
ownerName: ['previousOwnerName', 'customerName'],
};
for (const [name, names] of Object.entries(aliases))
if (!result[name]) result[name] = names.map((key) => result[key]).find(Boolean);
result.registrationCityName ||= result['上牌城市'] ?? result.plateCityName;
result.carCityName ||= result['车辆所在地'] ?? result.vehicleCityName;
return result;
}
function toFormValues(data: Detail): ConditionValues {
const next: ConditionValues = { ...data };
for (const name of DATE_FIELDS) next[name] = dateValue(data[name]);
next.interiorCondition = data.interiorNewFlag ?? data.interiorCondition;
next.newCarPriceDrop = data.priceReducedFlag ?? data.newCarPriceDrop;
next.reportConditionDescription = data.reportConditionDescription ?? data.carConditionDescription;
next.frameStructure = data.skeletonAndStructureDescription ?? data.frameStructure;
next.historyStatus = data.historyAndStatusDescription ?? data.historyStatus;
next.prepCost = data.preparationCostEstimate ?? data.prepCost;
next.marketRisk = data.marketConditionRisks ?? data.marketRisk;
next.mileageKm = data.mileage ?? data.displayMileage;
return next;
}
function ymd(value: unknown) {
return value ? dayjs(value as dayjs.ConfigType).format('YYYY-MM-DD') : undefined;
}
function basePayload(values: ConditionValues) {
return {
carBrandId: values.carBrandId,
carBrand: values.brandModel,
carChildsBrandId: values.carChildsBrandId,
carChildsBrandName: values.carChildsBrandName,
carSeriesId: values.carSeriesId,
carSeriesName: values.carSeriesName,
carTypeId: values.carTypeId,
carTypeName: values.carTypeName,
vin: values.vin,
licensePlate: values.licensePlate,
engineNumber: values.engineNumber,
registrationDate: ymd(values.registrationDate),
registrationProvinceId: values.registrationProvinceId,
registrationProvinceName: values.registrationProvinceName,
registrationCityId: values.registrationCityId,
registrationCityName: values.registrationCityName,
carProvinceId: values.carProvinceId,
carProvinceName: values.carProvinceName,
carCityId: values.carCityId,
carCityName: values.carCityName,
mileage: Number(values.displayMileage),
usageType: Number(values.usageType),
ownerType: Number(values.ownerType),
sunroof: Number(values.sunroof),
vehicleCategory: Number(values.vehicleCategory),
emissionStandard: Number(values.emissionStandard),
interiorColor: colorLabel(values.interiorColor),
exteriorColor: colorLabel(values.exteriorColor),
productionDate: ymd(values.productionDate),
guidePrice: Number(values.guidePrice),
buyNewCar: Number(values.buyNewCar),
hasAccident: Number(values.hasAccident),
overallRating: Number(values.overallRating),
conditionDescription: values.conditionDescription || undefined,
};
}
function responseOk(response: unknown) {
if (response === true) return true;
const body = response as { code?: number; data?: { code?: number } };
return body?.code === 0 || body?.data?.code === 0;
}
function rowsOf(value: unknown): Record<string, unknown>[] {
if (Array.isArray(value))
return value.filter(
(item): item is Record<string, unknown> => !!item && typeof item === 'object',
);
if (value && typeof value === 'object') {
const data = value as Record<string, unknown>;
return rowsOf(data.records ?? data.list ?? data.data ?? data.childs ?? []);
}
return [];
}
function districtOptions(value: unknown) {
const root = Array.isArray(value) ? value[0] : undefined;
return rowsOf((root as Record<string, unknown> | undefined)?.districts).map((item) => ({
label: String(item.name ?? ''),
value: String(item.code ?? ''),
}));
}
export default function ConditionDetail({ params }: { params: PageParams }) {
const { canPoint } = useAccess();
const message = useUMessage();
const [form] = UForm.useForm<ConditionValues>();
const [creatingAssessment, setCreatingAssessment] = useState(false);
const [creatingReport, setCreatingReport] = useState(false);
const [updatingBase, setUpdatingBase] = useState(false);
const [checkingThirdReport, setCheckingThirdReport] = useState(false);
const [thirdReport, setThirdReport] = useState(false);
const [thirdReportPresent, setThirdReportPresent] = useState<boolean>();
const [baseOpen, setBaseOpen] = useState(true);
const [videoUrl, setVideoUrl] = useState('');
const allowed = canPoint(UC.CONDITION_EDIT);
const detail = useQuery({
queryKey: ['usedcar-condition-detail', params.id],
queryFn: () => carConditionApi.getCarConditionDetail<Detail>({ id: params.id }),
enabled: Boolean(params.id),
});
const record = params.id ? ({ id: params.id } as Row) : undefined;
const data = detail.data ? (unwrap(detail.data) as Detail) : (record as Detail | undefined);
const sellerMerchantId = data?.sellerMerchantId;
const sellerStaff = useQuery({
queryKey: ['condition-seller-staff', sellerMerchantId],
queryFn: () =>
commonApi.getEmployeeOnTheJobByMerchantId<unknown>({ merchantId: sellerMerchantId }),
enabled: Boolean(sellerMerchantId),
});
const stationedStaff = useQuery({
queryKey: ['condition-stationed-staff', sellerMerchantId],
queryFn: () =>
commonApi.merchantStaffList<unknown>({ mainMerchantId: sellerMerchantId, sceneType: 7 }),
enabled: Boolean(sellerMerchantId),
});
const provinces = useQuery({
queryKey: ['condition-provinces'],
queryFn: () => commonApi.getDistrictDetail<unknown>({ districtName: '中国' }),
});
const registrationProvinceName = UForm.useWatch('registrationProvinceName', form);
const carProvinceName = UForm.useWatch('carProvinceName', form);
const registrationCities = useQuery({
queryKey: ['condition-registration-cities', registrationProvinceName],
queryFn: () => commonApi.getDistrictDetail<unknown>({ districtName: registrationProvinceName }),
enabled: Boolean(registrationProvinceName),
});
const carCities = useQuery({
queryKey: ['condition-car-cities', carProvinceName],
queryFn: () => commonApi.getDistrictDetail<unknown>({ districtName: carProvinceName }),
enabled: Boolean(carProvinceName),
});
const brandList = useQuery({
queryKey: ['condition-brands'],
queryFn: () => commonApi.scrmCarlifeGetOnlyCarBrandList<unknown>({}),
});
const brandId = UForm.useWatch('carBrandId', form);
const childBrandId = UForm.useWatch('carChildsBrandId', form);
const seriesId = UForm.useWatch('carSeriesId', form);
const series = useQuery({
queryKey: ['condition-series', brandId, childBrandId],
queryFn: () => commonApi.scrmCarlifeGetCarSeriesList<unknown>({ brandId, childBrandId }),
enabled: Boolean(brandId && childBrandId),
});
const carTypes = useQuery({
queryKey: ['condition-car-types', seriesId],
queryFn: () => commonApi.scrmCarlifeGetCarTypeList<unknown>({ carSeriesId: seriesId }),
enabled: Boolean(seriesId),
});
const photos = useMemo(() => (data ? sourcePhotos(data) : []), [data]);
useEffect(() => {
if (!detail.data) return;
const normalized = unwrap(detail.data) as Detail;
form.setFieldsValue(toFormValues(normalized));
const present = normalized.hasThirdPartyReport === 1;
setThirdReportPresent(present);
setThirdReport(Boolean(present && normalized.checkThirdPartyReport));
}, [detail.data, form]);
const updateCore = async (values: ConditionValues) => {
if (!record) return false;
const result = await carConditionApi.updateCarCondition({
id: Number(record.id),
licensePlate: String(values.licensePlate ?? '').trim(),
vin: String(values.vin ?? '').trim(),
registrationDate: ymd(values.registrationDate),
compulsoryInsuranceExpiry: ymd(values.compulsoryInsuranceExpiry),
annualInspectionExpiry: ymd(values.annualInspectionExpiry),
commercialInsuranceExpiry: ymd(values.commercialInsuranceExpiry),
previousOwnerPhone: String(values.previousOwnerPhone ?? '').trim() || undefined,
registrationProvinceId: values.registrationProvinceId,
registrationProvinceName: values.registrationProvinceName,
registrationCityId: values.registrationCityId,
registrationCityName: values.registrationCityName,
carProvinceId: values.carProvinceId,
carProvinceName: values.carProvinceName,
carCityId: values.carCityId,
carCityName: values.carCityName,
});
if (!responseOk(result)) {
message.error('更新失败');
return false;
}
return true;
};
const createAssessment = async () => {
if (!record || !data) return;
try {
const values = await form.validateFields(BASE_FIELDS.map((field) => field.name));
if (!photos.slice(0, 8).every((item) => item.url)) {
message.warning('一线回传缺少必传照片,无法生成评估单');
return;
}
setCreatingAssessment(true);
if (!(await updateCore(values))) return;
const result = await carConditionApi.oneClickCreateEvalOrder({
carConditionId: Number(record.id),
evalOrderBasicReqDTO: {
sellerUserId: values.sellerUserId || undefined,
sellerName: values.sellerName || undefined,
sellerMerchantId: data.sellerMerchantId,
sellerMerchantName: values.sellerMerchantName || undefined,
conversionUserId: values.conversionUserId || undefined,
conversionName: values.conversionName || undefined,
conversionMerchantId: values.conversionMerchantId || undefined,
conversionMerchantName: values.conversionMerchantName || undefined,
},
carBaseReqDTO: basePayload(values),
carLicenseReqDTO: {
keyCount: Number(values.keyCount),
transferCount: Number(values.transferCount),
compulsoryInsuranceExpiry: ymd(values.compulsoryInsuranceExpiry),
annualInspectionExpiry: ymd(values.annualInspectionExpiry),
commercialInsuranceExpiry: ymd(values.commercialInsuranceExpiry),
previousOwnerName: values.ownerName,
previousOwnerAddress: values.previousOwnerAddress,
previousOwnerPhone: values.previousOwnerPhone,
},
imageList: photos
.filter((photo) => photo.url)
.map((photo) => ({
fileType:
photo.subtype >= 11 && photo.subtype <= 17
? 1
: photo.subtype >= 21 && photo.subtype <= 22
? 2
: photo.subtype === 41
? 4
: 3,
fileSubtype: photo.subtype,
fileName: photo.url.split('/').pop()?.slice(0, 255) || 'image',
fileUrl: photo.url.slice(0, 500),
fileFormat: photo.video
? 'mp4'
: photo.url.split('?')[0].toLowerCase().endsWith('.png')
? 'png'
: 'jpeg',
})),
});
if (!responseOk(result)) {
message.error('操作失败');
return;
}
message.success('提交成功');
await detail.refetch();
} catch (error) {
if (error instanceof Error) message.error(errorDetail(error));
} finally {
setCreatingAssessment(false);
}
};
const updateBase = async () => {
try {
const values = await form.validateFields([
'licensePlate',
'vin',
'registrationDate',
'compulsoryInsuranceExpiry',
'annualInspectionExpiry',
'commercialInsuranceExpiry',
'previousOwnerPhone',
'registrationCityName',
'carCityName',
]);
setUpdatingBase(true);
if (await updateCore(values)) {
message.success('更新成功');
await detail.refetch();
}
} catch (error) {
if (error instanceof Error) message.error(errorDetail(error));
} finally {
setUpdatingBase(false);
}
};
const checkThirdPartyReport = async () => {
const vin = String(form.getFieldValue('vin') ?? '').trim();
if (!/^[A-HJ-NPR-Z0-9]{17}$/i.test(vin)) {
message.warning('请先填写 17 位有效车架号');
return;
}
setCheckingThirdReport(true);
try {
const result = await carConditionApi.checkCarConditionThirdPartyReport<{
code?: number;
data?: Record<string, unknown> | boolean;
}>({ vin });
const data = result.data;
const payload = data && typeof data === 'object' ? data : {};
const matched =
(result.code === undefined || Number(result.code) === 0) &&
data !== false &&
payload.matched !== false &&
payload.hasReport !== false &&
payload.hasRecord !== false;
setThirdReportPresent(matched);
if (!matched) setThirdReport(false);
message[matched ? 'success' : 'warning'](matched ? '已查询到事故报告' : '未查询到事故报告');
} catch (error) {
message.error(errorDetail(error));
} finally {
setCheckingThirdReport(false);
}
};
const createAiReport = async () => {
if (!record) return;
try {
const values = await form.validateFields(
[...BASE_FIELDS, ...PRICE_FIELDS].map((field) => field.name),
);
setCreatingReport(true);
const result = await carConditionApi.generateCarConditionAiReport({
carConditionId: Number(record.id),
vin: values.vin,
brandModel: values.brandModel,
targetPurchasePrice: Number(values.targetPrice),
maximumReservePrice: Number(values.maxReservedPrice),
priceReducedFlag: Number(values.newCarPriceDrop),
interiorNewFlag: Number(values.interiorCondition),
mileage: Number(values.mileageKm),
carConditionDescription: values.reportConditionDescription,
skeletonAndStructureDescription: values.frameStructure || undefined,
historyAndStatusDescription: values.historyStatus || undefined,
preparationCostEstimate: values.prepCost ? Number(values.prepCost) : undefined,
marketConditionRisks: values.marketRisk || undefined,
buyNewCar: Number(values.buyNewCar),
hasAccident: Number(values.hasAccident),
overallRating: Number(values.overallRating),
interiorColor: colorLabel(values.interiorColor),
exteriorColor: colorLabel(values.exteriorColor),
checkThirdPartyReport: thirdReport,
});
if (!responseOk(result)) {
message.error('操作失败');
return;
}
message.success('提交成功');
await detail.refetch();
} catch (error) {
if (error instanceof Error) message.error(errorDetail(error));
} finally {
setCreatingReport(false);
}
};
const checkVin = async () => {
const vin = String(form.getFieldValue('vin') ?? '').trim();
if (!/^[A-HJ-NPR-Z0-9]{17}$/i.test(vin)) return;
try {
const result = await commonApi.padVinValidate<{
code?: number;
data?: { valid?: boolean; message?: string };
message?: string;
}>({ vin });
if (result.code !== 0 || result.data?.valid === false)
message.warning(result.data?.message ?? result.message ?? '车架号未通过校验');
} catch (error) {
message.warning(errorDetail(error));
}
};
const brandRows = rowsOf(brandList.data);
const selectedBrand = brandRows.find((item) => String(item.id) === String(brandId));
const childBrands = rowsOf(selectedBrand?.childs);
const renderBaseControl = (field: (typeof BASE_FIELDS)[number]) => {
if (DATE_FIELDS.has(field.name)) return <UDatePicker style={{ width: '100%' }} />;
if (field.name === 'vin') return <UInput onBlur={() => void checkVin()} />;
if (field.name === 'brandModel')
return (
<div className="uc-condition-detail__compound">
<USelect
value={brandId as string}
options={brandRows.map((item) => ({ value: String(item.id), label: text(item.name) }))}
placeholder="请选择品牌"
onChange={(value) =>
form.setFieldsValue({
carBrandId: value,
carChildsBrandId: undefined,
carSeriesId: undefined,
carTypeId: undefined,
brandModel: '',
})
}
/>
<USelect
value={childBrandId as string}
options={childBrands.map((item) => ({
value: String(item.id),
label: text(item.name),
}))}
placeholder="请选择子品牌"
onChange={(value) =>
form.setFieldsValue({
carChildsBrandId: value,
carSeriesId: undefined,
carTypeId: undefined,
brandModel: '',
})
}
/>
<USelect
value={seriesId as string}
options={rowsOf(series.data).map((item) => ({
value: String(item.id),
label: text(item.name),
}))}
placeholder="请选择车系"
onChange={(value) =>
form.setFieldsValue({ carSeriesId: value, carTypeId: undefined, brandModel: '' })
}
/>
<USelect
value={form.getFieldValue('carTypeId') as string}
options={rowsOf(carTypes.data).map((item) => ({
value: String(item.id),
label: text(item.name),
}))}
placeholder="请选择车型"
onChange={(value) => {
const item = rowsOf(carTypes.data).find((row) => String(row.id) === String(value));
form.setFieldsValue({
carTypeId: value,
brandModel: [
selectedBrand?.name,
childBrands.find((row) => String(row.id) === String(childBrandId))?.name,
rowsOf(series.data).find((row) => String(row.id) === String(seriesId))?.name,
item?.name,
]
.filter(Boolean)
.join(' '),
});
}}
/>
</div>
);
const region =
field.name === 'registrationCityName'
? {
provinceName: 'registrationProvinceName',
provinceId: 'registrationProvinceId',
cityName: 'registrationCityName',
cityId: 'registrationCityId',
cities: registrationCities.data,
}
: field.name === 'carCityName'
? {
provinceName: 'carProvinceName',
provinceId: 'carProvinceId',
cityName: 'carCityName',
cityId: 'carCityId',
cities: carCities.data,
}
: undefined;
if (region)
return (
<div className="uc-condition-detail__compound">
<USelect
value={form.getFieldValue(region.provinceName) as string}
options={districtOptions(provinces.data)}
placeholder="请选择省"
onChange={(value, option) =>
form.setFieldsValue({
[region.provinceName]: option?.label,
[region.provinceId]: value,
[region.cityName]: undefined,
[region.cityId]: undefined,
})
}
/>
<USelect
value={form.getFieldValue(region.cityName) as string}
options={districtOptions(region.cities)}
placeholder="请选择市"
onChange={(value, option) =>
form.setFieldsValue({ [region.cityName]: option?.label, [region.cityId]: value })
}
/>
</div>
);
if (field.name === 'sellerUserId')
return (
<USelect
showSearch
loading={sellerStaff.isFetching}
options={rowsOf(sellerStaff.data).map((item) => ({
value: String(item.uuid),
label: text(item.staffName ?? item.userName ?? item.name),
}))}
onChange={(value, option) =>
form.setFieldsValue({ sellerUserId: value, sellerName: option?.label })
}
/>
);
if (field.name === 'conversionUserId')
return (
<USelect
showSearch
loading={stationedStaff.isFetching}
options={rowsOf(stationedStaff.data).map((item) => ({
value: String(item.staffUuid),
label: `${text(item.staffName)}(${text(item.yqMerchantName)})`,
}))}
onChange={(value, option) => {
const staff = rowsOf(stationedStaff.data).find(
(item) => String(item.staffUuid) === String(value),
);
form.setFieldsValue({
conversionUserId: value,
conversionName: option?.label,
conversionMerchantId: staff?.yqMerchantId,
conversionMerchantName: staff?.yqMerchantName,
});
}}
/>
);
return undefined;
};
if (!allowed)
return (
<UResult status="403" title="无编辑车况信息的权限" subTitle="请联系管理员开通编辑权限。" />
);
if (!record)
return <UResult status="404" title="未找到车况信息" subTitle="详情地址缺少车况单编号。" />;
return (
<PageShell>
<div className="uc-condition-detail">
<header className="uc-condition-detail__header">
<div>
<div className="uc-condition-detail__header-left">
<h1 className="uc-condition-detail__title">车况信息详情</h1>
<span className="uc-condition-source">
来源:
{SOURCE_LABEL[String(data?.source ?? '')] ?? text(data?.sourceName ?? data?.source)}
</span>
</div>
{data?.carConditionCode && (
<div className="uc-condition-detail__meta">
编号:{text(data?.carConditionCode)}
</div>
)}
</div>
<div>
<UButton type="default" onClick={() => goTo('condition')}>
返回列表
</UButton>
<UButton
type="primary"
disabled={Number(data?.status) === 1}
loading={creatingAssessment}
onClick={() => void createAssessment()}
>
一键生成评估单
</UButton>
</div>
</header>
{detail.isError ? (
<UAlert
type="error"
showIcon
title="车况详情加载失败"
description={errorDetail(detail.error)}
/>
) : null}
<div className="uc-condition-detail__body">
<aside className="uc-condition-detail__left">
<section className="uc-condition-detail__block">
<h2 className="uc-condition-detail__block-title">一线回传车况描述</h2>
<div className="uc-condition-detail__description">
{text(data?.conditionDescription)}
</div>
</section>
<section className="uc-condition-detail__block">
<h2 className="uc-condition-detail__block-title">一线回传照片</h2>
<div className="uc-condition-detail__photos">
{photos.length
? photos.map((photo) => (
<figure className="uc-condition-detail__photo" key={photo.url}>
{photo.video ? (
<button
type="button"
className="uc-condition-detail__video-button"
onClick={() => setVideoUrl(photo.url)}
>
<video className="uc-condition-detail__video" muted src={photo.url} />
<span>播放视频</span>
</button>
) : (
<UImage
src={photo.url}
width="100%"
height={110}
styles={{
image: { width: '100%', height: '110px', objectFit: 'cover' },
}}
/>
)}
<figcaption>{photo.caption}</figcaption>
</figure>
))
: '暂无照片'}
</div>
</section>
</aside>
<main className="uc-condition-detail__right">
<section>
<div className="uc-condition-detail__section-head">
<div>
<h2 className="uc-condition-detail__section-title uc-inline">完善评估单基础信息</h2>
<UButton className="uc-inline" type="link" loading={updatingBase} onClick={() => void updateBase()}>
更新
</UButton>
</div>
<span>
<UButton type="link" onClick={() => setBaseOpen((open) => !open)}>
{baseOpen ? '收起' : '展开'}
</UButton>
</span>
</div>
{baseOpen ? (
<>
<div className="uc-condition-detail__model-reference">
车型参考:{text(data?.brandModel)}
</div>
<CombiForm
mode="form"
form={form}
fields={BASE_FIELDS}
layout="horizontal"
labelWidth={150}
sectionContentStyle={{
display: 'grid',
gridTemplateColumns: 'repeat(2, minmax(0, 1fr))',
columnGap: 24,
}}
renderControl={renderBaseControl}
/>
</>
) : null}
</section>
<section>
<h2 className="uc-condition-detail__section-title">
补充核心压价策略(终极融合引擎)
</h2>
<CombiForm
mode="form"
form={form}
fields={PRICE_FIELDS}
layout="horizontal"
labelWidth={150}
sectionContentStyle={{
display: 'grid',
gridTemplateColumns: 'repeat(2, minmax(0, 1fr))',
columnGap: 24,
}}
/>
<div className="uc-condition-detail__third">
<UCheckbox
checked={thirdReport}
onChange={(event) => {
if (thirdReportPresent !== true) {
message.warning('未查询到事故报告,请先查询事故报告。');
setThirdReport(false);
return;
}
setThirdReport(event.target.checked);
}}
>
附加条件:融合高阶第三方出险报告
</UCheckbox>
<UButton
type="link"
loading={checkingThirdReport}
onClick={() => void checkThirdPartyReport()}
>
查询事故报告
</UButton>
<div>
勾选后,系统会校验车架号历史报告,并将严重碰撞和维保记录合并到 AI 收车报告中。
</div>
{thirdReportPresent === false ? (
<div className="uc-condition-detail__third-warning">
未查询到事故报告,请先使用“查询事故报告”。
</div>
) : null}
{thirdReportPresent === true && thirdReport ? (
<div className="uc-condition-detail__third-success">
校验通过:已匹配到历史理赔记录,将随表单合并生成。
</div>
) : null}
</div>
</section>
<footer className="uc-condition-detail__footer">
<UButton
type="primary"
loading={creatingReport}
onClick={() => void createAiReport()}
>
生成AI收车报告
</UButton>
</footer>
</main>
</div>
</div>
<UModal
open={Boolean(videoUrl)}
title="视频播放"
footer={null}
onCancel={() => setVideoUrl('')}
>
{videoUrl ? (
<video className="uc-condition-detail__video-preview" controls autoPlay src={videoUrl} />
) : null}
</UModal>
</PageShell>
);
}
apps/web/subapps/usedcar/src/pages/Condition/condition.css
0 → 100644
View file @
9af59b7
.uc-condition-status
{
display
:
inline-flex
;
align-items
:
center
;
gap
:
8px
;
color
:
var
(
--uj-text-2
);
}
.uc-inline
{
display
:
inline-block
;
}
.uc-condition-status
::before
{
content
:
''
;
width
:
6px
;
height
:
6px
;
border-radius
:
50%
;
background
:
var
(
--uj-text-4
);
}
.uc-condition-status--success
::before
{
background
:
var
(
--uj-primary
);
}
.uc-condition-status--pending
::before
{
background
:
var
(
--uj-text-4
);
}
.uc-condition-status--progress
::before
{
background
:
var
(
--uj-warning
);
}
.uc-condition-status--failed
::before
{
background
:
var
(
--uj-error
);
}
.uc-condition-drawer
.ant-drawer-body
{
padding
:
0
;
background
:
var
(
--uj-bg
);
}
.uc-condition-detail
{
min-height
:
100%
;
}
.uc-condition-detail__header
{
display
:
flex
;
justify-content
:
space-between
;
gap
:
16px
;
padding
:
16px
20px
;
background
:
var
(
--uj-surface
);
border-bottom
:
1px
solid
var
(
--uj-border
);
}
.uc-condition-detail__header-left
{
display
:
flex
;
align-items
:
center
;
flex-wrap
:
wrap
;
gap
:
10px
12px
;
}
.uc-condition-detail__title
{
margin
:
0
;
color
:
var
(
--uj-text-1
);
font-size
:
20px
;
}
.uc-condition-source
{
display
:
inline-flex
;
align-items
:
center
;
height
:
24px
;
padding
:
0
10px
;
font-size
:
12px
;
font-weight
:
normal
;
color
:
#5584f2
;
background
:
#ecf5ff
;
border
:
1px
solid
#d9ecff
;
border-radius
:
4px
;
line-height
:
1
;
white-space
:
nowrap
;
}
.uc-condition-detail__meta
{
margin-top
:
8px
;
color
:
var
(
--uj-text-3
);
}
.uc-condition-detail__body
{
display
:
grid
;
grid-template-columns
:
minmax
(
280px
,
32%
)
minmax
(
0
,
1
fr
);
align-items
:
start
;
background
:
var
(
--uj-surface
);
}
.uc-condition-detail__left
{
padding
:
16px
;
border-right
:
1px
solid
var
(
--uj-border
);
}
.uc-condition-detail__right
{
min-width
:
0
;
}
.uc-condition-detail__block
{
margin-bottom
:
20px
;
}
.uc-condition-detail__block-title
,
.uc-condition-detail__section-title
{
margin
:
0
0
12px
;
color
:
var
(
--uj-text-1
);
font-size
:
16px
;
font-weight
:
600
;
}
.uc-condition-detail__section-head
{
display
:
flex
;
align-items
:
center
;
justify-content
:
space-between
;
gap
:
12px
;
}
.uc-condition-detail__section-head
.uc-condition-detail__section-title
{
margin-bottom
:
12px
;
}
.uc-condition-detail__model-reference
{
margin
:
0
0
12px
;
padding
:
10px
14px
;
color
:
var
(
--uj-warning
);
background
:
var
(
--uj-warning-soft
);
border
:
1px
solid
var
(
--uj-warning-border
);
border-radius
:
4px
;
}
.uc-condition-detail__description
{
white-space
:
pre-wrap
;
line-height
:
1.6
;
color
:
var
(
--uj-text-2
);
}
.uc-condition-detail__photos
{
display
:
grid
;
grid-template-columns
:
repeat
(
2
,
minmax
(
0
,
1
fr
));
gap
:
16px
;
}
.uc-condition-detail__photo
{
margin
:
0
;
min-width
:
0
;
overflow
:
hidden
;
}
.uc-condition-detail__photo
.ant-image
{
display
:
block
;
width
:
100%
;
height
:
110px
;
overflow
:
hidden
;
border
:
1px
solid
var
(
--uj-border
);
border-radius
:
6px
;
background
:
var
(
--uj-bg
);
}
.uc-condition-detail__photo
.ant-image
img
,
.uc-condition-detail__video
{
width
:
100%
;
height
:
110px
;
object-fit
:
cover
;
}
.uc-condition-detail__photo
figcaption
{
margin-top
:
6px
;
color
:
var
(
--uj-text-3
);
font-size
:
12px
;
}
.uc-condition-detail__video-button
{
position
:
relative
;
width
:
100%
;
padding
:
0
;
border
:
0
;
background
:
transparent
;
cursor
:
pointer
;
}
.uc-condition-detail__video-button
span
{
position
:
absolute
;
inset
:
0
;
display
:
grid
;
place-items
:
center
;
color
:
var
(
--uj-on-primary
);
background
:
color-mix
(
in
srgb
,
var
(
--uj-brand-1
)
45%
,
transparent
);
}
.uc-condition-detail__video-preview
{
display
:
block
;
width
:
100%
;
max-height
:
70vh
;
background
:
var
(
--uj-brand-1
);
}
.uc-condition-detail__right
section
{
padding
:
16px
20px
;
border-bottom
:
6px
solid
var
(
--uj-bg
);
}
.uc-condition-detail__form
{
display
:
grid
;
grid-template-columns
:
repeat
(
2
,
minmax
(
0
,
1
fr
));
gap
:
0
24px
;
}
.uc-condition-detail__compound
{
display
:
grid
;
grid-template-columns
:
repeat
(
2
,
minmax
(
0
,
1
fr
));
gap
:
8px
;
width
:
100%
;
}
.uc-condition-detail__third
{
padding
:
14px
16px
;
color
:
var
(
--uj-text-2
);
background
:
var
(
--uj-primary-soft
);
border-radius
:
6px
;
}
.uc-condition-detail__third-warning
{
margin-top
:
8px
;
color
:
var
(
--uj-warning
);
}
.uc-condition-detail__third-success
{
margin-top
:
8px
;
color
:
var
(
--uj-success
);
}
.uc-condition-detail__footer
{
display
:
flex
;
justify-content
:
center
;
padding
:
24px
;
background
:
var
(
--uj-surface
);
}
@media
(
max-width
:
900px
)
{
.uc-condition-detail__body
{
grid-template-columns
:
1
fr
;
}
.uc-condition-detail__left
{
border-right
:
0
;
border-bottom
:
1px
solid
var
(
--uj-border
);
}
.uc-condition-detail__form
{
grid-template-columns
:
1
fr
;
}
}
apps/web/subapps/usedcar/src/pages/Condition/conditionConfig.ts
0 → 100644
View file @
9af59b7
import
type
{
FieldOption
,
FieldSchema
}
from
'@/components'
;
export
type
ConditionValues
=
Record
<
string
,
unknown
>
;
export
const
CONDITION_STATUS
:
FieldOption
[]
=
[
{
value
:
0
,
label
:
'待处理'
},
{
value
:
1
,
label
:
'已生成评估单'
},
];
export
const
AI_REPORT_STATUS
:
FieldOption
[]
=
[
{
value
:
0
,
label
:
'未生成'
},
{
value
:
1
,
label
:
'生成中'
},
{
value
:
2
,
label
:
'已生成'
},
{
value
:
3
,
label
:
'生成失败'
},
];
export
const
YES_NO
:
FieldOption
[]
=
[
{
value
:
0
,
label
:
'否'
},
{
value
:
1
,
label
:
'是'
},
];
const
COLORS
:
FieldOption
[]
=
[
'黑色'
,
'白色'
,
'银色'
,
'灰色'
,
'红色'
,
'蓝色'
,
'绿色'
,
'棕色'
,
'金色'
,
'橙色'
,
'紫色'
,
'黄色'
,
'香槟色'
,
'其他'
,
].
map
((
label
,
index
)
=>
({
label
,
value
:
String
(
index
+
1
)
}));
export
const
colorLabel
=
(
value
:
unknown
)
=>
COLORS
.
find
((
item
)
=>
String
(
item
.
value
)
===
String
(
value
))?.
label
;
const
required
=
(
label
:
string
)
=>
[{
required
:
true
,
message
:
`请选择
${
label
}
`
}];
const
requiredInput
=
(
label
:
string
)
=>
[
{
required
:
true
,
whitespace
:
true
,
message
:
`请填写
${
label
}
`
},
];
export
const
BASE_FIELDS
:
FieldSchema
<
ConditionValues
>
[]
=
[
{
name
:
'licensePlate'
,
label
:
'车牌号'
,
type
:
'input'
,
rules
:
requiredInput
(
'车牌号'
),
inputProps
:
{
maxLength
:
10
},
},
{
name
:
'registrationDate'
,
label
:
'上牌时间'
,
type
:
'date'
,
rules
:
required
(
'上牌时间'
)
},
{
name
:
'brandModel'
,
label
:
'车型'
,
type
:
'input'
,
rules
:
requiredInput
(
'车型'
),
inputProps
:
{
maxLength
:
100
},
},
{
name
:
'vin'
,
label
:
'车架号'
,
type
:
'input'
,
rules
:
[
{
required
:
true
,
pattern
:
/^
[
A-HJ-NPR-Z0-9
]{17}
$/i
,
message
:
'请输入 17 位有效车架号'
},
],
inputProps
:
{
maxLength
:
17
},
normalize
:
(
value
)
=>
String
(
value
??
''
)
.
toUpperCase
()
.
replace
(
/
[^
A-HJ-NPR-Z0-9
]
/g
,
''
)
.
slice
(
0
,
17
),
},
{
name
:
'engineNumber'
,
label
:
'发动机号'
,
type
:
'input'
,
inputProps
:
{
maxLength
:
20
}
},
{
name
:
'registrationCityName'
,
label
:
'上牌城市'
,
type
:
'input'
,
rules
:
requiredInput
(
'上牌城市'
),
inputProps
:
{
maxLength
:
100
},
},
{
name
:
'carCityName'
,
label
:
'车辆所在地'
,
type
:
'input'
,
rules
:
requiredInput
(
'车辆所在地'
),
inputProps
:
{
maxLength
:
100
},
},
{
name
:
'displayMileage'
,
label
:
'表显里程'
,
type
:
'input'
,
rules
:
[{
required
:
true
,
pattern
:
/^
\d{1,6}
$/
,
message
:
'表显里程须为不超过 6 位的数字'
}],
inputProps
:
{
maxLength
:
6
},
},
{
name
:
'vehicleCategory'
,
label
:
'车辆类别'
,
type
:
'select'
,
options
:
[
{
value
:
1
,
label
:
'置换车'
},
{
value
:
2
,
label
:
'报废车'
},
],
rules
:
required
(
'车辆类别'
),
},
{
name
:
'emissionStandard'
,
label
:
'排放标准'
,
type
:
'select'
,
options
:
[
3
,
4
,
5
,
6
].
map
((
value
)
=>
({
value
,
label
:
`国
${
value
}
`
})),
rules
:
required
(
'排放标准'
),
},
{
name
:
'productionDate'
,
label
:
'生产日期'
,
type
:
'date'
,
rules
:
required
(
'生产日期'
)
},
{
name
:
'guidePrice'
,
label
:
'指导价(元)'
,
type
:
'input'
,
rules
:
[{
required
:
true
,
pattern
:
/^
\d
+
(\.\d{1,2})?
$/
,
message
:
'请输入有效指导价'
}],
inputProps
:
{
maxLength
:
10
},
},
{
name
:
'sunroof'
,
label
:
'天窗'
,
type
:
'select'
,
options
:
[
{
value
:
1
,
label
:
'无天窗'
},
{
value
:
2
,
label
:
'普通天窗'
},
{
value
:
3
,
label
:
'全景天窗'
},
],
rules
:
required
(
'天窗'
),
},
{
name
:
'interiorColor'
,
label
:
'内饰颜色'
,
type
:
'select'
,
options
:
COLORS
,
rules
:
required
(
'内饰颜色'
),
},
{
name
:
'exteriorColor'
,
label
:
'外观颜色'
,
type
:
'select'
,
options
:
COLORS
,
rules
:
required
(
'外观颜色'
),
},
{
name
:
'sellerMerchantName'
,
label
:
'门店'
,
type
:
'input'
,
disabled
:
true
},
{
name
:
'sellerName'
,
label
:
'销售顾问'
,
type
:
'input'
,
inputProps
:
{
maxLength
:
50
}
},
{
name
:
'conversionName'
,
label
:
'驻店人员'
,
type
:
'input'
,
inputProps
:
{
maxLength
:
50
}
},
{
name
:
'ownerName'
,
label
:
'原车主名称'
,
type
:
'input'
,
rules
:
requiredInput
(
'原车主名称'
),
inputProps
:
{
maxLength
:
50
},
},
{
name
:
'previousOwnerPhone'
,
label
:
'原车主电话'
,
type
:
'input'
,
rules
:
[{
pattern
:
/^$|^
\d{11}
$/
,
message
:
'请输入 11 位手机号'
}],
inputProps
:
{
maxLength
:
11
},
normalize
:
(
value
)
=>
String
(
value
??
''
)
.
replace
(
/
\D
/g
,
''
)
.
slice
(
0
,
11
),
},
{
name
:
'previousOwnerAddress'
,
label
:
'原车主住址'
,
type
:
'textarea'
,
itemStyle
:
{
gridColumn
:
'span 2'
},
textareaProps
:
{
maxLength
:
200
,
rows
:
2
,
showCount
:
true
},
},
{
name
:
'keyCount'
,
label
:
'钥匙数量'
,
type
:
'input'
,
rules
:
[{
required
:
true
,
pattern
:
/^
\d
$/
,
message
:
'钥匙数量须为 0~9 的整数'
}],
inputProps
:
{
maxLength
:
1
},
},
{
name
:
'transferCount'
,
label
:
'过户次数'
,
type
:
'input'
,
rules
:
[{
required
:
true
,
pattern
:
/^
\d
$/
,
message
:
'过户次数须为 0~9 的整数'
}],
inputProps
:
{
maxLength
:
1
},
},
{
name
:
'compulsoryInsuranceExpiry'
,
label
:
'交强险到期'
,
type
:
'date'
},
{
name
:
'annualInspectionExpiry'
,
label
:
'年审到期日'
,
type
:
'date'
},
{
name
:
'commercialInsuranceExpiry'
,
label
:
'商业险到期'
,
type
:
'date'
},
{
name
:
'usageType'
,
label
:
'使用性质'
,
type
:
'select'
,
options
:
[
{
value
:
1
,
label
:
'非营运'
},
{
value
:
2
,
label
:
'营运'
},
{
value
:
3
,
label
:
'营转非'
},
],
rules
:
required
(
'使用性质'
),
},
{
name
:
'ownerType'
,
label
:
'所有人性质'
,
type
:
'select'
,
options
:
[
{
value
:
1
,
label
:
'个人'
},
{
value
:
2
,
label
:
'单位'
},
],
rules
:
required
(
'所有人性质'
),
},
{
name
:
'overallRating'
,
label
:
'综合评价'
,
type
:
'select'
,
options
:
[
'优'
,
'良'
,
'中'
,
'差'
].
map
((
label
,
index
)
=>
({
value
:
index
+
1
,
label
})),
rules
:
required
(
'综合评价'
),
},
{
name
:
'hasAccident'
,
label
:
'是否事故车'
,
type
:
'select'
,
options
:
YES_NO
,
rules
:
required
(
'是否事故车'
),
},
{
name
:
'buyNewCar'
,
label
:
'是否购买新车'
,
type
:
'select'
,
options
:
YES_NO
,
rules
:
required
(
'是否购买新车'
),
},
{
name
:
'conditionDescription'
,
label
:
'车况描述'
,
type
:
'textarea'
,
itemStyle
:
{
gridColumn
:
'span 2'
},
textareaProps
:
{
maxLength
:
200
,
rows
:
3
,
showCount
:
true
},
},
];
export
const
PRICE_FIELDS
:
FieldSchema
<
ConditionValues
>
[]
=
[
{
name
:
'targetPrice'
,
label
:
'目标收车价(元)'
,
type
:
'input'
,
rules
:
[{
required
:
true
,
pattern
:
/^
\d{1,9}
$/
,
message
:
'请输入不超过 9 位的正整数'
}],
},
{
name
:
'maxReservedPrice'
,
label
:
'最高保留价(元)'
,
type
:
'input'
,
rules
:
[{
required
:
true
,
pattern
:
/^
\d{1,9}
$/
,
message
:
'请输入不超过 9 位的正整数'
}],
},
{
name
:
'newCarPriceDrop'
,
label
:
'是否新车降价'
,
type
:
'select'
,
options
:
YES_NO
,
rules
:
required
(
'是否新车降价'
),
},
{
name
:
'interiorCondition'
,
label
:
'车辆内饰'
,
type
:
'select'
,
options
:
[
{
value
:
1
,
label
:
'新'
},
{
value
:
0
,
label
:
'旧'
},
],
rules
:
required
(
'车辆内饰'
),
},
{
name
:
'mileageKm'
,
label
:
'车辆公里数'
,
type
:
'input'
,
rules
:
[{
required
:
true
,
pattern
:
/^
\d{1,9}
$/
,
message
:
'请输入有效车辆公里数'
}],
},
{
name
:
'reportConditionDescription'
,
label
:
'车况描述(瑕疵/维保详述)'
,
type
:
'textarea'
,
itemStyle
:
{
gridColumn
:
'span 2'
},
rules
:
requiredInput
(
'车况描述'
),
textareaProps
:
{
maxLength
:
500
,
rows
:
4
,
showCount
:
true
},
},
{
name
:
'frameStructure'
,
label
:
'骨架与结构(一票否决)'
,
type
:
'textarea'
,
itemStyle
:
{
gridColumn
:
'span 2'
},
rules
:
requiredInput
(
'骨架与结构'
),
textareaProps
:
{
maxLength
:
100
,
rows
:
3
,
showCount
:
true
},
},
{
name
:
'historyStatus'
,
label
:
'历史与状态(隐形风险)'
,
type
:
'textarea'
,
itemStyle
:
{
gridColumn
:
'span 2'
},
rules
:
requiredInput
(
'历史与状态'
),
textareaProps
:
{
maxLength
:
100
,
rows
:
3
,
showCount
:
true
},
},
{
name
:
'prepCost'
,
label
:
'整备成本预估(元)'
,
type
:
'input'
,
inputProps
:
{
maxLength
:
9
}
},
{
name
:
'marketRisk'
,
label
:
'市场与行情风险'
,
type
:
'input'
,
inputProps
:
{
maxLength
:
100
}
},
];
export
const
labelOf
=
(
options
:
FieldOption
[],
value
:
unknown
)
=>
options
.
find
((
item
)
=>
String
(
item
.
value
)
===
String
(
value
))?.
label
??
'-'
;
apps/web/subapps/usedcar/src/pages/Condition/index.tsx
View file @
9af59b7
import { RoutePlaceholder } from '@/features/shared/RoutePlaceholder';
import { useMemo, useState } from 'react';
import { useQuery } from '@tanstack/react-query';
import { UAlert, UButton, UCard, UResult, useUMessage } from '@uj/ui';
import {
DataTable,
PageShell,
SearchForm,
type FieldOption,
type FieldSchema,
type RowActionSchema,
} from '@/components';
import { carConditionApi } from '@/api';
import { useAccess } from '@/access';
import { UC } from '@/permissions/codes';
import { loadUsedcarRemoteConfig } from '../../api/core/config-center';
import { errorDetail } from '@/utils/error';
import { goTo } from '../Leads/navigate';
import { AI_REPORT_STATUS, CONDITION_STATUS, labelOf } from './conditionConfig';
import './condition.css';
type Filters = Record<string, unknown> & {
ownerName?: string;
licensePlate?: string;
sellerMerchantId?: string | number;
status?: string | number;
aiReportStatus?: string | number;
};
type Row = Record<string, unknown> & {
id: string | number;
status?: string | number;
aiReportStatus?: string | number;
carConditionCode?: string;
};
type PageResult = { records: Row[]; total: number };
const text = (value: unknown) =>
value === undefined || value === null || value === '' ? '-' : String(value);
const statusTone = (value: unknown, success: string, failed?: string) => {
if (String(value) === success) return 'success';
if (failed !== undefined && String(value) === failed) return 'failed';
if (String(value) === '0') return 'pending';
return 'progress';
};
/** menu_code 1002610 · 车况信息 · usedcar:condition:view */
export default function Condition() {
export default function Condition() {
return <RoutePlaceholder title="车况信息" route="/usedcar/condition" />;
const { canPoint } = useAccess();
const message = useUMessage();
const [filters, setFilters] = useState<Filters>({});
const [page, setPage] = useState({ current: 1, size: 10 });
const merchants = useQuery({
queryKey: ['usedcar-condition-merchants'],
queryFn: () =>
carConditionApi.getCarConditionMerchantPageList<{ records: Array<Record<string, unknown>> }>({
currentPage: 1,
pageSize: 9_999_999,
t: {},
}),
enabled: canPoint(UC.CONDITION_VIEW),
});
const merchantOptions = useMemo<FieldOption[]>(() => {
const used = new Set<string>();
return (merchants.data?.records ?? []).flatMap((item) => {
const value = item.sellerMerchantId;
const key = String(value ?? '');
if (value === undefined || value === null || value === '' || used.has(key)) return [];
used.add(key);
return [{ value: value as string | number, label: text(item.sellerMerchantName) }];
});
}, [merchants.data]);
const list = useQuery({
queryKey: ['usedcar-condition-list', filters, page],
queryFn: () =>
carConditionApi.getVehicleConditionInfoPage<PageResult>({
currentPage: page.current,
pageSize: page.size,
t: filters,
}),
enabled: canPoint(UC.CONDITION_VIEW),
});
const fields: FieldSchema<Filters>[] = [
{
name: 'ownerName',
label: '车主姓名',
type: 'input',
essential: true,
inputProps: { maxLength: 50 },
},
{
name: 'licensePlate',
label: '车牌号',
type: 'input',
essential: true,
inputProps: { maxLength: 50 },
},
{
name: 'sellerMerchantId',
label: '所属门店',
type: 'select',
essential: true,
options: merchantOptions,
selectProps: { loading: merchants.isFetching, showSearch: true, optionFilterProp: 'label' },
},
{ name: 'status', label: '车况单状态', type: 'select', options: CONDITION_STATUS },
{ name: 'aiReportStatus', label: '收车报告状态', type: 'select', options: AI_REPORT_STATUS },
];
const columns = [
{ title: '车主姓名', dataIndex: 'ownerName', width: 120, line: 1, render: text },
{ title: '车牌号', dataIndex: 'licensePlate', width: 120, line: 1, render: text },
{ title: '车型', dataIndex: 'brandModel', width: 180, line: 1, render: text },
{ title: '所属门店', dataIndex: 'sellerMerchantName', width: 140, line: 1, render: text },
{ title: '销售顾问', dataIndex: 'sellerName', width: 120, line: 1, render: text },
{
title: '车况单状态',
dataIndex: 'status',
width: 130,
render: (value: unknown) => (
<span className={`uc-condition-status uc-condition-status--${statusTone(value, '1')}`}>
{labelOf(CONDITION_STATUS, value)}
</span>
),
},
{
title: '收车报告状态',
dataIndex: 'aiReportStatus',
width: 130,
render: (value: unknown) => (
<span className={`uc-condition-status uc-condition-status--${statusTone(value, '2', '3')}`}>
{labelOf(AI_REPORT_STATUS, value)}
</span>
),
},
{ title: '提交时间', dataIndex: 'entryTime', width: 170, line: 1, render: text },
{ title: '创建人', dataIndex: 'createdBy', width: 120, line: 1, render: text },
];
const openAiReport = async (row: Row) => {
try {
const config = await loadUsedcarRemoteConfig();
const baseUrl = String(config.aiPurchase ?? '').trim();
if (!baseUrl) {
message.warning('未配置 AI 收车报告地址');
return;
}
const join = baseUrl.includes('?') ? '&' : '?';
window.open(
`${baseUrl}${join}source=1&carConditionCode=${encodeURIComponent(String(row.carConditionCode ?? ''))}`,
'_blank',
'noopener,noreferrer',
);
} catch (error) {
message.error(errorDetail(error));
}
};
const rowActions: RowActionSchema<Row>[] = [
{ label: '详情', permission: UC.CONDITION_EDIT, onClick: (row) => goTo(`condition/${row.id}`) },
{
label: 'AI收车报告',
permission: UC.CONDITION_AI_REPORT,
visible: (row) => Number(row.aiReportStatus) === 2,
onClick: (row) => void openAiReport(row),
},
];
if (!canPoint(UC.CONDITION_VIEW))
return (
<UResult status="403" title="无访问车况信息的权限" subTitle="请联系管理员开通访问权限。" />
);
return (
<PageShell fill title="车况信息">
<UCard className="uj-filter-card" size="small">
<SearchForm
fields={fields}
onSearch={(values) => {
setFilters(values);
setPage((current) => ({ ...current, current: 1 }));
}}
onReset={() => {
setFilters({});
setPage((current) => ({ ...current, current: 1 }));
}}
/>
</UCard>
{list.isError ? (
<UAlert
type="error"
showIcon
title="车况信息加载失败"
description={errorDetail(list.error)}
action={
<UButton type="link" onClick={() => void list.refetch()}>
重试
</UButton>
}
/>
) : null}
<UCard size="small" fill>
<DataTable<Row>
rowKey="id"
fillHeight
columns={columns}
dataSource={list.data?.records ?? []}
loading={list.isPending || list.isFetching}
rowActions={rowActions}
pagination={{
current: page.current,
pageSize: page.size,
total: list.data?.total ?? 0,
onChange: (current, size) => setPage({ 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