commit message

This commit is contained in:
Chopper
2021-05-13 10:56:04 +08:00
commit ec3e958037
728 changed files with 132685 additions and 0 deletions

View 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>

View 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;
}
}

View 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
>&nbsp;
<Button
type="info"
v-if="row.promotionStatus == 'NEW'"
size="small"
@click="manage(row)"
>管理</Button
>&nbsp;
<Button
type="error"
size="small"
v-if="row.promotionStatus != 'START'"
ghost
@click="remove(row)"
>删除</Button
>&nbsp;
<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>

View 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>