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

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

@@ -1,5 +1,5 @@
<template>
<el-drawer
<el-drawer
size="50%"
title="请选择"
:visible.sync="drawer"
@@ -7,7 +7,7 @@
:before-close="handleClose"
>
<div style="padding:15px">
<!-- <el-button class="closeBtn" type="primary" plain
<!-- <el-button class="closeBtn" type="primary" plain
@click="handleClose">确定选中并关闭</el-button
> -->
<el-form
@@ -15,13 +15,20 @@
:model="query"
@keyup.enter.native="getDataList()"
>
<el-form-item label="课程名称">
<el-form-item label="课程名称" v-if="type == 1">
<el-input
v-model="query.courseName"
placeholder="课程名称"
clearable
></el-input>
</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-button
@@ -31,50 +38,54 @@
"
>查询</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-table
v-loading="dataListLoading"
:data="dataList"
border
style="width: 100%; "
>
<!-- <el-table-column type="selection" > </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">
<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"],
props: ["requesturl", "oldData", "type"],
data() {
return {
drawer: true,
@@ -82,52 +93,78 @@ export default {
dataList: [],
selected: [],
query: {
courseName: ""
courseName: "",
productName: ""
},
pageSize: 10,
pageIndex: 1,
totalPage: 0,
dataListLoading: false,
dataListLoading: false
};
},
mounted() {
console.log("挂载");
this.getDataList();
},
filters: {
},
filters: {},
methods: {
checkBtnStatus(val) {
let index = this.oldData.findIndex(item => item.id === val.id);
if(index > -1){
return true
}else{
return false
}
var index;
if (this.type == 1) {
index = this.oldData.findIndex(item => item.id === val.id);
} else if (this.type == 4) {
index = this.oldData.findIndex(item => item.productId === val.productId);
}
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
var _list;
if (this.type == 1) {
console.log("课程", row);
_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)
}
else if (this.type == 4) {
console.log("商品", row);
_list = this.selected.map(item => item.productId);
if (_list.includes(row.productId)) {
this.$message({
message: "已选择该商品",
type: "warning"
});
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) {
this.pageSize = val;
this.pageIndex = 1;
this.getDataList();
@@ -139,32 +176,49 @@ export default {
},
handleClose(done) {
this.$emit("close", this.selected);
this.selected = []
this.selected = [];
},
getDataList() {
this.dataListLoading = true;
this.dataListLoading = true;
this.$http({
url: this.$http.adornUrl(this.requesturl),
method: "post",
data: this.$http.adornData({
page: this.pageIndex,
limit: this.pageSize,
title: this.query.courseName
data: this.$http.adornData(
this.type == 1
? {
page: this.pageIndex,
limit: this.pageSize,
title: this.query.courseName
}
: {
current: this.pageIndex,
limit: this.pageSize,
productName: this.query.productName,
goodsType: "00"
}
)
})
.then(({ data }) => {
if (data.code != 0) return this.$message.error(data.msg);
if (data && data.code === 0) {
if (this.type == 1) {
this.dataList = data.courses.records;
this.totalPage = data.courses.total;
} else if (this.type == 4) {
this.dataList = data.result.records;
this.totalPage = data.result.total;
}
} else {
this.dataList = [];
this.totalPage = 0;
}
this.dataListLoading = false;
})
}).then(({ data }) => {
if(data.code != 0) return this.$message.error(data.msg);
if (data && data.code === 0) {
this.dataList = data.courses.records;
this.totalPage = data.courses.total;
} else {
this.dataList = [];
this.totalPage = 0;
}
this.dataListLoading = false;
}).catch((e) => {
this.$message.error(e.msg);
this.dataListLoading = false;
});
.catch(e => {
this.$message.error(e.msg);
this.dataListLoading = false;
});
}
}
};