| | |
| | | action="/mes/exception/upload" |
| | | :headers="headers" |
| | | :before-upload="submitUpload" |
| | | :on-preview="handlePreview" |
| | | :on-remove="handleRemove" |
| | | :on-preview="handlePreview" |
| | | :on-success="uploadSuccess" |
| | | :data="paramData" |
| | | :file-list="fileList" |
| | |
| | | > |
| | | <el-button size="small" type="primary">点击上传</el-button> |
| | | <div slot="tip" class="el-upload__tip"> |
| | | 只能上传jpg图片,且不超过2MB |
| | | 只能上传jpg/png图片,且不超过5MB |
| | | </div> |
| | | </el-upload> |
| | | </el-col> |
| | |
| | | @refreshDataList="getData" |
| | | ></table-form> |
| | | </div> |
| | | <el-dialog title="图片预览" width="60%" :visible.sync="previewVisible" top="5vh"> |
| | | <img style="width:100%;height: 70vh" :src="dialogImageUrl" alt=""> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | <style lang="scss" scoped> |
| | |
| | | }, |
| | | data() { |
| | | return { |
| | | previewVisible: false, |
| | | dialogImageUrl: null, |
| | | fileList: [], |
| | | headers: { |
| | | Authorization: 'Bearer ' + getStore({ name: 'access_token' }) |
| | |
| | | } |
| | | }, |
| | | handlePreview(file) { |
| | | window.open(file.url) |
| | | this.previewVisible = true |
| | | }, |
| | | uploadSuccess(response, file, fileList) { |
| | | this.getFileList() |
| | |
| | | fileEl = {} |
| | | fileEl.name = attachment.original |
| | | fileEl.url = attachment.url |
| | | this.dialogImageUrl = attachment.url |
| | | fileEl.id = attachment.id |
| | | fileEl.fileName = attachment.fileName |
| | | this.fileList.push(fileEl) |
| | |
| | | }) |
| | | } |
| | | }, |
| | | submitUpload() { |
| | | submitUpload(file) { |
| | | console.info(this.currentRow && this.currentRow.id) |
| | | console.log(file); |
| | | if (this.currentRow && this.currentRow.id) { |
| | | const maxSize = 5 * 1024 *1024 |
| | | let jpgType = 'image/jpeg' |
| | | let pngType = 'image/png' |
| | | if(file.type != jpgType && file.type != pngType){ |
| | | this.$message.error('只能上传.jpg/.png类型的图片') |
| | | return false |
| | | } |
| | | if(file.szie > maxSize){ |
| | | this.$message.error('图片大小不能超过5MB') |
| | | } |
| | | this.paramData.exceptionId = this.currentRow.id |
| | | |
| | | } else { |
| | | this.$message.error('请先选择生产异常记录') |
| | | return false |