branch_lyj
Liuyujie 7 months ago
parent e8a2fc3417
commit f77570e5f0

@ -1,14 +1,21 @@
<template> 
<template>
<!-- 在模板中使用了coupon-detail组件并传递isEdit属性值为false可能用于区分添加或编辑操作 -->
<coupon-detail :isEdit="false"></coupon-detail>
</template>
<script>
import CouponDetail from './components/CouponDetail'
export default {
// CouponDetail'./components/CouponDetail'
import CouponDetail from './components/CouponDetail';
export default {
// addCoupon
name: 'addCoupon',
// CouponDetail使使
components: { CouponDetail }
}
}
</script>
<style scoped>
<!-- 带有scoped属性的style标签里面样式仅作用于当前组件目前为空 -->
</style>

@ -1,45 +1,79 @@
<template> 
<template>
<!-- 整体的外层容器用于布局包裹内部各部分内容 -->
<div class="app-container">
<!-- 用于表格布局的容器 -->
<div class="table-layout">
<!-- el-row行组件里面放置多个列用于显示表格标题 -->
<el-row>
<!-- el-col列组件设置占4格宽度显示名称标题 -->
<el-col :span="4" class="table-cell-title">名称</el-col>
<!-- el-col列组件设置占4格宽度显示优惠券类型标题 -->
<el-col :span="4" class="table-cell-title">优惠券类型</el-col>
<!-- el-col列组件设置占4格宽度显示可使用商品标题 -->
<el-col :span="4" class="table-cell-title">可使用商品</el-col>
<!-- el-col列组件设置占4格宽度显示使用门槛标题 -->
<el-col :span="4" class="table-cell-title">使用门槛</el-col>
<!-- el-col列组件设置占4格宽度显示面值标题 -->
<el-col :span="4" class="table-cell-title">面值</el-col>
<!-- el-col列组件设置占4格宽度显示状态标题 -->
<el-col :span="4" class="table-cell-title">状态</el-col>
</el-row>
<!-- el-row行组件里面放置多个列用于显示对应优惠券的具体信息使用了过滤器来格式化显示内容 -->
<el-row>
<!-- el-col列组件设置占4格宽度显示优惠券名称 -->
<el-col :span="4" class="table-cell">{{coupon.name}}</el-col>
<!-- el-col列组件设置占4格宽度显示格式化后的优惠券类型 -->
<el-col :span="4" class="table-cell">{{coupon.type | formatType}}</el-col>
<!-- el-col列组件设置占4格宽度显示格式化后的可使用商品类型 -->
<el-col :span="4" class="table-cell">{{coupon.useType | formatUseType}}</el-col>
<!-- el-col列组件设置占4格宽度按格式显示使用门槛 -->
<el-col :span="4" class="table-cell">{{coupon.minPoint}}元可用</el-col>
<!-- el-col列组件设置占4格宽度显示优惠券面值 -->
<el-col :span="4" class="table-cell">{{coupon.amount}}</el-col>
<!-- el-col列组件设置占4格宽度显示格式化后的状态 -->
<el-col :span="4" class="table-cell">{{coupon.endTime | formatStatus}}</el-col>
</el-row>
<!-- el-row行组件里面放置多个列用于显示表格另一部分标题 -->
<el-row>
<!-- el-col列组件设置占4格宽度显示有效期标题 -->
<el-col :span="4" class="table-cell-title">有效期</el-col>
<!-- el-col列组件设置占4格宽度显示总发行量标题 -->
<el-col :span="4" class="table-cell-title">总发行量</el-col>
<!-- el-col列组件设置占4格宽度显示已领取标题 -->
<el-col :span="4" class="table-cell-title">已领取</el-col>
<!-- el-col列组件设置占4格宽度显示待领取标题 -->
<el-col :span="4" class="table-cell-title">待领取</el-col>
<!-- el-col列组件设置占4格宽度显示已使用标题 -->
<el-col :span="4" class="table-cell-title">已使用</el-col>
<!-- el-col列组件设置占4格宽度显示未使用标题 -->
<el-col :span="4" class="table-cell-title">未使用</el-col>
</el-row>
<!-- el-row行组件里面放置多个列用于显示对应优惠券相关数量等具体信息使用了日期格式化等过滤器 -->
<el-row>
<!-- el-col列组件设置占4格宽度按格式显示有效期使用了日期格式化过滤器 -->
<el-col :span="4" class="table-cell" style="font-size: 13px">
{{coupon.startTime|formatDate}}{{coupon.endTime|formatDate}}
</el-col>
<!-- el-col列组件设置占4格宽度显示总发行量 -->
<el-col :span="4" class="table-cell">{{coupon.publishCount}}</el-col>
<!-- el-col列组件设置占4格宽度显示已领取数量 -->
<el-col :span="4" class="table-cell">{{coupon.receiveCount}}</el-col>
<el-col :span="4" class="table-cell">{{coupon.publishCount-coupon.receiveCount}}</el-col>
<!-- el-col列组件设置占4格宽度通过计算显示待领取数量 -->
<el-col :span="4" class="table-cell">{{coupon.publishCount - coupon.receiveCount}}</el-col>
<!-- el-col列组件设置占4格宽度显示已使用数量 -->
<el-col :span="4" class="table-cell">{{coupon.useCount}}</el-col>
<el-col :span="4" class="table-cell">{{coupon.publishCount-coupon.useCount}}</el-col>
<!-- el-col列组件设置占4格宽度通过计算显示未使用数量 -->
<el-col :span="4" class="table-cell">{{coupon.publishCount - coupon.useCount}}</el-col>
</el-row>
</div>
<!-- 筛选搜索区域的卡片容器设置无阴影效果 -->
<el-card class="filter-container" shadow="never">
<div>
<!-- 显示搜索图标 -->
<i class="el-icon-search"></i>
<!-- 显示筛选搜索文字提示 -->
<span>筛选搜索</span>
<!-- 用于触发查询搜索的按钮绑定点击事件设置样式等属性 -->
<el-button
style="float:right"
type="primary"
@ -47,6 +81,7 @@
size="small">
查询搜索
</el-button>
<!-- 用于重置筛选条件的按钮绑定点击事件设置样式等属性 -->
<el-button
style="float:right;margin-right: 15px"
@click="handleResetSearch()"
@ -55,8 +90,11 @@
</el-button>
</div>
<div style="margin-top: 15px">
<!-- 行内表单绑定数据模型设置尺寸标签宽度等属性 -->
<el-form :inline="true" :model="listQuery" size="small" label-width="140px">
<!-- 对应使用状态选择框的表单项 -->
<el-form-item label="使用状态:">
<!-- 下拉选择框双向绑定使用状态数据设置占位提示等属性通过循环生成下拉选项 -->
<el-select v-model="listQuery.useStatus" placeholder="全部" clearable class="input-width">
<el-option v-for="item in useTypeOptions"
:key="item.value"
@ -65,41 +103,54 @@
</el-option>
</el-select>
</el-form-item>
<!-- 对应订单编号输入框的表单项 -->
<el-form-item label="订单编号:">
<!-- 输入框双向绑定订单编号数据设置类名和占位提示 -->
<el-input v-model="listQuery.orderSn" class="input-width" placeholder="订单编号"></el-input>
</el-form-item>
</el-form>
</div>
</el-card>
<!-- 放置数据表格的容器 -->
<div class="table-container">
<!-- 数据表格组件绑定数据设置宽度等属性以及加载状态 -->
<el-table ref="couponHistoryTable"
:data="list"
style="width: 100%;"
v-loading="listLoading" border>
<!-- 显示优惠码的表格列 -->
<el-table-column label="优惠码" width="160" align="center">
<template slot-scope="scope">{{scope.row.couponCode}}</template>
</el-table-column>
<!-- 显示领取会员的表格列 -->
<el-table-column label="领取会员" width="140" align="center">
<template slot-scope="scope">{{scope.row.memberNickname}}</template>
</el-table-column>
<!-- 显示领取方式的表格列使用过滤器格式化内容 -->
<el-table-column label="领取方式" width="100" align="center">
<template slot-scope="scope">{{scope.row.getType | formatGetType}}</template>
</el-table-column>
<!-- 显示领取时间的表格列使用日期格式化过滤器 -->
<el-table-column label="领取时间" width="160" align="center">
<template slot-scope="scope">{{scope.row.createTime | formatTime}}</template>
</el-table-column>
<!-- 显示当前状态的表格列使用过滤器格式化内容 -->
<el-table-column label="当前状态" width="140" align="center">
<template slot-scope="scope">{{scope.row.useStatus | formatCouponHistoryUseType}}</template>
</el-table-column>
<!-- 显示使用时间的表格列使用日期格式化过滤器 -->
<el-table-column label="使用时间" width="160" align="center">
<template slot-scope="scope">{{scope.row.useTime | formatTime}}</template>
</el-table-column>
<!-- 显示订单编号的表格列做了空值处理 -->
<el-table-column label="订单编号" align="center">
<template slot-scope="scope">{{scope.row.orderSn===null?'N/A':scope.row.orderSn}}</template>
</el-table-column>
</el-table>
</div>
<!-- 分页组件的容器 -->
<div class="pagination-container">
<!-- 分页组件设置背景各类事件绑定页面尺寸等属性 -->
<el-pagination
background
@size-change="handleSizeChange"
@ -114,11 +165,15 @@
</div>
</template>
<script>
import {formatDate} from '@/utils/date';
import {getCoupon} from '@/api/coupon';
import {fetchList as fetchCouponHistoryList} from '@/api/couponHistory';
// '@/utils/date'formatDate
import {formatDate} from '@/utils/date';
// '@/api/coupon'getCoupon
import {getCoupon} from '@/api/coupon';
// '@/api/couponHistory'fetchCouponHistoryList
import {fetchList as fetchCouponHistoryList} from '@/api/couponHistory';
const defaultTypeOptions = [
//
const defaultTypeOptions = [
{
label: '全场赠券',
value: 0
@ -135,15 +190,17 @@
label: '注册赠券',
value: 3
}
];
const defaultListQuery = {
];
// 使
const defaultListQuery = {
pageNum: 1,
pageSize: 10,
useStatus: null,
orderSn: null,
couponId: null
};
const defaultUseTypeOptions= [
};
// 使使使
const defaultUseTypeOptions = [
{
label: "未使用",
value: 0
@ -156,27 +213,38 @@
label: "已过期",
value: 2
}
];
export default {
];
export default {
name: 'couponHistoryList',
data() {
return {
//
coupon: {},
//
listQuery: Object.assign({}, defaultListQuery),
useTypeOptions:Object.assign({},defaultUseTypeOptions),
list:null,
total:null,
listLoading:false
// 使
useTypeOptions: Object.assign({}, defaultUseTypeOptions),
// null
list: null,
// null
total: null,
// false
listLoading: false
}
},
created() {
// coupon
getCoupon(this.$route.query.id).then(response => {
this.coupon = response.data;
});
this.listQuery.couponId=this.$route.query.id;
// id
this.listQuery.couponId = this.$route.query.id;
//
this.getList();
},
filters: {
//
formatType(type) {
for (let i = 0; i < defaultTypeOptions.length; i++) {
if (type === defaultTypeOptions[i].value) {
@ -185,6 +253,7 @@
}
return '';
},
// 使
formatUseType(useType) {
if (useType === 0) {
return '全场通用';
@ -194,6 +263,7 @@
return '指定商品';
}
},
//
formatPlatform(platform) {
if (platform === 1) {
return '移动平台';
@ -203,6 +273,7 @@
return '全平台';
}
},
//
formatDate(time) {
if (time == null || time === '') {
return 'N/A';
@ -210,6 +281,7 @@
let date = new Date(time);
return formatDate(date, 'yyyy-MM-dd')
},
//
formatStatus(endTime) {
let now = new Date().getTime();
if (endTime > now) {
@ -218,13 +290,15 @@
return '已过期';
}
},
//
formatGetType(type) {
if(type===1){
if (type === 1) {
return '主动获取';
}else{
} else {
return '后台赠送';
}
},
// 使
formatCouponHistoryUseType(useType) {
if (useType === 0) {
return '未使用';
@ -234,6 +308,7 @@
return '已过期';
}
},
//
formatTime(time) {
if (time == null || time === '') {
return 'N/A';
@ -243,51 +318,58 @@
},
},
methods: {
getList(){
this.listLoading=true;
fetchCouponHistoryList(this.listQuery).then(response=>{
this.listLoading=false;
this.list=response.data.list;
this.total=response.data.total;
// true
getList() {
this.listLoading = true;
fetchCouponHistoryList(this.listQuery).then(response => {
this.listLoading = false;
this.list = response.data.list;
this.total = response.data.total;
});
},
// id
handleResetSearch() {
this.listQuery = Object.assign({}, defaultListQuery);
this.listQuery.couponId=this.$route.query.id;
this.listQuery.couponId = this.$route.query.id;
},
//
handleSearchList() {
this.listQuery.pageNum = 1;
this.getList();
},
//
handleSizeChange(val) {
this.listQuery.pageNum = 1;
this.listQuery.pageSize = val;
this.getList();
},
//
handleCurrentChange(val) {
this.listQuery.pageNum = val;
this.getList();
}
}
}
}
</script>
<style scoped>
.app-container {
<!-- 定义类名为app-container的样式设置宽度外边距使其水平居中 -->
.app-container {
width: 80%;
margin: 20px auto;
}
.filter-container {
}
<!-- 定义类名为filter-container的样式设置上边距 -->
.filter-container {
margin-top: 20px;
}
.table-layout {
}
<!-- 定义类名为table-layout的样式设置上边距左边框上边框 -->
.table-layout {
margin-top: 20px;
border-left: 1px solid #DCDFE6;
border-top: 1px solid #DCDFE6;
}
.table-cell {
}
<!-- 定义类名为table-cell的样式设置高度行高边框内边距字体大小颜色文本对齐溢出处理等属性 -->
.table-cell {
height: 60px;
line-height: 40px;
border-right: 1px solid #DCDFE6;
@ -297,9 +379,9 @@
color: #606266;
text-align: center;
overflow: hidden;
}
.table-cell-title {
}
<!-- 定义类名为table-cell-title的样式设置边框内边距背景色文本对齐字体大小颜色等属性 -->
.table-cell-title {
border-right: 1px solid #DCDFE6;
border-bottom: 1px solid #DCDFE6;
padding: 10px;
@ -307,7 +389,7 @@
text-align: center;
font-size: 14px;
color: #303133;
}
}
</style>

@ -1,9 +1,14 @@
<template> 
<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"
@ -11,6 +16,7 @@
size="small">
查询搜索
</el-button>
<!-- 用于重置筛选条件的按钮绑定点击事件设置样式等属性 -->
<el-button
style="float:right;margin-right: 15px"
@click="handleResetSearch()"
@ -19,12 +25,18 @@
</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"
@ -35,54 +47,72 @@
</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>
@ -90,7 +120,9 @@
</el-table-column>
</el-table>
</div>
<!-- 分页组件的容器 -->
<div class="pagination-container">
<!-- 分页组件设置背景各类事件绑定页面尺寸等属性 -->
<el-pagination
background
@size-change="handleSizeChange"
@ -105,15 +137,20 @@
</div>
</template>
<script>
import {fetchList,deleteCoupon} from '@/api/coupon';
import {formatDate} from '@/utils/date';
const defaultListQuery = {
// '@/api/coupon'
import {fetchList, deleteCoupon} from '@/api/coupon';
// '@/utils/date'formatDate
import {formatDate} from '@/utils/date';
//
const defaultListQuery = {
pageNum: 1,
pageSize: 10,
name: null,
type: null
};
const defaultTypeOptions=[
};
//
const defaultTypeOptions = [
{
label: '全场赠券',
value: 0
@ -130,102 +167,124 @@
label: '注册赠券',
value: 3
}
];
export default {
name:'couponList',
];
export default {
name: 'couponList',
data() {
return {
listQuery:Object.assign({},defaultListQuery),
typeOptions:Object.assign({},defaultTypeOptions),
list:null,
total:null,
listLoading:false,
multipleSelection:[]
//
listQuery: Object.assign({}, defaultListQuery),
//
typeOptions: Object.assign({}, defaultTypeOptions),
// null
list: null,
// null
total: null,
// false
listLoading: false,
//
multipleSelection: []
}
},
created(){
created() {
//
this.getList();
},
filters:{
formatType(type){
for(let i=0;i<defaultTypeOptions.length;i++){
if(type===defaultTypeOptions[i].value){
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){
// 使
formatUseType(useType) {
if (useType === 0) {
return '全场通用';
}else if(useType===1){
} else if (useType === 1) {
return '指定分类';
}else{
} else {
return '指定商品';
}
},
formatPlatform(platform){
if(platform===1){
//
formatPlatform(platform) {
if (platform === 1) {
return '移动平台';
}else if(platform===2){
} else if (platform === 2) {
return 'PC平台';
}else{
} else {
return '全平台';
}
},
formatDate(time){
if(time==null||time===''){
//
formatDate(time) {
if (time == null || time === '') {
return 'N/A';
}
let date = new Date(time);
return formatDate(date, 'yyyy-MM-dd')
},
formatStatus(endTime){
//
formatStatus(endTime) {
let now = new Date().getTime();
let endDate = new Date(endTime);
if(endDate>now){
if (endDate > now) {
return '未过期'
}else{
} else {
return '已过期';
}
}
},
methods:{
methods: {
//
handleResetSearch() {
this.listQuery = Object.assign({}, defaultListQuery);
},
//
handleSearchList() {
this.listQuery.pageNum = 1;
this.getList();
},
handleSelectionChange(val){
//
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(){
//
handleAdd() {
this.$router.push({path: '/sms/addCoupon'})
},
// id
handleView(index, row) {
this.$router.push({path: '/sms/couponHistory', query: {id: row.id}})
},
// 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=>{
deleteCoupon(row.id).then(response => {
this.$message({
type: 'success',
message: '删除成功!'
@ -234,18 +293,20 @@
});
})
},
getList(){
this.listLoading=true;
fetchList(this.listQuery).then(response=>{
// true
getList() {
this.listLoading = true;
fetchList(this.listQuery).then(response => {
this.listLoading = false;
this.list = response.data.list;
this.total = response.data.total;
});
}
}
}
}
</script>
<style scoped>
<!-- scoped属性使样式仅作用于当前组件.input-width类设置元素宽度为203px -->
.input-width {
width: 203px;
}

@ -1,14 +1,21 @@
<template> 
<template>
<!-- 在模板中使用了coupon-detail组件并传递isEdit属性值为true可能用于告知该组件当前处于编辑模式 -->
<coupon-detail :isEdit="true"></coupon-detail>
</template>
<script>
import CouponDetail from './components/CouponDetail'
export default {
// './components/CouponDetail'CouponDetail
import CouponDetail from './components/CouponDetail';
export default {
// updateCoupon
name: 'updateCoupon',
// CouponDetail使使
components: { CouponDetail }
}
}
</script>
<style scoped>
<!-- 带有scoped属性的style标签里面样式仅作用于当前组件目前为空 -->
</style>

Loading…
Cancel
Save