From b07dcaaddf964f5ca45ea204c6037d8d62c6b4ad Mon Sep 17 00:00:00 2001
From: 张诺 <zhang_12370@163.com>
Date: 星期三, 08 四月 2026 17:22:41 +0800
Subject: [PATCH] feat(产品结构): 新增按BOM添加功能并优化产品结构管理

---
 src/views/productionManagement/productStructure/index.vue |   54 ++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 42 insertions(+), 12 deletions(-)

diff --git a/src/views/productionManagement/productStructure/index.vue b/src/views/productionManagement/productStructure/index.vue
index 2c109cd..fb9e7d8 100644
--- a/src/views/productionManagement/productStructure/index.vue
+++ b/src/views/productionManagement/productStructure/index.vue
@@ -1,11 +1,11 @@
 <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"
@@ -34,8 +34,8 @@
         </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>
 
@@ -45,7 +45,7 @@
     <!-- 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>
@@ -77,11 +77,11 @@
 
     minWidth: 160
   },
-  {
-    label: "瑙勬牸鍨嬪彿",
-    prop: "productModelName",
-    minWidth: 140
-  },
+	{
+		label: "鍥剧焊缂栧彿",
+		prop: "productModelName",
+		minWidth: 140
+	},
   {
     label: "鐗堟湰鍙�",
     prop: "version",
@@ -334,7 +334,7 @@
 };
 
 //  鏂囦欢涓婁紶鎴愬姛澶勭悊
-const handleFileSuccess = (response, file, fileList) => {
+const handleFileSuccess = (response, file) => {
   upload.open = false;
   upload.isUploading = false;
   proxy.$refs["uploadRef"].clearFiles();
@@ -342,13 +342,42 @@
     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()
+  // 杩欓噷涓嶉渶瑕侀澶栨搷浣�
 };
 
 //  瀵煎嚭鎸夐挳鎿嶄綔
@@ -420,6 +449,7 @@
     path: '/productionManagement/productStructureDetail',
     query: {
       id: row.id,
+      drawingNumber: row.drawingNumber || "",
       bomNo: row.bomNo || '',
       productName: row.productName || '',
       productModelName: row.productModelName || ''

--
Gitblit v1.9.3