砍价第一版本

master
pikachu 2021-07-12 23:42:59 +08:00
parent cc1afed902
commit 726b11eb82
3 changed files with 1323 additions and 0 deletions

View File

@ -0,0 +1,437 @@
<template>
<div>
<Card>
<Form ref="form" :model="form" :label-width="120" :rules="formRule">
<div class="base-info-item">
<div class="form-item-view">
<h4>商品信息</h4>
<FormItem label="选择商品" prop="scopeType">
<Button type="primary" @click="openSkuList"></Button>
<Button
type="error"
ghost
style="margin-left: 10px"
@click="delSelectGoods"
>批量删除
</Button
>
</FormItem>
<FormItem astyle="width: 100%">
<Table
border
:columns="columns"
:data="form.promotionGoodsList"
@on-selection-change="changeSelect"
>
<template slot-scope="{ row }" slot="skuId">
<div>{{ row.skuId }}</div>
</template>
<template slot-scope="{ index }" slot="settlementPrice">
<Input
type="number"
v-model="form.promotionGoodsList[index].settlementPrice"
/>
</template>
<template slot-scope="{ index }" slot="lowestPrice">
<Input
type="number"
v-model="form.promotionGoodsList[index].lowestPrice"
/>
</template>
<template slot-scope="{ index }" slot="highestPrice">
<Input
type="number"
v-model="form.promotionGoodsList[index].highestPrice"
/>
</template>
<template slot-scope="{ index }" slot="purchasePrice">
<Input
type="number"
v-model="form.promotionGoodsList[index].purchasePrice"
/>
</template>
<template slot-scope="{ index }" slot="stock">
<Input
type="number"
v-model="form.promotionGoodsList[index].stock"
/>
</template>
</Table>
</FormItem>
<FormItem label="活动时间" prop="rangeTime">
<DatePicker
type="datetimerange"
v-model="form.rangeTime"
format="yyyy-MM-dd HH:mm:ss"
placeholder="请选择"
:options="options"
style="width: 260px"
>
</DatePicker>
</FormItem>
<div>
<Button type="text" @click="closeCurrentPage"></Button>
<Button type="primary" :loading="submitLoading" @click="handleSubmit"></Button>
</div>
</div>
</div>
</Form>
</Card>
<sku-select
ref="skuSelect"
@selectedGoodsData="selectedGoodsData"
></sku-select>
</div>
</template>
<script>
import {
saveKanjiaActivityGoods,
getPlatformCoupon,
editPlatformCoupon,
} from "@/api/promotion";
import {regular} from "@/utils";
import skuSelect from "@/views/lili-dialog";
export default {
name: "addCoupon",
components: {
skuSelect,
},
watch: {},
data() {
return {
modalType: 0, //
form: {
promotionGoodsList: [], //
},
id: this.$route.query.id, // id
submitLoading: false, //
selectedGoods: [], // 便
promotionGoodsList: [], //
formRule: {
rangeTime: [{required: true, message: "请选择活动时间"}],
},
columns: [
{
type: "selection",
width: 60,
align: "center",
},
{
title: "商品名称",
key: "goodsName",
tooltip: true,
minWidth: 100,
},
{
title: "商品价格",
key: "price",
width: 120,
render: (h, params) => {
return h(
"div",
this.$options.filters.unitPrice(params.row.price, "¥")
);
},
},
{
title: "库存",
key: "quantity",
width: 100,
},
{
title: "结算价格",
slot: "settlementPrice",
width: 110,
},
{
title: "最低砍",
slot: "lowestPrice",
width: 110,
},
{
title: "最高砍",
slot: "highestPrice",
width: 110,
},
{
title: "最低购买金额",
slot: "purchasePrice",
width: 110,
},
{
title: "活动库存",
slot: "stock",
width: 110,
},
{
title: "操作",
key: "action",
align: "center",
width: 100,
render: (h, params) => {
return h(
"Button",
{
props: {
size: "small",
type: "error",
ghost: true,
},
on: {
click: () => {
this.delGoods(params.index);
},
},
},
"删除"
);
},
},
],
options: {
disabledDate(date) {
return date && date.valueOf() < Date.now() - 86400000;
},
},
};
},
async mounted() {
// id
if (this.id) {
this.getCoupon();
this.modalType = 1;
}
},
methods: {
getCoupon() {
getPlatformCoupon(this.id).then((res) => {
let data = res.result;
});
},
openSkuList() { //
this.$refs.skuSelect.open("goods");
let data = JSON.parse(JSON.stringify(this.promotionGoodsList))
data.forEach(e => {
e.id = e.skuId
})
this.$refs.skuSelect.goodsData = data;
},
/** 保存砍价活动 */
handleSubmit() {
this.$refs.form.validate((valid) => {
if (valid) {
const params = JSON.parse(JSON.stringify(this.form));
if (this.form.rangeTime[0] === '' || this.form.rangeTime[0] === '') {
this.$Message.error("请选择活动时间");
return
}
params.startTime = this.$options.filters.unixToDate(
this.form.rangeTime[0] / 1000
);
params.endTime = this.$options.filters.unixToDate(
this.form.rangeTime[1] / 1000
);
delete params.rangeTime
let checkResult = true
//
if (this.form.promotionGoodsList.length > 0) {
this.form.promotionGoodsList.forEach((res) => {
//
if (res.stock <= 0 || res.stock > res.quantity) {
checkResult = false
this.$Message.error("活动库存不能为0且不能超过商品库存");
return
}
//
if (!regular.money.test(res.purchasePrice)) {
checkResult = false
this.$Message.error("最低购买金额格式不正确");
}
//
if (!regular.money.test(res.settlementPrice)) {
checkResult = false
this.$Message.error("结算价格金额格式不正确");
return
}
//
if (res.settlementPrice < 0 || res.settlementPrice > res.price) {
checkResult = false
this.$Message.error("结算价格金额不能为0且不能超过商品价格");
return
}
//
if (!regular.money.test(res.highestPrice)) {
checkResult = false
this.$Message.error("最高可砍金额格式错误");
return
}
if (res.highestPrice <= 0 || res.highestPrice > res.price) {
checkResult = false
this.$Message.error("最高可砍金额不能为0且不能超过商品价格");
return
}
//
if (!regular.money.test(res.lowestPrice)) {
checkResult = false
this.$Message.error("最低可砍金额格式错误");
return
}
if (res.lowestPrice <= 0 || res.lowestPrice > res.price) {
checkResult = false
this.$Message.error("最低可砍金额不能为0");
return
}
//
if (res.lowestPrice > res.highestPrice) {
checkResult = false
this.$Message.error("最低砍价金额不能大于最高砍价金额");
return
}
});
}
if (!checkResult) {
return;
}
this.submitLoading = true;
if (this.modalType === 0) {
// id
delete params.id;
saveKanjiaActivityGoods(params).then((res) => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("砍价活动添加成功");
this.closeCurrentPage();
}
});
} else {
//
delete params.consumeLimit;
delete params.updateTime;
editPlatformCoupon(params).then((res) => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("优惠券修改成功");
this.closeCurrentPage();
}
});
}
}
});
},
//
closeCurrentPage() {
this.$store.commit("removeTag", "add-platform-coupon");
localStorage.pageOpenedList = JSON.stringify(
this.$store.state.app.pageOpenedList
);
this.$router.go(-1);
},
openSkuList() {
//
this.$refs.skuSelect.open("goods");
let data = JSON.parse(JSON.stringify(this.form.promotionGoodsList));
data.forEach((e) => {
e.id = e.skuId;
});
this.$refs.skuSelect.goodsData = data;
},
changeSelect(e) {
//
this.selectedGoods = e;
},
delSelectGoods() {
//
if (this.selectedGoods.length <= 0) {
this.$Message.warning("您还未选择要删除的数据");
return;
}
this.$Modal.confirm({
title: "确认删除",
content: "您确认要删除所选商品吗?",
onOk: () => {
let ids = [];
this.selectedGoods.forEach(function (e) {
ids.push(e.id);
});
this.form.promotionGoodsList = this.form.promotionGoodsList.filter(
(item) => {
return !ids.includes(item.id);
}
);
},
});
},
delGoods(index) {
//
this.form.promotionGoodsList.splice(index, 1);
},
selectedGoodsData(item) {
//
let list = [];
item.forEach((e) => {
list.push({
settlementPrice: e.settlementPrice || 0,
purchasePrice: e.purchasePrice || 0,
lowestPrice: e.lowestPrice || 0,
highestPrice: e.highestPrice || 0,
stock: e.stock || 0,
goodsName: e.goodsName,
price: e.price,
originalPrice: e.price,
quantity: e.quantity,
storeId: e.storeId,
storeName: e.storeName,
skuId: e.id,
});
});
console.warn(list)
this.form.promotionGoodsList = list;
},
},
};
</script>
<style lang="scss" scpoed>
h4 {
margin-bottom: 10px;
padding: 0 10px;
border: 1px solid #ddd;
background-color: #f8f8f8;
font-weight: bold;
color: #333;
font-size: 14px;
line-height: 40px;
text-align: left;
}
.describe {
font-size: 12px;
margin-left: 10px;
color: #999;
}
.effectiveDays {
font-size: 12px;
color: #999;
> * {
margin: 0 4px;
}
}
.tips {
font-size: 12px;
color: #999;
}
</style>

