| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <div style="text-align: right; margin-bottom: 10px;"> |
| | | <el-button type="primary" @click="handleAdd">新增</el-button> |
| | | <el-button type="info" plain icon="Upload" @click="handleImport" |
| | | v-hasPermi="['product:bom:import']">导入</el-button> |
| | | <el-button type="warning" plain icon="Download" @click="handleExport" :disabled="selectedRows.length !== 1" |
| | | v-hasPermi="['product:bom:export']">导出</el-button> |
| | | <el-button type="primary" @click="handleAdd">新增</el-button> |
| | | <el-button type="danger" plain @click="handleBatchDelete" :disabled="selectedRows.length === 0">删除</el-button> |
| | | </div> |
| | | <PIMTable rowKey="id" :column="tableColumn" :tableData="tableData" :page="page" :isSelection="true" |
| | |
| | | </el-form-item> |
| | | </el-form> |
| | | <template #footer> |
| | | <el-button type="primary" @click="handleSubmit">确定</el-button> |
| | | <el-button @click="closeDialog">取消</el-button> |
| | | <el-button type="primary" @click="handleSubmit">确定</el-button> |
| | | </template> |
| | | </el-dialog> |
| | | |
| | |
| | | <!-- 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> |
| | |
| | | |
| | | minWidth: 160 |
| | | }, |
| | | { |
| | | label: "规格型号", |
| | | prop: "productModelName", |
| | | minWidth: 140 |
| | | }, |
| | | { |
| | | label: "图纸编号", |
| | | prop: "productModelName", |
| | | minWidth: 140 |
| | | }, |
| | | { |
| | | label: "版本号", |
| | | prop: "version", |
| | |
| | | }; |
| | | |
| | | // 文件上传成功处理 |
| | | 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() |
| | | // 这里不需要额外操作 |
| | | }; |
| | | |
| | | // 导出按钮操作 |
| | |
| | | path: '/productionManagement/productStructureDetail', |
| | | query: { |
| | | id: row.id, |
| | | drawingNumber: row.drawingNumber || "", |
| | | bomNo: row.bomNo || '', |
| | | productName: row.productName || '', |
| | | productModelName: row.productModelName || '' |