oil-station/fuintAdmin/src/views/EventMarketing/liJianMarketing/index.vue

741 lines
30 KiB
Vue
Raw Normal View History

2024-08-31 13:51:23 +08:00
<template>
2024-10-29 15:35:48 +08:00
<div class="app-open">
2024-08-31 13:51:23 +08:00
<div class="cot-box">
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="140px">
<div style="display: flex">
<div style="width: 50%">
2024-09-04 13:42:53 +08:00
<el-form-item label="活动名称" prop="activeName">
<el-input v-model="ruleForm.activeName"></el-input>
2024-08-31 13:51:23 +08:00
</el-form-item>
2024-09-04 13:42:53 +08:00
<el-form-item label="活动时间" prop="activeTimeType">
2024-08-31 13:51:23 +08:00
<div class="d-s">
2024-09-26 15:19:59 +08:00
<el-radio-group v-model="ruleForm.activeTimeType">
<el-radio :label="'0'">永久有效</el-radio>
<el-radio :label="'1'">自定义</el-radio>
</el-radio-group>
2024-08-31 13:51:23 +08:00
<el-date-picker
2024-09-26 15:19:59 +08:00
v-if="ruleForm.activeTimeType=='1'"
2024-08-31 13:51:23 +08:00
v-model="ruleForm.activeStartTime"
style="width: 160px"
type="date"
value-format="yyyy-MM-dd"
placeholder="开始日期">
</el-date-picker>
2024-10-15 18:11:07 +08:00
<span v-if="ruleForm.activeTimeType=='1'" style="margin: 0 5px"></span>
2024-08-31 13:51:23 +08:00
<el-date-picker
2024-09-26 15:19:59 +08:00
v-if="ruleForm.activeTimeType=='1'"
2024-08-31 13:51:23 +08:00
v-model="ruleForm.activeEndTime"
style="width: 160px"
type="date"
value-format="yyyy-MM-dd"
placeholder="结束日期">
</el-date-picker>
</div>
</el-form-item>
2024-09-04 13:42:53 +08:00
<el-form-item label="优惠类型" prop="offerType">
2024-08-31 13:51:23 +08:00
<div class="d-s">
2024-10-15 18:11:07 +08:00
<el-radio-group v-model="ruleForm.offerType" @input="changeOfferType()">
<el-radio :label="'0'">立减优惠</el-radio>
<el-radio :label="'1'">折扣优惠</el-radio>
2024-09-26 15:19:59 +08:00
</el-radio-group>
2024-08-31 13:51:23 +08:00
</div>
2024-10-15 18:11:07 +08:00
<span style="color: grey;font-size: 12px">例如:立减优惠满100立减2元;折扣优惠满200享受95折</span>
2024-09-26 15:19:59 +08:00
2024-08-31 13:51:23 +08:00
</el-form-item>
2024-09-04 13:42:53 +08:00
<el-form-item label="活动类型" prop="activeType">
2024-08-31 13:51:23 +08:00
<div class="d-s">
2024-09-26 15:19:59 +08:00
<el-radio-group v-model="ruleForm.activeType">
<el-radio :label="'0'">固定优惠</el-radio>
<el-radio :label="'1'" v-if="ruleForm.offerType=='0'">随机满减</el-radio>
<el-radio :label="'2'" v-if="ruleForm.offerType=='0'">每满</el-radio>
</el-radio-group>
2024-08-31 13:51:23 +08:00
</div>
2024-09-04 13:42:53 +08:00
<div style="color: grey;font-size: 11px">
固定满减:订单满足规则时只优惠一次且金额固定:满100元立减5元订单金额是210元则优惠减5元
</div>
<div style="color: grey;font-size: 11px" v-if="ruleForm.offerType==0">
随机满减:订单满足规则时只优惠一次且金额随机:满100元立减5-8订单金额是210元则优惠在5-8元范围内随机生成
</div>
<div style="color: grey;font-size: 11px" v-if="ruleForm.offerType==0">
每满:订单满足规则时按规则优患多次:每满100元立减5元活动订单金额是210元则按每满优惠减10元
</div>
2024-08-31 13:51:23 +08:00
</el-form-item>
2024-09-04 13:42:53 +08:00
<el-form-item label="适用会员等级" prop="levelId">
2024-09-13 16:30:17 +08:00
<el-select v-model="ruleForm.levelId" multiple clearable placeholder="请选择会员等级(多选)" style="width: 100%">
2024-08-31 13:51:23 +08:00
<el-option
v-for="(item,index) in userGradeList"
:label="item.name"
:value="item.id.toString()"
:key="index"></el-option>
</el-select>
</el-form-item>
2024-09-04 13:42:53 +08:00
<el-form-item label="会员标签" prop="babelIds">
2024-09-13 16:30:17 +08:00
<el-select v-model="ruleForm.babelIds" multiple clearable placeholder="请选择会员标签(多选)" style="width: 100%">
2024-08-31 13:51:23 +08:00
<el-option
v-for="item in userLabelList"
:key="item.id+''"
:label="item.labelName"
:value="item.id+''"></el-option>
</el-select>
</el-form-item>
2024-09-04 13:42:53 +08:00
<el-form-item label="每人每天参与上限" prop="dayLimitNum">
<el-input v-model="ruleForm.dayLimitNum"></el-input>
2024-08-31 13:51:23 +08:00
<span style="color: grey;font-size: 12px">每个会员每天限制参与的次数0标识不限</span>
</el-form-item>
2024-09-04 13:42:53 +08:00
<el-form-item label="每人每月参与上限" prop="monthLimitNum">
<el-input v-model="ruleForm.monthLimitNum"></el-input>
2024-08-31 13:51:23 +08:00
<span style="color: grey;font-size: 12px">每个会员每月限制参与的次数0标识不限</span>
</el-form-item>
2024-09-04 13:42:53 +08:00
<el-form-item label="每人累计参与上限" prop="limitNum">
<el-input v-model="ruleForm.limitNum"></el-input>
2024-08-31 13:51:23 +08:00
<span style="color: grey;font-size: 12px">每个会员累计限制参与的次数0标识不限</span>
</el-form-item>
</div>
<div style="width: 50%">
2024-09-04 13:42:53 +08:00
<el-form-item label="适用时间段" prop="timeType">
2024-09-26 15:19:59 +08:00
<div style="width: 100px;margin-top: 10px">
<el-radio-group v-model="ruleForm.timeType">
<div style="display: flex; width: 500px;margin-bottom: 15px;">
<el-radio :label="'1'">每周</el-radio>
2024-10-15 18:11:07 +08:00
<el-checkbox-group v-model="weekDay" style="margin-left: 20px" :disabled="ruleForm.timeType!='1'">
2024-09-26 15:19:59 +08:00
<el-checkbox v-for="(item,index) in weekList" :key="index" :label="item"></el-checkbox>
</el-checkbox-group>
</div>
<el-radio :label="'2'">每月
2024-10-15 18:11:07 +08:00
<el-select :disabled="ruleForm.timeType!='2'" v-model="monthDay" placeholder="请选择每月固定日期" multiple
style="margin-left: 20px">
2024-09-26 15:19:59 +08:00
<el-option
v-for="item in 31"
:key="item+''"
:label="item+'日'"
:value="item+''">
</el-option>
</el-select>
</el-radio>
</el-radio-group>
2024-08-31 13:51:23 +08:00
</div>
<div style="margin-top: 20px">
2024-09-18 17:24:03 +08:00
<el-form-item label="时间段" prop="timeApplyStart" label-width="65px">
2024-08-31 13:51:23 +08:00
<el-time-picker
2024-09-04 13:42:53 +08:00
v-model="ruleForm.timeApplyStart"
2024-08-31 13:51:23 +08:00
format="HH:mm"
value-format="HH:mm"
placeholder="请选择开始时间点">
</el-time-picker>
<el-time-picker
2024-09-04 13:42:53 +08:00
v-model="ruleForm.timeApplyEnd"
2024-08-31 13:51:23 +08:00
format="HH:mm"
value-format="HH:mm"
placeholder="请选择结束时间点">
</el-time-picker>
</el-form-item>
</div>
</el-form-item>
2024-09-04 13:42:53 +08:00
<el-form-item label="适用油品油号" prop="applyOilType">
2024-08-31 13:51:23 +08:00
<div class="d-s">
2024-09-26 15:19:59 +08:00
<el-radio-group v-model="ruleForm.applyOilType">
<el-radio :label="'0'">不限</el-radio>
<el-radio :label="'1'">自定义</el-radio>
</el-radio-group>
2024-10-15 18:11:07 +08:00
<el-select v-if="ruleForm.applyOilType=='1'" v-model="ruleForm.applyOil" multiple clearable
placeholder="请选择油品油号(多选)">
2024-09-03 16:32:30 +08:00
<el-option v-for="(item,index) in oilNumberList" :key="index"
:label="getOilNamess(oilNameList,item.oilName)" :value="item.oilName"></el-option>
2024-08-31 13:51:23 +08:00
</el-select>
</div>
</el-form-item>
<el-form-item label="可使用支付方式" prop="paymentType">
<el-checkbox-group v-model="ruleForm.paymentType">
<el-checkbox
v-for="dict in dict.type.payment_type"
v-if="dict.value!='APPLET_CODE'"
:key="dict.value"
2024-09-29 16:40:07 +08:00
:label="dict.value"
2024-10-15 18:11:07 +08:00
:value="dict.value">{{ dict.label }}
</el-checkbox>
2024-08-31 13:51:23 +08:00
</el-checkbox-group>
</el-form-item>
2024-09-04 13:42:53 +08:00
<el-form-item label="活动方式" prop="activeManner">
2024-10-10 15:45:09 +08:00
<el-radio-group v-model="ruleForm.activeManner">
2024-10-15 18:11:07 +08:00
<div style="display: flex;font-size: 14px;margin: 10px 0;align-items: center">
2024-10-10 15:45:09 +08:00
<el-radio label="0" name="type">按订单金额</el-radio>
2024-08-31 13:51:23 +08:00
<img src="@/assets/images/tjb.png"
2024-09-19 10:41:11 +08:00
style="width: 20px;height: 20px;cursor: pointer;margin-left: 10px"
2024-09-04 17:32:58 +08:00
@click="addPoints(0)">
2024-08-31 13:51:23 +08:00
</div>
2024-09-04 13:42:53 +08:00
<div v-if="ruleForm.offerType == 0 && ruleForm.activeType == 0">
2024-10-15 18:11:07 +08:00
<div v-for="(item,index) in orderList" :key="index"
style="font-size: 14px;margin: 15px 0;display: flex;align-items: center">
2024-09-04 13:42:53 +08:00
<span>订单金额满</span>
2024-09-04 17:32:58 +08:00
<el-input placeholder="请输入" style="width: 30%;margin: 0 10px" v-model="item.full">
2024-09-04 13:42:53 +08:00
<template slot="append"></template>
</el-input>
<span>固定优惠</span>
2024-09-04 17:32:58 +08:00
<el-input placeholder="请输入" style="width: 30%;margin: 0 10px" v-model="item.sub">
2024-09-04 13:42:53 +08:00
<template slot="append"></template>
</el-input>
<img src="@/assets/images/ljt.png" style="width: 25px;height: 25px;"
@click="deletePoints(index)">
</div>
</div>
<div v-if="ruleForm.offerType == 0 && ruleForm.activeType == 1">
2024-10-15 18:11:07 +08:00
<div v-for="(item,index) in orderList" :key="index"
style="font-size: 14px;margin: 15px 0;display: flex;align-items: center">
2024-09-04 13:42:53 +08:00
<span>订单金额满</span>
2024-09-04 17:32:58 +08:00
<el-input placeholder="请输入" style="width: 20%;margin: 0 10px" v-model="item.full">
2024-09-04 13:42:53 +08:00
<template slot="append"></template>
</el-input>
<span>随机优惠</span>
2024-09-04 17:32:58 +08:00
<el-input placeholder="请输入" style="width: 20%;margin: 0 10px" v-model="item.randomFront">
2024-09-04 13:42:53 +08:00
<template slot="append"></template>
</el-input>
<span></span>
2024-09-04 17:32:58 +08:00
<el-input placeholder="请输入" style="width: 20%;margin: 0 10px" v-model="item.randomAfter">
2024-09-04 13:42:53 +08:00
<template slot="append"></template>
</el-input>
<img src="@/assets/images/ljt.png" style="width: 25px;height: 25px;"
@click="deletePoints(index)">
</div>
</div>
<div v-if="ruleForm.offerType == 0 && ruleForm.activeType == 2">
2024-10-15 18:11:07 +08:00
<div v-for="(item,index) in orderList" :key="index"
style="font-size: 14px;margin: 15px 0;display: flex;align-items: center">
2024-09-04 13:42:53 +08:00
<span>订单金额每满</span>
2024-09-04 17:32:58 +08:00
<el-input placeholder="请输入" style="width: 19%;margin: 0 10px" v-model="item.full">
2024-09-04 13:42:53 +08:00
<template slot="append"></template>
</el-input>
<span>固定优惠</span>
2024-09-04 17:32:58 +08:00
<el-input placeholder="请输入" style="width: 19%;margin: 0 10px" v-model="item.sub">
2024-09-04 13:42:53 +08:00
<template slot="append"></template>
</el-input>
<span>最大优惠</span>
2024-09-04 17:32:58 +08:00
<el-input placeholder="请输入" style="width: 19%;margin: 0 10px" v-model="item.maxPreferential">
2024-09-04 13:42:53 +08:00
<template slot="append"></template>
</el-input>
<img src="@/assets/images/ljt.png" style="width: 25px;height: 25px;"
@click="deletePoints(index)">
</div>
</div>
<div v-if="ruleForm.offerType == 1 && ruleForm.activeType == 0">
2024-10-15 18:11:07 +08:00
<div v-for="(item,index) in orderList" :key="index"
style="font-size: 14px;margin: 15px 0;display: flex;align-items: center">
2024-09-04 13:42:53 +08:00
<span>订单金额满</span>
2024-09-04 17:32:58 +08:00
<el-input placeholder="请输入" style="width: 20%;margin: 0 10px" v-model="item.full">
2024-09-04 13:42:53 +08:00
<template slot="append"></template>
</el-input>
<span>享受折扣</span>
2024-09-04 17:32:58 +08:00
<el-input placeholder="请输入" style="width: 20%;margin: 0 10px" v-model="item.enjoyDiscount">
2024-09-04 13:42:53 +08:00
<template slot="append"></template>
</el-input>
<span>最大优惠</span>
2024-09-04 17:32:58 +08:00
<el-input placeholder="请输入" style="width: 20%;margin: 0 10px" v-model="item.maxPreferential">
2024-09-04 13:42:53 +08:00
<template slot="append"></template>
</el-input>
<img src="@/assets/images/ljt.png" style="width: 25px;height: 25px;"
@click="deletePoints(index)">
</div>
2024-08-31 13:51:23 +08:00
</div>
2024-09-19 10:41:11 +08:00
<div style="display: flex;font-size: 14px;margin: 15px 0;align-items: center">
2024-10-10 15:45:09 +08:00
<el-radio label="1" name="type">按加油升数</el-radio>
2024-08-31 13:51:23 +08:00
<img src="@/assets/images/tjb.png"
2024-09-19 10:41:11 +08:00
style="width: 20px;height: 20px;cursor: pointer;margin-left: 10px"
2024-09-04 17:32:58 +08:00
@click="addGrowthValues(1)">
2024-08-31 13:51:23 +08:00
</div>
2024-09-04 13:42:53 +08:00
<div v-if="ruleForm.offerType == 0 && ruleForm.activeType == 0">
2024-10-15 18:11:07 +08:00
<div v-for="(item,index) in refuelList" :key="index"
style="font-size: 14px;margin: 15px 0;display: flex;align-items: center">
2024-09-04 13:42:53 +08:00
<span>加油升数满</span>
2024-09-04 17:32:58 +08:00
<el-input placeholder="请输入" style="width: 30%;margin: 0 10px" v-model="item.full">
2024-09-04 13:42:53 +08:00
<template slot="append">L</template>
</el-input>
<span>固定优惠</span>
<el-input placeholder="请输入" style="width: 30%;margin: 0 10px"
2024-09-04 17:32:58 +08:00
v-model="item.sub">
2024-09-04 13:42:53 +08:00
<template slot="append"></template>
</el-input>
<img src="@/assets/images/ljt.png" style="width: 25px;height: 25px;"
@click="deleteGrowthValues(index)">
</div>
</div>
<div v-if="ruleForm.offerType == 0 && ruleForm.activeType == 1">
2024-10-15 18:11:07 +08:00
<div v-for="(item,index) in refuelList" :key="index"
style="font-size: 14px;margin: 15px 0;display: flex;align-items: center">
2024-09-04 13:42:53 +08:00
<span>加油升数满</span>
2024-09-04 17:32:58 +08:00
<el-input placeholder="请输入" style="width: 20%;margin: 0 10px" v-model="item.full">
2024-09-04 13:42:53 +08:00
<template slot="append">L</template>
</el-input>
<span>随机优惠</span>
<el-input placeholder="请输入" style="width: 20%;margin: 0 10px"
2024-09-04 17:32:58 +08:00
v-model="item.randomFront">
2024-09-04 13:42:53 +08:00
<template slot="append"></template>
</el-input>
<span></span>
<el-input placeholder="请输入" style="width: 20%;margin: 0 10px"
2024-09-04 17:32:58 +08:00
v-model="item.randomAfter">
2024-09-04 13:42:53 +08:00
<template slot="append"></template>
</el-input>
<img src="@/assets/images/ljt.png" style="width: 25px;height: 25px;"
@click="deleteGrowthValues(index)">
</div>
</div>
<div v-if="ruleForm.offerType == 0 && ruleForm.activeType == 2">
2024-10-15 18:11:07 +08:00
<div v-for="(item,index) in refuelList" :key="index"
style="font-size: 14px;margin: 15px 0;display: flex;align-items: center">
2024-09-04 13:42:53 +08:00
<span>加油升数每满</span>
2024-09-04 17:32:58 +08:00
<el-input placeholder="请输入" style="width: 19%;margin: 0 10px" v-model="item.full">
2024-09-04 13:42:53 +08:00
<template slot="append">L</template>
</el-input>
<span>固定优惠</span>
<el-input placeholder="请输入" style="width: 19%;margin: 0 10px"
2024-09-04 17:32:58 +08:00
v-model="item.sub">
2024-09-04 13:42:53 +08:00
<template slot="append"></template>
</el-input>
<span>最大优惠</span>
<el-input placeholder="请输入" style="width: 19%;margin: 0 10px"
2024-09-04 17:32:58 +08:00
v-model="item.maxPreferential">
2024-09-04 13:42:53 +08:00
<template slot="append"></template>
</el-input>
<img src="@/assets/images/ljt.png" style="width: 25px;height: 25px;"
@click="deleteGrowthValues(index)">
</div>
</div>
<div v-if="ruleForm.offerType == 1 && ruleForm.activeType == 0">
2024-10-15 18:11:07 +08:00
<div v-for="(item,index) in refuelList" :key="index"
style="font-size: 14px;margin: 15px 0;display: flex;align-items: center">
2024-09-04 13:42:53 +08:00
<span>加油升数满</span>
2024-09-04 17:32:58 +08:00
<el-input placeholder="请输入" style="width: 20%;margin: 0 10px" v-model="item.full">
2024-09-04 13:42:53 +08:00
<template slot="append">L</template>
</el-input>
<span>享受折扣</span>
<el-input placeholder="请输入" style="width: 20%;margin: 0 10px"
2024-09-04 17:32:58 +08:00
v-model="item.enjoyDiscount">
2024-09-04 13:42:53 +08:00
<template slot="append"></template>
</el-input>
<span>最大优惠</span>
<el-input placeholder="请输入" style="width: 20%;margin: 0 10px"
2024-09-04 17:32:58 +08:00
v-model="item.maxPreferential">
2024-09-04 13:42:53 +08:00
<template slot="append"></template>
</el-input>
<img src="@/assets/images/ljt.png" style="width: 25px;height: 25px;"
@click="deleteGrowthValues(index)">
</div>
2024-08-31 13:51:23 +08:00
</div>
2024-10-10 15:45:09 +08:00
</el-radio-group>
2024-08-31 13:51:23 +08:00
</el-form-item>
</div>
</div>
<el-form-item style="text-align: center">
<el-button @click="resetForm('ruleForm')">取消</el-button>
<el-button type="primary" @click="submitRuleForm('ruleForm')">保存</el-button>
</el-form-item>
</el-form>
</div>
</div>
</template>
<script>
import {listUserLabel} from "@/api/staff/user/userlabel";
import {listUserGrade} from "@/api/staff/user/usergrade";
2024-09-03 16:32:30 +08:00
import {getOilNameList, oilNumberList} from "@/api/order/oilnumgun";
2024-09-04 17:32:58 +08:00
import {addActiveSubPrice, editActiveSubPrice, getActiveSubPrice} from "@/api/EventMarketing/activeSubPrice";
2024-08-31 13:51:23 +08:00
export default {
name: "LiJianMarketing",
dicts: ['payment_type'],
2024-10-15 18:11:07 +08:00
props: ['activeId'],
2024-08-31 13:51:23 +08:00
data() {
return {
ruleForm: {
2024-09-26 15:19:59 +08:00
activeTimeType: '0',
2024-09-04 13:42:53 +08:00
paymentType: [],
activeManner: [],
2024-09-26 15:19:59 +08:00
offerType: '0',
activeType: '0',
timeType: '0',
applyOilType: '0',
2024-08-31 13:51:23 +08:00
},
2024-09-04 13:42:53 +08:00
userGradeList: [],
userLabelList: [],
2024-09-03 16:32:30 +08:00
oilNameList: [],
// 油号列表
oilNumberList: [],
2024-08-31 13:51:23 +08:00
activityTimeTypeList: ["永久有效", "自定义"],
2024-09-26 15:19:59 +08:00
tindex1: '0',
2024-08-31 13:51:23 +08:00
preferentialTypeList: ["立减优惠", "折扣优惠"],
2024-09-26 15:19:59 +08:00
tindex2: '0',
2024-08-31 13:51:23 +08:00
weekMonthTypeList: ["每周", "每月"],
2024-09-26 15:19:59 +08:00
tindex3: '0',
2024-09-04 13:42:53 +08:00
oilTypeList: ['不限', '自定义'],
2024-09-26 15:19:59 +08:00
tindex4: '0',
2024-09-04 13:42:53 +08:00
activityTypeList: ['固定满减', '随机满减', '每满'],
2024-09-26 15:19:59 +08:00
tindex5: '0',
2024-08-31 13:51:23 +08:00
weekList: ["周一", "周二", "周三", "周四", "周五", "周六", "周日"],
weekDay: [],
monthDay: [],
2024-09-19 14:33:28 +08:00
orderList: [{
2024-09-26 15:19:59 +08:00
activeManner: '0',
2024-09-19 14:33:28 +08:00
full: "",
sub: "",
randomFront: "",
randomAfter: "",
maxPreferential: "",
enjoyDiscount: "",
}],
refuelList: [{
2024-09-26 15:19:59 +08:00
activeManner: '0',
2024-09-19 14:33:28 +08:00
full: "",
sub: "",
randomFront: "",
randomAfter: "",
maxPreferential: "",
enjoyDiscount: "",
}],
2024-08-31 13:51:23 +08:00
// 表单校验
rules: {
2024-10-15 18:11:07 +08:00
timeType: [
2024-09-26 15:19:59 +08:00
{required: true, message: '适用时间段不能为空', trigger: 'blur'},
],
2024-10-15 18:11:07 +08:00
activeType: [
2024-09-26 15:19:59 +08:00
{required: true, message: '活动类型不能为空', trigger: 'blur'},
],
2024-09-04 17:32:58 +08:00
activeName: [
2024-08-31 13:51:23 +08:00
{required: true, message: '活动名称不能为空', trigger: 'blur'},
],
2024-09-04 17:32:58 +08:00
activeTimeType: [
2024-08-31 13:51:23 +08:00
{required: true, message: '活动时间不能为空', trigger: 'blur'},
],
2024-09-04 17:32:58 +08:00
offerType: [
{required: true, message: '优惠类型不能为空', trigger: 'blur'},
2024-08-31 13:51:23 +08:00
],
2024-09-04 17:32:58 +08:00
levelId: [
2024-08-31 13:51:23 +08:00
{required: true, message: '适用会员等级不能为空', trigger: 'blur'},
],
2024-09-04 17:32:58 +08:00
dayLimitNum: [
2024-08-31 13:51:23 +08:00
{required: true, message: '每人每天参与上限不能为空', trigger: 'blur'},
],
2024-09-04 17:32:58 +08:00
monthLimitNum: [
2024-08-31 13:51:23 +08:00
{required: true, message: '每人每月参与上限不能为空', trigger: 'blur'},
],
2024-09-04 17:32:58 +08:00
limitNum: [
2024-08-31 13:51:23 +08:00
{required: true, message: '每人累计参与上限不能为空', trigger: 'blur'},
],
2024-09-04 17:32:58 +08:00
applyOilType: [
{required: true, message: '适用油品油号不能为空', trigger: 'blur'},
],
paymentType: [
{required: true, message: '可使用支付方式不能为空', trigger: 'blur'},
2024-08-31 13:51:23 +08:00
],
2024-09-04 17:32:58 +08:00
activeManner: [
{required: true, message: '活动方式不能为空', trigger: 'blur'},
2024-08-31 13:51:23 +08:00
],
2024-10-10 15:45:09 +08:00
timeApplyStart: [
{
validator: (rule, value, callback) => {
if (!this.ruleForm.timeApplyStart || !this.ruleForm.timeApplyEnd) {
callback(new Error("请选择完整的时间段"));
} else {
callback();
}
},
trigger: "change"
}
]
2024-08-31 13:51:23 +08:00
}
}
},
created() {
2024-09-12 15:44:25 +08:00
if (this.activeId) {
// 查询信息
this.getInfo()
}
2024-08-31 13:51:23 +08:00
this.listUserGrade()
this.getUserLabelList()
2024-09-03 16:32:30 +08:00
this.getOilList()
2024-08-31 13:51:23 +08:00
},
2024-09-04 13:42:53 +08:00
methods: {
2024-10-15 18:11:07 +08:00
changeOfferType() {
2024-09-26 15:19:59 +08:00
this.ruleForm.activeType = '0'
2024-10-15 18:11:07 +08:00
console.log(this.ruleForm, 446)
2024-09-26 15:19:59 +08:00
},
2024-09-04 13:42:53 +08:00
getOilList() {
2024-09-03 16:32:30 +08:00
getOilNameList().then(response => {
this.oilNameList = response.data;
})
oilNumberList().then(response => {
this.oilNumberList = response.data.records;
})
},
getOilNamess(list, id) {
let name = ""
if (list != null && list != "") {
list.forEach(item => {
if (item.id == id) {
name = item.oilName;
}
})
}
return name;
},
2024-08-31 13:51:23 +08:00
// 会员等级
listUserGrade() {
2024-09-04 13:42:53 +08:00
listUserGrade({page: 1, pageSize: 1000}).then(res => {
2024-08-31 13:51:23 +08:00
if (res.code == 200) {
this.userGradeList = res.data.records
}
})
},
// 会员标签
2024-09-04 13:42:53 +08:00
getUserLabelList() {
listUserLabel({page: 1, pageSize: 10000}).then(res => {
2024-08-31 13:51:23 +08:00
this.userLabelList = res.data.records
})
},
2024-09-04 13:42:53 +08:00
getInfo() {
2024-09-12 15:44:25 +08:00
getActiveSubPrice(this.activeId).then(res => {
2024-09-04 17:32:58 +08:00
if (res.data) {
this.ruleForm = res.data
if (res.data.timeSlots) {
2024-09-26 15:19:59 +08:00
if (res.data.timeType == 1) {
2024-09-04 17:32:58 +08:00
this.weekDay = this.ruleForm.timeSlots.split(",")
2024-09-26 15:19:59 +08:00
} else if (res.data.timeType == 2) {
2024-09-04 17:32:58 +08:00
this.monthDay = this.ruleForm.timeSlots.split(",")
}
}
2024-09-13 16:30:17 +08:00
if (res.data.levelId) this.ruleForm.levelId = res.data.levelId.split(",")
if (res.data.babelIds) this.ruleForm.babelIds = res.data.babelIds.split(",")
2024-09-04 17:32:58 +08:00
if (res.data.applyOil) this.ruleForm.applyOil = res.data.applyOil.split(",")
if (res.data.paymentType) this.ruleForm.paymentType = res.data.paymentType.split(",")
if (res.data.activeManner) this.ruleForm.activeManner = res.data.activeManner.split(",")
if (res.data.orderList) this.orderList = this.ruleForm.orderList
if (res.data.refuelList) this.refuelList = this.ruleForm.refuelList
} else {
this.ruleForm = {
2024-09-26 15:19:59 +08:00
activeTimeType: '0',
2024-09-04 17:32:58 +08:00
paymentType: [],
activeManner: [],
2024-09-26 15:19:59 +08:00
offerType: '0',
activeType: '0',
timeType: '0',
applyOilType: '0',
2024-09-04 17:32:58 +08:00
}
this.tindex1 = 0
this.tindex2 = 0
this.tindex3 = 0
this.tindex4 = 0
this.tindex5 = 0
}
})
2024-08-31 13:51:23 +08:00
},
2024-09-04 17:32:58 +08:00
addPoints(activeManner) {
2024-08-31 13:51:23 +08:00
let data = {
2024-09-04 17:32:58 +08:00
activeManner: activeManner,
full: "",
sub: "",
randomFront: "",
randomAfter: "",
maxPreferential: "",
enjoyDiscount: "",
2024-08-31 13:51:23 +08:00
}
2024-09-04 17:32:58 +08:00
this.orderList.push(data)
2024-08-31 13:51:23 +08:00
},
deletePoints(index) {
2024-09-04 17:32:58 +08:00
this.orderList.splice(index, 1);
2024-08-31 13:51:23 +08:00
},
2024-09-04 17:32:58 +08:00
addGrowthValues(activeManner) {
2024-08-31 13:51:23 +08:00
let data = {
2024-09-04 17:32:58 +08:00
activeManner: activeManner,
full: "",
sub: "",
randomFront: "",
randomAfter: "",
maxPreferential: "",
enjoyDiscount: "",
2024-08-31 13:51:23 +08:00
}
2024-09-04 17:32:58 +08:00
this.refuelList.push(data)
2024-08-31 13:51:23 +08:00
},
deleteGrowthValues(index) {
2024-09-04 17:32:58 +08:00
this.refuelList.splice(index, 1);
2024-08-31 13:51:23 +08:00
},
Typeindex1(index) {
this.tindex1 = index
2024-09-04 13:42:53 +08:00
this.ruleForm.activeTimeType = index
2024-08-31 13:51:23 +08:00
},
Typeindex2(index) {
this.tindex2 = index
2024-09-04 13:42:53 +08:00
this.ruleForm.offerType = index
2024-09-16 16:30:12 +08:00
this.ruleForm.activeType = 0
2024-09-04 13:42:53 +08:00
if (index == 0) {
this.activityTypeList = ['固定满减', '随机满减', '每满']
} else {
this.activityTypeList = ['固定满减']
}
this.tindex5 = 0
2024-09-04 17:32:58 +08:00
this.orderList = []
this.refuelList = []
2024-08-31 13:51:23 +08:00
},
Typeindex3(index) {
this.tindex3 = index
2024-09-04 13:42:53 +08:00
this.ruleForm.timeType = index
2024-08-31 13:51:23 +08:00
},
Typeindex4(index) {
this.tindex4 = index
2024-09-04 13:42:53 +08:00
this.ruleForm.applyOilType = index
2024-08-31 13:51:23 +08:00
},
Typeindex5(index) {
this.tindex5 = index
2024-09-04 13:42:53 +08:00
this.ruleForm.activeType = index
2024-08-31 13:51:23 +08:00
},
submitRuleForm(formName) {
2024-10-15 18:11:07 +08:00
//活动方式为 订单金额
if (this.ruleForm.activeManner && this.ruleForm.activeManner.includes('0')) {
const list = this.orderList.some(item => {
if (item.full === '' || item.sub === '') {
this.$message.error("请填写订单相关活动规则,如不需要请删除");
return true; // 返回 true 表示停止循环
}
});
if (list) {
return true; //退出当前方法
}
}
//活动方式为 订单金额
if (this.ruleForm.activeManner && this.ruleForm.activeManner.includes('1')) {
const list = this.refuelList.some(item => {
if (item.full === '' || item.sub === '') {
this.$message.error("请填写加油相关活动规则,如不需要请删除");
return true; // 返回 true 表示停止循环
}
});
if (list) {
return true; //退出当前方法
}
}
2024-09-04 13:42:53 +08:00
if (this.tindex1 == 1) {
if (!this.ruleForm.activeStartTime || !this.ruleForm.activeEndTime) {
2024-08-31 13:51:23 +08:00
this.$message.error("请选择活动开始时间")
return
}
}
2024-09-13 16:30:17 +08:00
if (this.ruleForm.activeManner && this.ruleForm.activeManner.includes('0')) {
if (!this.orderList || this.orderList.length == 0) {
this.$message.error("请先添加活动方式规则")
return;
}
}
if (this.ruleForm.activeManner && this.ruleForm.activeManner.includes('1')) {
if (!this.refuelList || this.refuelList.length == 0) {
this.$message.error("请先添加活动方式规则")
return;
}
}
2024-10-15 18:11:07 +08:00
if (this.ruleForm.activeManner.length == 0) {
2024-09-19 14:33:28 +08:00
this.$message.warning("请选择活动方式");
return
}
2024-10-15 18:11:07 +08:00
if (this.ruleForm.activeManner && this.ruleForm.activeManner.includes('0')) {
//如果选订单则 清空加油活动
this.refuelList = []
2024-09-19 14:33:28 +08:00
}
2024-10-15 18:11:07 +08:00
if (this.ruleForm.activeManner && this.ruleForm.activeManner.includes('1')) {
//如果加油 则清空订单
this.orderList = []
2024-09-19 14:33:28 +08:00
}
2024-08-31 13:51:23 +08:00
this.$refs[formName].validate((valid) => {
if (valid) {
2024-09-26 15:19:59 +08:00
if (this.ruleForm.timeType == 1) {
2024-09-04 17:32:58 +08:00
this.ruleForm.timeSlots = this.weekDay.toString()
2024-09-26 15:19:59 +08:00
} else if (this.ruleForm.timeType == 2) {
2024-09-04 17:32:58 +08:00
this.ruleForm.timeSlots = this.monthDay.toString()
}
2024-09-13 16:30:17 +08:00
if (this.ruleForm.levelId) this.ruleForm.levelId = this.ruleForm.levelId.toString()
if (this.ruleForm.babelIds) this.ruleForm.babelIds = this.ruleForm.babelIds.toString()
2024-09-04 17:32:58 +08:00
if (this.ruleForm.applyOil) this.ruleForm.applyOil = this.ruleForm.applyOil.toString()
if (this.ruleForm.paymentType) this.ruleForm.paymentType = this.ruleForm.paymentType.toString()
if (this.ruleForm.activeManner) this.ruleForm.activeManner = this.ruleForm.activeManner.toString()
if (this.orderList) this.ruleForm.orderList = this.orderList
if (this.refuelList) this.ruleForm.refuelList = this.refuelList
2024-08-31 13:51:23 +08:00
if (this.ruleForm.id) {
2024-09-04 13:42:53 +08:00
// 修改
2024-09-04 17:32:58 +08:00
editActiveSubPrice(this.ruleForm).then(res => {
this.$message.success("修改成功")
2024-09-11 17:35:10 +08:00
// this.getInfo()
2024-10-15 18:11:07 +08:00
this.$router.push({path: "/EventMarketing/center/index", query: {id: '3'}})
2024-09-04 17:32:58 +08:00
})
2024-08-31 13:51:23 +08:00
} else {
2024-09-04 13:42:53 +08:00
// 添加
2024-09-04 17:32:58 +08:00
addActiveSubPrice(this.ruleForm).then(res => {
if (res.data) {
this.$message.success("添加成功")
2024-09-11 17:35:10 +08:00
// this.getInfo()
2024-10-15 18:11:07 +08:00
this.$router.push({path: "/EventMarketing/center/index", query: {id: '3'}})
2024-09-04 17:32:58 +08:00
} else {
this.$message.error("添加失败")
}
})
2024-08-31 13:51:23 +08:00
}
}
});
},
resetForm(formName) {
this.$refs[formName].resetFields();
2024-09-11 17:35:10 +08:00
// this.getInfo()
2024-10-15 18:11:07 +08:00
this.$router.push({path: "/EventMarketing/center/index", query: {activeId: this.activeId}})
2024-08-31 13:51:23 +08:00
},
}
}
</script>
<style lang="scss" scoped>
.cot-box {
width: 100%;
border-radius: 8px;
background: #fff;
box-sizing: border-box;
2024-10-29 15:35:48 +08:00
padding: 15px;
2024-08-31 13:51:23 +08:00
margin: 0 auto;
2024-10-29 15:35:48 +08:00
height: 86vh;
2024-08-31 13:51:23 +08:00
}
.d-s {
display: flex;
align-items: center;
}
.icon-type {
display: flex;
align-items: center;
font-weight: 400;
font-size: 14px;
color: #999999;
margin-right: 20px;
cursor: pointer;
}
.acvtive {
color: #FF770F !important;
}
2024-10-29 15:35:48 +08:00
.app-open{
background: #f9f9f9;
box-sizing: border-box;
padding: 10px;
}
2024-08-31 13:51:23 +08:00
</style>