Commit 1c32f146 by lixiaomin

修改优惠券

parent b143a965
......@@ -8,14 +8,6 @@ export function listClass(query) {
params: query,
});
}
// 查询列表
export function getList(query) {
return request({
url: "/system/category/getList",
method: "get",
params: query,
});
}
// 查询详细
export function getClass(id) {
......@@ -26,10 +18,10 @@ export function getClass(id) {
}
// 新增
export function addClass(data) {
export function addCoupon(data) {
return request({
url: "/system/category",
method: "post",
url: "/coupon",
method: "put",
data: data,
});
}
......
......@@ -18,7 +18,7 @@ export function addCouCategory(data) {
});
}
// 新增
// 修改
export function updateCouCategory(data) {
return request({
url: "/coupon-category/update",
......@@ -51,4 +51,11 @@ export function onlineCouCategory(id) {
});
}
// 详情
export function getCouCategory(id) {
return request({
url: "/coupon-category/detail/" + id,
method: "get",
});
}
......@@ -5,14 +5,14 @@
<el-input v-model="queryParams.name" placeholder="分类名称 " clearable @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="状态">
<el-select v-model="queryParams.state" placeholder="请选择" clearable @keyup.enter.native="handleQuery">
<!-- <el-select v-model="queryParams.state" placeholder="请选择" clearable @keyup.enter.native="handleQuery">
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-select> -->
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery" v-hasPermi="['coupon:coupon:query']">搜索</el-button>
......@@ -60,8 +60,8 @@
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
@pagination="getList" />
<!-- 添加或修改对话框 -->
<el-dialog :title="title" :visible.sync="open" width="1200px" append-to-body class="dialogClass">
<el-form ref="form" :model="form" :rules="rules" label-width="140px">
<el-dialog :title="title" :visible.sync="open" width="1400px" append-to-body class="dialogClass">
<el-form ref="form" :model="form" :rules="rules" label-width="150px">
<el-row>
<el-form-item label="优惠券名称" prop="name">
<el-input v-model="form.name" placeholder="请输入优惠券名称" minlength="1" maxlength="100"/>
......@@ -69,21 +69,21 @@
</el-row>
<el-row>
<el-col :span="6">
<el-form-item label="券类别" prop="" >
<el-select v-model="form.name" placeholder="请选择" @change="selectChange()" style="width: 326px;">
<el-form-item label="券类别" prop="categoryId" >
<el-select v-model="form.categoryId" placeholder="请选择" @change="selectChange" class="width">
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value">
v-for="item in couCategoryList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="11">
<div style="margin-left: 105px;">
<div style="margin-left: 140px;">
<el-form-item label="券价值">
<el-radio-group v-model="form.cost">
<el-radio-group v-model="type" disabled style="margin-left: 6px;">
<el-radio :label="1">抵扣</el-radio>
<el-radio :label="2">折扣</el-radio>
<el-radio :label="3" style="margin-left: 13px;">免单</el-radio>
......@@ -91,62 +91,62 @@
</el-form-item>
<div style="margin-left: 73px;">
<div class="marginLeft10">
<span>立减</span><el-input class="inputCalss"/><span class="spanClass"></span>
<el-radio-group v-model="form.cost" class="marginLeft10">
<el-radio :label="1" class="marginLeft10">无门槛</el-radio>
<el-radio :label="6" ><el-input class="inputCalss"/><span class="spanClass"></span></el-radio>
<span>立减</span><el-input v-model="liJian" class="inputCalss" :disabled="type=='2' || type=='3'"/><span class="spanClass"></span>
<el-radio-group v-model="firstRadioValue" class="marginLeft10">
<el-radio :label="1" class="marginLeft10" :disabled="type=='2'">无门槛</el-radio>
<el-radio :label="2" :disabled="type=='2'"><el-input v-model="priceLimit" class="inputCalss" :disabled="type=='2'"/><span class="spanClass"></span></el-radio>
</el-radio-group>
</div>
<div style="margin-left: 36px;margin-top: 10px;">
<el-input class="inputCalss"/><span class="spanClass"></span>
<el-radio-group v-model="form.cost1" class="marginLeft10">
<el-radio :label="1" class="marginLeft10">单杯</el-radio>
<el-radio :label="6" style="margin-left: 14px;">整单</el-radio>
<div style="margin-left: 36px;margin-top: 10px;" >
<el-input v-model="jiZhe" class="inputCalss" :disabled="type=='1' || type=='3'"/><span class="spanClass" ></span>
<el-radio-group v-model="twoRadioValue" class="marginLeft10">
<el-radio :label="3" class="marginLeft10" :disabled="type=='1'">单杯</el-radio>
<el-radio :label="4" style="margin-left: 14px;" :disabled="type=='1' || type=='3'">整单</el-radio>
</el-radio-group>
</div>
</div>
</div>
</el-col>
<el-col :span="7">
<el-form-item label="User可领次数" label-width="110px">
<el-radio-group v-model="form.cost" >
<el-radio :label="1">
<span></span><el-input class="inputCalss"/><span class="spanClass"></span>
<el-input class="inputCalss"/><span class="spanClass"></span>
<el-form-item label="User可领次数" label-width="110px" prop="userNumber" style="margin-left: 15px;">
<el-radio-group v-model="form.userNumber" >
<el-radio :label="1" >
<span></span><el-input class="inputCalss" v-model="form.daysLimit" :disabled="form.userNumber=='2'"/><span class="spanClass"></span>
<el-input class="inputCalss" v-model="form.userLimit" :disabled="form.userNumber=='2'"/><span class="spanClass"></span>
</el-radio>
<el-radio :label="6" style="margin-top: 10px;">无限制</el-radio>
<el-radio :label="2" style="margin-top: 10px;">无限制</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
</el-row>
<el-row style="margin-top: 8px;">
<el-col :span="10">
<el-form-item label="优惠券绝对有效时间" >
<el-col :span="9">
<el-form-item label="优惠券绝对有效时间" prop="times">
<el-date-picker
v-model="times"
v-model="form.times"
type="datetimerange"
range-separator="至"
start-placeholder="请选择开始日期"
end-placeholder="请选择结束日期" value-format="yyyy-MM-dd HH:mm" format="yyyy-MM-dd HH:mm" class="width"/>
end-placeholder="请选择结束日期" value-format="yyyy-MM-dd HH:mm:ss" class="width"/>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="领取后相对有效时间">
<el-input class="inputCalss"/><span class="spanClass"></span>
<el-col :span="8">
<el-form-item label="领取后相对有效时间" label-width="190px">
<el-input class="inputCalss" v-model="form.relativeTime"/><span class="spanClass"></span>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="优惠券可领取时间" style=" margin-left: 41px;">
<el-date-picker v-model="form.date" type="date" placeholder="请选择领取日期" style="width: 205px;"/>
<el-col :span="7">
<el-form-item label="优惠券可领取时间" >
<el-date-picker v-model="form.startTime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="请选择领取日期" style="width: 205px;"/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col>
<el-form-item label="适用范围">
<el-cascader :options="rangeList" clearable placeholder="请选择使用商品范围" class="width"/>
<el-cascader :options="rangeList" :props="{ multiple: true }" clearable collapse-tags placeholder="请选择地区门店" class="marginLeft20 width"/>
<el-select v-model="form.week" placeholder="请选择可用日期" multiple collapse-tags style="margin-left:36px; width:330px">
<el-cascader :options="shopRangeList" v-model="shopRange" clearable placeholder="请选择使用商品范围" class="width" :props="{ multiple: true}" collapse-tags :show-all-levels="false"/>
<el-cascader :options="storesList" v-model="storesRange" :props="{ multiple: true }" clearable collapse-tags placeholder="请选择地区门店" :show-all-levels="false" style="margin-left:55px;width:300px;"/>
<el-select v-model="form.weekLimit" placeholder="请选择可用日期" multiple collapse-tags style="margin-left: 130px;width: 328px;" clearable>
<el-option
v-for="item in weekList"
:key="item.value"
......@@ -157,14 +157,18 @@
</el-form-item>
</el-col>
</el-row>
<el-form-item label="短信通知" >
<el-form-item label="短信通知" prop="sendMsgTag">
<div style="display: flex;">
<div>
<el-radio v-model="form.mess" label="1"></el-radio>
<el-radio v-model="form.mess" label="2"></el-radio>
<el-radio-group v-model="form.sendMsgTag" @change="changeMsg">
<el-radio :label="1"></el-radio>
<el-radio :label="2"></el-radio>
</el-radio-group>
</div>
<div style="margin-left: 20px;">
<el-input placeholder="请输入短信内容" style="width: 907px;"></el-input>
<div style="margin-left: 75px;">
<el-select v-model="form.msgId" style="width: 1000px;" :disabled="selectMess">
<el-option value="1" label="模板1" ></el-option>
</el-select>
</div>
</div>
</el-form-item>
......@@ -180,19 +184,20 @@
<script>
import {
listClass,
getClass,
delClass,
addClass,
updateClass,
turnList
} from "@/api/coupon/couponType";
addCoupon,
} from "@/api/coupon/coupon";
import {getCouCategoryList} from "@/api/coupon/couponType";
import GiveCoupon from './giveCoupon.vue';
import {listClass} from "@/api/system/category";
import {listSpu} from "@/api/system/goods";
import {listShop} from "@/api/system/shop";
import piovince from '@/utils/piovince'
export default {
name: "Class",
components: { GiveCoupon},
data() {
return {
piovince,
// 遮罩层
loading: true,
// 总条数
......@@ -211,91 +216,171 @@ export default {
state: null
},
// 表单参数
form: {},
form: {
categoryIds:[],
goodsIds:[],
sendMsgTag:2
},
// 表单校验
rules: {
name: [{ required: true, message: "不能为空", trigger: "blur" }],
status: [{ required: true, message: "不能为空", trigger: "blur" }],
code: [{ required: true, message: "不能为空", trigger: "blur" }],
createTime: [{ required: true, message: "不能为空", trigger: "blur" }],
categoryId: [{ required: true, message: "不能为空", trigger: "blur" }],
userNumber: [{ required: true, message: "不能为空", trigger: "change" }],
times: [{required: true, message: "不能为空", trigger: "change" }],
sendMsgTag: [{required: true, message: "不能为空", trigger: "change" }]
},
options: [{
value: '1',
label: '满减券'
}, {
value: '2',
label: '折扣券'
}],
rangeList:[{
value: '1',
label: '全国通用',
},{
value: '北京',
label: '北京市',
children: [{
value: '北京',
label: '北京市',
children: [{
value: 'haidian',
label: '海淀区',
children:[{
value:'1',
label:'海淀黄庄店'
},{
value:'2',
label:'凯德茂店'
}]
}, {
value: 'chaoyang',
label: '朝阳区',
children:[{
value:'1',
label:'朝阳大悦城店'
}]
}]
},{
value: 'henan',
label: '河南省',
children: [{
value: 'zhengzhou',
label: '郑州市'
}, {
value: 'zhoukou',
label: '周口市'
}]
}]
}],
times:[],
couCategoryList: [],
storesList:[],
weekList:[{
value: '1',
value: 1,
label: '星期一'
}, {
value: '2',
value: 2,
label: '星期二'
}, {
value: '3',
value: 3,
label: '星期三'
}, {
value: '4',
value: 4,
label: '星期四'
}, {
value: '5',
value: 5,
label: '星期五'
}, {
value: '6',
value: 6,
label: '星期六'
}, {
value: '7',
value: 7,
label: '星期日'
}]
}],
type:"",
liJian:"",
firstRadioValue:"",
twoRadioValue:"",
priceLimit:"",
jiZhe:"",
shopRangeList:[],
categoryList:[],
shopList:[],
shopRange:[],
cityList:[],
storesRange:[],
selectMess:true,
};
},
created() {
this.getList();
this.getCategoryList();
this.getShopList();
this.getCityList();
},
methods: {
/** 查询商品分类列表 */
getCategoryList() {
listClass({pageNum: 1,pageSize: 10000,state:1}).then((response) => {
this.categoryList = response.rows;
});
},
/** 查询商品列表 */
getShopList() {
listSpu({pageNum: 1,pageSize: 10000,state:3}).then((response) => {
this.shopList = response.rows;
});
},
/** 查询店铺列表 */
getCityList() {
listShop({pageNum: 1,pageSize: 10000,state:1}).then((response) => {
this.cityList = response.rows;
});
},
// 封装商品范围下拉数据
getShopRangeList(){
let catList=[];
let shList=[];
if(this.categoryList.length>0){
for(let i=0;i<this.categoryList.length;i++){
let categoryObj={}
categoryObj.value=this.categoryList[i].id;
categoryObj.label=this.categoryList[i].name;
catList.push(categoryObj);
}
}
if(this.shopList.length>0){
for(let i=0;i<this.shopList.length;i++){
let shObj={}
shObj.value=this.shopList[i].id;
shObj.label=this.shopList[i].name;
shList.push(shObj);
}
}
this.shopRangeList=[{value:0,label:"全品类"},{value:1,label:"分品类",children:catList},{value:2,label:"分商品",children:shList}]
},
//封装门店下拉数据
getStoresList(){
let piovinceList=this.piovince;
if(this.cityList.length>0){
for(let a=0;a<this.cityList.length;a++){
let sheng=this.cityList[a].province;
let shi=this.cityList[a].city;
let qu=this.cityList[a].zone;
let storesName=this.cityList[a].name;
let storesId=this.cityList[a].id;
for(let i=0;i<piovinceList.length;i++){
if(sheng==piovinceList[i].value){
let shiList=piovinceList[i].children;
if(shiList.length>0){
for(let j=0;j<shiList.length;j++){
if(shi==shiList[j].value){
let quList=shiList[j].children;
if(quList.length>0){
let arry=[];
for(let q=0;q<quList.length;q++){
if(qu==quList[q].value){
let quObj={value:qu,label:quList[q].label,children:[{value:storesId,label:storesName}]}
arry.push(quObj);
}
}
let obj={value:sheng,label:piovinceList[i].label,children:[{value:shi,label:shiList[j].label,children:arry}]}
this.storesList.push(obj);
}
}
}
}
}
}
}
}
},
changeMsg(val){
this.selectMess=false;
if(val==1){
this.selectMess=true;
this.form.msgId="";
}
},
/** 查询券类别列表 */
getcouCategoryList() {
getCouCategoryList({state:1,pageNum:1,pageSize:10000}).then((response) => {
this.couCategoryList = response.rows;
});
},
selectChange(val){
this.liJian="";
this.firstRadioValue="";
this.twoRadioValue="";
this.priceLimit="";
this.jiZhe="";
for(let i=0;i<this.couCategoryList.length;i++){
if(this.couCategoryList[i].id==val){
this.type=this.couCategoryList[i].type;
if(this.type=="1"){
this.firstRadioValue=1;
}else{
this.firstRadioValue=1;
this.twoRadioValue=3;
}
}
}
},
giveClick(){
this.$refs.giveCoupon.getList();
......@@ -340,8 +425,12 @@ export default {
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.form.sendMsgTag=2
this.open = true;
this.title = "新增优惠券";
this.getcouCategoryList();
this.getShopRangeList();
this.getStoresList();
},
/** 启用、禁用按钮操作 */
handleStatus(row,tag) {
......@@ -382,21 +471,88 @@ export default {
submitForm() {
this.$refs["form"].validate((valid) => {
if (valid) {
if (this.form.id != null) {
if(this.form.state == "1"){
this.$message.error("停用之后才可以修改");
if(this.type=="1"){
if(this.liJian==""){
this.$message.error("立减输入框必填!");
return;
}
this.form.priceDiscount=this.liJian
}else if(this.type=="2"){
if(this.jiZhe==""){
this.$message.error("折输入框必填!");
return;
}
if(this.twoRadioValue=="3"){
this.form.orderLimit=true;
}else{
this.form.orderLimit=false;
}
this.form.priceLimit=this.jiZhe;
}else if(this.type=="3"){
if(this.firstRadioValue=="2"){
if(this.priceLimit==""){
this.$message.error("满X元输入框必填!");
return;
}
}
this.form.orderLimit=true;
}
if(this.firstRadioValue=="2"){
if(this.priceLimit==""){
this.$message.error("满X元输入框必填!");
return;
}
this.form.priceLimit=this.priceLimit;
}else if(this.firstRadioValue=="1"){
this.form.priceLimit=0;
}
if(this.form.userNumber=="2"){
this.form.daysLimit=0;
this.form.userLimit=0;
}else{
this.form.daysLimit="";
this.form.userLimit="";
}
if(this.form.times.length>0){
this.form.useStartTime=this.form.times[0];
this.form.useEndTime=this.form.times[1]
}
if(this.shopRange.length>0){
let cateList=[];
let goodSList=[];
for(let i=0;i<this.shopRange.length;i++){
if(this.shopRange[i][0]==0){
cateList.push(0);
}else if(this.shopRange[i][0]==1){
cateList.push(this.shopRange[i][1]);
}else if(this.shopRange[i][0]==2){
goodSList.push(this.shopRange[i][1]);
}
}
this.form.categoryIds=cateList;
this.form.goodsIds=goodSList;
}
if(this.storesRange.length>0){
//console.log("this.storesRange",this.storesRange);
}
if(this.form.sendMsgTag==1){
this.form.sendMsg=true;
}else if(this.form.sendMsgTag==2){
this.form.sendMsg=false;
}
console.log("this.form",this.form);
if (this.form.id != null) {
updateClass(this.form).then((response) => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addClass(this.form).then((response) => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
addCoupon(this.form).then((response) => {
console.log("response",response);
// this.$modal.msgSuccess("新增成功");
// this.open = false;
// this.getList();
});
}
}
......@@ -427,10 +583,10 @@ export default {
<style lang="scss" >
.dialogClass .spanClass{
margin-left: 10px;
margin-left: 6px;
}
.dialogClass .inputCalss{
width:50px;
width:70px;
margin-left: 10px;
}
.dialogClass .el-radio__label {
......@@ -439,13 +595,8 @@ export default {
.dialogClass .marginLeft10 {
padding-left: 10px;
}
.dialogClass .marginLeft20 {
padding-left: 20px;
}
.dialogClass .width {
width: 326px;
width: 355px;
}
</style>
......@@ -35,7 +35,7 @@ module.exports = {
proxy: {
// detail: https://cli.vuejs.org/config/#devserver-proxy
[process.env.VUE_APP_BASE_API]: {
target: `http://140.143.224.240:8090`,
target: `http://140.143.224.240:8091`,
changeOrigin: true,
pathRewrite: {
["^" + process.env.VUE_APP_BASE_API]: "",
......
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