pull/6/head
py4fbma29 3 months ago
commit 5e78d9fccd

@ -2,7 +2,6 @@
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')
@ -10,10 +9,8 @@ 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,7 +8,6 @@ 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)
} }

Binary file not shown.

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

@ -1,7 +1,27 @@
// 导入封装好的请求工具用于发起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:'/companyAddress/list', // 接口的URL路径指向公司地址列表的后端接口
method:'get' url: '/companyAddress/list',
// 请求方法:使用 HTTP GET 方法获取数据
method: 'get'
}) })
} }

@ -1,38 +1,106 @@
// 导入封装的 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: '/coupon/list', // 接口URL路径获取优惠券列表
method:'get', method: 'get', // 请求方法GET
params:params params: params // 查询参数通过URL参数传递
}) })
} }
/**
* 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: '/coupon/create', // 接口URL路径创建优惠券
method:'post', method: 'post', // 请求方法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: '/coupon/' + id, // 接口URL路径根据ID获取优惠券详情
method:'get', method: 'get' // 请求方法GET
}) })
} }
export function updateCoupon(id,data) { /**
* updateCoupon - 更新指定优惠券的信息
*
* 该函数通过 POST 请求提交修改后的优惠券数据更新指定ID的优惠券
*
* @param {number|string} id - 优惠券的唯一标识ID
* @param {Object} data - 修改后的优惠券数据
* @returns {Promise} - 返回一个Promise对象包含操作结果
*
* 用法示例
* updateCoupon(1, { name: 'Updated Sale', discount: 25 }).then(response => {
* console.log(response);
* });
*/
export function updateCoupon(id, data) {
return request({ return request({
url:'/coupon/update/'+id, url: '/coupon/update/' + id, // 接口URL路径更新指定ID的优惠券
method:'post', method: 'post', // 请求方法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: '/coupon/delete/' + id, // 接口URL路径删除指定ID的优惠券
method:'post', method: 'post' // 请求方法POST
}) })
} }

@ -1,8 +1,27 @@
// 导入封装的 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: '/couponHistory/list', // 接口URL路径获取优惠券历史记录列表
method:'get', method: 'get', // 请求方法GET
params:params params: params // 查询参数,通过 URL 参数传递
}) })
} }

@ -1,35 +1,109 @@
// 导入封装的 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: '/flash/list', // 接口URL获取限时购活动列表
method:'get', method: 'get', // 请求方法GET
params:params params: params // 查询参数,通过 URL 查询字符串传递
}) })
} }
export function updateStatus(id,params) {
/**
* updateStatus - 更新限时购活动状态
*
* 该函数通过 POST 请求更新指定限时购活动的状态
*
* @param {number|string} id - 限时购活动的唯一标识ID
* @param {Object} params - 状态更新参数例如 { status: 1 }
* @returns {Promise} - 返回一个 Promise 对象包含操作结果
*
* 用法示例
* updateStatus(1, { status: 1 }).then(response => {
* console.log(response);
* });
*/
export function updateStatus(id, params) {
return request({ return request({
url:'/flash/update/status/'+id, url: '/flash/update/status/' + id, // 接口URL更新指定活动状态
method:'post', method: 'post', // 请求方法POST
params:params params: params // 状态参数,通过 URL 查询字符串传递
}) })
} }
/**
* 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: '/flash/delete/' + id, // 接口URL删除指定活动
method:'post' method: 'post' // 请求方法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: '/flash/create', // 接口URL创建限时购活动
method:'post', method: 'post', // 请求方法POST
data:data data: data // 请求体,包含活动的详细数据
}) })
} }
export function updateFlash(id,data) {
/**
* updateFlash - 更新指定的限时购活动
*
* 该函数通过 POST 请求提交更新后的活动数据更新指定ID的限时购活动
*
* @param {number|string} id - 限时购活动的唯一标识ID
* @param {Object} data - 更新后的活动数据
* @returns {Promise} - 返回一个 Promise 对象包含操作结果
*
* 用法示例
* updateFlash(1, { name: 'Updated Flash Sale', startTime: '2024-06-15' }).then(response => {
* console.log(response);
* });
*/
export function updateFlash(id, data) {
return request({ return request({
url:'/flash/update/'+id, url: '/flash/update/' + id, // 接口URL更新指定ID的活动
method:'post', method: 'post', // 请求方法POST
data:data data: data // 请求体,包含更新后的活动数据
}) })
} }

@ -1,28 +1,88 @@
// 导入封装的 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: '/flashProductRelation/list', // 接口URL获取关联列表
method:'get', method: 'get', // 请求方法GET
params:params params: params // 查询参数,通过 URL 传递
}) })
} }
/**
* 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: '/flashProductRelation/create', // 接口URL创建关联
method:'post', method: 'post', // 请求方法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: '/flashProductRelation/delete/' + id, // 接口URL删除关联
method:'post' method: 'post' // 请求方法POST
}) })
} }
export function updateFlashProductRelation(id,data) {
/**
* updateFlashProductRelation - 更新指定的限时购商品关联数据
*
* 该函数通过 POST 请求提交更新后的限时购商品关联数据
*
* @param {number|string} id - 限时购商品关联的唯一标识 ID
* @param {Object} data - 更新后的关联数据例如 { sort: 2 }
* @returns {Promise} - 返回一个 Promise 对象包含操作结果
*
* 用法示例
* updateFlashProductRelation(1, { sort: 2 }).then(response => {
* console.log(response);
* });
*/
export function updateFlashProductRelation(id, data) {
return request({ return request({
url:'/flashProductRelation/update/'+id, url: '/flashProductRelation/update/' + id, // 接口URL更新关联
method:'post', method: 'post', // 请求方法POST
data:data data: data // 请求体,包含更新数据
}) })
} }

