|
|
|
@ -56,7 +56,8 @@ |
|
|
|
|
@click="mockFetchData">重新识别</el-button> |
|
|
|
|
<EquipmentRegistrationForm ref="ERF" v-else :initialData="formData" /> |
|
|
|
|
</div> |
|
|
|
|
<el-button style="position: absolute;bottom: 20px;z-index: 9999;right: 50%;transform: translateX(50%);" @click="exportToWord">保存并下载</el-button> |
|
|
|
|
<el-button style="position: absolute;bottom: 20px;z-index: 9999;right: 50%;transform: translateX(50%);" |
|
|
|
|
@click="exportToWord">保存并下载</el-button> |
|
|
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
@ -217,19 +218,29 @@ |
|
|
|
|
//工作压力 |
|
|
|
|
processNominalPressure(formData) { |
|
|
|
|
try { |
|
|
|
|
// 收集有效数据(包含原始值和数值) |
|
|
|
|
const validEntries = formData.certificateList |
|
|
|
|
.filter(item => |
|
|
|
|
item.type === 'productQualified' && |
|
|
|
|
item.nominalWorkingPressure?.trim() |
|
|
|
|
) |
|
|
|
|
.map(item => ({ |
|
|
|
|
original: item.nominalWorkingPressure, |
|
|
|
|
numeric: parseFloat(item.nominalWorkingPressure) |
|
|
|
|
})) |
|
|
|
|
.filter(entry => !isNaN(entry.numeric)); |
|
|
|
|
// 1. 定义数据收集函数 |
|
|
|
|
const collectEntries = (type) => { |
|
|
|
|
return formData.certificateList |
|
|
|
|
.filter(item => |
|
|
|
|
item.type === type && |
|
|
|
|
item.nominalWorkingPressure?.trim() |
|
|
|
|
) |
|
|
|
|
.map(item => ({ |
|
|
|
|
original: item.nominalWorkingPressure, |
|
|
|
|
numeric: parseFloat(item.nominalWorkingPressure) |
|
|
|
|
})) |
|
|
|
|
.filter(entry => !isNaN(entry.numeric)); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// 2. 先获取产品合格证数据 |
|
|
|
|
let validEntries = collectEntries('certificateOfApproval'); |
|
|
|
|
|
|
|
|
|
// 3. 如果没有有效数据,获取安装合格证数据 |
|
|
|
|
if (validEntries.length === 0) { |
|
|
|
|
validEntries = collectEntries('productQualified'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 获取最大值对应的原始值 |
|
|
|
|
// 4. 处理结果 |
|
|
|
|
if (validEntries.length > 0) { |
|
|
|
|
const maxEntry = validEntries.reduce((a, b) => |
|
|
|
|
a.numeric > b.numeric ? a : b |
|
|
|
@ -263,22 +274,41 @@ |
|
|
|
|
formData.contractor = ''; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
// 气瓶容积处理 |
|
|
|
|
//气瓶容积处理 |
|
|
|
|
processCylinderVolume(formData) { |
|
|
|
|
try { |
|
|
|
|
// 1. 过滤有效数据并转换为数值 |
|
|
|
|
const validVolumes = formData.certificateList |
|
|
|
|
// 1. 定义数据处理函数 |
|
|
|
|
const processVolume = (item) => { |
|
|
|
|
const volumeStr = item.cylinderVolume |
|
|
|
|
.replace(/L/gi, '') |
|
|
|
|
.replace(/,/g, '.'); |
|
|
|
|
return parseFloat(volumeStr); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// 2. 先获取产品合格证数据 |
|
|
|
|
let validVolumes = formData.certificateList |
|
|
|
|
.filter(item => |
|
|
|
|
item.type === 'productQualified' && |
|
|
|
|
item.cylinderVolume?.trim() |
|
|
|
|
) |
|
|
|
|
.map(item => parseFloat(item.cylinderVolume)) |
|
|
|
|
.map(processVolume) |
|
|
|
|
.filter(num => !isNaN(num)); |
|
|
|
|
|
|
|
|
|
// 2. 计算总和(保留两位小数) |
|
|
|
|
// 3. 如果没有产品合格证数据,则取安装合格证数据 |
|
|
|
|
if (validVolumes.length === 0) { |
|
|
|
|
validVolumes = formData.certificateList |
|
|
|
|
.filter(item => |
|
|
|
|
item.type === 'certificateOfApproval' && |
|
|
|
|
item.cylinderVolume?.trim() |
|
|
|
|
) |
|
|
|
|
.map(processVolume) |
|
|
|
|
.filter(num => !isNaN(num)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 4. 计算结果 |
|
|
|
|
if (validVolumes.length > 0) { |
|
|
|
|
const sum = validVolumes.reduce((acc, cur) => acc + cur, 0); |
|
|
|
|
formData.cylinderVolume = sum.toFixed(2); // 根据需求调整小数位数 |
|
|
|
|
formData.cylinderVolume = sum.toFixed(2); |
|
|
|
|
} else { |
|
|
|
|
formData.cylinderVolume = 0; |
|
|
|
|
} |
|
|
|
@ -315,37 +345,60 @@ |
|
|
|
|
//多信息处理(重要) |
|
|
|
|
processInfoList(formData) { |
|
|
|
|
try { |
|
|
|
|
// 1. 获取最长的certificateOfApproval的productId |
|
|
|
|
const longestApprovalId = formData.certificateList |
|
|
|
|
.filter(item => item.type === 'certificateOfApproval') |
|
|
|
|
.map(item => item.productId?.trim() || '') |
|
|
|
|
.reduce((maxId, current) => |
|
|
|
|
current.length > maxId.length ? current : maxId, |
|
|
|
|
''); |
|
|
|
|
// 1. 分两个阶段获取productId |
|
|
|
|
let availableIds = []; |
|
|
|
|
|
|
|
|
|
// 第一阶段:从certificateOfApproval获取最长ID并分割 |
|
|
|
|
const approvalIds = formData.certificateList |
|
|
|
|
.filter(item => item.type === 'certificateOfApproval' && item.productId?.trim()) |
|
|
|
|
.map(item => item.productId.trim()); |
|
|
|
|
|
|
|
|
|
// 2. 分割最长ID为子ID数组 |
|
|
|
|
const availableIds = longestApprovalId.includes('/') |
|
|
|
|
? longestApprovalId.split('/').map(s => s.trim()) |
|
|
|
|
: [longestApprovalId]; |
|
|
|
|
if (approvalIds.length > 0) { |
|
|
|
|
// 取最长ID并分割 |
|
|
|
|
const longestId = approvalIds.reduce((a, b) => a.length > b.length ? a : b); |
|
|
|
|
availableIds = longestId.includes('/') |
|
|
|
|
? longestId.split('/').map(s => s.trim()) |
|
|
|
|
: [longestId]; |
|
|
|
|
} |
|
|
|
|
// 第二阶段:如果第一阶段没有数据,从productQualified获取所有ID |
|
|
|
|
else { |
|
|
|
|
availableIds = formData.certificateList |
|
|
|
|
.filter(item => |
|
|
|
|
item.type === 'productQualified' && |
|
|
|
|
item.productId?.trim() |
|
|
|
|
) |
|
|
|
|
.map(item => item.productId.trim()) |
|
|
|
|
.filter(Boolean); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 3. 筛选需要处理的监督检验数据 |
|
|
|
|
// 2. 筛选需要处理的监督检验数据 |
|
|
|
|
const supervisionItems = formData.certificateList |
|
|
|
|
.filter(item => item.type === 'supervisionAndInspection') |
|
|
|
|
.slice(0, 3); |
|
|
|
|
|
|
|
|
|
// 4. 创建可修改的ID池(仅包含最长ID分割后的子ID) |
|
|
|
|
// 3. 创建可修改的ID池 |
|
|
|
|
let remainingIds = [...availableIds]; |
|
|
|
|
|
|
|
|
|
formData.infoList = supervisionItems.map(item => { |
|
|
|
|
const supervisionProductId = item.productId?.trim() || ''; |
|
|
|
|
const supervisionProductId = item.productBatchNumber?.trim() || ''; |
|
|
|
|
let matchedId = ''; |
|
|
|
|
|
|
|
|
|
// 精确匹配逻辑 |
|
|
|
|
// 匹配逻辑保持不变 |
|
|
|
|
if (supervisionProductId) { |
|
|
|
|
// ...原有匹配逻辑不变... |
|
|
|
|
} |
|
|
|
|
// 新增:当supervision没有productId时,取剩余ID第一个 |
|
|
|
|
else if (remainingIds.length > 0) { |
|
|
|
|
const exactMatch = remainingIds.find(id => id === supervisionProductId); |
|
|
|
|
const partialMatch = remainingIds.find(id => |
|
|
|
|
id.includes(supervisionProductId) || |
|
|
|
|
supervisionProductId.includes(id) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if (exactMatch) { |
|
|
|
|
matchedId = exactMatch; |
|
|
|
|
remainingIds = remainingIds.filter(id => id !== exactMatch); |
|
|
|
|
} else if (partialMatch) { |
|
|
|
|
matchedId = partialMatch; |
|
|
|
|
remainingIds = remainingIds.filter(id => id !== partialMatch); |
|
|
|
|
} |
|
|
|
|
} else if (remainingIds.length > 0) { |
|
|
|
|
matchedId = remainingIds.shift(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -357,13 +410,32 @@ |
|
|
|
|
}; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// 空数组兜底 |
|
|
|
|
formData.infoList = Array.isArray(formData.infoList) ? formData.infoList : []; |
|
|
|
|
} catch (e) { |
|
|
|
|
console.error('infoList处理失败:', e); |
|
|
|
|
formData.infoList = []; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
// 新增车辆VIN码处理方法 |
|
|
|
|
processVehicleVin(formData) { |
|
|
|
|
try { |
|
|
|
|
// 1. 过滤有效数据 |
|
|
|
|
const validVins = formData.certificateList |
|
|
|
|
.filter(item => |
|
|
|
|
item.type === 'certificateOfApproval' && |
|
|
|
|
item.vehicleVin?.trim() // 排除空值 |
|
|
|
|
) |
|
|
|
|
.map(item => item.vehicleVin.trim()); |
|
|
|
|
|
|
|
|
|
// 2. 取第一个有效值(无论是否重复) |
|
|
|
|
formData.vehicleVin = validVins.length > 0 |
|
|
|
|
? validVins[0] |
|
|
|
|
: ''; |
|
|
|
|
} catch (e) { |
|
|
|
|
console.error('车辆VIN码处理失败:', e); |
|
|
|
|
formData.vehicleVin = ''; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
// 模拟接口调用 |
|
|
|
|
async mockFetchData() { |
|
|
|
|
// setTimeout(() => { |
|
|
|
@ -490,6 +562,7 @@ |
|
|
|
|
certificateList: [], // 初始化数组容器 |
|
|
|
|
infoList: [] |
|
|
|
|
}); |
|
|
|
|
console.log('合并结果', mergedData); |
|
|
|
|
// const mergedData = { |
|
|
|
|
// registrationCategory: "过户", |
|
|
|
|
// unifiedSocialCode: "91130185MAE5XYHG9W", |
|
|
|
@ -528,7 +601,7 @@ |
|
|
|
|
// unifiedSocialCode: null, |
|
|
|
|
// userAddress: null, |
|
|
|
|
// userUnit: null, |
|
|
|
|
// vehicleVin: null, |
|
|
|
|
// vehicleVin: 'LVSHJCAM6AE012342', |
|
|
|
|
// }, { |
|
|
|
|
// commissionDate: null, |
|
|
|
|
// contractor: "XX工程公司", |
|
|
|
@ -586,7 +659,7 @@ |
|
|
|
|
// unifiedSocialCode: null, |
|
|
|
|
// userAddress: null, |
|
|
|
|
// userUnit: null, |
|
|
|
|
// vehicleVin: null, |
|
|
|
|
// vehicleVin: 'LVSHJCAM6AE012345', |
|
|
|
|
// }, { |
|
|
|
|
// commissionDate: null, |
|
|
|
|
// contractor: null, |
|
|
|
@ -768,6 +841,205 @@ |
|
|
|
|
// } |
|
|
|
|
// ] |
|
|
|
|
// } |
|
|
|
|
// const mergedData = { |
|
|
|
|
// "registrationCategory": "过户", |
|
|
|
|
// "equipmentType": "高压气瓶", |
|
|
|
|
// "productName": "车用气瓶", |
|
|
|
|
// "cylinderQuantity": 2, |
|
|
|
|
// "fillingMedium": "CNG", |
|
|
|
|
// "nominalWorkingPressure": "20MPa", |
|
|
|
|
// "cylinderVolume": "100.70", |
|
|
|
|
// "manufacturer": "", |
|
|
|
|
// "productionDate": "", |
|
|
|
|
// "productId": "", |
|
|
|
|
// "internalId": "", |
|
|
|
|
// "contractor": "河北长安汽车有限公司", |
|
|
|
|
// "supervisionAgency": "衡阳金化高压容器股份有限公司/ 安徽绿动能源股份有限公司", |
|
|
|
|
// "userUnit": "李冉", |
|
|
|
|
// "userAddress": "河北省石家庄市鹿泉区铜冶镇南李庄村李龙街七巷3号", |
|
|
|
|
// "unifiedSocialCode": "130185198912101360", |
|
|
|
|
// "postalCode": "050200", |
|
|
|
|
// "licensePlate": "冀A0SC80", |
|
|
|
|
// "vehicleVin": "LS4ASL2K5RG809594", |
|
|
|
|
// "commissionDate": "2025-02-10", |
|
|
|
|
// "telephone": "", |
|
|
|
|
// "safetyManager": "", |
|
|
|
|
// "mobilePhone": "", |
|
|
|
|
// "certificateList": [ |
|
|
|
|
// { |
|
|
|
|
// "id": null, |
|
|
|
|
// "registrationCategory": null, |
|
|
|
|
// "equipmentType": "特种气瓶", |
|
|
|
|
// "productName": "车用气瓶", |
|
|
|
|
// "cylinderQuantity": "1", |
|
|
|
|
// "fillingMedium": "CNG", |
|
|
|
|
// "nominalWorkingPressure": "20MPa", |
|
|
|
|
// "cylinderVolume": "70.4", |
|
|
|
|
// "manufacturer": null, |
|
|
|
|
// "productionDate": null, |
|
|
|
|
// "productId": "C", |
|
|
|
|
// "internalId": null, |
|
|
|
|
// "contractor": null, |
|
|
|
|
// "supervisionAgency": null, |
|
|
|
|
// "userUnit": null, |
|
|
|
|
// "userAddress": null, |
|
|
|
|
// "unifiedSocialCode": null, |
|
|
|
|
// "postalCode": null, |
|
|
|
|
// "licensePlate": null, |
|
|
|
|
// "vehicleVin": null, |
|
|
|
|
// "commissionDate": null, |
|
|
|
|
// "telephone": null, |
|
|
|
|
// "safetyManager": null, |
|
|
|
|
// "mobilePhone": null, |
|
|
|
|
// "infoList": null, |
|
|
|
|
// "createTime": null, |
|
|
|
|
// "productBatchNumber": null, |
|
|
|
|
// "type": "productQualified" |
|
|
|
|
// }, |
|
|
|
|
// { |
|
|
|
|
// "id": null, |
|
|
|
|
// "registrationCategory": null, |
|
|
|
|
// "equipmentType": "特种气瓶", |
|
|
|
|
// "productName": "车用气瓶", |
|
|
|
|
// "cylinderQuantity": "1", |
|
|
|
|
// "fillingMedium": "CNG", |
|
|
|
|
// "nominalWorkingPressure": "20MPa", |
|
|
|
|
// "cylinderVolume": "30.3", |
|
|
|
|
// "manufacturer": null, |
|
|
|
|
// "productionDate": null, |
|
|
|
|
// "productId": "NI054039", |
|
|
|
|
// "internalId": null, |
|
|
|
|
// "contractor": null, |
|
|
|
|
// "supervisionAgency": null, |
|
|
|
|
// "userUnit": null, |
|
|
|
|
// "userAddress": null, |
|
|
|
|
// "unifiedSocialCode": null, |
|
|
|
|
// "postalCode": null, |
|
|
|
|
// "licensePlate": null, |
|
|
|
|
// "vehicleVin": null, |
|
|
|
|
// "commissionDate": null, |
|
|
|
|
// "telephone": null, |
|
|
|
|
// "safetyManager": null, |
|
|
|
|
// "mobilePhone": null, |
|
|
|
|
// "infoList": null, |
|
|
|
|
// "createTime": null, |
|
|
|
|
// "productBatchNumber": null, |
|
|
|
|
// "type": "productQualified" |
|
|
|
|
// }, |
|
|
|
|
// { |
|
|
|
|
// "id": null, |
|
|
|
|
// "registrationCategory": null, |
|
|
|
|
// "equipmentType": "特种气瓶", |
|
|
|
|
// "productName": "车用气瓶", |
|
|
|
|
// "cylinderQuantity": null, |
|
|
|
|
// "fillingMedium": null, |
|
|
|
|
// "nominalWorkingPressure": "20MPa", |
|
|
|
|
// "cylinderVolume": null, |
|
|
|
|
// "manufacturer": null, |
|
|
|
|
// "productionDate": null, |
|
|
|
|
// "productId": "NI054039/128240627132", |
|
|
|
|
// "internalId": null, |
|
|
|
|
// "contractor": "河北长安汽车有限公司", |
|
|
|
|
// "supervisionAgency": null, |
|
|
|
|
// "userUnit": null, |
|
|
|
|
// "userAddress": null, |
|
|
|
|
// "unifiedSocialCode": null, |
|
|
|
|
// "postalCode": null, |
|
|
|
|
// "licensePlate": null, |
|
|
|
|
// "vehicleVin": "LS4ASL2K5RG809594", |
|
|
|
|
// "commissionDate": null, |
|
|
|
|
// "telephone": null, |
|
|
|
|
// "safetyManager": null, |
|
|
|
|
// "mobilePhone": null, |
|
|
|
|
// "infoList": null, |
|
|
|
|
// "createTime": null, |
|
|
|
|
// "productBatchNumber": null, |
|
|
|
|
// "type": "certificateOfApproval" |
|
|
|
|
// }, |
|
|
|
|
// { |
|
|
|
|
// "id": null, |
|
|
|
|
// "registrationCategory": null, |
|
|
|
|
// "equipmentType": "特种气瓶", |
|
|
|
|
// "productName": "车用气瓶", |
|
|
|
|
// "cylinderQuantity": null, |
|
|
|
|
// "fillingMedium": null, |
|
|
|
|
// "nominalWorkingPressure": null, |
|
|
|
|
// "cylinderVolume": null, |
|
|
|
|
// "manufacturer": "衡阳金化高压容器股份有限公司", |
|
|
|
|
// "productionDate": "2024年09月01日", |
|
|
|
|
// "productId": null, |
|
|
|
|
// "internalId": null, |
|
|
|
|
// "contractor": null, |
|
|
|
|
// "supervisionAgency": "衡阳金化高压容器股份有限公司", |
|
|
|
|
// "userUnit": null, |
|
|
|
|
// "userAddress": null, |
|
|
|
|
// "unifiedSocialCode": null, |
|
|
|
|
// "postalCode": null, |
|
|
|
|
// "licensePlate": null, |
|
|
|
|
// "vehicleVin": null, |
|
|
|
|
// "commissionDate": null, |
|
|
|
|
// "telephone": null, |
|
|
|
|
// "safetyManager": null, |
|
|
|
|
// "mobilePhone": null, |
|
|
|
|
// "infoList": null, |
|
|
|
|
// "createTime": null, |
|
|
|
|
// "productBatchNumber": "128240627", |
|
|
|
|
// "type": "supervisionAndInspection" |
|
|
|
|
// }, |
|
|
|
|
// { |
|
|
|
|
// "id": null, |
|
|
|
|
// "registrationCategory": null, |
|
|
|
|
// "equipmentType": "特种气瓶", |
|
|
|
|
// "productName": "车用气瓶", |
|
|
|
|
// "cylinderQuantity": null, |
|
|
|
|
// "fillingMedium": null, |
|
|
|
|
// "nominalWorkingPressure": null, |
|
|
|
|
// "cylinderVolume": null, |
|
|
|
|
// "manufacturer": "安徽绿动能源股份有限公司", |
|
|
|
|
// "productionDate": "2024年08月01日", |
|
|
|
|
// "productId": null, |
|
|
|
|
// "internalId": null, |
|
|
|
|
// "contractor": null, |
|
|
|
|
// "supervisionAgency": "安徽绿动能源股份有限公司", |
|
|
|
|
// "userUnit": null, |
|
|
|
|
// "userAddress": null, |
|
|
|
|
// "unifiedSocialCode": null, |
|
|
|
|
// "postalCode": null, |
|
|
|
|
// "licensePlate": null, |
|
|
|
|
// "vehicleVin": null, |
|
|
|
|
// "commissionDate": null, |
|
|
|
|
// "telephone": null, |
|
|
|
|
// "safetyManager": null, |
|
|
|
|
// "mobilePhone": null, |
|
|
|
|
// "infoList": null, |
|
|
|
|
// "createTime": null, |
|
|
|
|
// "productBatchNumber": "NI054", |
|
|
|
|
// "type": "supervisionAndInspection" |
|
|
|
|
// } |
|
|
|
|
// ], |
|
|
|
|
// "infoList": [ |
|
|
|
|
// { |
|
|
|
|
// "manufacturer": "衡阳金化高压容器股份有限公司", |
|
|
|
|
// "productionDate": "2024年09月01日", |
|
|
|
|
// "productId": "NI054039", |
|
|
|
|
// "internalId": "" |
|
|
|
|
// }, |
|
|
|
|
// { |
|
|
|
|
// "manufacturer": "安徽绿动能源股份有限公司", |
|
|
|
|
// "productionDate": "2024年08月01日", |
|
|
|
|
// "productId": "128240627132", |
|
|
|
|
// "internalId": "" |
|
|
|
|
// }, |
|
|
|
|
// { |
|
|
|
|
// "manufacturer": "", |
|
|
|
|
// "productionDate": "", |
|
|
|
|
// "productId": "", |
|
|
|
|
// "internalId": "" |
|
|
|
|
// } |
|
|
|
|
// ], |
|
|
|
|
// "total_pages": 1, |
|
|
|
|
// "processing_time": "7.94s" |
|
|
|
|
// } |
|
|
|
|
this.calculateCylinderQuantity(mergedData);//气瓶数量 |
|
|
|
|
this.processFillingMedium(mergedData);//重装介质 |
|
|
|
|
this.processNominalPressure(mergedData);//工作压力 |
|
|
|
@ -775,6 +1047,7 @@ |
|
|
|
|
this.processContractor(mergedData); //施工单位 |
|
|
|
|
this.processSupervisionAgency(mergedData); //监督检验机构 |
|
|
|
|
this.processInfoList(mergedData); //产品信息 |
|
|
|
|
this.processVehicleVin(mergedData); // 新增车辆VIN处理 |
|
|
|
|
this.formData = mergedData; |
|
|
|
|
console.log(this.formData) |
|
|
|
|
} catch (error) { |
|
|
|
|