branch_lyj
Liuyujie 7 months ago
parent f77570e5f0
commit 7d848d789f

@ -1,9 +1,14 @@
<template>  <template>
<!-- 整个页面的外层容器用于对内部各部分内容进行整体布局 -->
<div class="app-container"> <div class="app-container">
<!-- 筛选搜索区域的卡片容器设置了无阴影效果 -->
<el-card class="filter-container" shadow="never"> <el-card class="filter-container" shadow="never">
<div> <div>
<!-- 显示搜索图标用于提示此处可进行搜索操作 -->
<i class="el-icon-search"></i> <i class="el-icon-search"></i>
<!-- 显示筛选搜索文字明确此处功能 -->
<span>筛选搜索</span> <span>筛选搜索</span>
<!-- 用于触发查询搜索操作的按钮设置了按钮样式类型为主要按钮绑定了点击事件handleSearchList -->
<el-button <el-button
style="float:right" style="float:right"
type="primary" type="primary"
@ -11,6 +16,7 @@
size="small"> size="small">
查询搜索 查询搜索
</el-button> </el-button>
<!-- 用于触发重置筛选条件操作的按钮设置了按钮样式与右侧有一定间距绑定了点击事件handleResetSearch -->
<el-button <el-button
style="float:right;margin-right: 15px" style="float:right;margin-right: 15px"
@click="handleResetSearch()" @click="handleResetSearch()"
@ -19,42 +25,75 @@
</el-button> </el-button>
</div> </div>
<div style="margin-top: 15px"> <div style="margin-top: 15px">
<!-- 行内表单用于设置筛选条件绑定了数据模型listQuery设置了表单尺寸和标签宽度 -->
<el-form :inline="true" :model="listQuery" size="small" label-width="140px"> <el-form :inline="true" :model="listQuery" size="small" label-width="140px">
<!-- 对应活动名称输入框的表单项 -->
<el-form-item label="活动名称:"> <el-form-item label="活动名称:">
<!-- 输入框双向绑定listQuery.keyword数据设置了类名占位提示以及可清除内容的属性 -->
<el-input v-model="listQuery.keyword" class="input-width" placeholder="活动名称" clearable></el-input> <el-input v-model="listQuery.keyword" class="input-width" placeholder="活动名称" clearable></el-input>
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
</el-card> </el-card>
<!-- 操作区域的卡片容器同样设置了无阴影效果 -->
<el-card class="operate-container" shadow="never"> <el-card class="operate-container" shadow="never">
<i class="el-icon-tickets"></i> <i class="el-icon-tickets"></i>
<span>数据列表</span> <span>数据列表</span>
<!-- 用于触发添加活动操作的按钮设置了按钮尺寸类名绑定了点击事件handleAdd -->
<el-button size="mini" class="btn-add" @click="handleAdd()" style="margin-left: 20px">添加活动</el-button> <el-button size="mini" class="btn-add" @click="handleAdd()" style="margin-left: 20px">添加活动</el-button>
<!-- 用于触发查看秒杀时间段列表操作的按钮设置了按钮尺寸类名绑定了点击事件handleShowSessionList -->
<el-button size="mini" class="btn-add" @click="handleShowSessionList()"></el-button> <el-button size="mini" class="btn-add" @click="handleShowSessionList()"></el-button>
</el-card> </el-card>
<!-- 放置数据表格的容器 -->
<div class="table-container"> <div class="table-container">
<!-- 数据表格组件绑定了数据list设置了宽度加载状态以及边框等属性 -->
<el-table ref="flashTable" <el-table ref="flashTable"
:data="list" :data="list"
style="width: 100%;" style="width: 100%;"
v-loading="listLoading" border> v-loading="listLoading" border>
<!-- 显示选择框的表格列用于多选操作设置了宽度和对齐方式 -->
<el-table-column type="selection" width="60" align="center"></el-table-column> <el-table-column type="selection" width="60" align="center"></el-table-column>
<!-- 显示编号的表格列设置了宽度和对齐方式 -->
<el-table-column label="编号" width="100" align="center"> <el-table-column label="编号" width="100" align="center">
<template slot-scope="scope">{{scope.row.id}}</template> <template slot-scope="scope">
<!-- 在表格单元格的作用域内显示对应行数据中的id字段内容 -->
{{scope.row.id}}
</template>
</el-table-column> </el-table-column>
<!-- 显示活动标题的表格列内容居中对齐 -->
<el-table-column label="活动标题" align="center"> <el-table-column label="活动标题" align="center">
<template slot-scope="scope">{{scope.row.title}}</template> <template slot-scope="scope">
<!-- 在表格单元格的作用域内显示对应行数据中的title字段内容 -->
{{scope.row.title}}
</template>
</el-table-column> </el-table-column>
<!-- 显示活动状态的表格列设置了宽度和对齐方式使用了过滤器formatActiveStatus来格式化显示内容 -->
<el-table-column label="活动状态" width="140" align="center"> <el-table-column label="活动状态" width="140" align="center">
<template slot-scope="scope">{{scope.row |formatActiveStatus}}</template> <template slot-scope="scope">
<!-- 在表格单元格的作用域内使用过滤器对对应行数据进行格式化后显示 -->
{{scope.row | formatActiveStatus}}
</template>
</el-table-column> </el-table-column>
<!-- 显示开始时间的表格列设置了宽度和对齐方式使用了日期格式化过滤器formatDate -->
<el-table-column label="开始时间" width="140" align="center"> <el-table-column label="开始时间" width="140" align="center">
<template slot-scope="scope">{{scope.row.startDate | formatDate}}</template> <template slot-scope="scope">
<!-- 在表格单元格的作用域内使用日期格式化过滤器对对应行数据中的时间进行格式化后显示 -->
{{scope.row.startDate | formatDate}}
</template>
</el-table-column> </el-table-column>
<!-- 显示结束时间的表格列设置了宽度和对齐方式同样使用了日期格式化过滤器formatDate -->
<el-table-column label="结束时间" width="140" align="center"> <el-table-column label="结束时间" width="140" align="center">
<template slot-scope="scope">{{scope.row.endDate | formatDate}}</template> <template slot-scope="scope">
<!-- 在表格单元格的作用域内使用日期格式化过滤器对对应行数据中的时间进行格式化后显示 -->
{{scope.row.endDate | formatDate}}
</template>
</el-table-column> </el-table-column>
<!-- 显示上线/下线操作的表格列设置了宽度和对齐方式里面包含一个开关组件 -->
<el-table-column label="上线/下线" width="200" align="center"> <el-table-column label="上线/下线" width="200" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<!-- 开关组件用于切换上线/下线状态绑定了状态改变的事件handleStatusChange设置了激活值和未激活值双向绑定对应行数据中的status字段 -->
<el-switch <el-switch
@change="handleStatusChange(scope.$index, scope.row)" @change="handleStatusChange(scope.$index, scope.row)"
:active-value="1" :active-value="1"
@ -63,17 +102,21 @@
</el-switch> </el-switch>
</template> </template>
</el-table-column> </el-table-column>
<!-- 显示操作按钮的表格列设置了宽度和对齐方式 -->
<el-table-column label="操作" width="180" align="center"> <el-table-column label="操作" width="180" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<!-- 用于触发设置商品操作的按钮设置了按钮尺寸类型为文本按钮绑定了点击事件handleSelectSession -->
<el-button size="mini" <el-button size="mini"
type="text" type="text"
@click="handleSelectSession(scope.$index, scope.row)">设置商品 @click="handleSelectSession(scope.$index, scope.row)">设置商品
</el-button> </el-button>
<!-- 用于触发编辑操作的按钮设置了按钮尺寸类型为文本按钮绑定了点击事件handleUpdate -->
<el-button size="mini" <el-button size="mini"
type="text" type="text"
@click="handleUpdate(scope.$index, scope.row)"> @click="handleUpdate(scope.$index, scope.row)">
编辑 编辑
</el-button> </el-button>
<!-- 用于触发删除操作的按钮设置了按钮尺寸类型为文本按钮绑定了点击事件handleDelete -->
<el-button size="mini" <el-button size="mini"
type="text" type="text"
@click="handleDelete(scope.$index, scope.row)">删除 @click="handleDelete(scope.$index, scope.row)">删除
@ -82,7 +125,10 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
</div> </div>
<!-- 分页组件的容器 -->
<div class="pagination-container"> <div class="pagination-container">
<!-- 分页组件设置了背景显示页面尺寸改变和当前页码改变的事件绑定以及布局当前页码每页显示数量可选的页面尺寸和数据总条数等属性 -->
<el-pagination <el-pagination
background background
@size-change="handleSizeChange" @size-change="handleSizeChange"
@ -94,16 +140,22 @@
:total="total"> :total="total">
</el-pagination> </el-pagination>
</div> </div>
<!-- 弹出对话框组件用于添加活动的相关操作设置了标题对话框显示状态的双向绑定以及宽度属性 -->
<el-dialog <el-dialog
title="添加活动" title="添加活动"
:visible.sync="dialogVisible" :visible.sync="dialogVisible"
width="40%"> width="40%">
<!-- 表单组件用于在对话框内收集添加活动的相关信息绑定了数据模型flashPromotion设置了表单引用标签宽度和尺寸等属性 -->
<el-form :model="flashPromotion" <el-form :model="flashPromotion"
ref="flashPromotionForm" ref="flashPromotionForm"
label-width="150px" size="small"> label-width="150px" size="small">
<!-- 对应活动标题输入框的表单项 -->
<el-form-item label="活动标题:"> <el-form-item label="活动标题:">
<!-- 输入框双向绑定flashPromotion.title数据设置了宽度 -->
<el-input v-model="flashPromotion.title" style="width: 250px"></el-input> <el-input v-model="flashPromotion.title" style="width: 250px"></el-input>
</el-form-item> </el-form-item>
<!-- 对应开始时间选择框的表单项使用了日期选择器组件 -->
<el-form-item label="开始时间:"> <el-form-item label="开始时间:">
<el-date-picker <el-date-picker
v-model="flashPromotion.startDate" v-model="flashPromotion.startDate"
@ -111,6 +163,7 @@
placeholder="请选择时间"> placeholder="请选择时间">
</el-date-picker> </el-date-picker>
</el-form-item> </el-form-item>
<!-- 对应结束时间选择框的表单项同样使用了日期选择器组件 -->
<el-form-item label="结束时间:"> <el-form-item label="结束时间:">
<el-date-picker <el-date-picker
v-model="flashPromotion.endDate" v-model="flashPromotion.endDate"
@ -118,98 +171,136 @@
placeholder="请选择时间"> placeholder="请选择时间">
</el-date-picker> </el-date-picker>
</el-form-item> </el-form-item>
<!-- 对应上线/下线选择的表单项使用了单选按钮组组件 -->
<el-form-item label="上线/下线"> <el-form-item label="上线/下线">
<el-radio-group v-model="flashPromotion.status"> <el-radio-group v-model="flashPromotion.status">
<!-- 上线单选按钮选项 -->
<el-radio :label="1">上线</el-radio> <el-radio :label="1">上线</el-radio>
<!-- 下线单选按钮选项 -->
<el-radio :label="0">下线</el-radio> <el-radio :label="0">下线</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
</el-form> </el-form>
<!-- 对话框底部的操作按钮区域使用了插槽footer -->
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<!-- 取消按钮点击可关闭对话框设置了按钮尺寸 -->
<el-button @click="dialogVisible = false" size="small"> </el-button> <el-button @click="dialogVisible = false" size="small"> </el-button>
<!-- 确定按钮点击可触发确认添加活动的相关逻辑设置了按钮类型为主要按钮尺寸为小尺寸 -->
<el-button type="primary" @click="handleDialogConfirm()" size="small"> </el-button> <el-button type="primary" @click="handleDialogConfirm()" size="small"> </el-button>
</span> </span>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
<script> <script>
import {fetchList, updateStatus, deleteFlash, createFlash, updateFlash} from '@/api/flash'; // '@/api/flash'
import {formatDate} from '@/utils/date'; import {fetchList, updateStatus, deleteFlash, createFlash, updateFlash} from '@/api/flash';
// '@/utils/date'formatDate
import {formatDate} from '@/utils/date';
const defaultListQuery = { //
const defaultListQuery = {
pageNum: 1, pageNum: 1,
pageSize: 5, pageSize: 5,
keyword: null keyword: null
}; };
const defaultFlashPromotion = { //
const defaultFlashPromotion = {
id: null, id: null,
title: null, title: null,
startDate: null, startDate: null,
endDate: null, endDate: null,
status: 0 status: 0
}; };
export default {
export default {
name: 'flashPromotionList', name: 'flashPromotionList',
data() { data() {
return { return {
// defaultListQuery
listQuery: Object.assign({}, defaultListQuery), listQuery: Object.assign({}, defaultListQuery),
// null
list: null, list: null,
// null
total: null, total: null,
// falsetrue
listLoading: false, listLoading: false,
// /false
dialogVisible: false, dialogVisible: false,
// defaultFlashPromotion
flashPromotion: Object.assign({}, defaultFlashPromotion), flashPromotion: Object.assign({}, defaultFlashPromotion),
// truefalsefalse
isEdit: false isEdit: false
} }
}, },
created() { created() {
//
this.getList(); this.getList();
}, },
filters: { filters: {
//
formatActiveStatus(row) { formatActiveStatus(row) {
//
let nowDate = new Date(); let nowDate = new Date();
//
let startDate = new Date(row.startDate); let startDate = new Date(row.startDate);
//
let endDate = new Date(row.endDate); let endDate = new Date(row.endDate);
//
if (nowDate.getTime() >= startDate.getTime() && nowDate.getTime() <= endDate.getTime()) { if (nowDate.getTime() >= startDate.getTime() && nowDate.getTime() <= endDate.getTime()) {
return '活动进行中'; return '活动进行中';
} else if (nowDate.getTime() > endDate.getTime()) { }
//
else if (nowDate.getTime() > endDate.getTime()) {
return '活动已结束'; return '活动已结束';
} else { }
//
else {
return '活动未开始'; return '活动未开始';
} }
}, },
// 'N/A'
formatDate(time) { formatDate(time) {
if (time == null || time === '') { if (time == null || time === '') {
return 'N/A'; return 'N/A';
} }
//
let date = new Date(time); let date = new Date(time);
// formatDate 'yyyy-MM-dd'
return formatDate(date, 'yyyy-MM-dd') return formatDate(date, 'yyyy-MM-dd')
} }
}, },
methods: { methods: {
// 便
handleResetSearch() { handleResetSearch() {
this.listQuery = Object.assign({}, defaultListQuery); this.listQuery = Object.assign({}, defaultListQuery);
}, },
// 1
handleSearchList() { handleSearchList() {
this.listQuery.pageNum = 1; this.listQuery.pageNum = 1;
this.getList(); this.getList();
}, },
// 1
handleSizeChange(val) { handleSizeChange(val) {
this.listQuery.pageNum = 1; this.listQuery.pageNum = 1;
this.listQuery.pageSize = val; this.listQuery.pageSize = val;
this.getList(); this.getList();
}, },
//
handleCurrentChange(val) { handleCurrentChange(val) {
this.listQuery.pageNum = val; this.listQuery.pageNum = val;
this.getList(); this.getList();
}, },
// true
handleAdd() { handleAdd() {
this.dialogVisible = true; this.dialogVisible = true;
this.isEdit = false; this.isEdit = false;
this.flashPromotion = Object.assign({},defaultFlashPromotion); this.flashPromotion = Object.assign({}, defaultFlashPromotion);
}, },
// '/sms/flashSession'
handleShowSessionList() { handleShowSessionList() {
this.$router.push({path: '/sms/flashSession'}) this.$router.push({path: '/sms/flashSession'})
}, },
//
handleStatusChange(index, row) { handleStatusChange(index, row) {
this.$confirm('是否要修改该状态?', '提示', { this.$confirm('是否要修改该状态?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
@ -230,6 +321,7 @@
this.getList(); this.getList();
}); });
}, },
//
handleDelete(index, row) { handleDelete(index, row) {
this.$confirm('是否要删除该活动?', '提示', { this.$confirm('是否要删除该活动?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
@ -245,11 +337,13 @@
}); });
}); });
}, },
// true便
handleUpdate(index, row) { handleUpdate(index, row) {
this.dialogVisible = true; this.dialogVisible = true;
this.isEdit = true; this.isEdit = true;
this.flashPromotion = Object.assign({},row); this.flashPromotion = Object.assign({}, row);
}, },
//
handleDialogConfirm() { handleDialogConfirm() {
this.$confirm('是否要确认?', '提示', { this.$confirm('是否要确认?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
@ -257,12 +351,12 @@
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
if (this.isEdit) { if (this.isEdit) {
updateFlash(this.flashPromotion.id,this.flashPromotion).then(response => { updateFlash(this.flashPromotion.id, this.flashPromotion).then(response => {
this.$message({ this.$message({
message: '修改成功!', message: '修改成功!',
type: 'success' type: 'success'
}); });
this.dialogVisible =false; this.dialogVisible = false;
this.getList(); this.getList();
}) })
} else { } else {
@ -271,15 +365,17 @@
message: '添加成功!', message: '添加成功!',
type: 'success' type: 'success'
}); });
this.dialogVisible =false; this.dialogVisible = false;
this.getList(); this.getList();
}) })
} }
}) })
}, },
handleSelectSession(index,row){ // '/sms/selectSession' id
this.$router.push({path:'/sms/selectSession',query:{flashPromotionId:row.id}}) handleSelectSession(index, row) {
this.$router.push({path: '/sms/selectSession', query: {flashPromotionId: row.id}})
}, },
// truefalse
getList() { getList() {
this.listLoading = true; this.listLoading = true;
fetchList(this.listQuery).then(response => { fetchList(this.listQuery).then(response => {
@ -289,7 +385,7 @@
}); });
} }
} }
} }
</script> </script>
<style></style> <style></style>

