增加优惠类型+增加优惠券绑定商品

This commit is contained in:
2024-11-28 14:33:41 +08:00
parent 7c9962a45d
commit fb20c724b4
6 changed files with 991 additions and 132 deletions

View File

@@ -15,13 +15,20 @@
:model="query" :model="query"
@keyup.enter.native="getDataList()" @keyup.enter.native="getDataList()"
> >
<el-form-item label="课程名称"> <el-form-item label="课程名称" v-if="type == 1">
<el-input <el-input
v-model="query.courseName" v-model="query.courseName"
placeholder="课程名称" placeholder="课程名称"
clearable clearable
></el-input> ></el-input>
</el-form-item> </el-form-item>
<el-form-item label="商品名称" v-if="type == 4">
<el-input
v-model="query.productName"
placeholder="商品名称"
clearable
></el-input>
</el-form-item>
<el-form-item> <el-form-item>
<el-button <el-button
@@ -31,27 +38,31 @@
" "
>查询</el-button >查询</el-button
> >
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
<div style="padding: 15px"> <div style="padding: 15px">
<el-table v-loading="dataListLoading" <el-table
v-loading="dataListLoading"
:data="dataList" :data="dataList"
border border
style="width: 100%; " style="width: 100%; "
> >
<!-- <el-table-column type="selection" > </el-table-column> --> <!-- <el-table-column type="selection" > </el-table-column> -->
<el-table-column prop="title" label="名称" > </el-table-column> <el-table-column prop="title" label="名称" v-if="type == 1">
</el-table-column>
<el-table-column prop="productName" label="名称" v-if="type == 4">
</el-table-column>
<el-table-column prop="description" label="操作" width="100"> <el-table-column prop="description" label="操作" width="100">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button :disabled="checkBtnStatus(scope.row)" <el-button
type="primary" plain :disabled="checkBtnStatus(scope.row)"
type="primary"
plain
size="small" size="small"
@click="handleSelect(scope.row)" @click="handleSelect(scope.row)"
> >
{{checkBtnStatus(scope.row) ? '已选择' : '选择'}} {{ checkBtnStatus(scope.row) ? "已选择" : "选择" }}
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
@@ -67,14 +78,14 @@
layout="total, sizes, prev, pager, next, jumper" layout="total, sizes, prev, pager, next, jumper"
> >
</el-pagination> </el-pagination>
</div> </div>
</el-drawer> </el-drawer>
</template> </template>
<script> <script>
export default { export default {
name: "selectPro", name: "selectPro",
props: ["requesturl", "oldData"], props: ["requesturl", "oldData", "type"],
data() { data() {
return { return {
drawer: true, drawer: true,
@@ -82,49 +93,75 @@ export default {
dataList: [], dataList: [],
selected: [], selected: [],
query: { query: {
courseName: "" courseName: "",
productName: ""
}, },
pageSize: 10, pageSize: 10,
pageIndex: 1, pageIndex: 1,
totalPage: 0, totalPage: 0,
dataListLoading: false, dataListLoading: false
}; };
}, },
mounted() { mounted() {
console.log("挂载"); console.log("挂载");
this.getDataList(); this.getDataList();
},
filters: {
}, },
filters: {},
methods: { methods: {
checkBtnStatus(val) { checkBtnStatus(val) {
let index = this.oldData.findIndex(item => item.id === val.id); var index;
if(index > -1){ if (this.type == 1) {
return true index = this.oldData.findIndex(item => item.id === val.id);
}else{ } else if (this.type == 4) {
return false index = this.oldData.findIndex(item => item.productId === val.productId);
} }
if (index > -1) {
return true;
} else {
return false;
}
}, },
handleSelect(row) { handleSelect(row) {
var _list = this.selected.map( item => item.id) var _list;
if(_list.includes(row.id)){ if (this.type == 1) {
console.log("课程", row);
_list = this.selected.map(item => item.id);
if (_list.includes(row.id)) {
this.$message({ this.$message({
message: '已选择该课程', message: "已选择该课程",
type: 'warning' type: "warning"
}) });
return return;
} }
this.selected.push(row); }
let index = this.dataList.findIndex(item => item.id === row.id); else if (this.type == 4) {
this.dataList.splice(index,1) console.log("商品", row);
_list = this.selected.map(item => item.productId);
if (_list.includes(row.productId)) {
this.$message({ this.$message({
message: '选择成功', message: "已选择该商品",
type:'success' type: "warning"
}) });
console.log('选择的课程',this.selected) return;
}
}
this.selected.push(row);
var index;
if(this.type==1){
index = this.dataList.findIndex(item => item.id === row.id);
}
else if(this.type==4){
index = this.dataList.findIndex(item => item.productId === row.productId);
}
this.$forceUpdate()
this.dataList.splice(index, 1);
this.$message({
message: "选择成功",
type: "success"
});
console.log("选择的课程", this.selected);
}, },
// 每页数 // 每页数
sizeChangeHandle(val) { sizeChangeHandle(val) {
@@ -139,29 +176,46 @@ export default {
}, },
handleClose(done) { handleClose(done) {
this.$emit("close", this.selected); this.$emit("close", this.selected);
this.selected = [] this.selected = [];
}, },
getDataList() { getDataList() {
this.dataListLoading = true; this.dataListLoading = true;
this.$http({ this.$http({
url: this.$http.adornUrl(this.requesturl), url: this.$http.adornUrl(this.requesturl),
method: "post", method: "post",
data: this.$http.adornData({ data: this.$http.adornData(
this.type == 1
? {
page: this.pageIndex, page: this.pageIndex,
limit: this.pageSize, limit: this.pageSize,
title: this.query.courseName title: this.query.courseName
}
: {
current: this.pageIndex,
limit: this.pageSize,
productName: this.query.productName,
goodsType: "00"
}
)
}) })
}).then(({ data }) => { .then(({ data }) => {
if(data.code != 0) return this.$message.error(data.msg); if (data.code != 0) return this.$message.error(data.msg);
if (data && data.code === 0) { if (data && data.code === 0) {
if (this.type == 1) {
this.dataList = data.courses.records; this.dataList = data.courses.records;
this.totalPage = data.courses.total; this.totalPage = data.courses.total;
} else if (this.type == 4) {
this.dataList = data.result.records;
this.totalPage = data.result.total;
}
} else { } else {
this.dataList = []; this.dataList = [];
this.totalPage = 0; this.totalPage = 0;
} }
this.dataListLoading = false; this.dataListLoading = false;
}).catch((e) => { })
.catch(e => {
this.$message.error(e.msg); this.$message.error(e.msg);
this.dataListLoading = false; this.dataListLoading = false;
}); });

View File

@@ -1,12 +1,12 @@
<script type="text/javascript"> <script type="text/javascript">
// const baseUrl = "http://192.168.110.100:9200/pb"; //张川川后端 const baseUrl = "http://192.168.110.100:9200/pb"; //张川川后端
// const baseUrl = 'http://59.110.212.44:9100/pb' // const baseUrl = 'http://59.110.212.44:9100/pb'
// const baseUrl = "https://testapi.nuttyreading.com"; // const baseUrl = "https://testapi.nuttyreading.com";
const baseUrl = 'https://api.nuttyreading.com' // const baseUrl = 'https://api.nuttyreading.com'
// function commonFun() { // function commonFun() {
// console.log("公共方法") // console.log("公共方法")
// } // }
const rangList =[ const rangList = [
{ {
value: 0, value: 0,
label: "无限制" label: "无限制"
@@ -14,13 +14,27 @@ const rangList =[
{ {
value: 1, value: 1,
label: "课程券" label: "课程券"
}, },{
value: 4,
label: "商品券"
} ,
{ {
value: 2, value: 2,
label: "课程品类券" label: "课程品类券"
},
{
value: 3,
label: "全部课程券"
},
{
value: 5,
label: "全部商品券"
} }
]; ];
const TypeList =[ const TypeList = [
{ {
value: "0", value: "0",
label: "现金" label: "现金"
@@ -29,9 +43,11 @@ const TypeList =[
value: "1", value: "1",
label: "折扣" label: "折扣"
} }
] ];
export default { export default {
baseUrl,rangList,TypeList baseUrl,
rangList,
TypeList
//commonFun //commonFun
}; };
</script> </script>

View File

@@ -0,0 +1,391 @@
<template>
<el-dialog
width="700px"
:title="`${!dataForm.id?'新增':'修改'}活动`"
:close-on-click-modal="false"
:visible.sync="visible"
@close="handlereset"
style="height: auto;"
>
<div style="margin-bottom: 60px;">
<el-form
style="height: auto;"
class="addFormBox"
:model="dataForm"
:rules="dataRule"
ref="dataForm"
label-width="80px"
>
<el-form-item label="活动名称" prop="title">
<el-input v-model="dataForm.introduction" placeholder="" clearable></el-input>
</el-form-item>
<el-form-item label="价格" prop="title">
<el-input v-model="dataForm.price" placeholder="" clearable></el-input>
</el-form-item>
<el-form-item label="简易VIP" prop="title">
<el-input v-model="dataForm.price" placeholder="" clearable></el-input>
</el-form-item>
<el-form-item label="超级VIP" prop="title">
<el-input v-model="dataForm.price" placeholder="" clearable></el-input>
</el-form-item>
<el-form-item label="有效时长" prop="dateType">
<el-radio v-model="dataForm.dateType" :label='0'>长期有效</el-radio>
<el-radio v-model="dataForm.dateType" :label='1'>短期有效</el-radio>
</el-form-item>
<el-form-item label="开始时间" prop="startTime" v-if="dataForm.dateType==1">
<el-date-picker
value-format="yyyy-MM-dd HH:mm:ss"
v-model="dataForm.startTime"
type="datetime"
placeholder="选择开始时间">
</el-date-picker>
</el-form-item>
<el-form-item label="结束时间" prop="endTime" v-if="dataForm.dateType==1">
<el-date-picker
value-format="yyyy-MM-dd HH:mm:ss"
v-model="dataForm.endTime"
type="datetime"
placeholder="选择结束时间">
</el-date-picker>
</el-form-item>
<el-form-item label="活动简介" prop="introduction">
<el-input v-model="dataForm.introduction" placeholder="活动简介" type="textarea" rows="3"></el-input>
</el-form-item>
<el-form-item label="活动图" prop="type">
<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"
custom-class="iconBox"
>
<img width="100%" :src="dataForm.icon" alt="" />
</el-dialog>
</el-form-item>
</el-form>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="handlereset">取消</el-button>
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
</span>
</el-dialog>
</template>
<script>
import debounce from "lodash/debounce"; //导入lodash中的debounce
import global from "@/views/common/common.vue"; //引入共用组间
export default {
props: ["typeList", "APPList"],
data() {
return {
bindProductData: {}, // 封面图
fileList: [], // 封面图
baseUrl: global.baseUrl,
visible: false,
// 富文本编辑器配置
props: {
dictType: "",
dictValue: ""
},
gushuList: [],
restaurants: [],
author: "",
publisherList: [],
fileList: [],
fileListNovel: [],
dialogImageUrl: "",
dialogVisible: false,
dataForm: {
type: 0,
app_type: 0
},
dataRule: {
title: [{ required: true, message: "活动名称不能为空", trigger: "blur" }]
},
urlList: {
// info: "/master/message/getMessageById",
add: "/master/mainAd/addMainAd",
edit: "/master/mainAd/editMainAd",
productInfo: "/master/shopProduct/getProductDetail"
}
};
},
components: { },
created() {},
mounted() {
},
methods: {
selectType() {
this.bindProductData = {};
this.dataForm.relationId = "";
this.$forceUpdate();
},
clearBind() {
this.bindProductData = {};
this.dataForm.relationId = "";
this.$forceUpdate();
},
async bindProduct(data) {
console.log("data at line 186:", data);
this.dataForm.relationId = data.productId;
this.bindProductData = data;
// await this.getProductInfo();
this.$forceUpdate();
},
showProTable(data) {
console.log("data", data);
this.$nextTick(() => {
this.$refs.commonShopTable.open();
});
},
handleRemove(file, fileList) {
this.dataForm.icon = "";
// this.dataForm.noneBtnImg = fileList.length >= this.dataForm.limitCountImg;
},
handlePicSuccess(res, file) {
if (res.msg == "success") {
this.dataForm.icon = res;
this.$message.success("上传成功");
} else {
this.$message.error("上传失败");
}
},
changeType(e) {
console.log("e at line 256:", e);
if (e == 0) {
this.dataForm.content = "";
} else {
this.dataForm.url = "";
}
},
contentUploadSuccess(res, file) {
// console.log(res)
let quill = this.$refs.myQuillEditor.quill;
// 如果上传成功
if (res) {
// 获取光标所在位置
let length = quill.getSelection().index;
// 插入图片res为服务器返回的图片链接地址
quill.insertEmbed(length, "image", res.url);
// 调整光标到最后
quill.setSelection(length + 1);
} else {
// 提示信息需引入Message
this.$message.error("图片插入失败!");
}
},
// 失去焦点事件
onEditorBlur(quill) {
// console.log('editor blur!', quill)
},
// 获得焦点事件
onEditorFocus(quill) {
//console.log('editor focus!', quill)
},
// 准备富文本编辑器
onEditorReady(quill) {
// console.log('editor ready!', quill)
},
init(row) {
this.dataForm = { ...row };
if (this.dataForm.icon) {
this.fileList.push({
name: this.dataForm.icon,
url: this.dataForm.icon
});
}
if (this.dataForm.shopProduct) {
this.bindProductData = { ...this.dataForm.shopProduct };
} else {
this.bindProductData = {};
}
this.$forceUpdate();
this.visible = true;
this.$nextTick(()=>{
this.$refs.dataForm.clearValidate();
})
},
async getProductInfo() {
if (this.dataForm.relationId == "" || this.dataForm.type != 0) {
return false;
}
await this.$http({
url: this.$http.adornUrl(this.urlList.productInfo),
method: "POST",
data: {
productId: this.dataForm.relationId
},
header: {
//默认 无 说明:请求头
"Content-Type": "application/json"
}
}).then(({ data }) => {
console.log("data at line 273:", data);
this.bindProductData = data.detail.detail;
});
},
// 表单提交
dataFormSubmit: debounce(async function () {
this.$refs["dataForm"].validate(valid => {
if (valid) {
if (this.dataForm.appType == 0 || this.dataForm.appType) {
if (this.dataForm.type == 0 && this.dataForm.relationId == "") {
this.$message.error("请选择关联商品");
return;
}
} else {
this.$message.error("请选择发布APP");
return;
}
if (this.dataForm.type == 0 || this.dataForm.type) {
} else {
this.$message.error("请选择广告类型");
return;
}
if (!this.dataForm.icon || this.dataForm.icon == "") {
this.$message.error("请上传图片");
return;
}
console.log("this.dataForm.type at line 332:", this.dataForm);
this.$http
.request({
url: this.$http.adornUrl(
this.dataForm.id ? this.urlList.edit : this.urlList.add
),
method: "POST",
data: this.dataForm,
header: {
//默认 无 说明:请求头
"Content-Type": "application/json"
}
})
.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);
}
});
}
});
},200),
handlePicSuccess(res, file) {
// console.log(res,'res')
if (res.msg == "success") {
this.dataForm.icon = res.url;
this.fileList.push({
name: file.name,
url: res.url
});
// console.log(this.dataForm.image,'image')
this.$message.success("上传成功");
} else {
this.$message.error("上传失败");
}
},
handleRemove(file, fileList) {
this.dataForm.icon = "";
this.fileList = [];
this.dataForm.noneBtnImg = fileList.length >= this.dataForm.limitCountImg;
},
handlePictureCardPreview(file) {
this.dataForm.icon = file.url;
this.dialogVisible = true;
},
handleDownload(file) {
console.log(file);
},
handlereset() {
(this.fileList = []), (this.fileListNovel = []), (this.visible = false);
},
handlePreview(file) {
console.log(file);
},
handleExceed(files, fileList) {
this.$message.warning(
`当前限制选择 3 个文件,本次选择了 ${
files.length
} 个文件,共选择了 ${files.length + fileList.length} 个文件`
);
},
beforeRemove(file, fileList) {
return this.$confirm(`确定移除 ${file.name}`);
},
handleRemoveNovel(file) {
this.dataForm.novel = "";
},
handleNovelSuccess(file) {
this.dataForm.novel = file.url;
}
}
};
</script>
<style lang="scss" scoped>
.el-uploadfeng {
/deep/ .el-upload-list__item {
width: 120px;
height: 120px;
.el-upload-list__item-thumbnail {
object-fit: cover !important;
}
}
/deep/ .el-upload--picture-card {
width: 100px;
height: 100px;
line-height: 110px;
}
}
/deep/ .addFormBox.el-form-item {
margin-bottom: 10px !important;
}
/deep/ .ql-container {
min-height: 400px !important ;
}
/deep/ .el-radio {
margin-right: 0 !important;
}
/deep/ .iconBox {
background: transparent !important;
}
</style>

View File

@@ -0,0 +1,350 @@
<template>
<div class="mod-config" style="height: calc(100vh - 180px );">
<el-button type="primary" size="small" @click="addOrUpdateHandle()" style="margin-bottom: 20px;float: right;"
>新增活动</el-button
>
<div style="height: calc(100% - 40px );">
<el-table
:data="dataList"
border
height="90%"
v-loading="dataListLoading"
style="width: 100%;"
>
<el-table-column label="活动ID" width="70" align="center" prop="productId">
</el-table-column>
<el-table-column
prop="title"
header-align="center"
align="center"
label="活动名称"
width="200"
>
<template slot-scope="scope">
</template>
</el-table-column>
<!-- <el-table-column
prop="title"
header-align="center"
align="center"
label="APP"
width="200"
>
<template slot-scope="scope">
<div>
<span v-if="scope.row.appType == 0">疯子读书</span>
<span v-if="scope.row.appType == 1">吴门医述</span>
<span v-if="scope.row.appType == 2">众妙之门</span>
</div>
</template>
</el-table-column> -->
<el-table-column
prop="title"
header-align="center"
align="center"
label="活动图片"
>
<template slot-scope="scope">
<img
v-if="scope.row.icon != ''"
:src="scope.row.icon"
alt=""
style="width: 50px; height: 70px;"
/>
</template>
</el-table-column>
<el-table-column
prop="title"
header-align="center"
align="center"
label="价格"
>
<template slot-scope="scope">
</template>
</el-table-column>
<el-table-column
prop="title"
header-align="center"
align="center"
label="活动详情"
>
<template slot-scope="scope">
</template>
</el-table-column>
<el-table-column
width="160"
prop="createTime"
header-align="center"
align="center"
label="创建日期"
>
</el-table-column>
<el-table-column
fixed="right"
header-align="center"
align="center"
width="140"
label="操作"
>
<template slot-scope="scope">
<div>
<el-button
type="text"
size="small"
@click="addOrUpdateHandle(scope.row)"
>修改</el-button
>
<el-button
type="text"
size="small"
style="color: red;"
@click="deleteHandle(scope.row.id)"
>删除</el-button
>
</div>
</template>
</el-table-column>
</el-table>
</div>
<!-- 弹窗, 新增 / 修改 -->
<add-or-update
v-if="addOrUpdateVisible"
ref="addOrUpdate"
:APPList="APPList"
:typeList="typeList"
@refreshDataList="getDataList"
></add-or-update>
</div>
</template>
<script>
import AddOrUpdate from "./eventManagement-add-or-update";
export default {
data() {
return {
typeList: [
{ label: "商品", value: 0 },
{ label: "充值", value: 1 },
{ label: "VIP", value: 2 },
{ label: "活动", value: 3 }
],
selectQueryApp: null,
APPList: [
{ label: "疯子读书", value: 0 },
{ label: "吴门医述", value: 1 },
{ label: "众妙之门", value: 2 }
],
dataForm: {
key: ""
},
query: {
type: "",
title: ""
},
dataList: [],
delFlag: false,
pageIndex: 1,
pageSize: 10,
totalPage: 0,
dataListLoading: false,
dataListSelections: [],
addOrUpdateVisible: false,
urlList: {
list: "/master/mainAd/getMainAdList"
}
};
},
components: {
AddOrUpdate
},
activated() {
if (this.$route.query.upPageInde != null) {
this.pageIndex = this.$route.query.upPageIndex;
console.log(this.pageIndex);
}
this.getDataList();
},
methods: {
// 获取数据列表
getDataList() {
console.log("this.selectQueryApp at line 195:", this.selectQueryApp);
this.dataListLoading = true;
this.$http
.request({
url: this.$http.adornUrl(this.urlList.list),
method: "POST",
data: {},
header: {
//默认 无 说明:请求头
"Content-Type": "application/json"
}
})
.then(({ data }) => {
if (data && data.code === 0) {
this.dataList = data.list;
console.log('this.dataList at line 230:', this.dataList)
// this.totalPage = data.result.total;
} else {
this.dataList = [];
// this.totalPage = 0;
}
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;
},
// 新增 / 修改
addOrUpdateHandle(row) {
console.log('row at line 258:', row)
this.addOrUpdateVisible = true;
this.$nextTick(() => {
this.$refs.addOrUpdate.init({
...row
});
});
},
// 删除
deleteHandle(id) {
this.$confirm(
`确定对[id=${id}]进行[${id ? "删除" : "删除"}]操作?`,
"提示",
{
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}
).then(() => {
this.$http({
url: this.$http.adornUrl("/master/mainAd/delMainAd"),
method: "POST",
data: {
id: id
}
}).then(({ data }) => {
if (data && data.code === 0) {
this.$message({
message: "操作成功",
type: "success",
});
this.$nextTick(() => {
this.getDataList();
});
} else {
this.$message.error(data.msg);
}
});
});
},
// 开关变化
SwitchChange(event) {
/*点击时他会自动把你绑定的值变更,直接去请求数据就可以了*/
var parms = {
delFlag: event.delFlag,
id: event.id
};
this.$http({
url: this.$http.adornUrl("/book/book/update"),
method: "post",
data: parms
})
.then(res => {
this.$message({
message: "成功",
type: "success"
});
this.loading = false;
this.getDataList();
})
.catch(error => {
this.loading = false;
console.log(error);
});
console.log(event);
},
chapterHandle(id, row) {
if (row.novel == "") {
this.$alert("请上传电子书文件后在进行此操作", "提示", {
confirmButtonText: "好的"
});
return false;
}
this.$http({
url: this.$http.adornUrl("/book/book/getChapter"),
method: "get",
params: this.$http.adornParams({
id: id
})
}).then(res => {
this.$message({
message: "成功",
type: "success"
});
this.loading = false;
this.getDataList();
});
},
contentHandle(id) {
this.$http({
url: this.$http.adornUrl("/book/bookchaptercontent/getBookVoices"),
method: "get",
params: this.$http.adornParams({
id: id
})
}).then(res => {
this.$message({
message: "成功",
type: "success"
});
this.loading = false;
this.getDataList();
});
},
voicesHandle(id) {
//allVoices
this.$http({
// url: this.$http.adornUrl('/book/bookchaptercontent/allVoices'),
url: this.$http.adornUrl("/book/bookchaptercontent/AllVOices"),
method: "get",
params: this.$http.adornParams({
id: id
})
}).then(res => {
console.log("book/bookchaptercontent/AllVOices");
this.$message({
message: "成功",
type: "success"
});
this.loading = false;
this.getDataList();
});
}
}
};
</script>

View File

@@ -135,27 +135,42 @@
> >
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="24" v-if="dataForm.couponRange == 1"> <el-col
:span="24"
v-if="dataForm.couponRange == 1 || dataForm.couponRange == 4"
>
<el-form-item label="" prop="rangeInfo" width="100%"> <el-form-item label="" prop="rangeInfo" width="100%">
<div class="flexBox"> <div class="flexBox">
<el-table <el-table
v-if="proSelectLinkList.length > 0" v-if="proSelectLinkList.length > 0"
:data="proSelectLinkList" :data="proSelectLinkList"
> >
<el-table-column label="课程名称"> <el-table-column
:label="
`${dataForm.couponRange == 1 ? '课程' : '商品'}名称`
"
>
<template slot-scope="scope"> <template slot-scope="scope">
{{ scope.row.title }} {{
dataForm.couponRange == 1
? scope.row.title
: scope.row.productName
}}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="封面"> <el-table-column label="封面">
<template slot-scope="scope"> <template slot-scope="scope">
<div <div
v-if="scope.row.image" v-if="scope.row.image || scope.row.productImages"
style="width:100%;display: flex; style="width:100%;display: flex;
align-items: center;justify-content: center;" align-items: center;justify-content: center;"
> >
<img <img
:src="scope.row.image" :src="
dataForm.couponRange == 1
? scope.row.image
: scope.row.productImages
"
alt="" alt=""
width="40px" width="40px"
height="40px" height="40px"
@@ -289,6 +304,7 @@
<selectPro <selectPro
ref="selectPro" ref="selectPro"
v-if="showSelectPro" v-if="showSelectPro"
:type="dataForm.couponRange"
@close="selectProClose" @close="selectProClose"
:requesturl="requesturl" :requesturl="requesturl"
:oldData="proSelectLinkList" :oldData="proSelectLinkList"
@@ -426,25 +442,42 @@ export default {
if (data.length > 0) { if (data.length > 0) {
this.proSelectLinkList = this.proSelectLinkList.concat(data); this.proSelectLinkList = this.proSelectLinkList.concat(data);
var list = [...this.proSelectLinkList]; var list = [...this.proSelectLinkList];
if (this.dataForm.couponRange == 1) {
this.proSelectLinkList = [ this.proSelectLinkList = [
...new Map(list.map(item => [item.id, item])).values() ...new Map(list.map(item => [item.id, item])).values()
]; ];
} else if (this.dataForm.couponRange == 4) {
this.proSelectLinkList = [
...new Map(list.map(item => [item.productId, item])).values()
];
}
// this.dataForm.rangeInfo = this.proSelectLinkList.map( item => item.id).join(',') // this.dataForm.rangeInfo = this.proSelectLinkList.map( item => item.id).join(',')
console.log("去重后", this.proSelectLinkList); console.log("去重后", this.proSelectLinkList);
} }
}, },
addLinkPro() { addLinkPro() {
this.showSelectPro = true; this.showSelectPro = true;
this.requesturl = "/common/coupon/getCourseList"; this.requesturl =
this.dataForm.couponRange == 1
? "/common/coupon/getCourseList"
: "/master/shopProduct/listByPage";
}, },
changeCate(e) { changeCate(e) {
console.log("e", e); console.log("e", e);
this.cateSelectLinkList = e; this.cateSelectLinkList = e;
this.showCateError = false; this.showCateError = false;
// this.dataForm.rangeInfo = e.join(","); // this.dataForm.rangeInfo = e.join(",");
}, },
async changeRange(e) { async changeRange(e) {
console.log("范围切换", e); console.log("范围切换", e); if (e == 1 || e == 4) {
this.selectLinkList = [];
this.proSelectLinkList = [];
this.$forceUpdate();
}
// this.dataForm.couponRange = e // this.dataForm.couponRange = e
// this.getDataList() // this.getDataList()
}, },
@@ -531,6 +564,10 @@ export default {
data.couponEntity.rangeList.length > 0 data.couponEntity.rangeList.length > 0
) { ) {
this.selectLinkList = data.couponEntity.rangeList; this.selectLinkList = data.couponEntity.rangeList;
console.log(
"this.selectLinkList at line 544:",
this.selectLinkList
);
} else { } else {
this.selectLinkList = []; this.selectLinkList = [];
} }
@@ -548,7 +585,10 @@ export default {
this.cateSelectLinkList = ss.map(element => this.cateSelectLinkList = ss.map(element =>
parseInt(element) parseInt(element)
); );
} else if (this.dataForm.couponRange == 1) { } else if (
this.dataForm.couponRange == 1 ||
this.dataForm.couponRange == 4
) {
this.proSelectLinkList = this.selectLinkList; this.proSelectLinkList = this.selectLinkList;
} else { } else {
this.cateSelectLinkList = []; this.cateSelectLinkList = [];
@@ -683,15 +723,17 @@ export default {
this.dataForm.rangeInfo = this.proSelectLinkList this.dataForm.rangeInfo = this.proSelectLinkList
.map(item => item.id) .map(item => item.id)
.join(","); .join(",");
// if (
// this.dataForm.rangeInfo == null ||
// this.dataForm.rangeInfo == ""
// ) {
// this.$message.error("请选择课程");
// return false;
// }
} }
if (Number(this.dataForm.useLevel) <= Number(this.dataForm.couponAmount)) { if (this.dataForm.couponRange == 4) {
if (this.proSelectLinkList.length == 0)
return this.$message.error("请选择商品");
this.dataForm.rangeInfo = this.proSelectLinkList
.map(item => item.productId)
.join(",");
}
if (
Number(this.dataForm.useLevel) <= Number(this.dataForm.couponAmount)
) {
this.$message.error("优惠券面额不能大于使用门槛"); this.$message.error("优惠券面额不能大于使用门槛");
return false; return false;
} }

View File

@@ -280,6 +280,12 @@ export default {
return "课程券"; return "课程券";
case 2: case 2:
return "课程品类券"; return "课程品类券";
case 3:
return "全部课程";
case 4:
return "商品券";
case 5:
return "全部商品券";
} }
} }
}, },