From de4e098a962e8403d9b32590f0acba025b8072f6 Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期六, 14 三月 2026 17:51:27 +0800
Subject: [PATCH] 一些修改
---
src/views/basicData/product/index.vue | 169 ++++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 121 insertions(+), 48 deletions(-)
diff --git a/src/views/basicData/product/index.vue b/src/views/basicData/product/index.vue
index 32dad2b..45931bc 100644
--- a/src/views/basicData/product/index.vue
+++ b/src/views/basicData/product/index.vue
@@ -6,7 +6,7 @@
style="width: 210px"
placeholder="杈撳叆鍏抽敭瀛楄繘琛屾悳绱�"
@change="searchFilter"
- @clear="searchFilter"
+ @clear="searchFilter1"
clearable
prefix-icon="Search" />
<el-button type="primary"
@@ -32,8 +32,7 @@
<div class="custom-tree-node">
<span class="tree-node-content">
<el-icon class="tree-icon">
- <component :is="data.children && data.children.length > 0
- ? node.expanded ? 'FolderOpened' : 'Folder' : 'Tickets'" />
+ <component :is="node.expanded ? 'FolderOpened' : 'Folder'" />
</el-icon>
<span class="tree-node-label">{{ data.label }}</span>
</span>
@@ -85,7 +84,7 @@
</el-button>
<ImportExcel :product-id="currentId"
@uploadSuccess="getModelList" />
- <el-input v-model="specification"
+ <el-input v-model="model"
placeholder="瑙勬牸鍨嬪彿"
style="width: 150px"
clearable
@@ -122,8 +121,8 @@
<el-row :gutter="30">
<el-col :span="24">
<el-form-item label="浜у搧鍚嶇О锛�"
- prop="materialName">
- <el-input v-model="form.materialName"
+ prop="productName">
+ <el-input v-model="form.productName"
placeholder="璇疯緭鍏ヤ骇鍝佸悕绉�"
maxlength="20"
show-word-limit
@@ -169,8 +168,8 @@
<el-row :gutter="30">
<el-col :span="24">
<el-form-item label="鍩烘湰鍗曚綅锛�"
- prop="baseUnit">
- <el-input v-model="form.baseUnit"
+ prop="unit">
+ <el-input v-model="form.unit"
placeholder="璇疯緭鍏ュ熀鏈崟浣�"
clearable
@keydown.enter.prevent />
@@ -211,8 +210,8 @@
<el-row>
<el-col :span="24">
<el-form-item label="瑙勬牸鍨嬪彿锛�"
- prop="specification">
- <el-input v-model="modelForm.specification"
+ prop="model">
+ <el-input v-model="modelForm.model"
placeholder="璇疯緭鍏ヨ鏍煎瀷鍙�"
clearable
@keydown.enter.prevent />
@@ -302,6 +301,7 @@
delProductModel,
modelListPage,
productTreeList,
+ productTreeListQuery,
addOrEditProductConfig,
updateOrEditProductConfig,
delProductConfig,
@@ -327,7 +327,7 @@
const expandedKeys = ref([]);
const inventoryCategoryList = ref([]);
const materialTypeList = ref([]);
- const specification = ref("");
+ const model = ref("");
const materialCode = ref("");
const getloadData = () => {
@@ -374,11 +374,11 @@
const tableColumn = ref([
{
label: "瑙勬牸鍨嬪彿",
- prop: "materialName",
+ prop: "productName",
},
{
label: "瑙勬牸",
- prop: "specification",
+ prop: "model",
},
{
label: "鐗╂枡缂栫爜",
@@ -386,7 +386,7 @@
},
{
label: "鍗曚綅",
- prop: "baseUnit",
+ prop: "unit",
},
{
dataType: "action",
@@ -417,28 +417,28 @@
form: {
materialTypeId: null,
inventoryCategoryId: null,
- materialName: "",
- baseUnit: "",
+ productName: "",
+ unit: "",
remark: "",
},
rules: {
- materialName: [
+ productName: [
{ required: true, message: "璇疯緭鍏�", trigger: "blur" },
{ max: 20, message: "浜у搧鍚嶇О涓嶈兘瓒呰繃20涓瓧绗�", trigger: "blur" },
],
inventoryCategoryId: [
{ required: true, message: "璇烽�夋嫨", trigger: "change" },
],
- baseUnit: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ unit: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
},
modelForm: {
- specification: "",
+ model: "",
supplyType: "",
materialCode: "",
id: null,
},
modelRules: {
- specification: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ model: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
supplyType: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
materialCode: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
},
@@ -459,29 +459,20 @@
// 鏌ヨ浜у搧鏍�
const getProductTreeList = () => {
treeLoad.value = true;
- productTreeList()
+ productTreeList({ type: 2 })
.then(res => {
// 杞崲鏂扮殑鏁版嵁鏍煎紡
const newList = [];
expandedKeys.value = [];
for (const category of res.data) {
- // 娣诲姞鍒嗙被鑺傜偣
+ // 娣诲姞鍒嗙被鑺傜偣锛堝彧杩斿洖涓�灞傛暟鎹紝涓嶅寘鍚瓙鑺傜偣锛�
const categoryNode = {
label: category.configName,
id: category.configId,
isLeaf: false,
- children: category.materialList.map(item => ({
- id: item.id,
- isLeaf: true,
- label: item.materialName,
- inventoryCategoryId: item.inventoryCategoryId,
- materialTypeId: item.materialTypeId,
- remark: item.remark,
- baseUnit: item.baseUnit,
- })),
+ children: [], // 鍒濆鍖栦负绌烘暟缁勶紝鐐瑰嚮鏃跺啀鍔犺浇
};
newList.push(categoryNode);
- expandedKeys.value.push(category.configName);
}
list.value = newList;
treeLoad.value = false;
@@ -490,9 +481,64 @@
treeLoad.value = false;
});
};
+ const searchFilter1 = () => {
+ getProductTreeList();
+ };
// 杩囨护浜у搧鏍�
const searchFilter = () => {
- proxy.$refs.tree.filter(search.value);
+ if (!search.value) {
+ // 濡傛灉鎼滅储鍏抽敭瀛椾负绌猴紝閲嶆柊鍔犺浇鍘熷鏁版嵁
+ // getProductTreeList();
+ return;
+ }
+
+ treeLoad.value = true;
+ // 璋冪敤 productTreeListQuery 鎺ュ彛杩涜鎼滅储
+ productTreeListQuery({ productName: search.value })
+ .then(res => {
+ // 澶勭悊杩斿洖鐨勬暟鎹�
+ const newList = [];
+ if (res.data && res.data.length > 0) {
+ for (const category of res.data) {
+ for (const item of list.value) {
+ if (item.id == category.configId) {
+ item.children = (category.materialList || []).map(item => ({
+ id: item.id,
+ isLeaf: true,
+ label: item.productName,
+ inventoryCategoryId: item.inventoryCategoryId,
+ materialTypeId: item.materialTypeId,
+ remark: item.remark,
+ unit: item.unit,
+ }));
+ break;
+ }
+ }
+ // 杞崲鏁版嵁鏍煎紡
+ // const categoryNode = {
+ // label: category.configName,
+ // id: category.configId,
+ // isLeaf: false,
+ // children: (category.materialList || []).map(item => ({
+ // id: item.id,
+ // isLeaf: true,
+ // label: item.productName,
+ // inventoryCategoryId: item.inventoryCategoryId,
+ // materialTypeId: item.materialTypeId,
+ // remark: item.remark,
+ // unit: item.unit,
+ // })),
+ // };
+ // newList.push(categoryNode);
+ }
+ }
+ // 浣跨敤 el-tree 鐨勫唴缃繃婊ゅ姛鑳芥悳绱�
+ proxy.$refs.tree.filter(search.value);
+ treeLoad.value = false;
+ })
+ .catch(err => {
+ treeLoad.value = false;
+ });
};
// 鎵撳紑浜у搧寮规
const openProDia = (type, data) => {
@@ -500,18 +546,18 @@
productDia.value = true;
// 閲嶇疆琛ㄥ崟
form.value = {
- materialName: "",
+ productName: "",
inventoryCategoryId: null,
- baseUnit: "",
+ unit: "",
remark: "",
materialTypeId: null,
};
console.log(data);
if (type === "edit" && data) {
// 缂栬緫妯″紡锛屽洖濉暟鎹�
- form.value.materialName = data.label || "";
+ form.value.productName = data.label || "";
form.value.inventoryCategoryId = data.inventoryCategoryId || null;
- form.value.baseUnit = data.baseUnit || "";
+ form.value.unit = data.unit || "";
form.value.remark = data.remark || "";
form.value.materialTypeId = data.materialTypeId || null;
form.value.id = data.id || null;
@@ -540,16 +586,16 @@
modelOperationType.value = type;
modelDia.value = true;
// 閲嶇疆鎵�鏈夊瓧娈�
- modelForm.value.specification = "";
+ modelForm.value.model = "";
modelForm.value.supplyType = "";
modelForm.value.id = null;
modelForm.value.materialCode = null;
if (type === "edit" && data) {
// 缂栬緫妯″紡锛屽洖濉暟鎹�
- modelForm.value.specification = data.specification || "";
+ modelForm.value.model = data.model || "";
modelForm.value.supplyType = data.supplyType || "";
- modelForm.value.id = data.skuId || null;
+ modelForm.value.id = data.id || null;
modelForm.value.materialCode = data.materialCode || null;
}
};
@@ -561,8 +607,8 @@
// const params = {
// materialTypeId: null,
// inventoryCategoryId: form.value.inventoryCategoryId,
- // materialName: form.value.materialName,
- // baseUnit: form.value.baseUnit,
+ // productName: form.value.productName,
+ // unit: form.value.unit,
// remark: form.value.remark,
// };
@@ -684,8 +730,35 @@
};
// 閫夋嫨浜у搧
const handleNodeClick = (val, node, el) => {
- // 鐐瑰嚮闈炲彾瀛愯妭鐐规椂锛屼笉鎵ц浠ヤ笅閫昏緫
+ // 鐐瑰嚮闈炲彾瀛愯妭鐐规椂锛屽姞杞藉瓙鑺傜偣鏁版嵁
if (!val.isLeaf) {
+ // 璋冪敤 productTreeListQuery 鎺ュ彛鑾峰彇瀛愯妭鐐规暟鎹�
+ // treeLoad.value = true;
+ productTreeListQuery({ materialTypeId: val.id })
+ .then(res => {
+ // 澶勭悊杩斿洖鐨勬暟鎹�
+ if (res.data && res.data.length > 0) {
+ const materialList = res.data[0].materialList || [];
+ // 杞崲瀛愯妭鐐规暟鎹牸寮�
+ const children = materialList.map(item => ({
+ id: item.id,
+ isLeaf: true,
+ label: item.productName,
+ inventoryCategoryId: item.inventoryCategoryId,
+ materialTypeId: item.materialTypeId,
+ remark: item.remark,
+ unit: item.unit,
+ }));
+ // 鏇存柊鑺傜偣鐨勫瓙鑺傜偣
+ val.children = children;
+ // 灞曞紑鑺傜偣
+ node.expanded = true;
+ }
+ // treeLoad.value = false;
+ })
+ .catch(err => {
+ // treeLoad.value = false;
+ });
return;
}
// 鍒ゆ柇鏄惁涓哄彾瀛愯妭鐐�
@@ -702,8 +775,8 @@
if (valid) {
// 鏋勫缓鎻愪氦鍙傛暟
const params = {
- materialId: currentId.value,
- specification: modelForm.value.specification,
+ productId: currentId.value,
+ model: modelForm.value.model,
materialCode: modelForm.value.materialCode,
supplyType: modelForm.value.supplyType,
};
@@ -748,10 +821,10 @@
}
tableLoading.value = true;
modelListPage({
- materialId: currentId.value,
+ productId: currentId.value,
current: page.current,
size: page.size,
- specification: specification.value,
+ model: model.value,
materialCode: materialCode.value,
}).then(res => {
console.log("res", res);
@@ -764,7 +837,7 @@
const handleDelete = () => {
let ids = [];
if (selectedRows.value.length > 0) {
- ids = selectedRows.value.map(item => item.skuId);
+ ids = selectedRows.value.map(item => item.id);
} else {
proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
return;
--
Gitblit v1.9.3