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/Detail/index.vue  |  326 +++++++++++++++++++++++++++++++----
 src/api/basicData/product.js                                      |   17 +
 src/api/productionManagement/productStructure.js                  |    8 
 src/api/productionManagement/productStructureRecord.js            |   20 ++
 src/views/productionManagement/productStructure/StructureEdit.vue |   47 ++--
 src/router/index.js                                               |   13 -
 src/views/productionManagement/productStructure/index.vue         |   54 ++++-
 7 files changed, 394 insertions(+), 91 deletions(-)

diff --git a/src/api/basicData/product.js b/src/api/basicData/product.js
index d29a064..f0ce00a 100644
--- a/src/api/basicData/product.js
+++ b/src/api/basicData/product.js
@@ -1,6 +1,14 @@
 // 浜у搧缁存姢椤甸潰鎺ュ彛
 import request from '@/utils/request'
 
+// 浜у搧鍒楄〃鏌ヨ
+export function productListPage(query) {
+    return request({
+        url: '/basic/product/listPage',
+        method: 'get',
+        params: query
+    })
+}
 // 浜у搧鏍戞煡璇�
 export function productTreeList(query) {
     return request({
@@ -56,12 +64,11 @@
         params: query
     })
 }
-
-//  涓嬭浇浜у搧瀵煎叆妯℃澘
-export function downloadProductModelImportTemplate() {
+// 涓嬭浇浜у搧瀵煎叆妯℃澘
+export function downloadTemplate() {
     return request({
-        url: '/basic/product/export',
+        url: '/basic/product/downloadTemplate',
         method: 'get',
         responseType: 'blob'
     })
-}
\ No newline at end of file
+}
diff --git a/src/api/productionManagement/productStructure.js b/src/api/productionManagement/productStructure.js
index e69e14a..978c709 100644
--- a/src/api/productionManagement/productStructure.js
+++ b/src/api/productionManagement/productStructure.js
@@ -9,6 +9,14 @@
   });
 }
 
+// 鏍规嵁BOM ID鏌ヨ鐖堕」浜у搧
+export function listByBomIdIsParent(bomId) {
+  return request({
+    url: "/productStructure/listBybomIdIsParent/" + bomId,
+    method: "get",
+  });
+}
+
 export function add(data) {
   return request({
     url: "/productStructure",
diff --git a/src/api/productionManagement/productStructureRecord.js b/src/api/productionManagement/productStructureRecord.js
new file mode 100644
index 0000000..65ec4ee
--- /dev/null
+++ b/src/api/productionManagement/productStructureRecord.js
@@ -0,0 +1,20 @@
+// 鐢熶骇璁㈠崟棰嗘枡璁板綍鎺ュ彛
+import request from "@/utils/request";
+
+// 鏍规嵁璁㈠崟ID鏌ヨ鐗╂枡娓呭崟锛堥鏂欐暟鎹級
+export function listPage(query) {
+  return request({
+    url: "/productStructureRecord/listPage",
+    method: "get",
+    params: query,
+  });
+}
+
+// 棰嗘枡鎻愪氦
+export function pick(data) {
+  return request({
+    url: "/productStructureRecord/pick",
+    method: "post",
+    data: data,
+  });
+}
diff --git a/src/router/index.js b/src/router/index.js
index f342004..e5dc580 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -106,19 +106,6 @@
       },
     ],
   },
-  {
-    path: "/projectManagement/Management/detail",
-    component: Layout,
-    hidden: true,
-    children: [
-      {
-        path: ":id",
-        component: () => import("@/views/projectManagement/Management/projectDetail.vue"),
-        name: "ProjectManagementDetail",
-        meta: { title: "椤圭洰璇︽儏", activeMenu: "/projectManagement/Management" },
-      },
-    ],
-  },
 ];
 
 // 鍔ㄦ�佽矾鐢憋紝鍩轰簬鐢ㄦ埛鏉冮檺鍔ㄦ�佸幓鍔犺浇
