2026-08-10 15:36:53 +08:00
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
|
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
|
|
|
|
|
import { useRouter } from 'vue-router'
|
2026-08-11 11:15:44 +08:00
|
|
|
|
import { Boxes, Eye, ListChecks, Pencil, Plus, Sparkles } from '@lucide/vue'
|
2026-08-10 15:36:53 +08:00
|
|
|
|
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
|
|
|
|
|
|
import { useAccessPreviewStore } from '@/core/access/accessPreview'
|
|
|
|
|
|
import { listAllPlatformWarehouses, type PlatformWarehouseSummaryResource } from '@/modules/warehouses'
|
2026-08-11 18:06:35 +08:00
|
|
|
|
import { listPlatformPartners, type PlatformPartnerResource } from '@/modules/master-data'
|
|
|
|
|
|
import { listOceanBookings, type OceanBookingResource } from '@/modules/ocean-bookings'
|
2026-08-10 16:24:54 +08:00
|
|
|
|
import AdminPage from '@/shared/components/AdminPage.vue'
|
2026-08-10 15:36:53 +08:00
|
|
|
|
import ApiErrorMeta from '@/shared/components/ApiErrorMeta.vue'
|
2026-08-12 16:31:46 +08:00
|
|
|
|
import AppDialog from '@/shared/components/AppDialog.vue'
|
2026-08-10 15:36:53 +08:00
|
|
|
|
import AppDrawer from '@/shared/components/AppDrawer.vue'
|
|
|
|
|
|
import DataTable, { type DataTableColumn } from '@/shared/components/DataTable.vue'
|
2026-08-10 16:24:54 +08:00
|
|
|
|
import ListPageLayout from '@/shared/components/ListPageLayout.vue'
|
2026-08-10 15:36:53 +08:00
|
|
|
|
import LoadErrorState from '@/shared/components/LoadErrorState.vue'
|
|
|
|
|
|
import QueryToolbar, { type QueryField, type QueryModel } from '@/shared/components/QueryToolbar.vue'
|
|
|
|
|
|
import { getApiErrorDetails, type ApiErrorDetails } from '@/shared/api/http'
|
|
|
|
|
|
import { createContainer, getContainer, listContainers, updateContainer, updateContainerTransport } from '../api/platformContainerLoading'
|
|
|
|
|
|
import type { ContainerBookingResource, ContainerPlanStatus, ContainerSaveRequest } from '../types'
|
|
|
|
|
|
|
2026-08-11 11:15:44 +08:00
|
|
|
|
type Filters = QueryModel & { keyword: string; containerType: string; status: ContainerPlanStatus | ''; sailingRange: string[] }
|
2026-08-10 15:36:53 +08:00
|
|
|
|
type ContainerForm = ContainerSaveRequest & { id: string; version: number }
|
|
|
|
|
|
|
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
|
const access = useAccessPreviewStore()
|
|
|
|
|
|
const rows = ref<ContainerBookingResource[]>([])
|
|
|
|
|
|
const warehouses = ref<PlatformWarehouseSummaryResource[]>([])
|
2026-08-11 18:06:35 +08:00
|
|
|
|
const destinationWarehouses = ref<PlatformWarehouseSummaryResource[]>([])
|
|
|
|
|
|
const partners = ref<PlatformPartnerResource[]>([])
|
|
|
|
|
|
const oceanBookings = ref<OceanBookingResource[]>([])
|
2026-08-10 15:36:53 +08:00
|
|
|
|
const loading = ref(false)
|
|
|
|
|
|
const warehouseLoading = ref(false)
|
|
|
|
|
|
const loadError = ref<ApiErrorDetails | null>(null)
|
|
|
|
|
|
const warehouseError = ref<ApiErrorDetails | null>(null)
|
2026-08-11 18:06:35 +08:00
|
|
|
|
const businessOptionsLoading = ref(false)
|
|
|
|
|
|
const businessOptionsError = ref('')
|
2026-08-10 15:36:53 +08:00
|
|
|
|
const page = ref(1)
|
|
|
|
|
|
const pageSize = ref(20)
|
|
|
|
|
|
const total = ref(0)
|
2026-08-11 11:15:44 +08:00
|
|
|
|
const filters = ref<Filters>({ keyword: '', containerType: '', status: '', sailingRange: [] })
|
2026-08-10 15:36:53 +08:00
|
|
|
|
const applied = ref<Filters>({ ...filters.value })
|
|
|
|
|
|
const detailOpen = ref(false)
|
|
|
|
|
|
const detailLoading = ref(false)
|
|
|
|
|
|
const detailError = ref<ApiErrorDetails | null>(null)
|
|
|
|
|
|
const detail = ref<ContainerBookingResource | null>(null)
|
|
|
|
|
|
const detailTarget = ref<ContainerBookingResource | null>(null)
|
|
|
|
|
|
const editorOpen = ref(false)
|
|
|
|
|
|
const editorError = ref<ApiErrorDetails | null>(null)
|
|
|
|
|
|
const saving = ref(false)
|
|
|
|
|
|
const formRef = ref<FormInstance>()
|
|
|
|
|
|
let listSequence = 0
|
|
|
|
|
|
let detailSequence = 0
|
|
|
|
|
|
|
|
|
|
|
|
function emptyForm(): ContainerForm {
|
|
|
|
|
|
return {
|
|
|
|
|
|
id: '', version: 0, containerNo: null, cabinetNo: '', warehouseId: '', warehouseName: null,
|
|
|
|
|
|
billOfLadingNo: null, vesselName: null, voyageNo: null, containerType: '40HQ', shippingCompanyId: null,
|
|
|
|
|
|
shippingCompanyName: null, departurePortCode: null, departurePortName: null, destinationPortCode: null,
|
|
|
|
|
|
destinationPortName: null, destinationWarehouseCode: null, destinationWarehouseName: null,
|
|
|
|
|
|
capacityCbm: null, maxWeightKg: null, terminalTruckingCompany: null, loadingAt: null,
|
|
|
|
|
|
estimatedSailingAt: null, actualSailingAt: null, estimatedPortArrivalAt: null, actualPortArrivalAt: null,
|
|
|
|
|
|
estimatedWarehouseArrivalAt: null, actualWarehouseArrivalAt: null,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
const form = reactive<ContainerForm>(emptyForm())
|
|
|
|
|
|
const rules: FormRules<ContainerForm> = {
|
|
|
|
|
|
cabinetNo: [{ required: true, message: '请输入柜次号', trigger: 'blur' }],
|
|
|
|
|
|
warehouseId: [{ required: true, message: '请选择装柜仓库', trigger: 'change' }],
|
|
|
|
|
|
containerType: [{ required: true, message: '请选择柜型', trigger: 'change' }],
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const canCreate = computed(() => access.can('platform:firstleg:container:create'))
|
2026-08-11 18:06:35 +08:00
|
|
|
|
const canView = computed(() => access.can('platform:firstleg:container:view'))
|
2026-08-10 15:36:53 +08:00
|
|
|
|
const canEdit = computed(() => access.can('platform:firstleg:container:edit'))
|
|
|
|
|
|
const canSmartLoading = computed(() => access.can('platform:firstleg:smart-loading:list'))
|
2026-08-11 11:15:44 +08:00
|
|
|
|
const canViewPreload = computed(() => access.can('platform:firstleg:preload:list'))
|
|
|
|
|
|
const canViewLoadingList = computed(() => access.can('platform:firstleg:loading-list:list'))
|
2026-08-12 16:31:46 +08:00
|
|
|
|
const editorTitle = computed(() => form.id ? '编辑' : '新增')
|
2026-08-10 15:36:53 +08:00
|
|
|
|
const transportOnly = computed(() => Boolean(form.id) && detail.value?.planStatus === 'LOADING')
|
2026-08-11 18:06:35 +08:00
|
|
|
|
const shippingCompanies = computed(() => partners.value.filter((partner) => partner.status === 'ACTIVE' && partner.types.includes('CARRIER')))
|
|
|
|
|
|
const truckingCompanies = computed(() => partners.value.filter((partner) => partner.status === 'ACTIVE' && partner.types.some((type) => ['CARRIER', 'SUPPLIER'].includes(type))))
|
|
|
|
|
|
|
|
|
|
|
|
interface PortOption { value: string; code: string | null; name: string | null }
|
|
|
|
|
|
function portValue(code: string | null | undefined, name: string | null | undefined) { return code || name ? JSON.stringify([code || '', name || '']) : '' }
|
|
|
|
|
|
function collectPorts(direction: 'departure' | 'destination'): PortOption[] {
|
|
|
|
|
|
const entries = oceanBookings.value.map((booking) => direction === 'departure'
|
|
|
|
|
|
? { code: booking.departurePortCode, name: booking.departurePortName }
|
|
|
|
|
|
: { code: booking.destinationPortCode, name: booking.destinationPortName })
|
|
|
|
|
|
const current = direction === 'departure'
|
|
|
|
|
|
? { code: form.departurePortCode, name: form.departurePortName }
|
|
|
|
|
|
: { code: form.destinationPortCode, name: form.destinationPortName }
|
|
|
|
|
|
entries.push(current)
|
|
|
|
|
|
const options = new Map<string, PortOption>()
|
|
|
|
|
|
for (const entry of entries) {
|
|
|
|
|
|
if (!entry.code && !entry.name) continue
|
|
|
|
|
|
const value = portValue(entry.code, entry.name)
|
|
|
|
|
|
options.set(value, { value, code: entry.code || null, name: entry.name || null })
|
|
|
|
|
|
}
|
|
|
|
|
|
return [...options.values()].sort((left, right) => (left.name || left.code || '').localeCompare(right.name || right.code || '', 'zh-CN'))
|
|
|
|
|
|
}
|
|
|
|
|
|
const departurePorts = computed(() => collectPorts('departure'))
|
|
|
|
|
|
const destinationPorts = computed(() => collectPorts('destination'))
|
|
|
|
|
|
const departurePortValue = computed(() => portValue(form.departurePortCode, form.departurePortName))
|
|
|
|
|
|
const destinationPortValue = computed(() => portValue(form.destinationPortCode, form.destinationPortName))
|
|
|
|
|
|
const shippingCompanyValue = computed(() => form.shippingCompanyId || (form.shippingCompanyName ? `name:${form.shippingCompanyName}` : ''))
|
|
|
|
|
|
const destinationWarehouseValue = computed(() => form.destinationWarehouseCode || (form.destinationWarehouseName ? `name:${form.destinationWarehouseName}` : ''))
|
2026-08-10 15:36:53 +08:00
|
|
|
|
|
|
|
|
|
|
const queryFields = computed<QueryField[]>(() => [
|
|
|
|
|
|
{ key: 'keyword', type: 'input', label: '关键词', width: 220, placeholder: '柜次号、柜号或提单号', props: { 'aria-label': '关键词', maxlength: 128 } },
|
|
|
|
|
|
{ key: 'containerType', type: 'select', label: '柜型', width: 140, options: ['20GP', '40GP', '40HQ', '45HQ'].map((value) => ({ label: value, value })), props: { 'aria-label': '柜型' } },
|
2026-08-11 11:52:30 +08:00
|
|
|
|
{ key: 'status', type: 'select', label: '排柜状态', width: 150, options: [{ label: '待装柜', value: 'WAIT_LOADING' }, { label: '预装柜中', value: 'EDITING' }, { label: '拣货中', value: 'LOADING' }, { label: '装柜完成', value: 'COMPLETED' }], props: { 'aria-label': '排柜状态' } },
|
2026-08-10 15:36:53 +08:00
|
|
|
|
{ key: 'sailingRange', type: 'daterange', label: '预计开船', width: 260, props: { 'aria-label': '预计开船日期范围' } },
|
|
|
|
|
|
])
|
|
|
|
|
|
const columns: DataTableColumn[] = [
|
2026-08-11 11:15:44 +08:00
|
|
|
|
{ key: 'actions', label: '操作', width: 310, fixed: 'left', slotName: 'actions' },
|
2026-08-10 15:36:53 +08:00
|
|
|
|
{ key: 'cabinetNo', label: '柜次', minWidth: 180, slotName: 'cabinet' },
|
|
|
|
|
|
{ key: 'containerNo', label: '集装箱号', minWidth: 150, slotName: 'containerNo' },
|
|
|
|
|
|
{ key: 'planStatus', label: '状态', width: 110, slotName: 'status' },
|
|
|
|
|
|
{ key: 'warehouseName', prop: 'warehouseName', label: '装柜仓库', minWidth: 160 },
|
|
|
|
|
|
{ key: 'route', label: '航线', minWidth: 220, slotName: 'route' },
|
|
|
|
|
|
{ key: 'containerType', prop: 'containerType', label: '柜型', width: 100 },
|
|
|
|
|
|
{ key: 'capacity', label: '容量上限', minWidth: 150, slotName: 'capacity' },
|
|
|
|
|
|
{ key: 'vessel', label: '船名/航次', minWidth: 180, slotName: 'vessel' },
|
|
|
|
|
|
{ key: 'estimatedSailingAt', label: '预计开船', minWidth: 160, slotName: 'estimatedSailingAt' },
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
function optional(value: string | null) { return value?.trim() || null }
|
2026-08-11 11:52:30 +08:00
|
|
|
|
function statusText(status: ContainerPlanStatus) { return ({ WAIT_LOADING: '待装柜', EDITING: '预装柜中', LOADING: '拣货中', COMPLETED: '装柜完成' })[status] }
|
2026-08-10 15:36:53 +08:00
|
|
|
|
function formatTime(value: string | null | undefined) { return value?.replace('T', ' ').slice(0, 16) || '—' }
|
2026-08-10 17:42:17 +08:00
|
|
|
|
function containerViewLabel(row: ContainerBookingResource) {
|
|
|
|
|
|
const reference = [row.cabinetNo, row.containerNo, row.bookingNo]
|
|
|
|
|
|
.find((value) => typeof value === 'string' && value.trim())
|
|
|
|
|
|
return reference ? `查看 ${reference}` : '查看货柜详情'
|
|
|
|
|
|
}
|
2026-08-10 15:36:53 +08:00
|
|
|
|
function replaceForm(source: ContainerBookingResource | null) {
|
|
|
|
|
|
Object.assign(form, emptyForm(), source || {})
|
|
|
|
|
|
}
|
|
|
|
|
|
function payload(): ContainerSaveRequest {
|
|
|
|
|
|
const selectedWarehouse = warehouses.value.find((warehouse) => String(warehouse.id) === form.warehouseId)
|
|
|
|
|
|
return {
|
|
|
|
|
|
containerNo: optional(form.containerNo), cabinetNo: form.cabinetNo.trim(),
|
|
|
|
|
|
warehouseId: form.warehouseId,
|
|
|
|
|
|
warehouseName: selectedWarehouse?.warehouseName || optional(form.warehouseName),
|
|
|
|
|
|
billOfLadingNo: optional(form.billOfLadingNo), vesselName: optional(form.vesselName), voyageNo: optional(form.voyageNo),
|
|
|
|
|
|
containerType: form.containerType,
|
|
|
|
|
|
shippingCompanyId: optional(form.shippingCompanyId), shippingCompanyName: optional(form.shippingCompanyName),
|
|
|
|
|
|
departurePortCode: optional(form.departurePortCode), departurePortName: optional(form.departurePortName),
|
|
|
|
|
|
destinationPortCode: optional(form.destinationPortCode), destinationPortName: optional(form.destinationPortName),
|
|
|
|
|
|
destinationWarehouseCode: optional(form.destinationWarehouseCode), destinationWarehouseName: optional(form.destinationWarehouseName),
|
|
|
|
|
|
capacityCbm: form.capacityCbm, maxWeightKg: form.maxWeightKg, terminalTruckingCompany: optional(form.terminalTruckingCompany),
|
|
|
|
|
|
loadingAt: form.loadingAt, estimatedSailingAt: form.estimatedSailingAt, actualSailingAt: form.actualSailingAt,
|
|
|
|
|
|
estimatedPortArrivalAt: form.estimatedPortArrivalAt, actualPortArrivalAt: form.actualPortArrivalAt,
|
|
|
|
|
|
estimatedWarehouseArrivalAt: form.estimatedWarehouseArrivalAt, actualWarehouseArrivalAt: form.actualWarehouseArrivalAt,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-08-11 18:06:35 +08:00
|
|
|
|
function partnerLabel(partner: PlatformPartnerResource) {
|
|
|
|
|
|
return `${partner.partnerName}${partner.partnerCode ? `(${partner.partnerCode})` : ''}`
|
|
|
|
|
|
}
|
|
|
|
|
|
function portLabel(port: PortOption) {
|
|
|
|
|
|
return port.name && port.code ? `${port.name}(${port.code})` : port.name || port.code || '未命名港口'
|
|
|
|
|
|
}
|
|
|
|
|
|
function selectShippingCompany(partnerId: string) {
|
|
|
|
|
|
if (partnerId.startsWith('name:')) {
|
|
|
|
|
|
form.shippingCompanyId = null
|
|
|
|
|
|
form.shippingCompanyName = partnerId.slice(5) || null
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
const partner = partners.value.find((item) => String(item.id) === partnerId)
|
|
|
|
|
|
form.shippingCompanyId = partnerId || null
|
|
|
|
|
|
form.shippingCompanyName = partner?.partnerName || null
|
|
|
|
|
|
}
|
|
|
|
|
|
function selectPort(direction: 'departure' | 'destination', value: string) {
|
|
|
|
|
|
const option = (direction === 'departure' ? departurePorts.value : destinationPorts.value).find((item) => item.value === value)
|
|
|
|
|
|
if (direction === 'departure') {
|
|
|
|
|
|
form.departurePortCode = option?.code || null
|
|
|
|
|
|
form.departurePortName = option?.name || null
|
|
|
|
|
|
} else {
|
|
|
|
|
|
form.destinationPortCode = option?.code || null
|
|
|
|
|
|
form.destinationPortName = option?.name || null
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
function selectDestinationWarehouse(warehouseCode: string) {
|
|
|
|
|
|
if (warehouseCode.startsWith('name:')) {
|
|
|
|
|
|
form.destinationWarehouseCode = null
|
|
|
|
|
|
form.destinationWarehouseName = warehouseCode.slice(5) || null
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
const warehouse = destinationWarehouses.value.find((item) => item.warehouseCode === warehouseCode)
|
|
|
|
|
|
form.destinationWarehouseCode = warehouseCode || null
|
|
|
|
|
|
form.destinationWarehouseName = warehouse?.warehouseName || null
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-08-10 15:36:53 +08:00
|
|
|
|
async function loadWarehouses() {
|
|
|
|
|
|
warehouseLoading.value = true; warehouseError.value = null
|
2026-08-11 18:06:35 +08:00
|
|
|
|
try {
|
|
|
|
|
|
const records = await listAllPlatformWarehouses({ status: 'ACTIVE' })
|
|
|
|
|
|
warehouses.value = records.filter((warehouse) => warehouse.warehouseType === 'DOMESTIC')
|
|
|
|
|
|
destinationWarehouses.value = records.filter((warehouse) => warehouse.warehouseType !== 'DOMESTIC')
|
|
|
|
|
|
}
|
2026-08-10 15:36:53 +08:00
|
|
|
|
catch (error) { warehouseError.value = getApiErrorDetails(error, '装柜仓库加载失败') }
|
|
|
|
|
|
finally { warehouseLoading.value = false }
|
|
|
|
|
|
}
|
2026-08-11 18:06:35 +08:00
|
|
|
|
async function loadBusinessOptions() {
|
|
|
|
|
|
businessOptionsLoading.value = true
|
|
|
|
|
|
businessOptionsError.value = ''
|
|
|
|
|
|
const errors: string[] = []
|
|
|
|
|
|
const [partnerResult, bookingResult] = await Promise.allSettled([
|
|
|
|
|
|
loadAllPartners(),
|
|
|
|
|
|
loadAllOceanBookings(),
|
|
|
|
|
|
])
|
|
|
|
|
|
if (partnerResult.status === 'fulfilled') partners.value = partnerResult.value
|
|
|
|
|
|
else errors.push(getApiErrorDetails(partnerResult.reason, '船公司与拖车公司加载失败').message)
|
|
|
|
|
|
if (bookingResult.status === 'fulfilled') oceanBookings.value = bookingResult.value
|
|
|
|
|
|
else errors.push(getApiErrorDetails(bookingResult.reason, '港口候选加载失败').message)
|
|
|
|
|
|
businessOptionsError.value = errors.join(';')
|
|
|
|
|
|
businessOptionsLoading.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
async function loadAllPartners() {
|
|
|
|
|
|
const firstPage = await listPlatformPartners({ page: 1, size: 200, status: 'ACTIVE' })
|
|
|
|
|
|
if (firstPage.pages <= 1) return firstPage.records
|
|
|
|
|
|
const remaining = await Promise.all(Array.from({ length: firstPage.pages - 1 }, (_, index) => listPlatformPartners({ page: index + 2, size: 200, status: 'ACTIVE' })))
|
|
|
|
|
|
return [firstPage, ...remaining].flatMap((pageResult) => pageResult.records)
|
|
|
|
|
|
}
|
|
|
|
|
|
async function loadAllOceanBookings() {
|
|
|
|
|
|
const firstPage = await listOceanBookings({ page: 1, size: 200 })
|
|
|
|
|
|
if (firstPage.pages <= 1) return firstPage.records
|
|
|
|
|
|
const remaining = await Promise.all(Array.from({ length: firstPage.pages - 1 }, (_, index) => listOceanBookings({ page: index + 2, size: 200 })))
|
|
|
|
|
|
return [firstPage, ...remaining].flatMap((pageResult) => pageResult.records)
|
|
|
|
|
|
}
|
2026-08-10 15:36:53 +08:00
|
|
|
|
async function loadRows() {
|
|
|
|
|
|
const sequence = ++listSequence
|
|
|
|
|
|
loading.value = true; loadError.value = null
|
|
|
|
|
|
const [from, to] = applied.value.sailingRange || []
|
|
|
|
|
|
try {
|
|
|
|
|
|
const result = await listContainers({
|
|
|
|
|
|
page: page.value, size: pageSize.value, keyword: applied.value.keyword.trim() || undefined,
|
2026-08-11 11:15:44 +08:00
|
|
|
|
containerType: applied.value.containerType || undefined,
|
2026-08-10 15:36:53 +08:00
|
|
|
|
status: applied.value.status, estimatedSailingFrom: from ? `${from}T00:00:00` : undefined,
|
|
|
|
|
|
estimatedSailingTo: to ? `${to}T23:59:59` : undefined,
|
|
|
|
|
|
})
|
|
|
|
|
|
if (sequence !== listSequence) return
|
|
|
|
|
|
rows.value = result.records; total.value = result.total
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
if (sequence !== listSequence) return
|
|
|
|
|
|
rows.value = []; total.value = 0; loadError.value = getApiErrorDetails(error, '货柜列表加载失败,请稍后重试')
|
|
|
|
|
|
} finally { if (sequence === listSequence) loading.value = false }
|
|
|
|
|
|
}
|
2026-08-10 18:12:23 +08:00
|
|
|
|
function search() { applied.value = { ...filters.value, sailingRange: [...filters.value.sailingRange] }; if (page.value === 1) void loadRows(); else page.value = 1 }
|
2026-08-10 15:36:53 +08:00
|
|
|
|
async function openDetail(source: object) {
|
|
|
|
|
|
const row = source as ContainerBookingResource
|
|
|
|
|
|
detailTarget.value = row
|
|
|
|
|
|
detailOpen.value = true; detail.value = null; detailError.value = null; detailLoading.value = true
|
|
|
|
|
|
const sequence = ++detailSequence
|
|
|
|
|
|
try { const result = await getContainer(row.id); if (sequence === detailSequence) detail.value = result }
|
|
|
|
|
|
catch (error) { if (sequence === detailSequence) detailError.value = getApiErrorDetails(error, '货柜详情加载失败') }
|
|
|
|
|
|
finally { if (sequence === detailSequence) detailLoading.value = false }
|
|
|
|
|
|
}
|
|
|
|
|
|
function openCreate() { detail.value = null; editorError.value = null; replaceForm(null); editorOpen.value = true }
|
|
|
|
|
|
async function openEdit(source: object) {
|
|
|
|
|
|
const row = source as ContainerBookingResource
|
|
|
|
|
|
editorError.value = null
|
|
|
|
|
|
try { detail.value = await getContainer(row.id); replaceForm(detail.value); editorOpen.value = true }
|
|
|
|
|
|
catch (error) { ElMessage.error(getApiErrorDetails(error, '货柜详情加载失败').message) }
|
|
|
|
|
|
}
|
|
|
|
|
|
async function save() {
|
|
|
|
|
|
if (!(await formRef.value?.validate().catch(() => false))) return
|
|
|
|
|
|
saving.value = true
|
|
|
|
|
|
editorError.value = null
|
|
|
|
|
|
try {
|
|
|
|
|
|
if (!form.id) await createContainer(payload())
|
|
|
|
|
|
else if (transportOnly.value) await updateContainerTransport(form.id, form.version, { containerNo: optional(form.containerNo), voyageNo: optional(form.voyageNo) })
|
|
|
|
|
|
else await updateContainer(form.id, form.version, payload())
|
|
|
|
|
|
ElMessage.success(form.id ? '货柜已更新' : '货柜已新增'); editorOpen.value = false; await loadRows()
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
const details = getApiErrorDetails(error, '保存失败')
|
2026-08-11 11:15:44 +08:00
|
|
|
|
if (details.code === 'A0409' && form.id) {
|
|
|
|
|
|
const submitted = { ...form }
|
|
|
|
|
|
try {
|
|
|
|
|
|
const latest = await getContainer(form.id)
|
|
|
|
|
|
detail.value = latest
|
|
|
|
|
|
replaceForm(latest)
|
|
|
|
|
|
Object.assign(form, submitted, { id: latest.id, version: latest.version })
|
|
|
|
|
|
editorError.value = { ...details, message: '数据已被其他人修改,已刷新最新版本并保留本次输入,请重新确认后提交' }
|
|
|
|
|
|
ElMessage.warning(editorError.value.message)
|
|
|
|
|
|
} catch (refreshError) {
|
|
|
|
|
|
editorError.value = getApiErrorDetails(refreshError, '数据已被其他人修改,且最新数据刷新失败,请稍后重试')
|
|
|
|
|
|
ElMessage.error(editorError.value.message)
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
editorError.value = details
|
|
|
|
|
|
ElMessage.error(details.message)
|
|
|
|
|
|
}
|
2026-08-10 15:36:53 +08:00
|
|
|
|
} finally { saving.value = false }
|
|
|
|
|
|
}
|
2026-08-11 11:15:44 +08:00
|
|
|
|
function goContainerProcess(source: object) {
|
|
|
|
|
|
const row = source as ContainerBookingResource
|
|
|
|
|
|
if (row.planStatus === 'EDITING') {
|
|
|
|
|
|
void router.push({ name: 'smart-loading-workbench', params: { containerId: row.id } })
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
void router.push({
|
|
|
|
|
|
name: row.planStatus === 'LOADING' ? 'loading-plans' : 'loading-lists',
|
|
|
|
|
|
query: { planId: row.planId || undefined, warehouseId: row.warehouseId },
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2026-08-10 15:36:53 +08:00
|
|
|
|
|
2026-08-10 18:21:40 +08:00
|
|
|
|
watch([page, pageSize], ([nextPage, nextSize], [previousPage, previousSize]) => {
|
|
|
|
|
|
if (nextPage !== previousPage || nextSize !== previousSize) void loadRows()
|
|
|
|
|
|
})
|
2026-08-11 18:06:35 +08:00
|
|
|
|
onMounted(() => { void Promise.all([loadWarehouses(), loadBusinessOptions(), loadRows()]) })
|
2026-08-10 15:36:53 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<template>
|
2026-08-10 16:24:54 +08:00
|
|
|
|
<AdminPage as="div">
|
|
|
|
|
|
<section class="container-page">
|
|
|
|
|
|
<ListPageLayout ariaLabel="货柜列表">
|
|
|
|
|
|
<template #toolbar>
|
2026-08-10 18:12:23 +08:00
|
|
|
|
<QueryToolbar v-model="filters" class="surface-panel" ariaLabel="货柜筛选" :fields="queryFields" preference-key="container-loading-query" @search="search" />
|
2026-08-10 16:24:54 +08:00
|
|
|
|
</template>
|
2026-08-11 11:15:44 +08:00
|
|
|
|
<template v-if="loadError" #state>
|
|
|
|
|
|
<LoadErrorState title="货柜列表加载失败" :message="loadError.message" :loading="loading" @retry="loadRows"><template #details><ApiErrorMeta :details="loadError" /></template></LoadErrorState>
|
2026-08-10 16:24:54 +08:00
|
|
|
|
</template>
|
2026-08-11 11:15:44 +08:00
|
|
|
|
<section v-if="!loadError" class="surface-panel table-panel">
|
2026-08-10 16:24:54 +08:00
|
|
|
|
<DataTable v-model:page="page" v-model:page-size="pageSize" :data="rows" :columns="columns" :total="total" :loading="loading" preference-key="container-loading-table" empty-text="暂无货柜">
|
|
|
|
|
|
<template #toolbar-actions><el-button v-if="canCreate" type="primary" @click="openCreate"><Plus :size="16" />新增货柜</el-button></template>
|
2026-08-12 18:00:26 +08:00
|
|
|
|
<template #actions="{ row }"><div class="row-actions"><el-button v-if="canView" size="small" type="primary" plain :aria-label="containerViewLabel(row as ContainerBookingResource)" @click="openDetail(row)"><Eye :size="15" />查看</el-button><el-button v-if="canView && canEdit && row.planStatus !== 'COMPLETED'" size="small" @click="openEdit(row)"><Pencil :size="15" />{{ row.planStatus === 'LOADING' ? '录入集装箱号' : '编辑' }}</el-button><el-button v-if="row.planStatus === 'EDITING' && canSmartLoading" size="small" type="primary" @click="goContainerProcess(row)"><Sparkles :size="15" />排柜</el-button><el-button v-else-if="row.planStatus === 'LOADING' && canViewPreload" size="small" type="primary" plain @click="goContainerProcess(row)"><ListChecks :size="15" />查看预装清单</el-button><el-button v-else-if="row.planStatus === 'COMPLETED' && canViewLoadingList" size="small" type="primary" plain @click="goContainerProcess(row)"><ListChecks :size="15" />查看装柜清单</el-button></div></template>
|
2026-08-10 16:24:54 +08:00
|
|
|
|
<template #cabinet="{ row }"><strong>{{ row.cabinetNo }}</strong><small>{{ row.bookingNo }}</small></template>
|
|
|
|
|
|
<template #containerNo="{ row }">{{ row.containerNo || '待录入' }}</template>
|
|
|
|
|
|
<template #status="{ row }"><el-tag :type="row.planStatus === 'COMPLETED' ? 'success' : row.planStatus === 'LOADING' ? 'warning' : 'info'">{{ statusText(row.planStatus) }}</el-tag></template>
|
|
|
|
|
|
<template #route="{ row }">{{ row.departurePortName || row.departurePortCode || '—' }} → {{ row.destinationPortName || row.destinationPortCode || '—' }}</template>
|
|
|
|
|
|
<template #capacity="{ row }">{{ row.capacityCbm ? `${row.capacityCbm} m³` : '—' }} / {{ row.maxWeightKg ? `${row.maxWeightKg} kg` : '—' }}</template>
|
|
|
|
|
|
<template #vessel="{ row }">{{ [row.vesselName, row.voyageNo].filter(Boolean).join(' / ') || '—' }}</template>
|
|
|
|
|
|
<template #estimatedSailingAt="{ row }">{{ formatTime(row.estimatedSailingAt) }}</template>
|
|
|
|
|
|
</DataTable>
|
|
|
|
|
|
</section>
|
|
|
|
|
|
</ListPageLayout>
|
2026-08-10 15:36:53 +08:00
|
|
|
|
|
|
|
|
|
|
<AppDrawer v-model="detailOpen" title="货柜详情" size="min(760px, 94vw)" :loading="detailLoading" :show-confirm="false" cancel-text="关闭">
|
|
|
|
|
|
<LoadErrorState v-if="detailError" title="货柜详情加载失败" :message="detailError.message" @retry="detailTarget && openDetail(detailTarget)"><template #details><ApiErrorMeta :details="detailError" /></template></LoadErrorState>
|
|
|
|
|
|
<el-descriptions v-else-if="detail" :column="2" border class="details"><el-descriptions-item label="柜次号">{{ detail.cabinetNo }}</el-descriptions-item><el-descriptions-item label="集装箱号">{{ detail.containerNo || '—' }}</el-descriptions-item><el-descriptions-item label="状态">{{ statusText(detail.planStatus) }}</el-descriptions-item><el-descriptions-item label="柜型">{{ detail.containerType }}</el-descriptions-item><el-descriptions-item label="装柜仓库">{{ detail.warehouseName || '—' }}</el-descriptions-item><el-descriptions-item label="目的仓">{{ detail.destinationWarehouseName || detail.destinationWarehouseCode || '—' }}</el-descriptions-item><el-descriptions-item label="船公司">{{ detail.shippingCompanyName || '—' }}</el-descriptions-item><el-descriptions-item label="船名/航次">{{ [detail.vesselName, detail.voyageNo].filter(Boolean).join(' / ') || '—' }}</el-descriptions-item><el-descriptions-item label="提单号">{{ detail.billOfLadingNo || '—' }}</el-descriptions-item><el-descriptions-item label="拖车公司">{{ detail.terminalTruckingCompany || '—' }}</el-descriptions-item><el-descriptions-item label="预计开船">{{ formatTime(detail.estimatedSailingAt) }}</el-descriptions-item><el-descriptions-item label="预计到港">{{ formatTime(detail.estimatedPortArrivalAt) }}</el-descriptions-item></el-descriptions>
|
|
|
|
|
|
</AppDrawer>
|
|
|
|
|
|
|
2026-08-12 16:31:46 +08:00
|
|
|
|
<AppDialog v-model="editorOpen" class="container-editor-dialog" :title="editorTitle" width="min(820px, calc(100vw - 28px))" :confirm-loading="saving" :confirm-disabled="Boolean(warehouseError && !transportOnly)" confirm-text="确定" cancel-text="关闭" @confirm="save">
|
2026-08-10 15:36:53 +08:00
|
|
|
|
<LoadErrorState v-if="editorError" title="货柜保存失败" :message="editorError.message" compact :retry-text="form.id ? '刷新最新数据' : '重试保存'" @retry="form.id ? openEdit({ id: form.id }) : save()"><template #details><ApiErrorMeta :details="editorError" /></template></LoadErrorState>
|
2026-08-11 11:52:30 +08:00
|
|
|
|
<el-alert v-if="transportOnly" title="拣货中仅允许修改集装箱号和航次,其他字段已锁定。" type="warning" :closable="false" />
|
2026-08-11 11:15:44 +08:00
|
|
|
|
<LoadErrorState v-if="warehouseError && !transportOnly" title="装柜仓库加载失败" :message="warehouseError.message" compact @retry="loadWarehouses"><template #details><ApiErrorMeta :details="warehouseError" /></template></LoadErrorState>
|
2026-08-11 18:06:35 +08:00
|
|
|
|
<el-alert v-if="businessOptionsError && !transportOnly" type="warning" :closable="false" show-icon :title="businessOptionsError"><el-button link type="warning" :loading="businessOptionsLoading" @click="loadBusinessOptions">重新加载业务选项</el-button></el-alert>
|
2026-08-11 11:15:44 +08:00
|
|
|
|
<el-form v-if="!warehouseError || transportOnly" ref="formRef" :model="form" :rules="rules" label-position="top" class="form-grid">
|
2026-08-11 18:06:35 +08:00
|
|
|
|
<el-form-item label="集装箱号"><el-input v-model="form.containerNo" maxlength="64" placeholder="请输入集装箱号,开始装柜前必填" /></el-form-item>
|
2026-08-12 16:31:46 +08:00
|
|
|
|
<el-form-item label="柜号" prop="cabinetNo"><el-input v-model="form.cabinetNo" maxlength="64" placeholder="请输入柜号" :disabled="transportOnly" /></el-form-item>
|
2026-08-11 18:06:35 +08:00
|
|
|
|
<el-form-item label="装柜仓库" prop="warehouseId"><el-select v-model="form.warehouseId" filterable placeholder="请选择装柜仓库" :loading="warehouseLoading" loading-text="仓库加载中" no-data-text="暂无可用国内仓库" :disabled="transportOnly"><el-option v-for="warehouse in warehouses" :key="String(warehouse.id)" :label="`${warehouse.warehouseName}(${warehouse.warehouseCode})`" :value="String(warehouse.id)" /></el-select></el-form-item>
|
|
|
|
|
|
<el-form-item label="提单号"><el-input v-model="form.billOfLadingNo" maxlength="128" placeholder="请输入提单号(可选)" :disabled="transportOnly" /></el-form-item>
|
|
|
|
|
|
<el-form-item label="船名"><el-input v-model="form.vesselName" maxlength="128" placeholder="请输入船名" :disabled="transportOnly" /></el-form-item>
|
|
|
|
|
|
<el-form-item label="航次"><el-input v-model="form.voyageNo" maxlength="64" placeholder="请输入航次" /></el-form-item>
|
2026-08-12 16:31:46 +08:00
|
|
|
|
<el-form-item label="箱型(货柜类型)" prop="containerType"><el-select v-model="form.containerType" placeholder="请选择箱型" :disabled="transportOnly"><el-option v-for="value in ['20GP','40GP','40HQ','45HQ']" :key="value" :label="value" :value="value" /></el-select></el-form-item>
|
|
|
|
|
|
<el-form-item label="船公司"><el-select :model-value="shippingCompanyValue" filterable clearable placeholder="请选择船公司" :loading="businessOptionsLoading" loading-text="船公司加载中" no-data-text="暂无可用船公司" :disabled="transportOnly" @update:model-value="selectShippingCompany(String($event || ''))"><el-option v-if="shippingCompanyValue && !shippingCompanies.some((partner) => String(partner.id) === shippingCompanyValue)" :label="form.shippingCompanyName || '原船公司'" :value="shippingCompanyValue" /><el-option v-for="partner in shippingCompanies" :key="String(partner.id)" :label="partnerLabel(partner)" :value="String(partner.id)" /></el-select></el-form-item>
|
2026-08-11 18:06:35 +08:00
|
|
|
|
<el-form-item label="起运港"><el-select :model-value="departurePortValue" filterable clearable placeholder="请选择起运港" :loading="businessOptionsLoading" loading-text="港口加载中" no-data-text="暂无订舱港口数据" :disabled="transportOnly" @update:model-value="selectPort('departure', String($event || ''))"><el-option v-for="port in departurePorts" :key="port.value" :label="portLabel(port)" :value="port.value" /></el-select></el-form-item>
|
|
|
|
|
|
<el-form-item label="目的港"><el-select :model-value="destinationPortValue" filterable clearable placeholder="请选择目的港" :loading="businessOptionsLoading" loading-text="港口加载中" no-data-text="暂无订舱港口数据" :disabled="transportOnly" @update:model-value="selectPort('destination', String($event || ''))"><el-option v-for="port in destinationPorts" :key="port.value" :label="portLabel(port)" :value="port.value" /></el-select></el-form-item>
|
|
|
|
|
|
<el-form-item label="目的仓"><el-select :model-value="destinationWarehouseValue" filterable clearable placeholder="请选择目的仓" :loading="warehouseLoading" loading-text="目的仓加载中" no-data-text="暂无可用海外/FBA仓库" :disabled="transportOnly" @update:model-value="selectDestinationWarehouse(String($event || ''))"><el-option v-if="destinationWarehouseValue && !destinationWarehouses.some((warehouse) => warehouse.warehouseCode === destinationWarehouseValue)" :label="form.destinationWarehouseName || form.destinationWarehouseCode || '原目的仓'" :value="destinationWarehouseValue" /><el-option v-for="warehouse in destinationWarehouses" :key="String(warehouse.id)" :label="`${warehouse.warehouseName}(${warehouse.warehouseCode})`" :value="warehouse.warehouseCode" /></el-select></el-form-item>
|
2026-08-12 16:31:46 +08:00
|
|
|
|
<el-form-item label="货柜容量(m³)"><el-input-number v-model="form.capacityCbm" :min="0.001" :precision="3" controls-position="right" placeholder="请输入货柜容量" :disabled="transportOnly" /></el-form-item>
|
|
|
|
|
|
<el-form-item label="重量上限(kg)"><el-input-number v-model="form.maxWeightKg" :min="0.001" :precision="3" controls-position="right" placeholder="请输入重量上限" :disabled="transportOnly" /></el-form-item>
|
2026-08-11 18:06:35 +08:00
|
|
|
|
<el-form-item label="拖车公司"><el-select v-model="form.terminalTruckingCompany" filterable clearable allow-create default-first-option placeholder="请选择或输入拖车公司" :loading="businessOptionsLoading" loading-text="拖车公司加载中" no-data-text="暂无合作单位,可直接输入" :disabled="transportOnly"><el-option v-for="partner in truckingCompanies" :key="String(partner.id)" :label="partnerLabel(partner)" :value="partner.partnerName" /></el-select></el-form-item>
|
|
|
|
|
|
<el-form-item label="计划装柜时间"><el-date-picker v-model="form.loadingAt" type="datetime" value-format="YYYY-MM-DDTHH:mm:ss" placeholder="请选择计划装柜时间" :disabled="transportOnly" /></el-form-item>
|
|
|
|
|
|
<el-form-item label="预计开船时间"><el-date-picker v-model="form.estimatedSailingAt" type="datetime" value-format="YYYY-MM-DDTHH:mm:ss" placeholder="请选择预计开船时间" :disabled="transportOnly" /></el-form-item>
|
|
|
|
|
|
<el-form-item label="预计到港时间"><el-date-picker v-model="form.estimatedPortArrivalAt" type="datetime" value-format="YYYY-MM-DDTHH:mm:ss" placeholder="请选择预计到港时间" :disabled="transportOnly" /></el-form-item>
|
2026-08-10 15:36:53 +08:00
|
|
|
|
</el-form>
|
2026-08-12 16:31:46 +08:00
|
|
|
|
</AppDialog>
|
2026-08-10 16:24:54 +08:00
|
|
|
|
</section>
|
|
|
|
|
|
</AdminPage>
|
2026-08-10 15:36:53 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
2026-08-12 16:31:46 +08:00
|
|
|
|
.container-page { display: grid; gap: 16px; min-width: 0; }.container-page small { display: block; margin-top: 4px; color: var(--cc-muted); }.row-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }.row-actions :deep(.el-button + .el-button) { margin-left: 0; }.form-grid { display: grid; grid-template-columns: minmax(0,1fr); gap: 0; }.form-grid :deep(.el-select),.form-grid :deep(.el-date-editor),.form-grid :deep(.el-input-number) { width: 100%; }.details :deep(.el-descriptions__label) { width: 120px; }
|
|
|
|
|
|
:global(.container-editor-dialog.el-dialog) { display: flex; width: min(820px, calc(100vw - 28px)) !important; max-height: 90vh; margin-block: 5vh !important; overflow: hidden; flex-direction: column; border-radius: 12px; }
|
|
|
|
|
|
:global(.container-editor-dialog .el-dialog__header) { flex: 0 0 auto; margin: 0; padding: 20px 28px; border-bottom: 1px solid #e5eaf1; }
|
|
|
|
|
|
:global(.container-editor-dialog .el-dialog__title) { color: #1e293b; font-size: 18px; font-weight: 700; }
|
|
|
|
|
|
:global(.container-editor-dialog .el-dialog__body) { min-height: 0; padding: 28px; overflow-y: auto; }
|
|
|
|
|
|
:global(.container-editor-dialog .el-dialog__footer) { flex: 0 0 auto; padding: 16px 28px; border-top: 1px solid #e5eaf1; background: #f8fafc; }
|
|
|
|
|
|
@media(max-width:720px){:global(.container-editor-dialog.el-dialog){max-height:calc(100vh - 20px);margin-block:10px!important}:global(.container-editor-dialog .el-dialog__header),:global(.container-editor-dialog .el-dialog__body),:global(.container-editor-dialog .el-dialog__footer){padding-inline:16px}.details :deep(.el-descriptions__body table),.details :deep(tbody),.details :deep(tr),.details :deep(td){display:block;width:100%!important}.row-actions { min-width: 180px; }}
|
2026-08-10 15:36:53 +08:00
|
|
|
|
</style>
|