Merge pull request '合并' (#5) from branch_lyj into main

pull/6/head
py4fbma29 7 months ago
commit 648ef08f1f

@ -11,8 +11,8 @@
export default {
name: 'AppMain',
computed: {
// .......key() {
// return this.$route.name !== undefined ? this.$route.name + +new Date() : this.$route + +new Date()
// key() {
// 111 11 return this.$route.name !== undefined ? this.$route.name + +new Date() : this.$route + +new Date()
// }
}
}

@ -1,13 +1,18 @@
<template> 
<template>
<!-- 使用HomeAdvertiseDetail组件并传递一个名为isEdit的prop值为false -->
<home-advertise-detail :isEdit="false"></home-advertise-detail>
</template>
<script>
import HomeAdvertiseDetail from './components/HomeAdvertiseDetail'
export default {
name: 'addHomeAdvertise',
components: { HomeAdvertiseDetail }
}
</script>
<style></style>
// HomeAdvertiseDetail
import HomeAdvertiseDetail from './components/HomeAdvertiseDetail'
//
export default {
// addHomeAdvertise
name: 'addHomeAdvertise',
// 使
components: { HomeAdvertiseDetail }
}
</script>
<style></style>

@ -1,15 +1,19 @@
<template> 
<el-card class="form-container" shadow="never">
<!-- 表单容器使用Element UI的卡片组件 -->
<el-form :model="homeAdvertise"
:rules="rules"
ref="homeAdvertiseFrom"
label-width="150px"
size="small">
<!-- 表单绑定数据模型和验证规则引用名称为'homeAdvertiseFrom' -->
<el-form-item label="广告名称:" prop="name">
<el-input v-model="homeAdvertise.name" class="input-width"></el-input>
<!-- 输入框绑定到homeAdvertise.name用于输入广告名称 -->
</el-form-item>
<el-form-item label="广告位置:">
<el-select v-model="homeAdvertise.type">
<!-- 下拉选择框绑定到homeAdvertise.type用于选择广告位置 -->
<el-option
v-for="type in typeOptions"
:key="type.value"
@ -23,27 +27,33 @@
type="datetime"
placeholder="选择日期"
v-model="homeAdvertise.startTime"></el-date-picker>
<!-- 日期选择器绑定到homeAdvertise.startTime用于选择开始时间 -->
</el-form-item>
<el-form-item label="到期时间:" prop="endTime">
<el-date-picker
type="datetime"
placeholder="选择日期"
v-model="homeAdvertise.endTime"></el-date-picker>
<!-- 日期选择器绑定到homeAdvertise.endTime用于选择到期时间 -->
</el-form-item>
<el-form-item label="上线/下线:">
<el-radio-group v-model="homeAdvertise.status">
<!-- 单选按钮组绑定到homeAdvertise.status用于选择广告状态上线或下线 -->
<el-radio :label="0">下线</el-radio>
<el-radio :label="1">上线</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="广告图片:">
<single-upload v-model="homeAdvertise.pic"></single-upload>
<!-- 自定义上传组件绑定到homeAdvertise.pic用于上传广告图片 -->
</el-form-item>
<el-form-item label="排序:">
<el-input v-model="homeAdvertise.sort" class="input-width"></el-input>
<!-- 输入框绑定到homeAdvertise.sort用于输入广告排序 -->
</el-form-item>
<el-form-item label="广告链接:" prop="url">
<el-input v-model="homeAdvertise.url" class="input-width"></el-input>
<!-- 输入框绑定到homeAdvertise.url用于输入广告链接 -->
</el-form-item>
<el-form-item label="广告备注:">
<el-input
@ -53,18 +63,21 @@
placeholder="请输入内容"
v-model="homeAdvertise.note">
</el-input>
<!-- 文本域绑定到homeAdvertise.note用于输入广告备注 -->
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onSubmit('homeAdvertiseFrom')"></el-button>
<!-- 提交按钮点击时调用submitForm方法 -->
<el-button v-if="!isEdit" @click="resetForm('homeAdvertiseFrom')"></el-button>
<!-- 重置按钮点击时调用resetForm方法 -->
</el-form-item>
</el-form>
</el-card>
</template>
<script>
import SingleUpload from '@/components/Upload/singleUpload'
import {createHomeAdvertise, getHomeAdvertise, updateHomeAdvertise} from '@/api/homeAdvertise'
const defaultTypeOptions = [
import SingleUpload from '@/components/Upload/singleUpload' //
import {createHomeAdvertise, getHomeAdvertise, updateHomeAdvertise} from '@/api/homeAdvertise' // API
const defaultTypeOptions = [ // 广
{
label: 'PC首页轮播',
value: 0
@ -74,7 +87,7 @@
value: 1
}
];
const defaultHomeAdvertise = {
const defaultHomeAdvertise = { // 广
name: null,
type: 1,
pic: null,
@ -86,18 +99,18 @@
sort: 0
};
export default {
name: 'HomeAdvertiseDetail',
components:{SingleUpload},
props: {
name: 'HomeAdvertiseDetail', //
components:{SingleUpload}, //
props: { // isEdit
isEdit: {
type: Boolean,
default: false
}
},
data() {
data() { //
return {
homeAdvertise: null,
rules: {
homeAdvertise: null, // 广
rules: { //
name: [
{required: true, message: '请输入广告名称', trigger: 'blur'},
{min: 2, max: 140, message: '长度在 2 到 140 个字符', trigger: 'blur'}
@ -115,42 +128,42 @@
{required: true, message: '请选择广告图片', trigger: 'blur'}
]
},
typeOptions: Object.assign({}, defaultTypeOptions)
typeOptions: Object.assign({}, defaultTypeOptions) // 广
}
},
created(){
if (this.isEdit) {
created(){ //
if (this.isEdit) { // 广homeAdvertise
getHomeAdvertise(this.$route.query.id).then(response => {
this.homeAdvertise = response.data;
});
}else{
}else{ // homeAdvertise
this.homeAdvertise = Object.assign({},defaultHomeAdvertise);
}
},
methods: {
onSubmit(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
methods: { //
onSubmit(formName) { //
this.$refs[formName].validate((valid) => { //
if (valid) { // API
this.$confirm('是否提交数据', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
if (this.isEdit) {
if (this.isEdit) { // 广API
updateHomeAdvertise(this.$route.query.id, this.homeAdvertise).then(response => {
this.$refs[formName].resetFields();
this.$message({
this.$refs[formName].resetFields(); //
this.$message({ //
message: '修改成功',
type: 'success',
duration:1000
});
this.$router.back();
this.$router.back(); //
});
} else {
} else { // 广API
createHomeAdvertise(this.homeAdvertise).then(response => {
this.$refs[formName].resetFields();
this.homeAdvertise = Object.assign({},defaultHomeAdvertise);
this.$message({
this.$refs[formName].resetFields(); //
this.homeAdvertise = Object.assign({},defaultHomeAdvertise); // homeAdvertise
this.$message({ //
message: '提交成功',
type: 'success',
duration:1000
@ -159,26 +172,26 @@
}
});
} else {
} else { //
this.$message({
message: '验证失败',
type: 'error',
duration:1000
});
return false;
return false; //
}
});
},
resetForm(formName) {
this.$refs[formName].resetFields();
this.homeAdvertise = Object.assign({},defaultHomeAdvertise);
resetForm(formName) { //
this.$refs[formName].resetFields(); //
this.homeAdvertise = Object.assign({},defaultHomeAdvertise); // homeAdvertise
}
}
}
</script>
<style scoped>
.input-width {
width: 70%;
<style scoped> // scoped
.input-width { //
width: 70%; // 70%
}
</style>

@ -1,9 +1,13 @@
<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 +15,7 @@
size="small">
查询搜索
</el-button>
<!-- 重置按钮 -->
<el-button
style="float:right;margin-right: 15px"
@click="handleResetSearch()"
@ -18,11 +23,14 @@
重置
</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"
@ -32,6 +40,7 @@
</el-option>
</el-select>
</el-form-item>
<!-- 到期时间筛选项 -->
<el-form-item label="到期时间:">
<el-date-picker
class="input-width"
@ -44,36 +53,48 @@
</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="homeAdvertiseTable"
: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="120" 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="120" align="center">
<template slot-scope="scope">{{scope.row.type | formatType}}</template>
</el-table-column>
<!-- 广告图片列 -->
<el-table-column label="广告图片" width="120" align="center">
<template slot-scope="scope"><img style="height: 80px" :src="scope.row.pic"></template>
</el-table-column>
<!-- 时间列 -->
<el-table-column label="时间" width="220" align="center">
<template slot-scope="scope">
<p>开始时间{{scope.row.startTime | formatTime}}</p>
<p>到期时间{{scope.row.endTime | formatTime}}</p>
</template>
</el-table-column>
<!-- 上线/下线状态列 -->
<el-table-column label="上线/下线" width="120" align="center">
<template slot-scope="scope">
<el-switch
@ -84,18 +105,23 @@
</el-switch>
</template>
</el-table-column>
<!-- 点击次数列 -->
<el-table-column label="点击次数" width="120" align="center">
<template slot-scope="scope">{{scope.row.clickCount}}</template>
</el-table-column>
<!-- 生成订单列 -->
<el-table-column label="生成订单" width="120" align="center">
<template slot-scope="scope">{{scope.row.orderCount}}</template>
</el-table-column>
<!-- 操作列 -->
<el-table-column label="操作" width="120" align="center">
<template slot-scope="scope">
<!-- 编辑按钮 -->
<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)">删除
@ -104,10 +130,13 @@
</el-table-column>
</el-table>
</div>
<!-- 这是一个包含批量操作和分页功能的容器 div -->
<div class="batch-operate-container">
<!-- el-select 组件用于选择批量操作的类型设置了 small 尺寸并使用 v-model 双向绑定数据到 operateType 变量placeholder 用于显示默认提示文本 -->
<el-select
size="small"
v-model="operateType" placeholder="批量操作">
<!-- 使用 v-for 循环遍历 operates 数组来生成 el-option 选项每个选项的 key 根据 item.value 来设置label 显示文本取自 item.labelvalue 值取自 item.value -->
<el-option
v-for="item in operates"
:key="item.value"
@ -115,6 +144,7 @@
:value="item.value">
</el-option>
</el-select>
<!-- el-button 组件是一个按钮设置了左边距为 20 像素添加了 search-button 类名绑定了点击事件 handleBatchOperate()按钮类型为 primary通常是主要操作按钮的样式尺寸为 small -->
<el-button
style="margin-left: 20px"
class="search-button"
@ -124,6 +154,7 @@
确定
</el-button>
</div>
<!-- 这是一个用于分页功能展示的容器 div -->
<div class="pagination-container">
<el-pagination
background
@ -139,169 +170,200 @@
</div>
</template>
<script>
import {fetchList,updateStatus,deleteHomeAdvertise} from '@/api/homeAdvertise';
import {formatDate} from '@/utils/date';
const defaultListQuery = {
pageNum: 1,
pageSize: 5,
name: null,
type: null,
endTime:null
};
const defaultTypeOptions = [
{
label: 'PC首页轮播',
value: 0
},
{
label: 'APP首页轮播',
value: 1
// '@/api/homeAdvertise'广
import {fetchList, updateStatus, deleteHomeAdvertise} from '@/api/homeAdvertise';
// '@/utils/date'
import {formatDate} from '@/utils/date';
//
const defaultListQuery = {
pageNum: 1,
pageSize: 5,
name: null,
type: null,
endTime: null
};
// 广PCAPP
const defaultTypeOptions = [
{
label: 'PC首页轮播',
value: 0
},
{
label: 'APP首页轮播',
value: 1
}
];
export default {
name: 'homeAdvertiseList',
data() {
return {
//
listQuery: Object.assign({}, defaultListQuery),
// 广
typeOptions: Object.assign({}, defaultTypeOptions),
// 广null
list: null,
// 广null
total: null,
// false
listLoading: false,
// 广
multipleSelection: [],
//
operates: [
{
label: "删除",
value: 0
}
],
// null
operateType: null
}
];
export default {
name: 'homeAdvertiseList',
data() {
return {
listQuery: Object.assign({}, defaultListQuery),
typeOptions: Object.assign({}, defaultTypeOptions),
list: null,
total: null,
listLoading: false,
multipleSelection: [],
operates: [
{
label: "删除",
value: 0
}
],
operateType: null
},
created() {
// 广
this.getList();
},
filters: {
// 广
formatType(type) {
if (type === 1) {
return 'APP首页轮播';
} else {
return 'PC首页轮播';
}
},
created() {
//
formatTime(time) {
if (time == null || time === '') {
return 'N/A';
}
let date = new Date(time);
return formatDate(date, 'yyyy-MM-dd hh:mm:ss')
},
},
methods: {
//
handleResetSearch() {
this.listQuery = Object.assign({}, defaultListQuery);
},
//
handleSearchList() {
this.listQuery.pageNum = 1;
this.getList();
},
filters:{
formatType(type){
if(type===1){
return 'APP首页轮播';
}else{
return 'PC首页轮播';
}
},
formatTime(time){
if(time==null||time===''){
return 'N/A';
}
let date = new Date(time);
return formatDate(date, 'yyyy-MM-dd hh:mm:ss')
},
//
handleSelectionChange(val) {
this.multipleSelection = val;
},
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();
},
handleUpdateStatus(index,row){
this.$confirm('是否要修改上线/下线状态?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
updateStatus(row.id,{status:row.status}).then(response=>{
this.getList();
this.$message({
type: 'success',
message: '修改成功!'
});
});
}).catch(() => {
//
handleSizeChange(val) {
this.listQuery.pageNum = 1;
this.listQuery.pageSize = val;
this.getList();
},
//
handleCurrentChange(val) {
this.listQuery.pageNum = val;
this.getList();
},
// 广
handleUpdateStatus(index, row) {
this.$confirm('是否要修改上线/下线状态?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
updateStatus(row.id, {status: row.status}).then(response => {
this.getList();
this.$message({
type: 'success',
message: '已取消操作!'
message: '修改成功!'
});
this.getList();
});
},
handleDelete(index,row){
this.deleteHomeAdvertise(row.id);
},
handleBatchOperate(){
if (this.multipleSelection < 1) {
this.$message({
message: '请选择一条记录',
type: 'warning',
duration: 1000
});
return;
}
let ids = [];
for (let i = 0; i < this.multipleSelection.length; i++) {
ids.push(this.multipleSelection[i].id);
}
if(this.operateType===0){
//
this.deleteHomeAdvertise(ids);
}else {
}).catch(() => {
this.$message({
type: 'success',
message: '已取消操作!'
});
this.getList();
});
},
// 广广
handleDelete(index, row) {
this.deleteHomeAdvertise(row.id);
},
//
handleBatchOperate() {
if (this.multipleSelection < 1) {
this.$message({
message: '请选择一条记录',
type: 'warning',
duration: 1000
});
return;
}
let ids = [];
for (let i = 0; i < this.multipleSelection.length; i++) {
ids.push(this.multipleSelection[i].id);
}
if (this.operateType === 0) {
//
this.deleteHomeAdvertise(ids);
} else {
this.$message({
message: '请选择批量操作类型',
type: 'warning',
duration: 1000
});
}
},
// 广广
handleAdd() {
this.$router.push({path: '/sms/addAdvertise'})
},
// 广广广id
handleUpdate(index, row) {
this.$router.push({path: '/sms/updateAdvertise', query: {id: row.id}})
},
// 广true
getList() {
this.listLoading = true;
fetchList(this.listQuery).then(response => {
this.listLoading = false;
this.list = response.data.list;
this.total = response.data.total;
})
},
// 广
deleteHomeAdvertise(ids) {
this.$confirm('是否要删除该广告?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let params = new URLSearchParams();
params.append("ids", ids);
deleteHomeAdvertise(params).then(response => {
this.getList();
this.$message({
message: '请选择批量操作类型',
type: 'warning',
duration: 1000
});
}
},
handleAdd(){
this.$router.push({path: '/sms/addAdvertise'})
},
handleUpdate(index,row){
this.$router.push({path: '/sms/updateAdvertise', query: {id: row.id}})
},
getList() {
this.listLoading = true;
fetchList(this.listQuery).then(response => {
this.listLoading = false;
this.list = response.data.list;
this.total = response.data.total;
})
},
deleteHomeAdvertise(ids){
this.$confirm('是否要删除该广告?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let params=new URLSearchParams();
params.append("ids",ids);
deleteHomeAdvertise(params).then(response=>{
this.getList();
this.$message({
type: 'success',
message: '删除成功!'
});
type: 'success',
message: '删除成功!'
});
})
}
});
})
}
}
}
</script>
<style scoped>
.input-width {
width: 203px;
}
<!-- 带有scoped属性的style标签里面样式仅作用于当前组件 -->
.input-width {
<!-- 定义类选择器样式设置宽度为203px -->
width: 203px;
}
</style>

@ -1,13 +1,17 @@
<template> 
<template>
<!-- 在模板中使用了名为home-advertise-detail的自定义组件并传递了一个名为isEdit且值为true的属性可能用于控制该组件处于编辑状态相关的展示或功能 -->
<home-advertise-detail :isEdit="true"></home-advertise-detail>
</template>
<script>
import HomeAdvertiseDetail from './components/HomeAdvertiseDetail'
export default {
name: 'updateHomeAdvertise',
components: { HomeAdvertiseDetail }
}
// HomeAdvertiseDetail'./components/HomeAdvertiseDetail'
import HomeAdvertiseDetail from './components/HomeAdvertiseDetail'
export default {
name: 'updateHomeAdvertise',
// HomeAdvertiseDetail使使
components: { HomeAdvertiseDetail }
}
</script>
<style></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.brandName" class="input-width" placeholder="品牌名称"></el-input>
</el-form-item>
<!-- 推荐状态选择框的表单项 -->
<el-form-item label="推荐状态:">
<!-- 下拉选择框双向绑定推荐状态数据设置占位提示等属性 -->
<el-select v-model="listQuery.recommendStatus" placeholder="全部" clearable class="input-width">
<!-- 循环生成下拉选项 -->
<el-option v-for="item in recommendOptions"
:key="item.value"
:label="item.label"
@ -35,40 +47,51 @@
</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="handleSelectBrand()"></el-button>
</el-card>
<!-- 放置数据表格的容器 -->
<div class="table-container">
<!-- 数据表格组件绑定数据设置宽度等属性还有选择改变等相关事件 -->
<el-table ref="homeBrandTable"
: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="120" 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.brandName}}</template>
</el-table-column>
<!-- 通过开关显示是否推荐的表格列绑定状态改变事件 -->
<el-table-column label="是否推荐" width="200" align="center">
<template slot-scope="scope">
<el-switch
@change="handleRecommendStatusStatusChange(scope.$index, scope.row)"
:active-value="1"
:inactive-value="0"
v-model="scope.row.recommendStatus">
</el-switch>
@change="handleRecommendStatusStatusChange(scope.$index, scope.row)"
:active-value="1"
:inactive-value="0"
v-model="scope.row.recommendStatus">
</el-switch>
</template>
</el-table-column>
<!-- 显示排序的表格列 -->
<el-table-column label="排序" width="160" align="center">
<template slot-scope="scope">{{scope.row.sort}}</template>
</el-table-column>
<!-- 显示状态的表格列使用过滤器格式化内容 -->
<el-table-column label="状态" width="160" align="center">
<template slot-scope="scope">{{scope.row.recommendStatus | formatRecommendStatus}}</template>
</el-table-column>
<!-- 显示操作按钮的表格列 -->
<el-table-column label="操作" width="180" align="center">
<template slot-scope="scope">
<el-button size="mini"
@ -83,10 +106,13 @@
</el-table-column>
</el-table>
</div>
<!-- 批量操作相关选择框和按钮的容器 -->
<div class="batch-operate-container">
<!-- 选择批量操作类型的下拉框双向绑定操作类型数据 -->
<el-select
size="small"
v-model="operateType" placeholder="批量操作">
<!-- 循环生成下拉选项 -->
<el-option
v-for="item in operates"
:key="item.value"
@ -94,6 +120,7 @@
:value="item.value">
</el-option>
</el-select>
<!-- 触发批量操作的按钮设置样式类型等属性绑定点击事件 -->
<el-button
style="margin-left: 20px"
class="search-button"
@ -103,7 +130,9 @@
确定
</el-button>
</div>
<!-- 分页组件的容器 -->
<div class="pagination-container">
<!-- 分页组件设置背景各类事件绑定页面尺寸等属性 -->
<el-pagination
background
@size-change="handleSizeChange"
@ -115,19 +144,26 @@
:total="total">
</el-pagination>
</div>
<!-- 选择品牌的对话框组件设置标题可见性绑定宽度等属性 -->
<el-dialog title="选择品牌" :visible.sync="selectDialogVisible" width="40%">
<!-- 对话框内的品牌名称搜索输入框绑定数据设置样式等属性 -->
<el-input v-model="dialogData.listQuery.keyword"
style="width: 250px;margin-bottom: 20px"
size="small"
placeholder="品牌名称搜索">
<!-- 输入框后的搜索按钮绑定点击事件 -->
<el-button slot="append" icon="el-icon-search" @click="handleSelectSearch()"></el-button>
</el-input>
<!-- 对话框内展示品牌相关数据的表格设置数据绑定选择改变事件等属性 -->
<el-table :data="dialogData.list"
@selection-change="handleDialogSelectionChange" border>
<!-- 显示选择框的表格列 -->
<el-table-column type="selection" width="60" align="center"></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="220" align="center">
<template slot-scope="scope">
商品<span class="color-main">{{scope.row.productCount}}</span>
@ -135,7 +171,9 @@
</template>
</el-table-column>
</el-table>
<!-- 对话框内的分页组件容器 -->
<div class="pagination-container">
<!-- 分页组件设置背景各类事件绑定页面尺寸等属性 -->
<el-pagination
background
@size-change="handleDialogSizeChange"
@ -149,23 +187,30 @@
</div>
<div style="clear: both;"></div>
<div slot="footer">
<!-- 对话框取消按钮点击隐藏对话框 -->
<el-button size="small" @click="selectDialogVisible = false"> </el-button>
<!-- 对话框确认按钮绑定点击事件 -->
<el-button size="small" type="primary" @click="handleSelectDialogConfirm()"> </el-button>
</div>
</el-dialog>
<!-- 设置排序的对话框组件设置标题可见性绑定宽度等属性 -->
<el-dialog title="设置排序"
:visible.sync="sortDialogVisible"
width="40%">
<!-- 对话框内的表单绑定数据模型设置标签宽度等属性 -->
<el-form :model="sortDialogData"
label-width="150px">
<!-- 排序输入框的表单项 -->
<el-form-item label="排序:">
<el-input v-model="sortDialogData.sort" style="width: 200px"></el-input>
</el-form-item>
</el-form>
<span slot="footer">
<el-button @click="sortDialogVisible = false" size="small"> </el-button>
<el-button type="primary" @click="handleUpdateSort" size="small"> </el-button>
</span>
<!-- 对话框取消按钮点击隐藏对话框 -->
<el-button @click="sortDialogVisible = false" size="small"> </el-button>
<!-- 对话框确认按钮绑定点击事件 -->
<el-button type="primary" @click="handleUpdateSort" size="small"> </el-button>
</span>
</el-dialog>
</div>
</template>

@ -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 {
name: 'addCoupon',
components: { CouponDetail }
}
// CouponDetail'./components/CouponDetail'
import CouponDetail from './components/CouponDetail';
export default {
// addCoupon
name: 'addCoupon',
// CouponDetail使使
components: { CouponDetail }
}
</script>
<style scoped>
<!-- 带有scoped属性的style标签里面样式仅作用于当前组件目前为空 -->
</style>

@ -1,12 +1,16 @@
<template> 
<template>
<!-- el-card组件作为表单的容器设置了类名和无阴影效果 -->
<el-card class="form-container" shadow="never">
<!-- el-form表单组件绑定了数据模型coupon设置了验证规则表单引用标签宽度和尺寸等属性 -->
<el-form :model="coupon"
:rules="rules"
ref="couponFrom"
label-width="150px"
size="small">
<!-- 优惠券类型的表单项使用el-select下拉选择框来选择类型 -->
<el-form-item label="优惠券类型:">
<el-select v-model="coupon.type">
<!-- 通过v-for循环生成下拉选项 -->
<el-option
v-for="type in typeOptions"
:key="type.value"
@ -15,11 +19,14 @@
</el-option>
</el-select>
</el-form-item>
<!-- 优惠券名称的表单项使用el-input输入框输入名称设置了数据绑定和类名 -->
<el-form-item label="优惠券名称:" prop="name">
<el-input v-model="coupon.name" class="input-width"></el-input>
</el-form-item>
<!-- 适用平台的表单项用el-select下拉选择框选择平台 -->
<el-form-item label="适用平台:">
<el-select v-model="coupon.platform">
<!-- 通过v-for循环生成下拉选项 -->
<el-option
v-for="item in platformOptions"
:key="item.value"
@ -28,33 +35,40 @@
</el-option>
</el-select>
</el-form-item>
<!-- 总发行量的表单项用el-input输入框输入发行量设置了数据绑定和占位提示等属性 -->
<el-form-item label="总发行量:" prop="publishCount">
<el-input v-model.number="coupon.publishCount" placeholder="只能输入正整数" class="input-width"></el-input>
</el-form-item>
<!-- 面额的表单项用el-input输入框输入面额设置了数据绑定占位提示和后缀文本等属性 -->
<el-form-item label="面额:" prop="amount">
<el-input v-model.number="coupon.amount" placeholder="面值只能是数值限2位小数" class="input-width">
<template slot="append"></template>
</el-input>
</el-form-item>
<!-- 每人限领的表单项用el-input输入框输入限领数量设置了数据绑定和后缀文本等属性 -->
<el-form-item label="每人限领:">
<el-input v-model="coupon.perLimit" placeholder="只能输入正整数" class="input-width">
<template slot="append"></template>
</el-input>
</el-form-item>
<!-- 使用门槛的表单项用el-input输入框输入门槛金额设置了数据绑定前后缀文本等属性 -->
<el-form-item label="使用门槛:" prop="minPoint">
<el-input v-model.number="coupon.minPoint" placeholder="只能输入正整数" class="input-width">
<template slot="prepend"></template>
<template slot="append">元可用</template>
</el-input>
</el-form-item>
<!-- 领取日期的表单项用el-date-picker日期选择器选择日期设置了数据绑定和类名等属性 -->
<el-form-item label="领取日期:" prop="enableTime">
<el-date-picker type="date" placeholder="选择日期" v-model="coupon.enableTime" class="input-width"></el-date-picker>
</el-form-item>
<!-- 有效期的表单项通过两个el-date-picker日期选择器分别选择开始和结束日期 -->
<el-form-item label="有效期:">
<el-date-picker type="date" placeholder="选择日期" v-model="coupon.startTime" style="width: 150px"></el-date-picker>
<span style="margin-left: 20px;margin-right: 20px"></span>
<el-date-picker type="date" placeholder="选择日期" v-model="coupon.endTime" style="width: 150px"></el-date-picker>
</el-form-item>
<!-- 可使用商品的表单项用el-radio-group单选按钮组选择使用类型 -->
<el-form-item label="可使用商品:">
<el-radio-group v-model="coupon.useType">
<el-radio-button :label="0">全场通用</el-radio-button>
@ -62,21 +76,27 @@
<el-radio-button :label="2">指定商品</el-radio-button>
</el-radio-group>
</el-form-item>
<!-- 当可使用商品类型为指定分类时显示的内容包含分类选择器添加按钮和展示关联分类关系的表格 -->
<el-form-item v-show="coupon.useType===1">
<!-- el-cascader分类选择器用于选择分类设置了可清除占位提示等属性 -->
<el-cascader
clearable
placeholder="请选择分类名称"
v-model="selectProductCate"
:options="productCateOptions">
</el-cascader>
<!-- 添加分类关联的按钮绑定点击事件 -->
<el-button @click="handleAddProductCategoryRelation()"></el-button>
<!-- 展示已添加的分类关联关系的表格设置了数据绑定等属性 -->
<el-table ref="productCateRelationTable"
:data="coupon.productCategoryRelationList"
style="width: 100%;margin-top: 20px"
border>
<!-- 显示分类名称的表格列 -->
<el-table-column label="分类名称" align="center">
<template slot-scope="scope">{{scope.row.parentCategoryName}}>{{scope.row.productCategoryName}}</template>
</el-table-column>
<!-- 显示操作按钮删除的表格列 -->
<el-table-column label="操作" align="center" width="100">
<template slot-scope="scope">
<el-button size="mini"
@ -87,7 +107,9 @@
</el-table-column>
</el-table>
</el-form-item>
<!-- 当可使用商品类型为指定商品时显示的内容包含商品选择框添加按钮和展示关联商品关系的表格 -->
<el-form-item v-show="coupon.useType===2">
<!-- el-select商品选择框设置了可过滤远程搜索等属性 -->
<el-select
v-model="selectProduct"
filterable
@ -96,6 +118,7 @@
placeholder="商品名称/商品货号"
:remote-method="searchProductMethod"
:loading="selectProductLoading">
<!-- 通过v-for循环生成商品选项 -->
<el-option
v-for="item in selectProductOptions"
:key="item.productId"
@ -105,17 +128,22 @@
<span style="float: right; color: #8492a6; font-size: 13px">NO.{{ item.productSn }}</span>
</el-option>
</el-select>
<!-- 添加商品关联的按钮绑定点击事件 -->
<el-button @click="handleAddProductRelation()"></el-button>
<!-- 展示已添加的商品关联关系的表格设置了数据绑定等属性 -->
<el-table ref="productRelationTable"
:data="coupon.productRelationList"
style="width: 100%;margin-top: 20px"
border>
<!-- 显示商品名称的表格列 -->
<el-table-column label="商品名称" align="center">
<template slot-scope="scope">{{scope.row.productName}}</template>
</el-table-column>
<!-- 显示商品货号的表格列 -->
<el-table-column label="货号" align="center" width="120" >
<template slot-scope="scope">NO.{{scope.row.productSn}}</template>
</el-table-column>
<!-- 显示操作按钮删除的表格列 -->
<el-table-column label="操作" align="center" width="100">
<template slot-scope="scope">
<el-button size="mini"
@ -126,6 +154,7 @@
</el-table-column>
</el-table>
</el-form-item>
<!-- 备注的表单项用el-input输入框输入备注内容设置了类名类型为文本域等属性 -->
<el-form-item label="备注:">
<el-input
class="input-width"
@ -135,241 +164,276 @@
v-model="coupon.note">
</el-input>
</el-form-item>
<!-- 提交和重置按钮所在的表单项 -->
<el-form-item>
<!-- 提交按钮设置类型为primary绑定点击事件 -->
<el-button type="primary" @click="onSubmit('couponFrom')"></el-button>
<!-- 重置按钮根据条件判断是否显示绑定点击事件 -->
<el-button v-if="!isEdit" @click="resetForm('couponFrom')"></el-button>
</el-form-item>
</el-form>
</el-card>
</template>
<script>
import {createCoupon,getCoupon,updateCoupon} from '@/api/coupon';
import {fetchSimpleList as fetchProductList} from '@/api/product';
import {fetchListWithChildren} from '@/api/productCate'
const defaultCoupon = {
type: 0,
name: null,
platform: 0,
amount: null,
perLimit: 1,
minPoint: null,
startTime: null,
endTime: null,
useType: 0,
note: null,
publishCount: null,
productRelationList: [],
productCategoryRelationList: []
};
const defaultTypeOptions = [
{
label: '全场赠券',
value: 0
},
{
label: '会员赠券',
value: 1
},
{
label: '购物赠券',
value: 2
},
{
label: '注册赠券',
value: 3
// '@/api/coupon'
import {createCoupon, getCoupon, updateCoupon} from '@/api/coupon';
// '@/api/product'fetchProductList
import {fetchSimpleList as fetchProductList} from '@/api/product';
// '@/api/productCate'
import {fetchListWithChildren} from '@/api/productCate';
//
const defaultCoupon = {
type: 0,
name: null,
platform: 0,
amount: null,
perLimit: 1,
minPoint: null,
startTime: null,
endTime: null,
useType: 0,
note: null,
publishCount: null,
productRelationList: [],
productCategoryRelationList: []
};
//
const defaultTypeOptions = [
{
label: '全场赠券',
value: 0
},
{
label: '会员赠券',
value: 1
},
{
label: '购物赠券',
value: 2
},
{
label: '注册赠券',
value: 3
}
];
// PC
const defaultPlatformOptions = [
{
label: '全平台',
value: 0
},
{
label: '移动平台',
value: 1
},
{
label: 'PC平台',
value: 2
}
];
export default {
name: 'CouponDetail',
// isEditfalse
props: {
isEdit: {
type: Boolean,
default: false
}
];
const defaultPlatformOptions = [
{
label: '全平台',
value: 0
},
{
label: '移动平台',
value: 1
},
{
label: 'PC平台',
value: 2
},
data() {
return {
//
coupon: Object.assign({}, defaultCoupon),
//
typeOptions: Object.assign({}, defaultTypeOptions),
//
platformOptions: Object.assign({}, defaultPlatformOptions),
//
rules: {
name: [
{required: true, message: '请输入优惠券名称', trigger: 'blur'},
{min: 2, max: 140, message: '长度在 2 到 140 个字符', trigger: 'blur'}
],
publishCount: [
{type: 'number', required: true, message: '只能输入正整数', trigger: 'blur'}
],
amount: [
{type: 'number', required: true, message: '面值只能是数值0.01-10000限2位小数', trigger: 'blur'}
],
minPoint: [
{type: 'number', required: true, message: '只能输入正整数', trigger: 'blur'}
]
},
// null
selectProduct: null,
// false
selectProductLoading: false,
//
selectProductOptions: [],
// null
selectProductCate: null,
//
productCateOptions: []
}
];
export default {
name: 'CouponDetail',
props: {
isEdit: {
type: Boolean,
default: false
}
},
data() {
return {
coupon: Object.assign({}, defaultCoupon),
typeOptions: Object.assign({}, defaultTypeOptions),
platformOptions: Object.assign({}, defaultPlatformOptions),
rules: {
name: [
{required: true, message: '请输入优惠券名称', trigger: 'blur'},
{min: 2, max: 140, message: '长度在 2 到 140 个字符', trigger: 'blur'}
],
publishCount: [
{type: 'number',required: true, message: '只能输入正整数', trigger: 'blur'}
],
amount: [
{type: 'number',required: true,message: '面值只能是数值0.01-10000限2位小数',trigger: 'blur'}
],
minPoint: [
{type: 'number',required: true,message: '只能输入正整数',trigger: 'blur'}
]
},
selectProduct:null,
selectProductLoading: false,
selectProductOptions:[],
selectProductCate: null,
productCateOptions: []
}
},
created(){
if(this.isEdit){
getCoupon(this.$route.query.id).then(response=>{
this.coupon=response.data;
});
}
this.getProductCateList();
},
methods:{
onSubmit(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
this.$confirm('是否提交数据', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
if(this.isEdit){
updateCoupon(this.$route.query.id,this.coupon).then(response=>{
this.$refs[formName].resetFields();
this.$message({
message: '修改成功',
type: 'success',
duration:1000
});
this.$router.back();
},
created() {
// coupon
if (this.isEdit) {
getCoupon(this.$route.query.id).then(response => {
this.coupon = response.data;
});
}
//
this.getProductCateList();
},
methods: {
//
onSubmit(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
this.$confirm('是否提交数据', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
if (this.isEdit) {
updateCoupon(this.$route.query.id, this.coupon).then(response => {
this.$refs[formName].resetFields();
this.$message({
message: '修改成功',
type: 'success',
duration: 1000
});
}else{
createCoupon(this.coupon).then(response=>{
this.$refs[formName].resetFields();
this.$message({
message: '提交成功',
type: 'success',
duration:1000
});
this.$router.back();
this.$router.back();
});
} else {
createCoupon(this.coupon).then(response => {
this.$refs[formName].resetFields();
this.$message({
message: '提交成功',
type: 'success',
duration: 1000
});
}
});
} else {
this.$message({
message: '验证失败',
type: 'error',
duration:1000
});
return false;
}
});
},
resetForm(formName) {
this.$refs[formName].resetFields();
this.coupon = Object.assign({},defaultCoupon);
},
searchProductMethod(query){
if (query !== '') {
this.loading = true;
fetchProductList({keyword:query}).then(response=>{
this.loading=false;
let productList = response.data;
this.selectProductOptions = [];
for(let i=0;i<productList.length;i++){
let item = productList[i];
this.selectProductOptions.push({productId:item.id,productName:item.name,productSn:item.productSn});
this.$router.back();
});
}
});
} else {
this.selectProductOptions = [];
}
},
handleAddProductRelation(){
if(this.selectProduct===null){
this.$message({
message: '请先选择商品',
type: 'warning'
message: '验证失败',
type: 'error',
duration: 1000
});
return
return false;
}
this.coupon.productRelationList.push(this.getProductById(this.selectProduct));
this.selectProduct=null;
},
handleDeleteProductRelation(index,row){
this.coupon.productRelationList.splice(index,1);
},
handleAddProductCategoryRelation(){
if(this.selectProductCate===null||this.selectProductCate.length===0){
this.$message({
message: '请先选择商品分类',
type: 'warning'
});
return
}
this.coupon.productCategoryRelationList.push(this.getProductCateByIds(this.selectProductCate));
this.selectProductCate=[];
},
handleDeleteProductCateRelation(index,row){
this.coupon.productCategoryRelationList.splice(index,1);
},
getProductById(id){
for(let i=0;i<this.selectProductOptions.length;i++){
if(id===this.selectProductOptions[i].productId){
return this.selectProductOptions[i];
});
},
// coupon
resetForm(formName) {
this.$refs[formName].resetFields();
this.coupon = Object.assign({}, defaultCoupon);
},
//
searchProductMethod(query) {
if (query!== '') {
this.loading = true;
fetchProductList({keyword: query}).then(response => {
this.loading = false;
let productList = response.data;
this.selectProductOptions = [];
for (let i = 0; i < productList.length; i++) {
let item = productList[i];
this.selectProductOptions.push({productId: item.id, productName: item.name, productSn: item.productSn});
}
});
} else {
this.selectProductOptions = [];
}
},
//
handleAddProductRelation() {
if (this.selectProduct === null) {
this.$message({
message: '请先选择商品',
type: 'warning'
});
return
}
this.coupon.productRelationList.push(this.getProductById(this.selectProduct));
this.selectProduct = null;
},
//
handleDeleteProductRelation(index, row) {
this.coupon.productRelationList.splice(index, 1);
},
//
handleAddProductCategoryRelation() {
if (this.selectProductCate === null || this.selectProductCate.length === 0) {
this.$message({
message: '请先选择商品分类',
type: 'warning'
});
return
}
this.coupon.productCategoryRelationList.push(this.getProductCateByIds(this.selectProductCate));
this.selectProductCate = [];
},
//
handleDeleteProductCateRelation(index, row) {
this.coupon.productCategoryRelationList.splice(index, 1);
},
// idid
getProductById(id) {
for (let i = 0; i < this.selectProductOptions.length; i++) {
if (id === this.selectProductOptions[i].productId) {
return this.selectProductOptions[i];
}
return null;
},
getProductCateList() {
fetchListWithChildren().then(response => {
let list = response.data;
this.productCateOptions = [];
for (let i = 0; i < list.length; i++) {
let children = [];
if (list[i].children != null && list[i].children.length > 0) {
for (let j = 0; j < list[i].children.length; j++) {
children.push({label: list[i].children[j].name, value: list[i].children[j].id});
}
}
return null;
},
//
getProductCateList() {
fetchListWithChildren().then(response => {
let list = response.data;
this.productCateOptions = [];
for (let i = 0; i < list.length; i++) {
let children = [];
if (list[i].children!= null && list[i].children.length > 0) {
for (let j = 0; j < list[i].children.length; j++) {
children.push({label: list[i].children[j].name, value: list[i].children[j].id});
}
this.productCateOptions.push({label: list[i].name, value: list[i].id, children: children});
}
});
},
getProductCateByIds(ids){
let name;
let parentName;
for (let i = 0; i < this.productCateOptions.length; i++) {
if (this.productCateOptions[i].value === ids[0]) {
parentName = this.productCateOptions[i].label;
for (let j = 0; j < this.productCateOptions[i].children.length; j++) {
if (this.productCateOptions[i].children[j].value === ids[1]) {
name = this.productCateOptions[i].children[j].label;
}
this.productCateOptions.push({label: list[i].name, value: list[i].id, children: children});
}
});
},
// idid
getProductCateByIds(ids) {
let name;
let parentName;
for (let i = 0; i < this.productCateOptions.length; i++) {
if (this.productCateOptions[i].value === ids[0]) {
parentName = this.productCateOptions[i].label;
for (let j = 0; j < this.productCateOptions[i].children.length; j++) {
if (this.productCateOptions[i].children[j].value === ids[1]) {
name = this.productCateOptions[i].children[j].label;
}
}
}
return {productCategoryId: ids[1], productCategoryName: name, parentCategoryName: parentName};
}
return {productCategoryId: ids[1], productCategoryName: name, parentCategoryName: parentName};
}
}
}
</script>
<style scoped>
.input-width {
width: 60%;
}
<!-- 带有scoped属性的style标签意味着里面定义的样式仅作用于当前组件内的元素 -->
.input-width {
<!-- 定义了一个类选择器样式作用是将应用该类的元素宽度设置为其父元素宽度的60% -->
width: 60%;
}
</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,200 +165,231 @@
</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 = [
{
label: '全场赠券',
value: 0
//
const defaultTypeOptions = [
{
label: '全场赠券',
value: 0
},
{
label: '会员赠券',
value: 1
},
{
label: '购物赠券',
value: 2
},
{
label: '注册赠券',
value: 3
}
];
// 使
const defaultListQuery = {
pageNum: 1,
pageSize: 10,
useStatus: null,
orderSn: null,
couponId: null
};
// 使使使
const defaultUseTypeOptions = [
{
label: "未使用",
value: 0
},
{
label: "已使用",
value: 1
},
{
label: "已过期",
value: 2
}
];
export default {
name: 'couponHistoryList',
data() {
return {
//
coupon: {},
//
listQuery: Object.assign({}, defaultListQuery),
// 使
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;
});
// 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) {
return defaultTypeOptions[i].label;
}
}
return '';
},
{
label: '会员赠券',
value: 1
// 使
formatUseType(useType) {
if (useType === 0) {
return '全场通用';
} else if (useType === 1) {
return '指定分类';
} else {
return '指定商品';
}
},
{
label: '购物赠券',
value: 2
//
formatPlatform(platform) {
if (platform === 1) {
return '移动平台';
} else if (platform === 2) {
return 'PC平台';
} else {
return '全平台';
}
},
{
label: '注册赠券',
value: 3
}
];
const defaultListQuery = {
pageNum: 1,
pageSize: 10,
useStatus: null,
orderSn: null,
couponId: null
};
const defaultUseTypeOptions= [
{
label: "未使用",
value: 0
//
formatDate(time) {
if (time == null || time === '') {
return 'N/A';
}
let date = new Date(time);
return formatDate(date, 'yyyy-MM-dd')
},
{
label: "已使用",
value: 1
//
formatStatus(endTime) {
let now = new Date().getTime();
if (endTime > now) {
return '未过期'
} else {
return '已过期';
}
},
{
label: "已过期",
value: 2
}
];
export default {
name: 'couponHistoryList',
data() {
return {
coupon: {},
listQuery: Object.assign({}, defaultListQuery),
useTypeOptions:Object.assign({},defaultUseTypeOptions),
list:null,
total:null,
listLoading:false
//
formatGetType(type) {
if (type === 1) {
return '主动获取';
} else {
return '后台赠送';
}
},
// 使
formatCouponHistoryUseType(useType) {
if (useType === 0) {
return '未使用';
} else if (useType === 1) {
return '已使用';
} else {
return '已过期';
}
},
//
formatTime(time) {
if (time == null || time === '') {
return 'N/A';
}
let date = new Date(time);
return formatDate(date, 'yyyy-MM-dd hh:mm:ss')
},
created() {
getCoupon(this.$route.query.id).then(response => {
this.coupon = response.data;
},
methods: {
// true
getList() {
this.listLoading = true;
fetchCouponHistoryList(this.listQuery).then(response => {
this.listLoading = false;
this.list = response.data.list;
this.total = response.data.total;
});
this.listQuery.couponId=this.$route.query.id;
},
// id
handleResetSearch() {
this.listQuery = Object.assign({}, defaultListQuery);
this.listQuery.couponId = this.$route.query.id;
},
//
handleSearchList() {
this.listQuery.pageNum = 1;
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 '已过期';
}
},
formatGetType(type) {
if(type===1){
return '主动获取';
}else{
return '后台赠送';
}
},
formatCouponHistoryUseType(useType) {
if (useType === 0) {
return '未使用';
} else if (useType === 1) {
return '已使用';
} else {
return '已过期';
}
},
formatTime(time) {
if (time == null || time === '') {
return 'N/A';
}
let date = new Date(time);
return formatDate(date, 'yyyy-MM-dd hh:mm:ss')
},
//
handleSizeChange(val) {
this.listQuery.pageNum = 1;
this.listQuery.pageSize = val;
this.getList();
},
methods: {
getList(){
this.listLoading=true;
fetchCouponHistoryList(this.listQuery).then(response=>{
this.listLoading=false;
this.list=response.data.list;
this.total=response.data.total;
});
},
handleResetSearch() {
this.listQuery = Object.assign({}, defaultListQuery);
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();
}
//
handleCurrentChange(val) {
this.listQuery.pageNum = val;
this.getList();
}
}
}
</script>
<style scoped>
.app-container {
width: 80%;
margin: 20px auto;
}
.filter-container {
margin-top: 20px;
}
.table-layout {
margin-top: 20px;
border-left: 1px solid #DCDFE6;
border-top: 1px solid #DCDFE6;
}
.table-cell {
height: 60px;
line-height: 40px;
border-right: 1px solid #DCDFE6;
border-bottom: 1px solid #DCDFE6;
padding: 10px;
font-size: 14px;
color: #606266;
text-align: center;
overflow: hidden;
}
.table-cell-title {
border-right: 1px solid #DCDFE6;
border-bottom: 1px solid #DCDFE6;
padding: 10px;
background: #F2F6FC;
text-align: center;
font-size: 14px;
color: #303133;
}
<style scoped>
<!-- 定义类名为app-container的样式设置宽度外边距使其水平居中 -->
.app-container {
width: 80%;
margin: 20px auto;
}
<!-- 定义类名为filter-container的样式设置上边距 -->
.filter-container {
margin-top: 20px;
}
<!-- 定义类名为table-layout的样式设置上边距左边框上边框 -->
.table-layout {
margin-top: 20px;
border-left: 1px solid #DCDFE6;
border-top: 1px solid #DCDFE6;
}
<!-- 定义类名为table-cell的样式设置高度行高边框内边距字体大小颜色文本对齐溢出处理等属性 -->
.table-cell {
height: 60px;
line-height: 40px;
border-right: 1px solid #DCDFE6;
border-bottom: 1px solid #DCDFE6;
padding: 10px;
font-size: 14px;
color: #606266;
text-align: center;
overflow: hidden;
}
<!-- 定义类名为table-cell-title的样式设置边框内边距背景色文本对齐字体大小颜色等属性 -->
.table-cell-title {
border-right: 1px solid #DCDFE6;
border-bottom: 1px solid #DCDFE6;
padding: 10px;
background: #F2F6FC;
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,147 +137,176 @@
</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
// '@/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 = [
{
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),
// null
list: null,
// null
total: null,
// false
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 '指定商品';
}
},
{
label: '会员赠券',
value: 1
//
formatPlatform(platform) {
if (platform === 1) {
return '移动平台';
} else if (platform === 2) {
return 'PC平台';
} else {
return '全平台';
}
},
{
label: '购物赠券',
value: 2
//
formatDate(time) {
if (time == null || time === '') {
return 'N/A';
}
let date = new Date(time);
return formatDate(date, 'yyyy-MM-dd')
},
{
label: '注册赠券',
value: 3
}
];
export default {
name:'couponList',
data() {
return {
listQuery:Object.assign({},defaultListQuery),
typeOptions:Object.assign({},defaultTypeOptions),
list:null,
total:null,
listLoading:false,
multipleSelection:[]
//
formatStatus(endTime) {
let now = new Date().getTime();
let endDate = new Date(endTime);
if (endDate > now) {
return '未过期'
} else {
return '已过期';
}
}
},
methods: {
//
handleResetSearch() {
this.listQuery = Object.assign({}, defaultListQuery);
},
created(){
//
handleSearchList() {
this.listQuery.pageNum = 1;
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();
let endDate = new Date(endTime);
if(endDate>now){
return '未过期'
}else{
return '已过期';
}
}
//
handleSelectionChange(val) {
this.multipleSelection = val;
},
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();
//
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'})
},
// 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 => {
this.$message({
type: 'success',
message: '删除成功!'
});
})
},
getList(){
this.listLoading=true;
fetchList(this.listQuery).then(response=>{
this.listLoading = false;
this.list = response.data.list;
this.total = response.data.total;
this.getList();
});
}
})
},
// 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 {
name: 'updateCoupon',
components: { CouponDetail }
}
// './components/CouponDetail'CouponDetail
import CouponDetail from './components/CouponDetail';
export default {
// updateCoupon
name: 'updateCoupon',
// CouponDetail使使
components: { CouponDetail }
}
</script>
<style scoped>
<!-- 带有scoped属性的style标签里面样式仅作用于当前组件目前为空 -->
</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>
<!-- 用于触发查询搜索操作的按钮设置了按钮样式类型为主要按钮绑定了点击事件handleSearchList -->
<el-button
style="float:right"
type="primary"
@ -11,6 +16,7 @@
size="small">
查询搜索
</el-button>
<!-- 用于触发重置筛选条件操作的按钮设置了按钮样式与右侧有一定间距绑定了点击事件handleResetSearch -->
<el-button
style="float:right;margin-right: 15px"
@click="handleResetSearch()"
@ -19,42 +25,75 @@
</el-button>
</div>
<div style="margin-top: 15px">
<!-- 行内表单用于设置筛选条件绑定了数据模型listQuery设置了表单尺寸和标签宽度 -->
<el-form :inline="true" :model="listQuery" size="small" label-width="140px">
<!-- 对应活动名称输入框的表单项 -->
<el-form-item label="活动名称:">
<!-- 输入框双向绑定listQuery.keyword数据设置了类名占位提示以及可清除内容的属性 -->
<el-input v-model="listQuery.keyword" class="input-width" placeholder="活动名称" clearable></el-input>
</el-form-item>
</el-form>
</div>
</el-card>
<!-- 操作区域的卡片容器同样设置了无阴影效果 -->
<el-card class="operate-container" shadow="never">
<i class="el-icon-tickets"></i>
<span>数据列表</span>
<!-- 用于触发添加活动操作的按钮设置了按钮尺寸类名绑定了点击事件handleAdd -->
<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-card>
<!-- 放置数据表格的容器 -->
<div class="table-container">
<!-- 数据表格组件绑定了数据list设置了宽度加载状态以及边框等属性 -->
<el-table ref="flashTable"
:data="list"
style="width: 100%;"
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>
<template slot-scope="scope">
<!-- 在表格单元格的作用域内显示对应行数据中的id字段内容 -->
{{scope.row.id}}
</template>
</el-table-column>
<!-- 显示活动标题的表格列内容居中对齐 -->
<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>
<!-- 显示活动状态的表格列设置了宽度和对齐方式使用了过滤器formatActiveStatus来格式化显示内容 -->
<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>
<!-- 显示开始时间的表格列设置了宽度和对齐方式使用了日期格式化过滤器formatDate -->
<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>
<!-- 显示结束时间的表格列设置了宽度和对齐方式同样使用了日期格式化过滤器formatDate -->
<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 label="上线/下线" width="200" align="center">
<template slot-scope="scope">
<!-- 开关组件用于切换上线/下线状态绑定了状态改变的事件handleStatusChange设置了激活值和未激活值双向绑定对应行数据中的status字段 -->
<el-switch
@change="handleStatusChange(scope.$index, scope.row)"
:active-value="1"
@ -63,17 +102,21 @@
</el-switch>
</template>
</el-table-column>
<!-- 显示操作按钮的表格列设置了宽度和对齐方式 -->
<el-table-column label="操作" width="180" align="center">
<template slot-scope="scope">
<!-- 用于触发设置商品操作的按钮设置了按钮尺寸类型为文本按钮绑定了点击事件handleSelectSession -->
<el-button size="mini"
type="text"
@click="handleSelectSession(scope.$index, scope.row)">设置商品
</el-button>
<!-- 用于触发编辑操作的按钮设置了按钮尺寸类型为文本按钮绑定了点击事件handleUpdate -->
<el-button size="mini"
type="text"
@click="handleUpdate(scope.$index, scope.row)">
编辑
</el-button>
<!-- 用于触发删除操作的按钮设置了按钮尺寸类型为文本按钮绑定了点击事件handleDelete -->
<el-button size="mini"
type="text"
@click="handleDelete(scope.$index, scope.row)">删除
@ -82,7 +125,10 @@
</el-table-column>
</el-table>
</div>
<!-- 分页组件的容器 -->
<div class="pagination-container">
<!-- 分页组件设置了背景显示页面尺寸改变和当前页码改变的事件绑定以及布局当前页码每页显示数量可选的页面尺寸和数据总条数等属性 -->
<el-pagination
background
@size-change="handleSizeChange"
@ -94,16 +140,22 @@
:total="total">
</el-pagination>
</div>
<!-- 弹出对话框组件用于添加活动的相关操作设置了标题对话框显示状态的双向绑定以及宽度属性 -->
<el-dialog
title="添加活动"
:visible.sync="dialogVisible"
width="40%">
<!-- 表单组件用于在对话框内收集添加活动的相关信息绑定了数据模型flashPromotion设置了表单引用标签宽度和尺寸等属性 -->
<el-form :model="flashPromotion"
ref="flashPromotionForm"
label-width="150px" size="small">
<!-- 对应活动标题输入框的表单项 -->
<el-form-item label="活动标题:">
<!-- 输入框双向绑定flashPromotion.title数据设置了宽度 -->
<el-input v-model="flashPromotion.title" style="width: 250px"></el-input>
</el-form-item>
<!-- 对应开始时间选择框的表单项使用了日期选择器组件 -->
<el-form-item label="开始时间:">
<el-date-picker
v-model="flashPromotion.startDate"
@ -111,6 +163,7 @@
placeholder="请选择时间">
</el-date-picker>
</el-form-item>
<!-- 对应结束时间选择框的表单项同样使用了日期选择器组件 -->
<el-form-item label="结束时间:">
<el-date-picker
v-model="flashPromotion.endDate"
@ -118,178 +171,221 @@
placeholder="请选择时间">
</el-date-picker>
</el-form-item>
<!-- 对应上线/下线选择的表单项使用了单选按钮组组件 -->
<el-form-item label="上线/下线">
<el-radio-group v-model="flashPromotion.status">
<!-- 上线单选按钮选项 -->
<el-radio :label="1">上线</el-radio>
<!-- 下线单选按钮选项 -->
<el-radio :label="0">下线</el-radio>
</el-radio-group>
</el-form-item>
</el-form>
<!-- 对话框底部的操作按钮区域使用了插槽footer -->
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false" size="small"> </el-button>
<el-button type="primary" @click="handleDialogConfirm()" size="small"> </el-button>
</span>
<!-- 取消按钮点击可关闭对话框设置了按钮尺寸 -->
<el-button @click="dialogVisible = false" size="small"> </el-button>
<!-- 确定按钮点击可触发确认添加活动的相关逻辑设置了按钮类型为主要按钮尺寸为小尺寸 -->
<el-button type="primary" @click="handleDialogConfirm()" size="small"> </el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import {fetchList, updateStatus, deleteFlash, createFlash, updateFlash} from '@/api/flash';
import {formatDate} from '@/utils/date';
// '@/api/flash'
import {fetchList, updateStatus, deleteFlash, createFlash, updateFlash} from '@/api/flash';
// '@/utils/date'formatDate
import {formatDate} from '@/utils/date';
const defaultListQuery = {
pageNum: 1,
pageSize: 5,
keyword: null
};
const defaultFlashPromotion = {
id: null,
title: null,
startDate: null,
endDate: null,
status: 0
};
export default {
name: 'flashPromotionList',
data() {
return {
listQuery: Object.assign({}, defaultListQuery),
list: null,
total: null,
listLoading: false,
dialogVisible: false,
flashPromotion: Object.assign({}, defaultFlashPromotion),
isEdit: false
//
const defaultListQuery = {
pageNum: 1,
pageSize: 5,
keyword: null
};
//
const defaultFlashPromotion = {
id: null,
title: null,
startDate: null,
endDate: null,
status: 0
};
export default {
name: 'flashPromotionList',
data() {
return {
// defaultListQuery
listQuery: Object.assign({}, defaultListQuery),
// null
list: null,
// null
total: null,
// falsetrue
listLoading: false,
// /false
dialogVisible: false,
// defaultFlashPromotion
flashPromotion: Object.assign({}, defaultFlashPromotion),
// truefalsefalse
isEdit: false
}
},
created() {
//
this.getList();
},
filters: {
//
formatActiveStatus(row) {
//
let nowDate = new Date();
//
let startDate = new Date(row.startDate);
//
let endDate = new Date(row.endDate);
//
if (nowDate.getTime() >= startDate.getTime() && nowDate.getTime() <= endDate.getTime()) {
return '活动进行中';
}
//
else if (nowDate.getTime() > endDate.getTime()) {
return '活动已结束';
}
//
else {
return '活动未开始';
}
},
created() {
// 'N/A'
formatDate(time) {
if (time == null || time === '') {
return 'N/A';
}
//
let date = new Date(time);
// formatDate 'yyyy-MM-dd'
return formatDate(date, 'yyyy-MM-dd')
}
},
methods: {
// 便
handleResetSearch() {
this.listQuery = Object.assign({}, defaultListQuery);
},
// 1
handleSearchList() {
this.listQuery.pageNum = 1;
this.getList();
},
filters: {
formatActiveStatus(row) {
let nowDate = new Date();
let startDate = new Date(row.startDate);
let endDate = new Date(row.endDate);
if (nowDate.getTime() >= startDate.getTime() && nowDate.getTime() <= endDate.getTime()) {
return '活动进行中';
} else if (nowDate.getTime() > endDate.getTime()) {
return '活动已结束';
} else {
return '活动未开始';
}
},
formatDate(time) {
if (time == null || time === '') {
return 'N/A';
}
let date = new Date(time);
return formatDate(date, 'yyyy-MM-dd')
}
// 1
handleSizeChange(val) {
this.listQuery.pageNum = 1;
this.listQuery.pageSize = val;
this.getList();
},
methods: {
handleResetSearch() {
this.listQuery = Object.assign({}, defaultListQuery);
},
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();
},
handleAdd() {
this.dialogVisible = true;
this.isEdit = false;
this.flashPromotion = Object.assign({},defaultFlashPromotion);
},
handleShowSessionList() {
this.$router.push({path: '/sms/flashSession'})
},
handleStatusChange(index, row) {
this.$confirm('是否要修改该状态?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
updateStatus(row.id, {status: row.status}).then(response => {
this.$message({
type: 'success',
message: '修改成功!'
});
//
handleCurrentChange(val) {
this.listQuery.pageNum = val;
this.getList();
},
// true
handleAdd() {
this.dialogVisible = true;
this.isEdit = false;
this.flashPromotion = Object.assign({}, defaultFlashPromotion);
},
// '/sms/flashSession'
handleShowSessionList() {
this.$router.push({path: '/sms/flashSession'})
},
//
handleStatusChange(index, row) {
this.$confirm('是否要修改该状态?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
updateStatus(row.id, {status: row.status}).then(response => {
this.$message({
type: 'success',
message: '修改成功!'
});
}).catch(() => {
});
}).catch(() => {
this.$message({
type: 'info',
message: '取消修改'
});
this.getList();
});
},
//
handleDelete(index, row) {
this.$confirm('是否要删除该活动?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
deleteFlash(row.id).then(response => {
this.$message({
type: 'info',
message: '取消修改'
type: 'success',
message: '删除成功!'
});
this.getList();
});
},
handleDelete(index, row) {
this.$confirm('是否要删除该活动?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
deleteFlash(row.id).then(response => {
});
},
// true便
handleUpdate(index, row) {
this.dialogVisible = true;
this.isEdit = true;
this.flashPromotion = Object.assign({}, row);
},
//
handleDialogConfirm() {
this.$confirm('是否要确认?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
if (this.isEdit) {
updateFlash(this.flashPromotion.id, this.flashPromotion).then(response => {
this.$message({
type: 'success',
message: '删除成功!'
message: '修改成功!',
type: 'success'
});
this.dialogVisible = false;
this.getList();
});
});
},
handleUpdate(index, row) {
this.dialogVisible = true;
this.isEdit = true;
this.flashPromotion = Object.assign({},row);
},
handleDialogConfirm() {
this.$confirm('是否要确认?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
if (this.isEdit) {
updateFlash(this.flashPromotion.id,this.flashPromotion).then(response => {
this.$message({
message: '修改成功!',
type: 'success'
});
this.dialogVisible =false;
this.getList();
})
} else {
createFlash(this.flashPromotion).then(response => {
this.$message({
message: '添加成功!',
type: 'success'
});
this.dialogVisible =false;
this.getList();
})
}
})
},
handleSelectSession(index,row){
this.$router.push({path:'/sms/selectSession',query:{flashPromotionId:row.id}})
},
getList() {
this.listLoading = true;
fetchList(this.listQuery).then(response => {
this.listLoading = false;
this.list = response.data.list;
this.total = response.data.total;
});
}
})
} else {
createFlash(this.flashPromotion).then(response => {
this.$message({
message: '添加成功!',
type: 'success'
});
this.dialogVisible = false;
this.getList();
})
}
})
},
// '/sms/selectSession' id
handleSelectSession(index, row) {
this.$router.push({path: '/sms/selectSession', query: {flashPromotionId: row.id}})
},
// truefalse
getList() {
this.listLoading = true;
fetchList(this.listQuery).then(response => {
this.listLoading = false;
this.list = response.data.list;
this.total = response.data.total;
});
}
}
}
</script>
<style></style>

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

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

@ -1,29 +1,55 @@
<template> 
<template>
<!-- 整个页面的外层容器用于对内部各部分内容进行整体布局 -->
<div class="app-container">
<!-- el-card组件用于创建一个卡片式的容器设置了无阴影效果shadow="never"并添加了"operate-container"类名通常可用于放置操作相关的元素比如这里放置了添加按钮等 -->
<el-card shadow="never" class="operate-container">
<!-- 显示一个图标此处使用的是element-ui提供的"el-icon-tickets"图标用于对下方数据列表进行某种示意比如暗示和票务商品列表等相关的操作场景 -->
<i class="el-icon-tickets"></i>
<!-- 显示文字"数据列表"用于明确下方表格所展示数据的性质让用户知晓表格中呈现的是什么内容 -->
<span>数据列表</span>
<!-- el-button组件用于创建一个按钮设置了按钮尺寸为"mini"小型按钮添加了"btn-add"类名可能用于样式设置等绑定了点击事件"handleAdd"点击该按钮可触发对应的添加操作逻辑 -->
<el-button size="mini" class="btn-add" @click="handleAdd()"></el-button>
</el-card>
<!-- 放置数据表格的容器用于包裹下面的el-table组件使其在页面布局上更加规整将表格与其他元素区分开来 -->
<div class="table-container">
<!-- el-table组件用于创建一个数据表格设置了表格引用为"flashSessionTable"绑定了数据"list"这个数据应该是从组件的data属性或者通过接口获取等方式得到的包含了要展示在表格中的具体数据内容设置表格宽度为占满父容器100%根据"listLoading"的值来显示加载状态如加载动画等方便用户知晓数据是否正在加载中并添加了边框样式 -->
<el-table ref="flashSessionTable"
:data="list"
style="width: 100%;"
v-loading="listLoading" border>
<!-- el-table-column组件用于定义表格中的列此列用于展示编号信息设置了列的宽度为100像素内容在单元格中居中对齐 -->
<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组件用于定义表格中的列此列用于展示秒杀时间段名称信息内容在单元格中居中对齐直接展示对应行数据中的"name"字段内容用于显示每个秒杀时间段对应的名称 -->
<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组件用于定义表格中的列此列用于展示每日开始时间信息内容在单元格中居中对齐使用了名为"formatTime"的过滤器应该是在组件的filters选项中定义的用于对时间数据进行格式化处理对时间数据进行格式化后再展示 -->
<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组件用于定义表格中的列此列用于展示每日结束时间信息内容在单元格中居中对齐同样使用了名为"formatTime"的过滤器对时间数据进行格式化后再展示 -->
<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-switch组件开关组件用于切换启用/禁用状态 -->
<el-table-column label="启用" align="center">
<template slot-scope="scope">
<!-- el-switch组件用于创建一个开关按钮绑定了状态改变的事件"handleStatusChange"当开关状态改变时会触发该事件传递当前行的索引和整行数据作为参数设置了激活值为1表示启用状态对应的数值未激活值为0表示禁用状态对应的数值双向绑定对应行数据中的"status"字段意味着开关状态的改变会直接更新对应行数据里的这个字段值 -->
<el-switch
@change="handleStatusChange(scope.$index, scope.row)"
:active-value="1"
@ -32,12 +58,15 @@
</el-switch>
</template>
</el-table-column>
<!-- el-table-column组件用于定义表格中的列此列用于展示操作按钮设置了列的宽度为180像素内容在单元格中居中对齐 -->
<el-table-column label="操作" width="180" align="center">
<template slot-scope="scope">
<!-- el-button组件用于创建一个按钮设置了按钮尺寸为"mini"小型按钮按钮类型为"text"文本样式按钮通常外观上更简洁无背景色等绑定了点击事件"handleUpdate"点击该按钮可触发编辑操作逻辑按钮显示的文字为"编辑" -->
<el-button size="mini"
type="text"
@click="handleUpdate(scope.$index, scope.row)">编辑
</el-button>
<!-- el-button组件用于创建一个按钮设置了按钮尺寸为"mini"小型按钮按钮类型为"text"文本样式按钮通常外观上更简洁无背景色等绑定了点击事件"handleDelete"点击该按钮可触发删除操作逻辑按钮显示的文字为"删除" -->
<el-button size="mini"
type="text"
@click="handleDelete(scope.$index, scope.row)">删除
@ -46,163 +75,203 @@
</el-table-column>
</el-table>
</div>
<!-- el-dialog组件用于创建一个弹出式对话框常用于展示表单让用户输入信息或者进行确认等操作设置了对话框的标题为"添加时间段"通过":visible.sync"双向绑定了对话框的显示状态与组件data中的dialogVisible属性相关联改变该属性值可控制对话框的显示与隐藏设置了对话框的宽度为40%相对于屏幕宽度等的占比用于控制对话框大小 -->
<el-dialog
title="添加时间段"
:visible.sync="dialogVisible"
width="40%">
<!-- el-form组件用于创建一个表单绑定了数据模型"flashSession"这个对象应该在组件的data属性中定义用于存储表单中输入的数据等设置了表单引用为"flashSessionForm"可用于后续对表单进行验证等操作时的标识设置了标签宽度为150像素表单整体尺寸为"small"小型尺寸用于统一表单元素的外观大小等风格 -->
<el-form :model="flashSession"
ref="flashSessionForm"
label-width="150px" size="small">
<!-- el-form-item组件用于定义表单中的表单项此表单项对应的标签为"秒杀时间段名称:"用于提示用户此处应输入的内容 -->
<el-form-item label="秒杀时间段名称:">
<!-- el-input组件用于创建一个输入框双向绑定了"flashSession.name"数据意味着用户在输入框中输入的内容会实时更新到"flashSession"对象的"name"属性中设置了输入框的宽度为250像素 -->
<el-input v-model="flashSession.name" style="width: 250px"></el-input>
</el-form-item>
<!-- el-form-item组件用于定义表单中的表单项此表单项对应的标签为"每日开始时间:"用于提示用户此处应选择时间 -->
<el-form-item label="每日开始时间:">
<!-- el-time-picker组件用于创建一个时间选择器用户可以通过它选择具体的时间双向绑定了"flashSession.startTime"数据选择的时间会更新到"flashSession"对象的"startTime"属性中设置了占位提示文字为"请选择时间" -->
<el-time-picker
v-model="flashSession.startTime"
placeholder="请选择时间">
</el-time-picker>
</el-form-item>
<!-- el-form-item组件用于定义表单中的表单项此表单项对应的标签为"每日结束时间:"用于提示用户此处应选择时间 -->
<el-form-item label="每日结束时间:">
<!-- el-time-picker组件用于创建一个时间选择器用户可以通过它选择具体的时间双向绑定了"flashSession.endTime"数据选择的时间会更新到"flashSession"对象的"endTime"属性中设置了占位提示文字为"请选择时间" -->
<el-time-picker
v-model="flashSession.endTime"
placeholder="请选择时间">
</el-time-picker>
</el-form-item>
<!-- el-form-item组件用于定义表单中的表单项此表单项对应的标签为"是否启用"用于让用户选择该时间段是否启用 -->
<el-form-item label="是否启用">
<!-- el-radio-group组件用于创建一个单选按钮组绑定了"flashSession.status"数据意味着用户选择的单选按钮的值会更新到"flashSession"对象的"status"属性中 -->
<el-radio-group v-model="flashSession.status">
<!-- el-radio组件用于创建一个单选按钮设置了按钮的标签值为1对应的显示文字为"启用"用户选择该按钮后会将"flashSession.status"的值设为1 -->
<el-radio :label="1">启用</el-radio>
<!-- el-radio组件用于创建一个单选按钮设置了按钮的标签值为0对应的显示文字为"不启用"用户选择该按钮后会将"flashSession.status"的值设为0 -->
<el-radio :label="0">不启用</el-radio>
</el-radio-group>
</el-form-item>
</el-form>
<!-- 对话框底部的操作按钮区域使用了插槽"footer"来定义通常用于放置确认取消等按钮 -->
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false" size="small"> </el-button>
<el-button type="primary" @click="handleDialogConfirm()" size="small"> </el-button>
</span>
<!-- el-button组件用于创建一个按钮点击事件绑定了将"dialogVisible"属性设为false的操作即关闭对话框设置了按钮尺寸为"small"小型按钮按钮显示的文字为"取 消" -->
<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>
</span>
</el-dialog>
</div>
</template>
<script>
import {fetchList,updateStatus,deleteSession,createSession,updateSession} from '@/api/flashSession';
import {formatDate} from '@/utils/date';
const defaultFlashSession={
name:null,
startTime:null,
endTime:null,
status:0
};
export default {
name: 'flashPromotionSessionList',
data() {
return {
list: null,
listLoading: false,
dialogVisible:false,
isEdit:false,
flashSession:Object.assign({},defaultFlashSession)
// '@/api/flashSession'API
import {fetchList, updateStatus, deleteSession, createSession, updateSession} from '@/api/flashSession';
// '@/utils/date'formatDate使
import {formatDate} from '@/utils/date';
//
const defaultFlashSession = { //
name: null,
startTime: null,
endTime: null,
status: 0 //
};
export default {
name: 'flashPromotionSessionList',
data() {
return {
// null便
list: null,
// falsetruefalse
listLoading: false,
// /false
dialogVisible: false,
// truefalsefalse便
isEdit: false,
// defaultFlashSession
flashSession: Object.assign({}, defaultFlashSession)
}
},
created() {
// 使
this.getList();
},
filters: {
// formatTime便
formatTime(time) {
// null 'N/A'
if (time == null || time === '') {
return 'N/A';
}
// JavaScriptDate便使formatDateDate便
let date = new Date(time);
// formatDate 'hh:mm:ss' Date "12:30:00"
return formatDate(date, 'hh:mm:ss')
}
},
methods: {
//
handleAdd() {
this.dialogVisible = true; //true
this.isEdit = false;
this.flashSession = Object.assign({}, defaultFlashSession); //
},
created() {
this.getList();
// /
handleStatusChange(index, row) {
this.$confirm('是否要修改该状态?', '提示', { //
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
updateStatus(row.id, {status: row.status}).then(response => {
this.$message({
type: 'success',
message: '修改成功!' //
});
});
}).catch(() => { //
this.$message({
type: 'info',
message: '取消修改'
});
this.getList(); //
});
},
filters:{
formatTime(time) {
if (time == null || time === '') {
return 'N/A';
}
let date = new Date(time);
return formatDate(date, 'hh:mm:ss')
}
// .
handleUpdate(index, row) {
this.dialogVisible = true; //true
this.isEdit = true; //
this.flashSession = Object.assign({}, row);
this.flashSession.startTime = new Date(row.startTime); //Date便便
this.flashSession.endTime = new Date(row.endTime);
},
methods: {
handleAdd() {
this.dialogVisible = true;
this.isEdit = false;
this.flashSession = Object.assign({},defaultFlashSession);
},
handleStatusChange(index,row){
this.$confirm('是否要修改该状态?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
updateStatus(row.id, {status: row.status}).then(response => {
this.$message({
type: 'success',
message: '修改成功!'
});
});
}).catch(() => {
// .
handleDelete(index, row) {
this.$confirm('是否要删除该时间段?', '提示', { //
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => { //
deleteSession(row.id).then(response => {
this.$message({
type: 'info',
message: '取消修改'
type: 'success',
message: '删除成功!' //
});
this.getList();
this.getList(); //使
});
},
handleUpdate(index,row){
this.dialogVisible = true;
this.isEdit = true;
this.flashSession = Object.assign({},row);
this.flashSession.startTime=new Date(row.startTime);
this.flashSession.endTime=new Date(row.endTime);
},
handleDelete(index,row){
this.$confirm('是否要删除该时间段?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
deleteSession(row.id).then(response => {
});
},
// .
handleDialogConfirm() {
this.$confirm('是否要确认?', '提示', { //
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => { //
if (this.isEdit) {
updateSession(this.flashSession.id, this.flashSession).then(response => {
this.$message({
type: 'success',
message: '删除成功!'
message: '修改成功!',
type: 'success'
});
this.dialogVisible = false;
this.getList();
});
});
},
handleDialogConfirm() {
this.$confirm('是否要确认?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
if (this.isEdit) {
updateSession(this.flashSession.id,this.flashSession).then(response => {
this.$message({
message: '修改成功!',
type: 'success'
});
this.dialogVisible =false;
this.getList();
})
} else {
createSession(this.flashSession).then(response => {
this.$message({
message: '添加成功!',
type: 'success'
});
this.dialogVisible =false;
this.getList();
})
}
})
},
getList() {
this.listLoading = true;
fetchList({}).then(response => {
this.listLoading = false;
this.list = response.data;
});
}
})
} else {
createSession(this.flashSession).then(response => {
this.$message({
message: '添加成功!', //
type: 'success'
});
this.dialogVisible = false;
this.getList(); //
})
}
})
},
//
getList() {
this.listLoading = true; //true
fetchList({}).then(response => { //fetchList
this.listLoading = false; //false
this.list = response.data; //list
});
}
}
}
</script>
<style scoped>
.operate-container {
margin-top: 0;
}
<!-- scoped属性表示当前这个style标签内定义的样式作用范围仅限于当前组件内部避免样式影响到其他组件中同名的类或元素起到样式隔离的作用使得样式管理更加清晰和模块化 -->
.operate-container {
<!-- 这是一个CSS选择器用于选中页面中所有应用了operate-container类名的元素接下来在花括号内定义的样式规则就会应用到这些被选中的元素上 -->
<!-- margin-top是CSS的一个属性用于设置元素的上外边距也就是该元素距离其上方相邻元素的间隔距离这里将其值设置为0意味着应用了operate-container类名的元素其上外边距为0像素能精准控制这类元素在页面垂直方向上的布局位置使其更贴合设计需求 -->
margin-top: 0;
}
</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>
<!-- 查询搜索按钮设置了样式为右浮动类型为主要按钮点击时触发handleSearchList方法按钮大小为小 -->
<el-button
style="float:right"
type="primary"
@ -11,6 +16,7 @@
size="small">
查询搜索
</el-button>
<!-- 重置按钮设置了样式为右浮动右外边距为15px点击时触发handleResetSearch方法按钮大小为小 -->
<el-button
style="float:right;margin-right: 15px"
@click="handleResetSearch()"
@ -19,12 +25,18 @@
</el-button>
</div>
<div style="margin-top: 15px">
<!-- 内联表单绑定了listQuery数据模型表单大小为小标签宽度为140px -->
<el-form :inline="true" :model="listQuery" size="small" label-width="140px">
<!-- 表单项目标签为商品名称 -->
<el-form-item label="商品名称:">
<!-- 输入框双向绑定listQuery.productName数据设置了类名和占位提示文字 -->
<el-input v-model="listQuery.productName" class="input-width" placeholder="商品名称"></el-input>
</el-form-item>
<!-- 表单项目标签为推荐状态 -->
<el-form-item label="推荐状态:">
<!-- 下拉选择框双向绑定listQuery.recommendStatus数据设置了占位提示文字和可清除添加了类名 -->
<el-select v-model="listQuery.recommendStatus" placeholder="全部" clearable class="input-width">
<!-- 循环生成下拉选项根据recommendOptions数据中的每个item来生成对应的选项 -->
<el-option v-for="item in recommendOptions"
:key="item.value"
:label="item.label"
@ -35,24 +47,34 @@
</el-form>
</div>
</el-card>
<!-- 操作相关的卡片容器设置了阴影效果为无 -->
<el-card class="operate-container" shadow="never">
<!-- 图标 -->
<i class="el-icon-tickets"></i>
<span>数据列表</span>
<!-- 显示数据列表文字 -->
<i>数据列表</i>
<!-- 选择商品按钮设置了按钮大小为迷你点击时触发handleSelectProduct方法 -->
<el-button size="mini" class="btn-add" @click="handleSelectProduct()"></el-button>
</el-card>
<!-- 表格容器 -->
<div class="table-container">
<!-- el-table组件绑定了list数据作为表格数据源设置了宽度为100%选择变化时触发handleSelectionChange方法加载状态绑定listLoading显示边框 -->
<el-table ref="newProductTable"
:data="list"
style="width: 100%;"
@selection-change="handleSelectionChange"
v-loading="listLoading" border>
<!-- 表格列类型为选择列宽度为60px内容居中对齐 -->
<el-table-column type="selection" width="60" align="center"></el-table-column>
<!-- 表格列标签为编号宽度为120px内容居中对齐通过插槽作用域显示对应行的id数据 -->
<el-table-column label="编号" width="120" align="center">
<template slot-scope="scope">{{scope.row.id}}</template>
</el-table-column>
<!-- 表格列标签为商品名称内容居中对齐通过插槽作用域显示对应行的productName数据 -->
<el-table-column label="商品名称" align="center">
<template slot-scope="scope">{{scope.row.productName}}</template>
</el-table-column>
<!-- 表格列标签为是否推荐宽度为200px内容居中对齐包含一个开关组件开关状态改变时触发handleRecommendStatusStatusChange方法设置了开关的激活值未激活值以及双向绑定对应行的recommendStatus数据 -->
<el-table-column label="是否推荐" width="200" align="center">
<template slot-scope="scope">
<el-switch
@ -63,12 +85,15 @@
</el-switch>
</template>
</el-table-column>
<!-- 表格列标签为排序宽度为160px内容居中对齐通过插槽作用域显示对应行的sort数据 -->
<el-table-column label="排序" width="160" align="center">
<template slot-scope="scope">{{scope.row.sort}}</template>
</el-table-column>
<!-- 表格列标签为状态宽度为160px内容居中对齐通过管道formatRecommendStatus对对应行的recommendStatus数据进行格式化后显示 -->
<el-table-column label="状态" width="160" align="center">
<template slot-scope="scope">{{scope.row.recommendStatus | formatRecommendStatus}}</template>
</el-table-column>
<!-- 表格列标签为操作宽度为180px内容居中对齐包含两个按钮分别点击时触发handleEditSort和handleDelete方法 -->
<el-table-column label="操作" width="180" align="center">
<template slot-scope="scope">
<el-button size="mini"
@ -83,10 +108,13 @@
</el-table-column>
</el-table>
</div>
<!-- 批量操作的容器 -->
<div class="batch-operate-container">
<!-- 下拉选择框设置了大小为小双向绑定operateType数据设置了占位提示文字 -->
<el-select
size="small"
v-model="operateType" placeholder="批量操作">
<!-- 循环生成下拉选项根据operates数据中的每个item来生成对应的选项 -->
<el-option
v-for="item in operates"
:key="item.value"
@ -94,6 +122,7 @@
:value="item.value">
</el-option>
</el-select>
<!-- 确定按钮设置了左外边距为20px样式类点击时触发handleBatchOperate方法类型为主要按钮大小为小 -->
<el-button
style="margin-left: 20px"
class="search-button"
@ -103,7 +132,9 @@
确定
</el-button>
</div>
<!-- 分页容器 -->
<div class="pagination-container">
<!-- el-pagination分页组件设置了背景色页面尺寸改变时触发handleSizeChange方法当前页改变时触发handleCurrentChange方法布局样式绑定了当前页每页显示数量可选的每页显示数量列表以及总记录数等属性 -->
<el-pagination
background
@size-change="handleSizeChange"
@ -115,27 +146,35 @@
:total="total">
</el-pagination>
</div>
<!-- 选择商品的对话框绑定了显示状态设置了标题和宽度 -->
<el-dialog title="选择商品" :visible.sync="selectDialogVisible" width="50%">
<!-- 输入框双向绑定dialogData.listQuery.keyword数据设置了宽度下外边距大小和占位提示文字包含一个搜索按钮点击时触发handleSelectSearch方法 -->
<el-input v-model="dialogData.listQuery.keyword"
style="width: 250px;margin-bottom: 20px"
size="small"
placeholder="商品名称搜索">
<el-button slot="append" icon="el-icon-search" @click="handleSelectSearch()"></el-button>
</el-input>
<!-- 表格绑定了dialogData.list数据作为数据源选择变化时触发handleDialogSelectionChange方法显示边框 -->
<el-table :data="dialogData.list"
@selection-change="handleDialogSelectionChange" border>
<!-- 表格列类型为选择列宽度为60px内容居中对齐 -->
<el-table-column type="selection" width="60" align="center"></el-table-column>
<!-- 表格列标签为商品名称内容居中对齐通过插槽作用域显示对应行的name数据 -->
<el-table-column label="商品名称" align="center">
<template slot-scope="scope">{{scope.row.name}}</template>
</el-table-column>
<!-- 表格列标签为货号宽度为160px内容居中对齐通过插槽作用域显示对应行的productSn数据格式化为NO. + 货号 -->
<el-table-column label="货号" width="160" align="center">
<template slot-scope="scope">NO.{{scope.row.productSn}}</template>
</el-table-column>
<!-- 表格列标签为价格宽度为120px内容居中对齐通过插槽作用域显示对应行的price数据格式化为 + 价格 -->
<el-table-column label="价格" width="120" align="center">
<template slot-scope="scope">{{scope.row.price}}</template>
</el-table-column>
</el-table>
<div class="pagination-container">
<!-- el-pagination分页组件设置了背景色页面尺寸改变时触发handleDialogSizeChange方法当前页改变时触发handleDialogCurrentChange方法布局样式绑定了当前页每页显示数量可选的每页显示数量列表以及总记录数等属性 -->
<el-pagination
background
@size-change="handleDialogSizeChange"
@ -149,282 +188,331 @@
</div>
<div style="clear: both;"></div>
<div slot="footer">
<!-- 取消按钮设置了大小为小点击时隐藏对话框 -->
<el-button size="small" @click="selectDialogVisible = false"> </el-button>
<!-- 确定按钮设置了大小为小类型为主要按钮点击时触发handleSelectDialogConfirm方法 -->
<el-button size="small" type="primary" @click="handleSelectDialogConfirm()"> </el-button>
</div>
</el-dialog>
<!-- 设置排序的对话框绑定了显示状态设置了标题和宽度 -->
<el-dialog title="设置排序"
:visible.sync="sortDialogVisible"
width="40%">
<!-- 表单绑定了sortDialogData数据模型设置了标签宽度 -->
<el-form :model="sortDialogData"
label-width="150px">
<!-- 表单项目标签为排序 -->
<el-form-item label="排序:">
<!-- 输入框双向绑定sortDialogData.sort数据设置了宽度 -->
<el-input v-model="sortDialogData.sort" style="width: 200px"></el-input>
</el-form-item>
</el-form>
<span slot="footer">
<!-- 取消按钮点击时隐藏对话框设置了大小为小 -->
<el-button @click="sortDialogVisible = false" size="small"> </el-button>
<!-- 确定按钮点击时触发handleUpdateSort方法设置了大小为小类型为主要按钮 -->
<el-button type="primary" @click="handleUpdateSort" size="small"> </el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import {fetchList,updateRecommendStatus,deleteHotProduct,createHotProduct,updateHotProductSort} from '@/api/hotProduct';
import {fetchList as fetchProductList} from '@/api/product';
// '@/api/hotProduct'
import {fetchList, updateRecommendStatus, deleteHotProduct, createHotProduct, updateHotProductSort} from '@/api/hotProduct';
// '@/api/product'fetchListfetchProductList
import {fetchList as fetchProductList} from '@/api/product';
const defaultListQuery = {
pageNum: 1,
pageSize: 5,
productName: null,
recommendStatus: null
};
const defaultRecommendOptions = [
{
label: '未推荐',
value: 0
},
{
label: '推荐中',
value: 1
}
];
export default {
name: 'hotProductList',
data() {
return {
listQuery: Object.assign({}, defaultListQuery),
recommendOptions: Object.assign({}, defaultRecommendOptions),
//
const defaultListQuery = {
pageNum: 1,
pageSize: 5,
productName: null,
recommendStatus: null
};
//
const defaultRecommendOptions = [
{
label: '未推荐',
value: 0
},
{
label: '推荐中',
value: 1
}
];
// Vue
export default {
//
name: 'hotProductList',
data() {
return {
// defaultListQuery
listQuery: Object.assign({}, defaultListQuery),
// defaultRecommendOptions
recommendOptions: Object.assign({}, defaultRecommendOptions),
// null
list: null,
// null
total: null,
// truefalse
listLoading: false,
//
multipleSelection: [],
//
operates: [
{
label: "设为推荐",
value: 0
},
{
label: "取消推荐",
value: 1
},
{
label: "删除",
value: 2
}
],
// null
operateType: null,
// falsetrue
selectDialogVisible: false,
//
dialogData: {
list: null,
total: null,
listLoading: false,
multipleSelection: [],
operates: [
{
label: "设为推荐",
value: 0
},
{
label: "取消推荐",
value: 1
},
{
label: "删除",
value: 2
}
],
operateType: null,
selectDialogVisible:false,
dialogData:{
list: null,
total: null,
multipleSelection:[],
listQuery:{
keyword: null,
pageNum: 1,
pageSize: 5
}
},
sortDialogVisible:false,
sortDialogData:{sort:0,id:null}
listQuery: {
keyword: null,
pageNum: 1,
pageSize: 5
}
},
//
sortDialogVisible: false,
// id
sortDialogData: {sort: 0, id: null}
}
},
//
created() {
this.getList();
},
// 1
filters: {
formatRecommendStatus(status) {
if (status === 1) {
return '推荐中';
} else {
return '未推荐';
}
}
},
methods: {
//
handleResetSearch() {
this.listQuery = Object.assign({}, defaultListQuery);
},
created() {
// 1
handleSearchList() {
this.listQuery.pageNum = 1;
this.getList();
},
filters:{
formatRecommendStatus(status){
if(status===1){
return '推荐中';
}else{
return '未推荐';
}
//
handleSelectionChange(val) {
this.multipleSelection = val;
},
// 1
handleSizeChange(val) {
this.listQuery.pageNum = 1;
this.listQuery.pageSize = val;
this.getList();
},
//
handleCurrentChange(val) {
this.listQuery.pageNum = val;
this.getList();
},
// id
handleRecommendStatusStatusChange(index, row) {
this.updateRecommendStatusStatus(row.id, row.recommendStatus);
},
// id
handleDelete(index, row) {
this.deleteProduct(row.id);
},
//
handleBatchOperate() {
if (this.multipleSelection < 1) {
this.$message({
message: '请选择一条记录',
type: 'warning',
duration: 1000
});
return;
}
let ids = []; //
for (let i = 0; i < this.multipleSelection.length; i++) {
ids.push(this.multipleSelection[i].id);
}
if (this.operateType === 0) {
//
this.updateRecommendStatusStatus(ids, 1);
} else if (this.operateType === 1) {
//
this.updateRecommendStatusStatus(ids, 0);
} else if (this.operateType === 2) {
//
this.deleteProduct(ids);
} else {
this.$message({ //
message: '请选择批量操作类型',
type: 'warning',
duration: 1000
});
}
},
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();
},
handleRecommendStatusStatusChange(index,row){
this.updateRecommendStatusStatus(row.id,row.recommendStatus);
},
handleDelete(index,row){
this.deleteProduct(row.id);
},
handleBatchOperate(){
if (this.multipleSelection < 1) {
//
handleSelectProduct() {
this.selectDialogVisible = true;
this.getDialogList();
},
//
handleSelectSearch() {
this.getDialogList();
},
// 1
handleDialogSizeChange(val) {
this.dialogData.listQuery.pageNum = 1;
this.dialogData.listQuery.pageSize = val;
this.getDialogList();
},
//
handleDialogCurrentChange(val) {
this.dialogData.listQuery.pageNum = val;
this.getDialogList();
},
//
handleDialogSelectionChange(val) {
this.dialogData.multipleSelection = val;
},
//
handleSelectDialogConfirm() {
if (this.dialogData.multipleSelection < 1) {
this.$message({
message: '请选择一条记录',
type: 'warning',
duration: 1000
});
return;
}
let selectProducts = [];
for (let i = 0; i < this.dialogData.multipleSelection.length; i++) {
selectProducts.push({
productId: this.dialogData.multipleSelection[i].id,
productName: this.dialogData.multipleSelection[i].name
});
}
this.$confirm('使用要进行添加操作?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => { //
createHotProduct(selectProducts).then(response => {
this.selectDialogVisible = false;
this.dialogData.multipleSelection = [];
this.getList();
this.$message({
message: '请选择一条记录',
type: 'warning',
duration: 1000
type: 'success',
message: '添加成功!'
});
return;
}
let ids = [];
for (let i = 0; i < this.multipleSelection.length; i++) {
ids.push(this.multipleSelection[i].id);
}
if (this.operateType === 0) {
//
this.updateRecommendStatusStatus(ids,1);
} else if (this.operateType === 1) {
//
this.updateRecommendStatusStatus(ids,0);
} else if(this.operateType===2){
//
this.deleteProduct(ids);
}else {
});
});
},
//
handleEditSort(index, row) {
this.sortDialogVisible = true;
this.sortDialogData.sort = row.sort; //id
this.sortDialogData.id = row.id;
},
//
handleUpdateSort() { //
this.$confirm('是否要修改排序?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => { //
updateHotProductSort(this.sortDialogData).then(response => {
this.sortDialogVisible = false;
this.getList();
this.$message({
message: '请选择批量操作类型',
type: 'warning',
duration: 1000
type: 'success',
message: '删除成功!'
});
}
},
handleSelectProduct(){
this.selectDialogVisible=true;
this.getDialogList();
},
handleSelectSearch(){
this.getDialogList();
},
handleDialogSizeChange(val) {
this.dialogData.listQuery.pageNum = 1;
this.dialogData.listQuery.pageSize = val;
this.getDialogList();
},
handleDialogCurrentChange(val) {
this.dialogData.listQuery.pageNum = val;
this.getDialogList();
},
handleDialogSelectionChange(val){
this.dialogData.multipleSelection = val;
},
handleSelectDialogConfirm(){
if (this.dialogData.multipleSelection < 1) {
});
})
},
//
getList() {
this.listLoading = true;
fetchList(this.listQuery).then(response => { //fetchList
this.listLoading = false;
this.list = response.data.list; //
this.total = response.data.total;
})
},
//
updateRecommendStatusStatus(ids, status) {
this.$confirm('是否要修改推荐状态?', '提示', { //
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let params = new URLSearchParams(); //idURLSearchParams
params.append("ids", ids);
params.append("recommendStatus", status);
updateRecommendStatus(params).then(response => { //updateRecommendStatus
this.getList();
this.$message({
message: '请选择一条记录',
type: 'warning',
duration: 1000
});
return;
}
let selectProducts = [];
for (let i = 0; i < this.dialogData.multipleSelection.length; i++) {
selectProducts.push({
productId:this.dialogData.multipleSelection[i].id,
productName:this.dialogData.multipleSelection[i].name
});
}
this.$confirm('使用要进行添加操作?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
createHotProduct(selectProducts).then(response=>{
this.selectDialogVisible=false;
this.dialogData.multipleSelection=[];
this.getList();
this.$message({
type: 'success',
message: '添加成功!'
});
type: 'success',
message: '修改成功!' //
});
});
},
handleEditSort(index,row){
this.sortDialogVisible=true;
this.sortDialogData.sort=row.sort;
this.sortDialogData.id=row.id;
},
handleUpdateSort(){
this.$confirm('是否要修改排序?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
updateHotProductSort(this.sortDialogData).then(response=>{
this.sortDialogVisible=false;
this.getList();
this.$message({
type: 'success',
message: '删除成功!'
});
});
})
},
getList() {
this.listLoading = true;
fetchList(this.listQuery).then(response => {
this.listLoading = false;
this.list = response.data.list;
this.total = response.data.total;
})
},
updateRecommendStatusStatus(ids,status){
this.$confirm('是否要修改推荐状态?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let params=new URLSearchParams();
params.append("ids",ids);
params.append("recommendStatus",status);
updateRecommendStatus(params).then(response=>{
this.getList();
this.$message({
type: 'success',
message: '修改成功!'
});
});
}).catch(() => {
}).catch(() => {
this.$message({
type: 'success',
message: '已取消操作!' //
});
this.getList();
});
},
//
deleteProduct(ids) {
this.$confirm('是否要删除该推荐?', '提示', { //
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let params = new URLSearchParams(); //idURLSearchParams
params.append("ids", ids);
deleteHotProduct(params).then(response => { //deleteHotProduct
this.getList();
this.$message({
type: 'success',
message: '已取消操作!'
message: '删除成功!' //
});
this.getList();
});
},
deleteProduct(ids){
this.$confirm('是否要删除该推荐?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let params=new URLSearchParams();
params.append("ids",ids);
deleteHotProduct(params).then(response=>{
this.getList();
this.$message({
type: 'success',
message: '删除成功!'
});
});
})
},
getDialogList(){
fetchProductList(this.dialogData.listQuery).then(response=>{
this.dialogData.list=response.data.list;
this.dialogData.total=response.data.total;
})
}
})
},
//
getDialogList() {
fetchProductList(this.dialogData.listQuery).then(response => { //fetchProductList
this.dialogData.list = response.data.list; //
this.dialogData.total = response.data.total;
})
}
}
}
</script>
<style></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>
<!-- 查询搜索按钮点击触发handleSearchList方法按钮样式为小型主色调 -->
<el-button
style="float:right"
type="primary"
@ -11,6 +16,7 @@
size="small">
查询搜索
</el-button>
<!-- 重置按钮点击触发handleResetSearch方法按钮样式为小型与查询搜索按钮有一定间隔 -->
<el-button
style="float:right;margin-right: 15px"
@click="handleResetSearch()"
@ -19,12 +25,18 @@
</el-button>
</div>
<div style="margin-top: 15px">
<!-- 内联表单绑定数据模型为listQuery表单尺寸为小标签宽度为140px -->
<el-form :inline="true" :model="listQuery" size="small" label-width="140px">
<!-- 商品名称表单项 -->
<el-form-item label="商品名称:">
<!-- 输入框双向绑定listQuery.productName设置了占位提示文字 -->
<el-input v-model="listQuery.productName" class="input-width" placeholder="商品名称"></el-input>
</el-form-item>
<!-- 推荐状态表单项 -->
<el-form-item label="推荐状态:">
<!-- 下拉选择框双向绑定listQuery.recommendStatus有清除功能设置了占位提示文字 -->
<el-select v-model="listQuery.recommendStatus" placeholder="全部" clearable class="input-width">
<!-- 循环生成下拉选项每个选项的keylabelvalue根据recommendOptions中的数据来设置 -->
<el-option v-for="item in recommendOptions"
:key="item.value"
:label="item.label"
@ -35,26 +47,37 @@
</el-form>
</div>
</el-card>
<!-- 操作区域的卡片 -->
<el-card class="operate-container" shadow="never">
<!-- 图标 -->
<i class="el-icon-tickets"></i>
<!-- 显示数据列表文字 -->
<span>数据列表</span>
<!-- 选择商品按钮点击触发handleSelectProduct方法按钮尺寸为迷你型 -->
<el-button size="mini" class="btn-add" @click="handleSelectProduct()"></el-button>
</el-card>
<!-- 表格容器 -->
<div class="table-container">
<!-- el-table组件绑定数据为list设置宽度为100%监听选择变化事件根据listLoading状态显示加载动画有边框 -->
<el-table ref="newProductTable"
:data="list"
style="width: 100%;"
@selection-change="handleSelectionChange"
v-loading="listLoading" border>
<!-- 选择列宽度为60px内容居中 -->
<el-table-column type="selection" width="60" align="center"></el-table-column>
<!-- 编号列宽度为120px内容居中通过插槽作用域展示对应行的id数据 -->
<el-table-column label="编号" width="120" align="center">
<template slot-scope="scope">{{scope.row.id}}</template>
</el-table-column>
<!-- 商品名称列内容居中通过插槽作用域展示对应行的productName数据 -->
<el-table-column label="商品名称" align="center">
<template slot-scope="scope">{{scope.row.productName}}</template>
</el-table-column>
<!-- 是否推荐列宽度为200px内容居中包含一个开关组件 -->
<el-table-column label="是否推荐" width="200" align="center">
<template slot-scope="scope">
<!-- 开关组件监听状态改变事件设置了激活和未激活的值双向绑定对应行的recommendStatus数据 -->
<el-switch
@change="handleRecommendStatusStatusChange(scope.$index, scope.row)"
:active-value="1"
@ -63,18 +86,23 @@
</el-switch>
</template>
</el-table-column>
<!-- 排序列宽度为160px内容居中通过插槽作用域展示对应行的sort数据 -->
<el-table-column label="排序" width="160" align="center">
<template slot-scope="scope">{{scope.row.sort}}</template>
</el-table-column>
<!-- 状态列宽度为160px内容居中通过管道formatRecommendStatus格式化对应行的recommendStatus数据来展示 -->
<el-table-column label="状态" width="160" align="center">
<template slot-scope="scope">{{scope.row.recommendStatus | formatRecommendStatus}}</template>
</el-table-column>
<!-- 操作列宽度为180px内容居中包含设置排序和删除两个按钮 -->
<el-table-column label="操作" width="180" align="center">
<template slot-scope="scope">
<!-- 设置排序按钮点击触发handleEditSort方法按钮尺寸为迷你型文本样式 -->
<el-button size="mini"
type="text"
@click="handleEditSort(scope.$index, scope.row)">设置排序
</el-button>
<!-- 删除按钮点击触发handleDelete方法按钮尺寸为迷你型文本样式 -->
<el-button size="mini"
type="text"
@click="handleDelete(scope.$index, scope.row)">删除
@ -83,10 +111,13 @@
</el-table-column>
</el-table>
</div>
<!-- 批量操作容器 -->
<div class="batch-operate-container">
<!-- 下拉选择框用于选择批量操作类型双向绑定operateType设置了占位提示文字 -->
<el-select
size="small"
v-model="operateType" placeholder="批量操作">
<!-- 循环生成下拉选项每个选项的keylabelvalue根据operates中的数据来设置 -->
<el-option
v-for="item in operates"
:key="item.value"
@ -94,6 +125,7 @@
:value="item.value">
</el-option>
</el-select>
<!-- 确定按钮点击触发handleBatchOperate方法按钮样式为小型主色调与下拉选择框有一定间隔 -->
<el-button
style="margin-left: 20px"
class="search-button"
@ -103,7 +135,9 @@
确定
</el-button>
</div>
<!-- 分页容器 -->
<div class="pagination-container">
<!-- el-pagination分页组件设置了背景色监听页面尺寸改变和当前页改变事件配置了布局页面尺寸可选页面尺寸列表当前页总数据量等属性 -->
<el-pagination
background
@size-change="handleSizeChange"
@ -115,27 +149,36 @@
:total="total">
</el-pagination>
</div>
<!-- 选择商品的对话框 -->
<el-dialog title="选择商品" :visible.sync="selectDialogVisible" width="50%">
<!-- 输入框双向绑定dialogData.listQuery.keyword设置了宽度样式占位提示文字包含一个搜索按钮 -->
<el-input v-model="dialogData.listQuery.keyword"
style="width: 250px;margin-bottom: 20px"
size="small"
placeholder="商品名称搜索">
<el-button slot="append" icon="el-icon-search" @click="handleSelectSearch()"></el-button>
</el-input>
<!-- el-table组件用于对话框内展示数据绑定数据为dialogData.list监听选择变化事件有边框 -->
<el-table :data="dialogData.list"
@selection-change="handleDialogSelectionChange" border>
<!-- 选择列宽度为60px内容居中 -->
<el-table-column type="selection" width="60" align="center"></el-table-column>
<!-- 商品名称列内容居中通过插槽作用域展示对应行的name数据 -->
<el-table-column label="商品名称" align="center">
<template slot-scope="scope">{{scope.row.name}}</template>
</el-table-column>
<!-- 货号列宽度为160px内容居中通过插槽作用域展示对应行的productSn数据格式化展示格式 -->
<el-table-column label="货号" width="160" align="center">
<template slot-scope="scope">NO.{{scope.row.productSn}}</template>
</el-table-column>
<!-- 价格列宽度为120px内容居中通过插槽作用域展示对应行的price数据格式化展示格式 -->
<el-table-column label="价格" width="120" align="center">
<template slot-scope="scope">{{scope.row.price}}</template>
</el-table-column>
</el-table>
<!-- 对话框内的分页容器 -->
<div class="pagination-container">
<!-- el-pagination分页组件设置了背景色监听对话框内页面尺寸改变和当前页改变事件配置了布局页面尺寸可选页面尺寸列表当前页总数据量等属性 -->
<el-pagination
background
@size-change="handleDialogSizeChange"
@ -149,282 +192,334 @@
</div>
<div style="clear: both;"></div>
<div slot="footer">
<!-- 取消按钮点击隐藏对话框按钮尺寸为小型 -->
<el-button size="small" @click="selectDialogVisible = false"> </el-button>
<!-- 确定按钮点击触发handleSelectDialogConfirm方法按钮尺寸为小型主色调 -->
<el-button size="small" type="primary" @click="handleSelectDialogConfirm()"> </el-button>
</div>
</el-dialog>
<!-- 设置排序的对话框 -->
<el-dialog title="设置排序"
:visible.sync="sortDialogVisible"
width="40%">
<!-- el-form表单组件绑定数据模型为sortDialogData设置标签宽度 -->
<el-form :model="sortDialogData"
label-width="150px">
<!-- 排序表单项 -->
<el-form-item label="排序:">
<!-- 输入框双向绑定sortDialogData.sort设置了宽度 -->
<el-input v-model="sortDialogData.sort" style="width: 200px"></el-input>
</el-form-item>
</el-form>
<span slot="footer">
<!-- 取消按钮点击隐藏对话框按钮尺寸为小型 -->
<el-button @click="sortDialogVisible = false" size="small"> </el-button>
<!-- 确定按钮点击触发handleUpdateSort方法按钮尺寸为小型主色调 -->
<el-button type="primary" @click="handleUpdateSort" size="small"> </el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import {fetchList,updateRecommendStatus,deleteNewProduct,createNewProduct,updateNewProductSort} from '@/api/newProduct';
import {fetchList as fetchProductList} from '@/api/product';
// '@/api/newProduct'
import {fetchList,updateRecommendStatus,deleteNewProduct,createNewProduct,updateNewProductSort} from '@/api/newProduct';
// '@/api/product'fetchListfetchProductList
import {fetchList as fetchProductList} from '@/api/product';
const defaultListQuery = {
pageNum: 1,
pageSize: 5,
productName: null,
recommendStatus: null
};
const defaultRecommendOptions = [
{
label: '未推荐',
value: 0
},
{
label: '推荐中',
value: 1
}
];
export default {
name: 'newProductList',
data() {
return {
listQuery: Object.assign({}, defaultListQuery),
recommendOptions: Object.assign({}, defaultRecommendOptions),
//
const defaultListQuery = {
pageNum: 1,
pageSize: 5,
productName: null,
recommendStatus: null
};
// ''0
const defaultRecommendOptions = [
{
label: '未推荐',
value: 0
},
{
label: '推荐中',
value: 1
}
];
export default {
name: 'newProductList',
data() {
return {
// defaultListQuery
listQuery: Object.assign({}, defaultListQuery),
// defaultRecommendOptions
recommendOptions: Object.assign({}, defaultRecommendOptions),
// null
list: null,
// null
total: null,
// false
listLoading: false,
//
multipleSelection: [],
// ''0
operates: [
{
label: "设为推荐",
value: 0
},
{
label: "取消推荐",
value: 1
},
{
label: "删除",
value: 2
}
],
// null
operateType: null,
// false
selectDialogVisible:false,
dialogData:{
// null
list: null,
// null
total: null,
listLoading: false,
multipleSelection: [],
operates: [
{
label: "设为推荐",
value: 0
},
{
label: "取消推荐",
value: 1
},
{
label: "删除",
value: 2
}
],
operateType: null,
selectDialogVisible:false,
dialogData:{
list: null,
total: null,
multipleSelection:[],
listQuery:{
keyword: null,
pageNum: 1,
pageSize: 5
}
},
sortDialogVisible:false,
sortDialogData:{sort:0,id:null}
//
multipleSelection:[],
listQuery:{
// null
keyword: null,
// 1
pageNum: 1,
// 5
pageSize: 5
}
},
// false
sortDialogVisible:false,
// id
sortDialogData:{sort:0,id:null}
}
},
created() {
// getList
this.getList();
},
filters:{
// formatRecommendStatus
formatRecommendStatus(status){
if(status===1){ //10''''
return '推荐中';
}else{
return '未推荐';
}
}
},
methods: {
// defaultListQuery
handleResetSearch() {
this.listQuery = Object.assign({}, defaultListQuery);
},
created() {
// 1getList
handleSearchList() {
this.listQuery.pageNum = 1;
this.getList();
},
filters:{
formatRecommendStatus(status){
if(status===1){
return '推荐中';
}else{
return '未推荐';
}
// multipleSelection
handleSelectionChange(val){
this.multipleSelection = val;
},
// 1getList
handleSizeChange(val) {
this.listQuery.pageNum = 1;
this.listQuery.pageSize = val;
this.getList();
},
// getList
handleCurrentChange(val) {
this.listQuery.pageNum = val;
this.getList();
},
// updateRecommendStatusStatusid
handleRecommendStatusStatusChange(index,row){
this.updateRecommendStatusStatus(row.id,row.recommendStatus);
},
// deleteProductid
handleDelete(index,row){
this.deleteProduct(row.id);
},
//
handleBatchOperate(){
if (this.multipleSelection < 1) {
this.$message({
message: '请选择一条记录',
type: 'warning',
duration: 1000
});
return;
}
let ids = []; //
for (let i = 0; i < this.multipleSelection.length; i++) {
ids.push(this.multipleSelection[i].id);
}
if (this.operateType === 0) {
//
this.updateRecommendStatusStatus(ids,1);
} else if (this.operateType === 1) {
//
this.updateRecommendStatusStatus(ids,0);
} else if(this.operateType===2){
//
this.deleteProduct(ids);
}else {
this.$message({
message: '请选择批量操作类型',
type: 'warning',
duration: 1000
});
}
},
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();
},
handleRecommendStatusStatusChange(index,row){
this.updateRecommendStatusStatus(row.id,row.recommendStatus);
},
handleDelete(index,row){
this.deleteProduct(row.id);
},
handleBatchOperate(){
if (this.multipleSelection < 1) {
// getDialogList
handleSelectProduct(){
this.selectDialogVisible=true;
this.getDialogList();
},
// getDialogList
handleSelectSearch(){
this.getDialogList();
},
// 1getDialogList
handleDialogSizeChange(val) {
this.dialogData.listQuery.pageNum = 1;
this.dialogData.listQuery.pageSize = val;
this.getDialogList();
},
// getDialogList
handleDialogCurrentChange(val) {
this.dialogData.listQuery.pageNum = val;
this.getDialogList();
},
// dialogData.multipleSelection
handleDialogSelectionChange(val){
this.dialogData.multipleSelection = val;
},
//
handleSelectDialogConfirm(){
if (this.dialogData.multipleSelection < 1) {
this.$message({
message: '请选择一条记录',
type: 'warning',
duration: 1000
});
return;
}
let selectProducts = []; //
for (let i = 0; i < this.dialogData.multipleSelection.length; i++) {
selectProducts.push({
productId:this.dialogData.multipleSelection[i].id,
productName:this.dialogData.multipleSelection[i].name
});
}
this.$confirm('使用要进行添加操作?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
createNewProduct(selectProducts).then(response=>{ //createNewProduct
this.selectDialogVisible=false;
this.dialogData.multipleSelection=[];
this.getList(); //
this.$message({
message: '请选择一条记录',
type: 'warning',
duration: 1000
type: 'success',
message: '添加成功!'
});
return;
}
let ids = [];
for (let i = 0; i < this.multipleSelection.length; i++) {
ids.push(this.multipleSelection[i].id);
}
if (this.operateType === 0) {
//
this.updateRecommendStatusStatus(ids,1);
} else if (this.operateType === 1) {
//
this.updateRecommendStatusStatus(ids,0);
} else if(this.operateType===2){
//
this.deleteProduct(ids);
}else {
});
});
},
//
handleEditSort(index,row){
this.sortDialogVisible=true;
this.sortDialogData.sort=row.sort;
this.sortDialogData.id=row.id; //id便
},
//
handleUpdateSort(){
this.$confirm('是否要修改排序?', '提示', { //
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
updateNewProductSort(this.sortDialogData).then(response=>{ //updateNewProductSort
this.sortDialogVisible=false;
this.getList(); //
this.$message({
message: '请选择批量操作类型',
type: 'warning',
duration: 1000
type: 'success',
message: '删除成功!'
});
}
},
handleSelectProduct(){
this.selectDialogVisible=true;
this.getDialogList();
},
handleSelectSearch(){
this.getDialogList();
},
handleDialogSizeChange(val) {
this.dialogData.listQuery.pageNum = 1;
this.dialogData.listQuery.pageSize = val;
this.getDialogList();
},
handleDialogCurrentChange(val) {
this.dialogData.listQuery.pageNum = val;
this.getDialogList();
},
handleDialogSelectionChange(val){
this.dialogData.multipleSelection = val;
},
handleSelectDialogConfirm(){
if (this.dialogData.multipleSelection < 1) {
});
})
},
//
getList() {
this.listLoading = true; //true
fetchList(this.listQuery).then(response => { //fetchList
this.listLoading = false; //false
this.list = response.data.list; //
this.total = response.data.total;
})
},
//
updateRecommendStatusStatus(ids,status){
this.$confirm('是否要修改推荐状态?', '提示', { //
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let params=new URLSearchParams(); //ididURLSearchParams
params.append("ids",ids);
params.append("recommendStatus",status);
updateRecommendStatus(params).then(response=>{ //updateRecommendStatus
this.getList(); //
this.$message({
message: '请选择一条记录',
type: 'warning',
duration: 1000
});
return;
}
let selectProducts = [];
for (let i = 0; i < this.dialogData.multipleSelection.length; i++) {
selectProducts.push({
productId:this.dialogData.multipleSelection[i].id,
productName:this.dialogData.multipleSelection[i].name
});
}
this.$confirm('使用要进行添加操作?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
createNewProduct(selectProducts).then(response=>{
this.selectDialogVisible=false;
this.dialogData.multipleSelection=[];
this.getList();
this.$message({
type: 'success',
message: '添加成功!'
});
type: 'success',
message: '修改成功!'
});
});
},
handleEditSort(index,row){
this.sortDialogVisible=true;
this.sortDialogData.sort=row.sort;
this.sortDialogData.id=row.id;
},
handleUpdateSort(){
this.$confirm('是否要修改排序?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
updateNewProductSort(this.sortDialogData).then(response=>{
this.sortDialogVisible=false;
this.getList();
this.$message({
type: 'success',
message: '删除成功!'
});
});
})
},
getList() {
this.listLoading = true;
fetchList(this.listQuery).then(response => {
this.listLoading = false;
this.list = response.data.list;
this.total = response.data.total;
})
},
updateRecommendStatusStatus(ids,status){
this.$confirm('是否要修改推荐状态?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let params=new URLSearchParams();
params.append("ids",ids);
params.append("recommendStatus",status);
updateRecommendStatus(params).then(response=>{
this.getList();
this.$message({
type: 'success',
message: '修改成功!'
});
});
}).catch(() => {
}).catch(() => {
this.$message({ //
type: 'success',
message: '已取消操作!'
});
this.getList();
});
},
//
deleteProduct(ids){
this.$confirm('是否要删除该推荐?', '提示', { //
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let params=new URLSearchParams(); //ididURLSearchParams
params.append("ids",ids);
deleteNewProduct(params).then(response=>{ //deleteNewProduct
this.getList(); //
this.$message({
type: 'success',
message: '已取消操作!'
message: '删除成功!'
});
this.getList();
});
},
deleteProduct(ids){
this.$confirm('是否要删除该推荐?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let params=new URLSearchParams();
params.append("ids",ids);
deleteNewProduct(params).then(response=>{
this.getList();
this.$message({
type: 'success',
message: '删除成功!'
});
});
})
},
getDialogList(){
fetchProductList(this.dialogData.listQuery).then(response=>{
this.dialogData.list=response.data.list;
this.dialogData.total=response.data.total;
})
}
})
},
//
getDialogList(){
fetchProductList(this.dialogData.listQuery).then(response=>{ //fetchProductList
this.dialogData.list=response.data.list; //
this.dialogData.total=response.data.total;
})
}
}
}
</script>
<style></style>

@ -1,9 +1,14 @@
<template> 
<template>
<!-- 整个页面的容器用于包裹内部的各个组件 -->
<div class="app-container">
<!-- el-card组件作为筛选搜索区域的容器设置阴影效果为"never"即无阴影 -->
<el-card class="filter-container" shadow="never">
<div>
<!-- 使用el-icon-search图标用于表示搜索相关的视觉元素 -->
<i class="el-icon-search"></i>
<!-- 显示"筛选搜索"的文字提示 -->
<span>筛选搜索</span>
<!-- el-button按钮组件样式设置为右浮动按钮类型为"primary"主要按钮样式通常为主题色等突出显示点击时调用handleSearchList方法按钮大小为"small" -->
<el-button
style="float:right"
type="primary"
@ -11,6 +16,7 @@
size="small">
查询搜索
</el-button>
<!-- el-button按钮组件样式设置为右浮动且距离右边距15px点击时调用handleResetSearch方法按钮大小为"small"用于重置相关操作 -->
<el-button
style="float:right;margin-right: 15px"
@click="handleResetSearch()"
@ -19,12 +25,18 @@
</el-button>
</div>
<div style="margin-top: 15px">
<!-- el-form表单组件设置为行内表单形式绑定的数据模型是listQuery表单尺寸为"small"标签宽度为140px -->
<el-form :inline="true" :model="listQuery" size="small" label-width="140px">
<!-- el-form-item表单项目组件用于输入框的包裹此处对应的标签文本为"专题名称:" -->
<el-form-item label="专题名称:">
<!-- el-input输入框组件双向绑定数据到listQuery.subjectName设置输入框的类名为"input-width"有相应的占位提示文字 -->
<el-input v-model="listQuery.subjectName" class="input-width" placeholder="专题名称"></el-input>
</el-form-item>
<!-- el-form-item表单项目组件用于下拉选择框的包裹对应的标签文本为"推荐状态:" -->
<el-form-item label="推荐状态:">
<!-- el-select下拉选择框组件双向绑定数据到listQuery.recommendStatus有相应的占位提示文字可清空选择设置类名为"input-width" -->
<el-select v-model="listQuery.recommendStatus" placeholder="全部" clearable class="input-width">
<!-- 通过v-for循环遍历recommendOptions数组生成el-option下拉选项每个选项根据item中的属性设置相应的键显示标签和值 -->
<el-option v-for="item in recommendOptions"
:key="item.value"
:label="item.label"
@ -35,24 +47,34 @@
</el-form>
</div>
</el-card>
<!-- el-card组件作为操作相关区域的容器设置阴影效果为"never"即无阴影 -->
<el-card class="operate-container" shadow="never">
<!-- 使用el-icon-tickets图标用于表示相关操作的视觉元素 -->
<i class="el-icon-tickets"></i>
<!-- 显示"数据列表"的文字提示 -->
<span>数据列表</span>
<!-- el-button按钮组件按钮尺寸为"mini"点击时调用handleSelectSubject方法按钮样式类名为"btn-add"用于选择专题操作 -->
<el-button size="mini" class="btn-add" @click="handleSelectSubject()"></el-button>
</el-card>
<!-- 作为表格显示区域的容器 -->
<div class="table-container">
<!-- el-table表格组件引用了ref为"newSubjectTable"绑定的数据为list设置宽度为100%监听行选择变化事件绑定加载状态到listLoading变量显示表格边框 -->
<el-table ref="newSubjectTable"
:data="list"
style="width: 100%;"
@selection-change="handleSelectionChange"
v-loading="listLoading" border>
<!-- el-table-column表格列组件设置列类型为"selection"用于行选择的复选框列宽度为60px内容居中对齐 -->
<el-table-column type="selection" width="60" align="center"></el-table-column>
<!-- el-table-column表格列组件对应的标签为"编号"宽度为120px内容居中对齐通过插槽作用域展示对应行数据中的id属性 -->
<el-table-column label="编号" width="120" align="center">
<template slot-scope="scope">{{scope.row.id}}</template>
</el-table-column>
<!-- el-table-column表格列组件对应的标签为"专题名称"内容居中对齐通过插槽作用域展示对应行数据中的subjectName属性 -->
<el-table-column label="专题名称" align="center">
<template slot-scope="scope">{{scope.row.subjectName}}</template>
</el-table-column>
<!-- el-table-column表格列组件对应的标签为"是否推荐"宽度为200px内容居中对齐内部包含一个el-switch开关组件用于切换推荐状态绑定相应的事件和值 -->
<el-table-column label="是否推荐" width="200" align="center">
<template slot-scope="scope">
<el-switch
@ -63,12 +85,15 @@
</el-switch>
</template>
</el-table-column>
<!-- el-table-column表格列组件对应的标签为"排序"宽度为160px内容居中对齐通过插槽作用域展示对应行数据中的sort属性 -->
<el-table-column label="排序" width="160" align="center">
<template slot-scope="scope">{{scope.row.sort}}</template>
</el-table-column>
<!-- el-table-column表格列组件对应的标签为"状态"宽度为160px内容居中对齐通过过滤器formatRecommendStatus对推荐状态数据进行格式化展示 -->
<el-table-column label="状态" width="160" align="center">
<template slot-scope="scope">{{scope.row.recommendStatus | formatRecommendStatus}}</template>
</el-table-column>
<!-- el-table-column表格列组件对应的标签为"操作"宽度为180px内容居中对齐内部包含两个el-button按钮组件分别用于设置排序和删除操作绑定对应的点击事件 -->
<el-table-column label="操作" width="180" align="center">
<template slot-scope="scope">
<el-button size="mini"
@ -83,10 +108,13 @@
</el-table-column>
</el-table>
</div>
<!-- 作为批量操作区域的容器 -->
<div class="batch-operate-container">
<!-- el-select下拉选择框组件尺寸为"small"双向绑定数据到operateType有相应的占位提示文字 -->
<el-select
size="small"
v-model="operateType" placeholder="批量操作">
<!-- 通过v-for循环遍历operates数组生成el-option下拉选项每个选项根据item中的属性设置相应的键显示标签和值 -->
<el-option
v-for="item in operates"
:key="item.value"
@ -94,6 +122,7 @@
:value="item.value">
</el-option>
</el-select>
<!-- el-button按钮组件距离左边距20px样式类名为"search-button"点击时调用handleBatchOperate方法按钮类型为"primary"主要按钮样式按钮尺寸为"small"用于确定批量操作 -->
<el-button
style="margin-left: 20px"
class="search-button"
@ -103,7 +132,9 @@
确定
</el-button>
</div>
<!-- 作为分页区域的容器 -->
<div class="pagination-container">
<!-- el-pagination分页组件设置背景色监听页面尺寸变化和当前页变化事件设置分页布局样式绑定每页显示数量可选的每页显示数量数组当前页码以及总数据量等相关属性 -->
<el-pagination
background
@size-change="handleSizeChange"
@ -115,27 +146,35 @@
:total="total">
</el-pagination>
</div>
<!-- el-dialog对话框组件标题为"选择专题"对话框显示状态双向绑定到selectDialogVisible变量宽度设置为50% -->
<el-dialog title="选择专题" :visible.sync="selectDialogVisible" width="50%">
<!-- el-input输入框组件双向绑定数据到dialogData.listQuery.keyword设置宽度底边距以及尺寸等样式属性有相应的占位提示文字内部包含一个用于搜索操作的el-button按钮 -->
<el-input v-model="dialogData.listQuery.keyword"
style="width: 250px;margin-bottom: 20px"
size="small"
placeholder="专题名称搜索">
<el-button slot="append" icon="el-icon-search" @click="handleSelectSearch()"></el-button>
</el-input>
<!-- el-table表格组件绑定的数据为dialogData.list监听行选择变化事件显示表格边框 -->
<el-table :data="dialogData.list"
@selection-change="handleDialogSelectionChange" border>
<!-- el-table-column表格列组件设置列类型为"selection"用于行选择的复选框列宽度为60px内容居中对齐 -->
<el-table-column type="selection" width="60" align="center"></el-table-column>
<!-- el-table-column表格列组件对应的标签为"专题名称"内容居中对齐通过插槽作用域展示对应行数据中的title属性 -->
<el-table-column label="专题名称" align="center">
<template slot-scope="scope">{{scope.row.title}}</template>
</el-table-column>
<!-- el-table-column表格列组件对应的标签为"所属分类"宽度为160px内容居中对齐通过插槽作用域展示对应行数据中的categoryName属性 -->
<el-table-column label="所属分类" width="160" align="center">
<template slot-scope="scope">{{scope.row.categoryName}}</template>
</el-table-column>
<!-- el-table-column表格列组件对应的标签为"添加时间"宽度为160px内容居中对齐通过过滤器formatTime对时间数据进行格式化展示 -->
<el-table-column label="添加时间" width="160" align="center">
<template slot-scope="scope">{{scope.row.createTime | formatTime}}</template>
</el-table-column>
</el-table>
<div class="pagination-container">
<!-- el-pagination分页组件设置背景色监听对话框内页面尺寸变化和当前页变化事件设置分页布局样式绑定对话框内每页显示数量当前页码以及总数据量等相关属性 -->
<el-pagination
background
@size-change="handleDialogSizeChange"
@ -149,291 +188,340 @@
</div>
<div style="clear: both;"></div>
<div slot="footer">
<!-- el-button按钮组件按钮尺寸为"small"点击时关闭对话框设置selectDialogVisible为false -->
<el-button size="small" @click="selectDialogVisible = false"> </el-button>
<!-- el-button按钮组件按钮尺寸为"small"按钮类型为"primary"主要按钮样式点击时调用handleSelectDialogConfirm方法用于确定操作 -->
<el-button size="small" type="primary" @click="handleSelectDialogConfirm()"> </el-button>
</div>
</el-dialog>
<!-- el-dialog对话框组件标题为"设置排序"对话框显示状态双向绑定到sortDialogVisible变量宽度设置为40% -->
<el-dialog title="设置排序"
:visible.sync="sortDialogVisible"
width="40%">
<!-- el-form表单组件绑定的数据模型是sortDialogData标签宽度为150px -->
<el-form :model="sortDialogData"
label-width="150px">
<!-- el-form-item表单项目组件对应的标签为"排序:"内部包含一个el-input输入框组件用于输入排序相关的值设置输入框宽度 -->
<el-form-item label="排序:">
<el-input v-model="sortDialogData.sort" style="width: 200px"></el-input>
</el-form-item>
</el-form>
<span slot="footer">
<!-- el-button按钮组件点击时关闭对话框设置sortDialogVisible为false按钮尺寸为"small" -->
<el-button @click="sortDialogVisible = false" size="small"> </el-button>
<!-- el-button按钮组件按钮类型为"primary"主要按钮样式点击时调用handleUpdateSort方法按钮尺寸为"small"用于确定排序设置操作 -->
<el-button type="primary" @click="handleUpdateSort" size="small"> </el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import {fetchList,updateRecommendStatus,deleteHomeSubject,createHomeSubject,updateHomeSubjectSort} from '@/api/homeSubject';
import {fetchList as fetchSubjectList} from '@/api/subject';
import {formatDate} from '@/utils/date';
// '@/api/homeSubject'
import {fetchList,updateRecommendStatus,deleteHomeSubject,createHomeSubject,updateHomeSubjectSort} from '@/api/homeSubject';
// '@/api/subject'fetchListfetchSubjectList
import {fetchList as fetchSubjectList} from '@/api/subject';
// '@/utils/date'formatDate
import {formatDate} from '@/utils/date';
const defaultListQuery = {
pageNum: 1,
pageSize: 5,
subjectName: null,
recommendStatus: null
};
const defaultRecommendOptions = [
{
label: '未推荐',
value: 0
},
{
label: '推荐中',
value: 1
}
];
export default {
name: 'homeSubjectList',
data() {
return {
listQuery: Object.assign({}, defaultListQuery),
recommendOptions: Object.assign({}, defaultRecommendOptions),
//
const defaultListQuery = {
pageNum: 1,
pageSize: 5,
subjectName: null,
recommendStatus: null
};
//
const defaultRecommendOptions = [
{
label: '未推荐',
value: 0
},
{
label: '推荐中',
value: 1
}
];
export default {
name: 'homeSubjectList',
data() {
return {
// defaultListQuery便
listQuery: Object.assign({}, defaultListQuery),
// defaultRecommendOptions
recommendOptions: Object.assign({}, defaultRecommendOptions),
// null
list: null,
// null
total: null,
// truefalse
listLoading: false,
//
multipleSelection: [],
//
operates: [
{
label: "设为推荐",
value: 0
},
{
label: "取消推荐",
value: 1
},
{
label: "删除",
value: 2
}
],
// null
operateType: null,
// falsetrue
selectDialogVisible: false,
//
dialogData: {
list: null,
total: null,
listLoading: false,
multipleSelection: [],
operates: [
{
label: "设为推荐",
value: 0
},
{
label: "取消推荐",
value: 1
},
{
label: "删除",
value: 2
}
],
operateType: null,
selectDialogVisible:false,
dialogData:{
list: null,
total: null,
multipleSelection:[],
listQuery:{
keyword: null,
pageNum: 1,
pageSize: 5
}
},
sortDialogVisible:false,
sortDialogData:{sort:0,id:null}
listQuery: {
keyword: null,
pageNum: 1,
pageSize: 5
}
},
// falsetrue
sortDialogVisible: false,
// id
sortDialogData: { sort: 0, id: null }
}
},
created() {
// getList
this.getList();
},
filters: {
// 1""""
formatRecommendStatus(status) {
if (status === 1) {
return '推荐中';
} else {
return '未推荐';
}
},
created() {
// "N/A"
formatTime(time) {
if (time == null || time === '') {
return 'N/A';
}
let date = new Date(time);
return formatDate(date, 'yyyy-MM-dd hh:mm:ss')
},
},
methods: {
// defaultListQuery
handleResetSearch() {
this.listQuery = Object.assign({}, defaultListQuery);
},
// 1getList
handleSearchList() {
this.listQuery.pageNum = 1;
this.getList();
},
filters:{
formatRecommendStatus(status){
if(status===1){
return '推荐中';
}else{
return '未推荐';
}
},
formatTime(time){
if(time==null||time===''){
return 'N/A';
}
let date = new Date(time);
return formatDate(date, 'yyyy-MM-dd hh:mm:ss')
},
// multipleSelection使
handleSelectionChange(val) {
this.multipleSelection = val;
},
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();
},
handleRecommendStatusStatusChange(index,row){
this.updateRecommendStatusStatus(row.id,row.recommendStatus);
},
handleDelete(index,row){
this.deleteSubject(row.id);
},
handleBatchOperate(){
if (this.multipleSelection < 1) {
// 1getList
handleSizeChange(val) {
this.listQuery.pageNum = 1;
this.listQuery.pageSize = val;
this.getList();
},
// getList
handleCurrentChange(val) {
this.listQuery.pageNum = val;
this.getList();
},
// updateRecommendStatusStatusid
handleRecommendStatusStatusChange(index, row) {
this.updateRecommendStatusStatus(row.id, row.recommendStatus);
},
// deleteSubjectid
handleDelete(index, row) {
this.deleteSubject(row.id);
},
//
//
handleBatchOperate() {
if (this.multipleSelection < 1) { //
this.$message({
message: '请选择一条记录',
type: 'warning',
duration: 1000
});
return;
}
let ids = []; //
for (let i = 0; i < this.multipleSelection.length; i++) {
ids.push(this.multipleSelection[i].id);
}
if (this.operateType === 0) {
//
this.updateRecommendStatusStatus(ids, 1);
} else if (this.operateType === 1) {
//
this.updateRecommendStatusStatus(ids, 0);
} else if (this.operateType === 2) {
//
this.deleteSubject(ids);
} else {
this.$message({
message: '请选择批量操作类型',
type: 'warning',
duration: 1000
});
}
},
//
handleSelectSubject() {
this.selectDialogVisible = true;
this.dialogData.listQuery.keyword = null;
this.getDialogList();//getDialogList
},
//
handleSelectSearch() {
this.getDialogList(); //getDialogList
},
//
handleDialogSizeChange(val) {
this.dialogData.listQuery.pageNum = 1; //1
this.dialogData.listQuery.pageSize = val;
this.getDialogList(); //getDialogList
},
//
handleDialogCurrentChange(val) {
this.dialogData.listQuery.pageNum = val;
this.getDialogList(); //getDialogList
},
// 使
handleDialogSelectionChange(val) {
this.dialogData.multipleSelection = val;
},
//
handleSelectDialogConfirm() {
if (this.dialogData.multipleSelection < 1) {
this.$message({
message: '请选择一条记录',
type: 'warning',
duration: 1000
});
return;
}
let selectSubjects = [];
for (let i = 0; i < this.dialogData.multipleSelection.length; i++) {
selectSubjects.push({
subjectId: this.dialogData.multipleSelection[i].id,
subjectName: this.dialogData.multipleSelection[i].title
});
}
this.$confirm('使用要进行添加操作?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
createHomeSubject(selectSubjects).then(response => { //// createHomeSubject
this.selectDialogVisible = false;
this.dialogData.multipleSelection = [];
this.getList();
this.$message({
message: '请选择一条记录',
type: 'warning',
duration: 1000
type: 'success',
message: '添加成功!'
});
return;
}
let ids = [];
for (let i = 0; i < this.multipleSelection.length; i++) {
ids.push(this.multipleSelection[i].id);
}
if (this.operateType === 0) {
//
this.updateRecommendStatusStatus(ids,1);
} else if (this.operateType === 1) {
//
this.updateRecommendStatusStatus(ids,0);
} else if(this.operateType===2){
//
this.deleteSubject(ids);
}else {
});
});
},
//
handleEditSort(index, row) {
this.sortDialogVisible = true;
this.sortDialogData.sort = row.sort;
this.sortDialogData.id = row.id; //id
},
//
handleUpdateSort() {
this.$confirm('是否要修改排序?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
updateHomeSubjectSort(this.sortDialogData).then(response => { //updateHomeSubjectSort
this.sortDialogVisible = false;
this.getList();
this.$message({
message: '请选择批量操作类型',
type: 'warning',
duration: 1000
type: 'success',
message: '删除成功!' //updateHomeSubjectSort
});
}
},
handleSelectSubject(){
this.selectDialogVisible=true;
this.dialogData.listQuery.keyword=null;
this.getDialogList();
},
handleSelectSearch(){
this.getDialogList();
},
handleDialogSizeChange(val) {
this.dialogData.listQuery.pageNum = 1;
this.dialogData.listQuery.pageSize = val;
this.getDialogList();
},
handleDialogCurrentChange(val) {
this.dialogData.listQuery.pageNum = val;
this.getDialogList();
},
handleDialogSelectionChange(val){
this.dialogData.multipleSelection = val;
},
handleSelectDialogConfirm(){
if (this.dialogData.multipleSelection < 1) {
});
})
},
//
getList() {
this.listLoading = true; //true
fetchList(this.listQuery).then(response => { //fetchList
this.listLoading = false; //false
this.list = response.data.list; ////
this.total = response.data.total;
})
},
//
updateRecommendStatusStatus(ids, status) {
this.$confirm('是否要修改推荐状态?', '提示', { //
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let params = new URLSearchParams(); //URLSearchParamsid
params.append("ids", ids);
params.append("finalRecommendStatus", status);
updateRecommendStatus(params).then(response => { //// updateRecommendStatus
this.getList();
this.$message({
message: '请选择一条记录',
type: 'warning',
duration: 1000
});
return;
}
let selectSubjects = [];
for (let i = 0; i < this.dialogData.multipleSelection.length; i++) {
selectSubjects.push({
subjectId:this.dialogData.multipleSelection[i].id,
subjectName:this.dialogData.multipleSelection[i].title
});
}
this.$confirm('使用要进行添加操作?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
createHomeSubject(selectSubjects).then(response=>{
this.selectDialogVisible=false;
this.dialogData.multipleSelection=[];
this.getList();
this.$message({
type: 'success',
message: '添加成功!'
});
type: 'success',
message: '修改成功!' //
});
});
},
handleEditSort(index,row){
this.sortDialogVisible=true;
this.sortDialogData.sort=row.sort;
this.sortDialogData.id=row.id;
},
handleUpdateSort(){
this.$confirm('是否要修改排序?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
updateHomeSubjectSort(this.sortDialogData).then(response=>{
this.sortDialogVisible=false;
this.getList();
this.$message({
type: 'success',
message: '删除成功!'
});
});
})
},
getList() {
this.listLoading = true;
fetchList(this.listQuery).then(response => {
this.listLoading = false;
this.list = response.data.list;
this.total = response.data.total;
})
},
updateRecommendStatusStatus(ids,status){
this.$confirm('是否要修改推荐状态?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let params=new URLSearchParams();
params.append("ids",ids);
params.append("recommendStatus",status);
updateRecommendStatus(params).then(response=>{
this.getList();
this.$message({
type: 'success',
message: '修改成功!'
});
});
}).catch(() => {
}).catch(() => {
this.$message({
type: 'success',
message: '已取消操作!' //
});
this.getList();
});
},
//
deleteSubject(ids) {
this.$confirm('是否要删除该推荐?', '提示', { //
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let params = new URLSearchParams(); //URLSearchParamsid
params.append("ids", ids);
deleteHomeSubject(params).then(response => { //// deleteHomeSubject
this.getList();
this.$message({
type: 'success',
message: '已取消操作!'
message: '删除成功!' //
});
this.getList();
});
},
deleteSubject(ids){
this.$confirm('是否要删除该推荐?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let params=new URLSearchParams();
params.append("ids",ids);
deleteHomeSubject(params).then(response=>{
this.getList();
this.$message({
type: 'success',
message: '删除成功!'
});
});
})
},
getDialogList(){
fetchSubjectList(this.dialogData.listQuery).then(response=>{
this.dialogData.list=response.data.list;
this.dialogData.total=response.data.total;
})
}
})
},
//
getDialogList() {
fetchSubjectList(this.dialogData.listQuery).then(response => { //fetchSubjectList
this.dialogData.list = response.data.list; //
this.dialogData.total = response.data.total;
})
}
}
}
</script>
<style></style>

Loading…
Cancel
Save