优惠券刚写

This commit is contained in:
@fawn-nine
2024-09-27 10:00:27 +08:00
parent fef43c2b40
commit ad50d3e54f
3 changed files with 200 additions and 81 deletions

View File

@@ -6,8 +6,32 @@ const baseUrl = "http://192.168.110.100:9200/pb"; //张川川后端
// function commonFun() { // function commonFun() {
// console.log("公共方法") // console.log("公共方法")
// } // }
const rangList =[
{
value: 0,
label: "无限制"
},
{
value: 1,
label: "课程券"
},
{
value: 2,
label: "课程品类券"
}
];
const TypeList =[
{
value: "0",
label: "现金"
},
{
value: "1",
label: "折扣"
}
]
export default { export default {
baseUrl baseUrl,rangList,TypeList
//commonFun //commonFun
}; };
</script> </script>

View File

@@ -1,5 +1,5 @@
<template> <template>
<el-dialog :title="!dataForm.id ? '新增' : '修改'" :close-on-click-modal="false" :visible.sync="visible" width="900px"> <el-dialog :title="!dataForm.id ? '新增' : '修改'" :close-on-click-modal="false" :visible.sync="visible" width="900px" @close="closeDia">
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()"
label-width="100px"> label-width="100px">
<el-row :gutter="10"> <el-row :gutter="10">
@@ -22,11 +22,11 @@
</el-input> </el-input>
</el-form-item></el-col> </el-form-item></el-col>
<el-col :span="8"><el-form-item label="商品类型" prop="couponProType"> <el-col :span="8"><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 v-model="dataForm.couponProType" placeholder="请选择"> <el-select v-model="dataForm.couponRange" placeholder="请选择">
<el-option <el-option
v-for="item in options2" v-for="item in rangList"
:key="item.value" :key="item.value"
:label="item.label" :label="item.label"
:value="item.value"> :value="item.value">
@@ -58,29 +58,32 @@
<el-row ::gutter="10"> <el-row ::gutter="10">
</el-row> </el-row>
<el-row ::gutter="10"> <el-row ::gutter="10">
<el-col :span="8"> <el-col :span="24">
<el-form-item label="开始时间" prop="takeEffectType"> <el-form-item label="生效方式" prop="effectType">
<el-radio-group v-model="dataForm.takeEffectType"> <el-radio-group v-model="dataForm.effectType">
<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-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="开始时间" prop="takeEffectDate" v-if="dataForm.takeEffectType == '1'"> <el-form-item label="开始时间" prop="effectTime" v-if="dataForm.effectType == '2'">
<el-date-picker <el-date-picker
v-model="dataForm.takeEffectDate" @change="datePicked" v-model="dataForm.effectTime" @change="datePicked"
type="datetime" value-format="timestamp" type="datetime" value-format="timestamp"
placeholder="选择日期时间" placeholder="选择日期时间"
default-time="12:00:00"> default-time="12:00:00">
</el-date-picker> </el-date-picker>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8" v-show="dataForm.effectType == '1'">
<el-form-item label="时效" prop="validity"> <el-form-item label="时效" prop="validity">
<el-input placeholder="" v-model="dataForm.validity" oninput="value=value.replace(/[^\d.]/g,'')"> <el-input placeholder="" v-model="dataForm.validity" oninput="value=value.replace(/[^\d.]/g,'')">
<template slot="append"></template> <template slot="append"></template>
</el-input> </el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row>
<el-row ::gutter="10">
<el-col :span="8"> <el-col :span="8">
<el-form-item label="总发行量" prop="totalCirculation"> <el-form-item label="总发行量" prop="totalCirculation">
<el-input v-model="dataForm.totalCirculation" placeholder="发行数量" oninput="value=value.replace(/[^\d.]/g,'')"> <el-input v-model="dataForm.totalCirculation" placeholder="发行数量" oninput="value=value.replace(/[^\d.]/g,'')">
@@ -103,10 +106,17 @@
</el-dialog> </el-dialog>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="24">
<el-form-item label="备注" prop="remark">
<el-input v-model="dataForm.remark" placeholder="备注" type="textarea" rows="2" autosize>
</el-input>
</el-form-item>
</el-col>
</el-row> </el-row>
</el-form> </el-form>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button @click="visible = false">取消</el-button> <el-button @click="closeDia">取消</el-button>
<el-button type="primary" @click="dataFormSubmit()">确定</el-button> <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
</span> </span>
</el-dialog> </el-dialog>
@@ -119,7 +129,7 @@ export default {
data() { data() {
return { return {
baseUrl:global.baseUrl, baseUrl:global.baseUrl,
visible: false, visible: true,
options2: [{ options2: [{
value: 0, value: 0,
label: '商品' label: '商品'
@@ -135,12 +145,13 @@ export default {
value: 1, value: 1,
label: '折扣券' label: '折扣券'
}], }],
rangList: global.rangList,
TypeList: global.TypeList,
dialogVisible:false, dialogVisible:false,
fileList: [], // 封面图 fileList: [], // 封面图
dataForm: { dataForm: {
couponType:null, couponType:null,
couponProType:null, // 使用商品类型 couponRange:null, // 使用商品类型
useLevel:null, // 使用门槛 useLevel:null, // 使用门槛
id: 0, id: 0,
couponName:'', couponName:'',
@@ -148,8 +159,8 @@ export default {
couponUrl:'', couponUrl:'',
limitedCollar:null, limitedCollar:null,
validity:'', validity:'',
takeEffectType: null, // 生效方式 effectType: null, // 生效方式
takeEffectDate:null, effectTime:null,
totalCirculation:null, totalCirculation:null,
remark:'' remark:''
@@ -164,13 +175,13 @@ export default {
couponAmount: [ couponAmount: [
{ required: true, message: '优惠券面额不能为空', trigger: 'blur' } { required: true, message: '优惠券面额不能为空', trigger: 'blur' }
], ],
takeEffectType: [ effectType: [
{ required: true, message: '生效方式不能为空', trigger: 'blur' } { required: true, message: '生效方式不能为空', trigger: 'blur' }
], ],
validity: [ // validity: [
{ required: true, message: '时效不能为空', trigger: 'blur' } // { required: true, message: '时效不能为空', trigger: 'blur' }
], // ],
couponProType: [ couponRange: [
{ required: true, message: '商品类型不能为空', trigger: 'blur' } { required: true, message: '商品类型不能为空', trigger: 'blur' }
], ],
useLevel: [ useLevel: [
@@ -217,26 +228,18 @@ export default {
this.$refs['dataForm'].resetFields() this.$refs['dataForm'].resetFields()
if (this.dataForm.id) { if (this.dataForm.id) {
this.$http({ this.$http({
url: this.$http.adornUrl(`/book/coupon/info/${this.dataForm.id}`), url: this.$http.adornUrl(`/common/coupon/getCouponInfo`),
method: 'get', method: 'post',
params: this.$http.adornParams() data: this.$http.adornData(
{ id: this.dataForm.id}
)
}).then(({ data }) => { }).then(({ data }) => {
if(data.code !==0) return this.$message.error(data.msg)
if (data && data.code === 0) { if (data && data.code === 0) {
this.dataForm.id = data.coupon.id this.dataForm = data.couponEntity
this.dataForm.couponType = data.coupon.couponType
this.dataForm.couponName = data.coupon.couponName
this.dataForm.couponAmount = data.coupon.couponAmount
this.dataForm.limitedCollar = data.coupon.limitedCollar
this.dataForm.validity = data.coupon.validity
this.dataForm.takeEffectType = data.coupon.takeEffectType
this.dataForm.takeEffectDate = data.coupon.takeEffectDate
this.dataForm.totalCirculation = data.coupon.totalCirculation
this.dataForm.remark = data.coupon.remark
this.dataForm.useLevel = data.coupon.useLevel,
this.dataForm.couponProType = data.coupon.couponProType
// this.dataForm.couponUrl = {name:'', url:} // this.dataForm.couponUrl = {name:'', url:}
if (data.coupon.couponUrl != "") { if (data.couponEntity.couponUrl != "") {
var img = { name: '', url: data.coupon.couponUrl } var img = { name: '', url: data.ouponEntity.couponUrl }
var attr = [] var attr = []
attr.push(img) attr.push(img)
this.fileList = attr this.fileList = attr
@@ -264,12 +267,35 @@ export default {
datePicked(){ datePicked(){
console.log(this.dataForm.startTime) console.log(this.dataForm.startTime)
}, },
closeDia(){
this.visible = false
this.dataForm.couponUrl = '';
this.$refs.dataForm.resetFields()
this.dataForm ={
couponType:null,
couponRange:null, // 使用商品类型
useLevel:null, // 使用门槛
id: 0,
couponName:'',
couponAmount:null,
couponUrl:'',
limitedCollar:null,
validity:'',
effectType: null, // 生效方式
effectTime:null,
totalCirculation:null,
remark:''
}
},
// 表单提交 // 表单提交
dataFormSubmit() { dataFormSubmit() {
this.$refs['dataForm'].validate((valid) => { this.$refs['dataForm'].validate((valid) => {
if (valid) { if (valid) {
this.$http({ this.$http({
url: this.$http.adornUrl(`/book/coupon/${!this.dataForm.id ? 'save' : 'update'}`), url: this.$http.adornUrl(`/common/coupon/${!this.dataForm.id ? 'addCoupon' : 'updateCoupon'}`),
method: 'post', method: 'post',
data: this.$http.adornData({ data: this.$http.adornData({
'id': this.dataForm.id || undefined, 'id': this.dataForm.id || undefined,
@@ -279,29 +305,33 @@ export default {
'couponUrl': this.dataForm.couponUrl, 'couponUrl': this.dataForm.couponUrl,
'limitedCollar' :this.dataForm.limitedCollar, 'limitedCollar' :this.dataForm.limitedCollar,
'validity' :this.dataForm.validity, 'validity' :this.dataForm.validity,
'takeEffectType' :this.dataForm.takeEffectType, 'effectType' :this.dataForm.effectType,
'takeEffectDate' :this.dataForm.takeEffectDate, 'effectTime' :this.dataForm.effectTime,
'totalCirculation' :this.dataForm.totalCirculation, 'totalCirculation' :this.dataForm.totalCirculation,
'remark':this.dataForm.remark , 'remark':this.dataForm.remark ,
'useLevel' : this.dataForm.useLevel, 'useLevel' : this.dataForm.useLevel,
'couponProType' : this.dataForm.couponProType, 'couponRange' : this.dataForm.couponRange,
'currentState' : '1', 'currentState' : '1',
'delFlag':0 'delFlag':0
}) })
}).then(({ data }) => { }).then(({ data }) => {
if(data.code!==0) return this.$message.error(data.msg)
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.visible = false this.dataForm.couponUrl = ''
this.closeDia()
this.$emit('refreshDataList') this.$emit('refreshDataList')
} }
}) })
} else {
this.$message.error(data.msg)
} }
}).catch((err) => {
this.$message.error(err.msg)
}) })
} }
}) })

View File

@@ -1,17 +1,38 @@
<template> <template>
<div class="mod-config"> <div class="mod-config">
<el-radio-group size="mini" v-model="couponActiveName" style="margin-bottom: 15px;" @tab-click="handleClick"> <el-radio-group v-model="currentState" style="margin-bottom: 15px;" @tab-click="handleClick">
<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-button label="2">已过期</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 size="mini" v-model="dataForm.key" placeholder="参数名" clearable></el-input> <el-input v-model="dataForm.couponName" placeholder="参数名" clearable></el-input>
</el-form-item>
<el-form-item label="优惠卷范围">
<el-select v-model="dataForm.couponRange" placeholder="请选择" @change="pageIndex = 1; getDataList()">
<el-option
v-for="item in rangList"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="优惠券类型">
<el-select v-model="dataForm.TypeList" placeholder="请选择" @change="pageIndex = 1; getDataList()">
<el-option
v-for="item in TypeList"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option>
</el-select>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button size="mini" @click="getDataList()">查询</el-button> <el-button @click="getDataList()">查询</el-button>
<el-button size="mini" 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>
@@ -43,29 +64,41 @@
prop="couponType" prop="couponType"
header-align="center" header-align="center"
align="center" align="center"
label="优惠卷类型"> label="优惠卷类型" width="100px">
<template slot-scope="scope">
<span v-if="scope.row.couponProType == 0">商品用券</span>
<span v-if="scope.row.couponProType == 1">电子书用券</span>
</template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="couponAmount" prop="couponAmount"
header-align="center" header-align="center"
align="center" align="center"
label="面值"> 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">
<span v-if="scope.row.createTime">创建时间{{scope.row.createTime}}</span>
<span v-if="scope.row.effectTime"><br/>生效时间{{scope.row.effectTime}}</span>
<span v-if="scope.row.expireTime"><br/>结束时间{{scope.row.expireTime}}</span>
</template>
</el-table-column>
<el-table-column
prop="couponRange"
header-align="center"
align="center"
label="优惠券范围">
<template slot-scope="scope">
{{scope.row.couponRange | getRange}}
</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="发行数量"> label="发行数量" width="90px">
</el-table-column> </el-table-column>
<!-- <el-table-column <!-- <el-table-column
prop="useCount" prop="useCount"
@@ -106,15 +139,22 @@
</template> </template>
<script> <script>
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'
export default { export default {
data () { data () {
return { return {
dataForm: { dataForm: {
key: '' couponName: '',
couponRange: '',
couponType:''
}, },
couponActiveName:'0', currentState:'0', // "currentState":""//当前状态 0 发放中 1结束
dataList: [], dataList: [],
rangList: global.rangList,
TypeList: global.TypeList,
pageIndex: 1, pageIndex: 1,
pageSize: 10, pageSize: 10,
totalPage: 0, totalPage: 0,
@@ -123,6 +163,25 @@
addOrUpdateVisible: false addOrUpdateVisible: false
} }
}, },
filters: {
// 格式化时间
getRange (value) {
// if (value && value != 0) {
// console.log('555555555',value)
switch (value) {
case 0:
return '无限制'
case 1:
return '课程券'
case 2:
return '课程品类券'
}
// } else {
// return ''
// }
}
},
components: { components: {
AddOrUpdate AddOrUpdate
}, },
@@ -131,24 +190,30 @@
}, },
methods: { methods: {
handleClick(){ handleClick(){
console.log(this.couponActiveName) console.log(this.currentState)
this.pageIndex = 1
this.getDataList()
}, },
// 获取数据列表 // 获取数据列表
getDataList () { getDataList () {
this.dataListLoading = true this.dataListLoading = true
this.$http({ this.$http({
url: this.$http.adornUrl('/book/coupon/list'), url: this.$http.adornUrl('/common/coupon/getCouponList'),
method: 'get', method: 'post',
params: this.$http.adornParams({ data: this.$http.adornData({
'page': this.pageIndex, 'page': this.pageIndex,
'limit': this.pageSize, 'limit': this.pageSize,
'key': this.dataForm.key, 'couponName': this.dataForm.couponName,
'currentState': this.couponActiveName 'currentState': this.currentState, //当前状态 0 发放中 1结束
"couponType": this.dataForm.couponType,//优惠券类型 0现金 1折扣
"couponRange":this.dataForm.couponRange,//优惠卷范围 0无限制 1课程卷 2课程品类卷
}) })
}).then(({data}) => { }).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.page.list this.dataList = data.couponPage.records
this.totalPage = data.page.totalCount this.totalPage = data.couponPage.total
} else { } else {
this.dataList = [] this.dataList = []
this.totalPage = 0 this.totalPage = 0
@@ -209,7 +274,7 @@
}) })
} }
},watch:{ },watch:{
couponActiveName: { currentState: {
handler(val, oldVal) { handler(val, oldVal) {
this.getDataList() this.getDataList()
}, },