View File

@ -0,0 +1,437 @@
<template>
<div>
<Card>
<Form ref="form" :model="form" :label-width="120" :rules="formRule">
<div class="base-info-item">
<div class="form-item-view">
<h4>商品信息</h4>
<FormItem label="选择商品" prop="scopeType">
<Button type="primary" @click="openSkuList"></Button>
<Button
type="error"
ghost
style="margin-left: 10px"
@click="delSelectGoods"
>批量删除
</Button
>
</FormItem>
<FormItem astyle="width: 100%">
<Table
border
:columns="columns"
:data="form.promotionGoodsList"
@on-selection-change="changeSelect"
>
<template slot-scope="{ row }" slot="skuId">
<div>{{ row.skuId }}</div>
</template>
<template slot-scope="{ index }" slot="settlementPrice">
<Input
type="number"
v-model="form.promotionGoodsList[index].settlementPrice"
/>
</template>
<template slot-scope="{ index }" slot="lowestPrice">
<Input
type="number"
v-model="form.promotionGoodsList[index].lowestPrice"
/>
</template>
<template slot-scope="{ index }" slot="highestPrice">
<Input
type="number"
v-model="form.promotionGoodsList[index].highestPrice"
/>
</template>
<template slot-scope="{ index }" slot="purchasePrice">
<Input
type="number"
v-model="form.promotionGoodsList[index].purchasePrice"
/>
</template>
<template slot-scope="{ index }" slot="stock">
<Input
type="number"
v-model="form.promotionGoodsList[index].stock"
/>
</template>
</Table>
</FormItem>
<FormItem label="活动时间" prop="rangeTime">
<DatePicker
type="datetimerange"
v-model="form.rangeTime"
format="yyyy-MM-dd HH:mm:ss"
placeholder="请选择"
:options="options"
style="width: 260px"
>
</DatePicker>
</FormItem>
<div>
<Button type="text" @click="closeCurrentPage"></Button>
<Button type="primary" :loading="submitLoading" @click="handleSubmit"></Button>
</div>
</div>
</div>
</Form>
</Card>
<sku-select
ref="skuSelect"
@selectedGoodsData="selectedGoodsData"
></sku-select>
</div>
</template>
<script>
import {
saveKanjiaActivityGoods,
getPlatformCoupon,
editPlatformCoupon,
} from "@/api/promotion";
import {regular} from "@/utils";
import skuSelect from "@/views/lili-dialog";
export default {
name: "addCoupon",
components: {
skuSelect,
},
watch: {},
data() {
return {
modalType: 0, //
form: {
promotionGoodsList: [], //
},
id: this.$route.query.id, // id
submitLoading: false, //
selectedGoods: [], // 便
promotionGoodsList: [], //
formRule: {
rangeTime: [{required: true, message: "请选择活动时间"}],
},
columns: [
{
type: "selection",
width: 60,
align: "center",
},
{
title: "商品名称",
key: "goodsName",
tooltip: true,
minWidth: 100,
},
{
title: "商品价格",
key: "price",
width: 120,
render: (h, params) => {
return h(
"div",
this.$options.filters.unitPrice(params.row.price, "¥")
);
},
},
{
title: "库存",
key: "quantity",
width: 100,
},
{
title: "结算价格",
slot: "settlementPrice",
width: 110,
},
{
title: "最低砍",
slot: "lowestPrice",
width: 110,
},
{
title: "最高砍",
slot: "highestPrice",
width: 110,
},
{
title: "最低购买金额",
slot: "purchasePrice",
width: 110,
},
{
title: "活动库存",
slot: "stock",
width: 110,
},
{
title: "操作",
key: "action",
align: "center",
width: 100,
render: (h, params) => {
return h(
"Button",
{
props: {
size: "small",
type: "error",
ghost: true,
},
on: {
click: () => {
this.delGoods(params.index);
},
},
},
"删除"
);
},
},
],
options: {
disabledDate(date) {
return date && date.valueOf() < Date.now() - 86400000;
},
},
};
},
async mounted() {
// id
if (this.id) {
this.getCoupon();
this.modalType = 1;
}
},
methods: {
getCoupon() {
getPlatformCoupon(this.id).then((res) => {
let data = res.result;
});
},
openSkuList() { //
this.$refs.skuSelect.open("goods");
let data = JSON.parse(JSON.stringify(this.promotionGoodsList))
data.forEach(e => {
e.id = e.skuId
})
this.$refs.skuSelect.goodsData = data;
},
/** 保存砍价活动 */
handleSubmit() {
this.$refs.form.validate((valid) => {
if (valid) {
const params = JSON.parse(JSON.stringify(this.form));
if (this.form.rangeTime[0] === '' || this.form.rangeTime[0] === '') {
this.$Message.error("请选择活动时间");
return
}
params.startTime = this.$options.filters.unixToDate(
this.form.rangeTime[0] / 1000
);
params.endTime = this.$options.filters.unixToDate(
this.form.rangeTime[1] / 1000
);
delete params.rangeTime
let checkResult = true
//
if (this.form.promotionGoodsList.length > 0) {
this.form.promotionGoodsList.forEach((res) => {
//
if (res.stock <= 0 || res.stock > res.quantity) {
checkResult = false
this.$Message.error("活动库存不能为0且不能超过商品库存");
return
}
//
if (!regular.money.test(res.purchasePrice)) {
checkResult = false
this.$Message.error("最低购买金额格式不正确");
}
//
if (!regular.money.test(res.settlementPrice)) {
checkResult = false
this.$Message.error("结算价格金额格式不正确");
return
}
//
if (res.settlementPrice < 0 || res.settlementPrice > res.price) {
checkResult = false
this.$Message.error("结算价格金额不能为0且不能超过商品价格");
return
}
//
if (!regular.money.test(res.highestPrice)) {
checkResult = false
this.$Message.error("最高可砍金额格式错误");
return
}
if (res.highestPrice <= 0 || res.highestPrice > res.price) {
checkResult = false
this.$Message.error("最高可砍金额不能为0且不能超过商品价格");
return
}
//
if (!regular.money.test(res.lowestPrice)) {
checkResult = false
this.$Message.error("最低可砍金额格式错误");
return
}
if (res.lowestPrice <= 0 || res.lowestPrice > res.price) {
checkResult = false
this.$Message.error("最低可砍金额不能为0");
return
}
//
if (res.lowestPrice > res.highestPrice) {
checkResult = false
this.$Message.error("最低砍价金额不能大于最高砍价金额");
return
}
});
}
if (!checkResult) {
return;
}
this.submitLoading = true;
if (this.modalType === 0) {
// id
delete params.id;
saveKanjiaActivityGoods(params).then((res) => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("砍价活动添加成功");
this.closeCurrentPage();
}
});
} else {
//
delete params.consumeLimit;
delete params.updateTime;
editPlatformCoupon(params).then((res) => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("优惠券修改成功");
this.closeCurrentPage();
}
});
}
}
});
},
//
closeCurrentPage() {
this.$store.commit("removeTag", "add-platform-coupon");
localStorage.pageOpenedList = JSON.stringify(
this.$store.state.app.pageOpenedList
);
this.$router.go(-1);
},
openSkuList() {
//
this.$refs.skuSelect.open("goods");
let data = JSON.parse(JSON.stringify(this.form.promotionGoodsList));
data.forEach((e) => {
e.id = e.skuId;
});
this.$refs.skuSelect.goodsData = data;
},
changeSelect(e) {
//
this.selectedGoods = e;
},
delSelectGoods() {
//
if (this.selectedGoods.length <= 0) {
this.$Message.warning("您还未选择要删除的数据");
return;
}
this.$Modal.confirm({
title: "确认删除",
content: "您确认要删除所选商品吗?",
onOk: () => {
let ids = [];
this.selectedGoods.forEach(function (e) {
ids.push(e.id);
});
this.form.promotionGoodsList = this.form.promotionGoodsList.filter(
(item) => {
return !ids.includes(item.id);
}
);
},
});
},
delGoods(index) {
//
this.form.promotionGoodsList.splice(index, 1);
},
selectedGoodsData(item) {
//
let list = [];
item.forEach((e) => {
list.push({
settlementPrice: e.settlementPrice || 0,
purchasePrice: e.purchasePrice || 0,
lowestPrice: e.lowestPrice || 0,
highestPrice: e.highestPrice || 0,
stock: e.stock || 0,
goodsName: e.goodsName,
price: e.price,
originalPrice: e.price,
quantity: e.quantity,
storeId: e.storeId,
storeName: e.storeName,
skuId: e.id,
});
});
console.warn(list)
this.form.promotionGoodsList = list;
},
},
};
</script>
<style lang="scss" scpoed>
h4 {
margin-bottom: 10px;
padding: 0 10px;
border: 1px solid #ddd;
background-color: #f8f8f8;
font-weight: bold;
color: #333;
font-size: 14px;
line-height: 40px;
text-align: left;
}
.describe {
font-size: 12px;
margin-left: 10px;
color: #999;
}
.effectiveDays {
font-size: 12px;
color: #999;
> * {
margin: 0 4px;
}
}
.tips {
font-size: 12px;
color: #999;
}
</style>

