| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468 |
- <style>
- .link_url {
- text-align: left;
- font-size: 14px;
- }
- .showqr .el-dialog__body {
- text-align: center;
- padding-bottom: 10px;
- }
- .el-dialog {
- min-width: 400px;
- }
- </style>
- <div id="app" v-cloak>
- <el-card shadow="never" style="border:0" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
- <div slot="header">
- <span>电子券管理</span>
- <div style="float: right;margin-top: -5px">
- <el-button type="primary"
- @click="$navigate({r: 'electron-coupon/default/edit'})"
- size="small">新建电子券
- </el-button>
- </div>
- </div>
- <div class="search-box">
- <!-- 搜索 -->
- <el-form :inline="true" :model="searchForm" size="small" class="demo-form-inline">
- <el-form-item label="电子券名称">
- <el-input placeholder="请输入电子券名称" v-model="searchForm.name"></el-input>
- </el-form-item>
- <el-form-item label="领取状态">
- <el-select v-model="searchForm.receive_status" placeholder="请选择领取状态">
- <el-option v-for="(name, index) in receive_status_option" :label="name" :value="index" :key="index"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="使用状态">
- <el-select v-model="searchForm.usage_status" placeholder="请选择使用状态">
- <el-option v-for="(item,index) in usage_status_option" :label="item" :value="index" :key="index"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" @click="search">搜索</el-button>
- <el-button type="danger" @click="resetSearch" v-if="show_clear_search_btn">清除条件</el-button>
- </el-form-item>
- </el-form>
- </div>
- <div class="table-body">
- <el-tabs>
- <el-table :data="list" stripe v-loading="loading" size="small" style="margin-bottom: 15px;">
- <el-table-column prop="id" label="序号" align="center"></el-table-column>
- <!-- <el-table-column prop="name" label="电子券名称" align="center"></el-table-column>-->
- <el-table-column
- label="电子券名称"
- min-width="120">
- <template slot-scope="scope">
- <div style="display: flex;align-items: center;">
- <el-image fit="cover" :src="scope.row.pic ? scope.row.pic : diy_img_prefix + '/static/addons/ElectronCoupon/ElectronCoupon.png'" style="width: 40px;height: 40px;display: block;margin-right: 5px;flex-shrink: 0;"></el-image>
- <div>
- <div>{{scope.row.name}}</div>
- </div>
- </div>
- </template>
- </el-table-column>
- <el-table-column prop="price" label="激活金额" align="center"></el-table-column>
- <el-table-column label="专有券" align="center" width="65px">
- <template slot-scope="scope">
- <span v-if="scope.row.is_proper == 1">是</span>
- <span v-else>否</span>
- </template>
- </el-table-column>
- <el-table-column label="类型" align="center" width="65px">
- <template slot-scope="scope">
- <span v-if="scope.row.pieces_type == 1">单券</span>
- <span v-else>多券</span>
- </template>
- </el-table-column>
- <el-table-column label="领取时间" min-width="150" align="center">
- <template slot-scope="scope">
- {{ scope.row.receive_begin_time | dateTimeFormat('Y-m-d H:i') }} 至 {{ scope.row.receive_end_time | dateTimeFormat('Y-m-d H:i') }}
- </template>
- </el-table-column>
- <el-table-column label="使用时间" min-width="150" align="center">
- <template slot-scope="scope">
- {{ scope.row.use_begin_time | dateTimeFormat('Y-m-d H:i') }} 至 {{ scope.row.use_end_time | dateTimeFormat('Y-m-d H:i') }}
- </template>
- </el-table-column>
- <el-table-column prop="user_level_name" label="可领取等级" min-width="90" align="center">
- <template slot-scope="scope">
- <span v-if="scope.row.receive_codition == 1">全体会员</span>
- <span v-else>{{ scope.row.user_level_name }}</span>
- </template>
- </el-table-column>
- <el-table-column prop="used_amount" label="已兑换" min-width="90" align="center"></el-table-column>
- <el-table-column prop="receive_amount" label="已领取" min-width="90" align="center"></el-table-column>
- <el-table-column prop="remain_num" label="剩余数量" min-width="90" align="center"></el-table-column>
- <el-table-column prop="give_quantity" label="赠送数量" min-width="90" align="center"></el-table-column>
- <el-table-column prop="is_show_in_center" label="领取中心" min-width="90" align="center">
- <template slot-scope="scope">
- <el-switch
- v-model="scope.row.is_show_in_center"
- @change="((val)=>{switchFun(val,scope.row.id,'is_show_in_center')})"
- :active-value="1"
- :inactive-value="0"
- active-text=""
- inactive-text=""
- >
- </el-switch>
- </template>
- </el-table-column>
- <el-table-column prop="status" label="状态" min-width="90" align="center">
- <template slot-scope="scope">
- <el-switch
- v-model="scope.row.status"
- @change="((val)=>{switchFunStatus(val,scope.row.id,'status')})"
- :active-value="1"
- :inactive-value="0"
- active-text=""
- inactive-text=""
- >
- </el-switch>
- </template>
- </el-table-column>
- <el-table-column prop="receive_status_name" label="领取状态" min-width="90" align="center"></el-table-column>
- <el-table-column prop="usage_status_name" label="使用状态" min-width="90" align="center"></el-table-column>
- <el-table-column label="操作" align="center" fixed="right" >
- <template slot-scope="scope">
- <el-button type="text" @click="handle('edit',scope.row)">编辑</el-button>
- <el-button type="text" @click="handle('destroy',scope.row)">删除</el-button>
- <el-button type="text" @click="giveClick(scope.row.id)">赠送</el-button>
- <el-button type="text" @click="userCoupon(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>
- </el-tabs>
- </div>
- </el-card>
- <el-dialog :visible.sync="give.show" width="20%" title="赠送电子券">
- <div>
- <el-form @submit.native.prevent size="small" label-width="150px">
- <el-form-item label="用户昵称">
- <el-autocomplete size="small" v-model="give.nickname" value-key="nickname" @keyup.enter.native="keyUp"
- :fetch-suggestions="querySearchAsync" placeholder="请输入用户昵称/id/手机号"
- @select="shareClick"></el-autocomplete>
- </el-form-item>
- <el-form-item label="赠送数量" prop="marks">
- <el-input type="number"
- :rows="4"
- placeholder="数量"
- v-model="give.number">
- </el-input>
- </el-form-item>
- </el-form>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="giveCancel" type="default" size="small">取消</el-button>
- <el-button type="primary" :loading="give.btnLoading" style="margin-bottom: 10px;" size="small" @click="giveSave">保存</el-button>
- </span>
- </el-dialog>
- </div>
- <script>
- const app = new Vue({
- el: '#app',
- data: {
- diy_img_prefix: '<?= Yii::getAlias('@attachurl') ?>',
- loading: false,
- give: {
- show:false,
- btnLoading:false,
- user_id:0,
- e_coupon_id:0,
- number:0,
- keyword:'',
- },
- delLoading: false,
- page: 1,
- pageCount: 0,
- list: [],
- receive_status_option: {
- 0: '未开始',
- 1: '领取中',
- 2: '已结束'
- },
- usage_status_option: {
- 0: '未开始',
- 1: '使用中',
- 2: '已过期'
- },
- searchForm:{
- name: null,
- receive_status: null,
- usage_status: null,
- },
- },
- mounted() {
- this.getList();
- },
- computed: {
- show_clear_search_btn: function() {
- return this.searchForm.name != null ||
- this.searchForm.receive_status != null ||
- this.searchForm.usage_status != null;
- },
- },
- methods: {
- pagination(currentPage) {
- let self = this;
- self.page = currentPage;
- self.getList();
- },
- switchFun(val, id, field) {
- if (field == 'is_show_in_center') {
- let param = {id: id, is_show_in_center: val};
- this.send('electron-coupon/default/handle',param)
- }
- },
- handle(type, data = null) {
- let id = data ? parseInt(data.id) : '';
- switch (type) {
- case 'edit':
- let params = {
- r: 'electron-coupon/default/edit'
- };
- if (id) params = Object.assign(params, {
- id: id
- });
- navigateTo(params);
- break;
- case 'destroy':
- param = {id: data.id,status: -1};
- this.$confirm('删除该条数据后不可以恢复, 是否继续?', '警告', {type: 'warning'}).then(() => {this.send('electron-coupon/default/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;
- },
- search() {// 清空查询条件
- this.page = 1;
- this.getList(this.searchForm);
- },
- resetSearch() {// 清空查询条件
- this.searchForm = {
- name: null,
- receive_status: null,
- usage_status: null
- };
- this.page = 1;
- this.getList();
- },
- getList(search = {}) {
- let self = this;
- self.loading = true;
- let basic_params = {
- page: self.page
- };
- let params = Object.assign(basic_params, search);
- request({
- params: {
- r: 'electron-coupon/default/index'
- },
- method: 'post',
- data: params
- }).then(e => {
- self.loading = false;
- if (e.data.code == 0) {
- self.list = e.data.data.page_data.list;
- self.pageCount = e.data.data.page_data.page_count;
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- self.loading = false;
- });
- },
- switchFunStatus(val, id, field) {
- let param = {id: id, status: val};
- this.send('electron-coupon/default/handle-status',param)
- },
- giveClick(id) {
- this.give.show = true;
- this.give.e_coupon_id = id;
- },
- shareClick(row) {
- this.give.user_id = row.id;
- },
- giveCancel() {
- this.$emit('input', false);
- this.give.show = false;
- },
- giveSave() {
- if (!this.give.user_id) {
- this.$message.error('请选择会员');
- return null;
- }
- this.give.btnLoading = true;
- request({
- params: {
- r: 'electron-coupon/default/give-coupon',
- },
- method: 'post',
- data: {
- e_coupon_id: this.give.e_coupon_id,
- user_id: this.give.user_id,
- number: this.give.number,
- }
- }).then(response => {
- this.give.btnLoading = false;
- if (response.data.code == 0) {
- this.$message.success('赠送成功');
- setTimeout(() => {
- location.reload();
- }, 500);
- this.editCancel();
- } else {
- this.$message.error(response.data.msg);
- }
- }).catch(response => {
- this.give.btnLoading = false;
- });
- },
- querySearchAsync(queryString, cb) {
- this.give.keyword = queryString;
- this.get_user(cb);
- },
- get_user(cb) {
- request({
- params: {
- r: 'distribution/default/search-user',
- keyword: this.give.keyword
- }
- }).then(res => {
- if (res.data.code == 0) {
- cb(res.data.data.list)
- } else {
- this.$message.error(res.data.msg);
- }
- });
- },
- userCoupon(id){
- this.$navigate({
- r: 'electron-coupon/user-coupon/index',
- e_coupon_id: id
- })
- },
- }
- });
- </script>
- <style>
- .el-tabs__header {
- font-size: 16px;
- }
- .table-body {
- padding: 20px;
- background-color: #fff;
- }
- .table-body .el-button {
- padding: 0 !important;
- border: 0;
- margin: 0 5px;
- }
- .input-item {
- width: 250px;
- margin: 0 0 20px;
- display: inline-block;
- }
- .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;
- }
- .batch {
- margin: 0 0 20px;
- display: inline-block;
- }
- .batch .el-button {
- padding: 9px 15px !important;
- }
- .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;
- }
- .search-box {
- padding: 10px 0 0 10px;
- background-color: #fff;
- margin-bottom: 10px;
- }
- </style>
|