1、新增结算模块
2、调整业务模块 3、调整客商模块
This commit is contained in:
@@ -496,7 +496,7 @@
|
||||
:headers="uploadHeaders"
|
||||
large
|
||||
class-prefix="vehicle"
|
||||
@success="url => setImage('roadTransportCertImage', url)"
|
||||
@success="url => handleVehicleCertificateUploadSuccess('roadTransportCertImage', url)"
|
||||
/>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
@@ -541,6 +541,7 @@ import {
|
||||
auditCertification,
|
||||
getExpiryStat,
|
||||
recognitionTransportCertificates,
|
||||
recognizeBaiduOcr,
|
||||
} from '@/api/transportCapacity/transport-vehicle';
|
||||
import { getDeptTree } from '@/api/system/dept';
|
||||
import { exportBlob } from '@/api/common';
|
||||
@@ -875,17 +876,57 @@ export default {
|
||||
handleVehicleCertificateUploadSuccess(prop, url) {
|
||||
this.setImage(prop, url);
|
||||
this.vehicleCertificateUploads[prop] = url;
|
||||
if (prop.startsWith('drivingLicense')) {
|
||||
if (prop.endsWith('Back')) {
|
||||
this.recognizeBaiduVehicleOcr(url, 'general', '', '行驶证', data => {
|
||||
this.applyBaiduVehicleLicenseGeneralRecognition(data);
|
||||
});
|
||||
return;
|
||||
}
|
||||
const side = prop === 'drivingLicenseViceFront' ? 'back' : 'front';
|
||||
this.recognizeBaiduVehicleOcr(url, 'vehicle_license', side, '行驶证', data => {
|
||||
this.applyBaiduVehicleLicenseRecognition(data);
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (prop === 'roadTransportCertImage') {
|
||||
this.recognizeBaiduVehicleOcr(
|
||||
url,
|
||||
'road_transport_certificate',
|
||||
'',
|
||||
'道路运输证',
|
||||
data => {
|
||||
this.applyBaiduRoadTransportCertificateRecognition(data);
|
||||
}
|
||||
);
|
||||
return;
|
||||
}
|
||||
this.recognizeVehicleCertificates();
|
||||
},
|
||||
recognizeBaiduVehicleOcr(url, type, side, documentName, applyRecognition) {
|
||||
if (!url) {
|
||||
this.$message.warning(`${documentName}图片上传成功,未获取到图片地址,无法自动识别`);
|
||||
return;
|
||||
}
|
||||
const loading = ElLoading.service({
|
||||
lock: true,
|
||||
text: `${documentName}识别中`,
|
||||
background: 'rgba(255, 255, 255, 0.7)',
|
||||
});
|
||||
recognizeBaiduOcr(url, type, side)
|
||||
.then(res => {
|
||||
applyRecognition(res.data.data?.result || {});
|
||||
this.$message.success(`${documentName}识别完成`);
|
||||
})
|
||||
.catch(() => {
|
||||
this.$message.warning(`${documentName}图片上传成功,自动识别失败,请手动填写车辆资质信息`);
|
||||
})
|
||||
.finally(() => {
|
||||
loading.close();
|
||||
});
|
||||
},
|
||||
recognizeVehicleCertificates() {
|
||||
const objectKeys = [
|
||||
this.vehicleCertificateUploads.drivingLicenseImage || this.vehicleForm.drivingLicenseImage,
|
||||
this.vehicleCertificateUploads.drivingLicenseMainBack ||
|
||||
this.vehicleForm.drivingLicenseMainBack,
|
||||
this.vehicleCertificateUploads.drivingLicenseViceFront ||
|
||||
this.vehicleForm.drivingLicenseViceFront,
|
||||
this.vehicleCertificateUploads.drivingLicenseViceBack ||
|
||||
this.vehicleForm.drivingLicenseViceBack,
|
||||
this.vehicleCertificateUploads.registrationImage || this.vehicleForm.registrationImage,
|
||||
].filter(Boolean);
|
||||
if (!objectKeys.length) {
|
||||
@@ -909,6 +950,168 @@ export default {
|
||||
loading.close();
|
||||
});
|
||||
},
|
||||
applyBaiduVehicleLicenseRecognition(data = {}) {
|
||||
const plateNo = this.getBaiduOcrValue(data, ['号牌号码', '车牌号码']);
|
||||
const vehicleType = this.getBaiduOcrValue(data, ['车辆类型']);
|
||||
const drivingLicenseNo = this.getBaiduOcrValue(data, ['档案编号']);
|
||||
const inspectionValidity = this.getBaiduOcrValue(data, ['检验有效期至', '检验有效期', '检验记录']);
|
||||
const registrationDate = this.getBaiduOcrValue(data, ['注册日期']);
|
||||
const registrationNo = this.getBaiduOcrValue(data, ['车辆识别代号', '车架号']);
|
||||
const approvedLoadKg = this.getBaiduOcrValue(data, ['核定载质量']);
|
||||
const outerDimensions = this.getBaiduOcrValue(data, ['外廓尺寸']);
|
||||
if (plateNo) {
|
||||
this.vehicleForm.plateNo = String(plateNo).replace(/\s/g, '').toUpperCase();
|
||||
this.splitPlateNo();
|
||||
this.syncPlateNo(false);
|
||||
}
|
||||
if (vehicleType) {
|
||||
this.vehicleForm.vehicleType = this.normalizeVehicleType(vehicleType);
|
||||
}
|
||||
if (drivingLicenseNo) {
|
||||
this.vehicleForm.drivingLicenseNo = String(drivingLicenseNo).replace(/\s/g, '');
|
||||
}
|
||||
this.applyDrivingLicenseValidity(inspectionValidity);
|
||||
if (registrationDate) {
|
||||
this.vehicleForm.registrationDate = this.normalizeDate(registrationDate);
|
||||
}
|
||||
if (registrationNo) {
|
||||
this.vehicleForm.registrationNo = String(registrationNo).replace(/\s/g, '');
|
||||
}
|
||||
if (approvedLoadKg) {
|
||||
this.vehicleForm.approvedLoadKg = this.normalizeVehicleNumber(approvedLoadKg);
|
||||
}
|
||||
this.applyOuterDimensions(outerDimensions);
|
||||
this.$nextTick(() => {
|
||||
[
|
||||
'plateNo',
|
||||
'vehicleType',
|
||||
'drivingLicenseNo',
|
||||
'drivingLicenseEndDate',
|
||||
'registrationNo',
|
||||
'approvedLoadKg',
|
||||
'outerLength',
|
||||
'outerWidth',
|
||||
'outerHeight',
|
||||
].forEach(prop => {
|
||||
this.$refs.vehicleForm?.validateField(prop);
|
||||
});
|
||||
});
|
||||
},
|
||||
applyBaiduVehicleLicenseGeneralRecognition(data = {}) {
|
||||
const words = this.getBaiduOcrWords(data);
|
||||
const getValue = labels => this.getBaiduGeneralOcrValue(words, labels);
|
||||
this.applyBaiduVehicleLicenseRecognition({
|
||||
words_result: {
|
||||
号牌号码: { words: getValue(['号牌号码', '车牌号码']) },
|
||||
车辆类型: { words: getValue(['车辆类型']) },
|
||||
档案编号: { words: getValue(['档案编号']) },
|
||||
检验有效期至: { words: getValue(['检验有效期至', '检验有效期', '检验记录']) },
|
||||
注册日期: { words: getValue(['注册日期']) },
|
||||
车辆识别代号: { words: getValue(['车辆识别代号', '车架号']) },
|
||||
核定载质量: { words: getValue(['核定载质量']) },
|
||||
外廓尺寸: { words: getValue(['外廓尺寸']) },
|
||||
},
|
||||
});
|
||||
},
|
||||
normalizeVehicleNumber(value = '') {
|
||||
const number = String(value || '').replace(/,/g, '').match(/-?\d+(?:\.\d+)?/);
|
||||
return number ? number[0] : '';
|
||||
},
|
||||
applyOuterDimensions(value = '') {
|
||||
const dimensions = String(value || '').match(/\d+(?:\.\d+)?/g) || [];
|
||||
if (dimensions[0]) this.vehicleForm.outerLength = dimensions[0];
|
||||
if (dimensions[1]) this.vehicleForm.outerWidth = dimensions[1];
|
||||
if (dimensions[2]) this.vehicleForm.outerHeight = dimensions[2];
|
||||
},
|
||||
applyBaiduRoadTransportCertificateRecognition(data = {}) {
|
||||
const certificateNo = this.getBaiduOcrValue(data, ['道路运输证号', '证号']);
|
||||
const validity = this.getBaiduOcrValue(data, ['有效期至', '有效期限', '有效期']);
|
||||
if (certificateNo) {
|
||||
this.vehicleForm.roadTransportCertNo = String(certificateNo).replace(/\s/g, '');
|
||||
}
|
||||
this.applyRoadTransportCertificateValidity(validity);
|
||||
this.$nextTick(() => {
|
||||
['roadTransportCertNo', 'roadTransportCertEndDate'].forEach(prop => {
|
||||
this.$refs.vehicleForm?.validateField(prop);
|
||||
});
|
||||
});
|
||||
},
|
||||
applyRoadTransportCertificateValidity(validity = '') {
|
||||
const value = String(validity || '');
|
||||
if (!value) return;
|
||||
if (/(长期|永久)/.test(value)) {
|
||||
this.vehicleForm.roadTransportCertLongTerm = 1;
|
||||
this.vehicleForm.roadTransportCertEndDate = '';
|
||||
return;
|
||||
}
|
||||
const dateList = value.match(/\d{4}[-/.年]\d{1,2}[-/.月]\d{1,2}日?/g) || [];
|
||||
if (dateList.length) {
|
||||
this.vehicleForm.roadTransportCertEndDate = this.normalizeDate(dateList[dateList.length - 1]);
|
||||
this.vehicleForm.roadTransportCertLongTerm = 0;
|
||||
}
|
||||
},
|
||||
applyDrivingLicenseValidity(validity = '') {
|
||||
const value = String(validity || '');
|
||||
if (!value) return;
|
||||
if (/(长期|永久)/.test(value)) {
|
||||
this.vehicleForm.drivingLicenseLongTerm = 1;
|
||||
this.vehicleForm.drivingLicenseEndDate = '';
|
||||
return;
|
||||
}
|
||||
const dateList = value.match(/\d{4}[-/.年]\d{1,2}[-/.月]\d{1,2}日?/g) || [];
|
||||
if (dateList.length) {
|
||||
this.vehicleForm.drivingLicenseEndDate = this.normalizeDate(dateList[dateList.length - 1]);
|
||||
this.vehicleForm.drivingLicenseLongTerm = 0;
|
||||
}
|
||||
},
|
||||
getBaiduOcrValue(data = {}, keys = []) {
|
||||
const wordsResult = data.words_result || data.wordsResult || {};
|
||||
const normalizedKeys = keys.map(key => String(key).toLowerCase());
|
||||
if (Array.isArray(wordsResult)) {
|
||||
const wordItem = wordsResult.find(item =>
|
||||
normalizedKeys.includes(String(item.key || item.name || '').toLowerCase())
|
||||
);
|
||||
return wordItem?.words || wordItem?.word || wordItem?.value || '';
|
||||
}
|
||||
const wordEntry = Object.entries(wordsResult).find(([key]) =>
|
||||
normalizedKeys.includes(String(key).toLowerCase())
|
||||
);
|
||||
if (!wordEntry) return '';
|
||||
const value = wordEntry[1];
|
||||
if (Array.isArray(value)) {
|
||||
const item = value.find(entry => entry?.words || entry?.word || entry?.value);
|
||||
return item?.words || item?.word || item?.value || '';
|
||||
}
|
||||
return typeof value === 'object' ? value.words || value.word || value.value || '' : value || '';
|
||||
},
|
||||
getBaiduOcrWords(data = {}) {
|
||||
const wordsResult = data.words_result || data.wordsResult || {};
|
||||
if (Array.isArray(wordsResult)) {
|
||||
return wordsResult.map(item => item.words || item.word || item.value || '').filter(Boolean);
|
||||
}
|
||||
return Object.values(wordsResult)
|
||||
.map(item => {
|
||||
if (Array.isArray(item)) {
|
||||
const entry = item.find(value => value?.words || value?.word || value?.value);
|
||||
return entry?.words || entry?.word || entry?.value || '';
|
||||
}
|
||||
return typeof item === 'object' ? item.words || item.word || item.value || '' : item || '';
|
||||
})
|
||||
.filter(Boolean);
|
||||
},
|
||||
getBaiduGeneralOcrValue(words = [], labels = []) {
|
||||
const normalizedWords = words.map(word => String(word || '').trim()).filter(Boolean);
|
||||
for (const label of labels) {
|
||||
const labelIndex = normalizedWords.findIndex(word => word.includes(label));
|
||||
if (labelIndex < 0) continue;
|
||||
const inlineValue = normalizedWords[labelIndex]
|
||||
.replace(new RegExp(`^.*${label}\\s*[::]?`), '')
|
||||
.trim();
|
||||
if (inlineValue) return inlineValue;
|
||||
if (normalizedWords[labelIndex + 1]) return normalizedWords[labelIndex + 1];
|
||||
}
|
||||
return '';
|
||||
},
|
||||
applyVehicleCertificateRecognition(data = {}) {
|
||||
const plateNo = data.drivingPlateNo || data.vehicleLicensePlateNo || '';
|
||||
const vehicleType = data.vehicleLicenseVehicleType || data.vehicleType || '';
|
||||
|
||||
Reference in New Issue
Block a user