|
|
@@ -72,6 +72,10 @@ const ModeType = ref([
|
|
|
{
|
|
|
label: 'Truck',
|
|
|
value: 'Truck'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: 'Rail',
|
|
|
+ value: 'Rail'
|
|
|
}
|
|
|
])
|
|
|
|
|
|
@@ -122,7 +126,7 @@ const isNotSubmit = computed(() => {
|
|
|
return true
|
|
|
}
|
|
|
|
|
|
- return false;
|
|
|
+ return false
|
|
|
})
|
|
|
|
|
|
// 控制Address是否超长
|
|
|
@@ -145,22 +149,22 @@ const isShowLimitLine4Style = computed(() => {
|
|
|
const createInputLimiter = (targetRef, showRef) => {
|
|
|
return (val: string) => {
|
|
|
if (val.length > 45) {
|
|
|
- targetRef.value = val.substring(0, 45);
|
|
|
- showRef.value = true;
|
|
|
+ targetRef.value = val.substring(0, 45)
|
|
|
+ showRef.value = true
|
|
|
setTimeout(() => {
|
|
|
- showRef.value = false;
|
|
|
- }, 3000);
|
|
|
+ showRef.value = false
|
|
|
+ }, 3000)
|
|
|
}
|
|
|
- };
|
|
|
-};
|
|
|
-const handleAddressLine1 = createInputLimiter(AddressLine1, isShowLimitLine1);
|
|
|
-const handleAddressLine2 = createInputLimiter(AddressLine2, isShowLimitLine2);
|
|
|
-const handleAddressLine3 = createInputLimiter(AddressLine3, isShowLimitLine3);
|
|
|
-const handleAddressLine4 = createInputLimiter(AddressLine4, isShowLimitLine4);
|
|
|
+ }
|
|
|
+}
|
|
|
+const handleAddressLine1 = createInputLimiter(AddressLine1, isShowLimitLine1)
|
|
|
+const handleAddressLine2 = createInputLimiter(AddressLine2, isShowLimitLine2)
|
|
|
+const handleAddressLine3 = createInputLimiter(AddressLine3, isShowLimitLine3)
|
|
|
+const handleAddressLine4 = createInputLimiter(AddressLine4, isShowLimitLine4)
|
|
|
|
|
|
const ManageAddressList = ref([])
|
|
|
// 需要特殊样式的日期列表
|
|
|
-const specialDates = ref([]);
|
|
|
+const specialDates = ref([])
|
|
|
|
|
|
|
|
|
const DateRangeChangeETA = (val:any) => {
|
|
|
@@ -255,7 +259,7 @@ const querySearchCity = (query: string) => {
|
|
|
}
|
|
|
// 特殊日期样式
|
|
|
const getCurrentStyle = (current: any) => {
|
|
|
- const dateString = current.format('YYYY.MM.DD');
|
|
|
+ const dateString = current.format('YYYY.MM.DD')
|
|
|
if (specialDates.value.includes(dateString)) {
|
|
|
return {
|
|
|
background: '#b3e5d4',
|
|
|
@@ -269,22 +273,15 @@ const getCurrentStyle = (current: any) => {
|
|
|
const submitAddressList = ref([])
|
|
|
const currentEditAddress = ref<any>(null)
|
|
|
const updateAddressList = (addressData) => {
|
|
|
- const { id, contact_type } = addressData;
|
|
|
+ const { sync_key, contact_type } = addressData
|
|
|
const existingIndex = submitAddressList.value.findIndex(
|
|
|
- item => item.id === id
|
|
|
+ item => item.sync_key === sync_key
|
|
|
)
|
|
|
if (contact_type === 'Delete') {
|
|
|
- if (existingIndex !== -1) {
|
|
|
- submitAddressList.value.splice(existingIndex, 1, {
|
|
|
- ...submitAddressList.value[existingIndex],
|
|
|
- contact_type: 'Delete'
|
|
|
- })
|
|
|
- } else {
|
|
|
- submitAddressList.value.push({
|
|
|
- ...addressData,
|
|
|
- contact_type: 'Delete'
|
|
|
- })
|
|
|
- }
|
|
|
+ submitAddressList.value.push({
|
|
|
+ ...addressData,
|
|
|
+ contact_type: 'Delete'
|
|
|
+ })
|
|
|
return
|
|
|
}
|
|
|
if (existingIndex !== -1) {
|
|
|
@@ -296,10 +293,10 @@ const updateAddressList = (addressData) => {
|
|
|
} else {
|
|
|
submitAddressList.value.push(addressData)
|
|
|
}
|
|
|
-};
|
|
|
+}
|
|
|
const isAddNewAddressVisible = ref(false)
|
|
|
const AddNewAddressDelivery = () => {
|
|
|
- currentEditAddress.value = null;
|
|
|
+ currentEditAddress.value = null
|
|
|
isAddNewAddressVisible.value = true
|
|
|
AddNewAddressVisible.value = true
|
|
|
AddressLine1.value = ''
|
|
|
@@ -335,23 +332,23 @@ const SaveNewAddress = () => {
|
|
|
postal_code: PostalCode.value,
|
|
|
contact_person: ContactPerson.value,
|
|
|
contact_number: ContactNumber.value,
|
|
|
- contact_id: '',
|
|
|
- sync_key: '',
|
|
|
- from_station: '',
|
|
|
+ contact_id: currentEditAddress.value? currentEditAddress.value.contact_id : '',
|
|
|
+ sync_key: currentEditAddress.value? currentEditAddress.value.sync_key : '',
|
|
|
+ from_station: currentEditAddress.value? currentEditAddress.value.from_station :'',
|
|
|
contact_type: 'Add',
|
|
|
create_user: 'Online_D_Address',
|
|
|
id: `temp_${Date.now()}`
|
|
|
}
|
|
|
if (currentEditAddress.value) {
|
|
|
- addressData.id = currentEditAddress.value.id;
|
|
|
-
|
|
|
+ const key = currentEditAddress.value.contact_type == 'Unedit' ? 'sync_key' : 'id'
|
|
|
+ addressData[key] = currentEditAddress.value[key]
|
|
|
+ addressData.contact_type = 'Modify'
|
|
|
const index = ManageAddressList.value.findIndex(
|
|
|
- item => item.id === currentEditAddress.value.id
|
|
|
+ item => item[key] === currentEditAddress.value[key]
|
|
|
)
|
|
|
if (index !== -1) {
|
|
|
ManageAddressList.value.splice(index, 1, addressData)
|
|
|
}
|
|
|
-
|
|
|
updateAddressList(addressData)
|
|
|
} else {
|
|
|
ManageAddressList.value.push(addressData)
|
|
|
@@ -376,7 +373,6 @@ const changeAddressRadio = () => {
|
|
|
}
|
|
|
selectedAddressList.value = ManageAddressList.value[Addressradio.value]
|
|
|
delivery_address = `${selectedAddressList.value.contact_person}(${selectedAddressList.value.contact_number})\n${selectedAddressList.value.address_1}\n${selectedAddressList.value.address_2}\n${selectedAddressList.value.address_3}\n${selectedAddressList.value.address_4},${selectedAddressList.value.country},${selectedAddressList.value.city},${selectedAddressList.value.postal_code}`
|
|
|
- console.log(delivery_address)
|
|
|
}
|
|
|
// 页面初始化
|
|
|
let checkShipments = []
|
|
|
@@ -402,10 +398,12 @@ const getInitBookingData = () => {
|
|
|
booking.value = res.data.data.booking_no
|
|
|
Requirements.value = res.data.data.special_requirements
|
|
|
modetypeValue.value = res.data.data.delivery_mode
|
|
|
- DateValue.value = res.data.data.created_time
|
|
|
+ DateValue.value = res.data.data.delivery_date
|
|
|
DeliveryTime.value = res.data.data.delivery_time
|
|
|
Modification.value = res.data.data.modify_reason
|
|
|
- const address1 = res.data.data.delivery_address.split('\r\n')[1]
|
|
|
+ selectedAddressList.value = res.data.data.delivery_address_detail
|
|
|
+ isselectedAddress.value = ''
|
|
|
+ const sync_key = res.data.data.delivery_address_detail.sync_key
|
|
|
checkShipments = res.data.data.tableData.map(item => ({ consignee_id: item.consignee_id, country: item.dc_country}))
|
|
|
checkShipmentsdata = Object.keys(checkShipments?.[0])
|
|
|
checkShipmentsSubmit = Object.keys(res.data.data.tableData?.[0])
|
|
|
@@ -429,13 +427,13 @@ const getInitBookingData = () => {
|
|
|
$api
|
|
|
.getAddressBookList({
|
|
|
...checkShipmentsInfo,
|
|
|
+ delivery_serial_no: a? a: ''
|
|
|
})
|
|
|
.then((res: any) => {
|
|
|
if (res.code === 200) {
|
|
|
ManageAddressList.value = res.data
|
|
|
ManageAddressList.value.forEach((item, index) => {
|
|
|
- if(item.address_1 === address1) {
|
|
|
- console.log(address1)
|
|
|
+ if(item.sync_key === sync_key) {
|
|
|
selectedAddressList.value = item
|
|
|
isselectedAddress.value = index
|
|
|
Addressradio.value = index
|
|
|
@@ -466,9 +464,9 @@ const isrecommenddate = ref()
|
|
|
const isConsistent = ref(false)
|
|
|
// 判断date是否一致
|
|
|
const areAllDateRangesSame = (date: any) => {
|
|
|
- const firstRange = date[0].date_range;
|
|
|
+ const firstRange = date[0].date_range
|
|
|
return date.every(item => {
|
|
|
- const currentRange = item.date_range;
|
|
|
+ const currentRange = item.date_range
|
|
|
if(currentRange.length === firstRange.length &&
|
|
|
currentRange.every((date, index) => date === firstRange[index])) {
|
|
|
return true
|
|
|
@@ -477,21 +475,21 @@ const areAllDateRangesSame = (date: any) => {
|
|
|
RecommendateList.value = date.map(item => ({Hbol: item.Hbol}))
|
|
|
return false
|
|
|
}
|
|
|
- });
|
|
|
+ })
|
|
|
}
|
|
|
// 遍历日期
|
|
|
const getDateRangeArray = (startDateStr, endDateStr) => {
|
|
|
if(startDateStr != '' && endDateStr != '') {
|
|
|
const parseDate = (str) => {
|
|
|
- const [year, month, day] = str.split('.').map(Number);
|
|
|
- return new Date(year, month - 1, day); // 月份从0开始计数
|
|
|
- };
|
|
|
+ const [year, month, day] = str.split('.').map(Number)
|
|
|
+ return new Date(year, month - 1, day) // 月份从0开始计数
|
|
|
+ }
|
|
|
|
|
|
- const startDate = parseDate(startDateStr);
|
|
|
- const endDate = parseDate(endDateStr);
|
|
|
+ const startDate = parseDate(startDateStr)
|
|
|
+ const endDate = parseDate(endDateStr)
|
|
|
|
|
|
- const dateArray = [];
|
|
|
- const currentDate = new Date(startDate);
|
|
|
+ const dateArray = []
|
|
|
+ const currentDate = new Date(startDate)
|
|
|
|
|
|
while (currentDate <= endDate) {
|
|
|
// 格式化为 YYYY.MM.DD
|
|
|
@@ -499,12 +497,12 @@ const getDateRangeArray = (startDateStr, endDateStr) => {
|
|
|
currentDate.getFullYear(),
|
|
|
(currentDate.getMonth() + 1).toString().padStart(2, '0'),
|
|
|
currentDate.getDate().toString().padStart(2, '0')
|
|
|
- ].join('.');
|
|
|
- dateArray.push(formattedDate);
|
|
|
- currentDate.setDate(currentDate.getDate() + 1);
|
|
|
+ ].join('.')
|
|
|
+ dateArray.push(formattedDate)
|
|
|
+ currentDate.setDate(currentDate.getDate() + 1)
|
|
|
}
|
|
|
|
|
|
- return dateArray;
|
|
|
+ return dateArray
|
|
|
}
|
|
|
}
|
|
|
const selectChangeEvent = (val: any, date: any, submitInfo: any) => {
|
|
|
@@ -528,20 +526,22 @@ const handleClickAddress = () => {
|
|
|
const nonDeletedAddresses = ManageAddressList.value.filter(
|
|
|
item => item.contact_type !== 'Delete'
|
|
|
)
|
|
|
- $api
|
|
|
- .getAddressBookList({
|
|
|
- ...getAddressListData.value,
|
|
|
- })
|
|
|
- .then((res: any) => {
|
|
|
- if (res.code === 200) {
|
|
|
- const newAddresses = res.data.filter(
|
|
|
- (apiAddr: any) =>
|
|
|
- !nonDeletedAddresses.some(localAddr => localAddr.id === apiAddr.id)
|
|
|
- )
|
|
|
- ManageAddressList.value = [...nonDeletedAddresses, ...newAddresses]
|
|
|
- ManageVisible.value = true
|
|
|
- }
|
|
|
- })
|
|
|
+ if(a == undefined) {
|
|
|
+ $api
|
|
|
+ .getAddressBookList({
|
|
|
+ ...getAddressListData.value,
|
|
|
+ })
|
|
|
+ .then((res: any) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ const newAddresses = res.data.filter(
|
|
|
+ (apiAddr: any) =>
|
|
|
+ !nonDeletedAddresses.some(localAddr => localAddr.id === apiAddr.id)
|
|
|
+ )
|
|
|
+ ManageAddressList.value = [...nonDeletedAddresses, ...newAddresses]
|
|
|
+ ManageVisible.value = true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//选择日期
|
|
|
@@ -566,7 +566,7 @@ const changeDatePicker = (val:any) => {
|
|
|
}
|
|
|
// 新增地址
|
|
|
const handleClickAddNewAddress = () => {
|
|
|
- currentEditAddress.value = null;
|
|
|
+ currentEditAddress.value = null
|
|
|
AddNewAddressVisible.value = true
|
|
|
isAddNewAddressVisible.value = false
|
|
|
AddressLine1.value = ''
|
|
|
@@ -581,7 +581,7 @@ const handleClickAddNewAddress = () => {
|
|
|
}
|
|
|
// 编辑地址
|
|
|
const handleClickEditAddress = (val:any) => {
|
|
|
- currentEditAddress.value = val;
|
|
|
+ currentEditAddress.value = val
|
|
|
AddNewAddressVisible.value = true
|
|
|
AddressLine1.value = val.address_1
|
|
|
AddressLine2.value = val.address_2
|
|
|
@@ -595,37 +595,36 @@ const handleClickEditAddress = (val:any) => {
|
|
|
const updatedAddress = {
|
|
|
...val,
|
|
|
contact_type: val.contact_type == 'Unedit'? 'Modify' : 'Add'
|
|
|
- };
|
|
|
- updateAddressList(updatedAddress);
|
|
|
+ }
|
|
|
+ updateAddressList(updatedAddress)
|
|
|
}
|
|
|
// 删除地址
|
|
|
const handleDeleteAddress = (val: any) => {
|
|
|
- if(val.contact_type === 'Add') {
|
|
|
- ManageAddressList.value = ManageAddressList.value.filter((item) => item.id !== val.id)
|
|
|
- } else {
|
|
|
- updateAddressList({
|
|
|
- ...val,
|
|
|
- contact_type: 'Delete'
|
|
|
- });
|
|
|
- ManageAddressList.value = ManageAddressList.value.filter((item) => item.id !== val.id)
|
|
|
+ const key = val.contact_type == 'Unedit' ? 'sync_key' : 'id'
|
|
|
+ console.log(val.contact_type)
|
|
|
+ if (val.contact_type !== 'Add') {
|
|
|
+ updateAddressList({ ...val, contact_type: 'Delete' })
|
|
|
}
|
|
|
- if (selectedAddressList.value?.id === val.id) {
|
|
|
- selectedAddressList.value = undefined;
|
|
|
- isselectedAddress.value = null;
|
|
|
+
|
|
|
+ ManageAddressList.value = ManageAddressList.value.filter((item) => item[key] !== val[key])
|
|
|
+
|
|
|
+ if (selectedAddressList.value?.[key] === val[key]) {
|
|
|
+ selectedAddressList.value = undefined
|
|
|
+ isselectedAddress.value = null
|
|
|
}
|
|
|
}
|
|
|
// 保存
|
|
|
const SubmitBooking = () => {
|
|
|
let datetwo = ''
|
|
|
if (a != undefined) {
|
|
|
- const value = DateValue.value;
|
|
|
+ const value = DateValue.value
|
|
|
const parts = value.includes(' ')
|
|
|
? value.split(' ')[0].split('-')
|
|
|
- : value.split('.');
|
|
|
- datetwo = `${parts[1]}/${parts[2]}/${parts[0]}`;
|
|
|
+ : value.split('.')
|
|
|
+ datetwo = `${parts[1]}/${parts[2]}/${parts[0]}`
|
|
|
} else {
|
|
|
- const parts = DateValue.value.split('.');
|
|
|
- datetwo = `${parts[1]}/${parts[2]}/${parts[0]}`;
|
|
|
+ const parts = DateValue.value.split('.')
|
|
|
+ datetwo = `${parts[1]}/${parts[2]}/${parts[0]}`
|
|
|
}
|
|
|
let result = []
|
|
|
if(submitAddressList.value.length != 0) {
|
|
|
@@ -633,7 +632,8 @@ const SubmitBooking = () => {
|
|
|
item.id === selectedAddressList.value.id ||
|
|
|
item.contact_type === 'Delete'
|
|
|
)
|
|
|
- const objExists = submitAddressList.value.some(item => item.id === selectedAddressList.value.id)
|
|
|
+ const key = selectedAddressList.value.contact_type == 'Unedit' ? 'sync_key' : 'id'
|
|
|
+ const objExists = submitAddressList.value.some(item => item[key] === selectedAddressList.value[key])
|
|
|
if (!objExists) {
|
|
|
result.push(selectedAddressList.value)
|
|
|
}
|
|
|
@@ -648,7 +648,6 @@ const SubmitBooking = () => {
|
|
|
[item]: result.map((row) => row[item] )
|
|
|
})
|
|
|
})
|
|
|
- console.log(addressshipmentinfo)
|
|
|
$api
|
|
|
.SaveBookingList({
|
|
|
serial_no: a != undefined ? a : '',
|