From c5f6d0f0c466b973040e821bf0a04017c9136141 Mon Sep 17 00:00:00 2001
From: cookiemy <1946749843@qq.com>
Date: Mon, 1 Jul 2024 15:17:22 +0800
Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E5=A4=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/components/category/category.vue | 11 +-
.../src/views/product/base/product/add.vue | 259 +-----------------
.../src/views/product/base/product/edit.vue | 51 +---
.../src/views/product/base/product/index.vue | 26 +-
4 files changed, 44 insertions(+), 303 deletions(-)
diff --git a/jjj_erp_admin/src/components/category/category.vue b/jjj_erp_admin/src/components/category/category.vue
index 9001591..c255e63 100644
--- a/jjj_erp_admin/src/components/category/category.vue
+++ b/jjj_erp_admin/src/components/category/category.vue
@@ -6,10 +6,11 @@
>
-
{{ node.label }}
-
+
@@ -75,7 +76,9 @@ export default {
},
},
},
- created() {},
+ created() {
+ console.log(this.$props.data, "data");
+ },
methods: {
searchFunc(e) {
this.$emit("search", this.search);
diff --git a/jjj_erp_admin/src/views/product/base/product/add.vue b/jjj_erp_admin/src/views/product/base/product/add.vue
index 87c1a3f..9685d3c 100644
--- a/jjj_erp_admin/src/views/product/base/product/add.vue
+++ b/jjj_erp_admin/src/views/product/base/product/add.vue
@@ -29,18 +29,12 @@
-
+
-
+
@@ -129,90 +123,6 @@
-
@@ -220,36 +130,8 @@
-
-
-
@@ -260,11 +142,6 @@
-
@@ -487,24 +364,6 @@
})
.catch((error) => {});
},
- // productGetMaxProductCode() {
- // let self = this;
- // ProductApi.productGetMaxProductCode()
- // .then((res) => {})
- // .catch((error) => {});
- // },
- // productToAdd() {
- // let self = this;
- // ProductApi.productToAdd()
- // .then((res) => {
- // self.options = res.data.attribute;
- // self.unitList= res.data.unit;
- // self.mfrsList=res.data.mfrs;
- // self.categoryList=res.data.category;
- // })
- // .catch((error) => {
- // });
- // },
someFunctionToGetIndex(skuType) {
if (skuType == "skuOne") {
return 0; // 返回 skuOne 对应的索引值
@@ -522,71 +381,6 @@
arr.splice(index, 1);
}
},
- // onSkuChange() {
- // this.autoSkuList();
- // },
- // onSkuOneDeSelect(value) {
- // this.removeByVal(this.form.skuOne, value);
- // this.autoSkuList();
- // },
- // onSkuTwoDeSelect(value) {
- // this.removeByVal(this.form.skuTwo, value);
- // this.autoSkuList();
- // },
- // onSkuThreeDeSelect(value) {
- // this.removeByVal(this.form.skuThree, value);
- // this.autoSkuList();
- // },
- // autoSkuList() {
- // let skuOneData = this.form.skuOne;
- // let skuTwoData = this.form.skuTwo;
- // let skuThreeData = this.form.skuThree;
- // // 清空现有的商品表格数据
- // let meTableData = [];
- // let currentBarCode = localStorage.getItem("firstBarCode");
- // // 计算可能的组合,并生成商品表格数据
- // skuOneData.forEach((sku1) => {
- // if (skuTwoData.length) {
- // skuTwoData.forEach((sku2) => {
- // if (skuThreeData.length) {
- // skuThreeData.forEach((sku3) => {
- // // 生成新的商品数据对象
- // let newData = {
- // sku: `${sku1}/${sku2}/${sku3}`, // 多属性字段值
- // productCode: currentBarCode,
- // };
- // // 将新的商品数据对象添加到商品表格数据数组中
- // meTableData.push(newData);
- // currentBarCode++;
- // });
- // } else {
- // // 生成新的商品数据对象(无第三个属性)
- // let newData = {
- // sku: `${sku1}/${sku2}`, // 多属性字段值
- // productCode: currentBarCode,
- // // 其他字段值根据需要添加
- // };
- // // 将新的商品数据对象添加到商品表格数据数组中
- // meTableData.push(newData);
- // currentBarCode++;
- // }
- // });
- // } else {
- // // 生成新的商品数据对象(无第二、第三个属性)
- // let newData = {
- // sku: `${sku1}`, // 多属性字段值
- // productCode: currentBarCode,
- // };
- // // 将新的商品数据对象添加到商品表格数据数组中
- // meTableData.push(newData);
- // currentBarCode++;
- // }
- // });
-
- // // 更新组件中的商品表格数据源
- // this.form.options = meTableData;
- // console.log(this.form.options, "option");
- // },
deleteImg(index) {
this.form.image.splice(index, 1);
},
@@ -706,35 +500,6 @@
let currentBarCode = localStorage.getItem("firstBarCode") || 1000;
return parseInt(currentBarCode) + index;
},
- // handleSpecChange(value) {
- // this.manySkuSelected = value.length;
- // console.log(this.manySkuSelected, "manySkuSelected");
- // this.form.skuOne = [];
- // this.form.skuTwo = [];
- // this.form.skuThree = [];
- // if (value.length <= 3) {
- // let skuOneId = value[0];
- // let skuTwoId = value[1];
- // let skuThreeId = value[2];
- // console.log(skuOneId, "skuOneId");
- // this.options.forEach((item, index) => {
- // console.log(item, "index");
- // if (index == skuOneId) {
- // this.skuOneTitle = item.attributeName;
- // this.skuOneList = this.options[index].valueList;
- // }
- // if (index == skuTwoId) {
- // this.skuTwoTitle = item.attributeName;
- // this.skuTwoList = this.options[index].valueList;
- // }
- // if (index == skuThreeId) {
- // this.skuThreeTitle = item.attributeName;
- // this.skuThreeList = this.options[index].valueList;
- // }
- // });
- // }
- // this.form.options = [];
- // },
handleUnitChange() {
if (this.form.multiUnit) {
// 如果勾选了多单位,将输入框改为选择框
@@ -751,18 +516,15 @@
/*添加用户*/
addUser() {
let self = this;
- // if(!self.form.skuList){
- // ElMessage.error("属性不能为空");
- // return;
- // }
let params = self.form;
- self.editOpen = true;
+
console.log(params, "params");
self.$refs.form.validate((valid) => {
if (valid) {
+ self.editOpen = true;
self.loading = true;
params.skuList = params.options;
- ProductApi.productAdd(params)
+ ProductApi.productAdd(params,true)
.then((data) => {
self.loading = false;
ElMessage({
@@ -776,9 +538,7 @@
self.loading = false;
self.editOpen = false;
});
- } else {
- self.editOpen = false;
- }
+ }
});
},
@@ -820,13 +580,6 @@
this.isProductUpload = false;
console.log(this.form.image, "this.form.image ");
},
- // returnImgsFunc(e) {
- // if (e != null && e.length > 0) {
- // this.filePath = e[0].filePath;
- // this.form.imageId = e[0].fileId;
- // }
- // this.isProductUpload = false;
- // },
},
};
diff --git a/jjj_erp_admin/src/views/product/base/product/edit.vue b/jjj_erp_admin/src/views/product/base/product/edit.vue
index 64e1c2a..0419ade 100644
--- a/jjj_erp_admin/src/views/product/base/product/edit.vue
+++ b/jjj_erp_admin/src/views/product/base/product/edit.vue
@@ -308,11 +308,6 @@
-
@@ -359,27 +354,6 @@
-
@@ -526,11 +500,11 @@ export default {
this.dialogVisible = this.open_edit;
if (this.dialogVisible) {
console.log(this.dialogVisible, "this.form");
- this.$nextTick(() => {
+ this.$nextTick(async () => {
this.form = this.editform;
this.productToAdd();
if (this.copy) {
- this.productGetMaxProductCode();
+ await this.productGetMaxProductCode();
this.form.productCode = "";
let firstBarCode = parseInt(localStorage.getItem("firstBarCode"), 10);
this.form.skuList.forEach((option) => {
@@ -541,20 +515,23 @@ export default {
}
this.form.options = this.form.skuList;
console.log(this.form.options, "this.options");
- // this.addOptions();
});
}
},
methods: {
productGetMaxProductCode() {
- let self = this;
- ProductApi.productGetMaxProductCode()
- .then((res) => {
- localStorage.removeItem("firstBarCode");
- self.firstBarCode = res.data;
- localStorage.setItem("firstBarCode", self.firstBarCode);
- })
- .catch((error) => {});
+ return new Promise((resolve, reject) => {
+ ProductApi.productGetMaxProductCode()
+ .then((res) => {
+ localStorage.removeItem("firstBarCode");
+ this.firstBarCode = res.data;
+ localStorage.setItem("firstBarCode", this.firstBarCode);
+ resolve();
+ })
+ .catch((error) => {
+ reject(error);
+ });
+ });
},
productToAdd() {
let self = this;
diff --git a/jjj_erp_admin/src/views/product/base/product/index.vue b/jjj_erp_admin/src/views/product/base/product/index.vue
index af1abf4..ebb003d 100644
--- a/jjj_erp_admin/src/views/product/base/product/index.vue
+++ b/jjj_erp_admin/src/views/product/base/product/index.vue
@@ -23,10 +23,6 @@
placeholder="请输入商品名称"
>
-
{});
},
- categoryLists() {
+ categoryLists(row) {
let self = this;
let Params = {};
+ if (row) {
+ Params.name = row;
+ }
ProductApi.categoryList(Params, true)
.then((res) => {
- self.categoryList = res.data;
+ const allCategories = {
+ name: "所有系统分类",
+ categoryId: 0,
+ isRoot: true,
+ children: res.data,
+ };
+ self.categoryList = [allCategories];
+ self.getData(self.categoryList[0]);
})
.catch((error) => {});
},
@@ -568,7 +577,6 @@ export default {
} else {
Params.categoryId = 0;
}
- // Params.type = self.activeName;
self.loading = true;
ProductApi.productList(Params, true)
.then((res) => {