Commit 61d2ddee authored by 邓春圆's avatar 邓春圆

Merge remote-tracking branch 'origin/dev' into dev

parents 54cd0a43 2bec96f8
......@@ -99,9 +99,7 @@ let autoTransCnt = 0
async function translate(obj){
// 对未翻译内容调用百度翻译进行翻译操作,有变量的不做处理
for(let text in obj){
if(obj[text] || text.includes('{'))continue
// 只有空格的不翻译
if(text.trim() === '')continue
if(obj[text] || text.trim() === '')continue
try{
const textEn = await translateText(text)
console.log(`${text} => ${textEn}\n`)
......
......@@ -3889,7 +3889,7 @@
"公司中文名称": "Chinese name of the company",
"展示": "show",
"无归属订单": "Unassigned Order",
"最多可放入{quantity}": "",
"最多可放入{quantity}": "Up to {quantity} can be placed",
"可放入仓方数": "Number of storage units that can be placed",
"可放入收费方数": "Number of charging parties that can be placed",
"入仓方数": "Number of parties entering the warehouse",
......@@ -4426,7 +4426,7 @@
"还有{days}天到期": "Due in {days} days",
"请选择客户经理。": "Please select an account manager.",
"回收客户": "Recycling customers",
"是否要回收当前{name}": "",
"是否要回收当前{name}": "Do you want to recycle the current {name}",
"回收成功。": "Recycling successful.",
"已完成目标值": "Target value completed",
"请输入目标单位": "Please enter the target unit",
......@@ -4523,12 +4523,12 @@
"所属目的国家": "Destination country",
" ": "",
"区间设置不完整,将被忽略": "Incomplete interval settings will be ignored",
"{n}个全包阶梯价": "",
"{n}个运费阶梯价": "",
"{n}个清关费阶梯价": "",
"已选择{route}条路线,{product}个商品": "",
"{n}个全包阶梯价": "{n} All inclusive tiered pricing",
"{n}个运费阶梯价": "{n} Shipping cost tiered pricing",
"{n}个清关费阶梯价": "{n} Staircase price for individual customs clearance fees",
"已选择{route}条路线,{product}个商品": "{route} selected, {product} products",
";确认提交修改?": "; Confirm submitting modifications?",
"空运{type}设置": "",
"空运{type}设置": "Air freight {type} settings",
"未选择包装类型将被忽略": "No packaging type selected will be ignored",
"请输入加价金额": "Please enter the markup amount",
"运费快捷加价": "Quick freight markup",
......@@ -4537,7 +4537,7 @@
"提交清关费": "Submit customs clearance fee",
"全包价快捷加价": "Quick and all inclusive price increase",
"提交全包价": "Submit full package price",
"第{no}阶段": "",
"第{no}阶段": "Stage {no}",
"线路重量上限": "Upper limit of line weight",
"包含": "contain",
"不包含": "Excluding",
......@@ -4545,5 +4545,14 @@
"运费+清关费": "Freight+customs clearance fee",
"未设置全包价阶梯价": "No fully inclusive tiered pricing has been set",
"未设置运费阶梯价": "No freight tiered pricing has been set",
"渠道包装清关费": "Channel packaging customs clearance fee"
}
"渠道包装清关费": "Channel packaging customs clearance fee",
"所属国家": "Country",
"请输入所属国家": "Please enter your country of origin",
"包装加价": "Packaging markup",
"海运运费价格设置": "Ocean freight price setting",
"海运清关费价格设置": "Price setting for sea freight customs clearance fees",
"请设置{priceName}第{index}阶段的起始值": "Please set the starting value for the {index} stage of {priceName}",
"请设置{priceName}第{index}阶段的结束值": "Please set the end value for the {index} stage of {priceName}",
"请设置第{index}阶段的{priceName}": "Please set the {priceName} for the {index} stage",
"请设置第{index}阶段的包装类型{i}的{priceName}": "Please set the {priceName} for the packaging type {i} in the {index} stage"
}
\ No newline at end of file
......@@ -756,6 +756,10 @@ export default {
if(row['discountFreightPrice'] && row['discountFreightPrice'] > 0){
freightFields.push({field: 'afterDiscountSeaFreight', label: this.$t('优惠后单价')})
}
// 包装加价
if(row['packagingFreightPrice'] && row['packagingFreightPrice'] > 0){
freightFields.push({field: 'packagingFreightPrice', label: this.$t('包装加价')})
}
freightFields.push({field: 'oneSeaFreight', label: this.$t('成交单价')})
console.log({freightFields})
freightFields.forEach(item => {
......@@ -790,6 +794,10 @@ export default {
if(row['discountClearanceFeePrice'] && row['discountClearanceFeePrice'] > 0){
clearanceFields.push({field: 'afterDiscountClearanceFreight', label: this.$t('优惠后单价')})
}
// 包装加价
if(row['packagingClearanceFeePrice'] && row['packagingClearanceFeePrice'] > 0){
clearanceFields.push({field: 'packagingClearanceFeePrice', label: this.$t('包装加价')})
}
clearanceFields.push({field: 'oneClearanceFreight', label: this.$t('成交单价')})
clearanceFields.forEach(item => {
if(row[item.field]){
......
......@@ -28,131 +28,81 @@
:label="$t('最小起计量')"
:prop="`minWeight`"
>
<inputor default2="0" v-model.number="form.minWeight" type="number" class="w-100" :rules="{validator: priceValidator, trigger: 'blur', message: '数量错误'}"/>
/ <selector v-model="form.minWeightUnit" :options="unitList" :label-field="$l(null, 'title')" value-field="id" defaultable2 class="w-100" disabled />
</el-form-item>
<!--阶梯订单-->
<template v-if="form.stepPrice==1" >
<div v-for="(item, index) in form.priceStepList" :key="index">
<div style="font-size:14px; margin:10px 0">
{{$t('第{index}阶梯定价方案', {index: index+1})}}
<template v-if="index == form.priceStepList.length - 1">
<el-link type="primary" @click.native="form.priceStepList.push({})">{{$t('添加区间')}}</el-link>
<el-divider v-if="index" direction="vertical"></el-divider>
<el-link v-if="index" type="danger" @click.native="form.priceStepList.splice(index, 1)">{{$t('删除')}}</el-link>
</template>
</div>
<div v-if="willBeIgnore(item)" style="color:red">{{$t('此阶梯未设置阶梯和价格,将会被忽略')}}</div>
<div v-else-if="!isStepPriceOk(item)" style="color:red">{{$t('此阶梯价信息设置不完整')}}</div>
<el-form-item :label="$t(`第{index}阶梯`, {index: index+1})">
<el-input v-model="item.startNum" type="number" placeholder="" class="w100"></el-input>
-
<el-input v-model="item.endNum" type="number" placeholder="" class="w100"></el-input>
/
<selector :disabled="index > 0" @input="syncAllUnit" v-model="item.weightUnit" :options="unitList" :label-field="$l('title')" value-field="id" defaultable2 class="w100" />
</el-form-item>
<el-form-item :label="$t('默认运费')" v-if="form.priceType != 1" :key="`transportPrice-${index}`">
<inputor default2="0" v-model.number="item.transportPrice" type="number" :placeholder="$t('整数或者两位小数')" class="w100 mr10" />
<selector :disabled="index > 0" @input="syncAllUnit" v-model="item.transportPriceUnit" :options="currencyList" :label-field="$l('title')" value-field="id" defaultable2 class="w100" />
/ <selector :disabled="index > 0" @input="syncAllUnit" v-model="item.transportVolumeUnit" :options="unitList" :label-field="$l('title')" value-field="id" defaultable2 class="w100" />
</el-form-item>
<el-form-item :label="$t('默认清关费')" v-if="form.priceType != 1 && type != 'air'">
<inputor default2="0" v-model.number="item.clearancePrice" type="number" :placeholder="$t('整数或者两位小数')" class="w100 mr10" />
<selector :disabled="index > 0" @input="syncAllUnit" v-model="item.clearancePriceUnit" :options="currencyList" :label-field="$l('title')" value-field="id" defaultable2 class="w100" />
/ <selector :disabled="index > 0" @input="syncAllUnit" v-model="item.clearanceVolumeUnit" :options="unitList" :label-field="$l('title')" value-field="id" defaultable2 class="w100" />
</el-form-item>
<el-form-item :label="$t('默认全包价')" v-if="form.priceType == 1" :key="`allPrice-${index}`">
<inputor default2="0" v-model.number="item.allPrice" type="number" :placeholder="$t('整数或者两位小数')" class="w100 mr10" />
<selector :disabled="index > 0" @input="syncAllUnit" v-model="item.allPriceUnit" :options="currencyList" :label-field="$l('title')" value-field="id" defaultable2 class="w100" />
/ <selector :disabled="index > 0" @input="syncAllUnit" v-model="item.allVolumeUnit" :options="unitList" :label-field="$l('title')" value-field="id" defaultable2 class="w100" />
</el-form-item>
</div>
</template>
<!--非阶梯订单-->
<template v-else>
<el-form-item :label="$t('默认全包价')" v-if="form.priceType == 1">
<inputor default2="0" v-model.number="form.allPrice" type="number" :placeholder="$t('整数或者两位小数')" class="w100 mr10" />
<selector v-model="form.allPriceUnit" @input="syncAllUnit" :options="currencyList" :label-field="$l('title')" value-field="id" defaultable2 class="w100" />
/ <selector v-model="form.allVolumeUnit" @input="syncAllUnit" :options="unitList" :label-field="$l('title')" value-field="id" defaultable2 class="w100" />
</el-form-item>
<template v-else>
<el-form-item :label="$t('默认运费')" prop="transportPrice">
<selector v-model="form.transportPriceUnit" @input="syncAllUnit" :options="currencyList" :label-field="$l('title')" value-field="id" defaultable2 class="w-100" />
<inputor default2="0" v-model.number="form.transportPrice" type="number" :placeholder="$t('整数或者两位小数')" class="w-100 ml-10 mr-10" />
/ <selector v-model="form.transportVolumeUnit" @input="syncAllUnit" :options="unitList" :label-field="$l('title')" value-field="id" defaultable2 class="w-100" />
</el-form-item>
<el-form-item :label="$t('默认清关费')" prop="clearancePrice" v-if="type != 'air'">
<selector v-model="form.clearancePriceUnit" @input="syncAllUnit" :options="currencyList" :label-field="$l('title')" value-field="id" defaultable2 class="w-100" />
<inputor default2="0" v-model.number="form.clearancePrice" type="number" :placeholder="$t('整数或者两位小数')" class="w-100 ml-10 mr-10" />
/ <selector v-model="form.clearanceVolumeUnit" @input="syncAllUnit" :options="unitList" :label-field="$l('title')" value-field="id" defaultable2 class="w-100" />
</el-form-item>
</template>
</template>
<!--特需-->
<template v-if="form.priceType==1">
<el-form-item
v-for="(special, specialIndex) in form.specialList"
:label="getDictDataLabel(DICT_TYPE.ECW_SPECIAL_REQ_FOR_LINE_PRODUCTS, special.specialDictType) + $t('全包价')"
:key="specialIndex + 'transport'">
<selector disabled v-model="special.allPriceUnit" :options="currencyList" :label-field="$l('title')" value-field="id" defaultable2 class="w-100" />
<inputor default2="0" v-model.number="special.allPrice" type="number" :placeholder="$t('整数或者两位小数')" class="w-100 ml-10 mr-10" />
/ <selector disabled v-model="special.allVolumeUnit" :options="unitList" :label-field="$l('title')" value-field="id" defaultable2 class="w-100" />
</el-form-item>
</template>
<template v-else v-for="(special, specialIndex) in form.specialList">
<el-form-item
:label="getDictDataLabel(DICT_TYPE.ECW_SPECIAL_REQ_FOR_LINE_PRODUCTS, special.specialDictType) + $t('运费')"
:key="specialIndex + 'transport'">
<selector disabled v-model="special.transportPriceUnit" :options="currencyList" :label-field="$l('title')" value-field="id" defaultable2 class="w-100" />
<inputor default2="0" v-model.number="special.transportPrice" type="number" :placeholder="$t('整数或者两位小数')" class="w-100 ml-10 mr-10" />
/ <selector disabled v-model="special.transportVolumeUnit" :options="unitList" :label-field="$l('title')" value-field="id" defaultable2 class="w-100" />
</el-form-item>
<el-form-item
v-if="type != 'air'"
:label="getDictDataLabel(DICT_TYPE.ECW_SPECIAL_REQ_FOR_LINE_PRODUCTS, special.specialDictType) + $t('清关费')"
:key="specialIndex + 'clearance'">
<selector disabled v-model="special.clearancePriceUnit" :options="currencyList" :label-field="$l('title')" value-field="id" defaultable2 class="w-100" />
<inputor default2="0" v-model.number="special.clearancePrice" type="number" :placeholder="$t('整数或者两位小数')" class="w-100 ml-10 mr-10" />
/ <selector disabled v-model="special.clearanceVolumeUnit" :options="unitList" :label-field="$l('title')" value-field="id" defaultable2 class="w-100" />
</el-form-item>
</template>
<!-- <el-form-item :label="$t('是否预付')" prop="advanceStatus">
<dict-selector form-type="radio" :type="DICT_TYPE.ADVANCE_STATUS" v-model="form.advanceStatus" />
</el-form-item> -->
<el-form-item :label="$t('价格有效期')">
<el-date-picker v-model="form.validateStartDate" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
-
<el-date-picker v-model="form.validateEndDate" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
<el-input-number v-model="form.minWeight" class="w-100" :min="0" :controls="false"/>
/ <selector v-model="form.minWeightUnit" :options="unitList" :label-field="$l(null, 'title')" value-field="id" class="w-100" disabled />
</el-form-item>
</el-col>
<el-col :span="12" v-if="form.stepPrice">
<h2>{{$t('快捷设置')}}</h2>
<div class="flex items-center">
{{$t('批量加价')}}+
<el-input v-model="quickForm.plus" class="w-100 ml-10 mr-10" :disabled="!!quickForm.minus"></el-input>
<selector disabled v-model="currencyAndUnit.currency" :options="currencyList" :label-field="$l('title')" value-field="id" class="w-100" />
/ <selector disabled v-model="currencyAndUnit.unit" :options="unitList" :label-field="$l('title')" value-field="id" class="w-100" />
<div class="ml-10">{{$t('*针对所有价格加价')}}</div>
</div>
<div class="flex items-center mt-10">
{{$t('批量减价')}} -
<el-input v-model="quickForm.minus" class="w-100 ml-10 mr-10" :disabled="!!quickForm.plus"></el-input>
<selector disabled v-model="currencyAndUnit.currency" :options="currencyList" :label-field="$l('title')" value-field="id" class="w-100" />
/ <selector disabled v-model="currencyAndUnit.unit" :options="unitList" :label-field="$l('title')" value-field="id" class="w-100" />
<div class="ml-10">{{$t('*针对所有价格加价')}}</div>
</div>
<div class="mt-10">
<el-button @click="quickSet" type="primary" :disabled="!quickForm.plus && !quickForm.minus">{{$t('确定')}}</el-button>
</div>
<el-col :span="12">
<quick-set :unit-list="unitList" :currency-list="currencyList" :value="form"></quick-set>
</el-col>
</el-row>
<template v-if="form.stepPrice">
<!--全包价-->
<template v-if="form.priceType==1" >
<div v-for="(item, index) in form.fullPriceStepList" :key="index">
<price-step
ref="stepPrice"
:index="index"
:currency-list="currencyList"
:unit-list="unitList"
field-prefix="all"
:price-name="$t('全包价')"
:show-add="index === form.fullPriceStepList.length -1"
:value="item"
@add="handleAddPrice('fullPriceStepList', $event)"
@delete="handleDeletePrice('fullPriceStepList', $event)"
@changeUnit="handleUnitChange(form.fullPriceStepList, index, ...$event)"
></price-step>
</div>
</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"
:value="item"
@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"
:value="item"
@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>
<sea-price
ref="seaPrice"
:price-type="form.priceType"
:currency-list="currencyList"
:unit-list="unitList"
:value="form"
@changeUnit="handleFormUnitChange($event)"
></sea-price>
</template>
</el-card>
......@@ -203,9 +153,17 @@ import Selector from '@/components/Selector'
import Inputor from '@/components/Inputor'
import Decimal from 'decimal.js'
import {getProduct} from "@/api/ecw/product";
import QuickSet from "@/views/ecw/productPrice/components/QuickSet.vue";
import PriceStep from "@/views/ecw/productPrice/components/PriceStep.vue";
import SeaPrice from "@/views/ecw/productPrice/components/SeaPrice.vue";
import Template from "@/views/cms/template/index.vue";
const DEFAULT_PRICE_UNIT = 1
const DEFAULT_VOLUME_UNIT = 7
const DEFAULT_WEIGHT_UNIT = 7
export default {
components: { RoutersSelector, ProductsSelector, Selector, Inputor },
components: {Template, SeaPrice, PriceStep, QuickSet, RoutersSelector, ProductsSelector, Selector, Inputor },
data() {
return {
checkList: [],
......@@ -214,7 +172,11 @@ export default {
specialList: [],
priceStepList: [],
stepPrice: 0,
priceType: null
priceType: null,
minWeightUnit: null,
allVolumeUnit: DEFAULT_VOLUME_UNIT,
transportVolumeUnit: DEFAULT_VOLUME_UNIT,
clearanceVolumeUnit: DEFAULT_VOLUME_UNIT,
// advanceStatus: 0,
// needBook: 0,
// dayLimit: 10000
......@@ -266,42 +228,6 @@ export default {
return !content && content !== 0 && content !== '0'
}
},
// 判断某个阶梯价是否会被忽略
willBeIgnore(){
return (stepPrice) => {
if(!this.isEmpty(stepPrice.startNum) || !this.isEmpty(stepPrice.endNum)) return false
if(this.form.priceType == 1 && !this.isEmpty(stepPrice.allPrice)) return false
if(this.form.priceType != 1 && !this.isEmpty(stepPrice.transportPrice) && !this.isEmpty(stepPrice.clearancePrice)) return false
return true
}
},
// 判断阶梯价是否设置不完整
isStepPriceOk(){
return (stepPrice) => {
console.log({
stepPrice,
startNum: this.isEmpty(stepPrice.startNum),
endNum:this.isEmpty(stepPrice.endNum),
allPrice: this.isEmpty(stepPrice.allPrice),
allPriceUnit: this.isEmpty(stepPrice.allPriceUnit),
allVolumeUnit: this.isEmpty(stepPrice.allVolumeUnit),
transportPrice: this.isEmpty(stepPrice.transportPrice),
transportPriceUnit: this.isEmpty(stepPrice.transportPriceUnit),
transportVolumeUnit: this.isEmpty(stepPrice.transportVolumeUnit),
priceType: this.form.priceType
})
if(this.isEmpty(stepPrice.startNum) || this.isEmpty(stepPrice.endNum)) return false
if(this.form.priceType == 1 && (this.isEmpty(stepPrice.allPrice) || this.isEmpty(stepPrice.allPriceUnit) || this.isEmpty(stepPrice.allVolumeUnit))){
console.log('全包价设置不完整')
return false
}
else if(this.form.priceType != 1 && (this.isEmpty(stepPrice.transportPrice) || this.isEmpty(stepPrice.transportPriceUnit) || this.isEmpty(stepPrice.transportVolumeUnit))){ // 清关费可能为0或者空
console.log('非全报价,未设置完整')
return false
}
return true
}
},
},
watch: {
checkList() { //选择路线
......@@ -317,24 +243,16 @@ export default {
this.$set(this.form, 'productType', this.product.typeId)
},
'form.stepPrice'(stepPrice){
if(stepPrice == 1 && !this.form.priceStepList.length){
this.form.priceStepList = [{}, {}]
}
if(this.form.stepPrice === 1){
this.initStepPrice()
}
this.syncMinWeightUnit()
},
selectedRoutes(routers) {
let transportIds = []
routers.forEach(item => {
item.shippingChannelId = item.channelId
transportIds.push(+item.transportId)
})
// 如果只选择了空运(3),则默认体积单位改成千克
transportIds = new Set(transportIds)
console.log(transportIds)
window.transportIds = transportIds
if(transportIds.size == 1 && transportIds.has(3)){
this.setDefaultVolumeUnit(6)
}else this.setDefaultVolumeUnit(7)
'form.priceType'(priceType){
if(this.form.stepPrice === 1){
this.initStepPrice()
}
this.syncMinWeightUnit()
},
'form.needBook'(val){
if(val) this.$set(this.form, 'dayLimit', 10000)
......@@ -342,17 +260,10 @@ export default {
},
},
async created() {
getCurrencyList().then(res => this.currencyList = res.data)
getUnitList().then(res => this.unitList = res.data)
this.currencyList = (await getCurrencyList())?.data || []
this.unitList = (await getUnitList())?.data || []
await this.$nextTick()
// 如果是空运,阶梯价格默认为1
if(this.type == 'air'){
this.$set(this.form, 'stepPrice', 1)
}
// 默认单位,空运千克,海运立方米
this.setDefaultVolumeUnit(this.type == 'air' ? 6 : 7)
// 如果是复制,则获取数据并填充,先复制,然后填充特需,避免数据的特需不全导致部分不显示
if(this.$route.query.templateId){
......@@ -360,19 +271,18 @@ export default {
}
// 从价格中获取特需的默认单位
const obj = (this.form.stepPrice ? this.form.priceStepList[0] : this.form) || {}
this.getDictDatas(this.DICT_TYPE.ECW_SPECIAL_REQ_FOR_LINE_PRODUCTS).forEach(item => {
// 没有的才push,已有的可能是从复制模板携带过来的数据
if(!this.form.specialList.find(special => special.specialDictType == item.value)) {
console.log('特需push', item.value)
this.form.specialList.push({
"clearancePrice": null,
"clearancePriceUnit": obj.clearancePriceUnit,
"clearanceVolumeUnit": obj.clearanceVolumeUnit,
"clearancePriceUnit": DEFAULT_PRICE_UNIT,
"clearanceVolumeUnit": DEFAULT_VOLUME_UNIT,
"specialDictType": item.value,
"transportPrice": null,
"transportPriceUnit": obj.transportPriceUnit,
"transportVolumeUnit": obj.transportVolumeUnit,
"transportPriceUnit": DEFAULT_PRICE_UNIT,
"transportVolumeUnit": DEFAULT_VOLUME_UNIT,
})
}else console.log('已存在特需', item.value)
})
......@@ -453,76 +363,116 @@ export default {
this.$refs.productSelector.choose(res.data)
})*/
},
// 同步全部单位
syncAllUnit(){
let obj = this.form.stepPrice == 1 ? this.form.priceStepList[0] : this.form
let fields = {}
// 全包价
if(this.form.priceType == 1){
fields = {
allPriceUnit: obj['allPriceUnit'],
allVolumeUnit: obj['allVolumeUnit']
}
}else{
fields = {
transportPriceUnit: obj.transportPriceUnit,
transportVolumeUnit: obj.transportVolumeUnit,
clearancePriceUnit: obj.clearancePriceUnit,
clearanceVolumeUnit: obj.clearanceVolumeUnit,
// 设置最小起计量单位
syncMinWeightUnit(){
// 如果是阶梯价
if(this.form.stepPrice){
const field = this.form.priceType === 1 ? "fullPriceStepList" : "freightPriceStepList"
const stepPriceList = this.form[field]
if(stepPriceList?.length){
this.form.minWeightUnit = stepPriceList[0]?.weightUnit || DEFAULT_WEIGHT_UNIT
}else {
this.form.minWeightUnit = DEFAULT_WEIGHT_UNIT
}
}else{
this.form.minWeightUnit = this.form[this.form.priceType === 1 ? 'allVolumeUnit' : 'transportVolumeUnit'] || DEFAULT_WEIGHT_UNIT
}
},
handleAddPrice(field, fieldPrefix){
if(!this.form[field]){
this.$set(this.form, field, [])
}
// 全包价还需要同步阶梯的重量单位
if(this.form.stepPrice == 1){
fields['weightUnit'] = obj.weightUnit
let priceUnit = DEFAULT_PRICE_UNIT
let volumeUnit = DEFAULT_VOLUME_UNIT
let weightUnit = DEFAULT_WEIGHT_UNIT
if(this.form[field].length){
const first = this.form[field][0]
priceUnit = first[`${fieldPrefix}PriceUnit`]
volumeUnit = first[`${fieldPrefix}VolumeUnit`]
weightUnit = first.weightUnit
}
this.syncSpecialUnit(fields)
console.log("添加价格的默认单位", {
priceUnit,
volumeUnit,
weightUnit
})
this.form[field].push({
[`${fieldPrefix}PriceUnit`]: priceUnit,
[`${fieldPrefix}VolumeUnit`]: volumeUnit,
weightUnit: weightUnit,
specialList:[]
})
},
handleDeletePrice(field, index){
this.form[field].splice(index, 1)
},
// 同步特需的货币单位和体积单位
syncSpecialUnit(obj){
console.log('syncSpecialUnit', obj)
if(!obj) return
// 同步特需单位
this.form.specialList.forEach(item => {
Object.assign(item, obj)
handleUnitChange(stepPriceList, index, data){
console.log('handleUnitChange', ...arguments)
if(index > 0) return
// 如果是重量单位,且不是清关费想换的,则需要同步最小起计量单位
if(data.field === 'weightUnit' && data.type != 'clearance'){
this.form.minWeightUnit = data.value
}
stepPriceList.forEach(item => {
item[data.field] = data.value
if(item.packagingList?.length){
item.packagingList.forEach(p => {
if(data.field.indexOf("PriceUnit") > -1){
p['packagingPriceUnit'] = data.value
}
if(data.field.indexOf("VolumeUnit") > -1){
p['packagingVolumeUnit'] = data.value
}
})
}
if(item.specialList?.length){
item.specialList.forEach(p => {
p[data.field] = data.value
})
}
})
},
// 如果是阶梯价则需要同步其他阶梯
if(this.form.stepPrice == 1){
this.form.priceStepList.forEach((item, index) => {
this.$set(this.form.priceStepList, index, Object.assign(item, obj))
// 获得用语提交的阶梯价副本
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
},
// 非阶梯价格更新单位
handleFormUnitChange(data){
console.log("handleFormUnitChange", {...data})
// 海运非阶梯价没有重量单位,所以按照体积单位同步最小起计量单位
if(data.field === 'transportVolumeUnit' || data.field == 'allVolumeUnit'){
this.form.minWeightUnit = data.value
}
// 不是阶梯价需要 同步最小起计量
if(obj['transportVolumeUnit'] || obj['allVolumeUnit']){
this.$set(this.form, 'minWeightUnit', obj['transportVolumeUnit'] || obj['allVolumeUnit'])
}
if(this.form.specialList?.length){
this.form.specialList.forEach(p => {
p[data.field] = data.value
})
}
},
// 价格校验器
priceValidator(rule, value, callback){
if(!value || value == '') return callback()
value = parseFloat(value)
if(!value || value < 0){
return callback(new Error('价格错误'))
initStepPrice(){
if(this.form.priceType == 1 && !this.form.fullPriceStepList?.length){
this.handleAddPrice("fullPriceStepList", 'all')
}
callback()
},
setDefaultVolumeUnit(unit){
this.$set(this.form, 'transportVolumeUnit', unit)
this.$set(this.form, 'clearanceVolumeUnit', unit)
this.$set(this.form, 'allVolumeUnit', unit)
this.$set(this.form, 'minWeightUnit', unit)
console.log(this.form.priceStepList, this.form.stepPrice)
// 阶梯价
if(this.form.stepPrice == 1 && this.form.priceStepList?.length){
this.form.priceStepList.forEach(item => {
this.$set(item, 'transportVolumeUnit', unit)
this.$set(item, 'clearanceVolumeUnit', unit)
this.$set(item, 'allVolumeUnit', unit)
this.$set(item, 'weightUnit', unit)
})
if(this.form.priceType === 0){
if(!this.form.freightPriceStepList?.length){
this.handleAddPrice('freightPriceStepList', 'transport')
}
if(!this.form.clearancePriceStepList?.length){
this.handleAddPrice('clearancePriceStepList', 'clearance')
}
}
},
submitForm() {
......@@ -550,33 +500,28 @@ export default {
if(!data.isAllProduct && (!data.productIdList || !data.productIdList.length)){
return this.$message.error('请选择商品')
}
/* if(this.form.stepPrice == 1){
data.priceStepList = this.form.priceStepList
} */
// 没有设置阶梯价格则不提交priceStepList
if(data.stepPrice != 1){
delete data.priceStepList
}else{
// 根据23-11-23 21点左右的群讨论,阶梯价如果留空则不提交,如果全部为空则不提交此字段
// 相关工单 https://zentao.test.jdshangmen.com/bug-view-5460.html
// 填写不完整的给提示
let notOk = []
data.priceStepList.forEach((item, index) => {
if(!this.willBeIgnore(item) && !this.isStepPriceOk(item)){
notOk.push(index + 1)
// 阶梯价校验
if(this.$refs.stepPrice){
let isValid = true
for (let stepPrice of this.$refs.stepPrice){
if(!stepPrice.validate()){
isValid = false
break
}
}
})
if(notOk.length){
return this.$confirm(this.$t("第{steps}阶梯设置不完整", {steps: notOk.join(",")}))
}
// 删除未填写的阶梯价
data.priceStepList = data.priceStepList.filter(item => {
return !this.willBeIgnore(item)
})
if(!data.priceStepList.length){
delete data.priceStepList
}
if(!isValid)return
}
// 全包价
if(this.form.priceType == 1) {
data.fullPriceStepList = this.getPriceList(this.form.fullPriceStepList)
delete data.clearancePriceStepList
delete data.freightPriceStepList
}else{
data.clearancePriceStepList = this.getPriceList(this.form.clearancePriceStepList)
data.freightPriceStepList = this.getPriceList(this.form.freightPriceStepList)
delete data.fullPriceStepList
}
data.lineChannelList = this.selectedRoutes
......
......@@ -102,21 +102,34 @@ export default {
const index = this.index
const errors = []
// 区间设置检查
if(index > 0 && !this.value.startNum){
errors.push(`请设置${this.priceName}${index+1}阶段的起始值`)
if(typeof this.value.startNum != "number"){
errors.push(this.$t("请设置{priceName}第{index}阶段的起始值", {
index: index + 1,
priceName: this.priceName
}))
}
if(!this.value.endNum){
errors.push(`请设置${this.priceName}${index+1}阶段的结束值`)
errors.push(this.$t("请设置{priceName}第{index}阶段的结束值", {
index: index + 1,
priceName: this.priceName
}))
}
// 价格检查
if(!this.validatePrice(this.value[`${this.fieldPrefix}Price`])){
errors.push(`请设置第${index+1}阶段的${this.priceName}`)
errors.push(this.$t("请设置第{index}阶段的{priceName}", {
index: index+1,
priceName: this.priceName
}))
}
// 包装价格检查
if(this.value.packagingList?.length){
this.value.packagingList.forEach((item, i) => {
if(item.packagingTypes?.length && !this.validatePrice(item.packagingPrice)){
errors.push(`请设置第${index+1}阶段的包装类型${i+1}${this.priceName}`)
errors.push(this.$t("请设置第{index}阶段的包装类型{i}的{priceName}", {
index: index+1,
i: i+1,
priceName: this.priceName
}))
}
})
}
......
......@@ -93,118 +93,133 @@ export default {
</script>
<template>
<div>
<el-form-item :label="$t('默认运费')" v-if="!priceType">
<el-input-number v-model="value[`transportPrice`]" :placeholder="$t('整数或者两位小数')" :controls="false":disabled="readonly" class="w-100 mr-10"/>
<selector
:disabled="readonly"
v-model="value[`transportPriceUnit`]"
:options="currencyList"
:label-field="$l(null, 'title')"
@input="$emit('changeUnit', {
<el-row>
<el-col :span="12">
<div class="page-title">{{$t('海运运费价格设置')}}</div>
<el-form-item :label="$t('默认运费')" v-if="!priceType">
<el-input-number v-model="value[`transportPrice`]" :placeholder="$t('整数或者两位小数')" :controls="false":disabled="readonly" class="w-100 mr-10"/>
<selector
:disabled="readonly"
v-model="value[`transportPriceUnit`]"
:options="currencyList"
:label-field="$l(null, 'title')"
@input="$emit('changeUnit', {
value: $event,
field: `transportPriceUnit`
})"
value-field="id"
class="w-100" />
/
<selector
:disabled="readonly"
v-model="value[`transportVolumeUnit`]"
:options="unitList"
:label-field="$l(null, 'title')"
@input="$emit('changeUnit', {
value-field="id"
class="w-100" />
/
<selector
:disabled="readonly"
v-model="value[`transportVolumeUnit`]"
:options="unitList"
:label-field="$l(null, 'title')"
@input="$emit('changeUnit', {
value: $event,
field: `transportVolumeUnit`
})"
value-field="id"
class="w-100" />
</el-form-item>
<el-form-item :label="$t('默认清关费')" v-if="!priceType">
<el-input-number v-model="value[`clearancePrice`]" :placeholder="$t('整数或者两位小数')" :disabled="readonly" :controls="false" class="w-100 mr-10"/>
<selector
:disabled="readonly"
v-model="value[`clearancePriceUnit`]"
:options="currencyList"
:label-field="$l(null, 'title')"
@input="$emit('changeUnit', {
value-field="id"
class="w-100" />
</el-form-item>
<el-form-item :label="$t('默认全包价')" v-if="priceType">
<el-input-number v-model="value[`allPrice`]" :placeholder="$t('整数或者两位小数')" :disabled="readonly" :controls="false" class="w-100 mr-10"/>
<selector
:disabled="readonly"
v-model="value[`allPriceUnit`]"
:options="currencyList"
:label-field="$l(null, 'title')"
@input="$emit('changeUnit', {
value: $event,
field: `clearancePriceUnit`
field: `allPriceUnit`
})"
value-field="id"
class="w-100" />
/
<selector
:disabled="readonly"
v-model="value[`clearanceVolumeUnit`]"
:options="unitList"
:label-field="$l(null, 'title')"
@input="$emit('changeUnit', {
value-field="id"
class="w-100" />
/
<selector
:disabled="readonly"
v-model="value[`allVolumeUnit`]"
:options="unitList"
:label-field="$l(null, 'title')"
@input="$emit('changeUnit', {
value: $event,
field: `clearanceVolumeUnit`
field: `allVolumeUnit`
})"
value-field="id"
class="w-100" />
</el-form-item>
<el-form-item :label="$t('默认全包价')" v-if="priceType">
<el-input-number v-model="value[`allPrice`]" :placeholder="$t('整数或者两位小数')" :disabled="readonly" :controls="false" class="w-100 mr-10"/>
<selector
:disabled="readonly"
v-model="value[`allPriceUnit`]"
:options="currencyList"
:label-field="$l(null, 'title')"
@input="$emit('changeUnit', {
value-field="id"
class="w-100" />
</el-form-item>
<!--特性加价-->
<template v-for="(special, specialIndex) in value.specialList">
<div :key="specialIndex + 'transport'">
<el-form-item
v-if="!priceType"
:label="getDictDataLabel(DICT_TYPE.ECW_SPECIAL_REQ_FOR_LINE_PRODUCTS, special.specialDictType) + $t('运费')"
>
<el-input-number v-model.number="special[`transportPrice`]" :controls="false" :min="0" :disabled="readonly" :placeholder="$t('整数或者两位小数')" class="w-100 mr-10" />
<selector disabled v-model="special[`transportPriceUnit`]" :options="currencyList" :label-field="$l(null, 'title')" value-field="id" defaultable2 class="w-100 mr-10" />
<span class="mr-10">/</span>
<selector disabled v-model="special[`transportVolumeUnit`]" :options="unitList" :label-field="$l(null, 'title')" value-field="id" defaultable2 class="w-100" />
</el-form-item>
<el-form-item
v-if="priceType"
:label="getDictDataLabel(DICT_TYPE.ECW_SPECIAL_REQ_FOR_LINE_PRODUCTS, special.specialDictType) + $t('全包价')"
>
<el-input-number v-model.number="special[`allPrice`]" :controls="false" :min="0" :disabled="readonly" :placeholder="$t('整数或者两位小数')" class="w-100 mr-10" />
<selector disabled v-model="special[`allPriceUnit`]" :options="currencyList" :label-field="$l(null, 'title')" value-field="id" defaultable2 class="w-100 mr-10" />
<span class="mr-10">/</span>
<selector disabled v-model="special[`allVolumeUnit`]" :options="unitList" :label-field="$l(null, 'title')" value-field="id" defaultable2 class="w-100" />
</el-form-item>
</div>
</template>
</el-col>
<el-col :span="12" v-if="!priceType">
<div class="page-title">{{$t('海运清关费价格设置')}}</div>
<el-form-item :label="$t('默认清关费')">
<el-input-number v-model="value[`clearancePrice`]" :placeholder="$t('整数或者两位小数')" :disabled="readonly" :controls="false" class="w-100 mr-10"/>
<selector
:disabled="readonly"
v-model="value[`clearancePriceUnit`]"
:options="currencyList"
:label-field="$l(null, 'title')"
@input="$emit('changeUnit', {
value: $event,
field: `allPriceUnit`
field: `clearancePriceUnit`
})"
value-field="id"
class="w-100" />
/
<selector
:disabled="readonly"
v-model="value[`allVolumeUnit`]"
:options="unitList"
:label-field="$l(null, 'title')"
@input="$emit('changeUnit', {
value-field="id"
class="w-100" />
/
<selector
:disabled="readonly"
v-model="value[`clearanceVolumeUnit`]"
:options="unitList"
:label-field="$l(null, 'title')"
@input="$emit('changeUnit', {
value: $event,
field: `allVolumeUnit`
field: `clearanceVolumeUnit`
})"
value-field="id"
class="w-100" />
</el-form-item>
<!--特性加价-->
<template v-for="(special, specialIndex) in value.specialList">
<div :key="specialIndex + 'transport'">
<el-form-item
v-if="!priceType"
:label="getDictDataLabel(DICT_TYPE.ECW_SPECIAL_REQ_FOR_LINE_PRODUCTS, special.specialDictType) + $t('运费')"
>
<el-input-number v-model.number="special[`transportPrice`]" :controls="false" :min="0" :disabled="readonly" :placeholder="$t('整数或者两位小数')" class="w-100 mr-10" />
<selector disabled v-model="special[`transportPriceUnit`]" :options="currencyList" :label-field="$l(null, 'title')" value-field="id" defaultable2 class="w-100 mr-10" />
<span class="mr-10">/</span>
<selector disabled v-model="special[`transportVolumeUnit`]" :options="unitList" :label-field="$l(null, 'title')" value-field="id" defaultable2 class="w-100" />
</el-form-item>
<el-form-item
v-if="!priceType"
:label="getDictDataLabel(DICT_TYPE.ECW_SPECIAL_REQ_FOR_LINE_PRODUCTS, special.specialDictType) + $t('清关费')"
>
<el-input-number v-model.number="special[`clearancePrice`]" :controls="false" :min="0" :disabled="readonly" :placeholder="$t('整数或者两位小数')" class="w-100 mr-10" />
<selector disabled v-model="special[`clearancePriceUnit`]" :options="currencyList" :label-field="$l(null, 'title')" value-field="id" defaultable2 class="w-100 mr-10" />
<span class="mr-10">/</span>
<selector disabled v-model="special[`clearanceVolumeUnit`]" :options="unitList" :label-field="$l(null, 'title')" value-field="id" defaultable2 class="w-100" />
</el-form-item>
<el-form-item
v-if="priceType"
:label="getDictDataLabel(DICT_TYPE.ECW_SPECIAL_REQ_FOR_LINE_PRODUCTS, special.specialDictType) + $t('全包价')"
>
<el-input-number v-model.number="special[`allPrice`]" :controls="false" :min="0" :disabled="readonly" :placeholder="$t('整数或者两位小数')" class="w-100 mr-10" />
<selector disabled v-model="special[`allPriceUnit`]" :options="currencyList" :label-field="$l(null, 'title')" value-field="id" defaultable2 class="w-100 mr-10" />
<span class="mr-10">/</span>
<selector disabled v-model="special[`allVolumeUnit`]" :options="unitList" :label-field="$l(null, 'title')" value-field="id" defaultable2 class="w-100" />
</el-form-item>
</div>
</template>
</div>
value-field="id"
class="w-100" />
</el-form-item>
<!--特性加价-->
<template v-for="(special, specialIndex) in value.specialList">
<div :key="specialIndex + 'transport'">
<el-form-item
v-if="!priceType"
:label="getDictDataLabel(DICT_TYPE.ECW_SPECIAL_REQ_FOR_LINE_PRODUCTS, special.specialDictType) + $t('清关费')"
>
<el-input-number v-model.number="special[`clearancePrice`]" :controls="false" :min="0" :disabled="readonly" :placeholder="$t('整数或者两位小数')" class="w-100 mr-10" />
<selector disabled v-model="special[`clearancePriceUnit`]" :options="currencyList" :label-field="$l(null, 'title')" value-field="id" defaultable2 class="w-100 mr-10" />
<span class="mr-10">/</span>
<selector disabled v-model="special[`clearanceVolumeUnit`]" :options="unitList" :label-field="$l(null, 'title')" value-field="id" defaultable2 class="w-100" />
</el-form-item>
</div>
</template>
</el-col>
</el-row>
</template>
<style scoped lang="scss">
......
......@@ -371,12 +371,14 @@ export default {
if(this.form.stepPrice === 1){
this.initStepPrice()
}
this.syncMinWeightUnit()
},
'form.stepPrice'(stepPrice){
if(this.form.stepPrice === 1){
this.initStepPrice()
}
this.stepPrice = !!stepPrice
this.syncMinWeightUnit()
},
needPay(val){
this.$set(this.form, 'needPay', val ? 1 : 0)
......@@ -521,6 +523,21 @@ export default {
})
},
methods: {
// 设置最小起计量单位
syncMinWeightUnit(){
// 如果是阶梯价
if(this.form.stepPrice){
const field = this.form.priceType === 1 ? "fullPriceStepList" : "freightPriceStepList"
const stepPriceList = this.form[field]
if(stepPriceList?.length){
this.form.minWeightUnit = stepPriceList[0]?.weightUnit || DEFAULT_WEIGHT_UNIT
}else {
this.form.minWeightUnit = DEFAULT_WEIGHT_UNIT
}
}else{
this.form.minWeightUnit = this.form[this.form.priceType === 1 ? 'allVolumeUnit' : 'transportVolumeUnit'] || DEFAULT_WEIGHT_UNIT
}
},
handleAddPrice(field, fieldPrefix){
if(!this.form[field]){
this.$set(this.form, field, [])
......@@ -593,11 +610,18 @@ export default {
},
// 非阶梯价格更新单位
handleFormUnitChange(data){
// 海运非阶梯价没有重量单位,所以按照体积单位同步最小起计量单位
if(data.field === 'transportVolumeUnit' || data.field == 'allVolumeUnit'){
this.form.minWeightUnit = data.value
}
if(this.form.specialList?.length){
this.form.specialList.forEach(p => {
p[data.field] = data.value
})
}
// TODO 等加了包装之后还需要同步包装的单位
},
initStepPrice(){
if(this.form.priceType == 1 && !this.form.fullPriceStepList?.length){
......
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