conditionConfig.ts
9.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
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}` },
];
/**
* 字段顺序即两列栅格的落位顺序:相邻两项语义成对(标识/地区/日期/价格/颜色/评价/人员/证件),
* 单格字段共 30 个恰好排满 15 行,不留半空行;跨两列的长文本统一收在末尾。
*/
export const BASE_FIELDS: FieldSchema<ConditionValues>[] = [
{
name: 'licensePlate',
label: '车牌号',
type: 'input',
rules: requiredInput('车牌号'),
inputProps: { maxLength: 10 },
},
{
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: 'brandModel',
label: '车型',
type: 'input',
rules: requiredInput('车型'),
inputProps: { maxLength: 100 },
},
{ 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: 'registrationDate', label: '上牌时间', type: 'date', rules: required('上牌时间') },
{ name: 'productionDate', label: '生产日期', type: 'date', rules: required('生产日期') },
{
name: 'displayMileage',
label: '表显里程',
type: 'input',
rules: [{ required: true, pattern: /^\d{1,6}$/, message: '表显里程须为不超过 6 位的数字' }],
inputProps: { maxLength: 6 },
},
{
name: 'guidePrice',
label: '指导价(元)',
type: 'input',
rules: [{ required: true, pattern: /^\d+(\.\d{1,2})?$/, message: '请输入有效指导价' }],
inputProps: { maxLength: 10 },
},
{
name: 'vehicleCategory',
label: '车辆类别',
type: 'select',
options: [
{ value: 1, label: '置换车' },
{ value: 2, label: '报废车' },
],
rules: required('车辆类别'),
},
{
name: 'usageType',
label: '使用性质',
type: 'select',
options: [
{ value: 1, label: '非营运' },
{ value: 2, label: '营运' },
{ value: 3, label: '营转非' },
],
rules: required('使用性质'),
},
{
name: 'emissionStandard',
label: '排放标准',
type: 'select',
options: [3, 4, 5, 6].map((value) => ({ value, label: `国${value}` })),
rules: required('排放标准'),
},
{
name: 'ownerType',
label: '所有人性质',
type: 'select',
options: [
{ value: 1, label: '个人' },
{ value: 2, label: '单位' },
],
rules: required('所有人性质'),
},
{
name: 'sunroof',
label: '天窗',
type: 'select',
options: [
{ value: 1, label: '无天窗' },
{ value: 2, label: '普通天窗' },
{ value: 3, label: '全景天窗' },
],
rules: required('天窗'),
},
{
name: 'overallRating',
label: '综合评价',
type: 'select',
options: ['优', '良', '中', '差'].map((label, index) => ({ value: index + 1, label })),
rules: required('综合评价'),
},
{
name: 'interiorColor',
label: '内饰颜色',
type: 'select',
options: COLORS,
rules: required('内饰颜色'),
},
{
name: 'exteriorColor',
label: '外观颜色',
type: 'select',
options: COLORS,
rules: required('外观颜色'),
},
{
name: 'hasAccident',
label: '是否事故车',
type: 'select',
options: YES_NO,
rules: required('是否事故车'),
},
{
name: 'buyNewCar',
label: '是否购买新车',
type: 'select',
options: YES_NO,
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: '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: 'previousOwnerAddress',
label: '原车主住址',
type: 'textarea',
itemStyle: { gridColumn: 'span 2' },
textareaProps: { maxLength: 200, rows: 2, showCount: true },
},
{
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: 'prepCost', label: '整备成本预估(元)', type: 'input', inputProps: { maxLength: 9 } },
{
name: 'marketRisk',
label: '市场与行情风险',
type: 'input',
itemStyle: { gridColumn: 'span 2' },
inputProps: { maxLength: 100 },
},
{
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 },
},
];
export const labelOf = (options: FieldOption[], value: unknown) =>
options.find((item) => String(item.value) === String(value))?.label ?? '-';
/** 状态点色调:列表与详情档案条共用同一套判定,避免两处各写一份漂移。 */
export 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';
};