From eaf431819ef6e5bd2429ed16d62ac52dbbfbbddf Mon Sep 17 00:00:00 2001 From: b2894lxlx <517289602@qq.com> Date: Mon, 2 Nov 2026 13:31:33 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E5=AE=A2=E5=95=86=E6=A1=A3?= =?UTF-8?q?=E6=A1=88=E8=90=A5=E4=B8=9A=E6=89=A7=E7=85=A7OCR=E6=94=B9?= =?UTF-8?q?=E6=8E=A5=E6=96=B0=E6=8E=A5=E5=8F=A3=E5=B9=B6=E5=9B=9E=E5=A1=AB?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- src/api/vehicle/customer-archive.js | 3 +- src/views/vehicle/customer-archive.vue | 57 +++++++++++++++++++++----- 2 files changed, 47 insertions(+), 13 deletions(-) diff --git a/src/api/vehicle/customer-archive.js b/src/api/vehicle/customer-archive.js index 0814c2a..1ccf902 100644 --- a/src/api/vehicle/customer-archive.js +++ b/src/api/vehicle/customer-archive.js @@ -176,12 +176,11 @@ export const syncKingdee = id => { export const recognizeBusinessLicenseOcr = imageUrl => { return request({ - url: '/blade-transport/baidu-ocr/recognize-url', + url: '/blade-transport/baidu-ocr/business-license', method: 'post', timeout: 60000, params: { imageUrl, - type: 'business_license', }, }); }; diff --git a/src/views/vehicle/customer-archive.vue b/src/views/vehicle/customer-archive.vue index 8f02324..1eddbc7 100644 --- a/src/views/vehicle/customer-archive.vue +++ b/src/views/vehicle/customer-archive.vue @@ -3938,7 +3938,7 @@ export default { }); recognizeBusinessLicenseOcr(url) .then(res => { - this.applyBusinessLicenseRecognition(res?.data?.data?.result || {}); + this.applyBusinessLicenseRecognition(res?.data?.data || {}); this.$message.success('营业执照识别完成'); }) .catch(() => { @@ -3946,8 +3946,31 @@ export default { }) .finally(() => loading.close()); }, + normalizeBusinessLicenseOcrFields(result = {}) { + if (Array.isArray(result)) { + return Object.fromEntries( + result + .filter(item => item && item.key) + .map(item => [String(item.key).trim(), String(item.value ?? '').trim()]) + .filter(([, value]) => value) + ); + } + if (result.fields && typeof result.fields === 'object' && !Array.isArray(result.fields)) { + return result.fields; + } + if (Array.isArray(result.data)) { + return this.normalizeBusinessLicenseOcrFields(result.data); + } + return result; + }, getBusinessLicenseOcrValue(result, labels) { - const words = result?.words_result || result?.wordsResult || result || {}; + const fields = this.normalizeBusinessLicenseOcrFields(result); + for (const label of labels) { + const value = fields[label]; + const text = value && typeof value === 'object' ? value.words : value; + if (text !== undefined && text !== null && String(text).trim()) return String(text).trim(); + } + const words = result?.words_result || result?.wordsResult || {}; for (const label of labels) { const value = words[label]; const text = value && typeof value === 'object' ? value.words : value; @@ -3959,23 +3982,35 @@ export default { return String(value || '').replace(/\s/g, '') === '无'; }, applyBusinessLicenseRecognition(result = {}) { - const code = this.getBusinessLicenseOcrValue(result, [ + const fields = this.normalizeBusinessLicenseOcrFields(result); + const code = this.getBusinessLicenseOcrValue(fields, [ + 'uscc', '统一社会信用代码', '社会信用代码', '注册号', ]); - const name = this.getBusinessLicenseOcrValue(result, ['单位名称', '企业名称', '名称']); - const legalPerson = this.getBusinessLicenseOcrValue(result, ['法定代表人', '法人']); - const address = this.getBusinessLicenseOcrValue(result, ['地址', '住所']); - const capital = this.getBusinessLicenseOcrValue(result, ['注册资本']); - const paidInCapital = this.getBusinessLicenseOcrValue(result, ['实缴资本', '实收资本']); - const term = this.getBusinessLicenseOcrValue(result, ['营业期限', '有效期']); - const termStartDate = this.getBusinessLicenseOcrValue(result, [ + const name = this.getBusinessLicenseOcrValue(fields, [ + 'company_name', + '单位名称', + '企业名称', + '名称', + ]); + const legalPerson = this.getBusinessLicenseOcrValue(fields, [ + 'legal_name', + '法定代表人', + '法人', + ]); + const address = this.getBusinessLicenseOcrValue(fields, ['add', '地址', '住所']); + const capital = this.getBusinessLicenseOcrValue(fields, ['capital', '注册资本']); + const paidInCapital = this.getBusinessLicenseOcrValue(fields, ['实缴资本', '实收资本']); + const term = this.getBusinessLicenseOcrValue(fields, ['period', '营业期限', '有效期']); + const termStartDate = this.getBusinessLicenseOcrValue(fields, [ + 'establishment_date', '有效期起始日期', '成立日期', '核准日期', ]); - const scope = this.getBusinessLicenseOcrValue(result, ['经营范围']); + const scope = this.getBusinessLicenseOcrValue(fields, ['经营范围']); if (code) this.archiveForm.unifiedCreditCode = code.replace(/\s/g, '').toUpperCase(); if (name) this.archiveForm.fullName = name; if (name) this.checkArchiveNameRisk();