This commit is contained in:
2024-10-29 16:42:06 +08:00
12 changed files with 2172 additions and 343 deletions

View File

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

View File

@@ -1,181 +1,352 @@
<template>
<el-dialog :title="!dataForm.id ? '新增' : '修改'" :close-on-click-modal="false" :visible.sync="visible" width="900px">
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()"
label-width="100px">
<div v-loading.fullscreen.lock="getCouponInfoLoad">
<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()"
label-width="100px"
>
<el-row :gutter="10">
<el-col :span="8">
<el-form-item label="优惠卷类型" prop="couponType">
<!-- <el-input v-model="dataForm.type" placeholder="优惠卷类型"></el-input> -->
<el-select v-model="dataForm.couponType" placeholder="请选择">
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8"><el-form-item label="使用门槛" prop="useLevel">
<el-input v-model="dataForm.useLevel" placeholder="" oninput="value=value.replace(/[^\d.]/g,'')">
<template slot="append"></template>
</el-input>
</el-form-item></el-col>
<el-col :span="8"><el-form-item label="商品类型" prop="couponProType">
<!-- <el-input v-model="dataForm.type" placeholder="优惠卷类型"></el-input> -->
<el-select v-model="dataForm.couponProType" placeholder="请选择">
<el-option
v-for="item in options2"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item></el-col>
</el-row>
<el-row :gutter="10">
<el-col :span="8">
<el-form-item label="优惠券名称" prop="couponName">
<el-input v-model="dataForm.couponName" placeholder="名称"></el-input>
<el-form-item label="优惠卷类型" prop="couponType">
<!-- <el-input v-model="dataForm.type" placeholder="优惠卷类型"></el-input> -->
<el-select v-model="dataForm.couponType" placeholder="请选择">
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="面额:" prop="couponAmount">
<el-input v-model="dataForm.couponAmount" placeholder="面额" oninput="value=value.replace(/[^\d.]/g,'')">
<el-col :span="8"
><el-form-item label="使用门槛" prop="useLevel">
<el-input
v-model="dataForm.useLevel"
placeholder=""
oninput="value=value.replace(/[^\d.]/g,'')"
>
<template slot="append"></template>
</el-input>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="每人限领" prop="limitedCollar">
<el-input v-model="dataForm.limitedCollar" oninput="value=value.replace(/[^\d.]/g,'')" placeholder="">
<template slot="append"></template>
<el-form-item label="面额" prop="couponAmount">
<el-input
v-model="dataForm.couponAmount"
placeholder="面额"
oninput="value=value.replace(/[^\d.]/g,'')"
>
<template slot="append"></template>
</el-input>
</el-form-item>
</el-col>
</el-row>
<el-row ::gutter="10">
</el-row>
<el-row ::gutter="10">
<el-row :gutter="10">
<el-col :span="8">
<el-form-item label="开始时间" prop="takeEffectType">
<el-radio-group v-model="dataForm.takeEffectType">
<el-radio :label="0">领取日</el-radio>
<el-radio :label="1">设置日期</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="开始时间" prop="takeEffectDate" v-if="dataForm.takeEffectType == '1'">
<el-date-picker
v-model="dataForm.takeEffectDate" @change="datePicked"
type="datetime" value-format="timestamp"
placeholder="选择日期时间"
default-time="12:00:00">
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="时效" prop="validity">
<el-input placeholder="" v-model="dataForm.validity" oninput="value=value.replace(/[^\d.]/g,'')">
<template slot="append"></template>
</el-input>
<el-form-item label="优惠券名称" prop="couponName">
<el-input
v-model="dataForm.couponName"
placeholder="名称"
></el-input>
</el-form-item>
</el-col>
<el-col :span="8">
<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,'')"
>
<template slot="append"></template>
</el-input>
</el-input>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="每人限领:" prop="limitedCollar">
<el-input
v-model="dataForm.limitedCollar"
oninput="value=value.replace(/[^\d.]/g,'')"
placeholder=""
>
<template slot="append"></template>
</el-input>
</el-form-item>
</el-col>
</el-row>
<el-row ::gutter="10"> </el-row>
<el-row ::gutter="10">
<el-col :span="8">
<el-form-item label="优惠卷范围" prop="couponRange">
<!-- <el-input v-model="dataForm.type" placeholder="优惠卷类型"></el-input> -->
<el-select
v-model="dataForm.couponRange"
placeholder="请选择"
@change="changeRange"
>
<el-option
v-for="item in rangList"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="16" v-if="dataForm.couponRange == 2">
<el-form-item label="绑定类目" prop="rangeInfo" width="100%">
<!-- <el-input v-model="dataForm.type" placeholder="优惠卷类型"></el-input> -->
<!-- {{cateSelectLinkList}} -->
<el-select
v-model="cateSelectLinkList"
multiple
placeholder="请选择课程类目"
@change="changeCate"
>
<el-option
v-for="item in courseCateList"
:key="item.id"
:label="item.title"
:value="item.id"
>
</el-option>
</el-select>
<span v-if="showCateError" style="color:red; font-size:12px">请选择绑定类目</span>
</el-form-item>
</el-col>
<el-col :span="24" v-if="dataForm.couponRange == 1">
<el-form-item label="" prop="rangeInfo" width="100%">
<div class="flexBox">
<el-table v-if="proSelectLinkList.length > 0" :data="proSelectLinkList">
<el-table-column label="课程名称">
<template slot-scope="scope">
{{ scope.row.title }}
</template>
</el-table-column>
<el-table-column label="封面">
<template slot-scope="scope">
<div
v-if="scope.row.image"
style="width:100%;display: flex;
align-items: center;justify-content: center;"
>
<img :src="scope.row.image" alt="" width="40px" height="40px" />
</div>
</template>
</el-table-column>
<el-table-column label="操作" width="100px">
<template slot-scope="scope">
<el-button type="danger" @click="delCourse(scope.row.id)" size="mini"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
<div
style="text-align:center; margin-top: 20px"
>
<el-button type="primary" @click="addLinkPro">添加绑定</el-button>
</div>
</div>
</el-form-item>
</el-col>
</el-row>
<el-row ::gutter="10">
<el-col :span="24">
<el-form-item label="生效方式" prop="effectType">
<el-radio-group v-model="dataForm.effectType">
<el-radio :label="0">长期有效</el-radio>
<el-radio :label="1">领取生效</el-radio>
<el-radio :label="2">自定义</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="10">
<el-col :span="12">
<el-form-item
label="开始时间"
prop="effectTime"
v-if="dataForm.effectType == '2'"
>
<el-date-picker
v-model="dataForm.effectTime"
@change="datePicked"
type="datetime"
value-format="timestamp"
placeholder="选择日期时间"
default-time="12:00:00"
>
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="结束时间"
prop="expireTime"
v-if="dataForm.effectType == '2'"
>
<el-date-picker
v-model="dataForm.expireTime"
@change="datePicked"
type="datetime"
value-format="timestamp"
placeholder="选择日期时间"
default-time="12:00:00"
>
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span="8" v-show="dataForm.effectType == '1'">
<el-form-item label="时效" prop="validity">
<el-input
placeholder=""
v-model="dataForm.validity"
oninput="value=value.replace(/[^\d.]/g,'')"
>
<template slot="append"></template>
</el-input>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="10">
<el-col :span="24">
<el-form-item label="封面图" prop="couponUrl">
<el-upload :limit="1" class="el-uploadfeng"
:action= "baseUrl + '/oss/fileoss'" list-type="picture-card"
:on-preview="handlePictureCardPreview" :file-list="fileList" :on-success="handlePicSuccess"
accept=".jpeg,.jpg,.gif,.png" :on-remove="handleRemove">
<i class="el-icon-plus"></i>
</el-upload>
<el-dialog :visible.sync="dialogVisible" :append-to-body="true">
<img width="100%" :src="dataForm.couponUrl" alt="">
</el-dialog>
</el-form-item>
<el-upload
:limit="1"
class="el-uploadfeng"
:action="baseUrl + '/oss/fileoss'"
list-type="picture-card"
:on-preview="handlePictureCardPreview"
:file-list="fileList"
:on-success="handlePicSuccess"
accept=".jpeg,.jpg,.gif,.png"
:on-remove="handleRemove"
>
<i class="el-icon-plus"></i>
</el-upload>
<el-dialog :visible.sync="dialogVisible" :append-to-body="true">
<img width="100%" :src="dataForm.couponUrl" alt="" />
</el-dialog>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="备注" prop="remark">
<el-input
v-model="dataForm.remark"
placeholder="备注"
type="textarea"
:rows="3"
autosize
>
</el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
<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>
</span>
</el-dialog>
<selectPro ref="selectPro" v-if="showSelectPro" @close="selectProClose" :requesturl = "requesturl" :oldData="proSelectLinkList"></selectPro>
</div>
</template>
<script>
import global from '../../common/common.vue' //引入共用组间
import selectPro from '../../../components/selectPro.vue'
import global from "../../common/common.vue"; //引入共用组间
export default {
baseUrl:global.baseUrl,
baseUrl: global.baseUrl,
data() {
return {
baseUrl:global.baseUrl,
visible: false,
options2: [{
value: 0,
label: '商品'
},{
value: 1,
label: '电子书'
}
showCateError: false,
requesturl:'', // 课程的请求地址
showSelectPro:false,
baseUrl: global.baseUrl,
visible: true,
options2: [
{
value: 0,
label: "商品"
},
{
value: 1,
label: "电子书"
}
],
options: [{
value: 0,
label: '现金券'
}, {
value: 1,
label: '折扣券'
}],
dialogVisible:false,
options: [
{
value: 0,
label: "现金券"
},
{
value: 1,
label: "折扣券"
}
],
rangList: global.rangList,
TypeList: global.TypeList,
dialogVisible: false,
fileList: [], // 封面图
rangeInfo: [],
courseCateList: [], //课程品类列表
selectLinkList: [], // 选中的商品列表()
cateSelectLinkList: [], // 选中的课程品类列表
proSelectLinkList: [], // 选中的商品列表()
dataForm: {
couponType:null,
couponProType:null, // 使用商品类型
useLevel:null, // 使用门槛
id: 0,
couponName:'',
couponAmount:null,
couponUrl:'',
limitedCollar:null,
validity:'',
takeEffectType: null, // 生效方式
takeEffectDate:null,
totalCirculation:null,
remark:''
id: undefined,
couponType: 0, //优惠券类型 0现金 1折扣
couponName: "", //优惠券名称
couponAmount: undefined, //优惠券面额
couponUrl: "", //优惠券封面
limitedCollar: 1, //每人限领
validity: 7, //时效(天)
effectType: 0, //生效方式 0长期有效 1领取生效 2自定义
effectTime: null, //生效日期
expireTime: null, //截止日期
totalCirculation: 100, //总发行数量
remark: "", //备注
useLevel: undefined, //使用门槛
couponRange: "", //优惠卷范围 0无限制 1课程卷 2课程品类卷
rangeInfo: "" //范围详情(课程卷是课程id,分割 课程品类卷是课程分类根id,分割)
},
getCouponInfoLoad: false, // 获取优惠券loadding
dataRule: {
couponType: [
{ required: true, message: '请填写本项', trigger: 'blur' }
{ required: true, message: "请填写本项", trigger: "blur" }
],
couponName: [
{ required: true, message: '名称不能为空', trigger: 'blur' }
{ required: true, message: "名称不能为空", trigger: "blur" }
],
couponAmount: [
{ required: true, message: '优惠券面额不能为空', trigger: 'blur' }
{ required: true, message: "优惠券面额不能为空", trigger: "blur" }
],
takeEffectType: [
{ required: true, message: '生效方式不能为空', trigger: 'blur' }
effectType: [
{ required: true, message: "生效方式不能为空", trigger: "blur" }
],
validity: [
{ required: true, message: '时效不能为空', trigger: 'blur' }
],
couponProType: [
{ required: true, message: '商品类型不能为空', trigger: 'blur' }
// validity: [
// { required: true, message: '时效不能为空', trigger: 'blur' }
// ],
couponRange: [
{ required: true, message: "商品类型不能为空", trigger: "blur" }
],
useLevel: [
{ required: true, message: '使用门槛0表示无门槛', trigger: 'blur' }
],
{ required: true, message: "使用门槛0表示无门槛", trigger: "blur" }
]
// startTime: [
// { required: true, message: '开始使用时间不能为空', trigger: 'blur' }
// ],
@@ -207,44 +378,148 @@ export default {
// { required: true, message: '可领取的会员类型0->无限制不能为空', trigger: 'blur' }
// ]
}
}
};
},
async created(){
// if (e == 2) {
this.courseCateList = await this.getCourseCateList();
console.log("this.courseCateList", await this.getCourseCateList());
// }
},
methods: {
selectProClose(data){
console.log('data', data)
this.showSelectPro = false
this.requesturl = ''
if(data.length > 0){
this.proSelectLinkList = this.proSelectLinkList.concat(data)
var list = [...this.proSelectLinkList]
this.proSelectLinkList = [...new Map(list.map(item => [item.id, item])).values()];
// this.dataForm.rangeInfo = this.proSelectLinkList.map( item => item.id).join(',')
console.log('去重后', this.proSelectLinkList)
}
},
addLinkPro(){
this.showSelectPro = true
this.requesturl = '/common/coupon/getCourseList'
},
changeCate(e) {
console.log("e", e);
this.cateSelectLinkList = e;
this.showCateError = false
// this.dataForm.rangeInfo = e.join(",");
},
async changeRange(e) {
console.log("范围切换", e);
// this.dataForm.couponRange = e
// this.getDataList()
},
async getCourseCateList() {
var list = [];
await this.$http({
url: this.$http.adornUrl("/master/courseMedical/getCourseMedicalList"),
method: "post",
data: this.$http.adornData({})
})
.then(async ({ data }) => {
if (data.code !== 0) return this.$message.error(data.msg);
console.log("data.Medicals", data.Medicals);
if (data && data.code == 0) {
this.courseCateList = data.Medicals;
} else {
this.courseCateList = [];
}
// this.dataListLoading = false
})
.catch(err => {
this.$message.error(err.msg);
});
return list;
},
init(id) {
this.dataForm.id = id || 0
this.visible = true
if(!id){
console.log('没有传值')
this.visible = true;
return
}
this.dataForm.id = id || 0;
this.getCouponInfoLoad = true;
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
this.$refs["dataForm"].resetFields();
if (this.dataForm.id) {
this.$http({
url: this.$http.adornUrl(`/book/coupon/info/${this.dataForm.id}`),
method: 'get',
params: this.$http.adornParams()
url: this.$http.adornUrl(`/common/coupon/getCouponInfo`),
method: "post",
data: this.$http.adornData({ id: this.dataForm.id })
}).then(({ data }) => {
if (data && data.code === 0) {
this.dataForm.id = data.coupon.id
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
if (data.code !== 0) return this.$message.error(data.msg);
this.visible = true;
this.getCouponInfoLoad = false;
if (data && data.code == 0) {
this.dataForm = data.couponEntity;
if (
this.dataForm.effectTime &&
this.dataForm.effectTime != null
) {
this.dataForm.effectTime = new Date(
data.couponEntity.effectTime
).getTime();
console.log("this.dataForm.effectTime", this.dataForm.effectTime );
} else {
this.dataForm.effectTime = null;
}
if (
this.dataForm.expireTime &&
this.dataForm.expireTime != null
) {
this.dataForm.expireTime = new Date(
data.couponEntity.expireTime
).getTime();
console.log(
"this.dataForm.expireTime",
this.dataForm.expireTime
);
} else {
this.dataForm.expireTime = null;
}
if(data.couponEntity.rangeList && data.couponEntity.rangeList.length > 0){
this.selectLinkList = data.couponEntity.rangeList
}else{
this.selectLinkList = []
}
if(this.dataForm.couponRange == 2 && this.dataForm.rangeInfo.length > 0 ){
// var list1 = [...this.selectLinkList]
// list1.forEach( item => {
// item.label = item.name
// })
// this.cateSelectLinkList = this.selectLinkList
var ss = this.dataForm.rangeInfo.split(',')
this.cateSelectLinkList = ss.map(element => parseInt(element) );
}else if(this.dataForm.couponRange == 1){
this.proSelectLinkList = this.selectLinkList
}else{
this.cateSelectLinkList = []
this.proSelectLinkList = []
}
// this.dataForm.couponUrl = {name:'', url:}
if (data.coupon.couponUrl != "") {
var img = { name: '', url: data.coupon.couponUrl }
var attr = []
attr.push(img)
this.fileList = attr
if (this.dataForm.couponUrl && this.dataForm.couponUrl != "") {
var img = { name: "", url: this.dataForm.couponUrl };
var attr = [];
attr.push(img);
this.fileList = attr;
}else{
this.fileList = []
}
}
}).catch(err => {
this.$message.error(err.msg);
this.getCouponInfoLoad = false;
})
}
})
});
},
handlePicSuccess(res, file) {
if (res.msg == "success") {
@@ -255,59 +530,148 @@ export default {
}
},
handleRemove(file, fileList) {
this.dataForm.couponUrl = '';
this.dataForm.couponUrl = "";
},
handlePictureCardPreview(file) {
this.dataForm.couponUrl = file.url;
this.dialogVisible = true;
},
datePicked(){
console.log(this.dataForm.startTime)
datePicked() {
console.log(this.dataForm.startTime);
},
delCourse(id) {
console.log('id',id)
let index = this.proSelectLinkList.findIndex(item => item.id === id);
this.proSelectLinkList.splice(index,1)
},
closeDia() {
this.visible = false;
this.dataForm.couponUrl = "";
this.$refs.dataForm.resetFields();
this.dataForm = {
id: undefined,
couponType: 0, //优惠券类型 0现金 1折扣
couponName: "", //优惠券名称
couponAmount: undefined, //优惠券面额
couponUrl: "", //优惠券封面
limitedCollar: 1, //每人限领
validity: 7, //时效(天)
effectType: 0, //生效方式 0长期有效 1领取生效 2自定义
effectTime: null, //生效日期
expireTime: null, //截止日期
totalCirculation: 100, //总发行数量
remark: "", //备注
useLevel: undefined, //使用门槛
couponRange: "", //优惠卷范围 0无限制 1课程卷 2课程品类卷
rangeInfo: "" //范围详情(课程卷是课程id,分割 课程品类卷是课程分类根id,分割)
};
this.proSelectLinkList = []
this.cateSelectLinkList = []
this.selectLinkList = []
this.fileList = []
},
// 表单提交
dataFormSubmit() {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
this.$http({
url: this.$http.adornUrl(`/book/coupon/${!this.dataForm.id ? 'save' : 'update'}`),
method: 'post',
data: this.$http.adornData({
'id': this.dataForm.id || undefined,
'couponType':this.dataForm.couponType,
'couponName':this.dataForm.couponName,
'couponAmount' :this.dataForm.couponAmount,
'couponUrl': this.dataForm.couponUrl,
'limitedCollar' :this.dataForm.limitedCollar,
'validity' :this.dataForm.validity,
'takeEffectType' :this.dataForm.takeEffectType,
'takeEffectDate' :this.dataForm.takeEffectDate,
'totalCirculation' :this.dataForm.totalCirculation,
'remark':this.dataForm.remark ,
'useLevel' : this.dataForm.useLevel,
'couponProType' : this.dataForm.couponProType,
'currentState' : '1',
'delFlag':0
})
}).then(({ data }) => {
if (data && data.code === 0) {
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.visible = false
this.$emit('refreshDataList')
}
})
} else {
this.$message.error(data.msg)
this.$refs["dataForm"].validate(valid => {
if (valid) {
if(!this.dataForm.id && this.dataForm.effectType == 2 && this.dataForm.effectTime < new Date().getTime()) return this.$message.error("生效时间不能小于当前时间")
if (this.dataForm.effectType == 2 ) {
if (
this.dataForm.effectTime == null ||
this.dataForm.effectTime == ""
) {
this.$message.error("生效时间不能为空");
return false;
}
if (
this.dataForm.expireTime == null ||
this.dataForm.expireTime == ""
) {
this.$message.error("截止时间不能为空");
return false;
}
if (this.dataForm.effectTime > this.dataForm.expireTime) {
this.$message.error("生效时间不能大于截止时间");
return false;
}
}
if (this.dataForm.effectType == 1) {
if (
this.dataForm.validity == null ||
this.dataForm.validity == "" ||
this.dataForm.validity == 0
) {
this.$message.error("时效不能为空");
return false;
}
}
if (this.dataForm.couponRange == 2) {
if(this.cateSelectLinkList.length == 0) {this.showCateError = true; return this.$message.error("请选择课程品类");}
this.dataForm.rangeInfo = this.cateSelectLinkList.join(',')
// if (
// this.dataForm.rangeInfo == null ||
// this.dataForm.rangeInfo == ""
// ) {
// this.$message.error("请选择课程品类");
// return false;
// }
}
if (this.dataForm.couponRange == 1) {
if(this.proSelectLinkList.length == 0) return this.$message.error("请选择课程");
this.dataForm.rangeInfo = this.proSelectLinkList.map( item => item.id).join(',')
// if (
// this.dataForm.rangeInfo == null ||
// this.dataForm.rangeInfo == ""
// ) {
// this.$message.error("请选择课程");
// return false;
// }
}
if(this.dataForm.useLevel < this.dataForm.couponAmount) return this.$message.error("优惠券面额不能大于使用门槛");
console.log('this.dataForm', this.dataForm)
this.$http({
url: this.$http.adornUrl(
`/common/coupon/${
!this.dataForm.id ? "addCoupon" : "updateCoupon"
}`
),
method: "post",
data: this.$http.adornData({
...this.dataForm
})
})
.then(({ data }) => {
if (data.code !== 0) return this.$message.error(data.msg);
if (data && data.code === 0) {
this.$message({
message: "操作成功",
type: "success",
duration: 1500,
onClose: () => {
this.dataForm.couponUrl = "";
this.closeDia();
this.$emit("refreshDataList");
}
});
}
})
.catch(err => {
this.$message.error(err.msg);
});
}
})
});
}
},
components: {
selectPro
}
}
};
</script>
<style lang="less" scoped>
.el-form-item__label {
@@ -323,6 +687,6 @@ export default {
width: 60px;
height: 60px;
line-height: 70px;
}}
}
}
</style>

