| | |
| | | <!-- BOM导入对话框 --> |
| | | <ImportDialog ref="uploadRef" v-model="upload.open" :title="upload.title" :action="upload.url" |
| | | :headers="upload.headers" :disabled="upload.isUploading" :on-progress="handleFileUploadProgress" |
| | | :on-success="handleFileSuccess" :show-download-template="true" @confirm="submitFileForm" |
| | | :on-success="handleFileSuccess" :on-error="handleFileError" :show-download-template="true" @confirm="submitFileForm" |
| | | @download-template="handleDownloadTemplate" @close="handleImportClose" /> |
| | | </div> |
| | | </template> |
| | |
| | | }; |
| | | |
| | | // 文件上传成功处理 |
| | | const handleFileSuccess = (response, file, fileList) => { |
| | | const handleFileSuccess = (response, file) => { |
| | | upload.open = false; |
| | | upload.isUploading = false; |
| | | proxy.$refs["uploadRef"].clearFiles(); |
| | |
| | | proxy.$modal.msgSuccess(response.msg || "导入成功"); |
| | | getList(); |
| | | } else { |
| | | proxy.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true }); |
| | | proxy.$modal.msgError(response.msg || "导入失败"); |
| | | } |
| | | }; |
| | | |
| | | // 提交上传文件 |
| | | // 文件上传失败处理 - 后端返回错误文件流 |
| | | const handleFileError = (error, file) => { |
| | | upload.open = false; |
| | | upload.isUploading = false; |
| | | proxy.$refs["uploadRef"].clearFiles(); |
| | | |
| | | // error 可能是 Blob 对象(后端返回的错误文件) |
| | | if (error instanceof Blob) { |
| | | // 下载错误文件 |
| | | const blob = error; |
| | | const downloadElement = document.createElement('a'); |
| | | const href = window.URL.createObjectURL(blob); |
| | | downloadElement.href = href; |
| | | downloadElement.download = "导入错误数据.xlsx"; |
| | | document.body.appendChild(downloadElement); |
| | | downloadElement.click(); |
| | | document.body.removeChild(downloadElement); |
| | | window.URL.revokeObjectURL(href); |
| | | proxy.$modal.msgError("导入失败,请查看下载的错误文件"); |
| | | } else if (error && error.msg) { |
| | | // 后端返回的错误信息 |
| | | proxy.$modal.msgError(error.msg); |
| | | } else { |
| | | // 普通错误 |
| | | proxy.$modal.msgError("导入失败"); |
| | | } |
| | | }; |
| | | |
| | | // 提交上传文件 - 现在由 ImportDialog 内部处理 |
| | | const submitFileForm = () => { |
| | | proxy.$refs["uploadRef"].submit(); |
| | | // ImportDialog 的 handleConfirm 会调用 uploadRef.value.submit() |
| | | // 这里不需要额外操作 |
| | | }; |
| | | |
| | | // 导出按钮操作 |