Commit d4f78866 authored by dragondean@qq.com's avatar dragondean@qq.com

海运价格设置的阶梯价适配成空运一样的

parent 17f3f7db
...@@ -103,22 +103,64 @@ ...@@ -103,22 +103,64 @@
<!--如果是阶梯价--> <!--如果是阶梯价-->
<template v-if="form.stepPrice"> <template v-if="form.stepPrice">
<div v-for="(item, index) in form.priceStepList" :key="index"> <!--全包价-->
<sea-step <template v-if="form.priceType==1" >
<div v-for="(item, index) in form.fullPriceStepList" :key="index">
<price-step
ref="stepPrice" ref="stepPrice"
:index="index" :index="index"
:price-type="form.priceType"
:currency-list="currencyList" :currency-list="currencyList"
:unit-list="unitList" :unit-list="unitList"
:show-add="index === form.priceStepList.length -1 && !readonly" field-prefix="all"
:price-name="$t('全包价')"
:show-add="index === form.fullPriceStepList.length -1 && !readonly"
:value="item" :value="item"
:readonly="readonly" :readonly="readonly"
@add="handleAddPrice($event)" @add="handleAddPrice('fullPriceStepList', $event)"
@delete="handleDeletePrice($event)" @delete="handleDeletePrice('fullPriceStepList', $event)"
@changeUnit="handleUnitChange(index, $event)" @changeUnit="handleUnitChange(form.fullPriceStepList, index, ...$event)"
></sea-step> ></price-step>
</div> </div>
</template> </template>
<el-row v-else :gutter="20" class="mt-20">
<el-col :span="12">
<div v-for="(item, index) in form.freightPriceStepList" :key="index">
<price-step
ref="stepPrice"
:index="index"
:currency-list="currencyList"
:unit-list="unitList"
field-prefix="transport"
:price-name="$t('运费')"
:show-add="index === form.freightPriceStepList.length -1 && !readonly"
:value="item"
:readonly="readonly"
@add="handleAddPrice('freightPriceStepList', $event)"
@delete="handleDeletePrice('freightPriceStepList', $event)"
@changeUnit="handleUnitChange(form.freightPriceStepList, index, ...$event)"
></price-step>
</div>
</el-col>
<el-col :span="12">
<div v-for="(item, index) in form.clearancePriceStepList" :key="index">
<price-step
ref="stepPrice"
:index="index"
:currency-list="currencyList"
:unit-list="unitList"
field-prefix="clearance"
:price-name="$t('清关费')"
:show-add="index === form.clearancePriceStepList.length -1 && !readonly"
:value="item"
:readonly="readonly"
@add="handleAddPrice('clearancePriceStepList', $event)"
@delete="handleDeletePrice('clearancePriceStepList', $event)"
@changeUnit="handleUnitChange(form.clearancePriceStepList, index, ...$event)"
></price-step>
</div>
</el-col>
</el-row>
</template>
<template v-else> <template v-else>
<sea-price <sea-price
ref="seaPrice" ref="seaPrice"
...@@ -127,7 +169,7 @@ ...@@ -127,7 +169,7 @@
:unit-list="unitList" :unit-list="unitList"
:value="form" :value="form"
:readonly="readonly" :readonly="readonly"
@changeUnit="handleFormUniChange($event)" @changeUnit="handleFormUnitChange($event)"
></sea-price> ></sea-price>
</template> </template>
...@@ -211,6 +253,7 @@ import Logs from "@/views/ecw/productPrice/components/Logs.vue"; ...@@ -211,6 +253,7 @@ import Logs from "@/views/ecw/productPrice/components/Logs.vue";
import SeaStep from "@/views/ecw/productPrice/components/SeaStep.vue"; import SeaStep from "@/views/ecw/productPrice/components/SeaStep.vue";
import Template from "@/views/cms/template/index.vue"; import Template from "@/views/cms/template/index.vue";
import SeaPrice from "@/views/ecw/productPrice/components/SeaPrice.vue"; import SeaPrice from "@/views/ecw/productPrice/components/SeaPrice.vue";
import PriceStep from "@/views/ecw/productPrice/components/PriceStep.vue";
const DEFAULT_PRICE_UNIT = 1 const DEFAULT_PRICE_UNIT = 1
const DEFAULT_VOLUME_UNIT = 7 const DEFAULT_VOLUME_UNIT = 7
...@@ -218,6 +261,7 @@ const DEFAULT_WEIGHT_UNIT = 7 ...@@ -218,6 +261,7 @@ const DEFAULT_WEIGHT_UNIT = 7
export default { export default {
components: { components: {
PriceStep,
SeaPrice, SeaPrice,
Template, Logs, QuickSet, PackagingType, RoutersSelector, ProductSelector, Selector, Inputor, SeaStep }, Template, Logs, QuickSet, PackagingType, RoutersSelector, ProductSelector, Selector, Inputor, SeaStep },
filters: {parseTime}, filters: {parseTime},
...@@ -320,15 +364,17 @@ export default { ...@@ -320,15 +364,17 @@ export default {
}, },
'form.priceType'(priceType){ 'form.priceType'(priceType){
if(this.form.stepPrice === 1){
this.initStepPrice()
}
}, },
'form.needBook'(val){ 'form.needBook'(val){
if(val) this.$set(this.form, 'dayLimit', 10000) if(val) this.$set(this.form, 'dayLimit', 10000)
else delete this.form.dayLimit else delete this.form.dayLimit
}, },
'form.stepPrice'(stepPrice){ 'form.stepPrice'(stepPrice){
if(stepPrice == 1 && !this.form.priceStepList?.length){ if(this.form.stepPrice === 1){
this.handleAddPrice("priceStepList") this.initStepPrice()
} }
this.stepPrice = !!stepPrice this.stepPrice = !!stepPrice
}, },
...@@ -489,44 +535,35 @@ export default { ...@@ -489,44 +535,35 @@ export default {
}) })
}, },
methods: { methods: {
handleAddPrice(){ handleAddPrice(field, fieldPrefix){
if(!this.form.priceStepList){ if(!this.form[field]){
this.$set(this.form, 'priceStepList', []) this.$set(this.form, field, [])
} }
let allPriceUnit = DEFAULT_PRICE_UNIT let priceUnit = DEFAULT_PRICE_UNIT
let allVolumeUnit = DEFAULT_VOLUME_UNIT let volumeUnit = DEFAULT_VOLUME_UNIT
let transportPriceUnit = DEFAULT_PRICE_UNIT
let transportVolumeUnit = DEFAULT_VOLUME_UNIT
let clearancePriceUnit = DEFAULT_PRICE_UNIT
let clearanceVolumeUnit = DEFAULT_VOLUME_UNIT
let weightUnit = DEFAULT_WEIGHT_UNIT let weightUnit = DEFAULT_WEIGHT_UNIT
if(this.form[field].length){
if(this.form.priceStepList?.length){ const first = this.form[field][0]
const first = this.form.priceStepList[0] priceUnit = first[`${fieldPrefix}PriceUnit`]
allPriceUnit = first.allPriceUnit volumeUnit = first[`${fieldPrefix}VolumeUnit`]
allVolumeUnit = first.allVolumeUnit
transportPriceUnit = first.transportPriceUnit
transportVolumeUnit = first.transportVolumeUnit
clearancePriceUnit = first.clearancePriceUnit
clearanceVolumeUnit = first.clearanceVolumeUnit
weightUnit = first.weightUnit weightUnit = first.weightUnit
} }
this.form.priceStepList.push({ console.log("添加价格的默认单位", {
allPriceUnit, priceUnit,
allVolumeUnit, volumeUnit,
transportPriceUnit, weightUnit
transportVolumeUnit, })
clearancePriceUnit, this.form[field].push({
clearanceVolumeUnit, [`${fieldPrefix}PriceUnit`]: priceUnit,
[`${fieldPrefix}VolumeUnit`]: volumeUnit,
weightUnit: weightUnit, weightUnit: weightUnit,
specialList:[] specialList:[]
}) })
}, },
handleDeletePrice(index){ handleDeletePrice(field, index){
this.form.priceStepList.splice(index, 1) this.form[field].splice(index, 1)
}, },
// 阶梯价更新单位 handleUnitChange(stepPriceList, index, data){
handleUnitChange(index, data){
console.log('handleUnitChange', ...arguments) console.log('handleUnitChange', ...arguments)
if(index > 0) return if(index > 0) return
...@@ -534,8 +571,13 @@ export default { ...@@ -534,8 +571,13 @@ export default {
if(data.field === 'weightUnit' && data.type != 'clearance'){ if(data.field === 'weightUnit' && data.type != 'clearance'){
this.form.minWeightUnit = data.value this.form.minWeightUnit = data.value
} }
this.form.priceStepList.forEach(item => { stepPriceList.forEach(item => {
item[data.field] = data.value item[data.field] = data.value
if(item.packagingList?.length){
item.packagingList.forEach(p => {
p[data.field] = data.value
})
}
if(item.specialList?.length){ if(item.specialList?.length){
item.specialList.forEach(p => { item.specialList.forEach(p => {
p[data.field] = data.value p[data.field] = data.value
...@@ -543,14 +585,42 @@ export default { ...@@ -543,14 +585,42 @@ export default {
} }
}) })
}, },
// 获得用语提交的阶梯价副本
getPriceList(stepList){
if(!stepList?.length) return []
let stepPriceList = JSON.parse(JSON.stringify(stepList))
stepPriceList.forEach((item, index) => {
item.rankNum = index + 1
item.packagingList = item.packagingList.filter(p => !!p.packagingTypes?.length)
item.packagingList = item.packagingList.map( p => {
p.packagingTypes = p.packagingTypes.join(",")
return p
})
})
return stepPriceList
},
// 非阶梯价格更新单位 // 非阶梯价格更新单位
handleFormUniChange(data){ handleFormUnitChange(data){
if(this.form.specialList?.length){ if(this.form.specialList?.length){
this.form.specialList.forEach(p => { this.form.specialList.forEach(p => {
p[data.field] = data.value p[data.field] = data.value
}) })
} }
}, },
initStepPrice(){
if(this.form.priceType == 1 && !this.form.fullPriceStepList?.length){
this.handleAddPrice("fullPriceStepList", 'all')
}
if(this.form.priceType === 0){
if(!this.form.freightPriceStepList?.length){
this.handleAddPrice('freightPriceStepList', 'transport')
}
if(!this.form.clearancePriceStepList?.length){
this.handleAddPrice('clearancePriceStepList', 'clearance')
}
}
},
// force 为是否强制提交,在价格过期的时候需要确认后强制提交 // force 为是否强制提交,在价格过期的时候需要确认后强制提交
submitForm(force = false) { submitForm(force = false) {
this.$refs["form"].validate(async (valid) => { this.$refs["form"].validate(async (valid) => {
...@@ -572,39 +642,22 @@ export default { ...@@ -572,39 +642,22 @@ export default {
// specialList: this.specialProducts, // specialList: this.specialProducts,
isAllProduct: 0 isAllProduct: 0
}) })
if(this.form.stepPrice != 1){
// data.priceStepList = this.priceStepList
delete data.priceStepList
// 非阶梯价格判断是否运费(全包价是否为空) let isValid = true
if((this.form.priceType == 0 && !this.form.transportPrice) || (this.form.priceType == 1 && !this.form.allPrice)){ for (let stepPrice of this.$refs.stepPrice){
return this.$message.error(this.$t('运费/全包价不能为0')) if(!stepPrice.validate()){
isValid = false
break
} }
}else{
// 全包价 的阶段 设置和运费(全包价)不能为空
let stepPriceEmpty = []
this.form.priceStepList.forEach((item, index) => {
let notEmptyFields = ['endNum', 'weightUnit']
// 第一条阶梯的起始值可以是0,其他的不能为0
if(index){
notEmptyFields.push('startNum')
} }
notEmptyFields.forEach(field => { if(!isValid)return
// 第一个阶梯的起始值不判断0
if(index === 0 && field == 'startNum' && item[field] == 0) return
if(!item[field] || item[field].toString().trim() == ''){ // 全包价
stepPriceEmpty.push({index, field}) if(this.form.priceType == 1) {
} data.fullPriceStepList = this.getPriceList(this.form.fullPriceStepList)
}) }else{
if((this.form.priceType == 0 && !item.transportPrice) || (this.form.priceType == 1 && !item.allPrice)){ data.clearancePriceStepList = this.getPriceList(this.form.clearancePriceStepList)
stepPriceEmpty.push({index, field: !item.transportPrice ? 'transportPrice' : 'allPrice'}) data.freightPriceStepList = this.getPriceList(this.form.freightPriceStepList)
}
})
if(stepPriceEmpty.length){
console.log('stepPriceEmpty', stepPriceEmpty)
return this.$message.error(this.$t('阶梯和价格设置不能留空'))
}
} }
// 设置了有效期,且已过期则给提示 // 设置了有效期,且已过期则给提示
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment