123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- <template>
- <div class="app-container">
- <el-card class="filter-container" shadow="never">
- <div>
- <i class="el-icon-search"></i>
- <span>筛选搜索</span>
- <el-button
- style="float:right"
- type="primary"
- @click="handleSearchList()"
- size="small">
- 查询搜索
- </el-button>
- <el-button
- style="float:right;margin-right: 15px"
- @click="handleResetSearch()"
- size="small">
- 重置
- </el-button>
- </div>
- <div style="margin-top: 15px">
- <el-form :inline="true" :model="listQuery" size="small" label-width="140px">
- <el-form-item label="优惠券名称:">
- <el-input v-model="listQuery.name" class="input-width" placeholder="优惠券名称"></el-input>
- </el-form-item>
- <el-form-item label="优惠券类型:">
- <el-select v-model="listQuery.type" placeholder="全部" clearable class="input-width">
- <el-option v-for="item in typeOptions"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- </el-form-item>
- </el-form>
- </div>
- </el-card>
- <el-card class="operate-container" shadow="never">
- <i class="el-icon-tickets"></i>
- <span>数据列表</span>
- <el-button size="mini" class="btn-add" @click="handleAdd()">添加</el-button>
- </el-card>
- <div class="table-container">
- <el-table ref="couponTable"
- :data="list"
- style="width: 100%;"
- @selection-change="handleSelectionChange"
- v-loading="listLoading" border>
- <el-table-column type="selection" width="60" align="center"></el-table-column>
- <el-table-column label="编号" width="100" align="center">
- <template slot-scope="scope">{{scope.row.id}}</template>
- </el-table-column>
- <el-table-column label="优惠劵名称" align="center">
- <template slot-scope="scope">{{scope.row.name}}</template>
- </el-table-column>
- <el-table-column label="优惠券类型" width="100" align="center">
- <template slot-scope="scope">{{scope.row.type | formatType}}</template>
- </el-table-column>
- <el-table-column label="可使用商品" width="100" align="center">
- <template slot-scope="scope">{{scope.row.useType | formatUseType}}</template>
- </el-table-column>
- <el-table-column label="使用门槛" width="140" align="center">
- <template slot-scope="scope">满{{scope.row.minPoint}}元可用</template>
- </el-table-column>
- <el-table-column label="面值" width="100" align="center">
- <template slot-scope="scope">{{scope.row.amount}}元</template>
- </el-table-column>
- <el-table-column label="适用平台" width="100" align="center">
- <template slot-scope="scope">{{scope.row.platform | formatPlatform}}</template>
- </el-table-column>
- <el-table-column label="有效期" width="180" align="center">
- <template slot-scope="scope">{{scope.row.startTime|formatDate}}至{{scope.row.endTime|formatDate}}</template>
- </el-table-column>
- <el-table-column label="状态" width="100" align="center">
- <template slot-scope="scope">{{scope.row.endTime | formatStatus}}</template>
- </el-table-column>
- <el-table-column label="操作" width="180" align="center">
- <template slot-scope="scope">
- <el-button size="mini"
- type="text"
- @click="handleView(scope.$index, scope.row)">查看</el-button>
- <el-button size="mini"
- type="text"
- @click="handleUpdate(scope.$index, scope.row)">
- 编辑</el-button>
- <el-button size="mini"
- type="text"
- @click="handleDelete(scope.$index, scope.row)">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- </div>
- <div class="pagination-container">
- <el-pagination
- background
- @size-change="handleSizeChange"
- @current-change="handleCurrentChange"
- layout="total, sizes,prev, pager, next,jumper"
- :current-page.sync="listQuery.pageNum"
- :page-size="listQuery.pageSize"
- :page-sizes="[5,10,15]"
- :total="total">
- </el-pagination>
- </div>
- </div>
- </template>
- <script>
- import {fetchList,deleteCoupon} from '@/api/coupon';
- import {formatDate} from '@/utils/date';
- const defaultListQuery = {
- pageNum: 1,
- pageSize: 10,
- name: null,
- type: null
- };
- const defaultTypeOptions=[
- {
- label: '全场赠券',
- value: 0
- },
- {
- label: '会员赠券',
- value: 1
- },
- {
- label: '购物赠券',
- value: 2
- },
- {
- label: '注册赠券',
- value: 3
- }
- ];
- export default {
- name:'couponList',
- data() {
- return {
- listQuery:Object.assign({},defaultListQuery),
- typeOptions:Object.assign({},defaultTypeOptions),
- list:null,
- total:null,
- listLoading:false,
- multipleSelection:[]
- }
- },
- created(){
- this.getList();
- },
- filters:{
- formatType(type){
- for(let i=0;i<defaultTypeOptions.length;i++){
- if(type===defaultTypeOptions[i].value){
- return defaultTypeOptions[i].label;
- }
- }
- return '';
- },
- formatUseType(useType){
- if(useType===0){
- return '全场通用';
- }else if(useType===1){
- return '指定分类';
- }else{
- return '指定商品';
- }
- },
- formatPlatform(platform){
- if(platform===1){
- return '移动平台';
- }else if(platform===2){
- return 'PC平台';
- }else{
- return '全平台';
- }
- },
- formatDate(time){
- if(time==null||time===''){
- return 'N/A';
- }
- let date = new Date(time);
- return formatDate(date, 'yyyy-MM-dd')
- },
- formatStatus(endTime){
- let now = new Date().getTime();
- if(endTime>now){
- return '未过期'
- }else{
- return '已过期';
- }
- }
- },
- methods:{
- handleResetSearch() {
- this.listQuery = Object.assign({}, defaultListQuery);
- },
- handleSearchList() {
- this.listQuery.pageNum = 1;
- this.getList();
- },
- handleSelectionChange(val){
- this.multipleSelection = val;
- },
- handleSizeChange(val) {
- this.listQuery.pageNum = 1;
- this.listQuery.pageSize = val;
- this.getList();
- },
- handleCurrentChange(val) {
- this.listQuery.pageNum = val;
- this.getList();
- },
- handleAdd(){
- this.$router.push({path: '/sms/addCoupon'})
- },
- handleView(index, row) {
- this.$router.push({path: '/sms/couponHistory', query: {id: row.id}})
- },
- handleUpdate(index, row) {
- this.$router.push({path: '/sms/updateCoupon', query: {id: row.id}})
- },
- handleDelete(index, row) {
- this.$confirm('是否进行删除操作?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- deleteCoupon(row.id).then(response=>{
- this.$message({
- type: 'success',
- message: '删除成功!'
- });
- this.getList();
- });
- })
- },
- getList(){
- fetchList(this.listQuery).then(response=>{
- this.listLoading = false;
- this.list = response.data.list;
- this.total = response.data.total;
- });
- }
- }
- }
- </script>
- <style scoped>
- .input-width {
- width: 203px;
- }
- </style>
|