| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356 |
- <div id="app" class="contents" v-cloak>
- <el-card shadow="never" body-style="background-color: #f3f3f3;padding: 10px 0 0;" style="min-width: 1000px;">
- <div slot="header">
- <div>
- <span>拼团活动</span>
- <div style="float:right;margin:-6px 0px">
- <el-button type="primary" size="small" @click="storage">创建活动</el-button>
- <!-- <com-export-dialog :field_list='exportList' :params="searchData">
- </com-export-dialog> -->
- </div>
- </div>
- </div>
- <div class="table-body">
- <el-form size="small" :inline="true" flex="dir:left cross:center">
- <div class="item-box" flex="dir:left cross:center">
- <div style="margin-right: 5px; margin-left: 25px;">活动名称</div>
- <el-input size="small" style="width: 200px" v-model="searchData.title" placeholder="请输入活动名称"></el-input>
- </div>
- <div class="item-box" flex="dir:left cross:center">
- <div style="margin-right: 5px; margin-left: 25px;">活动状态</div>
- <el-select v-model="searchData.activity_status" @change='search' class="select" size="small">
- <el-option :key="index" :label="item" :value="index" v-for="(item, index) in statusMap"></el-option>
- <!-- <el-option :key="1" label="未开始" :value="1"></el-option>
- <el-option :key="2" label="进行中" :value="2"></el-option>
- <el-option :key="3" label="停用" :value="3"></el-option>
- <el-option :key="4" label="已结束" :value="4"></el-option> -->
- </el-select>
- </div>
- <div class="item-box" flex="dir:left cross:center">
- <div style="margin-right: 5px; margin-left: 25px;">发布时间</div>
- <el-date-picker @change="selectedDateTime" size="small" v-model="selectTime" type="daterange" value-format="yyyy-MM-dd" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
- </el-date-picker>
- </div>
- <div class="item-box" flex="dir:left cross:center">
- <el-button size="small" type="primary" style="padding: 9px 15px !important;margin-right: 5px; margin-left: 25px;" @click="search">搜索
- </el-button>
- </div>
- <div class="item-box" flex="dir:left cross:center" v-if="searchData.activity_status || searchData.title || searchData.start_time || searchData.end_time">
- <el-button size="small" type="warning" style="padding: 9px 15px !important;" @click="clearSearch">清除搜索条件
- </el-button>
- </div>
- </el-form>
- <el-table v-loading=" listLoading" :data="list" stripe style="width: 100%">
- <el-table-column prop="id" label="ID" width="80" align="center">
- </el-table-column>
- <el-table-column prop="title" label="活动名称" width="150" align="center"></el-table-column>
- <el-table-column prop="relate_good_number" label="关联商品数量" width="150" title="" align="center"></el-table-column>
- <el-table-column prop="" label="规则" width="150" title="" align="center">
- <template slot-scope="scope">
- <com-ellipsis :line="1">{{scope.row.group_num}}中{{scope.row.random_win_num}}</com-ellipsis>
- </template>
- </el-table-column>
- <el-table-column label="拼团时间" align="center">
- <template slot-scope="scope">
- <com-ellipsis :line="1">{{scope.row.start_time}}至{{scope.row.end_time}}</com-ellipsis>
- </template>
- </el-table-column>
- <el-table-column label="创建时间" align="center">
- <template slot-scope="scope">
- {{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}
- </template>
- </el-table-column>
- <el-table-column label="状态" align="center">
- <template slot-scope="scope">
- {{statusMap[scope.row.activity_status]}}
- </template>
- </el-table-column>
- <el-table-column label="操作" width="250" align="center">
- <template slot-scope="scope">
- <el-button circle size="small" type="text" @click="activityStatisticsData(scope.row.id)">数据</el-button>
- <el-button circle size="small" type="text" @click="getQueue(scope.row.id)">队列</el-button>
- <el-button circle size="small" type="text" @click="storage(scope.row.id, scope.$index)">编辑</el-button>
- <el-button v-if="scope.row.activity_status==2" circle size="small" type="text" @click="switchActivity(scope.row.id, 3, scope.$index)">停用</el-button>
- <el-button v-if="scope.row.activity_status==3" circle size="small" type="text" @click="switchActivity(scope.row.id, 2, scope.$index)">启用</el-button>
- <el-button v-if="scope.row.activity_status!=2" circle size="small" type="text" @click="activityDelete(scope.row.id)">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- <div style="text-align: right;margin: 20px 0;">
- <el-pagination @current-change="pagination" background layout="prev, pager, next" :page-count="pageCount">
- </el-pagination>
- </div>
- </div>
- </el-card>
- </div>
- <script>
- const app = new Vue({
- el: '#app',
- data: {
- list: [],
- listLoading: false,
- page: 1,
- level: 1,
- pageCount: 0,
- searchData: {
- title: '',
- start_time: '',
- end_time: '',
- },
- selectTime: [],
- // 导出
- exportList: [],
- statusMap: [],
- },
- mounted: function() {
- this.getList();
- },
- methods: {
- //搜索
- search() {
- this.page = 1;
- this.getList();
- },
- clearSearch() {
- this.searchData.title = '';
- this.searchData.activity_id = null;
- this.searchData.start_time = '';
- this.searchData.end_time = '';
- this.selectTime = [];
- this.getList();
- },
- // 时间搜索触发
- selectedDateTime(params) {
- if (params != null) {
- this.searchData.start_time = params[0];
- this.searchData.end_time = params[1];
- } else {
- this.searchData.start_time = '';
- this.searchData.end_time = '';
- }
- },
- //跳转拼团活动统计数据
- activityStatisticsData(id) {
- navigateTo({
- r: 'lucky-group/group-activity/activity-data',
- activity_id: id,
- });
- },
- // getQueue(id) {
- // request({
- // params: {
- // r: 'lucky-group/group-activity/get-queue',
- // activity_id: id,
- // },
- // method: 'get',
- // }).then(e => {
- // this.listLoading = false;
- // if (e.data.code == 0) {
- // // this.statusMap = e.data.data.status_map;
- // // this.list = e.data.data.list;
- // // this.pageCount = e.data.data.page_count;
- // // this.exportList = e.data.data.exportList;
- // } else {
- // this.$message.error(e.data.msg)
- // }
- //
- // }).catch(e => {
- // console.log(e);
- // });
- // },
- getQueue(id) {
- navigateTo({
- r: 'lucky-group/group-activity/get-data',
- activity_id: id,
- });
- request({
- params: {
- r: 'lucky-group/group-activity/get-queue',
- activity_id: id,
- },
- method: 'get',
- }).then(e => {
- this.listLoading = false;
- if (e.data.code == 0) {
- // this.statusMap = e.data.data.status_map;
- // this.list = e.data.data.list;
- // this.pageCount = e.data.data.page_count;
- // this.exportList = e.data.data.exportList;
- } else {
- this.$message.error(e.data.msg)
- }
- }).catch(e => {
- console.log(e);
- });
- },
- pagination(currentPage) {
- let self = this;
- self.page = currentPage;
- self.getList();
- },
- getList() {
- this.listLoading = true;
- request({
- params: {
- r: 'lucky-group/group-activity/index',
- pagesize: 10,
- page: this.page,
- ...this.searchData,
- },
- method: 'get',
- }).then(e => {
- // console.log('等级列表=='+JSON.stringify(e))
- this.listLoading = false;
- if (e.data.code == 0) {
- this.statusMap = e.data.data.status_map;
- this.list = e.data.data.list;
- this.pageCount = e.data.data.page_count;
- this.exportList = e.data.data.exportList;
- } else {
- this.$message.error(e.data.msg)
- }
- }).catch(e => {
- console.log(e);
- });
- },
- //编辑 or 添加
- storage(id = null, index = null) {
- let request_url = {
- r: 'lucky-group/group-activity/storage'
- };
- if (id) request_url.id = id;
- navigateTo(request_url);
- },
- //删除
- activityDelete(id) {
- let self = this;
- self.$confirm('删除该条拼团活动, 是否继续?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- self.listLoading = true;
- request({
- params: {
- r: 'lucky-group/group-activity/delete',
- },
- method: 'post',
- data: {id: id}
- }).then(e => {
- self.listLoading = false;
- if (e.data.code === 0) {
- self.$message.success(e.data.msg);
- this.getList();
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- console.log(e);
- });
- }).catch(() => {
- self.$message.info('已取消删除')
- });
- },
- // 活动开关
- switchActivity(id, status, index) {
- self.listLoading = true;
- request({
- params: {
- r: 'lucky-group/group-activity/switch-acitity',
- },
- method: 'post',
- data: {id: id, status: status}
- }).then(e => {
- self.listLoading = false;
- if (e.data.code == 0) {
- this.$message.success('操作成功');
- this.list[index].activity_status = status;
- this.getList();
- } else {
- this.$message.error(e.data.msg);
- }
- }).catch(e => {
- console.log(e);
- this.$message.error('网络错误');
- });
- }
- }
- });
- </script>
- <style>
- .table-body {
- padding: 20px;
- background-color: #fff;
- }
- .input-item {
- display: inline-block;
- width: 250px;
- margin: 0 0 20px;
- }
- .input-item .el-input__inner {
- border-right: 0;
- }
- .input-item .el-input__inner:hover {
- border: 1px solid #dcdfe6;
- border-right: 0;
- outline: 0;
- }
- .input-item .el-input__inner:focus {
- border: 1px solid #dcdfe6;
- border-right: 0;
- outline: 0;
- }
- .input-item .el-input-group__append {
- background-color: #fff;
- border-left: 0;
- width: 10%;
- padding: 0;
- }
- .input-item .el-input-group__append .el-button {
- padding: 0;
- }
- .input-item .el-input-group__append .el-button {
- margin: 0;
- }
- /* .table-body .el-button {
- padding: 0 !important;
- border: 0;
- margin: 0 5px;
- }
- */
- .el-table th>.cell {
- color: #333;
- font-weight: bold;
- font-size: 14px;
- }
- .el-table__footer-wrapper,
- .el-table__header-wrapper {
- border-bottom: 1.4px solid #D6D6D6;
- }
- .el-button--mini.is-circle {
- padding: 3px;
- }
- .contents .el-button+.el-button {
- margin-left: 0px;
- }
- </style>
|