Commit aa924e3b authored by 1483922988@qq.com's avatar 1483922988@qq.com

海运空运加价可以为负数,任务578

parent b4443768
...@@ -2,80 +2,89 @@ ...@@ -2,80 +2,89 @@
import Selector from "@/components/Selector/index.vue"; import Selector from "@/components/Selector/index.vue";
import Inputor from "@/components/Inputor/index.vue"; import Inputor from "@/components/Inputor/index.vue";
import Template from "@/views/cms/template/index.vue"; import Template from "@/views/cms/template/index.vue";
import {DICT_TYPE, getDictDatas} from "@/utils/dict"; import { DICT_TYPE, getDictDatas } from "@/utils/dict";
export default { export default {
name: "SeaPrice", name: "SeaPrice",
components: {Inputor, Selector}, components: { Inputor, Selector },
props:{ props: {
// 字段前缀 // 字段前缀
fieldPrefix: String, fieldPrefix: String,
// 价格名称 // 价格名称
priceName: String, priceName: String,
// 包装类型字段 // 包装类型字段
packagingField: String, packagingField: String,
unitList:{ unitList: {
type: Array, type: Array,
default: [] default: [],
}, },
currencyList:{ currencyList: {
type: Array, type: Array,
default: [] default: [],
}, },
readonly: Boolean, readonly: Boolean,
value:{ value: {
type: Object, type: Object,
default: () => { default: () => {
return {} return {};
}
}
}, },
computed:{ },
packagingList(){ },
const dicts = JSON.parse(JSON.stringify(getDictDatas(DICT_TYPE.ECW_PACKAGING_TYPE))) computed: {
return dicts.map(dict => { packagingList() {
dict.enable = true const dicts = JSON.parse(
this.value[this.packagingField]?.forEach(item => { JSON.stringify(getDictDatas(DICT_TYPE.ECW_PACKAGING_TYPE))
if(item.packagingTypes?.length && item.packagingTypes.indexOf(dict.value) > -1){ );
dict.enable = false return dicts.map((dict) => {
} dict.enable = true;
}) this.value[this.packagingField]?.forEach((item) => {
return dict if (
}) item.packagingTypes?.length &&
item.packagingTypes.indexOf(dict.value) > -1
) {
dict.enable = false;
} }
});
return dict;
});
},
}, },
created() { created() {
this.initSpecialPrice() this.initSpecialPrice();
this.initPackingPrice() this.initPackingPrice();
}, },
data(){ data() {
return { return {};
}
}, },
methods:{ methods: {
getDictDatas, getDictDatas,
// 包装类型初始化 // 包装类型初始化
initPackingPrice(){ initPackingPrice() {
// 已有包装类型则处理字段,没有则初始化一个 // 已有包装类型则处理字段,没有则初始化一个
if(this.value[this.packagingField]?.length){ if (this.value[this.packagingField]?.length) {
this.value[this.packagingField].forEach(item => { this.value[this.packagingField].forEach((item) => {
if(!item.packagingTypes){ if (!item.packagingTypes) {
this.$set(item, 'packagingTypes', []) this.$set(item, "packagingTypes", []);
}else if(typeof item.packagingTypes == 'string'){ } else if (typeof item.packagingTypes == "string") {
item.packagingTypes = item.packagingTypes.split(',') item.packagingTypes = item.packagingTypes.split(",");
} }
}) });
return return;
} }
this.addPackage() this.addPackage();
}, },
// 初始化特需加价 // 初始化特需加价
initSpecialPrice(){ initSpecialPrice() {
if(!this.value.specialList){ if (!this.value.specialList) {
this.$set(this.value, 'specialList', []) this.$set(this.value, "specialList", []);
} }
this.getDictDatas(this.DICT_TYPE.ECW_SPECIAL_REQ_FOR_LINE_PRODUCTS).forEach(item => { this.getDictDatas(
if(!this.value.specialList.find(special => special.specialDictType == item.value)){ 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({ this.value.specialList.push({
allPrice: undefined, // 新建默认给0,否则默认是null allPrice: undefined, // 新建默认给0,否则默认是null
allPriceUnit: this.value[`allPriceUnit`], allPriceUnit: this.value[`allPriceUnit`],
...@@ -86,111 +95,174 @@ export default { ...@@ -86,111 +95,174 @@ export default {
clearancePrice: undefined, clearancePrice: undefined,
clearancePriceUnit: this.value[`clearancePriceUnit`], clearancePriceUnit: this.value[`clearancePriceUnit`],
clearanceVolumeUnit: this.value[`clearanceVolumeUnit`], clearanceVolumeUnit: this.value[`clearanceVolumeUnit`],
specialDictType: item.value specialDictType: item.value,
}) });
} }
}) });
}, },
// 添加包装类型运费 // 添加包装类型运费
addPackage(){ addPackage() {
if(!this.value[this.packagingField]){ if (!this.value[this.packagingField]) {
this.$set(this.value, this.packagingField, []) this.$set(this.value, this.packagingField, []);
} }
this.value[this.packagingField]?.push({ this.value[this.packagingField]?.push({
packagingPrice: undefined, packagingPrice: undefined,
packagingPriceUnit : this.value[`${this.fieldPrefix}PriceUnit`], packagingPriceUnit: this.value[`${this.fieldPrefix}PriceUnit`],
packagingVolumeUnit : this.value[`${this.fieldPrefix}VolumeUnit`], packagingVolumeUnit: this.value[`${this.fieldPrefix}VolumeUnit`],
}) });
}, },
// 删除包装类型运费 // 删除包装类型运费
deletePackage(index){ deletePackage(index) {
this.value[this.packagingField]?.splice(index, 1) this.value[this.packagingField]?.splice(index, 1);
}, },
// 校验 // 校验
validate(){ validate() {
let valid = true let valid = true;
// 价格检查 // 价格检查
if(!this.validatePrice(this.value[`${this.fieldPrefix}Price`])){ if (!this.validatePrice(this.value[`${this.fieldPrefix}Price`])) {
valid = false valid = false;
this.$message.error(this.$t("请设置{name}", {name: this.priceName})) this.$message.error(this.$t("请设置{name}", { name: this.priceName }));
} }
// 检查包装费 // 检查包装费
if(this.value[this.packagingField]?.length){ if (this.value[this.packagingField]?.length) {
this.value[this.packagingField]?.forEach((item, index) => { this.value[this.packagingField]?.forEach((item, index) => {
if(!item.packagingTypes?.length) return if (!item.packagingTypes?.length) return;
if(!this.validatePrice(item.packagingPrice)){ if (!this.validatePrice(item.packagingPrice)) {
valid = false valid = false;
this.$message.error(this.$t("请设置{name}的包装费{index}", {name: this.priceName, index: index+1})) this.$message.error(
} this.$t("请设置{name}的包装费{index}", {
name: this.priceName,
index: index + 1,
}) })
);
}
});
} }
return valid return valid;
}, },
// 校验价格是否为空,可以是0 // 校验价格是否为空,可以是0
validatePrice(value){ validatePrice(value) {
if(value === undefined || value === null || value === ''){ if (value === undefined || value === null || value === "") {
return false return false;
} }
return true return true;
}, },
} },
} };
</script> </script>
<template> <template>
<div> <div>
<div class="page-title">{{$t('{name}价格设置', {name: this.priceName})}}</div> <div class="page-title">
<el-form-item :label="$t('默认{name}', {name: this.priceName})"> {{ $t("{name}价格设置", { name: this.priceName }) }}
<el-input-number v-model="value[`${fieldPrefix}Price`]" :placeholder="$t('整数或者两位小数')" :controls="false":disabled="readonly" class="w-100 mr-10"/> </div>
<el-form-item :label="$t('默认{name}', { name: this.priceName })">
<el-input-number
v-model="value[`${fieldPrefix}Price`]"
:placeholder="$t('整数或者两位小数')"
:controls="false"
:disabled="readonly"
class="w-100 mr-10"
/>
<selector <selector
:disabled="readonly" :disabled="readonly"
v-model="value[`${fieldPrefix}PriceUnit`]" v-model="value[`${fieldPrefix}PriceUnit`]"
:options="currencyList" :options="currencyList"
:label-field="$l(null, 'title')" :label-field="$l(null, 'title')"
@input="$emit('changeUnit', { @input="
$emit('changeUnit', {
value: $event, value: $event,
field: `${fieldPrefix}PriceUnit` field: `${fieldPrefix}PriceUnit`,
})" })
"
value-field="id" value-field="id"
class="w-100" /> class="w-100"
/>
/ /
<selector <selector
:disabled="readonly" :disabled="readonly"
v-model="value[`${fieldPrefix}VolumeUnit`]" v-model="value[`${fieldPrefix}VolumeUnit`]"
:options="unitList" :options="unitList"
:label-field="$l(null, 'title')" :label-field="$l(null, 'title')"
@input="$emit('changeUnit', { @input="
$emit('changeUnit', {
value: $event, value: $event,
field: `${fieldPrefix}VolumeUnit` field: `${fieldPrefix}VolumeUnit`,
})" })
"
value-field="id" value-field="id"
class="w-100" /> class="w-100"
/>
</el-form-item> </el-form-item>
<!--特性加价--> <!--特性加价-->
<template v-for="(special, specialIndex) in value.specialList"> <template v-for="(special, specialIndex) in value.specialList">
<div :key="specialIndex + 'transport'"> <div :key="specialIndex + 'transport'">
<el-form-item <el-form-item
:label="getDictDataLabel(DICT_TYPE.ECW_SPECIAL_REQ_FOR_LINE_PRODUCTS, special.specialDictType) + priceName + $t('加价')" :label="
getDictDataLabel(
DICT_TYPE.ECW_SPECIAL_REQ_FOR_LINE_PRODUCTS,
special.specialDictType
) +
priceName +
$t('加价')
"
> >
<el-input-number v-model.number="special[`${fieldPrefix}Price`]" :controls="false" :min="0" :disabled="readonly" :placeholder="$t('整数或者两位小数')" class="w-100 mr-10" /> <el-input-number
<selector disabled v-model="special[`${fieldPrefix}PriceUnit`]" :options="currencyList" :label-field="$l(null, 'title')" value-field="id" class="w-100 mr-10" /> v-model.number="special[`${fieldPrefix}Price`]"
:controls="false"
:disabled="readonly"
:placeholder="$t('整数或者两位小数')"
class="w-100 mr-10"
/>
<selector
disabled
v-model="special[`${fieldPrefix}PriceUnit`]"
:options="currencyList"
:label-field="$l(null, 'title')"
value-field="id"
class="w-100 mr-10"
/>
<span class="mr-10">/</span> <span class="mr-10">/</span>
<selector disabled v-model="special[`${fieldPrefix}VolumeUnit`]" :options="unitList" :label-field="$l(null, 'title')" value-field="id" class="w-100" /> <selector
disabled
v-model="special[`${fieldPrefix}VolumeUnit`]"
:options="unitList"
:label-field="$l(null, 'title')"
value-field="id"
class="w-100"
/>
</el-form-item> </el-form-item>
</div> </div>
</template> </template>
<!--包装类型价格--> <!--包装类型价格-->
<template v-for="(item, i) in value[packagingField]"> <template v-for="(item, i) in value[packagingField]">
<el-form-item :label="$t('包装类型') + priceName + (i+1)" :key="i"> <el-form-item :label="$t('包装类型') + priceName + (i + 1)" :key="i">
<template #label> <template #label>
<div class="el-form-item__label" style="width: 150px;">{{$t('包装类型{name}加价', {name: priceName}) + (i+1)}}</div> <div class="el-form-item__label" style="width: 150px">
<div v-if="!item.packagingTypes || !item.packagingTypes.length" class="tips">{{$t('未选择包装类型将被忽略')}}</div> {{ $t("包装类型{name}加价", { name: priceName }) + (i + 1) }}
</div>
<div
v-if="!item.packagingTypes || !item.packagingTypes.length"
class="tips"
>
{{ $t("未选择包装类型将被忽略") }}
</div>
</template> </template>
<el-select v-model="item.packagingTypes" multiple placeholder="请选择" style="width: 100%; max-width: 450px; margin-bottom: 5px; display: block"> <el-select
v-model="item.packagingTypes"
multiple
placeholder="请选择"
style="
width: 100%;
max-width: 450px;
margin-bottom: 5px;
display: block;
"
>
<el-option <el-option
v-for="item in packagingList" v-for="item in packagingList"
:key="item.value" :key="item.value"
...@@ -200,14 +272,40 @@ export default { ...@@ -200,14 +272,40 @@ export default {
> >
</el-option> </el-option>
</el-select> </el-select>
<el-input-number v-model="item.packagingPrice" :controls="false" :min="0" :placeholder="$t('整数或者两位小数')" class="w-100 mr-10" /> <el-input-number
<selector disabled v-model="item.packagingPriceUnit" :options="currencyList" :label-field="$l(null, 'title')" value-field="id" defaultable2 class="w-100 mr-10" /> v-model="item.packagingPrice"
:controls="false"
:min="0"
:placeholder="$t('整数或者两位小数')"
class="w-100 mr-10"
/>
<selector
disabled
v-model="item.packagingPriceUnit"
:options="currencyList"
:label-field="$l(null, 'title')"
value-field="id"
defaultable2
class="w-100 mr-10"
/>
<span class="mr-10">/</span> <span class="mr-10">/</span>
<selector disabled v-model="item.packagingVolumeUnit" :options="unitList" :label-field="$l(null, 'title')" value-field="id" defaultable2 class="w-100" /> <selector
<template v-if="i == value[packagingField].length -1 && !readonly"> disabled
<el-link type="primary" @click.native="addPackage" class="ml-5">{{$t('添加')}}</el-link> v-model="item.packagingVolumeUnit"
:options="unitList"
:label-field="$l(null, 'title')"
value-field="id"
defaultable2
class="w-100"
/>
<template v-if="i == value[packagingField].length - 1 && !readonly">
<el-link type="primary" @click.native="addPackage" class="ml-5">{{
$t("添加")
}}</el-link>
<el-divider direction="vertical"></el-divider> <el-divider direction="vertical"></el-divider>
<el-link type="danger" @click.native="deletePackage(i)">{{$t('删除')}}</el-link> <el-link type="danger" @click.native="deletePackage(i)">{{
$t("删除")
}}</el-link>
</template> </template>
</el-form-item> </el-form-item>
</template> </template>
...@@ -218,10 +316,11 @@ export default { ...@@ -218,10 +316,11 @@ export default {
.bold { .bold {
font-weight: bold; font-weight: bold;
} }
.text-lg{ .text-lg {
font-size: 1.3rem; font-size: 1.3rem;
} }
.tips{ .tips {
font-size: 1rem; color: red; font-size: 1rem;
color: red;
} }
</style> </style>
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