优惠券
This commit is contained in:
@@ -8,3 +8,6 @@
|
||||
export default {
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.flexBox{ display: flex;}
|
||||
</style>
|
||||
|
||||
178
src/components/selectPro.vue
Normal file
178
src/components/selectPro.vue
Normal file
@@ -0,0 +1,178 @@
|
||||
<template>
|
||||
<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
|
||||
@click="
|
||||
pageIndex = 1;
|
||||
getDataList();
|
||||
"
|
||||
>查询</el-button
|
||||
>
|
||||
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<div style="padding: 15px">
|
||||
<el-table v-loading="dataListLoading"
|
||||
:data="dataList"
|
||||
border
|
||||
style="width: 100%; "
|
||||
>
|
||||
<!-- <el-table-column type="selection" > </el-table-column> -->
|
||||
<el-table-column prop="title" label="名称" > </el-table-column>
|
||||
<el-table-column prop="description" label="操作" width="100">
|
||||
<template slot-scope="scope">
|
||||
<el-button :disabled="checkBtnStatus(scope.row)"
|
||||
type="primary" plain
|
||||
size="small"
|
||||
@click="handleSelect(scope.row)"
|
||||
>
|
||||
{{checkBtnStatus(scope.row) ? '已选择' : '选择'}}
|
||||
|
||||
</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>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "selectPro",
|
||||
props: ["requesturl", "oldData"],
|
||||
data() {
|
||||
return {
|
||||
drawer: true,
|
||||
direction: "rtl",
|
||||
dataList: [],
|
||||
selected: [],
|
||||
query: {
|
||||
courseName: ""
|
||||
},
|
||||
pageSize: 10,
|
||||
pageIndex: 1,
|
||||
totalPage: 0,
|
||||
dataListLoading: false,
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
console.log("挂载");
|
||||
this.getDataList();
|
||||
|
||||
},
|
||||
filters: {
|
||||
|
||||
},
|
||||
methods: {
|
||||
checkBtnStatus(val) {
|
||||
let index = this.oldData.findIndex(item => item.id === val.id);
|
||||
if(index > -1){
|
||||
return true
|
||||
}else{
|
||||
return 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(this.requesturl),
|
||||
method: "post",
|
||||
data: this.$http.adornData({
|
||||
page: this.pageIndex,
|
||||
limit: this.pageSize,
|
||||
courseName: this.query.courseName,
|
||||
type:1,
|
||||
medicalId:"",//医学标签id,type为1时生效,空字符串为全部
|
||||
sociologyId:""//国学标签id,type为2时生效,空字符串为全部
|
||||
})
|
||||
}).then(({ data }) => {
|
||||
if(data.code != 0) return this.$message.error(data.msg);
|
||||
if (data && data.code === 0) {
|
||||
this.dataList = data.page.records;
|
||||
this.totalPage = data.page.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>
|
||||
@@ -1,117 +1,257 @@
|
||||
<template>
|
||||
<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">
|
||||
<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="couponRange">
|
||||
<!-- <el-input v-model="dataForm.type" placeholder="优惠卷类型"></el-input> -->
|
||||
<el-select v-model="dataForm.couponRange" placeholder="请选择">
|
||||
<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-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="">
|
||||
<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-col :span="8">
|
||||
<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,'')"
|
||||
>
|
||||
<template slot="append">张</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<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>
|
||||
</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-radio :label="0">长期有效</el-radio>
|
||||
<el-radio :label="1">领取生效</el-radio>
|
||||
<el-radio :label="2">自定义</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<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"
|
||||
</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>
|
||||
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,'')">
|
||||
<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="8">
|
||||
<el-form-item label="总发行量" prop="totalCirculation">
|
||||
<el-input v-model="dataForm.totalCirculation" 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-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="24">
|
||||
<el-col :span="8">
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="dataForm.remark" placeholder="备注" type="textarea" rows="2" autosize>
|
||||
<el-input
|
||||
v-model="dataForm.remark"
|
||||
placeholder="备注"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
autosize
|
||||
>
|
||||
</el-input>
|
||||
|
||||
</el-form-item>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
@@ -120,75 +260,91 @@
|
||||
<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,
|
||||
requesturl:'', // 课程的请求地址
|
||||
showSelectPro:false,
|
||||
baseUrl: global.baseUrl,
|
||||
visible: true,
|
||||
options2: [{
|
||||
value: 0,
|
||||
label: '商品'
|
||||
},{
|
||||
value: 1,
|
||||
label: '电子书'
|
||||
}
|
||||
options2: [
|
||||
{
|
||||
value: 0,
|
||||
label: "商品"
|
||||
},
|
||||
{
|
||||
value: 1,
|
||||
label: "电子书"
|
||||
}
|
||||
],
|
||||
options: [
|
||||
{
|
||||
value: 0,
|
||||
label: "现金券"
|
||||
},
|
||||
{
|
||||
value: 1,
|
||||
label: "折扣券"
|
||||
}
|
||||
],
|
||||
options: [{
|
||||
value: 0,
|
||||
label: '现金券'
|
||||
}, {
|
||||
value: 1,
|
||||
label: '折扣券'
|
||||
}],
|
||||
rangList: global.rangList,
|
||||
TypeList: global.TypeList,
|
||||
dialogVisible:false,
|
||||
dialogVisible: false,
|
||||
fileList: [], // 封面图
|
||||
dataForm: {
|
||||
id: undefined,
|
||||
couponType:0, //优惠券类型 0现金 1折扣
|
||||
couponName:'', //优惠券名称
|
||||
couponAmount : undefined, //优惠券面额
|
||||
couponUrl: '', //优惠券封面
|
||||
limitedCollar:1, //每人限领
|
||||
validity : 7, //时效(天)
|
||||
effectType: 0, //生效方式 0长期有效 1领取生效 2自定义
|
||||
effectTime :undefined, //生效日期
|
||||
expireTime: undefined, //截止日期
|
||||
totalCirculation : 100, //总发行数量
|
||||
remark: '', //备注
|
||||
useLevel : undefined, //使用门槛
|
||||
couponRange : '', //优惠卷范围 0无限制 1课程卷 2课程品类卷
|
||||
rangeInfo:"",//范围详情(课程卷是课程id,分割 课程品类卷是课程分类根id,分割)
|
||||
|
||||
rangeInfo: [],
|
||||
courseCateList: [], //课程品类列表
|
||||
selectLinkList: [], // 选中的商品列表()
|
||||
cateSelectLinkList: [], // 选中的课程品类列表
|
||||
proSelectLinkList: [], // 选中的商品列表()
|
||||
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,分割)
|
||||
},
|
||||
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" }
|
||||
],
|
||||
effectType: [
|
||||
{ required: true, message: '生效方式不能为空', trigger: 'blur' }
|
||||
{ required: true, message: "生效方式不能为空", trigger: "blur" }
|
||||
],
|
||||
// validity: [
|
||||
// { required: true, message: '时效不能为空', trigger: 'blur' }
|
||||
// ],
|
||||
couponRange: [
|
||||
{ required: true, message: '商品类型不能为空', trigger: 'blur' }
|
||||
{ required: true, message: "商品类型不能为空", trigger: "blur" }
|
||||
],
|
||||
useLevel: [
|
||||
{ required: true, message: '使用门槛;0表示无门槛', trigger: 'blur' }
|
||||
],
|
||||
{ required: true, message: "使用门槛;0表示无门槛", trigger: "blur" }
|
||||
]
|
||||
// startTime: [
|
||||
// { required: true, message: '开始使用时间不能为空', trigger: 'blur' }
|
||||
// ],
|
||||
@@ -220,36 +376,143 @@ 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 = '/master/course/getCourseList'
|
||||
},
|
||||
changeCate(e) {
|
||||
console.log("e", e);
|
||||
this.cateSelectLinkList = e;
|
||||
// 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
|
||||
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(`/common/coupon/getCouponInfo`),
|
||||
method: 'post',
|
||||
data: this.$http.adornData(
|
||||
{ id: this.dataForm.id}
|
||||
)
|
||||
method: "post",
|
||||
data: this.$http.adornData({ id: this.dataForm.id })
|
||||
}).then(({ data }) => {
|
||||
if(data.code !==0) return this.$message.error(data.msg)
|
||||
if (data && data.code === 0) {
|
||||
this.dataForm = data.couponEntity
|
||||
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.couponEntity.couponUrl != "") {
|
||||
var img = { name: '', url: data.ouponEntity.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") {
|
||||
@@ -260,72 +523,147 @@ 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);
|
||||
},
|
||||
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:''
|
||||
|
||||
}
|
||||
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.cateSelectLinkList = []
|
||||
this.selectLinkList = []
|
||||
this.fileList = []
|
||||
},
|
||||
|
||||
// 表单提交
|
||||
dataFormSubmit() {
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
if (valid) {
|
||||
|
||||
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')
|
||||
}
|
||||
})
|
||||
this.$refs["dataForm"].validate(valid => {
|
||||
if (valid) {
|
||||
if(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;
|
||||
}
|
||||
}).catch((err) => {
|
||||
this.$message.error(err.msg)
|
||||
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) 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 {
|
||||
@@ -341,6 +679,6 @@ export default {
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
line-height: 70px;
|
||||
|
||||
}}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<el-form-item>
|
||||
<el-input v-model="dataForm.couponName" placeholder="参数名" clearable></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="优惠卷范围">
|
||||
<el-form-item label="优惠券范围">
|
||||
<el-select v-model="dataForm.couponRange" placeholder="请选择" @change="pageIndex = 1; getDataList()">
|
||||
<el-option
|
||||
v-for="item in rangList"
|
||||
@@ -42,12 +42,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"
|
||||
@@ -64,7 +64,10 @@
|
||||
prop="couponType"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="优惠卷类型" width="100px">
|
||||
label="优惠券类型" width="100px">
|
||||
<template slot-scope="scope">
|
||||
{{scope.row.couponType | getType}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="couponAmount"
|
||||
@@ -119,8 +122,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>
|
||||
@@ -160,14 +163,23 @@ import commentsListVue from '../book/commentsList.vue'
|
||||
totalPage: 0,
|
||||
dataListLoading: false,
|
||||
dataListSelections: [],
|
||||
addOrUpdateVisible: false
|
||||
addOrUpdateVisible: false,
|
||||
courseCateList:[]
|
||||
}
|
||||
},
|
||||
filters: {
|
||||
// 格式化时间
|
||||
getRange (value) {
|
||||
// if (value && value != 0) {
|
||||
// console.log('555555555',value)
|
||||
getType (value) {
|
||||
switch (value) {
|
||||
case 0:
|
||||
return '长期有效'
|
||||
case 1:
|
||||
return '领取生效'
|
||||
case 2:
|
||||
return '自定义'
|
||||
}
|
||||
},
|
||||
getRange (value) {
|
||||
switch (value) {
|
||||
case 0:
|
||||
|
||||
@@ -176,10 +188,7 @@ import commentsListVue from '../book/commentsList.vue'
|
||||
return '课程券'
|
||||
case 2:
|
||||
return '课程品类券'
|
||||
}
|
||||
// } else {
|
||||
// return ''
|
||||
// }
|
||||
}
|
||||
}
|
||||
},
|
||||
components: {
|
||||
@@ -189,6 +198,8 @@ import commentsListVue from '../book/commentsList.vue'
|
||||
this.getDataList()
|
||||
},
|
||||
methods: {
|
||||
|
||||
|
||||
handleClick(){
|
||||
console.log(this.currentState)
|
||||
this.pageIndex = 1
|
||||
@@ -219,6 +230,9 @@ import commentsListVue from '../book/commentsList.vue'
|
||||
this.totalPage = 0
|
||||
}
|
||||
this.dataListLoading = false
|
||||
}).catch((e) => {
|
||||
this.$message.error(e.msg)
|
||||
this.dataListLoading = false
|
||||
})
|
||||
},
|
||||
// 每页数
|
||||
@@ -245,18 +259,20 @@ import commentsListVue from '../book/commentsList.vue'
|
||||
},
|
||||
// 删除
|
||||
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({
|
||||
|
||||
451
src/views/modules/coupon/userCouponList.vue
Normal file
451
src/views/modules/coupon/userCouponList.vue
Normal file
@@ -0,0 +1,451 @@
|
||||
<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">
|
||||
生效时间:{{scope.row.couponEntity.effectTime}}<br/>
|
||||
结束时间:{{scope.row.couponEntity.expireTime}}
|
||||
</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.couponType | 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.reason" 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:'',
|
||||
reason:'后台客服操作赠送',
|
||||
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/delCoupon'),
|
||||
method: 'post',
|
||||
data: this.$http.adornData({
|
||||
id: id
|
||||
})
|
||||
}).then(({data}) => {
|
||||
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
|
||||
|
||||
},
|
||||
surYou() {
|
||||
if(this.youForm.ids.length == 0){
|
||||
this.$message({
|
||||
message: '请选择优惠券',
|
||||
type: 'warning',
|
||||
duration: 1500,
|
||||
})
|
||||
return
|
||||
}
|
||||
var data = {
|
||||
"couponId": this.youForm.ids,
|
||||
"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>
|
||||
@@ -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 = []
|
||||
|
||||
Reference in New Issue
Block a user