Files
huangguo_admin/src/views/activity/noviceTaskCfg/index.vue
T
2025-06-10 17:11:41 +07:00

238 lines
8.3 KiB
Vue

<template>
<div class="pf-warpper avlist">
<el-row class="table-form">
<el-form :inline="true" :model="searchData" class="form-inline" size="mini">
<el-form-item label="任务类型">
<el-select placeholder="请选择任务类型" clearable v-model="searchData.type" style="width: 163px">
<el-option v-for="item in missioncfgTaskType" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item>
<el-button @click="add" icon="el-icon-circle-plus-outline" plain type="success">新增</el-button>
<el-button @click="refreshView" icon="el-icon-refresh" plain type="info">刷新</el-button>
</el-form-item>
</el-form>
</el-row>
<el-row>
<el-col>
<el-table :data="resData" element-loading-text="拼命加载中" border height="750" highlight-current-row style="width: 100%" v-loading="loading">
<el-table-column align="center" label="ID">
<template slot-scope="scope">{{ scope.row.id }}</template>
</el-table-column>
<el-table-column align="center" label="排序">
<template slot-scope="scope">{{ scope.row.rank }}</template>
</el-table-column>
<el-table-column align="center" label="标题" width="150">
<template slot-scope="scope">{{ scope.row.title }}</template>
</el-table-column>
<el-table-column align="center" label="图标" width="150">
<template slot-scope="scope">
<ShowImg style="width: 100px; height: 40px; margin: 0 auto" :urls="scope.row.icon"></ShowImg>
</template>
</el-table-column>
<el-table-column align="center" label="奖品名称" width="150">
<template slot-scope="scope">
<el-tag v-for="item in scope.row.prizeIds">
{{item |changeName(checkinPrizeList,'id','title') }}
</el-tag>
</template>
</el-table-column>
<el-table-column align="center" label="类型" width="150">
<template slot-scope="scope">{{ scope.row.category | changTaskCfgType }}</template>
</el-table-column>
<el-table-column align="center" label="跳转地址" width="300">
<template slot-scope="scope">{{ scope.row.jumpUrl }}</template>
</el-table-column>
<el-table-column align="center" label="描述" width="200">
<template slot-scope="scope">{{ scope.row.desc }}</template>
</el-table-column>
<el-table-column align="center" label="跳转链接" width="200">
<template slot-scope="scope">{{ scope.row.goTo }}</template>
</el-table-column>
<el-table-column align="center" label="目标参数">
<template slot-scope="scope">{{
scope.row.count
}}</template>
</el-table-column>
<el-table-column align="center" label="任务类型">
<template slot-scope="scope">{{
scope.row.type|changeMissioncfgTaskType
}}</template>
</el-table-column>
<el-table-column align="center" label="是否激活" width="100">
<template slot-scope="scope">
<el-button :type="scope.row.enable ? 'success' : 'danger'" plain size="mini">{{ scope.row.enable ? "已激活" : "未激活" }}</el-button>
</template>
</el-table-column>
<el-table-column align="center" label="是否自动发奖" width="100">
<template slot-scope="scope">
<el-button :type="scope.row.autoPrize ? 'success' : 'danger'" plain size="mini">{{ scope.row.autoPrize ? "是" : "否" }}</el-button>
</template>
</el-table-column>
<el-table-column align="center" label="创建时间" width="160">
<template slot-scope="scope">{{
scope.row.createdAt | BeiJingTime
}}</template>
</el-table-column>
<el-table-column align="center" label="更新时间" width="160">
<template slot-scope="scope">{{
scope.row.updatedAt | BeiJingTime
}}</template>
</el-table-column>
<el-table-column align="center" fixed="right" label="操作" width="180">
<template slot-scope="scope">
<el-button @click="handleEdit(scope.$index, scope.row)" size="mini" type="primary">编辑</el-button>
<el-button @click="handleDelete(scope.$index, scope.row)" size="mini" type="danger">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-col>
</el-row>
<div class="table-pagination">
<el-pagination :current-page="searchData.pageNum" :page-size="searchData.pageSize" :page-sizes="[10, 20, 30, 50, 100]" :total="total" @current-change="handleCurrentChange" @size-change="handleSizeChange" layout="total, sizes, prev, pager, next, jumper" />
</div>
<!-- 新增及编辑 -->
<Edit :taskCfgType="taskCfgType" :missioncfgTaskType="missioncfgTaskType" :checkinPrizeList="checkinPrizeList" :data="editData" v-if="editVisible" @close="closeEdit" />
</div>
</template>
<script>
// 引入模块
import Edit from './components/AddOrEdit'
import { noviceTaskDel, noviceTaskSearch } from '@/api/activity/noviceTaskCfg'
import ShowImg from '@/components/ShowImg/index.vue'
import { prizeList } from '@/api/activity/prize';
import { taskCfgType, missioncfgTaskType } from '@/filters/activity/missionList'
export default {
name: 'NoviceTaskCfg',
components: {
Edit,
ShowImg
},
data() {
return {
// 请求列表参数
searchData: {
pageNum: 1,
pageSize: 20,
type:undefined,
},
taskCfgType: taskCfgType(),
missioncfgTaskType: missioncfgTaskType(),
checkinPrizeList:[],
resData: [], // el-table表格数据
editVisible: false, // 新增或编辑弹出框
total: 0, // 数据总条数
loading: true, // 列表加载状态
// 编辑数据
editData: {
title: '新增',
data: {},
},
}
},
mounted() {
this.getPrizeList()
this.getList()
},
methods: {
// TODO:请求奖品列表数据
getPrizeList() {
prizeList(this.searchData).then(res => {
if (res.code === 200) {
this.checkinPrizeList = res.data.list;
} else {
this.checkinPrizeList = [];
this.$message.error('请求列表失败!');
}
this.loading = false;
});
},
// TODO:请求任务配置列表数据
getList() {
this.loading = true
noviceTaskSearch(this.searchData).then((res) => {
if (res.code === 200) {
this.resData = res.data.list
this.total = res.data.total
} else {
this.$message.error('请求列表失败!')
this.resData = []
this.total = 0
}
this.loading = false
})
},
//TODO:删除任务配置列表数据
handleDelete(index, row) {
this.$confirm('确定删除?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(() => {
noviceTaskDel({ id: row.id }).then((res) => {
if (res.code === 200) {
this.getList()
this.$message.success('成功删除!')
} else {
this.$message.error('操作失败')
}
})
})
},
onSearch() {
this.getList()
},
// 刷新数据
refreshView() {
this.getList()
},
// 新增按钮
add() {
this.editVisible = true
this.editData = {
title: '新增',
data: {},
}
},
// 编辑按钮
handleEdit(index, row) {
this.editVisible = true
this.editData = {
title: '编辑',
data: row,
}
},
// 关闭编辑弹窗
closeEdit() {
this.editData = {
title: '新增',
data: {},
}
this.editVisible = false
this.refreshView()
},
// 切换每页数据量
handleSizeChange(val) {
this.searchData.page.pageSize = val
this.getList()
},
// 切换页数
handleCurrentChange(val) {
this.searchData.page.pageNum = val
this.getList()
},
},
}
</script>