From 0fa8a1013163fe0006bddaadc0b24c4b3d7a195c Mon Sep 17 00:00:00 2001 From: fanfan Date: Wed, 29 May 2024 16:05:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/goods/index.js | 12 ++++++ src/common/model/goods/MultiSpec.js | 2 + src/views/dataCenter/goods/Index.vue | 56 +++++++++++++++++++++++++++- 3 files changed, 68 insertions(+), 2 deletions(-) diff --git a/src/api/goods/index.js b/src/api/goods/index.js index 38491fb..ceca30d 100644 --- a/src/api/goods/index.js +++ b/src/api/goods/index.js @@ -15,6 +15,7 @@ const api = { addPrice:'/goods/addPrice', exportData:'/goods/import', jingPin:'/goods/jingpin', + batchAddPrice:'/goods/batchAddPrice', } // 列表记录 @@ -143,6 +144,17 @@ export function addPrice (data) { method: 'post', data: data }) +} +/** + * 批量加价率 + * @param {*} data + */ +export function batchAddPrice (data) { + return axios({ + url: api.batchAddPrice, + method: 'post', + data: data + }) }/** * 导出 * @param {*} data diff --git a/src/common/model/goods/MultiSpec.js b/src/common/model/goods/MultiSpec.js index 30d1c80..63d1c07 100644 --- a/src/common/model/goods/MultiSpec.js +++ b/src/common/model/goods/MultiSpec.js @@ -141,6 +141,7 @@ export default class MultiSpec { const specGroupArr = this.specGroupArr() // sku记录的规格属性集(生成笛卡尔积) const cartesianList = cartesianProductOf(specGroupArr) + console.log(cartesianList,'specGroupArr') // 合并单元格 const rowSpanArr = this.rowSpanArr(specGroupArr, cartesianList) // 生成sku字段名 @@ -148,6 +149,7 @@ export default class MultiSpec { // 生成sku列表数据 this.buildSkuList(cartesianList) // 返回多规格数据 + console.log(this.multiSpecData.skuList) return this.multiSpecData } diff --git a/src/views/dataCenter/goods/Index.vue b/src/views/dataCenter/goods/Index.vue index 2cc7605..a03a730 100644 --- a/src/views/dataCenter/goods/Index.vue +++ b/src/views/dataCenter/goods/Index.vue @@ -178,6 +178,17 @@ + +
+ 加价利润率: + +
+
分类加价 + 批量加价 Date.now() @@ -736,11 +755,11 @@ export default { this.$message.error('金额不能小于0') this.rate = '' } else if (row.startsWith('0')) { - this.money = '' + this.rate = '' // 金额小数部分不能超过2位 } else if (!/^\d+(\.\d{1,2})?$/.test(row)) { this.$message.error('请输入数字!') - this.money = '' + this.rate = '' } else if (row.split('.')[1] && row.split('.')[1].length > 2) { this.$message.error('金额小数部分不能超过2位,请修改') this.rate = '' @@ -921,6 +940,39 @@ export default { this.isLoading = false }) }, + validateBatchAmount() { + const row = this.batchRate + // 金额不能小于0 + if (row < 0) { + this.$message.error('金额不能小于0') + this.batchRate = '' + } else if (row.startsWith('0')) { + this.batchRate = '' + // 金额小数部分不能超过2位 + } else if (!/^\d+(\.\d{1,2})?$/.test(row)) { + this.$message.error('请输入数字!') + this.batchRate = '' + } else if (row.split('.')[1] && row.split('.')[1].length > 2) { + this.$message.error('金额小数部分不能超过2位,请修改') + this.batchRate = '' + } + }, + handleBatchPrice(goodsIds, rate) { + if (!rate) { + this.$message.warn('请输入加价利润率', 1.5) + return + } + this.isLoading = true + GoodsApi.batchAddPrice({ goodsIds, rate }) + .then((result) => { + this.batchPrice = false + this.$message.success(result.message, 1.5) + this.handleRefresh() + }) + .finally((result) => { + this.isLoading = false + }) + }, // 停售 handleUpdateSales(goodsIds, is_sale) { this.isLoading = true