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

@ -1,15 +1,12 @@
<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"指定当前激活的步骤索引为 6:active="6"这里可能需要根据实际业务逻辑根据订单物流状态动态设置该值设置已完成步骤的状态样式为 "success"通常表示成功完成的视觉效果比如显示为绿色等设置每个步骤之间的间隔为 50pxspace="50px" -->
<el-steps direction="vertical" <el-steps direction="vertical"
:active="6" :active="6"
finish-status="success" finish-status="success"
space="50px"> space="50px">
<!-- 通过 v-for 指令循环遍历 logisticsList 数据数组来动态生成每个步骤el-step每个步骤绑定一个唯一的 key使用 :key="item.name" Vue 中循环渲染列表时key 是必要的有助于 Vue 更高效地更新虚拟 DOM设置步骤的标题为 item.name从数据中获取每个步骤对应的名称设置步骤的描述信息为 item.time从数据中获取对应时间信息 -->
<el-step v-for="item in logisticsList" <el-step v-for="item in logisticsList"
:key="item.name" :key="item.name"
:title="item.name" :title="item.name"
@ -18,7 +15,6 @@
</el-dialog> </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 '},
@ -28,17 +24,12 @@
{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 '}
]; ];
// Vue
export default { export default {
// Vue 'logisticsDialog'
name:'logisticsDialog', name:'logisticsDialog',
// props value Vue
props: { props: {
value: Boolean value: Boolean
}, },
computed:{ computed:{
// visible get set props value Vue props 便
visible: { visible: {
get() { get() {
return this.value; return this.value;
@ -50,16 +41,13 @@
}, },
data() { data() {
return { return {
// defaultLogisticsList Object.assign logisticsList
logisticsList:Object.assign({},defaultLogisticsList) logisticsList:Object.assign({},defaultLogisticsList)
} }
}, },
methods:{ methods:{
// emitInput 'input' val Vue $emit
emitInput(val) { emitInput(val) {
this.$emit('input', val) this.$emit('input', val)
}, },
// handleClose el-dialog :before-close emitInput false
handleClose(){ handleClose(){
this.emitInput(false); this.emitInput(false);
} }
@ -67,3 +55,5 @@
} }
</script> </script>
<style></style> <style></style>

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

@ -1,14 +1,9 @@
<template> <template> 
<!-- 创建一个类名为 "app-container" div 作为整体页面容器 -->
<div class="app-container"> <div class="app-container">
<!-- 使用 el-card 组件创建一个卡片式容器用于放置筛选搜索相关内容设置类名为 "filter-container" 并取消阴影效果 -->
<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>
<!-- 类似上述按钮设置右浮动及右外边距点击调用 "handleResetSearch" 方法用于重置筛选条件按钮大小为 "small"文本为 "重置" -->
<el-button <el-button
style="float:right;margin-right: 15px" style="float:right;margin-right: 15px"
@click="handleResetSearch()" @click="handleResetSearch()"
@ -25,17 +19,13 @@
</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 组件定义表单中的一项用于输入订单编号的搜索框双向绑定 "listQuery.orderSn"设置类名控制宽度添加占位提示文本 -->
<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>
<!-- 类似上述用于输入收货人相关关键字的搜索框绑定 "listQuery.receiverKeyword" -->
<el-form-item label="收货人:"> <el-form-item label="收货人:">
<el-input v-model="listQuery.receiverKeyword" class="input-width" placeholder="收货人姓名/手机号码"></el-input> <el-input v-model="listQuery.receiverKeyword" class="input-width" placeholder="收货人姓名/手机号码"></el-input>
</el-form-item> </el-form-item>
<!-- 用于选择提交时间的日期选择器绑定 "listQuery.createTime"设置日期格式类型为 "date"仅选择日期及占位提示文本通过类名控制宽度 -->
<el-form-item label="提交时间:"> <el-form-item label="提交时间:">
<el-date-picker <el-date-picker
class="input-width" class="input-width"
@ -45,7 +35,6 @@
placeholder="请选择时间"> placeholder="请选择时间">
</el-date-picker> </el-date-picker>
</el-form-item> </el-form-item>
<!-- 用于选择订单状态的下拉选择框绑定 "listQuery.status"设置类名控制宽度占位提示文本并允许清空选项通过循环选项数据动态生成下拉选项 -->
<el-form-item label="订单状态:"> <el-form-item label="订单状态:">
<el-select v-model="listQuery.status" class="input-width" placeholder="全部" clearable> <el-select v-model="listQuery.status" class="input-width" placeholder="全部" clearable>
<el-option v-for="item in statusOptions" <el-option v-for="item in statusOptions"
@ -55,7 +44,6 @@
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<!-- 用于选择订单分类的下拉选择框绑定 "listQuery.orderType"类似上述设置 -->
<el-form-item label="订单分类:"> <el-form-item label="订单分类:">
<el-select v-model="listQuery.orderType" class="input-width" placeholder="全部" clearable> <el-select v-model="listQuery.orderType" class="input-width" placeholder="全部" clearable>
<el-option v-for="item in orderTypeOptions" <el-option v-for="item in orderTypeOptions"
@ -65,7 +53,6 @@
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<!-- 用于选择订单来源的下拉选择框绑定 "listQuery.sourceType"同样的设置方式 -->
<el-form-item label="订单来源:"> <el-form-item label="订单来源:">
<el-select v-model="listQuery.sourceType" class="input-width" placeholder="全部" clearable> <el-select v-model="listQuery.sourceType" class="input-width" placeholder="全部" clearable>
<el-option v-for="item in sourceTypeOptions" <el-option v-for="item in sourceTypeOptions"
@ -78,54 +65,41 @@
</el-form> </el-form>
</div> </div>
</el-card> </el-card>
<!-- 使用 el-card 组件创建另一个卡片式容器用于展示数据列表相关的标题设置类名为 "operate-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>
</el-card> </el-card>
<!-- 创建一个类名为 "table-container" div用于放置展示数据的表格 -->
<div class="table-container"> <div class="table-container">
<!-- el-table 组件创建表格设置引用绑定数据宽度监听行选择变化事件以及控制加载状态等属性 -->
<el-table ref="orderTable" <el-table ref="orderTable"
: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="80" align="center"> <el-table-column label="编号" width="80" 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.orderSn}}</template> <template slot-scope="scope">{{scope.row.orderSn}}</template>
</el-table-column> </el-table-column>
<!-- 定义表格列展示提交时间信息设置宽度和文本对齐方式通过管道符调用 formatCreateTime 过滤器对时间进行格式化后展示 -->
<el-table-column label="提交时间" width="180" align="center"> <el-table-column label="提交时间" width="180" align="center">
<template slot-scope="scope">{{scope.row.createTime | formatCreateTime}}</template> <template slot-scope="scope">{{scope.row.createTime | formatCreateTime}}</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="120" align="center"> <el-table-column label="订单金额" width="120" align="center">
<template slot-scope="scope">{{scope.row.totalAmount}}</template> <template slot-scope="scope">{{scope.row.totalAmount}}</template>
</el-table-column> </el-table-column>
<!-- 定义表格列展示支付方式信息设置宽度和文本对齐方式通过管道符调用 formatPayType 过滤器对支付方式进行格式化后展示 -->
<el-table-column label="支付方式" width="120" align="center"> <el-table-column label="支付方式" width="120" align="center">
<template slot-scope="scope">{{scope.row.payType | formatPayType}}</template> <template slot-scope="scope">{{scope.row.payType | formatPayType}}</template>
</el-table-column> </el-table-column>
<!-- 定义表格列展示订单来源信息设置宽度和文本对齐方式通过管道符调用 formatSourceType 过滤器对订单来源进行格式化后展示 -->
<el-table-column label="订单来源" width="120" align="center"> <el-table-column label="订单来源" width="120" align="center">
<template slot-scope="scope">{{scope.row.sourceType | formatSourceType}}</template> <template slot-scope="scope">{{scope.row.sourceType | formatSourceType}}</template>
</el-table-column> </el-table-column>
<!-- 定义表格列展示订单状态信息设置宽度和文本对齐方式通过管道符调用 formatStatus 过滤器对订单状态进行格式化后展示 -->
<el-table-column label="订单状态" width="120" align="center"> <el-table-column label="订单状态" width="120" 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="200" align="center"> <el-table-column label="操作" width="200" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
@ -153,9 +127,7 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
</div> </div>
<!-- 创建一个类名为 "batch-operate-container" div用于放置批量操作相关的选择框和按钮 -->
<div class="batch-operate-container"> <div class="batch-operate-container">
<!-- el-select 组件创建下拉选择框设置大小绑定数据模型通过循环选项数据动态生成下拉选项 -->
<el-select <el-select
size="small" size="small"
v-model="operateType" placeholder="批量操作"> v-model="operateType" placeholder="批量操作">
@ -166,7 +138,6 @@
:value="item.value"> :value="item.value">
</el-option> </el-option>
</el-select> </el-select>
<!-- el-button 组件创建按钮设置左外边距类名点击调用 "handleBatchOperate" 方法按钮类型为 "primary" 以及按钮大小为 "small"文本为 "确定" -->
<el-button <el-button
style="margin-left: 20px" style="margin-left: 20px"
class="search-button" class="search-button"
@ -176,9 +147,7 @@
确定 确定
</el-button> </el-button>
</div> </div>
<!-- 创建一个类名为 "pagination-container" div用于放置分页组件 -->
<div class="pagination-container"> <div class="pagination-container">
<!-- el-pagination 组件创建分页器设置背景色监听页面大小和当前页变化事件配置分页布局绑定当前页每页显示数量以及可选的每页显示数量选项和总数据条数等属性 -->
<el-pagination <el-pagination
background background
@size-change="handleSizeChange" @size-change="handleSizeChange"
@ -190,7 +159,6 @@
:total="total"> :total="total">
</el-pagination> </el-pagination>
</div> </div>
<!-- el-dialog 组件创建一个对话框用于关闭订单时输入备注信息设置标题绑定可见性以及宽度等属性 -->
<el-dialog <el-dialog
title="关闭订单" title="关闭订单"
:visible.sync="closeOrder.dialogVisible" width="30%"> :visible.sync="closeOrder.dialogVisible" width="30%">
@ -207,20 +175,13 @@
<el-button type="primary" @click="handleCloseOrderConfirm"> </el-button> <el-button type="primary" @click="handleCloseOrderConfirm"> </el-button>
</span> </span>
</el-dialog> </el-dialog>
<!-- 使用 logistics-dialog 组件自定义组件双向绑定 visible 属性推测用于控制显示隐藏 -->
<logistics-dialog v-model="logisticsDialogVisible"></logistics-dialog> <logistics-dialog v-model="logisticsDialogVisible"></logistics-dialog>
</div> </div>
</template> </template>
<script> <script>
// '@/api/order' API import {fetchList,closeOrder,deleteOrder} from '@/api/order'
import {fetchList, closeOrder, deleteOrder} from '@/api/order';
// '@/utils/date' formatDate
import {formatDate} from '@/utils/date'; import {formatDate} from '@/utils/date';
// LogisticsDialog
import LogisticsDialog from '@/views/oms/order/components/logisticsDialog'; import LogisticsDialog from '@/views/oms/order/components/logisticsDialog';
// listQuery null
const defaultListQuery = { const defaultListQuery = {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
@ -231,96 +192,22 @@
sourceType: null, sourceType: null,
createTime: null, createTime: null,
}; };
// Vue datacreatedmethods
export default { export default {
name: '组件名称(这里未定义,可自行补充合适名称)',
data() {
return {
// Object.assign defaultListQuery
listQuery: Object.assign({}, defaultListQuery),
//
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: {
// fetchList
handleSearchList() {
//
this.listLoading = true;
fetchList(this.listQuery).then(response => {
this.list = response.data;
this.listLoading = false;
});
},
// handleSearchList listQuery
handleResetSearch() {
// listQuery
this.listQuery = Object.assign({}, defaultListQuery);
this.handleSearchList();
},
//
handleSelectionChange(selections) {
// selections
},
//
handleViewOrder(index, row) {
//
this.$router.push({path: '/orderDetail', query: {id: row.id}});
},
//
<script>
// Vue 使
export default {
// Vue
name: "orderList", name: "orderList",
// 使 LogisticsDialog
components:{LogisticsDialog}, components:{LogisticsDialog},
data() { data() {
return { return {
// Object.assign defaultListQuery
listQuery: Object.assign({}, defaultListQuery), listQuery: Object.assign({}, defaultListQuery),
// true
listLoading: true, listLoading: true,
// null
list: null, list: null,
// null
total: null, total: null,
// null
operateType: null, operateType: null,
//
multipleSelection: [], multipleSelection: [],
// id
closeOrder:{ closeOrder:{
dialogVisible:false, dialogVisible:false,
content:null, content:null,
orderIds:[] orderIds:[]
}, },
// label value
statusOptions: [ statusOptions: [
{ {
label: '待付款', label: '待付款',
@ -343,7 +230,6 @@
value: 4 value: 4
} }
], ],
//
orderTypeOptions: [ orderTypeOptions: [
{ {
label: '正常订单', label: '正常订单',
@ -354,7 +240,6 @@
value: 1 value: 1
} }
], ],
//
sourceTypeOptions: [ sourceTypeOptions: [
{ {
label: 'PC订单', label: 'PC订单',
@ -365,7 +250,6 @@
value: 1 value: 1
} }
], ],
//
operateOptions: [ operateOptions: [
{ {
label: "批量发货", label: "批量发货",
@ -380,21 +264,17 @@
value: 3 value: 3
} }
], ],
// false
logisticsDialogVisible:false logisticsDialogVisible:false
} }
}, },
created() { created() {
// getList
this.getList(); this.getList();
}, },
filters: { filters: {
// formatCreateTime 'yyyy-MM-dd hh:mm:ss'
formatCreateTime(time) { formatCreateTime(time) {
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')
}, },
// 1 ''2 '' ''
formatPayType(value) { formatPayType(value) {
if (value === 1) { if (value === 1) {
return '支付宝'; return '支付宝';
@ -404,7 +284,6 @@
return '未支付'; return '未支付';
} }
}, },
// 1 'APP' 'PC'
formatSourceType(value) { formatSourceType(value) {
if (value === 1) { if (value === 1) {
return 'APP订单'; return 'APP订单';
@ -412,7 +291,6 @@
return 'PC订单'; return 'PC订单';
} }
}, },
//
formatStatus(value) { formatStatus(value) {
if (value === 1) { if (value === 1) {
return '待发货'; return '待发货';
@ -430,44 +308,35 @@
}, },
}, },
methods: { methods: {
// listQuery defaultListQuery 便
handleResetSearch() { handleResetSearch() {
this.listQuery = Object.assign({}, defaultListQuery); this.listQuery = Object.assign({}, defaultListQuery);
}, },
// 1 getList
handleSearchList() { handleSearchList() {
this.listQuery.pageNum = 1; this.listQuery.pageNum = 1;
this.getList(); this.getList();
}, },
// val multipleSelection
handleSelectionChange(val){ handleSelectionChange(val){
this.multipleSelection = val; this.multipleSelection = val;
}, },
// Vue this.$router'/oms/orderDetail' id
handleViewOrder(index, row){ handleViewOrder(index, row){
this.$router.push({path:'/oms/orderDetail',query:{id:row.id}}) this.$router.push({path:'/oms/orderDetail',query:{id:row.id}})
}, },
// visible true id closeOrder.orderIds 便使
handleCloseOrder(index, row){ handleCloseOrder(index, row){
this.closeOrder.dialogVisible=true; this.closeOrder.dialogVisible=true;
this.closeOrder.orderIds=[row.id]; this.closeOrder.orderIds=[row.id];
}, },
// covertOrder '/oms/deliverOrderList'
handleDeliveryOrder(index, row){ handleDeliveryOrder(index, row){
let listItem = this.covertOrder(row); let listItem = this.covertOrder(row);
this.$router.push({path:'/oms/deliverOrderList',query:{list:[listItem]}}) this.$router.push({path:'/oms/deliverOrderList',query:{list:[listItem]}})
}, },
// logisticsDialogVisible true
handleViewLogistics(index, row){ handleViewLogistics(index, row){
this.logisticsDialogVisible=true; this.logisticsDialogVisible=true;
}, },
// ids id deleteOrder ids
handleDeleteOrder(index, row){ handleDeleteOrder(index, row){
let ids=[]; let ids=[];
ids.push(row.id); ids.push(row.id);
this.deleteOrder(ids); this.deleteOrder(ids);
}, },
//
handleBatchOperate(){ handleBatchOperate(){
if(this.multipleSelection==null||this.multipleSelection.length<1){ if(this.multipleSelection==null||this.multipleSelection.length<1){
this.$message({ this.$message({
@ -477,16 +346,14 @@
}); });
return; return;
} }
// 1
if(this.operateType===1){ if(this.operateType===1){
//
let list=[]; let list=[];
// 1 covertOrder list
for(let i=0;i<this.multipleSelection.length;i++){ for(let i=0;i<this.multipleSelection.length;i++){
if(this.multipleSelection[i].status===1){ if(this.multipleSelection[i].status===1){
list.push(this.covertOrder(this.multipleSelection[i])); list.push(this.covertOrder(this.multipleSelection[i]));
} }
} }
// 0
if(list.length===0){ if(list.length===0){
this.$message({ this.$message({
message: '选中订单中没有可以发货的订单', message: '选中订单中没有可以发货的订单',
@ -495,38 +362,32 @@
}); });
return; return;
} }
// '/oms/deliverOrderList'
this.$router.push({path:'/oms/deliverOrderList',query:{list:list}}) this.$router.push({path:'/oms/deliverOrderList',query:{list:list}})
}else if(this.operateType===2){ }else if(this.operateType===2){
// 2 //
// closeOrder.orderIds id closeOrder.orderIds visible true
this.closeOrder.orderIds=[]; this.closeOrder.orderIds=[];
for(let i=0;i<this.multipleSelection.length;i++){ for(let i=0;i<this.multipleSelection.length;i++){
this.closeOrder.orderIds.push(this.multipleSelection[i].id); this.closeOrder.orderIds.push(this.multipleSelection[i].id);
} }
this.closeOrder.dialogVisible=true; this.closeOrder.dialogVisible=true;
}else if(this.operateType===3){ }else if(this.operateType===3){
// 3 //
let ids=[]; let ids=[];
// id ids deleteOrder ids
for(let i=0;i<this.multipleSelection.length;i++){ for(let i=0;i<this.multipleSelection.length;i++){
ids.push(this.multipleSelection[i].id); ids.push(this.multipleSelection[i].id);
} }
this.deleteOrder(ids); this.deleteOrder(ids);
} }
}, },
// 1 getList
handleSizeChange(val){ handleSizeChange(val){
this.listQuery.pageNum = 1; this.listQuery.pageNum = 1;
this.listQuery.pageSize = val; this.listQuery.pageSize = val;
this.getList(); this.getList();
}, },
// getList
handleCurrentChange(val){ handleCurrentChange(val){
this.listQuery.pageNum = val; this.listQuery.pageNum = val;
this.getList(); this.getList();
}, },
//
handleCloseOrderConfirm() { handleCloseOrderConfirm() {
if (this.closeOrder.content == null || this.closeOrder.content === '') { if (this.closeOrder.content == null || this.closeOrder.content === '') {
this.$message({ this.$message({
@ -536,15 +397,6 @@
}); });
return; 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);

@ -180,292 +180,80 @@
</el-row> </el-row>
</div> </div>
<div style="margin-top: 20px"> <div style="margin-top: 20px">
<!-- 使用 svg-icon 组件展示一个图标设置图标类名为 "marker"并指定图标颜色 -->
<svg-icon icon-class="marker" style="color: #606266"></svg-icon> <svg-icon icon-class="marker" style="color: #606266"></svg-icon>
<!-- 展示一段文本应用 "font-small" 类名用于设置较小字体样式文本内容为 "操作信息" -->
<span class="font-small">操作信息</span> <span class="font-small">操作信息</span>
</div> </div>
<!-- 使用 el-table 组件展示表格数据设置了一些样式属性引用以及绑定数据等 -->
<el-table style="margin-top: 20px;width: 100%" <el-table style="margin-top: 20px;width: 100%"
ref="orderHistoryTable" ref="orderHistoryTable"
:data="order.historyList" border> :data="order.historyList" border>
<!-- 定义表格列展示 "操作者" 信息设置列宽度文本对齐方式并通过插槽作用域获取对应行数据展示 -->
<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.operateMan}} {{scope.row.operateMan}}
</template> </template>
</el-table-column> </el-table-column>
<!-- 定义表格列展示 "操作时间" 信息设置列宽度文本对齐方式通过调用 formatTime 方法格式化时间后展示 -->
<el-table-column label="操作时间" width="160" align="center"> <el-table-column label="操作时间" width="160" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
{{formatTime(scope.row.createTime)}} {{formatTime(scope.row.createTime)}}
</template> </template>
</el-table-column> </el-table-column>
<!-- 定义表格列展示 "订单状态" 信息设置列宽度文本对齐方式通过管道符调用 formatStatus 过滤器对状态进行格式化后展示 -->
<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.orderStatus | formatStatus}} {{scope.row.orderStatus | formatStatus}}
</template> </template>
</el-table-column> </el-table-column>
<!-- 定义表格列展示 "付款状态" 信息设置列宽度文本对齐方式通过管道符调用 formatPayStatus 过滤器对付款状态进行格式化后展示 -->
<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.orderStatus | formatPayStatus}} {{scope.row.orderStatus | formatPayStatus}}
</template> </template>
</el-table-column> </el-table-column>
<!-- 定义表格列展示 "发货状态" 信息设置列宽度文本对齐方式通过管道符调用 formatDeliverStatus 过滤器对发货状态进行格式化后展示 -->
<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.orderStatus | formatDeliverStatus}} {{scope.row.orderStatus | formatDeliverStatus}}
</template> </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.note}} {{scope.row.note}}
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<!-- 使用 el-card 组件包裹内容此处 el-card 结束标签在后面代码中未完整展示但推测是用于布局和样式统一等作用 -->
<el-card>
<!-- el-dialog 组件用于创建一个对话框用于修改收货人信息设置对话框标题绑定可见性以及宽度等属性 -->
<el-dialog title="修改收货人信息"
:visible.sync="receiverDialogVisible"
width="40%">
<!-- el-form 组件用于创建表单绑定数据模型为 receiverInfo设置表单引用以及标签宽度等属性 -->
<el-form :model="receiverInfo"
ref="receiverInfoForm"
label-width="150px">
<!-- el-form-item 组件用于定义表单中的一项此处展示 "收货人姓名" 输入框 -->
<el-form-item label="收货人姓名:">
<el-input v-model="receiverInfo.receiverName" style="width: 200px"></el-input>
</el-form-item>
<!-- 类似上述展示 "手机号码" 输入框 -->
<el-form-item label="手机号码:">
<el-input v-model="receiverInfo.receiverPhone" style="width: 200px">
</el-input>
</el-form-item>
<!-- 展示 "邮政编码" 输入框 -->
<el-form-item label="邮政编码:">
<el-input v-model="receiverInfo.receiverPostCode" style="width: 200px">
</el-input>
</el-form-item>
<!-- 使用 v-distpicker 组件可能是用于地区选择的第三方组件绑定省份城市地区数据并监听 selected 事件 -->
<el-form-item label="所在区域:">
<v-distpicker :province="receiverInfo.receiverProvince"
:city="receiverInfo.receiverCity"
:area="receiverInfo.receiverRegion"
@selected="onSelectRegion"></v-distpicker>
</el-form-item>
<!-- 展示 "详细地址" 输入框设置为文本域类型指定行数 -->
<el-form-item label="详细地址:">
<el-input v-model="receiverInfo.receiverDetailAddress" type="textarea" rows="3">
</el-input>
</el-form-item>
</el-form>
<!-- 在对话框的 footer 插槽中定义两个按钮一个用于取消点击隐藏对话框一个用于确定点击调用 handleUpdateReceiverInfo 方法 -->
<span slot="footer" class="dialog-footer">
<el-button @click="receiverDialogVisible = false"> </el-button>
<el-button type="primary" @click="handleUpdateReceiverInfo"> </el-button>
</span>
</el-dialog>
<!-- 另一个 el-dialog 组件用于修改费用信息同样设置标题可见性绑定和宽度等属性 -->
<el-dialog title="修改费用信息"
:visible.sync="moneyDialogVisible"
width="40%">
<!-- 内部使用类名为 "table-layout" div 进行布局通过多个 el-row el-col 组合展示费用相关信息表格形式 -->
<div class="table-layout">
<el-row>
<el-col :span="6" class="table-cell-title">商品合计</el-col>
<el-col :span="6" class="table-cell-title">运费</el-col>
<el-col :span="6" class="table-cell-title">优惠券</el-col>
<el-col :span="6" class="table-cell-title">积分抵扣</el-col>
</el-row>
<el-row>
<el-col :span="6" class="table-cell">{{order.totalAmount}}</el-col>
<el-col :span="6" class="table-cell">
<el-input v-model.number="moneyInfo.freightAmount" size="mini"><template slot="prepend"></template></el-input>
</el-col>
<el-col :span="6" class="table-cell">-{{order.couponAmount}}</el-col>
<el-col :span="6" class="table-cell">-{{order.integrationAmount}}</el-col>
</el-row>
<el-row>
<el-col :span="6" class="table-cell-title">活动优惠</el-col>
<el-col :span="6" class="table-cell-title">折扣金额</el-col>
<el-col :span="6" class="table-cell-title">订单总金额</el-col>
<el-col :span="6" class="table-cell-title">应付款金额</el-col>
</el-row>
<el-row>
<el-col :span="6" class="table-cell">-{{order.promotionAmount}}</el-col>
<el-col :span="6" class="table-cell">
<el-input v-model.number="moneyInfo.discountAmount" size="mini"><template slot="prepend">-</template></el-input>
</el-col>
<el-col :span="6" class="table-cell">
<span class="color-danger">{{order.totalAmount+moneyInfo.freightAmount}}</span>
</el-col>
<el-col :span="6" class="table-cell">
<span class="color-danger">{{order.payAmount+moneyInfo.freightAmount-moneyInfo.discountAmount}}</span>
</el-col>
</el-row>
</div>
<!-- 在对话框的 footer 插槽中同样定义取消和确定按钮确定按钮点击调用 handleUpdateMoneyInfo 方法 -->
<span slot="footer" class="dialog-footer">
<el-button @click="moneyDialogVisible = false"> </el-button>
<el-button type="primary" @click="handleUpdateMoneyInfo"> </el-button>
</span>
</el-dialog>
<!-- el-dialog 组件用于发送站内信设置相关属性 -->
<el-dialog title="发送站内信"
:visible.sync="messageDialogVisible"
width="40%">
<el-form :model="message"
ref="receiverInfoForm"
label-width="150px">
<el-form-item label="标题:">
<el-input v-model="message.title" style="width: 200px"></el-input>
</el-form-item>
<el-form-item label="内容:">
<el-input v-model="message.content" type="textarea" rows="3">
</el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="messageDialogVisible = false"> </el-button>
<el-button type="primary" @click="handleSendMessage"> </el-button>
</span>
</el-dialog>
<!-- el-dialog 组件用于关闭订单设置相关属性 -->
<el-dialog title="关闭订单"
:visible.sync="closeDialogVisible"
width="40%">
<el-form :model="closeInfo"
label-width="150px">
<el-form-item label="操作备注:">
<el-input v-model="closeInfo.note" type="textarea" rows="3">
</el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="closeDialogVisible = false"> </el-button>
<el-button type="primary" @click="handleCloseOrder"> </el-button>
</span>
</el-dialog>
<!-- el-dialog 组件用于备注订单设置相关属性 -->
<el-dialog title="备注订单"
:visible.sync="markOrderDialogVisible"
width="40%">
<el-form :model="markInfo"
label-width="150px">
<el-form-item label="操作备注:">
<el-input v-model="markInfo.note" type="textarea" rows="3">
</el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="markOrderDialogVisible = false"> </el-button>
<el-button type="primary" @click="handleMarkOrder"> </el-button>
</span>
</el-dialog>
<!-- 使用 logistics-dialog 组件自定义组件双向绑定 visible 属性推测用于控制显示隐藏 -->
<logistics-dialog v-model="logisticsDialogVisible"></logistics-dialog>
</el-card> </el-card>
</div>
</template>
<div style="margin-top: 20px">
<!-- 使用 svg-icon 组件展示一个图标设置图标类名为 "marker"并指定图标颜色 -->
<svg-icon icon-class="marker" style="color: #606266"></svg-icon>
<!-- 展示一段文本应用 "font-small" 类名用于设置较小字体样式文本内容为 "操作信息" -->
<span class="font-small">操作信息</span>
</div>
<!-- 使用 el-table 组件展示表格数据设置了一些样式属性引用以及绑定数据等 -->
<el-table style="margin-top: 20px;width: 100%"
ref="orderHistoryTable"
:data="order.historyList" border>
<!-- 定义表格列展示 "操作者" 信息设置列宽度文本对齐方式并通过插槽作用域获取对应行数据展示 -->
<el-table-column label="操作者" width="120" align="center">
<template slot-scope="scope">
{{scope.row.operateMan}}
</template>
</el-table-column>
<!-- 定义表格列展示 "操作时间" 信息设置列宽度文本对齐方式通过调用 formatTime 方法格式化时间后展示 -->
<el-table-column label="操作时间" width="160" align="center">
<template slot-scope="scope">
{{formatTime(scope.row.createTime)}}
</template>
</el-table-column>
<!-- 定义表格列展示 "订单状态" 信息设置列宽度文本对齐方式通过管道符调用 formatStatus 过滤器对状态进行格式化后展示 -->
<el-table-column label="订单状态" width="120" align="center">
<template slot-scope="scope">
{{scope.row.orderStatus | formatStatus}}
</template>
</el-table-column>
<!-- 定义表格列展示 "付款状态" 信息设置列宽度文本对齐方式通过管道符调用 formatPayStatus 过滤器对付款状态进行格式化后展示 -->
<el-table-column label="付款状态" width="120" align="center">
<template slot-scope="scope">
{{scope.row.orderStatus | formatPayStatus}}
</template>
</el-table-column>
<!-- 定义表格列展示 "发货状态" 信息设置列宽度文本对齐方式通过管道符调用 formatDeliverStatus 过滤器对发货状态进行格式化后展示 -->
<el-table-column label="发货状态" width="120" align="center">
<template slot-scope="scope">
{{scope.row.orderStatus | formatDeliverStatus}}
</template>
</el-table-column>
<!-- 定义表格列展示 "备注" 信息设置文本对齐方式通过插槽作用域获取对应行的备注数据展示 -->
<el-table-column label="备注" align="center">
<template slot-scope="scope">
{{scope.row.note}}
</template>
</el-table-column>
</el-table>
<!-- 使用 el-card 组件包裹内容此处 el-card 结束标签在后面代码中未完整展示但推测是用于布局和样式统一等作用 -->
<el-card>
<!-- el-dialog 组件用于创建一个对话框用于修改收货人信息设置对话框标题绑定可见性以及宽度等属性 -->
<el-dialog title="修改收货人信息" <el-dialog title="修改收货人信息"
:visible.sync="receiverDialogVisible" :visible.sync="receiverDialogVisible"
width="40%"> width="40%">
<!-- el-form 组件用于创建表单绑定数据模型为 receiverInfo设置表单引用以及标签宽度等属性 -->
<el-form :model="receiverInfo" <el-form :model="receiverInfo"
ref="receiverInfoForm" ref="receiverInfoForm"
label-width="150px"> label-width="150px">
<!-- el-form-item 组件用于定义表单中的一项此处展示 "收货人姓名" 输入框 -->
<el-form-item label="收货人姓名:"> <el-form-item label="收货人姓名:">
<el-input v-model="receiverInfo.receiverName" style="width: 200px"></el-input> <el-input v-model="receiverInfo.receiverName" style="width: 200px"></el-input>
</el-form-item> </el-form-item>
<!-- 类似上述展示 "手机号码" 输入框 -->
<el-form-item label="手机号码:"> <el-form-item label="手机号码:">
<el-input v-model="receiverInfo.receiverPhone" style="width: 200px"> <el-input v-model="receiverInfo.receiverPhone" style="width: 200px">
</el-input> </el-input>
</el-form-item> </el-form-item>
<!-- 展示 "邮政编码" 输入框 -->
<el-form-item label="邮政编码:"> <el-form-item label="邮政编码:">
<el-input v-model="receiverInfo.receiverPostCode" style="width: 200px"> <el-input v-model="receiverInfo.receiverPostCode" style="width: 200px">
</el-input> </el-input>
</el-form-item> </el-form-item>
<!-- 使用 v-distpicker 组件可能是用于地区选择的第三方组件绑定省份城市地区数据并监听 selected 事件 -->
<el-form-item label="所在区域:"> <el-form-item label="所在区域:">
<v-distpicker :province="receiverInfo.receiverProvince" <v-distpicker :province="receiverInfo.receiverProvince"
:city="receiverInfo.receiverCity" :city="receiverInfo.receiverCity"
:area="receiverInfo.receiverRegion" :area="receiverInfo.receiverRegion"
@selected="onSelectRegion"></v-distpicker> @selected="onSelectRegion"></v-distpicker>
</el-form-item> </el-form-item>
<!-- 展示 "详细地址" 输入框设置为文本域类型指定行数 -->
<el-form-item label="详细地址:"> <el-form-item label="详细地址:">
<el-input v-model="receiverInfo.receiverDetailAddress" type="textarea" rows="3"> <el-input v-model="receiverInfo.receiverDetailAddress" type="textarea" rows="3">
</el-input> </el-input>
</el-form-item> </el-form-item>
</el-form> </el-form>
<!-- 在对话框的 footer 插槽中定义两个按钮一个用于取消点击隐藏对话框一个用于确定点击调用 handleUpdateReceiverInfo 方法 -->
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button @click="receiverDialogVisible = false"> </el-button> <el-button @click="receiverDialogVisible = false"> </el-button>
<el-button type="primary" @click="handleUpdateReceiverInfo"> </el-button> <el-button type="primary" @click="handleUpdateReceiverInfo"> </el-button>
</span> </span>
</el-dialog> </el-dialog>
<!-- 另一个 el-dialog 组件用于修改费用信息同样设置标题可见性绑定和宽度等属性 -->
<el-dialog title="修改费用信息" <el-dialog title="修改费用信息"
:visible.sync="moneyDialogVisible" :visible.sync="moneyDialogVisible"
width="40%"> width="40%">
<!-- 内部使用类名为 "table-layout" div 进行布局通过多个 el-row el-col 组合展示费用相关信息表格形式 -->
<div class="table-layout"> <div class="table-layout">
<el-row> <el-row>
<el-col :span="6" class="table-cell-title">商品合计</el-col> <el-col :span="6" class="table-cell-title">商品合计</el-col>
@ -500,13 +288,11 @@
</el-col> </el-col>
</el-row> </el-row>
</div> </div>
<!-- 在对话框的 footer 插槽中同样定义取消和确定按钮确定按钮点击调用 handleUpdateMoneyInfo 方法 -->
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button @click="moneyDialogVisible = false"> </el-button> <el-button @click="moneyDialogVisible = false"> </el-button>
<el-button type="primary" @click="handleUpdateMoneyInfo"> </el-button> <el-button type="primary" @click="handleUpdateMoneyInfo"> </el-button>
</span> </span>
</el-dialog> </el-dialog>
<!-- el-dialog 组件用于发送站内信设置相关属性 -->
<el-dialog title="发送站内信" <el-dialog title="发送站内信"
:visible.sync="messageDialogVisible" :visible.sync="messageDialogVisible"
width="40%"> width="40%">
@ -526,7 +312,6 @@
<el-button type="primary" @click="handleSendMessage"> </el-button> <el-button type="primary" @click="handleSendMessage"> </el-button>
</span> </span>
</el-dialog> </el-dialog>
<!-- el-dialog 组件用于关闭订单设置相关属性 -->
<el-dialog title="关闭订单" <el-dialog title="关闭订单"
:visible.sync="closeDialogVisible" :visible.sync="closeDialogVisible"
width="40%"> width="40%">
@ -542,7 +327,6 @@
<el-button type="primary" @click="handleCloseOrder"> </el-button> <el-button type="primary" @click="handleCloseOrder"> </el-button>
</span> </span>
</el-dialog> </el-dialog>
<!-- el-dialog 组件用于备注订单设置相关属性 -->
<el-dialog title="备注订单" <el-dialog title="备注订单"
:visible.sync="markOrderDialogVisible" :visible.sync="markOrderDialogVisible"
width="40%"> width="40%">
@ -558,19 +342,177 @@
<el-button type="primary" @click="handleMarkOrder"> </el-button> <el-button type="primary" @click="handleMarkOrder"> </el-button>
</span> </span>
</el-dialog> </el-dialog>
<!-- 使用 logistics-dialog 组件自定义组件双向绑定 visible 属性推测用于控制显示隐藏 -->
<logistics-dialog v-model="logisticsDialogVisible"></logistics-dialog> <logistics-dialog v-model="logisticsDialogVisible"></logistics-dialog>
</el-card>
</div> </div>
</template> </template>
<script> <script>
{ import {getOrderDetail,updateReceiverInfo,updateMoneyInfo,closeOrder,updateOrderNote,deleteOrder} from '@/api/order';
// Vue import LogisticsDialog from '@/views/oms/order/components/logisticsDialog';
import {formatDate} from '@/utils/date';
import VDistpicker from 'v-distpicker';
const defaultReceiverInfo = {
orderId:null,
receiverName:null,
receiverPhone:null,
receiverPostCode:null,
receiverDetailAddress:null,
receiverProvince:null,
receiverCity:null,
receiverRegion:null,
status:null
};
export default {
name: 'orderDetail',
components: { VDistpicker, LogisticsDialog},
data() {
return {
id: null,
order: {},
receiverDialogVisible:false,
receiverInfo:Object.assign({},defaultReceiverInfo),
moneyDialogVisible:false,
moneyInfo:{orderId:null, freightAmount:0, discountAmount:0,status:null},
messageDialogVisible:false,
message: {title:null, content:null},
closeDialogVisible:false,
closeInfo:{note:null,id:null},
markOrderDialogVisible:false,
markInfo:{note:null},
logisticsDialogVisible:false
}
},
created() {
this.id = this.list = this.$route.query.id;
getOrderDetail(this.id).then(response => {
this.order = response.data;
});
},
filters: {
formatNull(value) {
if(value===undefined||value===null||value===''){
return '暂无';
}else{
return value;
}
},
formatLongText(value) {
if(value===undefined||value===null||value===''){
return '暂无';
}else if(value.length>8){
return value.substr(0, 8) + '...';
}else{
return value;
}
},
formatPayType(value) {
if (value === 1) {
return '支付宝';
} else if (value === 2) {
return '微信';
} else {
return '未支付';
}
},
formatSourceType(value) {
if (value === 1) {
return 'APP订单';
} else {
return 'PC订单';
}
},
formatOrderType(value) {
if (value === 1) {
return '秒杀订单';
} else {
return '正常订单';
}
},
formatAddress(order) {
let str = order.receiverProvince;
if (order.receiverCity != null) {
str += " " + order.receiverCity;
}
str += " " + order.receiverRegion;
str += " " + order.receiverDetailAddress;
return str;
},
formatStatus(value) {
if (value === 1) {
return '待发货';
} else if (value === 2) {
return '已发货';
} else if (value === 3) {
return '已完成';
} else if (value === 4) {
return '已关闭';
} else if (value === 5) {
return '无效订单';
} else {
return '待付款';
}
},
formatPayStatus(value) {
if (value === 0) {
return '未支付';
} else if(value===4){
return '已退款';
}else{
return '已支付';
}
},
formatDeliverStatus(value) {
if (value === 0||value === 1) {
return '未发货';
} else {
return '已发货';
}
},
formatProductAttr(value){
if(value==null){
return '';
}else{
let attr = JSON.parse(value);
let result='';
for(let i=0;i<attr.length;i++){
result+=attr[i].key;
result+=":";
result+=attr[i].value;
result+=";";
}
return result;
}
}
},
methods: {
onSelectRegion(data){
this.receiverInfo.receiverProvince=data.province.value;
this.receiverInfo.receiverCity=data.city.value;
this.receiverInfo.receiverRegion=data.area.value;
},
formatTime(time) {
if (time == null || time === '') {
return '';
}
let date = new Date(time);
return formatDate(date, 'yyyy-MM-dd hh:mm:ss')
},
formatStepStatus(value) {
if (value === 1) {
//
return 2;
} else if (value === 2) {
//
return 3;
} else if (value === 3) {
//
return 4;
}else {
//
return 1;
}
},
showUpdateReceiverDialog(){ showUpdateReceiverDialog(){
// receiverDialogVisible true
this.receiverDialogVisible=true; this.receiverDialogVisible=true;
// receiverInfo this.order
this.receiverInfo={ this.receiverInfo={
orderId:this.order.id, orderId:this.order.id,
receiverName:this.order.receiverName, receiverName:this.order.receiverName,
@ -584,24 +526,17 @@
} }
}, },
handleUpdateReceiverInfo(){ handleUpdateReceiverInfo(){
//
this.$confirm('是否要修改收货信息?', '提示', { this.$confirm('是否要修改收货信息?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
// updateReceiverInfo receiverInfo
// then
updateReceiverInfo(this.receiverInfo).then(response=>{ updateReceiverInfo(this.receiverInfo).then(response=>{
// receiverDialogVisible false
this.receiverDialogVisible=false; this.receiverDialogVisible=false;
//
this.$message({ this.$message({
type: 'success', type: 'success',
message: '修改成功!' message: '修改成功!'
}); });
// getOrderDetail id
// this.order
getOrderDetail(this.id).then(response => { getOrderDetail(this.id).then(response => {
this.order = response.data; this.order = response.data;
}); });
@ -609,35 +544,24 @@
}); });
}, },
showUpdateMoneyDialog(){ showUpdateMoneyDialog(){
// moneyDialogVisible true
this.moneyDialogVisible=true; this.moneyDialogVisible=true;
// moneyInfo orderId id
this.moneyInfo.orderId=this.order.id; this.moneyInfo.orderId=this.order.id;
// moneyInfo freightAmount
this.moneyInfo.freightAmount=this.order.freightAmount; this.moneyInfo.freightAmount=this.order.freightAmount;
// moneyInfo discountAmount
this.moneyInfo.discountAmount=this.order.discountAmount; this.moneyInfo.discountAmount=this.order.discountAmount;
// moneyInfo status
this.moneyInfo.status=this.order.status; this.moneyInfo.status=this.order.status;
}, },
handleUpdateMoneyInfo(){ handleUpdateMoneyInfo(){
//
this.$confirm('是否要修改费用信息?', '提示', { this.$confirm('是否要修改费用信息?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
// updateMoneyInfo moneyInfo
// then
updateMoneyInfo(this.moneyInfo).then(response=>{ updateMoneyInfo(this.moneyInfo).then(response=>{
// moneyDialogVisible false
this.moneyDialogVisible=false; this.moneyDialogVisible=false;
//
this.$message({ this.$message({
type: 'success', type: 'success',
message: '修改成功!' message: '修改成功!'
}); });
// getOrderDetail this.order
getOrderDetail(this.id).then(response => { getOrderDetail(this.id).then(response => {
this.order = response.data; this.order = response.data;
}); });
@ -645,23 +569,17 @@
}); });
}, },
showMessageDialog(){ showMessageDialog(){
// messageDialogVisible true
this.messageDialogVisible=true; this.messageDialogVisible=true;
// message title null
this.message.title=null; this.message.title=null;
// message content null
this.message.content=null; this.message.content=null;
}, },
handleSendMessage(){ handleSendMessage(){
//
this.$confirm('是否要发送站内信?', '提示', { this.$confirm('是否要发送站内信?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
// messageDialogVisible false
this.messageDialogVisible=false; this.messageDialogVisible=false;
//
this.$message({ this.$message({
type: 'success', type: 'success',
message: '发送成功!' message: '发送成功!'
@ -669,37 +587,25 @@
}); });
}, },
showCloseOrderDialog(){ showCloseOrderDialog(){
// closeDialogVisible true
this.closeDialogVisible=true; this.closeDialogVisible=true;
// closeInfo note null
this.closeInfo.note=null; this.closeInfo.note=null;
// closeInfo id id id
this.closeInfo.id=this.id; this.closeInfo.id=this.id;
}, },
handleCloseOrder(){ handleCloseOrder(){
//
this.$confirm('是否要关闭?', '提示', { this.$confirm('是否要关闭?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
// URLSearchParams
let params = new URLSearchParams(); let params = new URLSearchParams();
// params "ids" id
params.append("ids",[this.closeInfo.id]); params.append("ids",[this.closeInfo.id]);
// params "note" closeInfo note
params.append("note",this.closeInfo.note); params.append("note",this.closeInfo.note);
// closeOrder
// then
closeOrder(params).then(response=>{ closeOrder(params).then(response=>{
// closeDialogVisible false
this.closeDialogVisible=false; this.closeDialogVisible=false;
//
this.$message({ this.$message({
type: 'success', type: 'success',
message: '订单关闭成功!' message: '订单关闭成功!'
}); });
// getOrderDetail this.order
getOrderDetail(this.id).then(response => { getOrderDetail(this.id).then(response => {
this.order = response.data; this.order = response.data;
}); });
@ -707,39 +613,26 @@
}); });
}, },
showMarkOrderDialog(){ showMarkOrderDialog(){
// markOrderDialogVisible true
this.markOrderDialogVisible=true; this.markOrderDialogVisible=true;
// markInfo id id
this.markInfo.id=this.id; this.markInfo.id=this.id;
// closeOrder markInfo note null
this.closeOrder.note=null; this.closeOrder.note=null;
}, },
handleMarkOrder(){ handleMarkOrder(){
//
this.$confirm('是否要备注订单?', '提示', { this.$confirm('是否要备注订单?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
// URLSearchParams
let params = new URLSearchParams(); let params = new URLSearchParams();
// params "id" markInfo id id
params.append("id",this.markInfo.id); params.append("id",this.markInfo.id);
// params "note" markInfo note
params.append("note",this.markInfo.note); params.append("note",this.markInfo.note);
// params "status"
params.append("status",this.order.status); params.append("status",this.order.status);
// updateOrderNote
// then
updateOrderNote(params).then(response=>{ updateOrderNote(params).then(response=>{
// markOrderDialogVisible false
this.markOrderDialogVisible=false; this.markOrderDialogVisible=false;
//
this.$message({ this.$message({
type: 'success', type: 'success',
message: '订单备注成功!' message: '订单备注成功!'
}); });
// getOrderDetail this.order
getOrderDetail(this.id).then(response => { getOrderDetail(this.id).then(response => {
this.order = response.data; this.order = response.data;
}); });
@ -747,114 +640,75 @@
}); });
}, },
handleDeleteOrder(){ handleDeleteOrder(){
//
this.$confirm('是否要进行该删除操作?', '提示', { this.$confirm('是否要进行该删除操作?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
// URLSearchParams
let params = new URLSearchParams(); let params = new URLSearchParams();
// params "ids" id id
params.append("ids",[this.id]); params.append("ids",[this.id]);
// deleteOrder
// then
deleteOrder(params).then(response=>{ deleteOrder(params).then(response=>{
// 1000 1
this.$message({ this.$message({
message: '删除成功!', message: '删除成功!',
type: 'success', type: 'success',
duration: 1000 duration: 1000
}); });
// 使this.$router
this.$router.back(); this.$router.back();
}); });
}) })
}, },
showLogisticsDialog(){ showLogisticsDialog(){
// logisticsDialogVisible true
this.logisticsDialogVisible=true; this.logisticsDialogVisible=true;
} }
} }
}
</script> </script>
<style scoped> <style scoped>
/* 定义类名为 detail-container 的样式规则,用于设置某个容器的样式 */
.detail-container { .detail-container {
/* 设置宽度为页面宽度的 80% */
width: 80%; width: 80%;
/* 设置内边距,上下左右均为 20 像素 */
padding: 20px 20px 20px 20px; padding: 20px 20px 20px 20px;
/* 设置外边距,上下为 20 像素,左右自动居中 */
margin: 20px auto; margin: 20px auto;
} }
/* 定义类名为 operate-container 的样式规则,用于设置操作相关容器的样式 */
.operate-container { .operate-container {
/* 设置背景颜色 */
background: #F2F6FC; background: #F2F6FC;
/* 设置高度为 80 像素 */
height: 80px; height: 80px;
/* 设置外边距,上外边距为 -20 像素,左右外边距为 -20 像素,下外边距为 0 像素 */
margin: -20px -20px 0; margin: -20px -20px 0;
/* 设置行高为 80 像素,用于垂直居中内容 */
line-height: 80px; line-height: 80px;
} }
/* 定义类名为 operate-button-container 的样式规则,用于设置操作按钮容器的样式 */
.operate-button-container { .operate-button-container {
/* 让容器向右浮动 */
float: right; float: right;
/* 设置右外边距为 20 像素 */
margin-right: 20px margin-right: 20px
} }
/* 定义类名为 table-layout 的样式规则,可能用于设置表格布局相关的样式 */
.table-layout { .table-layout {
/* 设置上外边距为 20 像素 */
margin-top: 20px; margin-top: 20px;
/* 设置左边框样式,为 1 像素宽的实线,颜色为 #DCDFE6 */
border-left: 1px solid #DCDFE6; border-left: 1px solid #DCDFE6;
/* 设置上边框样式,为 1 像素宽的实线,颜色为 #DCDFE6 */
border-top: 1px solid #DCDFE6; border-top: 1px solid #DCDFE6;
} }
/* 定义类名为 table-cell 的样式规则,可能用于设置表格单元格的样式 */
.table-cell { .table-cell {
/* 设置高度为 60 像素 */
height: 60px; height: 60px;
/* 设置行高为 40 像素,用于控制单元格内文本的垂直对齐等 */
line-height: 40px; line-height: 40px;
/* 设置右边框样式,为 1 像素宽的实线,颜色为 #DCDFE6 */
border-right: 1px solid #DCDFE6; border-right: 1px solid #DCDFE6;
/* 设置下边框样式,为 1 像素宽的实线,颜色为 #DCDFE6 */
border-bottom: 1px solid #DCDFE6; border-bottom: 1px solid #DCDFE6;
/* 设置内边距为 10 像素 */
padding: 10px; padding: 10px;
/* 设置字体大小为 14 像素 */
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 {
/* 设置右边框样式,为 1 像素宽的实线,颜色为 #DCDFE6 */
border-right: 1px solid #DCDFE6; border-right: 1px solid #DCDFE6;
/* 设置下边框样式,为 1 像素宽的实线,颜色为 #DCDFE6 */
border-bottom: 1px solid #DCDFE6; border-bottom: 1px solid #DCDFE6;
/* 设置内边距为 10 像素 */
padding: 10px; padding: 10px;
/* 设置背景颜色 */
background: #F2F6FC; background: #F2F6FC;
/* 设置文本水平居中 */
text-align: center; text-align: center;
/* 设置字体大小为 14 像素 */
font-size: 14px; font-size: 14px;
/* 设置字体颜色 */
color: #303133; color: #303133;
} }
</style> </style>

@ -1,50 +1,39 @@
<template> <template> 
<!-- 使用 el-card 组件创建一个卡片式的容器设置类名为 "form-container"并通过 shadow="never" 属性取消卡片的阴影效果 -->
<el-card class="form-container" shadow="never"> <el-card class="form-container" shadow="never">
<!-- el-form 组件用于创建表单它绑定了名为 "orderSetting" 的数据模型设置了表单的引用名称为 "orderSettingForm"同时指定了表单验证规则 "rules"以及标签的宽度为 150px -->
<el-form :model="orderSetting" <el-form :model="orderSetting"
ref="orderSettingForm" ref="orderSettingForm"
:rules="rules" :rules="rules"
label-width="150px"> label-width="150px">
<!-- el-form-item 组件用于定义表单中的每一个表单项此处是针对 "秒杀订单超过" 这一设置项的表单项通过 prop 属性指定了验证对应的字段名 -->
<el-form-item label="秒杀订单超过:" prop="flashOrderOvertime"> <el-form-item label="秒杀订单超过:" prop="flashOrderOvertime">
<!-- el-input 组件创建一个输入框通过 v-model 指令双向绑定了 "orderSetting.flashOrderOvertime" 数据意味着用户在输入框中输入的值会实时更新到对应的数据属性中同时设置了类名 "input-width" 用于控制输入框宽度 -->
<el-input v-model="orderSetting.flashOrderOvertime" class="input-width"> <el-input v-model="orderSetting.flashOrderOvertime" class="input-width">
<!-- 使用 slot="append" 插槽在输入框后面添加一个单位文本 "分"用于提示用户输入的时间单位 -->
<template slot="append"></template> <template slot="append"></template>
</el-input> </el-input>
<!-- 一个普通的 <span> 标签用于显示一段提示文本设置了类名 "note-margin" 来控制其左边距提示内容为未付款时订单自动关闭的相关说明 -->
<span class="note-margin">未付款订单自动关闭</span> <span class="note-margin">未付款订单自动关闭</span>
</el-form-item> </el-form-item>
<!-- 与上面类似的表单项针对 "正常订单超过" 的设置同样有输入框及对应的提示信息 -->
<el-form-item label="正常订单超过:" prop="normalOrderOvertime"> <el-form-item label="正常订单超过:" prop="normalOrderOvertime">
<el-input v-model="orderSetting.normalOrderOvertime" 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="confirmOvertime"> <el-form-item label="发货超过:" prop="confirmOvertime">
<el-input v-model="orderSetting.confirmOvertime" class="input-width"> <el-input v-model="orderSetting.confirmOvertime" 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-form-item label="订单完成超过:" prop="finishOvertime">
<el-input v-model="orderSetting.finishOvertime" class="input-width"> <el-input v-model="orderSetting.finishOvertime" 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="commentOvertime"> <el-form-item label="订单完成超过:" prop="commentOvertime">
<el-input v-model="orderSetting.commentOvertime" class="input-width"> <el-input v-model="orderSetting.commentOvertime" 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-button 按钮通过 @click 指令绑定了 "confirm('orderSettingForm')" 方法即点击按钮时会调用名为 "confirm" 的方法并传入 "orderSettingForm" 参数按钮类型设置为 "primary"文本显示为 "提交" -->
<el-form-item> <el-form-item>
<el-button <el-button
@click="confirm('orderSettingForm')" @click="confirm('orderSettingForm')"
@ -53,12 +42,8 @@
</el-form> </el-form>
</el-card> </el-card>
</template> </template>
<script> <script>
// '@/api/orderSetting' "getOrderSetting" "updateOrderSetting"
import {getOrderSetting,updateOrderSetting} from '@/api/orderSetting'; import {getOrderSetting,updateOrderSetting} from '@/api/orderSetting';
// "defaultOrderSetting" 0 null
const defaultOrderSetting = { const defaultOrderSetting = {
id: null, id: null,
flashOrderOvertime: 0, flashOrderOvertime: 0,
@ -67,33 +52,22 @@
finishOvertime: 0, finishOvertime: 0,
commentOvertime: 0 commentOvertime: 0
}; };
// "checkTime" 使
const checkTime = (rule, value, callback) => { const checkTime = (rule, value, callback) => {
// callback Error
if (!value) { if (!value) {
return callback(new Error('时间不能为空')); return callback(new Error('时间不能为空'));
} }
console.log("checkTime",value); console.log("checkTime",value);
// parseInt
let intValue = parseInt(value); let intValue = parseInt(value);
// callback Error
if (!Number.isInteger(intValue)) { if (!Number.isInteger(intValue)) {
return callback(new Error('请输入数字值')); return callback(new Error('请输入数字值'));
} }
// callback
callback(); callback();
}; };
// Vue
export default { export default {
// Vue "orderSetting"
name: 'orderSetting', name: 'orderSetting',
data() { data() {
return { return {
// "orderSetting" Object.assign "defaultOrderSetting"
orderSetting: Object.assign({}, defaultOrderSetting), orderSetting: Object.assign({}, defaultOrderSetting),
// 使 "checkTime" 'blur'
rules: { rules: {
flashOrderOvertime:{validator: checkTime, trigger: 'blur' }, flashOrderOvertime:{validator: checkTime, trigger: 'blur' },
normalOrderOvertime:{validator: checkTime, trigger: 'blur' }, normalOrderOvertime:{validator: checkTime, trigger: 'blur' },
@ -104,24 +78,17 @@
} }
}, },
created(){ created(){
// "getDetail"
this.getDetail(); this.getDetail();
}, },
methods:{ methods:{
// "confirm" "formName"
confirm(formName){ confirm(formName){
// this.$refs[formName] validate "valid"
this.$refs[formName].validate((valid) => { this.$refs[formName].validate((valid) => {
// "valid" true
if (valid) { if (valid) {
// 使 $confirm "warning"
this.$confirm('是否要提交修改?', '提示', { this.$confirm('是否要提交修改?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
// "" "updateOrderSetting" 1 "orderSetting"
// then 使 $message "!" 1000 1
updateOrderSetting(1,this.orderSetting).then(response=>{ updateOrderSetting(1,this.orderSetting).then(response=>{
this.$message({ this.$message({
type: 'success', type: 'success',
@ -131,7 +98,6 @@
}) })
}); });
} else { } else {
// "valid" false使 $message ""
this.$message({ this.$message({
message: '提交参数不合法', message: '提交参数不合法',
type: 'warning' type: 'warning'
@ -140,9 +106,7 @@
} }
}); });
}, },
// "getDetail"
getDetail(){ getDetail(){
// "getOrderSetting" 1 then "orderSetting" 便
getOrderSetting(1).then(response=>{ getOrderSetting(1).then(response=>{
this.orderSetting=response.data; this.orderSetting=response.data;
}) })
@ -150,14 +114,14 @@
} }
} }
</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: { components: { BrandDetail }
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={
bigPic: '',
brandStory: '',
factoryStatus: 0,
firstLetter: '',
logo: '',
name: '',
showStatus: 0,
sort: 0
};
export default { export default {
name: "BrandDetail", // name: 'BrandDetail',
components: { components:{SingleUpload},
SingleUpload, //
},
props: { props: {
//
isEdit: { isEdit: {
type: Boolean, type: Boolean,
default: false, default: false
}, }
}, },
data() { data() {
//
const defaultBrand = {
bigPic: "", //
brandStory: "", //
factoryStatus: 0, //
firstLetter: "", //
logo: "", // LOGO
name: "", //
showStatus: 0, //
sort: 0, //
};
return { return {
brand: Object.assign({}, defaultBrand), // brand:Object.assign({}, defaultBrand),
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'}
], ],
logo: [{ required: true, message: "请输入品牌logo", trigger: "blur" }], logo: [
sort: [{ type: "number", message: "排序必须为数字" }], {required: true, message: '请输入品牌logo', trigger: 'blur'}
}, ],
}; sort: [
{type: 'number', message: '排序必须为数字'}
],
}
}
}, },
created() { created() {
//
if (this.isEdit) { if (this.isEdit) {
getBrand(this.$route.query.id).then((response) => { getBrand(this.$route.query.id).then(response => {
this.brand = response.data; // this.brand = response.data;
}); });
}else{ }else{
this.brand = Object.assign({}, this.defaultBrand); // this.brand = Object.assign({},defaultBrand);
} }
}, },
methods: { methods: {
//
onSubmit(formName) { onSubmit(formName) {
this.$refs[formName].validate((valid) => { this.$refs[formName].validate((valid) => {
if (valid) { if (valid) {
this.$confirm("是否提交数据", "提示", { this.$confirm('是否提交数据', '提示', {
confirmButtonText: "确定", confirmButtonText: '确定',
cancelButtonText: "取消", cancelButtonText: '取消',
type: "warning", type: 'warning'
}).then(() => { }).then(() => {
if (this.isEdit) { if (this.isEdit) {
// updateBrand(this.$route.query.id, this.brand).then(response => {
updateBrand(this.$route.query.id, this.brand).then(() => {
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 { } else {
// createBrand(this.brand).then(response => {
createBrand(this.brand).then(() => {
this.$refs[formName].resetFields(); this.$refs[formName].resetFields();
this.brand = Object.assign({}, this.defaultBrand); this.brand = Object.assign({},defaultBrand);
this.$message({ this.$message({
message: "提交成功", message: '提交成功',
type: "success", type: 'success',
duration: 1000, duration:1000
}); });
}); });
} }
}); });
} 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.brand = Object.assign({}, this.defaultBrand); this.brand = Object.assign({},defaultBrand);
}, }
}, }
}; }
</script> </script>
<style>
</style>

@ -1,10 +1,7 @@
<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
@ -15,25 +12,17 @@
查询结果 查询结果
</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 <el-input style="width: 203px" v-model="listQuery.keyword" placeholder="品牌名称/关键字"></el-input>
style="width: 203px"
v-model="listQuery.keyword"
placeholder="品牌名称/关键字">
</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>
<!-- 添加品牌按钮 -->
<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,14 +114,13 @@
</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
@ -158,69 +135,116 @@
</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"
},
{
label: "隐藏品牌",
value: "hideBrand"
}
], ],
operateType: null, // operateType: null,
listQuery: { listQuery: {
keyword: null, keyword: null,
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10
}, },
list: null, // list: null,
total: null, // total: null,
listLoading: true, // listLoading: true,
multipleSelection: [], // multipleSelection: []
}; }
}, },
created() { created() {
this.getList(); // this.getList();
}, },
methods: { methods: {
//
getList() { getList() {
this.listLoading = true; this.listLoading = true;
fetchList(this.listQuery).then((response) => { fetchList(this.listQuery).then(response => {
this.listLoading = false;
this.list = response.data.list; this.list = response.data.list;
this.total = response.data.total; this.total = response.data.total;
this.listLoading = false; this.totalPage = response.data.totalPage;
this.pageSize = response.data.pageSize;
}); });
}, },
// handleSelectionChange(val) {
searchBrandList() { this.multipleSelection = val;
this.listQuery.pageNum = 1;
this.getList();
},
//
handleBatchOperate() {
console.log(this.multipleSelection);
},
//
addBrand() {
this.$router.push({ path: "/pms/addBrand" });
}, },
//
handleUpdate(index, row) { handleUpdate(index, row) {
this.$router.push({ path: "/pms/updateBrand", query: { id: row.id } }); this.$router.push({path: '/pms/updateBrand', query: {id: row.id}})
}, },
//
handleDelete(index, row) { handleDelete(index, row) {
deleteBrand(row.id).then(() => { this.$confirm('是否要删除该品牌', '提示', {
this.$message({ message: "删除成功", type: "success" }); confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
deleteBrand(row.id).then(response => {
this.$message({
message: '删除成功',
type: 'success',
duration: 1000
});
this.getList(); 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) { handleSizeChange(val) {
this.listQuery.pageNum = 1;
this.listQuery.pageSize = val; this.listQuery.pageSize = val;
this.getList(); this.getList();
}, },
@ -228,10 +252,58 @@ export default {
this.listQuery.pageNum = val; this.listQuery.pageNum = val;
this.getList(); this.getList();
}, },
searchBrandList() {
this.listQuery.pageNum = 1;
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: { components: { BrandDetail }
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: { components: { ProductDetail }
ProductDetail, // ProductDetail }
},
};
</script> </script>
<style> <style>
/* 样式部分:暂无样式定义,根据需求可添加 */
</style> </style>

@ -1,13 +1,8 @@
<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
@ -18,43 +13,31 @@
</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}}
<!-- handAddStatus=0 显示多选框 -->
<el-checkbox-group v-if="productAttr.handAddStatus===0" v-model="selectProductAttr[idx].values"> <el-checkbox-group v-if="productAttr.handAddStatus===0" v-model="selectProductAttr[idx].values">
<el-checkbox <el-checkbox v-for="item in getInputListArr(productAttr.inputList)" :label="item" :key="item"
v-for="item in getInputListArr(productAttr.inputList)"
:label="item"
:key="item"
class="littleMarginLeft"></el-checkbox> 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"
@ -64,52 +47,102 @@
{{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,66 +162,456 @@
</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,
default: false
}
}, },
data() { data() {
return { return {
productAttributeCategoryOptions: [], // //
selectProductAttr: [], // hasEditCreated:false,
addProductAttrValue: '', // //
activeHtmlName: 'pc' // productAttributeCategoryOptions: [],
}; //
selectProductAttr: [],
//
selectProductParam: [],
//
selectProductAttrPics: [],
//
addProductAttrValue: '',
//
activeHtmlName: 'pc'
}
},
computed: {
//
hasAttrPic() {
if (this.selectProductAttrPics.length < 1) {
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 += ',';
}
}
}
}
}
}
}, },
created() { created() {
this.getProductAttrCateList(); // this.getProductAttrCateList();
},
watch: {
productId:function (newValue) {
if(!this.isEdit)return;
if(this.hasEditCreated)return;
if(newValue===undefined||newValue==null||newValue===0)return;
this.handleEditCreated();
}
}, },
methods: { methods: {
// handleEditCreated() {
//id
if(this.value.productAttributeCategoryId!=null){
this.handleProductAttrChange(this.value.productAttributeCategoryId);
}
this.hasEditCreated=true;
},
getProductAttrCateList() { getProductAttrCateList() {
fetchProductAttrCateList({ pageNum: 1, pageSize: 100 }).then(response => { let param = {pageNum: 1, pageSize: 100};
this.productAttributeCategoryOptions = response.data.list.map(item => ({ fetchProductAttrCateList(param).then(response => {
label: item.name, this.productAttributeCategoryOptions = [];
value: item.id 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) { handleProductAttrChange(value) {
this.getProductAttrList(0, value); // this.getProductAttrList(0, value);
this.getProductAttrList(1, value); // this.getProductAttrList(1, value);
},
getInputListArr(inputList) {
return inputList.split(',');
}, },
//
handleAddProductAttrValue(idx) { handleAddProductAttrValue(idx) {
if (this.addProductAttrValue) { 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.selectProductAttr[idx].options.push(this.addProductAttrValue);
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;
} }
}, },
// SKU handleRefreshProductSkuList() {
handleRemoveProductSku(index) { this.$confirm('刷新列表将导致sku信息重新生成是否要刷新', '提示', {
this.value.skuStockList.splice(index, 1); 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() { handlePrev() {
this.$emit('prevStep'); this.$emit('prevStep')
}, },
//
handleNext() { handleNext() {
this.$emit('nextStep'); this.mergeProductAttrValue();
this.mergeProductAttrPics();
this.$emit('nextStep')
}
} }
} }
};
</script> </script>
<style scoped> <style scoped>
@ -198,7 +619,22 @@ export default {
margin-left: 10px; margin-left: 10px;
} }
.littleMarginTop {
margin-top: 10px;
}
.paramInput {
width: 250px;
}
.paramInputLabel {
display: inline-block;
width: 100px;
text-align: right;
padding-right: 10px
}
.cardBg { .cardBg {
background: #f8f9fc; 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, // ID brandId: null,
brandName: '', // brandName: '',
deleteStatus: 0, // deleteStatus: 0,
description: '', // description: '',
detailDesc: '', // detailDesc: '',
detailHtml: '', // detailHtml: '',
detailMobileHtml: '', // detailMobileHtml: '',
detailTitle: '', // detailTitle: '',
feightTemplateId: 0, // ID feightTemplateId: 0,
flashPromotionCount: 0, // flashPromotionCount: 0,
flashPromotionPrice: 0, // flashPromotionId: 0,
giftPoint: 0, // flashPromotionPrice: 0,
giftGrowth: 0, // flashPromotionSort: 0,
keywords: '', // giftPoint: 0,
lowStock: 0, // giftGrowth: 0,
name: '', // keywords: '',
newStatus: 0, // lowStock: 0,
originalPrice: 0, // name: '',
price: 0, // newStatus: 0,
skuStockList: [], // SKU note: '',
productAttributeValueList: [], // originalPrice: 0,
promotionStartTime: '', // pic: '',
promotionEndTime: '', // //{memberLevelId: 0,memberPrice: 0,memberLevelName: null}
publishStatus: 0, // memberPriceList: [],
sale: 0, // //
stock: 0, // productFullReductionList: [{fullPrice: 0, reducePrice: 0}],
//
productLadderList: [{count: 0,discount: 0,price: 0}],
previewStatus: 0,
price: 0,
productAttributeCategoryId: null,
//{productAttributeId: 0, value: ''}
productAttributeValueList: [],
//sku{lowStock: 0, pic: '', price: 0, sale: 0, skuCode: '', spData: '', stock: 0}
skuStockList: [],
//{subjectId: 0}
subjectProductRelationList: [],
//{prefrenceAreaId: 0}
prefrenceAreaProductRelationList: [],
productCategoryId: null,
productCategoryName: '',
productSn: '',
promotionEndTime: '',
promotionPerLimit: 0,
promotionPrice: null,
promotionStartTime: '',
promotionType: 0,
publishStatus: 0,
recommandStatus: 0,
sale: 0,
serviceIds: '',
sort: 0,
stock: 0,
subTitle: '',
unit: '',
usePointLimit: 0,
verifyStatus: 0,
weight: 0
}; };
export default { export default {
name: 'ProductDetail', // name: 'ProductDetail',
components: { components: {ProductInfoDetail, ProductSaleDetail, ProductAttrDetail, ProductRelationDetail},
ProductInfoDetail,
ProductSaleDetail,
ProductAttrDetail,
ProductRelationDetail,
},
props: { props: {
isEdit: { isEdit: {
type: Boolean, type: Boolean,
default: false, // default: false
}, }
}, },
data() { data() {
return { return {
active: 0, // active: 0,
productParam: Object.assign({}, defaultProductParam), // productParam: Object.assign({}, defaultProductParam),
showStatus: [true, false, false, false], // showStatus: [true, false, false, false]
}; }
}, },
created(){ created(){
//
if(this.isEdit){ if(this.isEdit){
getProduct(this.$route.query.id).then((response) => { getProduct(this.$route.query.id).then(response=>{
this.productParam = response.data; // this.productParam=response.data;
}); });
} }
}, },
methods: { methods: {
//
hideAll() { hideAll() {
for (let i = 0; i < this.showStatus.length; i++) { for (let i = 0; i < this.showStatus.length; i++) {
this.showStatus[i] = false; this.showStatus[i] = false;
} }
}, },
//
prevStep() { prevStep() {
if (this.active > 0) { if (this.active > 0 && this.active < this.showStatus.length) {
this.active--; // 退 this.active--;
this.hideAll(); // this.hideAll();
this.showStatus[this.active] = true; // this.showStatus[this.active] = true;
} }
}, },
//
nextStep() { nextStep() {
if (this.active < this.showStatus.length - 1) { if (this.active < this.showStatus.length - 1) {
this.active++; // this.active++;
this.hideAll(); // this.hideAll();
this.showStatus[this.active] = true; // this.showStatus[this.active] = true;
} }
}, },
//
finishCommit(isEdit) { finishCommit(isEdit) {
this.$confirm('是否要提交该产品', '提示', { this.$confirm('是否要提交该产品', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning', type: 'warning'
}).then(() => { }).then(() => {
if(isEdit){ if(isEdit){
// updateProduct(this.$route.query.id,this.productParam).then(response=>{
updateProduct(this.$route.query.id, this.productParam).then(() => {
this.$message({ this.$message({
type: 'success', type: 'success',
message: '修改成功', message: '提交成功',
duration: 1000, duration:1000
}); });
this.$router.back(); // this.$router.back();
}); });
}else{ }else{
// createProduct(this.productParam).then(response=>{
createProduct(this.productParam).then(() => {
this.$message({ this.$message({
type: 'success', type: 'success',
message: '提交成功', message: '提交成功',
duration: 1000, duration:1000
}); });
location.reload(); // location.reload();
}); });
} }
}); })
}, }
}, }
}; }
</script> </script>
<style> <style>
/* 容器样式 */
.form-container { .form-container {
width: 960px; width: 960px;
margin: 0 auto;
} }
.form-inner-container { .form-inner-container {
width: 800px; 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 { export default {
name: 'ProductInfoDetail', // name: "ProductInfoDetail",
props: { props: {
value: Object, // value: Object,
isEdit: { isEdit: {
type: Boolean, // type: Boolean,
default: false, default: false
}, }
}, },
data() { data() {
return { return {
hasEditCreated: false, // hasEditCreated:false,
selectProductCateValue: [], // //
productCateOptions: [], // selectProductCateValue: [],
brandOptions: [], // productCateOptions: [],
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'}], brandId: [{required: true, message: '请选择商品品牌', trigger: 'blur'}],
description: [{required: true, message: '请输入商品介绍', trigger: 'blur'}], description: [{required: true, message: '请输入商品介绍', trigger: 'blur'}],
}, requiredProp: [{required: true, message: '该项为必填项', trigger: 'blur'}]
}
}; };
}, },
created() { created() {
//
this.getProductCateList(); this.getProductCateList();
this.getBrandList(); this.getBrandList();
}, },
computed:{ computed:{
// ID //
productId(){ productId(){
return this.value.id; return this.value.id;
}, }
}, },
watch: { watch: {
productId(newValue) { productId:function(newValue){
if (!this.isEdit || this.hasEditCreated || !newValue) return; if(!this.isEdit)return;
if(this.hasEditCreated)return;
if(newValue===undefined||newValue==null||newValue===0)return;
this.handleEditCreated(); this.handleEditCreated();
}, },
selectProductCateValue(newValue) { selectProductCateValue: function (newValue) {
// ID if (newValue != null && newValue.length === 2) {
if (newValue && newValue.length === 2) {
this.value.productCategoryId = newValue[1]; this.value.productCategoryId = newValue[1];
this.value.productCategoryName= this.getCateNameById(this.value.productCategoryId); this.value.productCategoryName= this.getCateNameById(this.value.productCategoryId);
} else { } else {
this.value.productCategoryId = null; this.value.productCategoryId = null;
this.value.productCategoryName=null; this.value.productCategoryName=null;
} }
}, }
}, },
methods: { methods: {
// //
handleEditCreated(){ handleEditCreated(){
if(this.value.productCategoryId!=null){ if(this.value.productCategoryId!=null){
this.selectProductCateValue = [ this.selectProductCateValue.push(this.value.cateParentId);
this.value.cateParentId, this.selectProductCateValue.push(this.value.productCategoryId);
this.value.productCategoryId,
];
} }
this.hasEditCreated=true; this.hasEditCreated=true;
}, },
//
getProductCateList() { getProductCateList() {
fetchListWithChildren().then((response) => { fetchListWithChildren().then(response => {
let list = response.data; let list = response.data;
this.productCateOptions = list.map((item) => ({ this.productCateOptions = [];
label: item.name, for (let i = 0; i < list.length; i++) {
value: item.id, let children = [];
children: item.children?.map((child) => ({ if (list[i].children != null && list[i].children.length > 0) {
label: child.name, for (let j = 0; j < list[i].children.length; j++) {
value: child.id, 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() { getBrandList() {
fetchBrandList({ pageNum: 1, pageSize: 100 }).then((response) => { fetchBrandList({pageNum: 1, pageSize: 100}).then(response => {
this.brandOptions = response.data.list.map((item) => ({ this.brandOptions = [];
label: item.name, let brandList = response.data.list;
value: item.id, for (let i = 0; i < brandList.length; i++) {
})); this.brandOptions.push({label: brandList[i].name, value: brandList[i].id});
}
}); });
}, },
// ID
getCateNameById(id){ getCateNameById(id){
for (const parent of this.productCateOptions) { let name=null;
for (const child of parent.children || []) { for(let i=0;i<this.productCateOptions.length;i++){
if (child.value === id) { for(let j=0;j<this.productCateOptions[i].children.length;j++){
return child.label; if(this.productCateOptions[i].children[j].value===id){
name=this.productCateOptions[i].children[j].label;
return name;
} }
} }
} }
return null; return name;
}, },
//
handleNext(formName){ handleNext(formName){
this.$refs[formName].validate((valid) => { this.$refs[formName].validate((valid) => {
if (valid) { if (valid) {
this.$emit('nextStep'); // this.$emit('nextStep');
} else { } else {
this.$message({ this.$message({
message: '验证失败', message: '验证失败',
type: 'error', type: 'error',
duration: 1000, duration:1000
}); });
return false;
} }
}); });
}, },
//
handleBrandChange(val) { handleBrandChange(val) {
const selectedBrand = this.brandOptions.find( let brandName = '';
(item) => item.value === val for (let i = 0; i < this.brandOptions.length; i++) {
); if (this.brandOptions[i].value === val) {
this.value.brandName = selectedBrand ? selectedBrand.label : ''; brandName = this.brandOptions[i].label;
}, break;
}, }
}; }
this.value.brandName = brandName;
}
}
}
</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() { data() {
return { return {
subjectList: [], // //
subjectTitles: ['待选择', '已选择'], // Transfer subjectList: [],
prefrenceAreaList: [], // //
prefrenceAreaTitles: ['待选择', '已选择'], // Transfer subjectTitles: ['待选择', '已选择'],
//
prefrenceAreaList: [],
//
prefrenceAreaTitles: ['待选择', '已选择']
}; };
}, },
created() { created() {
this.getSubjectList(); // this.getSubjectList();
this.getPrefrenceAreaList(); // this.getPrefrenceAreaList();
}, },
computed:{ computed:{
/** //
* 选中的专题通过 v-model computed 绑定选中的专题数据
*/
selectSubject:{ selectSubject:{
get() { get:function () {
let subjects =[]; let subjects =[];
if ( if(this.value.subjectProductRelationList==null||this.value.subjectProductRelationList.length<=0){
this.value.subjectProductRelationList == null ||
this.value.subjectProductRelationList.length <= 0
) {
return subjects; return subjects;
} }
// ID
for(let i=0;i<this.value.subjectProductRelationList.length;i++){ for(let i=0;i<this.value.subjectProductRelationList.length;i++){
subjects.push(this.value.subjectProductRelationList[i].subjectId); subjects.push(this.value.subjectProductRelationList[i].subjectId);
} }
return subjects; return subjects;
}, },
set(newValue) { set:function (newValue) {
//
this.value.subjectProductRelationList=[]; this.value.subjectProductRelationList=[];
for(let i=0;i<newValue.length;i++){ for(let i=0;i<newValue.length;i++){
this.value.subjectProductRelationList.push({subjectId:newValue[i]}); this.value.subjectProductRelationList.push({subjectId:newValue[i]});
} }
}
}, },
}, //
/**
* 选中的优选通过 v-model computed 绑定选中的优选数据
*/
selectPrefrenceArea:{ selectPrefrenceArea:{
get() { get:function () {
let prefrenceAreas =[]; let prefrenceAreas =[];
if ( if(this.value.prefrenceAreaProductRelationList==null||this.value.prefrenceAreaProductRelationList.length<=0){
this.value.prefrenceAreaProductRelationList == null ||
this.value.prefrenceAreaProductRelationList.length <= 0
) {
return prefrenceAreas; return prefrenceAreas;
} }
// ID for(let i=0;i<this.value.prefrenceAreaProductRelationList.length;i++){
for ( prefrenceAreas.push(this.value.prefrenceAreaProductRelationList[i].prefrenceAreaId);
let i = 0;
i < this.value.prefrenceAreaProductRelationList.length;
i++
) {
prefrenceAreas.push(
this.value.prefrenceAreaProductRelationList[i].prefrenceAreaId
);
} }
return prefrenceAreas; return prefrenceAreas;
}, },
set(newValue) { set:function (newValue) {
//
this.value.prefrenceAreaProductRelationList=[]; this.value.prefrenceAreaProductRelationList=[];
for(let i=0;i<newValue.length;i++){ for(let i=0;i<newValue.length;i++){
this.value.prefrenceAreaProductRelationList.push({ this.value.prefrenceAreaProductRelationList.push({prefrenceAreaId:newValue[i]});
prefrenceAreaId: newValue[i], }
}); }
} }
},
},
}, },
methods: { methods: {
/**
* 筛选方法根据关键词过滤 Transfer 组件数据
* @param {String} query - 查询关键词
* @param {Object} item - 当前项
*/
filterMethod(query, item) { filterMethod(query, item) {
return item.label.indexOf(query) > -1; return item.label.indexOf(query) > -1;
}, },
/**
* 获取专题列表数据
*/
getSubjectList() { getSubjectList() {
fetchSubjectList().then((response) => { fetchSubjectList().then(response => {
let list = response.data; let list = response.data;
this.subjectList = list.map((item) => ({ for (let i = 0; i < list.length; i++) {
label: item.title, this.subjectList.push({
key: item.id, label: list[i].title,
})); key: list[i].id
});
}
}); });
}, },
/**
* 获取优选列表数据
*/
getPrefrenceAreaList() { getPrefrenceAreaList() {
fetchPrefrenceAreaList().then((response) => { fetchPrefrenceAreaList().then(response=>{
let list = response.data; let list = response.data;
this.prefrenceAreaList = list.map((item) => ({ for (let i = 0; i < list.length; i++) {
label: item.name, this.prefrenceAreaList.push({
key: item.id, label: list[i].name,
})); key: list[i].id
});
}
}); });
}, },
/**
* 上一步操作通知父组件返回上一步
*/
handlePrev(){ handlePrev(){
this.$emit('prevStep'); this.$emit('prevStep')
}, },
/**
* 完成提交通知父组件提交表单数据
*/
handleFinishCommit(){ handleFinishCommit(){
this.$emit('finishCommit',this.isEdit); 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,8 +66,6 @@
<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>
开始时间 开始时间
@ -109,8 +73,8 @@
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,152 +82,221 @@
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-form-item v-show="value.promotionType===3">
<el-table :data="value.productLadderList" style="width: 80%" border> <el-table :data="value.productLadderList"
<el-table-column label="数量" align="center" width="120"> style="width: 80%" border>
<el-table-column
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-form-item v-show="value.promotionType===4">
<el-table :data="value.productFullReductionList" style="width: 80%" border> <el-table :data="value.productFullReductionList"
<el-table-column label="满" align="center" width="120"> style="width: 80%" border>
<el-table-column
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() { data() {
return { return {
//
pickerOptions1: { pickerOptions1: {
disabledDate(time) { disabledDate(time) {
return time.getTime() < Date.now(); // return time.getTime() < Date.now();
}, }
}, }
}; }
}, },
created() { created() {
fetchMemberLevelList({ defaultStatus: 0 }).then((response) => { if (this.isEdit) {
this.value.memberPriceList = response.data.map((item) => ({ // this.handleEditCreated();
memberLevelId: item.id, } else {
memberLevelName: item.name, fetchMemberLevelList({defaultStatus: 0}).then(response => {
memberPrice: 0, 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: { computed: {
// //
selectServiceList: { selectServiceList: {
get() { get() {
return this.value.serviceIds ? this.value.serviceIds.split(',').map(Number) : []; let list = [];
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) { set(newValue) {
this.value.serviceIds = newValue.join(','); 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: { methods: {
handleRemoveProductLadder(index) { handleEditCreated() {
this.value.productLadderList.splice(index, 1); 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;
if (productLadderList.length === 1) {
productLadderList.pop();
productLadderList.push({
count: 0,
discount: 0,
price: 0
})
} else {
productLadderList.splice(index, 1);
}
}, },
handleAddProductLadder() { handleAddProductLadder(index, row) {
this.value.productLadderList.push({ count: 0, discount: 0 }); 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) { handleRemoveFullReduction(index, row) {
this.value.productFullReductionList.splice(index, 1); let fullReductionList = this.value.productFullReductionList;
if (fullReductionList.length === 1) {
fullReductionList.pop();
fullReductionList.push({
fullPrice: 0,
reducePrice: 0
});
} else {
fullReductionList.splice(index, 1);
}
}, },
handleAddFullReduction() { handleAddFullReduction(index, row) {
this.value.productFullReductionList.push({ fullPrice: 0, reducePrice: 0 }); let fullReductionList = this.value.productFullReductionList;
if (fullReductionList.length < 3) {
fullReductionList.push({
fullPrice: 0,
reducePrice: 0
});
} else {
this.$message({
message: '最多只能添加三条',
type: 'warning'
});
}
}, },
handlePrev() { handlePrev() {
this.$emit('prevStep'); this.$emit('prevStep')
}, },
handleNext() { handleNext() {
this.$emit('nextStep'); this.$emit('nextStep')
}, }
}, }
}; }
</script> </script>
<style scoped> <style scoped>

@ -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,137 +59,146 @@
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
@ -197,66 +208,442 @@
: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'
const defaultListQuery = {
keyword: null,
pageNum: 1,
pageSize: 5,
publishStatus: null,
verifyStatus: null,
productSn: null,
productCategoryId: null,
brandId: null
};
export default { export default {
name: 'productList', name: "productList",
data() { data() {
return { return {
listQuery: { pageNum: 1, pageSize: 5 }, editSkuInfo:{
list: [], dialogVisible:false,
total: 0, productId:null,
listLoading: false, productSn:'',
operates: [{ label: '商品上架', value: 'publishOn' }], productAttributeCategoryId:null,
stockList:[],
productAttr:[],
keyword:null
},
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, 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() { created() {
this.getList(); this.getList();
this.getBrandList();
this.getProductCateList();
},
watch: {
selectProductCateValue: function (newValue) {
if (newValue != null && newValue.length == 2) {
this.listQuery.productCategoryId = newValue[1];
} else {
this.listQuery.productCategoryId = null;
}
}
},
filters: {
verifyStatusFilter(value) {
if (value === 1) {
return '审核通过';
} else {
return '未审核';
}
}
}, },
methods: { methods: {
// getProductSkuSp(row, index) {
let spData = JSON.parse(row.spData);
if(spData!=null&&index<spData.length){
return spData[index].value;
}else{
return null;
}
},
getList() { getList() {
this.listLoading = true; this.listLoading = true;
fetchList(this.listQuery).then((response) => { fetchList(this.listQuery).then(response => {
this.listLoading = false; this.listLoading = false;
this.list = response.data.list; this.list = response.data.list;
this.total = response.data.total; this.total = response.data.total;
}); });
}, },
// getBrandList() {
handleResetSearch() { fetchBrandList({pageNum: 1, pageSize: 100}).then(response => {
this.listQuery = { pageNum: 1, pageSize: 5 }; this.brandOptions = [];
this.getList(); 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() { handleSearchList() {
this.listQuery.pageNum = 1; this.listQuery.pageNum = 1;
this.getList(); this.getList();
}, },
//
handleAddProduct() { handleAddProduct() {
this.$router.push('/pms/addProduct'); 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 组件作为编辑商品的核心组件
* 该组件内部根据传入的 `is-edit` 参数区分新增或编辑模式
*/
import ProductDetail from './components/ProductDetail';
export default { export default {
name: 'updateProduct', // name: 'updateProduct',
components: { components: { ProductDetail }
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 组件
* 该组件用于处理商品属性的新增和编辑功能
* 通过传递 `is-edit` 参数来控制组件的操作模式
*/
import ProductAttrDetail from './components/ProductAttrDetail';
export default { export default {
//
name: 'addProductAttr', name: 'addProductAttr',
components: { components: { ProductAttrDetail }
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,38 +40,24 @@
<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>
@ -98,14 +67,9 @@
</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 = { const defaultProductAttr = {
filterType: 0, filterType: 0,
handAddStatus: 0, handAddStatus: 0,
@ -117,118 +81,105 @@ const defaultProductAttr = {
searchType: 0, searchType: 0,
selectType: 0, selectType: 0,
sort: 0, sort: 0,
type: 0, type: 0
}; };
export default { export default {
name: 'ProductAttrDetail', // name: "ProductAttrDetail",
props: { props: {
isEdit: { isEdit: {
type: Boolean, // type: Boolean,
default: false, default: false
}, }
}, },
data() { data() {
return { return {
productAttr: Object.assign({}, defaultProductAttr), // productAttr: Object.assign({}, defaultProductAttr),
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'}
], ]
}, },
productAttrCateList: null, // productAttrCateList: null,
inputListFormat: null, // inputListFormat:null
}; }
}, },
created() { created() {
if(this.isEdit){ if(this.isEdit){
// getProductAttr(this.$route.query.id).then(response => {
getProductAttr(this.$route.query.id).then((response) => {
this.productAttr = response.data; this.productAttr = response.data;
//
this.inputListFormat = this.productAttr.inputList.replace(/,/g,'\n'); this.inputListFormat = this.productAttr.inputList.replace(/,/g,'\n');
}); });
}else{ }else{
//
this.resetProductAttr(); this.resetProductAttr();
} }
this.getCateList(); // this.getCateList();
}, },
watch:{ watch:{
// inputListFormat: function (newValue, oldValue) {
inputListFormat(newValue) {
newValue = newValue.replace(/\n/g,','); newValue = newValue.replace(/\n/g,',');
this.productAttr.inputList = newValue; this.productAttr.inputList = newValue;
}, }
}, },
methods: { methods: {
//
getCateList() { getCateList() {
let listQuery = {pageNum: 1, pageSize: 100}; let listQuery = {pageNum: 1, pageSize: 100};
fetchList(listQuery).then((response) => { fetchList(listQuery).then(response => {
this.productAttrCateList = response.data.list; this.productAttrCateList = response.data.list;
}); });
}, },
//
resetProductAttr() { resetProductAttr() {
this.productAttr = Object.assign({}, defaultProductAttr); this.productAttr = Object.assign({}, defaultProductAttr);
this.productAttr.productAttributeCategoryId = Number(this.$route.query.cid); this.productAttr.productAttributeCategoryId = Number(this.$route.query.cid);
this.productAttr.type = Number(this.$route.query.type); this.productAttr.type = Number(this.$route.query.type);
}, },
//
onSubmit(formName) { onSubmit(formName) {
this.$refs[formName].validate((valid) => { this.$refs[formName].validate((valid) => {
if (valid) { if (valid) {
//
this.$confirm('是否提交数据', '提示', { this.$confirm('是否提交数据', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning', type: 'warning'
}).then(() => { }).then(() => {
if(this.isEdit){ if(this.isEdit){
// updateProductAttr(this.$route.query.id,this.productAttr).then(response=>{
updateProductAttr(this.$route.query.id, this.productAttr).then(() => {
this.$message({ this.$message({
message: '修改成功', message: '修改成功',
type: 'success', type: 'success',
duration: 1000, duration: 1000
}); });
this.$router.back(); this.$router.back();
}); });
}else{ }else{
// createProductAttr(this.productAttr).then(response=>{
createProductAttr(this.productAttr).then(() => {
this.$message({ this.$message({
message: '提交成功', message: '提交成功',
type: 'success', type: 'success',
duration: 1000, duration: 1000
}); });
this.resetForm(formName); this.resetForm('productAttrFrom');
}); });
} }
}); });
} 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.resetProductAttr(); this.resetProductAttr();
}
}, },
}, }
};
</script> </script>
<style scoped> <style scoped>
/* 样式部分:可以根据需求添加自定义样式 */
</style> </style>

@ -1,76 +1,60 @@
<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
@ -80,24 +64,19 @@
: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
*/
import {
fetchList,
createProductAttrCate,
deleteProductAttrCate,
updateProductAttrCate,
} from '@/api/productAttrCate';
export default { export default {
name: 'productAttrCateList', // name: 'productAttrCateList',
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
}, },
dialogVisible: false, // dialogVisible: false,
dialogTitle: '', // dialogTitle:'',
productAttrCate:{ productAttrCate:{
name:'', name:'',
id: null, id:null
}, },
rules: { rules: {
name: [{ required: true, message: '请输入类型名称', trigger: 'blur' }], name: [
}, { required: true, message: '请输入类型名称', trigger: 'blur' }
}; ]
}
}
}, },
created() { created() {
//
this.getList(); this.getList();
}, },
methods: { methods: {
//
getList() { getList() {
this.listLoading = true; this.listLoading = true;
fetchList(this.listQuery).then((response) => { fetchList(this.listQuery).then(response => {
this.listLoading = false; this.listLoading = false;
this.list = response.data.list; this.list = response.data.list;
this.total = response.data.total; this.total = response.data.total;
}); });
}, },
//
addProductAttrCate() { addProductAttrCate() {
this.dialogVisible = true; this.dialogVisible = true;
this.dialogTitle = '添加类型'; this.dialogTitle = "添加类型";
this.productAttrCate = { name: '', id: null };
}, },
//
handleSizeChange(val) { handleSizeChange(val) {
this.listQuery.pageNum = 1; this.listQuery.pageNum = 1;
this.listQuery.pageSize = val; this.listQuery.pageSize = val;
this.getList(); this.getList();
}, },
//
handleCurrentChange(val) { handleCurrentChange(val) {
this.listQuery.pageNum = val; this.listQuery.pageNum = val;
this.getList(); this.getList();
}, },
//
handleDelete(index, row) { handleDelete(index, row) {
this.$confirm('是否要删除该分类?', '提示', { this.$confirm('是否要删除该品牌', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning', type: 'warning'
}).then(() => { }).then(() => {
deleteProductAttrCate(row.id).then(() => { deleteProductAttrCate(row.id).then(response=>{
this.$message({ this.$message({
message: '删除成功', message: '删除成功',
type: 'success', type: 'success',
duration: 1000, duration:1000
}); });
this.getList(); this.getList();
}); });
}); });
}, },
//
handleUpdate(index, row) { handleUpdate(index, row) {
this.dialogVisible = true; this.dialogVisible = true;
this.dialogTitle = '编辑类型'; this.dialogTitle = "编辑类型";
this.productAttrCate.name = row.name; this.productAttrCate.name = row.name;
this.productAttrCate.id = row.id; this.productAttrCate.id = row.id;
}, },
//
getAttrList(index, row) { getAttrList(index, row) {
this.$router.push({ this.$router.push({path: '/pms/productAttrList',query:{cid:row.id,cname:row.name,type:0}})
path: '/pms/productAttrList',
query: { cid: row.id, cname: row.name, type: 0 },
});
}, },
//
getParamList(index, row) { getParamList(index, row) {
this.$router.push({ this.$router.push({path: '/pms/productAttrList',query:{cid:row.id,cname:row.name,type:1}})
path: '/pms/productAttrList',
query: { cid: row.id, cname: row.name, type: 1 },
});
}, },
//
handleConfirm(formName){ handleConfirm(formName){
this.$refs[formName].validate((valid) => { this.$refs[formName].validate((valid) => {
if (valid) { if (valid) {
const data = new URLSearchParams(); let data = new URLSearchParams();
data.append('name', this.productAttrCate.name); data.append("name",this.productAttrCate.name);
if(this.dialogTitle==="添加类型"){
if (this.dialogTitle === '添加类型') { createProductAttrCate(data).then(response=>{
// this.$message({
createProductAttrCate(data).then(() => { message: '添加成功',
this.$message({ message: '添加成功', type: 'success', duration: 1000 }); type: 'success',
duration:1000
});
this.dialogVisible = false; this.dialogVisible = false;
this.getList(); this.getList();
}); });
}else{ }else{
// updateProductAttrCate(this.productAttrCate.id,data).then(response=>{
updateProductAttrCate(this.productAttrCate.id, data).then(() => { this.$message({
this.$message({ message: '修改成功', type: 'success', duration: 1000 }); message: '修改成功',
type: 'success',
duration:1000
});
this.dialogVisible = false; this.dialogVisible = false;
this.getList(); this.getList();
}); });
} }
} else {
console.log('error submit!!');
return false;
} }
}); });
}, },
//
handleClose(){ handleClose(){
if (this.$refs.productAttrCatForm) { if (!this.dialogVisible && this.$refs.productAttrCatForm) {
this.$refs.productAttrCatForm.clearValidate(); this.$refs.productAttrCatForm.clearValidate()
} }
},
},
};
</script>
<style scoped>
.app-container {
padding: 20px;
} }
}
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
</style> </style>

@ -1,96 +1,80 @@
<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
@ -100,71 +84,60 @@
: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
*/
import { fetchList, deleteProductAttr } from '@/api/productAttr';
export default { export default {
name: 'productAttrList', // name: 'productAttrList',
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,
type: this.$route.query.type, // type: this.$route.query.type
}, },
operateType: null, // operateType: null,
multipleSelection: [], // multipleSelection: [],
operates: [ operates: [
{ label: '删除', value: 'deleteProductAttr' }, // {
], label: "删除",
}; value: "deleteProductAttr"
}
]
}
}, },
created() { created() {
this.getList(); // this.getList();
}, },
methods: { methods: {
//
getList() { getList() {
this.listLoading = true; this.listLoading = true;
fetchList(this.$route.query.cid, this.listQuery).then((response) => { fetchList(this.$route.query.cid, this.listQuery).then(response => {
this.listLoading = false; this.listLoading = false;
this.list = response.data.list; this.list = response.data.list;
this.total = response.data.total; this.total = response.data.total;
}); });
}, },
//
addProductAttr() { addProductAttr() {
this.$router.push({ this.$router.push({path:'/pms/addProductAttr',query:{cid:this.$route.query.cid,type:this.$route.query.type}});
path: '/pms/addProductAttr',
query: { cid: this.$route.query.cid, type: this.$route.query.type },
});
}, },
//
handleSelectionChange(val) { handleSelectionChange(val) {
this.multipleSelection = val; this.multipleSelection = val;
}, },
//
handleBatchOperate() { handleBatchOperate() {
if (this.multipleSelection.length < 1) { if (this.multipleSelection < 1) {
this.$message({ this.$message({
message: '请选择至少一条记录', message: '请选择一条记录',
type: 'warning', type: 'warning',
duration: 1000, duration: 1000
}); });
return; return;
} }
@ -172,77 +145,75 @@ export default {
this.$message({ this.$message({
message: '请选择批量操作类型', message: '请选择批量操作类型',
type: 'warning', type: 'warning',
duration: 1000, duration: 1000
}); });
return; return;
} }
let ids = [];
const ids = this.multipleSelection.map((item) => item.id); for (let i = 0; i < this.multipleSelection.length; i++) {
ids.push(this.multipleSelection[i].id);
}
this.handleDeleteProductAttr(ids); this.handleDeleteProductAttr(ids);
}, },
//
handleSizeChange(val) { handleSizeChange(val) {
this.listQuery.pageNum = 1; this.listQuery.pageNum = 1;
this.listQuery.pageSize = val; this.listQuery.pageSize = val;
this.getList(); this.getList();
}, },
//
handleCurrentChange(val) { handleCurrentChange(val) {
this.listQuery.pageNum = val; this.listQuery.pageNum = val;
this.getList(); this.getList();
}, },
//
handleUpdate(index, row) { handleUpdate(index, row) {
this.$router.push({path:'/pms/updateProductAttr',query:{id:row.id}}); this.$router.push({path:'/pms/updateProductAttr',query:{id:row.id}});
}, },
//
handleDeleteProductAttr(ids) { handleDeleteProductAttr(ids) {
this.$confirm('是否要删除选中的属性?', '提示', { this.$confirm('是否要删除该属性', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning', type: 'warning'
}).then(() => { }).then(() => {
const data = new URLSearchParams(); let data = new URLSearchParams();
data.append('ids', ids); data.append("ids", ids);
deleteProductAttr(data).then(() => { deleteProductAttr(data).then(response => {
this.$message({ this.$message({
message: '删除成功', message: '删除成功',
type: 'success', type: 'success',
duration: 1000, duration: 1000
}); });
this.getList(); this.getList();
}); });
}); });
}, },
//
handleDelete(index, row) { handleDelete(index, row) {
const ids = [row.id]; let ids = [];
ids.push(row.id);
this.handleDeleteProductAttr(ids); this.handleDeleteProductAttr(ids);
}, },
}, },
filters: { filters: {
//
inputTypeFilter(value) { inputTypeFilter(value) {
return value === 1 ? '从列表中选取' : '手工录入'; if (value === 1) {
return '从列表中选取';
} else {
return '手工录入'
}
}, },
//
selectTypeFilter(value) { selectTypeFilter(value) {
if (value === 1) return '单选'; if (value === 1) {
if (value === 2) return '多选'; return '单选';
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,7 +85,6 @@
sort: 0, sort: 0,
productAttributeIdList: [] productAttributeIdList: []
}; };
export default { export default {
name: "ProductCateDetail", name: "ProductCateDetail",
components: {SingleUpload}, components: {SingleUpload},
@ -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" 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="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,8 +81,6 @@
</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
@ -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=[];
ids.push(row.id)
data.append('ids',ids);
data.append('navStatus',row.navStatus); data.append('navStatus',row.navStatus);
updateNavStatus(data).then(() => { updateNavStatus(data).then(response=>{
this.$message.success('修改成功'); 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=[];
ids.push(row.id)
data.append('ids',ids);
data.append('showStatus',row.showStatus); data.append('showStatus',row.showStatus);
updateShowStatus(data).then(() => { updateShowStatus(data).then(response=>{
this.$message.success('修改成功'); 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 { export default {
// addHomeAdvertise
name: 'addHomeAdvertise', name: 'addHomeAdvertise',
// 使
components: { HomeAdvertiseDetail } 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,12 +139,8 @@
</div> </div>
</template> </template>
<script> <script>
// '@/api/homeAdvertise'广
import {fetchList,updateStatus,deleteHomeAdvertise} from '@/api/homeAdvertise'; import {fetchList,updateStatus,deleteHomeAdvertise} from '@/api/homeAdvertise';
// '@/utils/date'
import {formatDate} from '@/utils/date'; import {formatDate} from '@/utils/date';
//
const defaultListQuery = { const defaultListQuery = {
pageNum: 1, pageNum: 1,
pageSize: 5, pageSize: 5,
@ -183,7 +148,6 @@ const defaultListQuery = {
type: null, type: null,
endTime:null endTime:null
}; };
// 广PCAPP
const defaultTypeOptions = [ const defaultTypeOptions = [
{ {
label: 'PC首页轮播', label: 'PC首页轮播',
@ -194,40 +158,29 @@ const defaultTypeOptions = [
value: 1 value: 1
} }
]; ];
export default { export default {
name: 'homeAdvertiseList', name: 'homeAdvertiseList',
data() { data() {
return { return {
//
listQuery: Object.assign({}, defaultListQuery), listQuery: Object.assign({}, defaultListQuery),
// 广
typeOptions: Object.assign({}, defaultTypeOptions), typeOptions: Object.assign({}, defaultTypeOptions),
// 广null
list: null, list: null,
// 广null
total: null, total: null,
// false
listLoading: false, listLoading: false,
// 广
multipleSelection: [], multipleSelection: [],
//
operates: [ operates: [
{ {
label: "删除", label: "删除",
value: 0 value: 0
} }
], ],
// null
operateType: null operateType: null
} }
}, },
created() { created() {
// 广
this.getList(); this.getList();
}, },
filters:{ filters:{
// 广
formatType(type){ formatType(type){
if(type===1){ if(type===1){
return 'APP首页轮播'; return 'APP首页轮播';
@ -235,7 +188,6 @@ export default {
return 'PC首页轮播'; return 'PC首页轮播';
} }
}, },
//
formatTime(time){ formatTime(time){
if(time==null||time===''){ if(time==null||time===''){
return 'N/A'; return 'N/A';
@ -245,31 +197,25 @@ export default {
}, },
}, },
methods: { methods: {
//
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();
}, },
//
handleSelectionChange(val){ handleSelectionChange(val){
this.multipleSelection = val; this.multipleSelection = val;
}, },
//
handleSizeChange(val) { handleSizeChange(val) {
this.listQuery.pageNum = 1; this.listQuery.pageNum = 1;
this.listQuery.pageSize = val; this.listQuery.pageSize = val;
this.getList(); this.getList();
}, },
//
handleCurrentChange(val) { handleCurrentChange(val) {
this.listQuery.pageNum = val; this.listQuery.pageNum = val;
this.getList(); this.getList();
}, },
// 广
handleUpdateStatus(index,row){ handleUpdateStatus(index,row){
this.$confirm('是否要修改上线/下线状态?', '提示', { this.$confirm('是否要修改上线/下线状态?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
@ -291,11 +237,9 @@ export default {
this.getList(); this.getList();
}); });
}, },
// 广广
handleDelete(index,row){ handleDelete(index,row){
this.deleteHomeAdvertise(row.id); this.deleteHomeAdvertise(row.id);
}, },
//
handleBatchOperate(){ handleBatchOperate(){
if (this.multipleSelection < 1) { if (this.multipleSelection < 1) {
this.$message({ this.$message({
@ -320,15 +264,12 @@ export default {
}); });
} }
}, },
// 广广
handleAdd(){ handleAdd(){
this.$router.push({path: '/sms/addAdvertise'}) this.$router.push({path: '/sms/addAdvertise'})
}, },
// 广广广id
handleUpdate(index,row){ handleUpdate(index,row){
this.$router.push({path: '/sms/updateAdvertise', query: {id: row.id}}) this.$router.push({path: '/sms/updateAdvertise', query: {id: row.id}})
}, },
// 广true
getList() { getList() {
this.listLoading = true; this.listLoading = true;
fetchList(this.listQuery).then(response => { fetchList(this.listQuery).then(response => {
@ -337,7 +278,6 @@ export default {
this.total = response.data.total; this.total = response.data.total;
}) })
}, },
// 广
deleteHomeAdvertise(ids){ deleteHomeAdvertise(ids){
this.$confirm('是否要删除该广告?', '提示', { this.$confirm('是否要删除该广告?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
@ -359,9 +299,7 @@ export default {
} }
</script> </script>
<style scoped> <style scoped>
<!-- 带有scoped属性的style标签里面样式仅作用于当前组件 -->
.input-width { .input-width {
<!-- 定义类选择器样式设置宽度为203px -->
width: 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',
// HomeAdvertiseDetail使使
components: { 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,32 +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> <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
@ -83,15 +63,12 @@
</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,28 +149,21 @@
</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> <el-button type="primary" @click="handleUpdateSort" size="small"> </el-button>
</span> </span>
</el-dialog> </el-dialog>

@ -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 {
// addCoupon
name: 'addCoupon', name: 'addCoupon',
// CouponDetail使使
components: { 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,25 +135,17 @@
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';
// '@/api/product'fetchProductList
import {fetchSimpleList as fetchProductList} from '@/api/product'; import {fetchSimpleList as fetchProductList} from '@/api/product';
// '@/api/productCate' import {fetchListWithChildren} from '@/api/productCate'
import {fetchListWithChildren} from '@/api/productCate';
//
const defaultCoupon = { const defaultCoupon = {
type: 0, type: 0,
name: null, name: null,
@ -198,7 +161,6 @@ const defaultCoupon = {
productRelationList: [], productRelationList: [],
productCategoryRelationList: [] productCategoryRelationList: []
}; };
//
const defaultTypeOptions = [ const defaultTypeOptions = [
{ {
label: '全场赠券', label: '全场赠券',
@ -217,7 +179,6 @@ const defaultTypeOptions = [
value: 3 value: 3
} }
]; ];
// PC
const defaultPlatformOptions = [ const defaultPlatformOptions = [
{ {
label: '全平台', label: '全平台',
@ -232,10 +193,8 @@ const defaultPlatformOptions = [
value: 2 value: 2
} }
]; ];
export default { export default {
name: 'CouponDetail', name: 'CouponDetail',
// isEditfalse
props: { props: {
isEdit: { isEdit: {
type: Boolean, type: Boolean,
@ -244,13 +203,9 @@ export default {
}, },
data() { data() {
return { return {
//
coupon: Object.assign({}, defaultCoupon), coupon: Object.assign({}, defaultCoupon),
//
typeOptions: Object.assign({}, defaultTypeOptions), typeOptions: Object.assign({}, defaultTypeOptions),
//
platformOptions: Object.assign({}, defaultPlatformOptions), platformOptions: Object.assign({}, defaultPlatformOptions),
//
rules: { rules: {
name: [ name: [
{required: true, message: '请输入优惠券名称', trigger: 'blur'}, {required: true, message: '请输入优惠券名称', trigger: 'blur'},
@ -266,30 +221,22 @@ export default {
{type: 'number',required: true,message: '只能输入正整数',trigger: 'blur'} {type: 'number',required: true,message: '只能输入正整数',trigger: 'blur'}
] ]
}, },
// null
selectProduct:null, selectProduct:null,
// false
selectProductLoading: false, selectProductLoading: false,
//
selectProductOptions:[], selectProductOptions:[],
// null
selectProductCate: null, selectProductCate: null,
//
productCateOptions: [] productCateOptions: []
} }
}, },
created(){ created(){
// coupon
if(this.isEdit){ if(this.isEdit){
getCoupon(this.$route.query.id).then(response=>{ getCoupon(this.$route.query.id).then(response=>{
this.coupon=response.data; this.coupon=response.data;
}); });
} }
//
this.getProductCateList(); this.getProductCateList();
}, },
methods:{ methods:{
//
onSubmit(formName) { onSubmit(formName) {
this.$refs[formName].validate((valid) => { this.$refs[formName].validate((valid) => {
if (valid) { if (valid) {
@ -330,12 +277,10 @@ export default {
} }
}); });
}, },
// coupon
resetForm(formName) { resetForm(formName) {
this.$refs[formName].resetFields(); this.$refs[formName].resetFields();
this.coupon = Object.assign({},defaultCoupon); this.coupon = Object.assign({},defaultCoupon);
}, },
//
searchProductMethod(query){ searchProductMethod(query){
if (query !== '') { if (query !== '') {
this.loading = true; this.loading = true;
@ -352,7 +297,6 @@ export default {
this.selectProductOptions = []; this.selectProductOptions = [];
} }
}, },
//
handleAddProductRelation(){ handleAddProductRelation(){
if(this.selectProduct===null){ if(this.selectProduct===null){
this.$message({ this.$message({
@ -364,11 +308,9 @@ export default {
this.coupon.productRelationList.push(this.getProductById(this.selectProduct)); this.coupon.productRelationList.push(this.getProductById(this.selectProduct));
this.selectProduct=null; this.selectProduct=null;
}, },
//
handleDeleteProductRelation(index,row){ handleDeleteProductRelation(index,row){
this.coupon.productRelationList.splice(index,1); this.coupon.productRelationList.splice(index,1);
}, },
//
handleAddProductCategoryRelation(){ handleAddProductCategoryRelation(){
if(this.selectProductCate===null||this.selectProductCate.length===0){ if(this.selectProductCate===null||this.selectProductCate.length===0){
this.$message({ this.$message({
@ -380,11 +322,9 @@ export default {
this.coupon.productCategoryRelationList.push(this.getProductCateByIds(this.selectProductCate)); this.coupon.productCategoryRelationList.push(this.getProductCateByIds(this.selectProductCate));
this.selectProductCate=[]; this.selectProductCate=[];
}, },
//
handleDeleteProductCateRelation(index,row){ handleDeleteProductCateRelation(index,row){
this.coupon.productCategoryRelationList.splice(index,1); this.coupon.productCategoryRelationList.splice(index,1);
}, },
// idid
getProductById(id){ getProductById(id){
for(let i=0;i<this.selectProductOptions.length;i++){ for(let i=0;i<this.selectProductOptions.length;i++){
if(id===this.selectProductOptions[i].productId){ if(id===this.selectProductOptions[i].productId){
@ -393,7 +333,6 @@ export default {
} }
return null; return null;
}, },
//
getProductCateList() { getProductCateList() {
fetchListWithChildren().then(response => { fetchListWithChildren().then(response => {
let list = response.data; let list = response.data;
@ -409,7 +348,6 @@ export default {
} }
}); });
}, },
// idid
getProductCateByIds(ids){ getProductCateByIds(ids){
let name; let name;
let parentName; let parentName;
@ -429,9 +367,7 @@ export default {
} }
</script> </script>
<style scoped> <style scoped>
<!-- 带有scoped属性的style标签意味着里面定义的样式仅作用于当前组件内的元素 -->
.input-width { .input-width {
<!-- 定义了一个类选择器样式作用是将应用该类的元素宽度设置为其父元素宽度的60% -->
width: 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,14 +114,10 @@
</div> </div>
</template> </template>
<script> <script>
// '@/utils/date'formatDate
import {formatDate} from '@/utils/date'; import {formatDate} from '@/utils/date';
// '@/api/coupon'getCoupon
import {getCoupon} from '@/api/coupon'; import {getCoupon} from '@/api/coupon';
// '@/api/couponHistory'fetchCouponHistoryList
import {fetchList as fetchCouponHistoryList} from '@/api/couponHistory'; import {fetchList as fetchCouponHistoryList} from '@/api/couponHistory';
//
const defaultTypeOptions = [ const defaultTypeOptions = [
{ {
label: '全场赠券', label: '全场赠券',
@ -191,7 +136,6 @@ const defaultTypeOptions = [
value: 3 value: 3
} }
]; ];
// 使
const defaultListQuery = { const defaultListQuery = {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
@ -199,7 +143,6 @@ const defaultListQuery = {
orderSn: null, orderSn: null,
couponId: null couponId: null
}; };
// 使使使
const defaultUseTypeOptions= [ const defaultUseTypeOptions= [
{ {
label: "未使用", label: "未使用",
@ -214,37 +157,26 @@ const defaultUseTypeOptions = [
value: 2 value: 2
} }
]; ];
export default { export default {
name: 'couponHistoryList', name: 'couponHistoryList',
data() { data() {
return { return {
//
coupon: {}, coupon: {},
//
listQuery: Object.assign({}, defaultListQuery), listQuery: Object.assign({}, defaultListQuery),
// 使
useTypeOptions:Object.assign({},defaultUseTypeOptions), useTypeOptions:Object.assign({},defaultUseTypeOptions),
// null
list:null, list:null,
// null
total:null, total:null,
// false
listLoading:false listLoading:false
} }
}, },
created() { created() {
// coupon
getCoupon(this.$route.query.id).then(response => { getCoupon(this.$route.query.id).then(response => {
this.coupon = response.data; this.coupon = response.data;
}); });
// id
this.listQuery.couponId=this.$route.query.id; this.listQuery.couponId=this.$route.query.id;
//
this.getList(); this.getList();
}, },
filters: { filters: {
//
formatType(type) { formatType(type) {
for (let i = 0; i < defaultTypeOptions.length; i++) { for (let i = 0; i < defaultTypeOptions.length; i++) {
if (type === defaultTypeOptions[i].value) { if (type === defaultTypeOptions[i].value) {
@ -253,7 +185,6 @@ export default {
} }
return ''; return '';
}, },
// 使
formatUseType(useType) { formatUseType(useType) {
if (useType === 0) { if (useType === 0) {
return '全场通用'; return '全场通用';
@ -263,7 +194,6 @@ export default {
return '指定商品'; return '指定商品';
} }
}, },
//
formatPlatform(platform) { formatPlatform(platform) {
if (platform === 1) { if (platform === 1) {
return '移动平台'; return '移动平台';
@ -273,7 +203,6 @@ export default {
return '全平台'; return '全平台';
} }
}, },
//
formatDate(time) { formatDate(time) {
if (time == null || time === '') { if (time == null || time === '') {
return 'N/A'; return 'N/A';
@ -281,7 +210,6 @@ export default {
let date = new Date(time); let date = new Date(time);
return formatDate(date, 'yyyy-MM-dd') return formatDate(date, 'yyyy-MM-dd')
}, },
//
formatStatus(endTime) { formatStatus(endTime) {
let now = new Date().getTime(); let now = new Date().getTime();
if (endTime > now) { if (endTime > now) {
@ -290,7 +218,6 @@ export default {
return '已过期'; return '已过期';
} }
}, },
//
formatGetType(type) { formatGetType(type) {
if(type===1){ if(type===1){
return '主动获取'; return '主动获取';
@ -298,7 +225,6 @@ export default {
return '后台赠送'; return '后台赠送';
} }
}, },
// 使
formatCouponHistoryUseType(useType) { formatCouponHistoryUseType(useType) {
if (useType === 0) { if (useType === 0) {
return '未使用'; return '未使用';
@ -308,7 +234,6 @@ export default {
return '已过期'; return '已过期';
} }
}, },
//
formatTime(time) { formatTime(time) {
if (time == null || time === '') { if (time == null || time === '') {
return 'N/A'; return 'N/A';
@ -318,7 +243,6 @@ export default {
}, },
}, },
methods: { methods: {
// true
getList(){ getList(){
this.listLoading=true; this.listLoading=true;
fetchCouponHistoryList(this.listQuery).then(response=>{ fetchCouponHistoryList(this.listQuery).then(response=>{
@ -327,23 +251,19 @@ export default {
this.total=response.data.total; this.total=response.data.total;
}); });
}, },
// id
handleResetSearch() { handleResetSearch() {
this.listQuery = Object.assign({}, defaultListQuery); this.listQuery = Object.assign({}, defaultListQuery);
this.listQuery.couponId=this.$route.query.id; this.listQuery.couponId=this.$route.query.id;
}, },
//
handleSearchList() { handleSearchList() {
this.listQuery.pageNum = 1; this.listQuery.pageNum = 1;
this.getList(); this.getList();
}, },
//
handleSizeChange(val) { handleSizeChange(val) {
this.listQuery.pageNum = 1; this.listQuery.pageNum = 1;
this.listQuery.pageSize = val; this.listQuery.pageSize = val;
this.getList(); this.getList();
}, },
//
handleCurrentChange(val) { handleCurrentChange(val) {
this.listQuery.pageNum = val; this.listQuery.pageNum = val;
this.getList(); this.getList();
@ -351,24 +271,22 @@ export default {
} }
} }
</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;
@ -380,7 +298,7 @@ export default {
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;

@ -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,19 +105,14 @@
</div> </div>
</template> </template>
<script> <script>
// '@/api/coupon'
import {fetchList,deleteCoupon} from '@/api/coupon'; import {fetchList,deleteCoupon} from '@/api/coupon';
// '@/utils/date'formatDate
import {formatDate} from '@/utils/date'; import {formatDate} from '@/utils/date';
//
const defaultListQuery = { const defaultListQuery = {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
name: null, name: null,
type: null type: null
}; };
//
const defaultTypeOptions=[ const defaultTypeOptions=[
{ {
label: '全场赠券', label: '全场赠券',
@ -168,31 +131,22 @@ const defaultTypeOptions = [
value: 3 value: 3
} }
]; ];
export default { export default {
name:'couponList', name:'couponList',
data() { data() {
return { return {
//
listQuery:Object.assign({},defaultListQuery), listQuery:Object.assign({},defaultListQuery),
//
typeOptions:Object.assign({},defaultTypeOptions), typeOptions:Object.assign({},defaultTypeOptions),
// null
list:null, list:null,
// null
total:null, total:null,
// false
listLoading:false, listLoading:false,
//
multipleSelection:[] multipleSelection:[]
} }
}, },
created(){ created(){
//
this.getList(); this.getList();
}, },
filters:{ filters:{
//
formatType(type){ formatType(type){
for(let i=0;i<defaultTypeOptions.length;i++){ for(let i=0;i<defaultTypeOptions.length;i++){
if(type===defaultTypeOptions[i].value){ if(type===defaultTypeOptions[i].value){
@ -201,7 +155,6 @@ export default {
} }
return ''; return '';
}, },
// 使
formatUseType(useType){ formatUseType(useType){
if(useType===0){ if(useType===0){
return '全场通用'; return '全场通用';
@ -211,7 +164,6 @@ export default {
return '指定商品'; return '指定商品';
} }
}, },
//
formatPlatform(platform){ formatPlatform(platform){
if(platform===1){ if(platform===1){
return '移动平台'; return '移动平台';
@ -221,7 +173,6 @@ export default {
return '全平台'; return '全平台';
} }
}, },
//
formatDate(time){ formatDate(time){
if(time==null||time===''){ if(time==null||time===''){
return 'N/A'; return 'N/A';
@ -229,7 +180,6 @@ export default {
let date = new Date(time); let date = new Date(time);
return formatDate(date, 'yyyy-MM-dd') return formatDate(date, 'yyyy-MM-dd')
}, },
//
formatStatus(endTime){ formatStatus(endTime){
let now = new Date().getTime(); let now = new Date().getTime();
let endDate = new Date(endTime); let endDate = new Date(endTime);
@ -241,43 +191,34 @@ export default {
} }
}, },
methods:{ methods:{
//
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();
}, },
//
handleSelectionChange(val){ handleSelectionChange(val){
this.multipleSelection = val; this.multipleSelection = val;
}, },
//
handleSizeChange(val) { handleSizeChange(val) {
this.listQuery.pageNum = 1; this.listQuery.pageNum = 1;
this.listQuery.pageSize = val; this.listQuery.pageSize = val;
this.getList(); this.getList();
}, },
//
handleCurrentChange(val) { handleCurrentChange(val) {
this.listQuery.pageNum = val; this.listQuery.pageNum = val;
this.getList(); this.getList();
}, },
//
handleAdd(){ handleAdd(){
this.$router.push({path: '/sms/addCoupon'}) this.$router.push({path: '/sms/addCoupon'})
}, },
// id
handleView(index, row) { handleView(index, row) {
this.$router.push({path: '/sms/couponHistory', query: {id: row.id}}) this.$router.push({path: '/sms/couponHistory', query: {id: row.id}})
}, },
// id
handleUpdate(index, row) { handleUpdate(index, row) {
this.$router.push({path: '/sms/updateCoupon', query: {id: row.id}}) this.$router.push({path: '/sms/updateCoupon', query: {id: row.id}})
}, },
//
handleDelete(index, row) { handleDelete(index, row) {
this.$confirm('是否进行删除操作?', '提示', { this.$confirm('是否进行删除操作?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
@ -293,7 +234,6 @@ export default {
}); });
}) })
}, },
// true
getList(){ getList(){
this.listLoading=true; this.listLoading=true;
fetchList(this.listQuery).then(response=>{ fetchList(this.listQuery).then(response=>{
@ -306,7 +246,6 @@ export default {
} }
</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 {
// updateCoupon
name: 'updateCoupon', name: 'updateCoupon',
// CouponDetail使使
components: { 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,39 +118,29 @@
placeholder="请选择时间"> placeholder="请选择时间">
</el-date-picker> </el-date-picker>
</el-form-item> </el-form-item>
<!-- 对应上线/下线选择的表单项使用了单选按钮组组件 -->
<el-form-item label="上线/下线"> <el-form-item label="上线/下线">
<el-radio-group v-model="flashPromotion.status"> <el-radio-group v-model="flashPromotion.status">
<!-- 上线单选按钮选项 -->
<el-radio :label="1">上线</el-radio> <el-radio :label="1">上线</el-radio>
<!-- 下线单选按钮选项 -->
<el-radio :label="0">下线</el-radio> <el-radio :label="0">下线</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
</el-form> </el-form>
<!-- 对话框底部的操作按钮区域使用了插槽footer -->
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<!-- 取消按钮点击可关闭对话框设置了按钮尺寸 -->
<el-button @click="dialogVisible = false" size="small"> </el-button> <el-button @click="dialogVisible = false" size="small"> </el-button>
<!-- 确定按钮点击可触发确认添加活动的相关逻辑设置了按钮类型为主要按钮尺寸为小尺寸 -->
<el-button type="primary" @click="handleDialogConfirm()" size="small"> </el-button> <el-button type="primary" @click="handleDialogConfirm()" size="small"> </el-button>
</span> </span>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
<script> <script>
// '@/api/flash'
import {fetchList, updateStatus, deleteFlash, createFlash, updateFlash} from '@/api/flash'; import {fetchList, updateStatus, deleteFlash, createFlash, updateFlash} from '@/api/flash';
// '@/utils/date'formatDate
import {formatDate} from '@/utils/date'; import {formatDate} from '@/utils/date';
//
const defaultListQuery = { const defaultListQuery = {
pageNum: 1, pageNum: 1,
pageSize: 5, pageSize: 5,
keyword: null keyword: null
}; };
//
const defaultFlashPromotion = { const defaultFlashPromotion = {
id: null, id: null,
title: null, title: null,
@ -211,96 +148,68 @@ const defaultFlashPromotion = {
endDate: null, endDate: null,
status: 0 status: 0
}; };
export default { export default {
name: 'flashPromotionList', name: 'flashPromotionList',
data() { data() {
return { return {
// defaultListQuery
listQuery: Object.assign({}, defaultListQuery), listQuery: Object.assign({}, defaultListQuery),
// null
list: null, list: null,
// null
total: null, total: null,
// falsetrue
listLoading: false, listLoading: false,
// /false
dialogVisible: false, dialogVisible: false,
// defaultFlashPromotion
flashPromotion: Object.assign({}, defaultFlashPromotion), flashPromotion: Object.assign({}, defaultFlashPromotion),
// truefalsefalse
isEdit: false isEdit: false
} }
}, },
created() { created() {
//
this.getList(); this.getList();
}, },
filters: { filters: {
//
formatActiveStatus(row) { formatActiveStatus(row) {
//
let nowDate = new Date(); let nowDate = new Date();
//
let startDate = new Date(row.startDate); let startDate = new Date(row.startDate);
//
let endDate = new Date(row.endDate); let endDate = new Date(row.endDate);
//
if (nowDate.getTime() >= startDate.getTime() && nowDate.getTime() <= endDate.getTime()) { if (nowDate.getTime() >= startDate.getTime() && nowDate.getTime() <= endDate.getTime()) {
return '活动进行中'; return '活动进行中';
} } else if (nowDate.getTime() > endDate.getTime()) {
//
else if (nowDate.getTime() > endDate.getTime()) {
return '活动已结束'; return '活动已结束';
} } else {
//
else {
return '活动未开始'; return '活动未开始';
} }
}, },
// 'N/A'
formatDate(time) { formatDate(time) {
if (time == null || time === '') { if (time == null || time === '') {
return 'N/A'; return 'N/A';
} }
//
let date = new Date(time); let date = new Date(time);
// formatDate 'yyyy-MM-dd'
return formatDate(date, 'yyyy-MM-dd') return formatDate(date, 'yyyy-MM-dd')
} }
}, },
methods: { methods: {
// 便
handleResetSearch() { handleResetSearch() {
this.listQuery = Object.assign({}, defaultListQuery); this.listQuery = Object.assign({}, defaultListQuery);
}, },
// 1
handleSearchList() { handleSearchList() {
this.listQuery.pageNum = 1; this.listQuery.pageNum = 1;
this.getList(); this.getList();
}, },
// 1
handleSizeChange(val) { handleSizeChange(val) {
this.listQuery.pageNum = 1; this.listQuery.pageNum = 1;
this.listQuery.pageSize = val; this.listQuery.pageSize = val;
this.getList(); this.getList();
}, },
//
handleCurrentChange(val) { handleCurrentChange(val) {
this.listQuery.pageNum = val; this.listQuery.pageNum = val;
this.getList(); this.getList();
}, },
// true
handleAdd() { handleAdd() {
this.dialogVisible = true; this.dialogVisible = true;
this.isEdit = false; this.isEdit = false;
this.flashPromotion = Object.assign({},defaultFlashPromotion); this.flashPromotion = Object.assign({},defaultFlashPromotion);
}, },
// '/sms/flashSession'
handleShowSessionList() { handleShowSessionList() {
this.$router.push({path: '/sms/flashSession'}) this.$router.push({path: '/sms/flashSession'})
}, },
//
handleStatusChange(index, row) { handleStatusChange(index, row) {
this.$confirm('是否要修改该状态?', '提示', { this.$confirm('是否要修改该状态?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
@ -321,7 +230,6 @@ export default {
this.getList(); this.getList();
}); });
}, },
//
handleDelete(index, row) { handleDelete(index, row) {
this.$confirm('是否要删除该活动?', '提示', { this.$confirm('是否要删除该活动?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
@ -337,13 +245,11 @@ export default {
}); });
}); });
}, },
// true便
handleUpdate(index, row) { handleUpdate(index, row) {
this.dialogVisible = true; this.dialogVisible = true;
this.isEdit = true; this.isEdit = true;
this.flashPromotion = Object.assign({},row); this.flashPromotion = Object.assign({},row);
}, },
//
handleDialogConfirm() { handleDialogConfirm() {
this.$confirm('是否要确认?', '提示', { this.$confirm('是否要确认?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
@ -371,11 +277,9 @@ export default {
} }
}) })
}, },
// '/sms/selectSession' id
handleSelectSession(index,row){ handleSelectSession(index,row){
this.$router.push({path:'/sms/selectSession',query:{flashPromotionId:row.id}}) this.$router.push({path:'/sms/selectSession',query:{flashPromotionId:row.id}})
}, },
// truefalse
getList() { getList() {
this.listLoading = true; this.listLoading = true;
fetchList(this.listQuery).then(response => { fetchList(this.listQuery).then(response => {

@ -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,101 +99,71 @@
:total="dialogData.total"> :total="dialogData.total">
</el-pagination> </el-pagination>
</div> </div>
<!-- 用于清除浮动确保后续元素布局正常 -->
<div style="clear: both;"></div> <div style="clear: both;"></div>
<!-- 对话框底部的操作按钮区域使用了插槽footer -->
<div slot="footer"> <div slot="footer">
<!-- 取消按钮点击可关闭对话框设置了按钮尺寸 -->
<el-button size="small" @click="selectDialogVisible = false"> </el-button> <el-button size="small" @click="selectDialogVisible = false"> </el-button>
<!-- 确定按钮点击可触发确认选择商品的相关逻辑设置了按钮类型为主要按钮尺寸为小尺寸 -->
<el-button size="small" type="primary" @click="handleSelectDialogConfirm()"> </el-button> <el-button size="small" type="primary" @click="handleSelectDialogConfirm()"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
<!-- 弹出对话框组件用于编辑秒杀商品信息操作设置了标题对话框显示状态的双向绑定以及宽度属性 -->
<el-dialog title="编辑秒杀商品信息" <el-dialog title="编辑秒杀商品信息"
:visible.sync="editDialogVisible" :visible.sync="editDialogVisible"
width="40%"> width="40%">
<!-- 表单组件用于在对话框内展示和编辑秒杀商品的相关信息绑定了数据模型flashProductRelation设置了表单引用标签宽度和尺寸等属性 -->
<el-form :model="flashProductRelation" <el-form :model="flashProductRelation"
ref="flashProductRelationForm" ref="flashProductRelationForm"
label-width="150px" size="small"> label-width="150px" size="small">
<!-- 对应商品名称展示的表单项此处直接展示商品名称不可编辑 -->
<el-form-item label="商品名称:"> <el-form-item label="商品名称:">
<span>{{flashProductRelation.product.name}}</span> <span>{{flashProductRelation.product.name}}</span>
</el-form-item> </el-form-item>
<!-- 对应货号展示的表单项此处直接展示货号不可编辑 -->
<el-form-item label="货号:"> <el-form-item label="货号:">
<span>NO.{{flashProductRelation.product.productSn}}</span> <span>NO.{{flashProductRelation.product.productSn}}</span>
</el-form-item> </el-form-item>
<!-- 对应商品价格展示的表单项此处直接展示商品价格不可编辑 -->
<el-form-item label="商品价格:"> <el-form-item label="商品价格:">
<span>{{flashProductRelation.product.price}}</span> <span>{{flashProductRelation.product.price}}</span>
</el-form-item> </el-form-item>
<!-- 对应秒杀价格输入框的表单项使用输入框组件双向绑定flashProductRelation.flashPromotionPrice数据设置了类名并在输入框头部添加符号 -->
<el-form-item label="秒杀价格:"> <el-form-item label="秒杀价格:">
<el-input v-model="flashProductRelation.flashPromotionPrice" class="input-width"> <el-input v-model="flashProductRelation.flashPromotionPrice" class="input-width">
<template slot="prepend"></template> <template slot="prepend"></template>
</el-input> </el-input>
</el-form-item> </el-form-item>
<!-- 对应剩余数量展示的表单项此处直接展示剩余数量不可编辑 -->
<el-form-item label="剩余数量:"> <el-form-item label="剩余数量:">
<span>{{flashProductRelation.product.stock}}</span> <span>{{flashProductRelation.product.stock}}</span>
</el-form-item> </el-form-item>
<!-- 对应秒杀数量输入框的表单项使用输入框组件双向绑定flashProductRelation.flashPromotionCount数据设置了类名 -->
<el-form-item label="秒杀数量:"> <el-form-item label="秒杀数量:">
<el-input v-model="flashProductRelation.flashPromotionCount" class="input-width"></el-input> <el-input v-model="flashProductRelation.flashPromotionCount" class="input-width"></el-input>
</el-form-item> </el-form-item>
<!-- 对应限购数量输入框的表单项使用输入框组件双向绑定flashProductRelation.flashPromotionLimit数据设置了类名 -->
<el-form-item label="限购数量:"> <el-form-item label="限购数量:">
<el-input v-model="flashProductRelation.flashPromotionLimit" class="input-width"></el-input> <el-input v-model="flashProductRelation.flashPromotionLimit" class="input-width"></el-input>
</el-form-item> </el-form-item>
<!-- 对应排序输入框的表单项使用输入框组件双向绑定flashProductRelation.sort数据设置了类名 -->
<el-form-item label="排序:"> <el-form-item label="排序:">
<el-input v-model="flashProductRelation.sort" class="input-width"></el-input> <el-input v-model="flashProductRelation.sort" class="input-width"></el-input>
</el-form-item> </el-form-item>
</el-form> </el-form>
<!-- 对话框底部的操作按钮区域使用了插槽footer -->
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<!-- 取消按钮点击可关闭对话框设置了按钮尺寸 -->
<el-button @click="editDialogVisible = false" size="small"> </el-button> <el-button @click="editDialogVisible = false" size="small"> </el-button>
<!-- 确定按钮点击可触发确认编辑秒杀商品信息的相关逻辑设置了按钮类型为主要按钮尺寸为小尺寸 -->
<el-button type="primary" @click="handleEditDialogConfirm()" size="small"> </el-button> <el-button type="primary" @click="handleEditDialogConfirm()" size="small"> </el-button>
</span> </span>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
<script> <script>
// '@/api/flashProductRelation'
import {fetchList,createFlashProductRelation,deleteFlashProductRelation,updateFlashProductRelation} from '@/api/flashProductRelation'; import {fetchList,createFlashProductRelation,deleteFlashProductRelation,updateFlashProductRelation} from '@/api/flashProductRelation';
// '@/api/product''fetchProductList'
import {fetchList as fetchProductList} from '@/api/product'; import {fetchList as fetchProductList} from '@/api/product';
// IDID
const defaultListQuery = { const defaultListQuery = {
pageNum: 1, pageNum: 1,
pageSize: 5, pageSize: 5,
flashPromotionId: null, flashPromotionId: null,
flashPromotionSessionId: null flashPromotionSessionId: null
}; };
export default { export default {
name:'flashPromotionProductRelationList', name:'flashPromotionProductRelationList',
data() { data() {
return { return {
// defaultListQuery
listQuery: Object.assign({}, defaultListQuery), listQuery: Object.assign({}, defaultListQuery),
// null
list: null, list: null,
// null
total: null, total: null,
// falsetrue
listLoading: false, listLoading: false,
// /false
dialogVisible: false, dialogVisible: false,
// false
selectDialogVisible:false, selectDialogVisible:false,
//
dialogData:{ dialogData:{
list: null, list: null,
total: null, total: null,
@ -270,90 +174,75 @@ export default {
pageSize: 5 pageSize: 5
} }
}, },
// false
editDialogVisible:false, editDialogVisible:false,
//
flashProductRelation:{ flashProductRelation:{
product:{} product:{}
} }
} }
}, },
created(){ created(){
// ID
this.listQuery.flashPromotionId=this.$route.query.flashPromotionId; this.listQuery.flashPromotionId=this.$route.query.flashPromotionId;
// ID
this.listQuery.flashPromotionSessionId=this.$route.query.flashPromotionSessionId; this.listQuery.flashPromotionSessionId=this.$route.query.flashPromotionSessionId;
//
this.getList(); this.getList();
}, },
methods:{ methods:{
//
handleSizeChange(val) { handleSizeChange(val) {
this.listQuery.pageNum = 1; //1 this.listQuery.pageNum = 1;
this.listQuery.pageSize = val; this.listQuery.pageSize = val;
this.getList(); // this.getList();
}, },
//
handleCurrentChange(val) { handleCurrentChange(val) {
this.listQuery.pageNum = val; this.listQuery.pageNum = val;
this.getList(); // this.getList();
}, },
//
handleSelectProduct(){ handleSelectProduct(){
this.selectDialogVisible = true; //true this.selectDialogVisible=true;
this.getDialogList(); // this.getDialogList();
}, },
//
handleUpdate(index,row){ handleUpdate(index,row){
this.editDialogVisible = true; //true this.editDialogVisible = true;
this.flashProductRelation = Object.assign({}, row); //便 this.flashProductRelation = Object.assign({},row);
}, },
//
handleDelete(index,row){ handleDelete(index,row){
this.$confirm('是否要删除该商品?', '提示', { this.$confirm('是否要删除该商品?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { // }).then(() => {
deleteFlashProductRelation(row.id).then(response => { deleteFlashProductRelation(row.id).then(response => {
this.$message({ this.$message({
type: 'success', type: 'success',
message: '删除成功!' message: '删除成功!'
}); });
this.getList(); // this.getList();
}); });
}); });
}, },
//
handleSelectSearch(){ handleSelectSearch(){
this.getDialogList(); // this.getDialogList();
}, },
//
handleDialogSizeChange(val) { handleDialogSizeChange(val) {
this.dialogData.listQuery.pageNum = 1; //1 this.dialogData.listQuery.pageNum = 1;
this.dialogData.listQuery.pageSize = val; // this.dialogData.listQuery.pageSize = val;
this.getDialogList(); // this.getDialogList();
}, },
//
handleDialogCurrentChange(val) { handleDialogCurrentChange(val) {
this.dialogData.listQuery.pageNum = val; // this.dialogData.listQuery.pageNum = val;
this.getDialogList(); // this.getDialogList();
}, },
//
handleDialogSelectionChange(val){ handleDialogSelectionChange(val){
this.dialogData.multipleSelection = val; // this.dialogData.multipleSelection = val;
}, },
//
handleSelectDialogConfirm(){ handleSelectDialogConfirm(){
if (this.dialogData.multipleSelection.length < 1) { // if (this.dialogData.multipleSelection < 1) {
this.$message({ this.$message({
message: '请选择一条记录', // message: '请选择一条记录',
type: 'warning', type: 'warning',
duration: 1000 duration: 1000
}); });
return; return;
} }
let selectProducts = []; // let selectProducts = [];
for (let i = 0; i < this.dialogData.multipleSelection.length; i++) { for (let i = 0; i < this.dialogData.multipleSelection.length; i++) {
selectProducts.push({ selectProducts.push({
productId:this.dialogData.multipleSelection[i].id, productId:this.dialogData.multipleSelection[i].id,
@ -361,32 +250,31 @@ export default {
flashPromotionSessionId:this.listQuery.flashPromotionSessionId flashPromotionSessionId:this.listQuery.flashPromotionSessionId
}); });
} }
this.$confirm('是否要进行添加操作?', '提示', { // this.$confirm('使用要进行添加操作?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { // }).then(() => {
createFlashProductRelation(selectProducts).then(response=>{ createFlashProductRelation(selectProducts).then(response=>{
this.selectDialogVisible=false; this.selectDialogVisible=false;
this.dialogData.multipleSelection=[]; this.dialogData.multipleSelection=[];
this.getList(); this.getList();
this.$message({ this.$message({
type: 'success', type: 'success',
message: '添加成功!' // message: '添加成功!'
}); });
}); });
}); });
}, },
//
handleEditDialogConfirm(){ handleEditDialogConfirm(){
this.$confirm('是否要确认?', '提示', { // this.$confirm('是否要确认?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { // }).then(() => {
updateFlashProductRelation(this.flashProductRelation.id,this.flashProductRelation).then(response => { updateFlashProductRelation(this.flashProductRelation.id,this.flashProductRelation).then(response => {
this.$message({ this.$message({
message: '修改成功!', // message: '修改成功!',
type: 'success' type: 'success'
}); });
this.editDialogVisible =false; this.editDialogVisible =false;
@ -394,19 +282,17 @@ export default {
}) })
}) })
}, },
//
getList() { getList() {
this.listLoading = true; //true this.listLoading = true;
fetchList(this.listQuery).then(response => { // fetchList(this.listQuery).then(response => {
this.listLoading = false; //false this.listLoading = false;
this.list = response.data.list; // this.list = response.data.list;
this.total = response.data.total; this.total = response.data.total;
}); });
}, },
//
getDialogList(){ getDialogList(){
fetchProductList(this.dialogData.listQuery).then(response => { // fetchProductList(this.dialogData.listQuery).then(response=>{
this.dialogData.list = response.data.list; // this.dialogData.list=response.data.list;
this.dialogData.total=response.data.total; this.dialogData.total=response.data.total;
}) })
} }
@ -414,15 +300,10 @@ export default {
} }
</script> </script>
<style scoped> <style scoped>
<!-- 使用带有scoped属性的style标签表示这里定义的样式仅作用于当前组件内的元素避免样式污染其他组件 -->
<!-- 定义类名为operate-container的样式规则 -->
.operate-container{ .operate-container{
<!-- 设置该类所应用元素的上外边距为0用于控制其与上方元素的间距 -->
margin-top: 0; margin-top: 0;
} }
<!-- 定义类名为input-width的样式规则 -->
.input-width{ .input-width{
<!-- 设置该类所应用元素的宽度为200px通常可用于像输入框等需要统一宽度设置的表单元素 -->
width: 200px; width: 200px;
} }
</style> </style>

@ -1,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,54 +37,37 @@
</div> </div>
</template> </template>
<script> <script>
// '@/api/flashSession'fetchSelectList
import {fetchSelectList} from '@/api/flashSession'; import {fetchSelectList} from '@/api/flashSession';
// '@/utils/date'formatDate
import {formatDate} from '@/utils/date'; import {formatDate} from '@/utils/date';
export default { export default {
name: 'selectSessionList', name: 'selectSessionList',
data() { data() {
return { return {
// null
list: null, list: null,
// falsetruefalse
listLoading: false listLoading: false
} }
}, },
created() { created() {
//
this.getList(); this.getList();
}, },
filters:{ filters:{
// formatTime
formatTime(time) { formatTime(time) {
// null 'N/A'
if (time == null || time === '') { if (time == null || time === '') {
return 'N/A'; return 'N/A';
} }
// JavaScriptDate便使
let date = new Date(time); let date = new Date(time);
// formatDate 'hh:mm:ss' Date
return formatDate(date, 'hh:mm:ss') return formatDate(date, 'hh:mm:ss')
} }
}, },
methods: { methods: {
//
handleShowRelation(index,row){ handleShowRelation(index,row){
// 使Vue Router '/sms/flashProductRelation'
this.$router.push({path:'/sms/flashProductRelation',query:{ this.$router.push({path:'/sms/flashProductRelation',query:{
flashPromotionId: this.$route.query.flashPromotionId, flashPromotionSessionId: row.id}}) //IDflashPromotionIdIDflashPromotionSessionIdID flashPromotionId:this.$route.query.flashPromotionId, flashPromotionSessionId:row.id}})
}, },
//
getList() { getList() {
// true
this.listLoading = true; this.listLoading = true;
// fetchSelectListIDIDthen
fetchSelectList({flashPromotionId:this.$route.query.flashPromotionId}).then(response => { fetchSelectList({flashPromotionId:this.$route.query.flashPromotionId}).then(response => {
// false
this.listLoading = false; this.listLoading = false;
// list便
this.list = response.data; this.list = response.data;
}); });
} }
@ -121,10 +75,7 @@ export default {
} }
</script> </script>
<style scoped> <style scoped>
<!-- scoped属性表示该样式作用范围仅限于当前组件内的元素避免样式影响到其他组件中的同名元素起到样式隔离的作用 -->
.operate-container { .operate-container {
<!-- 这是一个CSS样式规则针对类名为operate-container的元素进行样式设置 -->
<!-- margin-top属性用于设置元素的上外边距这里将其值设置为0意味着该元素距离上方相邻元素的间距为0可用于精准控制元素在页面中的垂直布局位置 -->
margin-top: 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,115 +46,82 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
</div> </div>
<!-- el-dialog组件用于创建一个弹出式对话框常用于展示表单让用户输入信息或者进行确认等操作设置了对话框的标题为"添加时间段"通过":visible.sync"双向绑定了对话框的显示状态与组件data中的dialogVisible属性相关联改变该属性值可控制对话框的显示与隐藏设置了对话框的宽度为40%相对于屏幕宽度等的占比用于控制对话框大小 -->
<el-dialog <el-dialog
title="添加时间段" title="添加时间段"
:visible.sync="dialogVisible" :visible.sync="dialogVisible"
width="40%"> width="40%">
<!-- el-form组件用于创建一个表单绑定了数据模型"flashSession"这个对象应该在组件的data属性中定义用于存储表单中输入的数据等设置了表单引用为"flashSessionForm"可用于后续对表单进行验证等操作时的标识设置了标签宽度为150像素表单整体尺寸为"small"小型尺寸用于统一表单元素的外观大小等风格 -->
<el-form :model="flashSession" <el-form :model="flashSession"
ref="flashSessionForm" ref="flashSessionForm"
label-width="150px" size="small"> label-width="150px" size="small">
<!-- el-form-item组件用于定义表单中的表单项此表单项对应的标签为"秒杀时间段名称:"用于提示用户此处应输入的内容 -->
<el-form-item label="秒杀时间段名称:"> <el-form-item label="秒杀时间段名称:">
<!-- el-input组件用于创建一个输入框双向绑定了"flashSession.name"数据意味着用户在输入框中输入的内容会实时更新到"flashSession"对象的"name"属性中设置了输入框的宽度为250像素 -->
<el-input v-model="flashSession.name" style="width: 250px"></el-input> <el-input v-model="flashSession.name" style="width: 250px"></el-input>
</el-form-item> </el-form-item>
<!-- el-form-item组件用于定义表单中的表单项此表单项对应的标签为"每日开始时间:"用于提示用户此处应选择时间 -->
<el-form-item label="每日开始时间:"> <el-form-item label="每日开始时间:">
<!-- el-time-picker组件用于创建一个时间选择器用户可以通过它选择具体的时间双向绑定了"flashSession.startTime"数据选择的时间会更新到"flashSession"对象的"startTime"属性中设置了占位提示文字为"请选择时间" -->
<el-time-picker <el-time-picker
v-model="flashSession.startTime" v-model="flashSession.startTime"
placeholder="请选择时间"> placeholder="请选择时间">
</el-time-picker> </el-time-picker>
</el-form-item> </el-form-item>
<!-- el-form-item组件用于定义表单中的表单项此表单项对应的标签为"每日结束时间:"用于提示用户此处应选择时间 -->
<el-form-item label="每日结束时间:"> <el-form-item label="每日结束时间:">
<!-- el-time-picker组件用于创建一个时间选择器用户可以通过它选择具体的时间双向绑定了"flashSession.endTime"数据选择的时间会更新到"flashSession"对象的"endTime"属性中设置了占位提示文字为"请选择时间" -->
<el-time-picker <el-time-picker
v-model="flashSession.endTime" v-model="flashSession.endTime"
placeholder="请选择时间"> placeholder="请选择时间">
</el-time-picker> </el-time-picker>
</el-form-item> </el-form-item>
<!-- el-form-item组件用于定义表单中的表单项此表单项对应的标签为"是否启用"用于让用户选择该时间段是否启用 -->
<el-form-item label="是否启用"> <el-form-item label="是否启用">
<!-- el-radio-group组件用于创建一个单选按钮组绑定了"flashSession.status"数据意味着用户选择的单选按钮的值会更新到"flashSession"对象的"status"属性中 -->
<el-radio-group v-model="flashSession.status"> <el-radio-group v-model="flashSession.status">
<!-- el-radio组件用于创建一个单选按钮设置了按钮的标签值为1对应的显示文字为"启用"用户选择该按钮后会将"flashSession.status"的值设为1 -->
<el-radio :label="1">启用</el-radio> <el-radio :label="1">启用</el-radio>
<!-- el-radio组件用于创建一个单选按钮设置了按钮的标签值为0对应的显示文字为"不启用"用户选择该按钮后会将"flashSession.status"的值设为0 -->
<el-radio :label="0">不启用</el-radio> <el-radio :label="0">不启用</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
</el-form> </el-form>
<!-- 对话框底部的操作按钮区域使用了插槽"footer"来定义通常用于放置确认取消等按钮 -->
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<!-- el-button组件用于创建一个按钮点击事件绑定了将"dialogVisible"属性设为false的操作即关闭对话框设置了按钮尺寸为"small"小型按钮按钮显示的文字为"取 消" -->
<el-button @click="dialogVisible = false" size="small"> </el-button> <el-button @click="dialogVisible = false" size="small"> </el-button>
<!-- el-button组件用于创建一个按钮设置了按钮类型为"primary"主要按钮通常会有突出的样式比如颜色与其他按钮不同等点击事件绑定了"handleDialogConfirm"方法这个方法应该在组件的methods选项中定义用于处理确认添加等相关逻辑设置了按钮尺寸为"small"小型按钮按钮显示的文字为"确 定" -->
<el-button type="primary" @click="handleDialogConfirm()" size="small"> </el-button> <el-button type="primary" @click="handleDialogConfirm()" size="small"> </el-button>
</span> </span>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
<script> <script>
// '@/api/flashSession'API
import {fetchList,updateStatus,deleteSession,createSession,updateSession} from '@/api/flashSession'; import {fetchList,updateStatus,deleteSession,createSession,updateSession} from '@/api/flashSession';
// '@/utils/date'formatDate使
import {formatDate} from '@/utils/date'; import {formatDate} from '@/utils/date';
const defaultFlashSession={
//
const defaultFlashSession = { //
name:null, name:null,
startTime:null, startTime:null,
endTime:null, endTime:null,
status: 0 // status:0
}; };
export default { export default {
name: 'flashPromotionSessionList', name: 'flashPromotionSessionList',
data() { data() {
return { return {
// null便
list: null, list: null,
// falsetruefalse
listLoading: false, listLoading: false,
// /false
dialogVisible:false, dialogVisible:false,
// truefalsefalse便
isEdit:false, isEdit:false,
// defaultFlashSession
flashSession:Object.assign({},defaultFlashSession) flashSession:Object.assign({},defaultFlashSession)
} }
}, },
created() { created() {
// 使
this.getList(); this.getList();
}, },
filters:{ filters:{
// formatTime便
formatTime(time) { formatTime(time) {
// null 'N/A'
if (time == null || time === '') { if (time == null || time === '') {
return 'N/A'; return 'N/A';
} }
// JavaScriptDate便使formatDateDate便
let date = new Date(time); let date = new Date(time);
// formatDate 'hh:mm:ss' Date "12:30:00"
return formatDate(date, 'hh:mm:ss') return formatDate(date, 'hh:mm:ss')
} }
}, },
methods: { methods: {
//
handleAdd() { handleAdd() {
this.dialogVisible = true; //true this.dialogVisible = true;
this.isEdit = false; this.isEdit = false;
this.flashSession = Object.assign({}, defaultFlashSession); // this.flashSession = Object.assign({},defaultFlashSession);
}, },
// /
handleStatusChange(index,row){ handleStatusChange(index,row){
this.$confirm('是否要修改该状态?', '提示', { // this.$confirm('是否要修改该状态?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
@ -191,48 +129,45 @@ export default {
updateStatus(row.id, {status: row.status}).then(response => { updateStatus(row.id, {status: row.status}).then(response => {
this.$message({ this.$message({
type: 'success', type: 'success',
message: '修改成功!' // message: '修改成功!'
}); });
}); });
}).catch(() => { // }).catch(() => {
this.$message({ this.$message({
type: 'info', type: 'info',
message: '取消修改' message: '取消修改'
}); });
this.getList(); // this.getList();
}); });
}, },
// .
handleUpdate(index,row){ handleUpdate(index,row){
this.dialogVisible = true; //true this.dialogVisible = true;
this.isEdit = true; // this.isEdit = true;
this.flashSession = Object.assign({},row); this.flashSession = Object.assign({},row);
this.flashSession.startTime = new Date(row.startTime); //Date便便 this.flashSession.startTime=new Date(row.startTime);
this.flashSession.endTime=new Date(row.endTime); this.flashSession.endTime=new Date(row.endTime);
}, },
// .
handleDelete(index,row){ handleDelete(index,row){
this.$confirm('是否要删除该时间段?', '提示', { // this.$confirm('是否要删除该时间段?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { // }).then(() => {
deleteSession(row.id).then(response => { deleteSession(row.id).then(response => {
this.$message({ this.$message({
type: 'success', type: 'success',
message: '删除成功!' // message: '删除成功!'
}); });
this.getList(); //使 this.getList();
}); });
}); });
}, },
// .
handleDialogConfirm() { handleDialogConfirm() {
this.$confirm('是否要确认?', '提示', { // this.$confirm('是否要确认?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { // }).then(() => {
if (this.isEdit) { if (this.isEdit) {
updateSession(this.flashSession.id,this.flashSession).then(response => { updateSession(this.flashSession.id,this.flashSession).then(response => {
this.$message({ this.$message({
@ -245,31 +180,27 @@ export default {
} else { } else {
createSession(this.flashSession).then(response => { createSession(this.flashSession).then(response => {
this.$message({ this.$message({
message: '添加成功!', // message: '添加成功!',
type: 'success' type: 'success'
}); });
this.dialogVisible =false; this.dialogVisible =false;
this.getList(); // this.getList();
}) })
} }
}) })
}, },
//
getList() { getList() {
this.listLoading = true; //true this.listLoading = true;
fetchList({}).then(response => { //fetchList fetchList({}).then(response => {
this.listLoading = false; //false this.listLoading = false;
this.list = response.data; //list this.list = response.data;
}); });
} }
} }
} }
</script> </script>
<style scoped> <style scoped>
<!-- scoped属性表示当前这个style标签内定义的样式作用范围仅限于当前组件内部避免样式影响到其他组件中同名的类或元素起到样式隔离的作用使得样式管理更加清晰和模块化 -->
.operate-container { .operate-container {
<!-- 这是一个CSS选择器用于选中页面中所有应用了operate-container类名的元素接下来在花括号内定义的样式规则就会应用到这些被选中的元素上 -->
<!-- margin-top是CSS的一个属性用于设置元素的上外边距也就是该元素距离其上方相邻元素的间隔距离这里将其值设置为0意味着应用了operate-container类名的元素其上外边距为0像素能精准控制这类元素在页面垂直方向上的布局位置使其更贴合设计需求 -->
margin-top: 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,48 +149,36 @@
</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';
// '@/api/product'fetchListfetchProductList
import {fetchList as fetchProductList} from '@/api/product'; 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: '未推荐', label: '未推荐',
@ -240,26 +189,16 @@ const defaultRecommendOptions = [
value: 1 value: 1
} }
]; ];
// Vue
export default { export default {
//
name: 'hotProductList', name: 'hotProductList',
data() { data() {
return { return {
// defaultListQuery
listQuery: Object.assign({}, defaultListQuery), listQuery: Object.assign({}, defaultListQuery),
// defaultRecommendOptions
recommendOptions: Object.assign({}, defaultRecommendOptions), recommendOptions: Object.assign({}, defaultRecommendOptions),
// null
list: null, list: null,
// null
total: null, total: null,
// truefalse
listLoading: false, listLoading: false,
//
multipleSelection: [], multipleSelection: [],
//
operates: [ operates: [
{ {
label: "设为推荐", label: "设为推荐",
@ -274,11 +213,8 @@ export default {
value: 2 value: 2
} }
], ],
// null
operateType: null, operateType: null,
// falsetrue
selectDialogVisible:false, selectDialogVisible:false,
//
dialogData:{ dialogData:{
list: null, list: null,
total: null, total: null,
@ -289,17 +225,13 @@ export default {
pageSize: 5 pageSize: 5
} }
}, },
//
sortDialogVisible:false, sortDialogVisible:false,
// id
sortDialogData:{sort:0,id:null} sortDialogData:{sort:0,id:null}
} }
}, },
//
created() { created() {
this.getList(); this.getList();
}, },
// 1
filters:{ filters:{
formatRecommendStatus(status){ formatRecommendStatus(status){
if(status===1){ if(status===1){
@ -310,39 +242,31 @@ export default {
} }
}, },
methods: { methods: {
//
handleResetSearch() { handleResetSearch() {
this.listQuery = Object.assign({}, defaultListQuery); this.listQuery = Object.assign({}, defaultListQuery);
}, },
// 1
handleSearchList() { handleSearchList() {
this.listQuery.pageNum = 1; this.listQuery.pageNum = 1;
this.getList(); this.getList();
}, },
//
handleSelectionChange(val){ handleSelectionChange(val){
this.multipleSelection = val; this.multipleSelection = val;
}, },
// 1
handleSizeChange(val) { handleSizeChange(val) {
this.listQuery.pageNum = 1; this.listQuery.pageNum = 1;
this.listQuery.pageSize = val; this.listQuery.pageSize = val;
this.getList(); this.getList();
}, },
//
handleCurrentChange(val) { handleCurrentChange(val) {
this.listQuery.pageNum = val; this.listQuery.pageNum = val;
this.getList(); this.getList();
}, },
// id
handleRecommendStatusStatusChange(index,row){ handleRecommendStatusStatusChange(index,row){
this.updateRecommendStatusStatus(row.id,row.recommendStatus); this.updateRecommendStatusStatus(row.id,row.recommendStatus);
}, },
// id
handleDelete(index,row){ handleDelete(index,row){
this.deleteProduct(row.id); this.deleteProduct(row.id);
}, },
//
handleBatchOperate(){ handleBatchOperate(){
if (this.multipleSelection < 1) { if (this.multipleSelection < 1) {
this.$message({ this.$message({
@ -352,7 +276,7 @@ export default {
}); });
return; return;
} }
let ids = []; // let ids = [];
for (let i = 0; i < this.multipleSelection.length; i++) { for (let i = 0; i < this.multipleSelection.length; i++) {
ids.push(this.multipleSelection[i].id); ids.push(this.multipleSelection[i].id);
} }
@ -366,38 +290,32 @@ export default {
// //
this.deleteProduct(ids); this.deleteProduct(ids);
}else { }else {
this.$message({ // this.$message({
message: '请选择批量操作类型', message: '请选择批量操作类型',
type: 'warning', type: 'warning',
duration: 1000 duration: 1000
}); });
} }
}, },
//
handleSelectProduct(){ handleSelectProduct(){
this.selectDialogVisible=true; this.selectDialogVisible=true;
this.getDialogList(); this.getDialogList();
}, },
//
handleSelectSearch(){ handleSelectSearch(){
this.getDialogList(); this.getDialogList();
}, },
// 1
handleDialogSizeChange(val) { handleDialogSizeChange(val) {
this.dialogData.listQuery.pageNum = 1; this.dialogData.listQuery.pageNum = 1;
this.dialogData.listQuery.pageSize = val; this.dialogData.listQuery.pageSize = val;
this.getDialogList(); this.getDialogList();
}, },
//
handleDialogCurrentChange(val) { handleDialogCurrentChange(val) {
this.dialogData.listQuery.pageNum = val; this.dialogData.listQuery.pageNum = val;
this.getDialogList(); this.getDialogList();
}, },
//
handleDialogSelectionChange(val){ handleDialogSelectionChange(val){
this.dialogData.multipleSelection = val; this.dialogData.multipleSelection = val;
}, },
//
handleSelectDialogConfirm(){ handleSelectDialogConfirm(){
if (this.dialogData.multipleSelection < 1) { if (this.dialogData.multipleSelection < 1) {
this.$message({ this.$message({
@ -418,7 +336,7 @@ export default {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { // }).then(() => {
createHotProduct(selectProducts).then(response=>{ createHotProduct(selectProducts).then(response=>{
this.selectDialogVisible=false; this.selectDialogVisible=false;
this.dialogData.multipleSelection=[]; this.dialogData.multipleSelection=[];
@ -430,19 +348,17 @@ export default {
}); });
}); });
}, },
//
handleEditSort(index,row){ handleEditSort(index,row){
this.sortDialogVisible=true; this.sortDialogVisible=true;
this.sortDialogData.sort = row.sort; //id this.sortDialogData.sort=row.sort;
this.sortDialogData.id=row.id; this.sortDialogData.id=row.id;
}, },
// handleUpdateSort(){
handleUpdateSort() { //
this.$confirm('是否要修改排序?', '提示', { this.$confirm('是否要修改排序?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { // }).then(() => {
updateHotProductSort(this.sortDialogData).then(response=>{ updateHotProductSort(this.sortDialogData).then(response=>{
this.sortDialogVisible=false; this.sortDialogVisible=false;
this.getList(); this.getList();
@ -453,62 +369,58 @@ export default {
}); });
}) })
}, },
//
getList() { getList() {
this.listLoading = true; this.listLoading = true;
fetchList(this.listQuery).then(response => { //fetchList fetchList(this.listQuery).then(response => {
this.listLoading = false; this.listLoading = false;
this.list = response.data.list; // this.list = response.data.list;
this.total = response.data.total; this.total = response.data.total;
}) })
}, },
//
updateRecommendStatusStatus(ids,status){ updateRecommendStatusStatus(ids,status){
this.$confirm('是否要修改推荐状态?', '提示', { // this.$confirm('是否要修改推荐状态?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
let params = new URLSearchParams(); //idURLSearchParams let params=new URLSearchParams();
params.append("ids",ids); params.append("ids",ids);
params.append("recommendStatus",status); params.append("recommendStatus",status);
updateRecommendStatus(params).then(response => { //updateRecommendStatus updateRecommendStatus(params).then(response=>{
this.getList(); this.getList();
this.$message({ this.$message({
type: 'success', type: 'success',
message: '修改成功!' // message: '修改成功!'
}); });
}); });
}).catch(() => { }).catch(() => {
this.$message({ this.$message({
type: 'success', type: 'success',
message: '已取消操作!' // message: '已取消操作!'
}); });
this.getList(); this.getList();
}); });
}, },
//
deleteProduct(ids){ deleteProduct(ids){
this.$confirm('是否要删除该推荐?', '提示', { // this.$confirm('是否要删除该推荐?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
let params = new URLSearchParams(); //idURLSearchParams let params=new URLSearchParams();
params.append("ids",ids); params.append("ids",ids);
deleteHotProduct(params).then(response => { //deleteHotProduct deleteHotProduct(params).then(response=>{
this.getList(); this.getList();
this.$message({ this.$message({
type: 'success', type: 'success',
message: '删除成功!' // message: '删除成功!'
}); });
}); });
}) })
}, },
//
getDialogList(){ getDialogList(){
fetchProductList(this.dialogData.listQuery).then(response => { //fetchProductList fetchProductList(this.dialogData.listQuery).then(response=>{
this.dialogData.list = response.data.list; // this.dialogData.list=response.data.list;
this.dialogData.total=response.data.total; this.dialogData.total=response.data.total;
}) })
} }

@ -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,48 +149,36 @@
</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';
// '@/api/product'fetchListfetchProductList
import {fetchList as fetchProductList} from '@/api/product'; 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
}; };
// ''0
const defaultRecommendOptions = [ const defaultRecommendOptions = [
{ {
label: '未推荐', label: '未推荐',
@ -244,24 +189,16 @@ const defaultRecommendOptions = [
value: 1 value: 1
} }
]; ];
export default { export default {
name: 'newProductList', name: 'newProductList',
data() { data() {
return { return {
// defaultListQuery
listQuery: Object.assign({}, defaultListQuery), listQuery: Object.assign({}, defaultListQuery),
// defaultRecommendOptions
recommendOptions: Object.assign({}, defaultRecommendOptions), recommendOptions: Object.assign({}, defaultRecommendOptions),
// null
list: null, list: null,
// null
total: null, total: null,
// false
listLoading: false, listLoading: false,
//
multipleSelection: [], multipleSelection: [],
// ''0
operates: [ operates: [
{ {
label: "设为推荐", label: "设为推荐",
@ -276,40 +213,28 @@ export default {
value: 2 value: 2
} }
], ],
// null
operateType: null, operateType: null,
// false
selectDialogVisible:false, selectDialogVisible:false,
dialogData:{ dialogData:{
// null
list: null, list: null,
// null
total: null, total: null,
//
multipleSelection:[], multipleSelection:[],
listQuery:{ listQuery:{
// null
keyword: null, keyword: null,
// 1
pageNum: 1, pageNum: 1,
// 5
pageSize: 5 pageSize: 5
} }
}, },
// false
sortDialogVisible:false, sortDialogVisible:false,
// id
sortDialogData:{sort:0,id:null} sortDialogData:{sort:0,id:null}
} }
}, },
created() { created() {
// getList
this.getList(); this.getList();
}, },
filters:{ filters:{
// formatRecommendStatus
formatRecommendStatus(status){ formatRecommendStatus(status){
if(status===1){ //10'''' if(status===1){
return '推荐中'; return '推荐中';
}else{ }else{
return '未推荐'; return '未推荐';
@ -317,39 +242,31 @@ export default {
} }
}, },
methods: { methods: {
// defaultListQuery
handleResetSearch() { handleResetSearch() {
this.listQuery = Object.assign({}, defaultListQuery); this.listQuery = Object.assign({}, defaultListQuery);
}, },
// 1getList
handleSearchList() { handleSearchList() {
this.listQuery.pageNum = 1; this.listQuery.pageNum = 1;
this.getList(); this.getList();
}, },
// multipleSelection
handleSelectionChange(val){ handleSelectionChange(val){
this.multipleSelection = val; this.multipleSelection = val;
}, },
// 1getList
handleSizeChange(val) { handleSizeChange(val) {
this.listQuery.pageNum = 1; this.listQuery.pageNum = 1;
this.listQuery.pageSize = val; this.listQuery.pageSize = val;
this.getList(); this.getList();
}, },
// getList
handleCurrentChange(val) { handleCurrentChange(val) {
this.listQuery.pageNum = val; this.listQuery.pageNum = val;
this.getList(); this.getList();
}, },
// updateRecommendStatusStatusid
handleRecommendStatusStatusChange(index,row){ handleRecommendStatusStatusChange(index,row){
this.updateRecommendStatusStatus(row.id,row.recommendStatus); this.updateRecommendStatusStatus(row.id,row.recommendStatus);
}, },
// deleteProductid
handleDelete(index,row){ handleDelete(index,row){
this.deleteProduct(row.id); this.deleteProduct(row.id);
}, },
//
handleBatchOperate(){ handleBatchOperate(){
if (this.multipleSelection < 1) { if (this.multipleSelection < 1) {
this.$message({ this.$message({
@ -359,7 +276,7 @@ export default {
}); });
return; return;
} }
let ids = []; // let ids = [];
for (let i = 0; i < this.multipleSelection.length; i++) { for (let i = 0; i < this.multipleSelection.length; i++) {
ids.push(this.multipleSelection[i].id); ids.push(this.multipleSelection[i].id);
} }
@ -380,31 +297,25 @@ export default {
}); });
} }
}, },
// getDialogList
handleSelectProduct(){ handleSelectProduct(){
this.selectDialogVisible=true; this.selectDialogVisible=true;
this.getDialogList(); this.getDialogList();
}, },
// getDialogList
handleSelectSearch(){ handleSelectSearch(){
this.getDialogList(); this.getDialogList();
}, },
// 1getDialogList
handleDialogSizeChange(val) { handleDialogSizeChange(val) {
this.dialogData.listQuery.pageNum = 1; this.dialogData.listQuery.pageNum = 1;
this.dialogData.listQuery.pageSize = val; this.dialogData.listQuery.pageSize = val;
this.getDialogList(); this.getDialogList();
}, },
// getDialogList
handleDialogCurrentChange(val) { handleDialogCurrentChange(val) {
this.dialogData.listQuery.pageNum = val; this.dialogData.listQuery.pageNum = val;
this.getDialogList(); this.getDialogList();
}, },
// dialogData.multipleSelection
handleDialogSelectionChange(val){ handleDialogSelectionChange(val){
this.dialogData.multipleSelection = val; this.dialogData.multipleSelection = val;
}, },
//
handleSelectDialogConfirm(){ handleSelectDialogConfirm(){
if (this.dialogData.multipleSelection < 1) { if (this.dialogData.multipleSelection < 1) {
this.$message({ this.$message({
@ -414,7 +325,7 @@ export default {
}); });
return; return;
} }
let selectProducts = []; // let selectProducts = [];
for (let i = 0; i < this.dialogData.multipleSelection.length; i++) { for (let i = 0; i < this.dialogData.multipleSelection.length; i++) {
selectProducts.push({ selectProducts.push({
productId:this.dialogData.multipleSelection[i].id, productId:this.dialogData.multipleSelection[i].id,
@ -426,10 +337,10 @@ export default {
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
createNewProduct(selectProducts).then(response=>{ //createNewProduct createNewProduct(selectProducts).then(response=>{
this.selectDialogVisible=false; this.selectDialogVisible=false;
this.dialogData.multipleSelection=[]; this.dialogData.multipleSelection=[];
this.getList(); // this.getList();
this.$message({ this.$message({
type: 'success', type: 'success',
message: '添加成功!' message: '添加成功!'
@ -437,22 +348,20 @@ export default {
}); });
}); });
}, },
//
handleEditSort(index,row){ handleEditSort(index,row){
this.sortDialogVisible=true; this.sortDialogVisible=true;
this.sortDialogData.sort=row.sort; this.sortDialogData.sort=row.sort;
this.sortDialogData.id=row.id; //id便 this.sortDialogData.id=row.id;
}, },
//
handleUpdateSort(){ handleUpdateSort(){
this.$confirm('是否要修改排序?', '提示', { // this.$confirm('是否要修改排序?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
updateNewProductSort(this.sortDialogData).then(response=>{ //updateNewProductSort updateNewProductSort(this.sortDialogData).then(response=>{
this.sortDialogVisible=false; this.sortDialogVisible=false;
this.getList(); // this.getList();
this.$message({ this.$message({
type: 'success', type: 'success',
message: '删除成功!' message: '删除成功!'
@ -460,51 +369,48 @@ export default {
}); });
}) })
}, },
//
getList() { getList() {
this.listLoading = true; //true this.listLoading = true;
fetchList(this.listQuery).then(response => { //fetchList fetchList(this.listQuery).then(response => {
this.listLoading = false; //false this.listLoading = false;
this.list = response.data.list; // this.list = response.data.list;
this.total = response.data.total; this.total = response.data.total;
}) })
}, },
//
updateRecommendStatusStatus(ids,status){ updateRecommendStatusStatus(ids,status){
this.$confirm('是否要修改推荐状态?', '提示', { // this.$confirm('是否要修改推荐状态?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
let params=new URLSearchParams(); //ididURLSearchParams let params=new URLSearchParams();
params.append("ids",ids); params.append("ids",ids);
params.append("recommendStatus",status); params.append("recommendStatus",status);
updateRecommendStatus(params).then(response=>{ //updateRecommendStatus updateRecommendStatus(params).then(response=>{
this.getList(); // this.getList();
this.$message({ this.$message({
type: 'success', type: 'success',
message: '修改成功!' message: '修改成功!'
}); });
}); });
}).catch(() => { }).catch(() => {
this.$message({ // this.$message({
type: 'success', type: 'success',
message: '已取消操作!' message: '已取消操作!'
}); });
this.getList(); this.getList();
}); });
}, },
//
deleteProduct(ids){ deleteProduct(ids){
this.$confirm('是否要删除该推荐?', '提示', { // this.$confirm('是否要删除该推荐?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
let params=new URLSearchParams(); //ididURLSearchParams let params=new URLSearchParams();
params.append("ids",ids); params.append("ids",ids);
deleteNewProduct(params).then(response=>{ //deleteNewProduct deleteNewProduct(params).then(response=>{
this.getList(); // this.getList();
this.$message({ this.$message({
type: 'success', type: 'success',
message: '删除成功!' message: '删除成功!'
@ -512,10 +418,9 @@ export default {
}); });
}) })
}, },
//
getDialogList(){ getDialogList(){
fetchProductList(this.dialogData.listQuery).then(response=>{ //fetchProductList fetchProductList(this.dialogData.listQuery).then(response=>{
this.dialogData.list=response.data.list; // this.dialogData.list=response.data.list;
this.dialogData.total=response.data.total; this.dialogData.total=response.data.total;
}) })
} }

@ -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,49 +149,37 @@
</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';
// '@/api/subject'fetchListfetchSubjectList
import {fetchList as fetchSubjectList} from '@/api/subject'; import {fetchList as fetchSubjectList} from '@/api/subject';
// '@/utils/date'formatDate
import {formatDate} from '@/utils/date'; 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: '未推荐', label: '未推荐',
@ -241,24 +190,16 @@ const defaultRecommendOptions = [
value: 1 value: 1
} }
]; ];
export default { export default {
name: 'homeSubjectList', name: 'homeSubjectList',
data() { data() {
return { return {
// defaultListQuery便
listQuery: Object.assign({}, defaultListQuery), listQuery: Object.assign({}, defaultListQuery),
// defaultRecommendOptions
recommendOptions: Object.assign({}, defaultRecommendOptions), recommendOptions: Object.assign({}, defaultRecommendOptions),
// null
list: null, list: null,
// null
total: null, total: null,
// truefalse
listLoading: false, listLoading: false,
//
multipleSelection: [], multipleSelection: [],
//
operates: [ operates: [
{ {
label: "设为推荐", label: "设为推荐",
@ -273,11 +214,8 @@ export default {
value: 2 value: 2
} }
], ],
// null
operateType: null, operateType: null,
// falsetrue
selectDialogVisible:false, selectDialogVisible:false,
//
dialogData:{ dialogData:{
list: null, list: null,
total: null, total: null,
@ -288,18 +226,14 @@ export default {
pageSize: 5 pageSize: 5
} }
}, },
// falsetrue
sortDialogVisible:false, sortDialogVisible:false,
// id
sortDialogData:{sort:0,id:null} sortDialogData:{sort:0,id:null}
} }
}, },
created() { created() {
// getList
this.getList(); this.getList();
}, },
filters:{ filters:{
// 1""""
formatRecommendStatus(status){ formatRecommendStatus(status){
if(status===1){ if(status===1){
return '推荐中'; return '推荐中';
@ -307,7 +241,6 @@ export default {
return '未推荐'; return '未推荐';
} }
}, },
// "N/A"
formatTime(time){ formatTime(time){
if(time==null||time===''){ if(time==null||time===''){
return 'N/A'; return 'N/A';
@ -317,42 +250,33 @@ export default {
}, },
}, },
methods: { methods: {
// defaultListQuery
handleResetSearch() { handleResetSearch() {
this.listQuery = Object.assign({}, defaultListQuery); this.listQuery = Object.assign({}, defaultListQuery);
}, },
// 1getList
handleSearchList() { handleSearchList() {
this.listQuery.pageNum = 1; this.listQuery.pageNum = 1;
this.getList(); this.getList();
}, },
// multipleSelection使
handleSelectionChange(val){ handleSelectionChange(val){
this.multipleSelection = val; this.multipleSelection = val;
}, },
// 1getList
handleSizeChange(val) { handleSizeChange(val) {
this.listQuery.pageNum = 1; this.listQuery.pageNum = 1;
this.listQuery.pageSize = val; this.listQuery.pageSize = val;
this.getList(); this.getList();
}, },
// getList
handleCurrentChange(val) { handleCurrentChange(val) {
this.listQuery.pageNum = val; this.listQuery.pageNum = val;
this.getList(); this.getList();
}, },
// updateRecommendStatusStatusid
handleRecommendStatusStatusChange(index,row){ handleRecommendStatusStatusChange(index,row){
this.updateRecommendStatusStatus(row.id,row.recommendStatus); this.updateRecommendStatusStatus(row.id,row.recommendStatus);
}, },
// deleteSubjectid
handleDelete(index,row){ handleDelete(index,row){
this.deleteSubject(row.id); this.deleteSubject(row.id);
}, },
//
//
handleBatchOperate(){ handleBatchOperate(){
if (this.multipleSelection < 1) { // if (this.multipleSelection < 1) {
this.$message({ this.$message({
message: '请选择一条记录', message: '请选择一条记录',
type: 'warning', type: 'warning',
@ -360,7 +284,7 @@ export default {
}); });
return; return;
} }
let ids = []; // let ids = [];
for (let i = 0; i < this.multipleSelection.length; i++) { for (let i = 0; i < this.multipleSelection.length; i++) {
ids.push(this.multipleSelection[i].id); ids.push(this.multipleSelection[i].id);
} }
@ -381,32 +305,26 @@ export default {
}); });
} }
}, },
//
handleSelectSubject(){ handleSelectSubject(){
this.selectDialogVisible=true; this.selectDialogVisible=true;
this.dialogData.listQuery.keyword=null; this.dialogData.listQuery.keyword=null;
this.getDialogList();//getDialogList this.getDialogList();
}, },
//
handleSelectSearch(){ handleSelectSearch(){
this.getDialogList(); //getDialogList this.getDialogList();
}, },
//
handleDialogSizeChange(val) { handleDialogSizeChange(val) {
this.dialogData.listQuery.pageNum = 1; //1 this.dialogData.listQuery.pageNum = 1;
this.dialogData.listQuery.pageSize = val; this.dialogData.listQuery.pageSize = val;
this.getDialogList(); //getDialogList this.getDialogList();
}, },
//
handleDialogCurrentChange(val) { handleDialogCurrentChange(val) {
this.dialogData.listQuery.pageNum = val; this.dialogData.listQuery.pageNum = val;
this.getDialogList(); //getDialogList this.getDialogList();
}, },
// 使
handleDialogSelectionChange(val){ handleDialogSelectionChange(val){
this.dialogData.multipleSelection = val; this.dialogData.multipleSelection = val;
}, },
//
handleSelectDialogConfirm(){ handleSelectDialogConfirm(){
if (this.dialogData.multipleSelection < 1) { if (this.dialogData.multipleSelection < 1) {
this.$message({ this.$message({
@ -428,7 +346,7 @@ export default {
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
createHomeSubject(selectSubjects).then(response => { //// createHomeSubject createHomeSubject(selectSubjects).then(response=>{
this.selectDialogVisible=false; this.selectDialogVisible=false;
this.dialogData.multipleSelection=[]; this.dialogData.multipleSelection=[];
this.getList(); this.getList();
@ -439,85 +357,79 @@ export default {
}); });
}); });
}, },
//
handleEditSort(index,row){ handleEditSort(index,row){
this.sortDialogVisible=true; this.sortDialogVisible=true;
this.sortDialogData.sort=row.sort; this.sortDialogData.sort=row.sort;
this.sortDialogData.id = row.id; //id this.sortDialogData.id=row.id;
}, },
//
handleUpdateSort(){ handleUpdateSort(){
this.$confirm('是否要修改排序?', '提示', { this.$confirm('是否要修改排序?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
updateHomeSubjectSort(this.sortDialogData).then(response => { //updateHomeSubjectSort updateHomeSubjectSort(this.sortDialogData).then(response=>{
this.sortDialogVisible=false; this.sortDialogVisible=false;
this.getList(); this.getList();
this.$message({ this.$message({
type: 'success', type: 'success',
message: '删除成功!' //updateHomeSubjectSort message: '删除成功!'
}); });
}); });
}) })
}, },
//
getList() { getList() {
this.listLoading = true; //true this.listLoading = true;
fetchList(this.listQuery).then(response => { //fetchList fetchList(this.listQuery).then(response => {
this.listLoading = false; //false this.listLoading = false;
this.list = response.data.list; //// this.list = response.data.list;
this.total = response.data.total; this.total = response.data.total;
}) })
}, },
//
updateRecommendStatusStatus(ids,status){ updateRecommendStatusStatus(ids,status){
this.$confirm('是否要修改推荐状态?', '提示', { // this.$confirm('是否要修改推荐状态?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
let params = new URLSearchParams(); //URLSearchParamsid let params=new URLSearchParams();
params.append("ids",ids); params.append("ids",ids);
params.append("finalRecommendStatus", status); params.append("recommendStatus",status);
updateRecommendStatus(params).then(response => { //// updateRecommendStatus updateRecommendStatus(params).then(response=>{
this.getList(); this.getList();
this.$message({ this.$message({
type: 'success', type: 'success',
message: '修改成功!' // message: '修改成功!'
}); });
}); });
}).catch(() => { }).catch(() => {
this.$message({ this.$message({
type: 'success', type: 'success',
message: '已取消操作!' // message: '已取消操作!'
}); });
this.getList(); this.getList();
}); });
}, },
//
deleteSubject(ids){ deleteSubject(ids){
this.$confirm('是否要删除该推荐?', '提示', { // this.$confirm('是否要删除该推荐?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
let params = new URLSearchParams(); //URLSearchParamsid let params=new URLSearchParams();
params.append("ids",ids); params.append("ids",ids);
deleteHomeSubject(params).then(response => { //// deleteHomeSubject deleteHomeSubject(params).then(response=>{
this.getList(); this.getList();
this.$message({ this.$message({
type: 'success', type: 'success',
message: '删除成功!' // message: '删除成功!'
}); });
}); });
}) })
}, },
//
getDialogList(){ getDialogList(){
fetchSubjectList(this.dialogData.listQuery).then(response => { //fetchSubjectList fetchSubjectList(this.dialogData.listQuery).then(response=>{
this.dialogData.list = response.data.list; // this.dialogData.list=response.data.list;
this.dialogData.total=response.data.total; this.dialogData.total=response.data.total;
}) })
} }

Loading…
Cancel
Save