@ -1,48 +1,131 @@
// 导入封装的 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: '/flashSession/list', // 接口URL获取限时购场次列表
method: 'get', method: 'get', // 请求方法GET
params: params params: params // 查询参数,通过 URL 传递
}) })
} }
/**
* 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: '/flashSession/selectList', // 接口URL获取可选的场次列表
method: 'get', method: 'get', // 请求方法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: '/flashSession/update/status/' + id, // 接口URL更新场次状态
method: 'post', method: 'post', // 请求方法POST
params: params params: params // 状态参数,通过 URL 查询字符串传递
}) })
} }
/**
* 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: '/flashSession/delete/' + id, // 接口URL删除场次
method: 'post' method: 'post' // 请求方法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: '/flashSession/create', // 接口URL创建场次
method: 'post', method: 'post', // 请求方法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: '/flashSession/update/' + id, // 接口URL更新场次信息
method: 'post', method: 'post', // 请求方法POST
data: data data: data // 请求体,包含更新数据
}) })
} }

@ -1,43 +1,130 @@
// 导入封装的 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: '/home/advertise/list', // 接口URL获取首页广告列表
method:'get', method: 'get', // 请求方法GET
params:params params: params // 查询参数,通过 URL 传递
}) })
} }
export function updateStatus(id,params) {
/**
* updateStatus - 更新指定广告的状态
*
* 通过 POST 请求更新首页广告的状态启用/禁用
*
* @param {number|string} id - 广告的唯一标识ID
* @param {Object} params - 状态参数例如 { status: 1 }
* @returns {Promise} - 返回一个 Promise 对象包含操作结果
*
* 用法示例
* updateStatus(1, { status: 1 }).then(response => {
* console.log(response);
* });
*/
export function updateStatus(id, params) {
return request({ return request({
url:'/home/advertise/update/status/'+id, url: '/home/advertise/update/status/' + id, // 接口URL更新广告状态
method:'post', method: 'post', // 请求方法POST
params:params params: params // 状态参数,通过 URL 查询字符串传递
}) })
} }
/**
* 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: '/home/advertise/delete', // 接口URL批量删除广告
method:'post', method: 'post', // 请求方法POST
data:data data: data // 请求体包含广告ID数组
}) })
} }
/**
* 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: '/home/advertise/create', // 接口URL创建广告
method:'post', method: 'post', // 请求方法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: '/home/advertise/' + id, // 接口URL获取广告详情
method:'get', method: 'get' // 请求方法GET
}) })
} }
export function updateHomeAdvertise(id,data) { /**
* updateHomeAdvertise - 更新指定广告的信息
*
* 通过 POST 请求提交更新后的广告数据更新指定广告的信息
*
* @param {number|string} id - 广告的唯一标识ID
* @param {Object} data - 更新后的广告数据例如 { name: '更新广告', type: 2 }
* @returns {Promise} - 返回一个 Promise 对象包含操作结果
*
* 用法示例
* updateHomeAdvertise(1, { name: '更新广告', type: 2 }).then(response => {
* console.log(response);
* });
*/
export function updateHomeAdvertise(id, data) {
return request({ return request({
url:'/home/advertise/update/'+id, url: '/home/advertise/update/' + id, // 接口URL更新广告信息
method:'post', method: 'post', // 请求方法POST
data:data data: data // 请求体,包含更新后的广告数据
}) })
} }

@ -1,40 +1,110 @@
// 导入封装的 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: '/home/brand/list', // 接口URL获取品牌列表
method:'get', method: 'get', // 请求方法GET
params:params params: params // 查询参数,通过 URL 传递
}) })
} }
/**
* 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: '/home/brand/update/recommendStatus', // 接口URL更新推荐状态
method:'post', method: 'post', // 请求方法POST
data:data data: data // 请求体包含品牌ID和状态
}) })
} }
/**
* 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: '/home/brand/delete', // 接口URL批量删除品牌
method:'post', method: 'post', // 请求方法POST
data:data data: data // 请求体包含品牌ID数组
}) })
} }
/**
* 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: '/home/brand/create', // 接口URL创建品牌
method:'post', method: 'post', // 请求方法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: '/home/brand/update/sort/' + params.id, // 接口URL更新品牌排序
method:'post', method: 'post', // 请求方法POST
params:params params: params // 排序参数,通过 URL 查询字符串传递
}) })
} }

@ -1,40 +1,110 @@
// 导入封装的 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: '/home/recommendSubject/list', // 接口URL获取推荐专题列表
method:'get', method: 'get', // 请求方法GET
params:params params: params // 查询参数,通过 URL 传递
}) })
} }
/**
* 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: '/home/recommendSubject/update/recommendStatus', // 接口URL更新推荐状态
method:'post', method: 'post', // 请求方法POST
data:data data: data // 请求体包含专题ID和推荐状态
}) })
} }
/**
* 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: '/home/recommendSubject/delete', // 接口URL批量删除专题
method:'post', method: 'post', // 请求方法POST
data:data data: data // 请求体包含专题ID数组
}) })
} }
/**
* 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: '/home/recommendSubject/create', // 接口URL创建推荐专题
method:'post', method: 'post', // 请求方法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: '/home/recommendSubject/update/sort/' + params.id, // 接口URL更新专题排序
method:'post', method: 'post', // 请求方法POST
params:params params: params // 排序参数,通过 URL 查询字符串传递
}) })
} }

@ -1,40 +1,110 @@
// 导入封装的 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: '/home/recommendProduct/list', // 接口URL获取推荐商品列表
method:'get', method: 'get', // 请求方法GET
params:params params: params // 查询参数,通过 URL 传递
}) })
} }
/**
* 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: '/home/recommendProduct/update/recommendStatus', // 接口URL更新推荐状态
method:'post', method: 'post', // 请求方法POST
data:data data: data // 请求体包含商品ID和推荐状态
}) })
} }
/**
* 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: '/home/recommendProduct/delete', // 接口URL批量删除推荐商品
method:'post', method: 'post', // 请求方法POST
data:data data: data // 请求体包含商品ID数组
}) })
} }
/**
* 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: '/home/recommendProduct/create', // 接口URL创建推荐商品
method:'post', method: 'post', // 请求方法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: '/home/recommendProduct/update/sort/' + params.id, // 接口URL更新商品排序
method:'post', method: 'post', // 请求方法POST
params:params params: params // 排序参数,通过 URL 查询字符串传递
}) })
} }

@ -1,15 +1,33 @@
<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> <!-- 进一步的操作提示 -->
<el-button style="margin-top: 20px" type="primary" round @click="handleGoMain"></el-button> <div style="color:#909399; font-size: 14px">
请检查您输入的网址是否正确请点击以下按钮返回主页或者发送错误报告
</div>
<!-- 返回首页按钮 -->
<el-button
style="margin-top: 20px"
type="primary"
round
@click="handleGoMain"
>
返回首页
</el-button>
</div> </div>
</el-col> </el-col>
</div> </div>
@ -17,33 +35,50 @@
</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; margin: 120px auto; /* 页面居中,距离顶部 120px */
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>

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

