提交
This commit is contained in:
1 parent
87f7f6bf38
commit
5c6ace1dd3
4683 files changed
+1149971
-33842
No files matched your search
@@ -97,8 +97,17 @@
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" min-width="60" align="center" header-align="center">
|
||||
<el-table-column label="操作" min-width="160" align="center" header-align="center" fixed="right">
|
||||
<template #default="{ row, $index }">
|
||||
<el-button
|
||||
v-if="canOcrRecognize(row)"
|
||||
link
|
||||
type="primary"
|
||||
:loading="ocrLoadingKey === row._key"
|
||||
@click="handleOcrRecognize(row)"
|
||||
>
|
||||
<el-icon><MagicStick /></el-icon>自动识别
|
||||
</el-button>
|
||||
<el-button v-if="!isRowRequired(row)" link type="danger" @click="handleRemoveCert($index)">
|
||||
<el-icon><Delete /></el-icon>
|
||||
</el-button>
|
||||
@@ -112,9 +121,20 @@
|
||||
<span class="cert-card-index">
|
||||
{{ isRowRequired(cert) ? `必备 · ${cert.certName}` : `证书 ${index + 1}` }}
|
||||
</span>
|
||||
<el-button v-if="!isRowRequired(cert)" link type="danger" @click="handleRemoveCert(index)">
|
||||
<el-icon><Delete /></el-icon>删除
|
||||
</el-button>
|
||||
<div class="cert-card-head-actions">
|
||||
<el-button
|
||||
v-if="canOcrRecognize(cert)"
|
||||
link
|
||||
type="primary"
|
||||
:loading="ocrLoadingKey === cert._key"
|
||||
@click="handleOcrRecognize(cert)"
|
||||
>
|
||||
<el-icon><MagicStick /></el-icon>自动识别
|
||||
</el-button>
|
||||
<el-button v-if="!isRowRequired(cert)" link type="danger" @click="handleRemoveCert(index)">
|
||||
<el-icon><Delete /></el-icon>删除
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-grid-4 cert-card-grid">
|
||||
@@ -166,9 +186,10 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Delete, Plus } from '@element-plus/icons-vue'
|
||||
import { Delete, MagicStick, Plus } from '@element-plus/icons-vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import AttachmentUploadField from '@/components/business/attachment-upload-field/index.vue'
|
||||
import type { CertRow } from '@/api/pl'
|
||||
import { personnelCertOcrApi, type CertRow } from '@/api/pl'
|
||||
import {
|
||||
ensureCarrierVehicleCertSlots,
|
||||
ensureSelfVehicleCertSlots,
|
||||
@@ -317,6 +338,60 @@ function getCertRowClassName({ row }: { row: CertRowWithKey }) {
|
||||
|
||||
const certList = defineModel<CertRowWithKey[]>('modelValue', { default: () => [] })
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'id-card-recognized', certNo: string): void
|
||||
}>()
|
||||
|
||||
const OCR_CERT_NAMES = new Set(['身份证', '驾驶证', '行驶证'])
|
||||
const ocrLoadingKey = ref('')
|
||||
|
||||
function hasAttachment(row: CertRowWithKey) {
|
||||
return Boolean((row.attachmentUrls || '').split(',').some(s => s.trim()))
|
||||
}
|
||||
|
||||
function canOcrRecognize(row: CertRowWithKey) {
|
||||
return OCR_CERT_NAMES.has((row.certName || '').trim()) && hasAttachment(row)
|
||||
}
|
||||
|
||||
async function handleOcrRecognize(row: CertRowWithKey) {
|
||||
const certName = (row.certName || '').trim()
|
||||
if (!OCR_CERT_NAMES.has(certName)) {
|
||||
ElMessage.warning('仅支持身份证、驾驶证、行驶证自动识别')
|
||||
return
|
||||
}
|
||||
if (!hasAttachment(row)) {
|
||||
ElMessage.warning('请先上传证书附件')
|
||||
return
|
||||
}
|
||||
ocrLoadingKey.value = row._key
|
||||
try {
|
||||
const raw = await personnelCertOcrApi.recognize({
|
||||
certName,
|
||||
attachmentUrls: row.attachmentUrls || ''
|
||||
})
|
||||
const res = ((raw as any)?.data ?? raw) as {
|
||||
certNo?: string | null
|
||||
expireDate?: string | null
|
||||
}
|
||||
if (res?.certNo) {
|
||||
row.certNo = res.certNo
|
||||
}
|
||||
if (res?.expireDate) {
|
||||
row.expireDate = res.expireDate
|
||||
} else if (res?.certNo && !res?.expireDate) {
|
||||
ElMessage.warning('未识别到有效期,请手工填写')
|
||||
}
|
||||
if (certName === '身份证' && res?.certNo) {
|
||||
emit('id-card-recognized', res.certNo)
|
||||
}
|
||||
ElMessage.success('识别成功')
|
||||
} catch {
|
||||
// 错误提示由 bx HTTP 拦截器统一弹出
|
||||
} finally {
|
||||
ocrLoadingKey.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() =>
|
||||
[
|
||||
@@ -476,6 +551,12 @@ defineExpose({ hasUploading, clearUploadRefs, refreshRequiredSlots })
|
||||
border-bottom: 1px solid #eef2f6;
|
||||
}
|
||||
|
||||
.cert-card-head-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.cert-card-index {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
|
||||
Reference in new issue
Block a user