Commit 87adf6bb authored by dragondean@qq.com's avatar dragondean@qq.com

完善海运价格

parent 9a9db221
......@@ -4,13 +4,18 @@ import Selector from "@/components/Selector/index.vue";
export default {
name: "QuickSet.vue",
props:{
type:String,
unitList:{
type: Array,
default: []
default(){
return []
}
},
currencyList:{
type: Array,
default: []
default(){
return []
}
},
value:{
type: Object,
......@@ -28,6 +33,16 @@ export default {
computed:{
getUnit(){
return (field, unitField) => {
if(this.type == 'sea'){
if(this.value.stepPrice && !this.value.priceStepList?.length){
return null
}
if(this.value.stepPrice){
return this.value.priceStepList[0][unitField]
}
return this.value[unitField]
}
// 后面是空运的
if(!this.value[field]?.length) return null
return this.value[field][0][unitField]
}
......@@ -39,6 +54,9 @@ export default {
if(!amount){
return this.$message.error(this.$t('请输入加价金额'))
}
if(this.type == 'sea'){
return this.batchSetSeaPrice(type, amount)
}
if(this.value?.priceType == 1){
this.batchSetPrice("fullPriceStepList", 'all', amount)
}else if(type == 'transport'){
......@@ -71,6 +89,37 @@ export default {
})
}
})
},
batchSetSeaPrice(type, amount){
console.log('快捷设置海运价格', type, amount)
if(!this.value.stepPrice){
if(!this.value.priceType){
this.setSeaPrice(this.value,"transport", amount)
this.setSeaPrice(this.value,"clearance",amount)
}else{
this.setSeaPrice(this.value,"all", amount)
}
return
}
this.value.priceStepList.forEach(item => {
if(!this.value.priceType){
this.setSeaPrice(item,"transport", amount)
this.setSeaPrice(item,"clearance",amount)
}else{
this.setSeaPrice(item,"all", amount)
}
})
},
setSeaPrice(parent, fieldPrefix, amount){
console.log(parent[`${fieldPrefix}Price`], ...arguments)
parent[`${fieldPrefix}Price`] = (parent[fieldPrefix + 'Price'] * 100 + amount * 100) / 100
if(!parent.specialList?.length) return
parent.specialList.forEach(special => {
console.log(special.specialDictType, special[fieldPrefix + 'Price'])
if(special[fieldPrefix + 'Price']){
special[fieldPrefix + 'Price'] = (special[fieldPrefix + 'Price'] * 100 + amount * 100) / 100
}
})
}
}
}
......
<script>
import Selector from "@/components/Selector/index.vue";
import Inputor from "@/components/Inputor/index.vue";
import Template from "@/views/cms/template/index.vue";
import {DICT_TYPE, getDictDatas} from "@/utils/dict";
export default {
name: "SeaPrice",
components: {Template, Inputor, Selector},
props:{
priceType: Number, // 1全包价,0清关费+运费
unitList:{
type: Array,
default: []
},
currencyList:{
type: Array,
default: []
},
readonly: Boolean,
value:{
type: Object,
default: () => {
return {
}
}
}
},
created() {
this.initSpecialPrice()
},
data(){
return {
}
},
methods:{
getDictDatas,
// 初始化特需加价
initSpecialPrice(){
if(!this.value.specialList){
this.$set(this.value, 'specialList', [])
}
this.getDictDatas(this.DICT_TYPE.ECW_SPECIAL_REQ_FOR_LINE_PRODUCTS).forEach(item => {
if(!this.value.specialList.find(special => special.specialDictType == item.value)){
this.value.specialList.push({
allPrice: undefined, // 新建默认给0,否则默认是null
allPriceUnit: this.value[`allPriceUnit`],
allVolumeUnit: this.value[`allVolumeUnit`],
transportPrice: undefined, // 新建默认给0,否则默认是null
transportPriceUnit: this.value[`transportPriceUnit`],
transportVolumeUnit: this.value[`transportVolumeUnit`],
clearancePrice: undefined,
clearancePriceUnit: this.value[`clearancePriceUnit`],
clearanceVolumeUnit: this.value[`clearanceVolumeUnit`],
specialDictType: item.value
})
}
})
},
// 校验
validate(){
let valid = true
// 价格检查
if(this.priceType){
if(!this.validatePrice(this.value[`allPrice`])){
valid = false
this.$message.error(`请设置全包价`)
}
}else{
if(!this.validatePrice(this.value[`transportPrice`])){
valid = false
this.$message.error(`请设置运费`)
}
if(!this.validatePrice(this.value[`clearancePrice`])){
valid = false
this.$message.error(`请设置清关费`)
}
}
return valid
},
// 校验价格是否为空,可以是0
validatePrice(value){
if(value === undefined || value === null || value === ''){
return false
}
return true
},
}
}
</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', {
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: $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: $event,
field: `clearancePriceUnit`
})"
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: `clearanceVolumeUnit`
})"
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: `allPriceUnit`
})"
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: `allVolumeUnit`
})"
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>
</template>
<style scoped lang="scss">
.bold {
font-weight: bold;
}
.text-lg{
font-size: 1.3rem;
}
.tips{
font-size: 1rem; color: red;
}
</style>
<script>
import Selector from "@/components/Selector/index.vue";
import Inputor from "@/components/Inputor/index.vue";
import Template from "@/views/cms/template/index.vue";
import {DICT_TYPE, getDictDatas} from "@/utils/dict";
export default {
name: "SeaStep",
components: {Template, Inputor, Selector},
props:{
index: Number,
priceType: Number, // 1全包价,0清关费+运费
unitList:{
type: Array,
default: []
},
currencyList:{
type: Array,
default: []
},
showAdd: Boolean,
readonly: Boolean,
value:{
type: Object,
default: () => {
return {
}
}
}
},
created() {
this.initSpecialPrice()
},
data(){
return {
}
},
methods:{
getDictDatas,
// 初始化特需加价
initSpecialPrice(){
if(!this.value.specialList){
this.$set(this.value, 'specialList', [])
}
this.getDictDatas(this.DICT_TYPE.ECW_SPECIAL_REQ_FOR_LINE_PRODUCTS).forEach(item => {
if(!this.value.specialList.find(special => special.specialDictType == item.value)){
this.value.specialList.push({
allPrice: undefined, // 新建默认给0,否则默认是null
allPriceUnit: this.value[`allPriceUnit`],
allVolumeUnit: this.value[`allVolumeUnit`],
transportPrice: undefined, // 新建默认给0,否则默认是null
transportPriceUnit: this.value[`transportPriceUnit`],
transportVolumeUnit: this.value[`transportVolumeUnit`],
clearancePrice: undefined,
clearancePriceUnit: this.value[`clearancePriceUnit`],
clearanceVolumeUnit: this.value[`clearanceVolumeUnit`],
specialDictType: item.value
})
}
})
},
// 校验
validate(){
let valid = true
const index = this.index
// 区间设置检查
if(index > 0 && !this.value.startNum){
valid = false
this.$message.error(`请设置第${index+1}阶段的起始值`)
}
if(!this.value.endNum){
valid = false
this.$message.error(`请设置第${index+1}阶段的结束值`)
}
// 价格检查
if(this.priceType){
if(!this.validatePrice(this.value[`allPrice`])){
valid = false
this.$message.error(`请设置第${index+1}阶段的全包价`)
}
}else{
if(!this.validatePrice(this.value[`transportPrice`])){
valid = false
this.$message.error(`请设置第${index+1}阶段的运费`)
}
if(!this.validatePrice(this.value[`clearancePrice`])){
valid = false
this.$message.error(`请设置第${index+1}阶段的清关费`)
}
}
return valid
},
// 校验价格是否为空,可以是0
validatePrice(value){
if(value === undefined || value === null || value === ''){
return false
}
return true
},
}
}
</script>
<template>
<div>
<div style="font-size:14px; margin:10px 0">
{{$t('第{index}阶梯定价方案', {index: index+1})}}
<template v-if="showAdd">
<el-link type="primary" @click.native="$emit('add', fieldPrefix)">{{$t('添加区间')}}</el-link>
<el-divider direction="vertical"></el-divider>
<el-link type="danger" @click.native="$emit( 'delete', index)">{{$t('删除')}}</el-link>
</template>
</div>
<el-form-item :label="$t('第{index}阶梯', {index: index+1})">
<el-input-number v-model="value.startNum" :controls="false" class="w-100"></el-input-number>
-
<el-input-number v-model="value.endNum" :controls="false" class="w-100"></el-input-number>
/
<selector
:disabled="index>0"
v-model="value.weightUnit"
:options="unitList"
:label-field="$l(null, 'title')"
@input="$emit('changeUnit', {
value: $event,
field: 'weightUnit',
type: fieldPrefix
})"
value-field="id"
class="w-100" />
</el-form-item>
<el-form-item :label="$t('默认运费')" v-if="!priceType">
<el-input-number v-model="value[`transportPrice`]" :placeholder="$t('整数或者两位小数')" :precision="2" :controls="false" class="w-100 mr-10"/>
<selector
:disabled="index>0"
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="index>0"
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('整数或者两位小数')" :precision="2" :controls="false" class="w-100 mr-10"/>
<selector
:disabled="index>0"
v-model="value[`clearancePriceUnit`]"
:options="currencyList"
:label-field="$l(null, 'title')"
@input="$emit('changeUnit', {
value: $event,
field: `clearancePriceUnit`
})"
value-field="id"
class="w-100" />
/
<selector
:disabled="index>0"
v-model="value[`clearanceVolumeUnit`]"
:options="unitList"
:label-field="$l(null, 'title')"
@input="$emit('changeUnit', {
value: $event,
field: `clearanceVolumeUnit`
})"
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('整数或者两位小数')" :precision="2" :controls="false" class="w-100 mr-10"/>
<selector
:disabled="index>0"
v-model="value[`allPriceUnit`]"
:options="currencyList"
:label-field="$l(null, 'title')"
@input="$emit('changeUnit', {
value: $event,
field: `allPriceUnit`
})"
value-field="id"
class="w-100" />
/
<selector
:disabled="index>0"
v-model="value[`allVolumeUnit`]"
:options="unitList"
:label-field="$l(null, 'title')"
@input="$emit('changeUnit', {
value: $event,
field: `allVolumeUnit`
})"
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" :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" :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" :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>
</template>
<style scoped lang="scss">
.bold {
font-weight: bold;
}
.text-lg{
font-size: 1.3rem;
}
.tips{
font-size: 1rem; color: red;
}
</style>
......@@ -92,154 +92,50 @@
:label="$t('最小起计量')"
:prop="`minWeight`"
>
<inputor default2="0" v-model.number="form.minWeight" type="number" class="w-100" :rules="{validator: priceValidator, trigger: 'blur', message: '数量错误'}"/>
<el-input-number v-model="form.minWeight" type="number" class="w-100" :controls="false"/>
/ <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 && !readonly">
<el-link type="primary" @click.native="addStepPrice">{{$t('添加区间')}}</el-link>
<el-divider direction="vertical"></el-divider>
<el-link type="danger" @click.native="form.priceStepList.splice(index, 1)">{{$t('删除')}}</el-link>
</template>
</div>
<el-form-item :label="$t('第{index}阶梯', {index: index + 1})">
<el-input v-model="item.startNum" type="number" placeholder="" class="w-100"></el-input>
-
<el-input v-model="item.endNum" type="number" placeholder="" class="w-100"></el-input>
/
<selector :disabled="index > 0" @input="syncAllUnit" v-model="item.weightUnit" :options="unitList" :label-field="$l(null, 'title')" value-field="id" class="w-100" />
</el-form-item>
<el-form-item :label="$t('默认运费')" v-if="form.priceType != 1" :prop="`priceStepList.${index}.transportPrice`" :rules="{validator: priceValidator, trigger: 'blur', message: '价格错误'}">
<inputor default2="0" v-model.number="item.transportPrice" type="number" :placeholder="$t('整数或者两位小数')" class="w-100 mr-10"/>
<selector :disabled="index > 0" @input="syncAllUnit" v-model="item.transportPriceUnit" :options="currencyList" :label-field="$l(null, 'title')" value-field="id" class="w-100" />
/ <selector :disabled="index > 0" @input="syncAllUnit" v-model="item.transportVolumeUnit" :options="unitList" :label-field="$l(null, 'title')" value-field="id" class="w-100" />
</el-form-item>
<el-form-item :label="$t('默认清关费')" v-if="form.priceType != 1 && type != 'air'" :prop="`priceStepList.${index}.transportPrice`" :rules="{validator: priceValidator, trigger: 'blur', message: '价格错误'}">
<inputor default2="0" v-model.number="item.clearancePrice" type="number" :placeholder="$t('整数或者两位小数')" class="w-100 mr-10" :rules="{validator: priceValidator, trigger: 'blur', message: '价格错误'}"/>
<selector :disabled="index > 0" @input="syncAllUnit" v-model="item.clearancePriceUnit" :options="currencyList" :label-field="$l(null, 'title')" value-field="id" class="w-100" />
/ <selector disabled @input="syncAllUnit" v-model="item.clearanceVolumeUnit" :options="unitList" :label-field="$l(null, 'title')" value-field="id" class="w-100" />
</el-form-item>
<el-form-item
:label="$t('默认全包价')"
v-if="form.priceType == 1"
:prop="`priceStepList.${index}.allPrice`"
:rules="{validator: priceValidator, trigger: 'blur', message: '价格错误'}"
>
<selector :disabled="index > 0" @input="syncAllUnit" v-model="item.allPriceUnit" :options="currencyList" :label-field="$l(null, 'title')" value-field="id" class="w-100" />
<inputor default2="0" v-model.number="item.allPrice" type="number" :placeholder="$t('整数或者两位小数')" class="w-100 ml-10" :rules="{validator: priceValidator, trigger: 'blur', message: '价格错误'}"/>
/ <selector :disabled="index > 0" @input="syncAllUnit" v-model="item.allVolumeUnit" :options="unitList" :label-field="$l(null, 'title')" value-field="id" class="w-100" />
</el-form-item>
</div>
</template>
<template v-else>
<el-form-item :label="$t('默认全包价')" v-if="form.priceType == 1" prop="allPrice" :rules="{validator: priceValidator, trigger: 'blur', message: '价格错误'}">
<selector test="allPriceUnit" v-model="form.allPriceUnit" :options="currencyList" :label-field="$l('title')" value-field="id" class="w-100 mr-10 aaa" />
<inputor default2="0" v-model.number="form.allPrice" type="number" :placeholder="$t('整数或者两位小数')" class="w-100 mr10" />
<span class="mr-10">/</span>
<selector v-model="form.allVolumeUnit" :options="unitList" :label-field="$l('title')" value-field="id" class="w-100" />
</el-form-item>
<template v-else>
<el-form-item :label="$t('默认运费')" prop="transportPrice" :rules="{validator: priceValidator, trigger: 'blur', message: '价格错误'}">
<selector v-model="form.transportPriceUnit" :options="currencyList" :label-field="$l('title')" value-field="id" class="w-100 mr-10" />
<inputor default2="0" v-model.number="form.transportPrice" type="number" :placeholder="$t('整数或者两位小数')" class="w-100 mr-10" />
<span class="mr-10">/</span>
<selector v-model="form.transportVolumeUnit" :options="unitList" :label-field="$l('title')" value-field="id" class="w-100" />
</el-form-item>
<el-form-item v-if="type != 'air'" :label="$t('默认清关费')" prop="clearancePrice" :rules="{validator: priceValidator, trigger: 'blur', message: '价格错误'}">
<selector v-model="form.clearancePriceUnit" :options="currencyList" :label-field="$l('title')" value-field="id" class="w-100 mr-10" />
<inputor default2="0" v-model.number="form.clearancePrice" type="number" :placeholder="$t('整数或者两位小数')" class="w-100 mr-10" />
<span class="mr-10">/</span>
<selector disabled v-model="form.clearanceVolumeUnit" :options="unitList" :label-field="$l('title')" value-field="id" class="w-100" />
</el-form-item>
</template>
</template>
<!--特需-->
<template v-if="form.priceType==1">
<el-form-item
v-for="(special, specialIndex) in this.form.specialList"
:label="getDictDataLabel(DICT_TYPE.ECW_SPECIAL_REQ_FOR_LINE_PRODUCTS, special.specialDictType) + $t('全包价')"
:key="specialIndex + 'transport'"
:prop="`specialList.${specialIndex}`.allPrice"
:rules="{validator: priceValidator, trigger: 'blur', message: '价格错误'}"
>
<selector disabled v-model="special.allPriceUnit" :options="currencyList" :label-field="$l(null, 'title')" value-field="id" defaultable2 class="w-100 mr-10" />
<inputor default2="0" v-model.number="special.allPrice" type="number" :placeholder="$t('整数或者两位小数')" 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>
</template>
<template v-else v-for="(special, specialIndex) in this.form.specialList">
<el-form-item
:label="getDictDataLabel(DICT_TYPE.ECW_SPECIAL_REQ_FOR_LINE_PRODUCTS, special.specialDictType) + $t('运费')"
:key="specialIndex + 'transport'"
:prop="`specialList.${specialIndex}.transportPrice`"
:rules="{validator: priceValidator, trigger: 'blur', message: '价格错误'}"
>
<selector disabled v-model="special.transportPriceUnit" :options="currencyList" :label-field="$l(null, 'title')" value-field="id" defaultable2 class="w-100 mr-10" />
<inputor default2="0" v-model.number="special.transportPrice" type="number" :placeholder="$t('整数或者两位小数')" 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="type != 'air'"
:label="getDictDataLabel(DICT_TYPE.ECW_SPECIAL_REQ_FOR_LINE_PRODUCTS, special.specialDictType) + $t('清关费')"
:key="specialIndex + 'clearance'"
:prop="`specialList.${specialIndex}.clearancePrice`"
:rules="{validator: priceValidator, trigger: 'blur', message: '价格错误'}"
>
<selector disabled v-model="special.clearancePriceUnit" :options="currencyList" :label-field="$l(null, 'title')" value-field="id" defaultable2 class="w-100 mr-10" />
<inputor default2="0" v-model.number="special.clearancePrice" type="number" :placeholder="$t('整数或者两位小数')" 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>
</template>
<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-form-item>
</el-col>
<!--编辑的时候右侧显示快捷设置,查看的时候空运显示商品清关费-->
<el-col :span="12" v-if="!readonly">
<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 :value="form" type="sea" :unit-list="unitList" :currency-list="currencyList"></quick-set>
</el-col>
<!--
甲方要求不显示清关费 https://zentao.test.jdshangmen.com/bug-view-5298.html
-->
<!--<el-col :span="12" v-else-if="readonly && type === 'air'">
&lt;!&ndash;商品清关费&ndash;&gt;
<h2>{{$t('商品清关费价格')}}</h2>
<packaging-type v-if="product && product.priceStepClearanceList && product.priceStepClearanceList.length"
:value="product" key-arr="priceStepClearanceList" readonly/>
<div v-else>
{{$t('未设置清关费')}}
</div>
</el-col>-->
</el-row>
<!--如果是阶梯价-->
<template v-if="form.stepPrice">
<div v-for="(item, index) in form.priceStepList" :key="index">
<sea-step
ref="stepPrice"
:index="index"
:price-type="form.priceType"
:currency-list="currencyList"
:unit-list="unitList"
:show-add="index === form.priceStepList.length -1 && !readonly"
:value="item"
:readonly="readonly"
@add="handleAddPrice($event)"
@delete="handleDeletePrice($event)"
@changeUnit="handleUnitChange(index, $event)"
></sea-step>
</div>
</template>
<template v-else>
<sea-price
ref="seaPrice"
:price-type="form.priceType"
:currency-list="currencyList"
:unit-list="unitList"
:value="form"
:readonly="readonly"
@changeUnit="handleFormUniChange($event)"
></sea-price>
</template>
<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-form-item>
</el-card>
......@@ -271,6 +167,7 @@
<el-form-item :label="$t('是否单询')" prop="inquiry">
<dict-selector :type="DICT_TYPE.NEED_ORDER_INQUIRY" v-model="form.needOrderInquiry" form-type="radio" formatter="number"></dict-selector>
</el-form-item>
</el-card>
</el-form>
......@@ -287,86 +184,10 @@
<div style="margin: 20px 0">
<el-button @click="submitForm" type="primary" v-if="!readonly" :loading="loading">{{$t('确认提交')}}</el-button>
<el-button type="default" @click="$router.back()">{{$t('返回上一页')}}</el-button>
<el-button @click="showLogsDialog=true" type="primary" v-if="readonly">{{$t('查看价格日志')}}</el-button>
<el-button @click="showLogs" type="primary" v-if="readonly">{{$t('查看价格日志')}}</el-button>
</div>
<el-dialog :title="$t('查看价格日志')" :visible="showLogsDialog" :before-close="closeLogsDialog" width="1000px">
<el-table :data="logs">
<el-table-column :label="$t('序号')" type="index"></el-table-column>
<el-table-column :label="$t('修改人')" prop="creatorName" width="200px"></el-table-column>
<el-table-column :label="$t('修改时间')">
<template slot-scope="{row}">{{row.createTime|parseTime}}</template>
</el-table-column>
<el-table-column :label="$t('修改前')">
<template slot-scope="{row}">
<div>{{ $t('预付') }}<dict-tag :type="DICT_TYPE.ECW_PAY_ADVANCE" :value="row.detail.needPay" /></div>
<div>{{ $t('单价模式') }}<dict-tag :type="DICT_TYPE.ECW_PRICE_TYPE" :value="row.detail.priceType" /></div>
<div v-if="row.detail.minWeight">{{ $t('最小起计量') }}{{ row.detail.minWeight }}{{unitMap[row.detail.minWeightUnit]}}</div>
<!----阶梯定价-->
<template v-if="row.detail.stepPrice == 1">
<template v-for="(item, index) in row.detail.priceStepList">
<div class="mt-10">
{{index+1}}阶段
{{item.startNum}} - {{item.endNum}} {{unitMap[item.weightUnit]}}
</div>
<template v-if="row.detail.priceType != 1">
<div :key="index + '_freight'" class="pl-10" >
运费:
{{item.transportPrice}} {{currencyMap[item.transportPriceUnit]}} / {{unitMap[item.transportVolumeUnit]}}
</div>
<!--空运没有清关费, 不需要显示-->
<div v-if="type != 'air'" :key="item.specialDictType + '_clearance'" class="pl-10">
清关费:
{{item.clearancePrice}} {{currencyMap[item.clearancePriceUnit]}} / {{unitMap[item.clearanceVolumeUnit]}}
</div>
</template>
<div v-else class="pl-10">
全包价:
{{item.allPrice}} {{currencyMap[item.allPriceUnit]}} / {{unitMap[item.allVolumeUnit]}}
</div>
</template>
</template>
<template v-else>
<template v-if="row.detail.priceType != 1">
<div>
默认运费:
{{row.detail.transportPrice}} {{currencyMap[row.detail.transportPriceUnit]}} / {{unitMap[row.detail.transportVolumeUnit]}}
</div>
<div>
默认清关费:
{{row.detail.clearancePrice}} {{currencyMap[row.detail.clearancePriceUnit]}} / {{unitMap[row.detail.clearanceVolumeUnit]}}
</div>
</template>
<div v-else>
全包价:
{{row.detail.allPrice}} {{currencyMap[row.detail.allPriceUnit]}} / {{unitMap[row.detail.allVolumeUnit]}}
</div>
<template v-for="(item, index) in row.detail.specialList">
<template v-if="row.detail.priceType != 1">
<div :key="item.specialDictType + '_freight'" >
{{getDictDataLabel(DICT_TYPE.ECW_SPECIAL_REQ_FOR_LINE_PRODUCTS, item.specialDictType)}} 运费:
{{item.transportPrice}} {{currencyMap[item.transportPriceUnit]}} / {{unitMap[item.transportVolumeUnit]}}
</div>
<div :key="item.specialDictType + '_clearance'" >
{{getDictDataLabel(DICT_TYPE.ECW_SPECIAL_REQ_FOR_LINE_PRODUCTS, item.specialDictType)}} 清关费:
{{item.clearancePrice}} {{currencyMap[item.clearancePriceUnit]}} / {{unitMap[item.clearanceVolumeUnit]}}
</div>
</template>
<div v-else>
{{getDictDataLabel(DICT_TYPE.ECW_SPECIAL_REQ_FOR_LINE_PRODUCTS, item.specialDictType)}} 全包价:
{{item.allPrice}} {{currencyMap[item.allPriceUnit]}} / {{unitMap[item.allVolumeUnit]}}
</div>
</template>
</template>
<div v-if="row.detail.validateStartDate || row.detail.validateStartDate">有效期:{{ row.detail.validateStartDate|parseTime }}-{{ row.detail.validateEndDate|parseTime }}</div>
</template>
</el-table-column>
</el-table>
</el-dialog>
<logs ref="logs"></logs>
</div>
</template>
<script>
......@@ -385,8 +206,20 @@ import Decimal from "decimal.js";
import {getChannel} from "@/api/ecw/channel";
import PackagingType from "@/views/ecw/channel/componrnts/packaging-type.vue";
import {getStatusName} from './util'
import QuickSet from "./components/QuickSet.vue"
import Logs from "@/views/ecw/productPrice/components/Logs.vue";
import SeaStep from "@/views/ecw/productPrice/components/SeaStep.vue";
import Template from "@/views/cms/template/index.vue";
import SeaPrice from "@/views/ecw/productPrice/components/SeaPrice.vue";
const DEFAULT_PRICE_UNIT = 1
const DEFAULT_VOLUME_UNIT = 7
const DEFAULT_WEIGHT_UNIT = 7
export default {
components: {PackagingType, RoutersSelector, ProductSelector, Selector, Inputor },
components: {
SeaPrice,
Template, Logs, QuickSet, PackagingType, RoutersSelector, ProductSelector, Selector, Inputor, SeaStep },
filters: {parseTime},
data() {
return {
......@@ -401,9 +234,6 @@ export default {
},
needPay: false, // 是否需要预付
stepPrice: false, // 是否阶梯订单
// specialProducts: [],
// priceStepList: [{},{}], // 阶梯价格
// specialList:[], // 特殊需求,默认四个
rules: {
transportPrice: [{ required: true, message: this.$t("海运费不能为空"), trigger: "blur" }],
clearancePrice: [{ required: true, message: this.$t("清关费不能为空"), trigger: "blur" }],
......@@ -418,10 +248,6 @@ export default {
readonly: false,
lineList: [], //路线数组
loading: false,
showLogsDialog: false, // 显示价格日志弹层
logs: [],
// 批量加价/减价
quickForm:{}, // 快速加价/减价表单
// 渠道信息
channel: null
}
......@@ -470,11 +296,6 @@ export default {
},
watch: {
showLogsDialog(showLogsDialog){
if(showLogsDialog){
this.laodLogs()
}
},
checkList() { //选择路线
if (this.checkList.length > 0) {
this.form.lineChannelList = this.checkList.map(item => {
......@@ -498,58 +319,17 @@ export default {
}
},
form(val) {
if (!val) return
// 特殊需求回显
if (val.specialList) {
val.specialList.forEach(item => {
let index = this.form.specialList.findIndex(special => special.specialDictType == item.specialDictType)
if(index > -1)this.form.specialList[index] = item
})
}
},
'form.priceType'(priceType){
// 切换全包价的时候给默认货币单位,如果是回填则不需要给默认值
if(priceType == 1 && !this.form.allPrice){
this.$set(this.form, 'allPriceUnit', 1)
}
this.syncAllUnit('watch:form.priceType')
},
'form.minWeightUnit'(minWeightUnit){
console.log('最小起计量单位', minWeightUnit)
},
'form.transportVolumeUnit'(transportVolumeUnit){
// 最小其计量
this.$set(this.form, 'minWeightUnit', transportVolumeUnit)
this.syncSpecialUnit({transportVolumeUnit})
this.form.clearanceVolumeUnit = transportVolumeUnit // 清关费体积单位同步运费体积单位
},
'form.clearanceVolumeUnit'(clearanceVolumeUnit){
this.syncSpecialUnit({clearanceVolumeUnit})
},
'form.transportPriceUnit'(transportPriceUnit){
this.syncSpecialUnit({transportPriceUnit})
},
'form.clearancePriceUnit'(clearancePriceUnit){
this.syncSpecialUnit({clearancePriceUnit})
},
'form.allPriceUnit'(allPriceUnit){
this.syncSpecialUnit({allPriceUnit})
},
'form.allVolumeUnit'(allVolumeUnit){
// 最小起计量
this.$set(this.form, 'minWeightUnit', allVolumeUnit)
this.syncSpecialUnit({allVolumeUnit})
},
'form.needBook'(val){
if(val) this.$set(this.form, 'dayLimit', 10000)
else delete this.form.dayLimit
},
'form.stepPrice'(stepPrice){
if(stepPrice == 1 && (!this.form.priceStepList || !this.form.priceStepList.length)){
this.$set(this.form, 'priceStepList', [{},{}])
if(stepPrice == 1 && !this.form.priceStepList?.length){
this.handleAddPrice("priceStepList")
}
this.syncAllUnit('watch:form.stepPrice')
this.stepPrice = !!stepPrice
},
needPay(val){
......@@ -558,29 +338,15 @@ export default {
stepPrice(val){
this.$set(this.form, 'stepPrice', val ? 1 : 0)
},
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)
}
},
async created() {
this.currencyList = (await getCurrencyList())?.data || []
this.unitList = (await getUnitList())?.data || []
this.productTypeList = (await getProductTypeList())?.data || []
if(this.$route.query.readonly){
this.readonly = true
}
if(this.type == 'air'){
this.stepPrice = true
}
const defaultVolumeUnit = this.type === 'air' ? 6 : 7
const defaultPriceUnit = 1
......@@ -694,12 +460,6 @@ export default {
if(!this.$route.query.action || this.$route.query.action == 'batchUpdate'){
this.$nextTick(() => {
// 默认体积单位,空运为千克,海运为立方米
console.log('指定默认单位', this.type === 'air' ? 6 : 7)
this.setDefaultVolumeUnit(this.type === 'air' ? 6 : 7)
// 默认货币单位(美元)
this.setDefaultPriceUnit(1)
// 空运默认的阶梯重量单位是千克
if(this.type === 'air'){
this.$set(this.form.priceStepList[0], 'weightUnit', 6)
......@@ -714,16 +474,6 @@ export default {
this.$set(this.form, 'productId', +this.$route.query.product_id)
}
// 显示渠道(修改或者从异常处理等进入携带了渠道参数)
if(this.form.shippingChannelId && this.type == 'air'){
getChannel(this.form.shippingChannelId).then(res => {
this.channel = res.data
})
}
getCurrencyList().then(res => this.currencyList = res.data)
getUnitList().then(res => this.unitList = res.data)
this.getDictDatas(this.DICT_TYPE.ECW_SPECIAL_REQ_FOR_LINE_PRODUCTS).forEach(item => {
if(!this.form.specialList.find(special => special.specialDictType == item.value)){
this.form.specialList.push({
......@@ -739,72 +489,67 @@ export default {
})
},
methods: {
// 同步全部单位
syncAllUnit(from){
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.transportVolumeUnit, // 清关费和运费的体积单位同步
}
handleAddPrice(){
if(!this.form.priceStepList){
this.$set(this.form, 'priceStepList', [])
}
// 阶梯价还需要同步阶梯的重量单位
if(this.form.stepPrice == 1){
fields['weightUnit'] = obj.weightUnit
let allPriceUnit = DEFAULT_PRICE_UNIT
let allVolumeUnit = 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
if(this.form.priceStepList?.length){
const first = this.form.priceStepList[0]
allPriceUnit = first.allPriceUnit
allVolumeUnit = first.allVolumeUnit
transportPriceUnit = first.transportPriceUnit
transportVolumeUnit = first.transportVolumeUnit
clearancePriceUnit = first.clearancePriceUnit
clearanceVolumeUnit = first.clearanceVolumeUnit
weightUnit = first.weightUnit
}
console.log('-> 同步特需单位', fields, {from})
this.syncSpecialUnit(fields)
},
// 同步特需的货币单位和体积单位
syncSpecialUnit(obj){
console.log('syncSpecialUnit', obj)
if(!obj) return
// 同步特需单位
this.form.specialList.forEach(item => {
Object.assign(item, obj)
this.form.priceStepList.push({
allPriceUnit,
allVolumeUnit,
transportPriceUnit,
transportVolumeUnit,
clearancePriceUnit,
clearanceVolumeUnit,
weightUnit: weightUnit,
specialList:[]
})
// 如果是阶梯价则需要同步其他阶梯
if(this.form.stepPrice == 1 && this.form.priceStepList){
this.form.priceStepList.forEach((item, index) => {
this.$set(this.form.priceStepList, index, Object.assign(item, obj))
})
}
// 不是阶梯价需要 同步最小起计量
if(obj['transportVolumeUnit'] || obj['allVolumeUnit']){
this.$set(this.form, 'minWeightUnit', obj['transportVolumeUnit'] || obj['allVolumeUnit'])
}
},
priceValidator(rule, value, callback){
if(!value || value == '') return callback()
value = parseFloat(value)
if(!value || value < 0){
return callback(new Error('价格错误'))
}
callback()
handleDeletePrice(index){
this.form.priceStepList.splice(index, 1)
},
setDefaultVolumeUnit(unit){
console.log('设置默认体积单位', unit)
this.$set(this.form, 'transportVolumeUnit', unit)
this.$set(this.form, 'clearanceVolumeUnit', unit)
this.$set(this.form, 'allVolumeUnit', unit)
// 阶梯价更新单位
handleUnitChange(index, data){
console.log('handleUnitChange', ...arguments)
if(index > 0) return
// 如果是重量单位,且不是清关费想换的,则需要同步最小起计量单位
if(data.field === 'weightUnit' && data.type != 'clearance'){
this.form.minWeightUnit = data.value
}
this.form.priceStepList.forEach(item => {
item[data.field] = data.value
if(item.specialList?.length){
item.specialList.forEach(p => {
p[data.field] = data.value
})
}
})
},
setDefaultPriceUnit(priceUnit){
console.log('设置默认价格单位', priceUnit)
this.$set(this.form, 'transportPriceUnit', priceUnit)
this.$set(this.form, 'clearancePriceUnit', priceUnit)
this.$set(this.form, 'allPriceUnit', priceUnit)
// 非阶梯价格更新单位
handleFormUniChange(data){
if(this.form.specialList?.length){
this.form.specialList.forEach(p => {
p[data.field] = data.value
})
}
},
// force 为是否强制提交,在价格过期的时候需要确认后强制提交
submitForm(force = false) {
......@@ -946,46 +691,11 @@ export default {
}).finally(res => this.loading = false);
});
},
closeLogsDialog(){
this.showLogsDialog = false
},
laodLogs(){
getPriceSnapshotList(this.form.id).then(res => {
this.logs = res.data
this.logs.forEach(item => {
item.detail = JSON.parse(item.content)
})
})
},
// 快捷设置,只更新默认运费
quickSet(){
// 字段,根据是否全包价来取
let field = this.form.priceType == 1 ? 'allPrice' : 'transportPrice'
// 取得要加的数额(减少则是负数)
let amount = Decimal(this.quickForm.plus || -this.quickForm.minus)
this.form.priceStepList.forEach(item => {
// 加上对应的价格,但是不能小于0
this.$set(item, field, Math.max(0, Decimal(item[field] || 0).plus(amount).toNumber()))
})
},
// 添加区间价
addStepPrice(){
let fields = {}
const obj = this.form.priceStepList[0] || {}
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.transportVolumeUnit,
}
showLogs(){
if(!this.$refs.logs){
return this.$message.error("未找到组件")
}
this.form.priceStepList.push(fields)
this.$refs.logs.open(this.form.id)
}
}
}
......
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