1、新增结算模块
2、调整业务模块 3、调整客商模块
This commit is contained in:
@@ -400,7 +400,7 @@
|
||||
:readonly="readonly"
|
||||
:headers="uploadHeaders"
|
||||
large
|
||||
@success="url => setImage('qualificationFront', url)"
|
||||
@success="url => handleQualificationUploadSuccess('qualificationFront', url)"
|
||||
/>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
@@ -411,7 +411,7 @@
|
||||
:readonly="readonly"
|
||||
:headers="uploadHeaders"
|
||||
large
|
||||
@success="url => setImage('qualificationBack', url)"
|
||||
@success="url => handleQualificationUploadSuccess('qualificationBack', url)"
|
||||
/>
|
||||
</el-col>
|
||||
</el-row>
|
||||
@@ -504,6 +504,7 @@ import {
|
||||
getExpiryStat,
|
||||
recognitionIDCard,
|
||||
recognitionTransportCertificates,
|
||||
recognizeBaiduOcr,
|
||||
} from '@/api/transportCapacity/driver';
|
||||
import { getDeptTree } from '@/api/system/dept';
|
||||
import { getDictionary } from '@/api/system/dictbiz';
|
||||
@@ -754,6 +755,10 @@ export default {
|
||||
this.qualificationTypeOptions = (res.data.data || [])
|
||||
.map(item => item.dictValue)
|
||||
.filter(Boolean);
|
||||
const matchedType = this.matchQualificationType(this.driverForm.qualificationType);
|
||||
if (matchedType) {
|
||||
this.driverForm.qualificationType = matchedType;
|
||||
}
|
||||
});
|
||||
},
|
||||
formatDeptOptions(tree = [], level = 0) {
|
||||
@@ -953,12 +958,53 @@ export default {
|
||||
},
|
||||
handleIdCardUploadSuccess(prop, url) {
|
||||
this.setImage(prop, url);
|
||||
this.recognizeIdCard(url);
|
||||
if (prop !== 'idCardFront') {
|
||||
return;
|
||||
}
|
||||
this.recognizeBaiduOcr(url, 'id_card', 'front', '身份证', data => {
|
||||
this.applyIdCardRecognition(data);
|
||||
});
|
||||
},
|
||||
handleDrivingLicenseUploadSuccess(prop, url) {
|
||||
this.setImage(prop, url);
|
||||
this.drivingLicenseUploads[prop] = url;
|
||||
this.recognizeDrivingLicense();
|
||||
this.recognizeBaiduOcr(
|
||||
url,
|
||||
'driving_license',
|
||||
prop === 'drivingLicenseBack' ? 'back' : 'front',
|
||||
'驾驶证',
|
||||
data => {
|
||||
this.applyDrivingLicenseRecognition(data);
|
||||
}
|
||||
);
|
||||
},
|
||||
handleQualificationUploadSuccess(prop, url) {
|
||||
this.setImage(prop, url);
|
||||
this.recognizeBaiduOcr(url, 'general', '', '从业资格证', data => {
|
||||
this.applyQualificationRecognition(data);
|
||||
});
|
||||
},
|
||||
recognizeBaiduOcr(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();
|
||||
});
|
||||
},
|
||||
recognizeIdCard(url = '') {
|
||||
if (!url) {
|
||||
@@ -1040,11 +1086,11 @@ export default {
|
||||
const validDateStart =
|
||||
data.driverLicenseValidDateStart ||
|
||||
data.drivingLicenseStartDate ||
|
||||
this.getOcrValue(data, ['date_vaild_start', '有效期限(起始时间)']);
|
||||
this.getOcrValue(data, ['date_vaild_start', '有效期限(起始时间)', '有效起始日期']);
|
||||
const validDateEnd =
|
||||
data.driverLicenseValidDateEnd ||
|
||||
data.drivingLicenseEndDate ||
|
||||
this.getOcrValue(data, ['date_vaild_end', '有效期限(终止时间)', '有效期限(终⽌时间)']);
|
||||
this.getOcrValue(data, ['date_vaild_end', '有效期限(终止时间)', '有效期限(终⽌时间)', '有效截止日期']);
|
||||
if (driverName && !this.driverForm.driverName) {
|
||||
this.driverForm.driverName = driverName;
|
||||
}
|
||||
@@ -1067,6 +1113,7 @@ export default {
|
||||
this.driverForm.drivingLicenseEndDate = this.normalizeBirthday(validDateEnd);
|
||||
this.driverForm.drivingLicenseLongTerm = 0;
|
||||
}
|
||||
this.applyDrivingLicenseValidity(data);
|
||||
this.$nextTick(() => {
|
||||
[
|
||||
'driverName',
|
||||
@@ -1080,6 +1127,21 @@ export default {
|
||||
});
|
||||
});
|
||||
},
|
||||
applyDrivingLicenseValidity(data = {}) {
|
||||
const validity = this.getOcrValue(data, ['有效期限', '有效期']);
|
||||
if (!validity) return;
|
||||
const dateList = validity.match(/\d{4}[-/.年]\d{1,2}[-/.月]\d{1,2}日?/g) || [];
|
||||
if (!this.driverForm.drivingLicenseStartDate && dateList[0]) {
|
||||
this.driverForm.drivingLicenseStartDate = this.normalizeBirthday(dateList[0]);
|
||||
}
|
||||
if (/(长期|永久)/.test(validity)) {
|
||||
this.driverForm.drivingLicenseLongTerm = 1;
|
||||
this.driverForm.drivingLicenseEndDate = '';
|
||||
} else if (!this.driverForm.drivingLicenseEndDate && dateList[1]) {
|
||||
this.driverForm.drivingLicenseEndDate = this.normalizeBirthday(dateList[1]);
|
||||
this.driverForm.drivingLicenseLongTerm = 0;
|
||||
}
|
||||
},
|
||||
applyIdCardRecognition(data = {}) {
|
||||
const driverName = data.name || data.driverName || this.getOcrValue(data, ['name', '姓名']);
|
||||
const idCardNo = String(
|
||||
@@ -1093,8 +1155,7 @@ export default {
|
||||
data.nation ||
|
||||
data.ethnicGroup ||
|
||||
this.getOcrValue(data, ['ethnic_group', 'nation', '民族']);
|
||||
const ocrBirthday =
|
||||
data.birthday || data.birthDate || this.getOcrValue(data, ['date', '出生']);
|
||||
const ocrAddress = data.address || this.getOcrValue(data, ['address', '住址', '地址']);
|
||||
if (driverName) {
|
||||
this.driverForm.driverName = driverName;
|
||||
}
|
||||
@@ -1104,8 +1165,8 @@ export default {
|
||||
if (ocrNation) {
|
||||
this.driverForm.nation = this.normalizeNation(ocrNation);
|
||||
}
|
||||
if (ocrBirthday) {
|
||||
this.driverForm.birthday = this.normalizeBirthday(ocrBirthday);
|
||||
if (ocrAddress) {
|
||||
this.driverForm.address = String(ocrAddress).trim();
|
||||
}
|
||||
if (idCardNo) {
|
||||
this.driverForm.idCardNo = idCardNo;
|
||||
@@ -1113,7 +1174,7 @@ export default {
|
||||
this.driverForm.qualificationNo = idCardNo;
|
||||
}
|
||||
const idCardInfo = this.parseIdCardInfo(idCardNo);
|
||||
if (!this.driverForm.birthday && idCardInfo.birthday) {
|
||||
if (idCardInfo.birthday) {
|
||||
this.driverForm.birthday = idCardInfo.birthday;
|
||||
}
|
||||
if (!this.driverForm.gender && idCardInfo.gender) {
|
||||
@@ -1121,11 +1182,17 @@ export default {
|
||||
}
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
['driverName', 'idCardNo', 'birthday', 'gender', 'nation', 'qualificationNo'].forEach(
|
||||
prop => {
|
||||
this.$refs.driverForm?.validateField(prop);
|
||||
}
|
||||
);
|
||||
[
|
||||
'driverName',
|
||||
'idCardNo',
|
||||
'birthday',
|
||||
'gender',
|
||||
'nation',
|
||||
'qualificationNo',
|
||||
'address',
|
||||
].forEach(prop => {
|
||||
this.$refs.driverForm?.validateField(prop);
|
||||
});
|
||||
});
|
||||
},
|
||||
getOcrValue(data = {}, keys = []) {
|
||||
@@ -1136,7 +1203,102 @@ export default {
|
||||
const description = String(info.description || '');
|
||||
return keys.some(value => key === String(value).toLowerCase() || description === value);
|
||||
});
|
||||
return item ? item.value || '' : '';
|
||||
if (item) return item.value || '';
|
||||
const wordsResult = data.words_result || data.wordsResult || {};
|
||||
const normalizedKeys = keys.map(key => String(key).toLowerCase());
|
||||
if (Array.isArray(wordsResult)) {
|
||||
const wordItem = wordsResult.find(info =>
|
||||
normalizedKeys.includes(String(info.key || info.name || '').toLowerCase())
|
||||
);
|
||||
return wordItem?.words || wordItem?.value || '';
|
||||
}
|
||||
const wordEntry = Object.entries(wordsResult).find(([key]) =>
|
||||
normalizedKeys.includes(String(key).toLowerCase())
|
||||
);
|
||||
if (!wordEntry) return '';
|
||||
const value = wordEntry[1];
|
||||
return typeof value === 'object' ? value.words || value.value || '' : value || '';
|
||||
},
|
||||
applyQualificationRecognition(data = {}) {
|
||||
const qualificationType = this.getQualificationType(data);
|
||||
const qualificationNo = this.getQualificationNo(data);
|
||||
const matchedType = this.matchQualificationType(qualificationType);
|
||||
if (matchedType) {
|
||||
this.driverForm.qualificationType = matchedType;
|
||||
} else if (qualificationType && !this.qualificationTypeOptions.length) {
|
||||
this.driverForm.qualificationType = qualificationType;
|
||||
}
|
||||
if (qualificationNo && !this.driverForm.qualificationNo) {
|
||||
this.driverForm.qualificationNo = String(qualificationNo).replace(/\s/g, '');
|
||||
}
|
||||
const words = this.getBaiduOcrWords(data).join(' ');
|
||||
const dateList = words.match(/\d{4}[-/.年]\d{1,2}[-/.月]\d{1,2}日?/g) || [];
|
||||
if (/(长期|永久有效)/.test(words)) {
|
||||
this.driverForm.qualificationLongTerm = 1;
|
||||
this.driverForm.qualificationEndDate = '';
|
||||
} else if (dateList.length) {
|
||||
this.driverForm.qualificationEndDate = this.normalizeBirthday(dateList[dateList.length - 1]);
|
||||
this.driverForm.qualificationLongTerm = 0;
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
['qualificationType', 'qualificationNo', 'qualificationEndDate'].forEach(prop => {
|
||||
this.$refs.driverForm?.validateField(prop);
|
||||
});
|
||||
});
|
||||
},
|
||||
getQualificationType(data = {}) {
|
||||
const fieldValue = this.getOcrValue(data, ['从业资格类别', '从业资格类型']);
|
||||
if (fieldValue) return String(fieldValue).trim();
|
||||
const words = this.getBaiduOcrWords(data);
|
||||
const labelIndex = words.findIndex(word => /从业资格类别|从业资格类型/.test(word));
|
||||
if (labelIndex < 0) return '';
|
||||
const firstValue = words[labelIndex].replace(/^.*?(?:从业资格类别|从业资格类型)\s*[::]?/, '').trim();
|
||||
const values = firstValue ? [firstValue] : [];
|
||||
for (let index = labelIndex + 1; index < words.length; index += 1) {
|
||||
const word = String(words[index] || '').trim();
|
||||
if (!word || /^(有效起始日期|有效期限|核发机关|继续教育信息|诚信考核信息)/.test(word)) {
|
||||
break;
|
||||
}
|
||||
values.push(word);
|
||||
}
|
||||
return values.join('').replace(/[,,;;]+$/, '').trim();
|
||||
},
|
||||
matchQualificationType(value = '') {
|
||||
const text = String(value || '').replace(/\s/g, '');
|
||||
if (!text) return '';
|
||||
const options = this.qualificationTypeOptions || [];
|
||||
const normalizedOptions = options.map(option => ({
|
||||
value: option,
|
||||
text: String(option).replace(/\s/g, ''),
|
||||
}));
|
||||
const exact = normalizedOptions.find(option => option.text === text);
|
||||
if (exact) return exact.value;
|
||||
const candidates = text.split(/[,,;;]/).filter(Boolean);
|
||||
const matched = normalizedOptions.find(option =>
|
||||
candidates.some(candidate => candidate.includes(option.text) || option.text.includes(candidate))
|
||||
);
|
||||
return matched?.value || '';
|
||||
},
|
||||
getQualificationNo(data = {}) {
|
||||
const fieldValue = this.getOcrValue(data, ['从业资格证号', '资格证号', '证书编号']);
|
||||
if (fieldValue) return fieldValue;
|
||||
const words = this.getBaiduOcrWords(data);
|
||||
const labelIndex = words.findIndex(word => /^(?:(?:从业)?资格证号?|证书编号)[::]?$/.test(word));
|
||||
if (labelIndex >= 0 && words[labelIndex + 1]) {
|
||||
return words[labelIndex + 1];
|
||||
}
|
||||
const certificateLine = words.find(word => /(?:从业)?资格证号?|证书编号/.test(word));
|
||||
const match = certificateLine?.match(/(?:(?:从业)?资格证号?|证书编号)\s*[::]?\s*([A-Z0-9-]{6,})/i);
|
||||
return match?.[1] || '';
|
||||
},
|
||||
getBaiduOcrWords(data = {}) {
|
||||
const wordsResult = data.words_result || data.wordsResult || {};
|
||||
if (Array.isArray(wordsResult)) {
|
||||
return wordsResult.map(item => item.words || item.value || '').filter(Boolean);
|
||||
}
|
||||
return Object.values(wordsResult)
|
||||
.map(item => (typeof item === 'object' ? item.words || item.value || '' : item || ''))
|
||||
.filter(Boolean);
|
||||
},
|
||||
normalizeNation(value = '') {
|
||||
const nation = String(value || '').trim();
|
||||
|
||||
@@ -500,7 +500,7 @@
|
||||
:headers="uploadHeaders"
|
||||
large
|
||||
class-prefix="ship"
|
||||
@success="url => setImage('ownershipCertImage', url)"
|
||||
@success="url => handleShipCertificateUploadSuccess('ownershipCertImage', url)"
|
||||
/>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
@@ -512,7 +512,7 @@
|
||||
:headers="uploadHeaders"
|
||||
large
|
||||
class-prefix="ship"
|
||||
@success="url => setImage('safetyCertImage', url)"
|
||||
@success="url => handleShipCertificateUploadSuccess('safetyCertImage', url)"
|
||||
/>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
@@ -524,7 +524,7 @@
|
||||
:headers="uploadHeaders"
|
||||
large
|
||||
class-prefix="ship"
|
||||
@success="url => setImage('nationalityCertImage', url)"
|
||||
@success="url => handleShipCertificateUploadSuccess('nationalityCertImage', url)"
|
||||
/>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
@@ -536,7 +536,7 @@
|
||||
:headers="uploadHeaders"
|
||||
large
|
||||
class-prefix="ship"
|
||||
@success="url => setImage('safeManningCertImage', url)"
|
||||
@success="url => handleShipCertificateUploadSuccess('safeManningCertImage', url)"
|
||||
/>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
@@ -551,7 +551,7 @@
|
||||
:headers="uploadHeaders"
|
||||
large
|
||||
class-prefix="ship"
|
||||
@success="url => setImage('leaseContractImage', url)"
|
||||
@success="url => handleShipCertificateUploadSuccess('leaseContractImage', url)"
|
||||
/>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
@@ -563,7 +563,7 @@
|
||||
:headers="uploadHeaders"
|
||||
large
|
||||
class-prefix="ship"
|
||||
@success="url => setImage('businessTransportCertImage', url)"
|
||||
@success="url => handleShipCertificateUploadSuccess('businessTransportCertImage', url)"
|
||||
/>
|
||||
</el-col>
|
||||
</el-row>
|
||||
@@ -582,6 +582,7 @@
|
||||
<script>
|
||||
import { mapGetters } from 'vuex';
|
||||
import NProgress from 'nprogress';
|
||||
import { ElLoading } from 'element-plus';
|
||||
import { InfoFilled } from '@element-plus/icons-vue';
|
||||
import { option } from '@/option/transportCapacity/transport-ship';
|
||||
import { getDeptTree } from '@/api/system/dept';
|
||||
@@ -592,6 +593,7 @@ import {
|
||||
remove,
|
||||
changeStatus,
|
||||
getExpiryStat,
|
||||
recognizeBaiduOcr,
|
||||
} from '@/api/transportCapacity/transport-ship';
|
||||
import { exportBlob } from '@/api/common';
|
||||
import { getToken } from '@/utils/auth';
|
||||
@@ -893,6 +895,155 @@ export default {
|
||||
this.shipForm[prop] = url;
|
||||
this.$refs.shipForm?.validateField(prop);
|
||||
},
|
||||
handleShipCertificateUploadSuccess(prop, url) {
|
||||
this.setImage(prop, url);
|
||||
const documentNameMap = {
|
||||
ownershipCertImage: '船舶所有权证书',
|
||||
safetyCertImage: '内河船舶安全与环保证书',
|
||||
nationalityCertImage: '船舶国籍证书',
|
||||
safeManningCertImage: '内河船舶最低安全配员证书',
|
||||
leaseContractImage: '光船租赁登记证书',
|
||||
businessTransportCertImage: '船舶营业运输证',
|
||||
};
|
||||
this.recognizeBaiduOcr(url, documentNameMap[prop], data => {
|
||||
this.applyShipCertificateRecognition(prop, data);
|
||||
});
|
||||
},
|
||||
recognizeBaiduOcr(url, 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, 'general')
|
||||
.then(res => {
|
||||
applyRecognition(res.data.data?.result || {});
|
||||
this.$message.success(`${documentName}识别完成`);
|
||||
})
|
||||
.catch(() => {
|
||||
this.$message.warning(`${documentName}图片上传成功,自动识别失败,请手动填写证书信息`);
|
||||
})
|
||||
.finally(() => {
|
||||
loading.close();
|
||||
});
|
||||
},
|
||||
applyShipCertificateRecognition(prop, data = {}) {
|
||||
const words = this.getBaiduOcrWords(data);
|
||||
switch (prop) {
|
||||
case 'ownershipCertImage':
|
||||
this.fillShipCertificateText(words, 'ownershipRegistrationNo', ['登记号码', '登记号']);
|
||||
this.fillShipCertificateText(words, 'initialRegistrationNo', ['初次登记号码', '初始登记号码']);
|
||||
this.fillShipCertificateText(words, 'shipOwner', ['船舶所有人', '所有人']);
|
||||
this.fillShipCertificateText(words, 'shipIdentifierNo', ['船舶识别号', '船舶识别号码']);
|
||||
this.fillShipCertificateDate(words, 'ownershipAcquisitionDate', ['取得所有权日期', '取得日期']);
|
||||
break;
|
||||
case 'safetyCertImage':
|
||||
this.fillShipCertificateNumber(words, 'grossTonnage', ['总吨', '总吨位']);
|
||||
this.fillShipCertificateNumber(words, 'netTonnage', ['净吨', '净吨位']);
|
||||
this.fillShipCertificateText(words, 'shipInspectionNo', ['船检登记号', '船检证书号']);
|
||||
this.fillShipCertificateText(words, 'shipType', ['船舶类型']);
|
||||
break;
|
||||
case 'nationalityCertImage':
|
||||
this.fillShipCertificateDateRange(
|
||||
words,
|
||||
'nationalityCertStartDate',
|
||||
'nationalityCertEndDate',
|
||||
'nationalityCertLongTerm'
|
||||
);
|
||||
break;
|
||||
case 'safeManningCertImage':
|
||||
this.fillShipCertificateDateRange(
|
||||
words,
|
||||
'safeManningCertStartDate',
|
||||
'safeManningCertEndDate',
|
||||
'safeManningCertLongTerm'
|
||||
);
|
||||
break;
|
||||
case 'leaseContractImage':
|
||||
this.fillShipCertificateDate(words, 'leaseStartDate', ['起租日期', '租赁开始日期']);
|
||||
this.fillShipCertificateDate(words, 'leaseEndDate', ['终止日期', '租赁终止日期']);
|
||||
this.fillShipCertificateText(words, 'shipLessee', ['船舶承租人', '承租人']);
|
||||
break;
|
||||
case 'businessTransportCertImage':
|
||||
this.fillShipCertificateText(words, 'businessTransportCertNo', ['证书编号', '运输证号']);
|
||||
this.fillShipCertificateDate(words, 'businessTransportCertIssueDate', ['发证日期']);
|
||||
this.fillShipCertificateDate(words, 'businessTransportCertEndDate', ['有效期至', '有效期限']);
|
||||
this.fillShipCertificateText(words, 'shipOperator', ['船舶经营人', '经营人']);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
},
|
||||
getBaiduOcrWords(data = {}) {
|
||||
const wordsResult = data.words_result || data.wordsResult || {};
|
||||
if (Array.isArray(wordsResult)) {
|
||||
return wordsResult.map(item => item.words || item.value || '').filter(Boolean);
|
||||
}
|
||||
return Object.entries(wordsResult)
|
||||
.flatMap(([key, value]) => [key, typeof value === 'object' ? value.words || value.value || '' : value])
|
||||
.filter(Boolean);
|
||||
},
|
||||
getShipCertificateOcrValue(words = [], labels = []) {
|
||||
const normalizedWords = words.map(word => String(word || '').trim()).filter(Boolean);
|
||||
for (const label of labels) {
|
||||
const labelIndex = normalizedWords.findIndex(word =>
|
||||
new RegExp(`^${label}\\s*[::]?$`).test(word)
|
||||
);
|
||||
if (labelIndex >= 0 && normalizedWords[labelIndex + 1]) {
|
||||
return normalizedWords[labelIndex + 1];
|
||||
}
|
||||
const valueLine = normalizedWords.find(word =>
|
||||
new RegExp(`${label}\\s*[::]?\\s*(.+)$`).test(word)
|
||||
);
|
||||
if (valueLine) {
|
||||
return valueLine.replace(new RegExp(`^.*${label}\\s*[::]?\\s*`), '').trim();
|
||||
}
|
||||
}
|
||||
return '';
|
||||
},
|
||||
fillShipCertificateText(words, prop, labels) {
|
||||
const value = this.getShipCertificateOcrValue(words, labels);
|
||||
if (value) this.shipForm[prop] = value.replace(/\s/g, '');
|
||||
},
|
||||
fillShipCertificateNumber(words, prop, labels) {
|
||||
const value = this.getShipCertificateOcrValue(words, labels);
|
||||
const number = Number(String(value || '').replace(/[^\d.]/g, ''));
|
||||
if (!Number.isNaN(number) && value) this.shipForm[prop] = number;
|
||||
},
|
||||
fillShipCertificateDate(words, prop, labels) {
|
||||
const value = this.getShipCertificateOcrValue(words, labels);
|
||||
const date = this.getShipCertificateDates(value)[0];
|
||||
if (date) this.shipForm[prop] = date;
|
||||
},
|
||||
fillShipCertificateDateRange(words, startProp, endProp, longTermProp) {
|
||||
const text =
|
||||
this.getShipCertificateOcrValue(words, ['证书有效期', '有效期限', '有效期至', '有效期']) ||
|
||||
words.join(' ');
|
||||
if (/(长期|永久)/.test(text)) {
|
||||
this.shipForm[longTermProp] = 1;
|
||||
this.shipForm[startProp] = '';
|
||||
this.shipForm[endProp] = '';
|
||||
return;
|
||||
}
|
||||
const dateList = this.getShipCertificateDates(text);
|
||||
if (dateList[0] && dateList[1]) {
|
||||
this.shipForm[startProp] = dateList[0];
|
||||
this.shipForm[endProp] = dateList[dateList.length - 1];
|
||||
this.shipForm[longTermProp] = 0;
|
||||
}
|
||||
},
|
||||
getShipCertificateDates(value = '') {
|
||||
return (String(value || '').match(/\d{4}[-/.年]\d{1,2}[-/.月]\d{1,2}日?/g) || []).map(
|
||||
date => {
|
||||
const [, year, month, day] = date.match(/(\d{4})[-/.年](\d{1,2})[-/.月](\d{1,2})/) || [];
|
||||
return year ? `${year}-${month.padStart(2, '0')}-${day.padStart(2, '0')}` : '';
|
||||
}
|
||||
);
|
||||
},
|
||||
handleSubmit() {
|
||||
this.$refs.shipForm.validate(valid => {
|
||||
if (!valid) return;
|
||||
|
||||
@@ -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