From 00374f285b4fb7396fa171f9d35a93b048e348a2 Mon Sep 17 00:00:00 2001 From: Mrx <18278715334@163.com> Date: Tue, 17 Mar 2026 18:30:23 +0800 Subject: [PATCH] f --- .../components/EnterpriseInfo.vue | 64 +++++++++++++++---- 1 file changed, 50 insertions(+), 14 deletions(-) diff --git a/src/pages/certification/components/EnterpriseInfo.vue b/src/pages/certification/components/EnterpriseInfo.vue index 7b876ce..c6de9c4 100644 --- a/src/pages/certification/components/EnterpriseInfo.vue +++ b/src/pages/certification/components/EnterpriseInfo.vue @@ -123,7 +123,7 @@
- 请在非 IE 浏览器下上传大小不超过 3M 的图片,最多 10 张,需体现门楣 LOGO、办公设备与工作人员。 + 请在非 IE 浏览器下上传大小不超过 1M 的图片,最多 10 张,需体现门楣 LOGO、办公设备与工作人员。
- 请在非IE浏览器下上传大小不超过3M的图片,要求:不超过10张后台应用截图 + 请在非 IE 浏览器下上传大小不超过 1M 的图片,最多 10 张后台应用截图。
{ const beforeUpload = (file) => { const allowedTypes = ['image/jpeg', 'image/jpg', 'image/png', 'image/webp'] const isValidType = allowedTypes.includes(file.type) - const isValidSize = file.size / 1024 / 1024 < 5 + const maxSizeMB = 1 + const isValidSize = file.size / 1024 / 1024 < maxSizeMB if (!isValidType) { ElMessage.error('只支持 JPG、PNG、WEBP 格式的图片') return false } if (!isValidSize) { - ElMessage.error('图片大小不能超过 5MB') + ElMessage.error(`图片大小不能超过 ${maxSizeMB}MB`) return false } return true @@ -692,6 +693,25 @@ const uploadFileToServer = async (file) => { return res.data.url } +// 选择后立即上传:对 el-upload 的 file 对象上传并更新 url/status,不更新表单(由调用方更新) +const uploadFileOnceSelected = async (file) => { + if (!file?.raw) return null + if (file.url && !isBlobUrl(file.url)) return file.url // 已是服务器 URL,不重复上传 + file.status = 'uploading' + try { + const url = await uploadFileToServer(file.raw) + file.url = url + file.status = 'success' + if (file.response === undefined) file.response = {} + file.response.url = url + return url + } catch (err) { + file.status = 'fail' + ElMessage.error(err?.message || '图片上传失败') + return null + } +} + // 提交前将 blob 图片全部上传到七牛云,并更新表单中的 URL const uploadAllBlobFilesAndFillForm = async () => { const tasks = [] @@ -753,15 +773,19 @@ const extractUrls = (fileList) => { .filter(Boolean) } -// 营业执照图片变更(同时触发 OCR 识别) +// 营业执照图片变更:先 OCR 识别,再选择即上传 const handleBusinessLicenseChange = async (file, fileList) => { businessLicenseFileList.value = fileList const urls = extractUrls(fileList) form.value.businessLicenseImageURL = urls[0] || '' - // 使用当前选择的营业执照图片触发 OCR 识别 if (file && file.raw) { await handleFileChange(file) + // OCR 若未返回服务器 URL,则选择后立即上传 + if (isBlobUrl(form.value.businessLicenseImageURL)) { + const url = await uploadFileOnceSelected(file) + if (url) form.value.businessLicenseImageURL = url + } } } @@ -777,9 +801,12 @@ const clearBusinessLicense = () => { form.value.businessLicenseImageURL = '' } -// 授权代表身份证人像面图片变更 -const handleAuthorizedRepIDFrontChange = (file, fileList) => { +// 授权代表身份证人像面图片变更:选择即上传 +const handleAuthorizedRepIDFrontChange = async (file, fileList) => { authorizedRepIDFrontFileList.value = fileList + if (file?.raw && isBlobUrl(file.url)) { + await uploadFileOnceSelected(file) + } updateAuthorizedRepIDImageURLs() } @@ -788,9 +815,12 @@ const handleAuthorizedRepIDFrontRemove = (file, fileList) => { updateAuthorizedRepIDImageURLs() } -// 授权代表身份证国徽面图片变更 -const handleAuthorizedRepIDBackChange = (file, fileList) => { +// 授权代表身份证国徽面图片变更:选择即上传 +const handleAuthorizedRepIDBackChange = async (file, fileList) => { authorizedRepIDBackFileList.value = fileList + if (file?.raw && isBlobUrl(file.url)) { + await uploadFileOnceSelected(file) + } updateAuthorizedRepIDImageURLs() } @@ -859,9 +889,12 @@ const onScenarioDrop = (e) => { if (files.length > remain && remain > 0) ElMessage.warning(`最多上传 ${limit} 张,已忽略多余文件`) } -// 办公场地图片变更 -const handleOfficePlaceChange = (file, fileList) => { +// 办公场地图片变更:选择即上传 +const handleOfficePlaceChange = async (file, fileList) => { officePlaceFileList.value = fileList + if (file?.raw && isBlobUrl(file.url)) { + await uploadFileOnceSelected(file) + } form.value.officePlaceImageURLs = extractUrls(fileList) } @@ -870,9 +903,12 @@ const handleOfficePlaceRemove = (file, fileList) => { form.value.officePlaceImageURLs = extractUrls(fileList) } -// 应用场景附件图片变更 -const handleScenarioChange = (file, fileList) => { +// 应用场景附件图片变更:选择即上传 +const handleScenarioChange = async (file, fileList) => { scenarioFileList.value = fileList + if (file?.raw && isBlobUrl(file.url)) { + await uploadFileOnceSelected(file) + } form.value.scenarioAttachmentURLs = extractUrls(fileList) }