zouyu
2023-11-20 87bea556df452a4f44ddb4e56dd3bf6b676cce11
src/views/quality/exception/exception.vue
@@ -31,8 +31,8 @@
            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"
@@ -41,7 +41,7 @@
          >
            <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>
@@ -320,10 +320,22 @@
        })
      }
    },
    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