@@ -756,6 +756,25 @@ function removeCargoProductImage(item: FirstLegCargoItem) {
item . productImageError = ''
item . productImageError = ''
}
}
function normalizedAddressValue ( value : string | null | undefined ) {
return value ? . trim ( ) . toLocaleLowerCase ( ) ? ? ''
}
function findAddressBookEntryId ( addressType : CustomerOrderAddress [ 'addressType' ] , snapshot : FirstLegPartySnapshot | null ) {
if ( ! snapshot ) return ''
const address = orderAddresses . value . find ( ( item ) => item . addressType === addressType
&& normalizedAddressValue ( item . companyName || item . addressName ) === normalizedAddressValue ( snapshot . name )
&& normalizedAddressValue ( item . contactName ) === normalizedAddressValue ( snapshot . contactName )
&& normalizedAddressValue ( item . phone ) === normalizedAddressValue ( snapshot . phone )
&& normalizedAddressValue ( item . email ) === normalizedAddressValue ( snapshot . email )
&& normalizedAddressValue ( item . countryCode ) === normalizedAddressValue ( snapshot . countryRegion )
&& normalizedAddressValue ( item . province ) === normalizedAddressValue ( snapshot . province )
&& normalizedAddressValue ( item . city ) === normalizedAddressValue ( snapshot . city )
&& normalizedAddressValue ( item . postalCode ) === normalizedAddressValue ( snapshot . postalCode )
&& normalizedAddressValue ( item . addressLine ) === normalizedAddressValue ( snapshot . address ) )
return address == null ? '' : String ( address . id )
}
function draftFromOrder ( order : FirstLegOrder ) : FirstLegOrderDraft {
function draftFromOrder ( order : FirstLegOrder ) : FirstLegOrderDraft {
return {
return {
inboundCode : order . businessSummary . inboundCode ,
inboundCode : order . businessSummary . inboundCode ,
@@ -769,11 +788,11 @@ function draftFromOrder(order: FirstLegOrder): FirstLegOrderDraft {
receivingWarehouseId : order . receivingWarehouseId ,
receivingWarehouseId : order . receivingWarehouseId ,
expectedDepartureDate : order . expectedDepartureDate ,
expectedDepartureDate : order . expectedDepartureDate ,
shipperPartyId : order . shipperPartyId ,
shipperPartyId : order . shipperPartyId ,
senderAddressId : '' ,
senderAddressId : findAddressBookEntryId ( 'PICKUP' , order . shipperPartySnapshot ) ,
shipperPartySnapshot : order . shipperPartySnapshot ? { ... order . shipperPartySnapshot } : null ,
shipperPartySnapshot : order . shipperPartySnapshot ? { ... order . shipperPartySnapshot } : null ,
shipper : order . shipper ,
shipper : order . shipper ,
consigneePartyId : order . consigneePartyId ,
consigneePartyId : order . consigneePartyId ,
privateDestinationAddressId : '' ,
privateDestinationAddressId : findAddressBookEntryId ( 'PRIVATE_DESTINATION' , order . consigneePartySnapshot ) ,
consigneePartySnapshot : order . consigneePartySnapshot ? { ... order . consigneePartySnapshot } : null ,
consigneePartySnapshot : order . consigneePartySnapshot ? { ... order . consigneePartySnapshot } : null ,
consignee : order . consignee ,
consignee : order . consignee ,
priority : order . priority ,
priority : order . priority ,
@@ -1000,9 +1019,19 @@ function syncPrivateDestinationName(value: string) {
if ( form . consigneePartySnapshot ) form . consigneePartySnapshot . name = value
if ( form . consigneePartySnapshot ) form . consigneePartySnapshot . name = value
}
}
function selectPrivateAddress ( id : string ) {
function selectPrivateAddress ( id : string | null | undefined ) {
const address = privateAddresses . value . find ( ( item ) => String ( item . id ) === id )
const address = privateAddresses . value . find ( ( item ) => String ( item . id ) === id )
if ( ! address ) return
if ( ! address ) {
form . privateDestinationAddressId = ''
form . consigneePartyId = ''
form . consigneePartySnapshot = createEmptyPartySnapshot ( 'CONSIGNEE' )
form . consignee = ''
form . destination = ''
form . destinationCountryCode = ''
form . destinationWarehouseId = ''
form . destinationWarehouseName = ''
return
}
form . privateDestinationAddressId = String ( address . id )
form . privateDestinationAddressId = String ( address . id )
form . consigneePartyId = ''
form . consigneePartyId = ''
form . consigneePartySnapshot = addressSnapshot ( address , 'CONSIGNEE' )
form . consigneePartySnapshot = addressSnapshot ( address , 'CONSIGNEE' )
@@ -1039,9 +1068,16 @@ async function loadOrderAddresses() {
}
}
}
}
function selectPickupAddress ( id : string ) {
function selectPickupAddress ( id : string | null | undefined ) {
const address = pickupAddresses . value . find ( ( item ) => String ( item . id ) === id )
const address = pickupAddresses . value . find ( ( item ) => String ( item . id ) === id )
if ( ! address ) return
if ( ! address ) {
form . senderAddressId = ''
form . shipperPartyId = ''
form . shipperPartySnapshot = createEmptyPartySnapshot ( 'SHIPPER' )
form . shipper = ''
form . origin = ''
return
}
form . senderAddressId = String ( address . id )
form . senderAddressId = String ( address . id )
form . shipperPartyId = ''
form . shipperPartyId = ''
form . shipperPartySnapshot = addressSnapshot ( address , 'SHIPPER' )
form . shipperPartySnapshot = addressSnapshot ( address , 'SHIPPER' )
@@ -1079,6 +1115,12 @@ async function savePickupAddress() {
ElMessage . warning ( '请先完整填写提货地址和联系人资料' )
ElMessage . warning ( '请先完整填写提货地址和联系人资料' )
return
return
}
}
const existingAddressId = findAddressBookEntryId ( 'PICKUP' , snapshot )
if ( existingAddressId && existingAddressId !== form . senderAddressId ) {
selectPickupAddress ( existingAddressId )
ElMessage . info ( '相同的企业提货地址已存在,已为您选中' )
return
}
try {
try {
const payload = addressPayload ( 'PICKUP' , snapshot ! , addressName )
const payload = addressPayload ( 'PICKUP' , snapshot ! , addressName )
if ( form . senderAddressId ) await updateMerchantOrderAddress ( form . senderAddressId , payload )
if ( form . senderAddressId ) await updateMerchantOrderAddress ( form . senderAddressId , payload )
@@ -1100,6 +1142,12 @@ async function savePrivateAddress() {
return
return
}
}
snapshot ! . name = addressName
snapshot ! . name = addressName
const existingAddressId = findAddressBookEntryId ( 'PRIVATE_DESTINATION' , snapshot )
if ( existingAddressId && existingAddressId !== form . privateDestinationAddressId ) {
selectPrivateAddress ( existingAddressId )
ElMessage . info ( '相同的企业私人仓地址已存在,已为您选中' )
return
}
try {
try {
const payload = addressPayload ( 'PRIVATE_DESTINATION' , snapshot ! , addressName )
const payload = addressPayload ( 'PRIVATE_DESTINATION' , snapshot ! , addressName )
if ( form . privateDestinationAddressId ) await updateMerchantOrderAddress ( form . privateDestinationAddressId , payload )
if ( form . privateDestinationAddressId ) await updateMerchantOrderAddress ( form . privateDestinationAddressId , payload )
@@ -1117,8 +1165,8 @@ async function removeOrderAddress(type: CustomerOrderAddress['addressType']) {
if ( ! id ) return
if ( ! id ) return
try {
try {
await disableMerchantOrderAddress ( id )
await disableMerchantOrderAddress ( id )
if ( type === 'PICKUP' ) form . senderAddressId = ''
if ( type === 'PICKUP' ) selectPickupAddress ( null )
else form . privateDestinationAddressId = ''
else selectPrivateAddress ( null )
await loadOrderAddresses ( )
await loadOrderAddresses ( )
ElMessage . success ( '地址已从企业地址簿停用' )
ElMessage . success ( '地址已从企业地址簿停用' )
} catch ( error ) {
} catch ( error ) {
@@ -2057,7 +2105,7 @@ async function searchOrders(model: QueryModel) {
< / el -form -item >
< / el -form -item >
< el-form-item label = "买单 / 退税" prop = "taxMode" required > < el-radio-group v-model = "form.taxMode"><el-radio value="BUY_DECLARATION">买单</el-radio><el-radio value="TAX_REFUND" > 退税 < / el -radio > < / el-radio-group > < / el-form-item >
< el-form-item label = "买单 / 退税" prop = "taxMode" required > < el-radio-group v-model = "form.taxMode"><el-radio value="BUY_DECLARATION">买单</el-radio><el-radio value="TAX_REFUND" > 退税 < / el -radio > < / el-radio-group > < / el-form-item >
< el-form-item label = "是否整柜" prop = "transportMode" required > < el-radio-group v-model = "form.transportMode"><el-radio value="FCL">整柜</el-radio><el-radio value="LCL" > 散货 < / el -radio > < / el-radio-group > < / el-form-item >
< el-form-item label = "是否整柜" prop = "transportMode" required > < el-radio-group v-model = "form.transportMode"><el-radio value="FCL">整柜</el-radio><el-radio value="LCL" > 散货 < / el -radio > < / el-radio-group > < / el-form-item >
< el-form-item label = "是否商检" prop = "customsInspection" > < el-select v-model = "form.customsInspection" clearable placeholder="暂不选择"><el-option label="是" :value="true" /><el-option label="否" :value="false" /></el-select><small v-if="woodenCargoLines.length && form.customsInspection !== true" class="field-guidance field-guidance--error" > 第 {{ woodenCargoLines.join ( ' 、 ' ) }} 条货物已勾选 木制品 , 提交前 “ 是否商检 ” 必须 选择“ 是 ” 。 < / small > < / el -form -item >
< el-form-item label = "是否商检" prop = "customsInspection" > < el-select v-model = "form.customsInspection" clearable placeholder="暂不选择"><el-option label="是" :value="true" /><el-option label="否" :value="false" /></el-select><small v-if="woodenCargoLines.length && form.customsInspection !== true" class="field-guidance field-guidance--error" > 第 {{ woodenCargoLines.join ( ' 、 ' ) }} 条货物为 木制品 , 请将 “ 是否商检 ” 选择为 “ 是 ” 。 < / small > < / el -form -item >
< el-form-item label = "期望出货日期" > < el-date-picker v-model = "form.expectedDepartureDate" type="date" value-format="YYYY-MM-DD" placeholder="请选择期望出货日期" / > < / el-form-item >
< el-form-item label = "期望出货日期" > < el-date-picker v-model = "form.expectedDepartureDate" type="date" value-format="YYYY-MM-DD" placeholder="请选择期望出货日期" / > < / el-form-item >
< el-form-item label = "订单备注" > < el-input v-model = "form.customerRemark" type="textarea" :rows="3" resize="vertical" maxlength="300" show-word-limit placeholder="选填,例如:入仓前请电话联系" / > < / el-form-item >
< el-form-item label = "订单备注" > < el-input v-model = "form.customerRemark" type="textarea" :rows="3" resize="vertical" maxlength="300" show-word-limit placeholder="选填,例如:入仓前请电话联系" / > < / el-form-item >
< / div >
< / div >