diff --git a/src/views/productionManagement/productStructure/Detail/index.vue b/src/views/productionManagement/productStructure/Detail/index.vue
index 6734830..ec4a849 100644
--- a/src/views/productionManagement/productStructure/Detail/index.vue
+++ b/src/views/productionManagement/productStructure/Detail/index.vue
@@ -2,16 +2,21 @@
   <div class="app-container">
     <PageHeader content="浜у搧缁撴瀯璇︽儏">
       <template #right-button>
+        <el-button v-if="dataValue.isEdit && !isOrderPage"
+                   @click="cancelEdit">鍙栨秷
+        </el-button>
         <el-button v-if="!dataValue.isEdit && !isOrderPage"
                    type="primary"
-                   @click="dataValue.isEdit = true">缂栬緫
-        </el-button>
-        <el-button v-if="dataValue.isEdit && !isOrderPage"
-                   type="primary"
-                   @click="cancelEdit">鍙栨秷
+                   @click="dataValue.isEdit = true">鐐瑰嚮杩涜淇敼
         </el-button>
         <el-button v-if="!isOrderPage"
                    type="primary"
+                   @click="openBomAddDialog"
+                   :disabled="!dataValue.isEdit">
+          <el-icon><Document /></el-icon> 鎸塀OM娣诲姞
+        </el-button>
+        <el-button v-if="!isOrderPage"
+                   type="success"
                    :loading="dataValue.loading"
                    @click="submit"
                    :disabled="!dataValue.isEdit">纭
@@ -34,30 +39,30 @@
                       style="width: 100%">
               <el-table-column prop="productName"
                                label="浜у搧" />
-              <el-table-column prop="model"
-                               label="瑙勬牸">
-                <template #default="{ row, $index }">
-                  <el-form-item v-if="dataValue.isEdit"
-                                :rules="[{ required: true, message: '璇烽�夋嫨瑙勬牸', trigger: ['blur','change'] }]"
-                                style="margin: 0">
-                    <el-select v-model="row.model"
-                               placeholder="璇烽�夋嫨瑙勬牸"
-                               clearable
-                               :disabled="!dataValue.isEdit || dataValue.dataList.some(item => (item as any).tempId === row.tempId)"
-                               style="width: 100%"
-                               @visible-change="(v) => { if (v) openDialog(row.tempId) }">
-                      <el-option v-if="row.model"
-                                 :label="row.model"
-                                 :value="row.model" />
-                    </el-select>
-                  </el-form-item>
-                </template>
-              </el-table-column>
+							<el-table-column prop="model"
+															 label="鍥剧焊缂栧彿">
+								<template #default="{ row, $index }">
+									<el-form-item v-if="dataValue.isEdit"
+															:rules="[{ required: true, message: '璇烽�夋嫨瑙勬牸', trigger: ['blur','change'] }]"
+															style="margin: 0">
+										<el-select v-model="row.model"
+															 placeholder="璇烽�夋嫨瑙勬牸"
+															 clearable
+															 :disabled="!dataValue.isEdit || dataValue.dataList.some(item => (item as any).tempId === row.tempId)"
+															 style="width: 100%"
+															 @visible-change="(v) => { if (v) openDialog(row.tempId) }">
+											<el-option v-if="row.model"
+																 :label="row.model"
+																 :value="row.model" />
+										</el-select>
+									</el-form-item>
+								</template>
+							</el-table-column>
               <el-table-column prop="processName"
-                               label="娑堣�楀伐搴�">
+                               label="宸ュ簭">
                 <template #default="{ row, $index }">
                   <el-form-item v-if="dataValue.isEdit"
-                                :rules="dataValue.dataList.some(item => (item as any).tempId === row.tempId) ? [] : [{ required: true, message: '璇烽�夋嫨娑堣�楀伐搴�', trigger: 'change' }]"
+                                :rules="dataValue.dataList.some(item => (item as any).tempId === row.tempId) ? [] : [{ required: true, message: '璇烽�夊伐搴�', trigger: 'change' }]"
                                 style="margin: 0">
                     <el-select v-model="row.processId"
                                placeholder="璇烽�夋嫨"
@@ -74,10 +79,10 @@
                 </template>
               </el-table-column>
               <el-table-column prop="unitQuantity"
-                               label="鍗曚綅浜у嚭鎵�闇�鏁伴噺">
+                               label="鍗曚綅鐢ㄩ噺">
                 <template #default="{ row, $index }">
                   <el-form-item v-if="dataValue.isEdit"
