优惠券修改

This commit is contained in:
2024-10-30 15:29:21 +08:00
parent 25be4ddd57
commit 36564630cc
2 changed files with 302 additions and 214 deletions

View File

@@ -18,7 +18,7 @@
<el-col :span="8"> <el-col :span="8">
<el-form-item label="优惠卷类型" prop="couponType"> <el-form-item label="优惠卷类型" prop="couponType">
<!-- <el-input v-model="dataForm.type" placeholder="优惠卷类型"></el-input> --> <!-- <el-input v-model="dataForm.type" placeholder="优惠卷类型"></el-input> -->
<el-select v-model="dataForm.couponType" placeholder="请选择"> <el-select v-model="dataForm.couponType" placeholder="请选择" :disabled="!isEdit">
<el-option <el-option
v-for="item in options" v-for="item in options"
:key="item.value" :key="item.value"
@@ -31,7 +31,7 @@
</el-col> </el-col>
<el-col :span="8" <el-col :span="8"
><el-form-item label="使用门槛" prop="useLevel"> ><el-form-item label="使用门槛" prop="useLevel">
<el-input <el-input :disabled="!isEdit"
v-model="dataForm.useLevel" v-model="dataForm.useLevel"
placeholder="" placeholder=""
oninput="value=value.replace(/[^\d.]/g,'')" oninput="value=value.replace(/[^\d.]/g,'')"
@@ -42,7 +42,7 @@
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="面额:" prop="couponAmount"> <el-form-item label="面额:" prop="couponAmount">
<el-input <el-input :disabled="!isEdit"
v-model="dataForm.couponAmount" v-model="dataForm.couponAmount"
placeholder="面额" placeholder="面额"
oninput="value=value.replace(/[^\d.]/g,'')" oninput="value=value.replace(/[^\d.]/g,'')"
@@ -55,7 +55,7 @@
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :span="8"> <el-col :span="8">
<el-form-item label="优惠券名称" prop="couponName"> <el-form-item label="优惠券名称" prop="couponName">
<el-input <el-input :disabled="!isEdit"
v-model="dataForm.couponName" v-model="dataForm.couponName"
placeholder="名称" placeholder="名称"
></el-input> ></el-input>
@@ -89,7 +89,7 @@
<el-col :span="8"> <el-col :span="8">
<el-form-item label="优惠卷范围" prop="couponRange"> <el-form-item label="优惠卷范围" prop="couponRange">
<!-- <el-input v-model="dataForm.type" placeholder="优惠卷类型"></el-input> --> <!-- <el-input v-model="dataForm.type" placeholder="优惠卷类型"></el-input> -->
<el-select <el-select :disabled="!isEdit"
v-model="dataForm.couponRange" v-model="dataForm.couponRange"
placeholder="请选择" placeholder="请选择"
@change="changeRange" @change="changeRange"
@@ -166,7 +166,7 @@
<el-row ::gutter="10"> <el-row ::gutter="10">
<el-col :span="24"> <el-col :span="24">
<el-form-item label="生效方式" prop="effectType"> <el-form-item label="生效方式" prop="effectType">
<el-radio-group v-model="dataForm.effectType"> <el-radio-group v-model="dataForm.effectType" :disabled="!isEdit">
<el-radio :label="0">长期有效</el-radio> <el-radio :label="0">长期有效</el-radio>
<el-radio :label="1">领取生效</el-radio> <el-radio :label="1">领取生效</el-radio>
<el-radio :label="2">自定义</el-radio> <el-radio :label="2">自定义</el-radio>
@@ -181,7 +181,7 @@
prop="effectTime" prop="effectTime"
v-if="dataForm.effectType == '2'" v-if="dataForm.effectType == '2'"
> >
<el-date-picker <el-date-picker :disabled="!isEdit"
v-model="dataForm.effectTime" v-model="dataForm.effectTime"
@change="datePicked" @change="datePicked"
type="datetime" type="datetime"
@@ -194,7 +194,7 @@
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item <el-form-item
label="结束时间" label="结束时间" :disabled="!isEdit"
prop="expireTime" prop="expireTime"
v-if="dataForm.effectType == '2'" v-if="dataForm.effectType == '2'"
> >
@@ -211,7 +211,7 @@
</el-col> </el-col>
<el-col :span="8" v-show="dataForm.effectType == '1'"> <el-col :span="8" v-show="dataForm.effectType == '1'">
<el-form-item label="时效" prop="validity"> <el-form-item label="时效" prop="validity">
<el-input <el-input :disabled="!isEdit"
placeholder="" placeholder=""
v-model="dataForm.validity" v-model="dataForm.validity"
oninput="value=value.replace(/[^\d.]/g,'')" oninput="value=value.replace(/[^\d.]/g,'')"
@@ -225,6 +225,7 @@
<el-col :span="24"> <el-col :span="24">
<el-form-item label="封面图" prop="couponUrl" > <el-form-item label="封面图" prop="couponUrl" >
<el-upload <el-upload
:disabled="!isEdit"
:limit="1" :limit="1"
class="el-uploadfeng" class="el-uploadfeng"
:action="baseUrl + '/oss/fileoss'" :action="baseUrl + '/oss/fileoss'"
@@ -245,7 +246,7 @@
<el-col :span="8"> <el-col :span="8">
<el-form-item label="备注" prop="remark" > <el-form-item label="备注" prop="remark" >
<el-input <el-input
v-model="dataForm.remark" v-model="dataForm.remark":disabled="!isEdit"
placeholder="备注" placeholder="备注"
type="textarea" type="textarea"
:rows="3" :rows="3"
@@ -272,6 +273,7 @@ export default {
baseUrl: global.baseUrl, baseUrl: global.baseUrl,
data() { data() {
return { return {
isEdit:true,
showCateError: false, showCateError: false,
requesturl:'', // 课程的请求地址 requesturl:'', // 课程的请求地址
showSelectPro:false, showSelectPro:false,
@@ -440,6 +442,7 @@ export default {
if(!id){ if(!id){
console.log('没有传值') console.log('没有传值')
this.visible = true; this.visible = true;
this.isEdit=true
return return
} }
this.dataForm.id = id || 0; this.dataForm.id = id || 0;
@@ -454,9 +457,14 @@ export default {
}).then(({ data }) => { }).then(({ data }) => {
if (data.code !== 0) return this.$message.error(data.msg); if (data.code !== 0) return this.$message.error(data.msg);
this.visible = true; this.visible = true;
this.getCouponInfoLoad = false; this.getCouponInfoLoad = false;
if (data && data.code == 0) { if (data && data.code == 0) {
this.dataForm = data.couponEntity; this.dataForm = data.couponEntity;
if(this.dataForm.grantCount>0){
this.isEdit=false
}
if ( if (
this.dataForm.effectTime && this.dataForm.effectTime &&
this.dataForm.effectTime != null this.dataForm.effectTime != null

View File

@@ -1,16 +1,35 @@
<template> <template>
<div class="mod-config"> <div class="mod-config">
<el-radio-group v-model="currentState" style="margin-bottom: 15px;" @tab-click="handleClick"> <el-radio-group
v-model="currentState"
style="margin-bottom: 15px;"
@tab-click="handleClick"
>
<el-radio-button label="">全部</el-radio-button> <el-radio-button label="">全部</el-radio-button>
<el-radio-button label="0">生效中</el-radio-button> <el-radio-button label="0">生效中</el-radio-button>
<el-radio-button label="1">已过期</el-radio-button> <el-radio-button label="1">已过期</el-radio-button>
</el-radio-group> </el-radio-group>
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()"> <el-form
:inline="true"
:model="dataForm"
@keyup.enter.native="getDataList()"
>
<el-form-item> <el-form-item>
<el-input v-model="dataForm.couponName" placeholder="参数名" clearable></el-input> <el-input
v-model="dataForm.couponName"
placeholder="参数名"
clearable
></el-input>
</el-form-item> </el-form-item>
<el-form-item label="优惠券范围"> <el-form-item label="优惠券范围">
<el-select v-model="dataForm.couponRange" placeholder="请选择" @change="pageIndex = 1; getDataList()"> <el-select
v-model="dataForm.couponRange"
placeholder="请选择"
@change="
pageIndex = 1;
getDataList();
"
>
<el-option <el-option
v-for="item in rangList" v-for="item in rangList"
:key="item.value" :key="item.value"
@@ -21,7 +40,14 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="优惠券类型"> <el-form-item label="优惠券类型">
<el-select v-model="dataForm.TypeList" placeholder="请选择" @change="pageIndex = 1; getDataList()"> <el-select
v-model="dataForm.TypeList"
placeholder="请选择"
@change="
pageIndex = 1;
getDataList();
"
>
<el-option <el-option
v-for="item in TypeList" v-for="item in TypeList"
:key="item.value" :key="item.value"
@@ -33,7 +59,12 @@
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button @click="getDataList()">查询</el-button> <el-button @click="getDataList()">查询</el-button>
<el-button v-if="isAuth('book:coupon:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button> <el-button
v-if="isAuth('book:coupon:save')"
type="primary"
@click="addOrUpdateHandle()"
>新增</el-button
>
<!-- <el-button v-if="isAuth('book:coupon:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button> --> <!-- <el-button v-if="isAuth('book:coupon:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button> -->
</el-form-item> </el-form-item>
</el-form> </el-form>
@@ -42,7 +73,8 @@
border border
v-loading="dataListLoading" v-loading="dataListLoading"
@selection-change="selectionChangeHandle" @selection-change="selectionChangeHandle"
style="width: 100%;"> style="width: 100%;"
>
<!-- <el-table-column <!-- <el-table-column
type="selection" type="selection"
header-align="center" header-align="center"
@@ -53,18 +85,23 @@
prop="id" prop="id"
header-align="center" header-align="center"
align="center" align="center"
label="序号" width="50"> label="序号"
width="50"
>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="couponName" prop="couponName"
header-align="center" header-align="center"
align="center" align="center"
label="优惠券名称"> label="优惠券名称"
>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
header-align="center" header-align="center"
align="center" align="center"
label="优惠券类型" width="100px"> label="优惠券类型"
width="100px"
>
<template slot-scope="scope"> <template slot-scope="scope">
{{ scope.row.effectType | getType }} {{ scope.row.effectType | getType }}
</template> </template>
@@ -73,35 +110,55 @@
prop="couponAmount" prop="couponAmount"
header-align="center" header-align="center"
align="center" align="center"
label="面值" width="90px"> label="面值"
width="90px"
>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="expirationDate" prop="expirationDate"
header-align="center" header-align="center"
align="center" align="center"
label="时间"> label="时间"
>
<template slot-scope="scope"> <template slot-scope="scope">
<span v-if="scope.row.createTime">创建时间{{scope.row.createTime}}</span> <span v-if="scope.row.createTime"
<span v-if="scope.row.effectTime"><br/>生效时间{{scope.row.effectTime}}</span> >创建时间{{ scope.row.createTime }}</span
<span v-if="scope.row.expireTime"><br/>结束时间{{scope.row.expireTime}}</span> >
<span v-if="scope.row.effectTime"
><br />生效时间{{ scope.row.effectTime }}</span
>
<span v-if="scope.row.expireTime"
><br />结束时间{{ scope.row.expireTime }}</span
>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="couponRange" prop="couponRange"
header-align="center" header-align="center"
align="center" align="center"
label="优惠券范围"> label="优惠券范围"
>
<template slot-scope="scope"> <template slot-scope="scope">
{{ scope.row.couponRange | getRange }} {{ scope.row.couponRange | getRange }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="totalCirculation" prop="totalCirculation"
header-align="center" header-align="center"
align="center" align="center"
label="发行数量" width="90px"> label="发行数量"
width="90px"
>
</el-table-column><el-table-column
prop="grantCount"
header-align="center"
align="center"
label="已领取数量"
>
<template slot-scope="scope">
{{ scope.row.grantCount }}
</template>
</el-table-column> </el-table-column>
<!-- <el-table-column <!-- <el-table-column
prop="useCount" prop="useCount"
@@ -119,15 +176,17 @@
prop="receiveCount" prop="receiveCount"
header-align="center" header-align="center"
align="center" align="center"
label="操作"> label="操作"
>
<template slot-scope="scope"> <template slot-scope="scope">
<el-switch <el-switch
v-model="scope.row.currentState" v-model="scope.row.currentState"
:active-value="0" :active-value="0"
:inactive-value='1' :inactive-value="1"
@change="changeStateHandle(scope.row.id, scope.row.currentState)" @change="changeStateHandle(scope.row.id, scope.row.currentState)"
active-text="发放中" active-text="发放中"
inactive-text="暂停发放"> inactive-text="暂停发放"
>
</el-switch> </el-switch>
</template> </template>
</el-table-column> </el-table-column>
@@ -136,10 +195,23 @@
header-align="center" header-align="center"
align="center" align="center"
width="150" width="150"
label="操作"> label="操作"
>
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="primary" size="small" plain @click="addOrUpdateHandle(scope.row.id)">修改</el-button> <el-button
<el-button type="danger" size="small" plain @click="deleteHandle(scope.row.id)">删除</el-button> type="primary"
size="small"
plain
@click="addOrUpdateHandle(scope.row.id)"
>修改</el-button
>
<el-button
type="danger"
size="small"
plain
@click="deleteHandle(scope.row.id)"
>删除</el-button
>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@@ -150,27 +222,32 @@
:page-sizes="[10, 20, 50, 100]" :page-sizes="[10, 20, 50, 100]"
:page-size="pageSize" :page-size="pageSize"
:total="totalPage" :total="totalPage"
layout="total, sizes, prev, pager, next, jumper"> layout="total, sizes, prev, pager, next, jumper"
>
</el-pagination> </el-pagination>
<!-- 弹窗, 新增 / 修改 --> <!-- 弹窗, 新增 / 修改 -->
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update> <add-or-update
v-if="addOrUpdateVisible"
ref="addOrUpdate"
@refreshDataList="getDataList"
></add-or-update>
</div> </div>
</template> </template>
<script> <script>
import global from "@/views/common/common.vue"; //引入共用组间 import global from "@/views/common/common.vue"; //引入共用组间
import AddOrUpdate from './coupon-add-or-update' import AddOrUpdate from "./coupon-add-or-update";
import commentsListVue from '../book/commentsList.vue' import commentsListVue from "../book/commentsList.vue";
export default { export default {
data() { data() {
return { return {
dataForm: { dataForm: {
couponName: '', couponName: "",
couponRange: '', couponRange: "",
couponType:'' couponType: ""
}, },
currentState:'', // "currentState":""//当前状态 0 发放中 1结束 currentState: "", // "currentState":""//当前状态 0 发放中 1结束
dataList: [], dataList: [],
rangList: global.rangList, rangList: global.rangList,
TypeList: global.TypeList, TypeList: global.TypeList,
@@ -181,29 +258,28 @@ import commentsListVue from '../book/commentsList.vue'
dataListSelections: [], dataListSelections: [],
addOrUpdateVisible: false, addOrUpdateVisible: false,
courseCateList: [] courseCateList: []
} };
}, },
filters: { filters: {
// 格式化时间 // 格式化时间
getType(value) { getType(value) {
switch (value) { switch (value) {
case 0: case 0:
return '长期有效' return "长期有效";
case 1: case 1:
return '领取生效' return "领取生效";
case 2: case 2:
return '自定义' return "自定义";
} }
}, },
getRange(value) { getRange(value) {
switch (value) { switch (value) {
case 0: case 0:
return "无限制";
return '无限制'
case 1: case 1:
return '课程券' return "课程券";
case 2: case 2:
return '课程品类券' return "课程品类券";
} }
} }
}, },
@@ -211,133 +287,137 @@ import commentsListVue from '../book/commentsList.vue'
AddOrUpdate AddOrUpdate
}, },
activated() { activated() {
this.getDataList() this.getDataList();
}, },
methods: { methods: {
// 修改优惠券状态 // 修改优惠券状态
changeStateHandle(id, state) { changeStateHandle(id, state) {
console.log('进来了') console.log("进来了");
this.$http({ this.$http({
url: this.$http.adornUrl('/common/coupon/updateCouponState'), url: this.$http.adornUrl("/common/coupon/updateCouponState"),
method: 'post', method: "post",
data: this.$http.adornData({ data: this.$http.adornData({
id: id, id: id,
currentState: state currentState: state
}) })
}).then(({data}) => { })
.then(({ data }) => {
if (data && data.code === 0) { if (data && data.code === 0) {
this.$message({ this.$message({
message: '操作成功', message: "操作成功",
type:'success', type: "success",
duration: 1500, duration: 1500,
onClose: () => { onClose: () => {
this.getDataList() this.getDataList();
} }
}) });
} else { } else {
this.$message.error(data.msg) this.$message.error(data.msg);
} }
}).catch((e) => {
this.$message.error(e.msg)
}) })
.catch(e => {
this.$message.error(e.msg);
});
}, },
handleClick() { handleClick() {
console.log(this.currentState) console.log(this.currentState);
this.pageIndex = 1 this.pageIndex = 1;
this.getDataList() this.getDataList();
}, },
// 获取数据列表 // 获取数据列表
getDataList() { getDataList() {
this.dataListLoading = true this.dataListLoading = true;
this.$http({ this.$http({
url: this.$http.adornUrl('/common/coupon/getCouponList'), url: this.$http.adornUrl("/common/coupon/getCouponList"),
method: 'post', method: "post",
data: this.$http.adornData({ data: this.$http.adornData({
'page': this.pageIndex, page: this.pageIndex,
'limit': this.pageSize, limit: this.pageSize,
'couponName': this.dataForm.couponName, couponName: this.dataForm.couponName,
'currentState': this.currentState, //当前状态 0 发放中 1结束 currentState: this.currentState, //当前状态 0 发放中 1结束
"couponType": this.dataForm.couponType,//优惠券类型 0现金 1折扣 couponType: this.dataForm.couponType, //优惠券类型 0现金 1折扣
"couponRange":this.dataForm.couponRange,//优惠卷范围 0无限制 1课程卷 2课程品类卷 couponRange: this.dataForm.couponRange //优惠卷范围 0无限制 1课程卷 2课程品类卷
}) })
}).then(({data}) => { })
if(data.code !==0) return this.$message.error(data.msg) .then(({ data }) => {
if (data.code !== 0) return this.$message.error(data.msg);
if (data && data.code === 0) { if (data && data.code === 0) {
this.dataList = data.couponPage.records this.dataList = data.couponPage.records;
this.totalPage = data.couponPage.total this.totalPage = data.couponPage.total;
} else { } else {
this.dataList = [] this.dataList = [];
this.totalPage = 0 this.totalPage = 0;
} }
this.dataListLoading = false this.dataListLoading = false;
}).catch((e) => {
this.$message.error(e.msg)
this.dataListLoading = false
}) })
.catch(e => {
this.$message.error(e.msg);
this.dataListLoading = false;
});
}, },
// 每页数 // 每页数
sizeChangeHandle(val) { sizeChangeHandle(val) {
this.pageSize = val this.pageSize = val;
this.pageIndex = 1 this.pageIndex = 1;
this.getDataList() this.getDataList();
}, },
// 当前页 // 当前页
currentChangeHandle(val) { currentChangeHandle(val) {
this.pageIndex = val this.pageIndex = val;
this.getDataList() this.getDataList();
}, },
// 多选 // 多选
selectionChangeHandle(val) { selectionChangeHandle(val) {
this.dataListSelections = val this.dataListSelections = val;
}, },
// 新增 / 修改 // 新增 / 修改
addOrUpdateHandle(id) { addOrUpdateHandle(id) {
this.addOrUpdateVisible = true this.addOrUpdateVisible = true;
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.addOrUpdate.init(id) this.$refs.addOrUpdate.init(id);
// this.addOrUpdateVisible = true // this.addOrUpdateVisible = true
}) });
}, },
// 删除 // 删除
deleteHandle(id) { deleteHandle(id) {
// var ids = id ? [id] : this.dataListSelections.map(item => { // var ids = id ? [id] : this.dataListSelections.map(item => {
// return item.id // return item.id
// }) // })
this.$confirm(`确定对[id=${id}]进行删除操作?`, '提示', { this.$confirm(`确定对[id=${id}]进行删除操作?`, "提示", {
confirmButtonText: '确定', confirmButtonText: "确定",
cancelButtonText: '取消', cancelButtonText: "取消",
type: 'warning' type: "warning"
}).then(() => { }).then(() => {
this.$http({ this.$http({
url: this.$http.adornUrl('/common/coupon/delCoupon'), url: this.$http.adornUrl("/common/coupon/delCoupon"),
method: 'post', method: "post",
data: this.$http.adornData({ data: this.$http.adornData({
id: id id: id
}) })
}).then(({ data }) => { }).then(({ data }) => {
if (data && data.code === 0) { if (data && data.code === 0) {
this.$message({ this.$message({
message: '操作成功', message: "操作成功",
type: 'success', type: "success",
duration: 1500, duration: 1500,
onClose: () => { onClose: () => {
this.getDataList() this.getDataList();
} }
}) });
} else { } else {
this.$message.error(data.msg) this.$message.error(data.msg);
} }
}) });
}) });
} }
},watch:{ },
watch: {
currentState: { currentState: {
handler(val, oldVal) { handler(val, oldVal) {
this.getDataList() this.getDataList();
}, },
deep: true deep: true
},
} }
} }
};
</script> </script>