| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- <com-list-page :crumbs="crumbs" id="application">
- <com-list-table
- ref="table"
- :api-params="apiParams"
- :search-list="searchList"
- @get-api-data="setApiData"
- >
- <template slot="header-left">
- <el-button
- type="primary"
- size="mini"
- @click="$navigate({r: 'rebate/index/edit'})"
- icon="el-icon-plus"
- >添加活动</el-button>
- </template>
- <el-table-column prop="id" min-width="30" label="序号" align="center"></el-table-column>
- <el-table-column prop="title" label="活动名称" min-width="60" align="center"></el-table-column>
- <el-table-column label="活动时间" min-width="150" align="center">
- <template slot-scope="scope">
- {{ scope.row.start_date}} 至 {{ scope.row.end_date }}
- </template>
- </el-table-column>
- <el-table-column prop="reward_type" label="类型" align="center">
- <template slot-scope="scope">
- {{ reward_type_arr[scope.row.reward_type] }}
- </template>
- </el-table-column>
- <el-table-column label="状态" align="center">
- <template slot-scope="scope">
- <el-tag type="danger" v-if="scope.row.status == 0">停用中</el-tag>
- <el-tag type="success" v-else-if="scope.row.start_at < now_time && scope.row.end_at > now_time">进行中</el-tag>
- <el-tag v-else-if="scope.row.start_at > now_time">未开始</el-tag>
- <el-tag type="info" v-else>已过期</el-tag>
- </template>
- </el-table-column>
- <el-table-column label="参与人数" min-width="50" align="center">
- <template slot-scope="scope">
- {{ scope.row.statistics ? scope.row.statistics.join_num : 0 }}
- </template>
- </el-table-column>
- <el-table-column label="成交金额" min-width="50" align="center">
- <template slot-scope="scope">
- {{ scope.row.statistics ? scope.row.statistics.pay_money : 0 }}
- </template>
- </el-table-column>
- <el-table-column label="订单数" min-width="50" align="center">
- <template slot-scope="scope">
- {{ scope.row.statistics ? scope.row.statistics.pay_num : 0 }}
- </template>
- </el-table-column>
- <el-table-column prop="created_at" label="创建时间" min-width="70" align="center">
- <template slot-scope="scope">
- {{ scope.row.created_at | dateTimeFormat('Y-m-d H:i') }}
- </template>
- </el-table-column>
- <el-table-column label="操作" align="center">
- <template slot-scope="scope">
- <el-button type="text" v-if="scope.row.status == 1" @click="handle('operate', {id:scope.row.id, status:0, name:'停用'})">停用</el-button>
- <el-button type="text" v-if="scope.row.status == 0" @click="handle('operate', {id:scope.row.id, item_id:scope.row.item_id, status:1, name:'启用'})">启用</el-button>
- <el-button type="text" @click="handle('edit',scope.row)">编辑</el-button>
- <el-button type="text" @click="handle('log',scope.row)">奖励记录</el-button>
- <el-button type="text" @click="handle('activity_log',scope.row)">活动记录</el-button>
- <el-button type="text" @click="handle('destroy',scope.row)">删除</el-button>
- </template>
- </el-table-column>
- </com-list-table>
- </com-list-page>
- <script>
- const application = new Vue({
- el: '#application',
- data: {
- apiParams: {
- r: 'rebate/index/index',
- },
- crumbs: [
- {
- title: '首页',
- router: 'mall/overview/index',
- },
- {
- title: '推三返一',
- },
- ],
- searchList: [
- {
- key: 'title',
- title: '活动名称',
- type: 'text',
- },
- {
- key: 'reward_type',
- title: '类型',
- type: 'select',
- options: [
- {
- label: '条件奖励',
- value: 1
- },
- {
- label: '阶梯奖励',
- value: 2
- },
- ],
- },
- {
- key: 'status',
- title: '状态',
- type: 'select',
- options: [
- {
- label: '全部',
- value: 0
- },
- {
- label: '进行中',
- value: 1
- },
- {
- label: '已过期',
- value: 2
- },
- {
- label: '停用',
- value: 3
- },
- {
- label: '未开始',
- value: 4
- },
- ],
- },
- ],
- reward_type_arr: {
- 1: '条件奖励',
- 2: '阶梯奖励',
- },
- status_arr: {
- 0: '全部',
- 1: '进行中',
- 2: '已过期',
- 3: '停用',
- 4: '未开始',
- },
- now_time: 0,
- },
- methods: {
- setApiData(e) {
- this.now_time = e.now_time;
- },
- handle(type, data = null) {
- let id = data ? parseInt(data.id) : '';
- switch (type) {
- case 'edit':
- let params = {
- r: 'rebate/index/edit'
- };
- if (id) params = Object.assign(params, {
- id: id
- });
- navigateTo(params);
- break;
- case 'log':
- param = {
- r: 'rebate/index/reward-log'
- };
- if (id) param = Object.assign(param, {
- rid: id
- });
- navigateTo(param);
- break;
- case 'activity_log':
- param = {
- r: 'rebate/index/activity-log'
- };
- if (id) param = Object.assign(param, {
- rid: id
- });
- navigateTo(param);
- break;
- case 'destroy':
- param = {id: data.id,status: -1};
- this.$confirm('删除该条数据后不可以恢复, 是否继续?', '警告', {type: 'warning'}).then(() => {this.send('rebate/index/handle',param)})
- break;
- case 'operate':
- param = {id: data.id, item_id:data.item_id, status:data.status};
- console.log(data,'param');
- this.$confirm('是否继续'+data.name+'该活动?', '警告', {type: 'warning'}).then(() => {this.send('rebate/index/handle',param)})
- break;
- }
- },
- send(url, params, callback = null) {
- let self = this;
- request({
- params: {
- r: url,
- },
- method: 'post',
- data: params
- }).then(e => {
- if (e.data.code == 0) {
- self.$message.success(e.data.msg);
- self.getList();
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- console.log(e);
- });
- if(callback) return e.data;
- },
- }
- });
- </script>
|