-                                :rules="[{ required: true, message: '璇疯緭鍏ュ崟浣嶄骇鍑烘墍闇�鏁伴噺', trigger: ['blur','change'] }]"
+                                :rules="[{ required: true, message: '璇疯緭鍏ュ崟浣嶇敤閲�', trigger: ['blur','change'] }]"
                                 style="margin: 0">
                     <el-input-number v-model="row.unitQuantity"
                                      :min="0"
@@ -139,16 +144,43 @@
           </el-form>
         </template>
       </el-table-column>
-      <el-table-column label="BOM缂栧彿"
+      <el-table-column v-if="!isOrderPage"
+                       label="BOM缂栧彿"
                        prop="bomNo" />
       <el-table-column label="浜у搧鍚嶇О"
                        prop="productName" />
-      <el-table-column label="瑙勬牸鍨嬪彿"
-                       prop="model" />
+			<el-table-column label="鍥剧焊缂栧彿"
+														 prop="model" />
     </el-table>
     <product-select-dialog v-if="dataValue.showProductDialog"
                            v-model:model-value="dataValue.showProductDialog"
                            @confirm="handleProduct" />
+
+    <!-- 鎸塀OM娣诲姞寮圭獥 -->
+    <el-dialog v-model="bomAddDialogVisible" title="鎸塀OM娣诲姞" width="500px" @close="closeBomAddDialog">
+      <el-form ref="bomAddFormRef" :model="bomAddForm" :rules="bomAddRules" label-width="100px">
+        <el-form-item label="鐖堕」浜у搧" prop="parentProductId">
+          <el-select v-model="bomAddForm.parentProductId" placeholder="璇烽�夋嫨" clearable filterable
+            style="width: 100%" @change="handleBomParentProductChange">
+            <el-option v-for="item in parentProductOptions" :key="item.id"
+              :label="`${item.model || item.productCode || item.id} | ${item.productName}`"
+              :value="item.id" />
+          </el-select>
+        </el-form-item>
+        <el-form-item label="鐢ㄩ噺绯绘暟" prop="coefficient" style="margin-top: 20px;">
+          <el-input-number v-model="bomAddForm.coefficient" :min="0.01" :precision="2" :step="1"
+            controls-position="right" style="width: 100%" />
+        </el-form-item>
+      </el-form>
+      <template #footer>
+        <el-button type="primary" @click="submitBomAdd">纭畾</el-button>
+        <el-button @click="closeBomAddDialog">鍙栨秷</el-button>
+      </template>
+    </el-dialog>
+
+    <!-- 楂樼骇閫夋嫨浜у搧寮圭獥 -->
+    <product-select-dialog v-if="showAdvancedProductDialog" v-model:model-value="showAdvancedProductDialog"
+      @confirm="handleAdvancedProductSelect" />
   </div>
 </template>
 
@@ -161,11 +193,14 @@
     reactive,
     ref,
   } from "vue";
-  import { queryList, add } from "@/api/productionManagement/productStructure.js";
+  import { queryList, add, listByBomIdIsParent } from "@/api/productionManagement/productStructure.js";
   import { listProcessBom } from "@/api/productionManagement/productionOrder.js";
   import { list } from "@/api/productionManagement/productionProcess";
+  import { productListPage } from "@/api/basicData/product.js";
+  import { listPage as listBomPage } from "@/api/productionManagement/productBom.js";
   import { ElMessage } from "element-plus";
   import { useRoute, useRouter } from "vue-router";
+  import { Search, Document } from '@element-plus/icons-vue'
 
   defineComponent({
     name: "StructureEdit",
@@ -192,6 +227,7 @@
   // 浠庤矾鐢卞弬鏁拌幏鍙栦骇鍝佷俊鎭�
   const routeBomNo = computed(() => route.query.bomNo || "");
   const routeProductName = computed(() => route.query.productName || "");
+  const routeDrawingNumber = computed(() => route.query.drawingNumber || "");
   const routeProductModelName = computed(
     () => route.query.productModelName || ""
   );
@@ -212,9 +248,26 @@
     isEdit: false,
   });
 
