WEB/src/views/order/orderManagement/deliveryOrder.vue
2026-10-22 18:00:49 +08:00

1001 lines
32 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="order-sub-container">
<scan-box
ref="scanBox"
cache-key="orderManagement:deliveryOrder"
width="220px"
:tree-props="{ children: 'children', label: 'label' }"
:auto-submit="false"
:preset-tree="presetTree"
:available-fields="availableFieldsRef"
@condition-change="handleConditionChange"
@reset="handleConditionReset"
@condition-clear="handleConditionClear"
/>
<div class="main-content">
<div class="toolbar">
<div class="toolbar-left">
<order-toolbar-button-group
:buttons="toolbarButtons"
:resolve-disabled="resolveButtonDisabled"
:resolve-loading="resolveButtonLoading"
:resolve-label="resolveButtonLabel"
:layout-key="toolbarLayoutKey"
@action="handleToolbarButtonClick"
/>
</div>
<!-- 已迁移至 ScanBox:搜索订单号 -->
<!-- <div class="toolbar-right">
<el-input
size="small"
placeholder="搜索配送单号"
v-model="quickSearch"
style="width:220px"
@keyup.enter.native="onQuickSearch"
/>
</div> -->
</div>
<div class="split-stack" ref="splitStackRef">
<div class="upper-wrapper" :style="detailVisible ? upperPaneStyle : upperPaneFullStyle">
<upper-table
ref="upperTable"
title="配送订单列表"
default-align="center"
:enable-column-config="true"
table-id="order-management-delivery-order"
:data="list"
:columns="columns"
:table-size="tableSize"
:pagination="pagination"
:show-index="true"
:show-actions="true"
:show-selection="true"
:loading="loading"
:queryTime="queryTime"
@current-change="handleRowClick"
@page-change="handlePageChange"
@page-size-change="handlePageSizeChange"
@refresh="loadData"
@selection-change="onSelectionChange"
>
<template #column-is_urgency="{ row }">
<span :class="getStatusTextClass(getTagType('is_urgency', row.is_urgency))">
{{ translateOrderField('is_urgency', row.is_urgency) }}
</span>
</template>
<template #column-post_status="{ row }">
<span :class="getStatusTextClass(getTagType('post_status', row.post_status))">
{{ translateOrderField('post_status', row.post_status) }}
</span>
</template>
<template #column-storage_status="{ row }">
<span :class="getStatusTextClass(getTagType('storage_status', row.storage_status))">
{{ translateOrderField('storage_status', row.storage_status) }}
</span>
</template>
<template #column-print_status="{ row }">
<span :class="getStatusTextClass(getTagType('print_status', row.print_status))">
{{ translateOrderField('print_status', row.print_status) }}
</span>
</template>
<template #column-confirm_print_status="{ row }">
<span :class="getStatusTextClass(getTagType('confirm_print_status', row.confirm_print_status))">
{{ translateOrderField('confirm_print_status', row.confirm_print_status) }}
</span>
</template>
<template #column-pick_status="{ row }">
<span :class="getStatusTextClass(getTagType('pick_status', row.pick_status))">
{{ translateOrderField('pick_status', row.pick_status) }}
</span>
</template>
<template #column-pack_status="{ row }">
<span :class="getStatusTextClass(getTagType('pack_status', row.pack_status))">
{{ translateOrderField('pack_status', row.pack_status) }}
</span>
</template>
<template #column-sync_status="{ row }">
<span :class="getStatusTextClass(getTagType('sync_status', row.sync_status))">
{{ translateOrderField('sync_status', row.sync_status) }}
</span>
</template>
<template #column-outbound_status="{ row }">
<span :class="getStatusTextClass(getTagType('outbound_status', row.outbound_status))">
{{ translateOrderField('outbound_status', row.outbound_status) }}
</span>
</template>
<template #column-inspection_status="{ row }">
<span :class="getStatusTextClass(getTagType('inspection_status', row.inspection_status))">
{{ translateOrderField('inspection_status', row.inspection_status) }}
</span>
</template>
<template #column-recheck_status="{ row }">
<span :class="getStatusTextClass(getTagType('recheck_status', resolveOrderRecheckStatus(row)))">
{{ translateOrderField('recheck_status', resolveOrderRecheckStatus(row)) }}
</span>
</template>
<template #column-claim_status="{ row }">
<span :class="getStatusTextClass(getTagType('claim_status', row.claim_status))">
{{ translateOrderField('claim_status', row.claim_status) }}
</span>
</template>
<template #column-lock_status="{ row }">
<span :class="getStatusTextClass(getTagType('lock_status', row.lock_status))">
{{ translateOrderField('lock_status', row.lock_status) }}
</span>
</template>
<template #column-invoice_flag="{ row }">
<span :class="getStatusTextClass(getTagType('invoice_flag', row.invoice_flag))">
{{ translateOrderField('invoice_flag', row.invoice_flag) }}
</span>
</template>
<template #column-intercept_status="{ row }">
<span v-if="row.intercept_status && row.intercept_status !== 'none'" class="ut-status-text ut-status-text--danger">
{{ translateInterceptStatus(row.intercept_status) }}
</span>
<span v-else style="color:#909399">—</span>
</template>
<template #empty>
<div class="empty-tip">暂无配送订单</div>
</template>
</upper-table>
</div>
<template v-if="detailVisible">
<div class="pane-resizer" title="拖动调整列表与详情区域高度" @mousedown="beginSplitDrag" />
<div class="lower-level" v-if="selectedOrderId" :class="tableSize" :style="lowerPaneStyle">
<div class="detail-header">
<el-tabs v-model="activeTab" class="detail-tab">
<el-tab-pane label="订单明细" name="detail" />
<el-tab-pane label="商品明细" name="items" />
<el-tab-pane label="快递信息" name="express" />
<el-tab-pane label="订单日志" name="logs" />
</el-tabs>
<div v-if="activeTab === 'detail' || activeTab === 'items'" class="detail-header-actions">
<order-detail-display-toggle v-model="detailDisplayMode" />
</div>
</div>
<div class="detail-container">
<div v-if="activeTab === 'detail'" :key="`detail-${selectedOrderId}`" class="detail-page order-detail-wrapper">
<pending-order-detail-panel
:key="selectedOrderId"
:row="selectedRow"
:detail-request="fetchDeliveryOrderDetail"
:display-mode="detailDisplayMode"
/>
</div>
<div v-else-if="activeTab === 'items'" :key="`items-${selectedOrderId}`" class="detail-page order-detail-wrapper">
<order-items-detail-panel :key="selectedOrderId" :row="selectedRow" :detail-request="fetchDeliveryOrderDetail" :display-mode="detailDisplayMode" />
</div>
<div v-else-if="activeTab === 'express'" :key="`express-${selectedOrderId}`" class="detail-page">
<express-waybill-panel :key="selectedOrderId" :row="selectedRow" table-type="dispatch" @data-changed="loadData" />
</div>
<div v-else :key="`logs-${selectedOrderId}`" class="detail-page order-log-wrapper">
<log :key="selectedOrderId" :data="selectedRow" />
</div>
</div>
</div>
<div class="no-selection" v-else :style="lowerPaneStyle">
<div class="empty-tip">
<p>请从上方列表中选择一项查看详情</p>
</div>
</div>
</template>
</div>
</div>
<wave-platform-print-preview-dialog
v-model="batchPrintDialogVisible"
:error-message="batchPrintErrorMessage"
:payload="batchPrintPayload"
:request-meta="batchPrintRequestMeta"
@refresh="handleBatchPrintRefresh"
@print-success="onBatchPrintSuccess"
/>
<wave-platform-print-preview-dialog
v-model="subWaybillPrintDialogVisible"
:error-message="subWaybillPrintErrorMessage"
:payload="subWaybillPrintPayload"
:request-meta="subWaybillPrintRequestMeta"
@refresh="handleSubWaybillPrintRefresh"
@print-success="onSubWaybillPrintSuccess"
/>
<!-- 子单号打印:选择运单号 -->
<el-dialog
v-model="subWaybillSelectDialogVisible"
class="select-waybill-dialog"
width="min(680px, 92vw)"
align-center
append-to-body
:show-close="false"
:close-on-click-modal="false"
>
<!-- 面板结构对齐「手工录入运单号」(TaskProgressPanel) -->
<div class="task-panel">
<header class="task-panel__head">
<div class="task-panel__titles">
<h2>选择运单号打印</h2>
<p>勾选需要打印的运单号</p>
</div>
<button class="task-panel__close" type="button" aria-label="关闭" @click="closeSubWaybillSelectDialog">
<svg viewBox="0 0 12 12" fill="none">
<path d="M1 1L11 11M11 1L1 11" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" />
</svg>
</button>
</header>
<div class="task-panel__body">
<p
v-if="subWaybillSelectErrorMessage"
class="task-panel__form-tip task-panel__form-tip--error"
>
{{ subWaybillSelectErrorMessage }}
</p>
<div class="task-panel__form">
<div class="task-panel__field">
<span class="task-panel__field-label">已选运单</span>
<strong class="task-panel__field-value">{{ subWaybillSelectedWaybills.length }} 个</strong>
</div>
<div class="task-panel__section">
<span class="task-panel__section-title">运单号列表</span>
<div class="task-panel__table-wrap">
<el-table
v-loading="subWaybillSelectLoading"
:data="subWaybillOptions"
border
size="small"
max-height="240"
empty-text="无"
@selection-change="onSubWaybillSelectChange"
>
<el-table-column type="selection" width="48" />
<el-table-column prop="waybill_code" label="运单号" min-width="190" show-overflow-tooltip />
<el-table-column label="类型" width="80" align="center">
<template #default="{ row }">
<el-tag :type="row.is_main ? 'info' : 'success'" size="small">
{{ row.is_main ? '主单' : '子单' }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="logistics_name" label="物流公司" min-width="130" show-overflow-tooltip />
</el-table>
</div>
</div>
</div>
<p class="task-panel__form-tip">
仅打印已勾选的运单号,主单与子单可分别选择。
</p>
</div>
<footer class="task-panel__foot">
<span class="task-panel__hint">未勾选运单号时无法打印</span>
<div class="task-panel__actions">
<el-button size="small" @click="closeSubWaybillSelectDialog">取消</el-button>
<el-button
size="small"
type="primary"
:loading="subWaybillPrintLoading"
@click="confirmSubWaybillPrint"
>
打印所选运单
</el-button>
</div>
</footer>
</div>
</el-dialog>
<allocate-sub-order-number-form
v-model="allocateSubOrderNumberDialogVisible"
v-model:sub-order-count="allocateSubOrderNumberCount"
:loading="allocateSubOrderNumberLoading"
:order-id="allocateSubOrderNumberOrderId"
:order-code="allocateSubOrderNumberOrderCode"
@closed="resetAllocateSubOrderNumberDialog"
@submit="submitAllocateSubOrderNumber"
/>
<!-- 配送订单批量转退回拆包单(returnUnpack.transferByOrders):入参取勾选行 id -->
<transfer-by-orders-dialog
v-model:visible="transferByOrdersVisible"
:rows="transferByOrderRows"
@success="handleTransferByOrdersSuccess"
/>
<order-export-columns-dialog
v-model:visible="exportColumnsDialogVisible"
:mode="exportColumnsMode"
:loading="exportColumnsLoading"
:storage-key="exportColumnsStorageKey"
:scope="exportColumnsScope"
@confirm="confirmExportColumns"
/>
<order-export-progress-dialog
v-model:visible="exportDialogVisible"
:loading="exportLoading"
:progress-percent="exportProgressPercent"
:progress-status="exportProgressStatus"
:status-label="exportStatusLabel"
:task-id="exportTaskProgress.taskId"
:message="exportTaskProgress.message"
:error="exportTaskProgress.error"
:meta="exportTaskProgress"
/>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted, computed } from 'vue'
import { ElMessage } from 'element-plus'
import ScanBox from '@/components/ScanBox/index.vue'
import UpperTable from '@/components/UpperTable/index.vue'
import * as indexApi from '@/api/index/index'
import { orderDeliveryOrder } from '@/api/order.deliveryorder/orderdeliveryOrder'
import { orderPendingOrder } from '@/api/order.pendingorder/orderpendingOrder'
import {
deliveryAvailableFields,
deliveryColumns,
deliveryOrderToolbarButtons,
type ToolbarButtonConfig,
translateOrderField,
translateInterceptStatus,
getTagType,
getStatusTextClass,
fillExpressCompanyScanFieldOptions,
fillStoreScanFieldOptions,
extractStoreListFromResponse
} from './config/order-common-config'
import PendingOrderDetailPanel from './component/PendingOrderDetailPanel.vue'
import OrderItemsDetailPanel from './component/OrderItemsDetailPanel.vue'
import OrderDetailDisplayToggle, { type OrderDetailDisplayMode } from './component/OrderDetailDisplayToggle.vue'
import ExpressWaybillPanel from './component/ExpressWaybillPanel.vue'
import log from './component/log.vue'
import OrderExportProgressDialog from './component/OrderExportProgressDialog.vue'
import OrderExportColumnsDialog from './component/OrderExportColumnsDialog.vue'
import WavePlatformPrintPreviewDialog from '@/views/order/waveOrder/component/WavePlatformPrintPreviewDialog.vue'
import { createOrderPageExport } from './utils/order-page-export'
import { buildOrderWhereConditions, parseOrderListResponse, resolveOrderRecheckStatus } from './utils/order-index-helpers'
import { useOrderListPageCleanup } from './utils/use-order-list-page-cleanup'
import { useOrderBatchPrint } from './utils/use-order-batch-print'
import { useDeliveryOrderSubWaybillPrint } from './utils/use-delivery-sub-waybill-print'
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
import OrderToolbarButtonGroup from './component/OrderToolbarButtonGroup.vue'
import AllocateSubOrderNumberForm from './form/AllocateSubOrderNumberForm.vue'
import TransferByOrdersDialog from './component/TransferByOrdersDialog.vue'
import { createSimpleListToolbarController } from './utils/toolbar-actions'
import { safeInvoke } from '@/utils/safe-invoke'
const scanBox = ref<any>(null)
const upperTable = ref<any>(null)
const presetTree = ref<any[]>([])
const availableFieldsRef = reactive(JSON.parse(JSON.stringify(deliveryAvailableFields)))
const activeTab = ref('detail')
const detailDisplayMode = ref<OrderDetailDisplayMode>('compact')
const list = ref<any[]>([])
const loading = ref(false)
const queryTime = ref(0)
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
const tableSize = ref('small')
const columns = ref([...deliveryColumns])
const selectionRows = ref<any[]>([])
const selectedOrderId = ref<number | string | null>(null)
const detailVisible = ref(true)
const toolbarButtons = deliveryOrderToolbarButtons
const selectedRow = computed(() => {
return list.value.find((i: any) => i.id === selectedOrderId.value) || null
})
/** order.deliveryOrder.list:where 禁止传入 warehouse_id / warehouseId */
function sanitizeDeliveryListWhere(where: Record<string, any>) {
const w = { ...where }
delete w.warehouse_id
delete w.warehouseId
return w
}
/** order.deliveryOrder.detail:配送 dispatch 模型 */
function fetchDeliveryOrderDetail(data: Record<string, any>) {
return orderDeliveryOrder.detail({
...data,
tableType: 'dispatch'
})
}
const { splitStackRef, beginSplitDrag, lowerPaneStyle, upperPaneStyle } = useVerticalSplitPane({
defaultLowerPercent: 38
})
const upperPaneFullStyle = computed(() => ({
flex: '1 1 auto',
minHeight: '0',
overflow: 'hidden'
}))
function toggleDetailVisible() {
detailVisible.value = !detailVisible.value
}
onMounted(() => {
loadData()
loadOrderMetaOptions()
})
const {
batchPrintDialogVisible,
batchPrintLoading,
batchPrintErrorMessage,
batchPrintPayload,
batchPrintRequestMeta,
resetBatchPrintState,
handleBatchPrint,
handleBatchPrintRefresh,
onBatchPrintSuccess
} = useOrderBatchPrint({
getSelectionRows: () => selectionRows.value,
onPrintSuccess: () => loadData(),
emptySelectionMessage: '请先勾选需要批量打印的订单'
})
const {
dialogVisible: subWaybillPrintDialogVisible,
loading: subWaybillPrintLoading,
errorMessage: subWaybillPrintErrorMessage,
payload: subWaybillPrintPayload,
requestMeta: subWaybillPrintRequestMeta,
resetState: resetSubWaybillPrintState,
handlePrint: handleSubWaybillPrint,
handleRefresh: handleSubWaybillPrintRefresh,
onPrintSuccess: onSubWaybillPrintSuccess,
selectDialogVisible: subWaybillSelectDialogVisible,
selectLoading: subWaybillSelectLoading,
waybillOptions: subWaybillOptions,
selectedWaybills: subWaybillSelectedWaybills,
selectErrorMessage: subWaybillSelectErrorMessage,
onSelectChange: onSubWaybillSelectChange,
confirmPrintWaybills: confirmSubWaybillPrint,
closeSelectDialog: closeSubWaybillSelectDialog
} = useDeliveryOrderSubWaybillPrint({
getSelectionRows: () => selectionRows.value,
onPrintSuccess: () => loadData(),
emptySelectionMessage: '请先勾选需要打印子单号的订单'
})
useOrderListPageCleanup({
list,
selectionRows,
selectedOrderId,
onCleanup: () => {
resetBatchPrintState()
resetSubWaybillPrintState()
}
})
function normalizeOptionValue(value: unknown) {
return String(value ?? '').trim()
}
function mapNameOptions(rawList: any[], nameKeys: string[]) {
const result: Array<{ label: string; value: string }> = []
const seen = new Set<string>()
for (const item of rawList || []) {
const name = normalizeOptionValue(nameKeys.map((k) => item?.[k]).find((v) => v !== undefined && v !== null && v !== ''))
if (!name || seen.has(name)) continue
result.push({ label: name, value: name })
seen.add(name)
}
return result
}
async function loadOrderMetaOptions() {
try {
const [expressRes, platformRes, storesRes] = await Promise.all([
indexApi.getExpressList({ systemOnly: 'true' }),
indexApi.getPlatformList({ systemOnly: 'true' }),
indexApi.loadStores()
])
const expressData: any = expressRes?.data
const platformData: any = platformRes?.data
const expressRaw = expressData?.list || expressData || []
const platformRaw = platformData?.list || platformData || []
const logisticsField = availableFieldsRef.find((i: any) => i.value === 'logistics_name')
if (logisticsField) logisticsField.options = mapNameOptions(expressRaw, ['name', 'logistics_name', 'express_name'])
fillExpressCompanyScanFieldOptions(availableFieldsRef, expressRaw)
fillStoreScanFieldOptions(availableFieldsRef, extractStoreListFromResponse(storesRes))
const platformField = availableFieldsRef.find((i: any) => i.value === 'sys_platform_name')
if (platformField) platformField.options = mapNameOptions(platformRaw, ['name', 'platform_name'])
} catch {
const logisticsField = availableFieldsRef.find((i: any) => i.value === 'logistics_name')
if (logisticsField) logisticsField.options = []
fillExpressCompanyScanFieldOptions(availableFieldsRef, [])
fillStoreScanFieldOptions(availableFieldsRef, [])
const platformField = availableFieldsRef.find((i: any) => i.value === 'sys_platform_name')
if (platformField) platformField.options = []
}
}
async function loadData() {
if (loading.value) return
loading.value = true
const start = Date.now()
try {
const params = {
pagination: {
page: pagination.currentPage,
pageSize: pagination.pageSize
},
where: buildWhere(),
sort: {
sortField: 'updated_at',
sortOrder: 'DESC' as const
}
}
const res: any = await orderDeliveryOrder.list(params)
if (res && (res.code === 200 || res.code === 1)) {
const data = parseOrderListResponse(res)
list.value = data.list
pagination.total = data.total
} else {
list.value = []
pagination.total = 0
}
} catch (e) {
list.value = []
pagination.total = 0
ElMessage.error('获取配送订单列表失败')
} finally {
loading.value = false
queryTime.value = Date.now() - start
}
}
function buildWhere() {
const where = buildOrderWhereConditions(scanBox.value?.getConditions?.() || {})
return sanitizeDeliveryListWhere(where)
}
const pageExport = createOrderPageExport({
scopeKey: 'deliveryOrder',
buildWhere,
buildSort: () => ({
sortField: 'updated_at',
sortOrder: 'DESC'
}),
selectionRows,
columns,
fileNamePrefix: '配送订单',
storageKey: 'orderManagement:deliveryOrder:exportTaskId'
})
const {
exportLoading,
exportSelectionLoading,
exportDialogVisible,
exportTaskProgress,
exportProgressPercent,
exportProgressStatus,
exportStatusLabel,
handleExport,
handleExportWaybill,
handleExportItem,
handleExportSelection,
handleExportSelectionWaybill,
handleExportSelectionItem,
exportColumnsDialogVisible,
exportColumnsMode,
exportColumnsLoading,
exportColumnsStorageKey,
exportColumnsScope,
confirmExportColumns
} = pageExport
function handleConditionChange() {
pagination.currentPage = 1
loadData()
}
function handleConditionClear() {
pagination.currentPage = 1
loadData()
}
function handleConditionReset() {
pagination.currentPage = 1
scanBox.value?.reset?.()
loadData()
}
function onSelectionChange(rows: any[]) {
selectionRows.value = rows || []
}
function handleRowClick(row: any) {
selectedOrderId.value = row?.id || null
}
function handlePageChange(page: number) {
pagination.currentPage = page
loadData()
}
function handlePageSizeChange(size: number) {
pagination.pageSize = size
pagination.currentPage = 1
loadData()
}
function openColumnConfigPanel() {
upperTable.value?.openColumnConfig?.()
}
const buttonLoadingMap = computed<Record<string, boolean>>(() => ({
exportLoading: exportLoading.value,
exportSelectionLoading: exportSelectionLoading.value,
batchPrintLoading: batchPrintLoading.value,
subWaybillPrintLoading: subWaybillPrintLoading.value,
allocateSubOrderNumberLoading: allocateSubOrderNumberLoading.value
}))
const buttonDisabledMap = computed<Record<string, boolean>>(() => ({
hasNoSelection: selectionRows.value.length === 0,
notSingleSelection: selectionRows.value.length !== 1
}))
const buttonLabelMap = computed<Record<string, string>>(() => ({
detailToggleLabel: detailVisible.value ? '隐藏详情' : '显示详情'
}))
const toolbarLayoutKey = computed(() =>
JSON.stringify({
loading: buttonLoadingMap.value,
disabled: buttonDisabledMap.value,
labels: buttonLabelMap.value
})
)
const { actionMap: toolbarActionMap } = createSimpleListToolbarController({
loadData,
handleExport,
handleExportWaybill,
handleExportItem,
handleExportSelection,
handleExportSelectionWaybill,
handleExportSelectionItem,
openColumnConfigPanel,
toggleDetailVisible
})
toolbarActionMap.handleBatchPrint = handleBatchPrint
toolbarActionMap.handleSubWaybillPrint = handleSubWaybillPrint
// 分配子单号
const allocateSubOrderNumberDialogVisible = ref(false)
const allocateSubOrderNumberLoading = ref(false)
const allocateSubOrderNumberOrderId = ref<number | null>(null)
const allocateSubOrderNumberOrderCode = ref('')
const allocateSubOrderNumberCount = ref(1)
function openAllocateSubOrderNumberDialog() {
const rows = selectionRows.value
if (rows.length !== 1) {
ElMessage.warning('请选择 1 条订单进行子单号分配')
return
}
const row = rows[0] || {}
const orderId = Number(row?.order_id ?? row?.id)
if (!orderId || !Number.isInteger(orderId) || orderId <= 0) {
ElMessage.error('未识别到有效订单ID')
return
}
allocateSubOrderNumberOrderId.value = orderId
allocateSubOrderNumberOrderCode.value = String(row?.delivery_order_code || '')
allocateSubOrderNumberCount.value = 1
allocateSubOrderNumberDialogVisible.value = true
}
async function submitAllocateSubOrderNumber() {
if (!allocateSubOrderNumberOrderId.value || allocateSubOrderNumberLoading.value) return
const sub_order_count = Math.max(1, Number(allocateSubOrderNumberCount.value) || 1)
allocateSubOrderNumberLoading.value = true
try {
const res = await orderPendingOrder.allocateSubOrderNumber({
order_id: allocateSubOrderNumberOrderId.value,
sub_order_count
})
const ok = res && (res.code === 1 || res.code === 200 || res.flag === 'success')
if (!ok) {
ElMessage.error(res?.message || '分配子单号失败')
return
}
const taskId = res?.data?.task_id || res?.task_id
ElMessage.success(
taskId
? `分配子单号任务已受理(任务ID: ${taskId})`
: (res?.message || '分配子单号成功')
)
allocateSubOrderNumberDialogVisible.value = false
upperTable.value?.clearSelection?.()
selectionRows.value = []
await loadData()
} catch {
ElMessage.error('分配子单号失败')
} finally {
allocateSubOrderNumberLoading.value = false
}
}
function resetAllocateSubOrderNumberDialog() {
allocateSubOrderNumberOrderId.value = null
allocateSubOrderNumberOrderCode.value = ''
allocateSubOrderNumberCount.value = 1
}
toolbarActionMap.openAllocateSubOrderNumberDialog = openAllocateSubOrderNumberDialog
// 转退回拆包(returnUnpack.transferByOrders):入参取勾选配送订单的 id(wms_order_delivery*.id)
const transferByOrdersVisible = ref(false)
const transferByOrderRows = ref<any[]>([])
function openTransferByOrdersDialog() {
const rows = selectionRows.value
if (!rows.length) {
ElMessage.warning('请先勾选需要转退回拆包的配送订单')
return
}
transferByOrderRows.value = rows.slice()
transferByOrdersVisible.value = true
}
function handleTransferByOrdersSuccess() {
upperTable.value?.clearSelection?.()
selectionRows.value = []
loadData()
}
toolbarActionMap.openTransferByOrdersDialog = openTransferByOrdersDialog
function resolveButtonLoading(loadingKey?: string) {
if (!loadingKey) return false
return Boolean(buttonLoadingMap.value[loadingKey])
}
function resolveButtonDisabled(disabledKey?: string) {
if (!disabledKey) return false
return Boolean(buttonDisabledMap.value[disabledKey])
}
function resolveButtonLabel(defaultLabel: string, dynamicLabelKey?: string) {
if (!dynamicLabelKey) return defaultLabel
return buttonLabelMap.value[dynamicLabelKey] || defaultLabel
}
function handleToolbarButtonClick(action: ToolbarButtonConfig['action']) {
const handler = toolbarActionMap[action]
if (!handler) return
safeInvoke(() => handler())
}
</script>
<style scoped lang="scss">
@use "./styles/order-sub.scss";
/* 详情区外壳只保留左右 10px(订单明细/商品明细/订单日志面板自带 padding: 6px 10px 8px),
与 stock/external_stock 各面板保持一致 */
.order-sub-container .main-content .lower-level .detail-container {
padding: 0 10px;
}
.detail-page {
height: 100%;
overflow-x: hidden;
overflow-y: auto;
}
.order-detail-wrapper,
.order-log-wrapper {
height: 100%;
}
/* 选择运单号面板:结构 / 尺寸对齐手工录入运单号(TaskProgressPanel) */
.task-panel {
background: #fff;
color: #303133;
&__head {
display: flex;
align-items: flex-start;
gap: 12px;
padding: 16px;
}
&__titles {
flex: 1;
min-width: 0;
h2 {
margin: 0;
font-size: 18px;
line-height: 24px;
font-weight: 400;
color: #303133;
}
p {
margin: 4px 0 0;
font-size: 12px;
line-height: 18px;
color: #909399;
}
}
&__close {
width: 24px;
height: 24px;
flex: none;
display: inline-flex;
align-items: center;
justify-content: center;
border: none;
border-radius: 4px;
background: transparent;
color: #909399;
cursor: pointer;
transition: color 0.2s;
svg {
width: 12px;
height: 12px;
}
&:hover {
color: #409eff;
}
}
&__body {
padding: 12px 16px 0;
min-height: 0;
overflow-y: auto;
}
&__form {
display: flex;
flex-direction: column;
gap: 8px;
}
&__field {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
min-height: 40px;
padding: 8px 12px;
border: 1px solid #ebeef5;
border-radius: 4px;
background: #fafafa;
}
&__field-label {
font-size: 12px;
line-height: 20px;
color: #606266;
flex-shrink: 0;
white-space: nowrap;
}
&__field-value {
font-size: 13px;
font-weight: 500;
color: #303133;
text-align: right;
}
&__section {
display: flex;
flex-direction: column;
gap: 6px;
}
&__section-title {
font-size: 12px;
line-height: 20px;
color: #606266;
padding-left: 2px;
}
&__table-wrap {
border-radius: 4px;
overflow: hidden;
/* 勾选列(表头 + 数据单元格)复选框居中显示 */
:deep(.el-table-column--selection .cell) {
display: flex;
align-items: center;
justify-content: center;
padding: 0;
}
}
&__form-tip {
margin: 8px 0 0;
padding: 8px 12px;
border-radius: 4px;
background: #f4f4f5;
font-size: 12px;
line-height: 18px;
color: #909399;
&--error {
background: #fef0f0;
color: #f56c6c;
}
}
&__foot {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
padding: 12px 16px 16px;
flex-shrink: 0;
}
&__hint {
font-size: 12px;
color: #909399;
}
&__actions {
display: flex;
align-items: center;
gap: 8px;
:deep(.el-button) {
margin-left: 0;
margin-right: 0;
}
}
}
</style>
<style lang="scss">
/* el-dialog 会被 append 到 body:去掉默认头/内边距,统一交给面板(同手工录入运单号) */
.el-dialog.select-waybill-dialog {
padding: 0;
overflow: hidden;
.el-dialog__header {
display: none;
}
.el-dialog__body {
padding: 0;
}
}
</style>