main^2
fanfan 6 months ago
parent 59d093c54e
commit 0fa8a10131
  1. 12
      src/api/goods/index.js
  2. 2
      src/common/model/goods/MultiSpec.js
  3. 56
      src/views/dataCenter/goods/Index.vue

@ -15,6 +15,7 @@ const api = {
addPrice:'/goods/addPrice', addPrice:'/goods/addPrice',
exportData:'/goods/import', exportData:'/goods/import',
jingPin:'/goods/jingpin', jingPin:'/goods/jingpin',
batchAddPrice:'/goods/batchAddPrice',
} }
// 列表记录 // 列表记录
@ -143,6 +144,17 @@ export function addPrice (data) {
method: 'post', method: 'post',
data: data data: data
}) })
}
/**
* 批量加价率
* @param {*} data
*/
export function batchAddPrice (data) {
return axios({
url: api.batchAddPrice,
method: 'post',
data: data
})
}/** }/**
* 导出 * 导出
* @param {*} data * @param {*} data

@ -141,6 +141,7 @@ export default class MultiSpec {
const specGroupArr = this.specGroupArr() const specGroupArr = this.specGroupArr()
// sku记录的规格属性集(生成笛卡尔积) // sku记录的规格属性集(生成笛卡尔积)
const cartesianList = cartesianProductOf(specGroupArr) const cartesianList = cartesianProductOf(specGroupArr)
console.log(cartesianList,'specGroupArr')
// 合并单元格 // 合并单元格
const rowSpanArr = this.rowSpanArr(specGroupArr, cartesianList) const rowSpanArr = this.rowSpanArr(specGroupArr, cartesianList)
// 生成sku字段名 // 生成sku字段名
@ -148,6 +149,7 @@ export default class MultiSpec {
// 生成sku列表数据 // 生成sku列表数据
this.buildSkuList(cartesianList) this.buildSkuList(cartesianList)
// 返回多规格数据 // 返回多规格数据
console.log(this.multiSpecData.skuList)
return this.multiSpecData return this.multiSpecData
} }

@ -178,6 +178,17 @@
<input placeholder="请输入加价利润率" @input="validateAmount" v-model="rate" class="input" type="text" /> <input placeholder="请输入加价利润率" @input="validateAmount" v-model="rate" class="input" type="text" />
</div> </div>
</a-modal> </a-modal>
<a-modal
v-model:visible="batchPrice"
width="450px"
title="批量加价"
@ok="handleBatchPrice(selectedRowKeys, batchRate)"
>
<div class="fen" style="margin-top:-10px">
<span style="margin-right: 5px">加价利润率</span>
<input placeholder="请输入加价利润率" @input="validateBatchAmount" v-model="batchRate" class="input" type="text" />
</div>
</a-modal>
<a-modal <a-modal
v-model:visible="saleVisible" v-model:visible="saleVisible"
width="250px" width="250px"
@ -252,6 +263,12 @@
@click="priceVisible = true" @click="priceVisible = true"
>分类加价</a-button >分类加价</a-button
> >
<a-button
v-if="selectedRowKeys.length"
style="background-color: #67C23A; color: #fff; border: none; border-radius: 2px"
@click="batchPrice = true"
>批量加价</a-button
>
<a-button <a-button
style="background-color: #501212; color: #fff; border: none; border-radius: 2px" style="background-color: #501212; color: #fff; border: none; border-radius: 2px"
@click="handleExport(selectedRowKeys)" @click="handleExport(selectedRowKeys)"
@ -516,6 +533,7 @@ export default {
saleVisible: false, saleVisible: false,
priceVisible: false, priceVisible: false,
jingPinVisible: false, jingPinVisible: false,
batchPrice:false,
specsType: [ specsType: [
{ name: '全部', val: '' }, { name: '全部', val: '' },
{ name: '单规格', val: 10 }, { name: '单规格', val: 10 },
@ -550,6 +568,7 @@ export default {
categoryIds: [], categoryIds: [],
categoryPriceIds: [], categoryPriceIds: [],
rate: '', rate: '',
batchRate:'',
pickerOptions: { pickerOptions: {
disabledDate(time) { disabledDate(time) {
return time.getTime() > Date.now() return time.getTime() > Date.now()
@ -736,11 +755,11 @@ export default {
this.$message.error('金额不能小于0') this.$message.error('金额不能小于0')
this.rate = '' this.rate = ''
} else if (row.startsWith('0')) { } else if (row.startsWith('0')) {
this.money = '' this.rate = ''
// 2 // 2
} else if (!/^\d+(\.\d{1,2})?$/.test(row)) { } else if (!/^\d+(\.\d{1,2})?$/.test(row)) {
this.$message.error('请输入数字!') this.$message.error('请输入数字!')
this.money = '' this.rate = ''
} else if (row.split('.')[1] && row.split('.')[1].length > 2) { } else if (row.split('.')[1] && row.split('.')[1].length > 2) {
this.$message.error('金额小数部分不能超过2位,请修改') this.$message.error('金额小数部分不能超过2位,请修改')
this.rate = '' this.rate = ''
@ -921,6 +940,39 @@ export default {
this.isLoading = false 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) { handleUpdateSales(goodsIds, is_sale) {
this.isLoading = true this.isLoading = true

Loading…
Cancel
Save