View File

@ -0,0 +1,449 @@
<template>
<div class="search">
<Card>
<Row>
<Form ref="searchForm" :model="searchForm" inline :label-width="70" class="search-form">
<Form-item label="活动名称" prop="promotionName">
<Input type="text" v-model="searchForm.promotionName" 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">
<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">
<template slot-scope="{ row,index }" slot="action">
<Button v-if="!checked && row.promotionStatus === 'NEW' || row.promotionStatus === 'CLOSE'" type="primary" size="small" style="margin-right: 10px" @click="edit(row)">
</Button>
<Button v-if="!checked && row.promotionStatus === 'START' || row.promotionStatus === 'NEW'" type="error" size="small" style="margin-right: 10px" @click="remove(row)">
</Button>
</template>
</Table>
<Row type="flex" justify="end" class="page">
<Page :current="searchForm.pageNumber" :total="total" :page-size="searchForm.pageSize" @on-change="changePage" @on-page-size-change="changePageSize" :page-size-opts="[10, 20, 50]" size="small"
show-total show-elevator show-sizer></Page>
</Row>
</Card>
</div>
</template>
<script>
import {
getKanjiaList,
updatePlatformCouponStatus,
} from "@/api/promotion";
export default {
name: "coupon",
components: {},
data() {
return {
loading: true, //
modalType: 0, //
modalVisible: false, //
modalTitle: "", //
searchForm: {
//
pageNumber: 1, //
pageSize: 10, //
sort: "startTime", //
order: "desc", //
promotionName: ""
},
form: {
//
promotionName: "",
},
//
formValidate: {
promotionName: [
{ required: true, message: "不能为空", trigger: "blur" },
],
},
submitLoading: false, //
selectList: [], //
selectCount: 0, //
columns: [
{
title: "活动名称",
key: "promotionName",
minWidth: 100,
tooltip: true
},
{
title: "每人最低砍价",
key: "lowestPrice",
minWidth: 100,
render: (h, params) => {
return h(
"div",
this.$options.filters.unitPrice(params.row.lowestPrice, "¥")
);
},
},
{
title: "每人最高砍价",
key: "highestPrice",
minWidth: 100,
tooltip: true,
render: (h, params) => {
return h(
"div",
this.$options.filters.unitPrice(params.row.highestPrice, "¥")
);
},
},
{
title: "活动时间",
width: 300,
render: (h, params) => {
if (params.row.getType === "ACTIVITY") {
return h("div", "长期有效");
} else {
return h("div", {
domProps: {
innerHTML:
params.row.startTime + "" + params.row.endTime,
},
});
}
},
},
{
title: "状态",
key: "promotionStatus",
render: (h, params) => {
let text = "未知",
color = "red";
if (params.row.promotionStatus == "NEW") {
text = "未开始";
color = "geekblue";
} else if (params.row.promotionStatus == "START") {
text = "已开始";
color = "green";
} else if (params.row.promotionStatus == "END") {
text = "已结束";
color = "red";
} else if (params.row.promotionStatus == "CLOSE") {
text = "已关闭";
color = "red";
}
return h("div", [
h(
"Tag",
{
props: {
color: color,
},
},
text
),
]);
},
width: 130,
},
{
title: "操作",
slot: "action",
align: "center",
fixed: "right",
width: 180,
},
],
data: [], //
total: 0, //
selectCoupon: [], //
};
},
props: {
//
checked: {
type: Boolean,
default: false,
},
//
getType: {
type: String,
default: "",
},
//
selectedList: {
type: Array,
default: [],
},
},
watch: {
$route(to, from) {
if (to.fullPath == "/promotion/manager-coupon") {
this.init();
}
},
},
methods: {
//
selectedList: {
handler(val) {
//
if (val.length != 0) {
this.selectCoupon = val;
}
},
deep: true,
immediate: true,
},
check() {
// this.selectCoupon.push(this.selectList)
this.$emit("selected", this.selectCoupon);
},
init() {
this.getDataList();
},
//
add() {
this.$router.push({ name: "add-kanJia-activity" });
},
/** 跳转至领取详情页面 */
receiveInfo(v) {
this.$router.push({ name: "member-receive-coupon", query: { id: v.id } });
},
info(v) {
this.$router.push({ name: "platform-coupon-info", query: { id: v.id } });
},
changePage(v) {
this.searchForm.pageNumber = v;
this.getDataList();
// this.clearSelectAll();
},
changePageSize(v) {
this.searchForm.pageSize = v;
this.getDataList();
},
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() {
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;
},
getDataList() {
this.loading = true;
if (this.selectDate && this.selectDate[0] && this.selectDate[1]) {
this.searchForm.startTime = this.selectDate[0].getTime();
this.searchForm.endTime = this.selectDate[1].getTime();
} else {
this.searchForm.startTime = null;
this.searchForm.endTime = null;
}
//
getKanjiaList(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;
}
});
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) {
this.$router.push({ name: "edit-kanJia-activity", query: { id: v.id } });
},
remove(v) {
this.$Modal.confirm({
title: "确认下架",
//
content: "确认要下架此优惠券么?",
loading: true,
onOk: () => {
//
updatePlatformCouponStatus({
couponIds: v.id,
promotionStatus: "CLOSE",
})
.then((res) => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("优惠券已作废");
this.getDataList();
}
})
.catch(() => {
this.$Modal;
});
},
});
},
delAll() {
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: "CLOSE",
};
//
updatePlatformCouponStatus(params).then((res) => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("下架成功");
this.clearSelectAll();
this.getDataList();
}
});
},
});
},
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.init();
},
};
</script>
<style lang="scss">
@import "@/styles/table-common.scss";
</style>