diff --git a/src/views/modules/worklog/icworklog-add-or-update.vue b/src/views/modules/worklog/icworklog-add-or-update.vue index e3b72f34d..7160f2c66 100644 --- a/src/views/modules/worklog/icworklog-add-or-update.vue +++ b/src/views/modules/worklog/icworklog-add-or-update.vue @@ -42,12 +42,12 @@ - + - @@ -55,7 +55,7 @@ :action="uploadUlr" accept=".jpg,.png,.jpeg,.bmp" :on-success="handleFileSuccess" - :on-remove="handleFileRemove" + :on-remov·e="handleFileRemove" :on-preview="handleFileDownload" :limit="3" :before-upload="beforeUpload" @@ -66,7 +66,26 @@ 支持jpg、png、bmp - + --> + + + + 选择图片 + 最多上传3张图片,图片支持jpg、jpeg、bmp、git或png格式 + + {{ $t('cancel') }} @@ -96,8 +115,10 @@ export default { content: '', remark: '', mobile: '', - fileList: [] - } + fileList: [], + // imageList: [],// 图片集合 + }, + hideUploadBtn: false } }, created () { @@ -184,68 +205,118 @@ export default { return this.$message.error('网络错误') }) }, - beforeUpload (file) { - const array = file.name.split('.') - const extension = array[array.length - 1] + // beforeUpload (file) { + // const array = file.name.split('.') + // const extension = array[array.length - 1] - const formatarray = ['jpg', 'png', 'jpeg', 'bmp'] + // const formatarray = ['jpg', 'png', 'jpeg', 'bmp'] - if (formatarray.indexOf(extension) === -1) { - this.$message.error('只支持图片、word、pdf') - return false - } + // if (formatarray.indexOf(extension) === -1) { + // this.$message.error('只支持图片、word、pdf') + // return false + // } - }, + // }, + + // handleFileRemove (file) { - handleFileRemove (file) { + // if (file && file.status === "success") { + // this.dataForm.fileList.splice(this.dataForm.fileList.findIndex(item => item.uid === file.uid), 1) + // } + // }, + + // handleFileSuccess (res, file) { + + // if (res.code === 0 && res.msg === 'success') { + // const array = file.name.split('.') + // const fileType = array[array.length - 1] + + // const picArray = ['jpg', 'png', 'jpeg', 'bmp'] + // const videoarray = ['mp4', 'wma', 'm4a'] + // const docArray = ['doc', 'docx', 'xls', 'xlsx', 'pdf'] + // const mp3Array = ['mp3'] + + // if (picArray.indexOf(fileType) > -1) { + // file.attachmentFormat = 'image' + // } else if (videoarray.indexOf(fileType) > -1) { + // file.attachmentFormat = 'video' + // } else if (docArray.indexOf(fileType) > -1) { + // file.attachmentFormat = 'doc' + // } else if (mp3Array.indexOf(fileType) > -1) { + // file.attachmentFormat = 'voice' + // } + + // file.url = res.data.url + // file.type = fileType + + // file.fileName = file.name + // file.fileType = file.type + + // this.dataForm.fileList.push(file) + // console.log(this.dataForm.fileList) + // } else this.$message.error(res.msg) + // }, + //下载 + // handleFileDownload (file) { + // var a = document.createElement('a'); + // var event = new MouseEvent('click'); + // a.download = file.name; + // console.log(a) + // a.href = file.url; + // a.dispatchEvent(event); + + + // }, + + exceedPic () { + this.$message.warning("最多上传3张预览图片") + + }, + removePic (file, fileList) { + + // this.formData.imageList.splice(this.formData.imageList.findIndex(item => item === file.url), 1) if (file && file.status === "success") { this.dataForm.fileList.splice(this.dataForm.fileList.findIndex(item => item.uid === file.uid), 1) } - }, - - handleFileSuccess (res, file) { + this.hideUploadBtn = fileList.length >= 3; + }, + handleSuccess (res, file) { if (res.code === 0 && res.msg === 'success') { - const array = file.name.split('.') - const fileType = array[array.length - 1] - - const picArray = ['jpg', 'png', 'jpeg', 'bmp'] - const videoarray = ['mp4', 'wma', 'm4a'] - const docArray = ['doc', 'docx', 'xls', 'xlsx', 'pdf'] - const mp3Array = ['mp3'] - - if (picArray.indexOf(fileType) > -1) { - file.attachmentFormat = 'image' - } else if (videoarray.indexOf(fileType) > -1) { - file.attachmentFormat = 'video' - } else if (docArray.indexOf(fileType) > -1) { - file.attachmentFormat = 'doc' - } else if (mp3Array.indexOf(fileType) > -1) { - file.attachmentFormat = 'voice' - } + const array = file.name.split('.') + const fileType = array[array.length - 1] - file.url = res.data.url - file.type = fileType + const picArray = ['jpg', 'png', 'jpeg', 'bmp'] + const videoarray = ['mp4', 'wma', 'm4a'] + const docArray = ['doc', 'docx', 'xls', 'xlsx', 'pdf'] + const mp3Array = ['mp3'] - file.fileName = file.name - file.fileType = file.type + if (picArray.indexOf(fileType) > -1) { + file.attachmentFormat = 'image' + } else if (videoarray.indexOf(fileType) > -1) { + file.attachmentFormat = 'video' + } else if (docArray.indexOf(fileType) > -1) { + file.attachmentFormat = 'doc' + } else if (mp3Array.indexOf(fileType) > -1) { + file.attachmentFormat = 'voice' + } - this.dataForm.fileList.push(file) - console.log(this.dataForm.fileList) - } else this.$message.error(res.msg) - }, - //下载 - handleFileDownload (file) { + file.url = res.data.url + file.type = fileType + + file.fileName = file.name + file.fileType = file.type - var a = document.createElement('a'); - var event = new MouseEvent('click'); - a.download = file.name; - console.log(a) - a.href = file.url; - a.dispatchEvent(event); + this.dataForm.fileList.push(file) + console.log(this.dataForm.fileList) + } else this.$message.error(res.msg) + }, + // 最多上传3张图,超过时隐藏上传按钮 + handleEditChange (file, fileList) { + this.hideUploadBtn = fileList.length >= 3; }, // 表单提交 dataFormSubmitHandle: debounce(function () {