2024-08-07 09:55:31 +00:00
|
|
|
|
<template>
|
2024-08-09 10:04:10 +00:00
|
|
|
|
<div>
|
|
|
|
|
<obj-modal
|
|
|
|
|
class="obj-modal"
|
|
|
|
|
ref="modal"
|
|
|
|
|
labelWidth="100px"
|
|
|
|
|
:modalCols="modalCols"
|
|
|
|
|
:modalConfig="modalConfig"
|
|
|
|
|
:modalData="modalData"
|
|
|
|
|
:modalHandles="modalHandles"
|
|
|
|
|
>
|
|
|
|
|
<template slot="dialog__before">
|
2024-08-13 10:03:15 +00:00
|
|
|
|
<el-tabs :before-leave="beforeTabLeave" v-model="currentPanel">
|
2024-08-09 10:04:10 +00:00
|
|
|
|
<el-tab-pane label="基础信息" name="基础信息"></el-tab-pane>
|
|
|
|
|
<el-tab-pane label="销售信息" name="销售信息"></el-tab-pane>
|
|
|
|
|
<el-tab-pane label="其他信息" name="其他信息"></el-tab-pane>
|
|
|
|
|
</el-tabs>
|
|
|
|
|
</template>
|
2024-08-07 09:55:31 +00:00
|
|
|
|
</obj-modal>
|
2024-08-12 10:05:59 +00:00
|
|
|
|
<!-- 添加规格 -->
|
|
|
|
|
<addSpecifications
|
|
|
|
|
@getSpecs="getSpecs"
|
|
|
|
|
ref="addSpecifications"
|
|
|
|
|
></addSpecifications>
|
|
|
|
|
<!-- 属性 -->
|
|
|
|
|
<addAttribute
|
|
|
|
|
@getAttribute="getAttribute"
|
|
|
|
|
ref="addAttribute"
|
|
|
|
|
></addAttribute>
|
2024-08-09 10:04:10 +00:00
|
|
|
|
</div>
|
2024-08-07 09:55:31 +00:00
|
|
|
|
</template>
|
|
|
|
|
<script>
|
2024-08-12 10:05:59 +00:00
|
|
|
|
import addAttribute from "./add-attribute.vue";
|
2024-08-09 10:04:10 +00:00
|
|
|
|
import addSpecifications from "./add-specifications.vue";
|
2024-08-07 09:55:31 +00:00
|
|
|
|
import { debounce, cloneDeep } from "lodash";
|
|
|
|
|
export default {
|
2024-08-12 10:05:59 +00:00
|
|
|
|
components: { addSpecifications, addAttribute },
|
2024-08-09 10:04:10 +00:00
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
currentPanel: "基础信息",
|
|
|
|
|
modalData: {
|
|
|
|
|
merchantId: null,
|
|
|
|
|
shopId: null,
|
|
|
|
|
id: null,
|
|
|
|
|
name: "",
|
|
|
|
|
productCategoryId: "",
|
|
|
|
|
productPhotoList: [
|
|
|
|
|
// {
|
|
|
|
|
// "url": "https://dmjs.obs.cn-east-3.myhuaweicloud.com/hhsh/20240807/914faade6f82459388d084c14c91f866.png",
|
|
|
|
|
// "isMain": 1
|
|
|
|
|
// }
|
|
|
|
|
],
|
|
|
|
|
description: "",
|
|
|
|
|
productUnit: "",
|
|
|
|
|
productPlace: "",
|
|
|
|
|
//保质期
|
|
|
|
|
shelfLife: "",
|
|
|
|
|
//产品介绍图
|
|
|
|
|
productIntroducePhoto: "",
|
|
|
|
|
//产品介绍视频
|
|
|
|
|
productVideo: "",
|
|
|
|
|
//单价
|
|
|
|
|
singlePrice: "",
|
|
|
|
|
//单库存
|
|
|
|
|
singleStock: "",
|
|
|
|
|
//其他属性
|
2024-08-16 10:00:30 +00:00
|
|
|
|
otherAttribute: [], //[{"name":"颜色","value":"黄色;屎黄色"}]
|
2024-08-09 10:04:10 +00:00
|
|
|
|
//折扣情况
|
|
|
|
|
discountActivity: {
|
|
|
|
|
// "endTime": "2024-08-31 00:00:00",
|
|
|
|
|
// "id": "1821213180710957056",
|
|
|
|
|
// "merchantId": "1818337963053297664",
|
|
|
|
|
// "ruleObject": {
|
|
|
|
|
// "discount": 5,
|
|
|
|
|
// "limitCount": 99
|
|
|
|
|
// },
|
|
|
|
|
// "shopId": "1818337963523059712",
|
|
|
|
|
// "startTime": "2024-08-01 00:00:00",
|
|
|
|
|
// "type": 0
|
|
|
|
|
},
|
|
|
|
|
//是否折扣
|
|
|
|
|
isDiscount: 1,
|
|
|
|
|
marketId: null,
|
|
|
|
|
//最大消费
|
|
|
|
|
maxCostPrice: 15,
|
|
|
|
|
//市场最大消费
|
|
|
|
|
maxMarketPrice: 35,
|
|
|
|
|
//最大售价
|
|
|
|
|
maxSalePrice: 17.5,
|
|
|
|
|
//最低售价
|
|
|
|
|
minCostPrice: 10,
|
|
|
|
|
//市场最低售价
|
|
|
|
|
minMarketPrice: 20,
|
|
|
|
|
minSalePrice: 10,
|
|
|
|
|
salePrice: 20,
|
|
|
|
|
sort: 999,
|
2024-08-12 10:05:59 +00:00
|
|
|
|
status: "DOWN", //up 上架 //DOWN 放入仓库
|
2024-08-09 10:04:10 +00:00
|
|
|
|
stockNum: 200,
|
|
|
|
|
specType: 1,
|
|
|
|
|
productAttributeList: [
|
|
|
|
|
// {
|
|
|
|
|
// "id": "1821213026050191360",
|
|
|
|
|
// "attributeName": "重量",
|
|
|
|
|
// "attributeValue": "1斤,2斤"
|
|
|
|
|
// }
|
|
|
|
|
],
|
|
|
|
|
productSpecificationList: [
|
|
|
|
|
// {
|
|
|
|
|
// "attributeValue": "重量1斤",
|
|
|
|
|
// "costPrice": 10,
|
|
|
|
|
// "id": "1821213026083745792",
|
|
|
|
|
// "isDiscount": 1,
|
|
|
|
|
// "limitCount": 99,
|
|
|
|
|
// "marketPrice": 20,
|
|
|
|
|
// "productId": "1821207097380515840",
|
|
|
|
|
// "saleNum": 0,
|
|
|
|
|
// "salePrice": 10,
|
|
|
|
|
// "stockNum": 100,
|
|
|
|
|
// "virtualSaleNum": 0,
|
|
|
|
|
// "warnStockNum": 0,
|
|
|
|
|
// "_id": "重量1斤",
|
|
|
|
|
// "value": "售价¥10 成本¥10 库存100"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "attributeValue": "重量2斤",
|
|
|
|
|
// "costPrice": 15,
|
|
|
|
|
// "id": "1821213026083745793",
|
|
|
|
|
// "isDiscount": 1,
|
|
|
|
|
// "limitCount": 99,
|
|
|
|
|
// "marketPrice": 35,
|
|
|
|
|
// "productId": "1821207097380515840",
|
|
|
|
|
// "saleNum": 0,
|
|
|
|
|
// "salePrice": 17.5,
|
|
|
|
|
// "stockNum": 100,
|
|
|
|
|
// "virtualSaleNum": 0,
|
|
|
|
|
// "warnStockNum": 0,
|
|
|
|
|
// "_id": "重量2斤",
|
|
|
|
|
// "value": "售价¥17.5 成本¥15 库存100"
|
|
|
|
|
// }
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
modalConfig: {
|
|
|
|
|
title: "编辑商品",
|
|
|
|
|
show: false,
|
|
|
|
|
width: "1300px",
|
|
|
|
|
fullscreen: true,
|
|
|
|
|
},
|
|
|
|
|
fileList: [], //回显图片
|
2024-08-16 10:00:30 +00:00
|
|
|
|
fileListOne: [], //介绍图
|
|
|
|
|
fileListTwo: [], //视频
|
2024-08-12 10:05:59 +00:00
|
|
|
|
place: "", //场地
|
2024-08-13 10:03:15 +00:00
|
|
|
|
passCheck: [], //通行证
|
2024-08-09 10:04:10 +00:00
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
mounted() {},
|
2024-08-15 10:01:50 +00:00
|
|
|
|
watch: {
|
|
|
|
|
"modalConfig.show"(newVal) {
|
|
|
|
|
if (!newVal) {
|
|
|
|
|
this.currentPanel = "基础信息";
|
|
|
|
|
this.fileList = [];
|
2024-08-18 10:04:26 +00:00
|
|
|
|
(this.fileListOne = []), (this.fileListTwo = []);
|
2024-08-15 10:01:50 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
2024-08-09 10:04:10 +00:00
|
|
|
|
methods: {
|
|
|
|
|
toggle(e) {
|
|
|
|
|
if (this.modalConfig.show == false) {
|
|
|
|
|
this.modalConfig.show = true;
|
|
|
|
|
} else {
|
|
|
|
|
this.modalConfig.show = false;
|
|
|
|
|
}
|
|
|
|
|
if (e) {
|
|
|
|
|
console.log(e);
|
2024-08-15 10:01:50 +00:00
|
|
|
|
this.init(cloneDeep(e));
|
2024-08-09 10:04:10 +00:00
|
|
|
|
}
|
|
|
|
|
return {
|
2024-08-15 10:01:50 +00:00
|
|
|
|
add: () => {
|
2024-08-12 10:05:59 +00:00
|
|
|
|
this.$nextTick(() => {
|
2024-08-15 10:01:50 +00:00
|
|
|
|
this.modalConfig.title = "添加商品";
|
2024-08-12 10:05:59 +00:00
|
|
|
|
this.modalData = {
|
|
|
|
|
description: "",
|
|
|
|
|
merchantId: "",
|
|
|
|
|
name: "",
|
2024-08-16 10:00:30 +00:00
|
|
|
|
otherAttribute: [],
|
2024-08-12 10:05:59 +00:00
|
|
|
|
productAttributeList: [],
|
|
|
|
|
productCategoryId: "",
|
|
|
|
|
productIntroducePhoto: "",
|
|
|
|
|
productPhotoList: [],
|
|
|
|
|
productPlace: "",
|
2024-08-20 10:00:08 +00:00
|
|
|
|
productSpecificationList: [],
|
2024-08-12 10:05:59 +00:00
|
|
|
|
productUnit: "",
|
|
|
|
|
productVideo: "",
|
|
|
|
|
shelfLife: "",
|
|
|
|
|
shopId: "",
|
|
|
|
|
singlePrice: "",
|
|
|
|
|
singleStock: "",
|
2024-08-18 10:04:26 +00:00
|
|
|
|
specType: 0,
|
2024-08-12 10:05:59 +00:00
|
|
|
|
status: "UP",
|
|
|
|
|
};
|
|
|
|
|
this.modalData.merchantId = JSON.parse(
|
|
|
|
|
sessionStorage.getItem("userInfo")
|
|
|
|
|
).merchantId;
|
|
|
|
|
this.modalData.shopId = JSON.parse(
|
|
|
|
|
sessionStorage.getItem("userInfo")
|
|
|
|
|
).shopId;
|
2024-08-15 10:01:50 +00:00
|
|
|
|
this.passCheck = [];
|
|
|
|
|
this.place = [];
|
2024-08-12 10:05:59 +00:00
|
|
|
|
});
|
|
|
|
|
|
2024-08-09 10:04:10 +00:00
|
|
|
|
this.isAdd = true;
|
|
|
|
|
},
|
2024-08-15 10:01:50 +00:00
|
|
|
|
update: () => {
|
|
|
|
|
this.modalConfig.title = "编辑商品";
|
2024-08-09 10:04:10 +00:00
|
|
|
|
this.isAdd = false;
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
},
|
2024-08-15 10:01:50 +00:00
|
|
|
|
init(row) {
|
|
|
|
|
console.log(row);
|
|
|
|
|
this.fileList = row.productPhotoList.map((item) => {
|
|
|
|
|
return {
|
|
|
|
|
name: "",
|
|
|
|
|
url: item.url,
|
|
|
|
|
};
|
|
|
|
|
});
|
2024-08-16 10:00:30 +00:00
|
|
|
|
if (row.productIntroducePhoto) {
|
|
|
|
|
this.fileListOne = [
|
|
|
|
|
{
|
|
|
|
|
name: "",
|
|
|
|
|
url: row.productIntroducePhoto,
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
} else {
|
|
|
|
|
this.fileListOne = [];
|
|
|
|
|
}
|
|
|
|
|
if (row.productVideo) {
|
|
|
|
|
this.fileListTwo = [
|
|
|
|
|
{
|
|
|
|
|
name: "",
|
|
|
|
|
url: row.productVideo,
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
} else {
|
|
|
|
|
this.fileListTwo = [];
|
|
|
|
|
}
|
2024-08-15 10:01:50 +00:00
|
|
|
|
this.place = row.productPlace.split("-");
|
|
|
|
|
this.modalData = row;
|
2024-08-16 10:00:30 +00:00
|
|
|
|
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 = [];
|
|
|
|
|
}
|
2024-08-15 10:01:50 +00:00
|
|
|
|
},
|
2024-08-09 10:04:10 +00:00
|
|
|
|
addSpecs() {
|
|
|
|
|
console.log("123");
|
2024-08-15 10:01:50 +00:00
|
|
|
|
if (this.isAdd) {
|
|
|
|
|
this.$refs.addSpecifications
|
|
|
|
|
.toggle()
|
2024-08-16 10:00:30 +00:00
|
|
|
|
.add(
|
2024-08-15 10:01:50 +00:00
|
|
|
|
this.modalData.productAttributeList,
|
|
|
|
|
this.modalData.productSpecificationList
|
|
|
|
|
);
|
2024-08-16 10:00:30 +00:00
|
|
|
|
} else {
|
2024-08-18 10:04:26 +00:00
|
|
|
|
if (this.modalData.specType == 0) {
|
2024-08-16 10:00:30 +00:00
|
|
|
|
this.$refs.addSpecifications.toggle().update([], []);
|
|
|
|
|
} else {
|
|
|
|
|
this.$refs.addSpecifications
|
|
|
|
|
.toggle()
|
|
|
|
|
.update(
|
|
|
|
|
this.modalData.productAttributeList,
|
|
|
|
|
this.modalData.productSpecificationList
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-08-15 10:01:50 +00:00
|
|
|
|
}
|
2024-08-09 10:04:10 +00:00
|
|
|
|
},
|
2024-08-12 10:05:59 +00:00
|
|
|
|
//获取属性
|
|
|
|
|
getSpecs(tableData, AttributeData, salePrice, stockNum) {
|
2024-08-18 10:04:26 +00:00
|
|
|
|
this.modalData.specType = 1;
|
2024-08-12 10:05:59 +00:00
|
|
|
|
let AttributeList = AttributeData.map((item) => {
|
|
|
|
|
return {
|
|
|
|
|
attributeName: item.attributeName,
|
|
|
|
|
attributeValue: item.attributeValue.join(","),
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
this.$set(this.modalData, "productSpecificationList", tableData);
|
|
|
|
|
this.$set(this.modalData, "productAttributeList", AttributeList);
|
|
|
|
|
this.$set(this.modalData, "singlePrice", salePrice);
|
|
|
|
|
this.$set(this.modalData, "singleStock", stockNum);
|
|
|
|
|
},
|
|
|
|
|
addAttribute() {
|
2024-08-16 10:00:30 +00:00
|
|
|
|
if (this.isAdd) {
|
|
|
|
|
this.$refs.addAttribute.toggle().add(this.modalData.otherAttribute);
|
|
|
|
|
} else {
|
|
|
|
|
this.$refs.addAttribute.toggle().update(this.modalData.otherAttribute);
|
|
|
|
|
}
|
2024-08-12 10:05:59 +00:00
|
|
|
|
},
|
|
|
|
|
getAttribute(data) {
|
|
|
|
|
console.log(data);
|
|
|
|
|
this.modalData.otherAttribute = [
|
|
|
|
|
{
|
|
|
|
|
name: data.name,
|
|
|
|
|
value: data.value.join(","),
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
console.log(this.modalData);
|
|
|
|
|
},
|
2024-08-15 10:01:50 +00:00
|
|
|
|
beforeTabLeave(activeName, oldActiveName) {
|
|
|
|
|
if (this.passCheck.includes(activeName)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2024-08-13 10:03:15 +00:00
|
|
|
|
let state = "";
|
|
|
|
|
this.$refs.modal.validate((valid) => {
|
2024-08-15 10:01:50 +00:00
|
|
|
|
if (valid) {
|
|
|
|
|
if (!this.passCheck.includes(oldActiveName)) {
|
|
|
|
|
this.passCheck.push(oldActiveName);
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-08-13 10:03:15 +00:00
|
|
|
|
state = valid;
|
|
|
|
|
});
|
|
|
|
|
return state;
|
|
|
|
|
},
|
2024-08-09 10:04:10 +00:00
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
modalCols() {
|
|
|
|
|
switch (this.currentPanel) {
|
|
|
|
|
case "基础信息":
|
|
|
|
|
return [
|
|
|
|
|
{
|
|
|
|
|
label: "商品图片",
|
|
|
|
|
prop: "productPhotoList",
|
|
|
|
|
required: true,
|
|
|
|
|
rules: {
|
|
|
|
|
required: true,
|
|
|
|
|
message: "请上传商品图片",
|
|
|
|
|
trigger: "blur",
|
|
|
|
|
},
|
|
|
|
|
type: "jsx",
|
|
|
|
|
render: () => {
|
|
|
|
|
const handleChange = (file, fileList) => {
|
2024-08-12 10:05:59 +00:00
|
|
|
|
// console.log(fileList);
|
2024-08-09 10:04:10 +00:00
|
|
|
|
};
|
2024-08-12 10:05:59 +00:00
|
|
|
|
const handleAvatarSuccess = (res, file, fileList) => {
|
|
|
|
|
console.log(res, fileList);
|
|
|
|
|
this.modalData.productPhotoList = fileList.map(
|
|
|
|
|
(item, index) => {
|
|
|
|
|
if (index == 0) {
|
|
|
|
|
return {
|
|
|
|
|
isMain: 1,
|
2024-08-15 10:01:50 +00:00
|
|
|
|
url: item.response ? item.response.data : item.url,
|
2024-08-12 10:05:59 +00:00
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
return {
|
2024-08-15 10:01:50 +00:00
|
|
|
|
url: item.response ? item.response.data : item.url,
|
2024-08-12 10:05:59 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
2024-08-09 10:04:10 +00:00
|
|
|
|
console.log(this.modalData.productPhotoList);
|
2024-08-15 10:01:50 +00:00
|
|
|
|
this.fileList = fileList.map((item) => {
|
|
|
|
|
return {
|
|
|
|
|
name: item.name,
|
|
|
|
|
url: item.response ? item.response.data : item.url,
|
|
|
|
|
};
|
|
|
|
|
});
|
2024-08-09 10:04:10 +00:00
|
|
|
|
};
|
|
|
|
|
const handleRemove = (file, fileList) => {
|
|
|
|
|
console.log(file, fileList);
|
2024-08-12 10:05:59 +00:00
|
|
|
|
this.modalData.productPhotoList = fileList.map(
|
|
|
|
|
(item, index) => {
|
|
|
|
|
if (index == 0) {
|
|
|
|
|
return {
|
|
|
|
|
isMain: 1,
|
2024-08-15 10:01:50 +00:00
|
|
|
|
url: item.url,
|
2024-08-12 10:05:59 +00:00
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
return {
|
2024-08-15 10:01:50 +00:00
|
|
|
|
url: item.url,
|
2024-08-12 10:05:59 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
2024-08-09 10:04:10 +00:00
|
|
|
|
console.log(this.modalData.productPhotoList);
|
2024-08-15 10:01:50 +00:00
|
|
|
|
this.fileList = fileList.map((item) => {
|
|
|
|
|
return {
|
|
|
|
|
name: item.name,
|
|
|
|
|
url: item.url,
|
|
|
|
|
};
|
|
|
|
|
});
|
2024-08-09 10:04:10 +00:00
|
|
|
|
};
|
|
|
|
|
return (
|
|
|
|
|
<el-upload
|
|
|
|
|
class="upload-demo"
|
|
|
|
|
drag
|
|
|
|
|
action={this.$api.mer_admin.uploadFile()}
|
|
|
|
|
{...{
|
|
|
|
|
props: {
|
|
|
|
|
"on-change": handleChange,
|
|
|
|
|
"on-success": handleAvatarSuccess,
|
|
|
|
|
"on-remove": handleRemove,
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
headers={{
|
|
|
|
|
token: "Bearer " + this.$cookie.get("token"),
|
|
|
|
|
}}
|
|
|
|
|
multiple={true}
|
|
|
|
|
file-list={this.fileList}
|
2024-08-15 10:01:50 +00:00
|
|
|
|
list-type="picture"
|
2024-08-09 10:04:10 +00:00
|
|
|
|
>
|
|
|
|
|
<i class="el-icon-upload"></i>
|
|
|
|
|
<div class="el-upload__text">
|
|
|
|
|
将文件拖到此处,或<em>点击上传</em>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="el-upload__tip" slot="tip">
|
|
|
|
|
只能上传jpg/png文件,且不超过500kb
|
|
|
|
|
</div>
|
|
|
|
|
</el-upload>
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "商品类目",
|
|
|
|
|
prop: "productCategoryId",
|
|
|
|
|
type: "jsx",
|
|
|
|
|
required: true,
|
|
|
|
|
rules: {
|
|
|
|
|
required: true,
|
|
|
|
|
message: "请选择商品类目",
|
|
|
|
|
trigger: "blur",
|
|
|
|
|
},
|
|
|
|
|
render: () => {
|
|
|
|
|
return (
|
|
|
|
|
<el-select
|
|
|
|
|
placeholder="请选择商品类目"
|
|
|
|
|
v-model={this.modalData.productCategoryId}
|
|
|
|
|
>
|
|
|
|
|
{this.getProductCategory.map((item) => {
|
|
|
|
|
return (
|
|
|
|
|
<el-option
|
|
|
|
|
label={item.name}
|
|
|
|
|
value={item.id}
|
|
|
|
|
></el-option>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</el-select>
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "商品名称",
|
|
|
|
|
prop: "name",
|
|
|
|
|
type: "Input",
|
|
|
|
|
required: true,
|
2024-08-15 10:01:50 +00:00
|
|
|
|
maxlength: "30",
|
2024-08-09 10:04:10 +00:00
|
|
|
|
rules: {
|
|
|
|
|
required: true,
|
|
|
|
|
message: "请输入商品名称",
|
|
|
|
|
trigger: "blur",
|
|
|
|
|
},
|
|
|
|
|
placeholder: "请输入商品名称",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "商品描述",
|
|
|
|
|
prop: "description",
|
|
|
|
|
required: true,
|
|
|
|
|
rules: {
|
|
|
|
|
required: true,
|
|
|
|
|
message: "请填写商品描述",
|
|
|
|
|
trigger: "blur",
|
|
|
|
|
},
|
|
|
|
|
type: "jsx",
|
|
|
|
|
render: () => {
|
|
|
|
|
return (
|
|
|
|
|
<el-input
|
|
|
|
|
type="textarea"
|
2024-08-15 10:01:50 +00:00
|
|
|
|
maxlength={100}
|
2024-08-09 10:04:10 +00:00
|
|
|
|
v-model={this.modalData.description}
|
|
|
|
|
placeholder="请简单描述,如别称、口感、用途等"
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
break;
|
|
|
|
|
case "销售信息":
|
|
|
|
|
return [
|
|
|
|
|
{
|
|
|
|
|
label: "销售单位",
|
|
|
|
|
prop: "productUnit",
|
|
|
|
|
required: true,
|
|
|
|
|
rules: {
|
|
|
|
|
required: true,
|
|
|
|
|
message: "请选择销售单位",
|
|
|
|
|
trigger: "blur",
|
|
|
|
|
},
|
|
|
|
|
type: "jsx",
|
|
|
|
|
render: () => {
|
|
|
|
|
return (
|
|
|
|
|
<el-select
|
|
|
|
|
v-model={this.modalData.productUnit}
|
|
|
|
|
placeholder="请选择销售单位"
|
|
|
|
|
>
|
|
|
|
|
{this.getSaleUnit.map((item) => {
|
|
|
|
|
return (
|
|
|
|
|
<el-option
|
|
|
|
|
label={item.name}
|
2024-08-15 10:01:50 +00:00
|
|
|
|
value={item.name}
|
2024-08-09 10:04:10 +00:00
|
|
|
|
></el-option>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</el-select>
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "规格",
|
|
|
|
|
prop: "productSpecificationList",
|
2024-08-18 10:04:26 +00:00
|
|
|
|
// required: true,
|
|
|
|
|
// rules: {
|
|
|
|
|
// required: true,
|
|
|
|
|
// message: "请选择销售单位",
|
|
|
|
|
// trigger: "blur",
|
|
|
|
|
// },
|
2024-08-09 10:04:10 +00:00
|
|
|
|
type: "jsx",
|
|
|
|
|
render: () => {
|
|
|
|
|
return (
|
|
|
|
|
<el-button onClick={this.addSpecs}>
|
|
|
|
|
若有多规格请在此配置
|
|
|
|
|
</el-button>
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
},
|
2024-08-18 10:04:26 +00:00
|
|
|
|
{
|
|
|
|
|
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>
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
},
|
2024-08-09 10:04:10 +00:00
|
|
|
|
{
|
|
|
|
|
label: "价格",
|
|
|
|
|
prop: "singlePrice",
|
|
|
|
|
type: "jsx",
|
|
|
|
|
render: () => {
|
|
|
|
|
return (
|
|
|
|
|
<el-input
|
2024-08-18 10:04:26 +00:00
|
|
|
|
readonly={this.modalData.specType != 0}
|
2024-08-09 10:04:10 +00:00
|
|
|
|
placeholder="请输入价格"
|
|
|
|
|
v-model={this.modalData.singlePrice}
|
2024-08-18 10:04:26 +00:00
|
|
|
|
>
|
|
|
|
|
<template slot="append">单位(元)</template>
|
|
|
|
|
</el-input>
|
2024-08-09 10:04:10 +00:00
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "库存",
|
|
|
|
|
prop: "singleStock",
|
|
|
|
|
type: "jsx",
|
|
|
|
|
render: () => {
|
|
|
|
|
return (
|
|
|
|
|
<el-input
|
2024-08-18 10:04:26 +00:00
|
|
|
|
readonly={this.modalData.specType != 0}
|
2024-08-09 10:04:10 +00:00
|
|
|
|
placeholder="请输入库存"
|
|
|
|
|
v-model={this.modalData.singleStock}
|
|
|
|
|
></el-input>
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
},
|
2024-08-18 10:04:26 +00:00
|
|
|
|
{
|
|
|
|
|
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>
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
},
|
2024-08-09 10:04:10 +00:00
|
|
|
|
{
|
|
|
|
|
label: "其他属性",
|
|
|
|
|
prop: "productAttributeList",
|
|
|
|
|
type: "jsx",
|
|
|
|
|
render: () => {
|
2024-08-12 10:05:59 +00:00
|
|
|
|
return (
|
|
|
|
|
<el-button onClick={this.addAttribute}>
|
|
|
|
|
添加其他属性
|
|
|
|
|
</el-button>
|
|
|
|
|
);
|
2024-08-09 10:04:10 +00:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
break;
|
|
|
|
|
case "其他信息":
|
|
|
|
|
return [
|
|
|
|
|
{
|
|
|
|
|
label: "产地",
|
|
|
|
|
prop: "productPlace",
|
|
|
|
|
required: true,
|
|
|
|
|
rules: { required: true, message: "请选择产地", trigger: "blur" },
|
|
|
|
|
type: "jsx",
|
|
|
|
|
render: () => {
|
|
|
|
|
const change = (e) => {
|
|
|
|
|
console.log(e);
|
2024-08-12 10:05:59 +00:00
|
|
|
|
this.modalData.productPlace = e.join("-");
|
2024-08-09 10:04:10 +00:00
|
|
|
|
};
|
|
|
|
|
return (
|
|
|
|
|
<el-cascader
|
2024-08-12 10:05:59 +00:00
|
|
|
|
v-model={this.place}
|
2024-08-09 10:04:10 +00:00
|
|
|
|
onChange={change}
|
|
|
|
|
options={this.$api.mer_admin.getCityOptions()}
|
2024-08-20 10:00:08 +00:00
|
|
|
|
props={{
|
2024-08-09 10:04:10 +00:00
|
|
|
|
props: {
|
2024-08-20 10:00:08 +00:00
|
|
|
|
label: "name",
|
|
|
|
|
value: "name",
|
2024-08-09 10:04:10 +00:00
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
clearable
|
|
|
|
|
></el-cascader>
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "保质期",
|
|
|
|
|
prop: "shelfLife",
|
|
|
|
|
type: "jsx",
|
|
|
|
|
// required: true,
|
|
|
|
|
rules: {
|
|
|
|
|
required: true,
|
|
|
|
|
message: "请填写保质期",
|
|
|
|
|
trigger: "blur",
|
|
|
|
|
},
|
|
|
|
|
render: () => {
|
|
|
|
|
return (
|
|
|
|
|
<el-input
|
|
|
|
|
style="width:150px;"
|
|
|
|
|
placeholder="请填写保质期"
|
|
|
|
|
v-model={this.modalData.shelfLife}
|
|
|
|
|
>
|
|
|
|
|
<div slot="suffix">天</div>
|
|
|
|
|
</el-input>
|
|
|
|
|
);
|
|
|
|
|
},
|
2024-08-09 06:14:44 +00:00
|
|
|
|
},
|
2024-08-09 10:04:10 +00:00
|
|
|
|
{
|
|
|
|
|
label: "商品介绍图",
|
|
|
|
|
prop: "productIntroducePhoto",
|
|
|
|
|
type: "Input",
|
2024-08-18 10:04:26 +00:00
|
|
|
|
// required: true,
|
|
|
|
|
// rules: { required: true, message: "商品介绍图", trigger: "blur" },
|
2024-08-09 10:04:10 +00:00
|
|
|
|
placeholder: "商品介绍图",
|
|
|
|
|
type: "jsx",
|
|
|
|
|
render: () => {
|
|
|
|
|
const handleChange = (file, fileList) => {
|
2024-08-12 10:05:59 +00:00
|
|
|
|
// console.log(fileList);
|
|
|
|
|
};
|
|
|
|
|
const handleAvatarSuccess = (res) => {
|
|
|
|
|
this.modalData.productIntroducePhoto = res.data;
|
|
|
|
|
console.log(this.modalData.productIntroducePhoto);
|
|
|
|
|
};
|
|
|
|
|
const handleRemove = () => {
|
|
|
|
|
this.modalData.productIntroducePhoto = "";
|
|
|
|
|
console.log(this.modalData.productIntroducePhoto);
|
2024-08-09 10:04:10 +00:00
|
|
|
|
};
|
|
|
|
|
return (
|
|
|
|
|
<el-upload
|
|
|
|
|
class="upload-demo"
|
|
|
|
|
drag
|
|
|
|
|
action={this.$api.mer_admin.uploadFile()}
|
2024-08-12 10:05:59 +00:00
|
|
|
|
limit={1}
|
2024-08-16 10:00:30 +00:00
|
|
|
|
file-list={this.fileListOne}
|
|
|
|
|
list-type="picture"
|
2024-08-09 10:04:10 +00:00
|
|
|
|
{...{
|
|
|
|
|
props: {
|
|
|
|
|
"on-change": handleChange,
|
2024-08-12 10:05:59 +00:00
|
|
|
|
"on-success": handleAvatarSuccess,
|
|
|
|
|
"on-remove": handleRemove,
|
2024-08-09 10:04:10 +00:00
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
headers={{
|
|
|
|
|
token: "Bearer " + this.$cookie.get("token"),
|
|
|
|
|
}}
|
|
|
|
|
multiple
|
|
|
|
|
>
|
|
|
|
|
<i class="el-icon-upload"></i>
|
|
|
|
|
<div class="el-upload__text">
|
|
|
|
|
将文件拖到此处,或<em>点击上传</em>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="el-upload__tip" slot="tip">
|
|
|
|
|
只能上传jpg/png文件,且不超过500kb
|
|
|
|
|
</div>
|
|
|
|
|
</el-upload>
|
|
|
|
|
);
|
|
|
|
|
},
|
2024-08-07 09:55:31 +00:00
|
|
|
|
},
|
2024-08-09 10:04:10 +00:00
|
|
|
|
{
|
|
|
|
|
label: "商品视频",
|
|
|
|
|
prop: "productVideo",
|
2024-08-18 10:04:26 +00:00
|
|
|
|
// required: true,
|
|
|
|
|
// rules: {
|
|
|
|
|
// required: true,
|
|
|
|
|
// message: "请填写商品描述",
|
|
|
|
|
// trigger: "blur",
|
|
|
|
|
// },
|
2024-08-09 10:04:10 +00:00
|
|
|
|
type: "jsx",
|
|
|
|
|
render: () => {
|
|
|
|
|
const handleChange = (file, fileList) => {
|
|
|
|
|
console.log(fileList);
|
|
|
|
|
};
|
2024-08-12 10:05:59 +00:00
|
|
|
|
const handleAvatarSuccess = (res) => {
|
|
|
|
|
this.modalData.productVideo = res.data;
|
|
|
|
|
};
|
|
|
|
|
const handleRemove = () => {
|
|
|
|
|
this.modalData.productVideo = "";
|
|
|
|
|
};
|
2024-08-09 10:04:10 +00:00
|
|
|
|
return (
|
|
|
|
|
<el-upload
|
|
|
|
|
class="upload-demo"
|
|
|
|
|
drag
|
|
|
|
|
action={this.$api.mer_admin.uploadFile()}
|
2024-08-12 10:05:59 +00:00
|
|
|
|
limit={1}
|
2024-08-16 10:00:30 +00:00
|
|
|
|
file-list={this.fileListTwo}
|
|
|
|
|
list-type="picture"
|
2024-08-09 10:04:10 +00:00
|
|
|
|
{...{
|
|
|
|
|
props: {
|
|
|
|
|
"on-change": handleChange,
|
2024-08-12 10:05:59 +00:00
|
|
|
|
"on-success": handleAvatarSuccess,
|
|
|
|
|
"on-remove": handleRemove,
|
2024-08-09 10:04:10 +00:00
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
headers={{
|
|
|
|
|
token: "Bearer " + this.$cookie.get("token"),
|
|
|
|
|
}}
|
|
|
|
|
multiple
|
|
|
|
|
>
|
|
|
|
|
<i class="el-icon-upload"></i>
|
|
|
|
|
<div class="el-upload__text">
|
|
|
|
|
将文件拖到此处,或<em>点击上传</em>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="el-upload__tip" slot="tip">
|
|
|
|
|
只能上传jpg/png文件,且不超过500kb
|
|
|
|
|
</div>
|
|
|
|
|
</el-upload>
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2024-08-07 09:55:31 +00:00
|
|
|
|
},
|
2024-08-09 10:04:10 +00:00
|
|
|
|
modalHandles() {
|
|
|
|
|
return [
|
|
|
|
|
{
|
2024-08-15 10:01:50 +00:00
|
|
|
|
label: this.currentPanel === "其他信息" ? "立即上架" : "下一步",
|
2024-08-09 10:04:10 +00:00
|
|
|
|
type: "primary",
|
|
|
|
|
loading: this.isLoading,
|
|
|
|
|
submit: true,
|
|
|
|
|
handle: debounce(() => {
|
|
|
|
|
if (this.currentPanel === "基础信息") {
|
|
|
|
|
this.currentPanel = "销售信息";
|
|
|
|
|
} else if (this.currentPanel == "销售信息") {
|
|
|
|
|
this.currentPanel = "其他信息";
|
2024-08-07 09:55:31 +00:00
|
|
|
|
} else {
|
2024-08-12 10:05:59 +00:00
|
|
|
|
console.log("请求接口", this.modalData);
|
2024-08-18 10:04:26 +00:00
|
|
|
|
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,
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
}
|
2024-08-12 10:05:59 +00:00
|
|
|
|
this.$api.mer_admin.saveProduct(this.modalData).then((res) => {
|
|
|
|
|
console.log(res);
|
2024-08-15 10:01:50 +00:00
|
|
|
|
this.$emit("queryList");
|
|
|
|
|
this.toggle();
|
2024-08-12 10:05:59 +00:00
|
|
|
|
});
|
2024-08-07 09:55:31 +00:00
|
|
|
|
}
|
2024-08-09 10:04:10 +00:00
|
|
|
|
}, 300),
|
2024-08-07 09:55:31 +00:00
|
|
|
|
},
|
2024-08-15 10:01:50 +00:00
|
|
|
|
{
|
|
|
|
|
disabled: () => this.currentPanel != "其他信息",
|
|
|
|
|
label: "放入仓库",
|
|
|
|
|
type: "primary",
|
|
|
|
|
loading: this.isLoading,
|
|
|
|
|
submit: true,
|
|
|
|
|
handle: debounce(() => {
|
2024-08-18 10:04:26 +00:00
|
|
|
|
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,
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
}
|
2024-08-15 10:01:50 +00:00
|
|
|
|
this.modalData.status = "DOWN";
|
|
|
|
|
this.$api.mer_admin.saveProduct(this.modalData).then((res) => {
|
|
|
|
|
console.log(res);
|
|
|
|
|
this.$emit("queryList");
|
|
|
|
|
this.toggle();
|
|
|
|
|
});
|
|
|
|
|
}, 300),
|
|
|
|
|
},
|
2024-08-09 10:04:10 +00:00
|
|
|
|
];
|
2024-08-07 09:55:31 +00:00
|
|
|
|
},
|
2024-08-09 10:04:10 +00:00
|
|
|
|
},
|
|
|
|
|
asyncComputed: {
|
|
|
|
|
async getProductCategory() {
|
|
|
|
|
let res = await this.$api.mer_admin.getProductCategory();
|
|
|
|
|
return res.data.data;
|
2024-08-07 09:55:31 +00:00
|
|
|
|
},
|
2024-08-09 10:04:10 +00:00
|
|
|
|
async getSaleUnit() {
|
|
|
|
|
let res = await this.$api.mer_admin.getSaleUnit({
|
|
|
|
|
shopId: JSON.parse(sessionStorage.getItem("userInfo")).shopId,
|
|
|
|
|
});
|
|
|
|
|
console.log(res);
|
2024-08-09 06:14:44 +00:00
|
|
|
|
|
2024-08-09 10:04:10 +00:00
|
|
|
|
return res.data.data;
|
2024-08-07 09:55:31 +00:00
|
|
|
|
},
|
2024-08-09 10:04:10 +00:00
|
|
|
|
},
|
2024-08-07 09:55:31 +00:00
|
|
|
|
};
|
|
|
|
|
</script>
|
2024-08-09 06:14:44 +00:00
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.obj-modal ::v-deep {
|
2024-08-09 10:04:10 +00:00
|
|
|
|
.el-dialog__body {
|
|
|
|
|
padding: 0 30px;
|
|
|
|
|
}
|
2024-08-09 06:14:44 +00:00
|
|
|
|
}
|
|
|
|
|
</style>
|