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

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

View File

@ -83,11 +83,20 @@
<el-table-column
align="center"
width="180"
width="320"
label="操作"
fixed="right"
>
<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">
<el-button
type="primary"
@ -127,8 +136,8 @@ import { IShopData } from '@/api/types'
import Pagination from '@/components/Pagination/index.vue'
import { getShops } from '@/api/shop'
import { parseTime } from '@/utils'
import { getAllCategory, getAllTags, IQuestionData } from '@/api/question'
import { deleteActivity, getActivitys } from '@/api/activity'
import { getAllCategory, getAllTags } from '@/api/question'
import { deleteActivity, getActivitys, publishActivity, IActivityData } from '@/api/activity'
import { UserModule } from '@/store/modules/user'
@Component({
@ -157,7 +166,7 @@ import { UserModule } from '@/store/modules/user'
export default class extends Vue {
private total = 0
private list: IQuestionData[] = []
private list: IActivityData[] = []
private listLoading = true
private allDepts: IShopData[] = []
private listQuery = {
@ -277,5 +286,26 @@ export default class extends Vue {
private formatBool(row: number, column: number, cellValue: boolean) {
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>