Commit 4d4414f5 by cwq0219

商品编辑-规格

1 parent 409c4806
...@@ -81,6 +81,10 @@ ...@@ -81,6 +81,10 @@
margin-top: 20px; margin-top: 20px;
} }
.marketing .txt-center {
text-align: center;
}
.marketing .footer { .marketing .footer {
position: fixed; position: fixed;
bottom: 0; bottom: 0;
......
<!-- 编辑商品 --> <!-- 编辑商品 -->
<template> <template>
<div class="edit-share marketing"> <div class="edit-pro marketing">
<div class="container edit-container"> <div class="container edit-container">
<p class="edit-title">{{ title }}</p> <p class="edit-title">{{ title }}</p>
<div class="flex m-t-20"> <div class="flex m-t-20">
<div class="wechat-container"> <div class="wechat-container">
<div class="wechat-box"> <div class="wechat-box">
<img class="w-100-per" src="./images/pro-header.png"> <img class="w-100-per" src="./images/pro-header.png" />
<!-- <div class="home-banner wechant-conf-box home-bg" style="border: none;margin-top: 0;"> <!-- <div class="home-banner wechant-conf-box home-bg" style="border: none;margin-top: 0;">
<ul ng-show="wechatImgList.length != 0" class="home-banner-box wechant-config" ng-style="{'width':wechatImgList.length * 100 + '%'}"> <ul ng-show="wechatImgList.length != 0" class="home-banner-box wechant-config" :style="{'width':wechatImgList.length * 100 + '%'}">
<li ng-repeat="item in wechatImgList" ng-show="item.content"> <li ng-repeat="item in wechatImgList" ng-show="item.content">
<video ng-show="item.resType == 3" class="videoUpload" ng-src="{{trustUrl(formData.goodsVideo)}}" controls="controls"></video> <video ng-show="item.resType == 3" class="videoUpload" ng-src="{{trustUrl(formData.goodsVideo)}}" controls="controls"></video>
<img ng-show="item.resType == 1" ng-src="{{item.content}}" /> <img ng-show="item.resType == 1" ng-src="{{item.content}}" />
...@@ -96,6 +96,55 @@ ...@@ -96,6 +96,55 @@
</div> </div>
</div> </div>
</div> </div>
<template slot="proSpecsBtn">
<el-button :disabled="routeInfo.addOrEdit == 3" type="primary" @click="handleSpecsEdit(scope)">添加规格</el-button>
</template>
<div slot="proSpecs" style="margin-left: 110px;">
<div v-for="(subItem, subIndex) in specificationDetailList" :key="subIndex">
<div>
<span>规格名:</span>
<span>{{ subItem.specificationName }}</span>
<el-button v-show="!disabled" type="text" @click="handleSpecsEdit(2, subItem, index)">编辑</el-button>
<el-button v-show="!disabled" type="text" @click="handleSpecsDelete(subIndex)">删除</el-button>
</div>
<div class="flex">
<span style="width: 56px;">规格值:</span>
<div style="width: calc(100% - 56px);">
<div>
<span class="specs-label" v-for="(n, idx) in subItem.specificationValueList" :key="idx">{{ n.specificationValue }}</span>
</div>
</div>
</div>
</div>
</div>
<div slot="specsDetail" class="flex">
<span class="spesc-label" :style="{ width: labelWidth }">规格明细:</span>
<div style="width: calc(100% - 100px);">
<table class="table-spesc">
<tbody>
<tr>
<td :style="{ width: specsWidth }" v-for="(subItem, subIndex) in specificationDetailList" :key="subIndex">{{ subItem.specificationName }}</td>
<td :style="{ width: specsWidth }">零售价(元)</td>
<td :style="{ width: specsWidth }">库存</td>
</tr>
</tbody>
</table>
<table class="table-spesc" style="max-height: 400px;">
<tbody>
<tr style="border-bottom: 1px solid rgb(235, 235, 235);" v-for="(subItem, subIndex) in nameToValSpecsList" :key="subIndex">
<td :style="{ width: specsWidth }" v-for="(n, idx) in subItem.specsValueList" :key="idx">{{ n }}</td>
<td :style="{ width: specsWidth }">
<el-input placeholder="零售价" v-model="subItem.retailPrice" ng-blur="handleBlur()"></el-input>
<!-- <p ng-show="(parentData.groupOrStore == 1) && (+formData.supplyPrice > +item.retailPrice) && submitted"
class="text-danger form-text">零售价要大于供货价</p> -->
</td>
<td :style="{ width: specsWidth }">
<el-input placeholder="库存" v-model="subItem.stock"></el-input></td>
</tr>
</tbody>
</table>
</div>
</div>
<template slot="retailPrice"> <template slot="retailPrice">
<p>作为商品商城售卖的价格</p> <p>作为商品商城售卖的价格</p>
</template> </template>
...@@ -184,6 +233,19 @@ export default { ...@@ -184,6 +233,19 @@ export default {
} }
] ]
}, },
// 商品规格
specsWidth: '50%',
specificationDetailList: [],
nameToValSpecsList: [],
minRetailPrice: '',
// specsTableParams: {
// tableColumns: [
// {
// label: '码数',
// prop: ''
// }
// ]
// },
// 表单 // 表单
editForm: { editForm: {
goodsName: '', goodsName: '',
...@@ -193,6 +255,8 @@ export default { ...@@ -193,6 +255,8 @@ export default {
classifyIdList: [], classifyIdList: [],
zoneId: '', zoneId: '',
descImgList: [], descImgList: [],
// 商品规格
// specificationDetailList: [],
retailPrice: '', retailPrice: '',
originalPrice: '', originalPrice: '',
supplyPrice: '', supplyPrice: '',
...@@ -328,12 +392,28 @@ export default { ...@@ -328,12 +392,28 @@ export default {
}, },
editFormData: [ editFormData: [
{ {
label: '商品规格',
name: '',
addHtml: 'proSpecsBtn'
},
{
label: '',
name: 'specificationDetailList',
addHtml: 'proSpecs'
},
{
// label: '规格明细',
name: '',
addHtml: 'specsDetail'
},
{
label: '零售价', label: '零售价',
name: 'retailPrice', name: 'retailPrice',
type: 'input', type: 'input',
append: '元', append: '元',
width: '320px', width: '320px',
suffixSlot: 'retailPrice' suffixSlot: 'retailPrice',
isHide: false
}, },
{ {
label: '划线价', label: '划线价',
...@@ -357,8 +437,9 @@ export default { ...@@ -357,8 +437,9 @@ export default {
type: 'input', type: 'input',
append: '件', append: '件',
width: '320px', width: '320px',
suffixSlot: 'goodsStock' suffixSlot: 'goodsStock',
}, isHide: false
}
] ]
}, },
{ {
...@@ -450,7 +531,6 @@ export default { ...@@ -450,7 +531,6 @@ export default {
Promise.all([this.$apis.common.getClassifyListApi({}), this.$apis.common.getZoneListApi({ zoneType: 2, merchantId: this.userInfo.merchantId })]).then(([classify, zone]) => { Promise.all([this.$apis.common.getClassifyListApi({}), this.$apis.common.getZoneListApi({ zoneType: 2, merchantId: this.userInfo.merchantId })]).then(([classify, zone]) => {
this.baseData.classifyList = classify this.baseData.classifyList = classify
this.baseData.zoneList = zone this.baseData.zoneList = zone
console.log(this.baseData)
resolve() resolve()
}) })
}) })
...@@ -460,6 +540,15 @@ export default { ...@@ -460,6 +540,15 @@ export default {
var idx = this.externalFormList[2].editFormData.findIndex(item => item.name == 'expressFee') var idx = this.externalFormList[2].editFormData.findIndex(item => item.name == 'expressFee')
this.externalFormList[2].editFormData[idx].isHide = val != 2 this.externalFormList[2].editFormData[idx].isHide = val != 2
}, },
retailStockRule() {
var list = ['retailPrice', 'goodsStock']
var idx = ''
list.forEach(item => {
this.externalFormList[1].editRule[item][0].required = !this.editForm.specificationList.length
idx = this.externalFormList[1].editFormData.findIndex(subItem => subItem.name == item)
this.externalFormList[1].editFormData[idx].isHide = !!this.editForm.specificationList.length
})
},
// 选择门店 // 选择门店
handleRelateStoreClose() { handleRelateStoreClose() {
this.selectedList = this.$common.utils.deepClone(this.editForm.supplyMerchantList) this.selectedList = this.$common.utils.deepClone(this.editForm.supplyMerchantList)
...@@ -486,6 +575,136 @@ export default { ...@@ -486,6 +575,136 @@ export default {
} }
}) })
}, },
// 找最小规格值
findSpeceMin() {
this.minRetailPrice = this.nameToValSpecsList[0].retailPrice
this.nameToValSpecsList.forEach(item => {
if (+item.retailPrice < +this.minRetailPrice) {
this.minRetailPrice = item.retailPrice
}
})
},
// 规格值解构
changeSpecs(isRecovery) {
this.nameToValSpecsList = []
var markIdx = 0
for (var i = 0; i < this.specificationDetailList.length; i++) {
markIdx = 0
for (var j = 0; j < this.specificationDetailList[i].specificationValueList.length; j++) {
if (i == 0) {
this.nameToValSpecsList.push({
specsValueList: [this.specificationDetailList[i].specificationValueList[j].specificationValue],
retailPrice: '',
stock: ''
})
} else {
var targetValLen = this.specificationDetailList[i].specificationValueList.length
var loopNum = 0
var tempMarkIdx = 0
if (j == 0 && targetValLen > 1) {
var obj = JSON.parse(JSON.stringify(this.nameToValSpecsList))
this.nameToValSpecsList = []
obj.forEach((item, index) => {
for (var k = 0; k < targetValLen; k++) {
this.nameToValSpecsList.push(JSON.parse(JSON.stringify(item)))
}
})
}
loopNum = this.nameToValSpecsList.length / targetValLen
tempMarkIdx = markIdx
for (var k = 0; k < loopNum; k++) {
this.nameToValSpecsList[tempMarkIdx].specsValueList.push(this.specificationDetailList[i].specificationValueList[j].specificationValue)
tempMarkIdx = tempMarkIdx + targetValLen
}
markIdx = markIdx + 1
}
}
}
console.log(this.nameToValSpecsList)
console.log(this.specificationDetailList)
if (isRecovery) {
this.nameToValSpecsList.forEach((item, index) => {
var specificationObj = {}
item.specsValueList.forEach((subItem, subIndex) => {
specificationObj[this.specificationDetailList[subIndex].specificationName] = subItem
})
item.specificationData = this.setLocaleCompare(specificationObj)
for (var i = 0; i < this.editForm.specificationDetailList.length; i++) {
var temp = this.editForm.specificationDetailList[i]
if (temp.specificationData == item.specificationData) {
item.retailPrice = (temp.retailPrice / 100).toFixed(2)
item.stock = temp.stock
break
}
}
})
}
console.log(this.nameToValSpecsList)
},
setLocaleCompare(params) {
let keys = []
let obj = []
Object.keys(params).forEach(item => {
keys.push(item)
})
keys.sort()
keys.forEach(item => {
obj.push([item, params[item]])
})
return obj.join('&').replace(/,/g, '-')
},
// 添加规格status(1 - 新增;2 - 编辑)
handleSpecsEdit(status, targetItem, targetIdx) {
if (status == 1 && this.specificationDetailList.length >= 5) {
this.$message({
message: '只能创建5个规格值',
type: 'error'
})
return true
}
var curSpeceNameList = []
this.specificationDetailList.forEach((item, index) => {
if (status == 1 || (status == 2 && index != targetIdx)) {
curSpeceNameList.push(item.specificationName)
}
})
var params = {
// 1 - 新增;2 - 编辑
status: status,
curSpeceNameList: curSpeceNameList
}
if (status == 2) {
params.formData = JSON.parse(JSON.stringify(targetItem))
}
// $uibModal.open({
// templateUrl: 'biz/mallManage/view/model/editSpecsModel.html',
// controller: 'editSpecsModel',
// size: 'lg',
// resolve: {
// specsConfig: function () {
// return params
// }
// }
// }).result.then(function (specsForm) {
// //关闭弹框后执行方法
// if (status == 1) {
// $scope.specificationDetailList.push(specsForm)
// $scope.specsWidth = (100 / ($scope.specificationDetailList.length + 2)) + '%'
// } else {
// $scope.specificationDetailList[targetIdx] = specsForm
// }
// $scope.formData.retailPrice = ''
// $scope.formData.goodsStock = ''
// changeSpecs(false)
// }, function () {});
},
// 恢复规格值
recoverySpec() {
this.specsWidth = (100 / ( this.specificationDetailList.length + 2 )) + '%'
this.changeSpecs(true)
},
// 恢复商品描述 // 恢复商品描述
recoveryDescribe() { recoveryDescribe() {
this.editForm.goodsDescList.forEach((item, index) => { this.editForm.goodsDescList.forEach((item, index) => {
...@@ -514,7 +733,8 @@ export default { ...@@ -514,7 +733,8 @@ export default {
goodsVideo: res.goodsVideo || '', goodsVideo: res.goodsVideo || '',
classifyIdList: res.classifyList.map(item => item.id), classifyIdList: res.classifyList.map(item => item.id),
originalPrice: (res.originalPrice / 100).toFixed(2), originalPrice: (res.originalPrice / 100).toFixed(2),
retailPrice: res.retailPrice ? (res.retailPrice / 100).toFixed(2) : '', // retailPrice: res.retailPrice ? (res.retailPrice / 100).toFixed(2) : '',
retailPrice: '',
supplyPrice: res.supplyPrice ? (res.supplyPrice / 100).toFixed(2) : '', supplyPrice: res.supplyPrice ? (res.supplyPrice / 100).toFixed(2) : '',
describeTxt: '', describeTxt: '',
descImgList: [] descImgList: []
...@@ -523,9 +743,20 @@ export default { ...@@ -523,9 +743,20 @@ export default {
if (this.editForm.deliveryType == 2) { if (this.editForm.deliveryType == 2) {
this.editForm.expressFee = (res.expressFee / 100).toFixed(2) this.editForm.expressFee = (res.expressFee / 100).toFixed(2)
} }
// 规格
if (this.editForm.specificationList.length) {
this.specificationDetailList = this.$common.utils.deepClone(this.editForm.specificationList)
this.recoverySpec()
this.findSpeceMin()
} else {
// 零售价
this.editForm.retailPrice = (res.retailPrice / 100).toFixed(2)
}
this.retailStockRule()
this.editForm.goodsDescList.length && this.recoveryDescribe() this.editForm.goodsDescList.length && this.recoveryDescribe()
this.editForm.supplyMerchantList.length && this.recoveryMerchantList() this.editForm.supplyMerchantList.length && this.recoveryMerchantList()
console.log(this.editForm) this.handleTypeChange(this.editForm.deliveryType)
// console.log(this.editForm)
// this.editForm.supplyMerchantList = res.merchantRefList // this.editForm.supplyMerchantList = res.merchantRefList
// this.editForm.supplyMerchantList.forEach(item => { // this.editForm.supplyMerchantList.forEach(item => {
// item.merchantNo = item.merchantId // item.merchantNo = item.merchantId
...@@ -638,4 +869,41 @@ export default { ...@@ -638,4 +869,41 @@ export default {
} }
} }
</script> </script>
<style scoped></style> <style>
.edit-pro .specs-label {
padding: 1px 10px;
font-size: 13px;
border-radius: 2px;
display: inline-block;
border: 1px solid #cccccc;
margin-right: 10px;
}
.edit-pro .spesc-label {
box-sizing: border-box;
width: 110px;
color: #666;
text-align: right;
padding-right: 12px;
}
.edit-pro .table-spesc {
width: 100%;
text-align: center;
margin-bottom: 0;
}
.edit-pro .table-spesc tbody tr {
border: 1px solid #e7e7e7;
}
.edit-pro .table-spesc tbody td {
display: inline-block;
box-sizing: border-box;
width: 20%;
border: none;
padding: 2px 6px;
vertical-align: center;
text-align: center;
}
.edit-pro .table-spesc .el-input--small .el-input__inner {
text-align: center !important;
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!