2021-05-13 10:56:04 +08:00
< template >
< div class = "seckill" >
< Card >
< Row >
2021-06-04 17:35:59 +08:00
< Form ref = "searchForm" :model = "searchForm" inline :label-width = "70" class = "search-form" >
2021-05-13 10:56:04 +08:00
< Form-item label = "活动名称" prop = "promotionName" >
2021-06-04 17:35:59 +08:00
< Input type = "text" v-model = "searchForm.promotionName" placeholder="请输入活动名称" clearable style="width: 200px" / >
2021-05-13 10:56:04 +08:00
< / Form-item >
< Form-item label = "活动状态" prop = "promotionStatus" >
2021-06-04 17:35:59 +08:00
< Select v-model = "searchForm.promotionStatus" placeholder="请选择" clearable style="width: 200px" >
2021-05-13 10:56:04 +08:00
< Option value = "NEW" > 未开始 < / Option >
< Option value = "START" > 已开始 / 上架 < / Option >
< Option value = "END" > 已结束 / 下架 < / Option >
< Option value = "CLOSE" > 紧急关闭 / 作废 < / Option >
< / Select >
< / Form-item >
< Form-item label = "活动时间" >
2021-06-04 17:35:59 +08:00
< DatePicker v-model = "selectDate" type="daterange" clearable placeholder="选择起始时间" style="width: 200px" > < / DatePicker >
2021-05-13 10:56:04 +08:00
< / Form-item >
2021-06-04 17:35:59 +08:00
< Button @click ="handleSearch" type = "primary" icon = "ios-search" class = "search-btn" > 搜索 < / Button >
2021-05-13 10:56:04 +08:00
< / Form >
< / Row >
2021-08-05 18:07:11 +08:00
< Tabs value = "list" class = "mt_10" @on-click ="clickTabPane" >
2021-06-22 18:11:23 +08:00
< TabPane label = "秒杀活动列表" name = "list" >
2021-07-20 14:06:53 +08:00
< Table :loading = "loading" border :columns = "columns" :data = "data" ref = "table" class = "mt_10" >
2021-06-22 18:11:23 +08:00
< template slot -scope = " { row } " slot = "action" >
< Button type = "info" size = "small" class = "mr_5" v-if = "row.promotionStatus == 'NEW'" @click="edit(row)" > 编辑 < / Button >
2021-06-03 11:51:39 +08:00
2021-06-22 18:11:23 +08:00
< Button type = "info" size = "small" class = "mr_5" v -else @click ="manage(row)" > 查看 < / Button >
2021-06-03 11:47:34 +08:00
2021-08-05 18:07:11 +08:00
< Button type = "success" size = "small" class = "mr_5" v-if = "row.promotionStatus == 'NEW'" @click="manage(row)" > 管理 < / Button >
2021-06-03 11:47:34 +08:00
2021-06-22 18:11:23 +08:00
< Button type = "error" size = "small" v -if = "
row . promotionStatus == 'START' || row . promotionStatus == 'NEW'
" class=" mr _5 " @click=" off ( row ) " > 下架 < / Button >
& nbsp ;
< Button type = "error" size = "small" v-if = "row.promotionStatus == 'CLOSE'" ghost @click="expire(row)" > 删除 < / Button >
< / template >
< / Table >
2021-07-20 14:06:53 +08:00
< Row type = "flex" justify = "end" class = "mt_10" >
2021-06-22 18:11:23 +08:00
< Page style = "margin: 20px 0;" :current = "searchForm.pageNumber" :total = "total" :page-size = "searchForm.pageSize" @on-change ="changePage" @on-page-size-change ="changePageSize"
: page - size - opts = "[10, 20, 50]" size = "small" show - total show - elevator show - sizer > < / Page >
< / Row >
< / TabPane >
< TabPane label = "秒杀活动设置" name = "setup" >
< setupSeckill v-if = "setupFlag" > < / setupSeckill >
< / TabPane >
< / Tabs >
2021-06-03 11:51:39 +08:00
2021-05-13 10:56:04 +08:00
< / Card >
< / div >
< / template >
< script >
import { getSeckillList , delSeckill , closeSeckill } from "@/api/promotion" ;
2021-06-04 17:35:59 +08:00
import setupSeckill from "@/views/promotion/seckill/setupSeckill" ;
2021-05-13 10:56:04 +08:00
export default {
name : "seckill" ,
2021-06-04 17:35:59 +08:00
components : {
2021-07-26 18:12:13 +08:00
setupSeckill
2021-06-04 17:35:59 +08:00
} ,
2021-05-13 10:56:04 +08:00
data ( ) {
return {
loading : true , // 表单加载状态
searchForm : {
// 搜索框初始化对象
2021-06-04 17:35:59 +08:00
pageNumber : 1 , // 当前页数
2021-05-13 10:56:04 +08:00
pageSize : 10 , // 页面大小
sort : "startTime" ,
order : "desc" , // 默认排序方式
} ,
2021-06-04 17:35:59 +08:00
setupFlag : false , //默认不请求设置
columns : [
// 表单
2021-05-13 10:56:04 +08:00
{
title : "活动名称" ,
key : "promotionName" ,
minWidth : 130 ,
tooltip : true ,
} ,
{
title : "开始时间" ,
key : "startTime" ,
width : 180 ,
} ,
{
title : "申请截止时间" ,
key : "applyEndTime" ,
width : 180 ,
} ,
{
title : "活动状态" ,
key : "promotionStatus" ,
width : 100 ,
render : ( h , params ) => {
if ( params . row . promotionStatus == "NEW" ) {
2021-06-23 15:22:07 +08:00
return h ( "Tag" , { props : { color : "geekblue" , } , } , "新建" ) ;
2021-05-13 10:56:04 +08:00
} else if ( params . row . promotionStatus == "START" ) {
2021-06-23 15:22:07 +08:00
return h ( "Tag" , { props : { color : "green" , } , } , "开始" ) ;
2021-05-13 10:56:04 +08:00
} else if ( params . row . promotionStatus == "END" ) {
2021-06-23 00:21:17 +08:00
return h ( "Tag" , { props : { color : "volcano" , } , } , "结束" ) ;
2021-06-23 15:22:07 +08:00
} else if ( params . row . promotionStatus == "CLOSE" ) {
return h ( "Tag" , { props : { color : "red" , } , } , "结束" ) ;
2021-05-13 10:56:04 +08:00
}
} ,
} ,
{
title : "申请规则" ,
key : "seckillRule" ,
minWidth : 120 ,
tooltip : true ,
} ,
{
title : "操作" ,
slot : "action" ,
align : "center" ,
width : 250 ,
} ,
] ,
data : [ ] , // 表单数据
total : 0 , // 表单数据总数
} ;
} ,
methods : {
2021-07-26 18:12:13 +08:00
// tab栏点击切换列表和设置
2021-06-04 17:35:59 +08:00
clickTabPane ( name ) {
if ( name == "setup" ) {
this . setupFlag = true ;
} else {
this . setupFlag = false ;
}
} ,
// 初始化信息
2021-05-13 10:56:04 +08:00
init ( ) {
this . getDataList ( ) ;
} ,
2021-07-26 18:12:13 +08:00
// 分页 改变页码
2021-05-13 10:56:04 +08:00
changePage ( v ) {
2021-06-04 17:35:59 +08:00
this . searchForm . pageNumber = v ;
2021-05-13 10:56:04 +08:00
this . getDataList ( ) ;
} ,
2021-07-26 18:12:13 +08:00
// 分页 改变页数
2021-05-13 10:56:04 +08:00
changePageSize ( v ) {
2021-07-26 18:12:13 +08:00
this . searchForm . pageNumber = 1 ;
2021-05-13 10:56:04 +08:00
this . searchForm . pageSize = v ;
this . getDataList ( ) ;
} ,
2021-07-26 18:12:13 +08:00
// 搜索
2021-05-13 10:56:04 +08:00
handleSearch ( ) {
2021-07-26 18:12:13 +08:00
this . searchForm . pageNumber = 1 ;
2021-05-13 10:56:04 +08:00
this . searchForm . pageSize = 10 ;
this . getDataList ( ) ;
} ,
edit ( v ) {
// 编辑
this . $router . push ( { name : "manager-seckill-add" , query : { id : v . id } } ) ;
} ,
manage ( v ) {
// 管理
this . $router . push ( { name : "seckill-goods" , query : { id : v . id } } ) ;
} ,
off ( v ) {
// 下架
this . $Modal . confirm ( {
title : "提示" ,
content : "您确定要下架该活动吗?" ,
onOk : ( ) => {
closeSeckill ( v . id ) . then ( ( res ) => {
if ( res . success ) {
this . $Message . success ( "下架成功" ) ;
this . getDataList ( ) ;
}
} ) ;
} ,
} ) ;
} ,
expire ( v ) {
// 作废
this . $Modal . confirm ( {
title : "提示" ,
content : "您确定要作废该活动吗?" ,
onOk : ( ) => {
delSeckill ( v . id ) . then ( ( res ) => {
if ( res . success ) {
this . $Message . success ( "作废成功" ) ;
this . getDataList ( ) ;
}
} ) ;
} ,
} ) ;
} ,
2021-06-04 17:35:59 +08:00
// 获取数据集合
2021-05-13 10:56:04 +08:00
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 ;
}
// 带多条件搜索参数获取表单数据
getSeckillList ( this . searchForm ) . then ( ( res ) => {
this . loading = false ;
if ( res . success ) {
this . data = res . result . records ;
this . total = res . result . total ;
}
} ) ;
} ,
} ,
mounted ( ) {
this . init ( ) ;
} ,
} ;
< / script >
< style lang = "scss" >
2021-06-22 18:11:23 +08:00
. mr _5 {
margin : 0 5 px ;
2021-06-03 11:47:34 +08:00
}
2021-05-13 10:56:04 +08:00
< / style >