View File

@@ -1,17 +1,39 @@
<template>
<div class="mod-config">
<el-radio-group size="mini" v-model="couponActiveName" style="margin-bottom: 15px;" @tab-click="handleClick">
<el-radio-button label="0">全部</el-radio-button>
<el-radio-button label="1">生效中</el-radio-button>
<el-radio-button label="2">已过期</el-radio-button>
<el-radio-group v-model="currentState" style="margin-bottom: 15px;" @tab-click="handleClick">
<el-radio-button label="">全部</el-radio-button>
<el-radio-button label="0">生效中</el-radio-button>
<el-radio-button label="1">已过期</el-radio-button>
</el-radio-group>
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
<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-button size="mini" @click="getDataList()">查询</el-button>
<el-button size="mini" v-if="isAuth('book:coupon:save')" type="primary" @click="addOrUpdateHandle()">新增</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:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button> -->
</el-form-item>
</el-form>
@@ -21,12 +43,12 @@
v-loading="dataListLoading"
@selection-change="selectionChangeHandle"
style="width: 100%;">
<el-table-column
<!-- <el-table-column
type="selection"
header-align="center"
align="center"
width="50">
</el-table-column>
</el-table-column> -->
<el-table-column
prop="id"
header-align="center"
@@ -39,33 +61,47 @@
align="center"
label="优惠券名称">
</el-table-column>
<el-table-column
prop="couponType"
<el-table-column
header-align="center"
align="center"
label="优惠类型">
<template slot-scope="scope">
<span v-if="scope.row.couponProType == 0">商品用券</span>
<span v-if="scope.row.couponProType == 1">电子书用券</span>
</template>
label="优惠类型" width="100px">
<template slot-scope="scope">
{{scope.row.effectType | getType}}
</template>
</el-table-column>
<el-table-column
prop="couponAmount"
header-align="center"
align="center"
label="面值">
</el-table-column>
label="面值" width="90px">
</el-table-column>
<el-table-column
prop="expirationDate"
header-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
prop="totalCirculation"
header-align="center"
align="center"
label="发行数量">
label="发行数量" width="90px">
</el-table-column>
<!-- <el-table-column
prop="useCount"
@@ -79,6 +115,22 @@
align="center"
label="领取数量">
</el-table-column> -->
<el-table-column
prop="receiveCount"
header-align="center"
align="center"
label="操作">
<template slot-scope="scope">
<el-switch
v-model="scope.row.currentState"
:active-value ="0"
:inactive-value='1'
@change="changeStateHandle(scope.row.id, scope.row.currentState)"
active-text="发放中"
inactive-text="暂停发放">
</el-switch>
</template>
</el-table-column>
<el-table-column
fixed="right"
header-align="center"
@@ -86,8 +138,8 @@
width="150"
label="操作">
<template slot-scope="scope">
<el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
<!-- <el-button type="text" size="small" @click="deleteHandle(scope.row.id)">删除</el-button> -->
<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>
</el-table-column>
</el-table>
@@ -106,21 +158,53 @@
</template>
<script>
import global from "@/views/common/common.vue"; //引入共用组间
import AddOrUpdate from './coupon-add-or-update'
import commentsListVue from '../book/commentsList.vue'
export default {
data () {
return {
dataForm: {
key: ''
couponName: '',
couponRange: '',
couponType:''
},
couponActiveName:'0',
currentState:'', // "currentState":""//当前状态 0 发放中 1结束
dataList: [],
rangList: global.rangList,
TypeList: global.TypeList,
pageIndex: 1,
pageSize: 10,
totalPage: 0,
dataListLoading: false,
dataListSelections: [],
addOrUpdateVisible: false
addOrUpdateVisible: false,
courseCateList:[]
}
},
filters: {
// 格式化时间
getType (value) {
switch (value) {
case 0:
return '长期有效'
case 1:
return '领取生效'
case 2:
return '自定义'
}
},
getRange (value) {
switch (value) {
case 0:
return '无限制'
case 1:
return '课程券'
case 2:
return '课程品类券'
}
}
},
components: {
@@ -129,31 +213,67 @@
activated () {
this.getDataList()
},
methods: {
methods: {
// 修改优惠券状态
changeStateHandle (id, state) {
console.log('进来了')
this.$http({
url: this.$http.adornUrl('/common/coupon/updateCouponState'),
method: 'post',
data: this.$http.adornData({
id: id,
currentState: state
})
}).then(({data}) => {
if (data && data.code === 0) {
this.$message({
message: '操作成功',
type:'success',
duration: 1500,
onClose: () => {
this.getDataList()
}
})
} else {
this.$message.error(data.msg)
}
}).catch((e) => {
this.$message.error(e.msg)
})
},
handleClick(){
console.log(this.couponActiveName)
console.log(this.currentState)
this.pageIndex = 1
this.getDataList()
},
// 获取数据列表
getDataList () {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/book/coupon/list'),
method: 'get',
params: this.$http.adornParams({
url: this.$http.adornUrl('/common/coupon/getCouponList'),
method: 'post',
data: this.$http.adornData({
'page': this.pageIndex,
'limit': this.pageSize,
'key': this.dataForm.key,
'currentState': this.couponActiveName
'couponName': this.dataForm.couponName,
'currentState': this.currentState, //当前状态 0 发放中 1结束
"couponType": this.dataForm.couponType,//优惠券类型 0现金 1折扣
"couponRange":this.dataForm.couponRange,//优惠卷范围 0无限制 1课程卷 2课程品类卷
})
}).then(({data}) => {
if(data.code !==0) return this.$message.error(data.msg)
if (data && data.code === 0) {
this.dataList = data.page.list
this.totalPage = data.page.totalCount
this.dataList = data.couponPage.records
this.totalPage = data.couponPage.total
} else {
this.dataList = []
this.totalPage = 0
}
this.dataListLoading = false
}).catch((e) => {
this.$message.error(e.msg)
this.dataListLoading = false
})
},
// 每页数
@@ -172,26 +292,29 @@
this.dataListSelections = val
},
// 新增 / 修改
addOrUpdateHandle (id) {
this.addOrUpdateVisible = true
this.$nextTick(() => {
this.$refs.addOrUpdate.init(id)
addOrUpdateHandle (id) {
this.addOrUpdateVisible = true
this.$nextTick(() => {
this.$refs.addOrUpdate.init(id)
// this.addOrUpdateVisible = true
})
},
// 删除
deleteHandle (id) {
var ids = id ? [id] : this.dataListSelections.map(item => {
return item.id
})
this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
// var ids = id ? [id] : this.dataListSelections.map(item => {
// return item.id
// })
this.$confirm(`确定对[id=${id}]进行删除操作?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$http({
url: this.$http.adornUrl('/book/coupon/delete'),
url: this.$http.adornUrl('/common/coupon/delCoupon'),
method: 'post',
data: this.$http.adornData(ids, false)
data: this.$http.adornData({
id: id
})
}).then(({data}) => {
if (data && data.code === 0) {
this.$message({
@@ -209,7 +332,7 @@
})
}
},watch:{
couponActiveName: {
currentState: {
handler(val, oldVal) {
this.getDataList()
},

View File

@@ -0,0 +1,458 @@
<template>
<div>
<el-drawer
size="50%"
title="用户优惠券列表"
:visible.sync="drawer"
:direction="direction"
:before-close="handleClose"
>
<div style="padding:15px">
<!-- <el-button class="closeBtn" type="primary" plain
@click="handleClose">确定选中并关闭</el-button
> -->
<el-form
:inline="true"
:model="query"
@keyup.enter.native="getDataList()"
>
<!-- <el-form-item label="课程名称">
<el-input
v-model="query.courseName"
placeholder="课程名称"
clearable
></el-input>
</el-form-item> -->
<el-form-item label="优惠券状态">
<el-select
v-model="query.status"
placeholder="请选择"
@change="
pageIndex = 1;
getDataList();
"
>
<el-option
v-for="item in statusList"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="获得类型">
<el-select
v-model="query.getType"
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-button type="primary" @click="getAllCoupon()"
>赠送优惠券</el-button
>
</el-form-item>
</el-form>
</div>
<div style="padding: 15px">
<!-- {{dataList}} -->
<el-table
v-loading="dataListLoading"
:data="dataList"
border
style="width: 100%; "
>
<!-- <el-table-column type="selection" > </el-table-column> -->
<el-table-column prop="id" label="名称">
<template slot-scope="scope">{{scope.row.couponEntity.couponName}}</template>
</el-table-column>
<el-table-column prop="id" label="获得途径">
<template slot-scope="scope">
<span v-if="scope.row.getType == 0">后台赠送<br/>
<i>原因{{scope.row.remark}}</i>
</span>
<span v-if="scope.row.getType == 1">主动获取</span>
</template>
</el-table-column>
<el-table-column prop="id" label="使用上限x张">
<template slot-scope="scope">
{{scope.row.couponEntity.limitedCollar}}
</template>
</el-table-column>
<el-table-column prop="id" label="使用门槛(元)">
<template slot-scope="scope">
{{scope.row.couponEntity.useLevel}}
</template>
</el-table-column>
<el-table-column prop="id" label="优惠券范围">
<template slot-scope="scope">
{{scope.row.couponEntity.couponRange | getRange}}
</template>
</el-table-column>
<el-table-column prop="id" label="优惠券类型">
<template slot-scope="scope">
{{scope.row.couponEntity.effectType | getType}}
</template>
</el-table-column>
<el-table-column prop="description" label="操作" width="100">
<template slot-scope="scope">
<el-button
type="danger"
plain
size="small"
@click="deleteHandle(scope.row.id)"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
:current-page="pageIndex"
:page-sizes="[10, 20, 50, 100]"
:page-size="pageSize"
:total="totalPage"
style="padding: 30px 0; text-align: center;"
layout="total, sizes, prev, pager, next, jumper"
>
</el-pagination>
</div>
</el-drawer>
<el-dialog
title="优惠券列表"
:close-on-click-modal="false"
:visible.sync="youVisible"
append-to-body
width="600px"
@close="dialogHandleClose"
>
<el-form :model="youForm" label-width="100px">
<el-form-item label="选择优惠券">
<el-select
v-model="youForm.ids"
filterable
remote
reserve-keyword
placeholder="请输入优惠券名称"
:remote-method="getAllCoupon"
:loading="loading"
>
<el-option
v-for="item in couponList"
:key="item.id"
:label="item.couponName"
:value="item.id"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="赠送原因">
<el-input
v-model="youForm.remark" type="textarea"
placeholder="请输入"
clearable
></el-input>
</el-form-item>
<!-- {{youForm.ids}} -->
<el-form-item>
<el-button
type="primary"
@click="surYou"
>赠送</el-button
>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="youVisible = false">取消</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
export default {
name: "selectPro",
props: ["userId"],
data() {
return {
youVisible: false,
// userId: this.$router.query.userId,
drawer: true,
direction: "rtl",
dataList: [],
selected: [],
query: {
// courseName: ""
status: "",
getType: ""
},
couponList: [],
statusList: [
{
label: "未使用",
value: "0"
},
{
label: "已使用",
value: "1"
},
{
label: "已过期",
value: "2"
}
],
typeList: [
{
label: "后台赠送",
value: "0"
},
{
label: "主动获取",
value: "1"
}
],
pageSize: 10,
pageIndex: 1,
totalPage: 0,
dataListLoading: false,
youForm: {
couponName:'',
remark:'后台客服操作赠送',
ids:undefined
},
loading: false,
};
},
mounted() {
console.log("挂载", this.userId);
// this.userId =
this.getDataList();
},
filters: {
// 格式化时间
getType (value) {
switch (value) {
case 0:
return '长期有效'
case 1:
return '领取生效'
case 2:
return '自定义'
}
},
getRange (value) {
switch (value) {
case 0:
return '无限制'
case 1:
return '课程券'
case 2:
return '课程品类券'
}
}
},
methods: {
deleteHandle (id) {
// var ids = id ? [id] : this.dataListSelections.map(item => {
// return item.id
// })
this.$confirm(`确定对[id=${id}]进行删除操作?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$http({
url: this.$http.adornUrl('/common/coupon/delCouponHistory'),
method: 'post',
data: this.$http.adornData({
couponHistoryId: id
})
}).then(({data}) => {
if(data.code!== 0) return this.$message.error(data.msg)
if (data && data.code === 0) {
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.getDataList()
}
})
} else {
this.$message.error(data.msg)
}
})
})
},
dialogHandleClose(){
this.youVisible = false
this.youForm.ids = undefined
// this.youForm.remark = ''
},
surYou() {
if(!this.youForm.ids){
this.$message({
message: '请选择优惠券',
type: 'warning',
duration: 1500,
})
return
}
var data = {
"couponId": this.youForm.ids,
"remark": this.youForm.remark,
"userId": this.userId,
"getType":0 //获取类型 0 后台赠送 1 主动获取
}
this.$http({
url: this.$http.adornUrl('/common/coupon/insertCouponHistory'),
method: 'post',
data: this.$http.adornData(data)
}).then(({
data
}) => {
if (data.code!== 0) return this.$message.error(data.msg);
if (data && data.code === 0) {
this.$message({
message: '赠送成功',
type: 'success',
duration: 1500,
})
this.dialogHandleClose()
this.getDataList()
}
// else{
// this.$message({
// message: data.msg,
// type: 'error',
// duration: 1500,
// })
// }
})
},
givePersonCoupon() {
// this.youVisible = true
},
getAllCoupon() {
this.loading = true;
this.$http({
url: this.$http.adornUrl("/common/coupon/getCouponList"),
method: "post",
data: this.$http.adornData({
page: 1,
limit: 10,
couponName: this.youForm.couponName,
currentState: '0', //当前状态 0 发放中 1结束
couponType: '', //优惠券类型 0现金 1折扣
couponRange: '' //优惠卷范围 0无限制 1课程卷 2课程品类卷
})
})
.then(({ data }) => {
if (data.code !== 0) return this.$message.error(data.msg);
if (data && data.code === 0) {
this.couponList = data.couponPage.records;
this.youVisible = true
// this.totalPage = data.couponPage.total;
} else {
this.dataList = [];
// this.totalPage = 0;
}
this.loading = false;
})
.catch(e => {
this.$message.error(e.msg);
this.loading = false;
});
},
handleSelect(row) {
var _list = this.selected.map(item => item.id);
if (_list.includes(row.id)) {
this.$message({
message: "已选择该课程",
type: "warning"
});
return;
}
this.selected.push(row);
let index = this.dataList.findIndex(item => item.id === row.id);
this.dataList.splice(index, 1);
this.$message({
message: "选择成功",
type: "success"
});
console.log("选择的课程", this.selected);
},
// 每页数
sizeChangeHandle(val) {
this.pageSize = val;
this.pageIndex = 1;
this.getDataList();
},
// 当前页
currentChangeHandle(val) {
this.pageIndex = val;
this.getDataList();
},
handleClose(done) {
this.$emit("close", this.selected);
this.selected = [];
},
getDataList() {
this.dataListLoading = true;
this.$http({
url: this.$http.adornUrl("/common/coupon/getCouponHistoryList"),
method: "post",
data: this.$http.adornData({
page: this.pageIndex,
limit: this.pageSize,
getType: this.query.getType, //获取类型 0 后台赠送 1 主动获取
status: this.query.status, //使用状态 0 未使用 1 已使用 2 已过期
userInfo: "", //用户信息
userId: this.userId
})
})
.then(({ data }) => {
if (data.code != 0) return this.$message.error(data.msg);
if (data && data.code === 0) {
this.dataList = data.couponList.records;
this.totalPage = data.couponList.total;
} else {
this.dataList = [];
this.totalPage = 0;
}
this.dataListLoading = false;
})
.catch(e => {
this.$message.error(e.msg);
this.dataListLoading = false;
});
}
}
};
</script>
<style lang="sass" scoped>
.closeBtn{position: absolute;right: 15px;top: 15px;}
</style>

