fei
1 天以前 d195776f9d23f7c79a049ccececdf674853eadb7
src/views/archiveManager/archiveMaterial/index.vue
@@ -239,12 +239,14 @@
      :on-preview="handlePreview"
      :on-remove="handleRemove"
      :file-list="fileList"
        :on-change="handleFileChange"
      :auto-upload="false"
      multiple
      accept=".jpg,.png"
    >
      <el-button slot="trigger" size="small" type="primary">选择文件</el-button>
      <el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload">上传到服务器</el-button>
      <el-button style="margin-left: 10px;" size="small" type="danger" @click="clearFileList">清空列表</el-button>
      <div slot="tip" class="el-upload__tip">可上传JPG等格式文件,单个文件不超过50MB</div>
    </el-upload>
  </el-dialog>
@@ -883,9 +885,29 @@
    handlePreview(file) {
      console.log(file)
    },
     handleFileChange(file, fileList) {
    console.log('当前文件列表:', fileList);
    this.fileList = fileList;
  },
    // 提交上传
    submitUpload() {
      // 获取当前选择的文件数量
      const fileCount = this.fileList.length
      if (fileCount === 0) {
        this.$modal.msgWarning('请先选择文件再上传')
        return
      }
      if(fileCount!==this.total)
      {
        this.$modal.msgWarning('请选择与记录数一致的文件')
        return
      }
      // 执行上传
      this.$refs.upload.submit()
    },
    clearFileList() {
      this.fileList = [];
      this.$modal.msgSuccess('已清空上传列表');
    },
          handleKeyDown(e) {
      // 在keydown事件中更早地阻止默认行为
@@ -1086,8 +1108,8 @@
  // }
  const formData = new FormData();
  formData.append('file', file);
  formData.append('recordId', this.recordId)
  alert(this.recordId)
 // formData.append('recordId', this.recordId)
  // alert(this.recordId)
  console.log(file)
  // 显示加载中状态