Compare commits

..

No commits in common. 'main' and 'branch_cwy' have entirely different histories.

@ -1,7 +1,7 @@
# mall-admin-web # mall-admin-web
<p> <p>
<a href="#公众号"><img src="http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/badge/%E5%85%AC%E4%BC%97%E5%8F%B7-macrozheng-blue.svg" alt="公众号"></a>
<a href="#公众号"><img src="http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/badge/%E4%BA%A4%E6%B5%81-%E5%BE%AE%E4%BF%A1%E7%BE%A4-2BA245.svg" alt="交流"></a>
<a href="https://github.com/macrozheng/mall"><img src="http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/badge/%E5%90%8E%E5%8F%B0%E9%A1%B9%E7%9B%AE-mall-blue.svg" alt="后台项目"></a> <a href="https://github.com/macrozheng/mall"><img src="http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/badge/%E5%90%8E%E5%8F%B0%E9%A1%B9%E7%9B%AE-mall-blue.svg" alt="后台项目"></a>
<a href="https://github.com/macrozheng/mall-swarm"><img src="http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/badge/Cloud%E7%89%88%E6%9C%AC-mall--swarm-brightgreen.svg" alt="SpringCloud版本"></a> <a href="https://github.com/macrozheng/mall-swarm"><img src="http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/badge/Cloud%E7%89%88%E6%9C%AC-mall--swarm-brightgreen.svg" alt="SpringCloud版本"></a>
<a href="https://gitee.com/macrozheng/mall-admin-web"><img src="http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/badge/%E7%A0%81%E4%BA%91-%E9%A1%B9%E7%9B%AE%E5%9C%B0%E5%9D%80-orange.svg" alt="码云"></a> <a href="https://gitee.com/macrozheng/mall-admin-web"><img src="http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/badge/%E7%A0%81%E4%BA%91-%E9%A1%B9%E7%9B%AE%E5%9C%B0%E5%9D%80-orange.svg" alt="码云"></a>
@ -9,14 +9,15 @@
## 前言 ## 前言
该项目为前后端分离项目的前端部分 该项目为前后端分离项目的前端部分,后端项目`mall`地址:[传送门](https://github.com/macrozheng/mall) 。
## 项目介绍 ## 项目介绍
`mall-admin-web`是一个电商后台管理系统的前端项目基于Vue+Element实现。主要包括商品管理、订单管理、会员管理、促销管理、运营管理、内容管理、统计报表、财务管理、权限管理、设置等功能。 `mall-admin-web`是一个电商后台管理系统的前端项目基于Vue+Element实现。主要包括商品管理、订单管理、会员管理、促销管理、运营管理、内容管理、统计报表、财务管理、权限管理、设置等功能。
### 项目演示 ### 项目演示
项目演示地址:[https://www.macrozheng.com/admin/](https://www.macrozheng.com/admin/) 项目在线演示地址:[https://www.macrozheng.com/admin/](https://www.macrozheng.com/admin/)
![后台管理系统功能演示](http://img.macrozheng.com/mall/project/mall_admin_show.png) ![后台管理系统功能演示](http://img.macrozheng.com/mall/project/mall_admin_show.png)
@ -67,6 +68,14 @@ src -- 源码目录
- 具体部署过程请参考:[mall前端项目的安装与部署](https://www.macrozheng.com/mall/deploy/mall_deploy_web.html) - 具体部署过程请参考:[mall前端项目的安装与部署](https://www.macrozheng.com/mall/deploy/mall_deploy_web.html)
- 前端自动化部署请参考:[使用Jenkins一键打包部署前端应用就是这么6](https://www.macrozheng.com/mall/reference/jenkins_vue.html) - 前端自动化部署请参考:[使用Jenkins一键打包部署前端应用就是这么6](https://www.macrozheng.com/mall/reference/jenkins_vue.html)
## 公众号
学习不走弯路,关注公众号「**macrozheng**」,回复「**学习路线**」获取mall项目专属学习路线
加微信群交流,公众号后台回复「**加群**」即可。
![公众号图片](http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/banner/qrcode_for_macrozheng_258.jpg)
## 许可证 ## 许可证
[Apache License 2.0](https://github.com/macrozheng/mall-admin-web/blob/master/LICENSE) [Apache License 2.0](https://github.com/macrozheng/mall-admin-web/blob/master/LICENSE)

@ -2,6 +2,7 @@
require('./check-versions')() require('./check-versions')()
process.env.NODE_ENV = 'production' process.env.NODE_ENV = 'production'
const ora = require('ora') const ora = require('ora')
const rm = require('rimraf') const rm = require('rimraf')
const path = require('path') const path = require('path')
@ -9,8 +10,10 @@ const chalk = require('chalk')
const webpack = require('webpack') const webpack = require('webpack')
const config = require('../config') const config = require('../config')
const webpackConfig = require('./webpack.prod.conf') const webpackConfig = require('./webpack.prod.conf')
const spinner = ora('building for production...') const spinner = ora('building for production...')
spinner.start() spinner.start()
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => { rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
if (err) throw err if (err) throw err
webpack(webpackConfig, (err, stats) => { webpack(webpackConfig, (err, stats) => {

@ -8,6 +8,7 @@ exports.assetsPath = function (_path) {
const assetsSubDirectory = process.env.NODE_ENV === 'production' const assetsSubDirectory = process.env.NODE_ENV === 'production'
? config.build.assetsSubDirectory ? config.build.assetsSubDirectory
: config.dev.assetsSubDirectory : config.dev.assetsSubDirectory
return path.posix.join(assetsSubDirectory, _path) return path.posix.join(assetsSubDirectory, _path)
} }

@ -16,8 +16,6 @@ import java.util.stream.Collectors;
* i11111 * i11111
* dsdhsjhfjs * dsdhsjhfjs
* fdjkf * fdjkf
* 1111111
* hjhfsj
*/ */
public class AdminUserDetails implements UserDetails { public class AdminUserDetails implements UserDetails {
//后台用户 //后台用户

@ -9,7 +9,7 @@
<name>mall-security</name> <name>mall-security</name>
<description>mall-security project for mall</description> <description>mall-security project for mall</description>
//zzzzzzz
<parent> <parent>
<groupId>com.macro.mall</groupId> <groupId>com.macro.mall</groupId>
<artifactId>mall</artifactId> <artifactId>mall</artifactId>

@ -14,7 +14,7 @@ import org.springframework.stereotype.Component;
import java.lang.reflect.Method; import java.lang.reflect.Method;
/**123456 /**
* RedisRedis * RedisRedis
* Created by macro on 2020/3/17. * Created by macro on 2020/3/17.
*/ */

@ -1,70 +1,54 @@
// 引入自定义的请求工具模块
import request from '@/utils/request' import request from '@/utils/request'
// 获取品牌列表
export function fetchList(params) { export function fetchList(params) {
// 调用请求方法发送GET请求到 '/brand/list',并将参数作为请求的查询参数
return request({ return request({
url: '/brand/list', // 请求的API接口地址 url:'/brand/list',
method: 'get', // 请求方法GET method:'get',
params: params // 请求参数将被附加到URL的查询字符串中 params:params
}) })
} }
//dwj1111111
// 创建新品牌
export function createBrand(data) { export function createBrand(data) {
// 调用请求方法发送POST请求到 '/brand/create',请求体包含品牌数据
return request({ return request({
url: '/brand/create', // 请求的API接口地址 url:'/brand/create',
method: 'post', // 请求方法POST method:'post',
data: data // 请求体数据,包含品牌的详细信息 data:data
}) })
} }
// 更新品牌的展示状态
export function updateShowStatus(data) { export function updateShowStatus(data) {
// 调用请求方法发送POST请求到 '/brand/update/showStatus',请求体包含展示状态的更新数据
return request({ return request({
url: '/brand/update/showStatus', // 请求的API接口地址 url:'/brand/update/showStatus',
method: 'post', // 请求方法POST method:'post',
data: data // 请求体数据,包含要更新的展示状态信息 data:data
}) })
} }
// 更新品牌的工厂状态
export function updateFactoryStatus(data) { export function updateFactoryStatus(data) {
// 调用请求方法发送POST请求到 '/brand/update/factoryStatus',请求体包含工厂状态的更新数据
return request({ return request({
url: '/brand/update/factoryStatus', // 请求的API接口地址 url:'/brand/update/factoryStatus',
method: 'post', // 请求方法POST method:'post',
data: data // 请求体数据,包含要更新的工厂状态信息 data:data
}) })
} }
// 删除品牌
export function deleteBrand(id) { export function deleteBrand(id) {
// 调用请求方法发送GET请求到 '/brand/delete/{id}'{id}为品牌的唯一标识
return request({ return request({
url: '/brand/delete/' + id, // 请求的API接口地址{id}动态插入 url:'/brand/delete/'+id,
method: 'get', // 请求方法GET method:'get',
}) })
} }
// 获取单个品牌的详细信息
export function getBrand(id) { export function getBrand(id) {
// 调用请求方法发送GET请求到 '/brand/{id}'{id}为品牌唯一标识
return request({ return request({
url: '/brand/' + id, // 请求的API接口地址{id}动态插入 url:'/brand/'+id,
method: 'get', // 请求方法GET method:'get',
}) })
} }
// 更新品牌的详细信息 export function updateBrand(id,data) {
export function updateBrand(id, data) {
// 调用请求方法发送POST请求到 '/brand/update/{id}',请求体包含品牌的更新数据
return request({ return request({
url: '/brand/update/' + id, // 请求的API接口地址{id}动态插入 url:'/brand/update/'+id,
method: 'post', // 请求方法POST method:'post',
data: data // 请求体数据,包含要更新的品牌详细信息 data:data
}) })
} }

@ -1,27 +1,7 @@
// 导入封装好的请求工具用于发起HTTP请求
import request from '@/utils/request' import request from '@/utils/request'
/**
* fetchList - 获取公司地址列表数据的函数
*
* 该函数通过发送一个 GET 请求到指定的后端接口
* 以获取公司地址列表数据数据返回后可以用于前端页面渲染
*
* @returns {Promise} - 返回一个Promise对象包含接口返回的数据
*
* 用法示例
* fetchList().then(response => {
* console.log(response); // 处理接口返回的数据
* }).catch(error => {
* console.error(error); // 处理错误
* });
*/
export function fetchList() { export function fetchList() {
return request({ return request({
// 接口的URL路径指向公司地址列表的后端接口 url:'/companyAddress/list',
url: '/companyAddress/list', method:'get'
// 请求方法:使用 HTTP GET 方法获取数据
method: 'get'
}) })
} }

@ -1,106 +1,38 @@
// 导入封装的 HTTP 请求工具,用于与后端接口通信
import request from '@/utils/request' import request from '@/utils/request'
/**
* fetchList - 获取优惠券列表
*
* 该函数通过 GET 请求获取优惠券列表并支持通过参数进行查询筛选
*
* @param {Object} params - 查询参数例如分页筛选条件等
* @returns {Promise} - 返回一个Promise对象包含接口返回的数据
*
* 用法示例
* fetchList({ pageNum: 1, pageSize: 10 }).then(response => {
* console.log(response);
* });
*/
export function fetchList(params) { export function fetchList(params) {
return request({ return request({
url: '/coupon/list', // 接口URL路径获取优惠券列表 url:'/coupon/list',
method: 'get', // 请求方法GET method:'get',
params: params // 查询参数通过URL参数传递 params:params
}) })
} }
/**
* createCoupon - 创建新的优惠券
*
* 该函数通过 POST 请求向后端提交新优惠券的数据
*
* @param {Object} data - 优惠券的详细数据包含名称折扣等字段
* @returns {Promise} - 返回一个Promise对象包含接口返回的数据
*
* 用法示例
* createCoupon({ name: 'Spring Sale', discount: 20 }).then(response => {
* console.log(response);
* });
*/
export function createCoupon(data) { export function createCoupon(data) {
return request({ return request({
url: '/coupon/create', // 接口URL路径创建优惠券 url:'/coupon/create',
method: 'post', // 请求方法POST method:'post',
data: data // 请求体,包含优惠券数据 data:data
}) })
} }
/**
* getCoupon - 获取单个优惠券的详情
*
* 该函数通过 GET 请求获取指定ID的优惠券详细信息
*
* @param {number|string} id - 优惠券的唯一标识ID
* @returns {Promise} - 返回一个Promise对象包含优惠券的详细数据
*
* 用法示例
* getCoupon(1).then(response => {
* console.log(response);
* });
*/
export function getCoupon(id) { export function getCoupon(id) {
return request({ return request({
url: '/coupon/' + id, // 接口URL路径根据ID获取优惠券详情 url:'/coupon/'+id,
method: 'get' // 请求方法GET method:'get',
}) })
} }
/** export function updateCoupon(id,data) {
* updateCoupon - 更新指定优惠券的信息
*
* 该函数通过 POST 请求提交修改后的优惠券数据更新指定ID的优惠券
*
* @param {number|string} id - 优惠券的唯一标识ID
* @param {Object} data - 修改后的优惠券数据
* @returns {Promise} - 返回一个Promise对象包含操作结果
*
* 用法示例
* updateCoupon(1, { name: 'Updated Sale', discount: 25 }).then(response => {
* console.log(response);
* });
*/
export function updateCoupon(id, data) {
return request({ return request({
url: '/coupon/update/' + id, // 接口URL路径更新指定ID的优惠券 url:'/coupon/update/'+id,
method: 'post', // 请求方法POST method:'post',
data: data // 请求体,包含修改后的数据 data:data
}) })
} }
/**
* deleteCoupon - 删除指定优惠券
*
* 该函数通过 POST 请求删除指定ID的优惠券
*
* @param {number|string} id - 优惠券的唯一标识ID
* @returns {Promise} - 返回一个Promise对象包含操作结果
*
* 用法示例
* deleteCoupon(1).then(response => {
* console.log(response);
* });
*/
export function deleteCoupon(id) { export function deleteCoupon(id) {
return request({ return request({
url: '/coupon/delete/' + id, // 接口URL路径删除指定ID的优惠券 url:'/coupon/delete/'+id,
method: 'post' // 请求方法POST method:'post',
}) })
} }

@ -1,27 +1,8 @@
// 导入封装的 HTTP 请求工具,用于发送 HTTP 请求
import request from '@/utils/request' import request from '@/utils/request'
/**
* fetchList - 获取优惠券历史记录列表
*
* 该函数通过 GET 请求获取优惠券使用历史的记录列表
* 可以通过传入查询参数如分页筛选条件等来筛选数据
*
* @param {Object} params - 查询参数包括分页信息筛选条件等
* 示例参数{ pageNum: 1, pageSize: 10, couponId: 1001 }
* @returns {Promise} - 返回一个 Promise 对象包含接口返回的数据
*
* 用法示例
* fetchList({ pageNum: 1, pageSize: 10 }).then(response => {
* console.log(response); // 处理接口返回的数据
* }).catch(error => {
* console.error('获取数据失败:', error); // 处理请求错误
* });
*/
export function fetchList(params) { export function fetchList(params) {
return request({ return request({
url: '/couponHistory/list', // 接口URL路径获取优惠券历史记录列表 url:'/couponHistory/list',
method: 'get', // 请求方法GET method:'get',
params: params // 查询参数,通过 URL 参数传递 params:params
}) })
} }

@ -1,109 +1,35 @@
// 导入封装的 HTTP 请求工具,用于发送 HTTP 请求
import request from '@/utils/request' import request from '@/utils/request'
/**
* fetchList - 获取限时购活动列表
*
* 该函数通过 GET 请求获取限时购活动的列表数据并支持通过参数进行查询筛选
*
* @param {Object} params - 查询参数例如分页筛选条件等
* 示例{ pageNum: 1, pageSize: 10 }
* @returns {Promise} - 返回一个 Promise 对象包含接口返回的数据
*
* 用法示例
* fetchList({ pageNum: 1, pageSize: 10 }).then(response => {
* console.log(response);
* });
*/
export function fetchList(params) { export function fetchList(params) {
return request({ return request({
url: '/flash/list', // 接口URL获取限时购活动列表 url:'/flash/list',
method: 'get', // 请求方法GET method:'get',
params: params // 查询参数,通过 URL 查询字符串传递 params:params
}) })
} }
export function updateStatus(id,params) {
/**
* updateStatus - 更新限时购活动状态
*
* 该函数通过 POST 请求更新指定限时购活动的状态
*
* @param {number|string} id - 限时购活动的唯一标识ID
* @param {Object} params - 状态更新参数例如 { status: 1 }
* @returns {Promise} - 返回一个 Promise 对象包含操作结果
*
* 用法示例
* updateStatus(1, { status: 1 }).then(response => {
* console.log(response);
* });
*/
export function updateStatus(id, params) {
return request({ return request({
url: '/flash/update/status/' + id, // 接口URL更新指定活动状态 url:'/flash/update/status/'+id,
method: 'post', // 请求方法POST method:'post',
params: params // 状态参数,通过 URL 查询字符串传递 params:params
}) })
} }
/**
* deleteFlash - 删除指定的限时购活动
*
* 该函数通过 POST 请求删除指定ID的限时购活动
*
* @param {number|string} id - 限时购活动的唯一标识ID
* @returns {Promise} - 返回一个 Promise 对象包含操作结果
*
* 用法示例
* deleteFlash(1).then(response => {
* console.log(response);
* });
*/
export function deleteFlash(id) { export function deleteFlash(id) {
return request({ return request({
url: '/flash/delete/' + id, // 接口URL删除指定活动 url:'/flash/delete/'+id,
method: 'post' // 请求方法POST method:'post'
}) })
} }
/**
* createFlash - 创建新的限时购活动
*
* 该函数通过 POST 请求向后端提交新的限时购活动数据
*
* @param {Object} data - 活动的详细数据例如 { name: 'Flash Sale', startTime: '2024-06-01' }
* @returns {Promise} - 返回一个 Promise 对象包含创建结果
*
* 用法示例
* createFlash({ name: 'Summer Flash Sale', startTime: '2024-06-01' }).then(response => {
* console.log(response);
* });
*/
export function createFlash(data) { export function createFlash(data) {
return request({ return request({
url: '/flash/create', // 接口URL创建限时购活动 url:'/flash/create',
method: 'post', // 请求方法POST method:'post',
data: data // 请求体,包含活动的详细数据 data:data
}) })
} }
export function updateFlash(id,data) {
/**
* updateFlash - 更新指定的限时购活动
*
* 该函数通过 POST 请求提交更新后的活动数据更新指定ID的限时购活动
*
* @param {number|string} id - 限时购活动的唯一标识ID
* @param {Object} data - 更新后的活动数据
* @returns {Promise} - 返回一个 Promise 对象包含操作结果
*
* 用法示例
* updateFlash(1, { name: 'Updated Flash Sale', startTime: '2024-06-15' }).then(response => {
* console.log(response);
* });
*/
export function updateFlash(id, data) {
return request({ return request({
url: '/flash/update/' + id, // 接口URL更新指定ID的活动 url:'/flash/update/'+id,
method: 'post', // 请求方法POST method:'post',
data: data // 请求体,包含更新后的活动数据 data:data
}) })
} }

@ -1,88 +1,28 @@
// 导入封装的 HTTP 请求工具,用于与后端 API 进行通信
import request from '@/utils/request' import request from '@/utils/request'
/**
* fetchList - 获取限时购商品关联列表
*
* 该函数通过 GET 请求获取限时购活动与商品的关联列表
* 支持通过查询参数进行筛选和分页
*
* @param {Object} params - 查询参数例如分页和过滤条件
* 示例{ flashId: 1, pageNum: 1, pageSize: 10 }
* @returns {Promise} - 返回一个 Promise 对象包含接口返回的数据
*
* 用法示例
* fetchList({ flashId: 1, pageNum: 1, pageSize: 10 }).then(response => {
* console.log(response);
* });
*/
export function fetchList(params) { export function fetchList(params) {
return request({ return request({
url: '/flashProductRelation/list', // 接口URL获取关联列表 url:'/flashProductRelation/list',
method: 'get', // 请求方法GET method:'get',
params: params // 查询参数,通过 URL 传递 params:params
}) })
} }
/**
* createFlashProductRelation - 创建新的限时购商品关联
*
* 该函数通过 POST 请求提交限时购活动与商品的关联数据
*
* @param {Object} data - 关联数据例如 { flashId: 1, productId: 100, sort: 1 }
* @returns {Promise} - 返回一个 Promise 对象包含操作结果
*
* 用法示例
* createFlashProductRelation({ flashId: 1, productId: 100, sort: 1 }).then(response => {
* console.log(response);
* });
*/
export function createFlashProductRelation(data) { export function createFlashProductRelation(data) {
return request({ return request({
url: '/flashProductRelation/create', // 接口URL创建关联 url:'/flashProductRelation/create',
method: 'post', // 请求方法POST method:'post',
data: data // 请求体,包含关联数据 data:data
}) })
} }
/**
* deleteFlashProductRelation - 删除指定的限时购商品关联
*
* 该函数通过 POST 请求删除指定 ID 的限时购商品关联数据
*
* @param {number|string} id - 限时购商品关联的唯一标识 ID
* @returns {Promise} - 返回一个 Promise 对象包含操作结果
*
* 用法示例
* deleteFlashProductRelation(1).then(response => {
* console.log(response);
* });
*/
export function deleteFlashProductRelation(id) { export function deleteFlashProductRelation(id) {
return request({ return request({
url: '/flashProductRelation/delete/' + id, // 接口URL删除关联 url:'/flashProductRelation/delete/'+id,
method: 'post' // 请求方法POST method:'post'
}) })
} }
export function updateFlashProductRelation(id,data) {
/**
* updateFlashProductRelation - 更新指定的限时购商品关联数据
*
* 该函数通过 POST 请求提交更新后的限时购商品关联数据
*
* @param {number|string} id - 限时购商品关联的唯一标识 ID
* @param {Object} data - 更新后的关联数据例如 { sort: 2 }
* @returns {Promise} - 返回一个 Promise 对象包含操作结果
*
* 用法示例
* updateFlashProductRelation(1, { sort: 2 }).then(response => {
* console.log(response);
* });
*/
export function updateFlashProductRelation(id, data) {
return request({ return request({
url: '/flashProductRelation/update/' + id, // 接口URL更新关联 url:'/flashProductRelation/update/'+id,
method: 'post', // 请求方法POST method:'post',
data: data // 请求体,包含更新数据 data:data
}) })
} }

@ -1,131 +1,48 @@
// 导入封装的 HTTP 请求工具,用于与后端 API 进行通信
import request from '@/utils/request' import request from '@/utils/request'
/**
* fetchList - 获取限时购场次列表
*
* 通过 GET 请求获取限时购场次的列表数据支持查询参数筛选结果
*
* @param {Object} params - 查询参数例如分页信息等
* 示例{ pageNum: 1, pageSize: 10 }
* @returns {Promise} - 返回一个 Promise 对象包含接口返回的数据
*
* 用法示例
* fetchList({ pageNum: 1, pageSize: 10 }).then(response => {
* console.log(response);
* });
*/
export function fetchList(params) { export function fetchList(params) {
return request({ return request({
url: '/flashSession/list', // 接口URL获取限时购场次列表 url: '/flashSession/list',
method: 'get', // 请求方法GET method: 'get',
params: params // 查询参数,通过 URL 传递 params: params
}) })
} }
/**
* fetchSelectList - 获取可选择的限时购场次列表
*
* 通过 GET 请求获取简化版的限时购场次数据用于下拉选择框等场景
*
* @param {Object} params - 查询参数例如过滤条件等
* 示例{ flashId: 1 }
* @returns {Promise} - 返回一个 Promise 对象包含接口返回的数据
*
* 用法示例
* fetchSelectList({ flashId: 1 }).then(response => {
* console.log(response);
* });
*/
export function fetchSelectList(params) { export function fetchSelectList(params) {
return request({ return request({
url: '/flashSession/selectList', // 接口URL获取可选的场次列表 url: '/flashSession/selectList',
method: 'get', // 请求方法GET method: 'get',
params: params // 查询参数 params: params
}) })
} }
/**
* updateStatus - 更新指定场次的状态
*
* 通过 POST 请求更新场次的状态例如启用或禁用状态
*
* @param {number|string} id - 限时购场次的唯一标识ID
* @param {Object} params - 状态参数例如 { status: 1 }
* @returns {Promise} - 返回一个 Promise 对象包含操作结果
*
* 用法示例
* updateStatus(1, { status: 1 }).then(response => {
* console.log(response);
* });
*/
export function updateStatus(id, params) { export function updateStatus(id, params) {
return request({ return request({
url: '/flashSession/update/status/' + id, // 接口URL更新场次状态 url: '/flashSession/update/status/' + id,
method: 'post', // 请求方法POST method: 'post',
params: params // 状态参数,通过 URL 查询字符串传递 params: params
}) })
} }
/**
* deleteSession - 删除指定的限时购场次
*
* 通过 POST 请求删除指定 ID 的限时购场次
*
* @param {number|string} id - 限时购场次的唯一标识ID
* @returns {Promise} - 返回一个 Promise 对象包含操作结果
*
* 用法示例
* deleteSession(1).then(response => {
* console.log(response);
* });
*/
export function deleteSession(id) { export function deleteSession(id) {
return request({ return request({
url: '/flashSession/delete/' + id, // 接口URL删除场次 url: '/flashSession/delete/' + id,
method: 'post' // 请求方法POST method: 'post'
}) })
} }
/**
* createSession - 创建新的限时购场次
*
* 通过 POST 请求提交新的场次数据创建限时购场次
*
* @param {Object} data - 场次的详细数据例如 { name: '上午场', startTime: '08:00', endTime: '12:00' }
* @returns {Promise} - 返回一个 Promise 对象包含操作结果
*
* 用法示例
* createSession({ name: '上午场', startTime: '08:00', endTime: '12:00' }).then(response => {
* console.log(response);
* });
*/
export function createSession(data) { export function createSession(data) {
return request({ return request({
url: '/flashSession/create', // 接口URL创建场次 url: '/flashSession/create',
method: 'post', // 请求方法POST method: 'post',
data: data // 请求体,包含场次数据 data: data
}) })
} }
/**
* updateSession - 更新指定的限时购场次数据
*
* 通过 POST 请求提交更新后的场次数据更新指定 ID 的场次信息
*
* @param {number|string} id - 限时购场次的唯一标识ID
* @param {Object} data - 更新后的场次数据例如 { name: '下午场', startTime: '13:00', endTime: '18:00' }
* @returns {Promise} - 返回一个 Promise 对象包含操作结果
*
* 用法示例
* updateSession(1, { name: '下午场', startTime: '13:00', endTime: '18:00' }).then(response => {
* console.log(response);
* });
*/
export function updateSession(id, data) { export function updateSession(id, data) {
return request({ return request({
url: '/flashSession/update/' + id, // 接口URL更新场次信息 url: '/flashSession/update/' + id,
method: 'post', // 请求方法POST method: 'post',
data: data // 请求体,包含更新数据 data: data
}) })
} }

@ -1,130 +1,43 @@
// 导入封装的 HTTP 请求工具,用于与后端 API 进行通信
import request from '@/utils/request' import request from '@/utils/request'
/**
* fetchList - 获取首页广告列表
*
* 通过 GET 请求获取首页广告列表支持查询参数进行筛选或分页
*
* @param {Object} params - 查询参数例如分页和过滤条件
* 示例{ pageNum: 1, pageSize: 10 }
* @returns {Promise} - 返回一个 Promise 对象包含接口返回的数据
*
* 用法示例
* fetchList({ pageNum: 1, pageSize: 10 }).then(response => {
* console.log(response);
* });
*/
export function fetchList(params) { export function fetchList(params) {
return request({ return request({
url: '/home/advertise/list', // 接口URL获取首页广告列表 url:'/home/advertise/list',
method: 'get', // 请求方法GET method:'get',
params: params // 查询参数,通过 URL 传递 params:params
}) })
} }
export function updateStatus(id,params) {
/**
* updateStatus - 更新指定广告的状态
*
* 通过 POST 请求更新首页广告的状态启用/禁用
*
* @param {number|string} id - 广告的唯一标识ID
* @param {Object} params - 状态参数例如 { status: 1 }
* @returns {Promise} - 返回一个 Promise 对象包含操作结果
*
* 用法示例
* updateStatus(1, { status: 1 }).then(response => {
* console.log(response);
* });
*/
export function updateStatus(id, params) {
return request({ return request({
url: '/home/advertise/update/status/' + id, // 接口URL更新广告状态 url:'/home/advertise/update/status/'+id,
method: 'post', // 请求方法POST method:'post',
params: params // 状态参数,通过 URL 查询字符串传递 params:params
}) })
} }
/**
* deleteHomeAdvertise - 批量删除首页广告
*
* 通过 POST 请求删除多个广告记录
*
* @param {Array<number|string>} data - 广告ID数组例如 [1, 2, 3]
* @returns {Promise} - 返回一个 Promise 对象包含操作结果
*
* 用法示例
* deleteHomeAdvertise([1, 2, 3]).then(response => {
* console.log(response);
* });
*/
export function deleteHomeAdvertise(data) { export function deleteHomeAdvertise(data) {
return request({ return request({
url: '/home/advertise/delete', // 接口URL批量删除广告 url:'/home/advertise/delete',
method: 'post', // 请求方法POST method:'post',
data: data // 请求体包含广告ID数组 data:data
}) })
} }
/**
* createHomeAdvertise - 创建新的首页广告
*
* 通过 POST 请求提交新的广告数据创建首页广告
*
* @param {Object} data - 广告的详细数据例如 { name: '新广告', type: 1, pic: 'url' }
* @returns {Promise} - 返回一个 Promise 对象包含操作结果
*
* 用法示例
* createHomeAdvertise({ name: '新广告', type: 1 }).then(response => {
* console.log(response);
* });
*/
export function createHomeAdvertise(data) { export function createHomeAdvertise(data) {
return request({ return request({
url: '/home/advertise/create', // 接口URL创建广告 url:'/home/advertise/create',
method: 'post', // 请求方法POST method:'post',
data: data // 请求体,包含广告数据 data:data
}) })
} }
/**
* getHomeAdvertise - 获取指定广告详情
*
* 通过 GET 请求获取单个广告的详细信息
*
* @param {number|string} id - 广告的唯一标识ID
* @returns {Promise} - 返回一个 Promise 对象包含广告详情数据
*
* 用法示例
* getHomeAdvertise(1).then(response => {
* console.log(response);
* });
*/
export function getHomeAdvertise(id) { export function getHomeAdvertise(id) {
return request({ return request({
url: '/home/advertise/' + id, // 接口URL获取广告详情 url:'/home/advertise/'+id,
method: 'get' // 请求方法GET method:'get',
}) })
} }
/** export function updateHomeAdvertise(id,data) {
* updateHomeAdvertise - 更新指定广告的信息
*
* 通过 POST 请求提交更新后的广告数据更新指定广告的信息
*
* @param {number|string} id - 广告的唯一标识ID
* @param {Object} data - 更新后的广告数据例如 { name: '更新广告', type: 2 }
* @returns {Promise} - 返回一个 Promise 对象包含操作结果
*
* 用法示例
* updateHomeAdvertise(1, { name: '更新广告', type: 2 }).then(response => {
* console.log(response);
* });
*/
export function updateHomeAdvertise(id, data) {
return request({ return request({
url: '/home/advertise/update/' + id, // 接口URL更新广告信息 url:'/home/advertise/update/'+id,
method: 'post', // 请求方法POST method:'post',
data: data // 请求体,包含更新后的广告数据 data:data
}) })
} }

@ -1,110 +1,40 @@
// 导入封装的 HTTP 请求工具,用于与后端 API 进行通信
import request from '@/utils/request' import request from '@/utils/request'
/**
* fetchList - 获取首页品牌列表
*
* 通过 GET 请求获取首页品牌列表支持分页和条件筛选
*
* @param {Object} params - 查询参数例如分页和筛选条件
* 示例{ pageNum: 1, pageSize: 10, keyword: '品牌名' }
* @returns {Promise} - 返回一个 Promise 对象包含接口返回的数据
*
* 用法示例
* fetchList({ pageNum: 1, pageSize: 10 }).then(response => {
* console.log(response);
* });
*/
export function fetchList(params) { export function fetchList(params) {
return request({ return request({
url: '/home/brand/list', // 接口URL获取品牌列表 url:'/home/brand/list',
method: 'get', // 请求方法GET method:'get',
params: params // 查询参数,通过 URL 传递 params:params
}) })
} }
/**
* updateRecommendStatus - 批量更新品牌推荐状态
*
* 通过 POST 请求批量更新品牌的推荐状态如是否推荐
*
* @param {Array<Object>} data - 推荐状态数据包含品牌ID数组和推荐状态
* 示例{ ids: [1, 2, 3], recommendStatus: 1 }
* @returns {Promise} - 返回一个 Promise 对象包含操作结果
*
* 用法示例
* updateRecommendStatus({ ids: [1, 2], recommendStatus: 1 }).then(response => {
* console.log(response);
* });
*/
export function updateRecommendStatus(data) { export function updateRecommendStatus(data) {
return request({ return request({
url: '/home/brand/update/recommendStatus', // 接口URL更新推荐状态 url:'/home/brand/update/recommendStatus',
method: 'post', // 请求方法POST method:'post',
data: data // 请求体包含品牌ID和状态 data:data
}) })
} }
/**
* deleteHomeBrand - 批量删除首页品牌
*
* 通过 POST 请求删除多个品牌记录
*
* @param {Array<number|string>} data - 品牌ID数组例如 [1, 2, 3]
* @returns {Promise} - 返回一个 Promise 对象包含操作结果
*
* 用法示例
* deleteHomeBrand([1, 2, 3]).then(response => {
* console.log(response);
* });
*/
export function deleteHomeBrand(data) { export function deleteHomeBrand(data) {
return request({ return request({
url: '/home/brand/delete', // 接口URL批量删除品牌 url:'/home/brand/delete',
method: 'post', // 请求方法POST method:'post',
data: data // 请求体包含品牌ID数组 data:data
}) })
} }
/**
* createHomeBrand - 创建新的首页品牌
*
* 通过 POST 请求提交新的品牌数据创建首页品牌
*
* @param {Object} data - 品牌的详细数据例如 { brandId: 1, brandName: '品牌名', sort: 0 }
* @returns {Promise} - 返回一个 Promise 对象包含操作结果
*
* 用法示例
* createHomeBrand({ brandId: 1, brandName: '新品牌', sort: 1 }).then(response => {
* console.log(response);
* });
*/
export function createHomeBrand(data) { export function createHomeBrand(data) {
return request({ return request({
url: '/home/brand/create', // 接口URL创建品牌 url:'/home/brand/create',
method: 'post', // 请求方法POST method:'post',
data: data // 请求体,包含品牌数据 data:data
}) })
} }
/**
* updateHomeBrandSort - 更新品牌的排序值
*
* 通过 POST 请求更新指定品牌的排序值
*
* @param {Object} params - 排序参数包含品牌ID和新的排序值
* 示例{ id: 1, sort: 10 }
* @returns {Promise} - 返回一个 Promise 对象包含操作结果
*
* 用法示例
* updateHomeBrandSort({ id: 1, sort: 10 }).then(response => {
* console.log(response);
* });
*/
export function updateHomeBrandSort(params) { export function updateHomeBrandSort(params) {
return request({ return request({
url: '/home/brand/update/sort/' + params.id, // 接口URL更新品牌排序 url:'/home/brand/update/sort/'+params.id,
method: 'post', // 请求方法POST method:'post',
params: params // 排序参数,通过 URL 查询字符串传递 params:params
}) })
} }

@ -1,110 +1,40 @@
// 导入封装的 HTTP 请求工具,用于与后端 API 进行通信
import request from '@/utils/request' import request from '@/utils/request'
/**
* fetchList - 获取首页推荐专题列表
*
* 通过 GET 请求获取首页推荐专题列表支持分页和条件筛选
*
* @param {Object} params - 查询参数例如分页和筛选条件
* 示例{ pageNum: 1, pageSize: 10, keyword: '专题名' }
* @returns {Promise} - 返回一个 Promise 对象包含接口返回的数据
*
* 用法示例
* fetchList({ pageNum: 1, pageSize: 10 }).then(response => {
* console.log(response);
* });
*/
export function fetchList(params) { export function fetchList(params) {
return request({ return request({
url: '/home/recommendSubject/list', // 接口URL获取推荐专题列表 url:'/home/recommendSubject/list',
method: 'get', // 请求方法GET method:'get',
params: params // 查询参数,通过 URL 传递 params:params
}) })
} }
/**
* updateRecommendStatus - 批量更新推荐专题的推荐状态
*
* 通过 POST 请求批量更新首页推荐专题的推荐状态
*
* @param {Object} data - 推荐状态数据包含专题ID数组和推荐状态
* 示例{ ids: [1, 2, 3], recommendStatus: 1 }
* @returns {Promise} - 返回一个 Promise 对象包含操作结果
*
* 用法示例
* updateRecommendStatus({ ids: [1, 2, 3], recommendStatus: 1 }).then(response => {
* console.log(response);
* });
*/
export function updateRecommendStatus(data) { export function updateRecommendStatus(data) {
return request({ return request({
url: '/home/recommendSubject/update/recommendStatus', // 接口URL更新推荐状态 url:'/home/recommendSubject/update/recommendStatus',
method: 'post', // 请求方法POST method:'post',
data: data // 请求体包含专题ID和推荐状态 data:data
}) })
} }
/**
* deleteHomeSubject - 批量删除推荐专题
*
* 通过 POST 请求删除多个推荐专题
*
* @param {Array<number|string>} data - 专题ID数组例如 [1, 2, 3]
* @returns {Promise} - 返回一个 Promise 对象包含操作结果
*
* 用法示例
* deleteHomeSubject([1, 2, 3]).then(response => {
* console.log(response);
* });
*/
export function deleteHomeSubject(data) { export function deleteHomeSubject(data) {
return request({ return request({
url: '/home/recommendSubject/delete', // 接口URL批量删除专题 url:'/home/recommendSubject/delete',
method: 'post', // 请求方法POST method:'post',
data: data // 请求体包含专题ID数组 data:data
}) })
} }
/**
* createHomeSubject - 创建新的首页推荐专题
*
* 通过 POST 请求提交新的专题数据创建首页推荐专题
*
* @param {Object} data - 推荐专题的详细数据例如 { subjectId: 1, subjectName: '专题名', sort: 0 }
* @returns {Promise} - 返回一个 Promise 对象包含操作结果
*
* 用法示例
* createHomeSubject({ subjectId: 1, subjectName: '新专题', sort: 1 }).then(response => {
* console.log(response);
* });
*/
export function createHomeSubject(data) { export function createHomeSubject(data) {
return request({ return request({
url: '/home/recommendSubject/create', // 接口URL创建推荐专题 url:'/home/recommendSubject/create',
method: 'post', // 请求方法POST method:'post',
data: data // 请求体,包含推荐专题数据 data:data
}) })
} }
/**
* updateHomeSubjectSort - 更新推荐专题的排序值
*
* 通过 POST 请求更新指定推荐专题的排序值
*
* @param {Object} params - 排序参数包含专题ID和新的排序值
* 示例{ id: 1, sort: 10 }
* @returns {Promise} - 返回一个 Promise 对象包含操作结果
*
* 用法示例
* updateHomeSubjectSort({ id: 1, sort: 10 }).then(response => {
* console.log(response);
* });
*/
export function updateHomeSubjectSort(params) { export function updateHomeSubjectSort(params) {
return request({ return request({
url: '/home/recommendSubject/update/sort/' + params.id, // 接口URL更新专题排序 url:'/home/recommendSubject/update/sort/'+params.id,
method: 'post', // 请求方法POST method:'post',
params: params // 排序参数,通过 URL 查询字符串传递 params:params
}) })
} }

@ -1,110 +1,40 @@
// 导入封装的 HTTP 请求工具,用于与后端 API 进行通信
import request from '@/utils/request' import request from '@/utils/request'
/**
* fetchList - 获取首页推荐商品列表
*
* 通过 GET 请求获取首页推荐商品列表支持分页和条件筛选
*
* @param {Object} params - 查询参数例如分页和筛选条件
* 示例{ pageNum: 1, pageSize: 10, keyword: '商品名' }
* @returns {Promise} - 返回一个 Promise 对象包含接口返回的数据
*
* 用法示例
* fetchList({ pageNum: 1, pageSize: 10 }).then(response => {
* console.log(response);
* });
*/
export function fetchList(params) { export function fetchList(params) {
return request({ return request({
url: '/home/recommendProduct/list', // 接口URL获取推荐商品列表 url:'/home/recommendProduct/list',
method: 'get', // 请求方法GET method:'get',
params: params // 查询参数,通过 URL 传递 params:params
}) })
} }
/**
* updateRecommendStatus - 批量更新推荐商品的推荐状态
*
* 通过 POST 请求批量更新首页推荐商品的推荐状态
*
* @param {Object} data - 推荐状态数据包含商品ID数组和推荐状态
* 示例{ ids: [1, 2, 3], recommendStatus: 1 }
* @returns {Promise} - 返回一个 Promise 对象包含操作结果
*
* 用法示例
* updateRecommendStatus({ ids: [1, 2, 3], recommendStatus: 1 }).then(response => {
* console.log(response);
* });
*/
export function updateRecommendStatus(data) { export function updateRecommendStatus(data) {
return request({ return request({
url: '/home/recommendProduct/update/recommendStatus', // 接口URL更新推荐状态 url:'/home/recommendProduct/update/recommendStatus',
method: 'post', // 请求方法POST method:'post',
data: data // 请求体包含商品ID和推荐状态 data:data
}) })
} }
/**
* deleteHotProduct - 批量删除推荐商品
*
* 通过 POST 请求删除多个推荐商品
*
* @param {Array<number|string>} data - 商品ID数组例如 [1, 2, 3]
* @returns {Promise} - 返回一个 Promise 对象包含操作结果
*
* 用法示例
* deleteHotProduct([1, 2, 3]).then(response => {
* console.log(response);
* });
*/
export function deleteHotProduct(data) { export function deleteHotProduct(data) {
return request({ return request({
url: '/home/recommendProduct/delete', // 接口URL批量删除推荐商品 url:'/home/recommendProduct/delete',
method: 'post', // 请求方法POST method:'post',
data: data // 请求体包含商品ID数组 data:data
}) })
} }
/**
* createHotProduct - 创建新的首页推荐商品
*
* 通过 POST 请求提交新的商品数据创建首页推荐商品
*
* @param {Object} data - 商品的详细数据例如 { productId: 1, productName: '商品名', sort: 0 }
* @returns {Promise} - 返回一个 Promise 对象包含操作结果
*
* 用法示例
* createHotProduct({ productId: 1, productName: '新商品', sort: 1 }).then(response => {
* console.log(response);
* });
*/
export function createHotProduct(data) { export function createHotProduct(data) {
return request({ return request({
url: '/home/recommendProduct/create', // 接口URL创建推荐商品 url:'/home/recommendProduct/create',
method: 'post', // 请求方法POST method:'post',
data: data // 请求体,包含商品数据 data:data
}) })
} }
/**
* updateHotProductSort - 更新推荐商品的排序值
*
* 通过 POST 请求更新指定推荐商品的排序值
*
* @param {Object} params - 排序参数包含商品ID和新的排序值
* 示例{ id: 1, sort: 10 }
* @returns {Promise} - 返回一个 Promise 对象包含操作结果
*
* 用法示例
* updateHotProductSort({ id: 1, sort: 10 }).then(response => {
* console.log(response);
* });
*/
export function updateHotProductSort(params) { export function updateHotProductSort(params) {
return request({ return request({
url: '/home/recommendProduct/update/sort/' + params.id, // 接口URL更新商品排序 url:'/home/recommendProduct/update/sort/'+params.id,
method: 'post', // 请求方法POST method:'post',
params: params // 排序参数,通过 URL 查询字符串传递 params:params
}) })
} }

@ -1,194 +1,121 @@
<template> <template> 
<!-- 创建一个 div 元素作为整个组件内容的包裹容器这是 HTML 中常用的用于组织和划分页面结构的方式 --> <div>
<div> <el-upload
<!-- el-upload 组件用于实现文件上传功能它是基于 Element UI 库提供的组件方便在 Vue 项目中快速集成文件上传交互功能 --> :action="useOss?ossUploadUrl:minioUploadUrl"
<el-upload :data="useOss?dataObj:null"
<!-- 通过三元表达式根据 useOss 的值来动态决定上传文件的 action 属性值即上传文件的请求地址 --> list-type="picture-card"
<!-- 如果 useOss true就使用 ossUploadUrl 作为上传地址这通常意味着要将文件上传到阿里云 OSSObject Storage Service对象存储服务服务器上 --> :file-list="fileList"
<!-- 如果 useOss false则使用 minioUploadUrl 作为上传地址MinIO 也是一种常用的对象存储服务这里可以根据实际需求切换使用不同的存储服务来上传文件 --> :before-upload="beforeUpload"
:action="useOss?ossUploadUrl:minioUploadUrl" :on-remove="handleRemove"
<!-- 同样基于 useOss 的值来决定是否向上传请求中传递额外的数据以对象形式 --> :on-success="handleUploadSuccess"
<!-- useOss true dataObj 作为额外的数据传递给上传请求这些数据一般包含了与文件上传到 OSS 相关的配置信息例如上传策略签名等用于服务器验证上传的合法性 --> :on-preview="handlePreview"
<!-- useOss false 不传递额外的数据即设置为 null --> :limit="maxCount"
:data="useOss?dataObj:null" :on-exceed="handleExceed"
<!-- 设置文件列表在页面上的展示类型为 "picture-card"这种类型的展示效果通常是以卡片形式呈现已上传的文件在这里主要是图片文件 --> >
<!-- 每个文件会以一个独立的卡片样式展示方便用户直观地查看已上传的文件并且可以进行相应的操作如删除预览等 --> <i class="el-icon-plus"></i>
list-type="picture-card" </el-upload>
<!-- 通过绑定计算属性 fileList将已上传文件的相关信息以特定格式传递给 el-upload 组件以便组件能够正确展示已上传的文件列表 --> <el-dialog :visible.sync="dialogVisible">
<!-- 计算属性 fileList 会根据组件接收到的相关数据进行处理转化为 el-upload 组件可识别的格式后面会在计算属性部分详细说明 --> <img width="100%" :src="dialogImageUrl" alt="">
:file-list="fileList" </el-dialog>
<!-- 绑定一个名为 before-upload 的回调函数该函数会在每个文件上传之前被触发 --> </div>
<!-- 可以在这个函数中进行一些前置的验证准备工作例如当使用阿里云 OSS 上传时需要在这里获取并设置相关的上传策略等配置信息决定文件是否可以进行上传 -->
:before-upload="beforeUpload"
<!-- 绑定一个名为 on-remove 的回调函数当用户在已展示的文件列表中删除某个文件时这个函数会被触发 -->
<!-- 用于处理文件删除后的相关逻辑比如通知父组件文件列表发生了变化让父组件可以相应地更新页面上显示的文件信息等 -->
:on-remove="handleRemove"
<!-- 绑定一个名为 on-success 的回调函数在文件上传成功后该函数会被触发 -->
<!-- 可以在这个函数里进行后续的操作例如更新文件列表数据通知父组件上传成功的消息以及根据上传结果进行一些页面展示相关的调整等 -->
:on-success="handleUploadSuccess"
<!-- 绑定一个名为 on-preview 的回调函数当用户点击已上传的文件进行预览操作时这个函数会被触发 -->
<!-- 主要用于实现文件的预览功能比如打开一个对话框展示图片的大图等操作 -->
:on-preview="handlePreview"
<!-- 通过绑定 maxCount 属性来设置允许上传的文件最大数量这个属性的值来源于组件通过 props 接收的父组件传递过来的 maxCount -->
<!-- 限制用户最多只能上传指定数量的文件若用户尝试上传超过此数量的文件会触发相应的超出限制处理逻辑 -->
:limit="maxCount"
<!-- 绑定一个名为 on-exceed 的回调函数当用户上传的文件数量超过了通过 :limit 设置的最大数量时该函数会被触发 -->
<!-- 用于给出相应的提示信息告知用户上传文件数量超出了限制让用户知晓当前的操作不符合规定 -->
:on-exceed="handleExceed"
>
<!-- el-upload 组件内部添加一个图标元素使用 el-icon-plus 这个类来展示一个加号图标 -->
<!-- 通常这个加号图标在界面上用于提示用户可以点击此处进行文件上传操作是一种常见的交互设计方式 -->
<i class="el-icon-plus"></i>
</el-upload>
<!-- el-dialog 组件用于创建一个对话框用于展示图片的预览功能它也是 Element UI 库中的组件方便实现弹出式的展示界面 -->
<el-dialog :visible.sync="dialogVisible">
<!-- 在对话框内部放置一个 img 元素用于展示要预览的图片 -->
<!-- 通过绑定 src 属性为 dialogImageUrl根据这个属性的值来确定要展示的图片的路径从而正确显示相应的图片内容 -->
<!-- 设置图片的宽度为 100%让图片能够自适应对话框的宽度完整地展示出来 -->
<img width="100%" :src="dialogImageUrl" alt="">
</el-dialog>
</div>
</template> </template>
<script> <script>
// '@/api/oss' policy OSS Policy --> import {policy} from '@/api/oss'
// 访 OSS
import {policy} from '@/api/oss';
// Vue Vue 使使 export default {
export default { name: 'multiUpload',
// Vue 'multiUpload'便 props: {
name: 'multiUpload', //
// props --> value: Array,
props: { //
// value --> maxCount:{
// 便 --> type:Number,
value: Array, default:5
// maxCount --> }
// Number 5 5 --> },
maxCount: { data() {
type: Number, return {
default: 5 dataObj: {
} policy: '',
signature: '',
key: '',
ossaccessKeyId: '',
dir: '',
host: ''
}, },
data() { dialogVisible: false,
return { dialogImageUrl:null,
// dataObj 使 OSS --> useOss:false, //使oss->true;使MinIO->false
// policy signature ossaccessKeyId 访 ID OSS --> ossUploadUrl:'http://macro-oss.oss-cn-shenzhen.aliyuncs.com',
dataObj: { minioUploadUrl:'http://localhost:8080/minio/upload',
policy: '', };
signature: '', },
key: '', computed: {
ossaccessKeyId: '', fileList() {
dir: '', let fileList=[];
host: '' for(let i=0;i<this.value.length;i++){
}, fileList.push({url:this.value[i]});
// dialogVisible false --> }
// true使 --> return fileList;
dialogVisible: false, }
// dialogImageUrl null --> },
// 便 img --> methods: {
dialogImageUrl: null, emitInput(fileList) {
// useOss 使 OSS true MinIO false --> let value=[];
// --> for(let i=0;i<fileList.length;i++){
useOss: false, value.push(fileList[i].url);
// ossUploadUrl OSS --> }
// OSS useOss true 使 OSS --> this.$emit('input', value)
ossUploadUrl: 'http://macro-oss.oss-cn-shenzhen.aliyuncs.com', },
// minioUploadUrl MinIO --> handleRemove(file, fileList) {
// useOss false 使 MinIO MinIO --> this.emitInput(fileList);
minioUploadUrl: 'http://localhost:8080/minio/upload', },
}; handlePreview(file) {
}, this.dialogVisible = true;
computed: { this.dialogImageUrl=file.url;
// fileList value --> },
// value url fileList fileList --> beforeUpload(file) {
// fileList el-upload --> let _self = this;
fileList() { if(!this.useOss){
let fileList = []; //使oss
for (let i = 0; i < this.value.length; i++) { return true;
fileList.push({url: this.value[i]});
}
return fileList;
}
},
methods: {
// emitInput 'input' -->
// 使 -->
emitInput(fileList) {
let value = [];
for (let i = 0; i < fileList.length; i++) {
value.push(fileList[i].url);
}
this.$emit('input', value)
},
// handleRemove -->
// el-upload emitInput fileList -->
// -->
handleRemove(file, fileList) {
this.emitInput(fileList);
},
// handlePreview -->
// dialogVisible true使 -->
// file.url dialogImageUrl 便 img -->
handlePreview(file) {
this.dialogVisible = true;
this.dialogImageUrl = file.url;
},
// beforeUpload -->
// 使 OSS useOss false true -->
// 使 OSSuseOss true policy -->
// dataObj resolve(true) -->
// catch reject(false) -->
beforeUpload(file) {
let _self = this;
if (!this.useOss) {
// 使 oss
return true;
}
return new Promise((resolve, reject) => {
policy().then(response => {
_self.dataObj.policy = response.data.policy;
_self.dataObj.signature = response.data.signature;
_self.dataObj.ossaccessKeyId = response.data.accessKeyId;
_self.dataObj.key = response.data.dir + '/${filename}';
_self.dataObj.dir = response.data.dir;
_self.dataObj.host = response.data.host;
resolve(true)
}).catch(err => {
console.log(err)
reject(false)
})
})
},
// handleUploadSuccess -->
// 使 OSS useOss -->
// 使 OSS dataObj.hostdataObj.dirfile.name访 -->
// 使 OSS使res.data.url -->
// 14342 fileList -->
// emitInput 便 -->
handleUploadSuccess(res, file) {
let url = this.dataObj.host + '/' + this.dataObj.dir + '/' + file.name;
if (!this.useOss) {
// 使 oss
url = res.data.url;
}
this.fileList.push({name: file.name, url: url});
this.emitInput(this.fileList);
},
// handleExceed -->
// maxCount -->
// $message 使 this.maxCount -->
// 1000 1 -->
handleExceed(files, fileList) {
this.$message({
message: '最多只能上传' + this.maxCount + '张图片',
type: 'warning',
duration: 1000
});
},
} }
return new Promise((resolve, reject) => {
policy().then(response => {
_self.dataObj.policy = response.data.policy;
_self.dataObj.signature = response.data.signature;
_self.dataObj.ossaccessKeyId = response.data.accessKeyId;
_self.dataObj.key = response.data.dir + '/${filename}';
_self.dataObj.dir = response.data.dir;
_self.dataObj.host = response.data.host;
resolve(true)
}).catch(err => {
console.log(err)
reject(false)
})
})
},
handleUploadSuccess(res, file) {
let url = this.dataObj.host + '/' + this.dataObj.dir + '/' + file.name;
if(!this.useOss){
//使oss
url = res.data.url;
}
this.fileList.push({name: file.name,url:url});
this.emitInput(this.fileList);
},
handleExceed(files, fileList) {
this.$message({
message: '最多只能上传'+this.maxCount+'张图片',
type: 'warning',
duration:1000
});
},
} }
}
</script> </script>
<style> <style>
</style> </style>

@ -1,33 +1,15 @@
<template> <template>
<div> <div>
<!-- 页面主体容器 -->
<div class="app-container"> <div class="app-container">
<!-- 左侧图片展示 -->
<el-col :span="12"> <el-col :span="12">
<!-- 显示 404 错误图片 -->
<img :src="img_404" alt="404" class="img-style"> <img :src="img_404" alt="404" class="img-style">
</el-col> </el-col>
<!-- 右侧提示信息与按钮 -->
<el-col :span="12"> <el-col :span="12">
<div style="margin-left: 100px; margin-top: 60px"> <div style="margin-left: 100px;margin-top: 60px">
<!-- 错误标题 -->
<h1 class="color-main">OOPS!</h1> <h1 class="color-main">OOPS!</h1>
<!-- 错误描述 -->
<h2 style="color: #606266">很抱歉页面它不小心迷路了</h2> <h2 style="color: #606266">很抱歉页面它不小心迷路了</h2>
<!-- 进一步的操作提示 --> <div style="color:#909399;font-size: 14px">请检查您输入的网址是否正确请点击以下按钮返回主页或者发送错误报告</div>
<div style="color:#909399; font-size: 14px"> <el-button style="margin-top: 20px" type="primary" round @click="handleGoMain"></el-button>
请检查您输入的网址是否正确请点击以下按钮返回主页或者发送错误报告
</div>
<!-- 返回首页按钮 -->
<el-button
style="margin-top: 20px"
type="primary"
round
@click="handleGoMain"
>
返回首页
</el-button>
</div> </div>
</el-col> </el-col>
</div> </div>
@ -35,50 +17,33 @@
</template> </template>
<script> <script>
// 404
import img_404 from '@/assets/images/gif_404.gif'; import img_404 from '@/assets/images/gif_404.gif';
export default { export default {
name: 'wrongPage', // name: 'wrongPage',
data() { data() {
return { return {
// 404
img_404 img_404
}; }
}, },
methods: { methods: {
/**
* 返回首页的处理函数
* 将用户重定向到主页
*/
handleGoMain() { handleGoMain() {
this.$router.push({ path: '/' }); this.$router.push({path: '/'})
} }
}, },
}; }
</script> </script>
<style scoped> <style scoped>
/* 页面主容器样式 */
.app-container { .app-container {
width: 80%; width: 80%;
margin: 120px auto; /* 页面居中,距离顶部 120px */ margin: 120px auto;
display: flex; /* 使用 flex 布局 */
align-items: center; /* 垂直居中 */
} }
/* 404 图片样式 */
.img-style { .img-style {
width: auto; /* 宽度自适应 */ width: auto;
height: auto; /* 高度自适应 */ height: auto;
max-width: 100%; /* 图片最大宽度不超过容器 */ max-width: 100%;
max-height: 100%; /* 图片最大高度不超过容器 */ max-height: 100%;
}
/* 标题主颜色样式 */
.color-main {
color: #409EFF; /* 标题颜色 */
font-size: 48px; /* 字体大小 */
font-weight: bold; /* 加粗字体 */
} }
</style> </style>

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

@ -1,13 +1,9 @@
<template> <template> 
<!-- 应用容器 -->
<div class="app-container"> <div class="app-container">
<!-- 筛选搜索区域 -->
<el-card class="filter-container" shadow="never"> <el-card class="filter-container" shadow="never">
<div> <div>
<!-- 搜索图标和文本 -->
<i class="el-icon-search"></i> <i class="el-icon-search"></i>
<span>筛选搜索</span> <span>筛选搜索</span>
<!-- 查询搜索按钮 -->
<el-button <el-button
style="float:right" style="float:right"
type="primary" type="primary"
@ -15,7 +11,6 @@
size="small"> size="small">
查询搜索 查询搜索
</el-button> </el-button>
<!-- 重置按钮 -->
<el-button <el-button
style="float:right;margin-right: 15px" style="float:right;margin-right: 15px"
@click="handleResetSearch()" @click="handleResetSearch()"
@ -23,14 +18,11 @@
重置 重置
</el-button> </el-button>
</div> </div>
<!-- 表单区域用于输入筛选条件 -->
<div style="margin-top: 15px"> <div style="margin-top: 15px">
<el-form :inline="true" :model="listQuery" size="small" label-width="140px"> <el-form :inline="true" :model="listQuery" size="small" label-width="140px">
<!-- 输入搜索项 -->
<el-form-item label="输入搜索:"> <el-form-item label="输入搜索:">
<el-input v-model="listQuery.id" class="input-width" placeholder="服务单号"></el-input> <el-input v-model="listQuery.id" class="input-width" placeholder="服务单号"></el-input>
</el-form-item> </el-form-item>
<!-- 处理状态下拉选择 -->
<el-form-item label="处理状态:"> <el-form-item label="处理状态:">
<el-select v-model="listQuery.status" placeholder="全部" clearable class="input-width"> <el-select v-model="listQuery.status" placeholder="全部" clearable class="input-width">
<el-option v-for="item in statusOptions" <el-option v-for="item in statusOptions"
@ -40,7 +32,6 @@
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<!-- 申请时间选择 -->
<el-form-item label="申请时间:"> <el-form-item label="申请时间:">
<el-date-picker <el-date-picker
class="input-width" class="input-width"
@ -50,11 +41,9 @@
placeholder="请选择时间"> placeholder="请选择时间">
</el-date-picker> </el-date-picker>
</el-form-item> </el-form-item>
<!-- 操作人员输入 -->
<el-form-item label="操作人员:"> <el-form-item label="操作人员:">
<el-input v-model="listQuery.handleMan" class="input-width" placeholder="全部"></el-input> <el-input v-model="listQuery.handleMan" class="input-width" placeholder="全部"></el-input>
</el-form-item> </el-form-item>
<!-- 处理时间选择 -->
<el-form-item label="处理时间:"> <el-form-item label="处理时间:">
<el-date-picker <el-date-picker
class="input-width" class="input-width"
@ -67,58 +56,45 @@
</el-form> </el-form>
</div> </div>
</el-card> </el-card>
<!-- 数据列表操作区域 -->
<el-card class="operate-container" shadow="never"> <el-card class="operate-container" shadow="never">
<i class="el-icon-tickets"></i> <i class="el-icon-tickets"></i>
<span>数据列表</span> <span>数据列表</span>
</el-card> </el-card>
<!-- 表格容器 -->
<div class="table-container"> <div class="table-container">
<!-- 表格展示数据列表 -->
<el-table ref="returnApplyTable" <el-table ref="returnApplyTable"
:data="list" :data="list"
style="width: 100%;" style="width: 100%;"
@selection-change="handleSelectionChange" @selection-change="handleSelectionChange"
v-loading="listLoading" border> v-loading="listLoading" border>
<!-- 选择列 -->
<el-table-column type="selection" width="60" align="center"></el-table-column> <el-table-column type="selection" width="60" align="center"></el-table-column>
<!-- 服务单号列 -->
<el-table-column label="服务单号" width="180" align="center"> <el-table-column label="服务单号" width="180" align="center">
<template slot-scope="scope">{{scope.row.id}}</template> <template slot-scope="scope">{{scope.row.id}}</template>
</el-table-column> </el-table-column>
<!-- 申请时间列 -->
<el-table-column label="申请时间" width="180" align="center"> <el-table-column label="申请时间" width="180" align="center">
<template slot-scope="scope">{{scope.row.createTime | formatTime}}</template> <template slot-scope="scope">{{scope.row.createTime | formatTime}}</template>
</el-table-column> </el-table-column>
<!-- 用户账号列 -->
<el-table-column label="用户账号" align="center"> <el-table-column label="用户账号" align="center">
<template slot-scope="scope">{{scope.row.memberUsername}}</template> <template slot-scope="scope">{{scope.row.memberUsername}}</template>
</el-table-column> </el-table-column>
<!-- 退款金额列 -->
<el-table-column label="退款金额" width="180" align="center"> <el-table-column label="退款金额" width="180" align="center">
<template slot-scope="scope">{{scope.row | formatReturnAmount}}</template> <template slot-scope="scope">{{scope.row | formatReturnAmount}}</template>
</el-table-column> </el-table-column>
<!-- 申请状态列 -->
<el-table-column label="申请状态" width="180" align="center"> <el-table-column label="申请状态" width="180" align="center">
<template slot-scope="scope">{{scope.row.status | formatStatus}}</template> <template slot-scope="scope">{{scope.row.status | formatStatus}}</template>
</el-table-column> </el-table-column>
<!-- 处理时间列 -->
<el-table-column label="处理时间" width="180" align="center"> <el-table-column label="处理时间" width="180" align="center">
<template slot-scope="scope">{{scope.row.handleTime | formatTime}}</template> <template slot-scope="scope">{{scope.row.handleTime | formatTime}}</template>
</el-table-column> </el-table-column>
<!-- 操作列 -->
<el-table-column label="操作" width="180" align="center"> <el-table-column label="操作" width="180" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
size="mini" size="mini"
@click="handleViewDetail(scope.$index, scope.row)">查看详情</el-button> @click="handleViewDetail(scope.$index, scope.row)">查看详情</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</div> </div>
<!-- 批量操作容器 -->
<div class="batch-operate-container"> <div class="batch-operate-container">
<!-- 批量操作下拉选择 -->
<el-select <el-select
size="small" size="small"
v-model="operateType" placeholder="批量操作"> v-model="operateType" placeholder="批量操作">
@ -129,7 +105,6 @@
:value="item.value"> :value="item.value">
</el-option> </el-option>
</el-select> </el-select>
<!-- 批量操作按钮 -->
<el-button <el-button
style="margin-left: 20px" style="margin-left: 20px"
class="search-button" class="search-button"
@ -139,7 +114,6 @@
确定 确定
</el-button> </el-button>
</div> </div>
<!-- 分页容器 -->
<div class="pagination-container"> <div class="pagination-container">
<el-pagination <el-pagination
background background
@ -154,14 +128,9 @@
</div> </div>
</div> </div>
</template> </template>
<script> <script>
//
import {formatDate} from '@/utils/date'; import {formatDate} from '@/utils/date';
// API
import {fetchList,deleteApply} from '@/api/returnApply'; import {fetchList,deleteApply} from '@/api/returnApply';
//
const defaultListQuery = { const defaultListQuery = {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
@ -172,7 +141,6 @@
handleMan: null, handleMan: null,
handleTime: null handleTime: null
}; };
//
const defaultStatusOptions=[ const defaultStatusOptions=[
{ {
label: '待处理', label: '待处理',
@ -191,7 +159,6 @@
value: 3 value: 3
} }
]; ];
export default { export default {
name:'returnApplyList', name:'returnApplyList',
data() { data() {
@ -212,11 +179,9 @@
} }
}, },
created(){ created(){
//
this.getList(); this.getList();
}, },
filters:{ filters:{
//
formatTime(time) { formatTime(time) {
if(time==null||time===''){ if(time==null||time===''){
return 'N/A'; return 'N/A';
@ -224,7 +189,6 @@
let date = new Date(time); let date = new Date(time);
return formatDate(date, 'yyyy-MM-dd hh:mm:ss') return formatDate(date, 'yyyy-MM-dd hh:mm:ss')
}, },
//
formatStatus(status){ formatStatus(status){
for(let i=0;i<defaultStatusOptions.length;i++){ for(let i=0;i<defaultStatusOptions.length;i++){
if(status===defaultStatusOptions[i].value){ if(status===defaultStatusOptions[i].value){
@ -232,30 +196,24 @@
} }
} }
}, },
// 退
formatReturnAmount(row){ formatReturnAmount(row){
return row.productRealPrice*row.productCount; return row.productRealPrice*row.productCount;
} }
}, },
methods:{ methods:{
//
handleSelectionChange(val){ handleSelectionChange(val){
this.multipleSelection = val; this.multipleSelection = val;
}, },
//
handleResetSearch() { handleResetSearch() {
this.listQuery = Object.assign({}, defaultListQuery); this.listQuery = Object.assign({}, defaultListQuery);
}, },
//
handleSearchList() { handleSearchList() {
this.listQuery.pageNum = 1; this.listQuery.pageNum = 1;
this.getList(); this.getList();
}, },
//
handleViewDetail(index,row){ handleViewDetail(index,row){
this.$router.push({path:'/oms/returnApplyDetail',query:{id:row.id}}) this.$router.push({path:'/oms/returnApplyDetail',query:{id:row.id}})
}, },
//
handleBatchOperate(){ handleBatchOperate(){
if(this.multipleSelection==null||this.multipleSelection.length<1){ if(this.multipleSelection==null||this.multipleSelection.length<1){
this.$message({ this.$message({
@ -266,7 +224,7 @@
return; return;
} }
if(this.operateType===1){ if(this.operateType===1){
// //
this.$confirm('是否要进行删除操作?', '提示', { this.$confirm('是否要进行删除操作?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',

@ -1,69 +1,59 @@
<template> <template> 
<!-- 使用 el-dialog 组件创建一个对话框用于展示订单跟踪相关信息设置对话框的标题为 "订单跟踪"通过 :visible.sync 双向绑定对话框的可见性与组件的 visible 属性关联后面会详细介绍绑定 :before-close 事件处理函数用于在对话框关闭前执行一些操作设置对话框宽度为 40% --> <el-dialog title="订单跟踪"
<el-dialog title="订单跟踪" :visible.sync="visible"
:visible.sync="visible" :before-close="handleClose"
:before-close="handleClose" width="40%">
width="40%"> <el-steps direction="vertical"
<!-- el-steps 组件用于创建一个步骤条设置方向为垂直direction="vertical"指定当前激活的步骤索引为 6:active="6"这里可能需要根据实际业务逻辑根据订单物流状态动态设置该值设置已完成步骤的状态样式为 "success"通常表示成功完成的视觉效果比如显示为绿色等设置每个步骤之间的间隔为 50pxspace="50px" --> :active="6"
<el-steps direction="vertical" finish-status="success"
:active="6" space="50px">
finish-status="success" <el-step v-for="item in logisticsList"
space="50px"> :key="item.name"
<!-- 通过 v-for 指令循环遍历 logisticsList 数据数组来动态生成每个步骤el-step每个步骤绑定一个唯一的 key使用 :key="item.name" Vue 中循环渲染列表时key 是必要的有助于 Vue 更高效地更新虚拟 DOM设置步骤的标题为 item.name从数据中获取每个步骤对应的名称设置步骤的描述信息为 item.time从数据中获取对应时间信息 --> :title="item.name"
<el-step v-for="item in logisticsList" :description="item.time"></el-step>
:key="item.name" </el-steps>
:title="item.name" </el-dialog>
:description="item.time"></el-step>
</el-steps>
</el-dialog>
</template> </template>
<script> <script>
// defaultLogisticsListname time const defaultLogisticsList=[
const defaultLogisticsList = [ {name: '订单已提交,等待付款',time:'2017-04-01 12:00:00 '},
{name: '订单已提交,等待付款', time: '2017-04-01 12:00:00 '}, {name: '订单付款成功',time:'2017-04-01 12:00:00 '},
{name: '订单付款成功', time: '2017-04-01 12:00:00 '}, {name: '在北京市进行下级地点扫描,等待付款',time:'2017-04-01 12:00:00 '},
{name: '在北京市进行下级地点扫描,等待付款', time: '2017-04-01 12:00:00 '}, {name: '在分拨中心广东深圳公司进行卸车扫描,等待付款',time:'2017-04-01 12:00:00 '},
{name: '在分拨中心广东深圳公司进行卸车扫描,等待付款', time: '2017-04-01 12:00:00 '}, {name: '在广东深圳公司进行发出扫描',time:'2017-04-01 12:00:00 '},
{name: '在广东深圳公司进行发出扫描', time: '2017-04-01 12:00:00 '}, {name: '到达目的地网点广东深圳公司,快件将很快进行派送',time:'2017-04-01 12:00:00 '},
{name: '到达目的地网点广东深圳公司,快件将很快进行派送', time: '2017-04-01 12:00:00 '}, {name: '订单已签收,期待再次为您服务',time:'2017-04-01 12:00:00 '}
{name: '订单已签收,期待再次为您服务', time: '2017-04-01 12:00:00 '} ];
]; export default {
name:'logisticsDialog',
// Vue props: {
export default { value: Boolean
// Vue 'logisticsDialog' },
name: 'logisticsDialog', computed:{
// props value Vue visible: {
props: { get() {
value: Boolean return this.value;
}, },
computed: { set(visible){
// visible get set props value Vue props 便 this.value=visible;
visible: { }
get() { }
return this.value; },
}, data() {
set(visible) { return {
this.value = visible; logisticsList:Object.assign({},defaultLogisticsList)
} }
} },
}, methods:{
data() { emitInput(val) {
return { this.$emit('input', val)
// defaultLogisticsList Object.assign logisticsList },
logisticsList: Object.assign({}, defaultLogisticsList) handleClose(){
} this.emitInput(false);
},
methods: {
// emitInput 'input' val Vue $emit
emitInput(val) {
this.$emit('input', val)
},
// handleClose el-dialog :before-close emitInput false
handleClose() {
this.emitInput(false);
}
}
} }
</script> }
}
</script>
<style></style> <style></style>

@ -1,130 +1,99 @@
<template> <template> 
<!-- 创建一个类名为 "app-container" div 作为整体页面的容器 --> <div class="app-container">
<div class="app-container"> <el-card class="operate-container" shadow="never">
<!-- 使用 el-card 组件创建一个卡片式容器设置类名为 "operate-container" 并取消阴影效果用于展示页面相关标题 --> <i class="el-icon-tickets"></i>
<el-card class="operate-container" shadow="never"> <span>发货列表</span>
<!-- 使用一个图标元素el-icon-tickets展示一个图标 --> </el-card>
<i class="el-icon-tickets"></i> <div class="table-container">
<!-- 展示一段文本内容为 "发货列表"用于表明该页面主要展示的内容 --> <el-table ref="deliverOrderTable"
<span>发货列表</span> style="width: 100%;"
</el-card> :data="list" border>
<!-- 创建一个类名为 "table-container" div用于放置展示发货相关信息的表格以及操作按钮等内容 --> <el-table-column label="订单编号" width="180" align="center">
<div class="table-container"> <template slot-scope="scope">{{scope.row.orderSn}}</template>
<!-- el-table 组件创建一个表格设置引用名称宽度以及绑定数据等属性同时设置表格显示边框 --> </el-table-column>
<el-table ref="deliverOrderTable" <el-table-column label="收货人" width="180" align="center">
style="width: 100%;" <template slot-scope="scope">{{scope.row.receiverName}}</template>
:data="list" border> </el-table-column>
<!-- 定义表格列用于展示订单编号信息设置宽度和文本对齐方式通过插槽作用域获取对应行数据中的订单编号并展示 --> <el-table-column label="手机号码" width="160" align="center">
<el-table-column label="订单编号" width="180" align="center"> <template slot-scope="scope">{{scope.row.receiverPhone}}</template>
<template slot-scope="scope">{{scope.row.orderSn}}</template> </el-table-column>
</el-table-column> <el-table-column label="邮政编码" width="160" align="center">
<!-- 定义表格列用于展示收货人信息设置宽度和文本对齐方式通过插槽作用域获取对应行数据中的收货人姓名并展示 --> <template slot-scope="scope">{{scope.row.receiverPostCode}}</template>
<el-table-column label="收货人" width="180" align="center"> </el-table-column>
<template slot-scope="scope">{{scope.row.receiverName}}</template> <el-table-column label="收货地址" align="center">
</el-table-column> <template slot-scope="scope">{{scope.row.address}}</template>
<!-- 定义表格列用于展示手机号码信息设置宽度和文本对齐方式通过插槽作用域获取对应行数据中的手机号码并展示 --> </el-table-column>
<el-table-column label="手机号码" width="160" align="center"> <el-table-column label="配送方式" width="160" align="center">
<template slot-scope="scope">{{scope.row.receiverPhone}}</template> <template slot-scope="scope">
</el-table-column> <el-select placeholder="请选择物流公司"
<!-- 定义表格列用于展示邮政编码信息设置宽度和文本对齐方式通过插槽作用域获取对应行数据中的邮政编码并展示 --> v-model="scope.row.deliveryCompany"
<el-table-column label="邮政编码" width="160" align="center"> size="small">
<template slot-scope="scope">{{scope.row.receiverPostCode}}</template> <el-option v-for="item in companyOptions"
</el-table-column> :key="item"
<!-- 定义表格列用于展示收货地址信息设置文本对齐方式通过插槽作用域获取对应行数据中的收货地址并展示 --> :label="item"
<el-table-column label="收货地址" align="center"> :value="item">
<template slot-scope="scope">{{scope.row.address}}</template> </el-option>
</el-table-column> </el-select>
<!-- 定义表格列用于展示配送方式信息通过插槽作用域在每个单元格内创建一个下拉选择框用于选择物流公司绑定对应行数据中的 deliveryCompany 属性设置占位提示文本和小尺寸样式通过循环 companyOptions 数据动态生成下拉选项 --> </template>
<el-table-column label="配送方式" width="160" align="center"> </el-table-column>
<template slot-scope="scope"> <el-table-column label="物流单号" width="180" align="center">
<el-select placeholder="请选择物流公司" <template slot-scope="scope">
v-model="scope.row.deliveryCompany" <el-input size="small" v-model="scope.row.deliverySn"></el-input>
size="small"> </template>
<el-option v-for="item in companyOptions" </el-table-column>
:key="item" </el-table>
:label="item" <div style="margin-top: 15px;text-align: center">
:value="item"> <el-button @click="cancel"></el-button>
</el-option> <el-button @click="confirm" type="primary">确定</el-button>
</el-select> </div>
</template>
</el-table-column>
<!-- 定义表格列用于展示物流单号信息通过插槽作用域在每个单元格内创建一个小尺寸的输入框双向绑定对应行数据中的 deliverySn 属性用于输入物流单号 -->
<el-table-column label="物流单号" width="180" align="center">
<template slot-scope="scope">
<el-input size="small" v-model="scope.row.deliverySn"></el-input>
</template>
</el-table-column>
</el-table>
<!-- 创建一个 div设置上边距文本居中对齐用于放置操作按钮 -->
<div style="margin-top: 15px;text-align: center">
<!-- el-button 组件创建一个按钮点击时调用 "cancel" 方法按钮文本为 "取消" -->
<el-button @click="cancel"></el-button>
<!-- el-button 组件创建一个按钮点击时调用 "confirm" 方法按钮类型设置为 "primary"通常表示主要操作按钮样式上可能会突出显示按钮文本为 "确定" -->
<el-button @click="confirm" type="primary">确定</el-button>
</div>
</div>
</div> </div>
</div>
</template> </template>
<script>
import {deliveryOrder} from '@/api/order'
const defaultLogisticsCompanies=["顺丰快递","圆通快递","中通快递","韵达快递"];
export default {
name: 'deliverOrderList',
data() {
return {
list:[],
companyOptions:defaultLogisticsCompanies
}
},
created(){
this.list= this.$route.query.list;
//list
if(this.list instanceof Array===false){
this.list=[];
}
},
methods:{
cancel(){
this.$router.back();
},
confirm(){
this.$confirm('是否要进行发货操作?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
deliveryOrder(this.list).then(response=>{
this.$router.back();
this.$message({
type: 'success',
message: '发货成功!'
});
});
}).catch(() => {
this.$message({
type: 'info',
message: '已取消发货'
});
});
}
}
}
</script>
<style></style>
<script>
// '@/api/order' deliveryOrder
import {deliveryOrder} from '@/api/order';
//
const defaultLogisticsCompanies = ["顺丰快递", "圆通快递", "中通快递", "韵达快递"];
// Vue
export default {
// Vue "deliverOrderList"
name: 'deliverOrderList',
data() {
return {
//
list: [],
// defaultLogisticsCompanies
companyOptions: defaultLogisticsCompanies
}
},
created() {
// this.$route.query "list" list
this.list = this.$route.query.list;
// list list
if (this.list instanceof Array === false) {
this.list = [];
}
},
methods: {
// "cancel" Vue this.$router back
cancel() {
this.$router.back();
}
// "confirm"
confirm() {
// 使 $confirm "warning"
this.$confirm('是否要进行发货操作?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
// "" "deliveryOrder" list
// then Vue this.$router back 使 $message "!"
deliveryOrder(this.list).then(response => {
this.$router.back();
this.$message({
type: 'success',
message: '发货成功!'
});
});
}).catch(() => {
// "" catch 使 $message ""
this.$message({
type: 'info',
message: '已取消发货'
});
});
}
}
}
</script>
<style></style>

@ -1,550 +1,402 @@
<template> <template> 
<!-- 创建一个类名为 "app-container" div 作为整体页面容器 --> <div class="app-container">
<div class="app-container"> <el-card class="filter-container" shadow="never">
<!-- 使用 el-card 组件创建一个卡片式容器用于放置筛选搜索相关内容设置类名为 "filter-container" 并取消阴影效果 --> <div>
<el-card class="filter-container" shadow="never"> <i class="el-icon-search"></i>
<div> <span>筛选搜索</span>
<!-- 使用一个图标元素el-icon-search展示搜索图标 --> <el-button
<i class="el-icon-search"></i> style="float:right"
<!-- 展示一段文本内容为 "筛选搜索" --> type="primary"
<span>筛选搜索</span> @click="handleSearchList()"
<!-- el-button 组件创建一个按钮设置样式使其右浮动按钮类型为 "primary"点击时调用 "handleSearchList" 方法按钮大小为 "small"文本为 "查询搜索" --> size="small">
<el-button 查询搜索
style="float:right" </el-button>
type="primary" <el-button
@click="handleSearchList()" style="float:right;margin-right: 15px"
size="small"> @click="handleResetSearch()"
查询搜索 size="small">
</el-button> 重置
<!-- 类似上述按钮设置右浮动及右外边距点击调用 "handleResetSearch" 方法用于重置筛选条件按钮大小为 "small"文本为 "重置" --> </el-button>
<el-button </div>
style="float:right;margin-right: 15px" <div style="margin-top: 15px">
@click="handleResetSearch()" <el-form :inline="true" :model="listQuery" size="small" label-width="140px">
size="small"> <el-form-item label="输入搜索:">
重置 <el-input v-model="listQuery.orderSn" class="input-width" placeholder="订单编号"></el-input>
</el-button> </el-form-item>
</div> <el-form-item label="收货人:">
<div style="margin-top: 15px"> <el-input v-model="listQuery.receiverKeyword" class="input-width" placeholder="收货人姓名/手机号码"></el-input>
<!-- el-form 组件创建一个内联表单绑定数据模型为 "listQuery"设置表单大小为 "small"标签宽度为 "140px" --> </el-form-item>
<el-form :inline="true" :model="listQuery" size="small" label-width="140px"> <el-form-item label="提交时间:">
<!-- el-form-item 组件定义表单中的一项用于输入订单编号的搜索框双向绑定 "listQuery.orderSn"设置类名控制宽度添加占位提示文本 --> <el-date-picker
<el-form-item label="输入搜索:"> class="input-width"
<el-input v-model="listQuery.orderSn" class="input-width" placeholder="订单编号"></el-input> v-model="listQuery.createTime"
</el-form-item> value-format="yyyy-MM-dd"
<!-- 类似上述用于输入收货人相关关键字的搜索框绑定 "listQuery.receiverKeyword" --> type="date"
<el-form-item label="收货人:"> placeholder="请选择时间">
<el-input v-model="listQuery.receiverKeyword" class="input-width" placeholder="收货人姓名/手机号码"></el-input> </el-date-picker>
</el-form-item> </el-form-item>
<!-- 用于选择提交时间的日期选择器绑定 "listQuery.createTime"设置日期格式类型为 "date"仅选择日期及占位提示文本通过类名控制宽度 --> <el-form-item label="订单状态:">
<el-form-item label="提交时间:"> <el-select v-model="listQuery.status" class="input-width" placeholder="全部" clearable>
<el-date-picker <el-option v-for="item in statusOptions"
class="input-width" :key="item.value"
v-model="listQuery.createTime" :label="item.label"
value-format="yyyy-MM-dd" :value="item.value">
type="date" </el-option>
placeholder="请选择时间">
</el-date-picker>
</el-form-item>
<!-- 用于选择订单状态的下拉选择框绑定 "listQuery.status"设置类名控制宽度占位提示文本并允许清空选项通过循环选项数据动态生成下拉选项 -->
<el-form-item label="订单状态:">
<el-select v-model="listQuery.status" class="input-width" placeholder="全部" clearable>
<el-option v-for="item in statusOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<!-- 用于选择订单分类的下拉选择框绑定 "listQuery.orderType"类似上述设置 -->
<el-form-item label="订单分类:">
<el-select v-model="listQuery.orderType" class="input-width" placeholder="全部" clearable>
<el-option v-for="item in orderTypeOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<!-- 用于选择订单来源的下拉选择框绑定 "listQuery.sourceType"同样的设置方式 -->
<el-form-item label="订单来源:">
<el-select v-model="listQuery.sourceType" class="input-width" placeholder="全部" clearable>
<el-option v-for="item in sourceTypeOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
</el-form>
</div>
</el-card>
<!-- 使用 el-card 组件创建另一个卡片式容器用于展示数据列表相关的标题设置类名为 "operate-container" 并取消阴影效果 -->
<el-card class="operate-container" shadow="never">
<i class="el-icon-tickets"></i>
<span>数据列表</span>
</el-card>
<!-- 创建一个类名为 "table-container" div用于放置展示数据的表格 -->
<div class="table-container">
<!-- el-table 组件创建表格设置引用绑定数据宽度监听行选择变化事件以及控制加载状态等属性 -->
<el-table ref="orderTable"
: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="80" align="center">
<template slot-scope="scope">{{scope.row.id}}</template>
</el-table-column>
<!-- 定义表格列展示订单编号信息设置宽度和文本对齐方式 -->
<el-table-column label="订单编号" width="180" align="center">
<template slot-scope="scope">{{scope.row.orderSn}}</template>
</el-table-column>
<!-- 定义表格列展示提交时间信息设置宽度和文本对齐方式通过管道符调用 formatCreateTime 过滤器对时间进行格式化后展示 -->
<el-table-column label="提交时间" width="180" align="center">
<template slot-scope="scope">{{scope.row.createTime | formatCreateTime}}</template>
</el-table-column>
<!-- 定义表格列展示用户账号信息设置文本对齐方式通过插槽作用域获取对应行数据展示 -->
<el-table-column label="用户账号" align="center">
<template slot-scope="scope">{{scope.row.memberUsername}}</template>
</el-table-column>
<!-- 定义表格列展示订单金额信息设置宽度和文本对齐方式 -->
<el-table-column label="订单金额" width="120" align="center">
<template slot-scope="scope">{{scope.row.totalAmount}}</template>
</el-table-column>
<!-- 定义表格列展示支付方式信息设置宽度和文本对齐方式通过管道符调用 formatPayType 过滤器对支付方式进行格式化后展示 -->
<el-table-column label="支付方式" width="120" align="center">
<template slot-scope="scope">{{scope.row.payType | formatPayType}}</template>
</el-table-column>
<!-- 定义表格列展示订单来源信息设置宽度和文本对齐方式通过管道符调用 formatSourceType 过滤器对订单来源进行格式化后展示 -->
<el-table-column label="订单来源" width="120" align="center">
<template slot-scope="scope">{{scope.row.sourceType | formatSourceType}}</template>
</el-table-column>
<!-- 定义表格列展示订单状态信息设置宽度和文本对齐方式通过管道符调用 formatStatus 过滤器对订单状态进行格式化后展示 -->
<el-table-column label="订单状态" width="120" align="center">
<template slot-scope="scope">{{scope.row.status | formatStatus}}</template>
</el-table-column>
<!-- 定义表格列展示操作按钮设置宽度和文本对齐方式通过插槽作用域根据不同订单状态动态显示相应操作按钮 -->
<el-table-column label="操作" width="200" align="center">
<template slot-scope="scope">
<el-button
size="mini"
@click="handleViewOrder(scope.$index, scope.row)"
>查看订单</el-button>
<el-button
size="mini"
@click="handleCloseOrder(scope.$index, scope.row)"
v-show="scope.row.status===0">关闭订单</el-button>
<el-button
size="mini"
@click="handleDeliveryOrder(scope.$index, scope.row)"
v-show="scope.row.status===1">订单发货</el-button>
<el-button
size="mini"
@click="handleViewLogistics(scope.$index, scope.row)"
v-show="scope.row.status===2||scope.row.status===3">订单跟踪</el-button>
<el-button
size="mini"
type="danger"
@click="handleDeleteOrder(scope.$index, scope.row)"
v-show="scope.row.status===4">删除订单</el-button>
</template>
</el-table-column>
</el-table>
</div>
<!-- 创建一个类名为 "batch-operate-container" div用于放置批量操作相关的选择框和按钮 -->
<div class="batch-operate-container">
<!-- el-select 组件创建下拉选择框设置大小绑定数据模型通过循环选项数据动态生成下拉选项 -->
<el-select
size="small"
v-model="operateType" placeholder="批量操作">
<el-option
v-for="item in operateOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select> </el-select>
<!-- el-button 组件创建按钮设置左外边距类名点击调用 "handleBatchOperate" 方法按钮类型为 "primary" 以及按钮大小为 "small"文本为 "确定" --> </el-form-item>
<el-form-item label="订单分类:">
<el-select v-model="listQuery.orderType" class="input-width" placeholder="全部" clearable>
<el-option v-for="item in orderTypeOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="订单来源:">
<el-select v-model="listQuery.sourceType" class="input-width" placeholder="全部" clearable>
<el-option v-for="item in sourceTypeOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
</el-form>
</div>
</el-card>
<el-card class="operate-container" shadow="never">
<i class="el-icon-tickets"></i>
<span>数据列表</span>
</el-card>
<div class="table-container">
<el-table ref="orderTable"
: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="80" align="center">
<template slot-scope="scope">{{scope.row.id}}</template>
</el-table-column>
<el-table-column label="订单编号" width="180" align="center">
<template slot-scope="scope">{{scope.row.orderSn}}</template>
</el-table-column>
<el-table-column label="提交时间" width="180" align="center">
<template slot-scope="scope">{{scope.row.createTime | formatCreateTime}}</template>
</el-table-column>
<el-table-column label="用户账号" align="center">
<template slot-scope="scope">{{scope.row.memberUsername}}</template>
</el-table-column>
<el-table-column label="订单金额" width="120" align="center">
<template slot-scope="scope">{{scope.row.totalAmount}}</template>
</el-table-column>
<el-table-column label="支付方式" width="120" align="center">
<template slot-scope="scope">{{scope.row.payType | formatPayType}}</template>
</el-table-column>
<el-table-column label="订单来源" width="120" align="center">
<template slot-scope="scope">{{scope.row.sourceType | formatSourceType}}</template>
</el-table-column>
<el-table-column label="订单状态" width="120" align="center">
<template slot-scope="scope">{{scope.row.status | formatStatus}}</template>
</el-table-column>
<el-table-column label="操作" width="200" align="center">
<template slot-scope="scope">
<el-button
size="mini"
@click="handleViewOrder(scope.$index, scope.row)"
>查看订单</el-button>
<el-button
size="mini"
@click="handleCloseOrder(scope.$index, scope.row)"
v-show="scope.row.status===0">关闭订单</el-button>
<el-button
size="mini"
@click="handleDeliveryOrder(scope.$index, scope.row)"
v-show="scope.row.status===1">订单发货</el-button>
<el-button
size="mini"
@click="handleViewLogistics(scope.$index, scope.row)"
v-show="scope.row.status===2||scope.row.status===3">订单跟踪</el-button>
<el-button <el-button
style="margin-left: 20px" size="mini"
class="search-button" type="danger"
@click="handleBatchOperate()" @click="handleDeleteOrder(scope.$index, scope.row)"
type="primary" v-show="scope.row.status===4">删除订单</el-button>
size="small"> </template>
确定 </el-table-column>
</el-button> </el-table>
</div>
<!-- 创建一个类名为 "pagination-container" div用于放置分页组件 -->
<div class="pagination-container">
<!-- el-pagination 组件创建分页器设置背景色监听页面大小和当前页变化事件配置分页布局绑定当前页每页显示数量以及可选的每页显示数量选项和总数据条数等属性 -->
<el-pagination
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
layout="total, sizes,prev, pager, next,jumper"
:current-page.sync="listQuery.pageNum"
:page-size="listQuery.pageSize"
:page-sizes="[5,10,15]"
:total="total">
</el-pagination>
</div>
<!-- el-dialog 组件创建一个对话框用于关闭订单时输入备注信息设置标题绑定可见性以及宽度等属性 -->
<el-dialog
title="关闭订单"
:visible.sync="closeOrder.dialogVisible" width="30%">
<span style="vertical-align: top">操作备注</span>
<el-input
style="width: 80%"
type="textarea"
:rows="5"
placeholder="请输入内容"
v-model="closeOrder.content">
</el-input>
<span slot="footer" class="dialog-footer">
<el-button @click="closeOrder.dialogVisible = false"> </el-button>
<el-button type="primary" @click="handleCloseOrderConfirm"> </el-button>
</span>
</el-dialog>
<!-- 使用 logistics-dialog 组件自定义组件双向绑定 visible 属性推测用于控制显示隐藏 -->
<logistics-dialog v-model="logisticsDialogVisible"></logistics-dialog>
</div> </div>
<div class="batch-operate-container">
<el-select
size="small"
v-model="operateType" placeholder="批量操作">
<el-option
v-for="item in operateOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
<el-button
style="margin-left: 20px"
class="search-button"
@click="handleBatchOperate()"
type="primary"
size="small">
确定
</el-button>
</div>
<div class="pagination-container">
<el-pagination
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
layout="total, sizes,prev, pager, next,jumper"
:current-page.sync="listQuery.pageNum"
:page-size="listQuery.pageSize"
:page-sizes="[5,10,15]"
:total="total">
</el-pagination>
</div>
<el-dialog
title="关闭订单"
:visible.sync="closeOrder.dialogVisible" width="30%">
<span style="vertical-align: top">操作备注</span>
<el-input
style="width: 80%"
type="textarea"
:rows="5"
placeholder="请输入内容"
v-model="closeOrder.content">
</el-input>
<span slot="footer" class="dialog-footer">
<el-button @click="closeOrder.dialogVisible = false"> </el-button>
<el-button type="primary" @click="handleCloseOrderConfirm"> </el-button>
</span>
</el-dialog>
<logistics-dialog v-model="logisticsDialogVisible"></logistics-dialog>
</div>
</template> </template>
<script> <script>
// '@/api/order' API import {fetchList,closeOrder,deleteOrder} from '@/api/order'
import {fetchList, closeOrder, deleteOrder} from '@/api/order'; import {formatDate} from '@/utils/date';
// '@/utils/date' formatDate import LogisticsDialog from '@/views/oms/order/components/logisticsDialog';
import {formatDate} from '@/utils/date'; const defaultListQuery = {
// LogisticsDialog pageNum: 1,
import LogisticsDialog from '@/views/oms/order/components/logisticsDialog'; pageSize: 10,
orderSn: null,
// listQuery null receiverKeyword: null,
const defaultListQuery = { status: null,
pageNum: 1, orderType: null,
pageSize: 10, sourceType: null,
orderSn: null, createTime: null,
receiverKeyword: null, };
status: null, export default {
orderType: null, name: "orderList",
sourceType: null, components:{LogisticsDialog},
createTime: null, data() {
}; return {
listQuery: Object.assign({}, defaultListQuery),
// Vue datacreatedmethods listLoading: true,
list: null,
export default { total: null,
name: '组件名称(这里未定义,可自行补充合适名称)', operateType: null,
data() { multipleSelection: [],
return { closeOrder:{
// Object.assign defaultListQuery dialogVisible:false,
listQuery: Object.assign({}, defaultListQuery), content:null,
// orderIds:[]
list: [],
// false
listLoading: false,
// null
operateType: null,
// label value
operateOptions: [],
//
statusOptions: [],
//
orderTypeOptions: [],
//
sourceTypeOptions: [],
//
closeOrder: {
dialogVisible: false,
content: null
},
// false
logisticsDialogVisible: false
}
},
created() {
// fetchList list
// fetchList(this.listQuery).then(response => { this.list = response.data; });
}, },
methods: { statusOptions: [
// fetchList {
handleSearchList() { label: '待付款',
// value: 0
this.listLoading = true; },
fetchList(this.listQuery).then(response => { {
this.list = response.data; label: '待发货',
this.listLoading = false; value: 1
}); },
}, {
// handleSearchList listQuery label: '已发货',
handleResetSearch() { value: 2
// listQuery },
this.listQuery = Object.assign({}, defaultListQuery); {
this.handleSearchList(); label: '已完成',
}, value: 3
// },
handleSelectionChange(selections) { {
// selections label: '已关闭',
}, value: 4
// }
handleViewOrder(index, row) { ],
// orderTypeOptions: [
this.$router.push({path: '/orderDetail', query: {id: row.id}}); {
}, label: '正常订单',
// value: 0
<script> },
// Vue 使 {
export default { label: '秒杀订单',
// Vue value: 1
name: "orderList", }
// 使 LogisticsDialog ],
components: {LogisticsDialog}, sourceTypeOptions: [
data() { {
return { label: 'PC订单',
// Object.assign defaultListQuery value: 0
listQuery: Object.assign({}, defaultListQuery), },
// true {
listLoading: true, label: 'APP订单',
// null value: 1
list: null, }
// null ],
total: null, operateOptions: [
// null {
operateType: null, label: "批量发货",
// value: 1
multipleSelection: [], },
// id {
closeOrder: { label: "关闭订单",
dialogVisible: false, value: 2
content: null, },
orderIds: [] {
}, label: "删除订单",
// label value value: 3
statusOptions: [ }
{ ],
label: '待付款', logisticsDialogVisible:false
value: 0 }
}, },
{ created() {
label: '待发货', this.getList();
value: 1 },
}, filters: {
{ formatCreateTime(time) {
label: '已发货', let date = new Date(time);
value: 2 return formatDate(date, 'yyyy-MM-dd hh:mm:ss')
}, },
{ formatPayType(value) {
label: '已完成', if (value === 1) {
value: 3 return '支付宝';
}, } else if (value === 2) {
{ return '微信';
label: '已关闭', } else {
value: 4 return '未支付';
} }
], },
// formatSourceType(value) {
orderTypeOptions: [ if (value === 1) {
{ return 'APP订单';
label: '正常订单', } else {
value: 0 return 'PC订单';
}, }
{ },
label: '秒杀订单', formatStatus(value) {
value: 1 if (value === 1) {
} return '待发货';
], } else if (value === 2) {
// return '已发货';
sourceTypeOptions: [ } else if (value === 3) {
{ return '已完成';
label: 'PC订单', } else if (value === 4) {
value: 0 return '已关闭';
}, } else if (value === 5) {
{ return '无效订单';
label: 'APP订单', } else {
value: 1 return '待付款';
} }
], },
// },
operateOptions: [ methods: {
{ handleResetSearch() {
label: "批量发货", this.listQuery = Object.assign({}, defaultListQuery);
value: 1 },
}, handleSearchList() {
{ this.listQuery.pageNum = 1;
label: "关闭订单", this.getList();
value: 2 },
}, handleSelectionChange(val){
{ this.multipleSelection = val;
label: "删除订单", },
value: 3 handleViewOrder(index, row){
} this.$router.push({path:'/oms/orderDetail',query:{id:row.id}})
], },
// false handleCloseOrder(index, row){
logisticsDialogVisible: false this.closeOrder.dialogVisible=true;
} this.closeOrder.orderIds=[row.id];
}, },
created() { handleDeliveryOrder(index, row){
// getList let listItem = this.covertOrder(row);
this.getList(); this.$router.push({path:'/oms/deliverOrderList',query:{list:[listItem]}})
}, },
filters: { handleViewLogistics(index, row){
// formatCreateTime 'yyyy-MM-dd hh:mm:ss' this.logisticsDialogVisible=true;
formatCreateTime(time) { },
let date = new Date(time); handleDeleteOrder(index, row){
return formatDate(date, 'yyyy-MM-dd hh:mm:ss') let ids=[];
}, ids.push(row.id);
// 1 ''2 '' '' this.deleteOrder(ids);
formatPayType(value) { },
if (value === 1) { handleBatchOperate(){
return '支付宝'; if(this.multipleSelection==null||this.multipleSelection.length<1){
} else if (value === 2) { this.$message({
return '微信'; message: '请选择要操作的订单',
} else { type: 'warning',
return '未支付'; duration: 1000
} });
}, return;
// 1 'APP' 'PC' }
formatSourceType(value) { if(this.operateType===1){
if (value === 1) { //
return 'APP订单'; let list=[];
} else { for(let i=0;i<this.multipleSelection.length;i++){
return 'PC订单'; if(this.multipleSelection[i].status===1){
} list.push(this.covertOrder(this.multipleSelection[i]));
}, }
// }
formatStatus(value) { if(list.length===0){
if (value === 1) { this.$message({
return '待发货'; message: '选中订单中没有可以发货的订单',
} else if (value === 2) { type: 'warning',
return '已发货'; duration: 1000
} else if (value === 3) { });
return '已完成'; return;
} else if (value === 4) { }
return '已关闭'; this.$router.push({path:'/oms/deliverOrderList',query:{list:list}})
} else if (value === 5) { }else if(this.operateType===2){
return '无效订单'; //
} else { this.closeOrder.orderIds=[];
return '待付款'; for(let i=0;i<this.multipleSelection.length;i++){
} this.closeOrder.orderIds.push(this.multipleSelection[i].id);
}, }
}, this.closeOrder.dialogVisible=true;
methods: { }else if(this.operateType===3){
// listQuery defaultListQuery 便 //
handleResetSearch() { let ids=[];
this.listQuery = Object.assign({}, defaultListQuery); for(let i=0;i<this.multipleSelection.length;i++){
}, ids.push(this.multipleSelection[i].id);
// 1 getList }
handleSearchList() { this.deleteOrder(ids);
this.listQuery.pageNum = 1; }
this.getList(); },
}, handleSizeChange(val){
// val multipleSelection this.listQuery.pageNum = 1;
handleSelectionChange(val) { this.listQuery.pageSize = val;
this.multipleSelection = val; this.getList();
}, },
// Vue this.$router'/oms/orderDetail' id handleCurrentChange(val){
handleViewOrder(index, row) { this.listQuery.pageNum = val;
this.$router.push({path: '/oms/orderDetail', query: {id: row.id}}) this.getList();
}, },
// visible true id closeOrder.orderIds 便使 handleCloseOrderConfirm() {
handleCloseOrder(index, row) { if (this.closeOrder.content == null || this.closeOrder.content === '') {
this.closeOrder.dialogVisible = true; this.$message({
this.closeOrder.orderIds = [row.id]; message: '操作备注不能为空',
}, type: 'warning',
// covertOrder '/oms/deliverOrderList' duration: 1000
handleDeliveryOrder(index, row) { });
let listItem = this.covertOrder(row); return;
this.$router.push({path: '/oms/deliverOrderList', query: {list: [listItem]}}) }
},
// logisticsDialogVisible true
handleViewLogistics(index, row) {
this.logisticsDialogVisible = true;
},
// ids id deleteOrder ids
handleDeleteOrder(index, row) {
let ids = [];
ids.push(row.id);
this.deleteOrder(ids);
},
//
handleBatchOperate() {
if (this.multipleSelection == null || this.multipleSelection.length < 1) {
this.$message({
message: '请选择要操作的订单',
type: 'warning',
duration: 1000
});
return;
}
// 1
if (this.operateType === 1) {
let list = [];
// 1 covertOrder list
for (let i = 0; i < this.multipleSelection.length; i++) {
if (this.multipleSelection[i].status === 1) {
list.push(this.covertOrder(this.multipleSelection[i]));
}
}
// 0
if (list.length === 0) {
this.$message({
message: '选中订单中没有可以发货的订单',
type: 'warning',
duration: 1000
});
return;
}
// '/oms/deliverOrderList'
this.$router.push({path: '/oms/deliverOrderList', query: {list: list}})
} else if (this.operateType === 2) {
// 2
// closeOrder.orderIds id closeOrder.orderIds visible true
this.closeOrder.orderIds = [];
for (let i = 0; i < this.multipleSelection.length; i++) {
this.closeOrder.orderIds.push(this.multipleSelection[i].id);
}
this.closeOrder.dialogVisible = true;
} else if (this.operateType === 3) {
// 3
let ids = [];
// id ids deleteOrder ids
for (let i = 0; i < this.multipleSelection.length; i++) {
ids.push(this.multipleSelection[i].id);
}
this.deleteOrder(ids);
}
},
// 1 getList
handleSizeChange(val) {
this.listQuery.pageNum = 1;
this.listQuery.pageSize = val;
this.getList();
},
// getList
handleCurrentChange(val) {
this.listQuery.pageNum = val;
this.getList();
},
//
handleCloseOrderConfirm() {
if (this.closeOrder.content == null || this.closeOrder.content === '') {
this.$message({
message: '操作备注不能为空',
type: 'warning',
duration: 1000
});
return;
}
//
}
}
}
</script>
let params = new URLSearchParams(); let params = new URLSearchParams();
params.append('ids', this.closeOrder.orderIds); params.append('ids', this.closeOrder.orderIds);
params.append('note', this.closeOrder.content); params.append('note', this.closeOrder.content);

File diff suppressed because it is too large Load Diff

@ -1,163 +1,127 @@
<template> <template> 
<!-- 使用 el-card 组件创建一个卡片式的容器设置类名为 "form-container"并通过 shadow="never" 属性取消卡片的阴影效果 --> <el-card class="form-container" shadow="never">
<el-card class="form-container" shadow="never"> <el-form :model="orderSetting"
<!-- el-form 组件用于创建表单它绑定了名为 "orderSetting" 的数据模型设置了表单的引用名称为 "orderSettingForm"同时指定了表单验证规则 "rules"以及标签的宽度为 150px --> ref="orderSettingForm"
<el-form :model="orderSetting" :rules="rules"
ref="orderSettingForm" label-width="150px">
:rules="rules" <el-form-item label="秒杀订单超过:" prop="flashOrderOvertime">
label-width="150px"> <el-input v-model="orderSetting.flashOrderOvertime" class="input-width">
<!-- el-form-item 组件用于定义表单中的每一个表单项此处是针对 "秒杀订单超过" 这一设置项的表单项通过 prop 属性指定了验证对应的字段名 --> <template slot="append"></template>
<el-form-item label="秒杀订单超过:" prop="flashOrderOvertime"> </el-input>
<!-- el-input 组件创建一个输入框通过 v-model 指令双向绑定了 "orderSetting.flashOrderOvertime" 数据意味着用户在输入框中输入的值会实时更新到对应的数据属性中同时设置了类名 "input-width" 用于控制输入框宽度 --> <span class="note-margin">未付款订单自动关闭</span>
<el-input v-model="orderSetting.flashOrderOvertime" class="input-width"> </el-form-item>
<!-- 使用 slot="append" 插槽在输入框后面添加一个单位文本 "分"用于提示用户输入的时间单位 --> <el-form-item label="正常订单超过:" prop="normalOrderOvertime">
<template slot="append"></template> <el-input v-model="orderSetting.normalOrderOvertime" class="input-width">
</el-input> <template slot="append"></template>
<!-- 一个普通的 <span> 标签用于显示一段提示文本设置了类名 "note-margin" 来控制其左边距提示内容为未付款时订单自动关闭的相关说明 --> </el-input>
<span class="note-margin">未付款订单自动关闭</span> <span class="note-margin">未付款订单自动关闭</span>
</el-form-item> </el-form-item>
<!-- 与上面类似的表单项针对 "正常订单超过" 的设置同样有输入框及对应的提示信息 --> <el-form-item label="发货超过:" prop="confirmOvertime">
<el-form-item label="正常订单超过:" prop="normalOrderOvertime"> <el-input v-model="orderSetting.confirmOvertime" class="input-width">
<el-input v-model="orderSetting.normalOrderOvertime" class="input-width"> <template slot="append"></template>
<template slot="append"></template> </el-input>
</el-input> <span class="note-margin">未收货订单自动完成</span>
<span class="note-margin">未付款订单自动关闭</span> </el-form-item>
</el-form-item> <el-form-item label="订单完成超过:" prop="finishOvertime">
<!-- 针对 "发货超过" 的表单项输入框用于输入天数后面跟着相应的提示文本 --> <el-input v-model="orderSetting.finishOvertime" class="input-width">
<el-form-item label="发货超过:" prop="confirmOvertime"> <template slot="append"></template>
<el-input v-model="orderSetting.confirmOvertime" class="input-width"> </el-input>
<template slot="append"></template> <span class="note-margin">自动结束交易不能申请售后</span>
</el-input> </el-form-item>
<span class="note-margin">未收货订单自动完成</span> <el-form-item label="订单完成超过:" prop="commentOvertime">
</el-form-item> <el-input v-model="orderSetting.commentOvertime" class="input-width">
<!-- 针对 "订单完成超过" 的表单项此处有重复的标签名但应是不同业务场景下的时间设置同样有输入框和对应的提示内容 --> <template slot="append"></template>
<el-form-item label="订单完成超过:" prop="finishOvertime"> </el-input>
<el-input v-model="orderSetting.finishOvertime" class="input-width"> <span class="note-margin">自动五星好评</span>
<template slot="append"></template> </el-form-item>
</el-input> <el-form-item>
<span class="note-margin">自动结束交易不能申请售后</span> <el-button
</el-form-item> @click="confirm('orderSettingForm')"
<!-- 另一个针对 "订单完成超过" 的表单项可能对应不同的业务逻辑如自动五星好评相关的时间设置同样具备输入框和提示文本 --> type="primary">提交</el-button>
<el-form-item label="订单完成超过:" prop="commentOvertime"> </el-form-item>
<el-input v-model="orderSetting.commentOvertime" class="input-width"> </el-form>
<template slot="append"></template> </el-card>
</el-input>
<span class="note-margin">自动五星好评</span>
</el-form-item>
<!-- 定义一个表单项内部放置一个 el-button 按钮通过 @click 指令绑定了 "confirm('orderSettingForm')" 方法即点击按钮时会调用名为 "confirm" 的方法并传入 "orderSettingForm" 参数按钮类型设置为 "primary"文本显示为 "提交" -->
<el-form-item>
<el-button
@click="confirm('orderSettingForm')"
type="primary">提交</el-button>
</el-form-item>
</el-form>
</el-card>
</template> </template>
<script> <script>
// '@/api/orderSetting' "getOrderSetting" "updateOrderSetting" import {getOrderSetting,updateOrderSetting} from '@/api/orderSetting';
import {getOrderSetting, updateOrderSetting} from '@/api/orderSetting'; const defaultOrderSetting = {
id: null,
// "defaultOrderSetting" 0 null flashOrderOvertime: 0,
const defaultOrderSetting = { normalOrderOvertime: 0,
id: null, confirmOvertime: 0,
flashOrderOvertime: 0, finishOvertime: 0,
normalOrderOvertime: 0, commentOvertime: 0
confirmOvertime: 0, };
finishOvertime: 0, const checkTime = (rule, value, callback) => {
commentOvertime: 0 if (!value) {
}; return callback(new Error('时间不能为空'));
}
// "checkTime" 使 console.log("checkTime",value);
const checkTime = (rule, value, callback) => { let intValue = parseInt(value);
// callback Error if (!Number.isInteger(intValue)) {
if (!value) { return callback(new Error('请输入数字值'));
return callback(new Error('时间不能为空')); }
} callback();
console.log("checkTime", value); };
// parseInt export default {
let intValue = parseInt(value); name: 'orderSetting',
// callback Error data() {
if (!Number.isInteger(intValue)) { return {
return callback(new Error('请输入数字值')); orderSetting: Object.assign({}, defaultOrderSetting),
rules: {
flashOrderOvertime:{validator: checkTime, trigger: 'blur' },
normalOrderOvertime:{validator: checkTime, trigger: 'blur' },
confirmOvertime: {validator: checkTime, trigger: 'blur' },
finishOvertime: {validator: checkTime, trigger: 'blur' },
commentOvertime:{validator: checkTime, trigger: 'blur' }
} }
// callback }
callback(); },
}; created(){
this.getDetail();
// Vue },
export default { methods:{
// Vue "orderSetting" confirm(formName){
name: 'orderSetting', this.$refs[formName].validate((valid) => {
data() { if (valid) {
return { this.$confirm('是否要提交修改?', '提示', {
// "orderSetting" Object.assign "defaultOrderSetting" confirmButtonText: '确定',
orderSetting: Object.assign({}, defaultOrderSetting), cancelButtonText: '取消',
// 使 "checkTime" 'blur' type: 'warning'
rules: { }).then(() => {
flashOrderOvertime: {validator: checkTime, trigger: 'blur'}, updateOrderSetting(1,this.orderSetting).then(response=>{
normalOrderOvertime: {validator: checkTime, trigger: 'blur'}, this.$message({
confirmOvertime: {validator: checkTime, trigger: 'blur'}, type: 'success',
finishOvertime: {validator: checkTime, trigger: 'blur'}, message: '提交成功!',
commentOvertime: {validator: checkTime, trigger: 'blur'} duration:1000
}
}
},
created() {
// "getDetail"
this.getDetail();
},
methods: {
// "confirm" "formName"
confirm(formName) {
// this.$refs[formName] validate "valid"
this.$refs[formName].validate((valid) => {
// "valid" true
if (valid) {
// 使 $confirm "warning"
this.$confirm('是否要提交修改?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
// "" "updateOrderSetting" 1 "orderSetting"
// then 使 $message "!" 1000 1
updateOrderSetting(1, this.orderSetting).then(response => {
this.$message({
type: 'success',
message: '提交成功!',
duration: 1000
});
})
});
} else {
// "valid" false使 $message ""
this.$message({
message: '提交参数不合法',
type: 'warning'
});
return false;
}
}); });
}, })
// "getDetail" });
getDetail() { } else {
// "getOrderSetting" 1 then "orderSetting" 便 this.$message({
getOrderSetting(1).then(response => { message: '提交参数不合法',
this.orderSetting = response.data; type: 'warning'
}) });
} return false;
} }
});
},
getDetail(){
getOrderSetting(1).then(response=>{
this.orderSetting=response.data;
})
}
} }
}
</script> </script>
<style scoped> <style scoped>
/* 定义类名为 "input-width" 的样式规则,设置元素的宽度为父元素宽度的 50%,这个类名应用到了输入框上,用于控制输入框在表单中的宽度占比,使其看起来更美观、布局更合理 */ .input-width {
.input-width { width: 50%;
width: 50%; }
}
/* 定义类名为 "note-margin" 的样式规则,设置元素的左边距为 15 像素,这个类名应用到了提示文本的 <span> 标签上,用于控制提示文本与输入框之间的距离,使其有合适的间隔,视觉效果更好 */ .note-margin {
.note-margin { margin-left: 15px;
margin-left: 15px; }
}
</style> </style>

@ -1,19 +1,14 @@
<template> <template> 
<!-- 使用 BrandDetail 组件并传递 is-edit 属性为 false表示新增品牌模式 --> <brand-detail :is-edit='false'></brand-detail>
<brand-detail :is-edit="false"></brand-detail>
</template> </template>
<script> <script>
import BrandDetail from "./components/BrandDetail"; // BrandDetail import BrandDetail from './components/BrandDetail'
export default {
export default { name: 'addBrand',
name: "addBrand", // components: { BrandDetail }
components: { }
BrandDetail, // BrandDetail
},
};
</script> </script>
<style> <style>
/* 样式部分:目前为空,可根据需求添加页面样式 */
</style> </style>

@ -1,168 +1,145 @@
<template> <template> 
<!-- 页面卡片容器 -->
<el-card class="form-container" shadow="never"> <el-card class="form-container" shadow="never">
<!-- 表单定义 --> <el-form :model="brand" :rules="rules" ref="brandFrom" label-width="150px">
<el-form :model="brand" :rules="rules" ref="brandForm" label-width="150px">
<!-- 品牌名称输入框 -->
<el-form-item label="品牌名称:" prop="name"> <el-form-item label="品牌名称:" prop="name">
<el-input v-model="brand.name"></el-input> <el-input v-model="brand.name"></el-input>
</el-form-item> </el-form-item>
<!-- 品牌首字母输入框 -->
<el-form-item label="品牌首字母:"> <el-form-item label="品牌首字母:">
<el-input v-model="brand.firstLetter"></el-input> <el-input v-model="brand.firstLetter"></el-input>
</el-form-item> </el-form-item>
<!-- 品牌LOGO上传组件 -->
<el-form-item label="品牌LOGO" prop="logo"> <el-form-item label="品牌LOGO" prop="logo">
<single-upload v-model="brand.logo"></single-upload> <single-upload v-model="brand.logo"></single-upload>
</el-form-item> </el-form-item>
<!-- 品牌专区大图上传组件 -->
<el-form-item label="品牌专区大图:"> <el-form-item label="品牌专区大图:">
<single-upload v-model="brand.bigPic"></single-upload> <single-upload v-model="brand.bigPic"></single-upload>
</el-form-item> </el-form-item>
<!-- 品牌故事文本域 -->
<el-form-item label="品牌故事:"> <el-form-item label="品牌故事:">
<el-input <el-input
placeholder="请输入内容" placeholder="请输入内容"
type="textarea" type="textarea"
v-model="brand.brandStory" v-model="brand.brandStory"
:autosize="true" :autosize="true"></el-input>
></el-input>
</el-form-item> </el-form-item>
<!-- 排序输入框数字类型 -->
<el-form-item label="排序:" prop="sort"> <el-form-item label="排序:" prop="sort">
<el-input v-model.number="brand.sort"></el-input> <el-input v-model.number="brand.sort"></el-input>
</el-form-item> </el-form-item>
<!-- 是否显示单选按钮组 -->
<el-form-item label="是否显示:"> <el-form-item label="是否显示:">
<el-radio-group v-model="brand.showStatus"> <el-radio-group v-model="brand.showStatus">
<el-radio :label="1"></el-radio> <el-radio :label="1"></el-radio>
<el-radio :label="0"></el-radio> <el-radio :label="0"></el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<!-- 品牌制造商单选按钮组 -->
<el-form-item label="品牌制造商:"> <el-form-item label="品牌制造商:">
<el-radio-group v-model="brand.factoryStatus"> <el-radio-group v-model="brand.factoryStatus">
<el-radio :label="1"></el-radio> <el-radio :label="1"></el-radio>
<el-radio :label="0"></el-radio> <el-radio :label="0"></el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<!-- 提交和重置按钮 -->
<el-form-item> <el-form-item>
<el-button type="primary" @click="onSubmit('brandForm')"></el-button> <el-button type="primary" @click="onSubmit('brandFrom')"></el-button>
<el-button v-if="!isEdit" @click="resetForm('brandForm')"></el-button> <el-button v-if="!isEdit" @click="resetForm('brandFrom')"></el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</el-card> </el-card>
</template> </template>
<script> <script>
import { createBrand, getBrand, updateBrand } from "@/api/brand"; import {createBrand, getBrand, updateBrand} from '@/api/brand'
import SingleUpload from "@/components/Upload/singleUpload"; import SingleUpload from '@/components/Upload/singleUpload'
const defaultBrand={
export default { bigPic: '',
name: "BrandDetail", // brandStory: '',
components: { factoryStatus: 0,
SingleUpload, // firstLetter: '',
}, logo: '',
props: { name: '',
// showStatus: 0,
isEdit: { sort: 0
type: Boolean, };
default: false, export default {
name: 'BrandDetail',
components:{SingleUpload},
props: {
isEdit: {
type: Boolean,
default: false
}
}, },
}, data() {
data() { return {
// brand:Object.assign({}, defaultBrand),
const defaultBrand = { rules: {
bigPic: "", // name: [
brandStory: "", // {required: true, message: '请输入品牌名称', trigger: 'blur'},
factoryStatus: 0, // {min: 2, max: 140, message: '长度在 2 到 140 个字符', trigger: 'blur'}
firstLetter: "", // ],
logo: "", // LOGO logo: [
name: "", // {required: true, message: '请输入品牌logo', trigger: 'blur'}
showStatus: 0, // ],
sort: 0, // sort: [
}; {type: 'number', message: '排序必须为数字'}
],
return {
brand: Object.assign({}, defaultBrand), //
rules: {
name: [
{ required: true, message: "请输入品牌名称", trigger: "blur" },
{ min: 2, max: 140, message: "长度在 2 到 140 个字符", trigger: "blur" },
],
logo: [{ required: true, message: "请输入品牌logo", trigger: "blur" }],
sort: [{ type: "number", message: "排序必须为数字" }],
},
};
},
created() {
//
if (this.isEdit) {
getBrand(this.$route.query.id).then((response) => {
this.brand = response.data; //
});
} else {
this.brand = Object.assign({}, this.defaultBrand); //
}
},
methods: {
//
onSubmit(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
this.$confirm("是否提交数据", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
}).then(() => {
if (this.isEdit) {
//
updateBrand(this.$route.query.id, this.brand).then(() => {
this.$refs[formName].resetFields();
this.$message({
message: "修改成功",
type: "success",
duration: 1000,
});
this.$router.back();
});
} else {
//
createBrand(this.brand).then(() => {
this.$refs[formName].resetFields();
this.brand = Object.assign({}, this.defaultBrand);
this.$message({
message: "提交成功",
type: "success",
duration: 1000,
});
});
}
});
} else {
this.$message({
message: "验证失败",
type: "error",
duration: 1000,
});
return false;
} }
}); }
}, },
// created() {
resetForm(formName) { if (this.isEdit) {
this.$refs[formName].resetFields(); getBrand(this.$route.query.id).then(response => {
this.brand = Object.assign({}, this.defaultBrand); this.brand = response.data;
});
}else{
this.brand = Object.assign({},defaultBrand);
}
}, },
}, methods: {
}; onSubmit(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
this.$confirm('是否提交数据', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
if (this.isEdit) {
updateBrand(this.$route.query.id, this.brand).then(response => {
this.$refs[formName].resetFields();
this.$message({
message: '修改成功',
type: 'success',
duration:1000
});
this.$router.back();
});
} else {
createBrand(this.brand).then(response => {
this.$refs[formName].resetFields();
this.brand = Object.assign({},defaultBrand);
this.$message({
message: '提交成功',
type: 'success',
duration:1000
});
});
}
});
} else {
this.$message({
message: '验证失败',
type: 'error',
duration:1000
});
return false;
}
});
},
resetForm(formName) {
this.$refs[formName].resetFields();
this.brand = Object.assign({},defaultBrand);
}
}
}
</script> </script>
<style>
</style>

@ -1,39 +1,28 @@
<template> <template> 
<!-- 页面容器 -->
<div class="app-container"> <div class="app-container">
<!-- 筛选搜索区域 -->
<el-card class="filter-container" shadow="never"> <el-card class="filter-container" shadow="never">
<div> <div>
<!-- 搜索标题和按钮 --> <i class="el-icon-search"></i>
<i class="el-icon-search"></i> <span>筛选搜索</span>
<span>筛选搜索</span> <el-button
<el-button style="float: right"
style="float: right" @click="searchBrandList()"
@click="searchBrandList()" type="primary"
type="primary" size="small">
size="small"> 查询结果
查询结果 </el-button>
</el-button> </div>
</div> <div style="margin-top: 15px">
<!-- 筛选条件 --> <el-form :inline="true" :model="listQuery" size="small" label-width="140px">
<div style="margin-top: 15px"> <el-form-item label="输入搜索:">
<el-form :inline="true" :model="listQuery" size="small" label-width="140px"> <el-input style="width: 203px" v-model="listQuery.keyword" placeholder="品牌名称/关键字"></el-input>
<el-form-item label="输入搜索:"> </el-form-item>
<el-input </el-form>
style="width: 203px" </div>
v-model="listQuery.keyword"
placeholder="品牌名称/关键字">
</el-input>
</el-form-item>
</el-form>
</div>
</el-card> </el-card>
<!-- 操作区域 -->
<el-card class="operate-container" shadow="never"> <el-card class="operate-container" shadow="never">
<i class="el-icon-tickets"></i> <i class="el-icon-tickets"></i>
<span>数据列表</span> <span>数据列表</span>
<!-- 添加品牌按钮 -->
<el-button <el-button
class="btn-add" class="btn-add"
@click="addBrand()" @click="addBrand()"
@ -41,35 +30,26 @@
添加 添加
</el-button> </el-button>
</el-card> </el-card>
<!-- 数据表格区域 -->
<div class="table-container"> <div class="table-container">
<el-table <el-table ref="brandTable"
ref="brandTable" :data="list"
:data="list" style="width: 100%"
style="width: 100%" @selection-change="handleSelectionChange"
@selection-change="handleSelectionChange" v-loading="listLoading"
v-loading="listLoading" border>
border>
<!-- 表格列多选 -->
<el-table-column type="selection" width="60" align="center"></el-table-column> <el-table-column type="selection" width="60" align="center"></el-table-column>
<!-- 表格列编号 -->
<el-table-column label="编号" width="100" align="center"> <el-table-column label="编号" width="100" align="center">
<template slot-scope="scope">{{ scope.row.id }}</template> <template slot-scope="scope">{{scope.row.id}}</template>
</el-table-column> </el-table-column>
<!-- 表格列品牌名称 -->
<el-table-column label="品牌名称" align="center"> <el-table-column label="品牌名称" align="center">
<template slot-scope="scope">{{ scope.row.name }}</template> <template slot-scope="scope">{{scope.row.name}}</template>
</el-table-column> </el-table-column>
<!-- 表格列品牌首字母 -->
<el-table-column label="品牌首字母" width="100" align="center"> <el-table-column label="品牌首字母" width="100" align="center">
<template slot-scope="scope">{{ scope.row.firstLetter }}</template> <template slot-scope="scope">{{scope.row.firstLetter}}</template>
</el-table-column> </el-table-column>
<!-- 表格列排序 -->
<el-table-column label="排序" width="100" align="center"> <el-table-column label="排序" width="100" align="center">
<template slot-scope="scope">{{ scope.row.sort }}</template> <template slot-scope="scope">{{scope.row.sort}}</template>
</el-table-column> </el-table-column>
<!-- 表格列品牌制造商开关操作 -->
<el-table-column label="品牌制造商" width="100" align="center"> <el-table-column label="品牌制造商" width="100" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-switch <el-switch
@ -80,7 +60,6 @@
</el-switch> </el-switch>
</template> </template>
</el-table-column> </el-table-column>
<!-- 表格列是否显示开关操作 -->
<el-table-column label="是否显示" width="100" align="center"> <el-table-column label="是否显示" width="100" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-switch <el-switch
@ -91,42 +70,41 @@
</el-switch> </el-switch>
</template> </template>
</el-table-column> </el-table-column>
<!-- 表格列商品和评价相关信息 -->
<el-table-column label="相关" width="220" align="center"> <el-table-column label="相关" width="220" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<span>商品</span> <span>商品</span>
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
@click="getProductList(scope.$index, scope.row)"> @click="getProductList(scope.$index, scope.row)">100
100
</el-button> </el-button>
<span>评价</span> <span>评价</span>
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
@click="getProductCommentList(scope.$index, scope.row)"> @click="getProductCommentList(scope.$index, scope.row)">1000
1000
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
<!-- 表格列操作按钮编辑和删除 -->
<el-table-column label="操作" width="200" align="center"> <el-table-column label="操作" width="200" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button size="mini" @click="handleUpdate(scope.$index, scope.row)"> <el-button
编辑 size="mini"
@click="handleUpdate(scope.$index, scope.row)">编辑
</el-button> </el-button>
<el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)"> <el-button
删除 size="mini"
type="danger"
@click="handleDelete(scope.$index, scope.row)">删除
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</div> </div>
<!-- 批量操作区域 -->
<div class="batch-operate-container"> <div class="batch-operate-container">
<el-select size="small" v-model="operateType" placeholder="批量操作"> <el-select
size="small"
v-model="operateType" placeholder="批量操作">
<el-option <el-option
v-for="item in operates" v-for="item in operates"
:key="item.value" :key="item.value"
@ -136,102 +114,196 @@
</el-select> </el-select>
<el-button <el-button
style="margin-left: 20px" style="margin-left: 20px"
class="search-button"
@click="handleBatchOperate()" @click="handleBatchOperate()"
type="primary" type="primary"
size="small"> size="small">
确定 确定
</el-button> </el-button>
</div> </div>
<!-- 分页组件 -->
<div class="pagination-container"> <div class="pagination-container">
<el-pagination <el-pagination
background background
@size-change="handleSizeChange" @size-change="handleSizeChange"
@current-change="handleCurrentChange" @current-change="handleCurrentChange"
layout="total, sizes, prev, pager, next, jumper" layout="total, sizes,prev, pager, next,jumper"
:page-size="listQuery.pageSize" :page-size="listQuery.pageSize"
:page-sizes="[5, 10, 15]" :page-sizes="[5,10,15]"
:current-page.sync="listQuery.pageNum" :current-page.sync="listQuery.pageNum"
:total="total"> :total="total">
</el-pagination> </el-pagination>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { fetchList, updateShowStatus, updateFactoryStatus, deleteBrand } from "@/api/brand"; import {fetchList, updateShowStatus, updateFactoryStatus, deleteBrand} from '@/api/brand'
export default { export default {
name: "brandList", // name: 'brandList',
data() { data() {
return { return {
operates: [ operates: [
{ label: "显示品牌", value: "showBrand" }, {
{ label: "隐藏品牌", value: "hideBrand" }, label: "显示品牌",
], value: "showBrand"
operateType: null, // },
listQuery: { {
keyword: null, label: "隐藏品牌",
pageNum: 1, value: "hideBrand"
pageSize: 10, }
}, ],
list: null, // operateType: null,
total: null, // listQuery: {
listLoading: true, // keyword: null,
multipleSelection: [], // pageNum: 1,
}; pageSize: 10
}, },
created() { list: null,
this.getList(); // total: null,
}, listLoading: true,
methods: { multipleSelection: []
// }
getList() {
this.listLoading = true;
fetchList(this.listQuery).then((response) => {
this.list = response.data.list;
this.total = response.data.total;
this.listLoading = false;
});
}, },
// created() {
searchBrandList() {
this.listQuery.pageNum = 1;
this.getList(); this.getList();
}, },
// methods: {
handleBatchOperate() { getList() {
console.log(this.multipleSelection); this.listLoading = true;
}, fetchList(this.listQuery).then(response => {
// this.listLoading = false;
addBrand() { this.list = response.data.list;
this.$router.push({ path: "/pms/addBrand" }); this.total = response.data.total;
}, this.totalPage = response.data.totalPage;
// this.pageSize = response.data.pageSize;
handleUpdate(index, row) { });
this.$router.push({ path: "/pms/updateBrand", query: { id: row.id } }); },
}, handleSelectionChange(val) {
// this.multipleSelection = val;
handleDelete(index, row) { },
deleteBrand(row.id).then(() => { handleUpdate(index, row) {
this.$message({ message: "删除成功", type: "success" }); this.$router.push({path: '/pms/updateBrand', query: {id: row.id}})
},
handleDelete(index, row) {
this.$confirm('是否要删除该品牌', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
deleteBrand(row.id).then(response => {
this.$message({
message: '删除成功',
type: 'success',
duration: 1000
});
this.getList();
});
});
},
getProductList(index, row) {
console.log(index, row);
},
getProductCommentList(index, row) {
console.log(index, row);
},
handleFactoryStatusChange(index, row) {
var data = new URLSearchParams();
data.append("ids", row.id);
data.append("factoryStatus", row.factoryStatus);
updateFactoryStatus(data).then(response => {
this.$message({
message: '修改成功',
type: 'success',
duration: 1000
});
}).catch(error => {
if (row.factoryStatus === 0) {
row.factoryStatus = 1;
} else {
row.factoryStatus = 0;
}
});
},
handleShowStatusChange(index, row) {
let data = new URLSearchParams();
;
data.append("ids", row.id);
data.append("showStatus", row.showStatus);
updateShowStatus(data).then(response => {
this.$message({
message: '修改成功',
type: 'success',
duration: 1000
});
}).catch(error => {
if (row.showStatus === 0) {
row.showStatus = 1;
} else {
row.showStatus = 0;
}
});
},
handleSizeChange(val) {
this.listQuery.pageNum = 1;
this.listQuery.pageSize = val;
this.getList(); this.getList();
}); },
}, handleCurrentChange(val) {
// this.listQuery.pageNum = val;
handleSizeChange(val) { this.getList();
this.listQuery.pageSize = val; },
this.getList(); searchBrandList() {
}, this.listQuery.pageNum = 1;
handleCurrentChange(val) { this.getList();
this.listQuery.pageNum = val; },
this.getList(); handleBatchOperate() {
}, console.log(this.multipleSelection);
}, if (this.multipleSelection < 1) {
}; this.$message({
message: '请选择一条记录',
type: 'warning',
duration: 1000
});
return;
}
let showStatus = 0;
if (this.operateType === 'showBrand') {
showStatus = 1;
} else if (this.operateType === 'hideBrand') {
showStatus = 0;
} else {
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);
}
let data = new URLSearchParams();
data.append("ids", ids);
data.append("showStatus", showStatus);
updateShowStatus(data).then(response => {
this.getList();
this.$message({
message: '修改成功',
type: 'success',
duration: 1000
});
});
},
addBrand() {
this.$router.push({path: '/pms/addBrand'})
}
}
}
</script> </script>
<style rel="stylesheet/scss" lang="scss" scoped>
<style lang="scss" scoped>
/* 自定义样式 */
</style> </style>

@ -1,19 +1,14 @@
<template> <template> 
<!-- 使用 BrandDetail 组件并传递 is-edit 属性为 true表示编辑品牌模式 --> <brand-detail :is-edit='true'></brand-detail>
<brand-detail :is-edit="true"></brand-detail>
</template> </template>
<script> <script>
import BrandDetail from './components/BrandDetail'; // BrandDetail import BrandDetail from './components/BrandDetail'
export default {
export default { name: 'updateBrand',
name: 'updateBrand', // 使 components: { BrandDetail }
components: { }
BrandDetail, // BrandDetail 使使
},
};
</script> </script>
<style> <style>
/* 样式部分:暂无样式定义,保留扩展空间 */
</style> </style>

@ -1,19 +1,12 @@
<template> <template> 
<!-- 添加商品页面的根组件 --> <product-detail :is-edit='false'></product-detail>
<product-detail :is-edit="false"></product-detail>
</template> </template>
<script> <script>
import ProductDetail from './components/ProductDetail'; // ProductDetail import ProductDetail from './components/ProductDetail'
export default {
export default { name: 'addProduct',
name: 'addProduct', // components: { ProductDetail }
components: { }
ProductDetail, // ProductDetail
},
};
</script> </script>
<style> <style>
/* 样式部分:暂无样式定义,根据需求可添加 */
</style> </style>

@ -1,15 +1,10 @@
<template> <template>
<!-- 整个表单容器 -->
<div style="margin-top: 50px"> <div style="margin-top: 50px">
<!-- 表单内容区域 -->
<el-form :model="value" ref="productAttrForm" label-width="120px" class="form-inner-container" size="small"> <el-form :model="value" ref="productAttrForm" label-width="120px" class="form-inner-container" size="small">
<!-- 属性类型选择 -->
<el-form-item label="属性类型:"> <el-form-item label="属性类型:">
<el-select <el-select v-model="value.productAttributeCategoryId"
v-model="value.productAttributeCategoryId" placeholder="请选择属性类型"
placeholder="请选择属性类型" @change="handleProductAttrChange">
@change="handleProductAttrChange">
<el-option <el-option
v-for="item in productAttributeCategoryOptions" v-for="item in productAttributeCategoryOptions"
:key="item.value" :key="item.value"
@ -18,98 +13,136 @@
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<!-- 商品规格 -->
<el-form-item label="商品规格:"> <el-form-item label="商品规格:">
<el-card shadow="never" class="cardBg"> <el-card shadow="never" class="cardBg">
<div v-for="(productAttr, idx) in selectProductAttr" :key="idx"> <div v-for="(productAttr,idx) in selectProductAttr">
<!-- 显示属性名称 --> {{productAttr.name}}
{{ productAttr.name }} <el-checkbox-group v-if="productAttr.handAddStatus===0" v-model="selectProductAttr[idx].values">
<el-checkbox v-for="item in getInputListArr(productAttr.inputList)" :label="item" :key="item"
<!-- handAddStatus=0 显示多选框 --> class="littleMarginLeft"></el-checkbox>
<el-checkbox-group v-if="productAttr.handAddStatus === 0" v-model="selectProductAttr[idx].values">
<el-checkbox
v-for="item in getInputListArr(productAttr.inputList)"
:label="item"
:key="item"
class="littleMarginLeft"></el-checkbox>
</el-checkbox-group> </el-checkbox-group>
<!-- 手动添加的属性值 -->
<div v-else> <div v-else>
<el-checkbox-group v-model="selectProductAttr[idx].values"> <el-checkbox-group v-model="selectProductAttr[idx].values">
<div <div v-for="(item,index) in selectProductAttr[idx].options" style="display: inline-block"
v-for="(item, index) in selectProductAttr[idx].options" class="littleMarginLeft">
:key="index" <el-checkbox :label="item" :key="item"></el-checkbox>
style="display: inline-block" class="littleMarginLeft"> <el-button type="text" class="littleMarginLeft" @click="handleRemoveProductAttrValue(idx,index)">
<el-checkbox :label="item"></el-checkbox> </el-button>
<el-button type="text" class="littleMarginLeft" @click="handleRemoveProductAttrValue(idx, index)">删除</el-button>
</div> </div>
</el-checkbox-group> </el-checkbox-group>
<!-- 添加新属性值 --> <el-input v-model="addProductAttrValue" style="width: 160px;margin-left: 10px" clearable></el-input>
<el-input v-model="addProductAttrValue" style="width: 160px; margin-left: 10px" clearable></el-input>
<el-button class="littleMarginLeft" @click="handleAddProductAttrValue(idx)"></el-button> <el-button class="littleMarginLeft" @click="handleAddProductAttrValue(idx)"></el-button>
</div> </div>
</div> </div>
</el-card> </el-card>
<el-table style="width: 100%;margin-top: 20px"
<!-- SKU 列表表格 --> :data="value.skuStockList"
<el-table style="width: 100%; margin-top: 20px" :data="value.skuStockList" border> border>
<el-table-column <el-table-column
v-for="(item, index) in selectProductAttr" v-for="(item,index) in selectProductAttr"
:label="item.name" :label="item.name"
:key="item.id" :key="item.id"
align="center"> align="center">
<template slot-scope="scope"> <template slot-scope="scope">
{{ getProductSkuSp(scope.row, index) }} {{getProductSkuSp(scope.row,index)}}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column
<!-- 其他表格列销售价格促销价格库存等 --> label="销售价格"
<el-table-column label="销售价格" width="100" align="center"> width="100"
align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-input v-model="scope.row.price"></el-input> <el-input v-model="scope.row.price"></el-input>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="促销价格" width="100" align="center"> <el-table-column
label="促销价格"
width="100"
align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-input v-model="scope.row.promotionPrice"></el-input> <el-input v-model="scope.row.promotionPrice"></el-input>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="商品库存" width="80" align="center"> <el-table-column
label="商品库存"
width="80"
align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-input v-model="scope.row.stock"></el-input> <el-input v-model="scope.row.stock"></el-input>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="库存预警值" width="80" align="center"> <el-table-column
label="库存预警值"
width="80"
align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-input v-model="scope.row.lowStock"></el-input> <el-input v-model="scope.row.lowStock"></el-input>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="SKU编号" width="160" align="center"> <el-table-column
label="SKU编号"
width="160"
align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-input v-model="scope.row.skuCode"></el-input> <el-input v-model="scope.row.skuCode"></el-input>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" width="80" align="center"> <el-table-column
label="操作"
width="80"
align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="text" @click="handleRemoveProductSku(scope.$index)"></el-button> <el-button
type="text"
@click="handleRemoveProductSku(scope.$index, scope.row)">删除
</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<el-button
<!-- 操作按钮刷新同步价格同步库存 --> type="primary"
<el-button type="primary" style="margin-top: 20px" @click="handleRefreshProductSkuList"></el-button> style="margin-top: 20px"
<el-button type="primary" style="margin-top: 20px" @click="handleSyncProductSkuPrice"></el-button> @click="handleRefreshProductSkuList">刷新列表
<el-button type="primary" style="margin-top: 20px" @click="handleSyncProductSkuStock"></el-button> </el-button>
<el-button
type="primary"
style="margin-top: 20px"
@click="handleSyncProductSkuPrice">同步价格
</el-button>
<el-button
type="primary"
style="margin-top: 20px"
@click="handleSyncProductSkuStock">同步库存
</el-button>
</el-form-item>
<el-form-item label="属性图片:" v-if="hasAttrPic">
<el-card shadow="never" class="cardBg">
<div v-for="(item,index) in selectProductAttrPics">
<span>{{item.name}}:</span>
<single-upload v-model="item.pic"
style="width: 300px;display: inline-block;margin-left: 10px"></single-upload>
</div>
</el-card>
</el-form-item>
<el-form-item label="商品参数:">
<el-card shadow="never" class="cardBg">
<div v-for="(item,index) in selectProductParam" :class="{littleMarginTop:index!==0}">
<div class="paramInputLabel">{{item.name}}:</div>
<el-select v-if="item.inputType===1" class="paramInput" v-model="selectProductParam[index].value">
<el-option
v-for="item in getParamInputList(item.inputList)"
:key="item"
:label="item"
:value="item">
</el-option>
</el-select>
<el-input v-else class="paramInput" v-model="selectProductParam[index].value"></el-input>
</div>
</el-card>
</el-form-item> </el-form-item>
<!-- 商品相册 -->
<el-form-item label="商品相册:"> <el-form-item label="商品相册:">
<multi-upload v-model="selectProductPics"></multi-upload> <multi-upload v-model="selectProductPics"></multi-upload>
</el-form-item> </el-form-item>
<!-- 商品详情编辑器 -->
<el-form-item label="商品详情:"> <el-form-item label="商品详情:">
<el-tabs v-model="activeHtmlName" type="card"> <el-tabs v-model="activeHtmlName" type="card">
<el-tab-pane label="电脑端详情" name="pc"> <el-tab-pane label="电脑端详情" name="pc">
@ -120,8 +153,6 @@
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</el-form-item> </el-form-item>
<!-- 表单操作按钮 -->
<el-form-item style="text-align: center"> <el-form-item style="text-align: center">
<el-button size="medium" @click="handlePrev"></el-button> <el-button size="medium" @click="handlePrev"></el-button>
<el-button type="primary" size="medium" @click="handleNext"></el-button> <el-button type="primary" size="medium" @click="handleNext"></el-button>
@ -131,74 +162,479 @@
</template> </template>
<script> <script>
import { fetchList as fetchProductAttrCateList } from '@/api/productAttrCate'; import {fetchList as fetchProductAttrCateList} from '@/api/productAttrCate'
import { fetchList as fetchProductAttrList } from '@/api/productAttr'; import {fetchList as fetchProductAttrList} from '@/api/productAttr'
import SingleUpload from '@/components/Upload/singleUpload'; import SingleUpload from '@/components/Upload/singleUpload'
import MultiUpload from '@/components/Upload/multiUpload'; import MultiUpload from '@/components/Upload/multiUpload'
import Tinymce from '@/components/Tinymce'; import Tinymce from '@/components/Tinymce'
export default { export default {
name: 'ProductAttrDetail', // name: "ProductAttrDetail",
components: { SingleUpload, MultiUpload, Tinymce }, // components: {SingleUpload, MultiUpload, Tinymce},
props: { props: {
value: Object, // value: Object,
isEdit: { type: Boolean, default: false } // isEdit: {
}, type: Boolean,
data() { default: false
return { }
productAttributeCategoryOptions: [], //
selectProductAttr: [], //
addProductAttrValue: '', //
activeHtmlName: 'pc' //
};
},
created() {
this.getProductAttrCateList(); //
},
methods: {
//
getProductAttrCateList() {
fetchProductAttrCateList({ pageNum: 1, pageSize: 100 }).then(response => {
this.productAttributeCategoryOptions = response.data.list.map(item => ({
label: item.name,
value: item.id
}));
});
}, },
// data() {
handleProductAttrChange(value) { return {
this.getProductAttrList(0, value); // //
this.getProductAttrList(1, value); // hasEditCreated:false,
//
productAttributeCategoryOptions: [],
//
selectProductAttr: [],
//
selectProductParam: [],
//
selectProductAttrPics: [],
//
addProductAttrValue: '',
//
activeHtmlName: 'pc'
}
}, },
// computed: {
handleAddProductAttrValue(idx) { //
if (this.addProductAttrValue) { hasAttrPic() {
this.selectProductAttr[idx].options.push(this.addProductAttrValue); if (this.selectProductAttrPics.length < 1) {
this.addProductAttrValue = ''; return false;
}
return true;
},
//
productId(){
return this.value.id;
},
//
selectProductPics:{
get:function () {
let pics=[];
if(this.value.pic===undefined||this.value.pic==null||this.value.pic===''){
return pics;
}
pics.push(this.value.pic);
if(this.value.albumPics===undefined||this.value.albumPics==null||this.value.albumPics===''){
return pics;
}
let albumPics = this.value.albumPics.split(',');
for(let i=0;i<albumPics.length;i++){
pics.push(albumPics[i]);
}
return pics;
},
set:function (newValue) {
if (newValue == null || newValue.length === 0) {
this.value.pic = null;
this.value.albumPics = null;
} else {
this.value.pic = newValue[0];
this.value.albumPics = '';
if (newValue.length > 1) {
for (let i = 1; i < newValue.length; i++) {
this.value.albumPics += newValue[i];
if (i !== newValue.length - 1) {
this.value.albumPics += ',';
}
}
}
}
}
} }
}, },
// SKU created() {
handleRemoveProductSku(index) { this.getProductAttrCateList();
this.value.skuStockList.splice(index, 1);
}, },
// watch: {
handlePrev() { productId:function (newValue) {
this.$emit('prevStep'); if(!this.isEdit)return;
if(this.hasEditCreated)return;
if(newValue===undefined||newValue==null||newValue===0)return;
this.handleEditCreated();
}
}, },
// methods: {
handleNext() { handleEditCreated() {
this.$emit('nextStep'); //id
if(this.value.productAttributeCategoryId!=null){
this.handleProductAttrChange(this.value.productAttributeCategoryId);
}
this.hasEditCreated=true;
},
getProductAttrCateList() {
let param = {pageNum: 1, pageSize: 100};
fetchProductAttrCateList(param).then(response => {
this.productAttributeCategoryOptions = [];
let list = response.data.list;
for (let i = 0; i < list.length; i++) {
this.productAttributeCategoryOptions.push({label: list[i].name, value: list[i].id});
}
});
},
getProductAttrList(type, cid) {
let param = {pageNum: 1, pageSize: 100, type: type};
fetchProductAttrList(cid, param).then(response => {
let list = response.data.list;
if (type === 0) {
this.selectProductAttr = [];
for (let i = 0; i < list.length; i++) {
let options = [];
let values = [];
if (this.isEdit) {
if (list[i].handAddStatus === 1) {
//
options = this.getEditAttrOptions(list[i].id);
}
//
values = this.getEditAttrValues(i);
}
this.selectProductAttr.push({
id: list[i].id,
name: list[i].name,
handAddStatus: list[i].handAddStatus,
inputList: list[i].inputList,
values: values,
options: options
});
}
if(this.isEdit){
//
this.refreshProductAttrPics();
}
} else {
this.selectProductParam = [];
for (let i = 0; i < list.length; i++) {
let value=null;
if(this.isEdit){
//
value= this.getEditParamValue(list[i].id);
}
this.selectProductParam.push({
id: list[i].id,
name: list[i].name,
value: value,
inputType: list[i].inputType,
inputList: list[i].inputList
});
}
}
});
},
//
getEditAttrOptions(id) {
let options = [];
for (let i = 0; i < this.value.productAttributeValueList.length; i++) {
let attrValue = this.value.productAttributeValueList[i];
if (attrValue.productAttributeId === id) {
let strArr = attrValue.value.split(',');
for (let j = 0; j < strArr.length; j++) {
options.push(strArr[j]);
}
break;
}
}
return options;
},
//
getEditAttrValues(index) {
let values = new Set();
if (index === 0) {
for (let i = 0; i < this.value.skuStockList.length; i++) {
let sku = this.value.skuStockList[i];
let spData = JSON.parse(sku.spData);
if (spData!= null && spData.length>=1) {
values.add(spData[0].value);
}
}
} else if (index === 1) {
for (let i = 0; i < this.value.skuStockList.length; i++) {
let sku = this.value.skuStockList[i];
let spData = JSON.parse(sku.spData);
if (spData!= null && spData.length>=2) {
values.add(spData[1].value);
}
}
} else {
for (let i = 0; i < this.value.skuStockList.length; i++) {
let sku = this.value.skuStockList[i];
let spData = JSON.parse(sku.spData);
if (spData!= null && spData.length>=3) {
values.add(spData[2].value);
}
}
}
return Array.from(values);
},
//
getEditParamValue(id){
for(let i=0;i<this.value.productAttributeValueList.length;i++){
if(id===this.value.productAttributeValueList[i].productAttributeId){
return this.value.productAttributeValueList[i].value;
}
}
},
handleProductAttrChange(value) {
this.getProductAttrList(0, value);
this.getProductAttrList(1, value);
},
getInputListArr(inputList) {
return inputList.split(',');
},
handleAddProductAttrValue(idx) {
let options = this.selectProductAttr[idx].options;
if (this.addProductAttrValue == null || this.addProductAttrValue == '') {
this.$message({
message: '属性值不能为空',
type: 'warning',
duration: 1000
});
return
}
if (options.indexOf(this.addProductAttrValue) !== -1) {
this.$message({
message: '属性值不能重复',
type: 'warning',
duration: 1000
});
return;
}
this.selectProductAttr[idx].options.push(this.addProductAttrValue);
this.addProductAttrValue = null;
},
handleRemoveProductAttrValue(idx, index) {
this.selectProductAttr[idx].options.splice(index, 1);
},
getProductSkuSp(row, index) {
let spData = JSON.parse(row.spData);
if(spData!=null&&index<spData.length){
return spData[index].value;
}else{
return null;
}
},
handleRefreshProductSkuList() {
this.$confirm('刷新列表将导致sku信息重新生成是否要刷新', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.refreshProductAttrPics();
this.refreshProductSkuList();
});
},
handleSyncProductSkuPrice(){
this.$confirm('将同步第一个sku的价格到所有sku,是否继续', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
if(this.value.skuStockList!==null&&this.value.skuStockList.length>0){
let tempSkuList = [];
tempSkuList = tempSkuList.concat(tempSkuList,this.value.skuStockList);
let price=this.value.skuStockList[0].price;
for(let i=0;i<tempSkuList.length;i++){
tempSkuList[i].price=price;
}
this.value.skuStockList=[];
this.value.skuStockList=this.value.skuStockList.concat(this.value.skuStockList,tempSkuList);
}
});
},
handleSyncProductSkuStock(){
this.$confirm('将同步第一个sku的库存到所有sku,是否继续', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
if(this.value.skuStockList!==null&&this.value.skuStockList.length>0){
let tempSkuList = [];
tempSkuList = tempSkuList.concat(tempSkuList,this.value.skuStockList);
let stock=this.value.skuStockList[0].stock;
let lowStock=this.value.skuStockList[0].lowStock;
for(let i=0;i<tempSkuList.length;i++){
tempSkuList[i].stock=stock;
tempSkuList[i].lowStock=lowStock;
}
this.value.skuStockList=[];
this.value.skuStockList=this.value.skuStockList.concat(this.value.skuStockList,tempSkuList);
}
});
},
refreshProductSkuList() {
this.value.skuStockList = [];
let skuList = this.value.skuStockList;
//
if (this.selectProductAttr.length === 1) {
let attr = this.selectProductAttr[0];
for (let i = 0; i < attr.values.length; i++) {
skuList.push({
spData: JSON.stringify([{key:attr.name,value:attr.values[i]}])
});
}
} else if (this.selectProductAttr.length === 2) {
let attr0 = this.selectProductAttr[0];
let attr1 = this.selectProductAttr[1];
for (let i = 0; i < attr0.values.length; i++) {
if (attr1.values.length === 0) {
skuList.push({
spData: JSON.stringify([{key:attr0.name,value:attr0.values[i]}])
});
continue;
}
for (let j = 0; j < attr1.values.length; j++) {
let spData = [];
spData.push({key:attr0.name,value:attr0.values[i]});
spData.push({key:attr1.name,value:attr1.values[j]});
skuList.push({
spData: JSON.stringify(spData)
});
}
}
} else {
let attr0 = this.selectProductAttr[0];
let attr1 = this.selectProductAttr[1];
let attr2 = this.selectProductAttr[2];
for (let i = 0; i < attr0.values.length; i++) {
if (attr1.values.length === 0) {
skuList.push({
spData: JSON.stringify([{key:attr0.name,value:attr0.values[i]}])
});
continue;
}
for (let j = 0; j < attr1.values.length; j++) {
if (attr2.values.length === 0) {
let spData = [];
spData.push({key:attr0.name,value:attr0.values[i]});
spData.push({key:attr1.name,value:attr1.values[j]});
skuList.push({
spData: JSON.stringify(spData)
});
continue;
}
for (let k = 0; k < attr2.values.length; k++) {
let spData = [];
spData.push({key:attr0.name,value:attr0.values[i]});
spData.push({key:attr1.name,value:attr1.values[j]});
spData.push({key:attr2.name,value:attr2.values[k]});
skuList.push({
spData: JSON.stringify(spData)
});
}
}
}
}
},
refreshProductAttrPics() {
this.selectProductAttrPics = [];
if (this.selectProductAttr.length >= 1) {
let values = this.selectProductAttr[0].values;
for (let i = 0; i < values.length; i++) {
let pic=null;
if(this.isEdit){
//
pic=this.getProductSkuPic(values[i]);
}
this.selectProductAttrPics.push({name: values[i], pic: pic})
}
}
},
//
getProductSkuPic(name){
for(let i=0;i<this.value.skuStockList.length;i++){
let spData = JSON.parse(this.value.skuStockList[i].spData);
if(name===spData[0].value){
return this.value.skuStockList[i].pic;
}
}
return null;
},
//
mergeProductAttrValue() {
this.value.productAttributeValueList = [];
for (let i = 0; i < this.selectProductAttr.length; i++) {
let attr = this.selectProductAttr[i];
if (attr.handAddStatus === 1 && attr.options != null && attr.options.length > 0) {
this.value.productAttributeValueList.push({
productAttributeId: attr.id,
value: this.getOptionStr(attr.options)
});
}
}
for (let i = 0; i < this.selectProductParam.length; i++) {
let param = this.selectProductParam[i];
this.value.productAttributeValueList.push({
productAttributeId: param.id,
value: param.value
});
}
},
//
mergeProductAttrPics() {
for (let i = 0; i < this.selectProductAttrPics.length; i++) {
for (let j = 0; j < this.value.skuStockList.length; j++) {
let spData = JSON.parse(this.value.skuStockList[j].spData);
if (spData[0].value === this.selectProductAttrPics[i].name) {
this.value.skuStockList[j].pic = this.selectProductAttrPics[i].pic;
}
}
}
},
getOptionStr(arr) {
let str = '';
for (let i = 0; i < arr.length; i++) {
str += arr[i];
if (i != arr.length - 1) {
str += ',';
}
}
return str;
},
handleRemoveProductSku(index, row) {
let list = this.value.skuStockList;
if (list.length === 1) {
list.pop();
} else {
list.splice(index, 1);
}
},
getParamInputList(inputList) {
return inputList.split(',');
},
handlePrev() {
this.$emit('prevStep')
},
handleNext() {
this.mergeProductAttrValue();
this.mergeProductAttrPics();
this.$emit('nextStep')
}
} }
} }
};
</script> </script>
<style scoped> <style scoped>
.littleMarginLeft { .littleMarginLeft {
margin-left: 10px; margin-left: 10px;
} }
.littleMarginTop {
margin-top: 10px;
}
.paramInput {
width: 250px;
}
.cardBg { .paramInputLabel {
background: #f8f9fc; display: inline-block;
} width: 100px;
text-align: right;
padding-right: 10px
}
.cardBg {
background: #F8F9FC;
}
</style> </style>

@ -1,23 +1,17 @@
<template> <template> 
<!-- 商品详情表单容器 -->
<el-card class="form-container" shadow="never"> <el-card class="form-container" shadow="never">
<!-- 步骤条显示当前所处的步骤 -->
<el-steps :active="active" finish-status="success" align-center> <el-steps :active="active" finish-status="success" align-center>
<el-step title="填写商品信息"></el-step> <el-step title="填写商品信息"></el-step>
<el-step title="填写商品促销"></el-step> <el-step title="填写商品促销"></el-step>
<el-step title="填写商品属性"></el-step> <el-step title="填写商品属性"></el-step>
<el-step title="选择商品关联"></el-step> <el-step title="选择商品关联"></el-step>
</el-steps> </el-steps>
<!-- 商品基本信息组件 -->
<product-info-detail <product-info-detail
v-show="showStatus[0]" v-show="showStatus[0]"
v-model="productParam" v-model="productParam"
:is-edit="isEdit" :is-edit="isEdit"
@nextStep="nextStep"> @nextStep="nextStep">
</product-info-detail> </product-info-detail>
<!-- 商品促销信息组件 -->
<product-sale-detail <product-sale-detail
v-show="showStatus[1]" v-show="showStatus[1]"
v-model="productParam" v-model="productParam"
@ -25,8 +19,6 @@
@nextStep="nextStep" @nextStep="nextStep"
@prevStep="prevStep"> @prevStep="prevStep">
</product-sale-detail> </product-sale-detail>
<!-- 商品属性组件 -->
<product-attr-detail <product-attr-detail
v-show="showStatus[2]" v-show="showStatus[2]"
v-model="productParam" v-model="productParam"
@ -34,8 +26,6 @@
@nextStep="nextStep" @nextStep="nextStep"
@prevStep="prevStep"> @prevStep="prevStep">
</product-attr-detail> </product-attr-detail>
<!-- 商品关联信息组件 -->
<product-relation-detail <product-relation-detail
v-show="showStatus[3]" v-show="showStatus[3]"
v-model="productParam" v-model="productParam"
@ -45,140 +35,154 @@
</product-relation-detail> </product-relation-detail>
</el-card> </el-card>
</template> </template>
<script> <script>
import ProductInfoDetail from './ProductInfoDetail'; // import ProductInfoDetail from './ProductInfoDetail';
import ProductSaleDetail from './ProductSaleDetail'; // import ProductSaleDetail from './ProductSaleDetail';
import ProductAttrDetail from './ProductAttrDetail'; // import ProductAttrDetail from './ProductAttrDetail';
import ProductRelationDetail from './ProductRelationDetail'; // import ProductRelationDetail from './ProductRelationDetail';
import { createProduct, getProduct, updateProduct } from '@/api/product'; // API import {createProduct,getProduct,updateProduct} from '@/api/product';
// const defaultProductParam = {
const defaultProductParam = { albumPics: '',
albumPics: '', // brandId: null,
brandId: null, // ID brandName: '',
brandName: '', // deleteStatus: 0,
deleteStatus: 0, // description: '',
description: '', // detailDesc: '',
detailDesc: '', // detailHtml: '',
detailHtml: '', // detailMobileHtml: '',
detailMobileHtml: '', // detailTitle: '',
detailTitle: '', // feightTemplateId: 0,
feightTemplateId: 0, // ID flashPromotionCount: 0,
flashPromotionCount: 0, // flashPromotionId: 0,
flashPromotionPrice: 0, // flashPromotionPrice: 0,
giftPoint: 0, // flashPromotionSort: 0,
giftGrowth: 0, // giftPoint: 0,
keywords: '', // giftGrowth: 0,
lowStock: 0, // keywords: '',
name: '', // lowStock: 0,
newStatus: 0, // name: '',
originalPrice: 0, // newStatus: 0,
price: 0, // note: '',
skuStockList: [], // SKU originalPrice: 0,
productAttributeValueList: [], // pic: '',
promotionStartTime: '', // //{memberLevelId: 0,memberPrice: 0,memberLevelName: null}
promotionEndTime: '', // memberPriceList: [],
publishStatus: 0, // //
sale: 0, // productFullReductionList: [{fullPrice: 0, reducePrice: 0}],
stock: 0, // //
}; productLadderList: [{count: 0,discount: 0,price: 0}],
previewStatus: 0,
export default { price: 0,
name: 'ProductDetail', // productAttributeCategoryId: null,
components: { //{productAttributeId: 0, value: ''}
ProductInfoDetail, productAttributeValueList: [],
ProductSaleDetail, //sku{lowStock: 0, pic: '', price: 0, sale: 0, skuCode: '', spData: '', stock: 0}
ProductAttrDetail, skuStockList: [],
ProductRelationDetail, //{subjectId: 0}
}, subjectProductRelationList: [],
props: { //{prefrenceAreaId: 0}
isEdit: { prefrenceAreaProductRelationList: [],
type: Boolean, productCategoryId: null,
default: false, // productCategoryName: '',
}, productSn: '',
}, promotionEndTime: '',
data() { promotionPerLimit: 0,
return { promotionPrice: null,
active: 0, // promotionStartTime: '',
productParam: Object.assign({}, defaultProductParam), // promotionType: 0,
showStatus: [true, false, false, false], // publishStatus: 0,
}; recommandStatus: 0,
}, sale: 0,
created() { serviceIds: '',
// sort: 0,
if (this.isEdit) { stock: 0,
getProduct(this.$route.query.id).then((response) => { subTitle: '',
this.productParam = response.data; // unit: '',
}); usePointLimit: 0,
} verifyStatus: 0,
}, weight: 0
methods: { };
// export default {
hideAll() { name: 'ProductDetail',
for (let i = 0; i < this.showStatus.length; i++) { components: {ProductInfoDetail, ProductSaleDetail, ProductAttrDetail, ProductRelationDetail},
this.showStatus[i] = false; props: {
isEdit: {
type: Boolean,
default: false
} }
}, },
// data() {
prevStep() { return {
if (this.active > 0) { active: 0,
this.active--; // 退 productParam: Object.assign({}, defaultProductParam),
this.hideAll(); // showStatus: [true, false, false, false]
this.showStatus[this.active] = true; //
} }
}, },
// created(){
nextStep() { if(this.isEdit){
if (this.active < this.showStatus.length - 1) { getProduct(this.$route.query.id).then(response=>{
this.active++; // this.productParam=response.data;
this.hideAll(); // });
this.showStatus[this.active] = true; //
} }
}, },
// methods: {
finishCommit(isEdit) { hideAll() {
this.$confirm('是否要提交该产品?', '提示', { for (let i = 0; i < this.showStatus.length; i++) {
confirmButtonText: '确定', this.showStatus[i] = false;
cancelButtonText: '取消', }
type: 'warning', },
}).then(() => { prevStep() {
if (isEdit) { if (this.active > 0 && this.active < this.showStatus.length) {
// this.active--;
updateProduct(this.$route.query.id, this.productParam).then(() => { this.hideAll();
this.$message({ this.showStatus[this.active] = true;
type: 'success', }
message: '修改成功', },
duration: 1000, nextStep() {
if (this.active < this.showStatus.length - 1) {
this.active++;
this.hideAll();
this.showStatus[this.active] = true;
}
},
finishCommit(isEdit) {
this.$confirm('是否要提交该产品', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
if(isEdit){
updateProduct(this.$route.query.id,this.productParam).then(response=>{
this.$message({
type: 'success',
message: '提交成功',
duration:1000
});
this.$router.back();
}); });
this.$router.back(); // }else{
}); createProduct(this.productParam).then(response=>{
} else { this.$message({
// type: 'success',
createProduct(this.productParam).then(() => { message: '提交成功',
this.$message({ duration:1000
type: 'success', });
message: '提交成功', location.reload();
duration: 1000,
}); });
location.reload(); // }
}); })
} }
}); }
}, }
},
};
</script> </script>
<style> <style>
/* 容器样式 */ .form-container {
.form-container { width: 960px;
width: 960px; }
margin: 0 auto; .form-inner-container {
} width: 800px;
}
.form-inner-container {
width: 800px;
margin: 0 auto;
}
</style> </style>

@ -1,247 +1,200 @@
<template> <template>
<!-- 商品基本信息表单 -->
<div style="margin-top: 50px"> <div style="margin-top: 50px">
<el-form <el-form :model="value" :rules="rules" ref="productInfoForm" label-width="120px" class="form-inner-container" size="small">
:model="value"
:rules="rules"
ref="productInfoForm"
label-width="120px"
class="form-inner-container"
size="small"
>
<!-- 商品分类选择 -->
<el-form-item label="商品分类:" prop="productCategoryId"> <el-form-item label="商品分类:" prop="productCategoryId">
<el-cascader <el-cascader
v-model="selectProductCateValue" v-model="selectProductCateValue"
:options="productCateOptions" :options="productCateOptions">
></el-cascader> </el-cascader>
</el-form-item> </el-form-item>
<!-- 商品名称输入框 -->
<el-form-item label="商品名称:" prop="name"> <el-form-item label="商品名称:" prop="name">
<el-input v-model="value.name"></el-input> <el-input v-model="value.name"></el-input>
</el-form-item> </el-form-item>
<!-- 商品副标题输入框 -->
<el-form-item label="副标题:" prop="subTitle"> <el-form-item label="副标题:" prop="subTitle">
<el-input v-model="value.subTitle"></el-input> <el-input v-model="value.subTitle"></el-input>
</el-form-item> </el-form-item>
<!-- 商品品牌选择框 -->
<el-form-item label="商品品牌:" prop="brandId"> <el-form-item label="商品品牌:" prop="brandId">
<el-select <el-select
v-model="value.brandId" v-model="value.brandId"
@change="handleBrandChange" @change="handleBrandChange"
placeholder="请选择品牌" placeholder="请选择品牌">
>
<el-option <el-option
v-for="item in brandOptions" v-for="item in brandOptions"
:key="item.value" :key="item.value"
:label="item.label" :label="item.label"
:value="item.value" :value="item.value">
></el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<!-- 商品介绍文本域 -->
<el-form-item label="商品介绍:"> <el-form-item label="商品介绍:">
<el-input <el-input
:autoSize="true" :autoSize="true"
v-model="value.description" v-model="value.description"
type="textarea" type="textarea"
placeholder="请输入内容" placeholder="请输入内容"></el-input>
></el-input>
</el-form-item> </el-form-item>
<!-- 商品货号 -->
<el-form-item label="商品货号:"> <el-form-item label="商品货号:">
<el-input v-model="value.productSn"></el-input> <el-input v-model="value.productSn"></el-input>
</el-form-item> </el-form-item>
<!-- 商品售价 -->
<el-form-item label="商品售价:"> <el-form-item label="商品售价:">
<el-input v-model="value.price"></el-input> <el-input v-model="value.price"></el-input>
</el-form-item> </el-form-item>
<!-- 市场价 -->
<el-form-item label="市场价:"> <el-form-item label="市场价:">
<el-input v-model="value.originalPrice"></el-input> <el-input v-model="value.originalPrice"></el-input>
</el-form-item> </el-form-item>
<!-- 商品库存 -->
<el-form-item label="商品库存:"> <el-form-item label="商品库存:">
<el-input v-model="value.stock"></el-input> <el-input v-model="value.stock"></el-input>
</el-form-item> </el-form-item>
<!-- 计量单位 -->
<el-form-item label="计量单位:"> <el-form-item label="计量单位:">
<el-input v-model="value.unit"></el-input> <el-input v-model="value.unit"></el-input>
</el-form-item> </el-form-item>
<!-- 商品重量 -->
<el-form-item label="商品重量:"> <el-form-item label="商品重量:">
<el-input v-model="value.weight" style="width: 300px"></el-input> <el-input v-model="value.weight" style="width: 300px"></el-input>
<span style="margin-left: 20px"></span> <span style="margin-left: 20px"></span>
</el-form-item> </el-form-item>
<!-- 排序 -->
<el-form-item label="排序"> <el-form-item label="排序">
<el-input v-model="value.sort"></el-input> <el-input v-model="value.sort"></el-input>
</el-form-item> </el-form-item>
<!-- 下一步按钮 -->
<el-form-item style="text-align: center"> <el-form-item style="text-align: center">
<el-button <el-button type="primary" size="medium" @click="handleNext('productInfoForm')"></el-button>
type="primary"
size="medium"
@click="handleNext('productInfoForm')"
>
下一步填写商品促销
</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
</template> </template>
<script> <script>
import { fetchListWithChildren } from '@/api/productCate'; // import {fetchListWithChildren} from '@/api/productCate'
import { fetchList as fetchBrandList } from '@/api/brand'; // import {fetchList as fetchBrandList} from '@/api/brand'
import {getProduct} from '@/api/product';
export default {
name: 'ProductInfoDetail', // export default {
props: { name: "ProductInfoDetail",
value: Object, // props: {
isEdit: { value: Object,
type: Boolean, // isEdit: {
default: false, type: Boolean,
default: false
}
}, },
}, data() {
data() { return {
return { hasEditCreated:false,
hasEditCreated: false, // //
selectProductCateValue: [], // selectProductCateValue: [],
productCateOptions: [], // productCateOptions: [],
brandOptions: [], // brandOptions: [],
rules: { rules: {
name: [ name: [
{ required: true, message: '请输入商品名称', trigger: 'blur' }, {required: true, message: '请输入商品名称', trigger: 'blur'},
{ min: 2, max: 140, message: '长度在 2 到 140 个字符', trigger: 'blur' }, {min: 2, max: 140, message: '长度在 2 到 140 个字符', trigger: 'blur'}
], ],
subTitle: [{ required: true, message: '请输入商品副标题', trigger: 'blur' }], subTitle: [{required: true, message: '请输入商品副标题', trigger: 'blur'}],
productCategoryId: [ productCategoryId: [{required: true, message: '请选择商品分类', trigger: 'blur'}],
{ required: true, message: '请选择商品分类', trigger: 'blur' }, brandId: [{required: true, message: '请选择商品品牌', trigger: 'blur'}],
], description: [{required: true, message: '请输入商品介绍', trigger: 'blur'}],
brandId: [{ required: true, message: '请选择商品品牌', trigger: 'blur' }], requiredProp: [{required: true, message: '该项为必填项', trigger: 'blur'}]
description: [{ required: true, message: '请输入商品介绍', trigger: 'blur' }], }
}, };
};
},
created() {
//
this.getProductCateList();
this.getBrandList();
},
computed: {
// ID
productId() {
return this.value.id;
}, },
}, created() {
watch: { this.getProductCateList();
productId(newValue) { this.getBrandList();
if (!this.isEdit || this.hasEditCreated || !newValue) return;
this.handleEditCreated();
}, },
selectProductCateValue(newValue) { computed:{
// ID //
if (newValue && newValue.length === 2) { productId(){
this.value.productCategoryId = newValue[1]; return this.value.id;
this.value.productCategoryName = this.getCateNameById(this.value.productCategoryId);
} else {
this.value.productCategoryId = null;
this.value.productCategoryName = null;
} }
}, },
}, watch: {
methods: { productId:function(newValue){
// if(!this.isEdit)return;
handleEditCreated() { if(this.hasEditCreated)return;
if (this.value.productCategoryId != null) { if(newValue===undefined||newValue==null||newValue===0)return;
this.selectProductCateValue = [ this.handleEditCreated();
this.value.cateParentId, },
this.value.productCategoryId, selectProductCateValue: function (newValue) {
]; if (newValue != null && newValue.length === 2) {
this.value.productCategoryId = newValue[1];
this.value.productCategoryName= this.getCateNameById(this.value.productCategoryId);
} else {
this.value.productCategoryId = null;
this.value.productCategoryName=null;
}
} }
this.hasEditCreated = true;
},
//
getProductCateList() {
fetchListWithChildren().then((response) => {
let list = response.data;
this.productCateOptions = list.map((item) => ({
label: item.name,
value: item.id,
children: item.children?.map((child) => ({
label: child.name,
value: child.id,
})),
}));
});
}, },
methods: {
// //
getBrandList() { handleEditCreated(){
fetchBrandList({ pageNum: 1, pageSize: 100 }).then((response) => { if(this.value.productCategoryId!=null){
this.brandOptions = response.data.list.map((item) => ({ this.selectProductCateValue.push(this.value.cateParentId);
label: item.name, this.selectProductCateValue.push(this.value.productCategoryId);
value: item.id, }
})); this.hasEditCreated=true;
}); },
}, getProductCateList() {
fetchListWithChildren().then(response => {
// ID let list = response.data;
getCateNameById(id) { this.productCateOptions = [];
for (const parent of this.productCateOptions) { for (let i = 0; i < list.length; i++) {
for (const child of parent.children || []) { let children = [];
if (child.value === id) { if (list[i].children != null && list[i].children.length > 0) {
return child.label; 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});
}
});
},
getBrandList() {
fetchBrandList({pageNum: 1, pageSize: 100}).then(response => {
this.brandOptions = [];
let brandList = response.data.list;
for (let i = 0; i < brandList.length; i++) {
this.brandOptions.push({label: brandList[i].name, value: brandList[i].id});
}
});
},
getCateNameById(id){
let name=null;
for(let i=0;i<this.productCateOptions.length;i++){
for(let j=0;j<this.productCateOptions[i].children.length;j++){
if(this.productCateOptions[i].children[j].value===id){
name=this.productCateOptions[i].children[j].label;
return name;
}
} }
} }
} return name;
return null; },
}, handleNext(formName){
this.$refs[formName].validate((valid) => {
// if (valid) {
handleNext(formName) { this.$emit('nextStep');
this.$refs[formName].validate((valid) => { } else {
if (valid) { this.$message({
this.$emit('nextStep'); // message: '验证失败',
} else { type: 'error',
this.$message({ duration:1000
message: '验证失败', });
type: 'error', return false;
duration: 1000, }
}); });
},
handleBrandChange(val) {
let brandName = '';
for (let i = 0; i < this.brandOptions.length; i++) {
if (this.brandOptions[i].value === val) {
brandName = this.brandOptions[i].label;
break;
}
} }
}); this.value.brandName = brandName;
}, }
}
// }
handleBrandChange(val) {
const selectedBrand = this.brandOptions.find(
(item) => item.value === val
);
this.value.brandName = selectedBrand ? selectedBrand.label : '';
},
},
};
</script> </script>
<style scoped> <style scoped>
/* 表单样式居中 */
.form-inner-container {
max-width: 600px;
margin: 0 auto;
}
</style> </style>

@ -1,14 +1,10 @@
<template> <template>
<!-- 商品关联表单 -->
<div style="margin-top: 50px"> <div style="margin-top: 50px">
<el-form <el-form :model="value"
:model="value" ref="productRelationForm"
ref="productRelationForm" label-width="120px"
label-width="120px" class="form-inner-container"
class="form-inner-container" size="small">
size="small"
>
<!-- 关联专题 Transfer 组件 -->
<el-form-item label="关联专题:"> <el-form-item label="关联专题:">
<el-transfer <el-transfer
style="display: inline-block" style="display: inline-block"
@ -17,11 +13,9 @@
filter-placeholder="请输入专题名称" filter-placeholder="请输入专题名称"
v-model="selectSubject" v-model="selectSubject"
:titles="subjectTitles" :titles="subjectTitles"
:data="subjectList" :data="subjectList">
></el-transfer> </el-transfer>
</el-form-item> </el-form-item>
<!-- 关联优选 Transfer 组件 -->
<el-form-item label="关联优选:"> <el-form-item label="关联优选:">
<el-transfer <el-transfer
style="display: inline-block" style="display: inline-block"
@ -30,166 +24,122 @@
filter-placeholder="请输入优选名称" filter-placeholder="请输入优选名称"
v-model="selectPrefrenceArea" v-model="selectPrefrenceArea"
:titles="prefrenceAreaTitles" :titles="prefrenceAreaTitles"
:data="prefrenceAreaList" :data="prefrenceAreaList">
></el-transfer> </el-transfer>
</el-form-item> </el-form-item>
<!-- 操作按钮 -->
<el-form-item style="text-align: center"> <el-form-item style="text-align: center">
<el-button size="medium" @click="handlePrev"></el-button> <el-button size="medium" @click="handlePrev"></el-button>
<el-button type="primary" size="medium" @click="handleFinishCommit"> <el-button type="primary" size="medium" @click="handleFinishCommit"></el-button>
完成提交商品
</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
</template> </template>
<script> <script>
import { fetchListAll as fetchSubjectList } from '@/api/subject'; // API import {fetchListAll as fetchSubjectList} from '@/api/subject'
import { fetchList as fetchPrefrenceAreaList } from '@/api/prefrenceArea'; // API import {fetchList as fetchPrefrenceAreaList} from '@/api/prefrenceArea'
export default { export default {
name: 'ProductRelationDetail', // name: "ProductRelationDetail",
props: { props: {
value: Object, // value: Object,
isEdit: { isEdit: {
type: Boolean, // type: Boolean,
default: false, default: false
}
},
data() {
return {
//
subjectList: [],
//
subjectTitles: ['待选择', '已选择'],
//
prefrenceAreaList: [],
//
prefrenceAreaTitles: ['待选择', '已选择']
};
},
created() {
this.getSubjectList();
this.getPrefrenceAreaList();
}, },
}, computed:{
data() { //
return { selectSubject:{
subjectList: [], // get:function () {
subjectTitles: ['待选择', '已选择'], // Transfer let subjects =[];
prefrenceAreaList: [], // if(this.value.subjectProductRelationList==null||this.value.subjectProductRelationList.length<=0){
prefrenceAreaTitles: ['待选择', '已选择'], // Transfer return subjects;
}; }
}, for(let i=0;i<this.value.subjectProductRelationList.length;i++){
created() { subjects.push(this.value.subjectProductRelationList[i].subjectId);
this.getSubjectList(); // }
this.getPrefrenceAreaList(); //
},
computed: {
/**
* 选中的专题通过 v-model computed 绑定选中的专题数据
*/
selectSubject: {
get() {
let subjects = [];
if (
this.value.subjectProductRelationList == null ||
this.value.subjectProductRelationList.length <= 0
) {
return subjects; return subjects;
} },
// ID set:function (newValue) {
for (let i = 0; i < this.value.subjectProductRelationList.length; i++) { this.value.subjectProductRelationList=[];
subjects.push(this.value.subjectProductRelationList[i].subjectId); for(let i=0;i<newValue.length;i++){
} this.value.subjectProductRelationList.push({subjectId:newValue[i]});
return subjects; }
},
set(newValue) {
//
this.value.subjectProductRelationList = [];
for (let i = 0; i < newValue.length; i++) {
this.value.subjectProductRelationList.push({ subjectId: newValue[i] });
} }
}, },
}, //
selectPrefrenceArea:{
/** get:function () {
* 选中的优选通过 v-model computed 绑定选中的优选数据 let prefrenceAreas =[];
*/ if(this.value.prefrenceAreaProductRelationList==null||this.value.prefrenceAreaProductRelationList.length<=0){
selectPrefrenceArea: { return prefrenceAreas;
get() { }
let prefrenceAreas = []; for(let i=0;i<this.value.prefrenceAreaProductRelationList.length;i++){
if ( prefrenceAreas.push(this.value.prefrenceAreaProductRelationList[i].prefrenceAreaId);
this.value.prefrenceAreaProductRelationList == null || }
this.value.prefrenceAreaProductRelationList.length <= 0
) {
return prefrenceAreas; return prefrenceAreas;
},
set:function (newValue) {
this.value.prefrenceAreaProductRelationList=[];
for(let i=0;i<newValue.length;i++){
this.value.prefrenceAreaProductRelationList.push({prefrenceAreaId:newValue[i]});
}
} }
// ID }
for ( },
let i = 0; methods: {
i < this.value.prefrenceAreaProductRelationList.length; filterMethod(query, item) {
i++ return item.label.indexOf(query) > -1;
) {
prefrenceAreas.push(
this.value.prefrenceAreaProductRelationList[i].prefrenceAreaId
);
}
return prefrenceAreas;
}, },
set(newValue) { getSubjectList() {
// fetchSubjectList().then(response => {
this.value.prefrenceAreaProductRelationList = []; let list = response.data;
for (let i = 0; i < newValue.length; i++) { for (let i = 0; i < list.length; i++) {
this.value.prefrenceAreaProductRelationList.push({ this.subjectList.push({
prefrenceAreaId: newValue[i], label: list[i].title,
}); key: list[i].id
} });
}
});
}, },
}, getPrefrenceAreaList() {
}, fetchPrefrenceAreaList().then(response=>{
methods: { let list = response.data;
/** for (let i = 0; i < list.length; i++) {
* 筛选方法根据关键词过滤 Transfer 组件数据 this.prefrenceAreaList.push({
* @param {String} query - 查询关键词 label: list[i].name,
* @param {Object} item - 当前项 key: list[i].id
*/ });
filterMethod(query, item) { }
return item.label.indexOf(query) > -1; });
}, },
handlePrev(){
/** this.$emit('prevStep')
* 获取专题列表数据 },
*/ handleFinishCommit(){
getSubjectList() { this.$emit('finishCommit',this.isEdit);
fetchSubjectList().then((response) => { }
let list = response.data; }
this.subjectList = list.map((item) => ({ }
label: item.title,
key: item.id,
}));
});
},
/**
* 获取优选列表数据
*/
getPrefrenceAreaList() {
fetchPrefrenceAreaList().then((response) => {
let list = response.data;
this.prefrenceAreaList = list.map((item) => ({
label: item.name,
key: item.id,
}));
});
},
/**
* 上一步操作通知父组件返回上一步
*/
handlePrev() {
this.$emit('prevStep');
},
/**
* 完成提交通知父组件提交表单数据
*/
handleFinishCommit() {
this.$emit('finishCommit', this.isEdit);
},
},
};
</script> </script>
<style scoped> <style scoped>
/* 局部样式:可根据需要自定义样式 */
.form-inner-container {
max-width: 600px;
margin: 0 auto;
}
</style> </style>

@ -1,63 +1,43 @@
<template> <template>
<!-- 商品促销信息表单 -->
<div style="margin-top: 50px"> <div style="margin-top: 50px">
<el-form <el-form :model="value" ref="productSaleForm" label-width="120px" class="form-inner-container" size="small">
:model="value"
ref="productSaleForm"
label-width="120px"
class="form-inner-container"
size="small"
>
<!-- 赠送积分 -->
<el-form-item label="赠送积分:"> <el-form-item label="赠送积分:">
<el-input v-model="value.giftPoint"></el-input> <el-input v-model="value.giftPoint"></el-input>
</el-form-item> </el-form-item>
<!-- 赠送成长值 -->
<el-form-item label="赠送成长值:"> <el-form-item label="赠送成长值:">
<el-input v-model="value.giftGrowth"></el-input> <el-input v-model="value.giftGrowth"></el-input>
</el-form-item> </el-form-item>
<!-- 积分购买限制 -->
<el-form-item label="积分购买限制:"> <el-form-item label="积分购买限制:">
<el-input v-model="value.usePointLimit"></el-input> <el-input v-model="value.usePointLimit"></el-input>
</el-form-item> </el-form-item>
<!-- 预告商品开关 -->
<el-form-item label="预告商品:"> <el-form-item label="预告商品:">
<el-switch <el-switch
v-model="value.previewStatus" v-model="value.previewStatus"
:active-value="1" :active-value="1"
:inactive-value="0" :inactive-value="0">
></el-switch> </el-switch>
</el-form-item> </el-form-item>
<!-- 商品上架开关 -->
<el-form-item label="商品上架:"> <el-form-item label="商品上架:">
<el-switch <el-switch
v-model="value.publishStatus" v-model="value.publishStatus"
:active-value="1" :active-value="1"
:inactive-value="0" :inactive-value="0">
></el-switch> </el-switch>
</el-form-item> </el-form-item>
<!-- 商品推荐新品与推荐开关 -->
<el-form-item label="商品推荐:"> <el-form-item label="商品推荐:">
<span style="margin-right: 10px">新品</span> <span style="margin-right: 10px">新品</span>
<el-switch <el-switch
v-model="value.newStatus" v-model="value.newStatus"
:active-value="1" :active-value="1"
:inactive-value="0" :inactive-value="0">
></el-switch> </el-switch>
<span style="margin-left: 10px; margin-right: 10px">推荐</span> <span style="margin-left: 10px;margin-right: 10px">推荐</span>
<el-switch <el-switch
v-model="value.recommandStatus" v-model="value.recommandStatus"
:active-value="1" :active-value="1"
:inactive-value="0" :inactive-value="0">
></el-switch> </el-switch>
</el-form-item> </el-form-item>
<!-- 服务保证复选框组 -->
<el-form-item label="服务保证:"> <el-form-item label="服务保证:">
<el-checkbox-group v-model="selectServiceList"> <el-checkbox-group v-model="selectServiceList">
<el-checkbox :label="1">无忧退货</el-checkbox> <el-checkbox :label="1">无忧退货</el-checkbox>
@ -65,32 +45,18 @@
<el-checkbox :label="3">免费包邮</el-checkbox> <el-checkbox :label="3">免费包邮</el-checkbox>
</el-checkbox-group> </el-checkbox-group>
</el-form-item> </el-form-item>
<!-- 详细页标题 -->
<el-form-item label="详细页标题:"> <el-form-item label="详细页标题:">
<el-input v-model="value.detailTitle"></el-input> <el-input v-model="value.detailTitle"></el-input>
</el-form-item> </el-form-item>
<!-- 详细页描述 -->
<el-form-item label="详细页描述:"> <el-form-item label="详细页描述:">
<el-input v-model="value.detailDesc"></el-input> <el-input v-model="value.detailDesc"></el-input>
</el-form-item> </el-form-item>
<!-- 商品关键字 -->
<el-form-item label="商品关键字:"> <el-form-item label="商品关键字:">
<el-input v-model="value.keywords"></el-input> <el-input v-model="value.keywords"></el-input>
</el-form-item> </el-form-item>
<!-- 商品备注 -->
<el-form-item label="商品备注:"> <el-form-item label="商品备注:">
<el-input <el-input v-model="value.note" type="textarea" :autoSize="true"></el-input>
v-model="value.note"
type="textarea"
:autoSize="true"
></el-input>
</el-form-item> </el-form-item>
<!-- 选择优惠方式 -->
<el-form-item label="选择优惠方式:"> <el-form-item label="选择优惠方式:">
<el-radio-group v-model="value.promotionType" size="small"> <el-radio-group v-model="value.promotionType" size="small">
<el-radio-button :label="0">无优惠</el-radio-button> <el-radio-button :label="0">无优惠</el-radio-button>
@ -100,17 +66,15 @@
<el-radio-button :label="4">满减价格</el-radio-button> <el-radio-button :label="4">满减价格</el-radio-button>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item v-show="value.promotionType===1">
<!-- 特惠促销设置 -->
<el-form-item v-show="value.promotionType === 1">
<div> <div>
开始时间 开始时间
<el-date-picker <el-date-picker
v-model="value.promotionStartTime" v-model="value.promotionStartTime"
type="datetime" type="datetime"
:picker-options="pickerOptions1" :picker-options="pickerOptions1"
placeholder="选择开始时间" placeholder="选择开始时间">
></el-date-picker> </el-date-picker>
</div> </div>
<div class="littleMargin"> <div class="littleMargin">
结束时间 结束时间
@ -118,156 +82,225 @@
v-model="value.promotionEndTime" v-model="value.promotionEndTime"
type="datetime" type="datetime"
:picker-options="pickerOptions1" :picker-options="pickerOptions1"
placeholder="选择结束时间" placeholder="选择结束时间">
></el-date-picker> </el-date-picker>
</div> </div>
<div class="littleMargin"> <div class="littleMargin">
促销价格 促销价格
<el-input <el-input style="width: 220px" v-model="value.promotionPrice" placeholder="输入促销价格"></el-input>
style="width: 220px"
v-model="value.promotionPrice"
placeholder="输入促销价格"
></el-input>
</div> </div>
</el-form-item>
<!-- 会员价格设置 --> </el-form-item>
<el-form-item v-show="value.promotionType === 2"> <el-form-item v-show="value.promotionType===2">
<div v-for="(item, index) in value.memberPriceList" :key="index" class="littleMargin"> <div v-for="(item, index) in value.memberPriceList" :class="{littleMargin:index!==0}">
{{ item.memberLevelName }} {{item.memberLevelName}}
<el-input v-model="item.memberPrice" style="width: 200px"></el-input> <el-input v-model="item.memberPrice" style="width: 200px"></el-input>
</div> </div>
</el-form-item> </el-form-item>
<el-form-item v-show="value.promotionType===3">
<!-- 阶梯价格设置 --> <el-table :data="value.productLadderList"
<el-form-item v-show="value.promotionType === 3"> style="width: 80%" border>
<el-table :data="value.productLadderList" style="width: 80%" border> <el-table-column
<el-table-column label="数量" align="center" width="120"> label="数量"
align="center"
width="120">
<template slot-scope="scope"> <template slot-scope="scope">
<el-input v-model="scope.row.count"></el-input> <el-input v-model="scope.row.count"></el-input>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="折扣" align="center" width="120"> <el-table-column
label="折扣"
align="center"
width="120">
<template slot-scope="scope"> <template slot-scope="scope">
<el-input v-model="scope.row.discount"></el-input> <el-input v-model="scope.row.discount"></el-input>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center"> <el-table-column
align="center"
label="操作">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="text" @click="handleRemoveProductLadder(scope.$index)"> <el-button type="text" @click="handleRemoveProductLadder(scope.$index, scope.row)">删除</el-button>
删除 <el-button type="text" @click="handleAddProductLadder(scope.$index, scope.row)">添加</el-button>
</el-button>
<el-button type="text" @click="handleAddProductLadder(scope.$index)">
添加
</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</el-form-item> </el-form-item>
<el-form-item v-show="value.promotionType===4">
<!-- 满减价格设置 --> <el-table :data="value.productFullReductionList"
<el-form-item v-show="value.promotionType === 4"> style="width: 80%" border>
<el-table :data="value.productFullReductionList" style="width: 80%" border> <el-table-column
<el-table-column label="满" align="center" width="120"> label="满"
align="center"
width="120">
<template slot-scope="scope"> <template slot-scope="scope">
<el-input v-model="scope.row.fullPrice"></el-input> <el-input v-model="scope.row.fullPrice"></el-input>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="立减" align="center" width="120"> <el-table-column
label="立减"
align="center"
width="120">
<template slot-scope="scope"> <template slot-scope="scope">
<el-input v-model="scope.row.reducePrice"></el-input> <el-input v-model="scope.row.reducePrice"></el-input>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center"> <el-table-column
align="center"
label="操作">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="text" @click="handleRemoveFullReduction(scope.$index)"> <el-button type="text" @click="handleRemoveFullReduction(scope.$index, scope.row)">删除</el-button>
删除 <el-button type="text" @click="handleAddFullReduction(scope.$index, scope.row)">添加</el-button>
</el-button>
<el-button type="text" @click="handleAddFullReduction(scope.$index)">
添加
</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</el-form-item> </el-form-item>
<!-- 操作按钮 -->
<el-form-item style="text-align: center"> <el-form-item style="text-align: center">
<el-button size="medium" @click="handlePrev"></el-button> <el-button size="medium" @click="handlePrev"></el-button>
<el-button type="primary" size="medium" @click="handleNext"> <el-button type="primary" size="medium" @click="handleNext"></el-button>
下一步填写商品属性
</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
</template> </template>
<script> <script>
import { fetchList as fetchMemberLevelList } from '@/api/memberLevel'; // API import {fetchList as fetchMemberLevelList} from '@/api/memberLevel'
export default { export default {
name: 'ProductSaleDetail', name: "ProductSaleDetail",
props: { props: {
value: Object, // value: Object,
isEdit: { isEdit: {
type: Boolean, // type: Boolean,
default: false, default: false
}
},
data() {
return {
//
pickerOptions1: {
disabledDate(time) {
return time.getTime() < Date.now();
}
}
}
},
created() {
if (this.isEdit) {
// this.handleEditCreated();
} else {
fetchMemberLevelList({defaultStatus: 0}).then(response => {
let memberPriceList = [];
for (let i = 0; i < response.data.length; i++) {
let item = response.data[i];
memberPriceList.push({memberLevelId: item.id, memberLevelName: item.name})
}
this.value.memberPriceList = memberPriceList;
});
}
}, },
}, computed: {
data() { //
return { selectServiceList: {
pickerOptions1: { get() {
disabledDate(time) { let list = [];
return time.getTime() < Date.now(); // if (this.value.serviceIds === undefined || this.value.serviceIds == null || this.value.serviceIds === '') return list;
let ids = this.value.serviceIds.split(',');
for (let i = 0; i < ids.length; i++) {
list.push(Number(ids[i]));
}
return list;
}, },
set(newValue) {
let serviceIds = '';
if (newValue != null && newValue.length > 0) {
for (let i = 0; i < newValue.length; i++) {
serviceIds += newValue[i] + ',';
}
if (serviceIds.endsWith(',')) {
serviceIds = serviceIds.substr(0, serviceIds.length - 1)
}
this.value.serviceIds = serviceIds;
} else {
this.value.serviceIds = null;
}
}
}
},
methods: {
handleEditCreated() {
let ids = this.value.serviceIds.split(',');
console.log('handleEditCreated', ids);
for (let i = 0; i < ids.length; i++) {
this.selectServiceList.push(Number(ids[i]));
}
}, },
}; handleRemoveProductLadder(index, row) {
}, let productLadderList = this.value.productLadderList;
created() { if (productLadderList.length === 1) {
fetchMemberLevelList({ defaultStatus: 0 }).then((response) => { productLadderList.pop();
this.value.memberPriceList = response.data.map((item) => ({ productLadderList.push({
memberLevelId: item.id, count: 0,
memberLevelName: item.name, discount: 0,
memberPrice: 0, price: 0
})); })
}); } else {
}, productLadderList.splice(index, 1);
computed: { }
//
selectServiceList: {
get() {
return this.value.serviceIds ? this.value.serviceIds.split(',').map(Number) : [];
}, },
set(newValue) { handleAddProductLadder(index, row) {
this.value.serviceIds = newValue.join(','); let productLadderList = this.value.productLadderList;
if (productLadderList.length < 3) {
productLadderList.push({
count: 0,
discount: 0,
price: 0
})
} else {
this.$message({
message: '最多只能添加三条',
type: 'warning'
});
}
}, },
}, handleRemoveFullReduction(index, row) {
}, let fullReductionList = this.value.productFullReductionList;
methods: { if (fullReductionList.length === 1) {
handleRemoveProductLadder(index) { fullReductionList.pop();
this.value.productLadderList.splice(index, 1); fullReductionList.push({
}, fullPrice: 0,
handleAddProductLadder() { reducePrice: 0
this.value.productLadderList.push({ count: 0, discount: 0 }); });
}, } else {
handleRemoveFullReduction(index) { fullReductionList.splice(index, 1);
this.value.productFullReductionList.splice(index, 1); }
}, },
handleAddFullReduction() { handleAddFullReduction(index, row) {
this.value.productFullReductionList.push({ fullPrice: 0, reducePrice: 0 }); let fullReductionList = this.value.productFullReductionList;
}, if (fullReductionList.length < 3) {
handlePrev() { fullReductionList.push({
this.$emit('prevStep'); fullPrice: 0,
}, reducePrice: 0
handleNext() { });
this.$emit('nextStep'); } else {
}, this.$message({
}, message: '最多只能添加三条',
}; type: 'warning'
});
}
},
handlePrev() {
this.$emit('prevStep')
},
handleNext() {
this.$emit('nextStep')
}
}
}
</script> </script>
<style scoped> <style scoped>
.littleMargin { .littleMargin {
margin-top: 10px; margin-top: 10px;
} }
</style> </style>

@ -1,22 +1,24 @@
<template> <template> 
<!-- 商品管理页面 -->
<div class="app-container"> <div class="app-container">
<!-- 筛选搜索卡片 -->
<el-card class="filter-container" shadow="never"> <el-card class="filter-container" shadow="never">
<div> <div>
<i class="el-icon-search"></i> <i class="el-icon-search"></i>
<span>筛选搜索</span> <span>筛选搜索</span>
<!-- 查询按钮 --> <el-button
<el-button style="float: right" @click="handleSearchList()" type="primary" size="small"> style="float: right"
@click="handleSearchList()"
type="primary"
size="small">
查询结果 查询结果
</el-button> </el-button>
<!-- 重置按钮 --> <el-button
<el-button style="float: right; margin-right: 15px" @click="handleResetSearch()" size="small"> style="float: right;margin-right: 15px"
@click="handleResetSearch()"
size="small">
重置 重置
</el-button> </el-button>
</div> </div>
<div style="margin-top: 15px"> <div style="margin-top: 15px">
<!-- 搜索表单 -->
<el-form :inline="true" :model="listQuery" size="small" label-width="140px"> <el-form :inline="true" :model="listQuery" size="small" label-width="140px">
<el-form-item label="输入搜索:"> <el-form-item label="输入搜索:">
<el-input style="width: 203px" v-model="listQuery.keyword" placeholder="商品名称"></el-input> <el-input style="width: 203px" v-model="listQuery.keyword" placeholder="商品名称"></el-input>
@ -28,8 +30,8 @@
<el-cascader <el-cascader
clearable clearable
v-model="selectProductCateValue" v-model="selectProductCateValue"
:options="productCateOptions" :options="productCateOptions">
></el-cascader> </el-cascader>
</el-form-item> </el-form-item>
<el-form-item label="商品品牌:"> <el-form-item label="商品品牌:">
<el-select v-model="listQuery.brandId" placeholder="请选择品牌" clearable> <el-select v-model="listQuery.brandId" placeholder="请选择品牌" clearable>
@ -37,8 +39,8 @@
v-for="item in brandOptions" v-for="item in brandOptions"
:key="item.value" :key="item.value"
:label="item.label" :label="item.label"
:value="item.value" :value="item.value">
></el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="上架状态:"> <el-form-item label="上架状态:">
@ -47,8 +49,8 @@
v-for="item in publishStatusOptions" v-for="item in publishStatusOptions"
:key="item.value" :key="item.value"
:label="item.label" :label="item.label"
:value="item.value" :value="item.value">
></el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="审核状态:"> <el-form-item label="审核状态:">
@ -57,206 +59,591 @@
v-for="item in verifyStatusOptions" v-for="item in verifyStatusOptions"
:key="item.value" :key="item.value"
:label="item.label" :label="item.label"
:value="item.value" :value="item.value">
></el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
</el-card> </el-card>
<!-- 操作卡片 -->
<el-card class="operate-container" shadow="never"> <el-card class="operate-container" shadow="never">
<i class="el-icon-tickets"></i> <i class="el-icon-tickets"></i>
<span>数据列表</span> <span>数据列表</span>
<!-- 添加商品按钮 --> <el-button
<el-button class="btn-add" @click="handleAddProduct()" size="mini">添加</el-button> class="btn-add"
@click="handleAddProduct()"
size="mini">
添加
</el-button>
</el-card> </el-card>
<!-- 商品数据表格 -->
<div class="table-container"> <div class="table-container">
<el-table <el-table ref="productTable"
ref="productTable" :data="list"
:data="list" style="width: 100%"
style="width: 100%" @selection-change="handleSelectionChange"
@selection-change="handleSelectionChange" v-loading="listLoading"
v-loading="listLoading" border>
border
>
<!-- 表格列选择框 -->
<el-table-column type="selection" width="60" align="center"></el-table-column> <el-table-column type="selection" width="60" align="center"></el-table-column>
<!-- 表格列商品编号 -->
<el-table-column label="编号" width="100" align="center"> <el-table-column label="编号" width="100" align="center">
<template slot-scope="scope">{{ scope.row.id }}</template> <template slot-scope="scope">{{scope.row.id}}</template>
</el-table-column> </el-table-column>
<!-- 表格列商品图片 -->
<el-table-column label="商品图片" width="120" align="center"> <el-table-column label="商品图片" width="120" align="center">
<template slot-scope="scope"> <template slot-scope="scope"><img style="height: 80px" :src="scope.row.pic"></template>
<img style="height: 80px" :src="scope.row.pic" alt="商品图片" />
</template>
</el-table-column> </el-table-column>
<!-- 表格列商品名称与品牌 -->
<el-table-column label="商品名称" align="center"> <el-table-column label="商品名称" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<p>{{ scope.row.name }}</p> <p>{{scope.row.name}}</p>
<p>品牌{{ scope.row.brandName }}</p> <p>品牌{{scope.row.brandName}}</p>
</template> </template>
</el-table-column> </el-table-column>
<!-- 表格列价格与货号 -->
<el-table-column label="价格/货号" width="120" align="center"> <el-table-column label="价格/货号" width="120" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<p>价格{{ scope.row.price }}</p> <p>价格{{scope.row.price}}</p>
<p>货号{{ scope.row.productSn }}</p> <p>货号{{scope.row.productSn}}</p>
</template> </template>
</el-table-column> </el-table-column>
<!-- 表格列标签上架/新品/推荐 -->
<el-table-column label="标签" width="140" align="center"> <el-table-column label="标签" width="140" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<!-- 上架状态 --> <p>上架
<p>
上架
<el-switch <el-switch
@change="handlePublishStatusChange(scope.$index, scope.row)" @change="handlePublishStatusChange(scope.$index, scope.row)"
:active-value="1" :active-value="1"
:inactive-value="0" :inactive-value="0"
v-model="scope.row.publishStatus" v-model="scope.row.publishStatus">
></el-switch> </el-switch>
</p> </p>
<!-- 新品状态 --> <p>新品
<p>
新品
<el-switch <el-switch
@change="handleNewStatusChange(scope.$index, scope.row)" @change="handleNewStatusChange(scope.$index, scope.row)"
:active-value="1" :active-value="1"
:inactive-value="0" :inactive-value="0"
v-model="scope.row.newStatus" v-model="scope.row.newStatus">
></el-switch> </el-switch>
</p> </p>
<!-- 推荐状态 --> <p>推荐
<p>
推荐
<el-switch <el-switch
@change="handleRecommendStatusChange(scope.$index, scope.row)" @change="handleRecommendStatusChange(scope.$index, scope.row)"
:active-value="1" :active-value="1"
:inactive-value="0" :inactive-value="0"
v-model="scope.row.recommandStatus" v-model="scope.row.recommandStatus">
></el-switch> </el-switch>
</p>
</template>
</el-table-column>
<el-table-column label="排序" width="100" align="center">
<template slot-scope="scope">{{scope.row.sort}}</template>
</el-table-column>
<el-table-column label="SKU库存" width="100" align="center">
<template slot-scope="scope">
<el-button type="primary" icon="el-icon-edit" @click="handleShowSkuEditDialog(scope.$index, scope.row)" circle></el-button>
</template>
</el-table-column>
<el-table-column label="销量" width="100" align="center">
<template slot-scope="scope">{{scope.row.sale}}</template>
</el-table-column>
<el-table-column label="审核状态" width="100" align="center">
<template slot-scope="scope">
<p>{{scope.row.verifyStatus | verifyStatusFilter}}</p>
<p>
<el-button
type="text"
@click="handleShowVerifyDetail(scope.$index, scope.row)">审核详情
</el-button>
</p> </p>
</template> </template>
</el-table-column> </el-table-column>
<!-- 表格列操作 -->
<el-table-column label="操作" width="160" align="center"> <el-table-column label="操作" width="160" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<p> <p>
<el-button size="mini" @click="handleShowProduct(scope.$index, scope.row)">查看</el-button> <el-button
<el-button size="mini" @click="handleUpdateProduct(scope.$index, scope.row)">编辑</el-button> size="mini"
@click="handleShowProduct(scope.$index, scope.row)">查看
</el-button>
<el-button
size="mini"
@click="handleUpdateProduct(scope.$index, scope.row)">编辑
</el-button>
</p> </p>
<p> <p>
<el-button size="mini" @click="handleShowLog(scope.$index, scope.row)">日志</el-button> <el-button
<el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button> size="mini"
@click="handleShowLog(scope.$index, scope.row)">日志
</el-button>
<el-button
size="mini"
type="danger"
@click="handleDelete(scope.$index, scope.row)">删除
</el-button>
</p> </p>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</div> </div>
<!-- 批量操作区域 -->
<div class="batch-operate-container"> <div class="batch-operate-container">
<el-select size="small" v-model="operateType" placeholder="批量操作"> <el-select
size="small"
v-model="operateType" placeholder="批量操作">
<el-option <el-option
v-for="item in operates" v-for="item in operates"
:key="item.value" :key="item.value"
:label="item.label" :label="item.label"
:value="item.value" :value="item.value">
></el-option> </el-option>
</el-select> </el-select>
<el-button <el-button
style="margin-left: 20px" style="margin-left: 20px"
class="search-button" class="search-button"
@click="handleBatchOperate()" @click="handleBatchOperate()"
type="primary" type="primary"
size="small" size="small">
>
确定 确定
</el-button> </el-button>
</div> </div>
<!-- 分页组件 -->
<div class="pagination-container"> <div class="pagination-container">
<el-pagination <el-pagination
background background
@size-change="handleSizeChange" @size-change="handleSizeChange"
@current-change="handleCurrentChange" @current-change="handleCurrentChange"
layout="total, sizes, prev, pager, next, jumper" layout="total, sizes,prev, pager, next,jumper"
:page-size="listQuery.pageSize" :page-size="listQuery.pageSize"
:page-sizes="[5, 10, 15]" :page-sizes="[5,10,15]"
:current-page.sync="listQuery.pageNum" :current-page.sync="listQuery.pageNum"
:total="total" :total="total">
></el-pagination> </el-pagination>
</div> </div>
<el-dialog
title="编辑货品信息"
:visible.sync="editSkuInfo.dialogVisible"
width="40%">
<span>商品货号</span>
<span>{{editSkuInfo.productSn}}</span>
<el-input placeholder="按sku编号搜索" v-model="editSkuInfo.keyword" size="small" style="width: 50%;margin-left: 20px">
<el-button slot="append" icon="el-icon-search" @click="handleSearchEditSku"></el-button>
</el-input>
<el-table style="width: 100%;margin-top: 20px"
:data="editSkuInfo.stockList"
border>
<el-table-column
label="SKU编号"
align="center">
<template slot-scope="scope">
<el-input v-model="scope.row.skuCode"></el-input>
</template>
</el-table-column>
<el-table-column
v-for="(item,index) in editSkuInfo.productAttr"
:label="item.name"
:key="item.id"
align="center">
<template slot-scope="scope">
{{getProductSkuSp(scope.row,index)}}
</template>
</el-table-column>
<el-table-column
label="销售价格"
width="80"
align="center">
<template slot-scope="scope">
<el-input v-model="scope.row.price"></el-input>
</template>
</el-table-column>
<el-table-column
label="商品库存"
width="80"
align="center">
<template slot-scope="scope">
<el-input v-model="scope.row.stock"></el-input>
</template>
</el-table-column>
<el-table-column
label="库存预警值"
width="100"
align="center">
<template slot-scope="scope">
<el-input v-model="scope.row.lowStock"></el-input>
</template>
</el-table-column>
</el-table>
<span slot="footer" class="dialog-footer">
<el-button @click="editSkuInfo.dialogVisible = false"> </el-button>
<el-button type="primary" @click="handleEditSkuConfirm"> </el-button>
</span>
</el-dialog>
</div> </div>
</template> </template>
<script> <script>
import { import {
fetchList, fetchList,
updateDeleteStatus, updateDeleteStatus,
updateNewStatus, updateNewStatus,
updateRecommendStatus, updateRecommendStatus,
updatePublishStatus, updatePublishStatus
} from '@/api/product'; } from '@/api/product'
import {fetchList as fetchSkuStockList,update as updateSkuStockList} from '@/api/skuStock'
import {fetchList as fetchProductAttrList} from '@/api/productAttr'
import {fetchList as fetchBrandList} from '@/api/brand'
import {fetchListWithChildren} from '@/api/productCate'
export default { const defaultListQuery = {
name: 'productList', keyword: null,
data() { pageNum: 1,
return { pageSize: 5,
listQuery: { pageNum: 1, pageSize: 5 }, publishStatus: null,
list: [], verifyStatus: null,
total: 0, productSn: null,
listLoading: false, productCategoryId: null,
operates: [{ label: '商品上架', value: 'publishOn' }], brandId: null
operateType: null, };
}; export default {
}, name: "productList",
created() { data() {
this.getList(); return {
}, editSkuInfo:{
methods: { dialogVisible:false,
// productId:null,
getList() { productSn:'',
this.listLoading = true; productAttributeCategoryId:null,
fetchList(this.listQuery).then((response) => { stockList:[],
this.listLoading = false; productAttr:[],
this.list = response.data.list; keyword:null
this.total = response.data.total; },
}); operates: [
{
label: "商品上架",
value: "publishOn"
},
{
label: "商品下架",
value: "publishOff"
},
{
label: "设为推荐",
value: "recommendOn"
},
{
label: "取消推荐",
value: "recommendOff"
},
{
label: "设为新品",
value: "newOn"
},
{
label: "取消新品",
value: "newOff"
},
{
label: "转移到分类",
value: "transferCategory"
},
{
label: "移入回收站",
value: "recycle"
}
],
operateType: null,
listQuery: Object.assign({}, defaultListQuery),
list: null,
total: null,
listLoading: true,
selectProductCateValue: null,
multipleSelection: [],
productCateOptions: [],
brandOptions: [],
publishStatusOptions: [{
value: 1,
label: '上架'
}, {
value: 0,
label: '下架'
}],
verifyStatusOptions: [{
value: 1,
label: '审核通过'
}, {
value: 0,
label: '未审核'
}]
}
}, },
// created() {
handleResetSearch() {
this.listQuery = { pageNum: 1, pageSize: 5 };
this.getList(); this.getList();
this.getBrandList();
this.getProductCateList();
}, },
// watch: {
handleSearchList() { selectProductCateValue: function (newValue) {
this.listQuery.pageNum = 1; if (newValue != null && newValue.length == 2) {
this.getList(); this.listQuery.productCategoryId = newValue[1];
} else {
this.listQuery.productCategoryId = null;
}
}
}, },
// filters: {
handleAddProduct() { verifyStatusFilter(value) {
this.$router.push('/pms/addProduct'); if (value === 1) {
return '审核通过';
} else {
return '未审核';
}
}
}, },
}, methods: {
}; getProductSkuSp(row, index) {
let spData = JSON.parse(row.spData);
if(spData!=null&&index<spData.length){
return spData[index].value;
}else{
return null;
}
},
getList() {
this.listLoading = true;
fetchList(this.listQuery).then(response => {
this.listLoading = false;
this.list = response.data.list;
this.total = response.data.total;
});
},
getBrandList() {
fetchBrandList({pageNum: 1, pageSize: 100}).then(response => {
this.brandOptions = [];
let brandList = response.data.list;
for (let i = 0; i < brandList.length; i++) {
this.brandOptions.push({label: brandList[i].name, value: brandList[i].id});
}
});
},
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});
}
});
},
handleShowSkuEditDialog(index,row){
this.editSkuInfo.dialogVisible=true;
this.editSkuInfo.productId=row.id;
this.editSkuInfo.productSn=row.productSn;
this.editSkuInfo.productAttributeCategoryId = row.productAttributeCategoryId;
this.editSkuInfo.keyword=null;
fetchSkuStockList(row.id,{keyword:this.editSkuInfo.keyword}).then(response=>{
this.editSkuInfo.stockList=response.data;
});
if(row.productAttributeCategoryId!=null){
fetchProductAttrList(row.productAttributeCategoryId,{type:0}).then(response=>{
this.editSkuInfo.productAttr=response.data.list;
});
}
},
handleSearchEditSku(){
fetchSkuStockList(this.editSkuInfo.productId,{keyword:this.editSkuInfo.keyword}).then(response=>{
this.editSkuInfo.stockList=response.data;
});
},
handleEditSkuConfirm(){
if(this.editSkuInfo.stockList==null||this.editSkuInfo.stockList.length<=0){
this.$message({
message: '暂无sku信息',
type: 'warning',
duration: 1000
});
return
}
this.$confirm('是否要进行修改', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(()=>{
updateSkuStockList(this.editSkuInfo.productId,this.editSkuInfo.stockList).then(response=>{
this.$message({
message: '修改成功',
type: 'success',
duration: 1000
});
this.editSkuInfo.dialogVisible=false;
});
});
},
handleSearchList() {
this.listQuery.pageNum = 1;
this.getList();
},
handleAddProduct() {
this.$router.push({path:'/pms/addProduct'});
},
handleBatchOperate() {
if(this.operateType==null){
this.$message({
message: '请选择操作类型',
type: 'warning',
duration: 1000
});
return;
}
if(this.multipleSelection==null||this.multipleSelection.length<1){
this.$message({
message: '请选择要操作的商品',
type: 'warning',
duration: 1000
});
return;
}
this.$confirm('是否要进行该批量操作?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let ids=[];
for(let i=0;i<this.multipleSelection.length;i++){
ids.push(this.multipleSelection[i].id);
}
switch (this.operateType) {
case this.operates[0].value:
this.updatePublishStatus(1,ids);
break;
case this.operates[1].value:
this.updatePublishStatus(0,ids);
break;
case this.operates[2].value:
this.updateRecommendStatus(1,ids);
break;
case this.operates[3].value:
this.updateRecommendStatus(0,ids);
break;
case this.operates[4].value:
this.updateNewStatus(1,ids);
break;
case this.operates[5].value:
this.updateNewStatus(0,ids);
break;
case this.operates[6].value:
break;
case this.operates[7].value:
this.updateDeleteStatus(1,ids);
break;
default:
break;
}
this.getList();
});
},
handleSizeChange(val) {
this.listQuery.pageNum = 1;
this.listQuery.pageSize = val;
this.getList();
},
handleCurrentChange(val) {
this.listQuery.pageNum = val;
this.getList();
},
handleSelectionChange(val) {
this.multipleSelection = val;
},
handlePublishStatusChange(index, row) {
let ids = [];
ids.push(row.id);
this.updatePublishStatus(row.publishStatus, ids);
},
handleNewStatusChange(index, row) {
let ids = [];
ids.push(row.id);
this.updateNewStatus(row.newStatus, ids);
},
handleRecommendStatusChange(index, row) {
let ids = [];
ids.push(row.id);
this.updateRecommendStatus(row.recommandStatus, ids);
},
handleResetSearch() {
this.selectProductCateValue = [];
this.listQuery = Object.assign({}, defaultListQuery);
},
handleDelete(index, row){
this.$confirm('是否要进行删除操作?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let ids = [];
ids.push(row.id);
this.updateDeleteStatus(1,ids);
});
},
handleUpdateProduct(index,row){
this.$router.push({path:'/pms/updateProduct',query:{id:row.id}});
},
handleShowProduct(index,row){
console.log("handleShowProduct",row);
},
handleShowVerifyDetail(index,row){
console.log("handleShowVerifyDetail",row);
},
handleShowLog(index,row){
console.log("handleShowLog",row);
},
updatePublishStatus(publishStatus, ids) {
let params = new URLSearchParams();
params.append('ids', ids);
params.append('publishStatus', publishStatus);
updatePublishStatus(params).then(response => {
this.$message({
message: '修改成功',
type: 'success',
duration: 1000
});
});
},
updateNewStatus(newStatus, ids) {
let params = new URLSearchParams();
params.append('ids', ids);
params.append('newStatus', newStatus);
updateNewStatus(params).then(response => {
this.$message({
message: '修改成功',
type: 'success',
duration: 1000
});
});
},
updateRecommendStatus(recommendStatus, ids) {
let params = new URLSearchParams();
params.append('ids', ids);
params.append('recommendStatus', recommendStatus);
updateRecommendStatus(params).then(response => {
this.$message({
message: '修改成功',
type: 'success',
duration: 1000
});
});
},
updateDeleteStatus(deleteStatus, ids) {
let params = new URLSearchParams();
params.append('ids', ids);
params.append('deleteStatus', deleteStatus);
updateDeleteStatus(params).then(response => {
this.$message({
message: '删除成功',
type: 'success',
duration: 1000
});
});
this.getList();
}
}
}
</script> </script>
<style></style>
<style scoped>
.app-container {
padding: 20px;
}
</style>

@ -1,24 +1,12 @@
<template> <template> 
<!-- 商品详情组件用于编辑商品 --> <product-detail :is-edit='true'></product-detail>
<!-- 通过 `:is-edit="true"` 传递一个布尔值标识当前操作是编辑模式 -->
<product-detail :is-edit="true"></product-detail>
</template> </template>
<script> <script>
/** import ProductDetail from './components/ProductDetail'
* 导入 ProductDetail 组件作为编辑商品的核心组件 export default {
* 该组件内部根据传入的 `is-edit` 参数区分新增或编辑模式 name: 'updateProduct',
*/ components: { ProductDetail }
import ProductDetail from './components/ProductDetail'; }
export default {
name: 'updateProduct', //
components: {
ProductDetail, // ProductDetail 使使
},
};
</script> </script>
<style> <style>
/* 样式部分:暂无自定义样式,根据需求可以添加 */
</style> </style>

@ -1,26 +1,15 @@
<template> <template>
<!-- 商品属性详情组件 --> <product-attr-detail :is-edit='false'></product-attr-detail>
<!-- 使用 ProductAttrDetail 组件传递 is-edit="false" 表示新增模式 -->
<product-attr-detail :is-edit="false"></product-attr-detail>
</template> </template>
<script> <script>
/** import ProductAttrDetail from './components/ProductAttrDetail'
* 导入 ProductAttrDetail 组件 export default {
* 该组件用于处理商品属性的新增和编辑功能 name: 'addProductAttr',
* 通过传递 `is-edit` 参数来控制组件的操作模式 components: { ProductAttrDetail }
*/ }
import ProductAttrDetail from './components/ProductAttrDetail';
export default {
//
name: 'addProductAttr',
components: {
ProductAttrDetail, // ProductAttrDetail
},
};
</script> </script>
<style scoped> <style scoped>
/* 样式部分:暂无自定义样式,可根据需求添加 */
</style> </style>

@ -1,38 +1,25 @@
<template> <template>
<!-- 属性详情表单卡片 -->
<el-card class="form-container" shadow="never"> <el-card class="form-container" shadow="never">
<el-form <el-form :model="productAttr" :rules="rules" ref="productAttrFrom" label-width="150px">
:model="productAttr"
:rules="rules"
ref="productAttrFrom"
label-width="150px"
>
<!-- 属性名称 -->
<el-form-item label="属性名称:" prop="name"> <el-form-item label="属性名称:" prop="name">
<el-input v-model="productAttr.name"></el-input> <el-input v-model="productAttr.name"></el-input>
</el-form-item> </el-form-item>
<!-- 商品类型选择 -->
<el-form-item label="商品类型:"> <el-form-item label="商品类型:">
<el-select v-model="productAttr.productAttributeCategoryId" placeholder="请选择"> <el-select v-model="productAttr.productAttributeCategoryId" placeholder="请选择">
<el-option <el-option
v-for="item in productAttrCateList" v-for="item in productAttrCateList"
:key="item.id" :key="item.id"
:label="item.name" :label="item.name"
:value="item.id" :value="item.id">
></el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<!-- 分类筛选样式 -->
<el-form-item label="分类筛选样式:"> <el-form-item label="分类筛选样式:">
<el-radio-group v-model="productAttr.filterType"> <el-radio-group v-model="productAttr.filterType">
<el-radio :label="0">普通</el-radio> <el-radio :label="0">普通</el-radio>
<el-radio :label="1">颜色</el-radio> <el-radio :label="1">颜色</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<!-- 能否进行检索 -->
<el-form-item label="能否进行检索:"> <el-form-item label="能否进行检索:">
<el-radio-group v-model="productAttr.searchType"> <el-radio-group v-model="productAttr.searchType">
<el-radio :label="0">不需要检索</el-radio> <el-radio :label="0">不需要检索</el-radio>
@ -40,16 +27,12 @@
<el-radio :label="2">范围检索</el-radio> <el-radio :label="2">范围检索</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<!-- 商品属性关联 -->
<el-form-item label="商品属性关联:"> <el-form-item label="商品属性关联:">
<el-radio-group v-model="productAttr.relatedStatus"> <el-radio-group v-model="productAttr.relatedStatus">
<el-radio :label="1"></el-radio> <el-radio :label="1"></el-radio>
<el-radio :label="0"></el-radio> <el-radio :label="0"></el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<!-- 属性是否可选 -->
<el-form-item label="属性是否可选:"> <el-form-item label="属性是否可选:">
<el-radio-group v-model="productAttr.selectType"> <el-radio-group v-model="productAttr.selectType">
<el-radio :label="0">唯一</el-radio> <el-radio :label="0">唯一</el-radio>
@ -57,178 +40,146 @@
<el-radio :label="2">复选</el-radio> <el-radio :label="2">复选</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<!-- 属性值的录入方式 -->
<el-form-item label="属性值的录入方式:"> <el-form-item label="属性值的录入方式:">
<el-radio-group v-model="productAttr.inputType"> <el-radio-group v-model="productAttr.inputType">
<el-radio :label="0">手工录入</el-radio> <el-radio :label="0">手工录入</el-radio>
<el-radio :label="1">从下面列表中选择</el-radio> <el-radio :label="1">从下面列表中选择</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<!-- 属性值可选值列表 -->
<el-form-item label="属性值可选值列表:"> <el-form-item label="属性值可选值列表:">
<el-input <el-input :autosize="true" type="textarea" v-model="inputListFormat"></el-input>
:autosize="true"
type="textarea"
v-model="inputListFormat"
></el-input>
</el-form-item> </el-form-item>
<!-- 是否支持手动新增 -->
<el-form-item label="是否支持手动新增:"> <el-form-item label="是否支持手动新增:">
<el-radio-group v-model="productAttr.handAddStatus"> <el-radio-group v-model="productAttr.handAddStatus">
<el-radio :label="1"></el-radio> <el-radio :label="1"></el-radio>
<el-radio :label="0"></el-radio> <el-radio :label="0"></el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<!-- 排序属性 -->
<el-form-item label="排序属性:"> <el-form-item label="排序属性:">
<el-input v-model="productAttr.sort"></el-input> <el-input v-model="productAttr.sort"></el-input>
</el-form-item> </el-form-item>
<!-- 提交与重置按钮 -->
<el-form-item> <el-form-item>
<el-button type="primary" @click="onSubmit('productAttrFrom')"></el-button> <el-button type="primary" @click="onSubmit('productAttrFrom')"></el-button>
<el-button v-if="!isEdit" @click="resetForm('productAttrFrom')"></el-button> <el-button v-if="!isEdit" @click="resetForm('productAttrFrom')"></el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</el-card> </el-card>
</template> </template>
<script> <script>
import { fetchList } from '@/api/productAttrCate'; // API import {fetchList} from '@/api/productAttrCate'
import { import {createProductAttr,getProductAttr,updateProductAttr} from '@/api/productAttr'
createProductAttr,
getProductAttr,
updateProductAttr,
} from '@/api/productAttr'; // API
//
const defaultProductAttr = {
filterType: 0,
handAddStatus: 0,
inputList: '',
inputType: 0,
name: '',
productAttributeCategoryId: 0,
relatedStatus: 0,
searchType: 0,
selectType: 0,
sort: 0,
type: 0,
};
export default { const defaultProductAttr = {
name: 'ProductAttrDetail', // filterType: 0,
props: { handAddStatus: 0,
isEdit: { inputList: '',
type: Boolean, // inputType: 0,
default: false, name: '',
productAttributeCategoryId: 0,
relatedStatus: 0,
searchType: 0,
selectType: 0,
sort: 0,
type: 0
};
export default {
name: "ProductAttrDetail",
props: {
isEdit: {
type: Boolean,
default: false
}
}, },
}, data() {
data() { return {
return { productAttr: Object.assign({}, defaultProductAttr),
productAttr: Object.assign({}, defaultProductAttr), // rules: {
rules: { name: [
// {required: true, message: '请输入属性名称', trigger: 'blur'},
name: [ {min: 2, max: 140, message: '长度在 2 到 140 个字符', trigger: 'blur'}
{ required: true, message: '请输入属性名称', trigger: 'blur' }, ]
{ min: 2, max: 140, message: '长度在 2 到 140 个字符', trigger: 'blur' }, },
], productAttrCateList: null,
}, inputListFormat:null
productAttrCateList: null, // }
inputListFormat: null, //
};
},
created() {
if (this.isEdit) {
//
getProductAttr(this.$route.query.id).then((response) => {
this.productAttr = response.data;
//
this.inputListFormat = this.productAttr.inputList.replace(/,/g, '\n');
});
} else {
//
this.resetProductAttr();
}
this.getCateList(); //
},
watch: {
//
inputListFormat(newValue) {
newValue = newValue.replace(/\n/g, ',');
this.productAttr.inputList = newValue;
}, },
}, created() {
methods: { if(this.isEdit){
// getProductAttr(this.$route.query.id).then(response => {
getCateList() { this.productAttr = response.data;
let listQuery = { pageNum: 1, pageSize: 100 }; this.inputListFormat = this.productAttr.inputList.replace(/,/g,'\n');
fetchList(listQuery).then((response) => { });
this.productAttrCateList = response.data.list; }else{
}); this.resetProductAttr();
}
this.getCateList();
}, },
// watch:{
resetProductAttr() { inputListFormat: function (newValue, oldValue) {
this.productAttr = Object.assign({}, defaultProductAttr); newValue = newValue.replace(/\n/g,',');
this.productAttr.productAttributeCategoryId = Number(this.$route.query.cid); this.productAttr.inputList = newValue;
this.productAttr.type = Number(this.$route.query.type); }
}, },
// methods: {
onSubmit(formName) { getCateList() {
this.$refs[formName].validate((valid) => { let listQuery = {pageNum: 1, pageSize: 100};
if (valid) { fetchList(listQuery).then(response => {
// this.productAttrCateList = response.data.list;
this.$confirm('是否提交数据', '提示', { });
confirmButtonText: '确定', },
cancelButtonText: '取消', resetProductAttr() {
type: 'warning', this.productAttr = Object.assign({}, defaultProductAttr);
}).then(() => { this.productAttr.productAttributeCategoryId = Number(this.$route.query.cid);
if (this.isEdit) { this.productAttr.type = Number(this.$route.query.type);
// },
updateProductAttr(this.$route.query.id, this.productAttr).then(() => { onSubmit(formName) {
this.$message({ this.$refs[formName].validate((valid) => {
message: '修改成功', if (valid) {
type: 'success', this.$confirm('是否提交数据', '提示', {
duration: 1000, confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
if(this.isEdit){
updateProductAttr(this.$route.query.id,this.productAttr).then(response=>{
this.$message({
message: '修改成功',
type: 'success',
duration: 1000
});
this.$router.back();
}); });
this.$router.back(); }else{
}); createProductAttr(this.productAttr).then(response=>{
} else { this.$message({
// message: '提交成功',
createProductAttr(this.productAttr).then(() => { type: 'success',
this.$message({ duration: 1000
message: '提交成功', });
type: 'success', this.resetForm('productAttrFrom');
duration: 1000,
}); });
this.resetForm(formName); }
}); });
}
}); } else {
} else { this.$message({
// message: '验证失败',
this.$message({ type: 'error',
message: '验证失败', duration: 1000
type: 'error', });
duration: 1000, return false;
}); }
return false; });
} },
}); resetForm(formName) {
}, this.$refs[formName].resetFields();
// this.resetProductAttr();
resetForm(formName) { }
this.$refs[formName].resetFields();
this.resetProductAttr();
}, },
}, }
};
</script> </script>
<style scoped> <style scoped>
/* 样式部分:可以根据需求添加自定义样式 */
</style> </style>

@ -1,103 +1,82 @@
<template> <template> 
<!-- 商品属性分类管理页面 -->
<div class="app-container"> <div class="app-container">
<!-- 操作栏包含添加按钮 -->
<el-card class="operate-container" shadow="never"> <el-card class="operate-container" shadow="never">
<i class="el-icon-tickets" style="margin-top: 5px"></i> <i class="el-icon-tickets" style="margin-top: 5px"></i>
<span style="margin-top: 5px">数据列表</span> <span style="margin-top: 5px">数据列表</span>
<!-- 添加商品属性分类按钮 --> <el-button
<el-button class="btn-add" @click="addProductAttrCate()" size="mini">添加</el-button> class="btn-add"
@click="addProductAttrCate()"
size="mini">
添加
</el-button>
</el-card> </el-card>
<!-- 数据表格区域 -->
<div class="table-container"> <div class="table-container">
<el-table <el-table ref="productAttrCateTable"
ref="productAttrCateTable" style="width: 100%"
style="width: 100%" :data="list"
:data="list" v-loading="listLoading"
v-loading="listLoading" border>
border
>
<!-- 编号 -->
<el-table-column label="编号" width="100" align="center"> <el-table-column label="编号" width="100" align="center">
<template slot-scope="scope">{{ scope.row.id }}</template> <template slot-scope="scope">{{scope.row.id}}</template>
</el-table-column> </el-table-column>
<!-- 类型名称 -->
<el-table-column label="类型名称" align="center"> <el-table-column label="类型名称" align="center">
<template slot-scope="scope">{{ scope.row.name }}</template> <template slot-scope="scope">{{scope.row.name}}</template>
</el-table-column> </el-table-column>
<!-- 属性数量 -->
<el-table-column label="属性数量" width="200" align="center"> <el-table-column label="属性数量" width="200" align="center">
<template slot-scope="scope"> <template slot-scope="scope">{{scope.row.attributeCount==null?0:scope.row.attributeCount}}</template>
{{ scope.row.attributeCount == null ? 0 : scope.row.attributeCount }}
</template>
</el-table-column> </el-table-column>
<!-- 参数数量 -->
<el-table-column label="参数数量" width="200" align="center"> <el-table-column label="参数数量" width="200" align="center">
<template slot-scope="scope"> <template slot-scope="scope">{{scope.row.paramCount==null?0:scope.row.paramCount}}</template>
{{ scope.row.paramCount == null ? 0 : scope.row.paramCount }}
</template>
</el-table-column> </el-table-column>
<!-- 设置 -->
<el-table-column label="设置" width="200" align="center"> <el-table-column label="设置" width="200" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<!-- 属性列表按钮 --> <el-button
<el-button size="mini" @click="getAttrList(scope.$index, scope.row)"> size="mini"
属性列表 @click="getAttrList(scope.$index, scope.row)">属性列表
</el-button> </el-button>
<!-- 参数列表按钮 --> <el-button
<el-button size="mini" @click="getParamList(scope.$index, scope.row)"> size="mini"
参数列表 @click="getParamList(scope.$index, scope.row)">参数列表
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
<!-- 操作 -->
<el-table-column label="操作" width="200" align="center"> <el-table-column label="操作" width="200" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<!-- 编辑按钮 --> <el-button
<el-button size="mini" @click="handleUpdate(scope.$index, scope.row)">编辑</el-button> size="mini"
<!-- 删除按钮 --> @click="handleUpdate(scope.$index, scope.row)">编辑
<el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)"> </el-button>
删除 <el-button
size="mini"
type="danger"
@click="handleDelete(scope.$index, scope.row)">删除
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</div> </div>
<!-- 分页组件 -->
<div class="pagination-container"> <div class="pagination-container">
<el-pagination <el-pagination
background background
@size-change="handleSizeChange" @size-change="handleSizeChange"
@current-change="handleCurrentChange" @current-change="handleCurrentChange"
layout="total, sizes, prev, pager, next, jumper" layout="total, sizes,prev, pager, next,jumper"
:page-size="listQuery.pageSize" :page-size="listQuery.pageSize"
:page-sizes="[5, 10, 15]" :page-sizes="[5,10,15]"
:current-page.sync="listQuery.pageNum" :current-page.sync="listQuery.pageNum"
:total="total" :total="total">
></el-pagination> </el-pagination>
</div> </div>
<!-- 弹出框添加/编辑商品属性分类 -->
<el-dialog <el-dialog
:title="dialogTitle" :title="dialogTitle"
:visible.sync="dialogVisible" :visible.sync="dialogVisible"
:before-close="handleClose" :before-close="handleClose()"
width="30%" width="30%">
> <el-form ref="productAttrCatForm":model="productAttrCate" :rules="rules" label-width="120px">
<!-- 表单输入类型名称 -->
<el-form ref="productAttrCatForm" :model="productAttrCate" :rules="rules" label-width="120px">
<el-form-item label="类型名称" prop="name"> <el-form-item label="类型名称" prop="name">
<el-input v-model="productAttrCate.name" auto-complete="off"></el-input> <el-input v-model="productAttrCate.name" auto-complete="off"></el-input>
</el-form-item> </el-form-item>
</el-form> </el-form>
<!-- 弹窗底部操作按钮 -->
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false"> </el-button> <el-button @click="dialogVisible = false"> </el-button>
<el-button type="primary" @click="handleConfirm('productAttrCatForm')"> </el-button> <el-button type="primary" @click="handleConfirm('productAttrCatForm')"> </el-button>
@ -105,155 +84,127 @@
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
<script> <script>
/** import {fetchList,createProductAttrCate,deleteProductAttrCate,updateProductAttrCate} from '@/api/productAttrCate'
* 导入商品属性分类相关的 API
*/ export default {
import { name: 'productAttrCateList',
fetchList, data() {
createProductAttrCate, return {
deleteProductAttrCate, list: null,
updateProductAttrCate, total: null,
} from '@/api/productAttrCate'; listLoading: true,
listQuery: {
export default { pageNum: 1,
name: 'productAttrCateList', // pageSize: 5
data() { },
return { dialogVisible: false,
list: null, // dialogTitle:'',
total: null, // productAttrCate:{
listLoading: true, // name:'',
listQuery: { id:null
pageNum: 1, },
pageSize: 5, rules: {
}, name: [
dialogVisible: false, // { required: true, message: '请输入类型名称', trigger: 'blur' }
dialogTitle: '', // ]
productAttrCate: { }
name: '', }
id: null,
},
rules: {
name: [{ required: true, message: '请输入类型名称', trigger: 'blur' }],
},
};
},
created() {
//
this.getList();
},
methods: {
//
getList() {
this.listLoading = true;
fetchList(this.listQuery).then((response) => {
this.listLoading = false;
this.list = response.data.list;
this.total = response.data.total;
});
},
//
addProductAttrCate() {
this.dialogVisible = true;
this.dialogTitle = '添加类型';
this.productAttrCate = { name: '', id: null };
},
//
handleSizeChange(val) {
this.listQuery.pageNum = 1;
this.listQuery.pageSize = val;
this.getList();
}, },
created() {
//
handleCurrentChange(val) {
this.listQuery.pageNum = val;
this.getList(); this.getList();
}, },
methods: {
// getList() {
handleDelete(index, row) { this.listLoading = true;
this.$confirm('是否要删除该分类?', '提示', { fetchList(this.listQuery).then(response => {
confirmButtonText: '确定', this.listLoading = false;
cancelButtonText: '取消', this.list = response.data.list;
type: 'warning', this.total = response.data.total;
}).then(() => {
deleteProductAttrCate(row.id).then(() => {
this.$message({
message: '删除成功',
type: 'success',
duration: 1000,
});
this.getList();
}); });
}); },
}, addProductAttrCate() {
this.dialogVisible = true;
// this.dialogTitle = "添加类型";
handleUpdate(index, row) { },
this.dialogVisible = true; handleSizeChange(val) {
this.dialogTitle = '编辑类型'; this.listQuery.pageNum = 1;
this.productAttrCate.name = row.name; this.listQuery.pageSize = val;
this.productAttrCate.id = row.id; this.getList();
}, },
handleCurrentChange(val) {
// this.listQuery.pageNum = val;
getAttrList(index, row) { this.getList();
this.$router.push({ },
path: '/pms/productAttrList', handleDelete(index, row) {
query: { cid: row.id, cname: row.name, type: 0 }, this.$confirm('是否要删除该品牌', '提示', {
}); confirmButtonText: '确定',
}, cancelButtonText: '取消',
type: 'warning'
// }).then(() => {
getParamList(index, row) { deleteProductAttrCate(row.id).then(response=>{
this.$router.push({ this.$message({
path: '/pms/productAttrList', message: '删除成功',
query: { cid: row.id, cname: row.name, type: 1 }, type: 'success',
}); duration:1000
},
//
handleConfirm(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
const data = new URLSearchParams();
data.append('name', this.productAttrCate.name);
if (this.dialogTitle === '添加类型') {
//
createProductAttrCate(data).then(() => {
this.$message({ message: '添加成功', type: 'success', duration: 1000 });
this.dialogVisible = false;
this.getList();
}); });
this.getList();
});
});
},
handleUpdate(index, row) {
this.dialogVisible = true;
this.dialogTitle = "编辑类型";
this.productAttrCate.name = row.name;
this.productAttrCate.id = row.id;
},
getAttrList(index, row) {
this.$router.push({path: '/pms/productAttrList',query:{cid:row.id,cname:row.name,type:0}})
},
getParamList(index, row) {
this.$router.push({path: '/pms/productAttrList',query:{cid:row.id,cname:row.name,type:1}})
},
handleConfirm(formName){
this.$refs[formName].validate((valid) => {
if (valid) {
let data = new URLSearchParams();
data.append("name",this.productAttrCate.name);
if(this.dialogTitle==="添加类型"){
createProductAttrCate(data).then(response=>{
this.$message({
message: '添加成功',
type: 'success',
duration:1000
});
this.dialogVisible = false;
this.getList();
});
}else{
updateProductAttrCate(this.productAttrCate.id,data).then(response=>{
this.$message({
message: '修改成功',
type: 'success',
duration:1000
});
this.dialogVisible = false;
this.getList();
});
}
} else { } else {
// console.log('error submit!!');
updateProductAttrCate(this.productAttrCate.id, data).then(() => { return false;
this.$message({ message: '修改成功', type: 'success', duration: 1000 });
this.dialogVisible = false;
this.getList();
});
} }
});
},
handleClose(){
if (!this.dialogVisible && this.$refs.productAttrCatForm) {
this.$refs.productAttrCatForm.clearValidate()
} }
});
},
//
handleClose() {
if (this.$refs.productAttrCatForm) {
this.$refs.productAttrCatForm.clearValidate();
} }
}, }
}, }
};
</script> </script>
<style rel="stylesheet/scss" lang="scss" scoped>
<style scoped>
.app-container {
padding: 20px;
}
</style> </style>

@ -1,248 +1,219 @@
<template> <template> 
<!-- 商品属性列表页面 -->
<div class="app-container"> <div class="app-container">
<!-- 操作栏包含添加按钮 -->
<el-card class="operate-container" shadow="never"> <el-card class="operate-container" shadow="never">
<i class="el-icon-tickets" style="margin-top: 5px"></i> <i class="el-icon-tickets" style="margin-top: 5px"></i>
<span style="margin-top: 5px">数据列表</span> <span style="margin-top: 5px">数据列表</span>
<!-- 添加按钮跳转到添加商品属性页面 --> <el-button
<el-button class="btn-add" @click="addProductAttr()" size="mini">添加</el-button> class="btn-add"
@click="addProductAttr()"
size="mini">
添加
</el-button>
</el-card> </el-card>
<!-- 数据表格区域 -->
<div class="table-container"> <div class="table-container">
<el-table <el-table ref="productAttrTable"
ref="productAttrTable" :data="list"
:data="list" style="width: 100%"
style="width: 100%" @selection-change="handleSelectionChange"
@selection-change="handleSelectionChange" v-loading="listLoading"
v-loading="listLoading" border>
border
>
<!-- 多选框 -->
<el-table-column type="selection" width="60" align="center"></el-table-column> <el-table-column type="selection" width="60" align="center"></el-table-column>
<!-- 编号列 -->
<el-table-column label="编号" width="100" align="center"> <el-table-column label="编号" width="100" align="center">
<template slot-scope="scope">{{ scope.row.id }}</template> <template slot-scope="scope">{{scope.row.id}}</template>
</el-table-column> </el-table-column>
<!-- 属性名称列 -->
<el-table-column label="属性名称" width="140" align="center"> <el-table-column label="属性名称" width="140" align="center">
<template slot-scope="scope">{{ scope.row.name }}</template> <template slot-scope="scope">{{scope.row.name}}</template>
</el-table-column> </el-table-column>
<!-- 商品类型列 -->
<el-table-column label="商品类型" width="140" align="center"> <el-table-column label="商品类型" width="140" align="center">
<template slot-scope="scope">{{ $route.query.cname }}</template> <template slot-scope="scope">{{$route.query.cname}}</template>
</el-table-column> </el-table-column>
<!-- 属性是否可选列 -->
<el-table-column label="属性是否可选" width="120" align="center"> <el-table-column label="属性是否可选" width="120" align="center">
<template slot-scope="scope">{{ scope.row.selectType | selectTypeFilter }}</template> <template slot-scope="scope">{{scope.row.selectType|selectTypeFilter}}</template>
</el-table-column> </el-table-column>
<!-- 属性值录入方式列 -->
<el-table-column label="属性值的录入方式" width="150" align="center"> <el-table-column label="属性值的录入方式" width="150" align="center">
<template slot-scope="scope">{{ scope.row.inputType | inputTypeFilter }}</template> <template slot-scope="scope">{{scope.row.inputType|inputTypeFilter}}</template>
</el-table-column> </el-table-column>
<!-- 可选值列表列 -->
<el-table-column label="可选值列表" align="center"> <el-table-column label="可选值列表" align="center">
<template slot-scope="scope">{{ scope.row.inputList }}</template> <template slot-scope="scope">{{scope.row.inputList}}</template>
</el-table-column> </el-table-column>
<!-- 排序列 -->
<el-table-column label="排序" width="100" align="center"> <el-table-column label="排序" width="100" align="center">
<template slot-scope="scope">{{ scope.row.sort }}</template> <template slot-scope="scope">{{scope.row.sort}}</template>
</el-table-column> </el-table-column>
<!-- 操作列 -->
<el-table-column label="操作" width="200" align="center"> <el-table-column label="操作" width="200" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<!-- 编辑按钮 --> <el-button
<el-button size="mini" @click="handleUpdate(scope.$index, scope.row)">编辑</el-button> size="mini"
<!-- 删除按钮 --> @click="handleUpdate(scope.$index, scope.row)">编辑
<el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button> </el-button>
<el-button
size="mini"
type="danger"
@click="handleDelete(scope.$index, scope.row)">删除
</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</div> </div>
<!-- 批量操作栏 -->
<div class="batch-operate-container"> <div class="batch-operate-container">
<el-select size="small" v-model="operateType" placeholder="批量操作"> <el-select
size="small"
v-model="operateType" placeholder="批量操作">
<el-option <el-option
v-for="item in operates" v-for="item in operates"
:key="item.value" :key="item.value"
:label="item.label" :label="item.label"
:value="item.value" :value="item.value">
></el-option> </el-option>
</el-select> </el-select>
<el-button <el-button
style="margin-left: 20px" style="margin-left: 20px"
class="search-button" class="search-button"
@click="handleBatchOperate()" @click="handleBatchOperate()"
type="primary" type="primary"
size="small" size="small">
>
确定 确定
</el-button> </el-button>
</div> </div>
<!-- 分页组件 -->
<div class="pagination-container"> <div class="pagination-container">
<el-pagination <el-pagination
background background
@size-change="handleSizeChange" @size-change="handleSizeChange"
@current-change="handleCurrentChange" @current-change="handleCurrentChange"
layout="total, sizes, prev, pager, next, jumper" layout="total, sizes,prev, pager, next,jumper"
:page-size="listQuery.pageSize" :page-size="listQuery.pageSize"
:page-sizes="[5, 10, 15]" :page-sizes="[5,10,15]"
:current-page.sync="listQuery.pageNum" :current-page.sync="listQuery.pageNum"
:total="total" :total="total">
></el-pagination> </el-pagination>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
/** import {fetchList, deleteProductAttr} from '@/api/productAttr'
* 导入商品属性相关 API
*/ export default {
import { fetchList, deleteProductAttr } from '@/api/productAttr'; name: 'productAttrList',
data() {
export default { return {
name: 'productAttrList', // list: null,
data() { total: null,
return { listLoading: true,
list: null, // listQuery: {
total: null, // pageNum: 1,
listLoading: true, // pageSize: 5,
listQuery: { type: this.$route.query.type
pageNum: 1, },
pageSize: 5, operateType: null,
type: this.$route.query.type, // multipleSelection: [],
}, operates: [
operateType: null, // {
multipleSelection: [], // label: "删除",
operates: [ value: "deleteProductAttr"
{ label: '删除', value: 'deleteProductAttr' }, // }
], ]
};
},
created() {
this.getList(); //
},
methods: {
//
getList() {
this.listLoading = true;
fetchList(this.$route.query.cid, this.listQuery).then((response) => {
this.listLoading = false;
this.list = response.data.list;
this.total = response.data.total;
});
},
//
addProductAttr() {
this.$router.push({
path: '/pms/addProductAttr',
query: { cid: this.$route.query.cid, type: this.$route.query.type },
});
},
//
handleSelectionChange(val) {
this.multipleSelection = val;
},
//
handleBatchOperate() {
if (this.multipleSelection.length < 1) {
this.$message({
message: '请选择至少一条记录',
type: 'warning',
duration: 1000,
});
return;
} }
if (this.operateType !== 'deleteProductAttr') {
this.$message({
message: '请选择批量操作类型',
type: 'warning',
duration: 1000,
});
return;
}
const ids = this.multipleSelection.map((item) => item.id);
this.handleDeleteProductAttr(ids);
}, },
created() {
//
handleSizeChange(val) {
this.listQuery.pageNum = 1;
this.listQuery.pageSize = val;
this.getList();
},
//
handleCurrentChange(val) {
this.listQuery.pageNum = val;
this.getList(); this.getList();
}, },
methods: {
// getList() {
handleUpdate(index, row) { this.listLoading = true;
this.$router.push({ path: '/pms/updateProductAttr', query: { id: row.id } }); fetchList(this.$route.query.cid, this.listQuery).then(response => {
}, this.listLoading = false;
this.list = response.data.list;
// this.total = response.data.total;
handleDeleteProductAttr(ids) { });
this.$confirm('是否要删除选中的属性?', '提示', { },
confirmButtonText: '确定', addProductAttr() {
cancelButtonText: '取消', this.$router.push({path:'/pms/addProductAttr',query:{cid:this.$route.query.cid,type:this.$route.query.type}});
type: 'warning', },
}).then(() => { handleSelectionChange(val) {
const data = new URLSearchParams(); this.multipleSelection = val;
data.append('ids', ids); },
deleteProductAttr(data).then(() => { handleBatchOperate() {
if (this.multipleSelection < 1) {
this.$message({ this.$message({
message: '删除成功', message: '请选择一条记录',
type: 'success', type: 'warning',
duration: 1000, duration: 1000
});
return;
}
if (this.operateType !== 'deleteProductAttr') {
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);
}
this.handleDeleteProductAttr(ids);
},
handleSizeChange(val) {
this.listQuery.pageNum = 1;
this.listQuery.pageSize = val;
this.getList();
},
handleCurrentChange(val) {
this.listQuery.pageNum = val;
this.getList();
},
handleUpdate(index, row) {
this.$router.push({path:'/pms/updateProductAttr',query:{id:row.id}});
},
handleDeleteProductAttr(ids) {
this.$confirm('是否要删除该属性', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let data = new URLSearchParams();
data.append("ids", ids);
deleteProductAttr(data).then(response => {
this.$message({
message: '删除成功',
type: 'success',
duration: 1000
});
this.getList();
}); });
this.getList();
}); });
}); },
}, handleDelete(index, row) {
let ids = [];
// ids.push(row.id);
handleDelete(index, row) { this.handleDeleteProductAttr(ids);
const ids = [row.id]; },
this.handleDeleteProductAttr(ids);
},
},
filters: {
//
inputTypeFilter(value) {
return value === 1 ? '从列表中选取' : '手工录入';
},
//
selectTypeFilter(value) {
if (value === 1) return '单选';
if (value === 2) return '多选';
return '唯一';
}, },
}, filters: {
}; inputTypeFilter(value) {
if (value === 1) {
return '从列表中选取';
} else {
return '手工录入'
}
},
selectTypeFilter(value) {
if (value === 1) {
return '单选';
} else if (value === 2) {
return '多选';
} else {
return '唯一'
}
},
}
}
</script> </script>
<style scoped> <style rel="stylesheet/scss" lang="scss" scoped>
/* 自定义样式区域 */
.app-container {
padding: 20px;
}
</style> </style>

@ -1,20 +1,15 @@
<template> <template>
<!-- 引入商品属性详情组件编辑模式下展示 --> <product-attr-detail :is-edit='true'></product-attr-detail>
<product-attr-detail :is-edit="true"></product-attr-detail>
</template> </template>
<script> <script>
// import ProductAttrDetail from './components/ProductAttrDetail'
import ProductAttrDetail from './components/ProductAttrDetail';
export default { export default {
name: 'updateProductAttr', // name: 'updateProductAttr',
components: { components: { ProductAttrDetail }
ProductAttrDetail, // ProductAttrDetail }
},
};
</script> </script>
<style scoped> <style scoped>
/* scoped 表示样式只会应用于当前组件 */
</style> </style>

@ -1,20 +1,14 @@
<template> <template> 
<!-- 渲染分类详情组件is-edit false 表示添加模式 --> <product-cate-detail :is-edit='false'></product-cate-detail>
<product-cate-detail :is-edit="false"></product-cate-detail>
</template> </template>
<script> <script>
// import ProductCateDetail from './components/ProductCateDetail'
import ProductCateDetail from './components/ProductCateDetail';
export default { export default {
name: 'addProductCate', // name: 'addProductCate',
components: { components: { ProductCateDetail }
ProductCateDetail, // ProductCateDetail }
},
};
</script> </script>
<style> <style>
/* 样式作用域:默认留空,可以根据需要添加样式 */
</style> </style>

@ -1,19 +1,15 @@
<template> <template>
<!-- 分类详情表单使用 Element UI -->
<el-card class="form-container" shadow="never"> <el-card class="form-container" shadow="never">
<el-form :model="productCate" <el-form :model="productCate"
:rules="rules" :rules="rules"
ref="productCateFrom" ref="productCateFrom"
label-width="150px"> label-width="150px">
<!-- 分类名称输入框 -->
<el-form-item label="分类名称:" prop="name"> <el-form-item label="分类名称:" prop="name">
<el-input v-model="productCate.name"></el-input> <el-input v-model="productCate.name"></el-input>
</el-form-item> </el-form-item>
<!-- 上级分类选择框 -->
<el-form-item label="上级分类:"> <el-form-item label="上级分类:">
<el-select v-model="productCate.parentId" placeholder="请选择分类"> <el-select v-model="productCate.parentId"
placeholder="请选择分类">
<el-option <el-option
v-for="item in selectProductCateList" v-for="item in selectProductCateList"
:key="item.id" :key="item.id"
@ -22,67 +18,47 @@
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<!-- 数量单位输入框 -->
<el-form-item label="数量单位:"> <el-form-item label="数量单位:">
<el-input v-model="productCate.productUnit"></el-input> <el-input v-model="productCate.productUnit"></el-input>
</el-form-item> </el-form-item>
<!-- 排序输入框 -->
<el-form-item label="排序:"> <el-form-item label="排序:">
<el-input v-model="productCate.sort"></el-input> <el-input v-model="productCate.sort"></el-input>
</el-form-item> </el-form-item>
<!-- 是否显示单选按钮 -->
<el-form-item label="是否显示:"> <el-form-item label="是否显示:">
<el-radio-group v-model="productCate.showStatus"> <el-radio-group v-model="productCate.showStatus">
<el-radio :label="1"></el-radio> <el-radio :label="1"></el-radio>
<el-radio :label="0"></el-radio> <el-radio :label="0"></el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<!-- 是否显示在导航栏 -->
<el-form-item label="是否显示在导航栏:"> <el-form-item label="是否显示在导航栏:">
<el-radio-group v-model="productCate.navStatus"> <el-radio-group v-model="productCate.navStatus">
<el-radio :label="1"></el-radio> <el-radio :label="1"></el-radio>
<el-radio :label="0"></el-radio> <el-radio :label="0"></el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<!-- 分类图标上传组件 -->
<el-form-item label="分类图标:"> <el-form-item label="分类图标:">
<single-upload v-model="productCate.icon"></single-upload> <single-upload v-model="productCate.icon"></single-upload>
</el-form-item> </el-form-item>
<!-- 筛选属性列表 -->
<el-form-item v-for="(filterProductAttr, index) in filterProductAttrList" <el-form-item v-for="(filterProductAttr, index) in filterProductAttrList"
:label="index | filterLabelFilter" :label="index | filterLabelFilter"
:key="filterProductAttr.key"> :key="filterProductAttr.key"
>
<el-cascader <el-cascader
clearable clearable
v-model="filterProductAttr.value" v-model="filterProductAttr.value"
:options="filterAttrs"> :options="filterAttrs">
</el-cascader> </el-cascader>
<!-- 删除按钮 -->
<el-button style="margin-left: 20px" @click.prevent="removeFilterAttr(filterProductAttr)">删除</el-button> <el-button style="margin-left: 20px" @click.prevent="removeFilterAttr(filterProductAttr)">删除</el-button>
</el-form-item> </el-form-item>
<!-- 新增筛选属性按钮 -->
<el-form-item> <el-form-item>
<el-button size="small" type="primary" @click="handleAddFilterAttr()"></el-button> <el-button size="small" type="primary" @click="handleAddFilterAttr()"></el-button>
</el-form-item> </el-form-item>
<!-- 关键词输入框 -->
<el-form-item label="关键词:"> <el-form-item label="关键词:">
<el-input v-model="productCate.keywords"></el-input> <el-input v-model="productCate.keywords"></el-input>
</el-form-item> </el-form-item>
<!-- 分类描述输入框 -->
<el-form-item label="分类描述:"> <el-form-item label="分类描述:">
<el-input type="textarea" :autosize="true" v-model="productCate.description"></el-input> <el-input type="textarea" :autosize="true" v-model="productCate.description"></el-input>
</el-form-item> </el-form-item>
<!-- 提交和重置按钮 -->
<el-form-item> <el-form-item>
<el-button type="primary" @click="onSubmit('productCateFrom')"></el-button> <el-button type="primary" @click="onSubmit('productCateFrom')"></el-button>
<el-button v-if="!isEdit" @click="resetForm('productCateFrom')"></el-button> <el-button v-if="!isEdit" @click="resetForm('productCateFrom')"></el-button>
@ -92,7 +68,6 @@
</template> </template>
<script> <script>
// API
import {fetchList, createProductCate, updateProductCate, getProductCate} from '@/api/productCate'; import {fetchList, createProductCate, updateProductCate, getProductCate} from '@/api/productCate';
import {fetchListWithAttr} from '@/api/productAttrCate'; import {fetchListWithAttr} from '@/api/productAttrCate';
import {getProductAttrInfo} from '@/api/productAttr'; import {getProductAttrInfo} from '@/api/productAttr';
@ -110,10 +85,9 @@
sort: 0, sort: 0,
productAttributeIdList: [] productAttributeIdList: []
}; };
export default { export default {
name: "ProductCateDetail", name: "ProductCateDetail",
components: { SingleUpload }, components: {SingleUpload},
props: { props: {
isEdit: { isEdit: {
type: Boolean, type: Boolean,
@ -123,114 +97,168 @@
data() { data() {
return { return {
productCate: Object.assign({}, defaultProductCate), productCate: Object.assign({}, defaultProductCate),
selectProductCateList: [], // selectProductCateList: [],
rules: { rules: {
name: [ name: [
{ required: true, message: '请输入品牌名称', trigger: 'blur' }, {required: true, message: '请输入品牌名称', trigger: 'blur'},
{ min: 2, max: 140, message: '长度在 2 到 140 个字符', trigger: 'blur' } {min: 2, max: 140, message: '长度在 2 到 140 个字符', trigger: 'blur'}
] ]
}, },
filterAttrs: [], // filterAttrs: [],
filterProductAttrList: [{ value: [] }] // filterProductAttrList: [{
}; value: []
}]
}
}, },
created() { created() {
if (this.isEdit) { if (this.isEdit) {
//
getProductCate(this.$route.query.id).then(response => { getProductCate(this.$route.query.id).then(response => {
this.productCate = response.data; this.productCate = response.data;
}); });
//
getProductAttrInfo(this.$route.query.id).then(response => { getProductAttrInfo(this.$route.query.id).then(response => {
if (response.data != null && response.data.length > 0) { if (response.data != null && response.data.length > 0) {
this.filterProductAttrList = response.data.map((item, index) => ({ this.filterProductAttrList = [];
key: Date.now() + index, for (let i = 0; i < response.data.length; i++) {
value: [item.attributeCategoryId, item.attributeId] this.filterProductAttrList.push({
})); key: Date.now() + i,
value: [response.data[i].attributeCategoryId, response.data[i].attributeId]
})
}
} }
}); });
} else {
this.productCate = Object.assign({}, defaultProductCate);
} }
this.getSelectProductCateList(); this.getSelectProductCateList();
this.getProductAttrCateList(); this.getProductAttrCateList();
}, },
methods: { methods: {
//
getSelectProductCateList() { getSelectProductCateList() {
fetchList(0, { pageSize: 100, pageNum: 1 }).then(response => { fetchList(0, {pageSize: 100, pageNum: 1}).then(response => {
this.selectProductCateList = response.data.list; this.selectProductCateList = response.data.list;
this.selectProductCateList.unshift({ id: 0, name: '无上级分类' }); this.selectProductCateList.unshift({id: 0, name: '无上级分类'});
}); });
}, },
//
getProductAttrCateList() { getProductAttrCateList() {
fetchListWithAttr().then(response => { fetchListWithAttr().then(response => {
this.filterAttrs = response.data.map(category => ({ let list = response.data;
label: category.name, for (let i = 0; i < list.length; i++) {
value: category.id, let productAttrCate = list[i];
children: category.productAttributeList.map(attr => ({ let children = [];
label: attr.name, if (productAttrCate.productAttributeList != null && productAttrCate.productAttributeList.length > 0) {
value: attr.id for (let j = 0; j < productAttrCate.productAttributeList.length; j++) {
})) children.push({
})); label: productAttrCate.productAttributeList[j].name,
value: productAttrCate.productAttributeList[j].id
})
}
}
this.filterAttrs.push({label: productAttrCate.name, value: productAttrCate.id, children: children});
}
}); });
}, },
// getProductAttributeIdList() {
//
let productAttributeIdList = [];
for (let i = 0; i < this.filterProductAttrList.length; i++) {
let item = this.filterProductAttrList[i];
if (item.value !== null && item.value.length === 2) {
productAttributeIdList.push(item.value[1]);
}
}
return productAttributeIdList;
},
onSubmit(formName) { onSubmit(formName) {
this.$refs[formName].validate(valid => { this.$refs[formName].validate((valid) => {
if (valid) { if (valid) {
this.$confirm('是否提交数据', '提示', { type: 'warning' }).then(() => { this.$confirm('是否提交数据', '提示', {
this.productCate.productAttributeIdList = this.getProductAttributeIdList(); confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
if (this.isEdit) { if (this.isEdit) {
updateProductCate(this.$route.query.id, this.productCate).then(() => { this.productCate.productAttributeIdList = this.getProductAttributeIdList();
this.$message.success('修改成功'); updateProductCate(this.$route.query.id, this.productCate).then(response => {
this.$message({
message: '修改成功',
type: 'success',
duration: 1000
});
this.$router.back(); this.$router.back();
}); });
} else { } else {
createProductCate(this.productCate).then(() => { this.productCate.productAttributeIdList = this.getProductAttributeIdList();
createProductCate(this.productCate).then(response => {
this.$refs[formName].resetFields();
this.resetForm(formName); this.resetForm(formName);
this.$message.success('提交成功'); this.$message({
message: '提交成功',
type: 'success',
duration: 1000
});
}); });
} }
}); });
} else { } else {
this.$message.error('验证失败'); this.$message({
message: '验证失败',
type: 'error',
duration: 1000
});
return false;
} }
}); });
}, },
//
resetForm(formName) { resetForm(formName) {
this.$refs[formName].resetFields(); this.$refs[formName].resetFields();
this.productCate = Object.assign({}, defaultProductCate); this.productCate = Object.assign({}, defaultProductCate);
this.getSelectProductCateList();
this.filterProductAttrList = [{
value: []
}];
}, },
// ID removeFilterAttr(productAttributeId) {
getProductAttributeIdList() { if (this.filterProductAttrList.length === 1) {
return this.filterProductAttrList this.$message({
.filter(item => item.value.length === 2) message: '至少要留一个',
.map(item => item.value[1]); type: 'warning',
}, duration: 1000
// });
removeFilterAttr(filterAttr) { return;
const index = this.filterProductAttrList.indexOf(filterAttr); }
if (index > -1) this.filterProductAttrList.splice(index, 1); var index = this.filterProductAttrList.indexOf(productAttributeId);
if (index !== -1) {
this.filterProductAttrList.splice(index, 1)
}
}, },
//
handleAddFilterAttr() { handleAddFilterAttr() {
if (this.filterProductAttrList.length < 3) { if (this.filterProductAttrList.length === 3) {
this.filterProductAttrList.push({ value: [], key: Date.now() }); this.$message({
} else { message: '最多添加三个',
this.$message.warning('最多添加三个'); type: 'warning',
duration: 1000
});
return;
} }
this.filterProductAttrList.push({
value: null,
key: Date.now()
});
} }
}, },
filters: { filters: {
//
filterLabelFilter(index) { filterLabelFilter(index) {
return index === 0 ? '筛选属性:' : ''; if (index === 0) {
return '筛选属性:';
} else {
return '';
}
} }
} }
}; }
</script> </script>
<style scoped> <style scoped>
/* 本地样式,样式只对当前组件生效 */
</style> </style>

@ -1,53 +1,35 @@
<template> <template>
<!-- 页面主容器 -->
<div class="app-container"> <div class="app-container">
<!-- 操作栏包含添加按钮 -->
<el-card class="operate-container" shadow="never"> <el-card class="operate-container" shadow="never">
<i class="el-icon-tickets" style="margin-top: 5px"></i> <i class="el-icon-tickets" style="margin-top: 5px"></i>
<span style="margin-top: 5px">数据列表</span> <span style="margin-top: 5px">数据列表</span>
<el-button <el-button
class="btn-add" class="btn-add"
@click="handleAddProductCate" @click="handleAddProductCate()"
size="mini"> size="mini">
添加 添加
</el-button> </el-button>
</el-card> </el-card>
<!-- 表格数据容器 -->
<div class="table-container"> <div class="table-container">
<el-table <el-table ref="productCateTable"
ref="productCateTable" style="width: 100%"
style="width: 100%" :data="list"
:data="list" v-loading="listLoading" border>
v-loading="listLoading"
border>
<!-- 编号 -->
<el-table-column label="编号" width="100" align="center"> <el-table-column label="编号" width="100" align="center">
<template slot-scope="scope">{{ scope.row.id }}</template> <template slot-scope="scope">{{scope.row.id}}</template>
</el-table-column> </el-table-column>
<!-- 分类名称 -->
<el-table-column label="分类名称" align="center"> <el-table-column label="分类名称" align="center">
<template slot-scope="scope">{{ scope.row.name }}</template> <template slot-scope="scope">{{scope.row.name}}</template>
</el-table-column> </el-table-column>
<!-- 级别 -->
<el-table-column label="级别" width="100" align="center"> <el-table-column label="级别" width="100" align="center">
<template slot-scope="scope">{{ scope.row.level | levelFilter }}</template> <template slot-scope="scope">{{scope.row.level | levelFilter}}</template>
</el-table-column> </el-table-column>
<!-- 商品数量 -->
<el-table-column label="商品数量" width="100" align="center"> <el-table-column label="商品数量" width="100" align="center">
<template slot-scope="scope">{{ scope.row.productCount }}</template> <template slot-scope="scope">{{scope.row.productCount }}</template>
</el-table-column> </el-table-column>
<!-- 数量单位 -->
<el-table-column label="数量单位" width="100" align="center"> <el-table-column label="数量单位" width="100" align="center">
<template slot-scope="scope">{{ scope.row.productUnit }}</template> <template slot-scope="scope">{{scope.row.productUnit }}</template>
</el-table-column> </el-table-column>
<!-- 导航栏显示状态 -->
<el-table-column label="导航栏" width="100" align="center"> <el-table-column label="导航栏" width="100" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-switch <el-switch
@ -58,8 +40,6 @@
</el-switch> </el-switch>
</template> </template>
</el-table-column> </el-table-column>
<!-- 是否显示 -->
<el-table-column label="是否显示" width="100" align="center"> <el-table-column label="是否显示" width="100" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-switch <el-switch
@ -70,13 +50,9 @@
</el-switch> </el-switch>
</template> </template>
</el-table-column> </el-table-column>
<!-- 排序 -->
<el-table-column label="排序" width="100" align="center"> <el-table-column label="排序" width="100" align="center">
<template slot-scope="scope">{{ scope.row.sort }}</template> <template slot-scope="scope">{{scope.row.sort }}</template>
</el-table-column> </el-table-column>
<!-- 设置操作 -->
<el-table-column label="设置" width="200" align="center"> <el-table-column label="设置" width="200" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
@ -90,8 +66,6 @@
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
<!-- 操作 -->
<el-table-column label="操作" width="200" align="center"> <el-table-column label="操作" width="200" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
@ -107,16 +81,14 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
</div> </div>
<!-- 分页组件 -->
<div class="pagination-container"> <div class="pagination-container">
<el-pagination <el-pagination
background background
@size-change="handleSizeChange" @size-change="handleSizeChange"
@current-change="handleCurrentChange" @current-change="handleCurrentChange"
layout="total, sizes, prev, pager, next, jumper" layout="total, sizes,prev, pager, next,jumper"
:page-size="listQuery.pageSize" :page-size="listQuery.pageSize"
:page-sizes="[5, 10, 15]" :page-sizes="[5,10,15]"
:current-page.sync="listQuery.pageNum" :current-page.sync="listQuery.pageNum"
:total="total"> :total="total">
</el-pagination> </el-pagination>
@ -125,46 +97,44 @@
</template> </template>
<script> <script>
// API import {fetchList,deleteProductCate,updateShowStatus,updateNavStatus} from '@/api/productCate'
import {
fetchList,
deleteProductCate,
updateShowStatus,
updateNavStatus
} from '@/api/productCate';
export default { export default {
name: "productCateList", name: "productCateList",
data() { data() {
return { return {
list: null, // list: null,
total: null, // total: null,
listLoading: true, // listLoading: true,
listQuery: { // listQuery: {
pageNum: 1, pageNum: 1,
pageSize: 5 pageSize: 5
}, },
parentId: 0 // ID parentId: 0
}; }
}, },
created() { created() {
this.resetParentId(); this.resetParentId();
this.getList(); this.getList();
}, },
watch: { watch: {
// $route(route) {
$route() {
this.resetParentId(); this.resetParentId();
this.getList(); this.getList();
} }
}, },
methods: { methods: {
// ID resetParentId(){
resetParentId() {
this.listQuery.pageNum = 1; this.listQuery.pageNum = 1;
this.parentId = this.$route.query.parentId || 0; if (this.$route.query.parentId != null) {
this.parentId = this.$route.query.parentId;
} else {
this.parentId = 0;
}
},
handleAddProductCate() {
this.$router.push('/pms/addProductCate');
}, },
//
getList() { getList() {
this.listLoading = true; this.listLoading = true;
fetchList(this.parentId, this.listQuery).then(response => { fetchList(this.parentId, this.listQuery).then(response => {
@ -173,77 +143,88 @@
this.total = response.data.total; this.total = response.data.total;
}); });
}, },
// handleSizeChange(val) {
handleAddProductCate() { this.listQuery.pageNum = 1;
this.$router.push('/pms/addProductCate'); this.listQuery.pageSize = val;
this.getList();
},
handleCurrentChange(val) {
this.listQuery.pageNum = val;
this.getList();
}, },
//
handleNavStatusChange(index, row) { handleNavStatusChange(index, row) {
let data = new URLSearchParams(); let data = new URLSearchParams();
data.append('ids', row.id); let ids=[];
data.append('navStatus', row.navStatus); ids.push(row.id)
updateNavStatus(data).then(() => { data.append('ids',ids);
this.$message.success('修改成功'); data.append('navStatus',row.navStatus);
updateNavStatus(data).then(response=>{
this.$message({
message: '修改成功',
type: 'success',
duration: 1000
});
}); });
}, },
//
handleShowStatusChange(index, row) { handleShowStatusChange(index, row) {
let data = new URLSearchParams(); let data = new URLSearchParams();
data.append('ids', row.id); let ids=[];
data.append('showStatus', row.showStatus); ids.push(row.id)
updateShowStatus(data).then(() => { data.append('ids',ids);
this.$message.success('修改成功'); data.append('showStatus',row.showStatus);
updateShowStatus(data).then(response=>{
this.$message({
message: '修改成功',
type: 'success',
duration: 1000
});
}); });
}, },
//
handleShowNextLevel(index, row) { handleShowNextLevel(index, row) {
this.$router.push({ path: '/pms/productCate', query: { parentId: row.id } }); this.$router.push({path: '/pms/productCate', query: {parentId: row.id}})
},
handleTransferProduct(index, row) {
console.log('handleAddProductCate');
}, },
//
handleUpdate(index, row) { handleUpdate(index, row) {
this.$router.push({ path: '/pms/updateProductCate', query: { id: row.id } }); this.$router.push({path:'/pms/updateProductCate',query:{id:row.id}});
}, },
//
handleDelete(index, row) { handleDelete(index, row) {
this.$confirm('是否要删除该分类?', '提示', { this.$confirm('是否要删除该品牌', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
deleteProductCate(row.id).then(() => { deleteProductCate(row.id).then(response => {
this.$message.success('删除成功'); this.$message({
message: '删除成功',
type: 'success',
duration: 1000
});
this.getList(); this.getList();
}); });
}); });
},
//
handleSizeChange(val) {
this.listQuery.pageSize = val;
this.getList();
},
//
handleCurrentChange(val) {
this.listQuery.pageNum = val;
this.getList();
},
//
handleTransferProduct() {
this.$message.info('功能待实现');
} }
}, },
filters: { filters: {
//
levelFilter(value) { levelFilter(value) {
return value === 0 ? '一级' : '二级'; if (value === 0) {
return '一级';
} else if (value === 1) {
return '二级';
}
}, },
//
disableNextLevel(value) { disableNextLevel(value) {
return value !== 0; if (value === 0) {
return false;
} else {
return true;
}
} }
} }
}; }
</script> </script>
<style scoped> <style scoped>
/* 样式留空,按需添加 */
</style> </style>

@ -1,20 +1,14 @@
<template> <template> 
<!-- 渲染分类详情组件is-edit true 表示编辑模式 --> <product-cate-detail :is-edit='true'></product-cate-detail>
<product-cate-detail :is-edit="true"></product-cate-detail>
</template> </template>
<script> <script>
// import ProductCateDetail from './components/ProductCateDetail'
import ProductCateDetail from './components/ProductCateDetail';
export default { export default {
name: 'updateProductCate', // name: 'updateProductCate',
components: { components: { ProductCateDetail }
ProductCateDetail, // ProductCateDetail }
},
};
</script> </script>
<style> <style>
/* 样式部分留空,便于后续根据页面需求自定义样式 */
</style> </style>

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

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

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

@ -1,17 +1,13 @@
<template> <template> 
<!-- 在模板中使用了名为home-advertise-detail的自定义组件并传递了一个名为isEdit且值为true的属性可能用于控制该组件处于编辑状态相关的展示或功能 -->
<home-advertise-detail :isEdit="true"></home-advertise-detail> <home-advertise-detail :isEdit="true"></home-advertise-detail>
</template> </template>
<script> <script>
// HomeAdvertiseDetail'./components/HomeAdvertiseDetail' import HomeAdvertiseDetail from './components/HomeAdvertiseDetail'
import HomeAdvertiseDetail from './components/HomeAdvertiseDetail' export default {
export default { name: 'updateHomeAdvertise',
name: 'updateHomeAdvertise', components: { HomeAdvertiseDetail }
// HomeAdvertiseDetail使使 }
components: { HomeAdvertiseDetail }
}
</script> </script>
<style></style> <style></style>

@ -1,14 +1,9 @@
<template> <template> 
<!-- 页面整体的外层容器用于布局和包裹内部各部分内容 -->
<div class="app-container"> <div class="app-container">
<!-- 筛选搜索区域的卡片容器设置无阴影效果 -->
<el-card class="filter-container" shadow="never"> <el-card class="filter-container" shadow="never">
<div> <div>
<!-- 显示搜索图标 -->
<i class="el-icon-search"></i> <i class="el-icon-search"></i>
<!-- 显示筛选搜索的文字提示 -->
<span>筛选搜索</span> <span>筛选搜索</span>
<!-- 用于触发查询搜索的按钮绑定对应点击事件设置样式等属性 -->
<el-button <el-button
style="float:right" style="float:right"
type="primary" type="primary"
@ -16,7 +11,6 @@
size="small"> size="small">
查询搜索 查询搜索
</el-button> </el-button>
<!-- 用于重置筛选条件的按钮绑定对应点击事件设置样式等属性 -->
<el-button <el-button
style="float:right;margin-right: 15px" style="float:right;margin-right: 15px"
@click="handleResetSearch()" @click="handleResetSearch()"
@ -25,18 +19,12 @@
</el-button> </el-button>
</div> </div>
<div style="margin-top: 15px"> <div style="margin-top: 15px">
<!-- 行内表单绑定数据模型设置尺寸标签宽度等属性 -->
<el-form :inline="true" :model="listQuery" size="small" label-width="140px"> <el-form :inline="true" :model="listQuery" size="small" label-width="140px">
<!-- 品牌名称输入框的表单项 -->
<el-form-item label="品牌名称:"> <el-form-item label="品牌名称:">
<!-- 输入框双向绑定品牌名称数据设置类名和占位提示 -->
<el-input v-model="listQuery.brandName" class="input-width" placeholder="品牌名称"></el-input> <el-input v-model="listQuery.brandName" class="input-width" placeholder="品牌名称"></el-input>
</el-form-item> </el-form-item>
<!-- 推荐状态选择框的表单项 -->
<el-form-item label="推荐状态:"> <el-form-item label="推荐状态:">
<!-- 下拉选择框双向绑定推荐状态数据设置占位提示等属性 -->
<el-select v-model="listQuery.recommendStatus" placeholder="全部" clearable class="input-width"> <el-select v-model="listQuery.recommendStatus" placeholder="全部" clearable class="input-width">
<!-- 循环生成下拉选项 -->
<el-option v-for="item in recommendOptions" <el-option v-for="item in recommendOptions"
:key="item.value" :key="item.value"
:label="item.label" :label="item.label"
@ -47,51 +35,40 @@
</el-form> </el-form>
</div> </div>
</el-card> </el-card>
<!-- 操作区域的卡片容器无阴影效果 -->
<el-card class="operate-container" shadow="never"> <el-card class="operate-container" shadow="never">
<i class="el-icon-tickets"></i> <i class="el-icon-tickets"></i>
<span>数据列表</span> <span>数据列表</span>
<!-- 用于触发选择品牌操作的按钮绑定点击事件 -->
<el-button size="mini" class="btn-add" @click="handleSelectBrand()"></el-button> <el-button size="mini" class="btn-add" @click="handleSelectBrand()"></el-button>
</el-card> </el-card>
<!-- 放置数据表格的容器 -->
<div class="table-container"> <div class="table-container">
<!-- 数据表格组件绑定数据设置宽度等属性还有选择改变等相关事件 -->
<el-table ref="homeBrandTable" <el-table ref="homeBrandTable"
:data="list" :data="list"
style="width: 100%;" style="width: 100%;"
@selection-change="handleSelectionChange" @selection-change="handleSelectionChange"
v-loading="listLoading" border> v-loading="listLoading" border>
<!-- 显示选择框的表格列 -->
<el-table-column type="selection" width="60" align="center"></el-table-column> <el-table-column type="selection" width="60" align="center"></el-table-column>
<!-- 显示编号的表格列 -->
<el-table-column label="编号" width="120" align="center"> <el-table-column label="编号" width="120" align="center">
<template slot-scope="scope">{{scope.row.id}}</template> <template slot-scope="scope">{{scope.row.id}}</template>
</el-table-column> </el-table-column>
<!-- 显示品牌名称的表格列 -->
<el-table-column label="品牌名称" align="center"> <el-table-column label="品牌名称" align="center">
<template slot-scope="scope">{{scope.row.brandName}}</template> <template slot-scope="scope">{{scope.row.brandName}}</template>
</el-table-column> </el-table-column>
<!-- 通过开关显示是否推荐的表格列绑定状态改变事件 -->
<el-table-column label="是否推荐" width="200" align="center"> <el-table-column label="是否推荐" width="200" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-switch <el-switch
@change="handleRecommendStatusStatusChange(scope.$index, scope.row)" @change="handleRecommendStatusStatusChange(scope.$index, scope.row)"
:active-value="1" :active-value="1"
:inactive-value="0" :inactive-value="0"
v-model="scope.row.recommendStatus"> v-model="scope.row.recommendStatus">
</el-switch> </el-switch>
</template> </template>
</el-table-column> </el-table-column>
<!-- 显示排序的表格列 -->
<el-table-column label="排序" width="160" align="center"> <el-table-column label="排序" width="160" align="center">
<template slot-scope="scope">{{scope.row.sort}}</template> <template slot-scope="scope">{{scope.row.sort}}</template>
</el-table-column> </el-table-column>
<!-- 显示状态的表格列使用过滤器格式化内容 -->
<el-table-column label="状态" width="160" align="center"> <el-table-column label="状态" width="160" align="center">
<template slot-scope="scope">{{scope.row.recommendStatus | formatRecommendStatus}}</template> <template slot-scope="scope">{{scope.row.recommendStatus | formatRecommendStatus}}</template>
</el-table-column> </el-table-column>
<!-- 显示操作按钮的表格列 -->
<el-table-column label="操作" width="180" align="center"> <el-table-column label="操作" width="180" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button size="mini" <el-button size="mini"
@ -106,13 +83,10 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
</div> </div>
<!-- 批量操作相关选择框和按钮的容器 -->
<div class="batch-operate-container"> <div class="batch-operate-container">
<!-- 选择批量操作类型的下拉框双向绑定操作类型数据 -->
<el-select <el-select
size="small" size="small"
v-model="operateType" placeholder="批量操作"> v-model="operateType" placeholder="批量操作">
<!-- 循环生成下拉选项 -->
<el-option <el-option
v-for="item in operates" v-for="item in operates"
:key="item.value" :key="item.value"
@ -120,7 +94,6 @@
:value="item.value"> :value="item.value">
</el-option> </el-option>
</el-select> </el-select>
<!-- 触发批量操作的按钮设置样式类型等属性绑定点击事件 -->
<el-button <el-button
style="margin-left: 20px" style="margin-left: 20px"
class="search-button" class="search-button"
@ -130,9 +103,7 @@
确定 确定
</el-button> </el-button>
</div> </div>
<!-- 分页组件的容器 -->
<div class="pagination-container"> <div class="pagination-container">
<!-- 分页组件设置背景各类事件绑定页面尺寸等属性 -->
<el-pagination <el-pagination
background background
@size-change="handleSizeChange" @size-change="handleSizeChange"
@ -144,26 +115,19 @@
:total="total"> :total="total">
</el-pagination> </el-pagination>
</div> </div>
<!-- 选择品牌的对话框组件设置标题可见性绑定宽度等属性 -->
<el-dialog title="选择品牌" :visible.sync="selectDialogVisible" width="40%"> <el-dialog title="选择品牌" :visible.sync="selectDialogVisible" width="40%">
<!-- 对话框内的品牌名称搜索输入框绑定数据设置样式等属性 -->
<el-input v-model="dialogData.listQuery.keyword" <el-input v-model="dialogData.listQuery.keyword"
style="width: 250px;margin-bottom: 20px" style="width: 250px;margin-bottom: 20px"
size="small" size="small"
placeholder="品牌名称搜索"> placeholder="品牌名称搜索">
<!-- 输入框后的搜索按钮绑定点击事件 -->
<el-button slot="append" icon="el-icon-search" @click="handleSelectSearch()"></el-button> <el-button slot="append" icon="el-icon-search" @click="handleSelectSearch()"></el-button>
</el-input> </el-input>
<!-- 对话框内展示品牌相关数据的表格设置数据绑定选择改变事件等属性 -->
<el-table :data="dialogData.list" <el-table :data="dialogData.list"
@selection-change="handleDialogSelectionChange" border> @selection-change="handleDialogSelectionChange" border>
<!-- 显示选择框的表格列 -->
<el-table-column type="selection" width="60" align="center"></el-table-column> <el-table-column type="selection" width="60" align="center"></el-table-column>
<!-- 显示品牌名称的表格列 -->
<el-table-column label="品牌名称"align="center"> <el-table-column label="品牌名称"align="center">
<template slot-scope="scope">{{scope.row.name}}</template> <template slot-scope="scope">{{scope.row.name}}</template>
</el-table-column> </el-table-column>
<!-- 显示相关商品和评价数量信息的表格列 -->
<el-table-column label="相关" width="220" align="center"> <el-table-column label="相关" width="220" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
商品<span class="color-main">{{scope.row.productCount}}</span> 商品<span class="color-main">{{scope.row.productCount}}</span>
@ -171,9 +135,7 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<!-- 对话框内的分页组件容器 -->
<div class="pagination-container"> <div class="pagination-container">
<!-- 分页组件设置背景各类事件绑定页面尺寸等属性 -->
<el-pagination <el-pagination
background background
@size-change="handleDialogSizeChange" @size-change="handleDialogSizeChange"
@ -187,30 +149,23 @@
</div> </div>
<div style="clear: both;"></div> <div style="clear: both;"></div>
<div slot="footer"> <div slot="footer">
<!-- 对话框取消按钮点击隐藏对话框 -->
<el-button size="small" @click="selectDialogVisible = false"> </el-button> <el-button size="small" @click="selectDialogVisible = false"> </el-button>
<!-- 对话框确认按钮绑定点击事件 -->
<el-button size="small" type="primary" @click="handleSelectDialogConfirm()"> </el-button> <el-button size="small" type="primary" @click="handleSelectDialogConfirm()"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
<!-- 设置排序的对话框组件设置标题可见性绑定宽度等属性 -->
<el-dialog title="设置排序" <el-dialog title="设置排序"
:visible.sync="sortDialogVisible" :visible.sync="sortDialogVisible"
width="40%"> width="40%">
<!-- 对话框内的表单绑定数据模型设置标签宽度等属性 -->
<el-form :model="sortDialogData" <el-form :model="sortDialogData"
label-width="150px"> label-width="150px">
<!-- 排序输入框的表单项 -->
<el-form-item label="排序:"> <el-form-item label="排序:">
<el-input v-model="sortDialogData.sort" style="width: 200px"></el-input> <el-input v-model="sortDialogData.sort" style="width: 200px"></el-input>
</el-form-item> </el-form-item>
</el-form> </el-form>
<span slot="footer"> <span slot="footer">
<!-- 对话框取消按钮点击隐藏对话框 --> <el-button @click="sortDialogVisible = false" size="small"> </el-button>
<el-button @click="sortDialogVisible = false" size="small"> </el-button> <el-button type="primary" @click="handleUpdateSort" size="small"> </el-button>
<!-- 对话框确认按钮绑定点击事件 --> </span>
<el-button type="primary" @click="handleUpdateSort" size="small"> </el-button>
</span>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>

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

@ -1,16 +1,12 @@
<template> <template> 
<!-- el-card组件作为表单的容器设置了类名和无阴影效果 -->
<el-card class="form-container" shadow="never"> <el-card class="form-container" shadow="never">
<!-- el-form表单组件绑定了数据模型coupon设置了验证规则表单引用标签宽度和尺寸等属性 -->
<el-form :model="coupon" <el-form :model="coupon"
:rules="rules" :rules="rules"
ref="couponFrom" ref="couponFrom"
label-width="150px" label-width="150px"
size="small"> size="small">
<!-- 优惠券类型的表单项使用el-select下拉选择框来选择类型 -->
<el-form-item label="优惠券类型:"> <el-form-item label="优惠券类型:">
<el-select v-model="coupon.type"> <el-select v-model="coupon.type">
<!-- 通过v-for循环生成下拉选项 -->
<el-option <el-option
v-for="type in typeOptions" v-for="type in typeOptions"
:key="type.value" :key="type.value"
@ -19,14 +15,11 @@
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<!-- 优惠券名称的表单项使用el-input输入框输入名称设置了数据绑定和类名 -->
<el-form-item label="优惠券名称:" prop="name"> <el-form-item label="优惠券名称:" prop="name">
<el-input v-model="coupon.name" class="input-width"></el-input> <el-input v-model="coupon.name" class="input-width"></el-input>
</el-form-item> </el-form-item>
<!-- 适用平台的表单项用el-select下拉选择框选择平台 -->
<el-form-item label="适用平台:"> <el-form-item label="适用平台:">
<el-select v-model="coupon.platform"> <el-select v-model="coupon.platform">
<!-- 通过v-for循环生成下拉选项 -->
<el-option <el-option
v-for="item in platformOptions" v-for="item in platformOptions"
:key="item.value" :key="item.value"
@ -35,40 +28,33 @@
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<!-- 总发行量的表单项用el-input输入框输入发行量设置了数据绑定和占位提示等属性 -->
<el-form-item label="总发行量:" prop="publishCount"> <el-form-item label="总发行量:" prop="publishCount">
<el-input v-model.number="coupon.publishCount" placeholder="只能输入正整数" class="input-width"></el-input> <el-input v-model.number="coupon.publishCount" placeholder="只能输入正整数" class="input-width"></el-input>
</el-form-item> </el-form-item>
<!-- 面额的表单项用el-input输入框输入面额设置了数据绑定占位提示和后缀文本等属性 -->
<el-form-item label="面额:" prop="amount"> <el-form-item label="面额:" prop="amount">
<el-input v-model.number="coupon.amount" placeholder="面值只能是数值限2位小数" class="input-width"> <el-input v-model.number="coupon.amount" placeholder="面值只能是数值限2位小数" class="input-width">
<template slot="append"></template> <template slot="append"></template>
</el-input> </el-input>
</el-form-item> </el-form-item>
<!-- 每人限领的表单项用el-input输入框输入限领数量设置了数据绑定和后缀文本等属性 -->
<el-form-item label="每人限领:"> <el-form-item label="每人限领:">
<el-input v-model="coupon.perLimit" placeholder="只能输入正整数" class="input-width"> <el-input v-model="coupon.perLimit" placeholder="只能输入正整数" class="input-width">
<template slot="append"></template> <template slot="append"></template>
</el-input> </el-input>
</el-form-item> </el-form-item>
<!-- 使用门槛的表单项用el-input输入框输入门槛金额设置了数据绑定前后缀文本等属性 -->
<el-form-item label="使用门槛:" prop="minPoint"> <el-form-item label="使用门槛:" prop="minPoint">
<el-input v-model.number="coupon.minPoint" placeholder="只能输入正整数" class="input-width"> <el-input v-model.number="coupon.minPoint" placeholder="只能输入正整数" class="input-width">
<template slot="prepend"></template> <template slot="prepend"></template>
<template slot="append">元可用</template> <template slot="append">元可用</template>
</el-input> </el-input>
</el-form-item> </el-form-item>
<!-- 领取日期的表单项用el-date-picker日期选择器选择日期设置了数据绑定和类名等属性 -->
<el-form-item label="领取日期:" prop="enableTime"> <el-form-item label="领取日期:" prop="enableTime">
<el-date-picker type="date" placeholder="选择日期" v-model="coupon.enableTime" class="input-width"></el-date-picker> <el-date-picker type="date" placeholder="选择日期" v-model="coupon.enableTime" class="input-width"></el-date-picker>
</el-form-item> </el-form-item>
<!-- 有效期的表单项通过两个el-date-picker日期选择器分别选择开始和结束日期 -->
<el-form-item label="有效期:"> <el-form-item label="有效期:">
<el-date-picker type="date" placeholder="选择日期" v-model="coupon.startTime" style="width: 150px"></el-date-picker> <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> <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-date-picker type="date" placeholder="选择日期" v-model="coupon.endTime" style="width: 150px"></el-date-picker>
</el-form-item> </el-form-item>
<!-- 可使用商品的表单项用el-radio-group单选按钮组选择使用类型 -->
<el-form-item label="可使用商品:"> <el-form-item label="可使用商品:">
<el-radio-group v-model="coupon.useType"> <el-radio-group v-model="coupon.useType">
<el-radio-button :label="0">全场通用</el-radio-button> <el-radio-button :label="0">全场通用</el-radio-button>
@ -76,27 +62,21 @@
<el-radio-button :label="2">指定商品</el-radio-button> <el-radio-button :label="2">指定商品</el-radio-button>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<!-- 当可使用商品类型为指定分类时显示的内容包含分类选择器添加按钮和展示关联分类关系的表格 -->
<el-form-item v-show="coupon.useType===1"> <el-form-item v-show="coupon.useType===1">
<!-- el-cascader分类选择器用于选择分类设置了可清除占位提示等属性 -->
<el-cascader <el-cascader
clearable clearable
placeholder="请选择分类名称" placeholder="请选择分类名称"
v-model="selectProductCate" v-model="selectProductCate"
:options="productCateOptions"> :options="productCateOptions">
</el-cascader> </el-cascader>
<!-- 添加分类关联的按钮绑定点击事件 -->
<el-button @click="handleAddProductCategoryRelation()"></el-button> <el-button @click="handleAddProductCategoryRelation()"></el-button>
<!-- 展示已添加的分类关联关系的表格设置了数据绑定等属性 -->
<el-table ref="productCateRelationTable" <el-table ref="productCateRelationTable"
:data="coupon.productCategoryRelationList" :data="coupon.productCategoryRelationList"
style="width: 100%;margin-top: 20px" style="width: 100%;margin-top: 20px"
border> border>
<!-- 显示分类名称的表格列 -->
<el-table-column label="分类名称" align="center"> <el-table-column label="分类名称" align="center">
<template slot-scope="scope">{{scope.row.parentCategoryName}}>{{scope.row.productCategoryName}}</template> <template slot-scope="scope">{{scope.row.parentCategoryName}}>{{scope.row.productCategoryName}}</template>
</el-table-column> </el-table-column>
<!-- 显示操作按钮删除的表格列 -->
<el-table-column label="操作" align="center" width="100"> <el-table-column label="操作" align="center" width="100">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button size="mini" <el-button size="mini"
@ -107,9 +87,7 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
</el-form-item> </el-form-item>
<!-- 当可使用商品类型为指定商品时显示的内容包含商品选择框添加按钮和展示关联商品关系的表格 -->
<el-form-item v-show="coupon.useType===2"> <el-form-item v-show="coupon.useType===2">
<!-- el-select商品选择框设置了可过滤远程搜索等属性 -->
<el-select <el-select
v-model="selectProduct" v-model="selectProduct"
filterable filterable
@ -118,7 +96,6 @@
placeholder="商品名称/商品货号" placeholder="商品名称/商品货号"
:remote-method="searchProductMethod" :remote-method="searchProductMethod"
:loading="selectProductLoading"> :loading="selectProductLoading">
<!-- 通过v-for循环生成商品选项 -->
<el-option <el-option
v-for="item in selectProductOptions" v-for="item in selectProductOptions"
:key="item.productId" :key="item.productId"
@ -128,22 +105,17 @@
<span style="float: right; color: #8492a6; font-size: 13px">NO.{{ item.productSn }}</span> <span style="float: right; color: #8492a6; font-size: 13px">NO.{{ item.productSn }}</span>
</el-option> </el-option>
</el-select> </el-select>
<!-- 添加商品关联的按钮绑定点击事件 -->
<el-button @click="handleAddProductRelation()"></el-button> <el-button @click="handleAddProductRelation()"></el-button>
<!-- 展示已添加的商品关联关系的表格设置了数据绑定等属性 -->
<el-table ref="productRelationTable" <el-table ref="productRelationTable"
:data="coupon.productRelationList" :data="coupon.productRelationList"
style="width: 100%;margin-top: 20px" style="width: 100%;margin-top: 20px"
border> border>
<!-- 显示商品名称的表格列 -->
<el-table-column label="商品名称" align="center"> <el-table-column label="商品名称" align="center">
<template slot-scope="scope">{{scope.row.productName}}</template> <template slot-scope="scope">{{scope.row.productName}}</template>
</el-table-column> </el-table-column>
<!-- 显示商品货号的表格列 -->
<el-table-column label="货号" align="center" width="120" > <el-table-column label="货号" align="center" width="120" >
<template slot-scope="scope">NO.{{scope.row.productSn}}</template> <template slot-scope="scope">NO.{{scope.row.productSn}}</template>
</el-table-column> </el-table-column>
<!-- 显示操作按钮删除的表格列 -->
<el-table-column label="操作" align="center" width="100"> <el-table-column label="操作" align="center" width="100">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button size="mini" <el-button size="mini"
@ -154,7 +126,6 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
</el-form-item> </el-form-item>
<!-- 备注的表单项用el-input输入框输入备注内容设置了类名类型为文本域等属性 -->
<el-form-item label="备注:"> <el-form-item label="备注:">
<el-input <el-input
class="input-width" class="input-width"
@ -164,276 +135,241 @@
v-model="coupon.note"> v-model="coupon.note">
</el-input> </el-input>
</el-form-item> </el-form-item>
<!-- 提交和重置按钮所在的表单项 -->
<el-form-item> <el-form-item>
<!-- 提交按钮设置类型为primary绑定点击事件 -->
<el-button type="primary" @click="onSubmit('couponFrom')"></el-button> <el-button type="primary" @click="onSubmit('couponFrom')"></el-button>
<!-- 重置按钮根据条件判断是否显示绑定点击事件 -->
<el-button v-if="!isEdit" @click="resetForm('couponFrom')"></el-button> <el-button v-if="!isEdit" @click="resetForm('couponFrom')"></el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</el-card> </el-card>
</template> </template>
<script> <script>
// '@/api/coupon' import {createCoupon,getCoupon,updateCoupon} from '@/api/coupon';
import {createCoupon, getCoupon, updateCoupon} from '@/api/coupon'; import {fetchSimpleList as fetchProductList} from '@/api/product';
// '@/api/product'fetchProductList import {fetchListWithChildren} from '@/api/productCate'
import {fetchSimpleList as fetchProductList} from '@/api/product'; const defaultCoupon = {
// '@/api/productCate' type: 0,
import {fetchListWithChildren} from '@/api/productCate'; name: null,
platform: 0,
// amount: null,
const defaultCoupon = { perLimit: 1,
type: 0, minPoint: null,
name: null, startTime: null,
platform: 0, endTime: null,
amount: null, useType: 0,
perLimit: 1, note: null,
minPoint: null, publishCount: null,
startTime: null, productRelationList: [],
endTime: null, productCategoryRelationList: []
useType: 0, };
note: null, const defaultTypeOptions = [
publishCount: null, {
productRelationList: [], label: '全场赠券',
productCategoryRelationList: [] value: 0
}; },
// {
const defaultTypeOptions = [ label: '会员赠券',
{ value: 1
label: '全场赠券', },
value: 0 {
}, label: '购物赠券',
{ value: 2
label: '会员赠券', },
value: 1 {
}, label: '注册赠券',
{ value: 3
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
}
},
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: []
} }
}, ];
created() { const defaultPlatformOptions = [
// coupon {
if (this.isEdit) { label: '全平台',
getCoupon(this.$route.query.id).then(response => { value: 0
this.coupon = response.data; },
}); {
label: '移动平台',
value: 1
},
{
label: 'PC平台',
value: 2
} }
// ];
this.getProductCateList(); export default {
}, name: 'CouponDetail',
methods: { props: {
// isEdit: {
onSubmit(formName) { type: Boolean,
this.$refs[formName].validate((valid) => { default: false
if (valid) { }
this.$confirm('是否提交数据', '提示', { },
confirmButtonText: '确定', data() {
cancelButtonText: '取消', return {
type: 'warning' coupon: Object.assign({}, defaultCoupon),
}).then(() => { typeOptions: Object.assign({}, defaultTypeOptions),
if (this.isEdit) { platformOptions: Object.assign({}, defaultPlatformOptions),
updateCoupon(this.$route.query.id, this.coupon).then(response => { rules: {
this.$refs[formName].resetFields(); name: [
this.$message({ {required: true, message: '请输入优惠券名称', trigger: 'blur'},
message: '修改成功', {min: 2, max: 140, message: '长度在 2 到 140 个字符', trigger: 'blur'}
type: 'success', ],
duration: 1000 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();
}); });
this.$router.back(); }else{
}); createCoupon(this.coupon).then(response=>{
} else { this.$refs[formName].resetFields();
createCoupon(this.coupon).then(response => { this.$message({
this.$refs[formName].resetFields(); message: '提交成功',
this.$message({ type: 'success',
message: '提交成功', duration:1000
type: 'success', });
duration: 1000 this.$router.back();
}); });
this.$router.back(); }
}); });
} 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});
} }
}); });
} else { } else {
this.selectProductOptions = [];
}
},
handleAddProductRelation(){
if(this.selectProduct===null){
this.$message({ this.$message({
message: '验证失败', message: '请先选择商品',
type: 'error', type: 'warning'
duration: 1000
}); });
return false; return
} }
}); this.coupon.productRelationList.push(this.getProductById(this.selectProduct));
}, this.selectProduct=null;
// coupon },
resetForm(formName) { handleDeleteProductRelation(index,row){
this.$refs[formName].resetFields(); this.coupon.productRelationList.splice(index,1);
this.coupon = Object.assign({}, defaultCoupon); },
}, handleAddProductCategoryRelation(){
// if(this.selectProductCate===null||this.selectProductCate.length===0){
searchProductMethod(query) { this.$message({
if (query!== '') { message: '请先选择商品分类',
this.loading = true; type: 'warning'
fetchProductList({keyword: query}).then(response => { });
this.loading = false; return
let productList = response.data; }
this.selectProductOptions = []; this.coupon.productCategoryRelationList.push(this.getProductCateByIds(this.selectProductCate));
for (let i = 0; i < productList.length; i++) { this.selectProductCate=[];
let item = productList[i]; },
this.selectProductOptions.push({productId: item.id, productName: item.name, productSn: item.productSn}); 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];
} }
});
} 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;
return null; },
}, getProductCateList() {
// fetchListWithChildren().then(response => {
getProductCateList() { let list = response.data;
fetchListWithChildren().then(response => { this.productCateOptions = [];
let list = response.data; for (let i = 0; i < list.length; i++) {
this.productCateOptions = []; let children = [];
for (let i = 0; i < list.length; i++) { if (list[i].children != null && list[i].children.length > 0) {
let children = []; for (let j = 0; j < list[i].children.length; j++) {
if (list[i].children!= null && list[i].children.length > 0) { children.push({label: list[i].children[j].name, value: list[i].children[j].id});
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});
} }
this.productCateOptions.push({label: list[i].name, value: list[i].id, children: children}); });
} },
}); getProductCateByIds(ids){
}, let name;
// idid let parentName;
getProductCateByIds(ids) { for (let i = 0; i < this.productCateOptions.length; i++) {
let name; if (this.productCateOptions[i].value === ids[0]) {
let parentName; parentName = this.productCateOptions[i].label;
for (let i = 0; i < this.productCateOptions.length; i++) { for (let j = 0; j < this.productCateOptions[i].children.length; j++) {
if (this.productCateOptions[i].value === ids[0]) { if (this.productCateOptions[i].children[j].value === ids[1]) {
parentName = this.productCateOptions[i].label; name = this.productCateOptions[i].children[j].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> </script>
<style scoped> <style scoped>
<!-- 带有scoped属性的style标签意味着里面定义的样式仅作用于当前组件内的元素 --> .input-width {
.input-width { width: 60%;
<!-- 定义了一个类选择器样式作用是将应用该类的元素宽度设置为其父元素宽度的60% --> }
width: 60%;
}
</style> </style>

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

@ -1,14 +1,9 @@
<template> <template> 
<!-- 页面整体的外层容器用于布局包裹内部各部分内容 -->
<div class="app-container"> <div class="app-container">
<!-- 筛选搜索区域的卡片容器设置无阴影效果 -->
<el-card class="filter-container" shadow="never"> <el-card class="filter-container" shadow="never">
<div> <div>
<!-- 显示搜索图标 -->
<i class="el-icon-search"></i> <i class="el-icon-search"></i>
<!-- 显示筛选搜索文字提示 -->
<span>筛选搜索</span> <span>筛选搜索</span>
<!-- 用于触发查询搜索的按钮绑定点击事件设置样式等属性 -->
<el-button <el-button
style="float:right" style="float:right"
type="primary" type="primary"
@ -16,7 +11,6 @@
size="small"> size="small">
查询搜索 查询搜索
</el-button> </el-button>
<!-- 用于重置筛选条件的按钮绑定点击事件设置样式等属性 -->
<el-button <el-button
style="float:right;margin-right: 15px" style="float:right;margin-right: 15px"
@click="handleResetSearch()" @click="handleResetSearch()"
@ -25,18 +19,12 @@
</el-button> </el-button>
</div> </div>
<div style="margin-top: 15px"> <div style="margin-top: 15px">
<!-- 行内表单绑定数据模型设置尺寸标签宽度等属性 -->
<el-form :inline="true" :model="listQuery" size="small" label-width="140px"> <el-form :inline="true" :model="listQuery" size="small" label-width="140px">
<!-- 优惠券名称输入框的表单项 -->
<el-form-item label="优惠券名称:"> <el-form-item label="优惠券名称:">
<!-- 输入框双向绑定优惠券名称数据设置类名和占位提示 -->
<el-input v-model="listQuery.name" class="input-width" placeholder="优惠券名称"></el-input> <el-input v-model="listQuery.name" class="input-width" placeholder="优惠券名称"></el-input>
</el-form-item> </el-form-item>
<!-- 优惠券类型选择框的表单项 -->
<el-form-item label="优惠券类型:"> <el-form-item label="优惠券类型:">
<!-- 下拉选择框双向绑定优惠券类型数据设置占位提示等属性 -->
<el-select v-model="listQuery.type" placeholder="全部" clearable class="input-width"> <el-select v-model="listQuery.type" placeholder="全部" clearable class="input-width">
<!-- 通过循环生成下拉选项 -->
<el-option v-for="item in typeOptions" <el-option v-for="item in typeOptions"
:key="item.value" :key="item.value"
:label="item.label" :label="item.label"
@ -47,72 +35,54 @@
</el-form> </el-form>
</div> </div>
</el-card> </el-card>
<!-- 操作区域的卡片容器设置无阴影效果 -->
<el-card class="operate-container" shadow="never"> <el-card class="operate-container" shadow="never">
<i class="el-icon-tickets"></i> <i class="el-icon-tickets"></i>
<span>数据列表</span> <span>数据列表</span>
<!-- 用于触发添加操作的按钮绑定点击事件 -->
<el-button size="mini" class="btn-add" @click="handleAdd()"></el-button> <el-button size="mini" class="btn-add" @click="handleAdd()"></el-button>
</el-card> </el-card>
<!-- 放置数据表格的容器 -->
<div class="table-container"> <div class="table-container">
<!-- 数据表格组件绑定数据设置宽度等属性还有选择改变等相关事件 -->
<el-table ref="couponTable" <el-table ref="couponTable"
:data="list" :data="list"
style="width: 100%;" style="width: 100%;"
@selection-change="handleSelectionChange" @selection-change="handleSelectionChange"
v-loading="listLoading" border> v-loading="listLoading" border>
<!-- 显示选择框的表格列 -->
<el-table-column type="selection" width="60" align="center"></el-table-column> <el-table-column type="selection" width="60" align="center"></el-table-column>
<!-- 显示编号的表格列 -->
<el-table-column label="编号" width="100" align="center"> <el-table-column label="编号" width="100" align="center">
<template slot-scope="scope">{{scope.row.id}}</template> <template slot-scope="scope">{{scope.row.id}}</template>
</el-table-column> </el-table-column>
<!-- 显示优惠券名称的表格列 -->
<el-table-column label="优惠劵名称" align="center"> <el-table-column label="优惠劵名称" align="center">
<template slot-scope="scope">{{scope.row.name}}</template> <template slot-scope="scope">{{scope.row.name}}</template>
</el-table-column> </el-table-column>
<!-- 显示优惠券类型的表格列使用过滤器格式化内容 -->
<el-table-column label="优惠券类型" width="100" align="center"> <el-table-column label="优惠券类型" width="100" align="center">
<template slot-scope="scope">{{scope.row.type | formatType}}</template> <template slot-scope="scope">{{scope.row.type | formatType}}</template>
</el-table-column> </el-table-column>
<!-- 显示可使用商品类型的表格列使用过滤器格式化内容 -->
<el-table-column label="可使用商品" width="100" align="center"> <el-table-column label="可使用商品" width="100" align="center">
<template slot-scope="scope">{{scope.row.useType | formatUseType}}</template> <template slot-scope="scope">{{scope.row.useType | formatUseType}}</template>
</el-table-column> </el-table-column>
<!-- 显示使用门槛的表格列 -->
<el-table-column label="使用门槛" width="140" align="center"> <el-table-column label="使用门槛" width="140" align="center">
<template slot-scope="scope">{{scope.row.minPoint}}元可用</template> <template slot-scope="scope">{{scope.row.minPoint}}元可用</template>
</el-table-column> </el-table-column>
<!-- 显示面值的表格列 -->
<el-table-column label="面值" width="100" align="center"> <el-table-column label="面值" width="100" align="center">
<template slot-scope="scope">{{scope.row.amount}}</template> <template slot-scope="scope">{{scope.row.amount}}</template>
</el-table-column> </el-table-column>
<!-- 显示适用平台的表格列使用过滤器格式化内容 -->
<el-table-column label="适用平台" width="100" align="center"> <el-table-column label="适用平台" width="100" align="center">
<template slot-scope="scope">{{scope.row.platform | formatPlatform}}</template> <template slot-scope="scope">{{scope.row.platform | formatPlatform}}</template>
</el-table-column> </el-table-column>
<!-- 显示有效期的表格列使用日期格式化等过滤器 -->
<el-table-column label="有效期" width="180" align="center"> <el-table-column label="有效期" width="180" align="center">
<template slot-scope="scope">{{scope.row.startTime|formatDate}}{{scope.row.endTime|formatDate}}</template> <template slot-scope="scope">{{scope.row.startTime|formatDate}}{{scope.row.endTime|formatDate}}</template>
</el-table-column> </el-table-column>
<!-- 显示状态的表格列使用过滤器根据结束时间判断并格式化状态 -->
<el-table-column label="状态" width="100" align="center"> <el-table-column label="状态" width="100" align="center">
<template slot-scope="scope">{{scope.row.endTime | formatStatus}}</template> <template slot-scope="scope">{{scope.row.endTime | formatStatus}}</template>
</el-table-column> </el-table-column>
<!-- 显示操作按钮的表格列 -->
<el-table-column label="操作" width="180" align="center"> <el-table-column label="操作" width="180" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<!-- 查看按钮绑定点击事件 -->
<el-button size="mini" <el-button size="mini"
type="text" type="text"
@click="handleView(scope.$index, scope.row)">查看</el-button> @click="handleView(scope.$index, scope.row)">查看</el-button>
<!-- 编辑按钮绑定点击事件 -->
<el-button size="mini" <el-button size="mini"
type="text" type="text"
@click="handleUpdate(scope.$index, scope.row)"> @click="handleUpdate(scope.$index, scope.row)">
编辑</el-button> 编辑</el-button>
<!-- 删除按钮绑定点击事件 -->
<el-button size="mini" <el-button size="mini"
type="text" type="text"
@click="handleDelete(scope.$index, scope.row)">删除</el-button> @click="handleDelete(scope.$index, scope.row)">删除</el-button>
@ -120,9 +90,7 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
</div> </div>
<!-- 分页组件的容器 -->
<div class="pagination-container"> <div class="pagination-container">
<!-- 分页组件设置背景各类事件绑定页面尺寸等属性 -->
<el-pagination <el-pagination
background background
@size-change="handleSizeChange" @size-change="handleSizeChange"
@ -137,176 +105,147 @@
</div> </div>
</template> </template>
<script> <script>
// '@/api/coupon' import {fetchList,deleteCoupon} from '@/api/coupon';
import {fetchList, deleteCoupon} from '@/api/coupon'; import {formatDate} from '@/utils/date';
// '@/utils/date'formatDate const defaultListQuery = {
import {formatDate} from '@/utils/date'; pageNum: 1,
pageSize: 10,
// name: null,
const defaultListQuery = { type: null
pageNum: 1, };
pageSize: 10, const defaultTypeOptions=[
name: null, {
type: null label: '全场赠券',
}; value: 0
//
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 '指定商品';
}
}, },
// {
formatPlatform(platform) { label: '会员赠券',
if (platform === 1) { value: 1
return '移动平台';
} else if (platform === 2) {
return 'PC平台';
} else {
return '全平台';
}
}, },
// {
formatDate(time) { label: '购物赠券',
if (time == null || time === '') { value: 2
return 'N/A';
}
let date = new Date(time);
return formatDate(date, 'yyyy-MM-dd')
}, },
// {
formatStatus(endTime) { label: '注册赠券',
let now = new Date().getTime(); value: 3
let endDate = new Date(endTime);
if (endDate > now) {
return '未过期'
} else {
return '已过期';
}
} }
}, ];
methods: { export default {
// name:'couponList',
handleResetSearch() { data() {
this.listQuery = Object.assign({}, defaultListQuery); return {
}, listQuery:Object.assign({},defaultListQuery),
// typeOptions:Object.assign({},defaultTypeOptions),
handleSearchList() { list:null,
this.listQuery.pageNum = 1; total:null,
this.getList(); listLoading:false,
}, multipleSelection:[]
// }
handleSelectionChange(val) {
this.multipleSelection = val;
},
//
handleSizeChange(val) {
this.listQuery.pageNum = 1;
this.listQuery.pageSize = val;
this.getList();
}, },
// created(){
handleCurrentChange(val) {
this.listQuery.pageNum = val;
this.getList(); this.getList();
}, },
// filters:{
handleAdd() { formatType(type){
this.$router.push({path: '/sms/addCoupon'}) for(let i=0;i<defaultTypeOptions.length;i++){
}, if(type===defaultTypeOptions[i].value){
// id return defaultTypeOptions[i].label;
handleView(index, row) { }
this.$router.push({path: '/sms/couponHistory', query: {id: row.id}}) }
}, return '';
// id },
handleUpdate(index, row) { formatUseType(useType){
this.$router.push({path: '/sms/updateCoupon', query: {id: row.id}}) 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 '已过期';
}
}
}, },
// methods:{
handleDelete(index, row) { handleResetSearch() {
this.$confirm('是否进行删除操作?', '提示', { this.listQuery = Object.assign({}, defaultListQuery);
confirmButtonText: '确定', },
cancelButtonText: '取消', handleSearchList() {
type: 'warning' this.listQuery.pageNum = 1;
}).then(() => { this.getList();
deleteCoupon(row.id).then(response => { },
this.$message({ handleSelectionChange(val){
type: 'success', this.multipleSelection = val;
message: '删除成功!' },
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();
}); });
this.getList(); })
},
getList(){
this.listLoading=true;
fetchList(this.listQuery).then(response=>{
this.listLoading = false;
this.list = response.data.list;
this.total = response.data.total;
}); });
}) }
},
// true
getList() {
this.listLoading = true;
fetchList(this.listQuery).then(response => {
this.listLoading = false;
this.list = response.data.list;
this.total = response.data.total;
});
} }
} }
}
</script> </script>
<style scoped> <style scoped>
<!-- scoped属性使样式仅作用于当前组件.input-width类设置元素宽度为203px -->
.input-width { .input-width {
width: 203px; width: 203px;
} }

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

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

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

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

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

@ -1,14 +1,9 @@
<template> <template> 
<!-- 整个应用的容器 -->
<div class="app-container"> <div class="app-container">
<!-- 筛选搜索的卡片容器设置了阴影效果为无 -->
<el-card class="filter-container" shadow="never"> <el-card class="filter-container" shadow="never">
<div> <div>
<!-- 搜索图标 -->
<i class="el-icon-search"></i> <i class="el-icon-search"></i>
<!-- 显示筛选搜索文字 -->
<span>筛选搜索</span> <span>筛选搜索</span>
<!-- 查询搜索按钮设置了样式为右浮动类型为主要按钮点击时触发handleSearchList方法按钮大小为小 -->
<el-button <el-button
style="float:right" style="float:right"
type="primary" type="primary"
@ -16,7 +11,6 @@
size="small"> size="small">
查询搜索 查询搜索
</el-button> </el-button>
<!-- 重置按钮设置了样式为右浮动右外边距为15px点击时触发handleResetSearch方法按钮大小为小 -->
<el-button <el-button
style="float:right;margin-right: 15px" style="float:right;margin-right: 15px"
@click="handleResetSearch()" @click="handleResetSearch()"
@ -25,18 +19,12 @@
</el-button> </el-button>
</div> </div>
<div style="margin-top: 15px"> <div style="margin-top: 15px">
<!-- 内联表单绑定了listQuery数据模型表单大小为小标签宽度为140px -->
<el-form :inline="true" :model="listQuery" size="small" label-width="140px"> <el-form :inline="true" :model="listQuery" size="small" label-width="140px">
<!-- 表单项目标签为商品名称 -->
<el-form-item label="商品名称:"> <el-form-item label="商品名称:">
<!-- 输入框双向绑定listQuery.productName数据设置了类名和占位提示文字 -->
<el-input v-model="listQuery.productName" class="input-width" placeholder="商品名称"></el-input> <el-input v-model="listQuery.productName" class="input-width" placeholder="商品名称"></el-input>
</el-form-item> </el-form-item>
<!-- 表单项目标签为推荐状态 -->
<el-form-item label="推荐状态:"> <el-form-item label="推荐状态:">
<!-- 下拉选择框双向绑定listQuery.recommendStatus数据设置了占位提示文字和可清除添加了类名 -->
<el-select v-model="listQuery.recommendStatus" placeholder="全部" clearable class="input-width"> <el-select v-model="listQuery.recommendStatus" placeholder="全部" clearable class="input-width">
<!-- 循环生成下拉选项根据recommendOptions数据中的每个item来生成对应的选项 -->
<el-option v-for="item in recommendOptions" <el-option v-for="item in recommendOptions"
:key="item.value" :key="item.value"
:label="item.label" :label="item.label"
@ -47,34 +35,24 @@
</el-form> </el-form>
</div> </div>
</el-card> </el-card>
<!-- 操作相关的卡片容器设置了阴影效果为无 -->
<el-card class="operate-container" shadow="never"> <el-card class="operate-container" shadow="never">
<!-- 图标 -->
<i class="el-icon-tickets"></i> <i class="el-icon-tickets"></i>
<!-- 显示数据列表文字 --> <span>数据列表</span>
<i>数据列表</i>
<!-- 选择商品按钮设置了按钮大小为迷你点击时触发handleSelectProduct方法 -->
<el-button size="mini" class="btn-add" @click="handleSelectProduct()"></el-button> <el-button size="mini" class="btn-add" @click="handleSelectProduct()"></el-button>
</el-card> </el-card>
<!-- 表格容器 -->
<div class="table-container"> <div class="table-container">
<!-- el-table组件绑定了list数据作为表格数据源设置了宽度为100%选择变化时触发handleSelectionChange方法加载状态绑定listLoading显示边框 -->
<el-table ref="newProductTable" <el-table ref="newProductTable"
:data="list" :data="list"
style="width: 100%;" style="width: 100%;"
@selection-change="handleSelectionChange" @selection-change="handleSelectionChange"
v-loading="listLoading" border> v-loading="listLoading" border>
<!-- 表格列类型为选择列宽度为60px内容居中对齐 -->
<el-table-column type="selection" width="60" align="center"></el-table-column> <el-table-column type="selection" width="60" align="center"></el-table-column>
<!-- 表格列标签为编号宽度为120px内容居中对齐通过插槽作用域显示对应行的id数据 -->
<el-table-column label="编号" width="120" align="center"> <el-table-column label="编号" width="120" align="center">
<template slot-scope="scope">{{scope.row.id}}</template> <template slot-scope="scope">{{scope.row.id}}</template>
</el-table-column> </el-table-column>
<!-- 表格列标签为商品名称内容居中对齐通过插槽作用域显示对应行的productName数据 -->
<el-table-column label="商品名称" align="center"> <el-table-column label="商品名称" align="center">
<template slot-scope="scope">{{scope.row.productName}}</template> <template slot-scope="scope">{{scope.row.productName}}</template>
</el-table-column> </el-table-column>
<!-- 表格列标签为是否推荐宽度为200px内容居中对齐包含一个开关组件开关状态改变时触发handleRecommendStatusStatusChange方法设置了开关的激活值未激活值以及双向绑定对应行的recommendStatus数据 -->
<el-table-column label="是否推荐" width="200" align="center"> <el-table-column label="是否推荐" width="200" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-switch <el-switch
@ -85,15 +63,12 @@
</el-switch> </el-switch>
</template> </template>
</el-table-column> </el-table-column>
<!-- 表格列标签为排序宽度为160px内容居中对齐通过插槽作用域显示对应行的sort数据 -->
<el-table-column label="排序" width="160" align="center"> <el-table-column label="排序" width="160" align="center">
<template slot-scope="scope">{{scope.row.sort}}</template> <template slot-scope="scope">{{scope.row.sort}}</template>
</el-table-column> </el-table-column>
<!-- 表格列标签为状态宽度为160px内容居中对齐通过管道formatRecommendStatus对对应行的recommendStatus数据进行格式化后显示 -->
<el-table-column label="状态" width="160" align="center"> <el-table-column label="状态" width="160" align="center">
<template slot-scope="scope">{{scope.row.recommendStatus | formatRecommendStatus}}</template> <template slot-scope="scope">{{scope.row.recommendStatus | formatRecommendStatus}}</template>
</el-table-column> </el-table-column>
<!-- 表格列标签为操作宽度为180px内容居中对齐包含两个按钮分别点击时触发handleEditSort和handleDelete方法 -->
<el-table-column label="操作" width="180" align="center"> <el-table-column label="操作" width="180" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button size="mini" <el-button size="mini"
@ -108,13 +83,10 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
</div> </div>
<!-- 批量操作的容器 -->
<div class="batch-operate-container"> <div class="batch-operate-container">
<!-- 下拉选择框设置了大小为小双向绑定operateType数据设置了占位提示文字 -->
<el-select <el-select
size="small" size="small"
v-model="operateType" placeholder="批量操作"> v-model="operateType" placeholder="批量操作">
<!-- 循环生成下拉选项根据operates数据中的每个item来生成对应的选项 -->
<el-option <el-option
v-for="item in operates" v-for="item in operates"
:key="item.value" :key="item.value"
@ -122,7 +94,6 @@
:value="item.value"> :value="item.value">
</el-option> </el-option>
</el-select> </el-select>
<!-- 确定按钮设置了左外边距为20px样式类点击时触发handleBatchOperate方法类型为主要按钮大小为小 -->
<el-button <el-button
style="margin-left: 20px" style="margin-left: 20px"
class="search-button" class="search-button"
@ -132,9 +103,7 @@
确定 确定
</el-button> </el-button>
</div> </div>
<!-- 分页容器 -->
<div class="pagination-container"> <div class="pagination-container">
<!-- el-pagination分页组件设置了背景色页面尺寸改变时触发handleSizeChange方法当前页改变时触发handleCurrentChange方法布局样式绑定了当前页每页显示数量可选的每页显示数量列表以及总记录数等属性 -->
<el-pagination <el-pagination
background background
@size-change="handleSizeChange" @size-change="handleSizeChange"
@ -146,35 +115,27 @@
:total="total"> :total="total">
</el-pagination> </el-pagination>
</div> </div>
<!-- 选择商品的对话框绑定了显示状态设置了标题和宽度 -->
<el-dialog title="选择商品" :visible.sync="selectDialogVisible" width="50%"> <el-dialog title="选择商品" :visible.sync="selectDialogVisible" width="50%">
<!-- 输入框双向绑定dialogData.listQuery.keyword数据设置了宽度下外边距大小和占位提示文字包含一个搜索按钮点击时触发handleSelectSearch方法 -->
<el-input v-model="dialogData.listQuery.keyword" <el-input v-model="dialogData.listQuery.keyword"
style="width: 250px;margin-bottom: 20px" style="width: 250px;margin-bottom: 20px"
size="small" size="small"
placeholder="商品名称搜索"> placeholder="商品名称搜索">
<el-button slot="append" icon="el-icon-search" @click="handleSelectSearch()"></el-button> <el-button slot="append" icon="el-icon-search" @click="handleSelectSearch()"></el-button>
</el-input> </el-input>
<!-- 表格绑定了dialogData.list数据作为数据源选择变化时触发handleDialogSelectionChange方法显示边框 -->
<el-table :data="dialogData.list" <el-table :data="dialogData.list"
@selection-change="handleDialogSelectionChange" border> @selection-change="handleDialogSelectionChange" border>
<!-- 表格列类型为选择列宽度为60px内容居中对齐 -->
<el-table-column type="selection" width="60" align="center"></el-table-column> <el-table-column type="selection" width="60" align="center"></el-table-column>
<!-- 表格列标签为商品名称内容居中对齐通过插槽作用域显示对应行的name数据 -->
<el-table-column label="商品名称" align="center"> <el-table-column label="商品名称" align="center">
<template slot-scope="scope">{{scope.row.name}}</template> <template slot-scope="scope">{{scope.row.name}}</template>
</el-table-column> </el-table-column>
<!-- 表格列标签为货号宽度为160px内容居中对齐通过插槽作用域显示对应行的productSn数据格式化为NO. + 货号 -->
<el-table-column label="货号" width="160" align="center"> <el-table-column label="货号" width="160" align="center">
<template slot-scope="scope">NO.{{scope.row.productSn}}</template> <template slot-scope="scope">NO.{{scope.row.productSn}}</template>
</el-table-column> </el-table-column>
<!-- 表格列标签为价格宽度为120px内容居中对齐通过插槽作用域显示对应行的price数据格式化为 + 价格 -->
<el-table-column label="价格" width="120" align="center"> <el-table-column label="价格" width="120" align="center">
<template slot-scope="scope">{{scope.row.price}}</template> <template slot-scope="scope">{{scope.row.price}}</template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<div class="pagination-container"> <div class="pagination-container">
<!-- el-pagination分页组件设置了背景色页面尺寸改变时触发handleDialogSizeChange方法当前页改变时触发handleDialogCurrentChange方法布局样式绑定了当前页每页显示数量可选的每页显示数量列表以及总记录数等属性 -->
<el-pagination <el-pagination
background background
@size-change="handleDialogSizeChange" @size-change="handleDialogSizeChange"
@ -188,331 +149,282 @@
</div> </div>
<div style="clear: both;"></div> <div style="clear: both;"></div>
<div slot="footer"> <div slot="footer">
<!-- 取消按钮设置了大小为小点击时隐藏对话框 -->
<el-button size="small" @click="selectDialogVisible = false"> </el-button> <el-button size="small" @click="selectDialogVisible = false"> </el-button>
<!-- 确定按钮设置了大小为小类型为主要按钮点击时触发handleSelectDialogConfirm方法 -->
<el-button size="small" type="primary" @click="handleSelectDialogConfirm()"> </el-button> <el-button size="small" type="primary" @click="handleSelectDialogConfirm()"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
<!-- 设置排序的对话框绑定了显示状态设置了标题和宽度 -->
<el-dialog title="设置排序" <el-dialog title="设置排序"
:visible.sync="sortDialogVisible" :visible.sync="sortDialogVisible"
width="40%"> width="40%">
<!-- 表单绑定了sortDialogData数据模型设置了标签宽度 -->
<el-form :model="sortDialogData" <el-form :model="sortDialogData"
label-width="150px"> label-width="150px">
<!-- 表单项目标签为排序 -->
<el-form-item label="排序:"> <el-form-item label="排序:">
<!-- 输入框双向绑定sortDialogData.sort数据设置了宽度 -->
<el-input v-model="sortDialogData.sort" style="width: 200px"></el-input> <el-input v-model="sortDialogData.sort" style="width: 200px"></el-input>
</el-form-item> </el-form-item>
</el-form> </el-form>
<span slot="footer"> <span slot="footer">
<!-- 取消按钮点击时隐藏对话框设置了大小为小 -->
<el-button @click="sortDialogVisible = false" size="small"> </el-button> <el-button @click="sortDialogVisible = false" size="small"> </el-button>
<!-- 确定按钮点击时触发handleUpdateSort方法设置了大小为小类型为主要按钮 -->
<el-button type="primary" @click="handleUpdateSort" size="small"> </el-button> <el-button type="primary" @click="handleUpdateSort" size="small"> </el-button>
</span> </span>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
<script> <script>
// '@/api/hotProduct' import {fetchList,updateRecommendStatus,deleteHotProduct,createHotProduct,updateHotProductSort} from '@/api/hotProduct';
import {fetchList, updateRecommendStatus, deleteHotProduct, createHotProduct, updateHotProductSort} from '@/api/hotProduct'; import {fetchList as fetchProductList} from '@/api/product';
// '@/api/product'fetchListfetchProductList
import {fetchList as fetchProductList} from '@/api/product';
// const defaultListQuery = {
const defaultListQuery = { pageNum: 1,
pageNum: 1, pageSize: 5,
pageSize: 5, productName: null,
productName: null, recommendStatus: null
recommendStatus: null };
}; const defaultRecommendOptions = [
// {
const defaultRecommendOptions = [ label: '未推荐',
{ value: 0
label: '未推荐', },
value: 0 {
}, label: '推荐中',
{ value: 1
label: '推荐中', }
value: 1 ];
} export default {
]; name: 'hotProductList',
data() {
// Vue return {
export default { listQuery: Object.assign({}, defaultListQuery),
// recommendOptions: Object.assign({}, defaultRecommendOptions),
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, list: null,
total: null, total: null,
listLoading: false,
multipleSelection: [], multipleSelection: [],
listQuery: { operates: [
keyword: null, {
pageNum: 1, label: "设为推荐",
pageSize: 5 value: 0
} },
}, {
// label: "取消推荐",
sortDialogVisible: false, value: 1
// id },
sortDialogData: {sort: 0, id: null} {
} label: "删除",
}, value: 2
// }
created() { ],
this.getList(); operateType: null,
}, selectDialogVisible:false,
// 1 dialogData:{
filters: { list: null,
formatRecommendStatus(status) { total: null,
if (status === 1) { multipleSelection:[],
return '推荐中'; listQuery:{
} else { keyword: null,
return '未推荐'; pageNum: 1,
pageSize: 5
}
},
sortDialogVisible:false,
sortDialogData:{sort:0,id:null}
} }
}
},
methods: {
//
handleResetSearch() {
this.listQuery = Object.assign({}, defaultListQuery);
},
// 1
handleSearchList() {
this.listQuery.pageNum = 1;
this.getList();
},
//
handleSelectionChange(val) {
this.multipleSelection = val;
},
// 1
handleSizeChange(val) {
this.listQuery.pageNum = 1;
this.listQuery.pageSize = val;
this.getList();
}, },
// created() {
handleCurrentChange(val) {
this.listQuery.pageNum = val;
this.getList(); this.getList();
}, },
// id filters:{
handleRecommendStatusStatusChange(index, row) { formatRecommendStatus(status){
this.updateRecommendStatusStatus(row.id, row.recommendStatus); if(status===1){
}, return '推荐中';
// id }else{
handleDelete(index, row) { return '未推荐';
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: {
handleSelectProduct() { handleResetSearch() {
this.selectDialogVisible = true; this.listQuery = Object.assign({}, defaultListQuery);
this.getDialogList(); },
}, handleSearchList() {
// this.listQuery.pageNum = 1;
handleSelectSearch() { this.getList();
this.getDialogList(); },
}, handleSelectionChange(val){
// 1 this.multipleSelection = val;
handleDialogSizeChange(val) { },
this.dialogData.listQuery.pageNum = 1; handleSizeChange(val) {
this.dialogData.listQuery.pageSize = val; this.listQuery.pageNum = 1;
this.getDialogList(); this.listQuery.pageSize = val;
}, this.getList();
// },
handleDialogCurrentChange(val) { handleCurrentChange(val) {
this.dialogData.listQuery.pageNum = val; this.listQuery.pageNum = val;
this.getDialogList(); this.getList();
}, },
// handleRecommendStatusStatusChange(index,row){
handleDialogSelectionChange(val) { this.updateRecommendStatusStatus(row.id,row.recommendStatus);
this.dialogData.multipleSelection = val; },
}, handleDelete(index,row){
// this.deleteProduct(row.id);
handleSelectDialogConfirm() { },
if (this.dialogData.multipleSelection < 1) { handleBatchOperate(){
this.$message({ if (this.multipleSelection < 1) {
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({ this.$message({
type: 'success', message: '请选择一条记录',
message: '添加成功!' type: 'warning',
duration: 1000
}); });
}); return;
}); }
}, let ids = [];
// for (let i = 0; i < this.multipleSelection.length; i++) {
handleEditSort(index, row) { ids.push(this.multipleSelection[i].id);
this.sortDialogVisible = true; }
this.sortDialogData.sort = row.sort; //id if (this.operateType === 0) {
this.sortDialogData.id = row.id; //
}, this.updateRecommendStatusStatus(ids,1);
// } else if (this.operateType === 1) {
handleUpdateSort() { // //
this.$confirm('是否要修改排序?', '提示', { this.updateRecommendStatusStatus(ids,0);
confirmButtonText: '确定', } else if(this.operateType===2){
cancelButtonText: '取消', //
type: 'warning' this.deleteProduct(ids);
}).then(() => { // }else {
updateHotProductSort(this.sortDialogData).then(response => {
this.sortDialogVisible = false;
this.getList();
this.$message({ this.$message({
type: 'success', message: '请选择批量操作类型',
message: '删除成功!' type: 'warning',
duration: 1000
}); });
}); }
}) },
}, handleSelectProduct(){
// this.selectDialogVisible=true;
getList() { this.getDialogList();
this.listLoading = true; },
fetchList(this.listQuery).then(response => { //fetchList handleSelectSearch(){
this.listLoading = false; this.getDialogList();
this.list = response.data.list; // },
this.total = response.data.total; handleDialogSizeChange(val) {
}) this.dialogData.listQuery.pageNum = 1;
}, this.dialogData.listQuery.pageSize = val;
// this.getDialogList();
updateRecommendStatusStatus(ids, status) { },
this.$confirm('是否要修改推荐状态?', '提示', { // handleDialogCurrentChange(val) {
confirmButtonText: '确定', this.dialogData.listQuery.pageNum = val;
cancelButtonText: '取消', this.getDialogList();
type: 'warning' },
}).then(() => { handleDialogSelectionChange(val){
let params = new URLSearchParams(); //idURLSearchParams this.dialogData.multipleSelection = val;
params.append("ids", ids); },
params.append("recommendStatus", status); handleSelectDialogConfirm(){
updateRecommendStatus(params).then(response => { //updateRecommendStatus if (this.dialogData.multipleSelection < 1) {
this.getList();
this.$message({ this.$message({
type: 'success', 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: '添加成功!'
});
}); });
}); });
}).catch(() => { },
this.$message({ handleEditSort(index,row){
type: 'success', this.sortDialogVisible=true;
message: '已取消操作!' // this.sortDialogData.sort=row.sort;
}); this.sortDialogData.id=row.id;
this.getList(); },
}); handleUpdateSort(){
}, this.$confirm('是否要修改排序?', '提示', {
// confirmButtonText: '确定',
deleteProduct(ids) { cancelButtonText: '取消',
this.$confirm('是否要删除该推荐?', '提示', { // type: 'warning'
confirmButtonText: '确定', }).then(() => {
cancelButtonText: '取消', updateHotProductSort(this.sortDialogData).then(response=>{
type: 'warning' this.sortDialogVisible=false;
}).then(() => { this.getList();
let params = new URLSearchParams(); //idURLSearchParams this.$message({
params.append("ids", ids); type: 'success',
deleteHotProduct(params).then(response => { //deleteHotProduct message: '删除成功!'
this.getList(); });
});
})
},
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(() => {
this.$message({ this.$message({
type: 'success', type: 'success',
message: '删除成功!' // message: '已取消操作!'
}); });
this.getList();
}); });
}) },
}, deleteProduct(ids){
// this.$confirm('是否要删除该推荐?', '提示', {
getDialogList() { confirmButtonText: '确定',
fetchProductList(this.dialogData.listQuery).then(response => { //fetchProductList cancelButtonText: '取消',
this.dialogData.list = response.data.list; // type: 'warning'
this.dialogData.total = response.data.total; }).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;
})
}
} }
} }
}
</script> </script>
<style></style> <style></style>

@ -1,14 +1,9 @@
<template> <template> 
<!-- 整个页面的容器 -->
<div class="app-container"> <div class="app-container">
<!-- 筛选搜索区域的卡片 -->
<el-card class="filter-container" shadow="never"> <el-card class="filter-container" shadow="never">
<div> <div>
<!-- 搜索图标 -->
<i class="el-icon-search"></i> <i class="el-icon-search"></i>
<!-- 显示筛选搜索文字 -->
<span>筛选搜索</span> <span>筛选搜索</span>
<!-- 查询搜索按钮点击触发handleSearchList方法按钮样式为小型主色调 -->
<el-button <el-button
style="float:right" style="float:right"
type="primary" type="primary"
@ -16,7 +11,6 @@
size="small"> size="small">
查询搜索 查询搜索
</el-button> </el-button>
<!-- 重置按钮点击触发handleResetSearch方法按钮样式为小型与查询搜索按钮有一定间隔 -->
<el-button <el-button
style="float:right;margin-right: 15px" style="float:right;margin-right: 15px"
@click="handleResetSearch()" @click="handleResetSearch()"
@ -25,18 +19,12 @@
</el-button> </el-button>
</div> </div>
<div style="margin-top: 15px"> <div style="margin-top: 15px">
<!-- 内联表单绑定数据模型为listQuery表单尺寸为小标签宽度为140px -->
<el-form :inline="true" :model="listQuery" size="small" label-width="140px"> <el-form :inline="true" :model="listQuery" size="small" label-width="140px">
<!-- 商品名称表单项 -->
<el-form-item label="商品名称:"> <el-form-item label="商品名称:">
<!-- 输入框双向绑定listQuery.productName设置了占位提示文字 -->
<el-input v-model="listQuery.productName" class="input-width" placeholder="商品名称"></el-input> <el-input v-model="listQuery.productName" class="input-width" placeholder="商品名称"></el-input>
</el-form-item> </el-form-item>
<!-- 推荐状态表单项 -->
<el-form-item label="推荐状态:"> <el-form-item label="推荐状态:">
<!-- 下拉选择框双向绑定listQuery.recommendStatus有清除功能设置了占位提示文字 -->
<el-select v-model="listQuery.recommendStatus" placeholder="全部" clearable class="input-width"> <el-select v-model="listQuery.recommendStatus" placeholder="全部" clearable class="input-width">
<!-- 循环生成下拉选项每个选项的keylabelvalue根据recommendOptions中的数据来设置 -->
<el-option v-for="item in recommendOptions" <el-option v-for="item in recommendOptions"
:key="item.value" :key="item.value"
:label="item.label" :label="item.label"
@ -47,37 +35,26 @@
</el-form> </el-form>
</div> </div>
</el-card> </el-card>
<!-- 操作区域的卡片 -->
<el-card class="operate-container" shadow="never"> <el-card class="operate-container" shadow="never">
<!-- 图标 -->
<i class="el-icon-tickets"></i> <i class="el-icon-tickets"></i>
<!-- 显示数据列表文字 -->
<span>数据列表</span> <span>数据列表</span>
<!-- 选择商品按钮点击触发handleSelectProduct方法按钮尺寸为迷你型 -->
<el-button size="mini" class="btn-add" @click="handleSelectProduct()"></el-button> <el-button size="mini" class="btn-add" @click="handleSelectProduct()"></el-button>
</el-card> </el-card>
<!-- 表格容器 -->
<div class="table-container"> <div class="table-container">
<!-- el-table组件绑定数据为list设置宽度为100%监听选择变化事件根据listLoading状态显示加载动画有边框 -->
<el-table ref="newProductTable" <el-table ref="newProductTable"
:data="list" :data="list"
style="width: 100%;" style="width: 100%;"
@selection-change="handleSelectionChange" @selection-change="handleSelectionChange"
v-loading="listLoading" border> v-loading="listLoading" border>
<!-- 选择列宽度为60px内容居中 -->
<el-table-column type="selection" width="60" align="center"></el-table-column> <el-table-column type="selection" width="60" align="center"></el-table-column>
<!-- 编号列宽度为120px内容居中通过插槽作用域展示对应行的id数据 -->
<el-table-column label="编号" width="120" align="center"> <el-table-column label="编号" width="120" align="center">
<template slot-scope="scope">{{scope.row.id}}</template> <template slot-scope="scope">{{scope.row.id}}</template>
</el-table-column> </el-table-column>
<!-- 商品名称列内容居中通过插槽作用域展示对应行的productName数据 -->
<el-table-column label="商品名称" align="center"> <el-table-column label="商品名称" align="center">
<template slot-scope="scope">{{scope.row.productName}}</template> <template slot-scope="scope">{{scope.row.productName}}</template>
</el-table-column> </el-table-column>
<!-- 是否推荐列宽度为200px内容居中包含一个开关组件 -->
<el-table-column label="是否推荐" width="200" align="center"> <el-table-column label="是否推荐" width="200" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<!-- 开关组件监听状态改变事件设置了激活和未激活的值双向绑定对应行的recommendStatus数据 -->
<el-switch <el-switch
@change="handleRecommendStatusStatusChange(scope.$index, scope.row)" @change="handleRecommendStatusStatusChange(scope.$index, scope.row)"
:active-value="1" :active-value="1"
@ -86,23 +63,18 @@
</el-switch> </el-switch>
</template> </template>
</el-table-column> </el-table-column>
<!-- 排序列宽度为160px内容居中通过插槽作用域展示对应行的sort数据 -->
<el-table-column label="排序" width="160" align="center"> <el-table-column label="排序" width="160" align="center">
<template slot-scope="scope">{{scope.row.sort}}</template> <template slot-scope="scope">{{scope.row.sort}}</template>
</el-table-column> </el-table-column>
<!-- 状态列宽度为160px内容居中通过管道formatRecommendStatus格式化对应行的recommendStatus数据来展示 -->
<el-table-column label="状态" width="160" align="center"> <el-table-column label="状态" width="160" align="center">
<template slot-scope="scope">{{scope.row.recommendStatus | formatRecommendStatus}}</template> <template slot-scope="scope">{{scope.row.recommendStatus | formatRecommendStatus}}</template>
</el-table-column> </el-table-column>
<!-- 操作列宽度为180px内容居中包含设置排序和删除两个按钮 -->
<el-table-column label="操作" width="180" align="center"> <el-table-column label="操作" width="180" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<!-- 设置排序按钮点击触发handleEditSort方法按钮尺寸为迷你型文本样式 -->
<el-button size="mini" <el-button size="mini"
type="text" type="text"
@click="handleEditSort(scope.$index, scope.row)">设置排序 @click="handleEditSort(scope.$index, scope.row)">设置排序
</el-button> </el-button>
<!-- 删除按钮点击触发handleDelete方法按钮尺寸为迷你型文本样式 -->
<el-button size="mini" <el-button size="mini"
type="text" type="text"
@click="handleDelete(scope.$index, scope.row)">删除 @click="handleDelete(scope.$index, scope.row)">删除
@ -111,13 +83,10 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
</div> </div>
<!-- 批量操作容器 -->
<div class="batch-operate-container"> <div class="batch-operate-container">
<!-- 下拉选择框用于选择批量操作类型双向绑定operateType设置了占位提示文字 -->
<el-select <el-select
size="small" size="small"
v-model="operateType" placeholder="批量操作"> v-model="operateType" placeholder="批量操作">
<!-- 循环生成下拉选项每个选项的keylabelvalue根据operates中的数据来设置 -->
<el-option <el-option
v-for="item in operates" v-for="item in operates"
:key="item.value" :key="item.value"
@ -125,7 +94,6 @@
:value="item.value"> :value="item.value">
</el-option> </el-option>
</el-select> </el-select>
<!-- 确定按钮点击触发handleBatchOperate方法按钮样式为小型主色调与下拉选择框有一定间隔 -->
<el-button <el-button
style="margin-left: 20px" style="margin-left: 20px"
class="search-button" class="search-button"
@ -135,9 +103,7 @@
确定 确定
</el-button> </el-button>
</div> </div>
<!-- 分页容器 -->
<div class="pagination-container"> <div class="pagination-container">
<!-- el-pagination分页组件设置了背景色监听页面尺寸改变和当前页改变事件配置了布局页面尺寸可选页面尺寸列表当前页总数据量等属性 -->
<el-pagination <el-pagination
background background
@size-change="handleSizeChange" @size-change="handleSizeChange"
@ -149,36 +115,27 @@
:total="total"> :total="total">
</el-pagination> </el-pagination>
</div> </div>
<!-- 选择商品的对话框 -->
<el-dialog title="选择商品" :visible.sync="selectDialogVisible" width="50%"> <el-dialog title="选择商品" :visible.sync="selectDialogVisible" width="50%">
<!-- 输入框双向绑定dialogData.listQuery.keyword设置了宽度样式占位提示文字包含一个搜索按钮 -->
<el-input v-model="dialogData.listQuery.keyword" <el-input v-model="dialogData.listQuery.keyword"
style="width: 250px;margin-bottom: 20px" style="width: 250px;margin-bottom: 20px"
size="small" size="small"
placeholder="商品名称搜索"> placeholder="商品名称搜索">
<el-button slot="append" icon="el-icon-search" @click="handleSelectSearch()"></el-button> <el-button slot="append" icon="el-icon-search" @click="handleSelectSearch()"></el-button>
</el-input> </el-input>
<!-- el-table组件用于对话框内展示数据绑定数据为dialogData.list监听选择变化事件有边框 -->
<el-table :data="dialogData.list" <el-table :data="dialogData.list"
@selection-change="handleDialogSelectionChange" border> @selection-change="handleDialogSelectionChange" border>
<!-- 选择列宽度为60px内容居中 -->
<el-table-column type="selection" width="60" align="center"></el-table-column> <el-table-column type="selection" width="60" align="center"></el-table-column>
<!-- 商品名称列内容居中通过插槽作用域展示对应行的name数据 -->
<el-table-column label="商品名称" align="center"> <el-table-column label="商品名称" align="center">
<template slot-scope="scope">{{scope.row.name}}</template> <template slot-scope="scope">{{scope.row.name}}</template>
</el-table-column> </el-table-column>
<!-- 货号列宽度为160px内容居中通过插槽作用域展示对应行的productSn数据格式化展示格式 -->
<el-table-column label="货号" width="160" align="center"> <el-table-column label="货号" width="160" align="center">
<template slot-scope="scope">NO.{{scope.row.productSn}}</template> <template slot-scope="scope">NO.{{scope.row.productSn}}</template>
</el-table-column> </el-table-column>
<!-- 价格列宽度为120px内容居中通过插槽作用域展示对应行的price数据格式化展示格式 -->
<el-table-column label="价格" width="120" align="center"> <el-table-column label="价格" width="120" align="center">
<template slot-scope="scope">{{scope.row.price}}</template> <template slot-scope="scope">{{scope.row.price}}</template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<!-- 对话框内的分页容器 -->
<div class="pagination-container"> <div class="pagination-container">
<!-- el-pagination分页组件设置了背景色监听对话框内页面尺寸改变和当前页改变事件配置了布局页面尺寸可选页面尺寸列表当前页总数据量等属性 -->
<el-pagination <el-pagination
background background
@size-change="handleDialogSizeChange" @size-change="handleDialogSizeChange"
@ -192,334 +149,282 @@
</div> </div>
<div style="clear: both;"></div> <div style="clear: both;"></div>
<div slot="footer"> <div slot="footer">
<!-- 取消按钮点击隐藏对话框按钮尺寸为小型 -->
<el-button size="small" @click="selectDialogVisible = false"> </el-button> <el-button size="small" @click="selectDialogVisible = false"> </el-button>
<!-- 确定按钮点击触发handleSelectDialogConfirm方法按钮尺寸为小型主色调 -->
<el-button size="small" type="primary" @click="handleSelectDialogConfirm()"> </el-button> <el-button size="small" type="primary" @click="handleSelectDialogConfirm()"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
<!-- 设置排序的对话框 -->
<el-dialog title="设置排序" <el-dialog title="设置排序"
:visible.sync="sortDialogVisible" :visible.sync="sortDialogVisible"
width="40%"> width="40%">
<!-- el-form表单组件绑定数据模型为sortDialogData设置标签宽度 -->
<el-form :model="sortDialogData" <el-form :model="sortDialogData"
label-width="150px"> label-width="150px">
<!-- 排序表单项 -->
<el-form-item label="排序:"> <el-form-item label="排序:">
<!-- 输入框双向绑定sortDialogData.sort设置了宽度 -->
<el-input v-model="sortDialogData.sort" style="width: 200px"></el-input> <el-input v-model="sortDialogData.sort" style="width: 200px"></el-input>
</el-form-item> </el-form-item>
</el-form> </el-form>
<span slot="footer"> <span slot="footer">
<!-- 取消按钮点击隐藏对话框按钮尺寸为小型 -->
<el-button @click="sortDialogVisible = false" size="small"> </el-button> <el-button @click="sortDialogVisible = false" size="small"> </el-button>
<!-- 确定按钮点击触发handleUpdateSort方法按钮尺寸为小型主色调 -->
<el-button type="primary" @click="handleUpdateSort" size="small"> </el-button> <el-button type="primary" @click="handleUpdateSort" size="small"> </el-button>
</span> </span>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
<script> <script>
// '@/api/newProduct' import {fetchList,updateRecommendStatus,deleteNewProduct,createNewProduct,updateNewProductSort} from '@/api/newProduct';
import {fetchList,updateRecommendStatus,deleteNewProduct,createNewProduct,updateNewProductSort} from '@/api/newProduct'; import {fetchList as fetchProductList} from '@/api/product';
// '@/api/product'fetchListfetchProductList
import {fetchList as fetchProductList} from '@/api/product';
// const defaultListQuery = {
const defaultListQuery = { pageNum: 1,
pageNum: 1, pageSize: 5,
pageSize: 5, productName: null,
productName: null, recommendStatus: null
recommendStatus: null };
}; const defaultRecommendOptions = [
// ''0 {
const defaultRecommendOptions = [ label: '未推荐',
{ value: 0
label: '未推荐', },
value: 0 {
}, label: '推荐中',
{ value: 1
label: '推荐中', }
value: 1 ];
} export default {
]; name: 'newProductList',
data() {
export default { return {
name: 'newProductList', listQuery: Object.assign({}, defaultListQuery),
data() { recommendOptions: Object.assign({}, defaultRecommendOptions),
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, list: null,
// null
total: null, total: null,
// listLoading: false,
multipleSelection:[], multipleSelection: [],
listQuery:{ operates: [
// null {
keyword: null, label: "设为推荐",
// 1 value: 0
pageNum: 1, },
// 5 {
pageSize: 5 label: "取消推荐",
} value: 1
}, },
// false {
sortDialogVisible:false, label: "删除",
// id value: 2
sortDialogData:{sort:0,id:null} }
} ],
}, operateType: null,
created() { selectDialogVisible:false,
// getList dialogData:{
this.getList(); list: null,
}, total: null,
filters:{ multipleSelection:[],
// formatRecommendStatus listQuery:{
formatRecommendStatus(status){ keyword: null,
if(status===1){ //10'''' pageNum: 1,
return '推荐中'; pageSize: 5
}else{ }
return '未推荐'; },
sortDialogVisible:false,
sortDialogData:{sort:0,id:null}
} }
}
},
methods: {
// defaultListQuery
handleResetSearch() {
this.listQuery = Object.assign({}, defaultListQuery);
},
// 1getList
handleSearchList() {
this.listQuery.pageNum = 1;
this.getList();
},
// multipleSelection
handleSelectionChange(val){
this.multipleSelection = val;
}, },
// 1getList created() {
handleSizeChange(val) {
this.listQuery.pageNum = 1;
this.listQuery.pageSize = val;
this.getList(); this.getList();
}, },
// getList filters:{
handleCurrentChange(val) { formatRecommendStatus(status){
this.listQuery.pageNum = val; if(status===1){
this.getList(); return '推荐中';
}, }else{
// updateRecommendStatusStatusid return '未推荐';
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
});
} }
}, },
// getDialogList methods: {
handleSelectProduct(){ handleResetSearch() {
this.selectDialogVisible=true; this.listQuery = Object.assign({}, defaultListQuery);
this.getDialogList(); },
}, handleSearchList() {
// getDialogList this.listQuery.pageNum = 1;
handleSelectSearch(){ this.getList();
this.getDialogList(); },
}, handleSelectionChange(val){
// 1getDialogList this.multipleSelection = val;
handleDialogSizeChange(val) { },
this.dialogData.listQuery.pageNum = 1; handleSizeChange(val) {
this.dialogData.listQuery.pageSize = val; this.listQuery.pageNum = 1;
this.getDialogList(); this.listQuery.pageSize = val;
}, this.getList();
// getDialogList },
handleDialogCurrentChange(val) { handleCurrentChange(val) {
this.dialogData.listQuery.pageNum = val; this.listQuery.pageNum = val;
this.getDialogList(); this.getList();
}, },
// dialogData.multipleSelection handleRecommendStatusStatusChange(index,row){
handleDialogSelectionChange(val){ this.updateRecommendStatusStatus(row.id,row.recommendStatus);
this.dialogData.multipleSelection = val; },
}, handleDelete(index,row){
// this.deleteProduct(row.id);
handleSelectDialogConfirm(){ },
if (this.dialogData.multipleSelection < 1) { handleBatchOperate(){
this.$message({ if (this.multipleSelection < 1) {
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({ this.$message({
type: 'success', message: '请选择一条记录',
message: '添加成功!' type: 'warning',
duration: 1000
}); });
}); return;
}); }
}, let ids = [];
// for (let i = 0; i < this.multipleSelection.length; i++) {
handleEditSort(index,row){ ids.push(this.multipleSelection[i].id);
this.sortDialogVisible=true; }
this.sortDialogData.sort=row.sort; if (this.operateType === 0) {
this.sortDialogData.id=row.id; //id便 //
}, this.updateRecommendStatusStatus(ids,1);
// } else if (this.operateType === 1) {
handleUpdateSort(){ //
this.$confirm('是否要修改排序?', '提示', { // this.updateRecommendStatusStatus(ids,0);
confirmButtonText: '确定', } else if(this.operateType===2){
cancelButtonText: '取消', //
type: 'warning' this.deleteProduct(ids);
}).then(() => { }else {
updateNewProductSort(this.sortDialogData).then(response=>{ //updateNewProductSort
this.sortDialogVisible=false;
this.getList(); //
this.$message({ this.$message({
type: 'success', message: '请选择批量操作类型',
message: '删除成功!' type: 'warning',
duration: 1000
}); });
}); }
}) },
}, handleSelectProduct(){
// this.selectDialogVisible=true;
getList() { this.getDialogList();
this.listLoading = true; //true },
fetchList(this.listQuery).then(response => { //fetchList handleSelectSearch(){
this.listLoading = false; //false this.getDialogList();
this.list = response.data.list; // },
this.total = response.data.total; handleDialogSizeChange(val) {
}) this.dialogData.listQuery.pageNum = 1;
}, this.dialogData.listQuery.pageSize = val;
// this.getDialogList();
updateRecommendStatusStatus(ids,status){ },
this.$confirm('是否要修改推荐状态?', '提示', { // handleDialogCurrentChange(val) {
confirmButtonText: '确定', this.dialogData.listQuery.pageNum = val;
cancelButtonText: '取消', this.getDialogList();
type: 'warning' },
}).then(() => { handleDialogSelectionChange(val){
let params=new URLSearchParams(); //ididURLSearchParams this.dialogData.multipleSelection = val;
params.append("ids",ids); },
params.append("recommendStatus",status); handleSelectDialogConfirm(){
updateRecommendStatus(params).then(response=>{ //updateRecommendStatus if (this.dialogData.multipleSelection < 1) {
this.getList(); //
this.$message({ this.$message({
type: 'success', 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: '添加成功!'
});
}); });
}); });
}).catch(() => { },
this.$message({ // handleEditSort(index,row){
type: 'success', this.sortDialogVisible=true;
message: '已取消操作!' this.sortDialogData.sort=row.sort;
}); this.sortDialogData.id=row.id;
this.getList(); },
}); handleUpdateSort(){
}, this.$confirm('是否要修改排序?', '提示', {
// confirmButtonText: '确定',
deleteProduct(ids){ cancelButtonText: '取消',
this.$confirm('是否要删除该推荐?', '提示', { // type: 'warning'
confirmButtonText: '确定', }).then(() => {
cancelButtonText: '取消', updateNewProductSort(this.sortDialogData).then(response=>{
type: 'warning' this.sortDialogVisible=false;
}).then(() => { this.getList();
let params=new URLSearchParams(); //ididURLSearchParams this.$message({
params.append("ids",ids); type: 'success',
deleteNewProduct(params).then(response=>{ //deleteNewProduct message: '删除成功!'
this.getList(); // });
});
})
},
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(() => {
this.$message({ this.$message({
type: 'success', type: 'success',
message: '删除成功!' message: '已取消操作!'
}); });
this.getList();
}); });
}) },
}, deleteProduct(ids){
// this.$confirm('是否要删除该推荐?', '提示', {
getDialogList(){ confirmButtonText: '确定',
fetchProductList(this.dialogData.listQuery).then(response=>{ //fetchProductList cancelButtonText: '取消',
this.dialogData.list=response.data.list; // type: 'warning'
this.dialogData.total=response.data.total; }).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;
})
}
} }
} }
}
</script> </script>
<style></style> <style></style>

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

Loading…
Cancel
Save