@ -1,145 +1,168 @@
<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"></el-input> :autosize="true"
></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('brandFrom')"></el-button> <el-button type="primary" @click="onSubmit('brandForm')"></el-button>
<el-button v-if="!isEdit" @click="resetForm('brandFrom')"></el-button> <el-button v-if="!isEdit" @click="resetForm('brandForm')"></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: '', export default {
brandStory: '', name: "BrandDetail", //
factoryStatus: 0, components: {
firstLetter: '', SingleUpload, //
logo: '', },
name: '', props: {
showStatus: 0, //
sort: 0 isEdit: {
}; type: Boolean,
export default { default: false,
name: 'BrandDetail',
components:{SingleUpload},
props: {
isEdit: {
type: Boolean,
default: false
}
},
data() {
return {
brand:Object.assign({}, defaultBrand),
rules: {
name: [
{required: true, message: '请输入品牌名称', trigger: 'blur'},
{min: 2, max: 140, message: '长度在 2 到 140 个字符', trigger: 'blur'}
],
logo: [
{required: true, message: '请输入品牌logo', trigger: 'blur'}
],
sort: [
{type: 'number', message: '排序必须为数字'}
],
}
}
},
created() {
if (this.isEdit) {
getBrand(this.$route.query.id).then(response => {
this.brand = response.data;
});
}else{
this.brand = Object.assign({},defaultBrand);
}
}, },
methods: { },
onSubmit(formName) { data() {
this.$refs[formName].validate((valid) => { //
if (valid) { const defaultBrand = {
this.$confirm('是否提交数据', '提示', { bigPic: "", //
confirmButtonText: '确定', brandStory: "", //
cancelButtonText: '取消', factoryStatus: 0, //
type: 'warning' firstLetter: "", //
}).then(() => { logo: "", // LOGO
if (this.isEdit) { name: "", //
updateBrand(this.$route.query.id, this.brand).then(response => { showStatus: 0, //
this.$refs[formName].resetFields(); sort: 0, //
this.$message({ };
message: '修改成功',
type: 'success',
duration:1000
});
this.$router.back();
});
} else {
createBrand(this.brand).then(response => {
this.$refs[formName].resetFields();
this.brand = Object.assign({},defaultBrand);
this.$message({
message: '提交成功',
type: 'success',
duration:1000
});
});
}
});
} else { return {
this.$message({ brand: Object.assign({}, defaultBrand), //
message: '验证失败', rules: {
type: 'error', name: [
duration:1000 { required: true, message: "请输入品牌名称", trigger: "blur" },
}); { min: 2, max: 140, message: "长度在 2 到 140 个字符", trigger: "blur" },
return false; ],
} logo: [{ required: true, message: "请输入品牌logo", trigger: "blur" }],
}); sort: [{ type: "number", message: "排序必须为数字" }],
}, },
resetForm(formName) { };
this.$refs[formName].resetFields(); },
this.brand = Object.assign({},defaultBrand); created() {
} //
if (this.isEdit) {
getBrand(this.$route.query.id).then((response) => {
this.brand = response.data; //
});
} else {
this.brand = Object.assign({}, this.defaultBrand); //
} }
} },
methods: {
//
onSubmit(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
this.$confirm("是否提交数据", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
}).then(() => {
if (this.isEdit) {
//
updateBrand(this.$route.query.id, this.brand).then(() => {
this.$refs[formName].resetFields();
this.$message({
message: "修改成功",
type: "success",
duration: 1000,
});
this.$router.back();
});
} else {
//
createBrand(this.brand).then(() => {
this.$refs[formName].resetFields();
this.brand = Object.assign({}, this.defaultBrand);
this.$message({
message: "提交成功",
type: "success",
duration: 1000,
});
});
}
});
} else {
this.$message({
message: "验证失败",
type: "error",
duration: 1000,
});
return false;
}
});
},
//
resetForm(formName) {
this.$refs[formName].resetFields();
this.brand = Object.assign({}, this.defaultBrand);
},
},
};
</script> </script>
<style>
</style>

