Commit be15fcfd by chenwq

优惠券bug修复

1 parent a3b2702e
......@@ -89,6 +89,12 @@ const staticRoutes = Object.freeze([
meta: {}
},
{
name: 'editMemberService',
path: '/couponManage/editMemberService',
component: resolve => require([`@/views/couponManage/editMemberService.vue`], resolve),
meta: {}
},
{
name: 'editCashCoupon',
path: '/couponManage/editCashCoupon/:addOrEdit',
component: resolve => require([`@/views/couponManage/editCashCoupon.vue`], resolve),
......
......@@ -751,7 +751,7 @@ export default {
var merchantval = true
if (this.$isGroupUp) {
this.$refs.merchantRef.$refs[this.editChildRef].validate(merchantVaild => {
this.merchantval = merchantVaild
merchantval = merchantVaild
})
}
if (valid && merchantval) {
......
......@@ -534,7 +534,7 @@ export default {
var merchantval = true
if (this.$isGroupUp) {
this.$refs.merchantRef.$refs[this.editChildRef].validate(merchantVaild => {
this.merchantval = merchantVaild
merchantval = merchantVaild
})
}
if (valid && merchantval) {
......
......@@ -437,7 +437,7 @@ export default {
var merchantval = true
if (this.$isGroupUp) {
this.$refs.merchantRef.$refs[this.editChildRef].validate(merchantVaild => {
this.merchantval = merchantVaild
merchantval = merchantVaild
})
}
if (valid && merchantval) {
......
<!-- 编辑服务券 -->
<template>
<div class="edit-share marketing p-t-20 edit-box">
<div class="container edit-container" v-loading="loading">
<p class="edit-title">{{ title }}服务券</p>
<glsx-combi-form class="edit-form-container" ref="editFormRef" :isEdit="true" :isBlock="true" :formRef="editChildRef" :formObj="editForm" :formData="editFormData" :formRules="editRule">
<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>
</template>
<template slot="useTypeHtml">
<el-radio v-model="editForm.useType" label="0" :disabled="apear != 'couponAdd'">无限制</el-radio>
<br />
<el-form-item prop="usageTimes" style="margin-top: 12px; display: block">
<el-radio v-model="editForm.useType" label="1" :disabled="apear != 'couponAdd'">
有效期内可使用
<el-input v-model="editForm.usageTimes" style="width: 100px; margin-left: 5px; margin-right: 5px" :disabled="apear != 'couponAdd' || editForm.useType != 1" />
次
</el-radio>
</el-form-item>
<el-radio v-model="editForm.useType" label="2" :disabled="apear != 'couponAdd'">
<el-form-item prop="useLimitDays">
有效期内
<el-input v-model="editForm.useLimitDays" style="width: 100px; margin-left: 5px; margin-right: 5px" :disabled="apear != 'couponAdd' || editForm.useType != 2" />
天可使用
</el-form-item>
<el-form-item prop="usageTimes2">
<el-input v-model="editForm.usageTimes2" style="width: 100px; margin-right: 5px" :disabled="apear != 'couponAdd' || editForm.useType != 2" />
次
</el-form-item>
</el-radio>
</template>
<div class="live-room marketing edit-box">
<div class="topMsg">
<p class="pageTitle">基本信息</p>
</div>
<div class="live-room container m-t-10">
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="120px" class="demo-ruleForm">
<el-form-item size="small" label="服务名称" prop="couponName" style="width: 440px">
<el-input size="small" :disabled="disabledContent" v-model.trim="ruleForm.couponName" maxlength="20" placeholder="请输入服务名称,如“精洗轿车”"></el-input>
</el-form-item>
<el-form-item size="small" label="预估成本/元" prop="anticipatedCost" style="width: 440px">
<el-input size="small" :disabled="disabledCost" v-model.trim="ruleForm.anticipatedCost" maxlength="20" placeholder="请输入预估成本"></el-input>
</el-form-item>
<el-form-item size="small" label="有效期" prop="effectiveType">
<div class="radioGroupWrap">
<el-radio-group v-model="ruleForm.effectiveType" :disabled="disabledContent">
<el-radio :label="3" class="itemBlock">无有效期</el-radio>
<!-- effectiveType:1, effectiveDays:5 -->
<el-radio :label="1">
领取后
<el-input v-model="ruleForm.effectiveDays" maxlength="4" @input="
val => {
ruleForm.effectiveDays = val.replace(/[^\d]/g, '')
}
" :disabled="title == '查看' || title == '编辑' || ruleForm.effectiveType != 1" placeholder="请输入" size="small" style="width: 100px"></el-input>
天内有效
</el-radio>
<!-- effectiveStartTime effectiveEndTime +具体时间 -->
<el-radio :label="2">
<el-date-picker :size="small" :disabled="title == '查看' || title == '编辑' || ruleForm.effectiveType != 2" style="width: 230px" v-model="ruleForm.daterange" type="daterange" value-format="yyyy-MM-dd" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="pickerOptions || {}"></el-date-picker>
</el-radio>
</el-radio-group>
</div>
</el-form-item>
<el-form-item size="small" label="使用限制" prop="customUseLimit">
<div class="radioGroupWrap">
<el-radio-group v-model="ruleForm.customUseLimit" :disabled="disabledContent">
<el-radio :label="0" class="itemBlock">不限制使用次数</el-radio>
<!-- useType:1 useAmount:6 -->
<el-radio :label="1">
有效期内可使用
<el-button @click="sub1" class="addsubBtn" :disabled="title == '查看' || title == '编辑' || ruleForm.customUseLimit != 1">-</el-button>
<div class="numWrap">{{ ruleForm.limitTime1 }}</div>
<el-button @click="add1" class="addsubBtn" :disabled="title == '查看' || title == '编辑' || ruleForm.customUseLimit != 1">+</el-button>
次
</el-radio>
<el-radio :label="2">
有效期内每
<el-input v-model="ruleForm.limitDays" maxlength="4" @input="
val => {
ruleForm.limitDays = val.replace(/[^\d]/g, '')
}
" :disabled="title == '查看' || title == '编辑' || ruleForm.customUseLimit != 2" placeholder="请输入" size="small" style="width: 100px"></el-input>
天内可使用
<el-button @click.stop="sub2" class="addsubBtn" :disabled="title == '查看' || title == '编辑' || ruleForm.customUseLimit != 2">-</el-button>
<span class="numWrap">{{ ruleForm.limitTime2 }}</span>
<el-button @click.stop="add2" class="addsubBtn" :disabled="title == '查看' || title == '编辑' || ruleForm.customUseLimit != 2">+</el-button>
次
</el-radio>
</el-radio-group>
</div>
</el-form-item>
<el-form-item v-if="!$isGroupUp" size="small" label="会员价" prop="vipPrice" style="width: 315px">
<el-input size="small" :disabled="disabledContent" maxlength="8" v-model="ruleForm.vipPrice" placeholder="请输入" @keyup.native="ruleForm.vipPrice = oninput(ruleForm.vipPrice)">
<!-- <template slot="append">元</template> -->
<span slot="suffix" class="suffix-label">元</span>
</el-input>
</el-form-item>
<el-form-item v-if="!$isGroupUp" size="small" label="门店价" prop="shopPrice" style="width: 315px">
<el-input size="small" :disabled="disabledContent" maxlength="8" v-model="ruleForm.shopPrice" placeholder="请输入" @keyup.native="ruleForm.shopPrice = oninput(ruleForm.shopPrice)">
<!-- <template slot="append">元</template> -->
<span slot="suffix" class="suffix-label">元</span>
</el-input>
</el-form-item>
<!-- 库存,集团版集团账号-无限制库存;其他-输入框 -->
<template slot="stock" slot-scope="scope">
<span v-if="$isGroupUp">无库存限制</span>
<el-input :disabled="apear != 'couponAdd'" v-else class="w-150" v-model="editForm[scope.scope.name]" placeholder="请输入库存">
<el-form-item size="small" label="库存" prop="stock" style="width: 315px">
<!-- <el-input size="small" :disabled="title == '查看'" maxlength="6" v-model.number="ruleForm.stock" placeholder="请输入"></el-input> -->
<span v-if="$isGroupUp">永久有效</span>
<el-input :disabled="title == '查看'" v-else class="w-150" v-model="ruleForm.stock" placeholder="请输入库存">
<span slot="suffix">张</span>
</el-input>
</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'" />
</template>
</glsx-combi-form>
<div v-if="$isGroupUp">
</el-form-item>
<el-form-item size="small" label="使用说明" prop="useDescription" style="width: 670px">
<el-input size="small" :rows="6" :disabled="disabledDescription" type="textarea" v-model="ruleForm.useDescription" placeholder="请输入" maxlength="200" show-word-limit></el-input>
</el-form-item>
<el-form-item size="small" style="margin-left: -100px" v-show="isEdit">
<el-button style="margin-left: 80px" @click="editMessage">编辑</el-button>
</el-form-item>
<!-- <el-form-item size="small">
<el-button type="primary" @click="submitForm('ruleForm')" size="small">创建</el-button>
<el-button type="primary" @click="resetForm('ruleForm')" size="small">重置</el-button>
</el-form-item> -->
</el-form>
<div class="edit-container" v-if="$isGroupUp">
<p class="edit-title">适用门店配置</p>
<glsx-combi-form class="edit-form-container" ref="merchantRef" :isEdit="true" :isBlock="true" :formRef="editChildRef" :formObj="editForm" :formData="merchantEditFormData" :formRules="merchantRule"></glsx-combi-form>
<glsx-combi-form class="edit-form-container" ref="merchantRef" :isEdit="true" :isBlock="true" :formRef="editChildRef" :formObj="ruleForm" :formData="merchantEditFormData" :formRules="merchantRule"></glsx-combi-form>
</div>
</div>
<!-- <div class="left_show">
<div class="card-panel-top">
<div class="card-h-title">会员券</div>
<div class="card-extime" v-if="editForm.effectiveType == 3">有效期:无限制</div>
<div class="card-extime" v-if="editForm.effectiveType == 1">有效期:{{editForm.effectiveDays}}天</div>
<div class="card-extime" v-if="editForm.effectiveType == 2">有效期:{{couponTime}}</div>
<div class="card-name">{{editForm.couponName}}</div>
<div class="card-day" v-if="editForm.useType == 0">使用限制:无限定次数</div>
<div class="card-day" v-if="editForm.useType == 1">使用限制:{{editForm.usageTimes}}次</div>
<div class="card-day" v-if="editForm.useType == 2">使用限制:每{{editForm.useLimitDays}}天可以使用{{editForm.usageTimes2}}次</div>
<!-- <div class="serviceCard">
<div class="cardtop">
<img src="@/assets/serviceMemberCard.png" alt="" />
<span class="serviceName ellipsis-1" :title="ruleForm.couponName">{{ ruleForm.couponName || '-' }}</span>
<span class="effectiveRange">{{ limitText }}</span>
<span class="timeRange">{{ effectiveRangeText }}</span>
<div class="grayLine"></div>
<div class="desc">使用说明:</div>
<span class="detailDesc">{{ ruleForm.useDescription }}</span>
</div>
<div class="card-panel-bottom">
<div class="card-remark">使用说明:</div>
<div class="card-remark">{{editForm.useDescription}}</div>
</div> -->
<div class="right_show">
<div class="card-top"></div>
<div class="slider">
<div class="card_one">
<div :class="ruleForm.status == 3 ? 'darkColor' : ''" class="cname">{{ ruleForm.couponName }}</div>
<img src="../../images/unService.png" class="couponImg" v-if="ruleForm.status == 3" />
<img src="../../images/service.png" class="couponImg" v-else />
<!-- <div class="ctype">
<div class="ctypeName"></div>
</div> -->
<div class="validityPeriod">
<!-- <span class="ctime_name">有效期:</span> -->
<span>{{ effectiveRangeText }}</span>
</div>
<div style="height: 1px;background-color: rgb(238, 238, 238);margin: 0 16px;"></div>
<div :class="ruleForm.status == 3 ? 'darkColor' : ''" class="ctime">
<!-- <span class="ctime_name">使用限制:</span> -->
<span class="ctime_content">{{ limitText }}</span>
</div>
<div class="ccode">
<img src="../../assets/coupon/code2.png" />
</div>
<div style="height: 1px;background-color: rgb(238, 238, 238);margin: 7px 16px 8px;"></div>
<div class="process">
<img src="../../images/unArrow.png" v-if="ruleForm.status == 3" />
<img src="../../images/arrow.png" v-else />
<span class="process_text">导航到店</span>
<img class="rightArrow" src="../../images/rightArrow.png" />
<img src="../../images/unCar.png" v-if="ruleForm.status == 3" />
<img src="../../images/car.png" v-else />
<span class="process_text">开始服务</span>
<img class="rightArrow" src="../../images/rightArrow.png" />
<img src="../../images/unTicket.png" v-if="ruleForm.status == 3" />
<img src="../../images/ticket.png" v-else />
<span class="process_text">出示核销码</span>
</div>
</div>
<div class="card_two">
<div class="cremarks">有效日期:</div>
<div class="validityPeriod" style="margin: 0 8px 8px 8px;">
<span>{{ effectiveRangeText }}</span>
</div>
<div class="cremarks">使用说明:</div>
<div class="cremarks_content" style="white-space:pre-wrap">{{ ruleForm.useDescription }}</div>
</div>
</div>
</div> -->
<div class="footer" :style="{ left: footerLeft + 'px', width: footerWidth + 'px' }">
<el-button type="primary" v-if="apear != 'couponSee'" @click="handleConfirm">确定</el-button>
<el-button v-if="apear != 'couponSee'" @click="handleCancel">取消</el-button>
<el-button v-if="apear == 'couponSee'" @click="handleCancel">返回</el-button>
</div>
</div>
<div class="footer-panel" :style="{
left: footerLeft + 'px',
width: footerWidth + 'px'
}">
<el-button type="primary" @click="submitForm('ruleForm')" size="medium" :loading="sloading" v-if="showSubmit">确定</el-button>
<el-button type="primary" @click="goBack" size="medium">取消</el-button>
</div>
<!-- :hasScroll="false" :noBtnOk="true" :noCancel="true" :noClose="false" -->
<glsx-dialog title="" top="30vh" :hasScroll="false" width="547px" btnCloseLabel="取消" :noClose="false" :noCancel="true" btnSize="small" :isVisible="isDialogVisible" :showClose="false" @closeDialog="handleClose" @confirmDialog="handleConfirm">
<div class="content-body">
<img src="@/assets/icon-warning.png" alt="" />
<div>当前有内容信息未保存,是否继续返回?</div>
</div>
</glsx-dialog>
</div>
</template>
<script>
import glsxDialog from '@/components/glsx-dialog'
import { limitPrice } from '@/common/constant'
import { createService, detailService, updateService } from '@/api/modules/service'
export default {
name: 'editCashCoupon',
components: {
glsxDialog
},
data() {
var checkZero = (rule, value, callback) => {
setTimeout(() => {
if (value == 0) {
callback(new Error('请输入有效数字值'))
} else {
callback()
}
})
}
var checkStock = (rule, value, callback) => {
if (this.$isGroupUp) {
return callback()
}
if (value <= 0) {
return callback(new Error('库存不能为空或负数'))
}
setTimeout(() => {
if (!(/^[0-9]*$/.test(value))) {
callback(new Error('请输入数字值'))
} else {
if (value < 0) {
callback(new Error('必须大于或等于0'))
} else {
callback()
}
}
}, 1000)
}
return {
size: 'small',
title: '创建',
titleObj: {
1: '创建晒单',
2: '编辑晒单'
},
footerLeft: '0',
footerWidth: '0',
isEdit: false,
showSubmit: true,
disabledDescription: false,
disabledCost: false,
sloading: false,
isDialogVisible: false,
editChildRef: 'editChildRef',
loading: false,
// pickerOptions: {
// disabledDate(v) {//禁用当前之前的日期
// return v.getTime() < new Date().getTime() - 86400000;
// },
// disabledDate(time) {//禁用当前之后的日期
// return time.getTime() > Date.now() - 8.64e6
// }
// },
routeInfo: {
// 1-新增;2-编辑;3-查看
addOrEdit: 1,
id: ''
pickerOptions: {
disabledDate(time) {
return time.getTime() < Date.now() - 8.64e7 // 如果没有后面的-8.64e7就是不可以选择今天的
}
},
apear: '',
isDisabled: true,
couponTime: '',
editForm: {
ruleForm: {
anticipatedCost: '',
couponName: '',
effectiveType: '3',
useType: '0',
usageTimes: 1,
usageTimes2: 1,
// region: '',
// date1: '',
// date2: '',
// delivery: false,
// type: [],
// resource: '',
effectiveType: 3, //有效期(默认无有效期)
effectiveDays: '',
customUseLimit: 0, //使用限制(默认不限制使用次数)
limitTime1: 1,
limitDays: '30',
limitTime2: 5,
vipPrice: '',
shopPrice: '',
stock: '',
useDescription: '',
daterange: [],
scopeApplication: ''
},
editRule: {
couponName: [{ required: true, message: '请输入优惠券名称', trigger: 'change' }],
copyRuleForm: {},
rules: {
anticipatedCost: [{ required: true, message: '请输入预估成本', trigger: 'change' }],
couponName: [{ required: true, message: '请输入服务名称', trigger: 'blur' }],
// region: [{ required: true, message: '请选择活动区域', trigger: 'change' }],
// date1: [{ type: 'date', required: true, message: '请选择日期', trigger: 'change' }],
// date2: [{ type: 'date', required: true, message: '请选择时间', trigger: 'change' }],
// type: [{ type: 'array', required: true, message: '请至少选择一个活动性质', trigger: 'change' }],
effectiveType: [{ required: true, message: '请选择有效期', trigger: 'change' }],
effectiveTime: [{ required: true, message: '有效期不能为空', trigger: 'change' }],
effectiveDays: [{ required: true, message: '有效天数不能为空', trigger: 'blur' }],
useType: [{ required: true, message: '请选择使用限制', trigger: 'change' }],
usageTimes: [{ required: true, message: '使用次数不能为空', trigger: 'blur' }],
useLimitDays: [{ required: true, message: '有效期天数不能为空', trigger: 'blur' }],
usageTimes2: [{ required: true, message: '使用次数不能为空', trigger: 'blur' }],
vipPrice: [{ required: true, message: '会员价不能为空', trigger: 'change' }],
shopPrice: [{ required: true, message: '门店价不能为空', trigger: 'change' }],
stock: [{ required: true, message: '库存不能为空', trigger: 'change' }],
useDescription: [{ required: true, message: '使用说明不能为空', trigger: 'change' }]
customUseLimit: [{ required: true, message: '请选择使用限制', trigger: 'change' }],
vipPrice: [
{ required: true, message: '请输入会员价', trigger: 'blur' },
{ validator: checkZero, trigger: 'blur' }
],
shopPrice: [
{ required: true, message: '请输入门店价', trigger: 'blur' },
{ validator: checkZero, trigger: 'blur' }
],
stock: [
{ required: true, message: '请输入库存', trigger: 'blur' },
{ validator: checkStock, trigger: 'blur' }
]
// useDescription: [{ required: true, message: '请填写活动形式', trigger: 'blur' }]
},
editFormData: [
{
label: '服务名称',
name: 'couponName',
width: '320px',
type: 'input',
maxlength: 20
},
{
label: '有效期',
name: 'effectiveType',
addHtml: 'effectiveHtml'
},
{
label: '使用限制',
name: 'useType',
addHtml: 'useTypeHtml'
},
{
label: '会员价',
name: 'vipPrice',
width: '150px',
type: 'input',
isHide: false
},
{
label: '门店价',
name: 'shopPrice',
width: '150px',
type: 'input',
isHide: false
},
{
label: '库存',
name: 'stock',
addHtml: 'stock'
// width: '150px',
// type: 'input'
},
{
label: '使用说明',
name: 'useDescription',
addHtml: 'useDescriptionHtml'
}
],
merchantId: '',
merchantName: '',
title: this.$route.query.title || '',
// 适用门店
merchantRule: {
scopeApplication: [{ required: true, message: '请选择适用范围', trigger: 'change' }]
......@@ -207,287 +300,605 @@ export default {
]
}
},
computed: {
disabledContent() {
if (this.title == '查看' || this.title == '编辑') {
return true
}
return false
},
limitText() {
if (this.ruleForm.customUseLimit == 0) {
return `不限次数`
} else if (this.ruleForm.customUseLimit == 1) {
return `有效期内可使用${this.ruleForm.limitTime1}次`
} else if (this.ruleForm.customUseLimit == 2 && this.ruleForm.effectiveType != 3) {
return `有效期内每${this.ruleForm.limitDays}天内可使用${this.ruleForm.limitTime2}次`
} else if (this.ruleForm.customUseLimit == 2 && this.ruleForm.effectiveType == 3) {
return '不限次数'
}
return '不限次数'
},
effectiveRangeText() {
if (this.ruleForm.effectiveType == 1) {
return `领取后${this.ruleForm.effectiveDays}天内有效`
} else if (this.ruleForm.effectiveType == 2) {
return `${this.ruleForm.daterange[0]}-${this.ruleForm.daterange[1]}`
}
return '永久有效'
}
// 有效期内可使用3次
},
created() {
this.editRule.stock[0].required = !this.$isGroupUp
let hideAttrList = ['vipPrice', 'shopPrice']
if (this.$isGroupUp) {
hideAttrList.forEach(item => {
let idx = this.editFormData.findIndex(k => k.name == item)
this.editFormData[idx].isHide = true
})
this.copyRuleForm = JSON.parse(JSON.stringify(this.ruleForm)) //深拷贝一份数据
if (window.__POWERED_BY_QIANKUN__) {
//运行在qiankun容器中
this.merchantId = this.$globalState.session.merchantId
this.merchantName = this.$globalState.session.merchantName
}
if (this.title == '编辑' || this.title == '查看') {
this.isEdit = true
var breadcrumbTitle = this.title
this.getPageDetail()
}
this.rules.stock[0].required = !this.$isGroupUp
},
mounted() {
this.footerLeft = document.querySelector('.base-container-right').offsetLeft
this.footerWidth = document.documentElement.clientWidth - this.footerLeft
this.routeInfo = this.$route.params
// this.title = this.titleObj[this.routeInfo.addOrEdit]
this.routeInfo.addOrEdit != 1 ? this.getInfo() : ''
var id = this.routeInfo.id
var addOrEdit = this.routeInfo.addOrEdit
if (id) {
if (addOrEdit == 3) {
this.apear = 'couponSee'
this.title = '查看'
this.setAllDisabled('merchantEditFormData')
} else if (addOrEdit == 2) {
this.apear = 'couponEdit'
this.title = '编辑'
}
this.isDisabled = true
this.editFormData[0].isDisabled = this.isDisabled
this.editFormData[3].isDisabled = this.isDisabled
this.editFormData[4].isDisabled = this.isDisabled
this.editFormData[5].isDisabled = this.isDisabled
} else {
this.apear = 'couponAdd'
this.title = '创建'
this.isDisabled = false
if (this.title == '查看' || this.title == '编辑') {
this.disabledCost = true
this.disabledDescription = true
this.showSubmit = false
}
if (this.title == '查看') {
this.setAllDisabled('merchantEditFormData')
}
},
watch: {
'editForm.effectiveDays'(newValue, oldValue) {
this.editForm.effectiveDays = limitPrice(newValue, oldValue, 3, 0)
},
'editForm.usageTimes'(newValue, oldValue) {
this.editForm.usageTimes = limitPrice(newValue, oldValue, 3, 0)
},
'editForm.useLimitDays'(newValue, oldValue) {
this.editForm.useLimitDays = limitPrice(newValue, oldValue, 4, 0)
},
'editForm.usageTimes2'(newValue, oldValue) {
this.editForm.usageTimes2 = limitPrice(newValue, oldValue, 3, 0)
},
'editForm.vipPrice'(newValue, oldValue) {
this.editForm.vipPrice = limitPrice(newValue, oldValue, 5, 2)
},
'editForm.shopPrice'(newValue, oldValue) {
this.editForm.shopPrice = limitPrice(newValue, oldValue, 5, 2)
},
'editForm.stock'(newValue, oldValue) {
this.editForm.stock = limitPrice(newValue, oldValue, 6, 0, 1)
},
'editForm.effectiveTime'(newValue, oldValue) {
if (newValue && newValue.length > 0) {
this.couponTime = this.setDateString(newValue[0], true) + ' - ' + this.setDateString(newValue[1], true)
} else {
this.couponTime = ''
}
'ruleForm.anticipatedCost'(newValue, oldValue) {
this.ruleForm.anticipatedCost = limitPrice(newValue, oldValue, 4, 2, 0, 10000)
}
},
methods: {
setAllDisabled(editName) {
this[editName].forEach(item => {
item.isDisabled = true
})
},
setDateString(objField, special) {
var value = typeof objField == 'string' ? objField.split(' ')[0] : special ? objField.format('YYYY年MM月DD日') : objField.format('YYYY年MM月DD日')
return value
},
getInfo() {
this.loading = true
this.$apis.couponManage
.getCouponDetailApi({ couponId: this.routeInfo.id })
.then(res => {
this.editForm = this.$common.utils.deepClone(res)
this.editForm.effectiveType = this.editForm.effectiveType + ''
this.editForm.useType = this.editForm.useType + ''
if (this.$isGroupUp) {
this.editForm.scopeApplication = this.editForm.scopeApplication + ''
}
//有效期
//有效类型 1:固定天数,领取后计算 2:时间段,3:永久有效
if (this.editForm.effectiveType == 2) {
this.editForm.effectiveTime = [this.editForm.effectiveStartTime, this.editForm.effectiveEndTime]
}
//类型(0:不限制次数,1:根据有效期限制多少次,2:根据间隔多少天限制多少次)
if (this.editForm.useType == 1) {
this.editForm.usageTimes = this.editForm.useAmount
} else if (this.editForm.useType == 2) {
this.editForm.usageTimes2 = this.editForm.useAmount
}
}).finally(() => {
this.loading = false
})
},
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 == '1') {
//判断 有效期-有效天数是否验证
this.editRule.effectiveDays[0].required = true
} else {
this.editRule.effectiveDays[0].required = false
}
if (form.useType == '1') {
//判断 使用限制-有效期内使用次数是否验证
this.editRule.usageTimes[0].required = true
} else {
this.editRule.usageTimes[0].required = false
}
if (form.useType == '2') {
//判断 使用限制-有效天数和使用次数是否验证
this.editRule.useLimitDays[0].required = true
this.editRule.usageTimes2[0].required = true
} else {
this.editRule.useLimitDays[0].required = false
this.editRule.usageTimes2[0].required = false
}
editMessage() {
this.disabledCost = false
this.disabledDescription = false
this.showSubmit = true
},
getCouponInfoParams() {
var obj = {}
var id = this.routeInfo.id
var form = this.$common.utils.deepClone(this.editForm)
if (id) {
obj.couponId = id
} else {
//编辑时只允许编辑使用说明
//优惠券名称
obj.couponName = form.couponName
//优惠券类型 1:满减券,2:折扣券,3:代金券,4:实物券 5:购车代金券 6:商品折扣券,7:服务券
obj.discountType = '7'
//有效期
//有效类型 1:固定天数,领取后计算 2:时间段,3:永久有效
obj.effectiveType = form.effectiveType
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'
}
getPageDetail() {
let params = {}
params.couponId = this.$route.query.couponId
detailService(params).then(res => {
this.ruleForm = res
this.ruleForm.anticipatedCost = (res.anticipatedCost / 100).toFixed(2)
this.ruleForm.customUseLimit = res.useType
if (this.$isGroupUp) {
this.ruleForm.scopeApplication = res.scopeApplication + ''
}
//类型(0:不限制次数,1:根据有效期限制多少次,2:根据间隔多少天限制多少次)
obj.useType = form.useType
if (form.useType == 1) {
obj.useAmount = form.usageTimes
} else if (form.useType == 2) {
obj.useLimitDays = form.useLimitDays
obj.useAmount = form.usageTimes2
if (res.effectiveType == 1) {
this.ruleForm.effectiveDays = res.effectiveDays
}
//会员价
obj.vipPrice = form.vipPrice
//门店价
obj.shopPrice = form.shopPrice
//库存
obj.limitStockFlag = this.$isGroupUp ? 2 : 1
if (!this.$isGroupUp) {
obj.stock = form.stock
} else {
obj.scopeApplication = form.scopeApplication
if (res.effectiveType == 2) {
this.ruleForm.daterange = [res.effectiveStartTime, res.effectiveEndTime]
}
}
//使用描述
obj.useDescription = form.useDescription
return obj
// this.ruleForm.limitTime1 = ''
// this.ruleForm.limitTime2 = ''
// this.limitDays = ''
if (res.useType == 1) {
this.ruleForm.limitTime1 = res.useAmount
}
if (res.useType == 2) {
this.ruleForm.limitTime2 = res.useAmount
this.ruleForm.limitDays = res.useLimitDays
}
this.copyRuleForm = JSON.parse(JSON.stringify(this.ruleForm)) //深拷贝一份数据
})
},
handleConfirm() {
this.validateRules()
this.$refs.editFormRef.$refs[this.editChildRef].validate(valid => {
submitForm(formName) {
this.$refs[formName].validate(valid => {
var merchantval = true
if (this.$isGroupUp) {
this.$refs.merchantRef.$refs[this.editChildRef].validate(merchantVaild => {
this.merchantval = merchantVaild
merchantval = merchantVaild
})
}
if (valid && merchantval) {
var params = this.getCouponInfoParams()
let method = ''
if (params.couponId) {
method = 'updateCouponApi' //后台修改优惠券
if (this.isEdit == true) {
this.updateService()
} else {
method = 'createCouponApi' //后台创建优惠券
this.createService()
}
this.$apis.couponManage[method](params).then(res => {
} else {
return false
}
})
},
//创建服务
createService() {
let params = {
effectiveDays: '',
useAmount: '',
useLimitDays: ''
}
params.anticipatedCost = this.ruleForm.anticipatedCost * 100
params.directionalFlag = '1'
params.couponName = this.ruleForm.couponName
//有效期
params.effectiveType = this.ruleForm.effectiveType
//使用限制
params.useType = this.ruleForm.customUseLimit
//有效期 effectiveType: 3 1 2
if (this.ruleForm.effectiveType == 1 && !parseInt(this.ruleForm.effectiveDays)) {
this.$message.error('请输入有效期')
return false
}
params.effectiveDays = this.ruleForm.effectiveDays
if (this.ruleForm.effectiveType == 2) {
if (!this.ruleForm.daterange) {
this.$message.error('请输入有效期')
return false
} else {
params.effectiveStartTime = this.ruleForm.daterange[0] + ' 00:00:00'
params.effectiveEndTime = this.ruleForm.daterange[1] + ' 23:59:59'
}
}
//使用限制
if (this.ruleForm.customUseLimit == 1) {
if (!parseInt(this.ruleForm.limitTime1)) {
this.$message.error('请输入有效期使用次数')
return false
} else {
params.useAmount = this.ruleForm.limitTime1
}
}
if (this.ruleForm.customUseLimit == 2) {
if (!parseInt(this.ruleForm.limitTime2) || !parseInt(this.ruleForm.limitDays)) {
this.$message.error('请输入有效期使用次数')
return false
} else {
params.useLimitDays = this.ruleForm.limitDays
params.useAmount = this.ruleForm.limitTime2
}
}
params.vipPrice = this.ruleForm.vipPrice
params.shopPrice = this.ruleForm.shopPrice
// params.stock = this.ruleForm.stock
//库存
params.limitStockFlag = this.$isGroupUp ? 2 : 1
if (!this.$isGroupUp) {
params.stock = this.ruleForm.stock
} else {
params.scopeApplication = this.ruleForm.scopeApplication
}
params.useDescription = this.ruleForm.useDescription
params.discountType = 7
params.merchantId = this.merchantId
params.merchantName = this.merchantName
this.sloading = true
createService(params)
.then(res => {
if (res.code == 0) {
this.sloading = false
this.$message.success('操作成功')
this.$router.push('/couponManage/index')
} else {
this.sloading = false
this.$message({
message: res.code == '0' ? '操作成功' : '操作失败',
type: res.code == '0' ? 'success' : 'error'
type: 'error',
message: res.message
})
if (res.code == '0') {
this.handleCancel()
}
})
}
})
.catch(err => {
this.sloading = false
})
.finally(() => {
this.sloading = false
})
},
//更新服务
updateService() {
let param = {}
param.anticipatedCost = this.ruleForm.anticipatedCost * 100
param.discountType = 7
param.merchantId = this.merchantId
param.merchantName = this.merchantName
param.couponId = this.$route.query.couponId
param.stock = this.ruleForm.stock
param.useDescription = this.ruleForm.useDescription
this.sloading = true
updateService(param)
.then(res => {
if (res.code == 0) {
this.sloading = false
this.$message.success('编辑服务成功')
this.$router.push('/couponManage/index')
} else {
this.sloading = false
this.$message({
type: 'error',
message: res.message
})
}
})
.catch(err => {
this.sloading = false
})
.finally(() => {
this.sloading = false
})
},
goBack() {
if (JSON.stringify(this.ruleForm) == JSON.stringify(this.copyRuleForm) || this.title == '查看') {
this.$router.push('/couponManage/index')
} else {
// this.$message.error('是否保存信息')
this.isDialogVisible = true
}
},
handleClose() {
this.isDialogVisible = false
},
handleConfirm() {
this.$router.push('/couponManage/index')
},
oninput(value) {
let str = value
let len1 = str.substr(0, 1)
let len2 = str.substr(1, 1) //如果第一位是0,第二位不是点,就用数字把点替换掉
if (str.length > 1 && len1 == 0 && len2 != '.') {
str = str.substr(1, 1)
} //第一位不能是.
if (len1 == '.') {
str = ''
}
if (len1 == '+') {
str = ''
}
if (len1 == '-') {
str = ''
} //限制只能输入一个小数点
if (Number(value) >= 999999999) {
return (str = 999999999)
}
if (str.indexOf('.') != -1) {
let str_ = str.substr(str.indexOf('.') + 1)
if (str_.indexOf('.') != -1) {
str = str.substr(0, str.indexOf('.') + str_.indexOf('.') + 1)
}
})
}
//正则替换
// (/[^\-\d.]/g, ''))"
str = str.replace(/[^\d.^]+/g, '') // 保留数字和小数点
str = str.replace(/^\D*([0-9]\d*\.?\d{0,2})?.*$/, '$1') // 小数点后只能输 2 位
return str
},
handleCancel() {
this.$router.push({
path: '/couponManage/index'
})
sub1() {
if (this.ruleForm.limitTime1 <= 0) {
return
}
this.ruleForm.limitTime1--
},
add1() {
this.ruleForm.limitTime1++
},
sub2() {
if (this.ruleForm.limitTime2 <= 0) {
return
}
this.ruleForm.limitTime2--
},
add2() {
this.ruleForm.limitTime2++
}
}
}
</script>
<style scoped>
.left_show {
width: 400px;
/*min-height: 600px;*/
background: #fff;
/*border: 1px solid #eee;*/
position: relative;
display: flex;
flex-direction: column;
<style lang="scss" scoped>
.live-room {
.topMsg {
margin: 20px 0px 0;
padding: 0 20px;
background-color: #fff;
height: 56px;
border-bottom: 1px solid#DCDFE6;
display: flex;
justify-content: space-between;
align-items: center;
.pageTitle {
position: relative;
// margin-bottom: 20px;
// height: 20px;
font-size: 20px;
font-weight: 700;
color: #333333;
line-height: 20px;
letter-spacing: 1px;
}
}
.container {
margin: 0 0px 100px;
position: relative;
/deep/ .el-form-item__content {
.radioGroupWrap {
width: 550px;
height: 164px;
background-color: #f4f6fc;
padding-top: 10px;
padding-left: 20px;
}
}
.numWrap {
display: inline-block;
background-color: #fff;
min-width: 34px;
height: 22px;
text-align: center;
line-height: 22px;
margin: 0 2px;
vertical-align: text-bottom;
}
.addsubBtn {
background-color: #fff;
color: #5850ff;
padding: 5px 9px;
}
.el-radio {
display: block;
&:not(:first-child) {
margin-top: 18px;
}
}
.itemBlock {
margin-top: 10px;
}
}
.footer-panel {
display: flex;
align-items: center;
justify-content: center;
position: fixed;
width: 100%;
bottom: 0px;
height: 64px;
background: #ffffff;
z-index: 999;
box-shadow: 0px -1px 1px 0px rgba(88, 80, 255, 0.1);
}
/deep/ .el-dialog__header {
border: 0;
}
/deep/ .el-dialog__body {
border-bottom: 1px solid #e6e6e6;
padding: 20px 25px;
.content-body {
text-align: center;
height: 98px;
line-height: 26px;
div {
font-size: 16px;
color: #333333;
font-weight: 400;
font-weight: 400;
color: #333333;
}
}
}
/deep/ .el-dialog__footer {
border: 0;
text-align: center;
padding-top: 15px;
padding-bottom: 15px;
.el-button--small {
padding: 8px 26px;
}
}
}
.right_show {
position: absolute;
top: 110px;
left: 50%;
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;
}
.card_one {
width: 243px;
height: 285px;
background: #ffffff;
border-radius: 4px;
margin-left: 22px;
margin-top: 5.81px;
}
.cname {
margin: 16px 0 10px 16px;
display: inline-block;
font-size: 18px;
font-family: PingFangSC-Semibold, PingFang SC;
font-weight: 600;
color: #fc5b32;
max-width: 164px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
height: 35px;
}
.left_show .card-panel-top {
/* margin-top: 200px; */
width: 365px;
height: 122px;
background-color: rgba(245, 154, 35, 0.7);
border: none;
.ctype {
width: 48px;
height: 20px;
background: #5850ff;
border-radius: 2px;
margin-right: 8px;
margin-top: 8px;
display: inline-block;
float: right;
}
.ctypeName {
width: 36px;
height: 17px;
font-family: PingFangSC-Regular;
font-size: 12px;
color: #ffffff;
font-weight: 400;
margin-left: 6px;
}
.ctime {
margin: 8px 16px 9px;
text-align: center;
line-height: 24px;
position: relative;
color: #fc5b32;
}
.card-h-title {
position: absolute;
/* .ctime_name {
width: 48px;
height: 17px;
font-family: PingFangSC-Regular;
font-size: 12px;
color: #333333;
font-weight: 400;
} */
.ctime_content {
height: 17px;
font-family: PingFangSC-Regular;
font-size: 12px;
font-weight: 400;
margin-left: 5px;
}
.ccode {
width: 120px;
height: 120px;
margin: 0 16px;
margin: auto;
}
.ccodeName {
width: 68px;
height: 17px;
font-family: PingFangSC-Medium;
font-size: 12px;
color: #1d1d1d;
font-weight: 500;
font-size: 20px;
top: 20px;
transform: rotate(-45deg);
margin-left: 88px;
margin-top: 8px;
}
.card-panel-bottom {
width: 353px;
min-height: 90px;
background-color: rgba(250, 205, 145, 1);
padding: 6px;
.link-top {
width: 227px;
height: 1px;
background: #eeeeee;
margin-left: 8px;
margin-top: 8px;
}
.card-extime {
.code_d {
margin-left: 98px;
margin-top: 10px;
}
.card-name {
margin: 16px 0px;
font-size: 16px;
.card_two {
width: 243px;
height: 162px;
background: #ffffff;
border-radius: 4px;
margin-left: 22px;
margin-top: 8px;
}
.card-day {
margin-top: 10px;
.cremarks {
padding-left: 8px;
padding-top: 8px;
width: 60px;
height: 17px;
font-family: PingFangSC-Regular;
font-size: 12px;
color: #333333;
font-weight: 400;
}
.card-remark {
.cremarks_content {
margin-left: 8px;
margin-right: 8px;
margin-top: 4px;
width: 227px;
height: 80px;
font-family: PingFangSC-Regular;
font-size: 12px;
color: #666666;
font-weight: 400;
word-break: break-word;
overflow: auto;
}
.promptCopy {
font-size: 14px;
font-family: PingFangSC-Regular, PingFang SC;
color: #999;
margin-left: -10px;
}
.couponImg {
width: 69px;
height: 69px;
position: sticky;
float: right;
margin-top: -6px;
margin-right: -6px;
}
.validityPeriod {
font-size: 12px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #a0a0a0;
margin: 0 16px 8px 16px;
}
.process {
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 2px;
}
.process .process_text {
margin-left: 2px;
font-size: 12px;
color: #333;
}
.process img {
width: 12px;
height: 12px;
}
.process .rightArrow {
padding: 0 4px;
}
.slider {
height: 380px;
overflow: auto;
}
.slider::-webkit-scrollbar-thumb {
background: transparent;
}
.darkColor {
color: #999;
}
</style>
......@@ -349,7 +349,13 @@ export default {
//新增服务券
addService() {
this.$router.push('/couponManage/editMemberService/1')
// this.$router.push('/couponManage/editMemberService/1')
this.$router.push({
path: '/couponManage/editMemberService',
query: {
$title: encodeURI('创建服务')
}
})
},
//新增折扣劵
......@@ -371,7 +377,15 @@ export default {
goto = '/couponManage/editCashCoupon/'
} else if (row.discountType == '7') {
//服务券
goto = '/couponManage/editMemberService/'
this.$router.push({
path: '/couponManage/editMemberService',
query: {
couponId: row.id,
title: addOrEdit == 2 ? '编辑' : '查看',
$title: encodeURI('编辑服务')
}
})
return true
} else if (row.discountType == '2') {
//折扣劵
goto = '/couponManage/editDiscountCoupon/'
......
......@@ -203,7 +203,7 @@ export default {
// },
{
confId: '1',
confName: '已领取'
confName: '未使用'
},
{
confId: '2',
......@@ -211,7 +211,7 @@ export default {
},
{
confId: '3',
confName: '已过期'
confName: '已失效'
}
],
wechatUserFlagList: [
......
......@@ -202,7 +202,22 @@ export default {
label: '券来源',
prop: 'packageName',
formatter: cellValue => {
return cellValue.packageId ? cellValue.packageName : cellValue.directionalGiftId ? cellValue.directionalGiftName : '-'
let txt = ''
if (this.$isGroupUp) {
txt = cellValue.packageId ? cellValue.packageName : cellValue.directionalGiftId ? cellValue.directionalGiftName : '-'
} else {
txt = {
'': '-',
1: '营销活动',
2: '营销活动',
3: '会员服务套餐',
4: '营销活动',
5: '关联商品购买',
6: '通过集团套餐赠送',
7: '通过定向礼包赠送'
}[cellValue.receiveWay]
}
return txt
}
},
{
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!