Commit bafefaaa by wangql

111

1 parent 434d1c8e
...@@ -5,79 +5,76 @@ ...@@ -5,79 +5,76 @@
<div class="right_show"> <div class="right_show">
<div class="card-top"></div> <div class="card-top"></div>
<div class="card-middle"> <div class="card-middle">
<div> <div>
<span class="cname">{{ editForm.couponName }}</span> <span class="cname">{{ editForm.couponName }}</span>
<span class="ctype"><span class="ctypeName">代金券</span></span> <span class="ctype"><span class="ctypeName">代金券</span></span>
</div> </div>
<div class="ctime"> <div class="ctime">
<span class="ctime_name">有效期: </span> <span class="ctime_name">有效期:</span>
<span class="ctime_content" v-if="editForm.effectiveType == 3">无限制</span> <span class="ctime_content" v-if="editForm.effectiveType == 3">无限制</span>
<span class="ctime_content" v-if="editForm.effectiveType == 1">{{editForm.effectiveDays}}天</span> <span class="ctime_content" v-if="editForm.effectiveType == 1">{{ editForm.effectiveDays }}天</span>
<span class="ctime_content" v-if="editForm.effectiveType == 2">{{couponTime}}</span> <span class="ctime_content" v-if="editForm.effectiveType == 2">{{ couponTime }}</span>
</div> </div>
<div class="ctime"> <div class="ctime">
<span class="ctime_name">使用限制: </span> <span class="ctime_name">使用限制:</span>
<span class="ctime_content">{{editForm.useBarriers==1?'无限制':'满'+ editForm.full + '可用'}}</span> <span class="ctime_content">{{ editForm.useBarriers == 1 ? '无限制' : '满' + editForm.full + '可用' }}</span>
</div> </div>
<div class="cremarks">使用说明: </div> <div class="cremarks">使用说明:</div>
<div class="cremarks_content">{{editForm.useDescription}}</div> <div class="cremarks_content">{{ editForm.useDescription }}</div>
</div> </div>
</div> </div>
<p class="edit-title">{{ title }}代金券</p> <p class="edit-title">{{ title }}代金券</p>
<glsx-combi-form class="edit-form-container" style="min-height: 570px;" ref="editFormRef" labelWidth="144px" :isBlock="true" :formRef="editChildRef" :formObj="editForm" :formData="editFormData" :formRules="editRule"> <glsx-combi-form class="edit-form-container" style="min-height: 570px;" ref="editFormRef" labelWidth="144px" :isBlock="true" :formRef="editChildRef" :formObj="editForm" :formData="editFormData" :formRules="editRule">
<template slot="useChannelHtml"> <template slot="useChannelHtml">
<el-radio v-model="editForm.useChannel" label="1" :disabled="apear!='couponAdd'">线上商品</el-radio> <el-radio v-model="editForm.useChannel" label="1" :disabled="apear != 'couponAdd'">线上商品</el-radio>
<el-radio v-model="editForm.useChannel" label="2" :disabled="apear!='couponAdd'">到店核销</el-radio> <el-radio v-model="editForm.useChannel" label="2" :disabled="apear != 'couponAdd'">到店核销</el-radio>
</template> </template>
<template slot="effectiveHtml"> <template slot="effectiveHtml">
<el-radio v-model="editForm.effectiveType" label="3" :disabled="apear!='couponAdd'">无有效期</el-radio><br> <el-radio v-model="editForm.effectiveType" label="3" :disabled="apear != 'couponAdd'">无有效期</el-radio>
<el-form-item prop="effectiveTime" style="margin-top: 12px;display: block;"> <br />
<el-radio v-model="editForm.effectiveType" label="2" :disabled="apear!='couponAdd'"> <el-form-item prop="effectiveTime" style="margin-top: 12px;display: block;">
<el-date-picker <el-radio v-model="editForm.effectiveType" label="2" :disabled="apear != 'couponAdd'">
v-model="editForm.effectiveTime" <el-date-picker v-model="editForm.effectiveTime" type="daterange" style="width:295px" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd" :disabled="editForm.effectiveType != 2 || apear != 'couponAdd'" clearable></el-date-picker>
type="daterange" </el-radio>
style="width:295px" </el-form-item>
range-separator="至" <el-form-item prop="effectiveDays">
start-placeholder="开始日期" <el-radio v-model="editForm.effectiveType" label="1" :disabled="apear != 'couponAdd'">
end-placeholder="结束日期" 领取后
value-format="yyyy-MM-dd" <el-input v-model="editForm.effectiveDays" style="width:100px;margin-left:5px;margin-right:5px" :disabled="apear != 'couponAdd' || editForm.effectiveType != 1" />
:disabled="editForm.effectiveType != 2||apear!='couponAdd'" clearable> 天内有效
</el-date-picker> </el-radio>
</el-radio> </el-form-item>
</el-form-item>
<el-form-item prop="effectiveDays">
<el-radio v-model="editForm.effectiveType" label="1" :disabled="apear!='couponAdd'">
领取后<el-input v-model="editForm.effectiveDays" style="width:100px;margin-left:5px;margin-right:5px" :disabled="apear!='couponAdd'|| editForm.effectiveType != 1" />天内有效
</el-radio>
</el-form-item>
</template> </template>
<template slot="useBarriersHtml"> <template slot="useBarriersHtml">
<el-radio v-model="editForm.useBarriers" label="1" :disabled="apear!='couponAdd'">无限制</el-radio> <el-radio v-model="editForm.useBarriers" label="1" :disabled="apear != 'couponAdd'">无限制</el-radio>
<el-form-item prop="full"> <el-form-item prop="full">
<el-radio v-model="editForm.useBarriers" label="2" :disabled="apear!='couponAdd' || editForm.useChannel == 2"> <el-radio v-model="editForm.useBarriers" label="2" :disabled="apear != 'couponAdd' || editForm.useChannel == 2">
订单满<el-input v-model="editForm.full" placeholder="输入金额(元)" style="width: 110px;margin-left:5px;margin-right:5px" :disabled="apear!='couponAdd'|| editForm.useBarriers != 2" />元可用 订单满
</el-radio> <el-input v-model="editForm.full" placeholder="输入金额(元)" style="width: 110px;margin-left:5px;margin-right:5px" :disabled="apear != 'couponAdd' || editForm.useBarriers != 2" />
</el-form-item> 元可用
</el-radio>
</el-form-item>
</template> </template>
<template slot="denominationHtml"> <template slot="denominationHtml">
<el-input v-model="editForm.denomination" style="width: 150px" :disabled="apear!='couponAdd'" @blur.native.capture="editForm.useChannel == 1 && denominationBlur($event)"> <el-input v-model="editForm.denomination" style="width: 150px" :disabled="apear != 'couponAdd'" @blur.native.capture="editForm.useChannel == 1 && denominationBlur($event)">
<span slot="append">元</span> <span slot="append">元</span>
</el-input> </el-input>
<span style="color:red;margin-left:15px" v-if="priceFlag">存在零售价低于代金券的商品</span> <span style="color:red;margin-left:15px" v-if="priceFlag">存在零售价低于代金券的商品</span>
</template> </template>
<!-- 只有使用途径为线上商品时才有效,到店核销时屏蔽 --> <!-- 只有使用途径为线上商品时才有效,到店核销时屏蔽 -->
<template slot="goodsHtml"> <template slot="goodsHtml">
<el-radio v-model="editForm.goods" label="1" v-if="apear=='couponAdd'">全部商品可用</el-radio> <el-radio v-model="editForm.goods" label="1" v-if="apear == 'couponAdd'">全部商品可用</el-radio>
<el-radio v-model="editForm.goods" label="2" v-if="apear=='couponAdd'">指定商品可用 <el-radio v-model="editForm.goods" label="2" v-if="apear == 'couponAdd'">
<el-button type="primary" v-if="editForm.goods == 2" @click="chooseGoods">选择商品</el-button> 指定商品可用
</el-radio> <el-button type="primary" v-if="editForm.goods == 2" @click="chooseGoods">选择商品</el-button>
</el-radio>
</template> </template>
<!-- 新增时并且为指定商品时显示,编辑或者查看时也显示 --> <!-- 新增时并且为指定商品时显示,编辑或者查看时也显示 -->
<div slot="proTable" class="select-pro" v-if="apear!='couponAdd' || (editForm.useChannel == 1 && editForm.goods == 2)"> <div slot="proTable" class="select-pro" v-if="apear != 'couponAdd' || (editForm.useChannel == 1 && editForm.goods == 2)">
<div style="height:110px" v-if="editForm.goodsRefList.length"></div> <div style="height:110px" v-if="editForm.goodsRefList.length"></div>
<GLTable v-show="editForm.goodsRefList.length" :hasPage="false" :tableParams="tableParams" :tableData="editForm.goodsRefList"> <GLTable v-show="editForm.goodsRefList.length" :hasPage="false" :tableParams="tableParams" :tableData="editForm.goodsRefList">
<template slot="goodsImage" slot-scope="scope"> <template slot="goodsImage" slot-scope="scope">
<img class="img-60" :src="scope.scope.goodsImage"/> <img class="img-60" :src="scope.scope.goodsImage" />
</template> </template>
<span slot="auth-button" slot-scope="scope"> <span slot="auth-button" slot-scope="scope">
<el-button type="text" @click="handleProDelete(scope)">删除</el-button> <el-button type="text" @click="handleProDelete(scope)">删除</el-button>
...@@ -85,17 +82,16 @@ ...@@ -85,17 +82,16 @@
</GLTable> </GLTable>
</div> </div>
<template slot="useDescriptionHtml"> <template slot="useDescriptionHtml">
<el-input type="textarea" v-model="editForm.useDescription" style="width: 320px" :autosize="{ minRows: 2, maxRows: 4}" maxlength="200" :disabled="apear=='couponSee'" /> <el-input type="textarea" v-model="editForm.useDescription" style="width: 320px" :autosize="{ minRows: 2, maxRows: 4 }" maxlength="200" :disabled="apear == 'couponSee'" />
</template> </template>
</glsx-combi-form> </glsx-combi-form>
</div> </div>
<div class="footer" :style="{ left: footerLeft + 'px', width: footerWidth + 'px' }"> <div class="footer" :style="{ left: footerLeft + 'px', width: footerWidth + 'px' }">
<el-button type="default" v-if="apear!='couponSee'" @click="handleCancel">取消</el-button> <el-button type="default" v-if="apear != 'couponSee'" @click="handleCancel">取消</el-button>
<el-button type="primary" v-if="apear!='couponSee'" @click="handleConfirm">确定</el-button> <el-button type="primary" v-if="apear != 'couponSee'" @click="handleConfirm">确定</el-button>
<el-button type="default" v-if="apear=='couponSee'" @click="handleCancel">返回</el-button> <el-button type="default" v-if="apear == 'couponSee'" @click="handleCancel">返回</el-button>
</div> </div>
<select-muti-pro-forcoupon-dialog v-if="isMutiSelectVisible" :isMutiSelectVisible="isMutiSelectVisible" :searchForm="searchProForm" :selectedProList="selectedProList" @handleMutiSelectConfirm="handleMutiSelectConfirm" @handleMutiSelectClose="handleMutiSelectClose"> <select-muti-pro-forcoupon-dialog v-if="isMutiSelectVisible" :isMutiSelectVisible="isMutiSelectVisible" :searchForm="searchProForm" :selectedProList="selectedProList" @handleMutiSelectConfirm="handleMutiSelectConfirm" @handleMutiSelectClose="handleMutiSelectClose"></select-muti-pro-forcoupon-dialog>
</select-muti-pro-forcoupon-dialog>
</div> </div>
</template> </template>
...@@ -139,7 +135,7 @@ export default { ...@@ -139,7 +135,7 @@ export default {
useBarriers: '1', useBarriers: '1',
full: '', full: '',
goods: '1', goods: '1',
goodsRefList: [], goodsRefList: []
}, },
//商品列表 //商品列表
tableParams: { tableParams: {
...@@ -256,58 +252,59 @@ export default { ...@@ -256,58 +252,59 @@ export default {
var id = this.routeInfo.id var id = this.routeInfo.id
var addOrEdit = this.routeInfo.addOrEdit var addOrEdit = this.routeInfo.addOrEdit
if (id) { if (id) {
if(addOrEdit == 3){ if (addOrEdit == 3) {
this.apear = 'couponSee'; this.apear = 'couponSee'
this.title = '查看'; this.title = '查看'
}else if(addOrEdit == 2){ } else if (addOrEdit == 2) {
this.apear = 'couponEdit'; this.apear = 'couponEdit'
this.title = '编辑'; this.title = '编辑'
} }
this.editFormData[0].isDisabled = true this.editFormData[0].isDisabled = true
this.editFormData[5].isDisabled = true this.editFormData[5].isDisabled = true
} else { } else {
this.apear = 'couponAdd'; this.apear = 'couponAdd'
this.title = '创建'; this.title = '创建'
} }
}, },
watch: { watch: {
'editForm.effectiveDays'(newValue, oldValue){ 'editForm.effectiveDays'(newValue, oldValue) {
this.editForm.effectiveDays = limitPrice(newValue, oldValue, 3, 0) this.editForm.effectiveDays = limitPrice(newValue, oldValue, 3, 0)
}, },
'editForm.full'(newValue, oldValue){ 'editForm.full'(newValue, oldValue) {
this.editForm.full = limitPrice(newValue, oldValue, 5, 2) this.editForm.full = limitPrice(newValue, oldValue, 5, 2)
}, },
'editForm.denomination'(newValue, oldValue){ 'editForm.denomination'(newValue, oldValue) {
this.editForm.denomination = limitPrice(newValue, oldValue, 4, 0, 0, 2000) this.editForm.denomination = limitPrice(newValue, oldValue, 4, 0, 0, 2000)
}, },
'editForm.stock'(newValue, oldValue){ 'editForm.stock'(newValue, oldValue) {
this.editForm.stock = limitPrice(newValue, oldValue, 6, 0, 1) this.editForm.stock = limitPrice(newValue, oldValue, 6, 0, 1)
}, },
'editForm.effectiveTime'(newValue, oldValue){ 'editForm.effectiveTime'(newValue, oldValue) {
if(newValue && newValue.length > 0){ if (newValue && newValue.length > 0) {
this.couponTime = this.setDateString(newValue[0], true) + ' - ' + this.setDateString(newValue[1], true) this.couponTime = this.setDateString(newValue[0], true) + ' - ' + this.setDateString(newValue[1], true)
}else{ } else {
this.couponTime = '' this.couponTime = ''
} }
}, },
'editForm.useDescription'(newValue, oldValue){ 'editForm.useDescription'(newValue, oldValue) {
if(newValue){ if (newValue) {
this.remarksView = newValue.split('\n') this.remarksView = newValue.split('\n')
} }
}, },
'editForm.useChannel'(newValue, oldValue){ 'editForm.useChannel'(newValue, oldValue) {
if(newValue == 1){ if (newValue == 1) {
this.editFormData[6].isHide = false this.editFormData[6].isHide = false
}else{ } else {
this.editForm.useBarriers = '1' this.editForm.useBarriers = '1'
this.editForm.full = '' this.editForm.full = ''
this.editFormData[6].isHide = true this.editFormData[6].isHide = true
} }
}, },
'editForm.goods'(newValue, oldValue){ 'editForm.goods'(newValue, oldValue) {
if(newValue == 1){//全部商品 if (newValue == 1) {
// var goods = this.selectedAllProList //全部商品
// var goods = this.selectedAllProList
// if(goods && goods.length > 0){ // if(goods && goods.length > 0){
// this.minPirce = goods[0].retailPrice // this.minPirce = goods[0].retailPrice
// goods.forEach((item, index) => { // goods.forEach((item, index) => {
...@@ -319,7 +316,8 @@ export default { ...@@ -319,7 +316,8 @@ export default {
// this.priceFlag = true // this.priceFlag = true
// } // }
this.minPirce = this.minPirceForAll this.minPirce = this.minPirceForAll
}else{//指定商品 } else {
//指定商品
// var goods2 = this.editForm.goodsRefList // var goods2 = this.editForm.goodsRefList
// if(goods2 && goods2.length > 0){ // if(goods2 && goods2.length > 0){
// this.minPirce = goods2[0].retailPrice*100 // this.minPirce = goods2[0].retailPrice*100
...@@ -332,58 +330,56 @@ export default { ...@@ -332,58 +330,56 @@ export default {
// } // }
this.minPirce = this.minPirceForPart this.minPirce = this.minPirceForPart
} }
if(this.editForm.denomination && this.minPirce && this.editForm.denomination*100 > this.minPirce){ if (this.editForm.denomination && this.minPirce && this.editForm.denomination * 100 > this.minPirce) {
this.priceFlag = true this.priceFlag = true
}else{ } else {
this.priceFlag = false this.priceFlag = false
} }
}, }
}, },
methods: { methods: {
setDateString(objField, special) { setDateString(objField, special) {
var value = (typeof objField == 'string') ? objField.split(" ")[0] : special ? objField.format('YYYY年MM月DD日') : objField.format('YYYY年MM月DD日') var value = typeof objField == 'string' ? objField.split(' ')[0] : special ? objField.format('YYYY年MM月DD日') : objField.format('YYYY年MM月DD日')
return value return value
}, },
getAllGoods(goodsName){ getAllGoods(goodsName) {
var params = { var params = {
currentPage: 1, currentPage: 1,
pageNum: 1, pageNum: 1,
pageSize: 100000, pageSize: 100000,
pageStart: 0, pageStart: 0,
goodsStatus: 1, goodsStatus: 1,
goodsName:'' goodsName: ''
} }
if(goodsName){ if (goodsName) {
params.goodsName = goodsName params.goodsName = goodsName
} }
this.$apis.couponManage.getAllGoodsApi(params).then(res => { this.$apis.couponManage.getAllGoodsApi(params).then(res => {
const goods = this.$common.utils.deepClone(res.list) const goods = this.$common.utils.deepClone(res.list)
this.selectedAllProList = goods this.selectedAllProList = goods
if(goods && goods.length > 0){ if (goods && goods.length > 0) {
// this.minPirce = goods[0].retailPrice // this.minPirce = goods[0].retailPrice
// goods.forEach((item, index) => { // goods.forEach((item, index) => {
// if(item.retailPrice < this.minPirce){ // if(item.retailPrice < this.minPirce){
// this.minPirce = item.retailPrice // this.minPirce = item.retailPrice
// } // }
// }) // })
this.minPirceForAll = goods[0].retailPrice this.minPirceForAll = goods[0].retailPrice
goods.forEach((item, index) => { goods.forEach((item, index) => {
if(item.retailPrice < this.minPirceForAll){ if (item.retailPrice < this.minPirceForAll) {
this.minPirceForAll = item.retailPrice this.minPirceForAll = item.retailPrice
} }
}) })
}else{ } else {
this.priceFlag = true this.priceFlag = true
} }
}) })
}, },
//选择商品 //选择商品
chooseGoods(){ chooseGoods() {
this.selectedProList = this.$common.utils.deepClone(this.editForm.goodsRefList) this.selectedProList = this.$common.utils.deepClone(this.editForm.goodsRefList)
this.handleMutiSelectClose() this.handleMutiSelectClose()
}, },
...@@ -413,16 +409,16 @@ export default { ...@@ -413,16 +409,16 @@ export default {
// }else{ // }else{
// this.priceFlag = false // this.priceFlag = false
// } // }
this.minPirceForPart = goods[0].retailPrice*100 this.minPirceForPart = goods[0].retailPrice * 100
goods.forEach((item, index) => { goods.forEach((item, index) => {
var retailPrice = item.retailPrice*100 var retailPrice = item.retailPrice * 100
if(retailPrice < this.minPirceForPart){ if (retailPrice < this.minPirceForPart) {
this.minPirceForPart = retailPrice this.minPirceForPart = retailPrice
} }
}) })
if(this.editForm.denomination && this.editForm.denomination*100 > this.minPirceForPart){ if (this.editForm.denomination && this.editForm.denomination * 100 > this.minPirceForPart) {
this.priceFlag = true this.priceFlag = true
}else{ } else {
this.priceFlag = false this.priceFlag = false
} }
/** 选择指定商品时,面值最小值的判断区域应该在已选商品内 end*/ /** 选择指定商品时,面值最小值的判断区域应该在已选商品内 end*/
...@@ -448,22 +444,24 @@ export default { ...@@ -448,22 +444,24 @@ export default {
}) })
}, },
denominationBlur(event){ denominationBlur(event) {
if(this.editForm.goods == 1){//全部商品 if (this.editForm.goods == 1) {
this.minPirce = this.minPirceForAll //全部商品
}else{//指定商品 this.minPirce = this.minPirceForAll
this.minPirce = this.minPirceForPart } else {
} //指定商品
if(event.target.value*100 > this.minPirce){ this.minPirce = this.minPirceForPart
this.priceFlag = true }
}else{ if (event.target.value * 100 > this.minPirce) {
this.priceFlag = false this.priceFlag = true
} } else {
this.priceFlag = false
}
}, },
getInfo() { getInfo() {
this.$apis.couponManage.getCouponDetailApi({ couponId: this.routeInfo.id }).then(res => { this.$apis.couponManage.getCouponDetailApi({ couponId: this.routeInfo.id }).then(res => {
console.log(res); console.log(res)
this.editForm = this.$common.utils.deepClone(res) this.editForm = this.$common.utils.deepClone(res)
this.editForm.useChannel = this.editForm.useChannel + '' this.editForm.useChannel = this.editForm.useChannel + ''
this.editForm.effectiveType = this.editForm.effectiveType + '' this.editForm.effectiveType = this.editForm.effectiveType + ''
...@@ -472,112 +470,121 @@ export default { ...@@ -472,112 +470,121 @@ export default {
//有效期 //有效期
//有效类型 1:固定天数,领取后计算 2:时间段,3:无有效期 //有效类型 1:固定天数,领取后计算 2:时间段,3:无有效期
if (this.editForm.effectiveType == 2) { if (this.editForm.effectiveType == 2) {
this.editForm.effectiveTime = [this.editForm.effectiveStartTime,this.editForm.effectiveEndTime] this.editForm.effectiveTime = [this.editForm.effectiveStartTime, this.editForm.effectiveEndTime]
} }
this.editForm.goodsRefList = [] this.editForm.goodsRefList = []
if(this.editForm.goodsIds && this.editForm.goodsIds.length > 0){ if (this.editForm.goodsIds && this.editForm.goodsIds.length > 0) {
this.editForm.goodsIds.forEach((goodsId, index) => { this.editForm.goodsIds.forEach((goodsId, index) => {
var good = this.selectedAllProList.find(item => item.id == goodsId) var good = this.selectedAllProList.find(item => item.id == goodsId)
good.retailPrice = (good.retailPrice / 100).toFixed(2) good.retailPrice = (good.retailPrice / 100).toFixed(2)
this.editForm.goodsRefList.push(good) this.editForm.goodsRefList.push(good)
}) })
} }
this.tableParams.tableOption = false //去掉操作栏 this.tableParams.tableOption = false //去掉操作栏
}) })
}, },
validateRules(){ validateRules() {
var form = this.editForm var form = this.editForm
if(form.effectiveType == '2'){//判断 有效期-日期选择是否验证 if (form.effectiveType == '2') {
this.editRule.effectiveTime[0].required = true //判断 有效期-日期选择是否验证
}else { this.editRule.effectiveTime[0].required = true
this.editRule.effectiveTime[0].required = false } else {
this.editRule.effectiveTime[0].required = false
} }
if(form.effectiveType == '1'){//判断 有效期-有效天数是否验证 if (form.effectiveType == '1') {
this.editRule.effectiveDays[0].required = true //判断 有效期-有效天数是否验证
}else { this.editRule.effectiveDays[0].required = true
this.editRule.effectiveDays[0].required = false } else {
this.editRule.effectiveDays[0].required = false
} }
if(form.useBarriers == '2'){//判断 使用限制-订单满多少可用是否验证 if (form.useBarriers == '2') {
this.editRule.full[0].required = true //判断 使用限制-订单满多少可用是否验证
}else { this.editRule.full[0].required = true
this.editRule.full[0].required = false } else {
this.editRule.full[0].required = false
} }
if(this.apear == 'couponAdd'){ if (this.apear == 'couponAdd') {
this.editRule.goods[0].required = true this.editRule.goods[0].required = true
}else{ } else {
this.editRule.goods[0].required = false this.editRule.goods[0].required = false
} }
}, },
getCouponInfoParams() { getCouponInfoParams() {
var obj = {}; var obj = {}
var id = this.routeInfo.id var id = this.routeInfo.id
var form = this.$common.utils.deepClone(this.editForm) var form = this.$common.utils.deepClone(this.editForm)
if (id) { if (id) {
obj.couponId = id; obj.couponId = id
}else{//编辑时只允许编辑使用说明 } else {
//编辑时只允许编辑使用说明
//优惠券名称 //优惠券名称
obj.couponName = form.couponName; obj.couponName = form.couponName
//优惠券类型 1:满减券,2:折扣券,3:代金券,4:实物券 5:购车代金券 6:商品折扣券,7:会员服务 //优惠券类型 1:满减券,2:折扣券,3:代金券,4:实物券 5:购车代金券 6:商品折扣券,7:会员服务
obj.discountType = '3'; obj.discountType = '3'
obj.useChannel = form.useChannel obj.useChannel = form.useChannel
//有效期 //有效期
//有效类型 1:固定天数,领取后计算 2:时间段,3:无有效期 //有效类型 1:固定天数,领取后计算 2:时间段,3:无有效期
obj.effectiveType = form.effectiveType obj.effectiveType = form.effectiveType
if (form.effectiveType == 1) {//固定天数 if (form.effectiveType == 1) {
obj.effectiveDays = form.effectiveDays; //固定天数
} else if (form.effectiveType == 2) {//时间段 obj.effectiveDays = form.effectiveDays
} else if (form.effectiveType == 2) {
//时间段
const d = form.effectiveTime const d = form.effectiveTime
if (d && d.length > 0) { if (d && d.length > 0) {
obj.effectiveStartTime = d[0] + ' 00:00:00'; obj.effectiveStartTime = d[0] + ' 00:00:00'
obj.effectiveEndTime = d[1] + ' 23:59:59'; obj.effectiveEndTime = d[1] + ' 23:59:59'
} }
} }
//使用限制 1:无限制 2:满减 //使用限制 1:无限制 2:满减
obj.useBarriers = form.useBarriers obj.useBarriers = form.useBarriers
if (form.useBarriers == 2) { if (form.useBarriers == 2) {
//满多少减 //满多少减
obj.full = form.full; obj.full = form.full
} }
//面值 //面值
obj.denomination = form.denomination; obj.denomination = form.denomination
//库存 //库存
obj.stock = form.stock; obj.stock = form.stock
//类型(0:不限制次数,1:根据有效期限制多少次,2:根据间隔多少天限制多少次) //类型(0:不限制次数,1:根据有效期限制多少次,2:根据间隔多少天限制多少次)
obj.useType = 1 obj.useType = 1
//有效期或者间隔天数使用次数 //有效期或者间隔天数使用次数
obj.useAmount = 1 obj.useAmount = 1
if(form.useChannel == 1){//使用途径选择线上商品才需要对应的商品 if (form.useChannel == 1) {
//使用途径选择线上商品才需要对应的商品
//适用商品 //适用商品
if(form.goods == 1){//全部商品 if (form.goods == 1) {
//全部商品
obj.goodsIdList = this.selectedAllProList.length ? this.selectedAllProList.map(item => item.id) : [] obj.goodsIdList = this.selectedAllProList.length ? this.selectedAllProList.map(item => item.id) : []
}else{//指定商品 } else {
//指定商品
obj.goodsIdList = form.goodsRefList.length ? form.goodsRefList.map(item => item.id) : [] obj.goodsIdList = form.goodsRefList.length ? form.goodsRefList.map(item => item.id) : []
} }
} }
} }
//使用描述 //使用描述
obj.useDescription = form.useDescription; obj.useDescription = form.useDescription
return obj; return obj
}, },
handleConfirm() { handleConfirm() {
this.validateRules() this.validateRules()
this.$refs.editFormRef.$refs[this.editChildRef].validate(valid => { this.$refs.editFormRef.$refs[this.editChildRef].validate(valid => {
if (valid) { if (valid) {
if(this.priceFlag){//存在零售价低于代金券的商品 if (this.priceFlag) {
//存在零售价低于代金券的商品
return return
} }
var params = this.getCouponInfoParams() var params = this.getCouponInfoParams()
console.log(params); console.log(params)
if(this.apear == 'couponAdd' && params.useChannel == 1 && !params.goodsIdList.length){ if (this.apear == 'couponAdd' && params.useChannel == 1 && !params.goodsIdList.length) {
this.$message({ this.$message({
message: '未选择商品', message: '未选择商品',
type: 'error' type: 'error'
...@@ -585,10 +592,10 @@ export default { ...@@ -585,10 +592,10 @@ export default {
return return
} }
let method = '' let method = ''
if(params.couponId){ if (params.couponId) {
method = 'updateCouponApi'//后台修改优惠券 method = 'updateCouponApi' //后台修改优惠券
}else { } else {
method = 'createCouponApi'//后台创建优惠券 method = 'createCouponApi' //后台创建优惠券
} }
this.$apis.couponManage[method](params).then(res => { this.$apis.couponManage[method](params).then(res => {
this.$message({ this.$message({
...@@ -612,124 +619,124 @@ export default { ...@@ -612,124 +619,124 @@ export default {
</script> </script>
<style scoped> <style scoped>
.right_show { .right_show {
/* float: right; */ /* float: right; */
position: absolute; position: absolute;
z-index: 10; z-index: 10;
height: 566px; height: 566px;
width: 290px; width: 290px;
right: 44px; right: 44px;
top: 92px; top: 92px;
background-image:url(../../assets/coupon/phone.png); background-image: url(../../assets/coupon/phone.png);
} }
.right_show .card-top { .right_show .card-top {
height: 59px; height: 59px;
width: 251px; width: 251px;
margin-left: 18px; margin-left: 18px;
margin-top: 55px; margin-top: 55px;
} }
.right_show .card-middle { .right_show .card-middle {
height: 388px; height: 388px;
width: 251px; width: 251px;
margin-left: 18px; margin-left: 18px;
overflow:auto overflow: auto;
} }
.right_show .card-middle .cname { .right_show .card-middle .cname {
width: 170px; width: 170px;
height: 17px; height: 17px;
font-family: PingFangSC-Regular; font-family: PingFangSC-Regular;
font-size: 12px; font-size: 12px;
color: #666666; color: #666666;
font-weight: 400; font-weight: 400;
margin-left: 10px; margin-left: 10px;
margin-top: 15px; margin-top: 15px;
display: inline-block; display: inline-block;
} }
.right_show .card-middle .ctype { .right_show .card-middle .ctype {
width: 48px; width: 48px;
height: 20px; height: 20px;
background: #5850FF; background: #5850ff;
border-radius: 10px; border-radius: 10px;
margin-right: 6px; margin-right: 6px;
margin-top: 10px; margin-top: 10px;
display: inline-block; display: inline-block;
float: right; float: right;
} }
.right_show .card-middle .ctype .ctypeName { .right_show .card-middle .ctype .ctypeName {
width: 36px; width: 36px;
height: 17px; height: 17px;
font-family: PingFangSC-Regular; font-family: PingFangSC-Regular;
font-size: 12px; font-size: 12px;
color: #FFFFFF; color: #ffffff;
font-weight: 400; font-weight: 400;
margin-left: 6px; margin-left: 6px;
} }
.right_show .card-middle .ctime { .right_show .card-middle .ctime {
margin-left: 10px; margin-left: 10px;
margin-top: 17px; margin-top: 17px;
} }
.right_show .card-middle .ctime .ctime_name { .right_show .card-middle .ctime .ctime_name {
width: 48px; width: 48px;
height: 17px; height: 17px;
font-family: PingFangSC-Regular; font-family: PingFangSC-Regular;
font-size: 12px; font-size: 12px;
color: #333333; color: #333333;
font-weight: 400; font-weight: 400;
} }
.right_show .card-middle .ctime .ctime_content { .right_show .card-middle .ctime .ctime_content {
height: 17px; height: 17px;
font-family: PingFangSC-Regular; font-family: PingFangSC-Regular;
font-size: 12px; font-size: 12px;
color: #717171; color: #717171;
font-weight: 400; font-weight: 400;
margin-left: 5px; margin-left: 5px;
} }
.right_show .card-middle .ccode { .right_show .card-middle .ccode {
width: 120px; width: 120px;
height: 120px; height: 120px;
margin-left: 67px; margin-left: 67px;
margin-top: 8px; margin-top: 8px;
} }
.right_show .card-middle .ccodeName { .right_show .card-middle .ccodeName {
width: 68px; width: 68px;
height: 17px; height: 17px;
font-family: PingFangSC-Medium; font-family: PingFangSC-Medium;
font-size: 12px; font-size: 12px;
color: #1D1D1D; color: #1d1d1d;
font-weight: 500; font-weight: 500;
margin-left: 93px; margin-left: 93px;
margin-top: 8px; margin-top: 8px;
} }
.right_show .card-middle .cremarks { .right_show .card-middle .cremarks {
margin-left: 10px; margin-left: 10px;
margin-top: 17px; margin-top: 17px;
width: 60px; width: 60px;
height: 17px; height: 17px;
font-family: PingFangSC-Regular; font-family: PingFangSC-Regular;
font-size: 12px; font-size: 12px;
color: #333333; color: #333333;
font-weight: 400; font-weight: 400;
} }
.right_show .card-middle .cremarks_content { .right_show .card-middle .cremarks_content {
margin-left: 10px; margin-left: 10px;
margin-right: 11px; margin-right: 11px;
margin-top: 4px; margin-top: 4px;
width: 230px; width: 230px;
height: 34px; height: 34px;
font-family: PingFangSC-Regular; font-family: PingFangSC-Regular;
font-size: 12px; font-size: 12px;
color: #666666; color: #666666;
font-weight: 400; font-weight: 400;
word-break: break-word; word-break: break-word;
} }
</style> </style>
<!-- 编辑代金券 --> <!-- 编辑代金券 -->
<template> <template>
<div class="edit-share marketing p-t-20"> <div class="edit-share marketing p-t-20">
<div class="container edit-container" style="height: 630px;position: relative;"> <div class="container edit-container" style="height: 630px; position: relative">
<div class="right_show"> <div class="right_show">
<div class="card-top"></div> <div class="card-top"></div>
<div class="card-middle"> <div class="card-middle">
<div> <div>
<span class="cname">{{ editForm.couponName }}</span> <span class="cname">{{ editForm.couponName }}</span>
<span class="ctype"><span class="ctypeName">折扣券</span></span> <span class="ctype"><span class="ctypeName">折扣券</span></span>
</div> </div>
<div class="ctime"> <div class="ctime">
<span class="ctime_name">有效期: </span> <span class="ctime_name">有效期:</span>
<span class="ctime_content" v-if="editForm.effectiveType == 1">{{editForm.effectiveDays}}天</span> <span class="ctime_content" v-if="editForm.effectiveType == 1">{{ editForm.effectiveDays }}天</span>
<span class="ctime_content" v-if="editForm.effectiveType == 2">{{couponTime}}</span> <span class="ctime_content" v-if="editForm.effectiveType == 2">{{ couponTime }}</span>
</div> </div>
<div class="ctime"> <div class="ctime">
<span class="ctime_name">核销劵码: </span> <span class="ctime_name">核销劵码:</span>
</div> </div>
<img class="ccode" src="../../assets/coupon/code.png" /> <img class="ccode" src="../../assets/coupon/code.png" />
<div class="ccodeName">GH078-003</div> <div class="ccodeName">GH078-003</div>
<div class="cremarks">使用说明: </div> <div class="cremarks">使用说明:</div>
<div class="cremarks_content">{{editForm.useDescription}}</div> <div class="cremarks_content">{{ editForm.useDescription }}</div>
</div> </div>
</div> </div>
<p class="edit-title">{{ title }}折扣劵</p> <p class="edit-title">{{ title }}折扣劵</p>
<glsx-combi-form class="edit-form-container" ref="editFormRef" labelWidth="140px" :isBlock="true" :formRef="editChildRef" :formObj="editForm" :formData="editFormData" :formRules="editRule"> <glsx-combi-form class="edit-form-container" ref="editFormRef" labelWidth="140px" :isBlock="true" :formRef="editChildRef" :formObj="editForm" :formData="editFormData" :formRules="editRule">
<template slot="effectiveHtml"> <template slot="effectiveHtml">
<el-form-item prop="effectiveTime" style="margin-top: 12px;display: block;"> <el-form-item prop="effectiveTime" style="margin-top: 12px; display: block">
<el-radio v-model="editForm.effectiveType" label="2" :disabled="apear!='couponAdd'"> <el-radio v-model="editForm.effectiveType" label="2" :disabled="apear != 'couponAdd'">
<el-date-picker <el-date-picker v-model="editForm.effectiveTime" type="daterange" style="width: 295px" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd" :disabled="editForm.effectiveType != 2 || apear != 'couponAdd'" clearable></el-date-picker>
v-model="editForm.effectiveTime" </el-radio>
type="daterange" </el-form-item>
style="width:295px" <el-form-item prop="effectiveDays">
range-separator="至" <el-radio v-model="editForm.effectiveType" label="1" :disabled="apear != 'couponAdd'">
start-placeholder="开始日期" 领取后
end-placeholder="结束日期" <el-input v-model="editForm.effectiveDays" style="width: 100px; margin-left: 5px; margin-right: 5px" :disabled="apear != 'couponAdd' || editForm.effectiveType != 1" />
value-format="yyyy-MM-dd" 天内有效
:disabled="editForm.effectiveType != 2||apear!='couponAdd'" clearable> </el-radio>
</el-date-picker> </el-form-item>
</el-radio>
</el-form-item>
<el-form-item prop="effectiveDays">
<el-radio v-model="editForm.effectiveType" label="1" :disabled="apear!='couponAdd'">
领取后<el-input v-model="editForm.effectiveDays" style="width: 100px;margin-left:5px;margin-right:5px" :disabled="apear!='couponAdd'|| editForm.effectiveType != 1" />天内有效
</el-radio>
</el-form-item>
</template> </template>
<template slot="useDescriptionHtml"> <template slot="useDescriptionHtml">
<el-input type="textarea" v-model="editForm.useDescription" style="width: 320px" :autosize="{ minRows: 2, maxRows: 4}" maxlength="200" :disabled="apear=='couponSee'" /> <el-input type="textarea" v-model="editForm.useDescription" style="width: 320px" :autosize="{ minRows: 2, maxRows: 4 }" maxlength="200" :disabled="apear == 'couponSee'" />
</template> </template>
</glsx-combi-form> </glsx-combi-form>
</div> </div>
<div class="footer" :style="{ left: footerLeft + 'px', width: footerWidth + 'px' }"> <div class="footer" :style="{ left: footerLeft + 'px', width: footerWidth + 'px' }">
<el-button type="default" v-if="apear!='couponSee'" @click="handleCancel">取消</el-button> <el-button type="default" v-if="apear != 'couponSee'" @click="handleCancel">取消</el-button>
<el-button type="primary" v-if="apear!='couponSee'" @click="handleConfirm">确定</el-button> <el-button type="primary" v-if="apear != 'couponSee'" @click="handleConfirm">确定</el-button>
<el-button type="default" v-if="apear=='couponSee'" @click="handleCancel">返回</el-button> <el-button type="default" v-if="apear == 'couponSee'" @click="handleCancel">返回</el-button>
</div> </div>
</div> </div>
</template> </template>
...@@ -92,7 +85,7 @@ export default { ...@@ -92,7 +85,7 @@ export default {
couponTime: '', couponTime: '',
editForm: { editForm: {
couponName: '', couponName: '',
effectiveType: '2', effectiveType: '2'
}, },
editRule: { editRule: {
couponName: [{ required: true, message: '请输入优惠券名称', trigger: 'change' }], couponName: [{ required: true, message: '请输入优惠券名称', trigger: 'change' }],
...@@ -100,7 +93,7 @@ export default { ...@@ -100,7 +93,7 @@ export default {
effectiveTime: [{ required: true, message: '有效期不能为空', trigger: 'change' }], effectiveTime: [{ required: true, message: '有效期不能为空', trigger: 'change' }],
effectiveDays: [{ required: true, message: '有效天数不能为空', trigger: 'blur' }], effectiveDays: [{ required: true, message: '有效天数不能为空', trigger: 'blur' }],
useDescription: [{ required: true, message: '使用说明不能为空', trigger: 'change' }], useDescription: [{ required: true, message: '使用说明不能为空', trigger: 'change' }],
stock: [{ required: true, message: '发放数量不能为空', trigger: 'change' }], stock: [{ required: true, message: '发放数量不能为空', trigger: 'change' }]
}, },
editFormData: [ editFormData: [
{ {
...@@ -115,7 +108,7 @@ export default { ...@@ -115,7 +108,7 @@ export default {
name: 'stock', name: 'stock',
width: '180px', width: '180px',
type: 'input', type: 'input',
append: '张', append: '张'
}, },
{ {
label: '有效期', label: '有效期',
...@@ -140,109 +133,113 @@ export default { ...@@ -140,109 +133,113 @@ export default {
var id = this.routeInfo.id var id = this.routeInfo.id
var addOrEdit = this.routeInfo.addOrEdit var addOrEdit = this.routeInfo.addOrEdit
if (id) { if (id) {
if(addOrEdit == 3){ if (addOrEdit == 3) {
this.apear = 'couponSee'; this.apear = 'couponSee'
this.title = '查看'; this.title = '查看'
}else if(addOrEdit == 2){ } else if (addOrEdit == 2) {
this.apear = 'couponEdit'; this.apear = 'couponEdit'
this.title = '编辑'; this.title = '编辑'
} }
this.isDisabled = true this.isDisabled = true
this.editFormData[0].isDisabled = this.isDisabled this.editFormData[0].isDisabled = this.isDisabled
this.editFormData[1].isDisabled = this.isDisabled this.editFormData[1].isDisabled = this.isDisabled
} else { } else {
this.apear = 'couponAdd'; this.apear = 'couponAdd'
this.title = '创建'; this.title = '创建'
this.isDisabled = false this.isDisabled = false
} }
}, },
watch: { watch: {
'editForm.effectiveDays'(newValue, oldValue){ 'editForm.effectiveDays'(newValue, oldValue) {
this.editForm.effectiveDays = limitPrice(newValue, oldValue, 3, 0) this.editForm.effectiveDays = limitPrice(newValue, oldValue, 3, 0)
}, },
'editForm.stock'(newValue, oldValue){ 'editForm.stock'(newValue, oldValue) {
this.editForm.stock = limitPrice(newValue, oldValue, 6, 0, 1) this.editForm.stock = limitPrice(newValue, oldValue, 6, 0, 1)
}, },
'editForm.effectiveTime'(newValue, oldValue){ 'editForm.effectiveTime'(newValue, oldValue) {
if(newValue && newValue.length > 0){ if (newValue && newValue.length > 0) {
this.couponTime = this.setDateString(newValue[0], true) + ' ~ ' + this.setDateString(newValue[1], true) this.couponTime = this.setDateString(newValue[0], true) + ' ~ ' + this.setDateString(newValue[1], true)
}else{ } else {
this.couponTime = '' this.couponTime = ''
} }
}, }
}, },
methods: { methods: {
setDateString(objField, special) { setDateString(objField, special) {
var value = (typeof objField == 'string') ? objField.split(" ")[0] : special ? objField.format('YYYY年MM月DD日') : objField.format('YYYY年MM月DD日') var value = typeof objField == 'string' ? objField.split(' ')[0] : special ? objField.format('YYYY年MM月DD日') : objField.format('YYYY年MM月DD日')
return value return value
}, },
getInfo() { getInfo() {
this.$apis.couponManage.getCouponDetailApi({ couponId: this.routeInfo.id }).then(res => { this.$apis.couponManage.getCouponDetailApi({ couponId: this.routeInfo.id }).then(res => {
console.log(res); console.log(res)
this.editForm = this.$common.utils.deepClone(res) this.editForm = this.$common.utils.deepClone(res)
this.editForm.effectiveType = this.editForm.effectiveType + '' this.editForm.effectiveType = this.editForm.effectiveType + ''
//有效期 //有效期
//有效类型 1:固定天数,领取后计算 2:时间段,3:无有效期 //有效类型 1:固定天数,领取后计算 2:时间段,3:无有效期
if (this.editForm.effectiveType == 2) { if (this.editForm.effectiveType == 2) {
this.editForm.effectiveTime = [this.editForm.effectiveStartTime,this.editForm.effectiveEndTime] this.editForm.effectiveTime = [this.editForm.effectiveStartTime, this.editForm.effectiveEndTime]
} }
}) })
}, },
validateRules(){ validateRules() {
var form = this.editForm var form = this.editForm
if(form.effectiveType == '2'){//判断 有效期-日期选择是否验证 if (form.effectiveType == '2') {
this.editRule.effectiveTime[0].required = true //判断 有效期-日期选择是否验证
}else { this.editRule.effectiveTime[0].required = true
this.editRule.effectiveTime[0].required = false } else {
this.editRule.effectiveTime[0].required = false
} }
if(form.effectiveType == '1'){//判断 有效期-有效天数是否验证 if (form.effectiveType == '1') {
this.editRule.effectiveDays[0].required = true //判断 有效期-有效天数是否验证
}else { this.editRule.effectiveDays[0].required = true
this.editRule.effectiveDays[0].required = false } else {
this.editRule.effectiveDays[0].required = false
} }
}, },
getCouponInfoParams() { getCouponInfoParams() {
var obj = {}; var obj = {}
var id = this.routeInfo.id var id = this.routeInfo.id
var form = this.$common.utils.deepClone(this.editForm) var form = this.$common.utils.deepClone(this.editForm)
if (id) { if (id) {
obj.couponId = id; obj.couponId = id
}else{//编辑时只允许编辑使用说明 } else {
//编辑时只允许编辑使用说明
//优惠券名称 //优惠券名称
obj.couponName = form.couponName; obj.couponName = form.couponName
//优惠券类型 1:满减券,2:折扣券,3:代金券,4:实物券 5:购车代金券 6:商品折扣券,7:会员服务 //优惠券类型 1:满减券,2:折扣券,3:代金券,4:实物券 5:购车代金券 6:商品折扣券,7:会员服务
obj.discountType = '2'; obj.discountType = '2'
//有效期 //有效期
//有效类型 1:固定天数,领取后计算 2:时间段,3:无有效期 //有效类型 1:固定天数,领取后计算 2:时间段,3:无有效期
obj.effectiveType = form.effectiveType obj.effectiveType = form.effectiveType
if (form.effectiveType == 1) {//固定天数 if (form.effectiveType == 1) {
obj.effectiveDays = form.effectiveDays; //固定天数
} else if (form.effectiveType == 2) {//时间段 obj.effectiveDays = form.effectiveDays
} else if (form.effectiveType == 2) {
//时间段
const d = form.effectiveTime const d = form.effectiveTime
if (d && d.length > 0) { if (d && d.length > 0) {
obj.effectiveStartTime = d[0] + ' 00:00:00'; obj.effectiveStartTime = d[0] + ' 00:00:00'
obj.effectiveEndTime = d[1] + ' 23:59:59'; obj.effectiveEndTime = d[1] + ' 23:59:59'
} }
} }
//库存 //库存
obj.stock = form.stock; obj.stock = form.stock
//类型(0:不限制次数,1:根据有效期限制多少次,2:根据间隔多少天限制多少次) //类型(0:不限制次数,1:根据有效期限制多少次,2:根据间隔多少天限制多少次)
obj.useType = 1 obj.useType = 1
//有效期或者间隔天数使用次数 //有效期或者间隔天数使用次数
obj.useAmount = 1 obj.useAmount = 1
} }
//使用描述 //使用描述
obj.useDescription = form.useDescription; obj.useDescription = form.useDescription
return obj; return obj
}, },
handleConfirm() { handleConfirm() {
...@@ -250,12 +247,12 @@ export default { ...@@ -250,12 +247,12 @@ export default {
this.$refs.editFormRef.$refs[this.editChildRef].validate(valid => { this.$refs.editFormRef.$refs[this.editChildRef].validate(valid => {
if (valid) { if (valid) {
var params = this.getCouponInfoParams() var params = this.getCouponInfoParams()
console.log(params); console.log(params)
let method = '' let method = ''
if(params.couponId){ if (params.couponId) {
method = 'updateCouponApi'//后台修改优惠券 method = 'updateCouponApi' //后台修改优惠券
}else { } else {
method = 'createCouponApi'//后台创建优惠券 method = 'createCouponApi' //后台创建优惠券
} }
this.$apis.couponManage[method](params).then(res => { this.$apis.couponManage[method](params).then(res => {
this.$message({ this.$message({
...@@ -279,124 +276,124 @@ export default { ...@@ -279,124 +276,124 @@ export default {
</script> </script>
<style scoped> <style scoped>
.right_show { .right_show {
/* float: right; */ /* float: right; */
position: absolute; position: absolute;
z-index: 10; z-index: 10;
height: 566px; height: 566px;
width: 290px; width: 290px;
right: 44px; right: 44px;
top: 92px; top: 92px;
background-image:url(../../assets/coupon/phone.png); background-image: url(../../assets/coupon/phone.png);
} }
.right_show .card-top { .right_show .card-top {
height: 59px; height: 59px;
width: 251px; width: 251px;
margin-left: 18px; margin-left: 18px;
margin-top: 55px; margin-top: 55px;
} }
.right_show .card-middle { .right_show .card-middle {
height: 388px; height: 388px;
width: 251px; width: 251px;
margin-left: 18px; margin-left: 18px;
overflow:auto overflow: auto;
} }
.right_show .card-middle .cname { .right_show .card-middle .cname {
width: 170px; width: 170px;
height: 17px; height: 17px;
font-family: PingFangSC-Regular; font-family: PingFangSC-Regular;
font-size: 12px; font-size: 12px;
color: #666666; color: #666666;
font-weight: 400; font-weight: 400;
margin-left: 10px; margin-left: 10px;
margin-top: 15px; margin-top: 15px;
display: inline-block; display: inline-block;
} }
.right_show .card-middle .ctype { .right_show .card-middle .ctype {
width: 48px; width: 48px;
height: 20px; height: 20px;
background: #5850FF; background: #5850ff;
border-radius: 10px; border-radius: 10px;
margin-right: 6px; margin-right: 6px;
margin-top: 10px; margin-top: 10px;
display: inline-block; display: inline-block;
float: right; float: right;
} }
.right_show .card-middle .ctype .ctypeName { .right_show .card-middle .ctype .ctypeName {
width: 36px; width: 36px;
height: 17px; height: 17px;
font-family: PingFangSC-Regular; font-family: PingFangSC-Regular;
font-size: 12px; font-size: 12px;
color: #FFFFFF; color: #ffffff;
font-weight: 400; font-weight: 400;
margin-left: 6px; margin-left: 6px;
} }
.right_show .card-middle .ctime { .right_show .card-middle .ctime {
margin-left: 10px; margin-left: 10px;
margin-top: 17px; margin-top: 17px;
} }
.right_show .card-middle .ctime .ctime_name { .right_show .card-middle .ctime .ctime_name {
width: 48px; width: 48px;
height: 17px; height: 17px;
font-family: PingFangSC-Regular; font-family: PingFangSC-Regular;
font-size: 12px; font-size: 12px;
color: #333333; color: #333333;
font-weight: 400; font-weight: 400;
} }
.right_show .card-middle .ctime .ctime_content { .right_show .card-middle .ctime .ctime_content {
height: 17px; height: 17px;
font-family: PingFangSC-Regular; font-family: PingFangSC-Regular;
font-size: 12px; font-size: 12px;
color: #717171; color: #717171;
font-weight: 400; font-weight: 400;
margin-left: 5px; margin-left: 5px;
} }
.right_show .card-middle .ccode { .right_show .card-middle .ccode {
width: 120px; width: 120px;
height: 120px; height: 120px;
margin-left: 67px; margin-left: 67px;
margin-top: 8px; margin-top: 8px;
} }
.right_show .card-middle .ccodeName { .right_show .card-middle .ccodeName {
width: 68px; width: 68px;
height: 17px; height: 17px;
font-family: PingFangSC-Medium; font-family: PingFangSC-Medium;
font-size: 12px; font-size: 12px;
color: #1D1D1D; color: #1d1d1d;
font-weight: 500; font-weight: 500;
margin-left: 93px; margin-left: 93px;
margin-top: 8px; margin-top: 8px;
} }
.right_show .card-middle .cremarks { .right_show .card-middle .cremarks {
margin-left: 10px; margin-left: 10px;
margin-top: 17px; margin-top: 17px;
width: 60px; width: 60px;
height: 17px; height: 17px;
font-family: PingFangSC-Regular; font-family: PingFangSC-Regular;
font-size: 12px; font-size: 12px;
color: #333333; color: #333333;
font-weight: 400; font-weight: 400;
} }
.right_show .card-middle .cremarks_content { .right_show .card-middle .cremarks_content {
margin-left: 10px; margin-left: 10px;
margin-right: 11px; margin-right: 11px;
margin-top: 4px; margin-top: 4px;
width: 230px; width: 230px;
height: 34px; height: 34px;
font-family: PingFangSC-Regular; font-family: PingFangSC-Regular;
font-size: 12px; font-size: 12px;
color: #666666; color: #666666;
font-weight: 400; font-weight: 400;
word-break: break-word; word-break: break-word;
} }
</style> </style>
...@@ -5,56 +5,49 @@ ...@@ -5,56 +5,49 @@
<div class="right_show"> <div class="right_show">
<div class="card-top"></div> <div class="card-top"></div>
<div class="card-middle"> <div class="card-middle">
<div> <div>
<span class="cname">{{ editForm.couponName }}</span> <span class="cname">{{ editForm.couponName }}</span>
<span class="ctype"><span class="ctypeName">兑换券</span></span> <span class="ctype"><span class="ctypeName">兑换券</span></span>
</div> </div>
<div class="ctime"> <div class="ctime">
<span class="ctime_name">有效期: </span> <span class="ctime_name">有效期:</span>
<span class="ctime_content" v-if="editForm.effectiveType == 1">{{editForm.effectiveDays}}天</span> <span class="ctime_content" v-if="editForm.effectiveType == 1">{{ editForm.effectiveDays }}天</span>
<span class="ctime_content" v-if="editForm.effectiveType == 2">{{couponTime}}</span> <span class="ctime_content" v-if="editForm.effectiveType == 2">{{ couponTime }}</span>
</div> </div>
<div class="ctime"> <div class="ctime">
<span class="ctime_name">核销劵码: </span> <span class="ctime_name">核销劵码:</span>
</div> </div>
<img class="ccode" src="../../assets/coupon/code.png" /> <img class="ccode" src="../../assets/coupon/code.png" />
<div class="ccodeName">GH078-003</div> <div class="ccodeName">GH078-003</div>
<div class="cremarks">使用说明: </div> <div class="cremarks">使用说明:</div>
<div class="cremarks_content">{{editForm.useDescription}}</div> <div class="cremarks_content">{{ editForm.useDescription }}</div>
</div> </div>
</div> </div>
<p class="edit-title">{{ title }}兑换券</p> <p class="edit-title">{{ title }}兑换券</p>
<glsx-combi-form class="edit-form-container" ref="editFormRef" labelWidth="140px" :isBlock="true" :formRef="editChildRef" :formObj="editForm" :formData="editFormData" :formRules="editRule"> <glsx-combi-form class="edit-form-container" ref="editFormRef" labelWidth="140px" :isBlock="true" :formRef="editChildRef" :formObj="editForm" :formData="editFormData" :formRules="editRule">
<template slot="effectiveHtml"> <template slot="effectiveHtml">
<el-form-item prop="effectiveTime" style="margin-top: 12px;display: block;"> <el-form-item prop="effectiveTime" style="margin-top: 12px;display: block;">
<el-radio v-model="editForm.effectiveType" label="2" :disabled="apear!='couponAdd'"> <el-radio v-model="editForm.effectiveType" label="2" :disabled="apear != 'couponAdd'">
<el-date-picker <el-date-picker v-model="editForm.effectiveTime" type="daterange" style="width:295px" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd" :disabled="editForm.effectiveType != 2 || apear != 'couponAdd'" clearable></el-date-picker>
v-model="editForm.effectiveTime" </el-radio>
type="daterange" </el-form-item>
style="width:295px" <el-form-item prop="effectiveDays">
range-separator="至" <el-radio v-model="editForm.effectiveType" label="1" :disabled="apear != 'couponAdd'">
start-placeholder="开始日期" 领取后
end-placeholder="结束日期" <el-input v-model="editForm.effectiveDays" style="width: 100px;margin-left:5px;margin-right:5px" :disabled="apear != 'couponAdd' || editForm.effectiveType != 1" />
value-format="yyyy-MM-dd" 天内有效
:disabled="editForm.effectiveType != 2||apear!='couponAdd'" clearable> </el-radio>
</el-date-picker> </el-form-item>
</el-radio>
</el-form-item>
<el-form-item prop="effectiveDays">
<el-radio v-model="editForm.effectiveType" label="1" :disabled="apear!='couponAdd'">
领取后<el-input v-model="editForm.effectiveDays" style="width: 100px;margin-left:5px;margin-right:5px" :disabled="apear!='couponAdd'|| editForm.effectiveType != 1" />天内有效
</el-radio>
</el-form-item>
</template> </template>
<template slot="useDescriptionHtml"> <template slot="useDescriptionHtml">
<el-input type="textarea" v-model="editForm.useDescription" style="width: 320px" :autosize="{ minRows: 2, maxRows: 4}" maxlength="200" :disabled="apear=='couponSee'" /> <el-input type="textarea" v-model="editForm.useDescription" style="width: 320px" :autosize="{ minRows: 2, maxRows: 4 }" maxlength="200" :disabled="apear == 'couponSee'" />
</template> </template>
</glsx-combi-form> </glsx-combi-form>
</div> </div>
<div class="footer" :style="{ left: footerLeft + 'px', width: footerWidth + 'px' }"> <div class="footer" :style="{ left: footerLeft + 'px', width: footerWidth + 'px' }">
<el-button type="default" v-if="apear!='couponSee'" @click="handleCancel">取消</el-button> <el-button type="default" v-if="apear != 'couponSee'" @click="handleCancel">取消</el-button>
<el-button type="primary" v-if="apear!='couponSee'" @click="handleConfirm">确定</el-button> <el-button type="primary" v-if="apear != 'couponSee'" @click="handleConfirm">确定</el-button>
<el-button type="default" v-if="apear=='couponSee'" @click="handleCancel">返回</el-button> <el-button type="default" v-if="apear == 'couponSee'" @click="handleCancel">返回</el-button>
</div> </div>
</div> </div>
</template> </template>
...@@ -92,7 +85,7 @@ export default { ...@@ -92,7 +85,7 @@ export default {
couponTime: '', couponTime: '',
editForm: { editForm: {
couponName: '', couponName: '',
effectiveType: '2', effectiveType: '2'
}, },
editRule: { editRule: {
couponName: [{ required: true, message: '请输入优惠券名称', trigger: 'change' }], couponName: [{ required: true, message: '请输入优惠券名称', trigger: 'change' }],
...@@ -100,7 +93,7 @@ export default { ...@@ -100,7 +93,7 @@ export default {
effectiveTime: [{ required: true, message: '有效期不能为空', trigger: 'change' }], effectiveTime: [{ required: true, message: '有效期不能为空', trigger: 'change' }],
effectiveDays: [{ required: true, message: '有效天数不能为空', trigger: 'blur' }], effectiveDays: [{ required: true, message: '有效天数不能为空', trigger: 'blur' }],
useDescription: [{ required: true, message: '使用说明不能为空', trigger: 'change' }], useDescription: [{ required: true, message: '使用说明不能为空', trigger: 'change' }],
stock: [{ required: true, message: '发放数量不能为空', trigger: 'change' }], stock: [{ required: true, message: '发放数量不能为空', trigger: 'change' }]
}, },
editFormData: [ editFormData: [
{ {
...@@ -115,7 +108,7 @@ export default { ...@@ -115,7 +108,7 @@ export default {
name: 'stock', name: 'stock',
width: '180px', width: '180px',
type: 'input', type: 'input',
append: '张', append: '张'
}, },
{ {
label: '有效期', label: '有效期',
...@@ -140,109 +133,113 @@ export default { ...@@ -140,109 +133,113 @@ export default {
var id = this.routeInfo.id var id = this.routeInfo.id
var addOrEdit = this.routeInfo.addOrEdit var addOrEdit = this.routeInfo.addOrEdit
if (id) { if (id) {
if(addOrEdit == 3){ if (addOrEdit == 3) {
this.apear = 'couponSee'; this.apear = 'couponSee'
this.title = '查看'; this.title = '查看'
}else if(addOrEdit == 2){ } else if (addOrEdit == 2) {
this.apear = 'couponEdit'; this.apear = 'couponEdit'
this.title = '编辑'; this.title = '编辑'
} }
this.isDisabled = true this.isDisabled = true
this.editFormData[0].isDisabled = this.isDisabled this.editFormData[0].isDisabled = this.isDisabled
this.editFormData[1].isDisabled = this.isDisabled this.editFormData[1].isDisabled = this.isDisabled
} else { } else {
this.apear = 'couponAdd'; this.apear = 'couponAdd'
this.title = '创建'; this.title = '创建'
this.isDisabled = false this.isDisabled = false
} }
}, },
watch: { watch: {
'editForm.effectiveDays'(newValue, oldValue){ 'editForm.effectiveDays'(newValue, oldValue) {
this.editForm.effectiveDays = limitPrice(newValue, oldValue, 3, 0) this.editForm.effectiveDays = limitPrice(newValue, oldValue, 3, 0)
}, },
'editForm.stock'(newValue, oldValue){ 'editForm.stock'(newValue, oldValue) {
this.editForm.stock = limitPrice(newValue, oldValue, 6, 0, 1) this.editForm.stock = limitPrice(newValue, oldValue, 6, 0, 1)
}, },
'editForm.effectiveTime'(newValue, oldValue){ 'editForm.effectiveTime'(newValue, oldValue) {
if(newValue && newValue.length > 0){ if (newValue && newValue.length > 0) {
this.couponTime = this.setDateString(newValue[0], true) + ' - ' + this.setDateString(newValue[1], true) this.couponTime = this.setDateString(newValue[0], true) + ' - ' + this.setDateString(newValue[1], true)
}else{ } else {
this.couponTime = '' this.couponTime = ''
} }
}, }
}, },
methods: { methods: {
setDateString(objField, special) { setDateString(objField, special) {
var value = (typeof objField == 'string') ? objField.split(" ")[0] : special ? objField.format('YYYY年MM月DD日') : objField.format('YYYY年MM月DD日') var value = typeof objField == 'string' ? objField.split(' ')[0] : special ? objField.format('YYYY年MM月DD日') : objField.format('YYYY年MM月DD日')
return value return value
}, },
getInfo() { getInfo() {
this.$apis.couponManage.getCouponDetailApi({ couponId: this.routeInfo.id }).then(res => { this.$apis.couponManage.getCouponDetailApi({ couponId: this.routeInfo.id }).then(res => {
console.log(res); console.log(res)
this.editForm = this.$common.utils.deepClone(res) this.editForm = this.$common.utils.deepClone(res)
this.editForm.effectiveType = this.editForm.effectiveType + '' this.editForm.effectiveType = this.editForm.effectiveType + ''
//有效期 //有效期
//有效类型 1:固定天数,领取后计算 2:时间段,3:无有效期 //有效类型 1:固定天数,领取后计算 2:时间段,3:无有效期
if (this.editForm.effectiveType == 2) { if (this.editForm.effectiveType == 2) {
this.editForm.effectiveTime = [this.editForm.effectiveStartTime,this.editForm.effectiveEndTime] this.editForm.effectiveTime = [this.editForm.effectiveStartTime, this.editForm.effectiveEndTime]
} }
}) })
}, },
validateRules(){ validateRules() {
var form = this.editForm var form = this.editForm
if(form.effectiveType == '2'){//判断 有效期-日期选择是否验证 if (form.effectiveType == '2') {
this.editRule.effectiveTime[0].required = true //判断 有效期-日期选择是否验证
}else { this.editRule.effectiveTime[0].required = true
this.editRule.effectiveTime[0].required = false } else {
this.editRule.effectiveTime[0].required = false
} }
if(form.effectiveType == '1'){//判断 有效期-有效天数是否验证 if (form.effectiveType == '1') {
this.editRule.effectiveDays[0].required = true //判断 有效期-有效天数是否验证
}else { this.editRule.effectiveDays[0].required = true
this.editRule.effectiveDays[0].required = false } else {
this.editRule.effectiveDays[0].required = false
} }
}, },
getCouponInfoParams() { getCouponInfoParams() {
var obj = {}; var obj = {}
var id = this.routeInfo.id var id = this.routeInfo.id
var form = this.$common.utils.deepClone(this.editForm) var form = this.$common.utils.deepClone(this.editForm)
if (id) { if (id) {
obj.couponId = id; obj.couponId = id
}else{//编辑时只允许编辑使用说明 } else {
//编辑时只允许编辑使用说明
//优惠券名称 //优惠券名称
obj.couponName = form.couponName; obj.couponName = form.couponName
//优惠券类型 1:满减券,2:折扣券,3:代金券,4:实物券 5:购车代金券 6:商品折扣券,7:会员服务 //优惠券类型 1:满减券,2:折扣券,3:代金券,4:实物券 5:购车代金券 6:商品折扣券,7:会员服务
obj.discountType = '4'; obj.discountType = '4'
//有效期 //有效期
//有效类型 1:固定天数,领取后计算 2:时间段,3:无有效期 //有效类型 1:固定天数,领取后计算 2:时间段,3:无有效期
obj.effectiveType = form.effectiveType obj.effectiveType = form.effectiveType
if (form.effectiveType == 1) {//固定天数 if (form.effectiveType == 1) {
obj.effectiveDays = form.effectiveDays; //固定天数
} else if (form.effectiveType == 2) {//时间段 obj.effectiveDays = form.effectiveDays
} else if (form.effectiveType == 2) {
//时间段
const d = form.effectiveTime const d = form.effectiveTime
if (d && d.length > 0) { if (d && d.length > 0) {
obj.effectiveStartTime = d[0] + ' 00:00:00'; obj.effectiveStartTime = d[0] + ' 00:00:00'
obj.effectiveEndTime = d[1] + ' 23:59:59'; obj.effectiveEndTime = d[1] + ' 23:59:59'
} }
} }
//库存 //库存
obj.stock = form.stock; obj.stock = form.stock
//类型(0:不限制次数,1:根据有效期限制多少次,2:根据间隔多少天限制多少次) //类型(0:不限制次数,1:根据有效期限制多少次,2:根据间隔多少天限制多少次)
obj.useType = 1 obj.useType = 1
//有效期或者间隔天数使用次数 //有效期或者间隔天数使用次数
obj.useAmount = 1 obj.useAmount = 1
} }
//使用描述 //使用描述
obj.useDescription = form.useDescription; obj.useDescription = form.useDescription
return obj; return obj
}, },
handleConfirm() { handleConfirm() {
...@@ -250,12 +247,12 @@ export default { ...@@ -250,12 +247,12 @@ export default {
this.$refs.editFormRef.$refs[this.editChildRef].validate(valid => { this.$refs.editFormRef.$refs[this.editChildRef].validate(valid => {
if (valid) { if (valid) {
var params = this.getCouponInfoParams() var params = this.getCouponInfoParams()
console.log(params); console.log(params)
let method = '' let method = ''
if(params.couponId){ if (params.couponId) {
method = 'updateCouponApi'//后台修改优惠券 method = 'updateCouponApi' //后台修改优惠券
}else { } else {
method = 'createCouponApi'//后台创建优惠券 method = 'createCouponApi' //后台创建优惠券
} }
this.$apis.couponManage[method](params).then(res => { this.$apis.couponManage[method](params).then(res => {
this.$message({ this.$message({
...@@ -279,124 +276,124 @@ export default { ...@@ -279,124 +276,124 @@ export default {
</script> </script>
<style scoped> <style scoped>
.right_show { .right_show {
/* float: right; */ /* float: right; */
position: absolute; position: absolute;
z-index: 10; z-index: 10;
height: 566px; height: 566px;
width: 290px; width: 290px;
right: 44px; right: 44px;
top: 92px; top: 92px;
background-image:url(../../assets/coupon/phone.png); background-image: url(../../assets/coupon/phone.png);
} }
.right_show .card-top { .right_show .card-top {
height: 59px; height: 59px;
width: 251px; width: 251px;
margin-left: 18px; margin-left: 18px;
margin-top: 55px; margin-top: 55px;
} }
.right_show .card-middle { .right_show .card-middle {
height: 388px; height: 388px;
width: 251px; width: 251px;
margin-left: 18px; margin-left: 18px;
overflow:auto overflow: auto;
} }
.right_show .card-middle .cname { .right_show .card-middle .cname {
width: 170px; width: 170px;
height: 17px; height: 17px;
font-family: PingFangSC-Regular; font-family: PingFangSC-Regular;
font-size: 12px; font-size: 12px;
color: #666666; color: #666666;
font-weight: 400; font-weight: 400;
margin-left: 10px; margin-left: 10px;
margin-top: 15px; margin-top: 15px;
display: inline-block; display: inline-block;
} }
.right_show .card-middle .ctype { .right_show .card-middle .ctype {
width: 48px; width: 48px;
height: 20px; height: 20px;
background: #5850FF; background: #5850ff;
border-radius: 10px; border-radius: 10px;
margin-right: 6px; margin-right: 6px;
margin-top: 10px; margin-top: 10px;
display: inline-block; display: inline-block;
float: right; float: right;
} }
.right_show .card-middle .ctype .ctypeName { .right_show .card-middle .ctype .ctypeName {
width: 36px; width: 36px;
height: 17px; height: 17px;
font-family: PingFangSC-Regular; font-family: PingFangSC-Regular;
font-size: 12px; font-size: 12px;
color: #FFFFFF; color: #ffffff;
font-weight: 400; font-weight: 400;
margin-left: 6px; margin-left: 6px;
} }
.right_show .card-middle .ctime { .right_show .card-middle .ctime {
margin-left: 10px; margin-left: 10px;
margin-top: 17px; margin-top: 17px;
} }
.right_show .card-middle .ctime .ctime_name { .right_show .card-middle .ctime .ctime_name {
width: 48px; width: 48px;
height: 17px; height: 17px;
font-family: PingFangSC-Regular; font-family: PingFangSC-Regular;
font-size: 12px; font-size: 12px;
color: #333333; color: #333333;
font-weight: 400; font-weight: 400;
} }
.right_show .card-middle .ctime .ctime_content { .right_show .card-middle .ctime .ctime_content {
height: 17px; height: 17px;
font-family: PingFangSC-Regular; font-family: PingFangSC-Regular;
font-size: 12px; font-size: 12px;
color: #717171; color: #717171;
font-weight: 400; font-weight: 400;
margin-left: 5px; margin-left: 5px;
} }
.right_show .card-middle .ccode { .right_show .card-middle .ccode {
width: 120px; width: 120px;
height: 120px; height: 120px;
margin-left: 67px; margin-left: 67px;
margin-top: 8px; margin-top: 8px;
} }
.right_show .card-middle .ccodeName { .right_show .card-middle .ccodeName {
width: 68px; width: 68px;
height: 17px; height: 17px;
font-family: PingFangSC-Medium; font-family: PingFangSC-Medium;
font-size: 12px; font-size: 12px;
color: #1D1D1D; color: #1d1d1d;
font-weight: 500; font-weight: 500;
margin-left: 93px; margin-left: 93px;
margin-top: 8px; margin-top: 8px;
} }
.right_show .card-middle .cremarks { .right_show .card-middle .cremarks {
margin-left: 10px; margin-left: 10px;
margin-top: 17px; margin-top: 17px;
width: 60px; width: 60px;
height: 17px; height: 17px;
font-family: PingFangSC-Regular; font-family: PingFangSC-Regular;
font-size: 12px; font-size: 12px;
color: #333333; color: #333333;
font-weight: 400; font-weight: 400;
} }
.right_show .card-middle .cremarks_content { .right_show .card-middle .cremarks_content {
margin-left: 10px; margin-left: 10px;
margin-right: 11px; margin-right: 11px;
margin-top: 4px; margin-top: 4px;
width: 230px; width: 230px;
height: 34px; height: 34px;
font-family: PingFangSC-Regular; font-family: PingFangSC-Regular;
font-size: 12px; font-size: 12px;
color: #666666; color: #666666;
font-weight: 400; font-weight: 400;
word-break: break-word; word-break: break-word;
} }
</style> </style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!