@@ -361,6 +408,7 @@ export default {
prop: "name",
type: "Input",
required: true,
+ maxlength: "30",
rules: {
required: true,
message: "请输入商品名称",
@@ -382,6 +430,7 @@ export default {
return (
@@ -412,7 +461,7 @@ export default {
return (
);
})}
@@ -490,7 +539,6 @@ export default {
const change = (e) => {
console.log(e);
this.modalData.productPlace = e.join("-");
- console.log(aa);
};
return (
{
console.log(res);
+ this.$emit("queryList");
+ this.toggle();
});
}
}, 300),
},
+ {
+ disabled: () => this.currentPanel != "其他信息",
+ label: "放入仓库",
+ type: "primary",
+ loading: this.isLoading,
+ submit: true,
+ handle: debounce(() => {
+ this.modalData.status = "DOWN";
+ this.$api.mer_admin.saveProduct(this.modalData).then((res) => {
+ console.log(res);
+ this.$emit("queryList");
+ this.toggle();
+ });
+ }, 300),
+ },
];
},
},
diff --git a/src/views/modules/product/popup/add-specifications.vue b/src/views/modules/product/popup/add-specifications.vue
index b2f451a..7e7df04 100644
--- a/src/views/modules/product/popup/add-specifications.vue
+++ b/src/views/modules/product/popup/add-specifications.vue
@@ -136,12 +136,22 @@ export default {
add: () => {
this.modalConfig.title = "属性";
this.$nextTick(() => {
+ // this.$refs.modal.resetFields();
this.modalData = {};
- this.$refs.modal.resetFields();
});
this.isAdd = true;
},
- update: () => {
+ update: (productAttributeList, productSpecificationList) => {
+ console.log(productAttributeList, productSpecificationList);
+ this.AttributeData = productAttributeList.map((item) => {
+ return {
+ attributeName: item.attributeName,
+ attributeValue: item.attributeValue.split(","),
+ id: item.id,
+ inputVisible: false,
+ };
+ });
+ this.tableData = productSpecificationList;
this.isAdd = false;
},
};
@@ -211,9 +221,9 @@ export default {
this.tableData = data.map((item) => {
return {
attributeValue: item,
- salePrice: "",
- costPrice: "",
- stockNum: "",
+ salePrice: 0,
+ costPrice: 0,
+ stockNum: 0,
};
});
console.log(data);
@@ -259,6 +269,7 @@ export default {
this.tableData.length <= 0,
// submit: true,
handle: () => {
let salePrice = ""; //价格范围
From 948f7242451bc6cbc1506b031b701556eefb96c3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=BD=99=E5=90=8C=E5=AD=A6?= <2495967527@qq.com>
Date: Fri, 16 Aug 2024 18:00:30 +0800
Subject: [PATCH 4/6] =?UTF-8?q?=E5=95=86=E5=93=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../modules/product/popup/add-attribute.vue | 31 ++++++--
.../modules/product/popup/add-discount.vue | 2 +-
.../modules/product/popup/add-or-update.vue | 77 ++++++++++++++++---
.../product/popup/add-specifications.vue | 54 +++++++++----
4 files changed, 131 insertions(+), 33 deletions(-)
diff --git a/src/views/modules/product/popup/add-attribute.vue b/src/views/modules/product/popup/add-attribute.vue
index 837752a..712ed8a 100644
--- a/src/views/modules/product/popup/add-attribute.vue
+++ b/src/views/modules/product/popup/add-attribute.vue
@@ -111,15 +111,34 @@ export default {
this.init(cloneDeep(e.row));
}
return {
- add: () => {
+ add: (data) => {
this.modalConfig.title = "添加属性";
- this.$nextTick(() => {
- this.modalData = {};
- this.$refs.ruleForm.resetFields();
- });
+ if (data.length == 0) {
+ this.ruleForm = {
+ name: "",
+ value: [],
+ };
+ } else {
+ this.ruleForm = {
+ name: data[0].name,
+ value: data[0].value.split(","),
+ };
+ }
this.isAdd = true;
},
- update: () => {
+ update: (data) => {
+ console.log(data);
+ if (data.length == 0) {
+ this.ruleForm = {
+ name: "",
+ value: [],
+ };
+ } else {
+ this.ruleForm = {
+ name: data[0].name,
+ value: data[0].value.split(","),
+ };
+ }
this.isAdd = false;
},
};
diff --git a/src/views/modules/product/popup/add-discount.vue b/src/views/modules/product/popup/add-discount.vue
index e270d20..50836bd 100644
--- a/src/views/modules/product/popup/add-discount.vue
+++ b/src/views/modules/product/popup/add-discount.vue
@@ -204,7 +204,7 @@ export default {
.catch(() => {
this.$message({
type: "info",
- message: "已取消删除",
+ message: "已取消",
});
});
},
diff --git a/src/views/modules/product/popup/add-or-update.vue b/src/views/modules/product/popup/add-or-update.vue
index 4722c58..a79fb6b 100644
--- a/src/views/modules/product/popup/add-or-update.vue
+++ b/src/views/modules/product/popup/add-or-update.vue
@@ -64,7 +64,7 @@ export default {
//单库存
singleStock: "",
//其他属性
- otherAttribute: '[{"name":"颜色","value":"黄色;屎黄色"}]',
+ otherAttribute: [], //[{"name":"颜色","value":"黄色;屎黄色"}]
//折扣情况
discountActivity: {
// "endTime": "2024-08-31 00:00:00",
@@ -146,6 +146,8 @@ export default {
fullscreen: true,
},
fileList: [], //回显图片
+ fileListOne: [], //介绍图
+ fileListTwo: [], //视频
place: "", //场地
passCheck: [], //通行证
};
@@ -178,7 +180,7 @@ export default {
description: "",
merchantId: "",
name: "",
- otherAttribute: "",
+ otherAttribute: [],
productAttributeList: [],
productCategoryId: "",
productIntroducePhoto: "",
@@ -220,20 +222,67 @@ export default {
url: item.url,
};
});
+ if (row.productIntroducePhoto) {
+ this.fileListOne = [
+ {
+ name: "",
+ url: row.productIntroducePhoto,
+ },
+ ];
+ } else {
+ this.fileListOne = [];
+ }
+ if (row.productVideo) {
+ this.fileListTwo = [
+ {
+ name: "",
+ url: row.productVideo,
+ },
+ ];
+ } else {
+ this.fileListTwo = [];
+ }
this.place = row.productPlace.split("-");
this.modalData = row;
+ this.$set(this.modalData, "singleStock", row.stockNum);
+ if (row.minSalePrice == row.maxSalePrice) {
+ this.$set(this.modalData, "singlePrice", row.maxSalePrice);
+ } else {
+ this.$set(
+ this.modalData,
+ "singlePrice",
+ row.minSalePrice + "~" + row.maxSalePrice
+ );
+ }
+ if (!row.productAttributeList) {
+ this.$set(this.modalData, "productAttributeList", []);
+ }
+ if (row.otherAttribute) {
+ this.modalData.otherAttribute = JSON.parse(row.otherAttribute);
+ } else {
+ this.modalData.otherAttribute = [];
+ }
},
addSpecs() {
console.log("123");
if (this.isAdd) {
- this.$refs.addSpecifications.toggle().add();
- } else {
this.$refs.addSpecifications
.toggle()
- .update(
+ .add(
this.modalData.productAttributeList,
this.modalData.productSpecificationList
);
+ } else {
+ if (this.modalData.productAttributeList.length == 0) {
+ this.$refs.addSpecifications.toggle().update([], []);
+ } else {
+ this.$refs.addSpecifications
+ .toggle()
+ .update(
+ this.modalData.productAttributeList,
+ this.modalData.productSpecificationList
+ );
+ }
}
},
//获取属性
@@ -250,7 +299,11 @@ export default {
this.$set(this.modalData, "singleStock", stockNum);
},
addAttribute() {
- this.$refs.addAttribute.toggle().add();
+ if (this.isAdd) {
+ this.$refs.addAttribute.toggle().add(this.modalData.otherAttribute);
+ } else {
+ this.$refs.addAttribute.toggle().update(this.modalData.otherAttribute);
+ }
},
getAttribute(data) {
console.log(data);
@@ -488,9 +541,7 @@ export default {
render: () => {
return (
0
- }
+ readonly={this.modalData.productAttributeList.length > 0}
placeholder="请输入价格"
v-model={this.modalData.singlePrice}
>
@@ -504,9 +555,7 @@ export default {
render: () => {
return (
0
- }
+ readonly={this.modalData.productAttributeList.length > 0}
placeholder="请输入库存"
v-model={this.modalData.singleStock}
>
@@ -603,6 +652,8 @@ export default {
drag
action={this.$api.mer_admin.uploadFile()}
limit={1}
+ file-list={this.fileListOne}
+ list-type="picture"
{...{
props: {
"on-change": handleChange,
@@ -652,6 +703,8 @@ export default {
drag
action={this.$api.mer_admin.uploadFile()}
limit={1}
+ file-list={this.fileListTwo}
+ list-type="picture"
{...{
props: {
"on-change": handleChange,
diff --git a/src/views/modules/product/popup/add-specifications.vue b/src/views/modules/product/popup/add-specifications.vue
index 7e7df04..c0dda21 100644
--- a/src/views/modules/product/popup/add-specifications.vue
+++ b/src/views/modules/product/popup/add-specifications.vue
@@ -133,24 +133,50 @@ export default {
this.init(cloneDeep(e.row));
}
return {
- add: () => {
- this.modalConfig.title = "属性";
- this.$nextTick(() => {
- // this.$refs.modal.resetFields();
- this.modalData = {};
- });
+ add: (productAttributeList, productSpecificationList) => {
+ this.modalConfig.title = "添加属性";
+ if (productAttributeList.length == 0) {
+ this.AttributeData = [
+ {
+ attributeName: "",
+ attributeValue: [],
+ inputVisible: false,
+ },
+ ];
+ } else {
+ this.AttributeData = productAttributeList.map((item) => {
+ return {
+ attributeName: item.attributeName,
+ attributeValue: item.attributeValue.split(","),
+ id: item.id,
+ inputVisible: false,
+ };
+ });
+ }
+ this.tableData = productSpecificationList;
this.isAdd = true;
},
update: (productAttributeList, productSpecificationList) => {
+ this.modalConfig.title = "编辑属性";
console.log(productAttributeList, productSpecificationList);
- this.AttributeData = productAttributeList.map((item) => {
- return {
- attributeName: item.attributeName,
- attributeValue: item.attributeValue.split(","),
- id: item.id,
- inputVisible: false,
- };
- });
+ if (productAttributeList.length == 0) {
+ this.AttributeData = [
+ {
+ attributeName: "",
+ attributeValue: [],
+ inputVisible: false,
+ },
+ ];
+ } else {
+ this.AttributeData = productAttributeList.map((item) => {
+ return {
+ attributeName: item.attributeName,
+ attributeValue: item.attributeValue.split(","),
+ id: item.id,
+ inputVisible: false,
+ };
+ });
+ }
this.tableData = productSpecificationList;
this.isAdd = false;
},
From 7616190cd2069e2f31df8a0a4d31401fed3ac9fb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=BD=99=E5=90=8C=E5=AD=A6?= <2495967527@qq.com>
Date: Sun, 18 Aug 2024 14:33:37 +0800
Subject: [PATCH 5/6] add
---
.../product/popup/add-specifications.vue | 38 +++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/src/views/modules/product/popup/add-specifications.vue b/src/views/modules/product/popup/add-specifications.vue
index c0dda21..be0ed54 100644
--- a/src/views/modules/product/popup/add-specifications.vue
+++ b/src/views/modules/product/popup/add-specifications.vue
@@ -323,6 +323,44 @@ export default {
);
},
},
+ {
+ title: "重量",
+ field: "stockNum",
+ align: "center",
+ "min-width": "160px",
+ type: "jsx",
+ render: ({ row }) => {
+ return (
+
+
+
+ );
+ },
+ },
+ {
+ title: "体积",
+ field: "volume",
+ align: "center",
+ "min-width": "160px",
+ type: "jsx",
+ render: ({ row }) => {
+ return (
+
+
+
+ );
+ },
+ },
{
title: "操作",
fixed: "right",
From 637303fc1a3f96f578854cb53026fa332eaade2f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=BD=99=E5=90=8C=E5=AD=A6?= <2495967527@qq.com>
Date: Sun, 18 Aug 2024 18:04:26 +0800
Subject: [PATCH 6/6] add
---
.../modules/product/popup/add-or-update.vue | 129 ++++++++++++++++--
.../product/popup/add-specifications.vue | 14 +-
2 files changed, 123 insertions(+), 20 deletions(-)
diff --git a/src/views/modules/product/popup/add-or-update.vue b/src/views/modules/product/popup/add-or-update.vue
index a79fb6b..f8fa261 100644
--- a/src/views/modules/product/popup/add-or-update.vue
+++ b/src/views/modules/product/popup/add-or-update.vue
@@ -158,6 +158,7 @@ export default {
if (!newVal) {
this.currentPanel = "基础信息";
this.fileList = [];
+ (this.fileListOne = []), (this.fileListTwo = []);
}
},
},
@@ -186,14 +187,23 @@ export default {
productIntroducePhoto: "",
productPhotoList: [],
productPlace: "",
- productSpecificationList: [],
+ productSpecificationList: [
+ {
+ attributeValue: "默认",
+ costPrice: 20,
+ salePrice: 30,
+ stockNum: 10,
+ weight: 1,
+ volume: 0.3,
+ },
+ ],
productUnit: "",
productVideo: "",
shelfLife: "",
shopId: "",
singlePrice: "",
singleStock: "",
- specType: "",
+ specType: 0,
status: "UP",
};
this.modalData.merchantId = JSON.parse(
@@ -273,7 +283,7 @@ export default {
this.modalData.productSpecificationList
);
} else {
- if (this.modalData.productAttributeList.length == 0) {
+ if (this.modalData.specType == 0) {
this.$refs.addSpecifications.toggle().update([], []);
} else {
this.$refs.addSpecifications
@@ -287,6 +297,7 @@ export default {
},
//获取属性
getSpecs(tableData, AttributeData, salePrice, stockNum) {
+ this.modalData.specType = 1;
let AttributeList = AttributeData.map((item) => {
return {
attributeName: item.attributeName,
@@ -525,6 +536,12 @@ export default {
{
label: "规格",
prop: "productSpecificationList",
+ // required: true,
+ // rules: {
+ // required: true,
+ // message: "请选择销售单位",
+ // trigger: "blur",
+ // },
type: "jsx",
render: () => {
return (
@@ -534,6 +551,22 @@ export default {
);
},
},
+ {
+ label: "成本",
+ prop: "minCostPrice",
+ type: "jsx",
+ render: () => {
+ return (
+
+ 单位(元)
+
+ );
+ },
+ },
{
label: "价格",
prop: "singlePrice",
@@ -541,10 +574,12 @@ export default {
render: () => {
return (
0}
+ readonly={this.modalData.specType != 0}
placeholder="请输入价格"
v-model={this.modalData.singlePrice}
- >
+ >
+ 单位(元)
+
);
},
},
@@ -555,13 +590,41 @@ export default {
render: () => {
return (
0}
+ readonly={this.modalData.specType != 0}
placeholder="请输入库存"
v-model={this.modalData.singleStock}
>
);
},
},
+ {
+ label: "重量",
+ prop: "weight",
+ type: "jsx",
+ render: () => {
+ return (
+
+ );
+ },
+ },
+ {
+ label: "体积",
+ prop: "volume",
+ type: "jsx",
+ render: () => {
+ return (
+
+ );
+ },
+ },
{
label: "其他属性",
prop: "productAttributeList",
@@ -630,8 +693,8 @@ export default {
label: "商品介绍图",
prop: "productIntroducePhoto",
type: "Input",
- required: true,
- rules: { required: true, message: "商品介绍图", trigger: "blur" },
+ // required: true,
+ // rules: { required: true, message: "商品介绍图", trigger: "blur" },
placeholder: "商品介绍图",
type: "jsx",
render: () => {
@@ -680,12 +743,12 @@ export default {
{
label: "商品视频",
prop: "productVideo",
- required: true,
- rules: {
- required: true,
- message: "请填写商品描述",
- trigger: "blur",
- },
+ // required: true,
+ // rules: {
+ // required: true,
+ // message: "请填写商品描述",
+ // trigger: "blur",
+ // },
type: "jsx",
render: () => {
const handleChange = (file, fileList) => {
@@ -749,6 +812,25 @@ export default {
this.currentPanel = "其他信息";
} else {
console.log("请求接口", this.modalData);
+ if (this.modalData.specType == 0) {
+ this.modalData.productAttributeList = [
+ {
+ id: "1821213026050191360",
+ attributeName: "重量",
+ attributeValue: "1斤",
+ },
+ ];
+ this.modalData.productSpecificationList = [
+ {
+ attributeValue: "默认",
+ costPrice: this.modalData.minCostPrice,
+ salePrice: this.modalData.singlePrice,
+ stockNum: this.modalData.singleStock,
+ weight: this.modalData.weight,
+ volume: this.modalData.volume,
+ },
+ ];
+ }
this.$api.mer_admin.saveProduct(this.modalData).then((res) => {
console.log(res);
this.$emit("queryList");
@@ -764,6 +846,25 @@ export default {
loading: this.isLoading,
submit: true,
handle: debounce(() => {
+ if (this.modalData.specType == 0) {
+ this.modalData.productAttributeList = [
+ {
+ id: "1821213026050191360",
+ attributeName: "重量",
+ attributeValue: "1斤",
+ },
+ ];
+ this.modalData.productSpecificationList = [
+ {
+ attributeValue: "默认",
+ costPrice: this.modalData.minCostPrice,
+ salePrice: this.modalData.singlePrice,
+ stockNum: this.modalData.singleStock,
+ weight: this.modalData.weight,
+ volume: this.modalData.volume,
+ },
+ ];
+ }
this.modalData.status = "DOWN";
this.$api.mer_admin.saveProduct(this.modalData).then((res) => {
console.log(res);
diff --git a/src/views/modules/product/popup/add-specifications.vue b/src/views/modules/product/popup/add-specifications.vue
index be0ed54..15b1c23 100644
--- a/src/views/modules/product/popup/add-specifications.vue
+++ b/src/views/modules/product/popup/add-specifications.vue
@@ -250,6 +250,8 @@ export default {
salePrice: 0,
costPrice: 0,
stockNum: 0,
+ weight: 0,
+ volume: 0,
};
});
console.log(data);
@@ -266,7 +268,7 @@ export default {
"min-width": "160px",
},
{
- title: "价格",
+ title: "价格(元)",
field: "salePrice",
align: "center",
"min-width": "160px",
@@ -285,7 +287,7 @@ export default {
},
},
{
- title: "成本",
+ title: "成本(元)",
field: "costPrice",
align: "center",
"min-width": "160px",
@@ -324,8 +326,8 @@ export default {
},
},
{
- title: "重量",
- field: "stockNum",
+ title: "重量(千克)",
+ field: "weight",
align: "center",
"min-width": "160px",
type: "jsx",
@@ -335,7 +337,7 @@ export default {
@@ -343,7 +345,7 @@ export default {
},
},
{
- title: "体积",
+ title: "体积(立方米)",
field: "volume",
align: "center",
"min-width": "160px",