fzq #31

Closed
fanzhiqin wants to merge 215 commits from fzq into test
2 changed files with 29 additions and 16 deletions
Showing only changes of commit 566c900a24 - Show all commits

View File

@ -8,8 +8,10 @@
:file-list="fileList"
:on-preview="handleDownload"
:on-remove="handleRemove"
:before-upload="/.*?image.*?/i.test(extraParams.typeCode) ? validateImage : validateFile"
:before-remove="beforeRemove"
>
<!-- accept="image/*" -->
<!-- <el-upload class="yd-upload" :action="$http.adornUrl(url)" multiple name="files" :data="extraParams" :file-list="fileList" :on-remove="handleRemove" :before-remove="beforeRemove"> -->
<el-button size="small" type="primary">{{ buttonContent }}</el-button>
<div v-if="tip" slot="tip" class="el-upload__tip">{{ tip }}</div>
@ -93,17 +95,36 @@ export default {
})
},
/** 大小验证 */
/** 大小验证,由配置文件开启 */
validateFile(file) {
this.extraUploadParams.typeCode = 'equipmentInfoFile'
console.log("[*] 验证文件大小")
const isRightSize = file.size / 1024 / 1024 < 10
const isRightSize = file.size / 1024 / 1024 < 2
if (!isRightSize) {
this.$message.error(this.$t('upload.picSizeAlarm'))
// this.$message.error(this.$t('upload.picSizeAlarm'))
this.$message.error('文件不应超过 2MB')
}
return isRightSize
},
/** 图片验证,由配置文件开启 */
validateImage(file) {
console.log("[*] 验证图片")
const isRightSize = file.size / 1024 / 1024 < 2
if (!isRightSize) {
this.$message.error('文件不应超过 2MB')
// this.$message.error(this.$t('upload.picSizeAlarm'))
}
const isAccept = new RegExp('image/*').test(file.type)
if (!isAccept) {
// this.$message.error(this.$t('upload.picAlarm'))
this.$message.error('只允许上传图片')
}
return isRightSize && isAccept
},
/** 点击下载 */
handleDownload({ id: fileId, name: fileName }) {
const type = {
@ -142,9 +163,9 @@ export default {
})
},
beforeRemove(file, filelist) {
return this.$confirm(`确定移除 ${file.name}?`)
},
// beforeRemove(file, filelist) {
// return this.$confirm(` ${file.name}?`)
// },
handleRemove(file, filelist) {
// fileList

View File

@ -114,10 +114,6 @@ const addOrUpdateConfigs = {
extraParams: { typeCode: 'EquipmentInfoFile' },
buttonContent: '点击上传',
tip: '上传文件大小不要超过 2mb (2048kb)'
},
validators: {
size: () => {}, //
image: () => {} //
}
},
{
@ -130,11 +126,7 @@ const addOrUpdateConfigs = {
url: '/monitoring/attachment/uploadFileFormData',
extraParams: { typeCode: 'EquipmentInfoImage' },
buttonContent: '点击上传',
tip: '上传文件大小不要超过 2mb (2048kb)'
},
validators: {
size: () => {}, //
image: () => {} //
tip: '上传图片文件,且大小不要超过 2mb (2048kb)'
}
}
],