fix(client): keep delivery filters and latest query result consistent

This commit is contained in:
2026-10-02 10:58:00 +08:00
parent d19b1b2f8c
commit 162e9a2336
2 changed files with 108 additions and 3 deletions
@@ -19,6 +19,20 @@ const page = ref(1)
const pageSize = ref(20)
const filters = reactive({ documentNo: '', dispatchNo: '', waybillNo: '', status: '', deliveryMethod: '', plannedRange: [] as string[] })
const canCreate = computed(() => auth.hasPermission('merchant:warehouse:delivery:create'))
let requestSequence = 0
const deliveryMethodOptions = [
{ value: 'FBA_PICKUP', label: 'FBA 自提' },
{ value: 'CUSTOMER_PICKUP', label: '客户自提' },
{ value: 'TRUCK_PALLET', label: '卡派打托' },
{ value: 'TRUCK_FLOOR', label: '卡派地板' },
{ value: 'EXPRESS', label: '快递' },
{ value: 'OUTSOURCED', label: '外配' },
{ value: 'DEDICATED_TRUCK', label: '专车直送' },
{ value: 'LTL', label: '零担派送' },
{ value: 'TRUCK', label: '卡车派送' },
]
const deliveryMethodLabels: Record<string, string> = Object.fromEntries(deliveryMethodOptions.map(item => [item.value, item.label]))
const statusOptions = [
{ value: 'WAIT_DELIVERY', label: '待派送' },
@@ -37,14 +51,14 @@ const queryFields: QueryField[] = [
{ key: 'dispatchNo', label: '排车单号', type: 'input', placeholder: '请输入排车单号' },
{ key: 'waybillNo', label: '运单号', type: 'input', placeholder: '请输入运单号' },
{ key: 'status', label: '派送状态', type: 'select', options: statusOptions },
{ key: 'deliveryMethod', label: '派送方式', type: 'select', options: [{ label: '卡车派送', value: 'TRUCK' }, { label: '快递派送', value: 'COURIER' }, { label: '客户自提', value: 'SELF_PICKUP' }] },
{ key: 'deliveryMethod', label: '派送方式', type: 'select', options: deliveryMethodOptions },
{ key: 'plannedRange', label: '计划时间', type: 'daterange' },
]
const tableColumns: DataTableColumn[] = [
{ key: 'actions', label: '操作', slotName: 'actions', width: 90, fixed: 'left' }, { prop: 'deliveryNo', label: '派送单号', minWidth: 180 },
{ prop: 'dispatchNo', label: '排车单号', minWidth: 170 }, { prop: 'outboundNo', label: '出库单号', minWidth: 170 },
{ key: 'status', label: '状态', slotName: 'status', width: 110 }, { prop: 'overseasWarehouseName', label: '海外仓', minWidth: 160 },
{ prop: 'deliveryMethod', label: '派送方式', width: 120 }, { prop: 'waybillNo', label: '运单号', minWidth: 150 },
{ prop: 'deliveryMethod', label: '派送方式', width: 120, formatter: (_row: object, _column: unknown, value: string | null | undefined) => value ? deliveryMethodLabels[value] ?? value : '—' }, { prop: 'waybillNo', label: '运单号', minWidth: 150 },
{ prop: 'carrierName', label: '承运商', minWidth: 140 }, { key: 'planned', label: '计划派送', slotName: 'planned', width: 160 },
{ key: 'arrival', label: '预计到达', slotName: 'arrival', width: 160 }, { key: 'createdAt', label: '创建时间', slotName: 'createdAt', width: 160 },
]
@@ -84,18 +98,21 @@ function buildQuery(): DeliveryQuery {
}
async function loadOrders() {
const sequence = ++requestSequence
loading.value = true
errorMessage.value = ''
try {
const result = await listDeliveryOrders(buildQuery())
if (sequence !== requestSequence) return
records.value = result.records
total.value = result.total
} catch (error) {
if (sequence !== requestSequence) return
records.value = []
total.value = 0
errorMessage.value = error instanceof Error ? error.message : '派送单加载失败,请重试'
} finally {
loading.value = false
if (sequence === requestSequence) loading.value = false
}
}