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

编辑空运价格,还没测完

parent 23a160e8
......@@ -9,6 +9,14 @@ export function createProductPrice(data) {
})
}
export function createProductPriceAir(data) {
return request({
url: '/ecw/product-price/createAir',
method: 'post',
data: data
})
}
// 更新产品价格
export function updateProductPrice(data) {
return request({
......@@ -18,6 +26,15 @@ export function updateProductPrice(data) {
})
}
// 更新空运价格
export function updateProductPriceAir(data) {
return request({
url: '/ecw/product-price/updateAir',
method: 'put',
data: data
})
}
// 删除产品价格
export function deleteProductPrice(id) {
return request({
......
<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: "PriceStep",
components: {Inputor, Selector},
components: {Template, Inputor, Selector},
props:{
index: Number,
priceName: String,
......@@ -17,6 +19,8 @@ export default {
type: Array,
default: []
},
showAdd: Boolean,
readonly: Boolean,
value:{
type: Object,
default: () => {
......@@ -26,9 +30,91 @@ export default {
}
}
},
created() {
if(!this.value.packagingList){
this.addPackage()
}
this.initSpecialPrice()
},
data(){
return {
form: {}
}
},
computed:{
packagingList(){
return getDictDatas(DICT_TYPE.ECW_PACKAGING_TYPE).filter(dict => {
let enable = true
this.value.packagingList.forEach(item => {
if(item.packagingTypes?.length && item.packagingTypes.indexOf(dict.value) > -1){
enable = false
}
})
return enable
})
}
},
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({
[`${this.fieldPrefix}Price`]: 0, // 新建默认给0,否则默认是null
[`${this.fieldPrefix}PriceUnit`]: this.value[`${this.fieldPrefix}PriceUnit`],
[`${this.fieldPrefix}VolumeUnit`]: this.value[`${this.fieldPrefix}VolumeUnit`],
"specialDictType": item.value
})
}
})
},
// 添加包装类型运费
addPackage(){
if(!this.value.packagingList){
this.$set(this.value, 'packagingList', [])
}
this.value.packagingList.push({
packagingPrice: undefined,
packagingPriceUnit : this.value[`${this.fieldPrefix}PriceUnit`],
packagingVolumeUnit : this.value[`${this.fieldPrefix}VolumeUnit`],
})
},
// 删除包装类型运费
deletePackage(index){
this.value.packagingList.splice(index, 1)
},
// 校验
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.value[`${this.fieldPrefix}Price`]){
valid = false
this.$message.error(`请设置第${index+1}阶段的${this.priceName}`)
}
// 包装价格检查
if(this.value.packagingList?.length){
this.value.packagingList.forEach((item, i) => {
if(item.packagingTypes?.length && !item.packagingPrice){
valid = false
this.$message.error(`请设置第${index+1}阶段的包装类型${i+1}${this.priceName}`)
}
})
}
return valid
}
}
}
......@@ -36,21 +122,110 @@ export default {
<template>
<div>
<el-form-item :label="$t('第{index}阶梯', {index})">
<div class="bold text-lg">{{$t('空运{type}设置', {type: priceName})}}</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')" value-field="id" class="w-100" />
<selector
:disabled="index>0"
v-model="value.weightUnit"
:options="unitList"
:label-field="$l(null, 'title')"
@input="$emit('changeUnit', {
value: $event,
field: 'weightUnit'
})"
value-field="id"
class="w-100" />
</el-form-item>
<el-form-item :label="$t('默认') + priceName">
<el-input-number v-model="value[`${fieldPrefix}Price`]" :placeholder="$t('整数或者两位小数')" :precision="2" :controls="false" class="w-100 mr-10"/>
<selector :disabled="index > 1" v-model="value[`${fieldPrefix}PriceUnit`]" :options="currencyList" :label-field="$l(null, 'title')" value-field="id" class="w-100" />
/ <selector :disabled="index > 1" v-model="value[`${fieldPrefix}VolumeUnit`]" :options="unitList" :label-field="$l(null, 'title')" value-field="id" class="w-100" />
<selector
:disabled="index>0"
v-model="value[`${fieldPrefix}PriceUnit`]"
:options="currencyList"
:label-field="$l(null, 'title')"
@input="$emit('changeUnit', {
value: $event,
field: `${fieldPrefix}PriceUnit`
})"
value-field="id"
class="w-100" />
/
<selector
:disabled="index>0"
v-model="value[`${fieldPrefix}VolumeUnit`]"
:options="unitList"
:label-field="$l(null, 'title')"
@input="$emit('changeUnit', {
value: $event,
field: `${fieldPrefix}VolumeUnit`
})"
value-field="id"
class="w-100" />
</el-form-item>
<!--特性加价-->
<template v-for="(special, specialIndex) in value.specialList">
<el-form-item
:label="getDictDataLabel(DICT_TYPE.ECW_SPECIAL_REQ_FOR_LINE_PRODUCTS, special.specialDictType) + priceName"
:key="specialIndex + 'transport'"
>
<el-input-number v-model.number="special[`${fieldPrefix}Price`]" :controls="false" :min="0" :placeholder="$t('整数或者两位小数')" class="w-100 mr-10" />
<selector disabled v-model="special[`${fieldPrefix}PriceUnit`]" :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[`${fieldPrefix}VolumeUnit`]" :options="unitList" :label-field="$l(null, 'title')" value-field="id" defaultable2 class="w-100" />
</el-form-item>
</template>
<!--包装类型价格-->
<template v-for="(item, i) in value.packagingList">
<el-form-item :label="$t('包装类型') + priceName + (i+1)">
<template #label>
<div class="el-form-item__label" style="width: 150px;">{{$t('包装类型') + priceName + (i+1)}}</div>
</template>
<el-select v-model="item.packagingTypes" multiple placeholder="请选择" style="width: 100%; max-width: 450px; margin-bottom: 5px; display: block">
<el-option
v-for="item in packagingList"
:key="item.value"
:label="$l(item, 'label')"
:value="item.value"
>
</el-option>
</el-select>
<el-input-number 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>
<selector disabled v-model="item.packagingVolumeUnit" :options="unitList" :label-field="$l(null, 'title')" value-field="id" defaultable2 class="w-100" />
<template v-if="i == value.packagingList.length -1 && !readonly">
<el-link type="primary" @click.native="addPackage" class="ml-5">{{$t('添加')}}</el-link>
<el-divider direction="vertical"></el-divider>
<el-link type="danger" @click.native="deletePackage(i)">{{$t('删除')}}</el-link>
</template>
<div v-if="!item.packagingTypes || !item.packagingTypes.length" class="tips">{{$t('未选择包装类型,将被忽略')}}</div>
</el-form-item>
</template>
</div>
</template>
<style scoped lang="scss">
.bold {
font-weight: bold;
}
.text-lg{
font-size: 1.3rem;
}
.tips{
font-size: 1rem; color: red;
}
</style>
......@@ -32,7 +32,7 @@ export default {
</script>
<template>
<dv>
<div>
<h2>{{$t('快捷设置')}}</h2>
<div class="flex items-center">
{{$t('批量加价')}}+
......@@ -51,7 +51,7 @@ export default {
<div class="mt-10">
<el-button @click="$emit('confirm', quickForm)" type="primary" :disabled="!quickForm.plus && !quickForm.minus">{{$t('确定')}}</el-button>
</div>
</dv>
</div>
</template>
<style scoped lang="scss">
......
This diff is collapsed.
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