Commit ce03a317 by 胡悦
2 parents efeeba8f 723f869d
......@@ -89,6 +89,10 @@ body {
margin-top: 20px;
}
.marketing .txt-center {
text-align: center;
}
.marketing .footer {
position: fixed;
bottom: 0;
......@@ -144,6 +148,10 @@ body {
background-color: rgba(242, 242, 242, 1);
}
.marketing .message-Z-zinde {
z-index: 3000 !important;
}
.one-line-ellipsis {
display: -webkit-box;
overflow: hidden;
......
......@@ -3,7 +3,7 @@
<div class="glsx-combi-form">
<el-form :ref="formRef" :inline="true" :model="formObj" :label-width="labelWidth" :rules="formRules" size="small" class="glsx-combi-form-block">
<template v-for="(item, index) in formData">
<el-form-item v-if="!item.isHide" :key="index" :class="{ 'no-label': !item.label, isBlock: isBlock }" :style="{ ...item.style }" :label="item.label ? item.label + ':' : ''" :prop="item.name">
<el-form-item v-if="!item.isHide" :key="index" :id="item.name" :class="{ 'no-label': !item.label, isBlock: isBlock }" :style="{ ...item.style }" :label="item.label ? item.label + ':' : ''" :prop="item.name">
<span v-if="!item.isHide && item.tips" class="tips-block" slot="label">
<span class="tips-label">{{ item.label }}</span>
<el-tooltip popper-class="tooltip-class" effect="dark" :content="item.tips" :placement="item.placement || 'top'">
......
<!-- 编辑商品 -->
<template>
<div class="edit-share marketing">
<div class="edit-pro marketing">
<div class="container edit-container">
<p class="edit-title">{{ title }}</p>
<div class="flex m-t-20">
<div class="wechat-container">
<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;">
<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">
<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}}" />
......@@ -96,6 +96,55 @@
</div>
</div>
</div>
<template slot="proSpecsBtn">
<el-button :disabled="routeInfo.addOrEdit == 3" type="primary" @click="handleSpecsEdit(1)">添加规格</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, subIndex)">编辑</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">
<p>作为商品商城售卖的价格</p>
</template>
......@@ -127,6 +176,18 @@
<el-dialog :visible.sync="isImgVisible">
<img class="dialog-img" width="100%" :src="dialogImageUrl" alt="" />
</el-dialog>
<glsx-dialog title="规格" :isVisible.sync="isSpescVisible" width="70%" @confirmDialog="handleSpescConfirm" @closeDialog="handleSpescClose">
<el-form label-width="120px" :model="spescEditForm" :rules="spescRules" ref="spescRef">
<el-form-item label="规格名:" prop="specificationName">
<el-input class="w-320" :size="size" v-model="spescEditForm.specificationName" placeholder="请输入规格名"></el-input>
</el-form-item>
<el-form-item label="规格值:" prop="specificationValueList">
<el-tag style="margin-right: 10px;" v-for="(tag, i) in spescEditForm.specificationValueList" :key="i" closable :type="tag.type" @close="handleSpescDelete(tag)">{{ tag.specificationValue }}</el-tag>
<el-input class="input-new-tag" v-if="specsInputVisible" v-model="spescInputVal" ref="saveSpescInput" :size="size" @keyup.enter.native="handleInputConfirm" @blur="handleInputConfirm"></el-input>
<el-button v-else class="button-new-tag" size="small" @click="showInput">+ 规格值</el-button>
</el-form-item>
</el-form>
</glsx-dialog>
<relate-store-dialog v-if="relateStoreVisible" ref="relateStore" :relateStoreVisible="relateStoreVisible" :storeApi="storeApi" :storeSearchForm="storeSearchForm" :storeSelected="selectedList" @handleRelateStoreConfirm="handleRelateStoreConfirm" @handleRelateStoreClose="handleRelateStoreClose">
<el-row slot>
<el-form :model="storeSearchForm" ref="relate" :inline="true" label-width="90px">
......@@ -184,6 +245,30 @@ export default {
}
]
},
// 商品规格
specsWidth: '50%',
specificationDetailList: [],
nameToValSpecsList: [],
minRetailPrice: '',
// 添加规格弹窗
isSpescVisible: false,
spescRules: {
specificationName: [
{ required: true, message: '请输入规格名', trigger: 'blur' },
{ validator: (rule, value, callback) => {
return this.spescData.curSpeceNameList.some(item => item == value) ? callback(new Error('规格名重复')) : callback()
}, trigger: 'blur'
}
],
specificationValueList: [{ required: true, message: '请输入规格值', trigger: 'change' }]
},
spescData: {
status: '',
curSpeceNameList: []
},
spescEditForm: {},
specsInputVisible: false,
spescInputVal: '',
// 表单
editForm: {
goodsName: '',
......@@ -193,6 +278,8 @@ export default {
classifyIdList: [],
zoneId: '',
descImgList: [],
// 商品规格
// specificationDetailList: [],
retailPrice: '',
originalPrice: '',
supplyPrice: '',
......@@ -232,7 +319,7 @@ export default {
const base64 = file.name.split('.')[1] + '@' + imgFile.split(',')[1]
this.$apis.common.uploadImgApi({ file: base64, fileType: 'image' }).then(res => {
this.editForm[targetItem.name] = res
this.$refs.editFormRef.$refs.editProRef1.validateField(targetItem.name)
this.$refs.editFormRef.$refs.editProRef0.validateField(targetItem.name)
})
}
},
......@@ -252,7 +339,7 @@ export default {
resType: 1,
bizType: 1
})
this.$refs.editFormRef.$refs.editProRef1.validateField(targetItem.name)
this.$refs.editFormRef.$refs.editProRef0.validateField(targetItem.name)
})
}
},
......@@ -328,12 +415,28 @@ export default {
},
editFormData: [
{
label: '商品规格',
name: '',
addHtml: 'proSpecsBtn'
},
{
label: '',
name: 'specificationDetailList',
addHtml: 'proSpecs'
},
{
// label: '规格明细',
name: '',
addHtml: 'specsDetail'
},
{
label: '零售价',
name: 'retailPrice',
type: 'input',
append: '元',
width: '320px',
suffixSlot: 'retailPrice'
suffixSlot: 'retailPrice',
isHide: false
},
{
label: '划线价',
......@@ -357,8 +460,9 @@ export default {
type: 'input',
append: '件',
width: '320px',
suffixSlot: 'goodsStock'
},
suffixSlot: 'goodsStock',
isHide: false
}
]
},
{
......@@ -401,6 +505,8 @@ export default {
},
{
title: '分配门店',
editChildRef: 'editProRef3',
editRule: {},
editFormData: [
{
label: '发送门店',
......@@ -450,7 +556,6 @@ export default {
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.zoneList = zone
console.log(this.baseData)
resolve()
})
})
......@@ -460,6 +565,28 @@ export default {
var idx = this.externalFormList[2].editFormData.findIndex(item => item.name == 'expressFee')
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
})
},
// 二次确认
secondSimpleConfirm(title, txt, fn) {
this.$confirm(txt, title, {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
callback: action => {
if (action == 'confirm') {
fn && fn()
}
}
})
},
// 选择门店
handleRelateStoreClose() {
this.selectedList = this.$common.utils.deepClone(this.editForm.supplyMerchantList)
......@@ -474,17 +601,186 @@ export default {
this.$refs.relateStore.handleCurrentChange(1)
},
handleMerchantDelete(obj) {
this.$messageBox.confirm('是否删除该门店?', '删除', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'error',
callback: action => {
if (action == 'confirm') {
var idx = this.editForm.supplyMerchantList.findIndex(item => item.merchantNo == obj.scope.merchantNo)
this.editForm.supplyMerchantList.splice(idx, 1)
this.secondSimpleConfirm('删除', '是否删除该门店?', () => {
var idx = this.editForm.supplyMerchantList.findIndex(item => item.merchantNo == obj.scope.merchantNo)
this.editForm.supplyMerchantList.splice(idx, 1)
})
},
// 找最小规格值
findSpeceMin() {
this.minRetailPrice = this.nameToValSpecsList[0].retailPrice
this.nameToValSpecsList.forEach(item => {
if (+item.retailPrice < +this.minRetailPrice) {
this.minRetailPrice = item.retailPrice
}
})
},
// 规格值解构
changeSpecs(isRecovery) {
this.specsWidth = (100 / ( this.specificationDetailList.length + 2 )) + '%'
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, '-')
},
// 规格弹窗
handleSpescDelete(tag) {
this.spescEditForm.specificationValueList.splice(this.spescEditForm.specificationValueList.indexOf(tag), 1);
},
showInput() {
this.specsInputVisible = true
this.$nextTick(_ => {
this.$refs.saveSpescInput.$refs.input.focus()
});
},
handleInputConfirm() {
let spescInputVal = this.spescInputVal
if (this.spescEditForm.specificationValueList.length == 8) {
this.$message({
message: '规格值最多不能超过8个',
type: 'error',
customClass: 'message-Z-zinde'
})
return true
}
if (this.spescEditForm.specificationValueList.findIndex(i => i.specificationValue == spescInputVal) != -1) {
this.$message({
message: spescInputVal + '规格值已经存在',
type: 'error',
customClass: 'message-Z-zinde'
})
return true
}
if (spescInputVal) {
this.spescEditForm.specificationValueList.push({ specificationValue: spescInputVal })
}
this.specsInputVisible = false
this.spescInputVal = ''
},
handleSpescConfirm() {
this.$refs.spescRef.validate(valid => {
if (valid) {
if (this.spescData.status == 1) {
this.specificationDetailList.push(this.spescEditForm)
} else {
this.specificationDetailList[this.spescData.targetIdx] = this.spescEditForm
}
this.editForm.retailPrice = ''
this.editForm.goodsStock = ''
this.handleSpescClose()
this.changeSpecs(false)
}
})
},
handleSpescClose() {
this.isSpescVisible = !this.isSpescVisible
},
// 添加规格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)
}
})
this.spescData = {
// 1 - 新增;2 - 编辑
status: status,
targetIdx: targetIdx,
curSpeceNameList: curSpeceNameList
}
this.spescEditForm = status == 2 ? this.$common.utils.deepClone(targetItem) : { specificationName: '', specificationValueList: [] }
console.log(this.spescEditForm)
this.handleSpescClose()
},
// 删除规格值
handleSpecsDelete(index) {
this.secondSimpleConfirm('删除', '是否删除该规格?', () => {
this.specificationDetailList.splice(index, 1)
this.changeSpecs(false)
})
},
// 恢复规格值
recoverySpec() {
this.changeSpecs(true)
},
// 恢复商品描述
recoveryDescribe() {
......@@ -514,7 +810,7 @@ export default {
goodsVideo: res.goodsVideo || '',
classifyIdList: res.classifyList.map(item => item.id),
originalPrice: (res.originalPrice / 100).toFixed(2),
retailPrice: res.retailPrice ? (res.retailPrice / 100).toFixed(2) : '',
retailPrice: '',
supplyPrice: res.supplyPrice ? (res.supplyPrice / 100).toFixed(2) : '',
describeTxt: '',
descImgList: []
......@@ -523,9 +819,20 @@ export default {
if (this.editForm.deliveryType == 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.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.forEach(item => {
// item.merchantNo = item.merchantId
......@@ -595,40 +902,110 @@ export default {
this.editForm.descImgList.splice(idx, 1)
},
handleImgDelete(attrName, subIndex) {
this.$messageBox.confirm('是否删除该图片?', '删除', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'error',
callback: action => {
if (action == 'confirm') {
this.editForm[attrName].splice(subIndex, 1)
}
}
this.secondSimpleConfirm('删除', '是否删除该图片?', () => {
this.editForm[attrName].splice(subIndex, 1)
})
},
handleImgLook(src) {
this.isImgVisible = true
this.dialogImageUrl = src
},
// 跳转
whereToGo(id) {
document.getElementById(id).scrollIntoView()
},
// 图片-描述-end
handleConfirm() {
this.$refs.editFormRef.$refs[this.editChildRef].validate(valid => {
if (valid) {
var params = this.$common.utils.deepClone(this.editForm)
if (this.routeInfo.addOrEdit == 2) {
params.id = this.routeInfo.id
var isJump = false
for (var i = 0; i < this.externalFormList.length; i++) {
if (isJump) {
return true
}
this.$refs.editFormRef[i].$refs['editProRef' + i].validate((valid, errorObj) => {
if (!valid) {
isJump = true
this.whereToGo(Object.keys(errorObj)[0])
}
})
}
// this.$refs.editFormRef[0].$refs.editProRef0.validate((valid0, errorObj0) => {
// if (!valid0) {
// this.whereToGo(Object.keys(errorObj0)[0])
// return true
// }
// this.$refs.editFormRef[1].$refs.editProRef1.validate((valid1, errorObj1) => {
// if (!valid0) {
// this.whereToGo(Object.keys(errorObj1)[0])
// return true
// }
// this.$refs.editFormRef[2].$refs.editProRef2.validate(valid2 => {
// if (valid0 && valid1 && valid2) {
var params = this.$common.utils.deepClone(this.editForm)
var deleteAttrList = ['descImgList', 'describeTxt']
var priceList = ['retailPrice', 'originalPrice', 'supplyPrice', 'expressFee']
if (this.routeInfo.addOrEdit == 2) {
params.id = this.routeInfo.id
}
// 描述
params.goodsDescList = this.$common.utils.deepClone(this.editForm.descImgList)
if (this.editForm.describeTxt) {
params.goodsDescList.unshift({
content: this.editForm.describeTxt,
resType: 2,
bizType: 2
})
}
// 规格
params.specificationDetailList = []
this.nameToValSpecsList.forEach((item, index) => {
var specificationData = ''
item.specsValueList.forEach((subItem, subIndex) => {
if (subIndex != 0) {
specificationData += '&'
}
// this.$apis.zoneList.insertZoneApi(params).then(res => {
// this.$message({
// message: res.code == '0' ? '操作成功' : '操作失败',
// type: res.code == '0' ? 'success' : 'error'
// })
// if (res.code == '0') {
// this.handleCancel()
// }
// })
specificationData = specificationData + this.specificationDetailList[subIndex].specificationName + '-' + subItem
})
params.specificationDetailList.push({
specificationData: specificationData,
retailPrice: (item.retailPrice * 100).toFixed(0),
stock: item.stock
})
})
// 专区-门店没有专区
if (this.routeInfo.groupOrStore != 1) {
delete params.zoneId
}
// 价格格式化(计算到分)
priceList.forEach(item => {
if (params[item]) {
params[item] = (this.editForm[item] * 100).toFixed(0)
}
})
params.supplyMerchantList = []
this.editForm.supplyMerchantList.forEach(item => {
params.supplyMerchantList.push({
merchantId: item.merchantNo,
merchantName: item.merchantName,
merchantAccountLevel: item.merchantAccountLevel
})
})
deleteAttrList.forEach(item => {
delete params[item]
})
console.log(params)
// this.$apis.zoneList.insertZoneApi(params).then(res => {
// this.$message({
// message: res.code == '0' ? '操作成功' : '操作失败',
// type: res.code == '0' ? 'success' : 'error'
// })
// if (res.code == '0') {
// this.handleCancel()
// }
// })
// }
// })
// })
// })
},
handleCancel() {
this.$router.push({
......@@ -638,4 +1015,57 @@ export default {
}
}
</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;
}
.edit-pro .w-320 {
width: 320px;
}
/* .el-tag + .el-tag {
margin-left: 10px;
} */
.button-new-tag {
height: 32px;
line-height: 30px;
padding-top: 0;
padding-bottom: 0;
}
.input-new-tag {
width: 90px;
vertical-align: bottom;
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!