122 lines
3.5 KiB
Vue
122 lines
3.5 KiB
Vue
<template>
|
|
<section class="activitiesList">
|
|
<ai-list>
|
|
<ai-title slot="title" title="活动管理" isShowBottomBorder />
|
|
<template #content>
|
|
<ai-search-bar>
|
|
<template #left>
|
|
<el-button size="small" type="primary" icon="iconfont iconAdd" @click="toAdd('')" >创建活动</el-button>
|
|
</template>
|
|
</ai-search-bar>
|
|
<ai-table :tableData="tableData" :total="page.total" :current.sync="page.current" :size.sync="page.size" @getList="getList" :col-configs="colConfigs" :dict="dict">
|
|
<el-table-column slot="options" label="操作" fixed="right" align="center">
|
|
<template slot-scope="{ row }">
|
|
<el-button type="text" @click.native="toAdd(row.id)">详情</el-button>
|
|
<el-button type="text" v-show="row.status!=2" :disabled="row.status==2" @click.native="startEnd(row.id, row.status)">{{row.status == 0? '开启':'结束'}}</el-button>
|
|
<el-button type="text" @click.native="handleDelete(row.id)">删除</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
</ai-table>
|
|
</template>
|
|
</ai-list>
|
|
</section>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
name: 'activitiesList',
|
|
props: {
|
|
instance: Function,
|
|
dict: Object
|
|
},
|
|
data () {
|
|
return {
|
|
page: {
|
|
current: 1,
|
|
size: 10,
|
|
total: 0,
|
|
},
|
|
tableData: [],
|
|
}
|
|
},
|
|
created () {
|
|
this.$dict.load('electionStatus', 'electionMethod').then(()=> {
|
|
this.getList()
|
|
})
|
|
},
|
|
computed: {
|
|
colConfigs() {
|
|
return [
|
|
{prop: "title", label: "活动名称", align: "left", showOverflowTooltip: true},
|
|
{prop: "createUserName", label: "创建人", align: "center"},
|
|
{prop: "intoBegintime", label: "开始结束时间", align: "center", render: (h, {row}) => h('p',{textAlign:'center'},
|
|
`${row.intoBegintime}至${row.exitEndtime}`)},
|
|
{prop: "status", label: "活动状态", align: "center",dict:"electionMethod"},
|
|
{ slot: "options", },
|
|
]
|
|
}
|
|
},
|
|
methods: {
|
|
getList() {
|
|
this.instance.post(`/appactivityinfo/list`,null, {
|
|
params: {
|
|
...this.page,
|
|
}
|
|
}).then(res=> {
|
|
if(res?.data) {
|
|
this.tableData = res.data.records
|
|
this.page.total = res.data.total
|
|
}
|
|
})
|
|
},
|
|
toAdd(id) {
|
|
this.$emit('change', {
|
|
type: 'activitiesAdd',
|
|
params: {
|
|
id: id || '',
|
|
}
|
|
})
|
|
},
|
|
handleDelete(id) {
|
|
this.$confirm('确定删除该数据?').then(() => {
|
|
this.instance.post(`/appactivityinfo/delete?ids=${id}`).then(res=>{
|
|
if(res.code == 0) {
|
|
this.$message.success('删除成功!')
|
|
this.getList()
|
|
}
|
|
})
|
|
})
|
|
},
|
|
// 开启、结束
|
|
startEnd(id, status) {
|
|
let title = ''
|
|
let bool = null
|
|
let tips = ''
|
|
if(status == 0) {
|
|
title = '未到投票开始时间,确定要提前开始吗?'
|
|
bool = true
|
|
tips = '开启成功'
|
|
} else if(status == 1) {
|
|
title = '投票正在进行中,确定要提前结束吗?'
|
|
bool = false
|
|
tips = '结束成功'
|
|
}
|
|
this.$confirm(title).then(() => {
|
|
this.instance.post(`/app/appgeneralelectioninfo/start-end?id=${id}&start=${bool}`).then(res=>{
|
|
if(res.code == 0) {
|
|
this.$message.success(tips)
|
|
this.getList()
|
|
}
|
|
})
|
|
})
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.activitiesList {
|
|
height: 100%;
|
|
}
|
|
</style>
|