@ -1,52 +1,95 @@
<template>  <template>
<!-- 整个页面的外层容器用于对内部各部分内容进行整体布局 -->
<div class="app-container"> <div class="app-container">
<!-- 操作区域的卡片容器设置了无阴影效果 -->
<el-card class="operate-container" shadow="never"> <el-card class="operate-container" shadow="never">
<i class="el-icon-tickets"></i> <i class="el-icon-tickets"></i>
<span>数据列表</span> <span>数据列表</span>
<!-- 用于触发添加操作的按钮设置了按钮尺寸类名绑定了点击事件handleSelectProduct并且与左侧有一定间距 -->
<el-button size="mini" class="btn-add" @click="handleSelectProduct()" style="margin-left: 20px">添加</el-button> <el-button size="mini" class="btn-add" @click="handleSelectProduct()" style="margin-left: 20px">添加</el-button>
</el-card> </el-card>
<!-- 放置数据表格的容器用于展示商品相关数据列表 -->
<div class="table-container"> <div class="table-container">
<!-- 数据表格组件绑定了数据list设置了表格引用宽度加载状态以及边框等属性 -->
<el-table ref="productRelationTable" <el-table ref="productRelationTable"
:data="list" :data="list"
style="width: 100%;" style="width: 100%;"
v-loading="listLoading" border> v-loading="listLoading" border>
<!-- 显示编号的表格列设置了宽度和对齐方式 -->
<el-table-column label="编号" width="100" align="center"> <el-table-column label="编号" width="100" align="center">
<template slot-scope="scope">{{scope.row.id}}</template> <template slot-scope="scope">
<!-- 在表格单元格的作用域内显示对应行数据中的id字段内容 -->
{{scope.row.id}}
</template>
</el-table-column> </el-table-column>
<!-- 显示商品名称的表格列内容居中对齐显示的是每行数据中关联商品对象里的name字段 -->
<el-table-column label="商品名称" align="center"> <el-table-column label="商品名称" align="center">
<template slot-scope="scope">{{scope.row.product.name}}</template> <template slot-scope="scope">
<!-- 在表格单元格的作用域内显示对应行数据中关联商品对象里的name字段内容 -->
{{scope.row.product.name}}
</template>
</el-table-column> </el-table-column>
<!-- 显示货号的表格列设置了宽度和对齐方式展示格式为NO.加上商品的货号 -->
<el-table-column label="货号" width="140" align="center"> <el-table-column label="货号" width="140" align="center">
<template slot-scope="scope">NO.{{scope.row.product.productSn}}</template> <template slot-scope="scope">
<!-- 在表格单元格的作用域内按照特定格式显示对应行数据中关联商品对象里的productSn字段内容 -->
NO.{{scope.row.product.productSn}}
</template>
</el-table-column> </el-table-column>
<!-- 显示商品价格的表格列设置了宽度和对齐方式展示格式为加上商品价格 -->
<el-table-column label="商品价格" width="100" align="center"> <el-table-column label="商品价格" width="100" align="center">
<template slot-scope="scope">{{scope.row.product.price}}</template> <template slot-scope="scope">
<!-- 在表格单元格的作用域内按照特定格式显示对应行数据中关联商品对象里的price字段内容 -->
{{scope.row.product.price}}
</template>
</el-table-column> </el-table-column>
<!-- 显示剩余数量的表格列设置了宽度和对齐方式直接显示商品的剩余数量 -->
<el-table-column label="剩余数量" width="100" align="center"> <el-table-column label="剩余数量" width="100" align="center">
<template slot-scope="scope">{{scope.row.product.stock}}</template> <template slot-scope="scope">
<!-- 在表格单元格的作用域内显示对应行数据中关联商品对象里的stock字段内容 -->
{{scope.row.product.stock}}
</template>
</el-table-column> </el-table-column>
<!-- 显示秒杀价格的表格列设置了宽度和对齐方式根据秒杀价格是否为空进行不同展示若不为空则显示加上秒杀价格 -->
<el-table-column label="秒杀价格" width="100" align="center"> <el-table-column label="秒杀价格" width="100" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<!-- 使用v-if指令判断秒杀价格是否不为空如果是则按照特定格式显示 -->
<p v-if="scope.row.flashPromotionPrice!==null"> <p v-if="scope.row.flashPromotionPrice!==null">
{{scope.row.flashPromotionPrice}} {{scope.row.flashPromotionPrice}}
</p> </p>
</template> </template>
</el-table-column> </el-table-column>
<!-- 显示秒杀数量的表格列设置了宽度和对齐方式直接显示商品的秒杀数量 -->
<el-table-column label="秒杀数量" width="100" align="center"> <el-table-column label="秒杀数量" width="100" align="center">
<template slot-scope="scope">{{scope.row.flashPromotionCount}}</template> <template slot-scope="scope">
<!-- 在表格单元格的作用域内显示对应行数据中的flashPromotionCount字段内容 -->
{{scope.row.flashPromotionCount}}
</template>
</el-table-column> </el-table-column>
<!-- 显示限购数量的表格列设置了宽度和对齐方式直接显示商品的限购数量 -->
<el-table-column label="限购数量" width="100" align="center"> <el-table-column label="限购数量" width="100" align="center">
<template slot-scope="scope">{{scope.row.flashPromotionLimit}}</template> <template slot-scope="scope">
<!-- 在表格单元格的作用域内显示对应行数据中的flashPromotionLimit字段内容 -->
{{scope.row.flashPromotionLimit}}
</template>
</el-table-column> </el-table-column>
<!-- 显示排序的表格列设置了宽度和对齐方式直接显示商品的排序值 -->
<el-table-column label="排序" width="100" align="center"> <el-table-column label="排序" width="100" align="center">
<template slot-scope="scope">{{scope.row.sort}}</template> <template slot-scope="scope">
<!-- 在表格单元格的作用域内显示对应行数据中的sort字段内容 -->
{{scope.row.sort}}
</template>
</el-table-column> </el-table-column>
<!-- 显示操作按钮的表格列设置了宽度和对齐方式 -->
<el-table-column label="操作" width="100" align="center"> <el-table-column label="操作" width="100" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<!-- 用于触发编辑操作的按钮设置了按钮尺寸类型为文本按钮绑定了点击事件handleUpdate -->
<el-button size="mini" <el-button size="mini"
type="text" type="text"
@click="handleUpdate(scope.$index, scope.row)">编辑 @click="handleUpdate(scope.$index, scope.row)">编辑
</el-button> </el-button>
<!-- 用于触发删除操作的按钮设置了按钮尺寸类型为文本按钮绑定了点击事件handleDelete -->
<el-button size="mini" <el-button size="mini"
type="text" type="text"
@click="handleDelete(scope.$index, scope.row)">删除 @click="handleDelete(scope.$index, scope.row)">删除
@ -55,7 +98,10 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
</div> </div>
<!-- 分页组件的容器用于对商品数据列表进行分页操作 -->
<div class="pagination-container"> <div class="pagination-container">
<!-- 分页组件设置了背景显示页面尺寸改变和当前页码改变的事件绑定以及布局当前页码每页显示数量可选的页面尺寸和数据总条数等属性 -->
<el-pagination <el-pagination
background background
@size-change="handleSizeChange" @size-change="handleSizeChange"
@ -67,27 +113,47 @@
:total="total"> :total="total">
</el-pagination> </el-pagination>
</div> </div>
<!-- 弹出对话框组件用于选择商品操作设置了标题对话框显示状态的双向绑定以及宽度属性 -->
<el-dialog title="选择商品" :visible.sync="selectDialogVisible" width="50%"> <el-dialog title="选择商品" :visible.sync="selectDialogVisible" width="50%">
<!-- 输入框组件用于在对话框内输入关键词进行商品搜索双向绑定了dialogData.listQuery.keyword数据设置了宽度外边距尺寸以及占位提示等属性并且包含一个搜索图标按钮 -->
<el-input v-model="dialogData.listQuery.keyword" <el-input v-model="dialogData.listQuery.keyword"
style="width: 250px;margin-bottom: 20px" style="width: 250px;margin-bottom: 20px"
size="small" size="small"
placeholder="商品名称搜索"> placeholder="商品名称搜索">
<!-- 搜索图标按钮放置在输入框的尾部点击可触发handleSelectSearch事件 -->
<el-button slot="append" icon="el-icon-search" @click="handleSelectSearch()"></el-button> <el-button slot="append" icon="el-icon-search" @click="handleSelectSearch()"></el-button>
</el-input> </el-input>
<!-- 数据表格组件用于在对话框内展示搜索到的商品列表绑定了数据dialogData.list并设置了选择改变的事件绑定以及边框属性 -->
<el-table :data="dialogData.list" <el-table :data="dialogData.list"
@selection-change="handleDialogSelectionChange" border> @selection-change="handleDialogSelectionChange" border>
<!-- 显示选择框的表格列用于多选操作设置了宽度和对齐方式 -->
<el-table-column type="selection" width="60" align="center"></el-table-column> <el-table-column type="selection" width="60" align="center"></el-table-column>
<!-- 显示商品名称的表格列内容居中对齐直接显示商品的名称 -->
<el-table-column label="商品名称" align="center"> <el-table-column label="商品名称" align="center">
<template slot-scope="scope">{{scope.row.name}}</template> <template slot-scope="scope">
<!-- 在表格单元格的作用域内显示对应行数据中的name字段内容 -->
{{scope.row.name}}
</template>
</el-table-column> </el-table-column>
<!-- 显示货号的表格列设置了宽度和对齐方式展示格式为NO.加上商品的货号 -->
<el-table-column label="货号" width="160" align="center"> <el-table-column label="货号" width="160" align="center">
<template slot-scope="scope">NO.{{scope.row.productSn}}</template> <template slot-scope="scope">
<!-- 在表格单元格的作用域内按照特定格式显示对应行数据中的productSn字段内容 -->
NO.{{scope.row.productSn}}
</template>
</el-table-column> </el-table-column>
<!-- 显示价格的表格列设置了宽度和对齐方式展示格式为加上商品价格 -->
<el-table-column label="价格" width="120" align="center"> <el-table-column label="价格" width="120" align="center">
<template slot-scope="scope">{{scope.row.price}}</template> <template slot-scope="scope">
<!-- 在表格单元格的作用域内按照特定格式显示对应行数据中的price字段内容 -->
{{scope.row.price}}
</template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<!-- 分页组件的容器用于对对话框内的商品列表进行分页操作 -->
<div class="pagination-container"> <div class="pagination-container">
<!-- 分页组件设置了背景显示页面尺寸改变和当前页码改变的事件绑定以及布局当前页码每页显示数量可选的页面尺寸和数据总条数等属性 -->
<el-pagination <el-pagination
background background
@size-change="handleDialogSizeChange" @size-change="handleDialogSizeChange"
@ -99,213 +165,266 @@
:total="dialogData.total"> :total="dialogData.total">
</el-pagination> </el-pagination>
</div> </div>
<!-- 用于清除浮动确保后续元素布局正常 -->
<div style="clear: both;"></div> <div style="clear: both;"></div>
<!-- 对话框底部的操作按钮区域使用了插槽footer -->
<div slot="footer"> <div slot="footer">
<!-- 取消按钮点击可关闭对话框设置了按钮尺寸 -->
<el-button size="small" @click="selectDialogVisible = false"> </el-button> <el-button size="small" @click="selectDialogVisible = false"> </el-button>
<!-- 确定按钮点击可触发确认选择商品的相关逻辑设置了按钮类型为主要按钮尺寸为小尺寸 -->
<el-button size="small" type="primary" @click="handleSelectDialogConfirm()"> </el-button> <el-button size="small" type="primary" @click="handleSelectDialogConfirm()"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
<!-- 弹出对话框组件用于编辑秒杀商品信息操作设置了标题对话框显示状态的双向绑定以及宽度属性 -->
<el-dialog title="编辑秒杀商品信息" <el-dialog title="编辑秒杀商品信息"
:visible.sync="editDialogVisible" :visible.sync="editDialogVisible"
width="40%"> width="40%">
<!-- 表单组件用于在对话框内展示和编辑秒杀商品的相关信息绑定了数据模型flashProductRelation设置了表单引用标签宽度和尺寸等属性 -->
<el-form :model="flashProductRelation" <el-form :model="flashProductRelation"
ref="flashProductRelationForm" ref="flashProductRelationForm"
label-width="150px" size="small"> label-width="150px" size="small">
<!-- 对应商品名称展示的表单项此处直接展示商品名称不可编辑 -->
<el-form-item label="商品名称:"> <el-form-item label="商品名称:">
<span>{{flashProductRelation.product.name}}</span> <span>{{flashProductRelation.product.name}}</span>
</el-form-item> </el-form-item>
<!-- 对应货号展示的表单项此处直接展示货号不可编辑 -->
<el-form-item label="货号:"> <el-form-item label="货号:">
<span>NO.{{flashProductRelation.product.productSn}}</span> <span>NO.{{flashProductRelation.product.productSn}}</span>
</el-form-item> </el-form-item>
<!-- 对应商品价格展示的表单项此处直接展示商品价格不可编辑 -->
<el-form-item label="商品价格:"> <el-form-item label="商品价格:">
<span>{{flashProductRelation.product.price}}</span> <span>{{flashProductRelation.product.price}}</span>
</el-form-item> </el-form-item>
<!-- 对应秒杀价格输入框的表单项使用输入框组件双向绑定flashProductRelation.flashPromotionPrice数据设置了类名并在输入框头部添加符号 -->
<el-form-item label="秒杀价格:"> <el-form-item label="秒杀价格:">
<el-input v-model="flashProductRelation.flashPromotionPrice" class="input-width"> <el-input v-model="flashProductRelation.flashPromotionPrice" class="input-width">
<template slot="prepend"></template> <template slot="prepend"></template>
</el-input> </el-input>
</el-form-item> </el-form-item>
<!-- 对应剩余数量展示的表单项此处直接展示剩余数量不可编辑 -->
<el-form-item label="剩余数量:"> <el-form-item label="剩余数量:">
<span>{{flashProductRelation.product.stock}}</span> <span>{{flashProductRelation.product.stock}}</span>
</el-form-item> </el-form-item>
<!-- 对应秒杀数量输入框的表单项使用输入框组件双向绑定flashProductRelation.flashPromotionCount数据设置了类名 -->
<el-form-item label="秒杀数量:"> <el-form-item label="秒杀数量:">
<el-input v-model="flashProductRelation.flashPromotionCount" class="input-width"></el-input> <el-input v-model="flashProductRelation.flashPromotionCount" class="input-width"></el-input>
</el-form-item> </el-form-item>
<!-- 对应限购数量输入框的表单项使用输入框组件双向绑定flashProductRelation.flashPromotionLimit数据设置了类名 -->
<el-form-item label="限购数量:"> <el-form-item label="限购数量:">
<el-input v-model="flashProductRelation.flashPromotionLimit" class="input-width"></el-input> <el-input v-model="flashProductRelation.flashPromotionLimit" class="input-width"></el-input>
</el-form-item> </el-form-item>
<!-- 对应排序输入框的表单项使用输入框组件双向绑定flashProductRelation.sort数据设置了类名 -->
<el-form-item label="排序:"> <el-form-item label="排序:">
<el-input v-model="flashProductRelation.sort" class="input-width"></el-input> <el-input v-model="flashProductRelation.sort" class="input-width"></el-input>
</el-form-item> </el-form-item>
</el-form> </el-form>
<!-- 对话框底部的操作按钮区域使用了插槽footer -->
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<!-- 取消按钮点击可关闭对话框设置了按钮尺寸 -->
<el-button @click="editDialogVisible = false" size="small"> </el-button> <el-button @click="editDialogVisible = false" size="small"> </el-button>
<!-- 确定按钮点击可触发确认编辑秒杀商品信息的相关逻辑设置了按钮类型为主要按钮尺寸为小尺寸 -->
<el-button type="primary" @click="handleEditDialogConfirm()" size="small"> </el-button> <el-button type="primary" @click="handleEditDialogConfirm()" size="small"> </el-button>
</span> </span>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
<script> <script>
import {fetchList,createFlashProductRelation,deleteFlashProductRelation,updateFlashProductRelation} from '@/api/flashProductRelation'; // '@/api/flashProductRelation'
import {fetchList as fetchProductList} from '@/api/product'; import {fetchList, createFlashProductRelation, deleteFlashProductRelation, updateFlashProductRelation} from '@/api/flashProductRelation';
const defaultListQuery = { // '@/api/product''fetchProductList'
import {fetchList as fetchProductList} from '@/api/product';
// IDID
const defaultListQuery = {
pageNum: 1, pageNum: 1,
pageSize: 5, pageSize: 5,
flashPromotionId: null, flashPromotionId: null,
flashPromotionSessionId: null flashPromotionSessionId: null
}; };
export default {
name:'flashPromotionProductRelationList', export default {
name: 'flashPromotionProductRelationList',
data() { data() {
return { return {
// defaultListQuery
listQuery: Object.assign({}, defaultListQuery), listQuery: Object.assign({}, defaultListQuery),
// null
list: null, list: null,
// null
total: null, total: null,
// falsetrue
listLoading: false, listLoading: false,
// /false
dialogVisible: false, dialogVisible: false,
selectDialogVisible:false, // false
dialogData:{ selectDialogVisible: false,
//
dialogData: {
list: null, list: null,
total: null, total: null,
multipleSelection:[], multipleSelection: [],
listQuery:{ listQuery: {
keyword: null, keyword: null,
pageNum: 1, pageNum: 1,
pageSize: 5 pageSize: 5
} }
}, },
editDialogVisible:false, // false
flashProductRelation:{ editDialogVisible: false,
product:{} //
flashProductRelation: {
product: {}
} }
} }
}, },
created(){ created() {
this.listQuery.flashPromotionId=this.$route.query.flashPromotionId; // ID
this.listQuery.flashPromotionSessionId=this.$route.query.flashPromotionSessionId; this.listQuery.flashPromotionId = this.$route.query.flashPromotionId;
// ID
this.listQuery.flashPromotionSessionId = this.$route.query.flashPromotionSessionId;
//
this.getList(); this.getList();
}, },
methods:{ methods: {
//
handleSizeChange(val) { handleSizeChange(val) {
this.listQuery.pageNum = 1; this.listQuery.pageNum = 1; //1
this.listQuery.pageSize = val; this.listQuery.pageSize = val;
this.getList(); this.getList(); //
}, },
//
handleCurrentChange(val) { handleCurrentChange(val) {
this.listQuery.pageNum = val; this.listQuery.pageNum = val;
this.getList(); this.getList(); //
}, },
handleSelectProduct(){ //
this.selectDialogVisible=true; handleSelectProduct() {
this.getDialogList(); this.selectDialogVisible = true; //true
this.getDialogList(); //
}, },
handleUpdate(index,row){ //
this.editDialogVisible = true; handleUpdate(index, row) {
this.flashProductRelation = Object.assign({},row); this.editDialogVisible = true; //true
this.flashProductRelation = Object.assign({}, row); //便
}, },
handleDelete(index,row){ //
handleDelete(index, row) {
this.$confirm('是否要删除该商品?', '提示', { this.$confirm('是否要删除该商品?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => { //
deleteFlashProductRelation(row.id).then(response => { deleteFlashProductRelation(row.id).then(response => {
this.$message({ this.$message({
type: 'success', type: 'success',
message: '删除成功!' message: '删除成功!'
}); });
this.getList(); this.getList(); //
}); });
}); });
}, },
handleSelectSearch(){ //
this.getDialogList(); handleSelectSearch() {
this.getDialogList(); //
}, },
//
handleDialogSizeChange(val) { handleDialogSizeChange(val) {
this.dialogData.listQuery.pageNum = 1; this.dialogData.listQuery.pageNum = 1; //1
this.dialogData.listQuery.pageSize = val; this.dialogData.listQuery.pageSize = val; //
this.getDialogList(); this.getDialogList(); //
}, },
//
handleDialogCurrentChange(val) { handleDialogCurrentChange(val) {
this.dialogData.listQuery.pageNum = val; this.dialogData.listQuery.pageNum = val; //
this.getDialogList(); this.getDialogList(); //
}, },
handleDialogSelectionChange(val){ //
this.dialogData.multipleSelection = val; handleDialogSelectionChange(val) {
this.dialogData.multipleSelection = val; //
}, },
handleSelectDialogConfirm(){ //
if (this.dialogData.multipleSelection < 1) { handleSelectDialogConfirm() {
if (this.dialogData.multipleSelection.length < 1) { //
this.$message({ this.$message({
message: '请选择一条记录', message: '请选择一条记录', //
type: 'warning', type: 'warning',
duration: 1000 duration: 1000
}); });
return; return;
} }
let selectProducts = []; let selectProducts = []; //
for (let i = 0; i < this.dialogData.multipleSelection.length; i++) { for (let i = 0; i < this.dialogData.multipleSelection.length; i++) {
selectProducts.push({ selectProducts.push({
productId:this.dialogData.multipleSelection[i].id, productId: this.dialogData.multipleSelection[i].id,
flashPromotionId:this.listQuery.flashPromotionId, flashPromotionId: this.listQuery.flashPromotionId,
flashPromotionSessionId:this.listQuery.flashPromotionSessionId flashPromotionSessionId: this.listQuery.flashPromotionSessionId
}); });
} }
this.$confirm('使用要进行添加操作?', '提示', { this.$confirm('是否要进行添加操作?', '提示', { //
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => { //
createFlashProductRelation(selectProducts).then(response=>{ createFlashProductRelation(selectProducts).then(response => {
this.selectDialogVisible=false; this.selectDialogVisible = false;
this.dialogData.multipleSelection=[]; this.dialogData.multipleSelection = [];
this.getList(); this.getList();
this.$message({ this.$message({
type: 'success', type: 'success',
message: '添加成功!' message: '添加成功!' //
}); });
}); });
}); });
}, },
handleEditDialogConfirm(){ //
this.$confirm('是否要确认?', '提示', { handleEditDialogConfirm() {
this.$confirm('是否要确认?', '提示', { //
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => { //
updateFlashProductRelation(this.flashProductRelation.id,this.flashProductRelation).then(response => { updateFlashProductRelation(this.flashProductRelation.id, this.flashProductRelation).then(response => {
this.$message({ this.$message({
message: '修改成功!', message: '修改成功!', //
type: 'success' type: 'success'
}); });
this.editDialogVisible =false; this.editDialogVisible = false;
this.getList(); this.getList();
}) })
}) })
}, },
//
getList() { getList() {
this.listLoading = true; this.listLoading = true; //true
fetchList(this.listQuery).then(response => { fetchList(this.listQuery).then(response => { //
this.listLoading = false; this.listLoading = false; //false
this.list = response.data.list; this.list = response.data.list; //
this.total = response.data.total; this.total = response.data.total;
}); });
}, },
getDialogList(){ //
fetchProductList(this.dialogData.listQuery).then(response=>{ getDialogList() {
this.dialogData.list=response.data.list; fetchProductList(this.dialogData.listQuery).then(response => { //
this.dialogData.total=response.data.total; this.dialogData.list = response.data.list; //
this.dialogData.total = response.data.total;
}) })
} }
} }
} }
</script> </script>
<style scoped> <style scoped>
.operate-container{ <!-- 使用带有scoped属性的style标签表示这里定义的样式仅作用于当前组件内的元素避免样式污染其他组件 -->
<!-- 定义类名为operate-container的样式规则 -->
.operate-container{
<!-- 设置该类所应用元素的上外边距为0用于控制其与上方元素的间距 -->
margin-top: 0; margin-top: 0;
} }
.input-width{ <!-- 定义类名为input-width的样式规则 -->
.input-width{
<!-- 设置该类所应用元素的宽度为200px通常可用于像输入框等需要统一宽度设置的表单元素 -->
width: 200px; width: 200px;
} }
</style> </style>

@ -1,31 +1,60 @@
<template>  <template>
<!-- 整个页面的外层容器用于对内部各部分内容进行整体布局 -->
<div class="app-container"> <div class="app-container">
<!-- el-card组件用于创建一个卡片式的容器设置了无阴影效果并添加了"operate-container"类名通常可用于放置操作相关的元素或内容展示 -->
<el-card shadow="never" class="operate-container"> <el-card shadow="never" class="operate-container">
<!-- 显示一个图标此处使用的是element-ui提供的"el-icon-tickets"图标用于对下方数据列表进行某种示意比如表示和票务商品列表等相关 -->
<i class="el-icon-tickets"></i> <i class="el-icon-tickets"></i>
<!-- 显示文字"数据列表"用于明确下方表格所展示数据的性质 -->
<span>数据列表</span> <span>数据列表</span>
</el-card> </el-card>
<!-- 放置数据表格的容器用于包裹下面的el-table组件使其在页面布局上更加规整 -->
<div class="table-container"> <div class="table-container">
<!-- el-table组件用于创建一个数据表格设置了表格引用为"selectSessionTable"绑定了数据"list"设置表格宽度为占满父容器100%根据"listLoading"的值来显示加载状态如加载动画等并添加了边框样式 -->
<el-table ref="selectSessionTable" <el-table ref="selectSessionTable"
:data="list" :data="list"
style="width: 100%;" style="width: 100%;"
v-loading="listLoading" border> v-loading="listLoading" border>
<!-- el-table-column组件用于定义表格中的列此列用于展示编号信息设置了列的宽度为100像素内容在单元格中居中对齐 -->
<el-table-column label="编号" width="100" align="center"> <el-table-column label="编号" width="100" align="center">
<template slot-scope="scope">{{scope.row.id}}</template> <template slot-scope="scope">
<!-- 在表格单元格的作用域内通过插值表达式显示对应行数据中的"id"字段内容即展示每一行数据的编号 -->
{{scope.row.id}}
</template>
</el-table-column> </el-table-column>
<!-- el-table-column组件用于定义表格中的列此列用于展示秒杀时间段名称信息内容在单元格中居中对齐 -->
<el-table-column label="秒杀时间段名称" align="center"> <el-table-column label="秒杀时间段名称" align="center">
<template slot-scope="scope">{{scope.row.name}}</template> <template slot-scope="scope">
<!-- 在表格单元格的作用域内通过插值表达式显示对应行数据中的"name"字段内容即展示每一行数据对应的秒杀时间段的名称 -->
{{scope.row.name}}
</template>
</el-table-column> </el-table-column>
<!-- el-table-column组件用于定义表格中的列此列用于展示每日开始时间信息内容在单元格中居中对齐使用了名为"formatTime"的过滤器对时间数据进行格式化后再展示 -->
<el-table-column label="每日开始时间" align="center"> <el-table-column label="每日开始时间" align="center">
<template slot-scope="scope">{{scope.row.startTime | formatTime}}</template> <template slot-scope="scope">
<!-- 在表格单元格的作用域内使用"formatTime"过滤器对对应行数据中的"startTime"字段时间类型数据进行格式化处理后展示 -->
{{scope.row.startTime | formatTime}}
</template>
</el-table-column> </el-table-column>
<!-- el-table-column组件用于定义表格中的列此列用于展示每日结束时间信息内容在单元格中居中对齐同样使用了名为"formatTime"的过滤器对时间数据进行格式化后再展示 -->
<el-table-column label="每日结束时间" align="center"> <el-table-column label="每日结束时间" align="center">
<template slot-scope="scope">{{scope.row.endTime | formatTime}}</template> <template slot-scope="scope">
<!-- 在表格单元格的作用域内使用"formatTime"过滤器对对应行数据中的"endTime"字段时间类型数据进行格式化处理后展示 -->
{{scope.row.endTime | formatTime}}
</template>
</el-table-column> </el-table-column>
<!-- el-table-column组件用于定义表格中的列此列用于展示商品数量信息内容在单元格中居中对齐直接展示对应行数据中的"productCount"字段内容即显示每个秒杀时间段对应的商品数量 -->
<el-table-column label="商品数量" align="center"> <el-table-column label="商品数量" align="center">
<template slot-scope="scope">{{scope.row.productCount}}</template> <template slot-scope="scope">
<!-- 在表格单元格的作用域内通过插值表达式显示对应行数据中的"productCount"字段内容即展示每一行数据对应的商品数量 -->
{{scope.row.productCount}}
</template>
</el-table-column> </el-table-column>
<!-- el-table-column组件用于定义表格中的列此列用于展示操作按钮内容在单元格中居中对齐 -->
<el-table-column label="操作" align="center"> <el-table-column label="操作" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<!-- el-button组件用于创建一个按钮设置了按钮尺寸为"mini"小型按钮按钮类型为"text"绑定了点击事件"handleShowRelation"点击按钮可触发相应的操作逻辑此处按钮显示的文字为"商品列表"可能点击后会跳转到展示对应秒杀时间段下商品列表的页面 -->
<el-button size="mini" <el-button size="mini"
type="text" type="text"
@click="handleShowRelation(scope.$index, scope.row)">商品列表 @click="handleShowRelation(scope.$index, scope.row)">商品列表
@ -37,47 +66,67 @@
</div> </div>
</template> </template>
<script> <script>
import {fetchSelectList} from '@/api/flashSession'; // '@/api/flashSession'fetchSelectList
import {formatDate} from '@/utils/date'; import {fetchSelectList} from '@/api/flashSession';
export default { // '@/utils/date'formatDate
import {formatDate} from '@/utils/date';
export default {
name: 'selectSessionList', name: 'selectSessionList',
data() { data() {
return { return {
// null
list: null, list: null,
// falsetruefalse
listLoading: false listLoading: false
} }
}, },
created() { created() {
//
this.getList(); this.getList();
}, },
filters:{ filters: {
// formatTime
formatTime(time) { formatTime(time) {
// null 'N/A'
if (time == null || time === '') { if (time == null || time === '') {
return 'N/A'; return 'N/A';
} }
// JavaScriptDate便使
let date = new Date(time); let date = new Date(time);
// formatDate 'hh:mm:ss' Date
return formatDate(date, 'hh:mm:ss') return formatDate(date, 'hh:mm:ss')
} }
}, },
methods: { methods: {
handleShowRelation(index,row){ //
this.$router.push({path:'/sms/flashProductRelation',query:{ handleShowRelation(index, row) {
flashPromotionId:this.$route.query.flashPromotionId, flashPromotionSessionId:row.id}}) // 使Vue Router '/sms/flashProductRelation'
this.$router.push({path: '/sms/flashProductRelation', query: {
flashPromotionId: this.$route.query.flashPromotionId, flashPromotionSessionId: row.id}}) //IDflashPromotionIdIDflashPromotionSessionIdID
}, },
//
getList() { getList() {
// true
this.listLoading = true; this.listLoading = true;
fetchSelectList({flashPromotionId:this.$route.query.flashPromotionId}).then(response => { // fetchSelectListIDIDthen
fetchSelectList({flashPromotionId: this.$route.query.flashPromotionId}).then(response => {
// false
this.listLoading = false; this.listLoading = false;
// list便
this.list = response.data; this.list = response.data;
}); });
} }
} }
} }
</script> </script>
<style scoped> <style scoped>
.operate-container { <!-- scoped属性表示该样式作用范围仅限于当前组件内的元素避免样式影响到其他组件中的同名元素起到样式隔离的作用 -->
margin-top: 0; .operate-container {
} <!-- 这是一个CSS样式规则针对类名为operate-container的元素进行样式设置 -->
<!-- margin-top属性用于设置元素的上外边距这里将其值设置为0意味着该元素距离上方相邻元素的间距为0可用于精准控制元素在页面中的垂直布局位置 -->
margin-top: 0;
}
</style> </style>

@ -1,29 +1,55 @@
<template>  <template>
<!-- 整个页面的外层容器用于对内部各部分内容进行整体布局 -->
<div class="app-container"> <div class="app-container">
<!-- el-card组件用于创建一个卡片式的容器设置了无阴影效果shadow="never"并添加了"operate-container"类名通常可用于放置操作相关的元素比如这里放置了添加按钮等 -->
<el-card shadow="never" class="operate-container"> <el-card shadow="never" class="operate-container">
<!-- 显示一个图标此处使用的是element-ui提供的"el-icon-tickets"图标用于对下方数据列表进行某种示意比如暗示和票务商品列表等相关的操作场景 -->
<i class="el-icon-tickets"></i> <i class="el-icon-tickets"></i>
<!-- 显示文字"数据列表"用于明确下方表格所展示数据的性质让用户知晓表格中呈现的是什么内容 -->
<span>数据列表</span> <span>数据列表</span>
<!-- el-button组件用于创建一个按钮设置了按钮尺寸为"mini"小型按钮添加了"btn-add"类名可能用于样式设置等绑定了点击事件"handleAdd"点击该按钮可触发对应的添加操作逻辑 -->
<el-button size="mini" class="btn-add" @click="handleAdd()"></el-button> <el-button size="mini" class="btn-add" @click="handleAdd()"></el-button>
</el-card> </el-card>
<!-- 放置数据表格的容器用于包裹下面的el-table组件使其在页面布局上更加规整将表格与其他元素区分开来 -->
<div class="table-container"> <div class="table-container">
<!-- el-table组件用于创建一个数据表格设置了表格引用为"flashSessionTable"绑定了数据"list"这个数据应该是从组件的data属性或者通过接口获取等方式得到的包含了要展示在表格中的具体数据内容设置表格宽度为占满父容器100%根据"listLoading"的值来显示加载状态如加载动画等方便用户知晓数据是否正在加载中并添加了边框样式 -->
<el-table ref="flashSessionTable" <el-table ref="flashSessionTable"
:data="list" :data="list"
style="width: 100%;" style="width: 100%;"
v-loading="listLoading" border> v-loading="listLoading" border>
<!-- el-table-column组件用于定义表格中的列此列用于展示编号信息设置了列的宽度为100像素内容在单元格中居中对齐 -->
<el-table-column label="编号" width="100" align="center"> <el-table-column label="编号" width="100" align="center">
<template slot-scope="scope">{{scope.row.id}}</template> <template slot-scope="scope">
<!-- 在表格单元格的作用域内通过slot-scope获取到对应行的数据对象通过插值表达式显示对应行数据中的"id"字段内容即展示每一行数据的编号 -->
{{scope.row.id}}
</template>
</el-table-column> </el-table-column>
<!-- el-table-column组件用于定义表格中的列此列用于展示秒杀时间段名称信息内容在单元格中居中对齐直接展示对应行数据中的"name"字段内容用于显示每个秒杀时间段对应的名称 -->
<el-table-column label="秒杀时间段名称" align="center"> <el-table-column label="秒杀时间段名称" align="center">
<template slot-scope="scope">{{scope.row.name}}</template> <template slot-scope="scope">
<!-- 在表格单元格的作用域内通过插值表达式显示对应行数据中的"name"字段内容即展示每一行数据对应的秒杀时间段的名称 -->
{{scope.row.name}}
</template>
</el-table-column> </el-table-column>
<!-- el-table-column组件用于定义表格中的列此列用于展示每日开始时间信息内容在单元格中居中对齐使用了名为"formatTime"的过滤器应该是在组件的filters选项中定义的用于对时间数据进行格式化处理对时间数据进行格式化后再展示 -->
<el-table-column label="每日开始时间" align="center"> <el-table-column label="每日开始时间" align="center">
<template slot-scope="scope">{{scope.row.startTime | formatTime}}</template> <template slot-scope="scope">
<!-- 在表格单元格的作用域内使用"formatTime"过滤器对对应行数据中的"startTime"字段时间类型数据进行格式化处理后展示 -->
{{scope.row.startTime | formatTime}}
</template>
</el-table-column> </el-table-column>
<!-- el-table-column组件用于定义表格中的列此列用于展示每日结束时间信息内容在单元格中居中对齐同样使用了名为"formatTime"的过滤器对时间数据进行格式化后再展示 -->
<el-table-column label="每日结束时间" align="center"> <el-table-column label="每日结束时间" align="center">
<template slot-scope="scope">{{scope.row.endTime | formatTime}}</template> <template slot-scope="scope">
<!-- 在表格单元格的作用域内使用"formatTime"过滤器对对应行数据中的"endTime"字段时间类型数据进行格式化处理后展示 -->
{{scope.row.endTime | formatTime}}
</template>
</el-table-column> </el-table-column>
<!-- el-table-column组件用于定义表格中的列此列用于展示启用状态信息内容在单元格中居中对齐里面包含了一个el-switch组件开关组件用于切换启用/禁用状态 -->
<el-table-column label="启用" align="center"> <el-table-column label="启用" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<!-- el-switch组件用于创建一个开关按钮绑定了状态改变的事件"handleStatusChange"当开关状态改变时会触发该事件传递当前行的索引和整行数据作为参数设置了激活值为1表示启用状态对应的数值未激活值为0表示禁用状态对应的数值双向绑定对应行数据中的"status"字段意味着开关状态的改变会直接更新对应行数据里的这个字段值 -->
<el-switch <el-switch
@change="handleStatusChange(scope.$index, scope.row)" @change="handleStatusChange(scope.$index, scope.row)"
:active-value="1" :active-value="1"
@ -32,12 +58,15 @@
</el-switch> </el-switch>
</template> </template>
</el-table-column> </el-table-column>
<!-- el-table-column组件用于定义表格中的列此列用于展示操作按钮设置了列的宽度为180像素内容在单元格中居中对齐 -->
<el-table-column label="操作" width="180" align="center"> <el-table-column label="操作" width="180" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<!-- el-button组件用于创建一个按钮设置了按钮尺寸为"mini"小型按钮按钮类型为"text"文本样式按钮通常外观上更简洁无背景色等绑定了点击事件"handleUpdate"点击该按钮可触发编辑操作逻辑按钮显示的文字为"编辑" -->
<el-button size="mini" <el-button size="mini"
type="text" type="text"
@click="handleUpdate(scope.$index, scope.row)">编辑 @click="handleUpdate(scope.$index, scope.row)">编辑
</el-button> </el-button>
<!-- el-button组件用于创建一个按钮设置了按钮尺寸为"mini"小型按钮按钮类型为"text"文本样式按钮通常外观上更简洁无背景色等绑定了点击事件"handleDelete"点击该按钮可触发删除操作逻辑按钮显示的文字为"删除" -->
<el-button size="mini" <el-button size="mini"
type="text" type="text"
@click="handleDelete(scope.$index, scope.row)">删除 @click="handleDelete(scope.$index, scope.row)">删除
@ -46,82 +75,115 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
</div> </div>
<!-- el-dialog组件用于创建一个弹出式对话框常用于展示表单让用户输入信息或者进行确认等操作设置了对话框的标题为"添加时间段"通过":visible.sync"双向绑定了对话框的显示状态与组件data中的dialogVisible属性相关联改变该属性值可控制对话框的显示与隐藏设置了对话框的宽度为40%相对于屏幕宽度等的占比用于控制对话框大小 -->
<el-dialog <el-dialog
title="添加时间段" title="添加时间段"
:visible.sync="dialogVisible" :visible.sync="dialogVisible"
width="40%"> width="40%">
<!-- el-form组件用于创建一个表单绑定了数据模型"flashSession"这个对象应该在组件的data属性中定义用于存储表单中输入的数据等设置了表单引用为"flashSessionForm"可用于后续对表单进行验证等操作时的标识设置了标签宽度为150像素表单整体尺寸为"small"小型尺寸用于统一表单元素的外观大小等风格 -->
<el-form :model="flashSession" <el-form :model="flashSession"
ref="flashSessionForm" ref="flashSessionForm"
label-width="150px" size="small"> label-width="150px" size="small">
<!-- el-form-item组件用于定义表单中的表单项此表单项对应的标签为"秒杀时间段名称:"用于提示用户此处应输入的内容 -->
<el-form-item label="秒杀时间段名称:"> <el-form-item label="秒杀时间段名称:">
<!-- el-input组件用于创建一个输入框双向绑定了"flashSession.name"数据意味着用户在输入框中输入的内容会实时更新到"flashSession"对象的"name"属性中设置了输入框的宽度为250像素 -->
<el-input v-model="flashSession.name" style="width: 250px"></el-input> <el-input v-model="flashSession.name" style="width: 250px"></el-input>
</el-form-item> </el-form-item>
<!-- el-form-item组件用于定义表单中的表单项此表单项对应的标签为"每日开始时间:"用于提示用户此处应选择时间 -->
<el-form-item label="每日开始时间:"> <el-form-item label="每日开始时间:">
<!-- el-time-picker组件用于创建一个时间选择器用户可以通过它选择具体的时间双向绑定了"flashSession.startTime"数据选择的时间会更新到"flashSession"对象的"startTime"属性中设置了占位提示文字为"请选择时间" -->
<el-time-picker <el-time-picker
v-model="flashSession.startTime" v-model="flashSession.startTime"
placeholder="请选择时间"> placeholder="请选择时间">
</el-time-picker> </el-time-picker>
</el-form-item> </el-form-item>
<!-- el-form-item组件用于定义表单中的表单项此表单项对应的标签为"每日结束时间:"用于提示用户此处应选择时间 -->
<el-form-item label="每日结束时间:"> <el-form-item label="每日结束时间:">
<!-- el-time-picker组件用于创建一个时间选择器用户可以通过它选择具体的时间双向绑定了"flashSession.endTime"数据选择的时间会更新到"flashSession"对象的"endTime"属性中设置了占位提示文字为"请选择时间" -->
<el-time-picker <el-time-picker
v-model="flashSession.endTime" v-model="flashSession.endTime"
placeholder="请选择时间"> placeholder="请选择时间">
</el-time-picker> </el-time-picker>
</el-form-item> </el-form-item>
<!-- el-form-item组件用于定义表单中的表单项此表单项对应的标签为"是否启用"用于让用户选择该时间段是否启用 -->
<el-form-item label="是否启用"> <el-form-item label="是否启用">
<!-- el-radio-group组件用于创建一个单选按钮组绑定了"flashSession.status"数据意味着用户选择的单选按钮的值会更新到"flashSession"对象的"status"属性中 -->
<el-radio-group v-model="flashSession.status"> <el-radio-group v-model="flashSession.status">
<!-- el-radio组件用于创建一个单选按钮设置了按钮的标签值为1对应的显示文字为"启用"用户选择该按钮后会将"flashSession.status"的值设为1 -->
<el-radio :label="1">启用</el-radio> <el-radio :label="1">启用</el-radio>
<!-- el-radio组件用于创建一个单选按钮设置了按钮的标签值为0对应的显示文字为"不启用"用户选择该按钮后会将"flashSession.status"的值设为0 -->
<el-radio :label="0">不启用</el-radio> <el-radio :label="0">不启用</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
</el-form> </el-form>
<!-- 对话框底部的操作按钮区域使用了插槽"footer"来定义通常用于放置确认取消等按钮 -->
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<!-- el-button组件用于创建一个按钮点击事件绑定了将"dialogVisible"属性设为false的操作即关闭对话框设置了按钮尺寸为"small"小型按钮按钮显示的文字为"取 消" -->
<el-button @click="dialogVisible = false" size="small"> </el-button> <el-button @click="dialogVisible = false" size="small"> </el-button>
<!-- el-button组件用于创建一个按钮设置了按钮类型为"primary"主要按钮通常会有突出的样式比如颜色与其他按钮不同等点击事件绑定了"handleDialogConfirm"方法这个方法应该在组件的methods选项中定义用于处理确认添加等相关逻辑设置了按钮尺寸为"small"小型按钮按钮显示的文字为"确 定" -->
<el-button type="primary" @click="handleDialogConfirm()" size="small"> </el-button> <el-button type="primary" @click="handleDialogConfirm()" size="small"> </el-button>
</span> </span>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
<script> <script>
import {fetchList,updateStatus,deleteSession,createSession,updateSession} from '@/api/flashSession'; // '@/api/flashSession'API
import {formatDate} from '@/utils/date'; import {fetchList, updateStatus, deleteSession, createSession, updateSession} from '@/api/flashSession';
const defaultFlashSession={ // '@/utils/date'formatDate使
name:null, import {formatDate} from '@/utils/date';
startTime:null,
endTime:null, //
status:0 const defaultFlashSession = { //
}; name: null,
export default { startTime: null,
endTime: null,
status: 0 //
};
export default {
name: 'flashPromotionSessionList', name: 'flashPromotionSessionList',
data() { data() {
return { return {
// null便
list: null, list: null,
// falsetruefalse
listLoading: false, listLoading: false,
dialogVisible:false, // /false
isEdit:false, dialogVisible: false,
flashSession:Object.assign({},defaultFlashSession) // truefalsefalse便
isEdit: false,
// defaultFlashSession
flashSession: Object.assign({}, defaultFlashSession)
} }
}, },
created() { created() {
// 使
this.getList(); this.getList();
}, },
filters:{ filters: {
// formatTime便
formatTime(time) { formatTime(time) {
// null 'N/A'
if (time == null || time === '') { if (time == null || time === '') {
return 'N/A'; return 'N/A';
} }
// JavaScriptDate便使formatDateDate便
let date = new Date(time); let date = new Date(time);
// formatDate 'hh:mm:ss' Date "12:30:00"
return formatDate(date, 'hh:mm:ss') return formatDate(date, 'hh:mm:ss')
} }
}, },
methods: { methods: {
//
handleAdd() { handleAdd() {
this.dialogVisible = true; this.dialogVisible = true; //true
this.isEdit = false; this.isEdit = false;
this.flashSession = Object.assign({},defaultFlashSession); this.flashSession = Object.assign({}, defaultFlashSession); //
}, },
handleStatusChange(index,row){ // /
this.$confirm('是否要修改该状态?', '提示', { handleStatusChange(index, row) {
this.$confirm('是否要修改该状态?', '提示', { //
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
@ -129,80 +191,87 @@
updateStatus(row.id, {status: row.status}).then(response => { updateStatus(row.id, {status: row.status}).then(response => {
this.$message({ this.$message({
type: 'success', type: 'success',
message: '修改成功!' message: '修改成功!' //
}); });
}); });
}).catch(() => { }).catch(() => { //
this.$message({ this.$message({
type: 'info', type: 'info',
message: '取消修改' message: '取消修改'
}); });
this.getList(); this.getList(); //
}); });
}, },
handleUpdate(index,row){ // .
this.dialogVisible = true; handleUpdate(index, row) {
this.isEdit = true; this.dialogVisible = true; //true
this.flashSession = Object.assign({},row); this.isEdit = true; //
this.flashSession.startTime=new Date(row.startTime); this.flashSession = Object.assign({}, row);
this.flashSession.endTime=new Date(row.endTime); this.flashSession.startTime = new Date(row.startTime); //Date便便
this.flashSession.endTime = new Date(row.endTime);
}, },
handleDelete(index,row){ // .
this.$confirm('是否要删除该时间段?', '提示', { handleDelete(index, row) {
this.$confirm('是否要删除该时间段?', '提示', { //
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => { //
deleteSession(row.id).then(response => { deleteSession(row.id).then(response => {
this.$message({ this.$message({
type: 'success', type: 'success',
message: '删除成功!' message: '删除成功!' //
}); });
this.getList(); this.getList(); //使
}); });
}); });
}, },
// .
handleDialogConfirm() { handleDialogConfirm() {
this.$confirm('是否要确认?', '提示', { this.$confirm('是否要确认?', '提示', { //
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => { //
if (this.isEdit) { if (this.isEdit) {
updateSession(this.flashSession.id,this.flashSession).then(response => { updateSession(this.flashSession.id, this.flashSession).then(response => {
this.$message({ this.$message({
message: '修改成功!', message: '修改成功!',
type: 'success' type: 'success'
}); });
this.dialogVisible =false; this.dialogVisible = false;
this.getList(); this.getList();
}) })
} else { } else {
createSession(this.flashSession).then(response => { createSession(this.flashSession).then(response => {
this.$message({ this.$message({
message: '添加成功!', message: '添加成功!', //
type: 'success' type: 'success'
}); });
this.dialogVisible =false; this.dialogVisible = false;
this.getList(); this.getList(); //
}) })
} }
}) })
}, },
//
getList() { getList() {
this.listLoading = true; this.listLoading = true; //true
fetchList({}).then(response => { fetchList({}).then(response => { //fetchList
this.listLoading = false; this.listLoading = false; //false
this.list = response.data; this.list = response.data; //list
}); });
} }
} }
} }
</script> </script>
<style scoped> <style scoped>
.operate-container { <!-- scoped属性表示当前这个style标签内定义的样式作用范围仅限于当前组件内部避免样式影响到其他组件中同名的类或元素起到样式隔离的作用使得样式管理更加清晰和模块化 -->
margin-top: 0; .operate-container {
} <!-- 这是一个CSS选择器用于选中页面中所有应用了operate-container类名的元素接下来在花括号内定义的样式规则就会应用到这些被选中的元素上 -->
<!-- margin-top是CSS的一个属性用于设置元素的上外边距也就是该元素距离其上方相邻元素的间隔距离这里将其值设置为0意味着应用了operate-container类名的元素其上外边距为0像素能精准控制这类元素在页面垂直方向上的布局位置使其更贴合设计需求 -->
margin-top: 0;
}
</style> </style>

Loading…
Cancel
Save