Files
dvcp_v2_webapp/project/tianfuxing/AppActivitiesManagement/components/activitiesList.vue

144 lines
4.2 KiB
Vue
Raw Normal View History

2022-11-01 16:01:41 +08:00
<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>
2022-11-02 16:11:19 +08:00
<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="qrcode" width="200px" label="二维码" align="center">
<template slot-scope="{ row }">
<div class="qrcode">
<el-button type="text" @click="qrcode(row.qrCode, row.id)">{{ row.qrCode ? '预览' : '生成' }}</el-button>
</div>
</template>
</el-table-column>
2022-11-01 16:01:41 +08:00
<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>
2022-11-02 15:16:14 +08:00
<el-button type="text" :disabled="row.status ==2" @click.native="stopBtn(row.id)">结束</el-button>
2022-11-01 18:25:16 +08:00
<el-button type="text" @click.native="handleDelete(row.id)">删除</el-button>
2022-11-01 16:01:41 +08:00
</template>
</el-table-column>
</ai-table>
2022-11-02 16:11:19 +08:00
<div class="qrCode" v-viewer="{movable: true}" v-show="false">
<img :src="img">
</div>
2022-11-01 16:01:41 +08:00
</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: [],
2022-11-02 16:11:19 +08:00
img: '',
isLoading: false,
2022-11-01 16:01:41 +08:00
}
},
created () {
2022-11-03 10:22:49 +08:00
this.$dict.load('tfx_activityStatus').then(()=> {
2022-11-01 16:01:41 +08:00
this.getList()
})
},
computed: {
colConfigs() {
return [
2022-11-01 18:25:16 +08:00
{prop: "title", label: "活动名称", align: "left", showOverflowTooltip: true},
{prop: "createUserName", label: "创建人", align: "center"},
2022-11-03 10:14:09 +08:00
{prop: "intoBegintime", label: "开始结束时间", align: "center", width: "400px", render: (h, {row}) => h('p',{textAlign:'center'},
2022-11-01 18:25:16 +08:00
`${row.intoBegintime}${row.exitEndtime}`)},
2022-11-03 10:22:49 +08:00
{prop: "status", label: "活动状态", align: "center", dict:"tfx_activityStatus"},
2022-11-02 16:11:19 +08:00
{ slot: "qrcode"},
2022-11-01 16:01:41 +08:00
{ slot: "options", },
]
}
},
methods: {
getList() {
2022-11-03 10:14:09 +08:00
this.instance.post(`api/appactivityinfo/list`,null, {
2022-11-01 16:01:41 +08:00
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 || '',
}
})
},
2022-11-02 16:11:19 +08:00
qrcode (qrcode, id) {
if (!qrcode) {
this.isLoading = true
2022-11-03 10:14:09 +08:00
this.instance.post(`api/appactivityinfo/generateQrCode?id=${id}&width=400&height=400`).then(res => {
2022-11-02 16:11:19 +08:00
if (res.code == 0) {
this.$message.success('二维码生成成功!')
this.getList()
}
this.isLoading = false
})
} else {
this.img = qrcode
this.$nextTick(() => {
setTimeout(() => {
const viewer = this.$el.querySelector('.qrCode').$viewer
viewer.view()
}, 600)
})
}
},
2022-11-01 16:01:41 +08:00
handleDelete(id) {
2022-11-02 15:16:14 +08:00
this.$confirm('确定删除该活动?').then(() => {
2022-11-03 10:14:09 +08:00
this.instance.post(`api/appactivityinfo/delete?ids=${id}`).then(res=>{
2022-11-01 16:01:41 +08:00
if(res.code == 0) {
this.$message.success('删除成功!')
this.getList()
}
})
})
},
2022-11-02 15:16:14 +08:00
// 结束
stopBtn(id) {
this.$confirm('确定要结束该活动吗?').then(() => {
2022-11-03 10:14:09 +08:00
this.instance.post(`api/appactivityinfo/stop?id=${id}`).then(res=>{
2022-11-01 16:01:41 +08:00
if(res.code == 0) {
2022-11-02 15:16:14 +08:00
this.$message.success('结束成功!')
2022-11-01 16:01:41 +08:00
this.getList()
}
})
})
},
}
}
</script>
<style lang="scss" scoped>
.activitiesList {
height: 100%;
}
</style>