155 lines
		
	
	
		
			4.2 KiB
		
	
	
	
		
			Vue
		
	
	
	
	
	
			
		
		
	
	
			155 lines
		
	
	
		
			4.2 KiB
		
	
	
	
		
			Vue
		
	
	
	
	
	
| <template>
 | |
|   <ai-list class="notice">
 | |
|     <template slot="title">
 | |
|       <ai-title title="活动管理" isShowBottomBorder>
 | |
|       </ai-title>
 | |
|     </template>
 | |
|     <template slot="content">
 | |
|       <ai-search-bar class="search-bar">
 | |
|         <template #left>
 | |
|           <ai-select
 | |
|             v-model="search.status"
 | |
|             clearable
 | |
|             placeholder="请选择活动状态"
 | |
|             :selectList="statusList"
 | |
|             @change="search.current = 1, getList()">
 | |
|           </ai-select>
 | |
|           <el-button size="small" type="primary" icon="iconfont iconAdd" @click="toAdd('')">添加</el-button>
 | |
|         </template>
 | |
|         <template #right>
 | |
|           <el-input
 | |
|             v-model="search.title"
 | |
|             class="search-input"
 | |
|             size="small"
 | |
|             v-throttle="() => {search.current = 1, getList()}"
 | |
|             placeholder="请选择活动标题"
 | |
|             clearable
 | |
|             @clear="search.current = 1, search.province = '', getList()"
 | |
|             suffix-icon="iconfont iconSearch">
 | |
|           </el-input>
 | |
|         </template>
 | |
|       </ai-search-bar>
 | |
|       <ai-table
 | |
|         :tableData="tableData"
 | |
|         :col-configs="colConfigs"
 | |
|         :total="total"
 | |
|         style="margin-top: 6px;"
 | |
|         :current.sync="search.current"
 | |
|         :size.sync="search.size"
 | |
|         @getList="getList">
 | |
|         <el-table-column slot="options" width="180px" fixed="right" label="操作" align="center">
 | |
|           <template slot-scope="{ row }">
 | |
|             <div class="table-options">
 | |
|               <el-button type="text" @click="toAdd(row.id)">编辑</el-button>
 | |
|               <el-button type="text" @click="toDetail(row.id)">详情</el-button>
 | |
|               <el-button type="text" @click="stop(row.id, row.status)">{{ row.status === '1' ? '关闭' : '开启' }}</el-button>
 | |
|               <el-button type="text" @click="remove(row.id)">删除</el-button>
 | |
|             </div>
 | |
|           </template>
 | |
|         </el-table-column>
 | |
|       </ai-table>
 | |
|     </template>
 | |
|   </ai-list>
 | |
| </template>
 | |
| 
 | |
| <script>
 | |
|   export default {
 | |
|     name: 'List',
 | |
| 
 | |
|     props: {
 | |
|       instance: Function,
 | |
|       dict: Object
 | |
|     },
 | |
| 
 | |
|     data () {
 | |
|       return {
 | |
|         search: {
 | |
|           current: 1,
 | |
|           size: 10,
 | |
|           title: '',
 | |
|           status: ''
 | |
|         },
 | |
|         total: 10,
 | |
|         colConfigs: [
 | |
|           { prop: 'title',  label: '活动标题', align: 'left', width: '200px' },
 | |
|           { prop: 'signUpCount', label: '报名人数', align: 'center', format: e => e },
 | |
|           { prop: 'status', label: '活动状态', align: 'center', format: e => this.statusList.filter(v => v.dictValue === e)[0].dictName }
 | |
|         ],
 | |
|         tableData: [],
 | |
|         statusList: [
 | |
|           {
 | |
|             dictValue: '1',
 | |
|             dictName: '进行中'
 | |
|           },
 | |
|           {
 | |
|             dictValue: '2',
 | |
|             dictName: '已结束'
 | |
|           }
 | |
|         ]
 | |
|       }
 | |
|     },
 | |
| 
 | |
|     created() {
 | |
|       this.getList()
 | |
|     },
 | |
| 
 | |
|     methods: {
 | |
|       getList() {
 | |
|         this.instance.post(`/app/appactivityinfo/list`, null, {
 | |
|           params: {
 | |
|             ...this.search
 | |
|           }
 | |
|         }).then(res => {
 | |
|           if (res.code == 0) {
 | |
|             this.tableData = res.data.records
 | |
|             this.total = res.data.total
 | |
|           }
 | |
|         })
 | |
|       },
 | |
| 
 | |
|       stop (id, status) {
 | |
|         this.$confirm(status === '1' ? '确认关闭该活动?' : '确认开启该活动?').then(() => {
 | |
|           this.instance.post(`/app/appactivityinfo/stop?id=${id}`).then(res => {
 | |
|             if (res.code == 0) {
 | |
|               this.$message.success('操作成功!')
 | |
|               this.getList()
 | |
|             }
 | |
|           })
 | |
|         })
 | |
|       },
 | |
| 
 | |
|       remove (id) {
 | |
|         this.$confirm('确定删除该活动?').then(() => {
 | |
|           this.instance.post(`/app/appactivityinfo/delete?ids=${id}`).then(res => {
 | |
|             if (res.code == 0) {
 | |
|               this.$message.success('删除成功!')
 | |
|               this.getList()
 | |
|             }
 | |
|           })
 | |
|         })
 | |
|       },
 | |
| 
 | |
|       toDetail (id) {
 | |
|         this.$emit('change', {
 | |
|           type: 'Detail',
 | |
|           params: {
 | |
|             id: id || ''
 | |
|           }
 | |
|         })
 | |
|       },
 | |
| 
 | |
|       toAdd(id) {
 | |
|         this.$emit('change', {
 | |
|           type: 'Add',
 | |
|           params: {
 | |
|             id: id || ''
 | |
|           }
 | |
|         })
 | |
|       }
 | |
|     }
 | |
|   }
 | |
| </script>
 | |
| 
 | |
| <style lang="scss" scoped>
 | |
| </style>
 |