mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2025-12-21 10:25:53 +08:00
commit message
This commit is contained in:
410
seller/src/views/promotion/coupon/coupon.vue
Normal file
410
seller/src/views/promotion/coupon/coupon.vue
Normal file
@@ -0,0 +1,410 @@
|
||||
<template>
|
||||
<div class="search">
|
||||
<Card>
|
||||
<Row>
|
||||
<Form
|
||||
ref="searchForm"
|
||||
:model="searchForm"
|
||||
inline
|
||||
:label-width="100"
|
||||
class="search-form"
|
||||
>
|
||||
<Form-item label="优惠券名称">
|
||||
<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"
|
||||
class="search-btn"
|
||||
icon="ios-search"
|
||||
>搜索</Button
|
||||
>
|
||||
</Form>
|
||||
</Row>
|
||||
<Row class="operator padding-row">
|
||||
<Button @click="add" type="primary">添加</Button>
|
||||
<Button @click="delAll">批量下架</Button>
|
||||
<!-- <Button @click="upAll">批量上架</Button> -->
|
||||
</Row>
|
||||
<Row class="padding-row">
|
||||
<Table
|
||||
:loading="loading"
|
||||
border
|
||||
:columns="columns"
|
||||
:data="data"
|
||||
ref="table"
|
||||
sortable="custom"
|
||||
@on-sort-change="changeSort"
|
||||
@on-selection-change="changeSelect"
|
||||
>
|
||||
<template slot-scope="{ row }" slot="action">
|
||||
<Button
|
||||
v-if="row.promotionStatus === 'NEW' || row.promotionStatus === 'CLOSE'"
|
||||
type="primary"
|
||||
size="small"
|
||||
style="margin-right: 10px"
|
||||
@click="edit(row)"
|
||||
>编辑</Button
|
||||
>
|
||||
<Button
|
||||
v-if="row.promotionStatus !== 'CLOSE'"
|
||||
type="error"
|
||||
size="small"
|
||||
@click="remove(row)"
|
||||
>下架</Button
|
||||
>
|
||||
</template>
|
||||
</Table>
|
||||
</Row>
|
||||
<Row type="flex" justify="end" class="page">
|
||||
<Page
|
||||
:current="searchForm.pageNumber + 1"
|
||||
: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 {
|
||||
getShopCouponList,
|
||||
deleteShopCoupon,
|
||||
updateCouponStatus,
|
||||
} from "@/api/promotion";
|
||||
|
||||
export default {
|
||||
name: "coupon",
|
||||
data() {
|
||||
return {
|
||||
loading: true, // 表单加载状态
|
||||
searchForm: {
|
||||
// 搜索框初始化对象
|
||||
pageNumber: 0, // 当前页数
|
||||
pageSize: 10, // 页面大小
|
||||
sort: "startTime", // 默认排序字段
|
||||
order: "desc", // 默认排序方式
|
||||
},
|
||||
form: {
|
||||
// 添加或编辑表单对象初始化数据
|
||||
promotionName: "",
|
||||
},
|
||||
// 表单验证规则
|
||||
formValidate: {
|
||||
promotionName: [
|
||||
{ required: true, message: "不能为空", trigger: "blur" },
|
||||
],
|
||||
},
|
||||
submitLoading: false, // 添加或编辑提交状态
|
||||
selectList: [], // 多选数据
|
||||
selectCount: 0, // 多选计数
|
||||
columns: [
|
||||
// 表头
|
||||
{
|
||||
type: "selection",
|
||||
width: 60,
|
||||
align: "center",
|
||||
},
|
||||
{
|
||||
title: "活动名称",
|
||||
key: "promotionName",
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
title: "优惠券名称",
|
||||
key: "couponName",
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
title: "优惠券类型",
|
||||
key: "couponType",
|
||||
minWidth: 50,
|
||||
render: (h, params) => {
|
||||
let text = "未知";
|
||||
if (params.row.couponType == "DISCOUNT") {
|
||||
text = "打折";
|
||||
} else if (params.row.couponType == "PRICE") {
|
||||
text = "减免现金";
|
||||
}
|
||||
return h("div", [text]);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "面额",
|
||||
key: "price",
|
||||
minWidth: 40,
|
||||
},
|
||||
{
|
||||
title: "折扣",
|
||||
key: "couponDiscount",
|
||||
minWidth: 40,
|
||||
},
|
||||
{
|
||||
title: "状态",
|
||||
key: "status",
|
||||
minWidth: 30,
|
||||
render: (h, params) => {
|
||||
let text = "未知",
|
||||
color = "default";
|
||||
if (params.row.promotionStatus == "NEW") {
|
||||
text = "未开始";
|
||||
color = "default";
|
||||
} 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
|
||||
),
|
||||
]);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "品类描述",
|
||||
key: "scopeType",
|
||||
minWidth: 120,
|
||||
render: (h, params) => {
|
||||
let text = "未知";
|
||||
if (params.row.scopeType == "ALL") {
|
||||
text = "全品类";
|
||||
} else if (params.row.scopeType == "PORTION_GOODS_CATEGORY") {
|
||||
text = "部分商品分类";
|
||||
} else if (params.row.scopeType == "PORTION_GOODS") {
|
||||
text = "指定商品";
|
||||
} else if (params.row.scopeType == "PORTION_SHOP_CATEGORY") {
|
||||
text = "部分店铺分类";
|
||||
}
|
||||
return h("div", [text]);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "操作",
|
||||
slot: "action",
|
||||
align: "center",
|
||||
width: 200,
|
||||
},
|
||||
],
|
||||
data: [], // 表单数据
|
||||
total: 0, // 表单数据总数
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
this.getDataList();
|
||||
},
|
||||
add() {
|
||||
this.$router.push({ name: "add-coupon" });
|
||||
},
|
||||
/** 跳转至领取详情页面 */
|
||||
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 - 1;
|
||||
this.getDataList();
|
||||
this.clearSelectAll();
|
||||
},
|
||||
changePageSize(v) {
|
||||
this.searchForm.pageSize = v;
|
||||
this.getDataList();
|
||||
},
|
||||
handleSearch() {
|
||||
this.searchForm.pageNumber = 0;
|
||||
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);
|
||||
},
|
||||
changeSelect(e) {
|
||||
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;
|
||||
}
|
||||
// 带多条件搜索参数获取表单数据 请自行修改接口
|
||||
getShopCouponList(this.searchForm).then((res) => {
|
||||
this.loading = false;
|
||||
if (res.success) {
|
||||
this.data = res.result.records;
|
||||
this.total = res.result.total;
|
||||
}
|
||||
});
|
||||
this.total = this.data.length;
|
||||
this.loading = false;
|
||||
},
|
||||
|
||||
edit(v) {
|
||||
this.$router.push({ name: "add-coupon", query: { id: v.id } });
|
||||
},
|
||||
remove(v) {
|
||||
this.$Modal.confirm({
|
||||
title: "确认下架",
|
||||
// 记得确认修改此处
|
||||
content: "确认要下架此优惠券么?",
|
||||
loading: true,
|
||||
onOk: () => {
|
||||
this.loading = false;
|
||||
let params = {
|
||||
couponIds: v.id,
|
||||
promotionStatus: "CLOSE",
|
||||
};
|
||||
// 批量删除
|
||||
updateCouponStatus(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",
|
||||
};
|
||||
// 批量上架
|
||||
updateCouponStatus(params).then((res) => {
|
||||
this.$Modal.remove();
|
||||
if (res.success) {
|
||||
this.$Message.success("上架成功");
|
||||
this.clearSelectAll();
|
||||
this.getDataList();
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
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",
|
||||
};
|
||||
// 批量删除
|
||||
updateCouponStatus(params).then((res) => {
|
||||
this.$Modal.remove();
|
||||
if (res.success) {
|
||||
this.$Message.success("下架成功");
|
||||
this.clearSelectAll();
|
||||
this.getDataList();
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.init();
|
||||
},
|
||||
watch: {
|
||||
$route(to, from) {
|
||||
if (to.fullPath == "/promotion/coupon") {
|
||||
this.init();
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style lang="scss">
|
||||
@import "@/styles/table-common.scss";
|
||||
.search-form {
|
||||
width: 100% !important;
|
||||
}
|
||||
</style>
|
||||
655
seller/src/views/promotion/coupon/couponPublish.vue
Normal file
655
seller/src/views/promotion/coupon/couponPublish.vue
Normal file
@@ -0,0 +1,655 @@
|
||||
<template>
|
||||
<div class="wrapper">
|
||||
<Card>
|
||||
<Form ref="form" :model="form" :label-width="120" :rules="formRule">
|
||||
<div class="base-info-item">
|
||||
<h4>基本信息</h4>
|
||||
<div class="form-item-view">
|
||||
<FormItem label="活动名称" prop="promotionName">
|
||||
<Input
|
||||
type="text"
|
||||
v-model="form.promotionName"
|
||||
placeholder="活动名称"
|
||||
clearable
|
||||
style="width: 260px"
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem label="优惠券名称" prop="couponName">
|
||||
<Input
|
||||
type="text"
|
||||
v-model="form.couponName"
|
||||
placeholder="优惠券名称"
|
||||
clearable
|
||||
style="width: 260px"
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem label="优惠券类型" prop="couponType">
|
||||
<Select v-model="form.couponType" style="width: 260px">
|
||||
<Option value="DISCOUNT">打折</Option>
|
||||
<Option value="PRICE">减免现金</Option>
|
||||
</Select>
|
||||
</FormItem>
|
||||
<FormItem
|
||||
label="折扣"
|
||||
prop="discount"
|
||||
v-if="form.couponType == 'DISCOUNT'"
|
||||
>
|
||||
<Input
|
||||
type="number"
|
||||
v-model="form.couponDiscount"
|
||||
placeholder="折扣"
|
||||
clearable
|
||||
style="width: 260px"
|
||||
/>
|
||||
<span class="describe">请输入0-10之间数字,可以输入一位小数</span>
|
||||
</FormItem>
|
||||
<FormItem
|
||||
label="面额"
|
||||
prop="price"
|
||||
v-if="form.couponType == 'PRICE'"
|
||||
>
|
||||
<Input
|
||||
type="text"
|
||||
v-model="form.price"
|
||||
placeholder="面额"
|
||||
clearable
|
||||
style="width: 260px"
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem label="活动类型" prop="getType">
|
||||
<Select v-model="form.getType" style="width: 260px">
|
||||
<Option value="FREE">免费领取</Option>
|
||||
<Option value="ACTIVITY">活动赠送</Option>
|
||||
</Select>
|
||||
</FormItem>
|
||||
|
||||
<FormItem label="发放数量" prop="publishNum">
|
||||
<Input
|
||||
v-model="form.publishNum"
|
||||
placeholder="发放数量"
|
||||
style="width: 260px"
|
||||
/>
|
||||
</FormItem>
|
||||
</div>
|
||||
<h4>使用限制</h4>
|
||||
<div class="form-item-view">
|
||||
<FormItem label="消费门槛" prop="consumeThreshold">
|
||||
<Input
|
||||
type="text"
|
||||
v-model="form.consumeThreshold"
|
||||
placeholder="消费门槛"
|
||||
clearable
|
||||
style="width: 260px"
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem label="领取限制" prop="couponLimitNum">
|
||||
<Input
|
||||
v-model="form.couponLimitNum"
|
||||
placeholder="领取限制"
|
||||
clearable
|
||||
style="width: 260px"
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem label="有效期" prop="startTime">
|
||||
<DatePicker
|
||||
type="datetime"
|
||||
v-model="form.startTime"
|
||||
format="yyyy-MM-dd HH:mm:ss"
|
||||
placeholder="请选择"
|
||||
:options="options"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
>
|
||||
</DatePicker>
|
||||
-
|
||||
<DatePicker
|
||||
type="datetime"
|
||||
v-model="form.endTime"
|
||||
format="yyyy-MM-dd HH:mm:ss"
|
||||
:options="options"
|
||||
placeholder="请选择"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
>
|
||||
</DatePicker>
|
||||
</FormItem>
|
||||
<FormItem label="使用范围" prop="scopeType">
|
||||
<RadioGroup v-model="form.scopeType">
|
||||
<Radio label="ALL">全品类</Radio>
|
||||
<Radio label="PORTION_GOODS">指定商品</Radio>
|
||||
<Radio label="PORTION_GOODS_CATEGORY">部分商品分类</Radio>
|
||||
</RadioGroup>
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
style="width: 100%"
|
||||
v-if="form.scopeType == 'PORTION_GOODS'"
|
||||
>
|
||||
<div style="display: flex; margin-bottom: 10px">
|
||||
<Button type="primary" @click="$refs.skuSelect.open('goods')"
|
||||
>选择商品</Button
|
||||
>
|
||||
<Button
|
||||
type="error"
|
||||
ghost
|
||||
style="margin-left: 10px"
|
||||
@click="delSelectGoods"
|
||||
>批量删除</Button
|
||||
>
|
||||
</div>
|
||||
<Table
|
||||
border
|
||||
:columns="columns"
|
||||
:data="form.promotionGoodsList"
|
||||
@on-selection-change="changeSelect"
|
||||
>
|
||||
<template slot-scope="{ row }" slot="QRCode">
|
||||
<img
|
||||
:src="row.QRCode || '../../../assets/lili.png'"
|
||||
width="50px"
|
||||
height="50px"
|
||||
alt=""
|
||||
/>
|
||||
</template>
|
||||
</Table>
|
||||
</FormItem>
|
||||
|
||||
<FormItem v-if="form.scopeType == 'PORTION_GOODS_CATEGORY'">
|
||||
<Cascader @on-change="getGoodsCategory" :data="goodsCategoryList" style="width:300px;" v-model="form.scopeIdGoods"></Cascader>
|
||||
|
||||
</FormItem>
|
||||
|
||||
<FormItem label="范围描述" prop="description">
|
||||
<Input
|
||||
v-model="form.description"
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
maxlength="50"
|
||||
show-word-limit
|
||||
clearable
|
||||
style="width: 260px"
|
||||
/>
|
||||
</FormItem>
|
||||
<div>
|
||||
<Button type="text" @click="$router.push({ name: 'coupon' })"
|
||||
>返回</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 { saveShopCoupon, getShopCoupon, editShopCoupon } from "@/api/promotion";
|
||||
import { getGoodsCategoryAll } from "@/api/goods";
|
||||
import { regular } from "@/utils";
|
||||
import skuSelect from "@/views/lili-dialog";
|
||||
export default {
|
||||
name: "addCoupon",
|
||||
components: {
|
||||
skuSelect,
|
||||
},
|
||||
data() {
|
||||
const checkPrice = (rule, value, callback) => {
|
||||
if (!value && value !== 0) {
|
||||
return callback(new Error("面额不能为空"));
|
||||
} else if (!regular.money.test(value)) {
|
||||
callback(new Error("请输入正整数或者两位小数"));
|
||||
} else if (parseFloat(value) > 99999999) {
|
||||
callback(new Error("面额设置超过上限值"));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
const checkWeight = (rule, value, callback) => {
|
||||
if (!value && typeof value !== "number") {
|
||||
callback(new Error("消费门槛不能为空"));
|
||||
} else if (!regular.money.test(value)) {
|
||||
callback(new Error("请输入正整数或者两位小数"));
|
||||
} else if (parseFloat(value) > 99999999) {
|
||||
callback(new Error("消费门槛设置超过上限值"));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
const isLtEndDate = (rule, value, callback) => {
|
||||
if (new Date(value).getTime() > new Date(this.form.endTime).getTime()) {
|
||||
callback(new Error());
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
const isGtStartDate = (rule, value, callback) => {
|
||||
if (new Date(value).getTime() < new Date(this.form.startTime).getTime()) {
|
||||
callback(new Error());
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
return {
|
||||
modalType: 0, // 判断是新增还是编辑优惠券 0 新增 1 编辑
|
||||
categoryId: 0, // 分类id
|
||||
form: {
|
||||
/** 店铺承担比例 */
|
||||
sellerCommission: 0,
|
||||
/** 发行数量 */
|
||||
publishNum: 1,
|
||||
/** 运费承担者 */
|
||||
scopeType: "ALL",
|
||||
/** 限领数量 */
|
||||
couponLimitNum: 1,
|
||||
/** 活动类型 */
|
||||
couponType: "PRICE",
|
||||
/** 优惠券名称 */
|
||||
couponName: "",
|
||||
getType: "FREE",
|
||||
promotionGoodsList: [],
|
||||
scopeIdGoods: [],
|
||||
},
|
||||
id: this.$route.query.id,
|
||||
submitLoading: false, // 添加或编辑提交状态
|
||||
selectedGoods: [], // 已选商品列表,便于删除
|
||||
goodsCategoryList: [], // 商品分类列表
|
||||
shopCategoryList: [], // 店铺分类列表
|
||||
cascaderProps: {
|
||||
multiple: true,
|
||||
label: "name",
|
||||
value: "id",
|
||||
}, // 级联选择器配置项
|
||||
formRule: {
|
||||
promotionName: [{ required: true, message: "活动名称不能为空" }],
|
||||
couponName: [{ required: true, message: "优惠券名称不能为空" }],
|
||||
couponLimitNum: [{ required: true, message: "领取限制不能为空" }],
|
||||
price: [
|
||||
{ required: true, message: "请输入面额" },
|
||||
{ validator: checkPrice },
|
||||
],
|
||||
consumeThreshold: [
|
||||
{ required: true, message: "请输入消费门槛" },
|
||||
{ validator: checkWeight },
|
||||
],
|
||||
startTime: [
|
||||
{
|
||||
required: true,
|
||||
type: "date",
|
||||
message: "请选择开始时间",
|
||||
},
|
||||
{
|
||||
trigger: "change",
|
||||
message: "开始时间要小于结束时间",
|
||||
validator: isLtEndDate,
|
||||
},
|
||||
],
|
||||
endTime: [
|
||||
{
|
||||
required: true,
|
||||
type: "date",
|
||||
message: "请选择结束时间",
|
||||
},
|
||||
{
|
||||
trigger: "change",
|
||||
message: "结束时间要大于开始时间",
|
||||
validator: isGtStartDate,
|
||||
},
|
||||
],
|
||||
couponDiscount: [
|
||||
{ required: true, message: "请输入折扣" },
|
||||
{
|
||||
pattern: regular.discount,
|
||||
message: "请输入0-10的数字,可有一位小数",
|
||||
},
|
||||
],
|
||||
sellerCommission: [
|
||||
{ required: true, message: "请输入店铺承担比例" },
|
||||
{ pattern: regular.rate, message: "请输入0-100的正整数" },
|
||||
],
|
||||
publishNum: [
|
||||
{ required: true, message: "请输入发放数量" },
|
||||
{ pattern: regular.integer, message: "请输入正整数" },
|
||||
],
|
||||
couponLimitNum: [
|
||||
{ required: true, message: "请输入领取限制" },
|
||||
{ pattern: regular.integer, message: "请输入正整数" },
|
||||
],
|
||||
description: [{ required: true, message: "请输入范围描述" }],
|
||||
},
|
||||
columns: [
|
||||
{
|
||||
type: "selection",
|
||||
width: 60,
|
||||
align: "center",
|
||||
},
|
||||
{
|
||||
title: "商品名称",
|
||||
key: "goodsName",
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
title: "商品价格",
|
||||
key: "price",
|
||||
minWidth: 40,
|
||||
render: (h, params) => {
|
||||
return h(
|
||||
"div",
|
||||
this.$options.filters.unitPrice(params.row.price, "¥")
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "库存",
|
||||
key: "quantity",
|
||||
minWidth: 40,
|
||||
},
|
||||
|
||||
{
|
||||
title: "操作",
|
||||
key: "action",
|
||||
minWidth: 50,
|
||||
align: "center",
|
||||
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() {
|
||||
await this.getCagetoryList();
|
||||
// 如果id不为空则查询信息
|
||||
if (this.id) {
|
||||
this.getCoupon();
|
||||
this.modalType = 1;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getCoupon() {
|
||||
getShopCoupon(this.id).then((res) => {
|
||||
let data = res.result;
|
||||
if (!data.promotionGoodsList) data.promotionGoodsList = [];
|
||||
if (data.scopeType == "PORTION_GOODS_CATEGORY") {
|
||||
let prevCascader = data.scopeId.split(",");
|
||||
function next(params, prev) {
|
||||
for (let i = 0; i < params.length; i++) {
|
||||
const item = params[i];
|
||||
if (item.children) {
|
||||
next(item.children, [...prev, item]);
|
||||
} else {
|
||||
if (prevCascader.includes(item.id)) {
|
||||
prevCascader = prevCascader.map((key) => {
|
||||
if (key === item.id) {
|
||||
let result = prev.map((item) => item.id);
|
||||
return [...result, item.id];
|
||||
} else {
|
||||
return key;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
i === params.length - 1 && (prev = []);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
next(this.goodsCategoryList, []);
|
||||
data.scopeIdGoods = prevCascader;
|
||||
}
|
||||
this.form = data;
|
||||
});
|
||||
},
|
||||
/** 保存平台优惠券 */
|
||||
handleSubmit() {
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (valid) {
|
||||
const params = JSON.parse(JSON.stringify(this.form));
|
||||
const strat = this.$options.filters.unixToDate(
|
||||
this.form.startTime / 1000
|
||||
);
|
||||
const end = this.$options.filters.unixToDate(
|
||||
this.form.endTime / 1000
|
||||
);
|
||||
let scopeId = [];
|
||||
params.startTime = strat;
|
||||
params.endTime = end;
|
||||
|
||||
if (
|
||||
params.scopeType == "PORTION_GOODS" &&
|
||||
(!params.promotionGoodsList ||
|
||||
params.promotionGoodsList.length == 0)
|
||||
) {
|
||||
this.$Modal.warning({ title: "提示", content: "请选择指定商品" });
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
params.scopeType == "PORTION_GOODS_CATEGORY" &&
|
||||
(!params.scopeIdGoods || params.scopeIdGoods.length == 0)
|
||||
) {
|
||||
this.$Modal.warning({ title: "提示", content: "请选择商品分类" });
|
||||
return;
|
||||
}
|
||||
|
||||
if (params.scopeType == "PORTION_GOODS") {
|
||||
//指定商品
|
||||
params.promotionGoodsList.forEach((item) => {
|
||||
scopeId.push(item.skuId);
|
||||
});
|
||||
params.scopeId = scopeId.toString();
|
||||
} else if (params.scopeType == "ALL") {
|
||||
delete params.promotionGoodsList;
|
||||
} else if (params.scopeType == "PORTION_GOODS_CATEGORY") {
|
||||
//部分商品分类
|
||||
scopeId = this.filterCategoryId(params.scopeIdGoods, []);
|
||||
params.scopeId = scopeId.toString();
|
||||
delete params.promotionGoodsList;
|
||||
}
|
||||
delete params.scopeIdGoods;
|
||||
|
||||
this.submitLoading = true;
|
||||
if (this.modalType === 0) {
|
||||
// 添加 避免编辑后传入id等数据 记得删除
|
||||
delete params.id;
|
||||
saveShopCoupon(params).then((res) => {
|
||||
this.submitLoading = false;
|
||||
if (res.success) {
|
||||
this.$Message.success("优惠券发送成功");
|
||||
this.closeCurrentPage();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 编辑
|
||||
delete params.consumeLimit;
|
||||
delete params.couponDiscount;
|
||||
delete params.updateTime;
|
||||
|
||||
editShopCoupon(params).then((res) => {
|
||||
this.submitLoading = false;
|
||||
if (res.success) {
|
||||
this.$Message.success("优惠券修改成功");
|
||||
this.closeCurrentPage();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
// 关闭当前页面
|
||||
closeCurrentPage() {
|
||||
this.$store.commit("removeTag", "add-coupon");
|
||||
localStorage.storeOpenedList = JSON.stringify(
|
||||
this.$store.state.app.storeOpenedList
|
||||
);
|
||||
this.$router.push({
|
||||
path: "promotion/coupon",
|
||||
});
|
||||
},
|
||||
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 ids = [];
|
||||
let list = [];
|
||||
this.form.promotionGoodsList.forEach((e) => {
|
||||
ids.push(e.id);
|
||||
});
|
||||
item.forEach((e) => {
|
||||
if (!ids.includes(e.id)) {
|
||||
list.push({
|
||||
goodsName: e.goodsName,
|
||||
price: e.price,
|
||||
originalPrice: e.price,
|
||||
quantity: e.quantity,
|
||||
storeId: e.storeId,
|
||||
sellerName: e.sellerName,
|
||||
skuId: e.id,
|
||||
});
|
||||
}
|
||||
});
|
||||
this.form.promotionGoodsList.push(...list);
|
||||
},
|
||||
getGoodsCategory(e) {
|
||||
// 获取级联选择器商品分类id
|
||||
},
|
||||
|
||||
async getCagetoryList() {
|
||||
// 获取全部商品分类
|
||||
let data = await getGoodsCategoryAll();
|
||||
this.goodsCategoryList = this.filterCategory(data.result);
|
||||
// 过滤出可显示的值
|
||||
|
||||
this.goodsCategoryList = this.goodsCategoryList.map((item) => {
|
||||
if (item.children) {
|
||||
item.children = item.children.map((child) => {
|
||||
if (child.children) {
|
||||
child.children = child.children.map((son) => {
|
||||
return {
|
||||
value: son.id,
|
||||
label: son.name,
|
||||
};
|
||||
});
|
||||
return {
|
||||
value: child.id,
|
||||
label: child.name,
|
||||
children: child.children,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
value: child.id,
|
||||
label: child.name,
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
return { value: item.id, label: item.name, children: item.children };
|
||||
});
|
||||
},
|
||||
filterCategory(list) {
|
||||
// 递归删除空children
|
||||
list.forEach((item) => {
|
||||
if (item.children.length == 0) {
|
||||
delete item.children;
|
||||
} else {
|
||||
this.filterCategory(item.children);
|
||||
}
|
||||
});
|
||||
return list;
|
||||
},
|
||||
filterCategoryId(list, idArr) {
|
||||
// 递归获取分类id
|
||||
list.forEach((e) => {
|
||||
if (e instanceof Array) {
|
||||
this.filterCategoryId(e, idArr);
|
||||
} else {
|
||||
if (!idArr.includes(e)) idArr.push(e);
|
||||
}
|
||||
});
|
||||
return idArr;
|
||||
},
|
||||
},
|
||||
};
|
||||
</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;
|
||||
}
|
||||
.ivu-form-item{
|
||||
margin-bottom: 24px !important;
|
||||
}
|
||||
.wrapper{
|
||||
min-height: 1000px;
|
||||
}
|
||||
</style>
|
||||
|
||||
267
seller/src/views/promotion/fullCut/full-cut.vue
Normal file
267
seller/src/views/promotion/fullCut/full-cut.vue
Normal file
@@ -0,0 +1,267 @@
|
||||
<template>
|
||||
<div class="full-cut">
|
||||
<Card>
|
||||
<Row>
|
||||
<Form
|
||||
ref="searchForm"
|
||||
:model="searchForm"
|
||||
inline
|
||||
:label-width="70"
|
||||
class="search-form"
|
||||
>
|
||||
<Form-item label="活动名称">
|
||||
<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" class="search-btn" icon="ios-search">搜索</Button>
|
||||
</Form>
|
||||
</Row>
|
||||
<Row class="operation">
|
||||
<Button type="primary" @click="newAct">新增</Button>
|
||||
</Row>
|
||||
<Row>
|
||||
<Table
|
||||
:loading="loading"
|
||||
border
|
||||
:columns="columns"
|
||||
:data="data"
|
||||
ref="table"
|
||||
sortable="custom"
|
||||
>
|
||||
<template slot-scope="{ row }" slot="applyEndTime">
|
||||
{{ unixDate(row.applyEndTime) }}
|
||||
</template>
|
||||
<template slot-scope="{ row }" slot="promotionType">
|
||||
{{ row.isFullMinus ? "满减" : "满折" }}
|
||||
</template>
|
||||
<template slot-scope="{ row }" slot="hours">
|
||||
<Tag v-for="item in unixHours(row.hours)" :key="item">{{
|
||||
item
|
||||
}}</Tag>
|
||||
</template>
|
||||
<template slot-scope="{ row }" slot="action">
|
||||
<div>
|
||||
<Button
|
||||
type="primary"
|
||||
v-if="row.promotionStatus == 'NEW'"
|
||||
size="small"
|
||||
@click="edit(row)"
|
||||
>编辑</Button
|
||||
>
|
||||
<Button type="success" v-else size="small" @click="edit(row)"
|
||||
>查看</Button
|
||||
>
|
||||
<Button
|
||||
type="error"
|
||||
:disabled="row.promotionStatus == 'START'"
|
||||
ghost
|
||||
size="small"
|
||||
@click="del(row)"
|
||||
>删除</Button
|
||||
>
|
||||
</div>
|
||||
</template>
|
||||
</Table>
|
||||
</Row>
|
||||
<Row type="flex" justify="end" class="page operation">
|
||||
<Page
|
||||
:current="searchForm.pageNumber + 1"
|
||||
: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 { getFullDiscountList, delFullDiscount } from "@/api/promotion.js";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
loading: false, // 表单加载状态
|
||||
searchForm: { // 列表请求参数
|
||||
pageNumber: 0,
|
||||
pageSize: 10,
|
||||
sort: "startTime",
|
||||
order: "desc",
|
||||
},
|
||||
columns: [
|
||||
{
|
||||
title: "活动名称",
|
||||
key: "promotionName",
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
title: "开始时间",
|
||||
key: "startTime",
|
||||
minWidth: 60,
|
||||
},
|
||||
{
|
||||
title: "结束时间",
|
||||
key: "endTime",
|
||||
minWidth: 60,
|
||||
},
|
||||
{
|
||||
title: "活动类型",
|
||||
slot: "promotionType",
|
||||
minWidth: 60,
|
||||
},
|
||||
{
|
||||
title: "活动状态",
|
||||
key: "promotionStatus",
|
||||
minWidth: 60,
|
||||
render: (h, params) => {
|
||||
let text = "未知",
|
||||
color = "default";
|
||||
if (params.row.promotionStatus == "NEW") {
|
||||
text = "未开始";
|
||||
color = "default";
|
||||
} else if (params.row.promotionStatus == "START") {
|
||||
text = "已开始";
|
||||
color = "green";
|
||||
} else if (params.row.promotionStatus == "END") {
|
||||
text = "已结束";
|
||||
color = "blue";
|
||||
} else if (params.row.promotionStatus == "CLOSE") {
|
||||
text = "已关闭";
|
||||
color = "red";
|
||||
}
|
||||
return h("div", [
|
||||
h(
|
||||
"Tag",
|
||||
{
|
||||
props: {
|
||||
color: color,
|
||||
},
|
||||
},
|
||||
text
|
||||
),
|
||||
]);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "操作",
|
||||
slot: "action",
|
||||
align: "center",
|
||||
width: 200,
|
||||
},
|
||||
],
|
||||
data: [], // 表格数据
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
newAct() {
|
||||
// 新增活动
|
||||
this.$router.push({ name: "full-cut-detail" });
|
||||
},
|
||||
init() {
|
||||
this.getDataList();
|
||||
},
|
||||
changePage(v) {
|
||||
// 改变页数
|
||||
this.searchForm.pageNumber = v - 1;
|
||||
this.getDataList();
|
||||
},
|
||||
changePageSize(v) {
|
||||
// 改变页码
|
||||
this.searchForm.pageSize = v;
|
||||
this.getDataList();
|
||||
},
|
||||
handleSearch() {
|
||||
// 搜索
|
||||
this.searchForm.pageNumber = 0;
|
||||
this.searchForm.pageSize = 10;
|
||||
this.getDataList();
|
||||
},
|
||||
|
||||
edit(row) {
|
||||
// 编辑
|
||||
this.$router.push({ name: "full-cut-detail", query: { id: row.id } });
|
||||
},
|
||||
del(row) {
|
||||
this.$Modal.confirm({
|
||||
title: "提示",
|
||||
// 记得确认修改此处
|
||||
content: "确认删除此活动吗?",
|
||||
loading: true,
|
||||
onOk: () => {
|
||||
// 删除
|
||||
delFullDiscount(row.id).then((res) => {
|
||||
this.$Modal.remove();
|
||||
if (res.success) {
|
||||
this.$Message.success("删除成功");
|
||||
this.getDataList();
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
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;
|
||||
}
|
||||
getFullDiscountList(this.searchForm).then((res) => {
|
||||
this.loading = false;
|
||||
if (res.success) {
|
||||
this.data = res.result.records;
|
||||
this.total = res.result.total;
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.init();
|
||||
},
|
||||
watch: {
|
||||
$route(to, from) {
|
||||
if (to.fullPath == "/promotion/full-cut") {
|
||||
this.init();
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.operation {
|
||||
margin: 10px 0;
|
||||
}
|
||||
</style>
|
||||
576
seller/src/views/promotion/fullCut/newFullCut.vue
Normal file
576
seller/src/views/promotion/fullCut/newFullCut.vue
Normal file
@@ -0,0 +1,576 @@
|
||||
<template>
|
||||
<div>
|
||||
<Card>
|
||||
<Form ref="form" :model="form" :label-width="120" :rules="formRule">
|
||||
<div class="base-info-item">
|
||||
<h4>基本信息</h4>
|
||||
<div class="form-item-view">
|
||||
<FormItem label="活动名称" prop="promotionName">
|
||||
<Input
|
||||
type="text"
|
||||
v-model="form.promotionName"
|
||||
:disabled="form.promotionStatus != 'NEW'"
|
||||
placeholder="活动名称"
|
||||
clearable
|
||||
style="width: 260px"
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem label="活动时间" prop="rangeTime">
|
||||
<DatePicker
|
||||
type="datetimerange"
|
||||
v-model="form.rangeTime"
|
||||
:disabled="form.promotionStatus != 'NEW'"
|
||||
format="yyyy-MM-dd HH:mm:ss"
|
||||
placeholder="请选择"
|
||||
:options="options"
|
||||
style="width: 320px"
|
||||
>
|
||||
</DatePicker>
|
||||
</FormItem>
|
||||
<FormItem label="活动描述" prop="description">
|
||||
<Input
|
||||
v-model="form.description"
|
||||
:disabled="form.promotionStatus != 'NEW'"
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
clearable
|
||||
style="width: 260px"
|
||||
/>
|
||||
</FormItem>
|
||||
</div>
|
||||
|
||||
<h4>优惠设置</h4>
|
||||
<div class="form-item-view">
|
||||
<FormItem label="优惠门槛" prop="fullMoney">
|
||||
<Input
|
||||
type="text"
|
||||
v-model="form.fullMoney"
|
||||
:disabled="form.promotionStatus != 'NEW'"
|
||||
placeholder="优惠门槛"
|
||||
clearable
|
||||
style="width: 260px"
|
||||
/>
|
||||
<span class="describe">消费达到当前金额可以参与优惠</span>
|
||||
</FormItem>
|
||||
<FormItem label="优惠方式">
|
||||
<RadioGroup v-model="form.discountType">
|
||||
<Radio
|
||||
:disabled="form.promotionStatus != 'NEW'"
|
||||
label="isFullMinus"
|
||||
>减现金</Radio
|
||||
>
|
||||
<Radio
|
||||
:disabled="form.promotionStatus != 'NEW'"
|
||||
label="isFullRate"
|
||||
>打折</Radio
|
||||
>
|
||||
</RadioGroup>
|
||||
</FormItem>
|
||||
<FormItem
|
||||
v-if="form.discountType == 'isFullMinus'"
|
||||
label="优惠金额"
|
||||
prop="fullMinus"
|
||||
>
|
||||
<Input
|
||||
:disabled="form.promotionStatus != 'NEW'"
|
||||
type="text"
|
||||
v-model="form.fullMinus"
|
||||
placeholder="优惠金额"
|
||||
clearable
|
||||
style="width: 260px"
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem
|
||||
v-if="form.discountType == 'isFullRate'"
|
||||
label="优惠折扣"
|
||||
prop="fullRate"
|
||||
>
|
||||
<Input
|
||||
:disabled="form.promotionStatus != 'NEW'"
|
||||
type="text"
|
||||
v-model="form.fullRate"
|
||||
placeholder="优惠折扣"
|
||||
clearable
|
||||
style="width: 260px"
|
||||
/>
|
||||
<span class="describe">优惠折扣为0-10之间数字,可有一位小数</span>
|
||||
</FormItem>
|
||||
<FormItem label="额外赠送">
|
||||
<Checkbox
|
||||
:disabled="form.promotionStatus != 'NEW'"
|
||||
v-model="form.isFreeFreight"
|
||||
>免邮费</Checkbox
|
||||
>
|
||||
<Checkbox
|
||||
:disabled="form.promotionStatus != 'NEW'"
|
||||
v-model="form.isCoupon"
|
||||
>送优惠券</Checkbox
|
||||
>
|
||||
<Checkbox
|
||||
:disabled="form.promotionStatus != 'NEW'"
|
||||
v-model="form.isGift"
|
||||
>送赠品</Checkbox
|
||||
>
|
||||
<Checkbox
|
||||
:disabled="form.promotionStatus != 'NEW'"
|
||||
v-model="form.isPoint"
|
||||
>送积分</Checkbox
|
||||
>
|
||||
</FormItem>
|
||||
<FormItem v-if="form.isCoupon" label="赠送优惠券" prop="couponId">
|
||||
<Select
|
||||
v-model="form.couponId"
|
||||
:disabled="form.promotionStatus != 'NEW'"
|
||||
filterable
|
||||
:remote-method="getCouponList"
|
||||
placeholder="输入优惠券名称搜索"
|
||||
:loading="couponLoading"
|
||||
style="width: 260px"
|
||||
>
|
||||
<Option
|
||||
v-for="item in couponList"
|
||||
:value="item.id"
|
||||
:key="item.id"
|
||||
>{{ item.couponName }}</Option
|
||||
>
|
||||
</Select>
|
||||
</FormItem>
|
||||
<FormItem v-if="form.isGift" label="赠品" prop="giftId">
|
||||
<Select
|
||||
:disabled="form.promotionStatus != 'NEW'"
|
||||
v-model="form.giftId"
|
||||
filterable
|
||||
:remote-method="getGiftList"
|
||||
placeholder="输入赠品名称搜索"
|
||||
:loading="giftLoading"
|
||||
style="width: 260px"
|
||||
>
|
||||
<Option
|
||||
v-for="item in giftList"
|
||||
:value="item.id"
|
||||
:key="item.id"
|
||||
>{{ item.goodsName }}</Option
|
||||
>
|
||||
</Select>
|
||||
</FormItem>
|
||||
<FormItem v-if="form.isPoint" label="赠积分" prop="point">
|
||||
<Input
|
||||
:disabled="form.promotionStatus != 'NEW'"
|
||||
v-model="form.point"
|
||||
type="number"
|
||||
:min="0"
|
||||
style="width: 260px"
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem label="使用范围" prop="scopeType">
|
||||
<RadioGroup v-model="form.scopeType">
|
||||
<Radio :disabled="form.promotionStatus != 'NEW'" label="ALL"
|
||||
>全品类</Radio
|
||||
>
|
||||
<Radio
|
||||
:disabled="form.promotionStatus != 'NEW'"
|
||||
label="PORTION_GOODS"
|
||||
>指定商品</Radio
|
||||
>
|
||||
</RadioGroup>
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
style="width: 100%"
|
||||
v-if="form.scopeType == 'PORTION_GOODS'"
|
||||
>
|
||||
<div
|
||||
style="display: flex; margin-bottom: 10px"
|
||||
v-if="form.promotionStatus == 'NEW'"
|
||||
>
|
||||
<Button type="primary" @click="$refs.skuSelect.open('goods')"
|
||||
>选择商品</Button
|
||||
>
|
||||
<Button
|
||||
type="error"
|
||||
ghost
|
||||
style="margin-left: 10px"
|
||||
@click="delSelectGoods"
|
||||
>批量删除</Button
|
||||
>
|
||||
</div>
|
||||
<Table
|
||||
border
|
||||
:columns="columns"
|
||||
:data="form.promotionGoodsList"
|
||||
@on-selection-change="changeSelect"
|
||||
>
|
||||
<template slot-scope="{ row }" slot="QRCode">
|
||||
<img
|
||||
:src="row.QRCode || '../../../assets/lili.png'"
|
||||
width="50px"
|
||||
height="50px"
|
||||
alt=""
|
||||
/>
|
||||
</template>
|
||||
<template slot-scope="{ index }" slot="action">
|
||||
<Button
|
||||
type="error"
|
||||
:disabled="form.promotionStatus != 'NEW' && id"
|
||||
size="small"
|
||||
ghost
|
||||
@click="delGoods(index)"
|
||||
>删除</Button
|
||||
>
|
||||
</template>
|
||||
</Table>
|
||||
</FormItem>
|
||||
|
||||
<div>
|
||||
<Button type="text" @click="closeCurrentPage"
|
||||
>返回</Button
|
||||
>
|
||||
<Button
|
||||
type="primary"
|
||||
:disabled="form.promotionStatus != 'NEW' && id"
|
||||
:loading="submitLoading"
|
||||
@click="handleSubmit"
|
||||
>提交</Button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Form>
|
||||
</Card>
|
||||
<sku-select
|
||||
ref="skuSelect"
|
||||
@selectedGoodsData="selectedGoodsData"
|
||||
></sku-select>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
getShopCouponList,
|
||||
getFullDiscountById,
|
||||
newFullDiscount,
|
||||
editFullDiscount,
|
||||
} from "@/api/promotion";
|
||||
import { getGoodsSkuListDataSeller } from "@/api/goods";
|
||||
import { regular } from "@/utils";
|
||||
import skuSelect from "@/views/lili-dialog";
|
||||
export default {
|
||||
name: "addFullCut",
|
||||
components: {
|
||||
skuSelect,
|
||||
},
|
||||
data() {
|
||||
const checkPrice = (rule, value, callback) => {
|
||||
if (!value && value !== 0) {
|
||||
return callback(new Error("面额不能为空"));
|
||||
} else if (!regular.money.test(value)) {
|
||||
callback(new Error("请输入正整数或者两位小数"));
|
||||
} else if (parseFloat(value) > 99999999) {
|
||||
callback(new Error("面额设置超过上限值"));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
const checkWeight = (rule, value, callback) => {
|
||||
if (!value && typeof value !== "number") {
|
||||
callback(new Error("优惠门槛不能为空"));
|
||||
} else if (!regular.money.test(value)) {
|
||||
callback(new Error("请输入正整数或者两位小数"));
|
||||
} else if (parseFloat(value) > 99999999) {
|
||||
callback(new Error("优惠门槛设置超过上限值"));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
return {
|
||||
form: { // 活动表单
|
||||
discountType: "isFullMinus",
|
||||
scopeType: "ALL",
|
||||
promotionGoodsList: [],
|
||||
promotionStatus: "NEW",
|
||||
},
|
||||
id: this.$route.query.id, // 活动id
|
||||
submitLoading: false, // 添加或编辑提交状态
|
||||
selectedGoods: [], // 已选商品列表,便于删除
|
||||
formRule: { // 验证规则
|
||||
promotionName: [{ required: true, message: "活动名称不能为空" }],
|
||||
rangeTime: [{ required: true, message: "请选择活动时间" }],
|
||||
description: [{ required: true, message: "请填写活动描述" }],
|
||||
price: [
|
||||
{ required: true, message: "请输入面额" },
|
||||
{ validator: checkPrice },
|
||||
],
|
||||
consumptionLimit: [{ required: true, validator: checkWeight }],
|
||||
fullMoney: [{ required: true, validator: checkWeight }],
|
||||
fullMinus: [
|
||||
{ required: true, message: "请填写优惠金额" },
|
||||
{ pattern: regular.money, message: "请输入正确金额" },
|
||||
],
|
||||
fullRate: [
|
||||
{ required: true, message: "请填写优惠折扣" },
|
||||
{
|
||||
pattern: regular.discount,
|
||||
message: "请输入0-10的数字,可有一位小数",
|
||||
},
|
||||
],
|
||||
couponId: [{ required: true, message: "请选择优惠券" }],
|
||||
giftId: [{ required: true, message: "请选择赠品" }],
|
||||
point: [{ required: true, message: "请填写积分" }],
|
||||
},
|
||||
couponList: [], // 店铺优惠券列表
|
||||
giftList: [], // 赠品列表
|
||||
giftLoading: false, // 请求赠品状态
|
||||
columns: [ // 表头
|
||||
{
|
||||
type: "selection",
|
||||
width: 60,
|
||||
align: "center",
|
||||
},
|
||||
{
|
||||
title: "商品名称",
|
||||
key: "goodsName",
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
title: "商品价格",
|
||||
key: "price",
|
||||
minWidth: 40,
|
||||
render: (h, params) => {
|
||||
return h(
|
||||
"div",
|
||||
this.$options.filters.unitPrice(params.row.price, "¥")
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "库存",
|
||||
key: "quantity",
|
||||
minWidth: 40,
|
||||
},
|
||||
{
|
||||
title: "商品二维码",
|
||||
slot: "QRCode",
|
||||
},
|
||||
{
|
||||
title: "操作",
|
||||
slot: "action",
|
||||
minWidth: 50,
|
||||
},
|
||||
],
|
||||
options: {
|
||||
disabledDate(date) {
|
||||
return date && date.valueOf() < Date.now() - 86400000;
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
async mounted() {
|
||||
if (this.id) {
|
||||
this.getDetail();
|
||||
}
|
||||
this.getCouponList();
|
||||
this.getGiftList();
|
||||
},
|
||||
methods: {
|
||||
// 关闭当前页面
|
||||
closeCurrentPage() {
|
||||
this.$store.commit("removeTag", "full-cut-detail");
|
||||
localStorage.storeOpenedList = JSON.stringify(
|
||||
this.$store.state.app.storeOpenedList
|
||||
);
|
||||
this.$router.go(-1);
|
||||
},
|
||||
getDetail() {
|
||||
// 获取活动详情
|
||||
getFullDiscountById(this.id).then((res) => {
|
||||
let data = res.result;
|
||||
if (data.number == -1) {
|
||||
data.promotionGoodsList = [];
|
||||
data.scopeType = "ALL";
|
||||
} else {
|
||||
data.scopeType = "PORTION_GOODS";
|
||||
}
|
||||
if (data.isFullMinus) {
|
||||
data.discountType = "isFullMinus";
|
||||
delete data.isFullMinus;
|
||||
} else {
|
||||
data.discountType = "isFullMinus";
|
||||
delete data.isFullRate;
|
||||
}
|
||||
data.rangeTime = [];
|
||||
data.rangeTime.push(new Date(data.startTime), new Date(data.endTime));
|
||||
|
||||
this.form = data;
|
||||
});
|
||||
},
|
||||
/** 保存 */
|
||||
handleSubmit() {
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (valid) {
|
||||
const params = JSON.parse(JSON.stringify(this.form));
|
||||
const strat = this.$options.filters.unixToDate(
|
||||
this.form.rangeTime[0] / 1000
|
||||
);
|
||||
const end = this.$options.filters.unixToDate(
|
||||
this.form.rangeTime[1] / 1000
|
||||
);
|
||||
params.startTime = strat;
|
||||
params.endTime = end;
|
||||
|
||||
if (
|
||||
params.scopeType == "PORTION_GOODS" &&
|
||||
(!params.promotionGoodsList ||
|
||||
params.promotionGoodsList.length == 0)
|
||||
) {
|
||||
this.$Modal.warning({ title: "提示", content: "请选择指定商品" });
|
||||
return;
|
||||
}
|
||||
if (params.scopeType == "ALL") {
|
||||
delete params.promotionGoodsList;
|
||||
params.number = -1;
|
||||
} else {
|
||||
params.number = 1;
|
||||
params.promotionGoodsList.forEach((e) => {
|
||||
e.startTime = params.stratTime;
|
||||
e.endTime = params.endTime;
|
||||
});
|
||||
}
|
||||
if (params.discountType == "isFullMinus") {
|
||||
params.isFullMinus = true;
|
||||
} else {
|
||||
params.isFullRate = true;
|
||||
}
|
||||
delete params.scopeType;
|
||||
delete params.rangeTime;
|
||||
this.submitLoading = true;
|
||||
if (!this.id) {
|
||||
// 添加 避免编辑后传入id等数据 记得删除
|
||||
delete params.id;
|
||||
newFullDiscount(params).then((res) => {
|
||||
this.submitLoading = false;
|
||||
if (res.success) {
|
||||
this.$Message.success("添加活动成功");
|
||||
this.closeCurrentPage();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 编辑
|
||||
delete params.updateTime;
|
||||
|
||||
editFullDiscount(params).then((res) => {
|
||||
this.submitLoading = false;
|
||||
if (res.success) {
|
||||
this.$Message.success("编辑活动成功");
|
||||
this.closeCurrentPage();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
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 ids = [];
|
||||
let list = [];
|
||||
this.form.promotionGoodsList.forEach((e) => {
|
||||
ids.push(e.id);
|
||||
});
|
||||
item.forEach((e) => {
|
||||
if (!ids.includes(e.id)) {
|
||||
list.push({
|
||||
goodsName: e.goodsName,
|
||||
price: e.price,
|
||||
quantity: e.quantity,
|
||||
storeId: e.storeId,
|
||||
sellerName: e.sellerName,
|
||||
skuId: e.id,
|
||||
});
|
||||
}
|
||||
});
|
||||
this.form.promotionGoodsList.push(...list);
|
||||
},
|
||||
getCouponList(query) {
|
||||
// 优惠券列表
|
||||
let params = {
|
||||
pageSize: 10,
|
||||
pageNumber: 0,
|
||||
getType: "ACTIVITY",
|
||||
couponName: query,
|
||||
};
|
||||
this.couponLoading = true;
|
||||
getShopCouponList(params).then((res) => {
|
||||
this.couponLoading = false;
|
||||
if (res.success) {
|
||||
this.couponList = res.result.records;
|
||||
}
|
||||
});
|
||||
},
|
||||
getGiftList(query) {
|
||||
// 赠品列表
|
||||
let params = {
|
||||
pageSize: 10,
|
||||
pageNumber: 1,
|
||||
goodsName: query,
|
||||
};
|
||||
this.giftLoading = true;
|
||||
getGoodsSkuListDataSeller(params).then((res) => {
|
||||
this.giftLoading = false;
|
||||
if (res.success) {
|
||||
this.giftList = res.result.records;
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
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;
|
||||
}
|
||||
</style>
|
||||
|
||||
232
seller/src/views/promotion/pintuan/newPintuan.vue
Normal file
232
seller/src/views/promotion/pintuan/newPintuan.vue
Normal file
@@ -0,0 +1,232 @@
|
||||
<template>
|
||||
<div class="new-pintuan">
|
||||
<Card>
|
||||
<Form ref="form" :model="form" :label-width="130" :rules="formValidate">
|
||||
<FormItem label="活动名称" prop="promotionName" :label-width="130">
|
||||
<Input v-model="form.promotionName" clearable style="width: 260px" />
|
||||
<div style="color: #cccccc">
|
||||
活动名称将显示在对人拼团活动列表中,方便商家管理使用,最多输入25个字符
|
||||
</div>
|
||||
</FormItem>
|
||||
<FormItem label="活动时间" prop="startTime">
|
||||
<DatePicker
|
||||
type="datetime"
|
||||
v-model="form.startTime"
|
||||
format="yyyy-MM-dd HH:mm:ss"
|
||||
:options="options"
|
||||
placeholder="请选择"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
>
|
||||
</DatePicker>
|
||||
-
|
||||
<DatePicker
|
||||
type="datetime"
|
||||
v-model="form.endTime"
|
||||
format="yyyy-MM-dd HH:mm:ss"
|
||||
:options="options"
|
||||
placeholder="请选择"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
>
|
||||
</DatePicker>
|
||||
</FormItem>
|
||||
|
||||
<FormItem label="参团人数" prop="requiredNum" :label-width="130">
|
||||
<Input v-model="form.requiredNum" style="width: 260px">
|
||||
<span slot="append">人</span>
|
||||
</Input>
|
||||
<span style="color: #cccccc"
|
||||
>建议参团人数不少于2人,不超过20人。</span
|
||||
>
|
||||
</FormItem>
|
||||
<FormItem label="限购数量" prop="limitNum" :label-width="130">
|
||||
<Input v-model="form.limitNum" type="number" style="width: 260px">
|
||||
<span slot="append">件/人</span>
|
||||
</Input>
|
||||
<span style="color: #cccccc">如果设置为0则视为不限制购买数量</span>
|
||||
</FormItem>
|
||||
<FormItem label="虚拟成团" prop="fictitious">
|
||||
<RadioGroup v-model="form.fictitious">
|
||||
<Radio title="开启" :label="true">
|
||||
<span>开启</span>
|
||||
</Radio>
|
||||
<Radio title="关闭" :label="false">
|
||||
<span>关闭</span>
|
||||
</Radio>
|
||||
</RadioGroup>
|
||||
<br />
|
||||
<span style="color: #cccccc"
|
||||
>开启虚拟成团后,24小时人数未满的团,系统将会模拟匿名买家凑满人数,使该团成团;您只需要对已付款参团的真实买家发货;建议合理开启以提高</span
|
||||
>
|
||||
</FormItem>
|
||||
<FormItem label="拼团规则" prop="pintuanRule">
|
||||
<Input
|
||||
v-model="form.pintuanRule"
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
clearable
|
||||
style="width: 260px"
|
||||
/>
|
||||
<br />
|
||||
<span style="color: #cccccc"
|
||||
>拼团规则描述不能为空且不能大于255个字,会在WAP拼团详情页面显示</span
|
||||
>
|
||||
</FormItem>
|
||||
</Form>
|
||||
<div>
|
||||
<Button type="text" @click="closeCurrentPage">返回</Button>
|
||||
<Button type="primary" :loading="submitLoading" @click="handleSubmit"
|
||||
>提交</Button
|
||||
>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { savePintuan, editPintuan, getPintuanDetail } from "@/api/promotion";
|
||||
export default {
|
||||
data() {
|
||||
const isLtEndDate = (rule, value, callback) => {
|
||||
if (new Date(value).getTime() > new Date(this.form.endTime).getTime()) {
|
||||
callback(new Error());
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
const isGtStartDate = (rule, value, callback) => {
|
||||
if (new Date(value).getTime() < new Date(this.form.startTime).getTime()) {
|
||||
callback(new Error());
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
return {
|
||||
id: this.$route.query.id, // 拼团id
|
||||
form: {
|
||||
// 添加或编辑表单对象初始化数据
|
||||
promotionName: "",
|
||||
promotionTitle: "",
|
||||
pintuanRule: "",
|
||||
requiredNum: "",
|
||||
fictitious: false,
|
||||
limitNum: "",
|
||||
startTime: "",
|
||||
endTime: "",
|
||||
},
|
||||
// 表单验证规则
|
||||
formValidate: {
|
||||
promotionName: [{ required: true, message: "活动名称不能为空" }],
|
||||
requiredNum: [
|
||||
{ required: true, message: "参团人数不能为空" },
|
||||
{
|
||||
pattern: /^(1|[1-9]\d?|100)$/,
|
||||
message: "参团人数不合法",
|
||||
},
|
||||
],
|
||||
limitNum: [
|
||||
{ required: true, message: "限购数不能为空" },
|
||||
{
|
||||
pattern: /^(0|[1-9]\d?|100)$/,
|
||||
message: "限购数不合法",
|
||||
},
|
||||
],
|
||||
startTime: [
|
||||
{
|
||||
required: true,
|
||||
type: "date",
|
||||
message: "请选择开始时间",
|
||||
},
|
||||
{
|
||||
trigger: "change",
|
||||
message: "开始时间要小于结束时间",
|
||||
validator: isLtEndDate,
|
||||
},
|
||||
],
|
||||
endTime: [
|
||||
{
|
||||
required: true,
|
||||
type: "date",
|
||||
message: "请选择结束时间",
|
||||
},
|
||||
{
|
||||
trigger: "change",
|
||||
message: "结束时间要大于开始时间",
|
||||
validator: isGtStartDate,
|
||||
},
|
||||
],
|
||||
},
|
||||
submitLoading: false, // 添加或编辑提交状态
|
||||
options: { // 不可选取的时间段
|
||||
disabledDate(date) {
|
||||
return date && date.valueOf() < Date.now() - 86400000;
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
if (this.id) {
|
||||
this.getDetail();
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
// 关闭当前页面
|
||||
closeCurrentPage() {
|
||||
this.$store.commit("removeTag", "new-pintuan");
|
||||
localStorage.storeOpenedList = JSON.stringify(
|
||||
this.$store.state.app.storeOpenedList
|
||||
);
|
||||
this.$router.go(-1);
|
||||
},
|
||||
handleSubmit() {
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (valid) {
|
||||
this.submitLoading = true;
|
||||
let params = JSON.parse(JSON.stringify(this.form));
|
||||
params.startTime = this.$options.filters.unixToDate(
|
||||
this.form.startTime / 1000
|
||||
);
|
||||
params.endTime = this.$options.filters.unixToDate(
|
||||
this.form.endTime / 1000
|
||||
);
|
||||
if (!this.id) {
|
||||
// 添加 避免编辑后传入id等数据 记得删除
|
||||
delete params.id;
|
||||
savePintuan(params).then((res) => {
|
||||
this.submitLoading = false;
|
||||
if (res.success) {
|
||||
this.$Message.success("拼团活动发布成功");
|
||||
this.closeCurrentPage();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 编辑
|
||||
if (params.promotionGoodsList == "")
|
||||
delete params.promotionGoodsList;
|
||||
editPintuan(params).then((res) => {
|
||||
this.submitLoading = false;
|
||||
if (res.success) {
|
||||
this.$Message.success("操作成功");
|
||||
this.closeCurrentPage();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
getDetail() {
|
||||
getPintuanDetail(this.id).then((res) => {
|
||||
if (res.success) {
|
||||
this.form = res.result;
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
/deep/ .ivu-form-item{
|
||||
padding: 18px 10px !important;
|
||||
}
|
||||
</style>
|
||||
41
seller/src/views/promotion/pintuan/pintuan.scss
Normal file
41
seller/src/views/promotion/pintuan/pintuan.scss
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
.search {
|
||||
.operation {
|
||||
margin-bottom: 2vh;
|
||||
}
|
||||
|
||||
.select-count {
|
||||
font-weight: 600;
|
||||
color: #40a9ff;
|
||||
}
|
||||
|
||||
.select-clear {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.page {
|
||||
margin-top: 2vh;
|
||||
}
|
||||
|
||||
.drop-down {
|
||||
margin-left: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
.newPromotionView {
|
||||
width: 80%;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
|
||||
Input {
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.slotSpan {
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
341
seller/src/views/promotion/pintuan/pintuan.vue
Normal file
341
seller/src/views/promotion/pintuan/pintuan.vue
Normal file
@@ -0,0 +1,341 @@
|
||||
<template>
|
||||
<div class="search">
|
||||
<Row>
|
||||
<Col>
|
||||
</Col>
|
||||
</Row>
|
||||
<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" class="search-btn " icon="ios-search">搜索</Button>
|
||||
</Form>
|
||||
</Row>
|
||||
<Row class="operation padding-row">
|
||||
<Button @click="newAct" type="primary">添加</Button>
|
||||
</Row>
|
||||
<Row>
|
||||
<Table
|
||||
:loading="loading"
|
||||
border
|
||||
:columns="columns"
|
||||
:data="data"
|
||||
ref="table"
|
||||
sortable="custom"
|
||||
@on-sort-change="changeSort"
|
||||
@on-selection-change="changeSelect"
|
||||
>
|
||||
<template slot-scope="{ row }" slot="action">
|
||||
<Button
|
||||
type="primary"
|
||||
size="small"
|
||||
v-if="row.promotionStatus == 'NEW'"
|
||||
@click="edit(row)"
|
||||
>编辑</Button
|
||||
>
|
||||
<Button
|
||||
type="info"
|
||||
v-if="row.promotionStatus == 'NEW'"
|
||||
size="small"
|
||||
@click="manage(row)"
|
||||
>管理</Button
|
||||
>
|
||||
<Button
|
||||
type="error"
|
||||
size="small"
|
||||
v-if="row.promotionStatus != 'START'"
|
||||
ghost
|
||||
@click="remove(row)"
|
||||
>删除</Button
|
||||
>
|
||||
<Button
|
||||
type="success"
|
||||
v-if="
|
||||
row.promotionStatus == 'NEW' || row.promotionStatus == 'CLOSE'
|
||||
"
|
||||
size="small"
|
||||
@click="open(row)"
|
||||
>开启</Button
|
||||
>
|
||||
<Button
|
||||
type="warning"
|
||||
v-if="row.promotionStatus == 'START'"
|
||||
size="small"
|
||||
@click="close(row)"
|
||||
>关闭</Button
|
||||
>
|
||||
</template>
|
||||
</Table>
|
||||
</Row>
|
||||
<Row type="flex" justify="end" class="page">
|
||||
<Page
|
||||
:current="searchForm.pageNumber + 1"
|
||||
: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 {
|
||||
getPintuanList,
|
||||
deletePintuan,
|
||||
openPintuan,
|
||||
closePintuan,
|
||||
} from "@/api/promotion";
|
||||
export default {
|
||||
name: "pintuan",
|
||||
components: {},
|
||||
data() {
|
||||
return {
|
||||
loading: true, // 表单加载状态
|
||||
searchForm: {
|
||||
// 搜索框初始化对象
|
||||
pageNumber: 0, // 当前页数
|
||||
pageSize: 10, // 页面大小
|
||||
sort: "startTime", // 默认排序字段
|
||||
order: "desc", // 默认排序方式
|
||||
},
|
||||
selectDate: null, // 选择的时间
|
||||
selectList: [], // 多选数据
|
||||
selectCount: 0, // 多选计数
|
||||
columns: [
|
||||
{
|
||||
title: "活动名称",
|
||||
key: "promotionName",
|
||||
minWidth: 120
|
||||
},
|
||||
{
|
||||
title: "活动开始时间",
|
||||
key: "startTime",
|
||||
minWidth: 120
|
||||
},
|
||||
{
|
||||
title: "活动结束时间",
|
||||
key: "endTime",
|
||||
minWidth: 120
|
||||
},
|
||||
{
|
||||
title: "状态",
|
||||
key: "promotionStatus",
|
||||
minWidth: 100,
|
||||
render: (h, params) => {
|
||||
let text = "未知",
|
||||
color = "default";
|
||||
if (params.row.promotionStatus == "NEW") {
|
||||
text = "未开始";
|
||||
color = "default";
|
||||
} else if (params.row.promotionStatus == "START") {
|
||||
text = "已开始";
|
||||
color = "green";
|
||||
} else if (params.row.promotionStatus == "END") {
|
||||
text = "已结束";
|
||||
color = "blue";
|
||||
} else if (params.row.promotionStatus == "CLOSE") {
|
||||
text = "已关闭";
|
||||
color = "red";
|
||||
}
|
||||
return h("div", [h("Tag", { props: { color: color } }, text)]);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "操作",
|
||||
slot: "action",
|
||||
align: "center",
|
||||
width: 250,
|
||||
},
|
||||
],
|
||||
data: [], // 表单数据
|
||||
total: 0, // 表单数据总数
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
this.getDataList();
|
||||
},
|
||||
changePage(v) {
|
||||
this.searchForm.pageNumber = v - 1;
|
||||
this.getDataList();
|
||||
this.clearSelectAll();
|
||||
},
|
||||
changePageSize(v) {
|
||||
this.searchForm.pageSize = v;
|
||||
this.getDataList();
|
||||
},
|
||||
handleSearch() {
|
||||
this.searchForm.pageNumber = 0;
|
||||
this.searchForm.pageSize = 10;
|
||||
this.getDataList();
|
||||
},
|
||||
|
||||
clearSelectAll() {
|
||||
this.$refs.table.selectAll(false);
|
||||
},
|
||||
changeSelect(e) {
|
||||
this.selectList = e;
|
||||
this.selectCount = e.length;
|
||||
},
|
||||
selectDateRange(v) {
|
||||
if (v) {
|
||||
this.searchForm.startDate = v[0];
|
||||
this.searchForm.endDate = v[1];
|
||||
}
|
||||
},
|
||||
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;
|
||||
}
|
||||
// 带多条件搜索参数获取表单数据 请自行修改接口
|
||||
getPintuanList(this.searchForm).then((res) => {
|
||||
this.loading = false;
|
||||
if (res.success) {
|
||||
this.data = res.result.records;
|
||||
this.total = res.result.total;
|
||||
}
|
||||
});
|
||||
},
|
||||
newAct() {
|
||||
this.$router.push({ name: "new-pintuan" });
|
||||
},
|
||||
edit(v) {
|
||||
this.$router.push({ name: "new-pintuan", query: { id: v.id } });
|
||||
},
|
||||
manage(v) {
|
||||
this.$router.push({ name: "pintuan-goods", query: { id: v.id } });
|
||||
},
|
||||
open(v) {
|
||||
this.$Modal.confirm({
|
||||
title: "确认开启",
|
||||
content: "您确认要开启此拼团活动?",
|
||||
onOk: () => {
|
||||
let params = {
|
||||
startTime: this.openStartTime,
|
||||
endTime: this.openEndTime,
|
||||
};
|
||||
openPintuan(v.id, params).then((res) => {
|
||||
this.$Modal.remove();
|
||||
if (res.success) {
|
||||
this.$Message.success("开启活动成功");
|
||||
this.getDataList();
|
||||
}
|
||||
});
|
||||
},
|
||||
render: (h) => {
|
||||
return h("div", [
|
||||
h("DatePicker", {
|
||||
props: {
|
||||
type: "datetimerange",
|
||||
placeholder: "请选择开始时间和结束时间",
|
||||
},
|
||||
style: {
|
||||
width: "350px",
|
||||
},
|
||||
on: {
|
||||
input: (val) => {
|
||||
if (val[0]) {
|
||||
this.openStartTime = val[0].getTime();
|
||||
}
|
||||
if (val[1]) {
|
||||
this.openEndTime = val[1].getTime();
|
||||
}
|
||||
},
|
||||
},
|
||||
}),
|
||||
]);
|
||||
},
|
||||
});
|
||||
},
|
||||
close(v) {
|
||||
this.$Modal.confirm({
|
||||
title: "确认关闭",
|
||||
content: "您确认要关闭此拼团活动?",
|
||||
loading: true,
|
||||
onOk: () => {
|
||||
closePintuan(v.id).then((res) => {
|
||||
this.$Modal.remove();
|
||||
if (res.success) {
|
||||
this.$Message.success("关闭活动成功");
|
||||
this.getDataList();
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
remove(v) {
|
||||
this.$Modal.confirm({
|
||||
title: "确认删除",
|
||||
content: "您确认要删除此拼团活动?",
|
||||
loading: true,
|
||||
onOk: () => {
|
||||
// 删除
|
||||
deletePintuan(v.id).then((res) => {
|
||||
this.$Modal.remove();
|
||||
if (res.success) {
|
||||
this.$Message.success("操作成功");
|
||||
this.getDataList();
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
$route(to, from) {
|
||||
if (to.fullPath == "/promotion/pintuan") {
|
||||
this.init();
|
||||
}
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.init();
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style lang="scss">
|
||||
@import "pintuan.scss";
|
||||
@import "@/styles/table-common.scss";
|
||||
</style>
|
||||
329
seller/src/views/promotion/pintuan/pintuanGoods.vue
Normal file
329
seller/src/views/promotion/pintuan/pintuanGoods.vue
Normal file
@@ -0,0 +1,329 @@
|
||||
<template>
|
||||
<div class="pintuan-goods">
|
||||
<Card>
|
||||
<Table style="margin: 10px 0" border :columns="columns" :data="data"></Table>
|
||||
|
||||
<Row class="operation">
|
||||
<Button type="primary" @click="openSkuList">选择商品</Button>
|
||||
<Button @click="delAll">批量删除</Button>
|
||||
<Button @click="getDataList" icon="md-refresh">刷新</Button>
|
||||
<Button type="dashed" @click="
|
||||
() => {
|
||||
openTip = !openTip;
|
||||
}
|
||||
">{{ openTip ? "关闭提示" : "开启提示" }}</Button>
|
||||
</Row>
|
||||
<Row v-show="openTip">
|
||||
<Alert show-icon>
|
||||
已选择 <span class="select-count">{{ selectCount }}</span> 项
|
||||
<a class="select-clear" @click="clearSelectAll">清空</a>
|
||||
</Alert>
|
||||
</Row>
|
||||
<Row class="operation">
|
||||
<Table :loading="loading" border :columns="goodsColumns" :data="goodsData" ref="table" sortable="custom" @on-sort-change="changeSort" @on-selection-change="changeSelect">
|
||||
<template slot-scope="{ row, index }" slot="price">
|
||||
<Input v-model="row.price" @input="goodsData[index].price = row.price" />
|
||||
</template>
|
||||
<template slot-scope="{ row }" slot="QRCode">
|
||||
<img :src="row.QRCode || '../../../assets/lili.png'" width="50px" height="50px" alt="" />
|
||||
</template>
|
||||
</Table>
|
||||
</Row>
|
||||
<Row type="flex" justify="end" class="page operation">
|
||||
<Page :current="searchForm.pageNumber + 1" :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>
|
||||
<Row class="operation">
|
||||
<Button @click="closeCurrentPage">返回</Button>
|
||||
<Button type="primary" :loading="submitLoading" @click="save">保存</Button>
|
||||
</Row>
|
||||
</Card>
|
||||
|
||||
<sku-select ref="skuSelect" @selectedGoodsData="selectedGoodsData"></sku-select>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import {
|
||||
getPintuanGoodsList,
|
||||
getPintuanDetail,
|
||||
editPintuan,
|
||||
} from "@/api/promotion.js";
|
||||
import skuSelect from "@/views/lili-dialog";
|
||||
export default {
|
||||
components: {
|
||||
skuSelect,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
openTip: true, // 显示提示
|
||||
loading: false, // 表单加载状态
|
||||
searchForm: {
|
||||
// 搜索框初始化对象
|
||||
pageNumber: 0, // 当前页数
|
||||
pageSize: 10, // 页面大小
|
||||
},
|
||||
|
||||
submitLoading: false, // 添加或编辑提交状态
|
||||
selectList: [], // 多选数据
|
||||
selectCount: 0, // 多选计数
|
||||
data: [], // 表单数据
|
||||
total: 0, // 表单数据总数
|
||||
columns: [
|
||||
{
|
||||
title: "活动名称",
|
||||
key: "promotionName",
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
title: "活动开始时间",
|
||||
key: "startTime",
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
title: "活动结束时间",
|
||||
key: "endTime",
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
title: "状态",
|
||||
key: "promotionStatus",
|
||||
minWidth: 100,
|
||||
render: (h, params) => {
|
||||
let text = "未知",
|
||||
color = "";
|
||||
if (params.row.promotionStatus == "NEW") {
|
||||
text = "未开始";
|
||||
color = "default";
|
||||
} else if (params.row.promotionStatus == "START") {
|
||||
text = "已开始";
|
||||
color = "green";
|
||||
} else if (params.row.promotionStatus == "END") {
|
||||
text = "已结束";
|
||||
color = "blue";
|
||||
} else if (params.row.promotionStatus == "CLOSE") {
|
||||
text = "已关闭";
|
||||
color = "red";
|
||||
}
|
||||
return h("div", [
|
||||
h(
|
||||
"Tag",
|
||||
{
|
||||
props: {
|
||||
color: color,
|
||||
},
|
||||
},
|
||||
text
|
||||
),
|
||||
]);
|
||||
},
|
||||
},
|
||||
],
|
||||
goodsColumns: [
|
||||
{ type: "selection", width: 60, align: "center" },
|
||||
{
|
||||
title: "商品名称",
|
||||
key: "goodsName",
|
||||
minWidth: 120,
|
||||
},
|
||||
|
||||
{
|
||||
title: "库存",
|
||||
key: "quantity",
|
||||
minWidth: 40,
|
||||
},
|
||||
|
||||
{
|
||||
title: "拼团价格",
|
||||
key: "price",
|
||||
slot: "price",
|
||||
minWidth: 50,
|
||||
},
|
||||
|
||||
{
|
||||
title: "操作",
|
||||
key: "action",
|
||||
minWidth: 50,
|
||||
align: "center",
|
||||
render: (h, params) => {
|
||||
return h(
|
||||
"Button",
|
||||
{
|
||||
props: {
|
||||
size: "small",
|
||||
type: "error",
|
||||
ghost: true,
|
||||
},
|
||||
on: {
|
||||
click: () => {
|
||||
this.delGoods(params.index);
|
||||
},
|
||||
},
|
||||
},
|
||||
"删除"
|
||||
);
|
||||
},
|
||||
},
|
||||
],
|
||||
goodsData: [], // 商品列表
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
// 关闭当前页面
|
||||
closeCurrentPage() {
|
||||
this.$store.commit("removeTag", "pintuan-goods");
|
||||
localStorage.storeOpenedList = JSON.stringify(
|
||||
this.$store.state.app.storeOpenedList
|
||||
);
|
||||
this.$router.go(-1);
|
||||
},
|
||||
save() {
|
||||
if (this.goodsData.length == 0) {
|
||||
this.$Modal.warning({ title: "提示", content: "请选择活动商品" });
|
||||
return;
|
||||
}
|
||||
for (let i = 0; i < this.goodsData.length; i++) {
|
||||
let data = this.goodsData[i];
|
||||
if (!data.price) {
|
||||
this.$Modal.warning({
|
||||
title: "提示",
|
||||
content: `请填写【${data.goodsName}】的价格`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.goodsData.forEach((item) => {
|
||||
item.promotionId = this.data[0].id;
|
||||
item.startTime = this.data[0].startTime;
|
||||
item.endTime = this.data[0].endTime;
|
||||
});
|
||||
this.data[0].promotionGoodsList = this.goodsData;
|
||||
this.submitLoading = true;
|
||||
editPintuan(this.data[0]).then((res) => {
|
||||
this.submitLoading = false;
|
||||
if (res.success) {
|
||||
this.$Message.success("修改拼团商品成功");
|
||||
this.closeCurrentPage();
|
||||
}
|
||||
});
|
||||
},
|
||||
init() {
|
||||
this.getDataList();
|
||||
this.getPintuanMsg();
|
||||
},
|
||||
|
||||
changePage(v) {
|
||||
this.searchForm.pageNumber = v - 1;
|
||||
this.getDataList();
|
||||
this.clearSelectAll();
|
||||
},
|
||||
|
||||
changePageSize(v) {
|
||||
this.searchForm.pageSize = v;
|
||||
this.getDataList();
|
||||
},
|
||||
|
||||
handleSearch() {
|
||||
this.searchForm.pageNumber = 0;
|
||||
this.searchForm.pageSize = 10;
|
||||
this.getDataList();
|
||||
},
|
||||
|
||||
handleReset() {
|
||||
// 重置
|
||||
// this.$refs.searchForm.resetFields();
|
||||
this.searchForm.pageNumber = 0;
|
||||
this.searchForm.promotionName = "";
|
||||
this.selectDate = null;
|
||||
|
||||
// 重新加载数据
|
||||
this.getDataList();
|
||||
},
|
||||
|
||||
clearSelectAll() {
|
||||
this.$refs.table.selectAll(false);
|
||||
},
|
||||
changeSelect(e) {
|
||||
// 获取选择数据
|
||||
this.selectList = e;
|
||||
this.selectCount = e.length;
|
||||
},
|
||||
|
||||
getDataList() {
|
||||
this.loading = true;
|
||||
this.searchForm.pintuanId = this.$route.query.id;
|
||||
|
||||
getPintuanGoodsList(this.searchForm).then((res) => {
|
||||
this.loading = false;
|
||||
if (res.success) {
|
||||
this.goodsData = res.result.records;
|
||||
this.total = res.result.total;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
getPintuanMsg() {
|
||||
// 获取拼团详情
|
||||
getPintuanDetail(this.$route.query.id).then((res) => {
|
||||
if (res.success) this.data.push(res.result);
|
||||
});
|
||||
},
|
||||
delGoods(index) {
|
||||
// 删除商品
|
||||
this.goodsData.splice(index, 1);
|
||||
},
|
||||
delAll() {
|
||||
if (this.selectCount <= 0) {
|
||||
this.$Message.warning("您还未选择要删除的数据");
|
||||
return;
|
||||
}
|
||||
this.$Modal.confirm({
|
||||
title: "确认删除",
|
||||
content: "您确认要删除所选的 " + this.selectCount + " 条数据?",
|
||||
onOk: () => {
|
||||
let ids = [];
|
||||
this.selectList.forEach(function (e) {
|
||||
ids.push(e.id);
|
||||
});
|
||||
this.goodsData = this.goodsData.filter((item) => {
|
||||
return !ids.includes(item.id);
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
selectedGoodsData(item) {
|
||||
let ids = [];
|
||||
let list = [];
|
||||
this.goodsData.forEach((e) => {
|
||||
ids.push(e.id);
|
||||
});
|
||||
item.forEach((e) => {
|
||||
if (!ids.includes(e.id)) {
|
||||
list.push({
|
||||
goodsName: e.goodsName,
|
||||
price: e.price,
|
||||
originalPrice: e.price,
|
||||
quantity: e.quantity,
|
||||
storeId: e.storeId,
|
||||
sellerName: e.sellerName,
|
||||
thumbnail: e.thumbnail,
|
||||
skuId: e.id,
|
||||
categoryPath: e.categoryPath,
|
||||
});
|
||||
}
|
||||
});
|
||||
this.goodsData.push(...list);
|
||||
},
|
||||
openSkuList() {
|
||||
this.$refs.skuSelect.open("goods");
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.init();
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.operation {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
</style>
|
||||
254
seller/src/views/promotion/seckill/seckill.vue
Normal file
254
seller/src/views/promotion/seckill/seckill.vue
Normal file
@@ -0,0 +1,254 @@
|
||||
<template>
|
||||
<div class="seckill">
|
||||
<Card>
|
||||
<Row>
|
||||
<Form
|
||||
ref="searchForm"
|
||||
:model="searchForm"
|
||||
inline
|
||||
:label-width="70"
|
||||
class="search-form"
|
||||
>
|
||||
<Form-item label="活动名称" prop="goodsName">
|
||||
<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="padding-row">
|
||||
<Table
|
||||
:loading="loading"
|
||||
border
|
||||
:columns="columns"
|
||||
:data="data"
|
||||
ref="table"
|
||||
sortable="custom"
|
||||
>
|
||||
<template slot-scope="{ row }" slot="applyEndTime">
|
||||
{{ unixDate(row.applyEndTime) }}
|
||||
</template>
|
||||
<template slot-scope="{ row }" slot="hours">
|
||||
<Tag v-for="item in unixHours(row.hours)" :key="item">{{
|
||||
item
|
||||
}}</Tag>
|
||||
</template>
|
||||
<template slot-scope="{ row }" slot="action">
|
||||
<Button
|
||||
v-if="
|
||||
row.promotionStatus === 'NEW'
|
||||
"
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="manage(row)"
|
||||
>管理</Button
|
||||
>
|
||||
</template>
|
||||
</Table>
|
||||
</Row>
|
||||
<Row type="flex" justify="end" class="page">
|
||||
<Page
|
||||
:current="searchForm.pageNumber + 1"
|
||||
: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 { seckillList } from "@/api/promotion";
|
||||
export default {
|
||||
name: "goods",
|
||||
components: {},
|
||||
data() {
|
||||
return {
|
||||
loading: true, // 表单加载状态
|
||||
searchForm: {
|
||||
// 搜索框初始化对象
|
||||
pageNumber: 0, // 当前页数
|
||||
pageSize: 10, // 页面大小
|
||||
sort: "startTime",
|
||||
order: "desc", // 默认排序方式
|
||||
},
|
||||
columns: [
|
||||
{
|
||||
title: "活动名称",
|
||||
key: "promotionName",
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
title: "活动开始时间",
|
||||
key: "startTime",
|
||||
},
|
||||
{
|
||||
title: "报名截止时间",
|
||||
slot: "applyEndTime",
|
||||
},
|
||||
{
|
||||
title: "时间场次",
|
||||
slot: "hours",
|
||||
},
|
||||
{
|
||||
title: "状态",
|
||||
key: "promotionStatus",
|
||||
render: (h, params) => {
|
||||
let text = "未知",
|
||||
color = "default";
|
||||
if (params.row.promotionStatus == "NEW") {
|
||||
text = "未开始";
|
||||
color = "default";
|
||||
} 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
|
||||
),
|
||||
]);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "操作",
|
||||
slot: "action",
|
||||
align: "center",
|
||||
width: 100,
|
||||
},
|
||||
],
|
||||
data: [], // 表单数据
|
||||
total: 0, // 表单数据总数
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
this.getDataList();
|
||||
},
|
||||
changePage(v) {
|
||||
this.searchForm.pageNumber = v - 1;
|
||||
this.getDataList();
|
||||
},
|
||||
changePageSize(v) {
|
||||
this.searchForm.pageSize = v;
|
||||
this.getDataList();
|
||||
},
|
||||
handleSearch() {
|
||||
this.searchForm.pageNumber = 0;
|
||||
this.searchForm.pageSize = 10;
|
||||
this.getDataList();
|
||||
},
|
||||
|
||||
manage(row) {
|
||||
this.$router.push({ name: "seckill-goods", query: { id: row.id } });
|
||||
},
|
||||
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;
|
||||
}
|
||||
// 带多条件搜索参数获取表单数据
|
||||
seckillList(this.searchForm).then((res) => {
|
||||
this.loading = false;
|
||||
if (res.success) {
|
||||
this.data = res.result.records;
|
||||
this.total = res.result.total;
|
||||
}
|
||||
});
|
||||
},
|
||||
unixDate(time) {
|
||||
// 处理报名截止时间
|
||||
return this.$options.filters.unixToDate(new Date(time) / 1000);
|
||||
},
|
||||
unixHours(item) {
|
||||
// 处理小时场次
|
||||
let hourArr = item.split(",");
|
||||
for (let i = 0; i < hourArr.length; i++) {
|
||||
hourArr[i] += ":00";
|
||||
}
|
||||
return hourArr;
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.init();
|
||||
},
|
||||
watch: {
|
||||
$route(to, from) {
|
||||
if (to.fullPath == "/promotion/seckill") {
|
||||
this.init();
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.seckill {
|
||||
.operation {
|
||||
margin: 10px 0;
|
||||
}
|
||||
.select-count {
|
||||
font-weight: 600;
|
||||
color: #40a9ff;
|
||||
}
|
||||
.select-clear {
|
||||
margin-left: 10px;
|
||||
}
|
||||
.page {
|
||||
margin-top: 2vh;
|
||||
}
|
||||
.drop-down {
|
||||
margin-left: 5px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
444
seller/src/views/promotion/seckill/seckillGoods.vue
Normal file
444
seller/src/views/promotion/seckill/seckillGoods.vue
Normal file
@@ -0,0 +1,444 @@
|
||||
<template>
|
||||
<div class="seckill-goods">
|
||||
<Card>
|
||||
<Table border :columns="columns" :data="data">
|
||||
<template slot-scope="{ row }" slot="applyEndTime">
|
||||
{{ unixDate(row.applyEndTime) }}
|
||||
</template>
|
||||
<template slot-scope="{ row }" slot="hours">
|
||||
<Tag v-for="item in unixHours(row.hours)" :key="item">{{ item }}</Tag>
|
||||
</template>
|
||||
</Table>
|
||||
|
||||
<Row class="operation">
|
||||
<template v-if="promotionStatus == 'NEW'">
|
||||
<Button type="primary" @click="openSkuList">选择商品</Button>
|
||||
<Button @click="delAll">批量删除</Button>
|
||||
</template>
|
||||
</Row>
|
||||
<Row v-show="openTip">
|
||||
<Alert show-icon>
|
||||
已选择 <span class="select-count">{{ selectCount }}</span> 项
|
||||
</Alert>
|
||||
</Row>
|
||||
<Row class="operation">
|
||||
<Tabs type="card" v-model="tabIndex">
|
||||
<TabPane
|
||||
v-for="(tab, tabIndex) in goodsList"
|
||||
:key="tabIndex"
|
||||
:label="tab.hour"
|
||||
:name="tabIndex"
|
||||
>
|
||||
<Table
|
||||
:loading="loading"
|
||||
border
|
||||
:columns="goodsColumns"
|
||||
:data="tab.list"
|
||||
:ref="'table' + tabIndex"
|
||||
sortable="custom"
|
||||
@on-selection-change="changeSelect"
|
||||
>
|
||||
<template slot-scope="{ row }" slot="originalPrice">
|
||||
<div>{{ row.originalPrice | unitPrice("¥") }}</div>
|
||||
</template>
|
||||
|
||||
<template slot-scope="{ row, index }" slot="quantity">
|
||||
<Input
|
||||
v-model="row.quantity"
|
||||
:disabled="row.promotionApplyStatus == 'PASS'"
|
||||
@input="
|
||||
goodsList[tabIndex].list[index].quantity = row.quantity
|
||||
"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<template slot-scope="{ row, index }" slot="price">
|
||||
<Input
|
||||
v-model="row.price"
|
||||
:disabled="row.promotionApplyStatus == 'PASS'"
|
||||
@input="goodsList[tabIndex].list[index].price = row.price"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<template slot-scope="{ row }" slot="promotionApplyStatus">
|
||||
<Badge
|
||||
status="success"
|
||||
v-if="row.promotionApplyStatus == 'PASS'"
|
||||
:text="promotionApplyStatus(row.promotionApplyStatus)"
|
||||
/>
|
||||
<Badge
|
||||
status="blue"
|
||||
v-if="row.promotionApplyStatus == 'APPLY'"
|
||||
:text="promotionApplyStatus(row.promotionApplyStatus)"
|
||||
/>
|
||||
<Badge
|
||||
status="error"
|
||||
v-if="row.promotionApplyStatus == 'REFUSE'"
|
||||
:text="promotionApplyStatus(row.promotionApplyStatus)"
|
||||
/>
|
||||
<span
|
||||
v-if="row.promotionApplyStatus == 'REFUSE'"
|
||||
@click="showReason(row.failReason)"
|
||||
class="reason"
|
||||
>(拒绝原因)</span
|
||||
>
|
||||
<Badge
|
||||
status="error"
|
||||
v-if="row.promotionApplyStatus == ''"
|
||||
:text="promotionApplyStatus(row.promotionApplyStatus)"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<template slot-scope="{ row }" slot="QRCode">
|
||||
<img
|
||||
v-if="row.QRCode"
|
||||
:src="row.QRCode || '../../../assets/lili.png'"
|
||||
width="50px"
|
||||
height="50px"
|
||||
alt=""
|
||||
/>
|
||||
</template>
|
||||
<template slot-scope="{ row, index }" slot="action">
|
||||
<Button
|
||||
type="error"
|
||||
v-if="row.promotionApplyStatus !== 'PASS'"
|
||||
:disabled="promotionStatus != 'NEW'"
|
||||
size="small"
|
||||
ghost
|
||||
@click="delGoods(index, row.id)"
|
||||
>删除</Button
|
||||
>
|
||||
</template>
|
||||
</Table>
|
||||
</TabPane>
|
||||
</Tabs>
|
||||
</Row>
|
||||
|
||||
<Row class="operation">
|
||||
<Button @click="closeCurrentPage">返回</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
:loading="submitLoading"
|
||||
:disabled="promotionStatus != 'NEW'"
|
||||
@click="save"
|
||||
>提交</Button
|
||||
>
|
||||
</Row>
|
||||
</Card>
|
||||
|
||||
<sku-select
|
||||
ref="skuSelect"
|
||||
@selectedGoodsData="selectedGoodsData"
|
||||
></sku-select>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import {
|
||||
seckillGoodsList,
|
||||
seckillDetail,
|
||||
setSeckillGoods,
|
||||
removeSeckillGoods,
|
||||
} from "@/api/promotion.js";
|
||||
import skuSelect from "@/views/lili-dialog";
|
||||
export default {
|
||||
components: {
|
||||
skuSelect,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
promotionStatus: "", // 活动状态
|
||||
openTip: true,
|
||||
loading: false, // 表单加载状态
|
||||
searchForm: {
|
||||
// 搜索框初始化对象
|
||||
pageNumber: 0, // 当前页数
|
||||
pageSize: 1000, // 页面大小
|
||||
},
|
||||
tabIndex: 0, // 选择商品的下标
|
||||
submitLoading: false, // 添加或编辑提交状态
|
||||
selectList: [], // 多选数据
|
||||
selectCount: 0, // 多选计数
|
||||
data: [{}], // 表单数据
|
||||
columns: [
|
||||
{
|
||||
title: "活动名称",
|
||||
key: "promotionName",
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
title: "活动开始时间",
|
||||
key: "startTime",
|
||||
},
|
||||
{
|
||||
title: "报名截止时间",
|
||||
slot: "applyEndTime",
|
||||
},
|
||||
{
|
||||
title: "时间场次",
|
||||
slot: "hours",
|
||||
},
|
||||
],
|
||||
goodsColumns: [
|
||||
{ type: "selection", width: 60, align: "center" },
|
||||
{
|
||||
title: "商品名称",
|
||||
key: "goodsName",
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
title: "商品价格",
|
||||
slot: "originalPrice",
|
||||
minWidth: 50,
|
||||
},
|
||||
{
|
||||
title: "库存",
|
||||
slot: "quantity",
|
||||
minWidth: 40,
|
||||
},
|
||||
{
|
||||
title: "活动价格",
|
||||
slot: "price",
|
||||
minWidth: 50,
|
||||
},
|
||||
{
|
||||
title: "状态",
|
||||
slot: "promotionApplyStatus",
|
||||
minWidth: 30,
|
||||
},
|
||||
// {
|
||||
// title: "商品二维码",
|
||||
// slot: "QRCode",
|
||||
// },
|
||||
{
|
||||
title: "操作",
|
||||
slot: "action",
|
||||
minWidth: 50,
|
||||
},
|
||||
],
|
||||
goodsList: [] // 商品列表
|
||||
};
|
||||
},
|
||||
computed: {},
|
||||
methods: {
|
||||
// 关闭当前页面
|
||||
closeCurrentPage() {
|
||||
this.$store.commit("removeTag", "seckill-goods");
|
||||
localStorage.storeOpenedList = JSON.stringify(
|
||||
this.$store.state.app.storeOpenedList
|
||||
);
|
||||
this.$router.go(-1);
|
||||
},
|
||||
save() {
|
||||
// 提交
|
||||
// for(let i=0;i<this.goodsData.length;i++){
|
||||
// let data = this.goodsData[i]
|
||||
// if(!data.price){
|
||||
// this.$Modal.warning({
|
||||
// title:'提示',
|
||||
// content:`请填写【${data.goodsName}】的价格`
|
||||
// })
|
||||
// return
|
||||
// }
|
||||
// }
|
||||
|
||||
let list = JSON.parse(JSON.stringify(this.goodsList));
|
||||
let params = {
|
||||
seckillId: this.$route.query.id,
|
||||
applyVos: [],
|
||||
};
|
||||
list.forEach((e, index) => {
|
||||
e.list.forEach((i) => {
|
||||
// if(e.id) delete e.id
|
||||
params.applyVos.push(i);
|
||||
});
|
||||
});
|
||||
this.submitLoading = true;
|
||||
setSeckillGoods(params).then((res) => {
|
||||
this.submitLoading = false;
|
||||
if (res && res.success) {
|
||||
this.$Message.success("提交活动商品成功");
|
||||
this.closeCurrentPage();
|
||||
}
|
||||
});
|
||||
},
|
||||
init() {
|
||||
this.getSeckillMsg();
|
||||
},
|
||||
|
||||
clearSelectAll() {
|
||||
this.$refs.table.selectAll(false);
|
||||
},
|
||||
changeSelect(e) {
|
||||
// 获取选择数据
|
||||
this.selectList = e;
|
||||
this.selectCount = e.length;
|
||||
},
|
||||
|
||||
getDataList() {
|
||||
// 获取商品详情
|
||||
this.loading = true;
|
||||
this.searchForm.seckillId = this.$route.query.id;
|
||||
|
||||
// 处理过的时间 为‘1:00’
|
||||
let hours = this.unixHours(this.data[0].hours);
|
||||
hours.forEach((e) => {
|
||||
this.goodsList.push({
|
||||
hour: e,
|
||||
list: [],
|
||||
});
|
||||
});
|
||||
seckillGoodsList(this.searchForm).then((res) => {
|
||||
this.loading = false;
|
||||
if (res.success && res.result) {
|
||||
let data = res.result.records;
|
||||
// 未处理时间 为'1'
|
||||
let noFilterhours = this.data[0].hours.split(",");
|
||||
if (data.length) {
|
||||
noFilterhours.forEach((e, index) => {
|
||||
data.forEach((i) => {
|
||||
if (i.timeLine == e) {
|
||||
this.goodsList[index].list.push(i);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
getSeckillMsg() {
|
||||
// 获取活动详情
|
||||
seckillDetail(this.$route.query.id).then((res) => {
|
||||
if (res.success && res.result) {
|
||||
this.data = [];
|
||||
this.data.push(res.result);
|
||||
this.promotionStatus = res.result.promotionStatus;
|
||||
this.getDataList();
|
||||
}
|
||||
});
|
||||
},
|
||||
delGoods(index, id) {
|
||||
// 删除商品
|
||||
if (id) {
|
||||
removeSeckillGoods(this.$route.query.id, id).then((res) => {
|
||||
if (res.success) {
|
||||
this.goodsList[this.tabIndex].list.splice(index, 1);
|
||||
this.$Message.success("删除成功!");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.goodsList[this.tabIndex].list.splice(index, 1);
|
||||
this.$Message.success("删除成功!");
|
||||
}
|
||||
},
|
||||
delAll() {
|
||||
if (this.selectCount <= 0) {
|
||||
this.$Message.warning("您还未选择要删除的数据");
|
||||
return;
|
||||
}
|
||||
this.$Modal.confirm({
|
||||
title: "确认删除",
|
||||
content: "您确认要删除所选的 " + this.selectCount + " 条数据?",
|
||||
onOk: () => {
|
||||
let ids = [];
|
||||
this.selectList.forEach(function (e) {
|
||||
if (e.promotionApplyStatus !== 'PASS') {
|
||||
ids.push(e.id);
|
||||
}
|
||||
});
|
||||
this.goodsList[this.tabIndex].list = this.goodsList[
|
||||
this.tabIndex
|
||||
].list.filter((item) => {
|
||||
return !ids.includes(item.id);
|
||||
});
|
||||
removeSeckillGoods(this.$route.query.id, ids).then((res) => {
|
||||
if (res.success) {
|
||||
this.$Message.success("删除成功!");
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
selectedGoodsData(item) {
|
||||
// 选择器添加商品
|
||||
let ids = [];
|
||||
let list = [];
|
||||
|
||||
this.goodsList[this.tabIndex].list.forEach((e) => {
|
||||
ids.push(e.id);
|
||||
});
|
||||
item.forEach((e) => {
|
||||
if (!ids.includes(e.id)) {
|
||||
list.push({
|
||||
goodsName: e.goodsName,
|
||||
price: e.price,
|
||||
originalPrice: e.price,
|
||||
promotionApplyStatus: "",
|
||||
quantity: e.quantity,
|
||||
seckillId: this.$route.query.id,
|
||||
storeId: e.storeId,
|
||||
storeName: e.storeName,
|
||||
skuId: e.id,
|
||||
timeLine: this.data[0].hours.split(",")[this.tabIndex],
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
this.goodsList[this.tabIndex].list.push(...list);
|
||||
},
|
||||
openSkuList() {
|
||||
this.$refs.skuSelect.open("goods");
|
||||
},
|
||||
unixDate(time) {
|
||||
// 处理报名截止时间
|
||||
return this.$options.filters.unixToDate(new Date(time) / 1000);
|
||||
},
|
||||
unixHours(item) {
|
||||
if (item) {
|
||||
// 处理小时场次
|
||||
let hourArr = item.split(",");
|
||||
for (let i = 0; i < hourArr.length; i++) {
|
||||
hourArr[i] += ":00";
|
||||
}
|
||||
return hourArr;
|
||||
}
|
||||
return [];
|
||||
},
|
||||
promotionApplyStatus(key) {
|
||||
switch (key) {
|
||||
case "APPLY":
|
||||
return "申请";
|
||||
break;
|
||||
case "PASS":
|
||||
return "通过";
|
||||
break;
|
||||
case "REFUSE":
|
||||
return "拒绝";
|
||||
break;
|
||||
default:
|
||||
return "未申请";
|
||||
break;
|
||||
}
|
||||
},
|
||||
showReason(reason) {
|
||||
this.$Modal.info({
|
||||
title: "拒绝原因",
|
||||
content: reason,
|
||||
});
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.init();
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.operation {
|
||||
margin: 10px 0;
|
||||
}
|
||||
.reason {
|
||||
cursor: pointer;
|
||||
color: #2d8cf0;
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user