@ -1,28 +1,39 @@
<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> <!-- 搜索标题和按钮 -->
<span>筛选搜索</span> <i class="el-icon-search"></i>
<el-button <span>筛选搜索</span>
style="float: right" <el-button
@click="searchBrandList()" style="float: right"
type="primary" @click="searchBrandList()"
size="small"> type="primary"
查询结果 size="small">
</el-button> 查询结果
</div> </el-button>
<div style="margin-top: 15px"> </div>
<el-form :inline="true" :model="listQuery" size="small" label-width="140px"> <!-- 筛选条件 -->
<el-form-item label="输入搜索:"> <div style="margin-top: 15px">
<el-input style="width: 203px" v-model="listQuery.keyword" placeholder="品牌名称/关键字"></el-input> <el-form :inline="true" :model="listQuery" size="small" label-width="140px">
</el-form-item> <el-form-item label="输入搜索:">
</el-form> <el-input
</div> style="width: 203px"
v-model="listQuery.keyword"
placeholder="品牌名称/关键字">
</el-input>
</el-form-item>
</el-form>
</div>
</el-card> </el-card>
<!-- 操作区域 -->
<el-card class="operate-container" shadow="never"> <el-card class="operate-container" shadow="never">
<i class="el-icon-tickets"></i> <i class="el-icon-tickets"></i>
<span>数据列表</span> <span>数据列表</span>
<!-- 添加品牌按钮 -->
<el-button <el-button
class="btn-add" class="btn-add"
@click="addBrand()" @click="addBrand()"
@ -30,26 +41,35 @@
添加 添加
</el-button> </el-button>
</el-card> </el-card>
<!-- 数据表格区域 -->
<div class="table-container"> <div class="table-container">
<el-table ref="brandTable" <el-table
:data="list" ref="brandTable"
style="width: 100%" :data="list"
@selection-change="handleSelectionChange" style="width: 100%"
v-loading="listLoading" @selection-change="handleSelectionChange"
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.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
@ -60,6 +80,7 @@
</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,41 +91,42 @@
</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)">100 @click="getProductList(scope.$index, scope.row)">
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)">1000 @click="getProductCommentList(scope.$index, scope.row)">
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 <el-button size="mini" @click="handleUpdate(scope.$index, scope.row)">
size="mini" 编辑
@click="handleUpdate(scope.$index, scope.row)">编辑
</el-button> </el-button>
<el-button <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">
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 <el-select size="small" v-model="operateType" placeholder="批量操作">
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"
@ -114,196 +136,102 @@
</el-select> </el-select>
<el-button <el-button
style="margin-left: 20px" style="margin-left: 20px"
class="search-button"
@click="handleBatchOperate()" @click="handleBatchOperate()"
type="primary" type="primary"
size="small"> size="small">
确定 确定
</el-button> </el-button>
</div> </div>
<!-- 分页组件 -->
<div class="pagination-container"> <div class="pagination-container">
<el-pagination <el-pagination
background background
@size-change="handleSizeChange" @size-change="handleSizeChange"
@current-change="handleCurrentChange" @current-change="handleCurrentChange"
layout="total, sizes,prev, pager, next,jumper" layout="total, sizes, prev, pager, next, jumper"
:page-size="listQuery.pageSize" :page-size="listQuery.pageSize"
:page-sizes="[5,10,15]" :page-sizes="[5, 10, 15]"
:current-page.sync="listQuery.pageNum" :current-page.sync="listQuery.pageNum"
:total="total"> :total="total">
</el-pagination> </el-pagination>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import {fetchList, updateShowStatus, updateFactoryStatus, deleteBrand} from '@/api/brand' import { fetchList, updateShowStatus, updateFactoryStatus, deleteBrand } from "@/api/brand";
export default { export default {
name: 'brandList', name: "brandList", //
data() { data() {
return { return {
operates: [ operates: [
{ { label: "显示品牌", value: "showBrand" },
label: "显示品牌", { label: "隐藏品牌", value: "hideBrand" },
value: "showBrand" ],
}, operateType: null, //
{ listQuery: {
label: "隐藏品牌", keyword: null,
value: "hideBrand" pageNum: 1,
} pageSize: 10,
], },
operateType: null, list: null, //
listQuery: { total: null, //
keyword: null, listLoading: true, //
pageNum: 1, multipleSelection: [], //
pageSize: 10 };
}, },
list: null, created() {
total: null, this.getList(); //
listLoading: true, },
multipleSelection: [] methods: {
} //
getList() {
this.listLoading = true;
fetchList(this.listQuery).then((response) => {
this.list = response.data.list;
this.total = response.data.total;
this.listLoading = false;
});
}, },
created() { //
searchBrandList() {
this.listQuery.pageNum = 1;
this.getList(); this.getList();
}, },
methods: { //
getList() { handleBatchOperate() {
this.listLoading = true; console.log(this.multipleSelection);
fetchList(this.listQuery).then(response => { },
this.listLoading = false; //
this.list = response.data.list; addBrand() {
this.total = response.data.total; this.$router.push({ path: "/pms/addBrand" });
this.totalPage = response.data.totalPage; },
this.pageSize = response.data.pageSize; //
}); handleUpdate(index, row) {
}, this.$router.push({ path: "/pms/updateBrand", query: { id: row.id } });
handleSelectionChange(val) { },
this.multipleSelection = val; //
}, handleDelete(index, row) {
handleUpdate(index, row) { deleteBrand(row.id).then(() => {
this.$router.push({path: '/pms/updateBrand', query: {id: row.id}}) this.$message({ message: "删除成功", type: "success" });
},
handleDelete(index, row) {
this.$confirm('是否要删除该品牌', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
deleteBrand(row.id).then(response => {
this.$message({
message: '删除成功',
type: 'success',
duration: 1000
});
this.getList();
});
});
},
getProductList(index, row) {
console.log(index, row);
},
getProductCommentList(index, row) {
console.log(index, row);
},
handleFactoryStatusChange(index, row) {
var data = new URLSearchParams();
data.append("ids", row.id);
data.append("factoryStatus", row.factoryStatus);
updateFactoryStatus(data).then(response => {
this.$message({
message: '修改成功',
type: 'success',
duration: 1000
});
}).catch(error => {
if (row.factoryStatus === 0) {
row.factoryStatus = 1;
} else {
row.factoryStatus = 0;
}
});
},
handleShowStatusChange(index, row) {
let data = new URLSearchParams();
;
data.append("ids", row.id);
data.append("showStatus", row.showStatus);
updateShowStatus(data).then(response => {
this.$message({
message: '修改成功',
type: 'success',
duration: 1000
});
}).catch(error => {
if (row.showStatus === 0) {
row.showStatus = 1;
} else {
row.showStatus = 0;
}
});
},
handleSizeChange(val) {
this.listQuery.pageNum = 1;
this.listQuery.pageSize = val;
this.getList();
},
handleCurrentChange(val) {
this.listQuery.pageNum = val;
this.getList();
},
searchBrandList() {
this.listQuery.pageNum = 1;
this.getList(); this.getList();
}, });
handleBatchOperate() { },
console.log(this.multipleSelection); //
if (this.multipleSelection < 1) { handleSizeChange(val) {
this.$message({ this.listQuery.pageSize = val;
message: '请选择一条记录', this.getList();
type: 'warning', },
duration: 1000 handleCurrentChange(val) {
}); this.listQuery.pageNum = val;
return; this.getList();
} },
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,14 +1,19 @@
<template>  <template>
<brand-detail :is-edit='true'></brand-detail> <!-- 使用 BrandDetail 组件并传递 is-edit 属性为 true表示编辑品牌模式 -->
<brand-detail :is-edit="true"></brand-detail>
</template> </template>
<script> <script>
import BrandDetail from './components/BrandDetail' import BrandDetail from './components/BrandDetail'; // BrandDetail
export default {
name: 'updateBrand', export default {
components: { BrandDetail } name: 'updateBrand', // 使
} components: {
BrandDetail, // BrandDetail 使使
},
};
</script> </script>
<style> <style>
/* 样式部分:暂无样式定义,保留扩展空间 */
</style> </style>

@ -1,12 +1,19 @@
<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' import ProductDetail from './components/ProductDetail'; // ProductDetail
export default {
name: 'addProduct', export default {
components: { ProductDetail } name: 'addProduct', //
} components: {
ProductDetail, // ProductDetail
},
};
</script> </script>
<style> <style>
/* 样式部分:暂无样式定义,根据需求可添加 */
</style> </style>

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

@ -1,17 +1,23 @@
<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"
@ -19,6 +25,8 @@
@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"
@ -26,6 +34,8 @@
@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"
@ -35,154 +45,140 @@
</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'; import { createProduct, getProduct, updateProduct } from '@/api/product'; // API
const defaultProductParam = { //
albumPics: '', const defaultProductParam = {
brandId: null, albumPics: '', //
brandName: '', brandId: null, // ID
deleteStatus: 0, brandName: '', //
description: '', deleteStatus: 0, //
detailDesc: '', description: '', //
detailHtml: '', detailDesc: '', //
detailMobileHtml: '', detailHtml: '', //
detailTitle: '', detailMobileHtml: '', //
feightTemplateId: 0, detailTitle: '', //
flashPromotionCount: 0, feightTemplateId: 0, // ID
flashPromotionId: 0, flashPromotionCount: 0, //
flashPromotionPrice: 0, flashPromotionPrice: 0, //
flashPromotionSort: 0, giftPoint: 0, //
giftPoint: 0, giftGrowth: 0, //
giftGrowth: 0, keywords: '', //
keywords: '', lowStock: 0, //
lowStock: 0, name: '', //
name: '', newStatus: 0, //
newStatus: 0, originalPrice: 0, //
note: '', price: 0, //
originalPrice: 0, skuStockList: [], // SKU
pic: '', productAttributeValueList: [], //
//{memberLevelId: 0,memberPrice: 0,memberLevelName: null} promotionStartTime: '', //
memberPriceList: [], promotionEndTime: '', //
// publishStatus: 0, //
productFullReductionList: [{fullPrice: 0, reducePrice: 0}], sale: 0, //
// stock: 0, //
productLadderList: [{count: 0,discount: 0,price: 0}], };
previewStatus: 0,
price: 0, export default {
productAttributeCategoryId: null, name: 'ProductDetail', //
//{productAttributeId: 0, value: ''} components: {
productAttributeValueList: [], ProductInfoDetail,
//sku{lowStock: 0, pic: '', price: 0, sale: 0, skuCode: '', spData: '', stock: 0} ProductSaleDetail,
skuStockList: [], ProductAttrDetail,
//{subjectId: 0} ProductRelationDetail,
subjectProductRelationList: [], },
//{prefrenceAreaId: 0} props: {
prefrenceAreaProductRelationList: [], isEdit: {
productCategoryId: null, type: Boolean,
productCategoryName: '', default: false, //
productSn: '', },
promotionEndTime: '', },
promotionPerLimit: 0, data() {
promotionPrice: null, return {
promotionStartTime: '', active: 0, //
promotionType: 0, productParam: Object.assign({}, defaultProductParam), //
publishStatus: 0, showStatus: [true, false, false, false], //
recommandStatus: 0, };
sale: 0, },
serviceIds: '', created() {
sort: 0, //
stock: 0, if (this.isEdit) {
subTitle: '', getProduct(this.$route.query.id).then((response) => {
unit: '', this.productParam = response.data; //
usePointLimit: 0, });
verifyStatus: 0, }
weight: 0 },
}; methods: {
export default { //
name: 'ProductDetail', hideAll() {
components: {ProductInfoDetail, ProductSaleDetail, ProductAttrDetail, ProductRelationDetail}, for (let i = 0; i < this.showStatus.length; i++) {
props: { this.showStatus[i] = false;
isEdit: {
type: Boolean,
default: false
} }
}, },
data() { //
return { prevStep() {
active: 0, if (this.active > 0) {
productParam: Object.assign({}, defaultProductParam), this.active--; // 退
showStatus: [true, false, false, false] this.hideAll(); //
this.showStatus[this.active] = true; //
} }
}, },
created(){ //
if(this.isEdit){ nextStep() {
getProduct(this.$route.query.id).then(response=>{ if (this.active < this.showStatus.length - 1) {
this.productParam=response.data; this.active++; //
}); this.hideAll(); //
this.showStatus[this.active] = true; //
} }
}, },
methods: { //
hideAll() { finishCommit(isEdit) {
for (let i = 0; i < this.showStatus.length; i++) { this.$confirm('是否要提交该产品?', '提示', {
this.showStatus[i] = false; confirmButtonText: '确定',
} cancelButtonText: '取消',
}, type: 'warning',
prevStep() { }).then(() => {
if (this.active > 0 && this.active < this.showStatus.length) { if (isEdit) {
this.active--; //
this.hideAll(); updateProduct(this.$route.query.id, this.productParam).then(() => {
this.showStatus[this.active] = true; this.$message({
} type: 'success',
}, message: '修改成功',
nextStep() { duration: 1000,
if (this.active < this.showStatus.length - 1) {
this.active++;
this.hideAll();
this.showStatus[this.active] = true;
}
},
finishCommit(isEdit) {
this.$confirm('是否要提交该产品', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
if(isEdit){
updateProduct(this.$route.query.id,this.productParam).then(response=>{
this.$message({
type: 'success',
message: '提交成功',
duration:1000
});
this.$router.back();
}); });
}else{ this.$router.back(); //
createProduct(this.productParam).then(response=>{ });
this.$message({ } else {
type: 'success', //
message: '提交成功', createProduct(this.productParam).then(() => {
duration:1000 this.$message({
}); type: 'success',
location.reload(); message: '提交成功',
duration: 1000,
}); });
} location.reload(); //
}) });
} }
} });
} },
},
};
</script> </script>
<style>
.form-container {
width: 960px;
}
.form-inner-container {
width: 800px;
}
</style>
<style>
/* 容器样式 */
.form-container {
width: 960px;
margin: 0 auto;
}
.form-inner-container {
width: 800px;
margin: 0 auto;
}
</style>

@ -1,200 +1,247 @@
<template> <template>
<!-- 商品基本信息表单 -->
<div style="margin-top: 50px"> <div style="margin-top: 50px">
<el-form :model="value" :rules="rules" ref="productInfoForm" label-width="120px" class="form-inner-container" size="small"> <el-form
: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="请输入内容"></el-input> placeholder="请输入内容"
></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 type="primary" size="medium" @click="handleNext('productInfoForm')"></el-button> <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() { },
return { data() {
hasEditCreated:false, return {
// hasEditCreated: false, //
selectProductCateValue: [], selectProductCateValue: [], //
productCateOptions: [], productCateOptions: [], //
brandOptions: [], brandOptions: [], //
rules: { rules: {
name: [ name: [
{required: true, message: '请输入商品名称', trigger: 'blur'}, { required: true, message: '请输入商品名称', trigger: 'blur' },
{min: 2, max: 140, message: '长度在 2 到 140 个字符', trigger: 'blur'} { min: 2, max: 140, message: '长度在 2 到 140 个字符', trigger: 'blur' },
], ],
subTitle: [{required: true, message: '请输入商品副标题', trigger: 'blur'}], subTitle: [{ required: true, message: '请输入商品副标题', trigger: 'blur' }],
productCategoryId: [{required: true, message: '请选择商品分类', trigger: 'blur'}], productCategoryId: [
brandId: [{required: true, message: '请选择商品品牌', trigger: 'blur'}], { required: true, message: '请选择商品分类', trigger: 'blur' },
description: [{required: true, message: '请输入商品介绍', trigger: 'blur'}], ],
requiredProp: [{required: true, message: '该项为必填项', trigger: 'blur'}] brandId: [{ required: true, message: '请选择商品品牌', trigger: 'blur' }],
} description: [{ required: true, message: '请输入商品介绍', trigger: 'blur' }],
}; },
};
},
created() {
//
this.getProductCateList();
this.getBrandList();
},
computed: {
// ID
productId() {
return this.value.id;
}, },
created() { },
this.getProductCateList(); watch: {
this.getBrandList(); productId(newValue) {
if (!this.isEdit || this.hasEditCreated || !newValue) return;
this.handleEditCreated();
}, },
computed:{ selectProductCateValue(newValue) {
// // ID
productId(){ if (newValue && newValue.length === 2) {
return this.value.id; this.value.productCategoryId = newValue[1];
this.value.productCategoryName = this.getCateNameById(this.value.productCategoryId);
} else {
this.value.productCategoryId = null;
this.value.productCategoryName = null;
} }
}, },
watch: { },
productId:function(newValue){ methods: {
if(!this.isEdit)return; //
if(this.hasEditCreated)return; handleEditCreated() {
if(newValue===undefined||newValue==null||newValue===0)return; if (this.value.productCategoryId != null) {
this.handleEditCreated(); this.selectProductCateValue = [
}, this.value.cateParentId,
selectProductCateValue: function (newValue) { this.value.productCategoryId,
if (newValue != null && newValue.length === 2) { ];
this.value.productCategoryId = newValue[1];
this.value.productCategoryName= this.getCateNameById(this.value.productCategoryId);
} else {
this.value.productCategoryId = null;
this.value.productCategoryName=null;
}
} }
this.hasEditCreated = true;
}, },
methods: {
// //
handleEditCreated(){ getProductCateList() {
if(this.value.productCategoryId!=null){ fetchListWithChildren().then((response) => {
this.selectProductCateValue.push(this.value.cateParentId); let list = response.data;
this.selectProductCateValue.push(this.value.productCategoryId); this.productCateOptions = list.map((item) => ({
} label: item.name,
this.hasEditCreated=true; value: item.id,
}, children: item.children?.map((child) => ({
getProductCateList() { label: child.name,
fetchListWithChildren().then(response => { value: child.id,
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}); getBrandList() {
} fetchBrandList({ pageNum: 1, pageSize: 100 }).then((response) => {
} this.brandOptions = response.data.list.map((item) => ({
this.productCateOptions.push({label: list[i].name, value: list[i].id, children: children}); label: item.name,
} value: item.id,
}); }));
}, });
getBrandList() { },
fetchBrandList({pageNum: 1, pageSize: 100}).then(response => {
this.brandOptions = []; // ID
let brandList = response.data.list; getCateNameById(id) {
for (let i = 0; i < brandList.length; i++) { for (const parent of this.productCateOptions) {
this.brandOptions.push({label: brandList[i].name, value: brandList[i].id}); for (const child of parent.children || []) {
} if (child.value === id) {
}); return child.label;
},
getCateNameById(id){
let name=null;
for(let i=0;i<this.productCateOptions.length;i++){
for(let j=0;j<this.productCateOptions[i].children.length;j++){
if(this.productCateOptions[i].children[j].value===id){
name=this.productCateOptions[i].children[j].label;
return name;
}
}
}
return name;
},
handleNext(formName){
this.$refs[formName].validate((valid) => {
if (valid) {
this.$emit('nextStep');
} else {
this.$message({
message: '验证失败',
type: 'error',
duration:1000
});
return false;
}
});
},
handleBrandChange(val) {
let brandName = '';
for (let i = 0; i < this.brandOptions.length; i++) {
if (this.brandOptions[i].value === val) {
brandName = this.brandOptions[i].label;
break;
} }
} }
this.value.brandName = brandName;
} }
} return null;
} },
//
handleNext(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
this.$emit('nextStep'); //
} else {
this.$message({
message: '验证失败',
type: 'error',
duration: 1000,
});
}
});
},
//
handleBrandChange(val) {
const selectedBrand = this.brandOptions.find(
(item) => item.value === val
);
this.value.brandName = selectedBrand ? selectedBrand.label : '';
},
},
};
</script> </script>
<style scoped> <style scoped>
/* 表单样式居中 */
.form-inner-container {
max-width: 600px;
margin: 0 auto;
}
</style> </style>

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

@ -1,43 +1,63 @@
<template> <template>
<!-- 商品促销信息表单 -->
<div style="margin-top: 50px"> <div style="margin-top: 50px">
<el-form :model="value" ref="productSaleForm" label-width="120px" class="form-inner-container" size="small"> <el-form
: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>
@ -45,18 +65,32 @@
<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 v-model="value.note" type="textarea" :autoSize="true"></el-input> <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>
@ -66,15 +100,17 @@
<el-radio-button :label="4">满减价格</el-radio-button> <el-radio-button :label="4">满减价格</el-radio-button>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item v-show="value.promotionType===1">
<!-- 特惠促销设置 -->
<el-form-item v-show="value.promotionType === 1">
<div> <div>
开始时间 开始时间
<el-date-picker <el-date-picker
v-model="value.promotionStartTime" v-model="value.promotionStartTime"
type="datetime" type="datetime"
:picker-options="pickerOptions1" :picker-options="pickerOptions1"
placeholder="选择开始时间"> placeholder="选择开始时间"
</el-date-picker> ></el-date-picker>
</div> </div>
<div class="littleMargin"> <div class="littleMargin">
结束时间 结束时间
@ -82,225 +118,156 @@
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 style="width: 220px" v-model="value.promotionPrice" placeholder="输入促销价格"></el-input> <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">
<div v-for="(item, index) in value.memberPriceList" :class="{littleMargin:index!==0}"> <!-- 会员价格设置 -->
{{item.memberLevelName}} <el-form-item v-show="value.promotionType === 2">
<div v-for="(item, index) in value.memberPriceList" :key="index" class="littleMargin">
{{ item.memberLevelName }}
<el-input v-model="item.memberPrice" style="width: 200px"></el-input> <el-input v-model="item.memberPrice" style="width: 200px"></el-input>
</div> </div>
</el-form-item> </el-form-item>
<el-form-item v-show="value.promotionType===3">
<el-table :data="value.productLadderList" <!-- 阶梯价格设置 -->
style="width: 80%" border> <el-form-item v-show="value.promotionType === 3">
<el-table-column <el-table :data="value.productLadderList" style="width: 80%" border>
label="数量" <el-table-column label="数量" align="center" width="120">
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 <el-table-column label="折扣" align="center" width="120">
label="折扣"
align="center"
width="120">
<template slot-scope="scope"> <template slot-scope="scope">
<el-input v-model="scope.row.discount"></el-input> <el-input v-model="scope.row.discount"></el-input>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column label="操作" align="center">
align="center"
label="操作">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="text" @click="handleRemoveProductLadder(scope.$index, scope.row)">删除</el-button> <el-button type="text" @click="handleRemoveProductLadder(scope.$index)">
<el-button type="text" @click="handleAddProductLadder(scope.$index, scope.row)">添加</el-button> 删除
</el-button>
<el-button type="text" @click="handleAddProductLadder(scope.$index)">
添加
</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</el-form-item> </el-form-item>
<el-form-item v-show="value.promotionType===4">
<el-table :data="value.productFullReductionList" <!-- 满减价格设置 -->
style="width: 80%" border> <el-form-item v-show="value.promotionType === 4">
<el-table-column <el-table :data="value.productFullReductionList" style="width: 80%" border>
label="满" <el-table-column label="满" align="center" width="120">
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 <el-table-column label="立减" align="center" width="120">
label="立减"
align="center"
width="120">
<template slot-scope="scope"> <template slot-scope="scope">
<el-input v-model="scope.row.reducePrice"></el-input> <el-input v-model="scope.row.reducePrice"></el-input>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column label="操作" align="center">
align="center"
label="操作">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="text" @click="handleRemoveFullReduction(scope.$index, scope.row)">删除</el-button> <el-button type="text" @click="handleRemoveFullReduction(scope.$index)">
<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> <el-button type="primary" size="medium" @click="handleNext">
下一步填写商品属性
</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' import { fetchList as fetchMemberLevelList } from '@/api/memberLevel'; // API
export default { export default {
name: "ProductSaleDetail", name: 'ProductSaleDetail',
props: { props: {
value: Object, value: Object, //
isEdit: { isEdit: {
type: Boolean, type: Boolean, //
default: false default: false,
}
},
data() {
return {
//
pickerOptions1: {
disabledDate(time) {
return time.getTime() < Date.now();
}
}
}
},
created() {
if (this.isEdit) {
// this.handleEditCreated();
} else {
fetchMemberLevelList({defaultStatus: 0}).then(response => {
let memberPriceList = [];
for (let i = 0; i < response.data.length; i++) {
let item = response.data[i];
memberPriceList.push({memberLevelId: item.id, memberLevelName: item.name})
}
this.value.memberPriceList = memberPriceList;
});
}
}, },
computed: { },
// data() {
selectServiceList: { return {
get() { pickerOptions1: {
let list = []; disabledDate(time) {
if (this.value.serviceIds === undefined || this.value.serviceIds == null || this.value.serviceIds === '') return list; return time.getTime() < Date.now(); //
let ids = this.value.serviceIds.split(',');
for (let i = 0; i < ids.length; i++) {
list.push(Number(ids[i]));
}
return list;
}, },
set(newValue) {
let serviceIds = '';
if (newValue != null && newValue.length > 0) {
for (let i = 0; i < newValue.length; i++) {
serviceIds += newValue[i] + ',';
}
if (serviceIds.endsWith(',')) {
serviceIds = serviceIds.substr(0, serviceIds.length - 1)
}
this.value.serviceIds = serviceIds;
} else {
this.value.serviceIds = null;
}
}
}
},
methods: {
handleEditCreated() {
let ids = this.value.serviceIds.split(',');
console.log('handleEditCreated', ids);
for (let i = 0; i < ids.length; i++) {
this.selectServiceList.push(Number(ids[i]));
}
},
handleRemoveProductLadder(index, row) {
let productLadderList = this.value.productLadderList;
if (productLadderList.length === 1) {
productLadderList.pop();
productLadderList.push({
count: 0,
discount: 0,
price: 0
})
} else {
productLadderList.splice(index, 1);
}
},
handleAddProductLadder(index, row) {
let productLadderList = this.value.productLadderList;
if (productLadderList.length < 3) {
productLadderList.push({
count: 0,
discount: 0,
price: 0
})
} else {
this.$message({
message: '最多只能添加三条',
type: 'warning'
});
}
},
handleRemoveFullReduction(index, row) {
let fullReductionList = this.value.productFullReductionList;
if (fullReductionList.length === 1) {
fullReductionList.pop();
fullReductionList.push({
fullPrice: 0,
reducePrice: 0
});
} else {
fullReductionList.splice(index, 1);
}
}, },
handleAddFullReduction(index, row) { };
let fullReductionList = this.value.productFullReductionList; },
if (fullReductionList.length < 3) { created() {
fullReductionList.push({ fetchMemberLevelList({ defaultStatus: 0 }).then((response) => {
fullPrice: 0, this.value.memberPriceList = response.data.map((item) => ({
reducePrice: 0 memberLevelId: item.id,
}); memberLevelName: item.name,
} else { memberPrice: 0,
this.$message({ }));
message: '最多只能添加三条', });
type: 'warning' },
}); computed: {
} //
selectServiceList: {
get() {
return this.value.serviceIds ? this.value.serviceIds.split(',').map(Number) : [];
}, },
handlePrev() { set(newValue) {
this.$emit('prevStep') this.value.serviceIds = newValue.join(',');
}, },
handleNext() { },
this.$emit('nextStep') },
} methods: {
} handleRemoveProductLadder(index) {
} this.value.productLadderList.splice(index, 1);
},
handleAddProductLadder() {
this.value.productLadderList.push({ count: 0, discount: 0 });
},
handleRemoveFullReduction(index) {
this.value.productFullReductionList.splice(index, 1);
},
handleAddFullReduction() {
this.value.productFullReductionList.push({ fullPrice: 0, reducePrice: 0 });
},
handlePrev() {
this.$emit('prevStep');
},
handleNext() {
this.$emit('nextStep');
},
},
};
</script> </script>
<style scoped> <style scoped>
.littleMargin { .littleMargin {
margin-top: 10px; margin-top: 10px;
} }
</style> </style>

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

@ -1,12 +1,24 @@
<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' /**
export default { * 导入 ProductDetail 组件作为编辑商品的核心组件
name: 'updateProduct', * 该组件内部根据传入的 `is-edit` 参数区分新增或编辑模式
components: { ProductDetail } */
} import ProductDetail from './components/ProductDetail';
export default {
name: 'updateProduct', //
components: {
ProductDetail, // ProductDetail 使使
},
};
</script> </script>
<style> <style>
/* 样式部分:暂无自定义样式,根据需求可以添加 */
</style> </style>

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

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

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

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

@ -1,15 +1,20 @@
<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: { ProductAttrDetail } components: {
} ProductAttrDetail, // ProductAttrDetail
},
};
</script> </script>
<style scoped> <style scoped>
/* scoped 表示样式只会应用于当前组件 */
</style> </style>

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

@ -1,15 +1,19 @@
<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" <el-select v-model="productCate.parentId" placeholder="请选择分类">
placeholder="请选择分类">
<el-option <el-option
v-for="item in selectProductCateList" v-for="item in selectProductCateList"
:key="item.id" :key="item.id"
@ -18,47 +22,67 @@
</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>
@ -68,6 +92,7 @@
</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';
@ -85,9 +110,10 @@
sort: 0, sort: 0,
productAttributeIdList: [] productAttributeIdList: []
}; };
export default { export default {
name: "ProductCateDetail", name: "ProductCateDetail",
components: {SingleUpload}, components: { SingleUpload },
props: { props: {
isEdit: { isEdit: {
type: Boolean, type: Boolean,
@ -97,168 +123,114 @@
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: [{ filterProductAttrList: [{ value: [] }] //
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 = []; this.filterProductAttrList = response.data.map((item, index) => ({
for (let i = 0; i < response.data.length; i++) { key: Date.now() + index,
this.filterProductAttrList.push({ value: [item.attributeCategoryId, item.attributeId]
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 => {
let list = response.data; this.filterAttrs = response.data.map(category => ({
for (let i = 0; i < list.length; i++) { label: category.name,
let productAttrCate = list[i]; value: category.id,
let children = []; children: category.productAttributeList.map(attr => ({
if (productAttrCate.productAttributeList != null && productAttrCate.productAttributeList.length > 0) { label: attr.name,
for (let j = 0; j < productAttrCate.productAttributeList.length; j++) { value: attr.id
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('是否提交数据', '提示', { this.$confirm('是否提交数据', '提示', { type: 'warning' }).then(() => {
confirmButtonText: '确定', this.productCate.productAttributeIdList = this.getProductAttributeIdList();
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
if (this.isEdit) { if (this.isEdit) {
this.productCate.productAttributeIdList = this.getProductAttributeIdList(); updateProductCate(this.$route.query.id, this.productCate).then(() => {
updateProductCate(this.$route.query.id, this.productCate).then(response => { this.$message.success('修改成功');
this.$message({
message: '修改成功',
type: 'success',
duration: 1000
});
this.$router.back(); this.$router.back();
}); });
} else { } else {
this.productCate.productAttributeIdList = this.getProductAttributeIdList(); createProductCate(this.productCate).then(() => {
createProductCate(this.productCate).then(response => {
this.$refs[formName].resetFields();
this.resetForm(formName); this.resetForm(formName);
this.$message({ this.$message.success('提交成功');
message: '提交成功',
type: 'success',
duration: 1000
});
}); });
} }
}); });
} else { } else {
this.$message({ this.$message.error('验证失败');
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: []
}];
}, },
removeFilterAttr(productAttributeId) { // ID
if (this.filterProductAttrList.length === 1) { getProductAttributeIdList() {
this.$message({ return this.filterProductAttrList
message: '至少要留一个', .filter(item => item.value.length === 2)
type: 'warning', .map(item => item.value[1]);
duration: 1000 },
}); //
return; removeFilterAttr(filterAttr) {
} const index = this.filterProductAttrList.indexOf(filterAttr);
var index = this.filterProductAttrList.indexOf(productAttributeId); if (index > -1) this.filterProductAttrList.splice(index, 1);
if (index !== -1) {
this.filterProductAttrList.splice(index, 1)
}
}, },
//
handleAddFilterAttr() { handleAddFilterAttr() {
if (this.filterProductAttrList.length === 3) { if (this.filterProductAttrList.length < 3) {
this.$message({ this.filterProductAttrList.push({ value: [], key: Date.now() });
message: '最多添加三个', } else {
type: 'warning', this.$message.warning('最多添加三个');
duration: 1000
});
return;
} }
this.filterProductAttrList.push({
value: null,
key: Date.now()
});
} }
}, },
filters: { filters: {
//
filterLabelFilter(index) { filterLabelFilter(index) {
if (index === 0) { return index === 0 ? '筛选属性:' : '';
return '筛选属性:';
} else {
return '';
}
} }
} }
} };
</script> </script>
<style scoped> <style scoped>
/* 本地样式,样式只对当前组件生效 */
</style> </style>

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

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

Loading…
Cancel
Save