Commit 1dfde597 authored by zhangjianguo's avatar zhangjianguo

优惠券

parent 3e85bb52
This diff is collapsed.
......@@ -34,9 +34,8 @@
<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 msg.ProductList" :label="item.ProductId" :key="index" style="margin-right: 20px;" class="el-tag el-tag--warning el-tag--plain">
<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>
......@@ -297,7 +296,7 @@
ProductList:[],//指定商品类型的数组
StartDate:'',
EndDate:'',
value:'',
value:[],
},
checkedkeys:[],//默认选中的
huiyuan:false,
......@@ -338,6 +337,7 @@
category:false,
ProductCategoryTreeList:[],
commoditylist:[],//商品的list
AppointList:[],//指定商品分类
defaultProps: {
children: 'ChildList',
label: 'Name'
......@@ -357,13 +357,14 @@
tableData:[],
loading_t:false,
count:0,
multipleSelection:[]
multipleSelection:[],
AppointList2:[],
}
},
created(){
this.getMemberGradeList()
this.getProductCategoryTreeList()
this.getProductGoodsPageList()
},
......@@ -401,6 +402,24 @@
}else {
this.zhongxin=true
}
this.msg.MemberLevelList=res.data.data?res.data.data:[];
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 = []
......@@ -411,21 +430,30 @@
}
}
}
console.log(ProductList)
console.log(this.tableData)
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()
} else {
// this.Info(res.data.message);
}
......@@ -547,7 +575,7 @@
},
getUseType(val){
if(val ==1){
this.category=true
this.category=true;
this.$nextTick(() => {//在弹出dialog之前执行$nextTick回调函数,确保el-tree已经渲染
this.$refs.tree.setCheckedKeys(this.checkedkeys);
});
......@@ -560,7 +588,7 @@
this.checkedkeys=[]
},
deleteProduct(item,index){
this.msg.ProductList.splice(index,1)
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)
......@@ -589,6 +617,12 @@
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.apipost("/api/Coupon/AddOrUpdateDiscountCoupon",this.msg , res => {
this.loading= false
......@@ -619,9 +653,12 @@
}
}
}
this.msg.ProductList= ProductList
this.AppointList= ProductList
}
},
mounted(){
}
}
</script>
......
<template>
<div class="autorelease">
发放
<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="width: 1707px;"
border
:v-loading="loading"
>
<el-table-column
prop="ID"
label="ID"
width="343">
</el-table-column>
<el-table-column
prop="TriggerTypeStr"
label="触发事件"
width="341">
</el-table-column>
<el-table-column
prop="DiscountCouponName"
label="优惠券"
width="341">
</el-table-column>
<el-table-column
prop="GrantNum"
label="发放次数限制"
width="341">
<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: "autorelease"
name: "autorelease",
data(){
return{
msg:{
pageIndex:1,
pageSize:20,
},
tableData:[],
count:0,
loading:false
}
},
created(){
this.getDateList();
},
methods:{
getDateList(){
this.loading=true;
this.apipost("/api/Coupon/GetSelfMotionPageLis", 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('/addAutoreleaseCoupon');
},
Edit(row){
this.$router.push({
name: 'addAutoreleaseCoupon',
query: {
ID:row.ID,
blank: "y"
}
});
},
delete_b(row){
let that=this;
that.Confirm("是否删除?", function () {
that.apipost(
"/api/Coupon/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 scoped>
<style >
.autorelease .el-card__header{
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
background: #fff;
}
.autorelease .el-button--small{
padding: 9px 15px;
}
.autorelease .content .searchInput{
border: 1px solid #DCDFE6;
border-radius: 4px;
margin-left: 20px;
}
.autorelease .content .searchInput .el-input__inner{
border:none;outline:none;
height: 30px;
line-height: 30px;
}
.autorelease .content .searchInput{
line-height: normal;
display: inline-table;
border-collapse: separate;
border-spacing: 0;
width:250px;
}
.autorelease .content{
background: #fff;
margin-top:10px;
padding: 15px;
box-sizing: border-box;
}
</style>
......@@ -99,7 +99,7 @@
>
<template slot-scope="scope">
<el-tooltip class="item" effect="dark" content="发放优惠券" placement="top" >
<img src="../../assets/img/setup/send.png" alt="" class="imgstyle" @click="Edit(scope.row)">
<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)">
......@@ -158,6 +158,15 @@
this.$router.push('/addCoupon');
},
grant(row){
var arr=JSON.stringify(row)
this.$router.push({
name: 'grantCouPon',
query: {
row
}
});
},
Edit(row){
this.$router.push({
name: 'addCoupon',
......
<template>
<div class="grantCouPon">
<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="最低消费金额(元)">
<span>{{record.MinConsumePrice}}</span>
</el-form-item>
<el-form-item label="优惠金额(元)">
<span>{{record.DiscountsPrice}}</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.ResidueNum}}</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" 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>
</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: "grantCouPon",
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.loading = true;
this.apipost("/api/User/GetListByPhoneOrAliasName",{'AliasName':this.AliasName}, 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/Coupon/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 >
.grantCouPon .form-box {
background: #fff;
padding: 18px 50% 18px 0;
margin-top: 10px;
}
.grantCouPon .el-input--small .el-input__inner{
height: 32px;
line-height: 32px;
}
.grantCouPon .username{
margin-top: 10px;
font-size: 13px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.grantCouPon .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;
}
.grantCouPon .el-checkbox-button, .el-checkbox-button__inner{
display: inline-block;
position: relative;
}
.grantCouPon .user-list .avatar {
height: 60px;
width: 60px;
border-radius: 30px;
}
</style>
......@@ -152,7 +152,7 @@
<el-input v-model="msg.LongAndLat" :disabled="true" class="inputM_l"/>
</el-form-item>
<el-form-item label="地图" style="margin-top: 15px" label-width="80px">
<button class="el-button el-button--default el-button--small inputM_l">
<button class="el-button el-button--default el-button--small inputM_l" @click="isShowMap=true">
展开地图
</button>
</el-form-item>
......@@ -898,19 +898,24 @@
<el-button size="small" type="danger" @click="getChoiceLink()">确 定</el-button>
</span>
</el-dialog>
<!-- 地图选址 -->
<el-dialog title="地图展示" :visible.sync="isShowMap" width="960px">
<commonMap @map-submit="mapEvent"></commonMap>
</el-dialog>
</div>
</template>
<script>
import ChooseImg from "@/components/global/ChooseImg.vue";
import chooseMeun from "../common/chooseMeun.vue";
import commonMap from "../common/commonMap.vue";
export default {
name: "basicSetUp",
components: {
ChooseImg,
chooseMeun
chooseMeun,
commonMap
},
data() {
return {
......@@ -994,6 +999,7 @@
ConsultWay: [],
},
isShowMap:false,
isShowLink:false,
Choiceimg:0,
changeState:false,
......@@ -1148,6 +1154,14 @@
return callback();
}
},
//得到地图信息
mapEvent(e) {
this.msg.LongAndLat =e.lat + ',' + e.long;
this.msg.Address =e.address;
this.isShowMap=false;
},
//获取选择链接
getChoiceLink(){
//调用子组件方法
......
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