+  // 鎸塀OM娣诲姞鐩稿叧
+  const bomAddDialogVisible = ref(false);
+  const bomAddFormRef = ref();
+  const parentProductOptions = ref([]);
+  const selectedBomProduct = ref(null);
+  const selectedBomTreeData = ref([]); // 淇濆瓨閫変腑浜у搧鏃惰幏鍙栫殑BOM鏍戞暟鎹�
+  const showAdvancedProductDialog = ref(false);
+  const bomAddForm = reactive({
+    parentProductId: undefined,
+    coefficient:1
+  });
+  const bomAddRules = {
+    parentProductId: [{ required: true, message: "璇烽�夋嫨鐖堕」浜у搧", trigger: "change" }],
+    coefficient: [{ required: true, message: "璇疯緭鍏ョ敤閲忕郴鏁�", trigger: "blur" }]
+  };
+
   const tableData = reactive([
     {
       productName: "",
+      drawingNumber: "",
       model: "",
       bomNo: "",
     },
@@ -293,6 +346,7 @@
     dataValue.dataList.map(item => {
       if (item.tempId === dataValue.currentRowName) {
         item.productName = productData.productName;
+        item.drawingNumber = productData.drawingNumber || "";
         item.model = productData.model;
         item.productModelId = productData.id;
         item.unit = productData.unit || "";
@@ -305,6 +359,7 @@
   const childItem = (item: any, tempId: any, productData: any) => {
     if (item.tempId === tempId) {
       item.productName = productData.productName;
+      item.drawingNumber = productData.drawingNumber || "";
       item.model = productData.model;
       item.productModelId = productData.id;
       item.unit = productData.unit || "";
@@ -332,13 +387,8 @@
         isValid = false;
         return;
       }
-      if (!isTopLevel && !item.processId) {
-        ElMessage.error("璇烽�夋嫨娑堣�楀伐搴�");
-        isValid = false;
-        return;
-      }
       if (!item.unitQuantity) {
-        ElMessage.error("璇疯緭鍏ュ崟浣嶄骇鍑烘墍闇�鏁伴噺");
+        ElMessage.error("璇疯緭鍏ュ崟浣嶇敤閲�");
         isValid = false;
         return;
       }
@@ -503,9 +553,155 @@
     fetchData();
   };
 
+  // 鑾峰彇鐖堕」浜у搧鍒楄〃
+  const getParentProductList = async () => {
+    try {
+      const { data } = await listBomPage({ current: 1, size: 1000 });
+      parentProductOptions.value = data?.records || [];
+    } catch (error) {
+      console.error("鑾峰彇鐖堕」浜у搧鍒楄〃澶辫触:", error);
+      parentProductOptions.value = [];
+    }
+  };
+
+  // 鎵撳紑鎸塀OM娣诲姞寮圭獥
+  const openBomAddDialog = () => {
+    bomAddDialogVisible.value = true;
+    bomAddForm.parentProductId = undefined;
+    bomAddForm.coefficient = 1;
+    selectedBomProduct.value = null;
+    getParentProductList();
+  };
+
+  // 鍏抽棴鎸塀OM娣诲姞寮圭獥
+  const closeBomAddDialog = () => {
+    bomAddDialogVisible.value = false;
+    bomAddFormRef.value?.resetFields();
+    selectedBomProduct.value = null;
+  };
+
+  // 鎵撳紑楂樼骇閫夋嫨
+  const openAdvancedSelect = () => {
+    showAdvancedProductDialog.value = true;
+  };
+
+  // 鐖堕」浜у搧鍙樻洿
+  const handleBomParentProductChange = async (val) => {
+    if (val) {
+      const product = parentProductOptions.value.find(item => item.id === val);
+      selectedBomProduct.value = product || null;
+      console.log(val)
+      // 鐩存帴鐢ㄩ�変腑鐨� BOM ID 璋冪敤 listByBomIdIsParent
+      const { data: treeData } = await listByBomIdIsParent(val);
+      selectedBomTreeData.value = treeData || [];
+      // 灏嗕簩绾ф爲涓殑浜у搧娣诲姞鍒扮埗椤逛骇鍝侀�夐」锛堜粠绗簩绾у紑濮嬶級
+      const addTreeToOptions = (items: any[]) => {
+        items.forEach((item: any) => {
+          // 璺宠繃绗竴绾э紝鍙坊鍔犵浜岀骇鍙婁互涓嬬殑浜у搧
+          if (item.children && item.children.length > 0) {
+            item.children.forEach((child: any) => {
+              const exists = parentProductOptions.value.some(opt => opt.id === child.id);
+              if (!exists) {
+                parentProductOptions.value.push({
+                  id: child.id,
+                  productName: child.productName,
+                  model: child.model,
+                  productCode: child.model,
+                  spec: child.drawingNumber,
+                  drawingNumber: child.drawingNumber,
+                  stockQuantity: child.stockQuantity || 0
+                });
+              }
+              // 閫掑綊娣诲姞瀛愰」
+              if (child.children && child.children.length > 0) {
+                addTreeToOptions([child]);
+              }
+            });
+          }
+        });
+      };
+      if (selectedBomTreeData.value.length > 0) {
+        addTreeToOptions(selectedBomTreeData.value);
+      }
+    } else {
+      selectedBomProduct.value = null;
+      selectedBomTreeData.value = [];
+    }
+  };
+
+  // 鎻愪氦鎸塀OM娣诲姞
+  const submitBomAdd = () => {
+    bomAddFormRef.value.validate(async (valid) => {
+      if (!valid) return;
+
+      const product = parentProductOptions.value.find(item => item.id === bomAddForm.parentProductId);
+      if (!product) {
+        ElMessage.error("鏈壘鍒伴�変腑鐨勪骇鍝�");
+        return;
+      }
+
+      try {
+        // 浣跨敤閫夋嫨浜у搧鏃朵繚瀛樼殑BOM鏍戞暟鎹�
+        const bomItems = selectedBomTreeData.value || [];
+
+        if (bomItems.length === 0) {
+          ElMessage.warning("璇ヤ骇鍝佹病鏈塀OM淇℃伅");
+          return;
+        }
+
+        // 鍒楄〃鐨勭涓�绾у凡缁忓瓨鍦紝鎶夿OM鏁版嵁浣滀负绗竴绾х殑瀛愰」锛堢浜岀骇锛夋坊鍔�
+        if (dataValue.dataList.length > 0) {
+          const firstLevelItem = dataValue.dataList[0];
+          
+          // 鎶夿OM鏁版嵁娣诲姞鍒扮涓�绾х殑children涓�
+          const addBomItemsRecursively = (items: any[], parentItem: any) => {
+            items.forEach((item: any) => {
+              const newItem: any = {
+                parentId: item.parentId || "",
+                parentTempId: parentItem.tempId || "",
+                productName: item.productName || "",
+                productId: item.productId || item.productModelId || "",
+                model: item.model || "",
+                productModelId: item.productModelId || "",
+                drawingNumber: item.drawingNumber || "",
+                processId: item.processId || "",
+                processName: item.processName || "",
+                unitQuantity: (item.unitQuantity || 0) * bomAddForm.coefficient,
+                demandedQuantity: (item.demandedQuantity || 0) * bomAddForm.coefficient,
+                unit: item.unit || "",
+                children: [],
+                tempId: new Date().getTime() + Math.random(),
+              };
+
+              // 娣诲姞鍒扮埗椤圭殑children
+              if (!parentItem.children) {
+                parentItem.children = [];
+              }
+              parentItem.children.push(newItem);
+
+              // 閫掑綊澶勭悊瀛愰」
+              if (item.children && item.children.length > 0) {
+                addBomItemsRecursively(item.children, newItem);
+              }
+            });
+          };
+
+          addBomItemsRecursively(bomItems, firstLevelItem);
+        }
+
+        ElMessage.success("娣诲姞鎴愬姛");
+        closeBomAddDialog();
+      } catch (error) {
+        console.error("鎸塀OM娣诲姞澶辫触:", error);
+        ElMessage.error("娣诲姞澶辫触");
+      }
+    });
+  };
+
   onMounted(async () => {
     // 浠庤矾鐢卞弬鏁板洖鏄炬暟鎹�
     tableData[0].productName = routeProductName.value as string;
+    tableData[0].drawingNumber = routeDrawingNumber.value as string;
     tableData[0].model = routeProductModelName.value as string;
     tableData[0].bomNo = routeBomNo.value as string;
 
@@ -518,4 +714,56 @@
     await fetchProcessOptions();
     await fetchData();
   });
-</script>
\ No newline at end of file
+</script>
+
+<style scoped>
+.selected-product-info {
+  background-color: #f5f7fa;
+  border-radius: 4px;
+  padding: 16px;
+  margin: 10px 0;
+  position: relative;
+}
+
+.product-info-row {
+  display: flex;
+  margin-bottom: 8px;
+  font-size: 14px;
+}
+
+.product-info-row:last-child {
+  margin-bottom: 0;
+}
+
+.info-label {
+  color: #909399;
+  width: 70px;
+  flex-shrink: 0;
+}
+
+.info-value {
+  color: #303133;
+  flex: 1;
+}
+
+.stock-info-box {
+  position: absolute;
+  right: 16px;
+  top: 50%;
+  transform: translateY(-50%);
+  text-align: center;
+}
+
+.stock-number {
+  font-size: 28px;
+  font-weight: bold;
+  color: #303133;
+  line-height: 1;
+  margin-bottom: 4px;
+}
+
+.stock-label {
+  font-size: 12px;
+  color: #909399;
+}
+</style>
diff --git a/src/views/productionManagement/productStructure/StructureEdit.vue b/src/views/productionManagement/productStructure/StructureEdit.vue
index 4d07f5d..2116cf9 100644
--- a/src/views/productionManagement/productStructure/StructureEdit.vue
+++ b/src/views/productionManagement/productStructure/StructureEdit.vue
@@ -35,27 +35,30 @@
               <el-table-column prop="productName"
                                label="浜у搧"
                                width="150" />
-              <el-table-column prop="model"
-                               label="瑙勬牸"
-                               width="150">
-                <template #default="{ row, $index }">
-                  <el-form-item v-if="dataValue.isEdit"
-                                :prop="`dataList.${$index}.model`"
-                                :rules="[{ required: true, message: '璇烽�夋嫨瑙勬牸', trigger: ['blur','change'] }]"
-                                style="margin: 0">
-                    <el-select v-model="row.model"
-                               placeholder="璇烽�夋嫨浜у搧"
-                               clearable
-                               :disabled="!dataValue.isEdit"
-                               style="width: 100%"
-                               @visible-change="(v) => { if (v) openDialog($index) }">
-                      <el-option v-if="row.model"
-                                 :label="row.model"
-                                 :value="row.model" />
-                    </el-select>
-                  </el-form-item>
-                </template>
-              </el-table-column>
+							<el-table-column prop="model"
+															 label="鍥剧焊缂栧彿"
+															 width="150">
+								<template #default="{ row, $index }">
+									<el-form-item v-if="dataValue.isEdit"
+																:prop="`dataList.${$index}.model`"
+																:rules="[{ required: true, message: '璇烽�夋嫨鍥剧焊缂栧彿', trigger: ['blur','change'] }]"
+																style="margin: 0">
+										<el-select v-model="row.model"
+															 placeholder="璇烽�夋嫨浜у搧"
+															 clearable
+															 :disabled="!dataValue.isEdit"
+															 style="width: 100%"
+															 @visible-change="(v) => { if (v) openDialog($index) }">
+											<el-option v-if="row.model"
+																 :label="row.model"
+																 :value="row.model" />
+										</el-select>
+									</el-form-item>
+								</template>
+							</el-table-column>
+              <el-table-column prop="drawingNumber"
+                               label="瑙勬牸鍨嬪彿"
+                               width="150" />
               <el-table-column prop="processId"
                                label="娑堣�楀伐搴�"
                                width="150">
@@ -156,7 +159,7 @@
       </el-table-column>
       <el-table-column label="浜у搧缂栫爜" prop="productCode" />
       <el-table-column label="浜у搧鍚嶇О" prop="productName" />
-      <el-table-column label="瑙勬牸鍨嬪彿" prop="model" />
+      <el-table-column label="鍥剧焊缂栧彿" prop="model" />
       <el-table-column label="鍗曚綅" prop="unit" />
     </el-table>
 
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