From 0c4429a719f5c95a7690fae51efaaa799ef4e77d Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期一, 25 五月 2026 10:02:48 +0800
Subject: [PATCH] fix: 投入重量改成投入重量/数量
---
src/views/basicData/product/index.vue | 128 +++++++++++++++++++++++++++++++++++++++---
1 files changed, 117 insertions(+), 11 deletions(-)
diff --git a/src/views/basicData/product/index.vue b/src/views/basicData/product/index.vue
index 3f0921a..7552721 100644
--- a/src/views/basicData/product/index.vue
+++ b/src/views/basicData/product/index.vue
@@ -30,11 +30,8 @@
:props="{ children: 'children', label: 'label' }"
highlight-current
node-key="id"
- style="
- height: calc(100vh - 190px);
- overflow-y: scroll;
- scrollbar-width: none;
- "
+ class="product-tree-scroll"
+ style="height: calc(100vh - 190px); overflow-y: auto"
>
<template #default="{ node, data }">
<div class="custom-tree-node">
@@ -43,9 +40,17 @@
<component :is="data.children && data.children.length > 0
? node.expanded ? 'FolderOpened' : 'Folder' : 'Tickets'" />
</el-icon>
- {{ data.label }}
+ <span class="tree-node-label">{{ data.label }}</span>
</span>
<div>
+ <el-button
+ v-if="node.level > 1"
+ type="success"
+ link
+ @click.stop="handleDownCopy(node, data)"
+ >
+ 鍚戜笅澶嶅埗
+ </el-button>
<el-button
type="primary"
link
@@ -76,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"
@@ -111,6 +116,8 @@
<el-input
v-model="form.productName"
placeholder="璇疯緭鍏ヤ骇鍝佸悕绉�"
+ maxlength="20"
+ show-word-limit
clearable
@keydown.enter.prevent
/>
@@ -139,6 +146,18 @@
:rules="modelRules"
ref="modelFormRef"
>
+ <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">
@@ -184,6 +203,7 @@
delProductModel,
modelListPage,
productTreeList,
+ downCopyProductModel,
} from "@/api/basicData/product.js";
import ImportExcel from "./ImportExcel/index.vue";
@@ -202,6 +222,10 @@
const list = ref([]);
const expandedKeys = ref([]);
const tableColumn = ref([
+ {
+ label: "鏂欏彿",
+ prop: "materialCode",
+ },
{
label: "瑙勬牸鍨嬪彿",
prop: "model",
@@ -239,13 +263,18 @@
productName: "",
},
rules: {
- productName: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ productName: [
+ { required: true, message: "璇疯緭鍏�", trigger: "blur" },
+ { max: 20, message: "浜у搧鍚嶇О涓嶈兘瓒呰繃20涓瓧绗�", trigger: "blur" },
+ ],
},
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" }],
},
@@ -342,6 +371,49 @@
proxy.$modal.msg("宸插彇娑�");
});
};
+
+// 鍚戜笅澶嶅埗
+const handleDownCopy = (node, data) => {
+ if (currentId.value !== data.id) {
+ proxy.$modal.msgWarning("璇峰厛閫変腑褰撳墠浜у搧骞跺嬀閫夐渶瑕佸鍒剁殑鍨嬪彿");
+ return;
+ }
+
+ // 鑾峰彇鍚屽眰绾ц妭鐐�
+ 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;
+ }
+
+ const modelListId = selectedRows.value.map((item) => item.id);
+ if (!modelListId.length) {
+ proxy.$modal.msgWarning("娌℃湁閫夋嫨瑕佸鍒剁殑鍨嬪彿");
+ return;
+ }
+
+ ElMessageBox.confirm("纭灏嗗綋鍓嶈妭鐐圭殑瑙勬牸鍨嬪彿澶嶅埗鍒颁笅涓�琛岃妭鐐癸紵", "鍚戜笅澶嶅埗", {
+ confirmButtonText: "纭",
+ cancelButtonText: "鍙栨秷",
+ type: "info",
+ })
+ .then(() => {
+ downCopyProductModel({
+ productId: data.id,
+ targetProductId: nextNode.data.id,
+ modelListId,
+ }).then(() => {
+ proxy.$modal.msgSuccess("澶嶅埗鎴愬姛");
+ });
+ })
+ .catch(() => {});
+};
// 閫夋嫨浜у搧
const handleNodeClick = (val, node, el) => {
// 鍒ゆ柇鏄惁涓哄彾瀛愯妭鐐�
@@ -349,6 +421,7 @@
// 鍙湁鍙跺瓙鑺傜偣鎵嶆墽琛屼互涓嬮�昏緫
currentId.value = val.id;
currentParentId.value = val.parentId;
+ selectedRows.value = [];
getModelList();
};
@@ -383,6 +456,7 @@
};
const getModelList = () => {
tableLoading.value = true;
+ selectedRows.value = [];
modelListPage({
id: currentId.value,
current: page.current,
@@ -467,18 +541,21 @@
display: flex;
}
.left {
- width: 380px;
+ width: 450px;
+ min-width: 450px;
padding: 16px;
background: #ffffff;
}
.right {
- width: calc(100% - 380px);
+ flex: 1;
+ min-width: 0;
padding: 16px;
margin-left: 20px;
background: #ffffff;
}
.custom-tree-node {
flex: 1;
+ min-width: 0;
display: flex;
align-items: center;
justify-content: space-between;
@@ -486,13 +563,42 @@
padding-right: 8px;
}
.tree-node-content {
+ flex: 1;
+ min-width: 0;
display: flex;
- align-items: center; /* 鍨傜洿灞呬腑 */
+ align-items: center;
height: 100%;
+ overflow: hidden;
+}
+.tree-node-content .orange-icon {
+ flex-shrink: 0;
+}
+.tree-node-label {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
}
.orange-icon {
color: orange;
font-size: 18px;
margin-right: 8px; /* 鍥炬爣涓庢枃瀛椾箣闂村姞鐐归棿璺� */
}
+.product-tree-scroll {
+ scrollbar-width: thin;
+ scrollbar-color: #c0c4cc #f5f7fa;
+}
+.product-tree-scroll::-webkit-scrollbar {
+ width: 8px;
+}
+.product-tree-scroll::-webkit-scrollbar-track {
+ background: #f5f7fa;
+ border-radius: 4px;
+}
+.product-tree-scroll::-webkit-scrollbar-thumb {
+ background: #c0c4cc;
+ border-radius: 4px;
+}
+.product-tree-scroll::-webkit-scrollbar-thumb:hover {
+ background: #909399;
+}
</style>
--
Gitblit v1.9.3