优化
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import AppDialog from '@/shared/components/AppDialog.vue'
|
||||
import DataTable, { type DataTableColumn } from '@/shared/components/DataTable.vue'
|
||||
import LoadErrorState from '@/shared/components/LoadErrorState.vue'
|
||||
import ApiErrorMeta from '@/shared/components/ApiErrorMeta.vue'
|
||||
import { getApiErrorDetails, type ApiErrorDetails } from '@/shared/api/http'
|
||||
import { getDispatch, listLooseboardCargo, addLooseboardCargo, expandSelectionGroups, type Candidate, type DispatchDetail } from '@/modules/overseas-warehouse'
|
||||
const open=defineModel<boolean>({default:false})
|
||||
const props=defineProps<{dispatchNo:string}>()
|
||||
const emit=defineEmits<{saved:[]}>()
|
||||
const rows=ref<Candidate[]>([]), selected=ref<Candidate[]>([]), detail=ref<DispatchDetail|null>(null)
|
||||
const page=ref(1), size=ref(20), total=ref(0), loading=ref(false), saving=ref(false), error=ref<ApiErrorDetails|null>(null)
|
||||
const columns:DataTableColumn[]=[
|
||||
{key:'selection',type:'selection',width:45}, {key:'orderNo',label:'订单号',minWidth:180},
|
||||
{key:'customerName',label:'客户',minWidth:140}, {key:'inboundCode',label:'入仓号',minWidth:150},
|
||||
{key:'sourceStage',label:'货物阶段',width:110,formatter:(row:Candidate)=>!row.selection.warehousePalletId ? '申报待到仓' : '已实收'}, {key:'palletNo',label:'计划 / 实物托盘',minWidth:150}, {key:'destination',label:'目的地',minWidth:180,formatter:(row:Candidate)=>row.destination.warehouseCode || row.destination.address || '—'},
|
||||
{key:'availablePackages',label:'计划 / 可用箱数',width:100},
|
||||
{key:'blockReasons',label:'资格',minWidth:200,formatter:(row:Candidate)=>row.blockReasons.length?row.blockReasons.join(';'):'可添加'},
|
||||
]
|
||||
let generation=0
|
||||
async function load() {
|
||||
const current=++generation;loading.value=true;error.value=null;selected.value=[];rows.value=[];detail.value=null
|
||||
try {
|
||||
const [dispatch,value]=await Promise.all([getDispatch(props.dispatchNo),listLooseboardCargo(props.dispatchNo,page.value,size.value)])
|
||||
if(current!==generation)return
|
||||
if(dispatch.dispatchNo!==props.dispatchNo)throw new Error('排车身份不一致,请重新打开')
|
||||
detail.value=dispatch;rows.value=value.candidates;total.value=value.total
|
||||
}catch(cause){if(current===generation)error.value=getApiErrorDetails(cause,'散板货物读取失败')}
|
||||
finally{if(current===generation)loading.value=false}
|
||||
}
|
||||
async function submit(){
|
||||
if(!detail.value || saving.value || !selected.value.length)return
|
||||
saving.value=true;error.value=null
|
||||
try{
|
||||
if(selected.value.some(row=>row.blockReasons.length))throw new Error('所选货物存在阻断,请重新选择')
|
||||
const cargo=expandSelectionGroups(selected.value)
|
||||
// 完整组来源版本由后端复核;预约批次继续通过原排车预约工作台绑定。
|
||||
await addLooseboardCargo(props.dispatchNo,{recordVersion:detail.value.recordVersion,idempotencyKey:crypto.randomUUID(),cargo,batchAllocations:[]})
|
||||
ElMessage.success('散板货物已加入排车,请按当前货物重新审核');open.value=false;emit('saved')
|
||||
}catch(cause){await load();error.value=getApiErrorDetails(cause,'添加货物失败')}
|
||||
finally{saving.value=false}
|
||||
}
|
||||
watch(open,value=>{if(value){page.value=1;void load()}else generation++})
|
||||
watch([page,size],()=>{if(open.value)void load()})
|
||||
</script>
|
||||
<template><AppDialog v-model="open" title="添加散板货物" width="1180px" class="admin-density-dialog admin-workbench" :confirm-loading="saving" :confirm-disabled="loading || !selected.length || !detail?.actions.ADD_CARGO?.allowed" lock-while-submitting @confirm="submit">
|
||||
<LoadErrorState v-if="error" title="添加货物暂未完成" :message="error.message" @retry="load"><template #details><ApiErrorMeta :details="error" /></template></LoadErrorState>
|
||||
<el-alert v-if="detail && !detail.actions.ADD_CARGO?.allowed" :title="detail.actions.ADD_CARGO?.blockReason || '当前排车不可加货,请先退回审核或重新排车'" type="warning" :closable="false" />
|
||||
<el-alert title="申报货物可先加入排车;实际到仓后核对货量,完成实收后才能出库拣货。上门取货的凭证在对应取货排车节点上传。" type="info" :closable="false" />
|
||||
<DataTable v-model:page="page" v-model:page-size="size" :data="rows" :columns="columns" :total="total" :loading="loading" row-key="sourceKey" :page-sizes="[10,20,50]" empty-text="暂无可添加的已审核散板货物" @selection-change="selected=$event" />
|
||||
</AppDialog></template>
|
||||
@@ -2,6 +2,10 @@
|
||||
import '@/styles/adminWorkbench.css'
|
||||
import '@/styles/adminDensity.css'
|
||||
import { onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||
import { useAccessPreviewStore } from '@/core/access/accessPreview'
|
||||
import LooseboardCargoDialog from '../components/LooseboardCargoDialog.vue'
|
||||
const access=useAccessPreviewStore(), cargoOpen=ref(false), cargoDispatchNo=ref('')
|
||||
function addCargo(row:DispatchCapacityDemand){cargoDispatchNo.value=row.dispatchNo;cargoOpen.value=true}
|
||||
import AdminPage from '@/shared/components/AdminPage.vue'
|
||||
import ListPageLayout from '@/shared/components/ListPageLayout.vue'
|
||||
import DataTable, { type DataTableColumn } from '@/shared/components/DataTable.vue'
|
||||
@@ -16,6 +20,7 @@ const filters = ref<QueryModel>({ origin: '', destination: '' }), applied = ref(
|
||||
const fields: QueryField[] = [{ key: 'origin', label: '起运仓', type: 'input', placeholder: '起运仓名称', width: 190 }, { key: 'destination', label: '目的地', type: 'input', placeholder: '目的地名称', width: 190 }]
|
||||
const amount = (value: number | null | undefined) => value == null ? '—' : String(value)
|
||||
const columns: DataTableColumn[] = [
|
||||
{key:'actions',label:'操作',width:120,fixed:'left',slotName:'actions'},
|
||||
{ key: 'dispatchNo', label: '排车单号', minWidth: 200 },
|
||||
{ key: 'capacityReason', label: '余位状态', minWidth: 220, formatter: (row: DispatchCapacityDemand) => row.capacityKnown ? '余位已确认' : row.capacityReason || '余位待确认', afterColumn: 'dispatchNo' }, { key: 'warehouseName', label: '起运仓', minWidth: 160 },
|
||||
{ key: 'route', label: '路线', minWidth: 240, formatter: (row: DispatchCapacityDemand) => row.route || '—' },
|
||||
@@ -39,8 +44,10 @@ function search() { applied.value = { ...filters.value }; if (page.value === 1)
|
||||
watch([page, size], load); onMounted(load); onBeforeUnmount(() => { sequence++ })
|
||||
</script>
|
||||
<template><AdminPage class="admin-density admin-workbench"><ListPageLayout aria-label="散板需求"><div class="workbench-table is-page-surface">
|
||||
<LooseboardCargoDialog v-model="cargoOpen" :dispatch-no="cargoDispatchNo" @saved="load" />
|
||||
<DataTable appearance="integrated" preference-key="dispatch-capacity-demands" column-settings-mode="show" :results-visible="!error" v-model:page="page" v-model:page-size="size" :columns="columns" :data="rows" :total="total" :loading="loading" row-key="dispatchNo" empty-text="暂无已发布的散板需求">
|
||||
<template #toolbar-start><h1>散板需求</h1></template>
|
||||
<template #actions="{row}"><el-button v-if="(access.can('platform:fleet:capacity-offer:cargo-add') || access.can('platform:fleet:capacity-offer:manage')) && access.can('platform:overseas-warehouse:dispatch:edit') && access.can('platform:overseas-warehouse:dispatch:list')" link type="primary" @click="addCargo(row as DispatchCapacityDemand)">添加货物</el-button><span v-else>—</span></template>
|
||||
<template #filters><QueryToolbar v-model="filters" :fields="fields" ariaLabel="散板需求查询" :loading="loading" @search="search" /></template>
|
||||
<template #notices><LoadErrorState v-if="error" title="散板需求读取失败" :message="error.message" @retry="load"><template #details><ApiErrorMeta :details="error" /></template></LoadErrorState></template>
|
||||
<template #pagination-left>共 {{ total }} 条散板需求</template>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
export const overseasMasterDataPermissions = {
|
||||
capacityOfferList: 'platform:fleet:capacity-offer:list',
|
||||
capacityOfferManage: 'platform:fleet:capacity-offer:manage',
|
||||
capacityCargoAdd: 'platform:fleet:capacity-offer:cargo-add',
|
||||
capacityInquiryCreate: 'platform:fleet:capacity-offer:inquiry-create',
|
||||
capacityInquiryEdit: 'platform:fleet:capacity-offer:inquiry-edit',
|
||||
capacityInquiryCancel: 'platform:fleet:capacity-offer:inquiry-cancel',
|
||||
@@ -62,4 +63,3 @@ export const overseasMasterDataPermissions = {
|
||||
vehicleRecordUpload: 'platform:overseas-master-data:vehicle:record-upload',
|
||||
vehicleRecordFinanceSubmit: 'platform:overseas-master-data:vehicle:record-finance-submit',
|
||||
} as const
|
||||
|
||||
|
||||
Reference in New Issue
Block a user