Commit ffb47658 authored by zhangjianguo's avatar zhangjianguo

优惠券的新增 修改 和删除

parent 62832c9f
...@@ -147,11 +147,12 @@ ...@@ -147,11 +147,12 @@
this.apipost("/api/Coupon/GetCouponDetail",{'ID':ID} , res => { this.apipost("/api/Coupon/GetCouponDetail",{'ID':ID} , res => {
if (res.data.resultCode == 1) { if (res.data.resultCode == 1) {
this.msg = res.data.data this.msg = res.data.data
this.msg.value = '' this.msg.value = []
if(res.data.data.IndateType==2){ if(res.data.data.IndateType==2){
this.msg.value.push(res.data.data.StartDate) this.msg.value.push(res.data.data.StartDate.replace("T", " "))
this.msg.value.push(res.data.data.EndDate) this.msg.value.push(res.data.data.EndDate.replace("T", " "))
} }
console.log(this.msg.value)
if(res.data.data.TotalNum!=-1){ if(res.data.data.TotalNum!=-1){
this.checked=false this.checked=false
} }
......
...@@ -24,12 +24,30 @@ ...@@ -24,12 +24,30 @@
</el-form-item> </el-form-item>
<el-form-item label="指定商品类别或商品" > <el-form-item label="指定商品类别或商品" >
<el-radio-group v-model="msg.UseType" @change="getUseType"> <div style="display: flex;flex-direction: row;align-items: center">
<el-radio :label="1">指定商品类型</el-radio> <div @click="getUseType(1)" style="margin-right: 15px">
<el-radio :label="2">指定商品</el-radio> <el-radio :label="1" v-model="msg.UseType">指定商品类型</el-radio>
<el-radio :label="3">全场通用</el-radio> </div>
<el-radio :label="4">当面付</el-radio> <div @click='getUseType(2)' style="margin-right: 15px">
</el-radio-group> <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 msg.ProductList" :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(' + domainManager().ImageUrl+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>
<el-form-item label="最低消费金额(元)" prop="MinConsumePrice" class="is-required"> <el-form-item label="最低消费金额(元)" prop="MinConsumePrice" class="is-required">
<el-tooltip class="item" effect="dark" content="购物金额(不含运费)达到最低消费金额才可使用优惠券,无门槛优惠券请填0" placement="top" <el-tooltip class="item" effect="dark" content="购物金额(不含运费)达到最低消费金额才可使用优惠券,无门槛优惠券请填0" placement="top"
...@@ -83,13 +101,13 @@ ...@@ -83,13 +101,13 @@
</el-date-picker> </el-date-picker>
</el-form-item> </el-form-item>
<el-form-item label="可领取数量" prop="ReceiveNum" class="is-required"> <el-form-item label="可领取数量" prop="TotalNum" class="is-required">
<el-tooltip class="item" effect="dark" content="可领取数量为0则无法领取或发放,-1为不限制张数" placement="top" <el-tooltip class="item" effect="dark" content="可领取数量为0则无法领取或发放,-1为不限制张数" placement="top"
style="position: absolute;left: -16px;top:10px"> style="position: absolute;left: -16px;top:10px">
<i class="el-tooltip el-icon-info"></i> <i class="el-tooltip el-icon-info"></i>
</el-tooltip> </el-tooltip>
<el-input v-model="msg.ReceiveNum" 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-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.ReceiveNum=-1:msg.ReceiveNum=0">无限制</el-checkbox> <el-checkbox v-model="checked" @change="checked==true? msg.TotalNum=-1:msg.TotalNum=0">无限制</el-checkbox>
</el-form-item> </el-form-item>
<el-form-item label="排序" prop="Sort" class="is-required"> <el-form-item label="排序" prop="Sort" class="is-required">
...@@ -128,7 +146,10 @@ ...@@ -128,7 +146,10 @@
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</el-form> </el-form>
</div> </div>
<el-button type="primary" style="margin: 12px 0 " @click="preserve('msg')" v-loading="loading">保存</el-button>
<!--已指定商品类别选择--> <!--已指定商品类别选择-->
<el-dialog title="已指定商品类别" :visible.sync="category" width="714px"> <el-dialog title="已指定商品类别" :visible.sync="category" width="714px">
<el-tree <el-tree
...@@ -136,9 +157,117 @@ ...@@ -136,9 +157,117 @@
show-checkbox show-checkbox
default-expand-all default-expand-all
node-key="Id" node-key="Id"
ref="tree"
:default-checked-keys="checkedkeys"
@check="TreeList" @check="TreeList"
:props="defaultProps"> :props="defaultProps">
</el-tree> </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="domainManager().ImageUrl+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">
</div>
<button type="button" class="el-button el-button--default el-button--small" style="margin-left: 15px" @click="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="domainManager().ImageUrl+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="msg.pageSize"
layout="prev, pager, next"
:total="count">
</el-pagination>
</template>
</el-dialog> </el-dialog>
</div> </div>
...@@ -156,23 +285,28 @@ ...@@ -156,23 +285,28 @@
UseType:3, UseType:3,
MinConsumePrice:0, MinConsumePrice:0,
DiscountsPrice:0, //优惠金额/折扣 DiscountsPrice:0, //优惠金额/折扣
MaxDiscountsPrice:'', MaxDiscountsPrice:0,
IndateDay:1, IndateDay:1,
IndateType:1, IndateType:1,
ReceiveNum:-1, TotalNum:-1,
Sort:100, Sort:100,
Describe:'', Describe:'',
OnlyMember:1, OnlyMember:1,
PickupCenter:2, PickupCenter:2,
MemberLevelList:[], MemberLevelList:[],
ProductList:[],//指定商品类型的数组
StartDate:'',
EndDate:'',
value:'', value:'',
}, },
checkedkeys:[],//默认选中的
huiyuan:false, huiyuan:false,
zhongxin:true, zhongxin:true,
checked:true, checked:true,
loading:false, loading:false,
activeName:'first', activeName:'first',
commodity:false,
addcommodity:false,
rules:{ rules:{
Name:[ Name:[
{required: true, message: "优惠券名称不能为空", trigger: "blur"} {required: true, message: "优惠券名称不能为空", trigger: "blur"}
...@@ -186,7 +320,7 @@ ...@@ -186,7 +320,7 @@
IndateDay:[ IndateDay:[
{required: true, message: "优惠券有效天数不能为空", trigger: "blur"} {required: true, message: "优惠券有效天数不能为空", trigger: "blur"}
], ],
ReceiveNum:[ TotalNum:[
{required: true, message: "发放总数不能为空", trigger: "blur"} {required: true, message: "发放总数不能为空", trigger: "blur"}
], ],
Sort:[ Sort:[
...@@ -203,15 +337,35 @@ ...@@ -203,15 +337,35 @@
isIndeterminate: false, isIndeterminate: false,
category:false, category:false,
ProductCategoryTreeList:[], ProductCategoryTreeList:[],
commoditylist:[],//商品的list
defaultProps: { defaultProps: {
children: 'ChildList', children: 'ChildList',
label: 'Name' 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:[]
} }
}, },
created(){ created(){
this.getMemberGradeList() this.getMemberGradeList()
this.getProductCategoryTreeList() this.getProductCategoryTreeList()
this.getProductGoodsPageList()
}, },
methods:{ methods:{
getMemberGradeList(){ getMemberGradeList(){
...@@ -225,6 +379,48 @@ ...@@ -225,6 +379,48 @@
}) })
}, },
getDiscountCouponDetail(ID){
this.apipost("/api/Coupon/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
}
if(res.data.data.UseType==2){
let ProductList = res.data.data.ProductList;
let newData = []
for(let i= 0;i<ProductList.length;i++){
for(let j=0;j<this.tableData.length;j++){
if(ProductList[i].ProductId == this.tableData[j].Id){
newData.push(this.tableData[j])
}
}
}
console.log(ProductList)
console.log(this.tableData)
this.commoditylist = newData
}
} else {
this.Info(res.data.message);
}
})
},
getProductCategoryTreeList(){ getProductCategoryTreeList(){
this.apipost("/api/AppletGoods/GetProductCategoryTreeList",{}, res => { this.apipost("/api/AppletGoods/GetProductCategoryTreeList",{}, res => {
...@@ -236,6 +432,27 @@ ...@@ -236,6 +432,27 @@
}) })
}, },
getProductGoodsPageList(){
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.tableData = pageData
this.count = res.data.data.count
}
setTimeout(()=>{
if(this.$route.query.ID){
this.getDiscountCouponDetail(this.$route.query.ID)
}
},10)
})
},
cancel(){ cancel(){
this.$router.go(-1) this.$router.go(-1)
}, },
...@@ -263,17 +480,148 @@ ...@@ -263,17 +480,148 @@
this.checkAll = checkedCount === this.cities.length; this.checkAll = checkedCount === this.cities.length;
this.isIndeterminate = checkedCount > 0 && 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.commoditylist.concat(newdata)
},
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){ getUseType(val){
console.log(11111)
console.log(val)
if(val ==1){ if(val ==1){
this.category=true this.category=true
this.$nextTick(() => {//在弹出dialog之前执行$nextTick回调函数,确保el-tree已经渲染
this.$refs.tree.setCheckedKeys(this.checkedkeys);
});
}else if(val==2){
this.checkedkeys=[]
this.commodity =true
} }
}, },
getUseType2(){
this.checkedkeys=[]
},
deleteProduct(item,index){
this.msg.ProductList.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) {
this.loading= true
if(this.msg.IndateType==2){
this.msg.StartDate=this.msg.value[0];
this.msg.EndDate=this.msg.value[1];
this.msg.IndateDay=0
}
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
}
this.apipost("/api/Coupon/AddOrUpdateDiscountCoupon",this.msg , res => {
this.loading= false
if (res.data.resultCode == 1) {
this.Success(res.data.message);
this.$router.go(-1);//返回上一层
TreeList(val){ } else {
console.log(val) 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.msg.ProductList= ProductList
} }
} }
} }
</script> </script>
...@@ -317,4 +665,15 @@ ...@@ -317,4 +665,15 @@
padding: 10px 50% 10px 20px; padding: 10px 50% 10px 20px;
min-width: 1000px; min-width: 1000px;
} }
.addCoupon .splist{
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.addCoupon .app-image{
width: 50px;
height: 50px;
border-radius: 0%;
background-position: center center;
}
</style> </style>
...@@ -160,7 +160,7 @@ ...@@ -160,7 +160,7 @@
}, },
Edit(row){ Edit(row){
this.$router.push({ this.$router.push({
name: 'addCardTicket', name: 'addCoupon',
query: { query: {
ID:row.ID, ID:row.ID,
blank: "y" blank: "y"
...@@ -171,7 +171,7 @@ ...@@ -171,7 +171,7 @@
let that=this; let that=this;
that.Confirm("是否删除?", function () { that.Confirm("是否删除?", function () {
that.apipost( that.apipost(
"/api/Coupon/DelRules", "/api/Coupon/DelDiscountCoupon",
{Id:row.ID}, {Id:row.ID},
res => { res => {
if (res.data.resultCode == 1) { if (res.data.resultCode == 1) {
......
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