Commit cc04d92f by chenwq

优化评估单详情页面,重构数据展示逻辑,新增动态事件配置

1 parent 5710314b
......@@ -6,18 +6,11 @@ import { assessmentApi, type AssessmentDetail as Detail } from '@/api';
import { UC } from '@/permissions/codes';
import type { PageParams } from '@/routes';
import { goTo } from '../Leads/navigate';
import { PRICE_DETAIL_FIELDS, readOnlyValues, VEHICLE_DETAIL_FIELDS } from './detailConfig';
import { DYNAMIC_EVENT_CONFIG, PRICE_DETAIL_FIELDS, readOnlyValues, VEHICLE_ASSET_GROUPS, VEHICLE_DETAIL_FIELDS } from './detailConfig';
import './assessment.css';
const display = (value: unknown) =>
value === undefined || value === null || value === '' ? '-' : String(value);
const operationName: Record<string, string> = {
'10': '总部定价师估价',
'20': '驻店人员报价反馈',
'30': '驻店人员驳回',
'40': '总部核价',
'50': '总部核价驳回',
};
function files(value: unknown) {
return Array.isArray(value) ? value : [];
}
......@@ -69,15 +62,10 @@ export default function AssessmentDetail({ params }: { params: PageParams }) {
<UCard>
<h3>车辆资料</h3>
<div className="uc-assess-files">
{[
['车辆图片', files(data.carImageUrls)],
['证件资料', files(data.documentUrls)],
['车辆视频', files(data.carVideoUrls)],
['检测报告', files(data.carCheckReportUrls)],
['其他图片', files(data.otherImageUrls)],
].map(([label, urls]) => (
<span key={String(label)}>
{String(label)}:
{VEHICLE_ASSET_GROUPS.map((group) => {
const urls = files(data[group.key]);
return <span key={group.key}>
{group.label}:
{Array.isArray(urls) && urls.length
? urls.map((url, index) => (
<a key={String(url)} href={String(url)} target="_blank" rel="noreferrer">
......@@ -85,8 +73,8 @@ export default function AssessmentDetail({ params }: { params: PageParams }) {
</a>
))
: '-'}
</span>
))}
</span>;
})}
</div>
</UCard>
<PriceCard title="总部定价师估价与意见" data={pricing} fallback={data} />
......@@ -97,29 +85,21 @@ export default function AssessmentDetail({ params }: { params: PageParams }) {
<UAlert type="error" showIcon title="评估动态加载失败" />
) : history.data?.length ? (
<div className="uc-assess-history">
{history.data.map((item, index) => (
<div
{history.data.map((item, index) => {
const config = DYNAMIC_EVENT_CONFIG[String(item.opType)];
return <div
className="uc-assess-history__item"
key={`${String(item.quoteTime ?? '')}-${index}`}
>
<div className="uc-assess-history__head">
<b>
{operationName[String(item.opType)] ?? '评估动态'}:{display(item.createdBy)}
{config?.title ?? '评估动态'}:{display(item.createdBy)}
</b>
<span>{display(item.quoteTime)}</span>
</div>
{item.evalPrice !== undefined ? <p>价格:{display(item.evalPrice)} 元</p> : null}
{item.evalOpinion ? <p>意见:{display(item.evalOpinion)}</p> : null}
{item.rejectReason ? <p>驳回原因:{display(item.rejectReason)}</p> : null}
{item.rejectSuggestion ? <p>驳回意见:{display(item.rejectSuggestion)}</p> : null}
{item.customerTargetPrice ? (
<p>意向报价:{display(item.customerTargetPrice)} 元</p>
) : null}
{item.customerTargetPriceFeedback ? (
<p>报价反馈:{display(item.customerTargetPriceFeedback)}</p>
) : null}
</div>
))}
{config?.fields.map((field) => <p key={field.key}>{field.label}:{display(item[field.key])}{field.suffix ? ` ${field.suffix}` : ''}</p>)}
</div>;
})}
</div>
) : (
<UEmpty description="暂无评估动态" />
......
......@@ -12,9 +12,17 @@ const empty = (value: unknown): string =>
export const VEHICLE_DETAIL_FIELDS: ReadOnlyField<AssessmentDetail>[] = [
{ label: '车牌号', value: (data) => data.licensePlate },
{ label: '车架号', value: (data) => data.vin },
{ label: '车型', value: (data) => [data.carBrand, data.carSeriesName, data.carTypeName].filter(Boolean).join(' ') },
{
label: '车型',
value: (data) =>
[data.carBrand, data.carSeriesName, data.carTypeName].filter(Boolean).join(' '),
},
{ label: '上牌时间', value: (data) => data.registrationDate },
{ label: '上牌城市', value: (data) => [data.registrationProvinceName, data.registrationCityName].filter(Boolean).join('') },
{
label: '上牌城市',
value: (data) =>
[data.registrationProvinceName, data.registrationCityName].filter(Boolean).join(''),
},
{ label: '表显里程', value: (data) => data.mileageStr },
{ label: '门店', value: (data) => data.sellerMerchantName },
{ label: '销售顾问', value: (data) => data.sellerName },
......@@ -24,16 +32,82 @@ export const VEHICLE_DETAIL_FIELDS: ReadOnlyField<AssessmentDetail>[] = [
{ label: '车主联系方式', value: (data) => data.previousOwnerPhone },
{ label: '评估单下单时间', value: (data) => data.evalOrderTime },
{ label: '评估单编号', value: (data) => data.evalOrderNo },
{ label: '综合评价', value: (data) => ({ 1: '优', 2: '良', 3: '中', 4: '差' } as Record<number, string>)[Number(data.overallRating)] },
{
label: '综合评价',
value: (data) =>
(({ 1: '优', 2: '良', 3: '中', 4: '差' }) as Record<number, string>)[
Number(data.overallRating)
],
},
{ label: '车况描述', wide: true, value: (data) => data.conditionDescription },
];
export const PRICE_DETAIL_FIELDS: ReadOnlyField<Record<string, unknown>>[] = [
{ label: '评估价', value: (data) => data.evalPrice === undefined ? '-' : `${String(data.evalPrice)} 元` },
{
label: '评估价',
value: (data) => (data.evalPrice === undefined ? '-' : `${String(data.evalPrice)} 元`),
},
{ label: '总部定价师', value: (data) => data.createdBy },
{ label: '评估意见', value: (data) => data.evalOpinion },
];
export function readOnlyValues<T>(fields: ReadOnlyField<T>[], data: T): Array<[string, string, boolean?]> {
/** 车辆资料按类别配置;新增资料只需补一项,无需调整页面结构。 */
export const VEHICLE_ASSET_GROUPS = [
{ label: '车辆图片', key: 'carImageUrls' },
{ label: '证件资料', key: 'documentUrls' },
{ label: '车辆视频', key: 'carVideoUrls' },
{ label: '检测报告', key: 'carCheckReportUrls' },
{ label: '其他图片', key: 'otherImageUrls' },
] as const;
interface DynamicField {
label: string;
key: string;
suffix?: string;
}
/** 评估动态由操作类型决定展示内容,页面只按该配置渲染。 */
export const DYNAMIC_EVENT_CONFIG: Record<string, { title: string; fields: DynamicField[] }> = {
'10': {
title: '总部定价师估价',
fields: [
{ label: '评估价', key: 'evalPrice', suffix: '元' },
{ label: '评估意见', key: 'evalOpinion' },
],
},
'20': {
title: '驻店人员报价反馈',
fields: [
{ label: '意向报价', key: 'customerTargetPrice', suffix: '元' },
{ label: '报价反馈', key: 'customerTargetPriceFeedback' },
],
},
'30': {
title: '驻店人员驳回',
fields: [
{ label: '驳回原因', key: 'rejectReason' },
{ label: '驳回意见', key: 'rejectSuggestion' },
],
},
'40': {
title: '总部核价',
fields: [
{ label: '核价价格', key: 'evalPrice', suffix: '元' },
{ label: '核价意见', key: 'evalOpinion' },
],
},
'50': {
title: '总部核价驳回',
fields: [
{ label: '驳回原因', key: 'rejectReason' },
{ label: '驳回意见', key: 'rejectSuggestion' },
],
},
};
export function readOnlyValues<T>(
fields: ReadOnlyField<T>[],
data: T,
): Array<[string, string, boolean?]> {
return fields.map((field) => [field.label, empty(field.value(data)), field.wide]);
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!