优化
This commit is contained in:
@@ -12,11 +12,12 @@ import ListPageLayout from '@/shared/components/ListPageLayout.vue'
|
||||
import LoadErrorState from '@/shared/components/LoadErrorState.vue'
|
||||
import OperationErrorToast from '@/shared/components/OperationErrorToast.vue'
|
||||
import QueryToolbar, { type QueryField, type QueryModel } from '@/shared/components/QueryToolbar.vue'
|
||||
import { convertLastMileOrderToInboundPlan, listLastMileOrders, transferLastMileOrders } from '../api/lastMileOrders'
|
||||
import { convertLastMileContainerToInboundPlans, listLastMileOrders, transferLastMileOrders } from '../api/lastMileOrders'
|
||||
import OrderReferenceText from '../components/OrderReferenceText.vue'
|
||||
import { useAccessPreviewStore } from '@/core/access/accessPreview'
|
||||
import { overseasWarehousePermissions as permission } from '../permissions'
|
||||
import { toLastMileOrderListItem } from '../lastMilePresentation'
|
||||
import { groupPendingOrdersByContainer, type LastMileContainerPlanRow } from '../lastMileContainerPlanning'
|
||||
import type { LastMileOrderListItem } from '../types'
|
||||
|
||||
const rows = ref<LastMileOrderListItem[]>([])
|
||||
@@ -93,6 +94,19 @@ const columns: DataTableColumn[] = [
|
||||
{ key: 'customerRemark', prop: 'customerRemark', label: '备注(客户)', minWidth: 160 },
|
||||
{ key: 'warehouseRemark', prop: 'warehouseRemark', label: '备注(仓库)', minWidth: 160 },
|
||||
]
|
||||
const containerColumns: DataTableColumn[] = [
|
||||
{ key: 'actions', label: '操作', width: 190, fixed: 'left', slotName: 'actions' },
|
||||
{ key: 'containerNo', prop: 'containerNo', label: '柜号', minWidth: 180 },
|
||||
{ key: 'orderCount', prop: 'orderCount', label: '订单数', width: 90, align: 'right' },
|
||||
{ key: 'inboundCodeCount', prop: 'inboundCodeCount', label: '入仓码数', width: 100, align: 'right' },
|
||||
{ key: 'customerCount', prop: 'customerCount', label: '客户数', width: 90, align: 'right' },
|
||||
{ key: 'totalCartons', prop: 'totalCartons', label: '总箱数', width: 100, align: 'right' },
|
||||
{ key: 'totalPallets', prop: 'totalPallets', label: '总托数', width: 100, align: 'right' },
|
||||
{ key: 'totalVolumeCbm', prop: 'totalVolumeCbm', label: '总体积(m³)', width: 120, align: 'right' },
|
||||
{ key: 'eligibility', prop: 'eligibility', label: '资格', minWidth: 160, slotName: 'eligibility' },
|
||||
{ key: 'planNotice', prop: 'planNotice', label: '生成说明', minWidth: 320 },
|
||||
]
|
||||
const containerRows = computed(() => groupPendingOrdersByContainer(rows.value))
|
||||
|
||||
async function load(model: QueryModel = filters.value) {
|
||||
Object.assign(filters.value, model)
|
||||
@@ -132,7 +146,7 @@ async function load(model: QueryModel = filters.value) {
|
||||
|
||||
function search(model: QueryModel) { page.value = 1; void load(model) }
|
||||
function reset(model: QueryModel) { page.value = 1; void load(model) }
|
||||
function changeStatusTab() { page.value = 1; void load() }
|
||||
function changeStatusTab() { selectedRows.value = []; page.value = 1; void load() }
|
||||
function onSelectionChange(selection: object[]) { selectedRows.value = selection as LastMileOrderListItem[] }
|
||||
function openTransfer() {
|
||||
if (!selectedRows.value.length) { ElMessage.warning('请至少选择 1 条尾程订单'); return }
|
||||
@@ -152,20 +166,30 @@ async function submitTransfer() {
|
||||
} catch (error) { actionError.value = getApiErrorDetails(error, '转仓失败,请重试') }
|
||||
finally { actionLoading.value = false }
|
||||
}
|
||||
async function convertInboundPlan() {
|
||||
if (selectedRows.value.length !== 1) { ElMessage.warning('生成入库计划时请选择 1 条尾程订单'); return }
|
||||
const selected = selectedRows.value[0]
|
||||
const customerId = typeof selected.customerId === 'string' ? selected.customerId.trim() : ''
|
||||
if (!customerId) {
|
||||
actionError.value = { message: '所选尾程订单缺少客户标识,无法安全生成入库计划' }
|
||||
async function generateContainerInboundPlans(row: LastMileContainerPlanRow) {
|
||||
if (!row.eligible) {
|
||||
actionError.value = { message: row.eligibility }
|
||||
return
|
||||
}
|
||||
actionLoading.value = true; actionError.value = null
|
||||
if (!row.sourceContainerBookingId) {
|
||||
actionError.value = { message: '所选整柜缺少稳定来源柜身份,无法安全生成入库计划' }
|
||||
return
|
||||
}
|
||||
actionLoading.value = true
|
||||
actionError.value = null
|
||||
try {
|
||||
await convertLastMileOrderToInboundPlan({ orderId: String(selected.id), customerId })
|
||||
selectedRows.value = []; ElMessage.success('入库计划生成成功'); await load()
|
||||
} catch (error) { actionError.value = getApiErrorDetails(error, '生成入库计划失败,请重试') }
|
||||
finally { actionLoading.value = false }
|
||||
const plans = await convertLastMileContainerToInboundPlans({ sourceContainerBookingId: row.sourceContainerBookingId })
|
||||
if (plans.length !== row.orderCount) {
|
||||
actionError.value = { message: `柜级接口返回 ${plans.length} 个计划,与所选整柜 ${row.orderCount} 个尾程订单不一致` }
|
||||
return
|
||||
}
|
||||
ElMessage.success(`已为${row.orderCount}个尾程订单生成${plans.length}个入库计划`)
|
||||
await load()
|
||||
} catch (error) {
|
||||
actionError.value = getApiErrorDetails(error, '生成整柜入库计划失败,请重试')
|
||||
} finally {
|
||||
actionLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function openDetail(source: object) {
|
||||
@@ -195,8 +219,19 @@ onMounted(() => { void load() })
|
||||
<LoadErrorState v-if="actionError" title="尾程订单操作失败" :message="actionError.message" compact>
|
||||
<template #details><ApiErrorMeta :details="actionError" /></template>
|
||||
</LoadErrorState>
|
||||
<section v-if="!loadError" class="surface-panel table-panel"><DataTable v-model:page="page" v-model:page-size="pageSize" :data="rows" :columns="columns" :loading="loading" :total="total" preference-key="overseas-last-mile-orders" row-key="id" empty-text="暂无尾程订单" @selection-change="onSelectionChange" @update:page="load()" @update:page-size="page = 1; load()">
|
||||
<template #toolbar-actions><el-button v-if="access.can(permission.lastMileOrderTransfer)" plain :disabled="!selectedRows.length || actionLoading" @click="openTransfer">转仓</el-button><el-button v-if="access.can(permission.inboundOrderCreate)" type="primary" plain :disabled="selectedRows.length !== 1 || actionLoading" @click="convertInboundPlan">生成入库计划</el-button></template>
|
||||
<section v-if="!loadError && statusTab === '待分配'" class="surface-panel table-panel container-planning-panel">
|
||||
<el-alert title="选择一行即代表整柜;一次调用将为柜内每个尾程订单/入仓码分别生成独立入库计划,海外 PDA 仍按同一柜号作业。" type="info" :closable="false" show-icon />
|
||||
<DataTable :data="containerRows" :columns="containerColumns" :loading="loading" preference-key="overseas-last-mile-container-plans" row-key="id" empty-text="暂无待分配整柜">
|
||||
<template #actions="{ row }">
|
||||
<el-tooltip content="按整柜原子生成入库计划" placement="top">
|
||||
<span><el-button v-if="access.can(permission.inboundOrderCreate)" size="small" type="primary" plain :disabled="!(row as LastMileContainerPlanRow).eligible || actionLoading" @click="generateContainerInboundPlans(row as LastMileContainerPlanRow)">生成整柜入库计划</el-button></span>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
<template #eligibility="{ row }"><el-tag :type="(row as LastMileContainerPlanRow).eligible ? 'success' : 'danger'" effect="plain">{{ (row as LastMileContainerPlanRow).eligibility }}</el-tag></template>
|
||||
</DataTable>
|
||||
</section>
|
||||
<section v-else-if="!loadError" class="surface-panel table-panel"><DataTable v-model:page="page" v-model:page-size="pageSize" :data="rows" :columns="columns" :loading="loading" :total="total" preference-key="overseas-last-mile-orders" row-key="id" empty-text="暂无尾程订单" @selection-change="onSelectionChange" @update:page="load()" @update:page-size="page = 1; load()">
|
||||
<template #toolbar-actions><el-button v-if="access.can(permission.lastMileOrderTransfer)" plain :disabled="!selectedRows.length || actionLoading" @click="openTransfer">转仓</el-button></template>
|
||||
<template #actions="{ row }"><el-button size="small" plain type="primary" @click="openDetail(row)"><Eye :size="15" />查看</el-button></template>
|
||||
<template #orderNo="{ row }"><OrderReferenceText :value="String(row.orderNo || '')" /></template>
|
||||
<template #pagination-left>共 {{ total }} 条尾程订单 · 已选 {{ selectedRows.length }} 条</template>
|
||||
@@ -215,4 +250,5 @@ onMounted(() => { void load() })
|
||||
<style scoped>
|
||||
.last-mile-toolbar { padding: 14px 16px 0; }
|
||||
.last-mile-toolbar :deep(.query-toolbar) { margin-top: 12px; padding: 12px 0 16px; border: 0; border-top: 1px solid var(--cc-border); border-radius: 0; }
|
||||
.container-planning-panel > :deep(.el-alert) { margin-bottom: 12px; }
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user