Commit 3609929e authored by Mac's avatar Mac

套餐卡

parent cdc56c6e
......@@ -169,6 +169,12 @@
<li class="menu_item" :class="{'Fchecked':isChecked=='/offlineSetup'}" @click="isChecked='/offlineSetup',CommonJump('offlineSetup')">
<i class="el-icon-menu"></i><span>基本设置</span>
</li>
<li class="menu_item" :class="{'Fchecked':isChecked=='/osMealCardmanage'}" @click="isChecked='/osMealCardmanage',CommonJump('osMealCardmanage')">
<i class="el-icon-menu"></i><span>套餐卡</span>
</li>
<li class="menu_item" :class="{'Fchecked':isChecked=='/osCardrelease'}" @click="isChecked='/osCardrelease',CommonJump('osCardrelease')">
<i class="el-icon-menu"></i><span>套餐卡自动发放</span>
</li>
</ul>
</div>
......
<template>
<div class="osAddcardrelease">
<div class="form-box" style="margin-top: 0">
<div>
<span style="color: rgb(64, 158, 255);cursor: pointer;margin-left: 20px" @click="cancel">自动发放套餐卡券</span>
<span style="margin: 0 5px;color: #C0C4CC;">/</span>
<span>自动发放套餐卡券编辑</span>
</div>
</div>
<div class="el-card__body" style="background-color: white; padding: 15px 50% 15px 0 ;margin-top: 20px">
<el-form :model="msg" style="padding:0 20px;" :rules="rules" ref="msg" label-width="160px" size="small">
<el-form-item label="触发事件" class="is-required" style="width: 50%">
<el-select v-model="msg.TriggerType" placeholder="请选择">
<el-option
v-for="item in options"
:key="item.Id"
:label="item.Name"
:value="item.Id">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="发放的套餐卡券" class="is-required" style="width: 50%">
<el-select v-model="msg.DiscountCouponId" placeholder="请选择">
<el-option
v-for="item in options2"
:key="item.ID"
:label="item.Name"
:value="item.ID">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="发放次数" prop="GrantNum" class="is-required">
<el-tooltip class="item" effect="dark" content="每个用户可发放次数;如不限制发放次数,请填写0" placement="top"
style="position: absolute;left: -10px;top:10px">
<i class="el-tooltip el-icon-info"></i>
</el-tooltip>
<el-input v-model="msg.GrantNum" class="el-input--small" :disabled="checked" step="1" min="0" onkeyup="this.value= this.value.match(/\d+(\d{0,2})?/) ? this.value.match(/\d+(\d{0,2})?/)[0] : ''" style="width: 30%;"/>
<el-checkbox v-model="checked" @change="checked==true? msg.GrantNum=0:msg.GrantNum=1" style="margin-left: 10px">无限制</el-checkbox>
</el-form-item>
<el-form-item label="领取人" >
<el-radio-group v-model="msg.IsAll" >
<el-radio :label="0">所有用户</el-radio>
<el-radio :label="1">指定用户</el-radio>
<button class="el-button el-button--text" v-if="msg.IsAll ==1" @click="choice">选择用户</button>
</el-radio-group>
<div style="flex-wrap: wrap;" flex="dir:left">
<div flex="dir:top cross:center" class="user-item" v-for="(item,index) in UserList" :label="item.Id" :key="index">
<img :src="item.Photo" alt="" class="avatar">
<div class="username">{{item.Name}}</div>
<button type="button" class="el-button close el-button--danger is-circle" @click="delUserList(index)"><i class="el-icon-close"></i></button>
</div>
</div>
</el-form-item>
</el-form>
</div>
<el-button type="primary" style="margin: 12px 0 " @click="preserve('msg')" :loading="loading2">保存</el-button>
<!--选择用户-->
<el-dialog title="选择用户" :visible.sync="category" width="612px">
<div class="el-input el-input--small el-input-group el-input-group--append">
<input type="text" autocomplete="off" placeholder="输入用户ID、昵称搜索" class="el-input__inner" v-model="msg_t.Name">
<div class="el-input-group__append"><button type="button" class="el-button el-button--default" @click="search"><!----><!----><span>搜索</span></button></div>
</div>
<el-table
:data="tableData"
tooltip-effect="dark"
style="width: 100%"
v-loading="loading"
@selection-change="handleSelectionChange">
<el-table-column
type="selection"
width="55">
</el-table-column>
<el-table-column
prop="Id"
label="ID"
width="176">
</el-table-column>
<el-table-column
label="所在平台"
width="174">
<template slot-scope="scope">
<img v-if="scope.row.Source==1" style="width:24px;height:24px" src="../../assets/img/statistics/wechat.png" alt="" class="platform-img">
<img v-if="scope.row.Source==2" style="width:24px;height:24px" src="../../assets/img/statistics/zhifubao.png" alt="" class="platform-img">
<img v-if="scope.row.Source==3" style="width:24px;height:24px" src="../../assets/img/statistics/douyin.png" alt="" class="platform-img">
<img v-if="scope.row.Source==4" style="width:24px;height:24px" src="../../assets/img/statistics/baidu.png" alt="" class="platform-img">
</template>
</el-table-column>
<el-table-column
prop="Name"
label="昵称"
show-overflow-tooltip>
</el-table-column>
</el-table>
<el-pagination style="text-align:right"
background
@current-change="handleCurrentChange"
:page-size="msg_t.pageSize"
:current-page.sync="msg_t.pageIndex"
layout="prev, pager, next"
:total="count">
</el-pagination>
<div slot="footer" class="dialog-footer">
<el-button @click="category = false">取 消</el-button>
<el-button type="primary" @click="getProductList">确 定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
export default {
name: "osAddcardrelease",
data(){
return{
msg:{
ID:0,
TriggerType:0,
DiscountCouponId:0,
GrantNum:1,
IsAll:0,
UserList:[]
},
rules:{
GrantNum:[
{required: true, message: "最多发放次数不能为空", trigger: "blur"}
]
},
checked:false,
options:[],
options2:[],
Name:'',
category:false,
tableData: [],
msg_t:{
pageIndex:1,
pageSize:10,
Name:'',
SmallShopId:0,
},
count:0,
loading:false,
UserList:[],
Storage:[],
loading2:false
}
},
created(){
this.getrigger()
this.getrigger2()
setTimeout(()=>{
if(this.$route.query.ID){
this.gettRepositoryList(this.$route.query.ID)
}
},10)
},
methods:{
gettRepositoryList(ID){
this.apipost("/api/Education/GettRepositoryList",{'ID':ID} , res => {
if (res.data.resultCode == 1) {
this.msg = res.data.data
if(res.data.data.GrantNum==0){
this.checked=true
}
if(res.data.data.UserList){
this.UserList= res.data.data.UserList
for(let i = 0;i<this.UserList.length;i++){
this.UserList[i].Id = this.UserList[i].UserId
}
}
} else {
this.Info(res.data.message);
}
})
},
getrigger(){
this.apipost("/api/Coupon/GetTriggerTypeEnumList",{}, res => {
if (res.data.resultCode == 1) {
this.options = res.data.data;
this.msg.TriggerType = res.data.data[0].Id
} else {
this.Info(res.data.message);
}
})
},
getrigger2(){
this.apipost("/api/Reserve/GetAllDiscountCouponList",{}, res => {
if (res.data.resultCode == 1) {
this.options2 = res.data.data;
this.msg.DiscountCouponId = res.data.data[0].ID
} else {
this.Info(res.data.message);
}
})
},
choice(){
this.options2.forEach(x=>{
if(x.ID == this.msg.DiscountCouponId){
this.msg_t.SmallShopId = x.SmallShopId
}
})
this.category = true;
this.msg_t.pageIndex =1
this.getList()
},
getList(){
this.loading =true
this.apipost("/api/User/GetPageListByKey",this.msg_t, res => {
this.loading =false
if (res.data.resultCode == 1) {
this.tableData = res.data.data.pageData;
this.count = res.data.data.count;
} else {
this.Info(res.data.message);
}
})
},
getProductList(){
if(this.UserList.length>0){
let newStorage =[]
for(let i= 0;i<this.UserList.length;i++){
for(let j= 0;j<this.Storage.length;j++){
if(this.UserList[i].Id != this.Storage[j].Id){
newStorage.push(this.Storage[j])
}
}
}
this.UserList = this.UserList.concat(newStorage)
}else {
this.UserList = this.UserList.concat(this.Storage)
}
this.category = false;
},
search(){
this.msg_t.pageIndex =1
this.getList();
},
preserve(formName){
this.$refs[formName].validate((valid) => {
if (valid) {
let UList =[];
for(let i= 0;i<this.UserList.length;i++){
UList.push({'UserId':this.UserList[i].Id})
}
this.msg.UserList= UList
this.loading2 = true;
this.apipost("/api/Reserve/AddOrUpdateSelfMotion",this.msg, res => {
this.loading2 = false;
if (res.data.resultCode == 1) {
this.Success(res.data.message);
this.$router.go(-1);//返回上一层
} else {
this.Info(res.data.message);
}
})
} else {
return false;
}
});
},
handleSelectionChange(val){
this.Storage = val
},
handleCurrentChange(val) {
this.msg_t.pageIndex = val;
this.getList();
},
delUserList(index){
this.UserList.splice(index,1)
},
cancel(){
this.$router.go(-1)
}
}
}
</script>
<style >
.osAddcardrelease .form-box {
background: #fff;
padding: 20px 50% 20px 0;
margin-top: 10px;
}
.osAddcardrelease .el-input--small .el-input__inner{
margin-left: 10px;
height: 32px;
line-height: 32px;
}
.osAddcardrelease .form-body{
background-color: #fff;
padding: 10px 50% 10px 20px;
min-width: 1000px;
}
.osAddcardrelease .user-item {
border: 1px #eeeeee solid;
padding: 20px;
margin-right: 20px;
margin-bottom: 20px;
width: 120px;
height: 120px;
position: relative;
}
.osAddcardrelease .user-item .close {
position: absolute;
right: -10px;
top: -10px;
padding: 0;
border-radius: 100px;
width: 20px;
height: 20px;
}
.osAddcardrelease .user-item .avatar {
width: 50px;
height: 50px;
}
</style>
<template>
<div class="osAddmealcard">
<div class="form-box" style="margin-top: 0">
<div>
<span style="color: rgb(64, 158, 255);cursor: pointer;margin-left: 20px" @click="cancel">套餐卡管理</span>
<span style="margin: 0 5px;color: #C0C4CC;">/</span>
<span>套餐卡编辑</span>
</div>
</div>
<div class="el-card__body" style="background-color: white; padding: 0px;margin-top: 20px">
<el-form :model="msg" style="padding:0 20px;" :rules="rules" ref="msg" label-width="160px" size="small">
<div class="form-body">
<el-form-item label="套餐卡名称" prop="Name" class="is-required">
<el-input v-model="msg.Name" />
</el-form-item>
<el-form-item label="套餐卡图标" prop="CouponIco" class="is-required" >
<button class="el-button el-button--default el-button--small" @click="openChangeDig()">
选择图标
</button>
<div class="img_yuan inputM_l">
<img v-if="msg.CouponIco=='' || msg.CouponIco==null" src="../../assets/img/setup/default_img.png" alt="">
<img v-else :src="msg.CouponIco" alt="">
</div>
</el-form-item>
<!-- <el-form-item label="微店铺">-->
<!-- <el-select size="small" v-model="msg.SmallShopId" :filter-method="ChangeListName" filterable-->
<!-- placeholder="请选择">-->
<!-- <el-option label="不限" :value="0"></el-option>-->
<!-- <el-option v-for="item in SmallShopData" :key="item.Id" :label="item.Name" :value="item.Id">-->
<!-- </el-option>-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<!-- <el-form-item label="赞羊用户专用">-->
<!-- <el-radio-group v-model="msg.IsZanYangUse">-->
<!-- <el-radio :label="0"></el-radio>-->
<!-- <el-radio :label="1"></el-radio>-->
<!-- </el-radio-group>-->
<!-- </el-form-item>-->
<el-form-item label="加入领券中心">
<el-switch
:active-value="1"
:inactive-value="0"
v-model="msg.PickupCenter"
>
</el-switch>
</el-form-item>
<el-form-item label="指定商品类别或商品" >
<div style="display: flex;flex-direction: row;align-items: center">
<div @click="getUseType(1)" style="margin-right: 15px">
<el-radio :label="1" v-model="msg.UseType">指定商品类型</el-radio>
</div>
<div @click='getUseType(2)' style="margin-right: 15px">
<el-radio :label="2" v-model="msg.UseType">指定商品</el-radio>
</div>
<el-radio :label="3" v-model="msg.UseType" @change="getUseType2" style="margin-right: 15px">全场通用</el-radio>
<el-radio :label="4" v-model="msg.UseType" @change="getUseType2" >当面付</el-radio>
</div>
<div class="splist" v-if="msg.UseType==1">
<div v-for="(item,index) in AppointList" :label="item.ProductId" :key="index" style="margin-right: 20px;" class="el-tag el-tag--warning el-tag--plain">
<span>{{item.Name}}</span>
<i class="el-tag__close el-icon-close" @click="deleteProduct(item,index)"></i>
</div>
</div>
<div class="splist" v-if="msg.UseType==2">
<div v-for="(item,index) in commoditylist" :label="item.ProductId" :key="index" style="margin-right: 20px; position: relative; cursor: pointer;" >
<div class="app-image" :style="{backgroundImage:'url(' + item.CoverImage + ')',backgroundSize:'cover'}" ></div>
<i class="el-icon-error" style="position: absolute;right: -5px;top:-5px;color: #F56C6C;font-size: 20px" @click="deletecommod(index,1)"></i>
</div>
</div>
</el-form-item>
<el-form-item label="抵扣金额" prop="MaxDiscountsPrice" class="is-required">
<el-input v-model="msg.MaxDiscountsPrice" step="1" min="0" onkeyup="this.value= this.value.match(/\d+(\.\d{0,2})?/) ? this.value.match(/\d+(\.\d{0,2})?/)[0] : ''">
<template slot="append"></template>
</el-input>
</el-form-item>
<el-form-item label="卡券有效期" class="is-required">
<el-radio-group v-model="msg.IndateType">
<el-radio :label="1">领取后N天内有效</el-radio>
<el-radio :label="2">时间段</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="有效天数" prop="IndateDay" class="is-required" v-if="msg.IndateType==1">
<el-input v-model="msg.IndateDay" class="el-input--small" step="1" min="0" onkeyup="this.value= this.value.match(/\d+(\d{0,2})?/) ? this.value.match(/\d+(\d{0,2})?/)[0] : ''"/>
</el-form-item>
<el-form-item label="有效期范围" class="is-required" v-if="msg.IndateType==2" >
<el-date-picker
@input="daterangeChange"
style="padding: 3px 10px;width: 450px;height: 32px"
v-model.trim="msg.value"
type="datetimerange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="yyyy-MM-dd HH:mm:ss"
align="right">
</el-date-picker>
</el-form-item>
<el-form-item label="核销总次数" prop="HeXiao" class="is-required">
<el-input v-model="msg.HeXiao" class="el-input--small" placeholder="请输入整数" step="1" min="1" onkeyup="this.value= this.value.match(/\d+(\d{0,2})?/) ? this.value.match(/\d+(\d{0,2})?/)[0] : ''"/>
</el-form-item>
<el-form-item label="可领取数量" prop="TotalNum" class="is-required">
<el-tooltip class="item" effect="dark" content="可领取数量为0则无法领取或发放,-1为不限制张数" placement="top"
style="position: absolute;left: -16px;top:10px">
<i class="el-tooltip el-icon-info"></i>
</el-tooltip>
<el-input v-model="msg.TotalNum" class="el-input--small" :disabled="checked" step="1" min="0" onkeyup="this.value= this.value.match(/\d+(\d{0,2})?/) ? this.value.match(/\d+(\d{0,2})?/)[0] : ''"/>
<el-checkbox v-model="checked" @change="checked==true? msg.TotalNum=-1:msg.TotalNum=0">无限制</el-checkbox>
</el-form-item>
<el-form-item label="套餐卡描述">
<el-input
type="textarea"
:rows="2"
v-model="msg.Describe">
</el-input>
</el-form-item>
</div>
</el-form>
</div>
<el-button type="primary" style="margin: 12px 0 " @click="preserve('msg')" :loading="loading">保存</el-button>
<!--已指定商品类别选择-->
<el-dialog title="已指定商品类别" :visible.sync="category" width="714px">
<el-tree
:data="ProductCategoryTreeList"
show-checkbox
default-expand-all
node-key="Id"
ref="tree"
:default-checked-keys="checkedkeys"
@check="TreeList"
:props="defaultProps">
</el-tree>
<div slot="footer" class="dialog-footer">
<el-button @click="category = false">取 消</el-button>
<el-button type="primary" @click="getProductList">确 定</el-button>
</div>
</el-dialog>
<!--已指定商品选择-->
<el-dialog title="已指定商品" :visible.sync="commodity" width="1024px">
<template>
<button class="el-button el-button--primary el-button--small" style="float: right;" @click="addcommoditybtn">新增</button>
<el-table
:data="commoditylist"
style="width: 984px">
<el-table-column
prop="Id"
label="ID"
width="80">
</el-table-column>
<el-table-column
label="商品图"
width="80">
<template slot-scope="scope">
<img style="width:50px;height:50px;margin-right:1px" :src="scope.row.CoverImage" alt="">
</template>
</el-table-column>
<el-table-column
prop="Name"
label="商品名称"
width="604">
</el-table-column>
<el-table-column
prop="address"
label="操作"
>
<template slot-scope="scope">
<div class="cell">
<button type="button" class="el-button el-button--danger el-button--mini is-plain" @click="deletecommod(scope,2)"><span>删除</span></button>
</div>
</template>
</el-table-column>
</el-table>
</template>
</el-dialog>
<!--选择的商品列表-->
<el-dialog title="添加商品" :visible.sync="addcommodity" width="1024px">
<template>
<div class="el-form-item">
<div class="el-form-item__content" >
<div class="el-input el-input--small" style="width: 40%;" >
<input type="text" autocomplete="off" placeholder="商品名称" class="el-input__inner" v-model="msg2.Name"
@clear="msg2.pageIndex=1,getProductGoodsPageList()"
clearable
>
</div>
<button type="button" class="el-button el-button--default el-button--small" style="margin-left: 15px" @click="msg2.pageIndex=1,getProductGoodsPageList()">查找商品</button>
<button class="el-button el-button--default el-button--small" style="float: right;" @click="batchAdd">批量添加</button>
</div>
</div>
<el-table
v-loading="loading_t"
:data="tableData"
@selection-change="handleSelectionChange"
style="width: 984px">
<el-table-column
type="selection"
width="55">
</el-table-column>
<el-table-column
prop="Id"
label="ID"
width="80">
</el-table-column>
<el-table-column
label="商品图"
width="80">
<template slot-scope="scope">
<img style="width:50px;height:50px;margin-right:1px" :src="scope.row.CoverImage" alt="">
</template>
</el-table-column>
<el-table-column
prop="Name"
label="商品名称"
width="333">
</el-table-column>
<el-table-column
prop="address"
label="操作"
>
<template slot-scope="scope">
<el-button type="primary" plain size="mini" @click="addtableData(scope)" :disabled="scope.row.disabled">{{scope.row.disabled==true? '已添加':'添加'}}</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination style="text-align:right"
background
@current-change="handleCurrentChange"
:page-size="msg2.pageSize"
layout="prev, pager, next"
:current-page.sync="msg2.pageIndex"
:total="count">
</el-pagination>
</template>
</el-dialog>
<!-- 选择文件 -->
<el-dialog title="选择文件" :visible.sync="changeState" width="1240px">
<ChooseImg @SelectId="SelectId" ref="mychild"></ChooseImg>
</el-dialog>
</div>
</template>
<script>
import ChooseImg from "@/components/global/ChooseImg.vue";
export default {
name: "osAddmealcard",
components: {
ChooseImg,
},
data(){
return{
msg:{
ID:0,
Name:'',
CouponType:1,
UseType:3,
MaxDiscountsPrice:0,
IndateDay:1,
IndateType:1,
TotalNum:-1,
Describe:'',
OnlyMember:0,
PickupCenter:0,
MemberLevelList:[],
ProductList:[],//指定商品类型的数组
StartDate:'',
EndDate:'',
value:[],
SmallShopId:0,//微店id
IsZanYangUse:0,
HeXiao:1,
CouponIco:"",
},
checkedkeys:[],//默认选中的
huiyuan:false,
zhongxin:true,
checked:true,
loading:false,
activeName:'first',
commodity:false,
addcommodity:false,
changeState:false,
SmallShopData:[],
rules:{
Name:[
{required: true, message: "套餐卡名称不能为空", trigger: "blur"}
],
IndateDay:[
{required: true, message: "套餐卡有效天数不能为空", trigger: "blur"}
],
MaxDiscountsPrice:[
{required: true, message: "抵扣金额不能为空", trigger: "blur"}
],
TotalNum:[
{required: true, message: "发放总数不能为空", trigger: "blur"}
],
CouponIco:[
{required: true, message: "请选择套餐卡图标", trigger: "blur"}
],
HeXiao:[
{required: true, message: "请输入可核销总次数", trigger: "blur"}
],
value:[
{ type: 'array', required: true, message: '套餐卡有效期不能为空', trigger: 'change' }
]
},
cityOptions:[],
cities: [],
checkAll: false,
isIndeterminate: false,
category:false,
ProductCategoryTreeList:[],
commoditylist:[],//商品的list
AppointList:[],//指定商品分类
defaultProps: {
children: 'ChildList',
label: 'Name'
},
eData:{},
msg2:{
pageIndex:1,
pageSize:15,
Name:'',
GoodsStatus:0,
IsSelectSellOut:0,
CategoryIds:'',
Id:0,
StartTime:'',
EndTime:'',
},
tableData:[],
loading_t:false,
count:0,
multipleSelection:[],
AppointList2:[],
SmallShopMsg:{
Name:'',
}
}
},
created(){
this.getMemberGradeList()
this.getSmallShopsDropDownList()
},
methods:{
getMemberGradeList(){
this.cityOptions=[];
this.apipost("/api/User/GetMemberGradeList",{}, res => {
this.cities=res.data.data;
let data=res.data.data;
data.forEach(item=>{
this.cityOptions.push(item.Id)
})
})
this.getProductCategoryTreeList()
},
getDiscountCouponDetail(ID){
this.apipost("/api/Reserve/GetDiscountCouponDetail",{'ID':ID} , res => {
if (res.data.resultCode == 1) {
this.msg = res.data.data
this.msg.value = []
if(res.data.data.IndateType==2){
this.msg.value.push(res.data.data.StartDate.replace("T", " "))
this.msg.value.push(res.data.data.EndDate.replace("T", " "))
}
if(res.data.data.TotalNum!=-1){
this.checked=false
}
if(res.data.data.OnlyMember==0){
this.huiyuan=false
}else {
this.huiyuan=true
}
if(res.data.data.PickupCenter==0){
this.zhongxin=false
}else {
this.zhongxin=true
}
this.msg.MemberLevelList=res.data.data.MemberLevelList?res.data.data.MemberLevelList:[];
if(this.msg.MemberLevelList){ //设置全选状态
if(this.msg.MemberLevelList.length == this.cities.length){
this.checkAll=true
}
}
if(res.data.data.UseType==1){
let ProductList = res.data.data.ProductList;
let newData = []
for(let i= 0;i<ProductList.length;i++){
this.checkedkeys.push(ProductList[i].ProductId)
for(let j=0;j<this.ProductCategoryTreeList.length;j++){
if(ProductList[i].ProductId == this.ProductCategoryTreeList[j].Id){
newData.push(this.ProductCategoryTreeList[j])
}
if(this.ProductCategoryTreeList[j].ChildList.length>0){
this.getReturn(ProductList[i],this.ProductCategoryTreeList[j].ChildList)
}
}
}
this.AppointList = this.AppointList2.concat(newData)
}
if(res.data.data.UseType==2){
let ProductList = res.data.data.ProductList;
let newData = []
for(let i= 0;i<ProductList.length;i++){
this.apipost("/api/product/GetProductGoodsPageList",
{
pageIndex:1,
pageSize:15,
Name:'',
GoodsStatus:0,
IsSelectSellOut:0,
CategoryIds:'',
Id:ProductList[i].ProductId,
StartTime:'',
EndTime:'',
}
, res => {
if(res.data.resultCode==1){
let pageData= res.data.data.pageData;
newData.push(pageData[0])
}
})
}
this.commoditylist = newData
}
} else {
this.Info(res.data.message);
}
})
},
getReturn(ProductList,data){
for(let i=0;i<data.length;i++){
if(ProductList.ProductId == data[i].Id){
this.AppointList2.push(data[i])
}
if(data[i].ChildList.length>0){
this.getReturn(ProductList,data[i].ChildList)
}
}
},
getProductCategoryTreeList(){
this.apipost("/api/AppletGoods/GetProductCategoryTreeList",{}, res => {
if (res.data.resultCode == 1) {
this.ProductCategoryTreeList = res.data.data
this.getProductGoodsPageList(1)
} else {
// this.Info(res.data.message);
}
})
},
getProductGoodsPageList(type=2){
this.loading_t =true
this.apipost("/api/product/GetProductGoodsPageList", this.msg2, res => {
this.loading_t=false;
if(res.data.resultCode==1){
let pageData= res.data.data.pageData;
for(let i= 0;i<pageData.length;i++){
pageData[i].disabled=false;
this.commoditylist.forEach(x=>{
if(pageData[i].Id == x.Id){
pageData[i].disabled=true;
}
})
}
this.tableData = pageData
this.count = res.data.data.count
}
if(type==1){
setTimeout(()=>{
if(this.$route.query.ID){
this.getDiscountCouponDetail(this.$route.query.ID)
}
},10)
}
})
},
cancel(){
this.$router.go(-1)
},
handleCheckAllChange(val) {
this.msg.MemberLevelList = val ? this.cityOptions : [];
this.isIndeterminate = false;
},
handleCheckedCitiesChange(value) {
let checkedCount = value.length;
this.checkAll = checkedCount === this.cities.length;
this.isIndeterminate = checkedCount > 0 && checkedCount < this.cities.length;
},
addtableData(data){
this.tableData[data.$index].disabled=true;
this.commoditylist.push(data.row)
this.Success('添加成功');
},
batchAdd(){ //批量添加
let newdata=[]
for(let i=0;i<this.multipleSelection.length;i++){
if(this.commoditylist.length>0){
for(let j=0;j<this.commoditylist.length;j++){
if(this.multipleSelection[i].Id!=this.commoditylist[j].Id){
newdata.push(this.multipleSelection[i])
for(let z =0;z<this.tableData.length;z++){
if(this.tableData[z].Id==this.multipleSelection[i].Id){
this.tableData[z].disabled=true;
break
}
}
}
}
}else {
newdata.push(this.multipleSelection[i])
for(let z =0;z<this.tableData.length;z++){
if(this.tableData[z].Id==this.multipleSelection[i].Id){
this.tableData[z].disabled=true;
break
}
}
}
}
if(newdata.length>0){
this.Success('添加成功');
}
this.commoditylist = this.unique(this.commoditylist.concat(newdata))
},
// 数组去重
unique(arr) {
for (var i = 0, len = arr.length; i < len; i++) {
for (var j = i + 1, len = arr.length; j < len; j++) {
if (arr[i].Id === arr[j].Id ) {
arr.splice(j, 1);
j--; // 每删除一个数j的值就减1
len--; // j值减小时len也要相应减1(减少循环次数,节省性能)
}
}
}
return arr;
},
addcommoditybtn(){
this.addcommodity=true;
for(let i=0;i<this.tableData.length;i++){
this.tableData[i].disabled= false;
for(let j=0;j<this.commoditylist.length;j++){
if(this.commoditylist[j].Id== this.tableData[i].Id){
this.tableData[i].disabled=true
}
}
}
},
deletecommod(data,type){
if(type==1){
this.commoditylist.splice(data,1)
}else {
this.commoditylist.splice(data.$index,1)
}
},
handleSelectionChange(val) {
this.multipleSelection=val
},
getUseType(val){
if(val ==1){
this.category=true;
this.$nextTick(() => {//在弹出dialog之前执行$nextTick回调函数,确保el-tree已经渲染
this.$refs.tree.setCheckedKeys(this.checkedkeys);
});
}else if(val==2){
this.checkedkeys=[]
this.commodity =true
}
},
daterangeChange(e){
let _this =this
if(e==null){
_this.msg.value = []
}else {
_this.$nextTick(() => {
_this.$set(_this.msg, "value", [e[0], e[1]]);
});
}
_this.$forceUpdate();
},
getUseType2(){
this.checkedkeys=[]
},
deleteProduct(item,index){
this.AppointList.splice(index,1)
for(let i = 0;i<this.checkedkeys.length;i++){
if(this.checkedkeys[i]==item.ProductId){
this.checkedkeys.splice(i,1)
}
}
},
handleCurrentChange(val) {
this.msg2.pageIndex = val;
this.getProductGoodsPageList();
},
TreeList(val,e){
this.eData = e
},
preserve(formName){
this.$refs[formName].validate((valid) => {
if (valid) {
if(this.msg.IndateType==2){
if(this.msg.value.length>0){
this.msg.StartDate=this.msg.value[0];
this.msg.EndDate=this.msg.value[1];
this.msg.IndateDay=0
}else {
this.Error('套餐卡有效期不能为空')
return false
}
}
if(this.msg.UseType==2){
let ProductList= []
for(let i = 0;i<this.commoditylist.length;i++){
ProductList.push({'ProductId':this.commoditylist[i].Id,})
}
this.msg.ProductList =ProductList
}else if(this.msg.UseType==1){
let ProductList= []
for(let i = 0;i<this.AppointList.length;i++){
ProductList.push({'ProductId':this.AppointList[i].ProductId,})
}
this.msg.ProductList =ProductList
}
this.loading= true
this.apipost("/api/Reserve/AddOrUpdateDiscountCoupon",this.msg , res => {
this.loading= false
if (res.data.resultCode == 1) {
this.Success(res.data.message);
this.$router.go(-1);//返回上一层
} else {
this.Info(res.data.message);
}
})
} else {
return false;
}
});
},
getProductList(){
this.category = false;
let e = this.eData;
let ProductList = this.msg.ProductList;
ProductList=[]
this.checkedkeys = e.checkedKeys;
if(e.checkedNodes.length>0){
for(let i= 0;i<e.checkedNodes.length;i++){
if(e.checkedNodes[i].ChildList.length==0){
ProductList.push({'ProductId':e.checkedNodes[i].Id,'Name':e.checkedNodes[i].Name})
}
}
}
this.AppointList= ProductList
},
ChangeListName(val) {
this.SmallShopMsg.Name = val;
this.getSmallShopsDropDownList()
},
getSmallShopsDropDownList(){
this.apipost("/api/SmallShops/GetAllSmallShopsList",this.SmallShopMsg , res => {
this.loading= false
if (res.data.resultCode == 1) {
this.SmallShopData = res.data.data
} else {
this.Info(res.data.message);
}
})
},
openChangeDig(){
this.changeState=true;
setTimeout(()=>{
this.$refs.mychild.InitData();
},10)
},
SelectId(msg){
this.changeState=false;
this.msg.CouponIco= this.getIconLink(msg.url);
},
},
mounted(){
}
}
</script>
<style >
.osAddmealcard .form-box {
background: #fff;
padding: 20px 50% 20px 0;
margin-top: 10px;
}
.osAddmealcard .el-input--small .el-input__inner{
height: 32px;
line-height: 32px;
}
.osAddmealcard .img_yuan{
width: 80px;
height: 80px;
margin-top: 5px;
position: relative;
}
.osAddmealcard .img_yuan img{
width: 100%;
height: 100%;
}
.osAddmealcard .el-date-editor .el-range__icon {
line-height: 24px;
}
.osAddmealcard .el-date-editor .el-range-separator{
line-height: 24px;
}
.osAddmealcard .el-date-editor .el-range__close-icon{
line-height: 24px;
}
.osAddmealcard .el-form-item__label{
padding: 0 20px 0 0;
}
.osAddmealcard .form-body{
background-color: #fff;
padding: 10px 50% 10px 20px;
min-width: 1000px;
}
.osAddmealcard .splist{
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.osAddmealcard .app-image{
width: 50px;
height: 50px;
border-radius: 0%;
background-position: center center;
}
</style>
<template>
<div class="osCardrelease">
<div class="el-card__header">
<span>自动发放</span>
<div style="display: flex;flex-direction: row;align-items: center">
<el-button type="primary" class="el-button--small" @click="addRecharge">添加自动发放方案</el-button>
</div>
</div>
<div style="padding: 20px;background: #fff;">
<el-table
:data="tableData"
header-cell-class-name="headClass"
style="100%"
border
v-loading="loading"
>
<el-table-column
prop="ID"
label="ID">
</el-table-column>
<el-table-column
prop="TriggerTypeStr"
label="触发事件">
</el-table-column>
<el-table-column
prop="DiscountCouponName"
label="套餐卡">
</el-table-column>
<el-table-column
prop="GrantNum"
label="发放次数限制">
<template slot-scope="scope">
<div v-if="scope.row.GrantNum==0">
无限制
</div>
<div v-if="scope.row.GrantNum>0">
{{scope.row.GrantNum}}
</div>
</template>
</el-table-column>
<el-table-column
fixed="right"
label="操作"
>
<template slot-scope="scope">
<el-tooltip class="item" effect="dark" content="编辑" placement="top" >
<img src="../../assets/img/setup/edit.png" alt="" class="imgstyle" @click="Edit(scope.row)">
</el-tooltip>
<el-tooltip class="item" effect="dark" content="删除" placement="top" >
<img src="../../assets/img/setup/del.png" alt="" class="imgstyle" @click="delete_b(scope.row)">
</el-tooltip>
</template>
</el-table-column>
</el-table>
<el-pagination style="text-align:right"
background
@current-change="handleCurrentChange"
:page-size="msg.pageSize"
layout="prev, pager, next"
:total="count">
</el-pagination>
</div>
</div>
</template>
<script>
export default {
name: "osCardrelease",
data(){
return{
msg:{
pageIndex:1,
pageSize:20,
},
tableData:[],
count:0,
loading:false
}
},
created(){
this.getDateList();
},
methods:{
getDateList(){
this.loading=true;
this.apipost("/api/Reserve/GetSelfMotionPageList", this.msg, res => {
this.loading=false;
if(res.data.resultCode==1){
this.tableData = res.data.data.pageData;
this.count = res.data.data.count;
}else {
this.Info(res.data.message);
}
})
},
addRecharge(){
this.$router.push('/osAddcardrelease');
},
Edit(row){
this.$router.push({
name: 'osAddcardrelease',
query: {
ID:row.ID,
blank: "y"
}
});
},
delete_b(row){
let that=this;
that.Confirm("是否删除?", function () {
that.apipost(
"/api/Reserve/DelDiscountSelfMotion",
{Id:row.ID},
res => {
if (res.data.resultCode == 1) {
that.Success(res.data.message);
that.getDateList();
} else {
that.Error(res.data.message);
}
},
);
});
},
handleCurrentChange(val) {
this.msg.pageIndex = val;
this.getDateList();
},
}
}
</script>
<style >
.osCardrelease .el-card__header{
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
background: #fff;
}
.osCardrelease .el-button--small{
padding: 9px 15px;
}
.osCardrelease .content .searchInput{
border: 1px solid #DCDFE6;
border-radius: 4px;
margin-left: 20px;
}
.osCardrelease .content .searchInput .el-input__inner{
border:none;outline:none;
height: 30px;
line-height: 30px;
}
.osCardrelease .content .searchInput{
line-height: normal;
display: inline-table;
border-collapse: separate;
border-spacing: 0;
width:250px;
}
.osCardrelease .content{
background: #fff;
margin-top:10px;
padding: 15px;
box-sizing: border-box;
}
</style>
<template>
<div class="osMealCardmanage">
<div class="el-card__header">
<span>套餐卡管理</span>
<div style="display: flex;flex-direction: row;align-items: center">
<el-button type="primary" class="el-button--small" @click="addRecharge">新增</el-button>
</div>
</div>
<div class="content">
<div style="display: flex;flex-direction: row;align-items: center">
<div class="block">
<div class="searchInput" style="width:250px">
<el-input style="display:inline-block;width:225px;height:30px"
placeholder="请输入套餐卡名称搜索"
v-model="msg.Name"
size="small"
@clear="getList"
@keyup.enter.native="getList"
clearable>
</el-input>
<span @click="getList" class="el-icon-search" style="color:#979dad;font-size:14px;position:relative;top:1px"></span>
</div>
</div>
</div>
</div>
<div style="padding: 20px;background: #fff;">
<el-table
:data="tableData"
header-cell-class-name="headClass"
style="width: 100%"
border
>
<el-table-column
prop="ID"
label="ID"
width="100">
</el-table-column>
<el-table-column
prop="Name"
label="套餐卡信息">
<template slot-scope="scope">
<div class="app-image" :style="{backgroundImage:'url(' + scope.row.CouponIco + ')',backgroundSize:'cover'}"></div>
<div flex="dir:left cross:center">
{{scope.row.Name}}
</div>
</template>
</el-table-column>
<el-table-column
prop="HeXiao"
label="可用次数">
</el-table-column>
<el-table-column
label="有效时间"
prop="StartDate">
<template slot-scope="scope">
<div v-if="scope.row.IndateType==1">领取后{{scope.row.IndateDay}}天内有效</div>
<div v-if="scope.row.IndateType==2">开始时间:{{scope.row.StartDate}}</div>
<div v-if="scope.row.IndateType==2">结束时间:{{scope.row.EndDate}}</div>
</template>
</el-table-column>
<el-table-column
label="使用范围"
prop="UseTypeStr">
</el-table-column>
<el-table-column
label="添加日期"
prop="CreateDate">
</el-table-column>
<el-table-column
label="加入领券中心 "
width="120">
<!--PickupType-->
<template slot-scope="scope">
<el-switch
@change="dianswitch(scope.row)"
:active-value="1"
:inactive-value="0"
v-model="scope.row.PickupCenter"
>
</el-switch>
</template>
</el-table-column>
<el-table-column
fixed="right"
label="操作"
width="180"
>
<template slot-scope="scope">
<el-tooltip class="item" effect="dark" content="发放优惠券" placement="top" >
<img src="../../assets/img/setup/send.png" alt="" class="imgstyle" @click="grant(scope.row)">
</el-tooltip>
<el-tooltip class="item" effect="dark" content="编辑" placement="top" >
<img src="../../assets/img/setup/edit.png" alt="" class="imgstyle" @click="Edit(scope.row)">
</el-tooltip>
<el-tooltip class="item" effect="dark" content="删除" placement="top" >
<img src="../../assets/img/setup/del.png" alt="" class="imgstyle" @click="delete_b(scope.row)">
</el-tooltip>
</template>
</el-table-column>
</el-table>
<el-pagination style="text-align:right"
background
@current-change="handleCurrentChange"
:page-size="msg.pageSize"
layout="prev, pager, next"
:current-page.sync="msg.pageIndex"
:total="count">
</el-pagination>
</div>
</div>
</template>
<script>
export default {
name: "osMealCardmanage",
data(){
return{
msg:{
pageIndex:1,
pageSize:20,
Name:'',
},
tableData:[],
count:0,
loading:false
}
},
created(){
this.getDateList();
},
methods:{
getDateList(){
this.loading=true;
this.apipost("/api/Reserve/GetDiscountCouponPageList", this.msg, res => {
this.loading=false;
if(res.data.resultCode==1){
this.tableData = res.data.data.pageData;
this.count = res.data.data.count;
}else {
this.Info(res.data.message);
}
})
},
addRecharge(){
this.$router.push('/osAddmealcard');
},
grant(row){
var arr=JSON.stringify(row)
this.$router.push({
name: 'osedgrantCouPon',
query: {
row
}
});
},
Edit(row){
this.$router.push({
name: 'osAddmealcard',
query: {
ID:row.ID,
blank: "y"
}
});
},
delete_b(row){
let that=this;
that.Confirm("是否删除?", function () {
that.apipost(
"/api/Reserve/DelDiscountCoupon",
{Id:row.ID},
res => {
if (res.data.resultCode == 1) {
that.Success(res.data.message);
that.getDateList();
} else {
that.Error(res.data.message);
}
},
);
});
},
SetUp(){
this.$router.push('/rechargeSet');
},
getList(){
this.msg.pageIndex = 1
this.getDateList()
},
dianswitch(row){
this.apipost("/api/Reserve/UpdatePickupType", {'Id':row.ID}, res => {
if(res.data.resultCode==1){
this.Success(res.data.message);
}else {
this.Info(res.data.message);
}
})
},
handleCurrentChange(val) {
this.msg.pageIndex = val;
this.getDateList();
},
},
}
</script>
<style >
.osMealCardmanage .el-card__header{
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
background: #fff;
}
.osMealCardmanage .el-button--small{
padding: 9px 15px;
}
.osMealCardmanage .content .searchInput{
border: 1px solid #DCDFE6;
border-radius: 4px;
margin-left: 20px;
}
.osMealCardmanage .content .searchInput .el-input__inner{
border:none;outline:none;
height: 30px;
line-height: 30px;
}
.osMealCardmanage .content .searchInput{
line-height: normal;
display: inline-table;
border-collapse: separate;
border-spacing: 0;
width:250px;
}
.osMealCardmanage .content{
background: #fff;
margin-top:10px;
padding: 15px;
box-sizing: border-box;
}
.osMealCardmanage .app-image{
background-position: center center;
width: 50px;
height: 50px;
border-radius:0%;
float: left;
margin-right: 8px;
}
</style>
<template>
<div class="osedgrantCouPon">
<div class="form-box" style="margin-top: 0">
<div>
<span style="color: rgb(64, 158, 255);cursor: pointer;margin-left: 20px" @click="cancel">套餐卡管理</span>
<span style="margin: 0 5px;color: #C0C4CC;">/</span>
<span>套餐卡发放</span>
</div>
</div>
<div class="el-card__body" style="background-color: white; padding: 15px 50% 15px 0 ;margin-top: 20px">
<el-form :model="msg" style="padding:0 20px;" :rules="rules" ref="msg" label-width="160px" size="medium">
<el-form-item label="套餐卡名称">
<span>{{record.Name}}</span>
</el-form-item>
<el-form-item label="剩余数量">
<div v-if="record.TotalNum ==-1">{{record.TotalNum ==-1? '无限制领取':record.TotalNum}}</div>
<div v-if="record.TotalNum !=-1">{{record.TotalNum}}</div>
</el-form-item>
<el-form-item label="套餐卡有效期">
<div v-if="record.IndateType==1">领取后{{record.IndateDay}}天内有效</div>
<div v-if="record.IndateType==2">开始时间:{{record.StartDate}}</div>
<div v-if="record.IndateType==2">结束时间:{{record.EndDate}}</div>
</el-form-item>
<el-form-item label="发送数量" prop="GrantNum">
<el-input v-model="msg.GrantNum" size="small" style="width: 40%" step="1" min="0" onkeyup="this.value= this.value.match(/\d+(\d{0,2})?/) ? this.value.match(/\d+(\d{0,2})?/)[0] : ''"/>
</el-form-item>
<el-form-item label="发放对象" >
<el-tooltip class="item" effect="dark" content="请输入昵称/ID/手机号查找用户" placement="top"
style="position: absolute;left: -10px;top:10px">
<i class="el-tooltip el-icon-info"></i>
</el-tooltip>
<el-input v-model="AliasName" style="width: 20%;margin-left: 5px" placeholder="昵称/ID/手机号" size="small"/>
<el-button :loading="loading" @click="lookup" size="small">查找用户</el-button>
<div style="width: 80%;display: flex;flex-direction: row;flex-wrap: wrap;margin-top: 5px" v-if="ByPhone.length>0">
<el-checkbox-group v-model="msg.UserIds" @change = 'SelectBy'>
<el-checkbox-button v-for="(item,index) in ByPhone" :label="item.Id" :key="index" >
<img :src="item.Photo" alt="" class="avatar">
<div class="username">{{item.AliasName}}</div>
</el-checkbox-button>
</el-checkbox-group>
</div>
<div style="width: 30%;display: flex;flex-direction: row;margin-top: 5px;justify-content: center;color: #666666" v-if="ByPhone.length==0">暂无数据~</div>
</el-form-item>
</el-form>
</div>
<el-button type="primary" style="margin: 12px 0 " @click="preserve('msg')" :loading="loading2">保存</el-button>
<el-button @click="cancel">取消</el-button>
</div>
</template>
<script>
export default {
name: "osedgrantCouPon",
data(){
return{
record:{},
msg:{
GrantNum:0,
UserIds:[],
},
AliasName:'',
rules:{
GrantNum:[
{ validator: this.DiscountsPrice, trigger: 'blur' }
]
},
loading:false,
loading2:false,
ByPhone:[],
}
},
created(){
if(this.$route.query.row){
this.record = this.$route.query.row
}
},
methods:{
cancel(){
this.$router.go(-1)
},
lookup(){
this.msg.UserIds = [];//重新选择的时候清楚之前的
this.loading = true;
this.apipost("/api/User/GetListByPhoneOrAliasName",{'AliasName':this.AliasName,SmallShopId:this.record.SmallShopId}, res => {
this.loading = false;
if (res.data.resultCode == 1) {
this.ByPhone = res.data.data
} else {
this.Info(res.data.message);
}
})
},
SelectBy(val){
this.msg.UserIds = val
},
DiscountsPrice(rule, value, callback) {
if(value>0){
return callback();
}else {
return callback(new Error('发送数量需大于零'));
}
},
preserve(formName){
this.$refs[formName].validate((valid) => {
if (valid) {
let UserIds = ''
if(this.msg.UserIds.length>0){
UserIds = this.msg.UserIds.join(",")
}
let data = {
ID: this.record.ID,
GrantNum :this.msg.GrantNum,
UserIds:UserIds,
}
this.apipost("/api/Reserve/GrantCoupon",data, res => {
this.loading2 = false;
if (res.data.resultCode == 1) {
this.Success(res.data.message);
this.$router.go(-1);//返回上一层
} else {
this.Info(res.data.message);
}
})
} else {
return false;
}
});
}
}
}
</script>
<style >
.osedgrantCouPon .form-box {
background: #fff;
padding: 18px 50% 18px 0;
margin-top: 10px;
}
.osedgrantCouPon .el-input--small .el-input__inner{
height: 32px;
line-height: 32px;
}
.osedgrantCouPon .username{
margin-top: 10px;
font-size: 13px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.osedgrantCouPon .el-checkbox-button__inner {
border: 1px solid #e2e2e2;
height: 125px;
width: 120px;
padding-top: 15px;
text-align: center;
margin: 0 20px 20px 0;
cursor: pointer;
border-radius: 0!important;
}
.osedgrantCouPon .el-checkbox-button, .el-checkbox-button__inner{
display: inline-block;
position: relative;
}
.osedgrantCouPon .avatar {
height: 60px;
width: 60px;
border-radius: 30px;
}
</style>
......@@ -343,7 +343,37 @@ export default new Router({
path: '/offlineSetup',
name: 'offlineSetup',
component: resolve => require(['@/components/offlineService/offlineSetup'], resolve),
}
},
//线下 套餐卡列表
{
path: '/osMealCardmanage',
name: 'osMealCardmanage',
component: resolve => require(['@/components/offlineService/osMealCardmanage'], resolve),
},
//线下 套餐卡编辑
{
path: '/osAddmealcard',
name: 'osAddmealcard',
component: resolve => require(['@/components/offlineService/osAddmealcard'], resolve),
},
//线下 套餐卡自动发放
{
path: '/osCardrelease',
name: 'osCardrelease',
component: resolve => require(['@/components/offlineService/osCardrelease'], resolve),
},
//线下 套餐卡自动发放编辑
{
path: '/osAddcardrelease',
name: 'osAddcardrelease',
component: resolve => require(['@/components/offlineService/osAddcardrelease'], resolve),
},
//线下 套餐卡发放
{
path: '/osedgrantCouPon',
name: 'osedgrantCouPon',
component: resolve => require(['@/components/offlineService/osedgrantCouPon'], resolve),
},
]
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment