Commit 1b2976e7 authored by 邓春圆's avatar 邓春圆

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

parents 7fcb34c6 953c20b7
......@@ -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({
......@@ -71,6 +88,15 @@ export function batchUpdateProductPrice(query) {
})
}
// 批量修改空运产品价格
export function batchUpdateProductPriceAir(data) {
return request({
url: '/ecw/product-price/batchUpdate',
method: 'put',
data
})
}
// 批量拉黑
export function batchBlock(query) {
return request({
......@@ -124,3 +150,12 @@ export function batchAddPrice(data) {
data
})
}
// 批量加价空运
export function batchAddPriceAir(data) {
return request({
url: '/ecw/product-price/batchAddPriceAir',
method: 'put',
data
})
}
......@@ -12,7 +12,7 @@
<el-input v-model="queryParams.titleZh" :placeholder="$t('产品关键字')" style="width:120px" clearable :disabled="loading"/>
<el-button type="primary" @click="reLoad" :loading="loading">{{$t('搜索')}}</el-button>
<div>
<div style="height: 36px; display: flex; align-items: center">
<el-checkbox :label="$t('全选') + `(${$t('{total}个', {total})})`" @change="toggleAll" :disabled="isAllProduct || loading"></el-checkbox>
</div>
</div>
......@@ -27,18 +27,28 @@
</div>
<div class="flex-1 ml-10">
<el-card style="height:100%">
<div slot="header" class="header flex">
<div class="flex-1 flex items-center">{{$t('已选{cnt}个产品', {cnt: choosedList.length})}}</div>
<div slot="header" class="header">
<el-select v-model="selectedFilterParams.typeId" :placeholder="$t('选择类型')" style="width:120px" clearable :disabled="loading">
<el-option v-for="item in typeList" :key="item.id" :label="item.titleZh" :value="item.id" />
</el-select>
<el-select v-model="selectedFilterParams.attrId" :placeholder="$t('选择属性')" style="width:120px" clearable :disabled="loading">
<el-option v-for="item in attrList" :key="item.id" :label="item.attrName" :value="item.id" />
</el-select>
<el-input v-model="selectedFilterParams.titleZh" :placeholder="$t('产品关键字')" style="width:120px" clearable :disabled="loading"/>
<!--<el-button type="primary" @click="reLoad" :loading="loading">{{$t('搜索')}}</el-button>-->
<div class="flex">
<div class="flex-1 flex items-center">{{$t('已选{cnt}个产品', {cnt: choosedList.length})}}</div>
<el-button :disabled="!choosedList.length" type="text" @click="clearAll">{{$t('全部清除')}}</el-button>
</div>
</div>
<div class="list">
<div class="item" v-for="(choosed) in selectedList" :key="choosed.id" :data-data="JSON.stringify(choosed)">
<div class="item" v-for="(choosed) in selectedList" :key="choosed.id">
<el-link class="el-icon-delete" @click="remove(choosed)" :disabled="isAllProduct"/> {{choosed.titleZh}}
<div>{{choosed.titleEn}}</div>
</div>
</div>
<el-pagination :total="choosedList.length" :page-sizes="[100, 200, 300, 500]" :page-size="pageSize" @current-change="rightPage = $event" layout="prev, pager, next, total, sizes" :current-page="rightPage" />
<el-pagination :total="filteredList.length" :page-sizes="[100, 200, 300, 500]" :page-size="pageSize" @current-change="rightPage = $event" layout="prev, pager, next, total, sizes" :current-page="rightPage" />
</el-card>
</div>
</div>
......@@ -75,6 +85,11 @@ export default {
titleZh: null,
typeId: null
},
selectedFilterParams:{
attrId: null,
titleZh: null,
typeId: null
},
choosedList: [],
typeList: [],
attrList: [],
......@@ -110,9 +125,24 @@ export default {
currentList(){
return this.list.slice((this.leftPage - 1) * this.pageSize, this.leftPage * this.pageSize)
},
// 已勾选的显示列表
// 已选中 且符合筛选的
filteredList(){
return this.choosedList.filter(item => {
if(this.selectedFilterParams.typeId && item.typeId != this.selectedFilterParams.typeId){
return false
}
if(this.selectedFilterParams.attrId && item.attrId != this.selectedFilterParams.attrId){
return false
}
if(this.selectedFilterParams.titleZh && item.titleZh.indexOf(this.selectedFilterParams.titleZh) == -1){
return false
}
return true
})
},
// 已勾选的显示列表,当前分页显示的
selectedList(){
return this.choosedList.slice((this.rightPage - 1) * this.pageSize, this.rightPage * this.pageSize)
return this.filteredList.slice((this.rightPage - 1) * this.pageSize, this.rightPage * this.pageSize)
}
},
watch: {
......@@ -131,7 +161,7 @@ export default {
},*/
defaultIds(newValue, oldValue){
if(!oldValue || !oldValue.length){
this.loadDefaultProds()
// this.loadDefaultProds()
}
},
isall(isall){
......
......@@ -939,6 +939,14 @@ export default {
'form.channelId'(){
this.calculationPrice()
if(this.form.lineId) this.getOfferData()
// 选择渠道后需要筛选目的城市和线路
// 有点卡,改异步
this.$nextTick(() => {
// 更新目的城市备选
this.getTradeCity()
// 更新线路备选
this.getOpenedRouterList()
})
},
'form.consigneeCountryCode'(){
if(this.form.lineId) this.getOfferData()
......@@ -1086,7 +1094,7 @@ export default {
this.productAttrList = (await getProductAttrList()).data
this.channelList = (await getChannelList()).data
this.tradeCityList = (await getTradeCityList()).data
await this.getTradeCity()
this.currencyList = (await getCurrencyList()).data
this.unitList = (await getUnitList()).data
this.transportList = this.getDictDatas(this.DICT_TYPE.ECW_TRANSPORT_TYPE)
......@@ -1110,6 +1118,13 @@ export default {
},
methods: {
async getTradeCity(){
let query = {}
if(this.form.channelId){
query.channelId = this.form.channelId
}
this.tradeCityList = (await getTradeCityList(query)).data
},
onTableMounted(e){
// console.warn('onTableMounted', e)
},
......@@ -1333,6 +1348,9 @@ export default {
if(this.form.transportId){
params.transportType = this.form.transportId
}
if(this.form.channelId){
params.channelId = this.form.channelId
}
// 始发,目的和运输方式都没有的时候不获取
if(!params.startCityId && !params.destCityId && !params.transportType) return false
getOpenedRouterList(params).then(res => this.routerList = res.data.filter(item => {
......
......@@ -274,6 +274,8 @@
<el-button v-else-if="scope.row.orderExceptionType=='stock_up_exception'" v-hasPermi="['ecw:exception:stockUpException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row.orderId)">{{$t('处理')}}</el-button>
<el-button v-else-if="scope.row.orderExceptionType=='channel_exception'" v-hasPermi="['ecw:exception:channelException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row.orderId)">{{$t('处理')}}</el-button>
<el-button v-else-if="scope.row.orderExceptionType=='channel_packaging_overweight_exception'" v-hasPermi="['ecw:exception:channelPackagingException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row.orderId)">{{$t('处理')}}</el-button>
<!-- 2.0.2 -->
<el-button v-else-if="scope.row.orderExceptionType=='line_weight_exception'" v-hasPermi="['ecw:exception:lineWeightException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row.orderId)">{{$t('处理')}}</el-button>
</template>
</el-table-column>
</el-table>
......
......@@ -146,6 +146,8 @@
<el-button v-else-if="scope.row.orderExceptionStatus==2&&scope.row.orderExceptionType=='stock_up_exception'" v-hasPermi="['ecw:exception:stockUpException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('查看')}}</el-button>
<el-button v-else-if="scope.row.orderExceptionStatus==2&&scope.row.orderExceptionType=='channel_exception'" v-hasPermi="['ecw:exception:channelException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('查看')}}</el-button>
<el-button v-else-if="scope.row.orderExceptionStatus==2&&scope.row.orderExceptionType=='channel_packaging_overweight_exception'" v-hasPermi="['ecw:exception:channelPackagingException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('查看')}}</el-button>
<!-- v2.0.2 -->
<el-button v-else-if="scope.row.orderExceptionStatus==2&&scope.row.orderExceptionType=='line_Weight_exception'" v-hasPermi="['ecw:exception:lineWeightException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('查看')}}</el-button>
<el-tag style="margin-left:10px" v-if="scope.row.orderExceptionStatus==2">{{$t('已完成')}}</el-tag>
<el-button v-else-if="scope.row.orderExceptionType=='order_superfluous_box_exception'" v-hasPermi="['ecw:exception:superfluousBox']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('处理')}}</el-button>
......@@ -176,6 +178,8 @@
<el-button v-else-if="scope.row.orderExceptionType=='stock_up_exception'" v-hasPermi="['ecw:exception:stockUpException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('处理')}}</el-button>
<el-button v-else-if="scope.row.orderExceptionType=='channel_exception'" v-hasPermi="['ecw:exception:channelException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('处理')}}</el-button>
<el-button v-else-if="scope.row.orderExceptionType=='channel_packaging_overweight_exception'" v-hasPermi="['ecw:exception:channelPackagingException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('处理')}}</el-button>
<!-- v2.0.2 -->
<el-button v-else-if="scope.row.orderExceptionType=='line_weight_exception'" v-hasPermi="['ecw:exception:lineWeightException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('处理')}}</el-button>
</template>
</el-table-column>
</el-table>
......
......@@ -14,7 +14,7 @@
</el-form-item>
</el-row>
<div v-if="shopData&&['goods_add_exception','line_loop_exception','overweight_exception','stock_up_exception','in_warehousing_diff_exception','channel_exception','not_shipping_channel_exception','channel_packaging_overweight_exception'].indexOf(orderExceptionData.orderExceptionType) == -1">
<div v-if="shopData&&['goods_add_exception','line_loop_exception','overweight_exception','line_weight_exception','stock_up_exception','in_warehousing_diff_exception','channel_exception','not_shipping_channel_exception','channel_packaging_overweight_exception'].indexOf(orderExceptionData.orderExceptionType) == -1">
<el-row>
<el-form-item :label="$t('产品名称')+':'" >
{{shopData.prodTitleZh || ''}}
......@@ -34,11 +34,11 @@
</el-form-item>
</el-row>
<el-row>
<el-form-item :label="$t('异常类型')+':'" v-if="orderExceptionData.orderExceptionType=='overweight_exception'||orderExceptionData.orderExceptionType=='channel_packaging_overweight_exception'">
<el-form-item :label="$t('异常类型')+':'" v-if="['overweight_exception','channel_packaging_overweight_exception'].indexOf(orderExceptionData.orderExceptionType) == -1">
<dict-tag :type="DICT_TYPE.ORDER_ERROR_TYPE" :value="orderExceptionData.orderExceptionType" />
</el-form-item>
</el-row>
<el-row :span="12" v-if="orderExceptionData.orderExceptionType=='overweight_exception'||orderExceptionData.orderExceptionType=='channel_packaging_overweight_exception'">
<el-row :span="12" v-if="['overweight_exception','channel_packaging_overweight_exception'].indexOf(orderExceptionData.orderExceptionType) == -1">
<el-form-item :label="$t('异常描述')+':'">
<!-- <dict-tag :type="DICT_TYPE.ORDER_ERROR_TYPE" :value="orderExceptionData.orderExceptionType" /> -->
<!-- {{orderExceptionData.orderExceptionDescVO?orderExceptionData.orderExceptionDescVO.descZh:''}} -->
......@@ -54,7 +54,7 @@
</el-row>
<!-- 单证异常,发货人异常,其他异常 不显示这部分内容 -->
<div v-if="['order_doc_exception','order_consignor_exception', 'order_other_exception','overweight_exception','channel_packaging_overweight_exception'].indexOf(orderExceptionData.orderExceptionType) == -1">
<div v-if="['order_doc_exception','order_consignor_exception', 'order_other_exception','overweight_exception','line_weight_exception','channel_packaging_overweight_exception'].indexOf(orderExceptionData.orderExceptionType) == -1">
<!-- 预付异常,提货异常,代收货款是针对整个订单的 -->
<template v-if="['order_pay_exception','order_pick_up_exception', 'order_cod_exception','not_customer_service_exception'].indexOf(orderExceptionData.orderExceptionType) > -1">
<el-row>
......@@ -248,7 +248,7 @@
<el-table-column :label="$t('货值')" prop="worth" />
</el-table>
<!-- 重量超限异常 -->
<el-table v-if="['overweight_exception'].indexOf(orderExceptionData.orderExceptionType) > -1" border :data="loopOrderItem">
<el-table v-if="['line_weight_exception','overweight_exception'].indexOf(orderExceptionData.orderExceptionType) > -1" border :data="loopOrderItem">
<el-table-column :label="$t('序号')" align="center" prop="id" type="index">
<template slot-scope="scope">
<span>{{scope.$index + 1}}</span>
......@@ -296,7 +296,7 @@
</el-table-column>
<el-table-column :label="$t('货值')" prop="worth" />
</el-table>
<div class="overweight_order" v-if="['overweight_exception','channel_packaging_overweight_exception'].indexOf(orderExceptionData.orderExceptionType) > -1&&handlerParams.orderExceptionHandlerResult=='update_weight_limit'">
<div class="overweight_order" v-if="(['overweight_exception','channel_packaging_overweight_exception'].indexOf(orderExceptionData.orderExceptionType) > -1&&handlerParams.orderExceptionHandlerResult=='update_weight_limit')||(['line_weight_exception',].indexOf(orderExceptionData.orderExceptionType) > -1&&handlerParams.orderExceptionHandlerResult=='change_line_weight')">
<span>{{$t('空运订单重量上限')}}(kg)</span>
<div style="width:200px;margin-left:20px"><el-input type="number" v-model="handlerParams.weightLimit"></el-input></div>
</div>
......@@ -482,11 +482,16 @@
<div class="channel">
<div style="width:80px">{{$t('全包价')}}:</div>
<div style="width:88%" class="channel" v-if="orderExceptionData.orderExceptionStatus==0&&handlerParams.orderExceptionHandlerResult=='allow_over'">
<div v-if="!scope.row.seaFreightCurrency||!scope.row.seaFreightVolume">
/
</div>
<div v-else>
<inputor default2="0" v-model.number="scope.row.oneSeaFreight" type="number" :placeholder="$t('整数或者两位小数')" class="w100" />
<span>{{currencyMap[scope.row.seaFreightCurrency]}} / {{unitMap[scope.row.seaFreightVolume]}}</span>
<!-- <selector v-model="scope.row.seaFreightCurrency" :options="currencyList" :label-field="$l('title')" value-field="id" defaultable2 class="w100" />
/ <selector v-model="scope.row.seaFreightVolume" :options="unitList" :label-field="$l('title')" value-field="id" defaultable2 class="w100" /> -->
</div>
</div>
<div v-else class="channel">
<span v-if="!scope.row.oneSeaFreight">{{$t('未报价')}}</span>
<span v-else>{{scope.row.oneSeaFreight}} {{currencyMap[scope.row.seaFreightCurrency]}} / {{unitMap[scope.row.seaFreightVolume]}}</span>
......@@ -497,7 +502,10 @@
<!-- <span v-if="!scope.row.oneSeaFreight">{{$t('运费')}}:{{$t('未报价')}}</span> -->
<div class="channel" v-if="orderExceptionData.orderExceptionStatus==0&&handlerParams.orderExceptionHandlerResult=='allow_over'">
<div style="width:80px">{{$t('运费')}}:</div>
<div style="width:88%" class="channel" >
<div v-if="!scope.row.seaFreightCurrency||!scope.row.seaFreightVolume">
/
</div>
<div style="width:88%" class="channel" v-else>
<inputor default2="0" v-model.number="scope.row.oneSeaFreight" type="number" :placeholder="$t('整数或者两位小数')" class="w100" />
<span>{{currencyMap[scope.row.seaFreightCurrency]}} / {{unitMap[scope.row.seaFreightVolume]}}</span>
<!-- <selector v-model="scope.row.seaFreightCurrency" :options="currencyList" :label-field="$l('title')" value-field="id" defaultable2 class="w100" />
......@@ -516,11 +524,16 @@
<div class="channel">
<!-- <span v-if="!scope.row.oneClearanceFreight">{{$t('未报价')}}</span> -->
<div class="channel" v-if="orderExceptionData.orderExceptionStatus==0&&handlerParams.orderExceptionHandlerResult=='allow_over'">
<div v-if="!scope.row.clearanceFreightCurrency||!scope.row.clearanceFreightVolume">
/
</div>
<div v-else>
<inputor default2="0" v-model.number="scope.row.oneClearanceFreight" type="number" :placeholder="$t('整数或者两位小数')" class="w100" />
<span>{{currencyMap[scope.row.clearanceFreightCurrency]}} / {{unitMap[scope.row.clearanceFreightVolume]}}</span>
<!-- <selector v-model="scope.row.clearanceFreightCurrency" :options="currencyList" :label-field="$l('title')" value-field="id" defaultable2 class="w100" />
/ <selector v-model="scope.row.clearanceFreightVolume" :options="unitList" :label-field="$l('title')" value-field="id" defaultable2 class="w100" /> -->
</div>
</div>
<div v-else>
<span v-if="!scope.row.oneClearanceFreight">{{$t('未报价')}}</span>
<span v-else>{{scope.row.oneClearanceFreight}} {{currencyMap[scope.row.clearanceFreightCurrency]}} / {{unitMap[scope.row.clearanceFreightVolume]}}</span>
......@@ -531,17 +544,22 @@
</el-table>
</div>
<!-- 线路单证异常,重量超限 -->
<div v-if="orderExceptionData.orderExceptionType=='line_loop_exception'||(orderExceptionData.orderExceptionType=='overweight_exception'&&handlerParams.orderExceptionHandlerResult=='allow_over')">
<div v-if="orderExceptionData.orderExceptionType=='line_loop_exception'||((orderExceptionData.orderExceptionType=='overweight_exception'||orderExceptionData.orderExceptionType=='line_weight_exception')&&handlerParams.orderExceptionHandlerResult=='allow_over')">
<div v-for="row in loopOrderItem" :key="row.orderItemId">
<div v-if="row.charging ==1">
<div v-if="orderExceptionData.orderExceptionStatus==0" class="price_list">
<div class="price_label">{{$t('全包价')}}:</div>
<div v-if="!row.seaFreightCurrency||!row.seaFreightVolume">
/
</div>
<div v-else>
<inputor default2="0" style="width:100px" v-model.number="row.oneSeaFreight" type="number" :placeholder="$t('整数或者两位小数')" />
<span>{{currencyMap[row.seaFreightCurrency]}} / {{unitMap[row.seaFreightVolume]}}</span>
<!-- <selector v-model="row.seaFreightCurrency" style="width:100px" :options="currencyList" :label-field="$l('title')" value-field="id" defaultable2 />
/ <selector v-model="row.seaFreightVolume" style="width:100px" :options="unitList" :label-field="$l('title')" value-field="id" defaultable2 /> -->
</div>
</div>
<div v-else class="price_list">
<div v-if="!row.oneSeaFreight">
<span class="price_label">{{$t('全包价')}}:</span>
......@@ -559,15 +577,24 @@
<div class="price_list">
<div class="price_label">{{$t('运费')}}:</div>
<div class="price_list">
<div v-if="!row.seaFreightCurrency||!row.seaFreightVolume">
/
</div>
<div v-else>
<inputor style="width:100px" default2="0" v-model.number="row.oneSeaFreight" type="number" :placeholder="$t('整数或者两位小数')" />
<span>{{currencyMap[row.seaFreightCurrency]}} / {{unitMap[row.seaFreightVolume]}}</span>
<!-- <selector style="width:100px" v-model="row.seaFreightCurrency" :options="currencyList" :label-field="$l('title')" value-field="id" defaultable2 />
/ <selector style="width:100px" v-model="row.seaFreightVolume" :options="unitList" :label-field="$l('title')" value-field="id" defaultable2 /> -->
</div>
</div>
</div>
<div class="price_list">
<div class="price_label">{{$t('清关费')}}:</div>
<div class="price_list">
<div v-if="!row.clearanceFreightCurrency||!row.clearanceFreightVolume">
/
</div>
<div v-else>
<inputor style="width:100px" default2="0" v-model.number="row.oneClearanceFreight" type="number" :placeholder="$t('整数或者两位小数')" />
<span>{{currencyMap[row.clearanceFreightCurrency]}} / {{unitMap[row.clearanceFreightVolume]}}</span>
<!-- <selector style="width:100px" v-model="row.clearanceFreightCurrency" :options="currencyList" :label-field="$l('title')" value-field="id" defaultable2 />
......@@ -575,6 +602,7 @@
</div>
</div>
</div>
</div>
<div v-else>
<div class="price_list">
<div v-if="!row.oneSeaFreight">
......@@ -839,11 +867,16 @@
<div class="channel">
<div style="width:80px">{{$t('全包价')}}:</div>
<div style="width:88%" class="channel" v-if="orderExceptionData.orderExceptionStatus==0">
<div v-if="!scope.row.seaFreightCurrency||!scope.row.seaFreightVolume">
/
</div>
<div v-else>
<inputor default2="0" v-model.number="scope.row.oneSeaFreight" type="number" :placeholder="$t('整数或者两位小数')" class="w100" />
<span>{{currencyMap[scope.row.seaFreightCurrency]}} / {{unitMap[scope.row.seaFreightVolume]}}</span>
<!-- <selector v-model="scope.row.seaFreightCurrency" :options="currencyList" :label-field="$l('title')" value-field="id" defaultable2 class="w100" />
/ <selector v-model="scope.row.seaFreightVolume" :options="unitList" :label-field="$l('title')" value-field="id" defaultable2 class="w100" /> -->
</div>
</div>
<div v-else class="channel">
<span v-if="!scope.row.oneSeaFreight">{{$t('未报价')}}</span>
<span v-else>{{scope.row.oneSeaFreight}} {{currencyMap[scope.row.seaFreightCurrency]}} / {{unitMap[scope.row.seaFreightVolume]}}</span>
......@@ -855,12 +888,17 @@
<div class="channel" v-if="orderExceptionData.orderExceptionStatus==0">
<div style="width:80px">{{$t('运费')}}:</div>
<div style="width:88%" class="channel" >
<div v-if="!scope.row.seaFreightCurrency||!scope.row.seaFreightVolume">
/
</div>
<div v-else>
<inputor default2="0" v-model.number="scope.row.oneSeaFreight" type="number" :placeholder="$t('整数或者两位小数')" class="w100" />
<span>{{$t('运费')}}:{{scope.row.oneSeaFreight}} {{currencyMap[scope.row.seaFreightCurrency]}} / {{unitMap[scope.row.seaFreightVolume]}}</span>
<!-- <selector v-model="scope.row.seaFreightCurrency" :options="currencyList" :label-field="$l('title')" value-field="id" defaultable2 class="w100" />
/ <selector v-model="scope.row.seaFreightVolume" :options="unitList" :label-field="$l('title')" value-field="id" defaultable2 class="w100" /> -->
</div>
</div>
</div>
<div v-else class="channel">
<span v-if="!scope.row.oneSeaFreight">{{$t('运费')}}:{{$t('未报价')}}</span>
<span v-else>{{$t('运费')}}:{{scope.row.oneSeaFreight}} {{currencyMap[scope.row.seaFreightCurrency]}} / {{unitMap[scope.row.seaFreightVolume]}}</span>
......@@ -873,11 +911,16 @@
<div class="channel">
<!-- <span v-if="!scope.row.oneClearanceFreight">{{$t('未报价')}}</span> -->
<div class="channel" v-if="orderExceptionData.orderExceptionStatus==0">
<div v-if="!scope.row.clearanceFreightCurrency||!scope.row.clearanceFreightVolume">
/
</div>
<div v-else>
<inputor default2="0" v-model.number="scope.row.oneClearanceFreight" type="number" :placeholder="$t('整数或者两位小数')" class="w100" />
<span>{{currencyMap[scope.row.clearanceFreightCurrency]}} / {{unitMap[scope.row.clearanceFreightVolume]}}</span>
<!-- <selector v-model="scope.row.clearanceFreightCurrency" :options="currencyList" :label-field="$l('title')" value-field="id" defaultable2 class="w100" />
/ <selector v-model="scope.row.clearanceFreightVolume" :options="unitList" :label-field="$l('title')" value-field="id" defaultable2 class="w100" /> -->
</div>
</div>
<div v-else>
<span v-if="!scope.row.oneClearanceFreight">{{$t('未报价')}}</span>
<span v-else>{{scope.row.oneClearanceFreight}} {{currencyMap[scope.row.clearanceFreightCurrency]}} / {{unitMap[scope.row.clearanceFreightVolume]}}</span>
......@@ -947,9 +990,9 @@
待审核可能没有bpmStatus字段
-->
<template v-if="orderExceptionData.bpmStatus == 1 || (orderExceptionData.bpmId && !orderExceptionData.bpmStatus)">
<el-button v-if="['channel_packaging_overweight_exception','overweight_exception'].indexOf(orderExceptionData.orderExceptionType)>-1" type="primary" @click="$router.push(`/bpm/process-instance/detail?id=`+orderExceptionData.bpmId)">{{$t('重量超限改价审核中')}}</el-button>
<el-button v-if="['channel_packaging_overweight_exception','line_weight_exception','overweight_exception'].indexOf(orderExceptionData.orderExceptionType)>-1" type="primary" @click="$router.push(`/bpm/process-instance/detail?id=`+orderExceptionData.bpmId)">{{$t('重量超限改价审核中')}}</el-button>
<el-button v-else type="primary" @click="$router.push(`/bpm/process-instance/detail?id=`+orderExceptionData.bpmId)">{{$t('审核中')}}</el-button>
<el-button v-if="['channel_packaging_overweight_exception','overweight_exception'].indexOf(orderExceptionData.orderExceptionType)>-1" plain type="primary" @click="cancelAudit">{{$t('取消重量超限改价审核')}}</el-button>
<el-button v-if="['channel_packaging_overweight_exception','line_weight_exception','overweight_exception'].indexOf(orderExceptionData.orderExceptionType)>-1" plain type="primary" @click="cancelAudit">{{$t('取消重量超限改价审核')}}</el-button>
<el-button v-else plain type="primary" @click="cancelAudit">{{$t('取消审核')}}</el-button>
<el-button plain type="primary" @click="$store.dispatch('tagsView/delCurrentView')">{{$t('返回')}}</el-button>
</template>
......@@ -1212,6 +1255,7 @@
// if(response.data.hasOwnProperty('orderItemId')){
// that.getShopData(response.data.orderItemId)
// }
if(that.orderExceptionData.orderExceptionType == 'order_pay_exception'){
that.getOrderFeeByIdData()
that.getPreExceptionData()
......@@ -1266,21 +1310,21 @@
if(response.data.customerId){
this.getCustomerData(response.data.customerId)
}
if(['overweight_exception','not_shipping_channel_exception','channel_packaging_overweight_exception','channel_exception'].indexOf(this.orderExceptionData.orderExceptionType)>-1){
if(['overweight_exception','line_weight_exception','not_shipping_channel_exception','channel_packaging_overweight_exception','channel_exception'].indexOf(this.orderExceptionData.orderExceptionType)>-1){
// this.handlerParams.channelPriceList = []
this.getOpenedRouterList()
if(this.orderExceptionData.orderExceptionStatus==0){
this.orderData.orderItemVOList.map(v=>{
if(!v.oneSeaFreight){
v.seaFreightCurrency = this.currencyList[0]['id']
v.seaFreightVolume = this.unitList[1]['id']
}
if(!v.oneClearanceFreight){
v.clearanceFreightCurrency = this.currencyList[0]['id']
v.clearanceFreightVolume = this.unitList[1]['id']
}
})
}
// if(this.orderExceptionData.orderExceptionStatus==0){
// this.orderData.orderItemVOList.map(v=>{
// if(!v.oneSeaFreight){
// v.seaFreightCurrency = this.currencyList[0]['id']
// v.seaFreightVolume = this.unitList[1]['id']
// }
// if(!v.oneClearanceFreight){
// v.clearanceFreightCurrency = this.currencyList[0]['id']
// v.clearanceFreightVolume = this.unitList[1]['id']
// }
// })
// }
}
if(this.orderExceptionData.orderExceptionType=='line_loop_exception'){
this.getExceptionPriceList('line_loop_exception',1)
......@@ -1288,7 +1332,7 @@
if(this.handlerParams.orderExceptionHandlerResult=='continue_channel'){
this.getExceptionPriceList('continue_channel',1)
}
if(['overweight_exception','channel_packaging_overweight_exception'].indexOf(this.orderExceptionData.orderExceptionType)>-1){
if(['overweight_exception','line_weight_exception','channel_packaging_overweight_exception'].indexOf(this.orderExceptionData.orderExceptionType)>-1){
if(this.orderExceptionData.orderExceptionStatus!='0'&&this.handlerParams.orderExceptionHandlerResult=='allow_over'){
this.getExceptionPriceList('continue_channel',2)
}else{
......@@ -1320,7 +1364,7 @@
this.productId2 = this.productId1 = this.handlerParams.productId
}
if(this.orderExceptionData.orderExceptionStatus==0){
if(this.orderExceptionData.orderExceptionType=='overweight_exception'&&this.orderExceptionData.additionalJson&&this.orderExceptionData.additionalJson.weightSum){
if((this.orderExceptionData.orderExceptionType=='overweight_exception'||this.orderExceptionData.orderException=='line_weight_exception')&&this.orderExceptionData.additionalJson&&this.orderExceptionData.additionalJson.weightSum){
this.$set(this.handlerParams,'weightLimit', this.orderExceptionData.additionalJson.weightSum)
}
if(this.orderExceptionData.orderExceptionType=='channel_packaging_overweight_exception'&&this.orderExceptionData.additionalJson&&this.orderExceptionData.additionalJson.packagingWeightSum){
......@@ -1414,20 +1458,31 @@
return
}
}
if(['channel_packaging_overweight_exception','overweight_exception'].indexOf(this.orderExceptionData.orderExceptionType)>-1&&this.handlerParams.orderExceptionHandlerResult=='update_weight_limit'){
if(['channel_packaging_overweight_exception','line_weight_exception','overweight_exception'].indexOf(this.orderExceptionData.orderExceptionType)>-1&&this.handlerParams.orderExceptionHandlerResult=='update_weight_limit'){
if(!this.handlerParams.weightLimit){
this.$modal.msgError(this.$t('请输入空运订单上限'));
return
}
}
if(['line_loop_exception','channel_packaging_overweight_exception','overweight_exception','not_shipping_channel_exception'].indexOf(this.orderExceptionData.orderExceptionType)>-1){
if(['line_loop_exception','channel_packaging_overweight_exception','line_weight_exception','overweight_exception','not_shipping_channel_exception'].indexOf(this.orderExceptionData.orderExceptionType)>-1){
if(this.orderExceptionData.orderExceptionType=='line_loop_exception'||((this.orderExceptionData.orderExceptionType=='channel_packaging_overweight_exception'||this.orderExceptionData.orderExceptionType=='overweight_exception')&&this.handlerParams.orderExceptionHandlerResult=='allow_over')){
this.handlerParams.orderItemVOList = this.loopOrderItem
}else{
this.handlerParams.orderItemVOList = this.orderData.orderItemVOList
}
this.handlerParams.channelPriceList = []
let priceUnit = false
this.handlerParams.orderItemVOList.map(v=>{
if(v.charging==1){
if(!v.seaFreightCurrency||!v.seaFreightVolume){
priceUnit = true
}
}else{
if(!v.seaFreightCurrency||!v.seaFreightVolume||!v.clearanceFreightCurrency||!v.clearanceFreightVolume){
priceUnit = true
}
}
var listItem = {
orderId:v.orderId,
orderItemId:v.orderItemId,
......@@ -1442,6 +1497,10 @@
}
this.handlerParams.channelPriceList.push(listItem)
})
if(priceUnit){
this.$modal.msgError(this.$t('请先去设置运费或清关费本身的货币单位、计价单位'));
return
}
}
handlerExceptionByExceptionId(this.handlerParams).then(res=>{
this.$modal.msgSuccess(this.$t('提交成功'));
......
<template>
<div class="app-container">
<el-form ref="form" :model="form" :rules="rules" label-width="150px">
<products-selector ref="productSelector" v-model="form.productIdList" show-all @setall="isAllProduct=$event" :default-ids="form.productIdList" enable-filtered @setFiltered="isAllFilteredProduct=$event" class="mb-20" />
<routers-selector v-model="selectedRoutes" type="air" />
<el-card style="margin-bottom: 10px">
<div slot="header" style="font-size:20px;">
{{$t('价格设置')}}
</div>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item :label="$t('预付')" prop="needPay" >
<el-radio-group v-model="form.needPay">
<el-radio :label="1">{{ $t('预付') }}</el-radio>
<el-radio :label="0">{{ $t('均可') }}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item :label="$t('单价模式')" prop="priceType">
<dict-selector :type="DICT_TYPE.ECW_PRICE_TYPE" v-model="form.priceType" form-type="radio" formatter='number' />
</el-form-item>
<el-form-item
:label="$t('最小起计量')"
:prop="`minWeight`"
>
<el-input-number v-model="form.minWeight" :controls="false" class="w-100"/>
/ <selector v-model="form.minWeightUnit" :options="unitList" :label-field="$l(null, 'title')" value-field="id" defaultable2 class="w-100" disabled />
</el-form-item>
</el-col>
<el-col :span="12">
<quick-set :unit-list="unitList" :currency-list="currencyList" :value="form"></quick-set>
</el-col>
</el-row>
<!--全包价-->
<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>
<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>
<el-card>
<div slot="header" style="font-size:20px;">
{{$t('基础信息')}}
</div>
<el-form-item :label="$t('是否预约入仓')" prop="needBook">
<el-radio v-model.number="form.needBook" :label="1">{{$t('是')}}</el-radio>
<el-radio v-model.number="form.needBook" :label="0">{{$t('否')}}</el-radio>
</el-form-item>
<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>
<div style="margin: 20px 0">
<el-button @click="submitForm" type="primary" :loading="loading">{{$t('确认提交')}}</el-button>
<el-button type="default" @click="$router.back()">{{$t('返回上一页')}}</el-button>
</div>
</div>
</template>
<script>
import RoutersSelector from '@/components/RoutersSelector'
import {batchUpdateProductPrice, batchUpdateProductPriceAir, getProductPrice} from "@/api/ecw/productPrice";
import { getCurrencyList } from '@/api/ecw/currency';
import { getUnitList } from '@/api/ecw/unit';
import ProductsSelector from '@/components/ProductsSelector'
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 {getProductTypeList} from "@/api/ecw/productType";
// 定义默认的价格单位和体积单位
const DEFAULT_PRICE_UNIT = 1
const DEFAULT_VOLUME_UNIT = 6
const DEFAULT_WEIGHT_UNIT = 6
export default {
components: {PriceStep, QuickSet, RoutersSelector, ProductsSelector, Selector, Inputor },
data() {
return {
checkList: [],
selectedRoutes: [], // 勾选的路线渠道
form: {
stepPrice: 0,
priceType: null
},
isAllProduct: false, // 是否全部商品
isAllFilteredProduct: false, // 是否勾選全部搜索結果
specialProducts: [],
rules: {},
product: null,
currencyList: [],
unitList: [],
productTypeList: [],
productDisabled: true,
lineList: [], //路线数组
loading: false,
}
},
computed: {
// 判断是否空值
isEmpty() {
return (content) => {
return !content && content !== 0 && content !== '0'
}
},
},
watch: {
checkList() { //选择路线
if (this.checkList.length > 0) {
this.form.lineChannelList = this.checkList.map(item => {
return { lineId: item, shippingChannelId: 0 }
})
} else {
this.form.lineChannelList = []
}
},
product() {
this.$set(this.form, 'productType', this.product.typeId)
},
// 价格类型切换,需要初始化对应的字段
'form.priceType'(priceType){
if(priceType == 1 && !this.form.fullPriceStepList?.length){
this.handleAddPrice('fullPriceStepList', 'all')
}
if(priceType == 0){
if(!this.form.freightPriceStepList?.length){
this.handleAddPrice('freightPriceStepList', 'transport')
}
if(!this.form.clearancePriceStepList?.length){
this.handleAddPrice('clearancePriceStepList', 'clearance')
}
}
},
'form.needBook'(val){
if(val) this.$set(this.form, 'dayLimit', 10000)
else delete this.form.dayLimit
},
},
async created() {
this.currencyList = (await getCurrencyList())?.data || []
this.unitList = (await getUnitList())?.data || []
this.$set(this.form, 'stepPrice', 1)
// 如果是复制,则获取数据并填充,先复制,然后填充特需,避免数据的特需不全导致部分不显示
if(this.$route.query.templateId){
await this.getTemplateDetail(this.$route.query.templateId)
}
},
methods: {
// 获取模板数据(复制的源路线价格信息)
async getTemplateDetail(id){
const res = await getProductPrice(id)
// 填充商品、线路、价格信息、出货渠道(空运)
// this.form.productIdList = [res.data.productId]
/* 23-11-07要求不复制商品和线路 https://zentao.test.jdshangmen.com/bug-view-5145.html
this.selectedRoutes = [{
"lineId": res.data.warehouseLineId,
"channelId": res.data.shippingChannelId,
"transportId": res.data.warehouseLineDO.transportType,
"shippingChannelId":res.data.channelId
}]*/
// 要复制过来的字段
const {
allPrice,
allPriceUnit,
allVolumeUnit,
transportPrice,
transportPriceUnit,
transportVolumeUnit,
clearancePrice,
clearancePriceUnit,
clearanceVolumeUnit,
priceType,
stepPrice,
specialList,
priceStepList,
minWeight,
minWeightUnit,
needOrderInquiry,
needBook,
needPay
} = res.data
const data = {
allPrice,
allPriceUnit,
allVolumeUnit,
transportPrice,
transportPriceUnit,
transportVolumeUnit,
clearancePrice,
clearancePriceUnit,
clearanceVolumeUnit,
priceType,
stepPrice,
specialList,
priceStepList,
minWeight,
minWeightUnit,
needOrderInquiry,
needBook,
needPay
}
this.$set(this, 'form', Object.assign({}, this.form, data))
// 产品选择器默认选择的商品
/* 23-11-07要求不复制商品和线路 https://zentao.test.jdshangmen.com/bug-view-5145.html
getProduct(res.data.productId).then(res => {
this.$refs.productSelector.choose(res.data)
})*/
},
handleAddPrice(field, fieldPrefix){
if(!this.form[field]){
this.$set(this.form, field, [])
}
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
}
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)
},
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 => {
p[data.field] = data.value
})
}
if(item.specialList?.length){
item.specialList.forEach(p => {
p[data.field] = data.value
})
}
})
},
// 获得用语提交的阶梯价副本
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
},
submitForm() {
this.$refs["form"].validate(async (valid) => {
if (!valid) {
return;
}
// 只有新增的时候做判断
if (!this.$route.query.ids && (!this.selectedRoutes || !this.selectedRoutes.length)) {
this.$message.error(this.$t('请选择线路'));
return;
}
let data = Object.assign({}, this.form, {
isAllProduct: this.isAllProduct ? 1:0
})
// 如果是勾選了全部篩選商品,則獲取商品ID
if(this.isAllFilteredProduct){
data.productIdList = await this.$refs.productSelector.getFilteredIds()
}
if(!data.isAllProduct && (!data.productIdList || !data.productIdList.length)){
return this.$message.error('请选择商品')
}
data.lineChannelList = this.selectedRoutes
let isValid = true
for (let stepPrice of this.$refs.stepPrice){
if(!stepPrice.validate()){
isValid = false
break
}
}
if(!isValid)return
// 全包价
if(this.form.priceType == 1) {
data.fullPriceStepList = this.getPriceList(this.form.fullPriceStepList)
}else{
data.clearancePriceStepList = this.getPriceList(this.form.clearancePriceStepList)
data.freightPriceStepList = this.getPriceList(this.form.freightPriceStepList)
}
if(data.lineChannelList.length < 1){
return this.$message.error(this.$t('请选择需要修改的路线'))
}
await this.$confirm(this.$t('已选择{route}条路线,{product}个商品;确认提交修改?', {
route: data.lineChannelList.length,
product: this.isAllProduct ? this.$refs.productSelector.allTotal : data.productIdList.length
}))
this.loading = true
batchUpdateProductPriceAir(data).then(response => {
this.$modal.msgSuccess(this.$t("修改成功"));
this.$router.replace('/lineProject/product-price?' + (new URLSearchParams(this.$route.query)).toString())
})
.finally(res => this.loading = false)
});
},
// 快捷设置,只更新默认运费
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()))
})
}
}
}
</script>
<style scoped>
.w100{
width: 100px;
}
.mr10{
margin-right: 10px;
}
</style>
......@@ -13,59 +13,85 @@
</div>
<div :gutter="20">
<el-form-item :label="$t('单价模式')" prop="priceType">
<dict-selector :type="DICT_TYPE.ECW_PRICE_TYPE" v-model="form.priceType" form-type="radio" />
<dict-selector :type="DICT_TYPE.ECW_PRICE_TYPE" v-model="form.priceType" form-type="radio" formatter="number" />
<!--海运才需要是否含阶梯价的选项,空运只有阶梯价就不需要了-->
<div v-if="type == 'sea'">
<el-checkbox v-model="form.stepPrice" :true-label="1" :false-label="0">{{$t('是否含阶梯价')}}</el-checkbox>
</div>
</el-form-item>
<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 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 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"
:step-tips="!isStepPriceValid(item) ? $t('区间设置不完整,将被忽略') : null"
@add="handleAddPrice('fullPriceStepList', $event)"
@delete="handleDeletePrice('fullPriceStepList', $event)"
@changeUnit="handleUnitChange(form.fullPriceStepList, index, ...$event)"
></price-step>
</div>
</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>
<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"
:step-tips="!isStepPriceValid(item) ? $t('区间设置不完整,将被忽略') : null"
@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"
:step-tips="!isStepPriceValid(item) ? $t('区间设置不完整,将被忽略') : null"
@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>
</div>
</el-card>
</el-form>
......@@ -85,9 +111,16 @@ import ProductsSelector from '@/components/ProductsSelector'
import Selector from '@/components/Selector'
import Inputor from '@/components/Inputor'
import Decimal from 'decimal.js'
import SeaPrice from "@/views/ecw/productPrice/components/SeaPrice.vue";
import Template from "@/views/cms/template/index.vue";
import PriceStep from "@/views/ecw/productPrice/components/PriceStep.vue";
const DEFAULT_PRICE_UNIT = 1
const DEFAULT_VOLUME_UNIT = 7
const DEFAULT_WEIGHT_UNIT = 7
export default {
components: { RoutersSelector, ProductsSelector, Selector, Inputor },
components: {PriceStep, Template, SeaPrice, RoutersSelector, ProductsSelector, Selector, Inputor },
data() {
return {
checkList: [],
......@@ -117,23 +150,13 @@ export default {
type(){
return this.$route.path.split(/[-_]/).pop()
},
// 默认运费的货币和体积单位
currencyAndUnit(){
let currency = null, unit = null, fields = null
// 如果是阶梯价格则取第一阶梯,否则就取form中的字段
let obj = this.form.stepPrice == 1 ? this.form.priceStepList[0] : this.form
// 全包价
if(this.form.priceType == 1){
currency = obj.allPriceUnit
unit = obj.allVolumeUnit
}else{
currency = obj.transportPriceUnit
unit = obj.transportVolumeUnit
}
return {currency, unit}
// 判断阶梯价是否有效
isStepPriceValid(){
return stepPrice => {
return stepPrice.startNum && stepPrice.endNum
}
},
},
watch: {
checkList() { //选择路线
if (this.checkList.length > 0) {
......@@ -147,25 +170,21 @@ export default {
product() {
this.$set(this.form, 'productType', this.product.typeId)
},
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()
}
},
'form.stepPrice'(stepPrice){
if(this.form.stepPrice === 1){
this.initStepPrice()
}
this.stepPrice = !!stepPrice
},
},
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 || []
this.$nextTick(async() => {
this.setDefaultVolumeUnit(this.type == 'air' ? 6 : 7)
......@@ -187,76 +206,91 @@ export default {
})
},
methods: {
// 同步全部单位
syncAllUnit(){
let obj = 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,
handleAddPrice(field, fieldPrefix){
if(!this.form[field]){
this.$set(this.form, field, [])
}
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
}
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)
},
handleUnitChange(stepPriceList, index, data){
console.log('handleUnitChange', ...arguments)
if(index > 0) return
// 全包价还需要同步阶梯的重量单位
if(this.form.stepPrice == 1){
fields['weightUnit'] = obj.weightUnit
// 如果是重量单位,且不是清关费想换的,则需要同步最小起计量单位
if(data.field === 'weightUnit' && data.type != 'clearance'){
this.form.minWeightUnit = data.value
}
this.syncSpecialUnit(fields)
},
// 同步特需的货币单位和体积单位
syncSpecialUnit(obj){
console.log('syncSpecialUnit', obj)
if(!obj) return
// 同步特需单位
this.form.specialList.forEach(item => {
Object.assign(item, obj)
stepPriceList.forEach(item => {
item[data.field] = data.value
if(item.packagingList?.length){
item.packagingList.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))
}
if(item.specialList?.length){
item.specialList.forEach(p => {
p[data.field] = data.value
})
}
})
},
// 不是阶梯价需要 同步最小起计量
if(obj['transportVolumeUnit'] || obj['allVolumeUnit']){
this.$set(this.form, 'minWeightUnit', obj['transportVolumeUnit'] || obj['allVolumeUnit'])
}
// 获得用语提交的阶梯价副本
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.filter(this.isStepPriceValid)
},
// 价格校验器
priceValidator(rule, value, callback){
if(!value || value == '') return callback()
value = parseFloat(value)
if(!value || value < 0){
return callback(new Error('价格错误'))
// 非阶梯价格更新单位
handleFormUnitChange(data){
if(this.form.specialList?.length){
this.form.specialList.forEach(p => {
p[data.field] = data.value
})
}
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)
})
initStepPrice(){
if(this.form.priceType == 1 && !this.form.fullPriceStepList?.length){
this.handleAddPrice("fullPriceStepList", 'all')
}
if(this.form.priceType === 0){
if(!this.form.freightPriceStepList?.length){
this.handleAddPrice('freightPriceStepList', 'transport')
}
if(!this.form.clearancePriceStepList?.length){
this.handleAddPrice('clearancePriceStepList', 'clearance')
}
}
},
submitForm() {
......@@ -290,10 +324,39 @@ export default {
if(data.lineChannelList.length < 1){
return this.$message.error(this.$t('请选择需要修改的路线'))
}
await this.$confirm(this.$t('已选择{route}条路线,{product}个商品;确认提交修改?', {
data.fullPriceStepList= this.getPriceList(data.fullPriceStepList)
data.freightPriceStepList= this.getPriceList(data.freightPriceStepList)
data.clearancePriceStepList= this.getPriceList(data.clearancePriceStepList)
// 检查被忽略的阶梯价
let msgArr = [];
if(data.priceType){
const ignoreAll = data.fullPriceStepList.length != this.form.fullPriceStepList.length
if(ignoreAll){
msgArr.push(this.$t("{n}个全包阶梯价", {n: ignoreAll}))
}
}else{
const ignoreFreight = this.form.freightPriceStepList.length - data.freightPriceStepList.length
const ignoreClearance = this.form.clearancePriceStepList.length - data.clearancePriceStepList.length
if(ignoreFreight){
msgArr.push(this.$t("{n}个运费阶梯价", {n: ignoreFreight}))
}
if(ignoreClearance){
msgArr.push(this.$t("{n}个清关费阶梯价", {n: ignoreClearance}))
}
}
let msg = this.$t('已选择{route}条路线,{product}个商品', {
route: data.lineChannelList.length,
product: this.isAllProduct ? this.$refs.productSelector.allTotal : data.productIdList.length
}))
})
console.log(msgArr)
if(msgArr.length){
msg += ";" + msgArr.join(",") + "被忽略"
}
await this.$confirm(msg + this.$t(';确认提交修改?', ))
this.loading = true
batchAddPrice(data).then(async(response) => {
await this.$alert(this.$t("操作成功"));
......
<template>
<div class="app-container">
<el-form ref="form" :model="form" :rules="rules" label-width="150px">
<products-selector ref="productSelector" v-model="form.productIdList" show-all @setall="isAllProduct=$event"
enable-filtered @setFiltered="isAllFilteredProduct=$event"
:default-ids="form.productIdList" class="mb-20"/>
<routers-selector v-model="selectedRoutes" :type="type" />
<el-card style="margin-bottom: 10px">
<div slot="header" style="font-size:20px;">
{{$t('价格设置')}}
</div>
<el-form-item :label="$t('单价模式')" prop="priceType">
<dict-selector :type="DICT_TYPE.ECW_PRICE_TYPE" v-model="form.priceType" form-type="radio" formatter="number" />
</el-form-item>
<!--全包价-->
<template v-if="form.priceType === 1" >
<div v-for="(item, index) in form.fullPriceStepList" :key="index" class="mb-20">
<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"
:step-tips="!isStepPriceValid(item) ? $t('区间设置不完整,将被忽略') : null"
@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" class="mb-20">
<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"
:step-tips="!isStepPriceValid(item) ? $t('区间设置不完整,将被忽略') : null"
@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" class="mb-20">
<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"
:step-tips="!isStepPriceValid(item) ? $t('区间设置不完整,将被忽略') : null"
@add="handleAddPrice('clearancePriceStepList', $event)"
@delete="handleDeletePrice('clearancePriceStepList', $event)"
@changeUnit="handleUnitChange(form.clearancePriceStepList, index, ...$event)"
></price-step>
</div>
</el-col>
</el-row>
</el-card>
</el-form>
<div style="margin: 20px 0">
<el-button @click="submitForm" type="primary" :loading="loading">{{$t('确认提交')}}</el-button>
<el-button type="default" @click="$router.back()">{{$t('返回上一页')}}</el-button>
</div>
</div>
</template>
<script>
import RoutersSelector from '@/components/RoutersSelector'
import {batchAddPrice, batchAddPriceAir, batchUpdateProductPrice, getProductPrice} from "@/api/ecw/productPrice";
import { getCurrencyList } from '@/api/ecw/currency';
import { getUnitList } from '@/api/ecw/unit';
import ProductsSelector from '@/components/ProductsSelector'
import Selector from '@/components/Selector'
import Inputor from '@/components/Inputor'
import Decimal from 'decimal.js'
import PriceStep from "@/views/ecw/productPrice/components/PriceStep.vue";
import {getProductTypeList} from "@/api/ecw/productType";
// 定义默认的价格单位和体积单位
const DEFAULT_PRICE_UNIT = 1
const DEFAULT_VOLUME_UNIT = 6
const DEFAULT_WEIGHT_UNIT = 6
export default {
components: {PriceStep, RoutersSelector, ProductsSelector, Selector, Inputor },
data() {
return {
checkList: [],
selectedRoutes: [], // 勾选的路线渠道
form: {
priceType: undefined,
specialList: [],
// 空运固定阶梯价
stepPrice: 1,
fullPriceStepList:[],
freightPriceStepList:[],
clearancePriceStepList:[]
},
isAllProduct: false, // 是否全部商品
isAllFilteredProduct: false, // 是否全部篩選商品
specialProducts: [],
rules: {},
product: null,
currencyList: [],
unitList: [],
productTypeList: [],
productDisabled: true,
lineList: [], //路线数组
loading: false,
// 批量加价/减价
quickForm:{}
}
},
computed: {
// 类型,默认海运sea,air表示空运
type(){
return this.$route.path.split(/[-_]/).pop()
},
// 判断阶梯价是否有效
isStepPriceValid(){
return stepPrice => {
return stepPrice.startNum && stepPrice.endNum
}
},
},
watch: {
checkList() { //选择路线
if (this.checkList.length > 0) {
this.form.lineChannelList = this.checkList.map(item => {
return { lineId: item, shippingChannelId: 0 }
})
} else {
this.form.lineChannelList = []
}
},
product() {
this.$set(this.form, 'productType', this.product.typeId)
},
"form.priceType"(priceType){
if(priceType && !this.form.fullPriceStepList?.length){
this.handleAddPrice("fullPriceStepList", "all")
}
if(!priceType){
if(!this.form.freightPriceStepList?.length){
this.handleAddPrice("freightPriceStepList", "transport")
}
if(!this.form.clearancePriceStepList?.length){
this.handleAddPrice("clearancePriceStepList", "clearance")
}
}
}
},
async created() {
this.currencyList = (await getCurrencyList())?.data || []
this.unitList = (await getUnitList())?.data || []
this.productTypeList = (await getProductTypeList())?.data || []
},
methods: {
handleAddPrice(field, fieldPrefix){
if(!this.form[field]){
this.$set(this.form, field, [])
}
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
}
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)
},
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 => {
p[data.field] = data.value
})
}
if(item.specialList?.length){
item.specialList.forEach(p => {
p[data.field] = data.value
})
}
})
},
// 获得用语提交的阶梯价副本
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.filter(this.isStepPriceValid)
},
submitForm() {
this.$refs["form"].validate(async (valid) => {
if (!valid) {
return;
}
// 只有新增的时候做判断
if (!this.$route.query.ids && (!this.selectedRoutes || !this.selectedRoutes.length)) {
this.$message.error(this.$t('请选择线路'));
return;
}
let data = Object.assign({}, this.form, {
// lineChannelList: this.selectedRoutes,
// specialList: this.specialProducts,
isAllProduct: this.isAllProduct ? 1:0
})
if(!data.isAllProduct && (!data.productIdList || !data.productIdList.length)){
return this.$message.error(this.$t('请选择商品') + "!")
}
data.lineChannelList = this.selectedRoutes
if(data.lineChannelList.length < 1){
return this.$message.error(this.$t('请选择需要修改的路线'))
}
data.fullPriceStepList= this.getPriceList(data.fullPriceStepList)
data.freightPriceStepList= this.getPriceList(data.freightPriceStepList)
data.clearancePriceStepList= this.getPriceList(data.clearancePriceStepList)
// 检查被忽略的阶梯价
let msgArr = [];
if(data.priceType){
const ignoreAll = data.fullPriceStepList.length != this.form.fullPriceStepList.length
if(ignoreAll){
msgArr.push(this.$t("{n}个全包阶梯价", {n: ignoreAll}))
}
}else{
const ignoreFreight = this.form.freightPriceStepList.length - data.freightPriceStepList.length
const ignoreClearance = this.form.clearancePriceStepList.length - data.clearancePriceStepList.length
if(ignoreFreight){
msgArr.push(this.$t("{n}个运费阶梯价", {n: ignoreFreight}))
}
if(ignoreClearance){
msgArr.push(this.$t("{n}个清关费阶梯价", {n: ignoreClearance}))
}
}
let msg = this.$t('已选择{route}条路线,{product}个商品', {
route: data.lineChannelList.length,
product: this.isAllProduct ? this.$refs.productSelector.allTotal : data.productIdList.length
})
if(msgArr.length){
msg += ";" + msgArr.join(",") + "被忽略"
}
await this.$confirm(msg + this.$t(';确认提交修改?', ))
this.loading = true
batchAddPriceAir(data).then(async(response) => {
await this.$alert(this.$t("操作成功"));
this.$store.dispatch("tagsView/delCurrentView")
})
.finally(res => {
this.loading = false
})
});
}
}
}
</script>
<style scoped>
.w100{
width: 100px;
}
.mr10{
margin-right: 10px;
}
.tips{
color: red;
}
</style>
<script>
import {getPriceSnapshotList} from "@/api/ecw/productPrice";
export default {
name: "Logs",
props:{
currencyMap:{
type:Object,
default:() =>{
return {}
}
},
unitMap:{
type:Object,
default:() =>{
return {}
}
},
},
data(){
return {
showLogsDialog: false,
loading: false,
logs:[]
}
},
methods:{
open(id){
this.showLogsDialog = true
this.loading = true
getPriceSnapshotList(id).then(res => {
this.logs = res.data
this.logs.forEach(item => {
item.detail = JSON.parse(item.content)
})
}).finally(() => {
this.loading = false
})
},
closeLogsDialog(){
this.logs = []
this.showLogsDialog = false
}
}
}
</script>
<template>
<el-dialog :title="$t('查看价格日志')" :visible.sync="showLogsDialog" :before-close="closeLogsDialog" width="1000px">
<el-table :data="logs" v-loading="loading">
<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>
</template>
<style scoped lang="scss">
</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: "PriceStep",
components: {Template, Inputor, Selector},
props:{
index: Number,
priceName: String,
fieldPrefix: String,
unitList:{
type: Array,
default: []
},
currencyList:{
type: Array,
default: []
},
showAdd: Boolean,
readonly: Boolean,
stepTips: String,
value:{
type: Object,
default: () => {
return {
}
}
}
},
created() {
if(!this.value.packagingList){
this.addPackage()
}
// 格式化包装
if(this.value.packagingList?.length){
this.value.packagingList.forEach(item => {
if(item.packagingTypes && typeof item.packagingTypes == 'string'){
item.packagingTypes = item.packagingTypes.split(',')
}
})
}
this.initSpecialPrice()
},
data(){
return {
}
},
computed:{
packagingList(){
return getDictDatas(DICT_TYPE.ECW_PACKAGING_TYPE).map(dict => {
dict.enable = true
this.value.packagingList.forEach(item => {
if(item.packagingTypes?.length && item.packagingTypes.indexOf(dict.value) > -1){
dict.enable = false
}
})
return dict
})
}
},
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`]: undefined, // 新建默认给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(){
const index = this.index
const errors = []
// 区间设置检查
if(index > 0 && !this.value.startNum){
errors.push(`请设置${this.priceName}${index+1}阶段的起始值`)
}
if(!this.value.endNum){
errors.push(`请设置${this.priceName}${index+1}阶段的结束值`)
}
// 价格检查
if(!this.validatePrice(this.value[`${this.fieldPrefix}Price`])){
errors.push(`请设置第${index+1}阶段的${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}`)
}
})
}
if(errors.length){
this.$notify.error({
title: this.$t("表单错误"),
message: errors.join(';\n')
});
}
return !errors.length
},
// 校验价格是否为空,可以是0
validatePrice(value){
if(value === undefined || value === null || value === ''){
return false
}
return true
},
}
}
</script>
<template>
<div>
<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')"
@input="$emit('changeUnit', {
value: $event,
field: 'weightUnit',
type: fieldPrefix
})"
value-field="id"
class="w-100" />
<div class="tips" v-if="stepTips">{{stepTips}}</div>
</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>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>
<div v-if="!item.packagingTypes || !item.packagingTypes.length" class="tips">{{$t('未选择包装类型将被忽略')}}</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"
:disabled="!item.enable"
>
</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>
</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>
<script>
import Selector from "@/components/Selector/index.vue";
export default {
name: "QuickSet.vue",
props:{
type:String,
unitList:{
type: Array,
default(){
return []
}
},
currencyList:{
type: Array,
default(){
return []
}
},
value:{
type: Object,
default(){
return {}
}
}
},
components: {Selector},
data(){
return {
quickForm:{}, // 快速加价/减价表单
}
},
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]
}
}
},
methods:{
handleConfirm(type){
let amount = this.quickForm[type]
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'){
this.batchSetPrice("freightPriceStepList","transport", amount)
}else if(type == 'clearance'){
this.batchSetPrice("clearancePriceStepList", "clearance", amount)
}
},
batchSetPrice(field, fieldPrefix, amount){
if(!this.value[field]?.length) return
this.value[field].forEach(item => {
if(item[fieldPrefix + 'Price']){
item[fieldPrefix + 'Price'] = (item[fieldPrefix + 'Price'] * 100 + amount * 100) / 100
}
// 特性价格
if(item.specialList?.length){
item.specialList.forEach(special => {
console.log(special.specialDictType, special[fieldPrefix + 'Price'])
if(special[fieldPrefix + 'Price']){
special[fieldPrefix + 'Price'] = (special[fieldPrefix + 'Price'] * 100 + amount * 100) / 100
}
})
}
// 包装价格
if(item.packagingList?.length){
item.packagingList.forEach(packaging => {
if(packaging['packagingPrice']){
packaging['packagingPrice'] = (packaging['packagingPrice'] * 100 + amount * 100) / 100
}
})
}
})
},
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>
<template>
<div>
<h2 class="mt-5">{{$t('快捷设置')}}</h2>
<div class="flex items-center" v-if="value.priceType != 1">
<div class="w-100">{{$t('运费快捷加价')}}</div>
<el-input-number :controls="false" v-model="quickForm.transport" class="w-100 ml-10 mr-10"></el-input-number>
<selector disabled :value="getUnit('freightPriceStepList', 'transportPriceUnit')" :options="currencyList" :label-field="$l('title')" value-field="id" class="w-100" />
/ <selector disabled :value="getUnit('freightPriceStepList', 'transportVolumeUnit')" :options="unitList" :label-field="$l('title')" value-field="id" class="w-100" />
<div class="ml-10">
<el-button @click="handleConfirm('transport')" type="primary">{{$t('提交运费')}}</el-button>
</div>
</div>
<div class="flex items-center mt-10" v-if="value.priceType != 1">
<div class="w-100">{{$t('清关费快捷加价')}}</div>
<el-input-number :controls="false" v-model="quickForm.clearance" class="w-100 ml-10 mr-10"></el-input-number>
<selector disabled :value="getUnit('clearancePriceStepList', 'clearancePriceUnit')" :options="currencyList" :label-field="$l('title')" value-field="id" class="w-100" />
/ <selector disabled :value="getUnit('clearancePriceStepList', 'clearanceVolumeUnit')" :options="unitList" :label-field="$l('title')" value-field="id" class="w-100" />
<div class="ml-10">
<el-button @click="handleConfirm('clearance')" type="primary">{{$t('提交清关费')}}</el-button>
</div>
</div>
<div class="flex items-center" v-if="value.priceType == 1">
<div class="w-100">{{$t('全包价快捷加价')}}</div>
<el-input-number v-model="quickForm.all" :controls="false" class="w-100 ml-10 mr-10"></el-input-number>
<selector disabled :value="getUnit('fullPriceStepList', 'allPriceUnit')" :options="currencyList" :label-field="$l('title')" value-field="id" class="w-100" />
/ <selector disabled :value="getUnit('fullPriceStepList', 'allVolumeUnit')" :options="unitList" :label-field="$l('title')" value-field="id" class="w-100" />
<div class="ml-10">
<el-button @click="handleConfirm('all')" type="primary">{{$t('提交全包价')}}</el-button>
</div>
</div>
</div>
</template>
<style scoped lang="scss">
</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: "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,92 @@
: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>
</el-col>
<el-col :span="12">
<quick-set :value="form" type="sea" :unit-list="unitList" :currency-list="currencyList"></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 && !readonly"
:value="item"
:readonly="readonly"
@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 && !readonly"
:value="item"
:readonly="readonly"
@add="handleAddPrice('freightPriceStepList', $event)"
@delete="handleDeletePrice('freightPriceStepList', $event)"
@changeUnit="handleUnitChange(form.freightPriceStepList, index, ...$event)"
></price-step>
</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>
</el-col>
<el-col :span="12">
<div v-for="(item, index) in form.clearancePriceStepList" :key="index">
<price-step
ref="stepPrice"
:index="index"
:currency-list="currencyList"
:unit-list="unitList"
field-prefix="clearance"
:price-name="$t('清关费')"
:show-add="index === form.clearancePriceStepList.length -1 && !readonly"
:value="item"
:readonly="readonly"
@add="handleAddPrice('clearancePriceStepList', $event)"
@delete="handleDeletePrice('clearancePriceStepList', $event)"
@changeUnit="handleUnitChange(form.clearancePriceStepList, index, ...$event)"
></price-step>
</div>
</el-col>
</el-row>
</template>
<template v-else>
<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>
<sea-price
ref="seaPrice"
:price-type="form.priceType"
:currency-list="currencyList"
:unit-list="unitList"
:value="form"
:readonly="readonly"
@changeUnit="handleFormUnitChange($event)"
></sea-price>
</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>
<!--
甲方要求不显示清关费 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>
</el-card>
......@@ -271,6 +209,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 +226,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>
</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]}}
<el-button @click="showLogs" type="primary" v-if="readonly">{{$t('查看价格日志')}}</el-button>
</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 +248,22 @@ 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";
import PriceStep from "@/views/ecw/productPrice/components/PriceStep.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: {
PriceStep,
SeaPrice,
Template, Logs, QuickSet, PackagingType, RoutersSelector, ProductSelector, Selector, Inputor, SeaStep },
filters: {parseTime},
data() {
return {
......@@ -401,9 +278,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 +292,6 @@ export default {
readonly: false,
lineList: [], //路线数组
loading: false,
showLogsDialog: false, // 显示价格日志弹层
logs: [],
// 批量加价/减价
quickForm:{}, // 快速加价/减价表单
// 渠道信息
channel: null
}
......@@ -470,11 +340,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 +363,19 @@ 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.priceType'(priceType){
if(this.form.stepPrice === 1){
this.initStepPrice()
}
},
'form.stepPrice'(stepPrice){
if(stepPrice == 1 && (!this.form.priceStepList || !this.form.priceStepList.length)){
this.$set(this.form, 'priceStepList', [{},{}])
if(this.form.stepPrice === 1){
this.initStepPrice()
}
this.syncAllUnit('watch:form.stepPrice')
this.stepPrice = !!stepPrice
},
needPay(val){
......@@ -558,29 +384,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
......@@ -605,20 +417,6 @@ export default {
}
this.lineList = [res.data]
// 如果是阶梯价格,但是一个阶梯价都没有(异常数据),则默认给两个阶梯价
if(this.form.stepPrice == 1 && (!this.form.priceStepList || !this.form.priceStepList.length)){
const defaultStep = this.form.priceType == 1 ? {
allPriceUnit: defaultPriceUnit,
allVolumeUnit: defaultVolumeUnit,
weightUnit: defaultVolumeUnit
} : {
transportVolumeUnit: defaultVolumeUnit,
transportPriceUnit: defaultPriceUnit,
weightUnit: defaultVolumeUnit
}
console.log('阶梯价没有阶梯信息,默认给两个', {...defaultStep})
this.$set(this.form, 'priceStepList', [{...defaultStep},{...defaultStep}])
}
}
// action=batchUpdate且ids不为空
......@@ -694,12 +492,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 +506,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,75 +521,95 @@ 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(field, fieldPrefix){
if(!this.form[field]){
this.$set(this.form, field, [])
}
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
}
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)
},
handleUnitChange(stepPriceList, index, data){
console.log('handleUnitChange', ...arguments)
if(index > 0) return
// 阶梯价还需要同步阶梯的重量单位
if(this.form.stepPrice == 1){
fields['weightUnit'] = obj.weightUnit
// 如果是重量单位,且不是清关费想换的,则需要同步最小起计量单位
if(data.field === 'weightUnit' && data.type != 'clearance'){
this.form.minWeightUnit = data.value
}
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)
stepPriceList.forEach(item => {
item[data.field] = data.value
if(item.packagingList?.length){
item.packagingList.forEach(p => {
p[data.field] = data.value
})
// 如果是阶梯价则需要同步其他阶梯
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(item.specialList?.length){
item.specialList.forEach(p => {
p[data.field] = data.value
})
}
})
},
// 不是阶梯价需要 同步最小起计量
if(obj['transportVolumeUnit'] || obj['allVolumeUnit']){
this.$set(this.form, 'minWeightUnit', obj['transportVolumeUnit'] || obj['allVolumeUnit'])
}
// 获得用语提交的阶梯价副本
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
},
priceValidator(rule, value, callback){
if(!value || value == '') return callback()
value = parseFloat(value)
if(!value || value < 0){
return callback(new Error('价格错误'))
// 非阶梯价格更新单位
handleFormUnitChange(data){
if(this.form.specialList?.length){
this.form.specialList.forEach(p => {
p[data.field] = data.value
})
}
callback()
},
setDefaultVolumeUnit(unit){
console.log('设置默认体积单位', unit)
this.$set(this.form, 'transportVolumeUnit', unit)
this.$set(this.form, 'clearanceVolumeUnit', unit)
this.$set(this.form, 'allVolumeUnit', unit)
},
setDefaultPriceUnit(priceUnit){
console.log('设置默认价格单位', priceUnit)
this.$set(this.form, 'transportPriceUnit', priceUnit)
this.$set(this.form, 'clearancePriceUnit', priceUnit)
this.$set(this.form, 'allPriceUnit', priceUnit)
initStepPrice(){
if(this.form.priceType == 1 && !this.form.fullPriceStepList?.length){
this.handleAddPrice("fullPriceStepList", 'all')
}
if(this.form.priceType === 0){
if(!this.form.freightPriceStepList?.length){
this.handleAddPrice('freightPriceStepList', 'transport')
}
if(!this.form.clearancePriceStepList?.length){
this.handleAddPrice('clearancePriceStepList', 'clearance')
}
}
},
// force 为是否强制提交,在价格过期的时候需要确认后强制提交
submitForm(force = false) {
console.log("this.$refs[\"form\"]", this.$refs["form"])
this.$refs["form"].validate(async (valid) => {
if (!valid) {
return;
......@@ -827,39 +629,27 @@ export default {
// specialList: this.specialProducts,
isAllProduct: 0
})
if(this.form.stepPrice != 1){
// data.priceStepList = this.priceStepList
delete data.priceStepList
// 非阶梯价格判断是否运费(全包价是否为空)
if((this.form.priceType == 0 && !this.form.transportPrice) || (this.form.priceType == 1 && !this.form.allPrice)){
return this.$message.error(this.$t('运费/全包价不能为0'))
}
}else{
// 全包价 的阶段 设置和运费(全包价)不能为空
let stepPriceEmpty = []
this.form.priceStepList.forEach((item, index) => {
let notEmptyFields = ['endNum', 'weightUnit']
// 第一条阶梯的起始值可以是0,其他的不能为0
if(index){
notEmptyFields.push('startNum')
if(this.$refs.stepPrice){
let isValid = true
for (let stepPrice of this.$refs.stepPrice){
if(!stepPrice.validate()){
isValid = false
break
}
notEmptyFields.forEach(field => {
// 第一个阶梯的起始值不判断0
if(index === 0 && field == 'startNum' && item[field] == 0) return
if(!item[field] || item[field].toString().trim() == ''){
stepPriceEmpty.push({index, field})
}
})
if((this.form.priceType == 0 && !item.transportPrice) || (this.form.priceType == 1 && !item.allPrice)){
stepPriceEmpty.push({index, field: !item.transportPrice ? 'transportPrice' : 'allPrice'})
}
})
if(stepPriceEmpty.length){
console.log('stepPriceEmpty', stepPriceEmpty)
return this.$message.error(this.$t('阶梯和价格设置不能留空'))
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
}
// 设置了有效期,且已过期则给提示
......@@ -946,46 +736,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)
}
}
}
......
<template>
<div class="app-container">
<el-form ref="form" :model="form" label-width="150px" :disabled="readonly">
<el-form-item :label="$t('商品类型')" prop="productType">
<el-select v-model="form.productType" :disabled="!!$route.query.action">
<el-option
v-for="type in productTypeList"
:key="type.id"
:label="$l(type, 'title')"
:value="type.id"
></el-option>
</el-select>
</el-form-item>
<el-form-item :label="$t('商品名称')" prop="titleZh">
<product-selector v-model="form.productId" :product-type="form.productType" @change="product = $event" :disabled="!!$route.query.action" />
</el-form-item>
<el-form-item :label="$t('英文名称')" prop="titleEn">
<el-input :value="product ? product.titleEn : ''" disabled />
</el-form-item>
<!--多条路线批量修改-->
<template v-if="lineList.length">
<el-form-item :label="$t('路线')" prop="lineChannelList">
<template v-if="lineList.length == 1">
<el-input
v-for="(item, index) in lineList"
:key="index"
:value="!item.warehouseLineDO ? $t('数据异常,缺少warehouseLineDO字段') : $t('【{transport}】从【{from}】发往【{to}】', {
transport: getDictDataLabel(DICT_TYPE.ECW_TRANSPORT_TYPE, item.warehouseLineDO.transportType),
from: $l(item.warehouseLineDO, 'startTitle'),
to: $l(item.warehouseLineDO, 'destTitle')
})"
disabled />
</template>
<el-checkbox-group v-else v-model="checkList">
<el-checkbox
v-for="item in lineList"
:key="item.id"
:label="item.id"
:disabled="!item.warehouseLineDO"
style="display:block"
>
{{
!item.warehouseLineDO ? $t('数据异常,缺少warehouseLineDO字段') : $t('【{transport}】从【{from}】发往【{to}】', {
transport: getDictDataLabel(DICT_TYPE.ECW_TRANSPORT_TYPE, item.warehouseLineDO.transportType),
from: $l(item.warehouseLineDO, 'startTitle'),
to: $l(item.warehouseLineDO, 'destTitle')
})
}}
</el-checkbox>
</el-checkbox-group>
</el-form-item>
<el-form-item :label="$t('出货渠道')">
{{channel ? $l(channel, 'name') : '/'}}
</el-form-item>
</template>
<!--有路线则不显示路线选择器-->
<routers-selector v-else v-model="selectedRoutes" :option="routerOption" type="air" />
<el-card style="margin-bottom: 10px">
<div slot="header" style="font-size:20px;">
{{$t('价格设置')}}
<span>
<el-checkbox v-if="$route.query.action != 'batchUpdate'" label="" v-model="needPay">{{$t('预付')}}</el-checkbox>
</span>
</div>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item :label="$t('预付')" prop="needPay" v-if="$route.query.action == 'batchUpdate'" >
<el-radio-group v-model="form.needPay">
<el-radio :label="1">{{$t('预付')}}</el-radio>
<el-radio :label="0">{{$t('均可')}}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item :label="$t('单价模式')" prop="priceType">
<dict-selector :type="DICT_TYPE.ECW_PRICE_TYPE" v-model="form.priceType" form-type="radio" formatter="number" defaultable2 />
</el-form-item>
<el-form-item
:label="$t('最小起计量')"
:prop="`minWeight`"
>
<el-input-number :min="0" v-model="form.minWeight" :controls="false" class="w-100"/>
/ <selector v-model="form.minWeightUnit" :options="unitList" :label-field="$l(null, 'title')" value-field="id" defaultable2 class="w-100" disabled />
</el-form-item>
</el-col>
<el-col :span="12" v-if="!readonly">
<quick-set :unit-list="unitList" :currency-list="currencyList" :value="form"></quick-set>
</el-col>
</el-row>
<!--全包价-->
<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 && !readonly"
:value="item"
:readonly="readonly"
@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 && !readonly"
:value="item"
:readonly="readonly"
@add="handleAddPrice('freightPriceStepList', $event)"
@delete="handleDeletePrice('freightPriceStepList', $event)"
@changeUnit="handleUnitChange(form.freightPriceStepList, index, ...$event)"
></price-step>
</div>
</el-col>
<el-col :span="12">
<div v-for="(item, index) in form.clearancePriceStepList" :key="index">
<price-step
ref="stepPrice"
:index="index"
:currency-list="currencyList"
:unit-list="unitList"
field-prefix="clearance"
:price-name="$t('清关费')"
:show-add="index === form.clearancePriceStepList.length -1 && !readonly"
:value="item"
:readonly="readonly"
@add="handleAddPrice('clearancePriceStepList', $event)"
@delete="handleDeletePrice('clearancePriceStepList', $event)"
@changeUnit="handleUnitChange(form.clearancePriceStepList, index, ...$event)"
></price-step>
</div>
</el-col>
</el-row>
<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>
<el-card>
<div slot="header" style="font-size:20px;">
{{$t('基础信息')}}
</div>
<el-form-item :label="$t('是否预约入仓')" prop="needBook">
<el-radio v-model.number="form.needBook" :label="1">{{$t('是')}}</el-radio>
<el-radio v-model.number="form.needBook" :label="0">{{$t('否')}}</el-radio>
</el-form-item>
<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-form-item :label="$t('线路重量上限')" prop="inquiry">
<el-input-number v-model="form.weightLimit" :min="0" :controls="false"></el-input-number>
</el-form-item>
</el-card>
</el-form>
<el-card class="mt-10" v-if="readonly">
<el-descriptions :column="1">
<el-descriptions-item :label="$t('状态')">{{ statusName(form) }}</el-descriptions-item>
<el-descriptions-item :label="$t('创建时间')">{{form.createTime|parseTime}}</el-descriptions-item>
<el-descriptions-item :label="$t('创建人')">{{form.creatorName}}</el-descriptions-item>
<el-descriptions-item :label="$t('最新修改时间')">{{form.updateTime|parseTime}}</el-descriptions-item>
<el-descriptions-item :label="$t('最新修改人')">{{form.updaterName}}</el-descriptions-item>
</el-descriptions>
</el-card>
<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="showLogs" type="primary" v-if="readonly">{{$t('查看价格日志')}}</el-button>
</div>
<logs ref="logs"></logs>
</div>
</template>
<script>
import RoutersSelector from '@/components/RoutersSelector'
import {
createProductPrice,
updateProductPrice,
batchUpdateProductPrice,
getProductPrice,
getProductPriceList,
getPriceSnapshotList,
updateProductPriceAir, createProductPriceAir, batchUpdateProductPriceAir
} from "@/api/ecw/productPrice";
import { getProductType, getProductTypeList } from '@/api/ecw/productType'
import { getCurrencyList } from '@/api/ecw/currency';
import { getUnitList } from '@/api/ecw/unit';
import ProductSelector from '@/components/ProductSelector'
import { arrryToKeyedObjectBy } from '@/utils/index'
import Selector from '@/components/Selector'
import Inputor from '@/components/Inputor'
import {parseTime} from '@/utils/ruoyi'
import {openedRouterList} from '@/api/ecw/warehouse'
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 PriceStep from "@/views/ecw/productPrice/components/PriceStep.vue";
// 定义默认的价格单位和体积单位
const DEFAULT_PRICE_UNIT = 1
const DEFAULT_VOLUME_UNIT = 6
const DEFAULT_WEIGHT_UNIT = 6
export default {
components: {PriceStep, Logs, QuickSet, PackagingType, RoutersSelector, ProductSelector, Selector, Inputor },
filters: {parseTime},
data() {
return {
checkList: [],
selectedRoutes: [], // 勾选的路线渠道
form: {
minWeightUnit: 0,
priceStepList: [], // 阶梯价格
specialList: [],
// 是否单询,默认否
needOrderInquiry: '0'
},
needPay: false, // 是否需要预付
product: null,
currencyList: [],
unitList: [],
productTypeList: [],
productDisabled: true,
readonly: false,
lineList: [], //路线数组
loading: false,
channel: null
}
},
computed: {
statusName(){
return getStatusName
},
routerOption(){
return this.$route.query
},
currencyMap(){
let map = {}
this.currencyList.forEach(item => {
map[item.id] = this.$l(item, 'title')
})
return map
},
unitMap(){
let map = {}
this.unitList.forEach(item => {
map[item.id] = this.$l(item, 'title')
})
return map
},
// 默认运费的货币和体积单位
currencyAndUnit(){
let currency = null, unit = null
if(this.form.priceType == 1 && this.form.fullPriceStepList?.length){
currency = this.form.fullPriceStepList[0].allPriceUnit
unit = this.form.fullPriceStepList[0].allVolumeUnit
}
if(this.form.priceType == 1 && this.form.freightPriceStepList?.length){
currency = this.form.freightPriceStepList[0].allPriceUnit
unit = this.form.freightPriceStepList[0].allVolumeUnit
}
return {currency, unit}
},
},
watch: {
checkList() { //选择路线
if (this.checkList.length > 0) {
this.form.lineChannelList = this.checkList.map(item => {
return { lineId: item, shippingChannelId: 0 }
})
} else {
this.form.lineChannelList = []
}
},
product() {
this.$set(this.form, 'productType', this.product.typeId)
/* getProductType(this.product.typeId).then(res => {
this.productType = res.data
}) */
// 只有新建才需要把参数带过来
if(!this.$route.query.action){
this.$set(this.form, 'needBook', this.product.needBook)
this.$set(this.form, 'square', this.product.square)
this.$set(this.form, 'dayLimit', this.product.dayLimit)
this.$set(this.form, 'containerLocation', this.product.containerLocation)
}
},
// 价格类型切换,需要初始化对应的字段
'form.priceType'(priceType){
if(priceType == 1 && !this.form.fullPriceStepList?.length){
this.handleAddPrice('fullPriceStepList', 'all')
}
if(priceType == 0){
if(!this.form.freightPriceStepList?.length){
this.handleAddPrice('freightPriceStepList', 'transport')
}
if(!this.form.clearancePriceStepList?.length){
this.handleAddPrice('clearancePriceStepList', 'clearance')
}
}
},
'form.needBook'(val){
if(val) this.$set(this.form, 'dayLimit', 10000)
else delete this.form.dayLimit
},
needPay(val){
this.$set(this.form, 'needPay', val ? 1 : 0)
},
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() {
if(this.$route.query.readonly){
this.readonly = true
}
this.currencyList = (await getCurrencyList())?.data || []
this.unitList = (await getUnitList())?.data || []
this.productTypeList = (await getProductTypeList())?.data || []
// action=batchUpdate 表示批量修改单个商品的价格(一条或者多条),如果没有ids显示路线选择组件,否则不显示路线组件
// action=update 表示修改单个商品的单条路线价格,需要回显
if(this.$route.query.action == 'update'){
await this.initUpdate()
}
// action=batchUpdate且ids不为空
if(this.$route.query.action == 'batchUpdate'){
delete this.form.needBook
}
// 同时修改多条线路
if (this.$route.query.ids) {
let query = {
ids: this.$route.query.ids
}
getProductPriceList(query).then(res => {
this.lineList = res.data
this.lineList.forEach(item =>{
this.checkList.push(item.id)
})
})
}
// 未指定商品则不禁用商品选择
if(!this.$route.query.product_id){
this.productDisabled = false
}
// 没有操作标识的就是新建,给有效期默认值
if(!this.$route.query.action){
await this.initCreate()
}
if (this.$route.query.product_type) {
this.$set(this.form, 'productType', +this.$route.query.product_type)
}
if (this.$route.query.product_id) {
this.$set(this.form, 'productId', +this.$route.query.product_id)
}
// 显示渠道(修改或者从异常处理等进入携带了渠道参数)
if(this.form.shippingChannelId){
this.channel = (await getChannel(this.form.shippingChannelId))?.data || {}
}
},
methods: {
// 新建的初始化
async initCreate(){
this.form = {
priceType: 0,
stepPrice: 1,
advanceStatus: 0,
needBook: 0,
clearancePriceStepList: [],
freightPriceStepList: [],
fullPriceStepList: [],
validateEndDate: undefined,
validateStartDate: undefined,
clearancePrice: 0,
transportPrice: 0,
minWeight: 0,
minWeightUnit: null,
// 是否单询,默认否
needOrderInquiry: 0,
needPay: 0,
weightLimit: undefined
}
this.form.validateStartDate = parseTime(Date.now())
this.form.validateEndDate = parseTime(Date.now() + 86400*365*2*1000)
// 如果指定了始发,目的仓和运输方式,渠道,则是从未报价异常跳转过来的,固定一个路线
if(this.$route.query.startWarehouseId){
const res = await openedRouterList({
destCityId: this.$route.query.importCity,
lineId: this.$route.query.lineId,
startCityId: this.$route.query.exportCity,
transportType: this.$route.query.transportId
})
console.log("open ---> ", res)
this.lineList = [
Object.assign({
// id: res.data[0].id,
lineId:this.$route.query.lineId,
shippingChannelId: this.$route.query.channelId,
warehouseLineDO: {... res.data[0]}
})
]
// 后面会根据这个渠道ID获取渠道信息
this.form.shippingChannelId = this.$route.query.channelId
}
},
async initUpdate(){
let res = await getProductPrice(this.$route.query.id)
this.$set(this, 'form', res.data)
if(this.form.needPay){
this.needPay = true
}
if(res.data.validateStartDate){
this.form.validateStartDate = parseTime(res.data.validateStartDate)
}
if(res.data.validateEndDate){
this.form.validateEndDate = parseTime(res.data.validateEndDate)
}
this.lineList = [res.data]
// 如果没有对应的阶梯价字段,则初始化一个
await this.$nextTick()
if(this.form.priceType === 1){
if(!this.form.fullPriceStepList?.length){
this.handleAddPrice("fullPriceStepList", "all")
}
}else{
if(!this.form.clearancePriceStepList?.length){
this.handleAddPrice("clearancePriceStepList", "clearance")
}
if(!this.form.freightPriceStepList?.length){
this.handleAddPrice("freightPriceStepList", "transport")
}
}
},
handleAddPrice(field, fieldPrefix){
if(!this.form[field]){
this.$set(this.form, field, [])
}
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
}
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)
},
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 => {
p[data.field] = data.value
})
}
if(item.specialList?.length){
item.specialList.forEach(p => {
p[data.field] = data.value
})
}
})
},
// 获得用语提交的阶梯价副本
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
},
// force 为是否强制提交,在价格过期的时候需要确认后强制提交
submitForm(force = false) {
this.$refs["form"].validate(async (valid) => {
if (!valid) {
return;
}
if(!this.lineList.length && (!this.selectedRoutes || !this.selectedRoutes.length)) {
this.$message.error(this.$t('请选择线路'));
return;
}
let data = Object.assign({}, this.form, {
isAllProduct: 0
})
let isValid = true
for (let stepPrice of this.$refs.stepPrice){
if(!stepPrice.validate()){
isValid = false
break
}
}
if(!isValid)return
// 全包价
if(this.form.priceType == 1) {
data.fullPriceStepList = this.getPriceList(this.form.fullPriceStepList)
delete data.freightPriceStepList
delete data.clearancePriceStepList
}else{
data.clearancePriceStepList = this.getPriceList(this.form.clearancePriceStepList)
data.freightPriceStepList = this.getPriceList(this.form.freightPriceStepList)
delete data.freightPriceStepList
}
// 设置了有效期,且已过期则给提示
if(data.validateEndDate && force !== true){
let validateEndDate = new Date(data.validateEndDate)
if(validateEndDate.getTime() < Date.now()){
return this.$confirm('您设置的线路价格已过期,确定提交吗?', '提示', {
confirmButtonText: '确认提交',
cancelButtonText: '取消提交',
type: 'warning'
}).then(res => {
this.submitForm(true)
})
}
}
// 修改单条路线
if (this.$route.query.action == 'update') {
this.loading = true
return updateProductPriceAir(data).then(res => {
this.$modal.msgSuccess(this.$t("请求成功"));
this.$tab.closePage()
}).finally(res => this.loading = false)
}
// 批量修改(单个商品的单个路线,多个路线,或者全部路线)的提交
if (this.$route.query.action == 'batchUpdate') {
// 指定一条路线
if(this.lineList.length == 1){
data.lineChannelList = {
lineId: this.lineList[0].warehouseLineId,
shippingChannelId: this.lineList[0].shippingChannelId || 0
}
}
// 指定多条路线的需要过滤未勾选的
else if(this.lineList.length > 1){
data.lineChannelList = []
this.lineList.forEach(item => {
if(this.checkList.indexOf(item.id) > -1){
data.lineChannelList.push({
lineId: item.warehouseLineId,
shippingChannelId: item.shippingChannelId || 0
}
)
}
})
}
// 未指定路线的从路线选择组件里获取
if(!this.lineList.length){
data.lineChannelList = this.selectedRoutes
}
if(data.lineChannelList.length < 1){
return this.$message.error(this.$t('请选择需要修改的路线'))
}
await this.$confirm(this.$t("已选择{route}条路线,确认提交?", {route: data.lineChannelList.length}))
data.productIdList = [this.form.productId]
this.loading = true
batchUpdateProductPriceAir(data).then(response => {
this.$modal.msgSuccess(this.$t("修改成功"));
this.$router.replace('/product/product-price?' + (new URLSearchParams(this.$route.query)).toString())
}).finally(res => this.loading = false)
return;
}
// 添加的提交
if(!this.product){
return this.$message.error(this.$t('请选择商品'))
}
data.productId = this.product.id;
data.lineChannelList = this.lineList.length ? this.lineList : this.selectedRoutes
await this.$confirm(this.$t("已选择{route}条路线,确认提交?", {route: data.lineChannelList.length}))
this.loading = true
createProductPriceAir(data).then(response => {
this.$modal.msgSuccess(this.$t("请求成功"));
this.$router.replace('/lineProject/product-price?' + (new URLSearchParams(this.$route.query)).toString())
}).finally(res => this.loading = false);
});
},
showLogs(){
if(!this.$refs.logs){
return this.$message.error("未找到组件")
}
this.$refs.logs.open(this.form.id)
}
}
}
</script>
<style scoped>
.w-100{
width: 100px;
}
.mr10{
margin-right: 10px;
}
</style>
......@@ -4,7 +4,15 @@
<!-- 搜索工作栏 -->
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item :label="$t('商品名称')" prop="titleZh" v-if="!$route.query.product_id">
<el-input v-model="queryParams.titleZh" :placeholder="$t('请输入中英文名称、商品编码、海关编码')" clearable @keyup.enter.native="handleQuery"/>
<el-input v-model="queryParams.titleZh" :placeholder="$t('请输入中英文名称、商品编码、海关编码')" clearable @keyup.enter.native="handleQuery">
<template #prepend>
<el-select v-model="queryParams.searchType" style="width: 100px">
<el-option :value="1" :label="$t('包含')"></el-option>
<el-option :value="2" :label="$t('不包含')"></el-option>
<el-option :value="3" :label="$t('等于')"></el-option>
</el-select>
</template>
</el-input>
</el-form-item>
<el-form-item :label="$t('商品类型')" prop="typeId" v-if="!$route.query.product_id">
......@@ -58,7 +66,12 @@
<el-option :label="$t('否')" value="0"></el-option>
</el-select>
</el-form-item>
<el-form-item :label="$t('单价模式')" prop="priceType">
<el-select v-model="queryParams.priceType" :placeholder="$t('请选择')" clearable>
<el-option :label="$t('运费+清关费')" value="0"></el-option>
<el-option :label="$t('全包价')" value="1"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleQuery">{{$t('搜索')}}</el-button>
<el-button icon="el-icon-refresh" @click="resetQuery">{{$t('重置')}}</el-button>
......@@ -393,6 +406,7 @@ export default {
dateRangeCreateTime: [],
// 查询参数
queryParams: {
searchType: 1,
pageNo: 1,
pageSize: 10,
productId: null,
......
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