活动类表增加激活和冻结功能

This commit is contained in:
zhl 2021-05-19 16:24:24 +08:00
parent 364af18667
commit 344f7b002b
2 changed files with 49 additions and 14 deletions

View File

@ -2,10 +2,10 @@
import request from '@/utils/request' import request from '@/utils/request'
export interface IRewardData { export interface IRewardData {
id?: number, id?: number
rank?: number, rank?: number
rankEnd?: number, rankEnd?: number
coupon?: string, coupon?: string
count?: number count?: number
} }
@ -21,10 +21,10 @@ export interface IActivityData {
weekDays: number[] weekDays: number[]
beginTime: number[] beginTime: number[]
prepareTime: number prepareTime: number
active: number, active: boolean
beginDays: number[], beginDays: number[]
beginDay?: number, beginDay?: number
endDay?: number, endDay?: number
rewardInfo: IRewardData[] rewardInfo: IRewardData[]
} }
@ -34,7 +34,7 @@ export const defaultRewardData: IRewardData = {
export const defaultActivityData: IActivityData = { export const defaultActivityData: IActivityData = {
beginDays: [], beginDays: [],
active: 0, active: false,
beginTime: [], beginTime: [],
monthDays: [], monthDays: [],
weekDays: [], weekDays: [],
@ -62,7 +62,6 @@ export const getActivity = (id: string, params: any) =>
params params
}) })
export const saveActivity = (data: any) => export const saveActivity = (data: any) =>
request({ request({
url: '/activity/save', url: '/activity/save',
@ -76,3 +75,9 @@ export const deleteActivity = (id: string) =>
method: 'post' method: 'post'
}) })
export const publishActivity = (data: any) =>
request({
url: '/activity/publish',
method: 'post',
data
})

View File

@ -83,11 +83,20 @@
<el-table-column <el-table-column
align="center" align="center"
width="180" width="320"
label="操作" label="操作"
fixed="right" fixed="right"
> >
<template slot-scope="scope"> <template slot-scope="scope">
<el-button
:type="scope.row.active? 'warning': 'success'"
size="small"
style="margin-right: 10px"
v-permission="['activity:edit']"
@click="updateActivityStata(scope)"
>
{{ scope.row.active? '冻结': '激活' }}
</el-button>
<router-link :to="'/shop/activity_edit/'+scope.row._id"> <router-link :to="'/shop/activity_edit/'+scope.row._id">
<el-button <el-button
type="primary" type="primary"
@ -127,8 +136,8 @@ import { IShopData } from '@/api/types'
import Pagination from '@/components/Pagination/index.vue' import Pagination from '@/components/Pagination/index.vue'
import { getShops } from '@/api/shop' import { getShops } from '@/api/shop'
import { parseTime } from '@/utils' import { parseTime } from '@/utils'
import { getAllCategory, getAllTags, IQuestionData } from '@/api/question' import { getAllCategory, getAllTags } from '@/api/question'
import { deleteActivity, getActivitys } from '@/api/activity' import { deleteActivity, getActivitys, publishActivity, IActivityData } from '@/api/activity'
import { UserModule } from '@/store/modules/user' import { UserModule } from '@/store/modules/user'
@Component({ @Component({
@ -157,7 +166,7 @@ import { UserModule } from '@/store/modules/user'
export default class extends Vue { export default class extends Vue {
private total = 0 private total = 0
private list: IQuestionData[] = [] private list: IActivityData[] = []
private listLoading = true private listLoading = true
private allDepts: IShopData[] = [] private allDepts: IShopData[] = []
private listQuery = { private listQuery = {
@ -277,5 +286,26 @@ export default class extends Vue {
private formatBool(row: number, column: number, cellValue: boolean) { private formatBool(row: number, column: number, cellValue: boolean) {
return cellValue ? '是' : '否' return cellValue ? '是' : '否'
} }
private async updateActivityStata(scope: any) {
const { row } = scope
const str = row.active ? '确认取消冻结该活动?' : '确定激活该活动?'
try {
await this.$confirm(str, 'Warning', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
await publishActivity({ id: row._id, active: !row.active })
row.active = !row.active
if (row.active) {
for (const _d of this.list) {
_d.active = _d._id === row._id
}
}
} catch (err) {
console.log(err)
}
}
} }
</script> </script>