<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; } },
|