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)"
@@ -195,6 +203,7 @@
  delProductModel,
  modelListPage,
  productTreeList,
  downCopyProductModel,
} from "@/api/basicData/product.js";
import ImportExcel from "./ImportExcel/index.vue";
@@ -362,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) => {
  // 判断是否为叶子节点