分享

成功可编辑el-table使用el- upload上传文件

 北方天空A 2020-10-13

 <el-table-column prop="PdfFilePath" label="PDF文件" align="center">
          <template scope="scope">
            <el-upload
              class="upload-demo"
              action="http://172.16.90.244:12345/api/GeneTestResults/upload"
              accept=".pdf"
              multiple
              :limit="1"
              :on-exceed="handleExceed"
              size="mini"
              :on-remove="
                function (file, fileList) {
                  return handleRemove(file, fileList, scope.$index);
                }
              "
              :on-success="
                function (res, file, fileList) {
                  return handleSuccess(res, file, fileList, scope.$index);
                }
              "
              :file-list="fileList[scope.$index]"
            >
               
              <el-button size="small" type="text">上传文件</el-button>
              <div slot="tip" class="el-upload__tip">
                只能上传pdf文件,且不超过10M
              </div>
            </el-upload>
            <el-input v-model="scope.row.PdfFilePath" disabled="true" />
          </template>
        </el-table-column>
export default {
  filters: {},
  data() {
    return {
      ListGeneTestResults: [],
      fileList:[],
    };
  },
 
  methods: {
    handleExceed(files, fileList) {
      this.$message.warning(
        `当前限制选择1 个文件,本次选择了 ${files.length} 个文件,共选择了 ${
          files.length + fileList.length
        } 个文件`
      );
    },
     // 删除文件
    handleRemove (file, fileList, index) {
      this.ListGeneTestResults[index].file = ''
    },

    // 文件上传
    handleSuccess (res, file, fileList, index) {
      if (res.Code ==0) {
        this.ListGeneTestResults[index].PdfFilePath = "/UploadFile/" + file.name;
      }
    },

    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多