View File

@@ -392,7 +392,8 @@ export default {
// console.log('editor ready!', quill)
},
init(row) {
console.log("11111", row);
console.log("进来了吗?", row);
// if(!)
if (row && row.id) {
this.courseId = row.id
this.$http

View File

@@ -0,0 +1,299 @@
<template>
<div class="mod-config">
<el-form
:inline="true"
:model="dataForm"
@keyup.enter.native="getDataList()"
>
<el-form-item label="">
<el-input v-model="dataForm.orderSn" placeholder="请输入订单编号" clearable>
</el-input>
</el-form-item>
<el-form-item label="">
<el-input v-model="dataForm.userInfo" placeholder="请输入用户名" clearable>
</el-input>
</el-form-item>
<!-- <el-form-item label="">
<el-input v-model="dataForm.userInfo" placeholder="用户手机/邮箱/姓名" clearable>
</el-input>
</el-form-item> -->
<el-form-item >
<el-button
@click="
pageIndex = 1;
getDataList();
"
>查询</el-button
>
</el-form-item>
</el-form>
<el-table
:data="dataList"
border
v-loading="dataListLoading"
style="width: 100%;"
>
<el-table-column
header-align="center"
align="center"
label="复读课程"
>
<template slot-scope="scope">
{{scope.row.remark | getRemark}}
</template>
</el-table-column>
<el-table-column
prop="orderSn"
header-align="center"
align="center"
label="订单号"
>
</el-table-column>
<el-table-column
prop="createTime"
header-align="center"
align="center"
label="下单时间"
>
</el-table-column>
<el-table-column
prop="realMoney"
header-align="center"
align="center"
label="金额¥"
>
<template slot-scope="scope">
{{scope.row.realMoney}}
</template>
</el-table-column>
<el-table-column
header-align="center"
align="center"
label="用户信息"
>
<template slot-scope="scope">
用户{{scope.row.user.name || scope.row.user.nickname || '暂未设置'}}<br/>
电话{{scope.row.user.tel}}
</template>
</el-table-column>
<el-table-column
header-align="center"
align="center"
label="订单状态"
>
<template slot-scope="scope">
{{scope.row.orderStatus | getType}} </br>
支付方式{{scope.row.paymentMethod | getPayType}}<br/>
</template>
</el-table-column>
<!-- <el-table-column
fixed="right"
header-align="center"
align="center"
width="250"
label="操作"
>
<template slot-scope="scope">
<el-button v-if="scope.row.expire == 0" type="primary" @click="delay(scope.row)" plain size="mini">延期</el-button>
<el-button type="danger" @click="expired(scope.row)" plain size="mini">设置过期</el-button>
</template>
</el-table-column> -->
</el-table>
<el-pagination
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
:current-page="pageIndex"
:page-sizes="[10, 20, 50, 100]"
:page-size="pageSize"
:total="total"
layout="total, sizes, prev, pager, next, jumper"
>
</el-pagination>
</div>
</template>
<script>
// import AddOrUpdate from './user-add-or-update'
export default {
data() {
return {
dataForm: {
orderSn: "",
userInfo: ""
},
dataList: [],
pageIndex: 1,
pageSize: 10,
totalPage: 0,
total: 0,
totalLaoding: false,
dataListLoading: false
};
},
filters: {
// 获得订单状态
getType(value) {
var ss = ''
switch (value) {
case '0':
ss = '待付款'
break;
case '1':
ss = '待发货'
break;
case '2':
ss = '已发货'
break;
case '3':
ss = '已完成'
break;
}
return ss
},
getPayType(value) {
var ss = ''
switch (value) {
// case '0':
// ss = '余额'
// break;
case '1':
ss = '支付宝'
break;
case '2':
ss = '微信'
break;
case '3':
ss = 'ios内购'
break;
case '4':
ss = '天医币'
break;
}
return ss
},
getRemark(val){
var arr = val.split(',')
if (arr.length > 1) {
return arr[1].trim(); // 使用 trim 方法去除可能存在的空格
} else {
// 如果字符串中不包含逗号,则返回原字符串
return val;
}
},
},
components: {
// AddOrUpdate
},
created() {
this.getDataList()
},
activated() {
// this.getDataList()
// this.getcourpeList()
},
methods: {
// 获取数据列表
getDataList() {
this.dataListLoading = true;
this.$http({
// url: this.$http.adornUrl('/book/user/list'),
url: this.$http.adornUrl("/common/courseRelearn/orderListRelearn"),
method: "post",
data: this.$http.adornData({
"page": this.pageIndex,
"limit": this.pageSize,
...this.dataForm
})
})
.then(({ data }) => {
if(data && data.code!== 0) return this.$message.error(data.msg)
console.log(data,'data')
this.dataList = data.buyOrderPage.records;
this.totalPage = data.buyOrderPage.pages;
this.total = data.buyOrderPage.total;
this.dataListLoading = false;
});
},
// 每页数
sizeChangeHandle(val) {
this.pageSize = val;
this.pageIndex = 1;
this.getDataList();
},
// 当前页
currentChangeHandle(val) {
this.pageIndex = val;
this.getDataList();
},
// // 多选
// selectionChangeHandle(val) {
// this.dataListSelections = val
// },
// 新增 / 修改
closeDia() {
this.adc = false;
this.$refs.pointForm.resetFields();
// this.pointForm.pointType == 0
},
getCate(id) {
this.linshiids = []
this.$http({
url: this.$http.adornUrl("/master/userManage/catalogueListByCourse"),
method: "post",
data: this.$http.adornData({
"courseId": id
})
}).then(({ data }) => {
if (data && data.code === 0) {
console.log('data','data++++++++++++++++++++')
this.youForm.cate = data.list
// this.youForm.cate
}else{
this.youForm.cate = []
this.linshiids = []
}
}).catch(e => {
console.log('数据报错')
});
}
},
};
</script>
<style lang="less" scoped>
/deep/ .width100 .el-input__inner{width: 100%;}
.flexbox {
display: flex;
}
.userInfo {
margin-bottom: 20px;
}
.userInfo * {
font-size: 16px;
}
</style>

View File

@@ -0,0 +1,412 @@
<template>
<div>
<el-drawer
size="50%"
title="商品优惠券列表"
:visible.sync="drawer"
:direction="direction"
:before-close="handleClose"
>
<div style="padding:15px">
<!-- <el-button class="closeBtn" type="primary" plain
@click="handleClose">确定选中并关闭</el-button
> -->
<!-- <el-form
:inline="true"
:model="query"
@keyup.enter.native="getDataList()"
> -->
<!-- <el-form-item label="课程名称">
<el-input
v-model="query.courseName"
placeholder="课程名称"
clearable
></el-input>
</el-form-item> -->
<!-- <el-form-item> -->
<el-button type="primary" @click="getAllCoupon()"
>绑定新优惠券</el-button
>
<!-- </el-form-item> -->
<!-- </el-form> -->
</div>
<div style="padding: 15px">
<!-- {{dataList}} -->
<el-table
v-loading="dataListLoading"
:data="dataList"
border
style="width: 100%; "
>
<!-- <el-table-column type="selection" > </el-table-column> -->
<el-table-column prop="id" label="名称">
<template slot-scope="scope">{{scope.row.couponEntity.couponName}}</template>
</el-table-column>
<!-- <el-table-column prop="id" label="获得途径">
<template slot-scope="scope">
<span v-if="scope.row.getType == 0">后台赠送<br/>
<i>原因{{scope.row.remark}}</i>
</span>
<span v-if="scope.row.getType == 1">主动获取</span>
</template>
</el-table-column> -->
<el-table-column prop="id" label="使用上限x张">
<template slot-scope="scope">
{{scope.row.couponEntity.limitedCollar}}
</template>
</el-table-column>
<el-table-column prop="id" label="使用门槛(元)">
<template slot-scope="scope">
{{scope.row.couponEntity.useLevel}}
</template>
</el-table-column>
<el-table-column prop="id" label="优惠券范围">
<template slot-scope="scope">
{{scope.row.couponEntity.couponRange | getRange}}
</template>
</el-table-column>
<el-table-column prop="id" label="优惠券类型">
<template slot-scope="scope">
{{scope.row.couponEntity.effectType | getType}}
</template>
</el-table-column>
<el-table-column prop="description" label="操作" width="120">
<template slot-scope="scope">
<el-button
type="danger"
plain
size="small"
@click="deleteHandle(scope.row.id)"
>
断开绑定
</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
:current-page="pageIndex"
:page-sizes="[10, 20, 50, 100]"
:page-size="pageSize"
:total="totalPage"
style="padding: 30px 0; text-align: center;"
layout="total, sizes, prev, pager, next, jumper"
>
</el-pagination>
</div>
</el-drawer>
<el-dialog
title="添加优惠券绑定"
:close-on-click-modal="false"
:visible.sync="youVisible"
append-to-body
width="600px"
@close="dialogHandleClose"
>
<el-form :model="youForm" label-width="100px">
<el-form-item label="选择优惠券">
<el-select
v-model="youForm.ids"
filterable
remote
reserve-keyword
placeholder="请输入优惠券名称"
:remote-method="getAllCoupon"
:loading="loading"
>
<el-option
v-for="item in couponList"
:key="item.id"
:label="item.couponName"
:value="item.id"
>
</el-option>
</el-select>
</el-form-item>
<!-- {{youForm.ids}} -->
<el-form-item>
<el-button
type="primary"
@click="surYou"
> </el-button
>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="youVisible = false">取消</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
export default {
name: "productCouponList",
props: ["productId"],
data() {
return {
youVisible: false,
// userId: this.$router.query.userId,
drawer: true,
direction: "rtl",
dataList: [],
selected: [],
query: {
// courseName: ""
status: "",
getType: ""
},
couponList: [],
statusList: [
{
label: "未使用",
value: "0"
},
{
label: "已使用",
value: "1"
},
{
label: "已过期",
value: "2"
}
],
typeList: [
{
label: "后台赠送",
value: "0"
},
{
label: "主动获取",
value: "1"
}
],
pageSize: 10,
pageIndex: 1,
totalPage: 0,
dataListLoading: false,
youForm: {
couponName:'',
ids:undefined
},
loading: false,
};
},
mounted() {
console.log("挂载", this.productId);
// this.userId =
this.getDataList();
},
filters: {
// 格式化时间
getType (value) {
switch (value) {
case 0:
return '长期有效'
case 1:
return '领取生效'
case 2:
return '自定义'
}
},
getRange (value) {
switch (value) {
case 0:
return '无限制'
case 1:
return '课程券'
case 2:
return '课程品类券'
}
}
},
methods: {
deleteHandle (id) {
// var ids = id ? [id] : this.dataListSelections.map(item => {
// return item.id
// })
this.$confirm(`确定对[id=${id}]进行删除操作?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$http({
url: this.$http.adornUrl('/common/coupon/unbindCouponToProduct'),
method: 'post',
data: this.$http.adornData({
"id": id
})
}).then(({data}) => {
if(data.code!== 0) return this.$message.error(data.msg)
if (data && data.code === 0) {
this.$message({
message: '解绑成功',
type: 'success',
duration: 1500,
onClose: () => {
this.getDataList()
}
})
} else {
this.$message.error(data.msg)
}
})
})
},
dialogHandleClose(){
this.youVisible = false
this.youForm.ids = undefined
// this.youForm.remark = ''
},
surYou() {
if(!this.youForm.ids){
this.$message({
message: '请选择优惠券',
type: 'warning',
duration: 1500,
})
return
}
var data = {
"couponId": this.youForm.ids,
"productId": this.productId,
}
this.$http({
url: this.$http.adornUrl('/common/coupon/setCouponToProduct'),
method: 'post',
data: this.$http.adornData(data)
}).then(({
data
}) => {
if (data.code!== 0) return this.$message.error(data.msg);
if (data && data.code === 0) {
this.$message({
message: '绑定成功',
type: 'success',
duration: 1500,
})
this.dialogHandleClose()
this.getDataList()
}
// else{
// this.$message({
// message: data.msg,
// type: 'error',
// duration: 1500,
// })
// }
})
},
givePersonCoupon() {
// this.youVisible = true
},
getAllCoupon() {
this.loading = true;
this.$http({
url: this.$http.adornUrl("/common/coupon/getCouponList"),
method: "post",
data: this.$http.adornData({
page: 1,
limit: 10,
couponName: this.youForm.couponName,
currentState: '0', //当前状态 0 发放中 1结束
couponType: '', //优惠券类型 0现金 1折扣
couponRange: '' //优惠卷范围 0无限制 1课程卷 2课程品类卷
})
})
.then(({ data }) => {
if (data.code !== 0) return this.$message.error(data.msg);
if (data && data.code === 0) {
this.couponList = data.couponPage.records;
this.youVisible = true
// this.totalPage = data.couponPage.total;
} else {
this.dataList = [];
// this.totalPage = 0;
}
this.loading = false;
})
.catch(e => {
this.$message.error(e.msg);
this.loading = false;
});
},
handleSelect(row) {
var _list = this.selected.map(item => item.id);
if (_list.includes(row.id)) {
this.$message({
message: "已选择该课程",
type: "warning"
});
return;
}
this.selected.push(row);
let index = this.dataList.findIndex(item => item.id === row.id);
this.dataList.splice(index, 1);
this.$message({
message: "选择成功",
type: "success"
});
console.log("选择的课程", this.selected);
},
// 每页数
sizeChangeHandle(val) {
this.pageSize = val;
this.pageIndex = 1;
this.getDataList();
},
// 当前页
currentChangeHandle(val) {
this.pageIndex = val;
this.getDataList();
},
handleClose(done) {
this.$emit("close", this.selected);
this.selected = [];
},
getDataList() {
this.dataListLoading = true;
this.$http({
url: this.$http.adornUrl("/common/coupon/couponToProductList"),
method: "post",
data: this.$http.adornData({
page: this.pageIndex,
limit: this.pageSize,
productId: this.productId
})
})
.then(({ data }) => {
if (data.code != 0) return this.$message.error(data.msg);
// console.log('data',data)
if (data && data.code === 0) {
this.dataList = data.couponToShopproductPage.records;
this.totalPage = data.couponToShopproductPage.total;
} else {
this.dataList = [];
this.totalPage = 0;
}
this.dataListLoading = false;
})
.catch(e => {
this.$message.error(e.msg);
this.dataListLoading = false;
});
}
}
};
</script>
<style lang="sass" scoped>
.closeBtn{position: absolute;right: 15px;top: 15px;}
</style>

View File

@@ -142,7 +142,10 @@
@click.native="handleEditCurriculum(scope.row.productId)"
>新版修改</el-dropdown-item
> -->
<el-dropdown-item
@click.native="showLinkCoupon(scope.row.productId)"
>购买赠优惠券</el-dropdown-item
>
<el-dropdown-item
@click.native="handleEditCorrelation(scope.row.productId)"
>图书与课程</el-dropdown-item
@@ -196,16 +199,18 @@
<commonTags ref="commonTags"></commonTags>
<correlation ref="correlation"></correlation>
<choose-book v-if="chooseBookVisible" :bookIds = bookIds ref="chooseBook" :chooseBookVisible = chooseBookVisible @closeBookf = "closeBookf"></choose-book>
<pro-coupon-list v-if="LinkCouponVisible" :productId="curProductId" @close="proCouponClose"></pro-coupon-list>
</div>
</template>
<script>
import proCouponList from "./proCouponList.vue";
import chooseBook from "./chooseBook.vue";
import curriculum from "./curriculum.vue";
import AddOrUpdate from "./shopproduct-add-or-update";
// import AddOrUpdate from "./shopproduct-add-or-update";
import commonTree from "@/views/components/commonBookTags/tags.vue";
import commonTags from "./commonBookTags/commonTags1.vue";
import correlation from "./commonBookTags/correlation.vue";
export default {
@@ -225,7 +230,10 @@ export default {
addOrUpdateVisible: false,
chooseBookVisible: false,
curriculumVisible: false,
bookIds: []
bookIds: [],
LinkCouponVisible:false, // 显示优惠券弹窗
curProductId: undefined, // 当前的商品id
};
},
components: {
@@ -233,13 +241,23 @@ export default {
AddOrUpdate,
chooseBook,
commonTags,
correlation
correlation,
proCouponList
},
activated() {
this.getDataList();
this.getGoodsTypeList();
},
methods: {
showLinkCoupon(id) {
this.curProductId = id;
this.LinkCouponVisible = true;
},
proCouponClose() {
this.LinkCouponVisible = false;
},
getGoodsTypeList() {
this.$http({
url: this.$http.adornUrl("/book/sysdictdata/selectByType/goodsType"),

View File

@@ -110,7 +110,7 @@
<el-button type="text" size="small">/扣天医币记录</el-button>
</router-link>
</el-dropdown-item>
<el-dropdown-item><el-button type="text" size="small" @click="youhui(scope.row)">优惠券列表</el-button></el-dropdown-item>
<el-dropdown-item><el-button type="text" size="small" @click=" thisUserID = scope.row.id; youVisible = true">优惠券管理</el-button></el-dropdown-item>
<el-dropdown-item><el-button type="text" size="small" @click="resetPassword(scope.row)">修改密码</el-button></el-dropdown-item>
<el-dropdown-item>
<router-link :to="{ path: '/userCourse', query: {id:scope.row.id} }">
@@ -164,39 +164,15 @@
<el-button type="primary" @click="huaSheng(pointForm.peanutCoin)">确定</el-button>
</span>
</el-dialog>
<userCouponList v-if="youVisible" ref="userCouponList" :userId='thisUserID' @close="closeCoupon"></userCouponList>
<el-dialog title="优惠券列表" :close-on-click-modal="false" :visible.sync="youVisible" append-to-body width="600px">
<el-form :model="youForm" label-width="100px">
<el-form-item label="用户">
{{youForm.tel}} <span v-if="youForm.name!=''">({{youForm.name}})</span>
</el-form-item>
<el-form-item label="赠送优惠券">
<el-select v-model="youForm.courType" placeholder="请选择">
<el-option v-for="item in courperList" :key="item.id" :label="item.couponName" :value="item.id">
</el-option>
</el-select>
<el-button type="primary" @click="surYou" :disabled="youForm.courType==undefined">赠送</el-button>
</el-form-item>
<el-table :data="courperHistList" border :key='Math.random()'>
<el-table-column prop="couponName" label="已获得优惠券">
</el-table-column>
<el-table-column label="操作" header-align="center" align="center" width="80">
<template slot-scope="scope">
<el-button type="text" size="small" @click="courDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="youVisible=false">取消</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import userCouponList from '../coupon/userCouponList'
import AddOrUpdate from './user-add-or-update'
export default {
data() {
@@ -239,13 +215,17 @@
}
},
components: {
AddOrUpdate
AddOrUpdate,
userCouponList
},
activated() {
this.getDataList()
this.getcourpeList()
},
methods: {
closeCoupon(val){
this.youVisible = false
},
// 用户课程
userCourse(val){
@@ -312,26 +292,7 @@
// });
});
},
// 获取优惠券列表
getcourpeList() {
this.$http({
url: this.$http.adornUrl('/book/coupon/list'),
method: 'get',
params: this.$http.adornParams({
'page': this.pageIndex,
'limit': this.pageSize,
'key': this.dataForm.key,
'currentState': '1'
})
}).then(({
data
}) => {
if (data && data.code === 0) {
this.courperList = data.page.list
this.totalPage = data.page.totalCount
}
})
},
// 每页数
sizeChangeHandle(val) {
this.pageSize = val
@@ -417,58 +378,48 @@
})
})
},
// async getUserCouponList(userId) {
// var obj = undefined
// await this.$http({
// url: this.$http.adornUrl('/common/coupon/getCouponHistoryList'),
// method: 'post',
// data: this.$http.adornData({
// // 'userId': this.youForm.id,
// "page":1,
// "limit":10,
// "getType":"",//获取类型 0 后台赠送 1 主动获取
// "status":"",//使用状态 0 未使用 1 已使用 2 已过期
// "userInfo":"",//用户信息
// "userId": userId
// })
// }).then(async({ data }) => {
// if(data.code != 0 ) return this.$message.error(data.msg)
// if (data && data.code == 0) {
// obj = data
// console.log('data', data)
// this.youVisible = true
// }
// }).catch(({e}) => {
// console.log(e,'e')
// obj = undefined
// this.$message.error(e.msg)
// })
// return obj
// },
// 个人优惠券
youhui(e) {
this.youForm = e
this.youForm.memberId = e.id
this.$http({
url: this.$http.adornUrl('/book/couponhistory/list'),
method: 'post',
params: this.$http.adornParams({
'userId': e.id
})
}).then(({
data
}) => {
if (data && data.code === 0) {
this.courperHistList = data.page.list
this.youVisible = true
}
})
// async youhui(e) {
// this.youForm = e
// this.youForm.memberId = e.id
// var obj = await this.getUserCouponList(e.id)
// // if(obj){
// // this.courperHistList = obj
// console.log('1', obj)
// // }
},
surYou() {
let arrList = {}
arrList.memberId = this.youForm.memberId
arrList.couponId = this.youForm.courType
arrList.memberNickname = this.youForm.nickname
arrList.useStatus = 0
// // this.courperHistList = await this.getcourpeList(e.id)
this.$http({
url: this.$http.adornUrl('/book/couponhistory/save'),
method: 'post',
data: this.$http.adornData(arrList, false)
}).then(({
data
}) => {
if (data && data.code === 0) {
this.$message({
message: data.msg,
type: 'success',
duration: 1500,
})
this.youhui(this.youForm)
this.getDataList()
}else{
this.$message({
message: data.msg,
type: 'error',
duration: 1500,
})
}
})
},
// },
// 删除优惠券
courDelete(e) {
let arrList = []