oil-station/fuintAdmin/src/views/EventMarketing/newCertificate/index.vue
2024-11-04 16:18:56 +08:00

1460 lines
50 KiB
Vue

<template>
<div class="containers_app">
<!-- 优惠券 -->
<div class="card-boxs" >
<div class="top-hang">
<div class="d-s">
<el-input v-model="queryParams.name" clearable style=" width: 250px; margin-right: 10px"
placeholder="请输入优惠券名称"></el-input>
<el-select v-model="queryParams.type" clearable style=" width: 250px; margin-right: 10px"
placeholder="请选择优惠类型">
<el-option v-for="dict in dict.type.CardCoupon_type" :key="dict.value" :label="dict.label"
:value="dict.value"/>
</el-select>
<el-select v-model="queryParams.status" clearable style=" width: 250px; margin-right: 10px"
placeholder="请选择状态">
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
</el-option>
</el-select>
</div>
<div class="d-s">
<el-button type="primary" icon="el-icon-search" @click="getlist">查询</el-button>
<el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
<el-button type="primary" @click="addCertificate">新增优惠券</el-button>
</div>
</div>
<div style="height: 68.5vh;overflow: auto">
<el-table border :data="tableData" style="width: 100%">
<el-table-column label="序号" type="index"></el-table-column>
<el-table-column prop="number" label="优惠券编号"></el-table-column>
<el-table-column prop="name" label="优惠券名称"></el-table-column>
<el-table-column prop="type" label="优惠券类型">
<template slot-scope="scope">
<span v-if="scope.row.type==1">代金券</span>
<span v-if="scope.row.type==2">兑换券</span>
<span v-if="scope.row.type==3">折扣券</span>
<span v-if="scope.row.type==4">油品立减券</span>
<span v-if="scope.row.type==5">单品代金券</span>
</template>
</el-table-column>
<el-table-column prop="putType" label="投放类型">
<template slot-scope="scope">
<span v-if="scope.row.putType==1">营销投放</span>
<span v-if="scope.row.putType==2">免费领取</span>
<span v-if="scope.row.putType==3">积分兑换</span>
</template>
</el-table-column>
<!-- 优惠券列表中优惠内容 展示消费条件 订单金额 满 元 每 减 元 -->
<el-table-column label="消费条件">
<template slot-scope="scope">
<span>{{ getConditionsOfConsumption(scope.row) }}</span>
</template>
</el-table-column>
<el-table-column prop="createTime" label="有效期">
<template slot-scope="scope">
<span>{{ getExpirationDate(scope.row) }}</span>
</template>
</el-table-column>
<el-table-column prop="tfGetNum" label="已领/投放数量">
<template slot-scope="scope">
<span>{{ scope.row.tfGetNum || 0 }}/{{ scope.row.tfTotal || 0 }}</span>
</template>
</el-table-column>
<el-table-column prop="tfUseNum" label="已核销"></el-table-column>
<el-table-column prop="status" label="状态">
<template slot-scope="scope">
<span v-if="scope.row.status == 1" style="color: #0DC291">上架</span>
<span v-if="scope.row.status != 1" style="color: #F44522">下架</span>
</template>
</el-table-column>
<el-table-column prop="createByName" label="创建人"></el-table-column>
<el-table-column prop="createTime" label="创建时间"></el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<div style="display: flex;">
<el-button type="text" @click="updetenCardCoupon(scope.row.id)">修改</el-button>
<el-button type="text" @click="sxCoupon(scope.row.id)">
<span v-if="scope.row.status == 0">上架</span>
<span v-if="scope.row.status == 1">下架</span>
</el-button>
<el-button type="text" @click="deletId(scope.row.id)">删除</el-button>
</div>
</template>
</el-table-column>
</el-table>
</div>
<pagination v-show="total > 0" :total="total" :page.sync="pageNo" :limit.sync="pageSize" @pagination="getlist"/>
</div>
<el-drawer title="订单记录" :visible.sync="orderShow" size="55%" :before-close="handleClose" center>
<div class="box-der">
<div class="d-b">
<div class="d-s">
<el-input v-model="input" style="width: 200px;margin-right: 10px" placeholder="请输入订单号"></el-input>
<el-select v-model="value" placeholder="请选择" style="width: 200px;margin-right: 10px">
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
</el-option>
</el-select>
<el-date-picker v-model="value1" type="daterange" range-separator="至" start-placeholder="开始日期"
end-placeholder="结束日期">
</el-date-picker>
</div>
<el-button type="primary" icon="el-icon-search">搜索</el-button>
</div>
<el-table :data="orderData" border style="width: 100%">
<el-table-column label="序号" type="index"></el-table-column>
<el-table-column prop="date" label="订单号"></el-table-column>
<el-table-column prop="date" label="会员手机号"></el-table-column>
<el-table-column prop="date" label="礼品卡面值(元)"></el-table-column>
<el-table-column prop="date" label="数量"></el-table-column>
<el-table-column prop="date" label="礼品卡金额"></el-table-column>
<el-table-column prop="date" label="实收金额"></el-table-column>
<el-table-column prop="date" label="订单状态"></el-table-column>
<el-table-column prop="date" label="订单完成时间"></el-table-column>
</el-table>
</div>
</el-drawer>
<el-dialog title="新增/编辑优惠券" :close-on-click-modal="false" :visible.sync="centerDialogVisible" width="90%">
<!-- 表-->
<el-form :model="ruleForm" :rules="rules" :label-position="labelPosition" ref="ruleForm" label-width="120px"
class="demo-ruleForm">
<div class="d-s" style="justify-content: space-between">
<!-- 左-->
<div class="dialog-lift">
<div style="display: flex;align-items: center">
<el-form-item label="优惠券编号 " label-width="180px" required prop="number" style="width: 100%;margin-bottom: 0px;margin-right: 10px">
<el-input v-model="ruleForm.number" placeholder="请输入优惠券编号" disabled></el-input>
</el-form-item>
<el-button type="primary" icon="el-icon-refresh" circle @click="refreshNumber()"
v-if="!this.disabledBol"></el-button>
</div>
<el-form-item label="是否允许收银台送券" label-width="180px" required style="width: 100%;margin-bottom: 2px" prop="sySend">
<el-radio-group v-model="ruleForm.sySend">
<el-radio :label="'0'">否</el-radio>
<el-radio :label="'1'">是</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="生效日期设置" label-width="180px" required style="width: 100%;margin-bottom: 2px" prop="timeType">
<div class="d-s">
<el-radio-group v-model="ruleForm.timeType">
<el-radio :label="'1'">领取
<el-input v-model="ruleForm.validityDay" placeholder=""
style="width: 80px;margin: 0px 10px"></el-input>
<span>天内有效</span></el-radio>
<el-radio :label="'2'">指定使用日期</el-radio>
</el-radio-group>
</div>
</el-form-item>
<el-form-item label="生效日期" label-width="180px" required style="width: 100%;margin-bottom: 2px" v-if="ruleForm.timeType=='2'"
prop="effectiveDateStart">
<el-date-picker
v-model="ruleForm.effectiveDateStart"
style="width: 160px"
type="date"
value-format="yyyy-MM-dd"
placeholder="开始日期">
</el-date-picker>
<span style="margin: 0 5px">至</span>
<el-date-picker
v-model="ruleForm.effectiveDateEnd"
style="width: 160px"
type="date"
value-format="yyyy-MM-dd"
placeholder="结束日期">
</el-date-picker>
</el-form-item>
<el-form-item label="是否与其他优惠同时使用" label-width="180px" required style="width: 100%;margin-bottom: 2px" prop="useWithOther">
<el-radio-group v-model="ruleForm.useWithOther">
<el-radio :label="'0'">不可以</el-radio>
<el-radio :label="'1'">可以</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="使用次数限制" label-width="180px" required style="width: 100%;" prop="limitTotalDay">
<div class="d-s">
<div style="margin: 0px 5px;">每</div>
<el-input placeholder="" v-model="ruleForm.limitTotalDay" style="width: 140px">
<template slot="append">天</template>
</el-input>
<div style="margin: 0px 5px;">限制使用</div>
<el-input placeholder="" v-model="ruleForm.limitTotalNum" style="width: 140px">
<template slot="append">次</template>
</el-input>
</div>
</el-form-item>
<el-form-item label="时间段设置" label-width="180px" prop="availableOrUn" required>
<el-radio-group v-model="ruleForm.availableOrUn">
<el-radio :label="'0'">适用时间段</el-radio>
<el-radio :label="'1'">不可用时间段</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label-width="180px" v-if="ruleForm.type == '5'" label="适用商品" prop="productLimit" style="width: 100%;">
<el-radio v-model="ruleForm.productLimit" label="1">不限</el-radio>
<el-radio v-model="ruleForm.productLimit" label="2">自定义</el-radio>
<el-select multiple v-if="ruleForm.productLimit == 2" v-model="ruleForm.productIdList"
placeholder="请选择商品名称(可多选)" style="margin-left: 10px;width:300px">
<el-option
v-for="item in goodsList"
:key="item.id+''"
:label="item.name"
:value="item.id+''"></el-option>
</el-select>
</el-form-item>
<div v-if="ruleForm.availableOrUn == '0'" >
<el-form-item label-width="180px" label="适用时间段" prop="availableType" required>
<el-radio-group v-model="ruleForm.availableType">
<div style="display: flex; width: 500px;margin-top: 10px;margin-bottom: 10px">
<el-radio :label="'1'">每周</el-radio>
<el-checkbox-group v-model="weekDay" style="margin-left: 20px"
:disabled="ruleForm.availableType!='1'">
<el-checkbox v-for="(item,index) in weekList" :key="index" :label="item"></el-checkbox>
</el-checkbox-group>
</div>
<el-radio :label="'2'">每月
<el-select :disabled="ruleForm.availableType!='2'" v-model="monthDay" placeholder="请选择每月固定日期" multiple
style="margin-left: 20px;width: 385px">
<el-option
v-for="item in 31"
:key="item+''"
:label="item+'日'"
:value="item+''">
</el-option>
</el-select>
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="时间段" label-width="180px" v-if="ruleForm.availableOrUn == '0'" prop="availablePeriodStart" required>
<el-time-picker
v-model="ruleForm.availablePeriodStart"
format="HH:mm"
value-format="HH:mm"
placeholder="请选择开始时间点">
</el-time-picker>
<el-time-picker
v-model="ruleForm.availablePeriodEnd"
format="HH:mm"
value-format="HH:mm"
placeholder="请选择结束时间点">
</el-time-picker>
</el-form-item>
</div>
<el-form-item label="不适用时间段" v-if="ruleForm.availableOrUn == '1'" prop="unAvailableType" required>
<el-radio-group v-model="ruleForm.unAvailableType">
<div style="display: flex; width: 500px;margin-bottom: 15px;">
<el-radio :label="'1'">每周</el-radio>
<el-checkbox-group v-model="weekDay1" style="margin-left: 20px"
:disabled="ruleForm.unAvailableType!='1'">
<el-checkbox v-for="(item,index) in weekList" :key="index" :label="item"></el-checkbox>
</el-checkbox-group>
</div>
<el-radio :label="'2'">每月
<el-select :disabled="ruleForm.unAvailableType!='2'" v-model="monthDay1" placeholder="请选择每月固定日期" multiple
style="margin-left: 20px">
<el-option
v-for="item in 31"
:key="item+''"
:label="item+'日'"
:value="item+''">
</el-option>
</el-select>
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="时间段" v-if="ruleForm.availableOrUn == '1'" label-width="70px" prop="unAvailablePeriodStart" required>
<el-time-picker
v-model="ruleForm.unAvailablePeriodStart"
format="HH:mm"
value-format="HH:mm"
placeholder="请选择开始时间点">
</el-time-picker>
<el-time-picker
v-model="ruleForm.unAvailablePeriodEnd"
format="HH:mm"
value-format="HH:mm"
placeholder="请选择结束时间点">
</el-time-picker>
</el-form-item>
<el-form-item label="背景图" label-width="180px" style="width: 100%;" required prop="backgroundImage">
<imgUpload :limit="1" v-model="ruleForm.backgroundImage"></imgUpload>
</el-form-item>
</div>
<!-- 右-->
<div class="dialog-right">
<el-form-item label="优惠券名称" required prop="name" style="width: 100%;">
<el-input v-model="ruleForm.name" placeholder="请输入优惠券名称" :disabled="disabledBol"></el-input>
</el-form-item>
<el-form-item label="投放类型" required prop="putType" style="width: 100%;">
<el-select v-model="ruleForm.putType" placeholder="请选择投放类型" style="width: 100%">
<el-option v-for="dict in dict.type.putType_type" :key="dict.value" :label="dict.label"
:value="dict.value"/>
</el-select>
</el-form-item>
<el-form-item label="适用会员等级" required style="width: 100%;" prop="membershipLevel">
<el-select v-model="ruleForm.membershipLevel" multiple placeholder="请选择" style="width: 100%">
<el-option
v-for="(item,index) in membership"
:label="item.name"
:value="item.id.toString()"
:key="index"></el-option>
</el-select>
</el-form-item>
<el-form-item label="优惠券类型" prop="type" required style="width: 100%;">
<el-select v-model="ruleForm.type" placeholder="请选择优惠券类型" style="width: 100%" :disabled="disabledBol">
<el-option v-for="dict in dict.type.CardCoupon_type" :key="dict.value" :label="dict.label"
:value="dict.value"/>
</el-select>
</el-form-item>
<el-form-item label="消费条件" required style="width: 100%;"
v-if="ruleForm.type=='1'"
prop="useType">
<div class="d-s">
<el-select v-model="ruleForm.useType" placeholder="请选择金额" :disabled="disabledBol">
<el-option label="订单金额" value="1"/>
<el-option label="加油升数" value="2"/>
</el-select>
<div style="margin: 0px 5px;">满</div>
<el-input placeholder="" v-model="ruleForm.reachAmount" style="width: 140px" :disabled="disabledBol">
<template slot="append">{{ ruleForm.useType == '1' ? '元' : '升' }}</template>
</el-input>
<div style="width: 60px;text-align: center">优惠</div>
<el-input placeholder="" v-model="ruleForm.reduceAmount" style="width: 140px" :disabled="disabledBol">
<template slot="append">元</template>
</el-input>
</div>
</el-form-item>
<el-form-item label="消费条件" required style="width: 100%;"
v-if="ruleForm.type=='5'"
prop="useType">
<div class="d-s">
<el-select v-model="ruleForm.useType" placeholder="请选择金额" :disabled="disabledBol">
<el-option label="订单金额" value="1"/>
</el-select>
<div style="margin: 0px 5px;">满</div>
<el-input placeholder="" v-model="ruleForm.reachAmount" style="width: 140px" :disabled="disabledBol">
<template slot="append">元</template>
</el-input>
<div style="width: 60px;text-align: center">优惠</div>
<el-input placeholder="" v-model="ruleForm.reduceAmount" style="width: 140px" :disabled="disabledBol">
<template slot="append">元</template>
</el-input>
</div>
</el-form-item>
<el-form-item label="兑换内容" required style="width: 100%;" v-if="ruleForm.type=='2'" prop="exchangeContent">
<el-input placeholder="" v-model="ruleForm.exchangeContent" :disabled="disabledBol"></el-input>
</el-form-item>
<el-form-item label="优惠条件" required style="width: 100%;" v-if="ruleForm.type=='3'" prop="useType">
<div class="d-s">
<el-select v-model="ruleForm.useType" placeholder="请选择" style="width: 110px" :disabled="disabledBol">
<el-option label="订单金额" value="1"/>
<el-option label="加油升数" value="2"/>
</el-select>
<div style="width: 50px;text-align: center">范围</div>
<el-input placeholder="" v-model="ruleForm.zkStartAmount" style="width: 130px" :disabled="disabledBol">
<template slot="append">{{ ruleForm.useType == '1' ? '元' : '升' }}</template>
</el-input>
<div style="margin: 0px 5px;">~</div>
<el-input placeholder="" v-model="ruleForm.zkEndAmount" style="width: 130px" :disabled="disabledBol">
<template slot="append">{{ ruleForm.useType == '1' ? '元' : '升' }}</template>
</el-input>
<div style="width: 50px;text-align: center">优惠</div>
<el-input placeholder="" v-model="ruleForm.zkData" style="width: 130px" :disabled="disabledBol">
<template slot="append">折</template>
</el-input>
</div>
</el-form-item>
<el-form-item label="消费条件" required style="width: 100%;" v-if="ruleForm.type=='4'" prop="useType">
<div class="d-s">
<el-select v-model="ruleForm.useType" placeholder="请选择金额" :disabled="disabledBol">
<el-option label="订单金额" value="1"/>
<el-option label="加油升数" value="2"/>
</el-select>
<div style="margin: 0px 5px;">满</div>
<el-input placeholder="" v-model="ruleForm.reachAmount" style="width: 160px" :disabled="disabledBol">
<template slot="append">{{ ruleForm.useType == '1' ? '元' : '升' }}</template>
</el-input>
<div style="width: 40px;text-align: center">每</div>
<el-input placeholder="" v-model="ruleForm.ljOilNum" style="width: 160px" :disabled="disabledBol">
<template slot="append">L</template>
</el-input>
<div style="width: 40px;text-align: center">减</div>
<el-input placeholder="" v-model="ruleForm.ljOilAmount" style="width: 160px" :disabled="disabledBol">
<template slot="append">元</template>
</el-input>
</div>
</el-form-item>
<el-form-item label="适用油品油号" required style="width: 100%;" prop="oilLimit"
v-if="ruleForm.type=='1' || ruleForm.type=='3' || ruleForm.type=='4' ">
<div class="d-s">
<el-radio-group v-model="ruleForm.oilLimit">
<el-radio :label="'1'">不限</el-radio>
<el-radio style="margin-top: 10px" :label="'2'">自定义</el-radio>
</el-radio-group>
<el-select v-model="ruleForm.oilNumber" multiple placeholder="请选择" style="margin-left: 5px">
<el-option v-for="(item,index) in oilNumberList" :key="index"
:label="getOilNamess(oilNameList,item.oilName)" :value="item.oilName"></el-option>
</el-select>
</div>
</el-form-item>
<el-form-item label="最大优惠金额" v-if="ruleForm.type=='3'|| ruleForm.type=='4' " required style="width: 100%;" prop="zkMaxAmount">
<el-input placeholder="" v-model="ruleForm.zkMaxAmount" :disabled="disabledBol">
<template slot="append"></template>
</el-input>
</el-form-item>
<el-form-item label="每人领券限制" required style="width: 100%;" prop="getNumLimit">
<el-input v-model="ruleForm.getNumLimit" placeholder="请输入内容"></el-input>
</el-form-item>
<el-form-item label="每日领券限制" required style="width: 100%;" prop="dayGetLimit">
<el-input v-model="ruleForm.dayGetLimit" placeholder="请输入内容"></el-input>
</el-form-item>
<el-form-item label="投放总数" required style="width: 100%;" prop="tfTotal">
<el-input v-model="ruleForm.tfTotal" placeholder="请输入内容"></el-input>
</el-form-item>
<el-form-item label="使用条件" style="width: 100%;">
<el-input type="textarea" v-model="ruleForm.useCondition"></el-input>
</el-form-item>
<el-form-item label="备注" style="width: 100%;">
<el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="ruleForm.remark">
</el-input>
</el-form-item>
</div>
</div>
</el-form>
<div slot="footer" class="dialog-footer" style="text-align: center">
<el-button @click="centerDialogVisible = false">取 消</el-button>
<el-button type="primary" @click="addBlock(ruleForm)">保存</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
getList,
getListtj,
addList,
eitList,
deleteList,
oilDepotConfiguration,
getdownload,
getselectGiftValue,
getyi,
getwei,
getqb,
getsk
} from "@/api/EventMarketing/giftBlock";
import {delLJGoods, listLJGoods} from "@/api/convenienceStore/ljgoods";
import imgUpload from "@/components/ImageUpload/index.vue"
import {getToken} from "@/utils/auth";
import imgUpload1 from "@/components/map/imgUpload.vue";
import {Row} from "element-ui";
import {
addCardCoupon,
listCardCoupon,
getCardCoupon,
getCoupon,
CardCouponDelete,
editCardCoupon
} from "@/api/EventMarketing/cardCoupon";
import {getOilNameList, oilNumberList} from "@/api/order/oilnumgun";
import {listUserGrade} from "@/api/staff/user/usergrade";
export default {
name: 'index',
dicts: ['CardCoupon_type', 'putType_type', 'oilNumber_type'],
data() {
return {
disabledBol: false,
oilTypelist: [
"不限",
"自定义"
],
oilTypelistL: [
"每周",
"每月"
],
timelist: [
"指定具体使用日期",
"领取后",
],
whetherlist: [
"否",
"是",
],
tindex: 0,
timeType: 0,
//是否可与其他优惠一起使用1可以0不可以
useWithOther: 0,
validityDay: 30,
jglist: [],
onelist: [],
twolist: [],
threelist: [],
goodsList: [],
orderShow: false,
weekList: ["周一", "周二", "周三", "周四", "周五", "周六", "周日"],
monthList: [
{
label: "每月1号",
value: "1"
},
{
label: "每月2号",
value: "2"
},
{
label: "每月3号",
value: "3"
},
{
label: "每月4号",
value: "4"
},
{
label: "每月5号",
value: "5"
}, {
label: "每月6号",
value: "6"
}, {
label: "每月7号",
value: "7"
}, {
label: "每月8号",
value: "8"
}, {
label: "每月9号",
value: "9"
}, {
label: "每月10号",
value: "10"
}, {
label: "每月11号",
value: "11"
}, {
label: "每月12号",
value: "12"
}, {
label: "每月13号",
value: "13"
}, {
label: "每月14号",
value: "14"
}, {
label: "每月15号",
value: "15"
}, {
label: "每月16号",
value: "16"
}, {
label: "每月17号",
value: "17"
}, {
label: "每月18号",
value: "18"
}, {
label: "每月19号",
value: "19"
}, {
label: "每月20号",
value: "20"
}, {
label: "每月21号",
value: "21"
}, {
label: "每月22号",
value: "22"
}, {
label: "每月23号",
value: "23"
}, {
label: "每月24号",
value: "24"
}, {
label: "每月25号",
value: "25"
}, {
label: "每月26号",
value: "26"
}, {
label: "每月27号",
value: "27"
}, {
label: "每月28号",
value: "28"
}, {
label: "每月29号",
value: "29"
}
, {
label: "每月30号",
value: "30"
}
, {
label: "每月31号",
value: "31"
}
],
orderData: [{
date: '2016-05-02',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
},],
headers: {
'Access-Token': getToken(),
},
uploading: false,
fileList: [],
labelPosition: 'right',
queryParams: {
number: '',
remark: '',
activateStatus: null,
status: '',
pageNo: 1,
pageSize: 10
},
centerDialogVisible: false,
input: '',
total: 0,
pageNo: 1,
effectiveDateStart: '',
pageSize: 10,
option: [
{
value: '0',
label: '已激活'
}, {
value: '1',
label: '未激活'
},],
value1: '',
options: [
{
value: '1',
label: '上架'
}, {
value: '0',
label: '下架'
},],
value: '',
tjdata: {},
tableData: [
{
date: '2016-05-02',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
date: '2016-05-04',
name: '王小虎',
address: '上海市普陀区金沙江路 1517 弄'
}, {
date: '2016-05-01',
name: '王小虎',
address: '上海市普陀区金沙江路 1519 弄'
}, {
date: '2016-05-03',
name: '王小虎',
address: '上海市普陀区金沙江路 1516 弄'
}],
oilNumberList: [],
oilNameList: [],
weekDay: [],
monthDay: [],
weekDay1: [],
monthDay1: [],
ruleForm: {
useType: 1,
availableOrUn: '0',
productIdList: [],
productIds: '',
productLimit: 1,
oilLimit: '',
sySend: '',
timeType: '',
useWithOther: '',
availableType: '',
unAvailableType: '',
name: '',
number: '',
status: '',
quantity: '',
cardAmount: '',
remark: '',
putType: '',
oilNumber: '',
region: '',
membershipLevel: '',
//限制多少天内可使用几次的 天字段
limitTotalDay: '',
//限制多少天内可使用几次的 次字段
tfTotal: 0,
dayGetLimit: 0,
getNumLimit: 0,
useCondition: "",
validityDay: 30,
effectiveDateEnd: '',
effectiveDateStart: '',
},
membership: [],
rules: {
backgroundImage: [{required: true, message: '请上传背景图'}],
unAvailableType: [{required: true, message: '请选择不可使用日期类型'}],
availableType: [{required: true, message: '请选择适用日期类型'}],
availableOrUn: [{required: true, message: '请选择时间段'}],
name: [{required: true, message: '请输入名称'}],
number: [{required: true, message: '请输入编号'}],
putType: [{required: true, message: '请选择投放类型'}],
type: [{required: true, message: '请选择优惠券类型'}],
//自定义校验
oilLimit: [{required: true, validator: this.validateOilLimit, trigger: 'change'}],
membershipLevel: [{required: true, message: '请选择会员等级', trigger: 'blur'}],
sySend: [{required: true, message: '请选择收银台是否可送', trigger: 'blur'}],
timeType: [{required: true, message: '请选择时间类型', trigger: 'change'}],
//自定义校验
effectiveDateStart: [{validator: this.validateEffectiveDate}],
useWithOther: [{required: true, message: '请选择是否可与其他优惠券同享', trigger: 'blur'}],
//自定义校验
limitTotalDay: [{validator: this.validateLimitTotalDay}],
getNumLimit: [{required: true, message: '请输入每人领券限制'}],
tfTotal: [{required: true, message: '请输入投放总数'}],
dayGetLimit: [{required: true, message: '请输入每日领券限制'}],
//自定义校验
useType: [
{
validator: (rule, value, callback) => {
console.log('优惠券类型', this.dict.type.CardCoupon_type)
if (this.ruleForm.type == '1' || this.ruleForm.type == '5') {
if (!this.ruleForm.useType) {
callback(new Error("请选择优惠券使用条件"));
} else if (!this.ruleForm.reachAmount) {
callback(new Error("请输入限制条件"));
} else if (!this.ruleForm.reduceAmount) {
callback(new Error("请输入优惠金额"));
} else {
callback();
}
}
if (this.ruleForm.type == '3') {
if (!this.ruleForm.useType) {
callback(new Error("请选择优惠券使用条件"));
} else if (!this.ruleForm.zkStartAmount) {
callback(new Error("请输入范围最小值"));
} else if (!this.ruleForm.zkEndAmount) {
callback(new Error("请输入范围最大值"));
} else if (!this.ruleForm.zkData) {
callback(new Error("请输入折扣"));
} else {
callback();
}
}
if (this.ruleForm.type == '4') {
if (!this.ruleForm.useType) {
callback(new Error("请选择优惠券使用条件"));
} else if (!this.ruleForm.reachAmount) {
callback(new Error("请输入限制条件"));
} else if (!this.ruleForm.ljOilNum) {
callback(new Error("请输入升数"));
} else if (!this.ruleForm.ljOilAmount) {
callback(new Error("请输入立减金额"));
} else {
callback();
}
}
},
trigger: ['change', 'blur']
}
],
//自定义校验
unAvailablePeriodStart: [
{
validator: (rule, value, callback) => {
if (this.ruleForm.unAvailablePeriodStart === undefined) {
callback(new Error("请选择开始时间段"));
} else if (this.ruleForm.unAvailablePeriodEnd === undefined) {
callback(new Error("请选择结束时间段"));
} else {
callback();
}
},
trigger: ['change', 'blur']
}
],
//自定义校验
availablePeriodStart: [
{
validator: (rule, value, callback) => {
if (this.ruleForm.availablePeriodStart === undefined) {
callback(new Error("请选择开始时间段"));
} else if (this.ruleForm.availablePeriodEnd === undefined) {
callback(new Error("请选择结束时间段"));
} else {
callback();
}
},
trigger: ['change', 'blur']
}
],
exchangeContent: [{required: true, message: '请输入兑换内容'}],
}
}
},
created() {
this.getOilList()
this.getlist()
this.gettj()
this.getGoodsList()
},
components: {
imgUpload1,
imgUpload,
},
methods: {
//刷新生成的编号
refreshNumber() {
console.log("触发了", this.ruleForm)
this.ruleForm.number = this.generateCouponNumber()
},
getExpirationDate(row) {
if (row.timeType == '1') {
return '领取后 ' + row.validityDay + ' 天有效'
}
if (row.timeType == '2') {
return row.effectiveDateStart + ' ~ ' + row.effectiveDateEnd
}
},
getConditionsOfConsumption(row) {
// <span v-if="scope.row.type==1">代金券</span>
// <span v-if="scope.row.type==2">兑换券</span>
// <span v-if="scope.row.type==3">折扣券</span>
// <span v-if="scope.row.type==4">油品立减券</span>
// <span v-if="scope.row.type==5">单品代金券</span>
if (row.type == 1 || row.type == 5) {
if (row.useType == 1) {
return '订单金额 满' + row.reachAmount + '元 优惠' + row.reduceAmount + '元'
}
if (row.useType == 2) {
return '加油升数 满' + row.reachAmount + 'L 优惠' + row.reduceAmount + '元'
}
}
if (row.type == 2) {
return '兑换内容 ' + row.exchangeContent
}
if (row.type == 3) {
if (row.useType == 1) {
return '订单金额 范围' + row.zkStartAmount + '元 ~ ' + row.zkEndAmount + '元 优惠' + row.zkData + '折'
}
if (row.useType == 2) {
return '加油升数 范围' + row.zkStartAmount + 'L ~ ' + row.zkEndAmount + 'L 优惠' + row.zkData + '折'
}
}
if (row.type == 4) {
if (row.useType == 1) {
return '订单金额 满' + row.reachAmount + '元 每' + row.ljOilNum + 'L 减' + row.ljOilAmount + '元'
}
if (row.useType == 2) {
return '加油升数 满' + row.reachAmount + 'L 每' + row.ljOilNum + 'L 减' + row.ljOilAmount + '元'
}
}
},
validateLimitTotalDay(rule, value, callback) {
console.log(this.ruleForm.limitTotalDay)
console.log(this.ruleForm.limitTotalNum)
if (this.ruleForm.limitTotalDay == '') {
callback(new Error('请输入天数'));
} else if (this.ruleForm.limitTotalNum === undefined) {
callback(new Error('请输入次数'));
} else {
callback();
}
},
validateOilLimit(rule, value, callback) {
if (value == '') {
callback(new Error('请选择油品油号'));
} else if (value == '2' && this.ruleForm.oilNumber == '') {
callback(new Error('请选择自定义'));
} else {
callback();
}
},
validateEffectiveDate(rule, value, callback) {
// 检查开始时间是否为空
if (this.ruleForm.effectiveDateStart === undefined || this.ruleForm.effectiveDateStart === null) {
callback(new Error('请选择开始时间'));
}
// 检查结束时间是否为空
else if (this.ruleForm.effectiveDateEnd === undefined || this.ruleForm.effectiveDateEnd === null) {
callback(new Error('请选择结束时间'));
} else {
callback();
}
},
getGoodsList() {
listLJGoods({page: 1, pageSize: 10000, status: 'qy', isRecovery: 0}).then(response => {
this.goodsList = response.data.records;
});
},
sxCoupon(id) {
getCoupon(id).then(res => {
if (res.code == 200) {
this.$message({
message: '操作成功',
type: 'success'
});
this.getlist()
} else {
this.$message({
message: res.msg,
type: 'error'
});
}
})
},
listUserGrade() {
listUserGrade({page: 1, pageSize: 1000}).then(res => {
if (res.code == 200) {
this.membership = res.data.records
}
})
},
getOilList() {
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;
},
handleClose(done) {
// this.$confirm('确认关闭?')
// .then(_ => {
done();
// })
// .catch(_ => {});
},
Typeindex(index) {
this.tindex = index
},
TypeindexSet(index) {
this.timeType = index
},
TypeindexOther(index) {
this.useWithOther = index;
},
updetenCardCoupon(id) {
//锁定表单某些输入框
this.disabledBol = true
this.listUserGrade()
this.centerDialogVisible = !this.centerDialogVisible
getCardCoupon(id).then(res => {
this.ruleForm = res.data
console.log("类型", typeof this.ruleForm.unAvailablePeriodStart)
if (this.ruleForm.availableOrUn == null || this.ruleForm.availableOrUn == '') {
this.ruleForm.availableOrUn = '0'
}
if (res.data.unAvailableWeek) {
this.weekDay1 = res.data.unAvailableWeek.split(",")
}
if (res.data.unAvailableDay) {
this.monthDay1 = res.data.unAvailableDay.split(",")
}
if (res.data.availableWeek) {
this.weekDay = res.data.availableWeek.split(",")
}
if (res.data.availableDay) {
this.monthDay = res.data.availableDay.split(",")
}
if (res.data.membershipLevel) {
this.ruleForm.membershipLevel = res.data.membershipLevel.split(",")
}
if (res.data.oilNumber) {
this.ruleForm.oilNumber = res.data.oilNumber.split(",")
}
})
},
//生成时间
generateCouponNumber() {
const now = new Date();
var dateStr = now.getFullYear().toString() + // 年份取后两位
(now.getMonth() + 1).toString().padStart(2, '0') + // 月份
now.getDate().toString().padStart(2, '0') + // 日期
now.getHours().toString().padStart(2, '0') + // 小时
now.getMinutes().toString().padStart(2, '0') + // 分钟
now.getSeconds().toString().padStart(2, '0'); // 秒
return dateStr
},
addCertificate() {
this.disabledBol = false
this.ruleForm = {
useType: '1',
//单选框都要有默认值 否则会提示表单约束必填项
oilLimit: '',
sySend: '',
timeType: '',
useWithOther: '',
availableType: '',
unAvailableType: '',
name: '',
number: this.generateCouponNumber(),
quantity: '',
cardAmount: '',
remark: '',
putType: '',
oilNumber: '',
region: '',
membershipLevel: '',
limitTotalDay: '',
ruleForm: '',
tfTotal: 0,
dayGetLimit: 0,
getNumLimit: 0,
useCondition: "",
validityDay: 30
}
this.centerDialogVisible = !this.centerDialogVisible
// 新增优惠券
this.listUserGrade()
// 当对话框打开时,确保数据已经加载完成
this.$nextTick(() => {
this.$refs['ruleForm'].clearValidate();
});
},
getwysk(row) {
if (row.sailStatus == 1) {
this.$message.error("此卡已经售出过了呦")
return
}
if (row.activateStatus == 1) {
this.$message.error("此卡还未激活呦")
return
}
let data = {
id: row.id,
sailStatus: 1
}
getsk(data).then(res => {
this.getlist()
console.log(res)
this.$message.success("售卡成功")
})
},
// 下载
handleChange(file, fileList) {
this.uploading = true;
console.log(file)
if (file.status === 'success') {
this.uploading = false;
this.openUpload = false;
this.openUser = false;
this.fileList.splice(0, 1)
this.result = file.response.data
this.getlist()
}
},
putStatus(id) {
let data = {
id: 1,
exchangeStatus: id,
}
oilDepotConfiguration(data).then(res => {
if (res.code == 200) {
this.$message.success("操作成功")
this.gettj()
}
})
},
// 重置按钮操作
resetQuery() {
this.queryParams = {
number: '',
remark: '',
activateStatus: null,
status: '',
pageNo: 1,
pageSize: 10
}
this.goodsList = [];
this.getlist();
},
getlist() {
getselectGiftValue().then(res => {
console.log(res)
this.jglist = res.data
})
getqb().then(res => {
this.onelist = res.data
console.log(this.onelist)
})
getyi().then(res => {
this.twolist = res.data
})
getwei().then(res => {
this.threelist = res.data
})
this.queryParams.pageNo = this.pageNo
this.queryParams.pageSize = this.pageSize
listCardCoupon(this.queryParams).then(res => {
this.tableData = res.data.records
this.total = res.data.total;
})
// getList(this.queryParams).then(res => {
// this.tableData = res.data.records
// this.total = res.data.total;
// })
},
// 删除
deletId(id) {
this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
CardCouponDelete(id).then(res => {
if (res.code == 200) {
this.$message({
type: 'success',
message: '删除成功!'
});
this.getlist()
}
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
});
},
updateTableData(deletedRow) {
// 更新表格数据,例如移除已删除的行
this.tableData = this.tableData.filter(item => item.id !== deletedRow.id);
},
grounding() {
this.$confirm('是否上架本条数据', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$message({
type: 'success',
message: '上架成功!'
});
}).catch(() => {
this.$message({
type: 'info',
message: '已取消上架'
});
});
},
Offshelf() {
this.$confirm('是否下架本条数据', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$message({
type: 'success',
message: '删除成功!'
});
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
});
},
posteid(data) {
eitList(data).then(res => {
if (res.code == 200) {
this.$message.success('操作成功!');
} else {
this.$message.error('修改失败请稍后再试');
}
})
},
gettj() {
getListtj().then(res => {
this.tjdata = res.data
})
},
daking() {
this.centerDialogVisible = true
this.ruleForm = {
activateStatus: '0',
quantity: '1',
cardAmount: '1',
remark: '',
}
},
addBlock() {
//表单校验
this.$refs['ruleForm'].validate(valid => {
if (valid) {
if (this.ruleForm.membershipLevel) {
this.ruleForm.membershipLevel = this.ruleForm.membershipLevel.toString()
}
if (this.ruleForm.oilNumber) {
this.ruleForm.oilNumber = this.ruleForm.oilNumber.toString()
}
let productIds = this.ruleForm.productIdList + ''
this.ruleForm.availableWeek = this.weekDay + ''
this.ruleForm.availableDay = this.monthDay + ''
this.ruleForm.unAvailableWeek = this.weekDay1 + ''
this.ruleForm.unAvailableDay = this.monthDay1 + ''
this.ruleForm.productIds = productIds
if (!this.ruleForm.id) {
addCardCoupon(this.ruleForm).then(res => {
if (res.code == 200) {
this.$message.success('添加成功');
this.gettj()
this.getlist()
this.centerDialogVisible = false
} else {
this.$message.error('操作失败请稍后再试');
}
});
} else {
editCardCoupon(this.ruleForm).then(res => {
if (res.code == 200) {
this.$message.success('修改成功');
this.gettj()
this.getlist()
this.centerDialogVisible = false
} else {
this.$message.error('操作失败请稍后再试');
}
}).catch().catch(error => {
this.$message.error('操作失败请稍后再试');
});
}
}
});
}
}
}
</script>
<style scoped lang="scss">
.tj {
width: 100%;
display: flex;
justify-content: space-between;
}
.containers_app{
}
.box-der {
box-sizing: border-box;
padding: 15px;
}
.kar {
width: 100%;
background: #FFFFFF;
margin-bottom: 10px;
}
.d-b {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
margin-bottom: 10px;
}
.one-size {
font-size: 20px;
font-weight: bold;
color: #000;
}
.two-size {
font-size: 20px;
font-weight: bold;
color: #78b0fb;
}
.three-size {
font-size: 20px;
font-weight: bold;
color: #f73f3f;
}
.ds {
width: 100%;
display: flex;
align-items: center;
background: #f4f4f4;
border-radius: 6px;
margin-bottom: 15px;
box-sizing: border-box;
padding: 15px 5px;
}
.tj-text {
font-size: 18px;
font-weight: bold;
}
.tj-num {
margin: 5px auto;
//font-size: 28px;
color: #666;
text-align: center;
}
.tj-siez {
margin: 5px auto;
color: #909399;
font-size: 14px;
text-align: center;
}
.top-hang {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 15px;
}
.d-s {
display: flex;
}
.butoon {
box-sizing: border-box;
padding: 6px 10px;
border: 1px solid #fe8c4a;
border-radius: 6px;
font-size: 16px;
margin-left: 15px;
}
.sshi {
width: 33%;
background: #FFFFFF;
box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
box-sizing: border-box;
padding: 15px;
border-radius: 6px;
//background: #f9f9f9;
}
.tjaocuo {
width: 100%;
margin-bottom: 15px;
display: flex;
justify-content: space-between;
}
.title_ {
width: 100%;
display: flex;
align-items: center;
font-size: 20px;
font-weight: bold;
justify-content: center;
margin-bottom: 20px;
}
.card-boxs {
width: 100%;
height: 83.5vh;
background: #fff;
box-sizing: border-box;
padding: 15px;
border-radius: 10px;
}
.icon-type {
display: flex;
align-items: center;
font-weight: 400;
font-size: 14px;
color: #999999;
margin-right: 20px;
cursor: pointer;
}
.acvtive {
color: #FF770F !important;
}
.malou {
width: 60px;
}
.dialog-lift{
width: 48%;
}
.dialog-right{
width: 48%;
}
</style>