|
|
|
@@ -14,6 +14,7 @@ const emit = defineEmits<{ 'update:modelValue': [SaveTruckAppointmentRequest]; s
|
|
|
|
|
const formRef = ref<FormInstance>()
|
|
|
|
|
const relationWarning = ref('')
|
|
|
|
|
const derivedCustomerSource = ref<'booking' | 'container' | null>(null)
|
|
|
|
|
const billOfLadingFromBooking = ref(false)
|
|
|
|
|
const defaults: Partial<SaveTruckAppointmentRequest> = { expectedVersion: 0, currency: 'RMB', payableAmount: '0.00', receivableAmount: '0.00', packageCount: 0, palletCount: 0, transitMinutes: 0 }
|
|
|
|
|
function normalizeDraft(value: SaveTruckAppointmentRequest): SaveTruckAppointmentRequest { return { ...defaults, ...value, currency: value.currency?.trim().toUpperCase() || 'RMB' } }
|
|
|
|
|
const draft = reactive<SaveTruckAppointmentRequest>(normalizeDraft(props.modelValue))
|
|
|
|
@@ -52,6 +53,7 @@ const selectableWarehouses = computed(() => warehouses.value.filter((item) => (
|
|
|
|
|
const selectableCarriers = computed(() => carriers.value.filter((item) => (
|
|
|
|
|
item.status === 'ACTIVE'
|
|
|
|
|
)))
|
|
|
|
|
const selectedReleasedBooking = computed(() => bookings.value.find((item) => item.id === draft.oceanBookingId && item.status === 'RELEASED') || null)
|
|
|
|
|
function customerLabel(customer: PlatformTenantResource) { return customer.tenantName }
|
|
|
|
|
function selectCustomer(customerId: string) { const customer = selectableCustomers.value.find((item) => String(item.id) === customerId); draft.customerId = customer?.id ? String(customer.id) : null; draft.customerName = customer ? customerLabel(customer) : null; derivedCustomerSource.value = null; relationWarning.value = '' }
|
|
|
|
|
function selectCarrier(carrierId: string) { const carrier = selectableCarriers.value.find((item) => String(item.id) === carrierId); draft.carrierId = carrier?.id || null; draft.carrierName = carrier?.name || null }
|
|
|
|
@@ -74,13 +76,24 @@ function selectContainer(containerId: string) {
|
|
|
|
|
}
|
|
|
|
|
function selectBooking(bookingId: string) {
|
|
|
|
|
const item = bookings.value.find((entry) => entry.id === bookingId)
|
|
|
|
|
const previouslyDerivedBillOfLading = billOfLadingFromBooking.value
|
|
|
|
|
draft.oceanBookingId = item?.id || null
|
|
|
|
|
relationWarning.value = ''
|
|
|
|
|
if (!item) {
|
|
|
|
|
if (billOfLadingFromBooking.value) draft.billOfLadingNo = null
|
|
|
|
|
billOfLadingFromBooking.value = false
|
|
|
|
|
if (derivedCustomerSource.value === 'booking') { draft.customerId = null; draft.customerName = null; derivedCustomerSource.value = null }
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
applyRelatedCustomer(item.customerId, item.customerName, 'booking')
|
|
|
|
|
if (item.status === 'RELEASED') {
|
|
|
|
|
if (draft.billOfLadingNo && draft.billOfLadingNo !== item.billOfLadingNo) relationWarning.value = '已放舱订舱的提单号与当前填写值不一致,已使用订舱冻结快照'
|
|
|
|
|
draft.billOfLadingNo = item.billOfLadingNo || null
|
|
|
|
|
billOfLadingFromBooking.value = true
|
|
|
|
|
} else {
|
|
|
|
|
if (previouslyDerivedBillOfLading) draft.billOfLadingNo = null
|
|
|
|
|
billOfLadingFromBooking.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
async function loadOptions() {
|
|
|
|
|
optionsLoading.value = true; optionsError.value = ''
|
|
|
|
@@ -118,6 +131,7 @@ watch(() => props.readonly, (readonly) => { if (!readonly && !customers.value.le
|
|
|
|
|
<el-col :xs="24" :sm="12"><el-form-item label="客户" prop="customerId"><el-select :model-value="draft.customerId" filterable clearable placeholder="请选择客户" :loading="optionsLoading" no-data-text="暂无启用的客户" style="width:100%" @update:model-value="selectCustomer(String($event || ''))"><el-option v-if="draft.customerId && !selectableCustomers.some((item) => String(item.id) === String(draft.customerId))" :label="draft.customerName || '历史客户(需重新选择)'" :value="String(draft.customerId)" disabled /><el-option v-for="item in selectableCustomers" :key="String(item.id)" :label="customerLabel(item)" :value="String(item.id)" /></el-select></el-form-item></el-col>
|
|
|
|
|
<el-col :xs="24" :sm="12"><el-form-item label="承运商" prop="carrierId"><el-select :model-value="draft.carrierId" filterable clearable placeholder="请选择承运商" :loading="optionsLoading" no-data-text="暂无可用拖车供应商" style="width:100%" @update:model-value="selectCarrier(String($event || ''))"><el-option v-if="draft.carrierId && !selectableCarriers.some((item) => String(item.id) === String(draft.carrierId))" :label="draft.carrierName || '当前承运商(需重新选择)'" :value="String(draft.carrierId)" disabled /><el-option v-for="item in selectableCarriers" :key="String(item.id)" :label="item.name" :value="String(item.id)" /></el-select></el-form-item></el-col>
|
|
|
|
|
<el-col :xs="24" :sm="12"><el-form-item label="预计装箱时间" prop="plannedLoadingAt"><el-date-picker v-model="draft.plannedLoadingAt" type="datetime" value-format="YYYY-MM-DDTHH:mm:ss" placeholder="请选择预计装箱时间" style="width:100%" /></el-form-item></el-col>
|
|
|
|
|
<el-col :xs="24" :sm="12"><el-form-item label="提单号"><el-input v-model="draft.billOfLadingNo" :disabled="Boolean(selectedReleasedBooking)" maxlength="128" placeholder="草稿可暂不填写,派车前必填" /><div v-if="selectedReleasedBooking" class="field-hint">已从放舱订舱回填并锁定</div></el-form-item></el-col>
|
|
|
|
|
<el-col :xs="24"><el-divider content-position="left">可选关联</el-divider></el-col>
|
|
|
|
|
<el-col :xs="24" :sm="12"><el-form-item label="关联柜次(可选)"><el-select :model-value="draft.containerBookingId" filterable clearable placeholder="可选择柜次辅助补全" :loading="optionsLoading" no-data-text="暂无可关联柜次" style="width:100%" @update:model-value="selectContainer(String($event || ''))"><el-option v-for="item in containers" :key="item.id" :label="`柜次号:${item.cabinetNo || item.bookingNo || '待生成'} / 集装箱号:${item.containerNo || '待录入'}`" :value="item.id" /></el-select></el-form-item></el-col>
|
|
|
|
|
<el-col :xs="24" :sm="12"><el-form-item label="关联订舱(可选)"><el-select :model-value="draft.oceanBookingId" filterable clearable placeholder="可选择订舱辅助补全" :loading="optionsLoading" no-data-text="暂无可关联订舱" style="width:100%" @update:model-value="selectBooking(String($event || ''))"><el-option v-for="item in bookings" :key="item.id" :label="item.bookingNo || '订舱号缺失'" :value="item.id" /></el-select></el-form-item></el-col>
|
|
|
|
@@ -160,7 +174,8 @@ watch(() => props.readonly, (readonly) => { if (!readonly && !customers.value.le
|
|
|
|
|
.form-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
|
|
|
|
|
:deep(.el-divider) { margin: 18px 0 12px; }
|
|
|
|
|
:deep(.el-divider__text) { color: var(--el-text-color-primary); font-size: 14px; font-weight: 600; }
|
|
|
|
|
:deep(.el-input), :deep(.el-textarea), :deep(.el-date-editor) { max-width: 100%; }
|
|
|
|
|
:deep(.el-input), :deep(.el-textarea), :deep(.el-date-editor) { max-width: 100%; }
|
|
|
|
|
.field-hint { margin-top:4px; color:var(--cc-muted); font-size:12px; }
|
|
|
|
|
@media (max-width: 480px) {
|
|
|
|
|
.truck-form { padding-inline: 2px; }
|
|
|
|
|
.form-actions { position: sticky; bottom: 0; z-index: 2; margin: 8px -2px -4px; padding: 10px 2px; background: var(--el-bg-color); border-top: 1px solid var(--el-border-color-lighter); }
|
|
|
|
|