Commit bafefaaa by wangql

111

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