This commit is contained in:
Mrx
2026-03-17 18:30:23 +08:00
parent 792f8d6abe
commit 00374f285b

View File

@@ -123,7 +123,7 @@
<el-col :span="24"> <el-col :span="24">
<el-form-item label="办公场地照片"> <el-form-item label="办公场地照片">
<div class="text-xs mb-1 text-blue-500"> <div class="text-xs mb-1 text-blue-500">
请在非 IE 浏览器下上传大小不超过 3M 的图片最多 10 需体现门楣 LOGO办公设备与工作人员 请在非 IE 浏览器下上传大小不超过 1M 的图片最多 10 需体现门楣 LOGO办公设备与工作人员
</div> </div>
<div <div
class="upload-drop-zone" class="upload-drop-zone"
@@ -317,7 +317,7 @@
<el-form-item label="应用场景附件"> <el-form-item label="应用场景附件">
<div class="text-xs mb-1 text-blue-500"> <div class="text-xs mb-1 text-blue-500">
请在非IE浏览器下上传大小不超过3M的图片要求:不超过10张后台应用截图 请在非 IE 浏览器下上传大小不超过 1M 的图片最多 10 张后台应用截图
</div> </div>
<div <div
class="upload-drop-zone" class="upload-drop-zone"
@@ -625,14 +625,15 @@ const startCountdown = () => {
const beforeUpload = (file) => { const beforeUpload = (file) => {
const allowedTypes = ['image/jpeg', 'image/jpg', 'image/png', 'image/webp'] const allowedTypes = ['image/jpeg', 'image/jpg', 'image/png', 'image/webp']
const isValidType = allowedTypes.includes(file.type) 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) { if (!isValidType) {
ElMessage.error('只支持 JPG、PNG、WEBP 格式的图片') ElMessage.error('只支持 JPG、PNG、WEBP 格式的图片')
return false return false
} }
if (!isValidSize) { if (!isValidSize) {
ElMessage.error('图片大小不能超过 5MB') ElMessage.error(`图片大小不能超过 ${maxSizeMB}MB`)
return false return false
} }
return true return true
@@ -692,6 +693,25 @@ const uploadFileToServer = async (file) => {
return res.data.url 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 // 提交前将 blob 图片全部上传到七牛云,并更新表单中的 URL
const uploadAllBlobFilesAndFillForm = async () => { const uploadAllBlobFilesAndFillForm = async () => {
const tasks = [] const tasks = []
@@ -753,15 +773,19 @@ const extractUrls = (fileList) => {
.filter(Boolean) .filter(Boolean)
} }
// 营业执照图片变更(同时触发 OCR 识别 // 营业执照图片变更:先 OCR 识别,再选择即上传
const handleBusinessLicenseChange = async (file, fileList) => { const handleBusinessLicenseChange = async (file, fileList) => {
businessLicenseFileList.value = fileList businessLicenseFileList.value = fileList
const urls = extractUrls(fileList) const urls = extractUrls(fileList)
form.value.businessLicenseImageURL = urls[0] || '' form.value.businessLicenseImageURL = urls[0] || ''
// 使用当前选择的营业执照图片触发 OCR 识别
if (file && file.raw) { if (file && file.raw) {
await handleFileChange(file) 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 = '' form.value.businessLicenseImageURL = ''
} }
// 授权代表身份证人像面图片变更 // 授权代表身份证人像面图片变更:选择即上传
const handleAuthorizedRepIDFrontChange = (file, fileList) => { const handleAuthorizedRepIDFrontChange = async (file, fileList) => {
authorizedRepIDFrontFileList.value = fileList authorizedRepIDFrontFileList.value = fileList
if (file?.raw && isBlobUrl(file.url)) {
await uploadFileOnceSelected(file)
}
updateAuthorizedRepIDImageURLs() updateAuthorizedRepIDImageURLs()
} }
@@ -788,9 +815,12 @@ const handleAuthorizedRepIDFrontRemove = (file, fileList) => {
updateAuthorizedRepIDImageURLs() updateAuthorizedRepIDImageURLs()
} }
// 授权代表身份证国徽面图片变更 // 授权代表身份证国徽面图片变更:选择即上传
const handleAuthorizedRepIDBackChange = (file, fileList) => { const handleAuthorizedRepIDBackChange = async (file, fileList) => {
authorizedRepIDBackFileList.value = fileList authorizedRepIDBackFileList.value = fileList
if (file?.raw && isBlobUrl(file.url)) {
await uploadFileOnceSelected(file)
}
updateAuthorizedRepIDImageURLs() updateAuthorizedRepIDImageURLs()
} }
@@ -859,9 +889,12 @@ const onScenarioDrop = (e) => {
if (files.length > remain && remain > 0) ElMessage.warning(`最多上传 ${limit} 张,已忽略多余文件`) if (files.length > remain && remain > 0) ElMessage.warning(`最多上传 ${limit} 张,已忽略多余文件`)
} }
// 办公场地图片变更 // 办公场地图片变更:选择即上传
const handleOfficePlaceChange = (file, fileList) => { const handleOfficePlaceChange = async (file, fileList) => {
officePlaceFileList.value = fileList officePlaceFileList.value = fileList
if (file?.raw && isBlobUrl(file.url)) {
await uploadFileOnceSelected(file)
}
form.value.officePlaceImageURLs = extractUrls(fileList) form.value.officePlaceImageURLs = extractUrls(fileList)
} }
@@ -870,9 +903,12 @@ const handleOfficePlaceRemove = (file, fileList) => {
form.value.officePlaceImageURLs = extractUrls(fileList) form.value.officePlaceImageURLs = extractUrls(fileList)
} }
// 应用场景附件图片变更 // 应用场景附件图片变更:选择即上传
const handleScenarioChange = (file, fileList) => { const handleScenarioChange = async (file, fileList) => {
scenarioFileList.value = fileList scenarioFileList.value = fileList
if (file?.raw && isBlobUrl(file.url)) {
await uploadFileOnceSelected(file)
}
form.value.scenarioAttachmentURLs = extractUrls(fileList) form.value.scenarioAttachmentURLs = extractUrls(fileList)
} }