|
|
@@ -1,35 +1,32 @@
|
|
|
<template>
|
|
|
<div class="search">
|
|
|
<Card>
|
|
|
- <Row>
|
|
|
- <Form ref="searchForm" :model="searchForm" inline :label-width="70" class="search-form">
|
|
|
- <Form-item label="活动名称" prop="couponName">
|
|
|
- <Input type="text" v-model="searchForm.couponName" placeholder="请输入活动名称" clearable style="width: 200px" />
|
|
|
- </Form-item>
|
|
|
- <Form-item label="活动状态" prop="promotionStatus">
|
|
|
- <Select v-model="searchForm.promotionStatus" placeholder="请选择" clearable style="width: 200px">
|
|
|
- <Option value="NEW">未开始</Option>
|
|
|
- <Option value="START">已开始/上架</Option>
|
|
|
- <Option value="END">已结束/下架</Option>
|
|
|
- <Option value="CLOSE">紧急关闭/作废</Option>
|
|
|
- </Select>
|
|
|
- </Form-item>
|
|
|
- <Form-item label="活动时间">
|
|
|
- <DatePicker v-model="selectDate" type="daterange" clearable placeholder="选择起始时间" style="width: 200px"></DatePicker>
|
|
|
- </Form-item>
|
|
|
- <Button @click="handleSearch" type="primary" icon="ios-search" class="search-btn">搜索</Button>
|
|
|
- </Form>
|
|
|
- </Row>
|
|
|
- <Row class="operation padding-row">
|
|
|
+ <Form ref="searchForm" :model="searchForm" inline :label-width="70" class="search-form mb_10">
|
|
|
+ <Form-item label="活动名称" prop="couponName">
|
|
|
+ <Input type="text" v-model="searchForm.couponName" placeholder="请输入活动名称" clearable style="width: 200px" />
|
|
|
+ </Form-item>
|
|
|
+ <Form-item label="活动状态" prop="promotionStatus">
|
|
|
+ <Select v-model="searchForm.promotionStatus" placeholder="请选择" clearable style="width: 200px">
|
|
|
+ <Option value="NEW">未开始</Option>
|
|
|
+ <Option value="START">已开始/上架</Option>
|
|
|
+ <Option value="END">已结束/下架</Option>
|
|
|
+ <Option value="CLOSE">紧急关闭/作废</Option>
|
|
|
+ </Select>
|
|
|
+ </Form-item>
|
|
|
+ <Form-item label="活动时间">
|
|
|
+ <DatePicker v-model="selectDate" type="daterange" clearable placeholder="选择起始时间" style="width: 200px"></DatePicker>
|
|
|
+ </Form-item>
|
|
|
+ <Button @click="handleSearch" type="primary" icon="ios-search" class="search-btn">搜索</Button>
|
|
|
+ </Form>
|
|
|
+ <Row class="operation padding-row" v-if="getType !== 'ACTIVITY'">
|
|
|
<Button @click="add" type="primary">添加优惠券</Button>
|
|
|
<Button @click="delAll">批量下架</Button>
|
|
|
- <!-- <Button @click="upAll" >批量上架</Button> -->
|
|
|
</Row>
|
|
|
- <Table :loading="loading" border :columns="columns" :data="data" ref="table" sortable="custom" @on-sort-change="changeSort" @on-select-cancel="cancelSelect" @on-selection-change="changeSelect">
|
|
|
+ <Table v-if="refreshTable" :loading="loading" border :columns="columns" :data="data" ref="table" @on-selection-change="changeSelect">
|
|
|
<template slot-scope="{ row }" slot="action">
|
|
|
- <Button v-if="!checked && row.promotionStatus === 'NEW' || row.promotionStatus === 'CLOSE'" type="success" :class="{'mr_10' : !checked && row.promotionStatus === 'START' || row.promotionStatus === 'NEW'}" size="small" @click="edit(row)">编辑
|
|
|
+ <Button v-if="row.promotionStatus === 'NEW' || row.promotionStatus === 'CLOSE'" type="success" :class="{'mr_10' : row.promotionStatus === 'START' || row.promotionStatus === 'NEW'}" size="small" @click="edit(row)">编辑
|
|
|
</Button>
|
|
|
- <Button v-if="!checked && row.promotionStatus === 'START' || row.promotionStatus === 'NEW'" type="error" size="small" @click="remove(row)">下架
|
|
|
+ <Button v-if="row.promotionStatus === 'START' || row.promotionStatus === 'NEW'" type="error" size="small" @click="remove(row)">下架
|
|
|
</Button>
|
|
|
</template>
|
|
|
</Table>
|
|
|
@@ -220,15 +217,10 @@ export default {
|
|
|
],
|
|
|
data: [], // 表单数据
|
|
|
total: 0, // 表单数据总数
|
|
|
- selectCoupon: [], //本级选中的优惠券
|
|
|
+ refreshTable: true, // 修改选中状态后刷新表格
|
|
|
};
|
|
|
},
|
|
|
props: {
|
|
|
- // 是否为选中模式
|
|
|
- checked: {
|
|
|
- type: Boolean,
|
|
|
- default: false,
|
|
|
- },
|
|
|
//优惠券类型 查询参数
|
|
|
getType: {
|
|
|
type: String,
|
|
|
@@ -246,94 +238,73 @@ export default {
|
|
|
this.init();
|
|
|
}
|
|
|
},
|
|
|
- },
|
|
|
- methods: {
|
|
|
// 选中优惠券 父级传值
|
|
|
selectedList: {
|
|
|
handler(val) {
|
|
|
// 判断是否是父级回调给自己已选择优惠券
|
|
|
- if (val.length != 0) {
|
|
|
- this.selectCoupon = val;
|
|
|
+ if (val.length) {
|
|
|
+ this.selectList = val;
|
|
|
+ this.data.forEach((item) => {
|
|
|
+ item._checked = false;
|
|
|
+ if (this.selectList.length) {
|
|
|
+ this.selectList.forEach((child) => {
|
|
|
+ if (item.id == child.id) {
|
|
|
+ item._checked = true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.data.forEach((item) => {
|
|
|
+ item._checked = false;
|
|
|
+ });
|
|
|
}
|
|
|
+ this.refreshTable = false;
|
|
|
+ this.$nextTick(() =>{
|
|
|
+ this.refreshTable = true;
|
|
|
+ })
|
|
|
},
|
|
|
deep: true,
|
|
|
- immediate: true,
|
|
|
},
|
|
|
- check() {
|
|
|
- // this.selectCoupon.push(this.selectList)
|
|
|
- this.$emit("selected", this.selectCoupon);
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ check() { // 选中的优惠券
|
|
|
+ this.$emit("selected", this.selectList);
|
|
|
},
|
|
|
init() {
|
|
|
this.getDataList();
|
|
|
},
|
|
|
- add() {
|
|
|
+ add() { // 跳转添加页面
|
|
|
this.$router.push({ name: "add-platform-coupon" });
|
|
|
},
|
|
|
- /** 跳转至领取详情页面 */
|
|
|
- receiveInfo(v) {
|
|
|
- this.$router.push({ name: "member-receive-coupon", query: { id: v.id } });
|
|
|
- },
|
|
|
- info(v) {
|
|
|
+ info(v) { // 查看优惠券
|
|
|
this.$router.push({ name: "platform-coupon-info", query: { id: v.id } });
|
|
|
},
|
|
|
- changePage(v) {
|
|
|
+ changePage(v) { // 改变页码
|
|
|
this.searchForm.pageNumber = v;
|
|
|
this.getDataList();
|
|
|
- // this.clearSelectAll();
|
|
|
},
|
|
|
- changePageSize(v) {
|
|
|
+ changePageSize(v) { // 改变页数
|
|
|
this.searchForm.pageSize = v;
|
|
|
this.getDataList();
|
|
|
},
|
|
|
- handleSearch() {
|
|
|
+ handleSearch() { // 搜索
|
|
|
this.searchForm.pageNumber = 0;
|
|
|
this.searchForm.pageSize = 10;
|
|
|
this.getDataList();
|
|
|
},
|
|
|
- changeSort(e) {
|
|
|
- this.searchForm.sort = e.key;
|
|
|
- this.searchForm.order = e.order;
|
|
|
- if (e.order === "normal") {
|
|
|
- this.searchForm.order = "";
|
|
|
- }
|
|
|
- this.getDataList();
|
|
|
- },
|
|
|
- clearSelectAll() {
|
|
|
+ clearSelectAll() { // 清除选中状态
|
|
|
this.$refs.table.selectAll(false);
|
|
|
},
|
|
|
-
|
|
|
- /**
|
|
|
- * 取消已选择的数据
|
|
|
- */
|
|
|
- cancelSelect(selection, row) {
|
|
|
- console.log(row)
|
|
|
- let findCoupon = this.selectCoupon.find((item) => {
|
|
|
- return item.id == row.id;
|
|
|
- });
|
|
|
- // 如果没有则添加
|
|
|
- if (!findCoupon) {
|
|
|
- this.selectCoupon.push(row);
|
|
|
- } else {
|
|
|
- // 有重复数据就删除
|
|
|
- this.selectCoupon.map((item, index) => {
|
|
|
- if (item.id == findCoupon.id) {
|
|
|
- this.selectCoupon.splice(index, 1);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- },
|
|
|
/**
|
|
|
* 选择优惠券
|
|
|
*/
|
|
|
changeSelect(e) {
|
|
|
- if (this.checked && e.length != 0) {
|
|
|
- this.selectCoupon.push(...e);
|
|
|
- this.check();
|
|
|
- }
|
|
|
this.selectList = e;
|
|
|
this.selectCount = e.length;
|
|
|
+ if (this.getType === 'ACTIVITY') this.check()
|
|
|
},
|
|
|
- getDataList() {
|
|
|
+ getDataList() { // 获取数据
|
|
|
this.loading = true;
|
|
|
if (this.selectDate && this.selectDate[0] && this.selectDate[1]) {
|
|
|
this.searchForm.startTime = this.selectDate[0].getTime();
|
|
|
@@ -346,18 +317,6 @@ export default {
|
|
|
getPlatformCouponList(this.searchForm).then((res) => {
|
|
|
this.loading = false;
|
|
|
if (res.success) {
|
|
|
- res.result.records.forEach((item) => {
|
|
|
- if (this.selectCoupon.length != 0) {
|
|
|
- this.selectCoupon.forEach((child) => {
|
|
|
- if (item.id == child.id) {
|
|
|
- item.___selected = true;
|
|
|
- item._checked = true;
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- item.___selected = false;
|
|
|
- });
|
|
|
-
|
|
|
this.data = res.result.records;
|
|
|
this.total = res.result.total;
|
|
|
}
|
|
|
@@ -365,43 +324,11 @@ export default {
|
|
|
this.total = this.data.length;
|
|
|
this.loading = false;
|
|
|
},
|
|
|
- handleSubmit() {
|
|
|
- this.$refs.form.validate((valid) => {
|
|
|
- if (valid) {
|
|
|
- this.submitLoading = true;
|
|
|
- if (this.modalType === 0) {
|
|
|
- // 添加 避免编辑后传入id等数据 记得删除
|
|
|
- delete this.form.id;
|
|
|
- this.postRequest("/coupon/insertOrUpdate", this.form).then(
|
|
|
- (res) => {
|
|
|
- this.submitLoading = false;
|
|
|
- if (res.success) {
|
|
|
- this.$Message.success("操作成功");
|
|
|
- this.getDataList();
|
|
|
- this.modalVisible = false;
|
|
|
- }
|
|
|
- }
|
|
|
- );
|
|
|
- } else {
|
|
|
- // 编辑
|
|
|
- this.postRequest("/coupon/insertOrUpdate", this.form).then(
|
|
|
- (res) => {
|
|
|
- this.submitLoading = false;
|
|
|
- if (res.success) {
|
|
|
- this.$Message.success("操作成功");
|
|
|
- this.getDataList();
|
|
|
- this.modalVisible = false;
|
|
|
- }
|
|
|
- }
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- edit(v) {
|
|
|
+
|
|
|
+ edit(v) { // 跳转编辑页面
|
|
|
this.$router.push({ name: "edit-platform-coupon", query: { id: v.id } });
|
|
|
},
|
|
|
- remove(v) {
|
|
|
+ remove(v) { // 下架优惠券
|
|
|
this.$Modal.confirm({
|
|
|
title: "确认下架",
|
|
|
// 记得确认修改此处
|
|
|
@@ -426,7 +353,7 @@ export default {
|
|
|
},
|
|
|
});
|
|
|
},
|
|
|
- delAll() {
|
|
|
+ delAll() { // 批量下架
|
|
|
if (this.selectCount <= 0) {
|
|
|
this.$Message.warning("您还未选择要下架的优惠券");
|
|
|
return;
|
|
|
@@ -456,41 +383,12 @@ export default {
|
|
|
},
|
|
|
});
|
|
|
},
|
|
|
- upAll() {
|
|
|
- if (this.selectCount <= 0) {
|
|
|
- this.$Message.warning("请选择要上架的优惠券");
|
|
|
- return;
|
|
|
- }
|
|
|
- this.$Modal.confirm({
|
|
|
- title: "确认上架",
|
|
|
- content: "您确认要上架所选的 " + this.selectCount + " 条数据?",
|
|
|
- loading: true,
|
|
|
- onOk: () => {
|
|
|
- let ids = [];
|
|
|
- this.selectList.forEach(function (e) {
|
|
|
- ids.push(e.id);
|
|
|
- });
|
|
|
- let params = {
|
|
|
- couponIds: ids.toString(),
|
|
|
- promotionStatus: "START",
|
|
|
- };
|
|
|
- // 批量上架
|
|
|
- updatePlatformCouponStatus(params).then((res) => {
|
|
|
- this.$Modal.remove();
|
|
|
- if (res.success) {
|
|
|
- this.$Message.success("上架成功");
|
|
|
- this.clearSelectAll();
|
|
|
- this.getDataList();
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- });
|
|
|
- },
|
|
|
},
|
|
|
mounted() {
|
|
|
//如果作为组件方式,传入了类型值,则搜索参数附加类型
|
|
|
if (this.getType) {
|
|
|
this.searchForm.getType = this.getType;
|
|
|
+ this.columns.pop()
|
|
|
}
|
|
|
this.init();
|
|
|
},
|