This commit is contained in:
余同学 2024-08-18 18:04:26 +08:00
parent 51c8d837c1
commit 637303fc1a
2 changed files with 123 additions and 20 deletions

View File

@ -158,6 +158,7 @@ export default {
if (!newVal) { if (!newVal) {
this.currentPanel = "基础信息"; this.currentPanel = "基础信息";
this.fileList = []; this.fileList = [];
(this.fileListOne = []), (this.fileListTwo = []);
} }
}, },
}, },
@ -186,14 +187,23 @@ export default {
productIntroducePhoto: "", productIntroducePhoto: "",
productPhotoList: [], productPhotoList: [],
productPlace: "", productPlace: "",
productSpecificationList: [], productSpecificationList: [
{
attributeValue: "默认",
costPrice: 20,
salePrice: 30,
stockNum: 10,
weight: 1,
volume: 0.3,
},
],
productUnit: "", productUnit: "",
productVideo: "", productVideo: "",
shelfLife: "", shelfLife: "",
shopId: "", shopId: "",
singlePrice: "", singlePrice: "",
singleStock: "", singleStock: "",
specType: "", specType: 0,
status: "UP", status: "UP",
}; };
this.modalData.merchantId = JSON.parse( this.modalData.merchantId = JSON.parse(
@ -273,7 +283,7 @@ export default {
this.modalData.productSpecificationList this.modalData.productSpecificationList
); );
} else { } else {
if (this.modalData.productAttributeList.length == 0) { if (this.modalData.specType == 0) {
this.$refs.addSpecifications.toggle().update([], []); this.$refs.addSpecifications.toggle().update([], []);
} else { } else {
this.$refs.addSpecifications this.$refs.addSpecifications
@ -287,6 +297,7 @@ export default {
}, },
// //
getSpecs(tableData, AttributeData, salePrice, stockNum) { getSpecs(tableData, AttributeData, salePrice, stockNum) {
this.modalData.specType = 1;
let AttributeList = AttributeData.map((item) => { let AttributeList = AttributeData.map((item) => {
return { return {
attributeName: item.attributeName, attributeName: item.attributeName,
@ -525,6 +536,12 @@ export default {
{ {
label: "规格", label: "规格",
prop: "productSpecificationList", prop: "productSpecificationList",
// required: true,
// rules: {
// required: true,
// message: "",
// trigger: "blur",
// },
type: "jsx", type: "jsx",
render: () => { render: () => {
return ( return (
@ -534,6 +551,22 @@ export default {
); );
}, },
}, },
{
label: "成本",
prop: "minCostPrice",
type: "jsx",
render: () => {
return (
<el-input
readonly={this.modalData.specType != 0}
placeholder="请输入价格"
v-model={this.modalData.minCostPrice}
>
<template slot="append">单位</template>
</el-input>
);
},
},
{ {
label: "价格", label: "价格",
prop: "singlePrice", prop: "singlePrice",
@ -541,10 +574,12 @@ export default {
render: () => { render: () => {
return ( return (
<el-input <el-input
readonly={this.modalData.productAttributeList.length > 0} readonly={this.modalData.specType != 0}
placeholder="请输入价格" placeholder="请输入价格"
v-model={this.modalData.singlePrice} v-model={this.modalData.singlePrice}
></el-input> >
<template slot="append">单位</template>
</el-input>
); );
}, },
}, },
@ -555,13 +590,41 @@ export default {
render: () => { render: () => {
return ( return (
<el-input <el-input
readonly={this.modalData.productAttributeList.length > 0} readonly={this.modalData.specType != 0}
placeholder="请输入库存" placeholder="请输入库存"
v-model={this.modalData.singleStock} v-model={this.modalData.singleStock}
></el-input> ></el-input>
); );
}, },
}, },
{
label: "重量",
prop: "weight",
type: "jsx",
render: () => {
return (
<el-input
readonly={this.modalData.specType != 0}
placeholder="请输入库存"
v-model={this.modalData.weight}
></el-input>
);
},
},
{
label: "体积",
prop: "volume",
type: "jsx",
render: () => {
return (
<el-input
readonly={this.modalData.specType != 0}
placeholder="请输入库存"
v-model={this.modalData.volume}
></el-input>
);
},
},
{ {
label: "其他属性", label: "其他属性",
prop: "productAttributeList", prop: "productAttributeList",
@ -630,8 +693,8 @@ export default {
label: "商品介绍图", label: "商品介绍图",
prop: "productIntroducePhoto", prop: "productIntroducePhoto",
type: "Input", type: "Input",
required: true, // required: true,
rules: { required: true, message: "商品介绍图", trigger: "blur" }, // rules: { required: true, message: "", trigger: "blur" },
placeholder: "商品介绍图", placeholder: "商品介绍图",
type: "jsx", type: "jsx",
render: () => { render: () => {
@ -680,12 +743,12 @@ export default {
{ {
label: "商品视频", label: "商品视频",
prop: "productVideo", prop: "productVideo",
required: true, // required: true,
rules: { // rules: {
required: true, // required: true,
message: "请填写商品描述", // message: "",
trigger: "blur", // trigger: "blur",
}, // },
type: "jsx", type: "jsx",
render: () => { render: () => {
const handleChange = (file, fileList) => { const handleChange = (file, fileList) => {
@ -749,6 +812,25 @@ export default {
this.currentPanel = "其他信息"; this.currentPanel = "其他信息";
} else { } else {
console.log("请求接口", this.modalData); 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) => { this.$api.mer_admin.saveProduct(this.modalData).then((res) => {
console.log(res); console.log(res);
this.$emit("queryList"); this.$emit("queryList");
@ -764,6 +846,25 @@ export default {
loading: this.isLoading, loading: this.isLoading,
submit: true, submit: true,
handle: debounce(() => { 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.modalData.status = "DOWN";
this.$api.mer_admin.saveProduct(this.modalData).then((res) => { this.$api.mer_admin.saveProduct(this.modalData).then((res) => {
console.log(res); console.log(res);

View File

@ -250,6 +250,8 @@ export default {
salePrice: 0, salePrice: 0,
costPrice: 0, costPrice: 0,
stockNum: 0, stockNum: 0,
weight: 0,
volume: 0,
}; };
}); });
console.log(data); console.log(data);
@ -266,7 +268,7 @@ export default {
"min-width": "160px", "min-width": "160px",
}, },
{ {
title: "价格", title: "价格(元)",
field: "salePrice", field: "salePrice",
align: "center", align: "center",
"min-width": "160px", "min-width": "160px",
@ -285,7 +287,7 @@ export default {
}, },
}, },
{ {
title: "成本", title: "成本(元)",
field: "costPrice", field: "costPrice",
align: "center", align: "center",
"min-width": "160px", "min-width": "160px",
@ -324,8 +326,8 @@ export default {
}, },
}, },
{ {
title: "重量", title: "重量(千克)",
field: "stockNum", field: "weight",
align: "center", align: "center",
"min-width": "160px", "min-width": "160px",
type: "jsx", type: "jsx",
@ -335,7 +337,7 @@ export default {
<el-input-number <el-input-number
min={0} min={0}
size="small" size="small"
v-model={row.stockNum} v-model={row.weight}
placeholder="请输入重量" placeholder="请输入重量"
></el-input-number> ></el-input-number>
</div> </div>
@ -343,7 +345,7 @@ export default {
}, },
}, },
{ {
title: "体积", title: "体积(立方米)",
field: "volume", field: "volume",
align: "center", align: "center",
"min-width": "160px", "min-width": "160px",