<template>
|
<TableLayout :permissions="['business:coupon:query']">
|
<!-- 搜索表单 -->
|
<el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" inline>
|
<el-form-item label="名称" prop="name">
|
<el-input v-model="searchForm.name" placeholder="请输入优惠券名称" @keypress.enter.native="search"></el-input>
|
</el-form-item>
|
<!-- 0商家优惠券 1平台优惠券 -->
|
<el-form-item label="类型" prop="couponType">
|
<el-select v-model="searchForm.couponType" clearable placeholder="请选择优惠券类型" >
|
<el-option key="0" :value="0" label="满减券"></el-option>
|
<el-option key="1" :value="1" label="折扣券"></el-option>
|
</el-select>
|
</el-form-item>
|
<section>
|
<el-button type="primary" @click="search">搜索</el-button>
|
<el-button @click="reset">重置</el-button>
|
</section>
|
</el-form>
|
<!-- 表格和分页 -->
|
<template v-slot:table-wrap>
|
<ul class="toolbar" v-permissions="['business:coupon:create', 'business:coupon:delete']">
|
<li><el-button type="primary" icon="el-icon-plus" @click="$refs.operaCouponWindow.open('新建', null, 1)" v-permissions="['business:coupon:create']">新建</el-button></li>
|
<li><el-button type="danger" @click="deleteByIdInBatch" icon="el-icon-delete" v-permissions="['business:coupon:delete']">删除</el-button></li>
|
</ul>
|
<el-table
|
v-loading="isWorking.search"
|
:data="tableData.list"
|
stripe
|
border
|
@selection-change="handleSelectionChange"
|
>
|
<el-table-column type="selection" width="55"></el-table-column>
|
<el-table-column prop="name" label="优惠券名称" align="center" min-width="120px"></el-table-column>
|
<el-table-column label="类型" align="center" min-width="100px">
|
<template slot-scope="{row}">
|
<span v-if="row.couponType ===0"> 满减券</span>
|
<span v-if="row.couponType ===1"> 折扣券</span>
|
</template>
|
</el-table-column>
|
<el-table-column label="优惠规则" align="center" min-width="150px" show-overflow-tooltip>
|
<template slot-scope="{row}">
|
<span v-if="row.couponType ===0"> {{ `订单满${row.limitPrice||0}元,减${row.price||0}` }}元</span>
|
<span v-if="row.couponType ===1"> {{ `订单满${row.limitPrice||0}元,享${row.price||0}折` }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column prop="num" label="发放总量" align="center" min-width="100px"></el-table-column>
|
<el-table-column label="已发送数量" align="center" min-width="100px">
|
<template slot-scope="{row}">
|
<el-button type="text" @click="showCouponUse(row.id)">{{ row.received||0 }}</el-button>
|
</template>
|
</el-table-column>
|
<el-table-column label="剩余数量" align="center" min-width="100px">
|
<template slot-scope="{row}">
|
{{ (row.num||0) - (row.received||0) }}
|
</template>
|
</el-table-column>
|
<!--
|
<el-table-column prop="used" label="使用数量" align="center" min-width="100px"></el-table-column>
|
-->
|
<el-table-column prop="validDays" label="使用有效期" align="center" min-width="210px">
|
<template slot-scope="{row}">
|
<span v-if="row.useType ===0"><li> 起:{{ row.startDate}}</li> <li>止:{{row.endDate }}</li></span>
|
<span v-if="row.useType ===1"> {{ `领用后${row.validDays||0}天有效` }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column label="适用类型" align="center" min-width="100px">
|
<template slot-scope="{row}">
|
<span v-if="row.applyType ===0"> 全程通用</span>
|
<span v-if="row.applyType ===1"> 按品类</span>
|
<span v-if="row.applyType ===2"> 指定商品</span>
|
</template>
|
</el-table-column>
|
<el-table-column prop="status" label="状态" align="center" min-width="100px">
|
<template slot-scope="{row}">
|
<el-switch
|
v-model="row.status"
|
active-color="#13ce66"
|
inactive-color="#999"
|
:active-value="0"
|
:inactive-value="1"
|
@change="statusChange(row)"
|
></el-switch>
|
</template>
|
</el-table-column>
|
<el-table-column
|
v-if="containPermissions(['business:coupon:update', 'business:coupon:delete'])"
|
label="操作"
|
min-width="120"
|
fixed="right"
|
align="center"
|
>
|
<template slot-scope="{row}">
|
<el-button type="text" @click="$refs.operaCouponWindow.open('编辑优惠券', row)" icon="el-icon-edit" v-permissions="['business:coupon:update']">编辑</el-button>
|
<el-button type="text" style="color: red;" @click="deleteById(row)" icon="el-icon-delete" v-permissions="['business:coupon:delete']">删除</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
<pagination
|
@size-change="handleSizeChange"
|
@current-change="handlePageChange"
|
:pagination="tableData.pagination"
|
>
|
</pagination>
|
</template>
|
<!-- 新建/修改 -->
|
<OperaCouponWindow ref="operaCouponWindow" @success="handlePageChange"/>
|
<OperaCouponDetail ref="operaCouponDetail" />
|
<OperaCouponUsedDetail ref="operaCouponUsedDetail" />
|
</TableLayout>
|
</template>
|
|
<script>
|
import BaseTable from '@/components/base/BaseTable'
|
import TableLayout from '@/layouts/TableLayout'
|
import Pagination from '@/components/common/Pagination'
|
import OperaCouponWindow from '@/components/business/OperaCouponWindow'
|
import OperaCouponDetail from '@/components/business/OperaCouponDetail'
|
import OperaCouponUsedDetail from '@/components/business/OperaCouponUsedDetail'
|
import { updateStatus } from '@/api/business/coupon'
|
export default {
|
name: 'Coupon',
|
extends: BaseTable,
|
components: { TableLayout, Pagination, OperaCouponWindow, OperaCouponDetail, OperaCouponUsedDetail },
|
data () {
|
return {
|
// 搜索
|
searchForm: {
|
name: '',
|
couponType: ''
|
}
|
}
|
},
|
created () {
|
this.config({
|
module: '优惠券信息表',
|
api: '/business/coupon',
|
'field.id': 'id',
|
'field.main': 'id'
|
})
|
this.search()
|
},
|
methods: {
|
showDetail(row) {
|
this.$refs.operaCouponDetail.open('优惠券详情', row)
|
},
|
showCouponUse(id) {
|
|
this.$refs.operaCouponUsedDetail.open('优惠券领取详情', id)
|
},
|
statusChange(row) {
|
updateStatus(row)
|
.then(() => {
|
this.$tip.success('操作成功')
|
})
|
.catch(e => {
|
this.$tip.error(e)
|
})
|
.finally(() => {
|
this.handlePageChange()
|
})
|
}
|
},
|
}
|
</script>
|