From 57e75ea91e7210d058627e7930efc75526dab622 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期五, 22 五月 2026 09:43:09 +0800
Subject: [PATCH] feat(product): 添加产品规格型号向下复制功能 - 在产品树形结构中添加向下复制按钮,仅在层级大于1时显示 - 实现handleDownCopy方法,支持将当前节点规格型号复制到同层级下一个节点 - 添加downCopyProductModel API接口,用于处理向下复制请求 - 添加相应的警告和成功消息提示

---
 src/views/basicData/product/index.vue |   57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 56 insertions(+), 1 deletions(-)

diff --git a/src/views/basicData/product/index.vue b/src/views/basicData/product/index.vue
index c9058aa..fa8a203 100644
--- a/src/views/basicData/product/index.vue
+++ b/src/views/basicData/product/index.vue
@@ -44,6 +44,14 @@
               </span>
               <div>
                 <el-button
+                  v-if="node.level > 1"
+                  type="success"
+                  link
+                  @click="handleDownCopy(node, data)"
+                >
+                  鍚戜笅澶嶅埗
+                </el-button>
+                <el-button
                   type="primary"
                   link
                   @click="openProDia('edit', data)"
@@ -73,7 +81,7 @@
         <el-button type="primary" @click="openModelDia('add')">
           鏂板瑙勬牸鍨嬪彿
         </el-button>
-        <ImportExcel @uploadSuccess="getModelList" />
+        <ImportExcel :product-id="currentId" @uploadSuccess="getModelList" />
         <el-button
           type="danger"
           @click="handleDelete"
@@ -140,6 +148,18 @@
       >
         <el-row>
           <el-col :span="24">
+            <el-form-item label="鏂欏彿锛�" prop="materialCode">
+              <el-input
+                  v-model="modelForm.materialCode"
+                  placeholder="璇疯緭鍏ユ枡鍙�"
+                  clearable
+                  @keydown.enter.prevent
+              />
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row>
+          <el-col :span="24">
             <el-form-item label="瑙勬牸鍨嬪彿锛�" prop="model">
               <el-input
                 v-model="modelForm.model"
@@ -183,6 +203,7 @@
   delProductModel,
   modelListPage,
   productTreeList,
+  downCopyProductModel,
 } from "@/api/basicData/product.js";
 import ImportExcel from "./ImportExcel/index.vue";
 
@@ -201,6 +222,10 @@
 const list = ref([]);
 const expandedKeys = ref([]);
 const tableColumn = ref([
+  {
+    label: "鏂欏彿",
+    prop: "materialCode",
+  },
   {
     label: "瑙勬牸鍨嬪彿",
     prop: "model",
@@ -244,10 +269,12 @@
     ],
   },
   modelForm: {
+    materialCode: "",
     model: "",
     unit: "",
   },
   modelRules: {
+    materialCode: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }, { max: 200, message: "鐗╂枡缂栧彿涓嶈兘瓒呰繃200涓瓧绗�", trigger: "blur" }],
     model: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
     unit: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
   },
@@ -344,6 +371,34 @@
       proxy.$modal.msg("宸插彇娑�");
     });
 };
+
+// 鍚戜笅澶嶅埗
+const handleDownCopy = (node, data) => {
+  // 鑾峰彇鍚屽眰绾ц妭鐐�
+  const parent = node.parent;
+  const siblings = parent.childNodes || [];
+  // 鎵惧埌褰撳墠鑺傜偣鍦ㄥ悓灞傜骇涓殑绱㈠紩
+  const currentIndex = siblings.findIndex(item => item.data.id === data.id);
+  // 鑾峰彇涓嬩竴琛岃妭鐐�
+  const nextNode = siblings[currentIndex + 1];
+
+  if (!nextNode) {
+    proxy.$modal.msgWarning("褰撳墠鑺傜偣鏄悓灞傜骇鏈�鍚庝竴涓紝娌℃湁涓嬩竴琛屾暟鎹彲澶嶅埗");
+    return;
+  }
+
+  ElMessageBox.confirm("纭灏嗗綋鍓嶈妭鐐圭殑瑙勬牸鍨嬪彿澶嶅埗鍒颁笅涓�琛岃妭鐐癸紵", "鍚戜笅澶嶅埗", {
+    confirmButtonText: "纭",
+    cancelButtonText: "鍙栨秷",
+    type: "info",
+  })
+    .then(() => {
+      downCopyProductModel({ productId: data.id, targetProductId: nextNode.data.id }).then(() => {
+        proxy.$modal.msgSuccess("澶嶅埗鎴愬姛");
+      });
+    })
+    .catch(() => {});
+};
 // 閫夋嫨浜у搧
 const handleNodeClick = (val, node, el) => {
   // 鍒ゆ柇鏄惁涓哄彾瀛愯妭鐐�

--
Gitblit v1.9.3