Browse Source

fix:上传图片限制问题

main
buaixuexideshitongxue 1 month ago
parent
commit
3268317dcf
  1. 22
      src/components/file/upload.vue
  2. 2
      src/views/report/edit/controlPrice.vue

22
src/components/file/upload.vue

@ -73,17 +73,27 @@ watch(files, () => {
},{immediate:true});
function beforeUpload(file) {
const allowExt = ['doc', 'docx', 'pdf', 'xls', 'xlsx', 'zjxm', 'dwg', 'dwl', 'dwl2', 'pks6']
const name = (file?.name || '').toLowerCase()
const ext = name.includes('.') ? name.split('.').pop() : ''
if (!allowExt.includes(ext)) {
feedback.msgWarning(
'只能上传 Word / PDF / Excel / ZJXM /DWG /DWL /DWL2 /PKS6 文件(.doc .docx .pdf .xls .xlsx .ZJXM .DWG .DWL .DWL2 .PKS6)'
)
//
const imageExts = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'svg', 'tiff', 'tif', 'ico', 'heic', 'heif']
//
const archiveExts = ['zip', 'rar', '7z', 'tar', 'gz', 'bz2', 'xz', 'iso', 'dmg']
// PDF
if (imageExts.includes(ext)) {
feedback.msgWarning('图片文件请转为 PDF 后再上传')
return false
}
// 1024 * 1024 * 100 100MB
//
if (archiveExts.includes(ext)) {
feedback.msgWarning('暂不支持压缩包上传')
return false
}
// 100MB
if (file.size >= 104857600) {
feedback.msgError('文件大小不能超过100MB');
return false;

2
src/views/report/edit/controlPrice.vue

@ -1426,7 +1426,6 @@ function hasAuditAttachment() {
<file-upload v-model:files="fileTable.fileData" :uploadDrag="true" ></file-upload>
</el-col>
</el-row>
<p style="color: red;">说明附件上传仅支持 上传 Word / PDF / Excel / ZJXM /DWG /DWL /DWL2 /PKS6 文件.doc .docx .pdf .xls .xlsx .ZJXM .DWG .DWL .DWL2 .PKS6</p>
<footer class="flex end">
<el-button size="default" :loading="addFileTableLoading" type="primary" @click="addFileSubmit">确认</el-button>
<el-button @click="addFileDialog = false" >关闭</el-button>
@ -1466,7 +1465,6 @@ function hasAuditAttachment() {
<el-dialog v-model="upFileDialog" title="材料上传" destroy-on-close>
<file-upload v-model:files="formData.files[activeName][fileIndex].fileData" :uploadDrag="true" ></file-upload>
<p style="color: red;">说明附件上传仅支持 上传 Word / PDF / Excel / ZJXM /DWG /DWL /DWL2 /PKS6 文件.doc .docx .pdf .xls .xlsx .ZJXM .DWG .DWL .DWL2 .PKS6</p>
<footer class="flex end">
<el-button type="primary" @click="upFileDialog = false" size="large">确认</el-button>
<el-button @click="upFileDialog = false" size="large">关闭</el-button>

Loading…
Cancel
Save