Commit 912f206a by chenwq1

fix: gengxin

1 parent 65f72a25
......@@ -56,8 +56,9 @@ export default class DetectionOrderEdit extends PaginationComponent<Vehicle> {
reportId: q.id,
});
this.getDetailData();
this.getTemplateData('1');
this.getDefaultTemplate();
this.getDefaultTemplate().finally(() => {
this.getTemplateData('1');
});
}
unmounted(): void {
......@@ -95,14 +96,18 @@ export default class DetectionOrderEdit extends PaginationComponent<Vehicle> {
getDefaultTemplate() {
const routeData = this.$route.query || {};
DetectionController.inspectionTemplateDefault(this.axios, { taskId: routeData.id }).then(response => {
return DetectionController.inspectionTemplateDefault(this.axios, { taskId: routeData.id }).then(response => {
this.defaultData = response?.data?.data || {};
this.getCarTypeList(this.defaultData.carSeriesId);
return this.getCarTypeList(this.defaultData.carSeriesId);
});
}
getCarTypeList(id) {
DetectionController.getCarTypeList(this.axios, { csId: id }).then(response => {
if (!id) {
this.carTypeList = [];
return Promise.resolve();
}
return DetectionController.getCarTypeList(this.axios, { csId: id }).then(response => {
const data = response?.data?.data || {};
this.carTypeList = (data.carinfos || []).map(item => ({ text: item.name || "", value: String(item.id) || "" }));
});
......@@ -145,6 +150,26 @@ export default class DetectionOrderEdit extends PaginationComponent<Vehicle> {
dropdown: 'valueKey',
radio_button_select: 'valueKey'
};
// 节点名称 -> /inspectionTemplate/default 字段,按包含关系匹配
const matchers: { match: (n: string) => boolean; key: string }[] = [
{ match: n => n === '品牌', key: 'carBrand' },
{ match: n => n === '车系', key: 'carSeriesName' },
{ match: n => n === '车型', key: 'carTypeId' },
{ match: n => /车源/.test(n), key: 'sourceNo' },
{ match: n => /VIN|车架号/i.test(n), key: 'vin' },
{ match: n => /车牌/.test(n), key: 'licensePlate' },
{ match: n => /注册|登记/.test(n), key: 'registrationDate' },
{ match: n => /出厂|生产/.test(n), key: 'productionDate' },
{ match: n => /年检/.test(n), key: 'annualInspectionExpiry' },
{ match: n => /交强险/.test(n), key: 'compulsoryInsuranceExpiry' },
{ match: n => /排量/.test(n), key: 'displacement' },
{ match: n => /排放/.test(n), key: 'emissionStandard' },
{ match: n => /发动机/.test(n), key: 'engineNumber' },
{ match: n => /颜色/.test(n), key: 'exteriorColor' },
{ match: n => /钥匙/.test(n), key: 'keyCount' },
{ match: n => /里程/.test(n), key: 'mileage' },
{ match: n => /使用性质|营运/.test(n), key: 'usageType' },
];
const defaultList = list.map(item => {
const inspectionValueList = item?.inspectionResultVO?.inspectionValueList || [];
let value = null;
......@@ -153,12 +178,26 @@ export default class DetectionOrderEdit extends PaginationComponent<Vehicle> {
if (key) value = inspectionValueList[0][key] || '';
}
if (item.nodeName == '品牌') {
value = this.defaultData.carBrand || '';
}
if (item.nodeName == '车系') {
value = this.defaultData.carSeriesName || '';
if (value == null || value === '') {
const hit = matchers.find(m => m.match(String(item.nodeName || '')));
if (hit) {
const dv = this.defaultData?.[hit.key];
if (dv != null && dv !== '') {
value = String(dv);
// 下拉/单选:default 返回的是名称,需要换成 options 里的 id
if (item.interactionType === 'dropdown' || item.interactionType === 'radio_button_select') {
const optionsList = item.nodeName === '车型'
? this.carTypeList
: JSON.parse(item.options || '[]').map((s: string) => {
const parts = (s || '').split('-');
return { text: parts[1] || '', value: parts[0] || '' };
});
const opt = optionsList.find((o: any) => String(o.value) === value)
|| optionsList.find((o: any) => String(o.text) === value);
value = opt ? String(opt.value) : '';
}
}
}
}
return { ...item, resultStatus: item?.inspectionResultVO?.resultStatus == 3 ? true : false, value };
});
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!