| | |
| | | <el-input v-model="form.price" placeholder="请输入" @input="inputAction(form, 'price')" > |
| | | <template slot="append" >{{form.couponType ===1?'折':'元'}}</template> |
| | | </el-input> |
| | | <div class="discrep" v-if="form.couponType === 1" >,折扣优惠金额上限</div> |
| | | <el-input v-model="form.maxPrice" v-if="form.couponType === 1" placeholder="请输入" @input="inputAction(form, 'maxPrice')" > |
| | | <template slot="append" >元</template> |
| | | </el-input> |
| | | </div> |
| | | </el-form-item> |
| | | <el-form-item label="优惠券说明" prop="info"> |
| | | <el-input type="textarea" v-model="form.info" placeholder="请输入优惠券说明" v-trim/> |
| | | <el-input type="textarea" v-model="form.info" placeholder="请输入优惠券说明" maxlength="500" v-trim/> |
| | | </el-form-item> |
| | | <p class="tip-header" >使用限制</p> |
| | | <el-form-item label="有效期" prop="useType"> |
| | | <el-radio-group v-model="form.useType"> |
| | | <el-form-item label="有效期" prop="getDate"> |
| | | <el-radio-group v-model="form.useType" @change="changeApplyType"> |
| | | <el-radio :label="0">固定时段</el-radio> |
| | | <el-radio :label="1">固定时长</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | <el-form-item label="使用时段" prop="getDate" v-if="form.useType===0"> |
| | | <div class="date-style"> |
| | | <div class="date-style" v-if="form.useType===0"> |
| | | <el-date-picker |
| | | v-model="getDate" |
| | | type="datetimerange" |
| | |
| | | @change="selectDate" |
| | | ></el-date-picker> |
| | | </div> |
| | | </el-form-item> |
| | | <el-form-item label="固定时长" prop="validDays" v-if="form.useType===1"> |
| | | <div class="coupon-rule"> |
| | | <div class="coupon-rule" v-if="form.useType===1"> |
| | | <div class="discrep">领劵后</div> |
| | | <el-input |
| | | v-model="form.validDays" |
| | |
| | | </div> |
| | | </el-form-item> |
| | | <el-form-item label="适用对象" prop="applyType"> |
| | | <el-radio-group v-model="form.applyType"> |
| | | <el-radio-group v-model="form.applyType" @change="changeApplyType"> |
| | | <el-radio :label="0">全场通用</el-radio> |
| | | <el-radio :label="1">按品类</el-radio> |
| | | <el-radio :label="2">指定商品</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | <el-form-item v-if="form.applyType===1" label="选择品类" prop="applyCateIdList" > |
| | | <el-select v-model="form.applyCateIdList" placeholder="请选择,支持多选" filterable multiple clearable > |
| | | <el-form-item label="选择品类" prop="applyTypeRule" v-if="form.applyType===1"> |
| | | <el-select style="margin-left:10px;width: 300px;" v-model="form.applyCateIdList" placeholder="请选择商品分类,支持多选" filterable multiple clearable > |
| | | <el-option v-for="item in categorys" :key="'optCate'+item.id" :label="item.name" :value="item.id"> </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="选中商品" prop="applyTypeRule" v-if="form.applyType===2"> |
| | | <span style="font-size: 12px;color: #216EEE" @click="selectGoods">已指定【 {{applyDataList.length}} 】件商品</span> |
| | | <el-button style="margin-left:30px;display: inline-block;width: 80px;" type="primary" @click="selectGoods">去选择 </el-button> |
| | | </el-form-item> |
| | | <!-- <el-form-item v-if="form.applyType===1" label="选择品类" prop="applyCateIdList" > |
| | | <el-select v-model="form.applyCateIdList" placeholder="请选择商品分类,支持多选" filterable multiple clearable > |
| | | <el-option v-for="item in categorys" :key="'optCate'+item.id" :label="item.name" :value="item.id"> </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item v-if="form.applyType===2" label="选择商品" prop="applyIdList" style="display: flex"> |
| | | <span style="font-size: 12px;color: #216EEE" @click="selectGoods">已指定【 {{applyDataList.length}} 】件商品</span> |
| | | <el-button style="margin-left:30px;display: inline-block;width: 80px;" type="primary" @click="selectGoods">去选择 </el-button> |
| | | </el-form-item> |
| | | </el-form-item>--> |
| | | <p class="tip-header" >发放规则</p> |
| | | <el-form-item label="发放总量" prop="num"> |
| | | <div class="num-style"> |
| | | <el-input-number v-model="form.num" :controls="false" :min="1" :max="99999" placeholder="请输入发放总量(1~99999)" v-trim></el-input-number> |
| | | <el-input-number v-model="form.num" :controls="false" :min="0" :max="99999" placeholder="请输入发放总量(0~99999)" v-trim></el-input-number> |
| | | </div> |
| | | <p class="tip-warn" style="margin-bottom: 1px;"><i class="el-icon-warning"></i>提醒:发放总量为0表示不限制</p> |
| | | </el-form-item> |
| | | </el-form> |
| | | <OperaCouponGoodsWindow ref="OperaCouponGoodsWindow" @success="doSelect"/> |
| | |
| | | import { fetchList as shopList } from '@/api/business/shop' |
| | | import GlobalWindow from '@/components/common/GlobalWindow' |
| | | import { findAll as labelList } from '@/api/business/labels' |
| | | import { allList as goodsList} from '@/api/business/goods' |
| | | import { allList as goodsList } from '@/api/business/goods' |
| | | import OperaCouponGoodsWindow from '@/components/business/OperaCouponGoodsWindow' |
| | | export default { |
| | | name: 'OperaCouponWindow', |
| | | extends: BaseOpera, |
| | | components: { GlobalWindow,OperaCouponGoodsWindow }, |
| | | components: { GlobalWindow, OperaCouponGoodsWindow }, |
| | | data () { |
| | | const couponRules = (rule, value, callback) => { |
| | | if (!this.form.limitPrice) { |
| | | callback(new Error('请输入满额')) |
| | | } else if (!this.form.price) { |
| | | callback(new Error('请完善优惠规则')) |
| | | } else if (this.form.couponType == 1 && (this.form.price <= 0 || this.form.price >= 10)) { |
| | | callback(new Error('优惠折扣只能为 (0,10)范围内')) |
| | | } else { |
| | | callback() |
| | | } |
| | | } |
| | | const getDateRules = (rule, value, callback) => { |
| | | if (!this.form.startDate) { |
| | | if (!this.form.useType < 0) { |
| | | callback(new Error('请选择有效期')) |
| | | } else if (this.form.useType == 1 && !this.form.validDays) { |
| | | callback(new Error('请输入固定时长天数')) |
| | | } else if (this.form.useType == 0 && !this.form.startDate) { |
| | | callback(new Error('请选择开始时间')) |
| | | } else if (!this.form.endDate) { |
| | | } else if (this.form.useType == 0 && !this.form.endDate) { |
| | | callback(new Error('请输入结束时间')) |
| | | } else { |
| | | callback() |
| | | } |
| | | } |
| | | const getApplyTypeRule = (rule, value, callback) => { |
| | | if (!this.form.applyType < 0) { |
| | | callback(new Error('请选择适用范围')) |
| | | } else if (this.form.applyType == 1 && (!this.form.applyCateIdList || !this.form.applyCateIdList.length)) { |
| | | callback(new Error('请选择使用品类')) |
| | | } else if (this.form.applyType == 2 && (!this.form.applyIdList || !this.form.applyIdList.length)) { |
| | | callback(new Error('请选择指定商品')) |
| | | } else { |
| | | callback() |
| | | } |
| | |
| | | return { |
| | | searchLoading: false, |
| | | getDate: [], |
| | | applyDataList:[], |
| | | showGoods:false, |
| | | applyDataList: [], |
| | | showGoods: false, |
| | | // 表单数据 |
| | | form: { |
| | | id: null, |
| | |
| | | num: [ |
| | | { required: true, validator: numRule, message: '请输入发放总数', tigger: 'blur' } |
| | | ], |
| | | /*integral: [ |
| | | /* integral: [ |
| | | { required: true, validator: numRule, message: '请输入兑换条件', tigger: 'blur' } |
| | | ],*/ |
| | | // validDays: [ |
| | | // { required: true, message: '请输入可用时间', tigger: 'blur' } |
| | | // ], |
| | | // getDate: [ |
| | | // { required: true, validator: getDateRules, tigger: 'change' } |
| | | // ], |
| | | ], */ |
| | | getDate: [ |
| | | { required: true, validator: getDateRules } |
| | | ], |
| | | applyTypeRule: [ |
| | | { required: true, validator: getApplyTypeRule } |
| | | ] |
| | | // shopId: [ |
| | | // { required: true, validator: numRule, message: '请选择关联店铺', tigger: 'change' } |
| | | // ] |
| | |
| | | }) |
| | | }, |
| | | methods: { |
| | | selectGoods(){ |
| | | selectGoods () { |
| | | this.$refs.OperaCouponGoodsWindow.open('选择商品', this.applyDataList) |
| | | }, |
| | | loadLabels(){ |
| | | loadLabels () { |
| | | labelList({ |
| | | type: 0 // 商品分类 |
| | | }).then(res => { |
| | | this.categorys = res || [] |
| | | }) |
| | | }, |
| | | loadSelectGoods(){ |
| | | loadSelectGoods () { |
| | | console.log(this.form.applyIdList) |
| | | if(!this.form.applyIdList || !this.form.applyIdList.length){ |
| | | if (!this.form.applyIdList || !this.form.applyIdList.length) { |
| | | return |
| | | } |
| | | goodsList({ |
| | |
| | | this.applyDataList = res || [] |
| | | }) |
| | | }, |
| | | doSelect(rows){ |
| | | console.log(rows,this.applyDataList) |
| | | this.applyDataList =[] |
| | | this.form.applyIdList=[] |
| | | if(rows && rows.length){ |
| | | changeApplyType(){ |
| | | this.$refs.form.clearValidate() |
| | | }, |
| | | doSelect (rows) { |
| | | console.log(rows, this.applyDataList) |
| | | this.applyDataList = [] |
| | | this.form.applyIdList = [] |
| | | if (rows && rows.length) { |
| | | rows.forEach(item => { |
| | | this.applyDataList.push(item) |
| | | this.form.applyIdList.push(item.id) |
| | | }) |
| | | } |
| | | this.$refs.form.clearValidate(); |
| | | }, |
| | | open (title, target, type) { |
| | | this.showGoods=false |
| | | this.showGoods = false |
| | | this.title = title |
| | | this.visible = true |
| | | this.form.type = type |
| | | this.getDate = [] |
| | | this.form.startDate = '' |
| | | this.form.endDate = '' |
| | | this.applyDataList=[] |
| | | this.form.applyIdList=[] |
| | | this.form.applyCateIdList=[] |
| | | this.applyDataList = [] |
| | | this.form.applyIdList = [] |
| | | this.form.applyCateIdList = [] |
| | | this.loadLabels() |
| | | this.form.limitPrice=null |
| | | this.form.price=null |
| | | this.form.startDate=null |
| | | this.form.endDate=null |
| | | this.form.num=1 |
| | | this.form.limitPrice = null |
| | | this.form.price = null |
| | | this.form.startDate = null |
| | | this.form.endDate = null |
| | | this.form.num = 1 |
| | | // 新建 |
| | | if (target == null) { |
| | | this.$nextTick(() => { |
| | |
| | | for (const key in this.form) { |
| | | this.form[key] = target[key] |
| | | } |
| | | this.getDate = [target.startDate, target.endDate] |
| | | if(this.form.applyType === 1){ |
| | | this.form.applyCateIdList =[] |
| | | if (target.startDate && target.endDate) { |
| | | this.getDate = [target.startDate, target.endDate] |
| | | } |
| | | if (this.form.applyType === 1) { |
| | | this.form.applyCateIdList = [] |
| | | var ta = this.form.applyIds.split(',') |
| | | if(ta && ta.length){ |
| | | ta.forEach(tt =>{ |
| | | if (ta && ta.length) { |
| | | ta.forEach(tt => { |
| | | this.form.applyCateIdList.push(parseInt(tt)) |
| | | }) |
| | | } |
| | | } |
| | | if(this.form.applyType === 2){ |
| | | if (this.form.applyType === 2) { |
| | | this.form.applyIdList = this.form.applyIds.split(',') |
| | | this.loadSelectGoods() |
| | | } |