mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2025-12-22 19:05:54 +08:00
适配重构促销
This commit is contained in:
@@ -7,42 +7,79 @@
|
||||
<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>
|
||||
<Button type="dashed" @click="openTip = !openTip">{{
|
||||
openTip ? "关闭提示" : "开启提示"
|
||||
}}</Button>
|
||||
</Row>
|
||||
<Row v-show="openTip" v-if="status == 'manager'">
|
||||
<Row v-show="openTip" v-if="status == 'manager'">
|
||||
<Alert show-icon>
|
||||
已选择 <span >{{ selectCount }}</span> 项
|
||||
已选择 <span>{{ selectCount }}</span> 项
|
||||
<a class="select-clear" @click="clearSelectAll">清空</a>
|
||||
</Alert>
|
||||
</Row>
|
||||
<h3 class="act-goods">活动商品</h3>
|
||||
<Table class="mt_10" :loading="loading" border :columns="goodsColumns" :data="goodsData" ref="table" @on-selection-change="changeSelect">
|
||||
<Table
|
||||
class="mt_10"
|
||||
:loading="loading"
|
||||
border
|
||||
:columns="goodsColumns"
|
||||
:data="goodsData"
|
||||
ref="table"
|
||||
@on-selection-change="changeSelect"
|
||||
>
|
||||
<template slot-scope="{ row, index }" slot="price">
|
||||
<Input v-model="row.price" :disabled="status==='view'" @input="goodsData[index].price = row.price" />
|
||||
<Input
|
||||
v-model="row.price"
|
||||
:disabled="status === 'view'"
|
||||
@input="goodsData[index].price = row.price"
|
||||
/>
|
||||
</template>
|
||||
<template slot-scope="{ index }" slot="action">
|
||||
<Button type="error" size="small" ghost v-if="status === 'manager'" @click="delGoods(index)">删除</Button>
|
||||
<Button
|
||||
type="error"
|
||||
size="small"
|
||||
ghost
|
||||
v-if="status === 'manager'"
|
||||
@click="delGoods(index)"
|
||||
>删除</Button
|
||||
>
|
||||
</template>
|
||||
</Table>
|
||||
<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>
|
||||
<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 v-if="status == 'manager'" type="primary" :loading="submitLoading" @click="save">保存</Button>
|
||||
<Button
|
||||
v-if="status == 'manager'"
|
||||
type="primary"
|
||||
:loading="submitLoading"
|
||||
@click="save"
|
||||
>保存</Button
|
||||
>
|
||||
</Row>
|
||||
</Card>
|
||||
|
||||
<sku-select ref="skuSelect" :goodsData="goodsData" @selectedGoodsData="selectedGoodsData"></sku-select>
|
||||
<sku-select
|
||||
ref="skuSelect"
|
||||
:goodsData="goodsData"
|
||||
@selectedGoodsData="selectedGoodsData"
|
||||
></sku-select>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import {
|
||||
getPintuanGoodsList,
|
||||
getPintuanDetail,
|
||||
editPintuan,
|
||||
} from "@/api/promotion.js";
|
||||
import { getPintuanGoodsList, getPintuanDetail, editPintuan } from "@/api/promotion.js";
|
||||
import skuSelect from "@/views/lili-dialog";
|
||||
export default {
|
||||
components: {
|
||||
@@ -52,7 +89,8 @@ export default {
|
||||
return {
|
||||
openTip: true, // 显示提示
|
||||
loading: false, // 表单加载状态
|
||||
searchForm: { // 搜索框初始化对象
|
||||
searchForm: {
|
||||
// 搜索框初始化对象
|
||||
pageNumber: 0, // 当前页数
|
||||
pageSize: 10, // 页面大小
|
||||
},
|
||||
@@ -63,7 +101,8 @@ export default {
|
||||
data: [], // 表单数据
|
||||
total: 0, // 表单数据总数
|
||||
status: this.$route.query.status, // 查看还是修改
|
||||
columns: [ // 活动详情表头
|
||||
columns: [
|
||||
// 活动详情表头
|
||||
{
|
||||
title: "活动名称",
|
||||
key: "promotionName",
|
||||
@@ -99,17 +138,12 @@ export default {
|
||||
text = "已关闭";
|
||||
color = "red";
|
||||
}
|
||||
return h("div", [
|
||||
h(
|
||||
"Tag",
|
||||
{props: {color: color}},
|
||||
text
|
||||
),
|
||||
]);
|
||||
return h("div", [h("Tag", { props: { color: color } }, text)]);
|
||||
},
|
||||
},
|
||||
],
|
||||
goodsColumns: [ // 活动商品表头
|
||||
goodsColumns: [
|
||||
// 活动商品表头
|
||||
{ type: "selection", width: 60, align: "center" },
|
||||
{
|
||||
title: "商品名称",
|
||||
@@ -177,23 +211,27 @@ export default {
|
||||
}
|
||||
});
|
||||
},
|
||||
init() { // 初始化数据
|
||||
init() {
|
||||
// 初始化数据
|
||||
this.getDataList();
|
||||
this.getPintuanMsg();
|
||||
},
|
||||
|
||||
changePage(v) { // 分页 改变页数
|
||||
changePage(v) {
|
||||
// 分页 改变页数
|
||||
this.searchForm.pageNumber = v - 1;
|
||||
this.getDataList();
|
||||
this.clearSelectAll();
|
||||
},
|
||||
|
||||
changePageSize(v) { // 分页 改变每页数
|
||||
changePageSize(v) {
|
||||
// 分页 改变每页数
|
||||
this.searchForm.pageSize = v;
|
||||
this.getDataList();
|
||||
},
|
||||
|
||||
handleSearch() { // 搜索
|
||||
handleSearch() {
|
||||
// 搜索
|
||||
this.searchForm.pageNumber = 0;
|
||||
this.searchForm.pageSize = 10;
|
||||
this.getDataList();
|
||||
@@ -207,7 +245,8 @@ export default {
|
||||
this.getDataList();
|
||||
},
|
||||
|
||||
clearSelectAll() { // 清空所有已选项
|
||||
clearSelectAll() {
|
||||
// 清空所有已选项
|
||||
this.$refs.table.selectAll(false);
|
||||
},
|
||||
changeSelect(e) {
|
||||
@@ -216,7 +255,8 @@ export default {
|
||||
this.selectCount = e.length;
|
||||
},
|
||||
|
||||
getDataList() { // 获取商品列表
|
||||
getDataList() {
|
||||
// 获取商品列表
|
||||
this.loading = true;
|
||||
this.searchForm.pintuanId = this.$route.query.id;
|
||||
|
||||
@@ -228,15 +268,18 @@ export default {
|
||||
}
|
||||
});
|
||||
},
|
||||
getPintuanMsg() { // 获取拼团详情
|
||||
getPintuanMsg() {
|
||||
// 获取拼团详情
|
||||
getPintuanDetail(this.$route.query.id).then((res) => {
|
||||
if (res.success) this.data.push(res.result);
|
||||
});
|
||||
},
|
||||
delGoods(index) { // 删除商品
|
||||
delGoods(index) {
|
||||
// 删除商品
|
||||
this.goodsData.splice(index, 1);
|
||||
},
|
||||
delAll() { // 批量删除商品
|
||||
delAll() {
|
||||
// 批量删除商品
|
||||
if (this.selectCount <= 0) {
|
||||
this.$Message.warning("您还未选择要删除的数据");
|
||||
return;
|
||||
@@ -255,34 +298,38 @@ export default {
|
||||
},
|
||||
});
|
||||
},
|
||||
selectedGoodsData(item) { // 选择商品
|
||||
selectedGoodsData(item) {
|
||||
// 选择商品
|
||||
console.log(item);
|
||||
let list = [];
|
||||
item.forEach((e) => {
|
||||
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,
|
||||
});
|
||||
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,
|
||||
goodsId: e.goodsId,
|
||||
goodsType: e.goodsType,
|
||||
});
|
||||
});
|
||||
this.goodsData = list;
|
||||
},
|
||||
openSkuList() { // 显示商品选择器
|
||||
openSkuList() {
|
||||
// 显示商品选择器
|
||||
this.$refs.skuSelect.open("goods");
|
||||
let data = JSON.parse(JSON.stringify(this.goodsData))
|
||||
data.forEach(e => {
|
||||
e.id = e.skuId
|
||||
})
|
||||
let data = JSON.parse(JSON.stringify(this.goodsData));
|
||||
data.forEach((e) => {
|
||||
e.id = e.skuId;
|
||||
});
|
||||
this.$refs.skuSelect.goodsData = data;
|
||||
},
|
||||
},
|
||||
mounted () {
|
||||
mounted() {
|
||||
this.init();
|
||||
},
|
||||
};
|
||||
@@ -294,8 +341,8 @@ export default {
|
||||
.act-goods {
|
||||
margin: 20px 0;
|
||||
font-size: 15px;
|
||||
&::before{
|
||||
content: '|';
|
||||
&::before {
|
||||
content: "|";
|
||||
color: $theme_color;
|
||||
display: inline-block;
|
||||
font-weight: bold;
|
||||
@@ -2,7 +2,13 @@
|
||||
<div class="pintuan">
|
||||
<Card>
|
||||
<Row>
|
||||
<Form ref="searchForm" :model="searchForm" inline :label-width="70" class="search-form">
|
||||
<Form
|
||||
ref="searchForm"
|
||||
:model="searchForm"
|
||||
inline
|
||||
:label-width="70"
|
||||
class="search-form"
|
||||
>
|
||||
<Form-item label="活动名称" prop="promotionName">
|
||||
<Input
|
||||
type="text"
|
||||
@@ -34,66 +40,64 @@
|
||||
style="width: 200px"
|
||||
></DatePicker>
|
||||
</Form-item>
|
||||
<Button @click="handleSearch" type="primary" class="search-btn " icon="ios-search">搜索</Button>
|
||||
<Button
|
||||
@click="handleSearch"
|
||||
type="primary"
|
||||
class="search-btn"
|
||||
icon="ios-search"
|
||||
>搜索</Button
|
||||
>
|
||||
<Button @click="handleReset" class="search-btn">重置</Button>
|
||||
</Form>
|
||||
</Row>
|
||||
<Row class="operation padding-row">
|
||||
<Button @click="newAct" type="primary">添加</Button>
|
||||
</Row>
|
||||
<Table
|
||||
:loading="loading"
|
||||
border
|
||||
:columns="columns"
|
||||
:data="data"
|
||||
ref="table"
|
||||
>
|
||||
<Table :loading="loading" border :columns="columns" :data="data" ref="table">
|
||||
<template slot-scope="{ row }" slot="action">
|
||||
<div class="row">
|
||||
<Button
|
||||
type="default"
|
||||
size="small"
|
||||
v-if="row.promotionStatus == 'NEW'"
|
||||
@click="edit(row)"
|
||||
>编辑</Button
|
||||
>
|
||||
<Button
|
||||
type="info"
|
||||
v-if="row.promotionStatus == 'NEW'"
|
||||
size="small"
|
||||
@click="manage(row, 'manager')"
|
||||
>管理</Button
|
||||
>
|
||||
<Button
|
||||
type="info"
|
||||
v-if="row.promotionStatus !== 'NEW'"
|
||||
size="small"
|
||||
@click="manage(row, 'view')"
|
||||
>查看</Button
|
||||
>
|
||||
<Button
|
||||
type="error"
|
||||
size="small"
|
||||
v-if="row.promotionStatus != 'START'"
|
||||
@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
|
||||
>
|
||||
<div class="row">
|
||||
<Button
|
||||
type="default"
|
||||
size="small"
|
||||
v-if="row.promotionStatus == 'NEW'"
|
||||
@click="edit(row)"
|
||||
>编辑</Button
|
||||
>
|
||||
<Button
|
||||
type="info"
|
||||
v-if="row.promotionStatus == 'NEW'"
|
||||
size="small"
|
||||
@click="manage(row, 'manager')"
|
||||
>管理</Button
|
||||
>
|
||||
<Button
|
||||
type="info"
|
||||
v-if="row.promotionStatus !== 'NEW'"
|
||||
size="small"
|
||||
@click="manage(row, 'view')"
|
||||
>查看</Button
|
||||
>
|
||||
<Button
|
||||
type="error"
|
||||
size="small"
|
||||
v-if="row.promotionStatus != 'START'"
|
||||
@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
|
||||
>
|
||||
</div>
|
||||
</template>
|
||||
</Table>
|
||||
@@ -116,12 +120,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
getPintuanList,
|
||||
deletePintuan,
|
||||
openPintuan,
|
||||
closePintuan,
|
||||
} from "@/api/promotion";
|
||||
import { getPintuanList, deletePintuan, editPintuanStatus } from "@/api/promotion";
|
||||
export default {
|
||||
name: "pintuan",
|
||||
data() {
|
||||
@@ -139,7 +138,7 @@ export default {
|
||||
{
|
||||
title: "活动名称",
|
||||
key: "promotionName",
|
||||
minWidth: 120
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
title: "活动开始时间",
|
||||
@@ -206,8 +205,8 @@ export default {
|
||||
},
|
||||
// 重置
|
||||
handleReset() {
|
||||
this.searchForm = {}
|
||||
this.selectDate = ''
|
||||
this.searchForm = {};
|
||||
this.selectDate = "";
|
||||
this.searchForm.pageNumber = 0;
|
||||
this.searchForm.pageSize = 10;
|
||||
this.getDataList();
|
||||
@@ -239,11 +238,11 @@ export default {
|
||||
},
|
||||
// 新建拼团
|
||||
newAct() {
|
||||
this.$router.push({ name: "new-pintuan" });
|
||||
this.$router.push({ name: "pintuan-edit" });
|
||||
},
|
||||
// 编辑拼团
|
||||
edit(v) {
|
||||
this.$router.push({ name: "new-pintuan", query: { id: v.id } });
|
||||
this.$router.push({ name: "pintuan-edit", query: { id: v.id } });
|
||||
},
|
||||
// 管理拼团商品
|
||||
manage(v, status) {
|
||||
@@ -251,15 +250,20 @@ export default {
|
||||
},
|
||||
// 手动开启拼团活动
|
||||
open(v) {
|
||||
let sTime = new Date();
|
||||
sTime.setMinutes(sTime.getMinutes() + 10);
|
||||
let eTime = new Date(new Date().setHours(0, 0, 0, 0) + 24 * 60 * 60 * 1000 - 1);
|
||||
this.openStartTime = sTime.getTime();
|
||||
this.openEndTime = eTime.getTime();
|
||||
this.$Modal.confirm({
|
||||
title: "确认开启",
|
||||
title: "确认开启(默认为当前时间的十分钟之后)",
|
||||
content: "您确认要开启此拼团活动?",
|
||||
onOk: () => {
|
||||
let params = {
|
||||
startTime: this.openStartTime,
|
||||
endTime: this.openEndTime,
|
||||
};
|
||||
openPintuan(v.id, params).then((res) => {
|
||||
editPintuanStatus(v.id, params).then((res) => {
|
||||
this.$Modal.remove();
|
||||
if (res.success) {
|
||||
this.$Message.success("开启活动成功");
|
||||
@@ -273,6 +277,7 @@ export default {
|
||||
props: {
|
||||
type: "datetimerange",
|
||||
placeholder: "请选择开始时间和结束时间",
|
||||
value: [sTime, eTime],
|
||||
},
|
||||
style: {
|
||||
width: "350px",
|
||||
@@ -299,7 +304,7 @@ export default {
|
||||
content: "您确认要关闭此拼团活动?",
|
||||
loading: true,
|
||||
onOk: () => {
|
||||
closePintuan(v.id).then((res) => {
|
||||
editPintuanStatus(v.id).then((res) => {
|
||||
this.$Modal.remove();
|
||||
if (res.success) {
|
||||
this.$Message.success("关闭活动成功");
|
||||
@@ -333,9 +338,9 @@ export default {
|
||||
},
|
||||
// 页面缓存处理,从该页面离开时,修改KeepAlive为false,保证进入该页面是刷新
|
||||
beforeRouteLeave(to, from, next) {
|
||||
from.meta.keepAlive = false
|
||||
next()
|
||||
}
|
||||
from.meta.keepAlive = false;
|
||||
next();
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style lang="scss">
|
||||
|
||||
Reference in New Issue
Block a user