3894 lines
146 KiB
Vue
3894 lines
146 KiB
Vue
<template>
|
||
<div class="order-sub-container">
|
||
<scan-box
|
||
ref="scanBox"
|
||
:cache-key="props.scanBoxCacheKey"
|
||
:width="waveScanBoxConfig.width"
|
||
:tree-props="waveScanBoxConfig.treeProps"
|
||
:auto-submit="waveScanBoxConfig.autoSubmit"
|
||
: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" @wheel="handleToolbarWheel">
|
||
<div
|
||
class="toolbar-scroll-container"
|
||
ref="scrollContainerRef"
|
||
@mousedown="handleMouseDown"
|
||
@mousemove="handleMouseMove"
|
||
@mouseup="handleMouseUp"
|
||
@mouseleave="handleMouseUp"
|
||
>
|
||
<el-button
|
||
v-for="button in toolbarButtons"
|
||
:key="button.key"
|
||
:size="button.size || 'small'"
|
||
:type="button.type"
|
||
:plain="button.plain"
|
||
:disabled="resolveButtonDisabled(button.disabledKey)"
|
||
:loading="resolveButtonLoading(button.loadingKey)"
|
||
@click="handleToolbarButtonClick(button.action)"
|
||
>
|
||
{{ resolveButtonLabel(button.label, button.dynamicLabelKey) }}
|
||
</el-button>
|
||
</div>
|
||
</div>
|
||
<div class="toolbar-right">
|
||
<span class="toolbar-switch-label">显示库内抓取波次</span>
|
||
<el-switch
|
||
v-model="showInternalSourceWaves"
|
||
size="small"
|
||
@change="handleSourceFilterChange"
|
||
/>
|
||
</div>
|
||
</div>
|
||
|
||
<div v-if="batchAllocateExpressTaskProgress.taskId" class="task-progress-panel task-progress-panel--toolbar">
|
||
<div class="task-progress-panel__header">
|
||
<span class="task-progress-panel__title">快递号分配任务进度</span>
|
||
<span class="task-progress-panel__meta">任务ID:{{ batchAllocateExpressTaskProgress.taskId }}</span>
|
||
</div>
|
||
<el-progress :percentage="batchAllocateExpressTaskPercent" :status="batchAllocateExpressTaskProgressBarStatus" :stroke-width="16" />
|
||
<div class="task-progress-panel__info">
|
||
<span>状态:{{ getFetchTaskStatusText(batchAllocateExpressTaskProgress.status) }}</span>
|
||
<span>已完成订单:{{ batchAllocateExpressTaskProgress.successCount }} / {{ batchAllocateExpressTaskProgress.totalCount }}</span>
|
||
<span>失败订单:{{ batchAllocateExpressTaskProgress.failedCount }}</span>
|
||
<span v-if="batchAllocateExpressTaskProgress.updateTime">更新时间:{{ formatDateTime(batchAllocateExpressTaskProgress.updateTime) }}</span>
|
||
</div>
|
||
<div v-if="batchAllocateExpressTaskProgress.message || batchAllocateExpressTaskProgress.error" class="task-progress-panel__message">
|
||
{{ batchAllocateExpressTaskProgress.error || batchAllocateExpressTaskProgress.message }}
|
||
</div>
|
||
</div>
|
||
|
||
<div v-if="batchAllocateStorageTaskProgress.taskId" class="task-progress-panel task-progress-panel--toolbar">
|
||
<div class="task-progress-panel__header">
|
||
<span class="task-progress-panel__title">储位分配任务进度</span>
|
||
<span class="task-progress-panel__meta">任务ID:{{ batchAllocateStorageTaskProgress.taskId }}</span>
|
||
</div>
|
||
<el-progress :percentage="batchAllocateStorageTaskPercent" :status="batchAllocateStorageTaskProgressBarStatus" :stroke-width="16" />
|
||
<div class="task-progress-panel__info">
|
||
<span>状态:{{ getFetchTaskStatusText(batchAllocateStorageTaskProgress.status) }}</span>
|
||
<span>已完成订单:{{ batchAllocateStorageTaskProgress.successCount }} / {{ batchAllocateStorageTaskProgress.totalCount }}</span>
|
||
<span>失败订单:{{ batchAllocateStorageTaskProgress.failedCount }}</span>
|
||
<span v-if="batchAllocateStorageTaskProgress.updateTime">更新时间:{{ formatDateTime(batchAllocateStorageTaskProgress.updateTime) }}</span>
|
||
</div>
|
||
<div v-if="batchAllocateStorageTaskProgress.message || batchAllocateStorageTaskProgress.error" class="task-progress-panel__message">
|
||
{{ batchAllocateStorageTaskProgress.error || batchAllocateStorageTaskProgress.message }}
|
||
</div>
|
||
</div>
|
||
|
||
<div v-if="batchRemoveExceptionOrdersTaskProgress.taskId" class="task-progress-panel task-progress-panel--toolbar">
|
||
<div class="task-progress-panel__header">
|
||
<span class="task-progress-panel__title">移除异常订单任务进度</span>
|
||
<span class="task-progress-panel__meta">任务ID:{{ batchRemoveExceptionOrdersTaskProgress.taskId }}</span>
|
||
</div>
|
||
<el-progress :percentage="batchRemoveExceptionOrdersTaskPercent" :status="batchRemoveExceptionOrdersTaskProgressBarStatus" :stroke-width="16" />
|
||
<div class="task-progress-panel__info">
|
||
<span>状态:{{ getFetchTaskStatusText(batchRemoveExceptionOrdersTaskProgress.status) }}</span>
|
||
<span>已移除订单:{{ batchRemoveExceptionOrdersTaskProgress.successCount }} / {{ batchRemoveExceptionOrdersTaskProgress.totalCount }}</span>
|
||
<span>失败订单:{{ batchRemoveExceptionOrdersTaskProgress.failedCount }}</span>
|
||
<span v-if="batchRemoveExceptionOrdersTaskProgress.updateTime">更新时间:{{ formatDateTime(batchRemoveExceptionOrdersTaskProgress.updateTime) }}</span>
|
||
</div>
|
||
<div v-if="batchRemoveExceptionOrdersTaskProgress.message || batchRemoveExceptionOrdersTaskProgress.error" class="task-progress-panel__message">
|
||
{{ batchRemoveExceptionOrdersTaskProgress.error || batchRemoveExceptionOrdersTaskProgress.message }}
|
||
</div>
|
||
</div>
|
||
|
||
<div v-if="batchCancelTaskProgress.taskId" class="task-progress-panel task-progress-panel--toolbar">
|
||
<div class="task-progress-panel__header">
|
||
<span class="task-progress-panel__title">批量取消波次任务进度</span>
|
||
<span class="task-progress-panel__meta">任务ID:{{ batchCancelTaskProgress.taskId }}</span>
|
||
</div>
|
||
<el-progress :percentage="batchCancelTaskPercent" :status="batchCancelTaskProgressBarStatus" :stroke-width="16" />
|
||
<div class="task-progress-panel__info">
|
||
<span>状态:{{ getFetchTaskStatusText(batchCancelTaskProgress.status) }}</span>
|
||
<span>已处理波次:{{ batchCancelTaskProgress.successCount }} / {{ batchCancelTaskProgress.totalCount }}</span>
|
||
<span>失败波次:{{ batchCancelTaskProgress.failedCount }}</span>
|
||
<span v-if="batchCancelTaskProgress.updateTime">更新时间:{{ formatDateTime(batchCancelTaskProgress.updateTime) }}</span>
|
||
</div>
|
||
<div v-if="batchCancelTaskProgress.message || batchCancelTaskProgress.error" class="task-progress-panel__message">
|
||
{{ batchCancelTaskProgress.error || batchCancelTaskProgress.message }}
|
||
</div>
|
||
</div>
|
||
|
||
<div class="split-stack" ref="splitStackRef">
|
||
<div class="upper-wrapper" :style="detailVisible ? upperPaneStyle : upperPaneFullStyle">
|
||
<upper-table
|
||
ref="upperTable"
|
||
:title="waveUpperTableDefaults.title"
|
||
:enable-column-config="waveUpperTableDefaults.enableColumnConfig"
|
||
:column-config-schema-version="3"
|
||
:table-id="tableListId"
|
||
:data="list"
|
||
:row-key="getRowIdentity"
|
||
:columns="columns"
|
||
:table-size="tableSize"
|
||
:pagination="pagination"
|
||
:show-index="waveUpperTableDefaults.showIndex"
|
||
:show-selection="waveUpperTableDefaults.showSelection"
|
||
:loading="loading"
|
||
:queryTime="queryTime"
|
||
@current-change="handleRowClick"
|
||
@row-click="handleRowClick"
|
||
@page-change="handlePageChange"
|
||
@page-size-change="handlePageSizeChange"
|
||
@refresh="loadData"
|
||
@selection-change="handleSelectionChange"
|
||
>
|
||
<template #column-wave_id="{ row }">
|
||
<span>{{ row.wave_id ?? row.id ?? '—' }}</span>
|
||
</template>
|
||
|
||
<template #column-wave_no="{ row }">
|
||
<span>{{ getWaveCode(row) }}</span>
|
||
</template>
|
||
|
||
<template #column-wave_type="{ row }">
|
||
<el-tag size="small" type="info">
|
||
{{ getWaveTypeText(row) }}
|
||
</el-tag>
|
||
</template>
|
||
|
||
<template #column-wave_status="{ row }">
|
||
<el-tag size="small" :type="getStatusTagType(row)">
|
||
{{ getStatusText(row) }}
|
||
</el-tag>
|
||
</template>
|
||
|
||
<template #column-total_orders="{ row }">
|
||
<span>{{ row.total_orders ?? getOrderCount(row) }}</span>
|
||
</template>
|
||
|
||
<template #column-order_count="{ row }">
|
||
<span>{{ getOrderCount(row) }}</span>
|
||
</template>
|
||
|
||
<template #column-processed_orders="{ row }">
|
||
<span>{{ getProcessedOrders(row) }}</span>
|
||
</template>
|
||
|
||
<template #column-storage_assignment_status="{ row }">
|
||
<el-tag size="small" :type="getWaveAssignmentAggregateTagType(getStorageAssignmentStatusText(row))">
|
||
{{ getStorageAssignmentStatusText(row) }}
|
||
</el-tag>
|
||
</template>
|
||
|
||
<template #column-express_assignment_status="{ row }">
|
||
<el-tag size="small" :type="getWaveAssignmentAggregateTagType(row.express_assignment_status)">
|
||
{{ formatWaveExpressAssignmentStatusLabel(row.express_assignment_status) }}
|
||
</el-tag>
|
||
</template>
|
||
|
||
<template #column-print_assignment_status="{ row }">
|
||
<el-tag size="small" :type="getWaveAssignmentAggregateTagType(row.print_assignment_status)">
|
||
{{ formatWavePrintAssignmentStatusLabel(row.print_assignment_status) }}
|
||
</el-tag>
|
||
</template>
|
||
|
||
<template #column-distinguish_express="{ row }">
|
||
<el-tag size="small" :type="Number(row?.distinguish_express) ? 'warning' : 'info'">
|
||
{{ Number(row?.distinguish_express) ? '是' : '否' }}
|
||
</el-tag>
|
||
</template>
|
||
|
||
<template #column-item_detail_machine="{ row }">
|
||
<span class="order-info-text">{{ row.item_detail_machine || '—' }}</span>
|
||
</template>
|
||
|
||
<template #column-item_snapshot_key="{ row }">
|
||
<span class="order-info-text">{{ row.item_snapshot_key || '—' }}</span>
|
||
</template>
|
||
|
||
<template #column-item_snapshot="{ row }">
|
||
<span class="order-info-text">{{ getItemSnapshotText(row) }}</span>
|
||
</template>
|
||
|
||
<template #column-logistics_name="{ row }">
|
||
<span>{{ row.logistics_name || '—' }}</span>
|
||
</template>
|
||
|
||
<template #column-creator="{ row }">
|
||
<span>{{ row.creator || row.creator_name || '—' }}</span>
|
||
</template>
|
||
|
||
<template #column-create_time="{ row }">
|
||
{{ formatDateTime(row.create_time || row.created_at || row.create_at) }}
|
||
</template>
|
||
|
||
<template #column-update_time="{ row }">
|
||
{{ formatDateTime(row.update_time || row.updated_at || row.update_at) }}
|
||
</template>
|
||
|
||
<template #column-operation="{ row }">
|
||
<el-button link type="primary" size="small" @click.stop="openPendingOrdersByWave(row)">处理订单</el-button>
|
||
</template>
|
||
|
||
<template #empty>
|
||
<div class="empty-tip">{{ waveUpperTableDefaults.emptyText }}</div>
|
||
</template>
|
||
</upper-table>
|
||
</div>
|
||
|
||
<template v-if="detailVisible">
|
||
<div
|
||
class="pane-resizer"
|
||
title="拖动调整列表与详情区域高度"
|
||
@mousedown="beginSplitDrag"
|
||
/>
|
||
<div v-if="selectedRow" class="lower-level" :class="tableSize" :style="lowerPaneStyle">
|
||
<div class="detail-header">
|
||
<el-tabs v-model="activeTab" class="detail-tab">
|
||
<el-tab-pane label="波次明细" name="detail" />
|
||
</el-tabs>
|
||
</div>
|
||
|
||
<div class="detail-container">
|
||
<KeepAlive>
|
||
<div v-if="activeTab === 'detail'" class="detail-page order-detail-wrapper">
|
||
<wave-batch-detail-panel :row="selectedRow" />
|
||
</div>
|
||
</KeepAlive>
|
||
</div>
|
||
</div>
|
||
|
||
<div v-else class="no-selection" :style="lowerPaneStyle">
|
||
<div class="empty-tip">
|
||
<p>请从上方列表中选择一项查看详情</p>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
</div>
|
||
</div>
|
||
|
||
<el-dialog
|
||
v-model="pendingOrderDialogVisible"
|
||
:title="pendingOrderDialogTitle"
|
||
width="92vw"
|
||
class="wave-fixed-height-dialog"
|
||
destroy-on-close
|
||
append-to-body
|
||
align-center
|
||
@closed="handlePendingOrderDialogClosed"
|
||
>
|
||
<pending-order-list-panel v-if="pendingOrderDialogVisible && pendingOrderDialogWaveNo" :wave-no="pendingOrderDialogWaveNo" />
|
||
</el-dialog>
|
||
|
||
<el-dialog
|
||
v-model="groupOrderDialogVisible"
|
||
title="抓取团购单"
|
||
width="1280px"
|
||
class="wave-fixed-height-dialog"
|
||
align-center
|
||
:close-on-click-modal="false"
|
||
>
|
||
<div class="group-order-dialog">
|
||
<el-form :inline="true" size="small" class="group-order-filters">
|
||
<el-form-item label="货主">
|
||
<el-select
|
||
v-model="groupOrderFilters.storeId"
|
||
placeholder="全部"
|
||
clearable
|
||
filterable
|
||
style="width: 180px"
|
||
@change="handleGroupOrderFilterChange"
|
||
>
|
||
<el-option
|
||
v-for="store in groupOrderStoreOptions"
|
||
:key="String(store.value)"
|
||
:label="store.label"
|
||
:value="store.value"
|
||
/>
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item label="最小同组订单数">
|
||
<el-input-number
|
||
v-model="groupOrderFilters.sameOrderQuantity"
|
||
:min="1"
|
||
:controls="false"
|
||
style="width: 150px"
|
||
@change="handleGroupOrderFilterChange"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item label="店铺名称">
|
||
<el-input
|
||
v-model="groupOrderFilters.shopName"
|
||
clearable
|
||
placeholder="模糊匹配店铺名称"
|
||
style="width: 180px"
|
||
@keyup.enter="fetchGroupOrderList"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item label="包含 SKU">
|
||
<el-input
|
||
v-model="groupOrderFilters.includeSku"
|
||
clearable
|
||
placeholder="仅保留包含该 SKU 的分组"
|
||
style="width: 180px"
|
||
@keyup.enter="fetchGroupOrderList"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item>
|
||
<el-switch
|
||
v-model="groupOrderFilters.distinguishExpress"
|
||
active-text="区分快递"
|
||
inactive-text="不区分快递"
|
||
@change="handleGroupOrderFilterChange"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item>
|
||
<el-button type="primary" :loading="groupOrderListLoading" @click="fetchGroupOrderList">查询</el-button>
|
||
<el-button @click="resetGroupOrderFilters">重置</el-button>
|
||
</el-form-item>
|
||
</el-form>
|
||
|
||
<div class="group-order-toolbar">
|
||
<div class="group-order-toolbar__left">
|
||
<span>已选 {{ groupOrderSelectionRows.length }} 个结构</span>
|
||
</div>
|
||
<el-checkbox v-model="groupOrderFilters.returnOrderIds">返回订单 ID 列表</el-checkbox>
|
||
</div>
|
||
|
||
<el-table
|
||
ref="groupOrderTableRef"
|
||
:data="groupOrderList"
|
||
v-loading="groupOrderListLoading"
|
||
border
|
||
size="small"
|
||
row-key="item_detail_machine"
|
||
max-height="460"
|
||
@selection-change="handleGroupOrderSelectionChange"
|
||
>
|
||
<el-table-column type="selection" width="48" reserve-selection />
|
||
<el-table-column prop="item_detail" label="商品结构" min-width="260" show-overflow-tooltip />
|
||
<el-table-column prop="logistics_name" label="快递" min-width="130" show-overflow-tooltip />
|
||
<el-table-column prop="group_count" label="同组订单数" min-width="100" align="right" />
|
||
<el-table-column prop="items_total" label="商品总数" min-width="100" align="right" />
|
||
<el-table-column label="货主" min-width="110">
|
||
<template #default="{ row }">
|
||
{{ getGroupOrderStoreText(row) }}
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="状态汇总" min-width="240">
|
||
<template #default="{ row }">
|
||
<span class="status-summary-text">{{ getGroupOrderStatusSummary(row) }}</span>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="商品快照" min-width="280">
|
||
<template #default="{ row }">
|
||
<span class="order-info-text">{{ getGroupOrderItemSnapshotText(row) }}</span>
|
||
</template>
|
||
</el-table-column>
|
||
<!-- <el-table-column label="抓取数量" width="120" align="center">
|
||
<template #default="{ row }">
|
||
<el-input-number
|
||
:model-value="groupOrderQuantityMap[row.item_detail_machine]"
|
||
:min="1"
|
||
:controls="false"
|
||
placeholder="默认"
|
||
style="width: 92px"
|
||
@change="(value: number | undefined) => updateGroupOrderQuantity(row, value)"
|
||
/>
|
||
</template>
|
||
</el-table-column> -->
|
||
<el-table-column label="首单时间" min-width="168">
|
||
<template #default="{ row }">
|
||
{{ formatDateTime(row.first_order_time) }}
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="末单时间" min-width="168">
|
||
<template #default="{ row }">
|
||
{{ formatDateTime(row.last_order_time) }}
|
||
</template>
|
||
</el-table-column>
|
||
|
||
<template #empty>
|
||
<div class="empty-tip">暂无可抓取的团购单结构</div>
|
||
</template>
|
||
</el-table>
|
||
|
||
<div class="group-order-pagination">
|
||
<el-pagination
|
||
v-model:current-page="groupOrderPagination.currentPage"
|
||
v-model:page-size="groupOrderPagination.pageSize"
|
||
:page-sizes="[10, 20, 50, 100]"
|
||
:total="groupOrderPagination.total"
|
||
layout="total, sizes, prev, pager, next, jumper"
|
||
background
|
||
size="small"
|
||
@size-change="handleGroupOrderPageSizeChange"
|
||
@current-change="handleGroupOrderPageChange"
|
||
/>
|
||
</div>
|
||
</div>
|
||
<template #footer>
|
||
<el-button size="small" @click="groupOrderDialogVisible = false">取消</el-button>
|
||
<el-button size="small" type="primary" :loading="groupOrderSubmitting" @click="submitGroupOrderDialog">抓取选中结构</el-button>
|
||
</template>
|
||
</el-dialog>
|
||
|
||
<el-dialog
|
||
v-model="singleOrderDialogVisible"
|
||
title="散单抓取"
|
||
width="1280px"
|
||
class="single-fetch-dialog"
|
||
align-center
|
||
:close-on-click-modal="false"
|
||
>
|
||
<el-tabs v-model="singleOrderActiveTab" class="single-order-tabs">
|
||
<el-tab-pane label="不符合波次策略订单列表" name="fallback-orders">
|
||
<div class="single-fallback-layout">
|
||
<scan-box
|
||
ref="fallbackOrderScanBox"
|
||
:cache-key="groupWaveFallbackScanBoxCacheKey"
|
||
width="250px"
|
||
:tree-props="{ children: 'children', label: 'label' }"
|
||
:auto-submit="false"
|
||
:available-fields="fallbackOrderAvailableFieldsRef"
|
||
@condition-change="handleFallbackOrderConditionChange"
|
||
@condition-clear="handleFallbackOrderConditionClear"
|
||
@reset="handleFallbackOrderConditionReset"
|
||
/>
|
||
|
||
<div class="single-fallback-main">
|
||
<div class="group-order-toolbar">
|
||
<div class="group-order-toolbar__left">
|
||
<span>已选 {{ fallbackOrderSelectionRows.length }} 个订单</span>
|
||
</div>
|
||
<div>
|
||
<el-button
|
||
type="warning"
|
||
size="small"
|
||
:loading="waveStrategyQuickScanSubmitting"
|
||
@click="submitWaveStrategyQuickScan"
|
||
>
|
||
快速扫描
|
||
</el-button>
|
||
<el-button type="primary" size="small" :loading="fallbackOrderListLoading" @click="fetchFallbackOrderList">查询</el-button>
|
||
<el-button size="small" @click="resetFallbackOrderCondition">重置</el-button>
|
||
<el-button type="warning" size="small" :loading="singleOrderSubmitting" :disabled="!fallbackOrderSelectionRows.length" @click="submitFallbackOrderFetchByIds">按订单IDs抓取删单</el-button>
|
||
</div>
|
||
</div>
|
||
|
||
<el-table
|
||
ref="singleOrderTableRef"
|
||
:data="fallbackOrderList"
|
||
v-loading="fallbackOrderListLoading"
|
||
border
|
||
size="small"
|
||
row-key="id"
|
||
max-height="500"
|
||
@selection-change="handleFallbackOrderSelectionChange"
|
||
>
|
||
<el-table-column type="selection" width="48" reserve-selection />
|
||
<el-table-column label="订单号" min-width="180" show-overflow-tooltip>
|
||
<template #default="{ row }">
|
||
{{ row.delivery_no || row.delivery_order_code || row.order_sn || '—' }}
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="物流单号" min-width="160" show-overflow-tooltip>
|
||
<template #default="{ row }">
|
||
{{ row.tracking_no || row.tracking_number || '—' }}
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="店铺" min-width="140" show-overflow-tooltip>
|
||
<template #default="{ row }">
|
||
{{ row.store_name || row.shop_name || row.shop || '—' }}
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column prop="sys_platform_name" label="平台" min-width="120" show-overflow-tooltip />
|
||
<el-table-column label="物流公司" min-width="120" show-overflow-tooltip>
|
||
<template #default="{ row }">
|
||
{{ row.sys_logistics_name || row.logistics_name || '—' }}
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column prop="province" label="省份" min-width="100" show-overflow-tooltip />
|
||
<el-table-column label="商品种数" min-width="90" align="right">
|
||
<template #default="{ row }">
|
||
{{ row.items_count ?? row.item_count ?? '—' }}
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="商品总数" min-width="90" align="right">
|
||
<template #default="{ row }">
|
||
{{ row.items_total ?? row.item_total ?? '—' }}
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="商品快照" min-width="260" show-overflow-tooltip>
|
||
<template #default="{ row }">
|
||
<span class="order-info-text">{{ getFallbackOrderItemSnapshotText(row) }}</span>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column prop="wave_scan_result" label="扫描结果" min-width="110" align="center" />
|
||
<el-table-column label="更新时间" min-width="170">
|
||
<template #default="{ row }">
|
||
{{ formatDateTime(row.updated_at || row.update_time || row.updated_time) }}
|
||
</template>
|
||
</el-table-column>
|
||
|
||
<template #empty>
|
||
<div class="empty-tip">暂无不符合波次策略订单</div>
|
||
</template>
|
||
</el-table>
|
||
|
||
<div class="group-order-pagination">
|
||
<el-pagination
|
||
v-model:current-page="fallbackOrderPagination.currentPage"
|
||
v-model:page-size="fallbackOrderPagination.pageSize"
|
||
:page-sizes="[10, 20, 50, 100]"
|
||
:total="fallbackOrderPagination.total"
|
||
layout="total, sizes, prev, pager, next, jumper"
|
||
background
|
||
size="small"
|
||
@size-change="handleFallbackOrderPageSizeChange"
|
||
@current-change="handleFallbackOrderPageChange"
|
||
/>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</el-tab-pane>
|
||
|
||
<el-tab-pane label="波次策略" name="strategy-api">
|
||
<div class="wave-strategy-tab">
|
||
<div class="group-order-toolbar">
|
||
<div class="group-order-toolbar__left">
|
||
<span>当前仓库波次策略(wms_wave_strategy)</span>
|
||
</div>
|
||
<div class="wave-strategy-toolbar-actions">
|
||
<el-button type="success" size="small" @click="openCreateWaveStrategyDialog">
|
||
新建策略
|
||
</el-button>
|
||
<el-button type="primary" size="small" :loading="waveStrategyListLoading" @click="fetchWaveStrategyList">
|
||
刷新
|
||
</el-button>
|
||
</div>
|
||
</div>
|
||
|
||
<el-table
|
||
:data="waveStrategyList"
|
||
v-loading="waveStrategyListLoading"
|
||
border
|
||
size="small"
|
||
row-key="id"
|
||
max-height="500"
|
||
>
|
||
<el-table-column prop="id" label="ID" width="72" align="center" />
|
||
<el-table-column prop="strategy_name" label="策略名称" min-width="140" show-overflow-tooltip />
|
||
<el-table-column label="波次前缀" width="100" align="center">
|
||
<template #default="{ row }">
|
||
{{ row.wave_prefix || '—' }}
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column prop="warehouse_id" label="仓库ID" width="96" align="center" />
|
||
<el-table-column label="策略类型" width="88" align="center">
|
||
<template #default="{ row }">{{ row.strategy_type ?? '—' }}</template>
|
||
</el-table-column>
|
||
<el-table-column label="状态" width="72" align="center">
|
||
<template #default="{ row }">{{ row.status ?? '—' }}</template>
|
||
</el-table-column>
|
||
<el-table-column label="批次模式" width="88" align="center">
|
||
<template #default="{ row }">{{ row.batch_mode ?? '—' }}</template>
|
||
</el-table-column>
|
||
<el-table-column label="SKU区间" min-width="120" align="center">
|
||
<template #default="{ row }">
|
||
{{ row.order_min_sku ?? '—' }} ~ {{ row.order_max_sku ?? '—' }}
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="件数区间" min-width="120" align="center">
|
||
<template #default="{ row }">
|
||
{{ row.order_min_qty ?? '—' }} ~ {{ row.order_max_qty ?? '—' }}
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="同结构区间" min-width="120" align="center">
|
||
<template #default="{ row }">
|
||
{{ row.min_same_structure ?? '—' }} ~ {{ row.max_same_structure ?? '—' }}
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="同快递" width="72" align="center">
|
||
<template #default="{ row }">{{ row.require_same_express ?? '—' }}</template>
|
||
</el-table-column>
|
||
<el-table-column label="跨货主" width="72" align="center">
|
||
<template #default="{ row }">{{ row.allow_cross_owner ?? '—' }}</template>
|
||
</el-table-column>
|
||
<el-table-column prop="batch_max_orders" label="单波最大订单" width="112" align="center" />
|
||
<el-table-column prop="batch_max_skus" label="单波最大SKU" width="112" align="center" />
|
||
<el-table-column prop="group_batch_max_orders" label="团购单波最大" width="112" align="center" />
|
||
<el-table-column label="创建时间" min-width="168">
|
||
<template #default="{ row }">
|
||
{{ formatDateTime(row.create_time) }}
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="更新时间" min-width="168">
|
||
<template #default="{ row }">
|
||
{{ formatDateTime(row.update_time) }}
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column prop="description" label="说明" min-width="140" show-overflow-tooltip />
|
||
<el-table-column label="操作" width="150" align="center" fixed="right">
|
||
<template #default="{ row }">
|
||
<el-button
|
||
type="warning"
|
||
link
|
||
size="small"
|
||
:loading="waveStrategyFetchSubmittingId === Number(row?.id || 0)"
|
||
:disabled="!Number(row?.id || 0)"
|
||
@click="submitWaveStrategyFetchAdmin(row)"
|
||
>
|
||
后台抓取
|
||
</el-button>
|
||
<el-button type="primary" link size="small" @click="openEditWaveStrategyDialog(row)">
|
||
编辑
|
||
</el-button>
|
||
</template>
|
||
</el-table-column>
|
||
|
||
<template #empty>
|
||
<div class="empty-tip">暂无波次策略数据</div>
|
||
</template>
|
||
</el-table>
|
||
|
||
<div class="group-order-pagination">
|
||
<el-pagination
|
||
v-model:current-page="waveStrategyPagination.currentPage"
|
||
v-model:page-size="waveStrategyPagination.pageSize"
|
||
:page-sizes="[10, 20, 50, 100]"
|
||
:total="waveStrategyPagination.total"
|
||
layout="total, sizes, prev, pager, next, jumper"
|
||
background
|
||
size="small"
|
||
@size-change="handleWaveStrategyPageSizeChange"
|
||
@current-change="handleWaveStrategyPageChange"
|
||
/>
|
||
</div>
|
||
</div>
|
||
</el-tab-pane>
|
||
</el-tabs>
|
||
|
||
<template #footer>
|
||
<el-button size="small" @click="singleOrderDialogVisible = false">关闭</el-button>
|
||
</template>
|
||
</el-dialog>
|
||
|
||
<wave-fetch-task-progress-dialog
|
||
:model-value="Boolean(fetchTaskProgress.taskId)"
|
||
:progress="fetchTaskProgress"
|
||
/>
|
||
<wave-strategy-quick-scan-progress-dialog
|
||
v-model="waveStrategyQuickScanDialogVisible"
|
||
:progress="waveStrategyQuickScanResult"
|
||
@update:model-value="handleWaveStrategyQuickScanDialogVisibleChange"
|
||
/>
|
||
|
||
<el-dialog
|
||
v-model="waveStrategyFormDialogVisible"
|
||
:title="waveStrategyFormMode === 'create' ? '新建波次策略' : '编辑波次策略'"
|
||
width="720px"
|
||
class="wave-fixed-height-dialog"
|
||
align-center
|
||
destroy-on-close
|
||
append-to-body
|
||
>
|
||
<el-form
|
||
ref="waveStrategyFormRef"
|
||
:model="waveStrategyFormModel"
|
||
:rules="waveStrategyFormRules"
|
||
label-width="130px"
|
||
class="wave-strategy-form-grid"
|
||
>
|
||
<el-form-item label="策略名称" prop="strategy_name">
|
||
<el-input v-model="waveStrategyFormModel.strategy_name" clearable placeholder="请输入策略名称" maxlength="80" />
|
||
</el-form-item>
|
||
<el-form-item label="策略类型" prop="strategy_type">
|
||
<el-input-number v-model="waveStrategyFormModel.strategy_type" :min="1" :precision="0" controls-position="right" />
|
||
</el-form-item>
|
||
<el-form-item label="批次模式" prop="batch_mode">
|
||
<el-input-number v-model="waveStrategyFormModel.batch_mode" :min="1" :precision="0" controls-position="right" />
|
||
</el-form-item>
|
||
<el-form-item label="状态" prop="status">
|
||
<el-select v-model="waveStrategyFormModel.status" clearable placeholder="请选择状态">
|
||
<el-option
|
||
v-for="option in waveStrategyStatusOptions"
|
||
:key="String(option.value)"
|
||
:label="option.label"
|
||
:value="option.value"
|
||
/>
|
||
</el-select>
|
||
</el-form-item>
|
||
|
||
<el-form-item label="最小SKU数" prop="order_min_sku">
|
||
<el-input-number v-model="waveStrategyFormModel.order_min_sku" :min="0" :precision="0" controls-position="right" />
|
||
</el-form-item>
|
||
<el-form-item label="最大SKU数" prop="order_max_sku">
|
||
<el-input-number v-model="waveStrategyFormModel.order_max_sku" :min="0" :precision="0" controls-position="right" />
|
||
</el-form-item>
|
||
<el-form-item label="最小件数" prop="order_min_qty">
|
||
<el-input-number v-model="waveStrategyFormModel.order_min_qty" :min="0" :precision="0" controls-position="right" />
|
||
</el-form-item>
|
||
<el-form-item label="最大件数" prop="order_max_qty">
|
||
<el-input-number v-model="waveStrategyFormModel.order_max_qty" :min="0" :precision="0" controls-position="right" />
|
||
</el-form-item>
|
||
<el-form-item label="同结构最小数" prop="min_same_structure">
|
||
<el-input-number v-model="waveStrategyFormModel.min_same_structure" :min="0" :precision="0" controls-position="right" />
|
||
</el-form-item>
|
||
<el-form-item label="同结构最大数" prop="max_same_structure">
|
||
<el-input-number v-model="waveStrategyFormModel.max_same_structure" :min="0" :precision="0" controls-position="right" />
|
||
</el-form-item>
|
||
<el-form-item label="单波最大订单" prop="batch_max_orders">
|
||
<el-input-number v-model="waveStrategyFormModel.batch_max_orders" :min="0" :precision="0" controls-position="right" />
|
||
</el-form-item>
|
||
<el-form-item label="单波最大SKU" prop="batch_max_skus">
|
||
<el-input-number v-model="waveStrategyFormModel.batch_max_skus" :min="0" :precision="0" controls-position="right" />
|
||
</el-form-item>
|
||
<el-form-item label="团购单波最大" prop="group_batch_max_orders">
|
||
<el-input-number v-model="waveStrategyFormModel.group_batch_max_orders" :min="0" :precision="0" controls-position="right" />
|
||
</el-form-item>
|
||
<el-form-item label="要求同快递" prop="require_same_express">
|
||
<el-select v-model="waveStrategyFormModel.require_same_express" clearable placeholder="请选择">
|
||
<el-option
|
||
v-for="option in waveBooleanOptions"
|
||
:key="String(option.value)"
|
||
:label="option.label"
|
||
:value="option.value"
|
||
/>
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item label="允许跨货主" prop="allow_cross_owner">
|
||
<el-select v-model="waveStrategyFormModel.allow_cross_owner" clearable placeholder="请选择">
|
||
<el-option
|
||
v-for="option in waveBooleanOptions"
|
||
:key="String(option.value)"
|
||
:label="option.label"
|
||
:value="option.value"
|
||
/>
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item label="说明" prop="description" class="wave-strategy-form-item--full">
|
||
<el-input v-model="waveStrategyFormModel.description" type="textarea" :rows="2" clearable placeholder="策略说明(可选)" />
|
||
</el-form-item>
|
||
<el-form-item label="允许货主" class="wave-strategy-form-item--full">
|
||
<el-select
|
||
v-model="waveStrategyFormModel.allowed_owners"
|
||
multiple
|
||
filterable
|
||
clearable
|
||
collapse-tags
|
||
collapse-tags-tooltip
|
||
placeholder="请选择允许货主"
|
||
>
|
||
<el-option
|
||
v-for="option in waveStrategyOwnerOptions"
|
||
:key="option.value"
|
||
:label="option.label"
|
||
:value="option.value"
|
||
/>
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item label="允许快递编码" class="wave-strategy-form-item--full">
|
||
<el-select
|
||
v-model="waveStrategyFormModel.allowed_expresses"
|
||
multiple
|
||
filterable
|
||
clearable
|
||
collapse-tags
|
||
collapse-tags-tooltip
|
||
placeholder="请选择允许快递编码"
|
||
>
|
||
<el-option
|
||
v-for="option in waveStrategyExpressOptions"
|
||
:key="option.value"
|
||
:label="option.label"
|
||
:value="option.value"
|
||
/>
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item label="允许省份" class="wave-strategy-form-item--full">
|
||
<el-select
|
||
v-model="waveStrategyFormModel.allowed_provinces"
|
||
multiple
|
||
filterable
|
||
clearable
|
||
collapse-tags
|
||
collapse-tags-tooltip
|
||
placeholder="请选择允许省份"
|
||
>
|
||
<el-option
|
||
v-for="option in waveStrategyProvinceOptions"
|
||
:key="option.value"
|
||
:label="option.label"
|
||
:value="option.value"
|
||
/>
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item label="允许平台" class="wave-strategy-form-item--full">
|
||
<el-select
|
||
v-model="waveStrategyFormModel.allowed_platforms"
|
||
multiple
|
||
filterable
|
||
clearable
|
||
collapse-tags
|
||
collapse-tags-tooltip
|
||
placeholder="请选择允许平台"
|
||
>
|
||
<el-option
|
||
v-for="option in waveStrategyPlatformOptions"
|
||
:key="option.value"
|
||
:label="option.label"
|
||
:value="option.value"
|
||
/>
|
||
</el-select>
|
||
</el-form-item>
|
||
</el-form>
|
||
<template #footer>
|
||
<el-button @click="waveStrategyFormDialogVisible = false">取消</el-button>
|
||
<el-button type="primary" :loading="waveStrategyFormSubmitting" @click="submitWaveStrategyForm">
|
||
保存
|
||
</el-button>
|
||
</template>
|
||
</el-dialog>
|
||
|
||
<batch-receiving-print-dialog
|
||
v-model="wavePrintDialogVisible"
|
||
:selection-rows="wavePrintRows"
|
||
business-type="PICKING"
|
||
dialog-title="批量打印拣货单"
|
||
queue-no-field="wave_no"
|
||
document-label="波次"
|
||
:fetch-print-data="loadWavePrintFormData"
|
||
/>
|
||
|
||
<wave-platform-print-preview-dialog
|
||
v-model="platformPrintDialogVisible"
|
||
:error-message="platformPrintErrorMessage"
|
||
:payload="platformPrintPayload"
|
||
:request-meta="platformPrintRequestMeta"
|
||
/>
|
||
</div>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
import { KeepAlive, computed, onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue'
|
||
import { useRoute, useRouter } from 'vue-router'
|
||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||
import ScanBox from '@/components/ScanBox/index.vue'
|
||
import UpperTable from '@/components/UpperTable/index.vue'
|
||
import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config'
|
||
import {
|
||
waveScanBoxConfig,
|
||
waveUpperTableDefaults,
|
||
waveAvailableFields,
|
||
fallbackOrderAvailableFields,
|
||
waveBatchColumns,
|
||
waveWhereAllowedFields,
|
||
getWaveToolbarButtons,
|
||
waveStrategyFormRules,
|
||
waveStrategyStatusOptions,
|
||
waveBooleanOptions,
|
||
waveFetchTaskStatusTextMap,
|
||
waveStatusTextMap,
|
||
waveTypeTextMap,
|
||
waveStorageAssignmentStatusTextMap,
|
||
unwrapWavePlatformPrintPayload,
|
||
formatWaveExpressAssignmentStatusLabel,
|
||
formatWavePrintAssignmentStatusLabel,
|
||
getWaveAssignmentAggregateTagType
|
||
} from './config/wave-config'
|
||
import { safeInvoke } from '@/utils/safe-invoke'
|
||
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
|
||
import BatchReceivingPrintDialog from '@/components/BatchReceivingPrintDialog.vue'
|
||
import WavePlatformPrintPreviewDialog from './component/WavePlatformPrintPreviewDialog.vue'
|
||
import PendingOrderListPanel from './component/PendingOrderListPanel.vue'
|
||
import WaveBatchDetailPanel from './component/WaveBatchDetailPanel.vue'
|
||
import WaveFetchTaskProgressDialog from './component/WaveFetchTaskProgressDialog.vue'
|
||
import WaveStrategyQuickScanProgressDialog from './component/WaveStrategyQuickScanProgressDialog.vue'
|
||
import * as indexApi from '@/api/index/index'
|
||
import {
|
||
settingWarehouseGetSettings as getWarehouseSettings,
|
||
unwrapSettingWarehousePayload,
|
||
type SettingWarehouseSettingsPayload
|
||
} from '@/api/setting.warehouse/settingwarehouse'
|
||
import {
|
||
orderWaveBatchAllocateExpress,
|
||
orderWaveBatchAllocateExpressTaskProgress,
|
||
orderWaveBatchAllocateStorage,
|
||
orderWaveBatchAllocateStorageTaskProgress,
|
||
orderWaveBatchAutoGrouping,
|
||
orderWaveBatchCancel,
|
||
orderWaveBatchCancelTaskProgress,
|
||
orderWaveBatchFinishAutoGrouping,
|
||
orderWaveBatchRemoveExceptionOrders,
|
||
orderWaveBatchRemoveExceptionOrdersTaskProgress,
|
||
orderWaveBatchList,
|
||
orderWaveFetch,
|
||
orderWaveGroupFetch,
|
||
orderWaveSingleFetch,
|
||
orderWaveSingleFetchByIds,
|
||
orderWaveWaveStrategyCreate,
|
||
orderWaveWaveStrategyFetchAdmin,
|
||
orderWaveWaveStrategyFallbackOrderList,
|
||
orderWaveWaveStrategyQuickScan,
|
||
orderWaveWaveStrategyQuickScanTaskProgress,
|
||
orderWaveWaveStrategyUpdate,
|
||
orderWaveWaveStrategyList,
|
||
orderWaveFetchTaskProgress,
|
||
orderWaveGroupOrderFetchList
|
||
} from '@/api/order.wave/orderwave'
|
||
import type {
|
||
WaveBatchAutoGroupingResponse,
|
||
WaveBatchAllocateExpressTaskProgressResponse,
|
||
WaveBatchAllocateExpressResponse,
|
||
WaveBatchAllocateStorageTaskProgressResponse,
|
||
WaveBatchAllocateStorageResponse,
|
||
WaveBatchCancelResponse,
|
||
WaveBatchCancelTaskProgressResponse,
|
||
WaveBatchFinishAutoGroupingResponse,
|
||
WaveBatchListResponse,
|
||
WaveBatchRemoveExceptionOrdersResponse,
|
||
WaveBatchRemoveExceptionOrdersTaskProgressResponse,
|
||
WaveGroupOrderFetchListResponse,
|
||
WaveFetchParams,
|
||
WaveFetchResponse,
|
||
WaveFetchTaskProgressResponse,
|
||
WaveSingleFetchParams,
|
||
WaveStrategyCreateParams,
|
||
WaveStrategyFetchTaskCreatedResponse,
|
||
WaveStrategyFallbackOrderListResponse,
|
||
WaveStrategyFallbackOrderListRow,
|
||
WaveStrategyListResponse,
|
||
WaveStrategyMutationResponse,
|
||
WaveStrategyUpdateParams,
|
||
WaveStrategyQuickScanResponse,
|
||
WaveStrategyQuickScanTaskProgressResponse
|
||
} from '@/api/order.wave/orderwave'
|
||
import { useUserStore } from '@/stores/modules/user'
|
||
import { getWavePrintData, getWavePlatformPrintData } from '@/api/order.print/orderprint'
|
||
import type { WavePlatformPrintDataPayload } from '@/api/order.print/orderprint'
|
||
import pcasCodeData from 'china-division/dist/pcas-code.json'
|
||
|
||
const props = withDefaults(
|
||
defineProps<{
|
||
/** 与路由 path 组合,隔离 ScanBox 筛选缓存(波次各标签页须各不相同) */
|
||
scanBoxCacheKey?: string
|
||
}>(),
|
||
{
|
||
scanBoxCacheKey: 'wave-order-group-wave'
|
||
}
|
||
)
|
||
|
||
const groupWaveFallbackScanBoxCacheKey = computed(() => `${props.scanBoxCacheKey}-fallback-orders`)
|
||
|
||
const WAVE_TYPE = 1 as const
|
||
|
||
const route = useRoute()
|
||
const router = useRouter()
|
||
|
||
const scanBox = ref<any>(null)
|
||
const upperTable = ref<any>(null)
|
||
const groupOrderTableRef = ref<any>(null)
|
||
const scrollContainerRef = ref<HTMLElement | null>(null)
|
||
const loading = ref(false)
|
||
const showInternalSourceWaves = ref(false)
|
||
const batchAutoGroupingLoading = ref(false)
|
||
const batchFinishAutoGroupingLoading = ref(false)
|
||
const batchCancelLoading = ref(false)
|
||
const batchPrintLoading = ref(false)
|
||
const batchPlatformPrintLoading = ref(false)
|
||
const platformPrintDialogVisible = ref(false)
|
||
const platformPrintPayload = ref<WavePlatformPrintDataPayload | null>(null)
|
||
const platformPrintErrorMessage = ref('')
|
||
const platformPrintRequestMeta = ref<{ warehouse_id: number; wave_ids: Array<number | string> } | null>(null)
|
||
const batchAllocateExpressLoading = ref(false)
|
||
const batchAllocateStorageLoading = ref(false)
|
||
const batchRemoveExceptionOrdersLoading = ref(false)
|
||
const userStore = useUserStore()
|
||
const wavePrintDialogVisible = ref(false)
|
||
const wavePrintRows = ref<any[]>([])
|
||
const wavePrintDataMap = ref<Record<string, any>>({})
|
||
const queryTime = ref(0)
|
||
const tableSize = ref('small')
|
||
const activeTab = ref('detail')
|
||
const list = ref<any[]>([])
|
||
const selectedRow = ref<any>(null)
|
||
const selectionRows = ref<any[]>([])
|
||
const hasSelection = ref(false)
|
||
const groupOrderDialogVisible = ref(false)
|
||
const groupOrderListLoading = ref(false)
|
||
const groupOrderSubmitting = ref(false)
|
||
const groupOrderList = ref<any[]>([])
|
||
const groupOrderSelectionRows = ref<any[]>([])
|
||
const groupOrderStoreOptions = ref<Array<{ label: string; value: number | string }>>([])
|
||
const waveMaxOrderLimit = ref<number | null>(null)
|
||
const fetchTaskPollTimer = ref<ReturnType<typeof setTimeout> | null>(null)
|
||
const batchAllocateExpressTaskPollTimer = ref<ReturnType<typeof setTimeout> | null>(null)
|
||
const batchAllocateStorageTaskPollTimer = ref<ReturnType<typeof setTimeout> | null>(null)
|
||
const batchRemoveExceptionOrdersTaskPollTimer = ref<ReturnType<typeof setTimeout> | null>(null)
|
||
const batchCancelTaskPollTimer = ref<ReturnType<typeof setTimeout> | null>(null)
|
||
const waveStrategyQuickScanTaskPollTimer = ref<ReturnType<typeof setTimeout> | null>(null)
|
||
const waveStrategyQuickScanDialogVisible = ref(false)
|
||
const pendingOrderDialogVisible = ref(false)
|
||
const pendingOrderDialogWaveNo = ref('')
|
||
const fetchTaskProgress = reactive({
|
||
taskId: '',
|
||
status: 'submitted',
|
||
warehouseId: undefined as number | undefined,
|
||
structureCount: 0,
|
||
finishedStructureCount: 0,
|
||
progressPercent: 0,
|
||
totalFetchedQuantity: 0,
|
||
durationMs: 0,
|
||
error: '',
|
||
updateTime: '',
|
||
message: '',
|
||
fetchMode: '' as string,
|
||
maxFetchQuantity: undefined as number | undefined,
|
||
limitReached: undefined as boolean | undefined,
|
||
stopReason: '' as string
|
||
})
|
||
const batchAllocateExpressTaskProgress = reactive({
|
||
taskId: '',
|
||
status: 'submitted',
|
||
totalCount: 0,
|
||
successCount: 0,
|
||
failedCount: 0,
|
||
progressPercent: 0,
|
||
durationMs: 0,
|
||
updateTime: '',
|
||
error: '',
|
||
message: ''
|
||
})
|
||
const batchAllocateStorageTaskProgress = reactive({
|
||
taskId: '',
|
||
status: 'submitted',
|
||
totalCount: 0,
|
||
successCount: 0,
|
||
failedCount: 0,
|
||
progressPercent: 0,
|
||
durationMs: 0,
|
||
updateTime: '',
|
||
error: '',
|
||
message: ''
|
||
})
|
||
const batchRemoveExceptionOrdersTaskProgress = reactive({
|
||
taskId: '',
|
||
status: 'submitted',
|
||
totalCount: 0,
|
||
successCount: 0,
|
||
failedCount: 0,
|
||
progressPercent: 0,
|
||
durationMs: 0,
|
||
updateTime: '',
|
||
error: '',
|
||
message: ''
|
||
})
|
||
const batchCancelTaskProgress = reactive({
|
||
taskId: '',
|
||
status: 'submitted',
|
||
totalCount: 0,
|
||
successCount: 0,
|
||
failedCount: 0,
|
||
progressPercent: 0,
|
||
durationMs: 0,
|
||
updateTime: '',
|
||
error: '',
|
||
message: ''
|
||
})
|
||
|
||
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||
const groupOrderPagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||
const singleOrderDialogVisible = ref(false)
|
||
const singleOrderActiveTab = ref<'fallback-orders' | 'strategy-api'>('fallback-orders')
|
||
const singleOrderSubmitting = ref(false)
|
||
const singleOrderTableRef = ref<any>(null)
|
||
const fallbackOrderScanBox = ref<any>(null)
|
||
const fallbackOrderListLoading = ref(false)
|
||
const fallbackOrderList = ref<WaveStrategyFallbackOrderListRow[]>([])
|
||
const fallbackOrderSelectionRows = ref<any[]>([])
|
||
const fallbackOrderPagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||
const waveStrategyListLoading = ref(false)
|
||
const waveStrategyQuickScanSubmitting = ref(false)
|
||
const waveStrategyFetchSubmittingId = ref<number | null>(null)
|
||
const waveStrategyList = ref<any[]>([])
|
||
const waveStrategyFormDialogVisible = ref(false)
|
||
const waveStrategyFormSubmitting = ref(false)
|
||
const waveStrategyFormMode = ref<'create' | 'edit'>('create')
|
||
const waveStrategyEditingId = ref<number | null>(null)
|
||
const waveStrategyFormRef = ref<any>(null)
|
||
const waveStrategyFormModel = reactive({
|
||
strategy_name: '',
|
||
strategy_type: undefined as number | undefined,
|
||
batch_mode: undefined as number | undefined,
|
||
status: undefined as number | undefined,
|
||
order_min_sku: undefined as number | undefined,
|
||
order_max_sku: undefined as number | undefined,
|
||
order_min_qty: undefined as number | undefined,
|
||
order_max_qty: undefined as number | undefined,
|
||
min_same_structure: undefined as number | undefined,
|
||
max_same_structure: undefined as number | undefined,
|
||
batch_max_orders: undefined as number | undefined,
|
||
batch_max_skus: undefined as number | undefined,
|
||
group_batch_max_orders: undefined as number | undefined,
|
||
require_same_express: undefined as boolean | undefined,
|
||
allow_cross_owner: undefined as boolean | undefined,
|
||
description: '',
|
||
allowed_owners: [] as string[],
|
||
allowed_expresses: [] as string[],
|
||
allowed_provinces: [] as string[],
|
||
allowed_platforms: [] as string[]
|
||
})
|
||
const waveStrategyQuickScanResult = reactive({
|
||
status: '',
|
||
taskId: '',
|
||
warehouseId: undefined as number | undefined,
|
||
state: '',
|
||
message: '',
|
||
acceptedAt: '',
|
||
totalOrderCount: 0,
|
||
processedOrderCount: 0,
|
||
matchedOrderCount: 0,
|
||
unmatchedOrderCount: 0,
|
||
progressPercent: 0,
|
||
startTime: '',
|
||
endTime: '',
|
||
durationMs: 0,
|
||
errorMessage: ''
|
||
})
|
||
const waveStrategyPagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||
const fallbackOrderOwnerOptions = ref<Array<{ label: string; value: string }>>([])
|
||
const fallbackOrderLogisticsOptions = ref<Array<{ label: string; value: string }>>([])
|
||
const fallbackOrderPlatformOptions = ref<Array<{ label: string; value: string }>>([])
|
||
const waveStrategyOwnerOptions = ref<Array<{ label: string; value: string }>>([])
|
||
const waveStrategyExpressOptions = ref<Array<{ label: string; value: string }>>([])
|
||
const waveStrategyProvinceOptions = ref<Array<{ label: string; value: string }>>([])
|
||
const waveStrategyPlatformOptions = ref<Array<{ label: string; value: string }>>([])
|
||
const presetTree = ref<any[]>([])
|
||
const availableFieldsRef = reactive(JSON.parse(JSON.stringify(waveAvailableFields)))
|
||
const fallbackOrderAvailableFieldsRef = reactive(JSON.parse(JSON.stringify(fallbackOrderAvailableFields)))
|
||
const columns = ref(JSON.parse(JSON.stringify(waveBatchColumns)))
|
||
|
||
const toolbarButtons = computed(() => getWaveToolbarButtons(WAVE_TYPE))
|
||
|
||
const detailVisible = ref(true)
|
||
const { splitStackRef, beginSplitDrag, lowerPaneStyle, upperPaneStyle } = useVerticalSplitPane({
|
||
defaultLowerPercent: 38
|
||
})
|
||
const upperPaneFullStyle = computed(() => ({
|
||
flex: '1 1 auto',
|
||
minHeight: '0',
|
||
overflow: 'hidden' as const
|
||
}))
|
||
|
||
function toggleDetailVisible() {
|
||
detailVisible.value = !detailVisible.value
|
||
}
|
||
|
||
const isDragging = ref(false)
|
||
const startX = ref(0)
|
||
const scrollLeft = ref(0)
|
||
|
||
const handleToolbarWheel = (e: WheelEvent) => {
|
||
if (scrollContainerRef.value) {
|
||
e.preventDefault()
|
||
scrollContainerRef.value.scrollLeft += e.deltaY
|
||
}
|
||
}
|
||
|
||
const handleMouseDown = (e: MouseEvent) => {
|
||
if (!scrollContainerRef.value) return
|
||
isDragging.value = true
|
||
startX.value = e.pageX - scrollContainerRef.value.offsetLeft
|
||
scrollLeft.value = scrollContainerRef.value.scrollLeft
|
||
}
|
||
|
||
const handleMouseMove = (e: MouseEvent) => {
|
||
if (!isDragging.value || !scrollContainerRef.value) return
|
||
e.preventDefault()
|
||
const x = e.pageX - scrollContainerRef.value.offsetLeft
|
||
const walk = (x - startX.value) * 1.5
|
||
scrollContainerRef.value.scrollLeft = scrollLeft.value - walk
|
||
}
|
||
|
||
const handleMouseUp = () => {
|
||
isDragging.value = false
|
||
}
|
||
|
||
const buttonLoadingMap = computed(() => ({
|
||
loading: loading.value,
|
||
batchAutoGroupingLoading: batchAutoGroupingLoading.value,
|
||
batchFinishAutoGroupingLoading: batchFinishAutoGroupingLoading.value,
|
||
batchCancelLoading: batchCancelLoading.value,
|
||
batchPrintLoading: batchPrintLoading.value,
|
||
batchPlatformPrintLoading: batchPlatformPrintLoading.value,
|
||
batchAllocateExpressLoading: batchAllocateExpressLoading.value,
|
||
batchAllocateStorageLoading: batchAllocateStorageLoading.value,
|
||
batchRemoveExceptionOrdersLoading: batchRemoveExceptionOrdersLoading.value
|
||
}))
|
||
|
||
const batchPlatformPrintDisabled = computed(() => !printableSelectionRows.value.length)
|
||
|
||
const buttonDisabledMap = computed(() => ({
|
||
batchPickingPrintDisabled: batchPrintDisabled.value,
|
||
batchPrintDisabled: batchPrintDisabled.value,
|
||
batchPlatformPrintDisabled: batchPlatformPrintDisabled.value,
|
||
noSelection: !hasSelection.value
|
||
}))
|
||
|
||
const buttonLabelMap = computed(() => ({
|
||
batchPrintTotal: `批量打印(${selectedWaveOrderTotal.value})`,
|
||
batchPlatformPrintTotal: `批量打印(平台)(${selectedWaveOrderTotal.value})`,
|
||
batchPickingPrintTotal: `批量打印拣货单(${selectionRows.value.length})`,
|
||
detailToggleLabel: detailVisible.value ? '隐藏详情' : '显示详情'
|
||
}))
|
||
|
||
function resolveButtonLoading(loadingKey?: string) {
|
||
if (!loadingKey) return false
|
||
return Boolean((buttonLoadingMap.value as Record<string, boolean>)[loadingKey])
|
||
}
|
||
|
||
function resolveButtonDisabled(disabledKey?: string) {
|
||
if (!disabledKey) return false
|
||
return Boolean((buttonDisabledMap.value as Record<string, boolean>)[disabledKey])
|
||
}
|
||
|
||
function resolveButtonLabel(defaultLabel: string, dynamicLabelKey?: string) {
|
||
if (!dynamicLabelKey) return defaultLabel
|
||
return (buttonLabelMap.value as Record<string, string>)[dynamicLabelKey] || defaultLabel
|
||
}
|
||
|
||
const toolbarActionMap: Record<string, () => void> = {
|
||
loadData: () => {
|
||
void loadData()
|
||
},
|
||
openColumnConfigPanel: () => openColumnConfigPanel(),
|
||
toggleDetailVisible: () => toggleDetailVisible(),
|
||
handleBatchPrint: () => handleBatchPrint(),
|
||
handleBatchPlatformPrint: () => {
|
||
void handleBatchPlatformPrint()
|
||
},
|
||
handleBatchPrintPickingList: () => handleBatchPrintPickingList(),
|
||
handleBatchAutoGrouping: () => {
|
||
void handleBatchAutoGrouping()
|
||
},
|
||
handleBatchFinishAutoGrouping: () => {
|
||
void handleBatchFinishAutoGrouping()
|
||
},
|
||
handleBatchCancel: () => {
|
||
void handleBatchCancel()
|
||
},
|
||
handleBatchAllocateExpress: () => {
|
||
void handleBatchAllocateExpress()
|
||
},
|
||
handleBatchAllocateStorage: () => {
|
||
void handleBatchAllocateStorage()
|
||
},
|
||
handleBatchRemoveExceptionOrders: () => {
|
||
void handleBatchRemoveExceptionOrders()
|
||
},
|
||
openGroupOrderDialog: () => openGroupOrderDialog(),
|
||
openSingleOrderDialog: () => openSingleOrderDialog()
|
||
}
|
||
|
||
function handleToolbarButtonClick(action: ToolbarButtonConfig['action']) {
|
||
const handler = toolbarActionMap[action]
|
||
if (!handler) return
|
||
safeInvoke(() => handler())
|
||
}
|
||
|
||
const groupOrderFilters = reactive({
|
||
distinguishExpress: true,
|
||
storeId: undefined as number | string | undefined,
|
||
sameOrderQuantity: undefined as number | undefined,
|
||
shopName: '',
|
||
includeSku: '',
|
||
returnOrderIds: false
|
||
})
|
||
const isGroupWaveTab = computed(() => WAVE_TYPE === 1)
|
||
const currentWaveType = computed(() => WAVE_TYPE)
|
||
const tableListId = computed(() => `wave-management-list-${WAVE_TYPE}`)
|
||
|
||
const okCode = (code: unknown) => code === 1 || code === 200 || code === 0
|
||
|
||
function unwrapWaveStrategyFetchPayload(res: any): WaveStrategyFetchTaskCreatedResponse {
|
||
if (res && typeof res.data === 'object' && res.data !== null && !Array.isArray(res.data)) {
|
||
return res.data as WaveStrategyFetchTaskCreatedResponse
|
||
}
|
||
return res as WaveStrategyFetchTaskCreatedResponse
|
||
}
|
||
|
||
function applyWaveStrategyFetchUiResult(
|
||
payload: WaveStrategyFetchTaskCreatedResponse,
|
||
options: { defaultSuccessHint?: string; afterSuccess?: () => void | Promise<void> } = {}
|
||
) {
|
||
const validationErrors = payload?.validation_errors
|
||
if (Array.isArray(validationErrors) && validationErrors.length) {
|
||
const detail = validationErrors
|
||
.map((e) => [e?.field, e?.message].filter(Boolean).join(': ') || '')
|
||
.filter(Boolean)
|
||
.join(';')
|
||
ElMessage.warning(detail || payload?.message || '入参校验未通过')
|
||
return
|
||
}
|
||
|
||
const fs = payload.fetch_state
|
||
|
||
if (fs === 2) {
|
||
ElMessage.warning(payload.tip || payload.message || '抓取任务创建失败')
|
||
return
|
||
}
|
||
|
||
if (fs === 3) {
|
||
const taskId = String(payload.task_id ?? payload.existing_task_id ?? '')
|
||
const taskNo = String(payload.task_no ?? payload.existing_task_no ?? '')
|
||
const tip =
|
||
payload.tip ||
|
||
payload.message ||
|
||
(payload.can_enter_pick_flow ? '存在未完成任务,可直接进入拣货流程' : '存在未完成的抓取任务')
|
||
const suffix = [taskNo ? `任务编号:${taskNo}` : '', taskId ? `任务ID:${taskId}` : ''].filter(Boolean).join(',')
|
||
ElMessage.success(suffix ? `${tip}(${suffix})` : tip)
|
||
const after = options.afterSuccess
|
||
if (after) void after()
|
||
return
|
||
}
|
||
|
||
if (fs === 1 || fs === undefined || fs === null) {
|
||
const taskId = String(payload?.task_id ?? '')
|
||
const taskNo = String(payload?.task_no ?? '')
|
||
const summary = String(payload?.plan_summary ?? '')
|
||
if (fs === 1 && !taskId && !taskNo && !summary) {
|
||
ElMessage.warning(payload?.message || '接口未返回任务信息')
|
||
return
|
||
}
|
||
const hint = summary || payload?.message || options.defaultSuccessHint || '抓取任务已创建'
|
||
const suffix = [taskNo ? `任务编号:${taskNo}` : '', taskId ? `任务ID:${taskId}` : ''].filter(Boolean).join(',')
|
||
ElMessage.success(suffix ? `${hint}(${suffix})` : hint)
|
||
const after = options.afterSuccess
|
||
if (after) void after()
|
||
return
|
||
}
|
||
|
||
ElMessage.warning(payload?.message || `未知抓取状态(fetch_state=${String(fs)})`)
|
||
}
|
||
const printableSelectionRows = computed(() => selectionRows.value.filter((row: any) => !isAutoGroupingWave(row)))
|
||
const autoGroupingSelectionRows = computed(() => selectionRows.value.filter((row: any) => isAutoGroupingWave(row)))
|
||
const selectedWaveOrderTotal = computed(() => {
|
||
return printableSelectionRows.value.reduce((total: number, row: any) => total + Number(getOrderCount(row) || 0), 0)
|
||
})
|
||
const batchPrintDisabled = computed(() => {
|
||
return !printableSelectionRows.value.length || (waveMaxOrderLimit.value !== null && selectedWaveOrderTotal.value > waveMaxOrderLimit.value)
|
||
})
|
||
const batchAllocateExpressTaskPercent = computed(() => {
|
||
const value = Number(batchAllocateExpressTaskProgress.progressPercent || 0)
|
||
if (!Number.isFinite(value)) return 0
|
||
return Math.min(100, Math.max(0, value))
|
||
})
|
||
const batchAllocateExpressTaskProgressBarStatus = computed(() => {
|
||
if (batchAllocateExpressTaskProgress.status === 'failed' || batchAllocateExpressTaskProgress.status === 'not_found') return 'exception'
|
||
if (batchAllocateExpressTaskProgress.status === 'success' || batchAllocateExpressTaskPercent.value >= 100) return 'success'
|
||
return undefined
|
||
})
|
||
const batchAllocateStorageTaskPercent = computed(() => {
|
||
const value = Number(batchAllocateStorageTaskProgress.progressPercent || 0)
|
||
if (!Number.isFinite(value)) return 0
|
||
return Math.min(100, Math.max(0, value))
|
||
})
|
||
const batchAllocateStorageTaskProgressBarStatus = computed(() => {
|
||
if (batchAllocateStorageTaskProgress.status === 'failed' || batchAllocateStorageTaskProgress.status === 'not_found') return 'exception'
|
||
if (batchAllocateStorageTaskProgress.status === 'success' || batchAllocateStorageTaskPercent.value >= 100) return 'success'
|
||
return undefined
|
||
})
|
||
const batchRemoveExceptionOrdersTaskPercent = computed(() => {
|
||
const value = Number(batchRemoveExceptionOrdersTaskProgress.progressPercent || 0)
|
||
if (!Number.isFinite(value)) return 0
|
||
return Math.min(100, Math.max(0, value))
|
||
})
|
||
const batchRemoveExceptionOrdersTaskProgressBarStatus = computed(() => {
|
||
if (batchRemoveExceptionOrdersTaskProgress.status === 'failed' || batchRemoveExceptionOrdersTaskProgress.status === 'not_found') return 'exception'
|
||
if (batchRemoveExceptionOrdersTaskProgress.status === 'success' || batchRemoveExceptionOrdersTaskPercent.value >= 100) return 'success'
|
||
return undefined
|
||
})
|
||
const batchCancelTaskPercent = computed(() => {
|
||
const value = Number(batchCancelTaskProgress.progressPercent || 0)
|
||
if (!Number.isFinite(value)) return 0
|
||
return Math.min(100, Math.max(0, value))
|
||
})
|
||
const batchCancelTaskProgressBarStatus = computed(() => {
|
||
if (batchCancelTaskProgress.status === 'failed' || batchCancelTaskProgress.status === 'not_found') return 'exception'
|
||
if (batchCancelTaskProgress.status === 'success' || batchCancelTaskPercent.value >= 100) return 'success'
|
||
return undefined
|
||
})
|
||
const pendingOrderDialogTitle = computed(() => pendingOrderDialogWaveNo.value ? `待处理订单 - ${pendingOrderDialogWaveNo.value}` : '待处理订单')
|
||
|
||
watch(
|
||
() => singleOrderActiveTab.value,
|
||
(tab) => {
|
||
if (tab === 'strategy-api' && singleOrderDialogVisible.value) {
|
||
void fetchWaveStrategyList()
|
||
}
|
||
}
|
||
)
|
||
|
||
onMounted(() => {
|
||
initializePage()
|
||
})
|
||
|
||
onBeforeUnmount(() => {
|
||
stopFetchTaskPolling()
|
||
stopBatchAllocateExpressTaskPolling()
|
||
stopBatchAllocateStorageTaskPolling()
|
||
stopBatchRemoveExceptionOrdersTaskPolling()
|
||
stopBatchCancelTaskPolling()
|
||
stopWaveStrategyQuickScanTaskPolling()
|
||
})
|
||
|
||
async function initializePage() {
|
||
await Promise.all([loadWarehouseSettings(), loadData()])
|
||
}
|
||
|
||
async function loadWarehouseSettings() {
|
||
try {
|
||
const res: any = await getWarehouseSettings()
|
||
if (!res || !okCode(res.code)) {
|
||
throw new Error(res?.message || '获取仓库配置失败')
|
||
}
|
||
const payload = unwrapSettingWarehousePayload(
|
||
res as Record<string, unknown>
|
||
) as SettingWarehouseSettingsPayload
|
||
const maxWaveQuantity = Number(payload?.subject_config?.max_wave_quantity)
|
||
waveMaxOrderLimit.value = Number.isFinite(maxWaveQuantity) && maxWaveQuantity > 0 ? maxWaveQuantity : null
|
||
} catch (error) {
|
||
console.error('load warehouse settings failed:', error)
|
||
waveMaxOrderLimit.value = null
|
||
}
|
||
}
|
||
|
||
async function loadData() {
|
||
if (loading.value) return
|
||
loading.value = true
|
||
const start = Date.now()
|
||
try {
|
||
const rawWhere = buildWhereConditions(scanBox.value?.getConditions?.() || {})
|
||
if (!showInternalSourceWaves.value) {
|
||
rawWhere.source = 0
|
||
}
|
||
const where = sanitizeWaveWhere(rawWhere)
|
||
if (where.wave_type === undefined || where.wave_type === null || where.wave_type === '') {
|
||
where.wave_type = currentWaveType.value
|
||
}
|
||
const res = await orderWaveBatchList({
|
||
pagination: {
|
||
page: pagination.currentPage,
|
||
pageSize: pagination.pageSize
|
||
},
|
||
where
|
||
}) as WaveBatchListResponse & { code?: number; message?: string; data?: Partial<WaveBatchListResponse> }
|
||
if (!res || !okCode(res.code)) {
|
||
throw new Error(res?.message || '获取波次列表失败')
|
||
}
|
||
|
||
const responseList = Array.isArray(res.list)
|
||
? res.list
|
||
: Array.isArray(res.data?.list)
|
||
? res.data.list
|
||
: []
|
||
const responsePagination = res.pagination || res.data?.pagination || {}
|
||
|
||
list.value = responseList
|
||
pagination.currentPage = responsePagination.page || pagination.currentPage
|
||
pagination.pageSize = responsePagination.pageSize || pagination.pageSize
|
||
pagination.total = responsePagination.total || 0
|
||
|
||
syncSelectionRows()
|
||
syncSelectedRow()
|
||
} catch (error: any) {
|
||
console.error('load wave batch list failed:', error)
|
||
ElMessage.error(error?.message || '获取波次列表失败')
|
||
list.value = []
|
||
pagination.total = 0
|
||
selectedRow.value = null
|
||
} finally {
|
||
loading.value = false
|
||
queryTime.value = Date.now() - start
|
||
}
|
||
}
|
||
|
||
function handlePageChange(page: number) {
|
||
pagination.currentPage = page
|
||
loadData()
|
||
}
|
||
|
||
function handlePageSizeChange(size: number) {
|
||
pagination.pageSize = size
|
||
pagination.currentPage = 1
|
||
loadData()
|
||
}
|
||
|
||
function handleSourceFilterChange() {
|
||
pagination.currentPage = 1
|
||
void loadData()
|
||
}
|
||
|
||
function buildWhereConditions(rawConditions: Record<string, any>) {
|
||
const where: Record<string, any> = {}
|
||
Object.keys(rawConditions || {}).forEach((key) => {
|
||
const condition = rawConditions[key]
|
||
if (condition && typeof condition === 'object' && 'operator' in condition) {
|
||
const value = condition.value
|
||
if (value === undefined || value === null || value === '' || (Array.isArray(value) && value.length === 0)) {
|
||
return
|
||
}
|
||
where[key] = value
|
||
return
|
||
}
|
||
if (condition !== undefined && condition !== null && condition !== '') {
|
||
where[key] = Array.isArray(condition) ? condition[0] ?? '' : condition
|
||
}
|
||
})
|
||
return where
|
||
}
|
||
|
||
function sanitizeWaveWhere(where: Record<string, any>) {
|
||
const nextWhere: Record<string, any> = {}
|
||
Object.keys(where || {}).forEach((key) => {
|
||
if (!waveWhereAllowedFields.has(key)) return
|
||
if (key === 'warehouse_id' || key === 'warehouseId') return
|
||
const value = where[key]
|
||
if (value === undefined || value === null || value === '' || (Array.isArray(value) && value.length === 0)) return
|
||
nextWhere[key] = value
|
||
})
|
||
return nextWhere
|
||
}
|
||
|
||
function handleConditionChange() {
|
||
pagination.currentPage = 1
|
||
loadData()
|
||
}
|
||
|
||
function handleConditionClear() {
|
||
pagination.currentPage = 1
|
||
loadData()
|
||
}
|
||
|
||
function handleConditionReset() {
|
||
pagination.currentPage = 1
|
||
scanBox.value?.reset?.()
|
||
loadData()
|
||
}
|
||
|
||
function handleRowClick(row: any) {
|
||
selectedRow.value = row || null
|
||
}
|
||
|
||
function handleSelectionChange(rows: any[]) {
|
||
selectionRows.value = rows || []
|
||
hasSelection.value = selectionRows.value.length > 0
|
||
}
|
||
|
||
function openColumnConfigPanel() {
|
||
upperTable.value?.openColumnConfig?.()
|
||
}
|
||
|
||
function syncSelectionRows() {
|
||
if (!selectionRows.value.length) return
|
||
const selectedIds = new Set(selectionRows.value.map((row: any) => getRowIdentity(row)))
|
||
selectionRows.value = list.value.filter((row: any) => selectedIds.has(getRowIdentity(row)))
|
||
hasSelection.value = selectionRows.value.length > 0
|
||
}
|
||
|
||
function syncSelectedRow() {
|
||
if (!selectedRow.value) return
|
||
const currentId = getRowIdentity(selectedRow.value)
|
||
selectedRow.value = list.value.find((item: any) => getRowIdentity(item) === currentId) || null
|
||
}
|
||
|
||
function getRowIdentity(row: any) {
|
||
return String(row?.id || row?.wave_id || row?.batch_id || row?.wave_code || row?.batch_code || '')
|
||
}
|
||
|
||
function getWaveCode(row: any) {
|
||
return row?.wave_code || row?.batch_code || row?.wave_no || row?.batch_no || row?.code || row?.id || '—'
|
||
}
|
||
|
||
function openPendingOrdersByWave(row: any) {
|
||
const waveNo = String(row?.wave_no || '').trim()
|
||
if (!waveNo) {
|
||
ElMessage.warning('当前波次缺少波次号,无法跳转待处理订单页')
|
||
return
|
||
}
|
||
|
||
pendingOrderDialogWaveNo.value = waveNo
|
||
pendingOrderDialogVisible.value = true
|
||
}
|
||
|
||
function handlePendingOrderDialogClosed() {
|
||
pendingOrderDialogWaveNo.value = ''
|
||
loadData()
|
||
}
|
||
|
||
function getFetchTaskStatusText(status: string) {
|
||
return waveFetchTaskStatusTextMap[status] || status || '—'
|
||
}
|
||
|
||
function getStatusValue(row: any) {
|
||
return row?.status ?? row?.wave_status ?? row?.batch_status
|
||
}
|
||
|
||
function isAutoGroupingWave(row: any) {
|
||
const value = String(getStatusValue(row) ?? '').trim().toLowerCase()
|
||
return value === '0' || value === 'pending'
|
||
}
|
||
|
||
function getStatusText(row: any) {
|
||
const value = getStatusValue(row)
|
||
return waveStatusTextMap[String(value)] || (value ?? '—')
|
||
}
|
||
|
||
function getStatusTagType(row: any) {
|
||
const value = String(getStatusValue(row) ?? '')
|
||
if (value === '-1' || value === 'cancelled') return 'danger'
|
||
if (value === '0' || value === 'pending') return 'warning'
|
||
if (value === '1' || value === '2' || value === 'assigned') return 'success'
|
||
if (value === '3' || value === '4') return 'primary'
|
||
if (value === '5' || value === '6') return 'info'
|
||
return 'info'
|
||
}
|
||
|
||
function getWaveTypeText(row: any) {
|
||
const value = String(row?.wave_type ?? '')
|
||
return waveTypeTextMap[value] || (value || '—')
|
||
}
|
||
|
||
function getOrderCount(row: any) {
|
||
return row?.order_count ?? row?.total_orders ?? row?.total_order_count ?? row?.orders_count ?? row?.count ?? 0
|
||
}
|
||
|
||
function getProcessedOrders(row: any) {
|
||
return row?.processed_orders ?? row?.done_orders ?? 0
|
||
}
|
||
|
||
function getStorageAssignmentStatusText(row: any) {
|
||
const rawValue = row?.storage_assignment_status
|
||
const text = String(rawValue ?? '').trim()
|
||
if (!text) return '—'
|
||
|
||
const normalized = text.toLowerCase()
|
||
if (waveStorageAssignmentStatusTextMap[normalized] !== undefined) {
|
||
return waveStorageAssignmentStatusTextMap[normalized]
|
||
}
|
||
|
||
return text
|
||
}
|
||
|
||
function getItemSnapshotText(row: any) {
|
||
return row?.item_snapshot_key || row?.item_detail_machine || row?.item_detail || '—'
|
||
}
|
||
|
||
function formatDateTime(value: string | number | null | undefined) {
|
||
if (!value) return '—'
|
||
let normalizedValue: string | number = value
|
||
if (typeof value === 'string' && /^\d+$/.test(value.trim())) {
|
||
const numericValue = Number(value.trim())
|
||
normalizedValue = value.trim().length <= 10 ? numericValue * 1000 : numericValue
|
||
} else if (typeof value === 'number' && Number.isFinite(value) && value > 0 && value < 1000000000000) {
|
||
normalizedValue = value * 1000
|
||
}
|
||
|
||
const date = new Date(normalizedValue)
|
||
if (Number.isNaN(date.getTime())) return String(value)
|
||
const y = date.getFullYear()
|
||
const m = String(date.getMonth() + 1).padStart(2, '0')
|
||
const d = String(date.getDate()).padStart(2, '0')
|
||
const hh = String(date.getHours()).padStart(2, '0')
|
||
const mm = String(date.getMinutes()).padStart(2, '0')
|
||
const ss = String(date.getSeconds()).padStart(2, '0')
|
||
return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
|
||
}
|
||
|
||
function getSelectedWaveIds() {
|
||
return selectionRows.value
|
||
.map((row: any) => row?.id ?? row?.wave_id ?? row?.batch_id)
|
||
.filter((id: unknown) => id !== undefined && id !== null && id !== '')
|
||
}
|
||
|
||
async function handleBatchAutoGrouping() {
|
||
if (!selectionRows.value.length) {
|
||
ElMessage.warning('请先勾选要修改的波次')
|
||
return
|
||
}
|
||
|
||
const ids = getSelectedWaveIds()
|
||
if (!ids.length) {
|
||
ElMessage.warning('当前勾选记录缺少可用的波次 ID')
|
||
return
|
||
}
|
||
|
||
try {
|
||
await ElMessageBox.confirm(
|
||
`确定要将 ${ids.length} 个波次批量修改为自动加团中吗?仅会作用当前登录仓库命中的波次。`,
|
||
'批量改为自动加团',
|
||
{ type: 'warning', confirmButtonText: '确认修改', cancelButtonText: '取消' }
|
||
)
|
||
} catch {
|
||
return
|
||
}
|
||
|
||
batchAutoGroupingLoading.value = true
|
||
try {
|
||
const res = await orderWaveBatchAutoGrouping({ ids }) as WaveBatchAutoGroupingResponse & { code?: number; message?: string }
|
||
if (!res || !okCode(res.code)) {
|
||
throw new Error(res?.message || '批量修改自动加团状态失败')
|
||
}
|
||
ElMessage.success(res?.message || '批量修改为自动加团成功')
|
||
selectionRows.value = []
|
||
hasSelection.value = false
|
||
await loadData()
|
||
} catch (error: any) {
|
||
console.error('batch auto grouping wave failed:', error)
|
||
ElMessage.error(error?.message || '批量修改自动加团状态失败')
|
||
} finally {
|
||
batchAutoGroupingLoading.value = false
|
||
}
|
||
}
|
||
|
||
async function handleBatchFinishAutoGrouping() {
|
||
if (!selectionRows.value.length) {
|
||
ElMessage.warning('请先勾选要结束自动加团的波次')
|
||
return
|
||
}
|
||
|
||
const ids = getSelectedWaveIds()
|
||
if (!ids.length) {
|
||
ElMessage.warning('当前勾选记录缺少可用的波次 ID')
|
||
return
|
||
}
|
||
|
||
try {
|
||
await ElMessageBox.confirm(
|
||
`确定要将 ${ids.length} 个波次批量结束自动加团吗?仅会作用当前登录仓库命中且处于自动加团中的波次。`,
|
||
'批量结束自动加团',
|
||
{ type: 'warning', confirmButtonText: '确认结束', cancelButtonText: '取消' }
|
||
)
|
||
} catch {
|
||
return
|
||
}
|
||
|
||
batchFinishAutoGroupingLoading.value = true
|
||
try {
|
||
const res = await orderWaveBatchFinishAutoGrouping({ ids }) as WaveBatchFinishAutoGroupingResponse & { code?: number; message?: string }
|
||
if (!res || !okCode(res.code)) {
|
||
throw new Error(res?.message || '批量结束自动加团失败')
|
||
}
|
||
ElMessage.success(res?.message || '批量结束自动加团成功')
|
||
selectionRows.value = []
|
||
hasSelection.value = false
|
||
await loadData()
|
||
} catch (error: any) {
|
||
console.error('batch finish auto grouping wave failed:', error)
|
||
ElMessage.error(error?.message || '批量结束自动加团失败')
|
||
} finally {
|
||
batchFinishAutoGroupingLoading.value = false
|
||
}
|
||
}
|
||
|
||
function unwrapWavePrintPayload(res: any) {
|
||
const inner =
|
||
res?.data !== undefined && res?.data !== null && typeof res.data === 'object' && !Array.isArray(res.data)
|
||
? res.data
|
||
: res
|
||
const summaryRaw = inner?.summary
|
||
const summary =
|
||
summaryRaw !== undefined && summaryRaw !== null && typeof summaryRaw === 'object' && !Array.isArray(summaryRaw)
|
||
? (summaryRaw as Record<string, unknown>)
|
||
: {}
|
||
const waveListRaw = inner?.wave_list
|
||
const wave_list = Array.isArray(waveListRaw)
|
||
? (waveListRaw.filter((x) => x && typeof x === 'object') as Record<string, unknown>[])
|
||
: []
|
||
const extRaw = inner?.ext
|
||
const ext =
|
||
extRaw !== undefined && extRaw !== null && typeof extRaw === 'object' && !Array.isArray(extRaw)
|
||
? (extRaw as Record<string, unknown>)
|
||
: undefined
|
||
return { summary, wave_list, ext }
|
||
}
|
||
|
||
function getWaveOrders(wave: Record<string, unknown>) {
|
||
const keys = ['orders', 'order_list', 'order_details', 'items', 'print_orders', 'order_rows', 'details']
|
||
for (const key of keys) {
|
||
const value = wave[key]
|
||
if (Array.isArray(value)) return value
|
||
}
|
||
return []
|
||
}
|
||
|
||
function toWavePrintForm(wave: Record<string, unknown>) {
|
||
const details = getWaveOrders(wave)
|
||
return {
|
||
...wave,
|
||
wave_no: String(wave.wave_no ?? wave.batch_no ?? wave.wave_code ?? wave.id ?? '—'),
|
||
details
|
||
}
|
||
}
|
||
|
||
function rowWaveKey(row: any) {
|
||
return String(row?.id ?? row?.wave_id ?? row?.batch_id ?? row?.wave_no ?? '')
|
||
}
|
||
|
||
async function loadWavePrintFormData(row: any) {
|
||
const key = rowWaveKey(row)
|
||
return wavePrintDataMap.value[key] || toWavePrintForm(row || {})
|
||
}
|
||
|
||
async function openBatchPrintDialog(rows: any[]) {
|
||
const first = rows[0] as Record<string, unknown>
|
||
const warehouseId = Number(first?.warehouse_id ?? userStore.user?.warehouse_id ?? userStore.user?.store_id)
|
||
if (!Number.isFinite(warehouseId) || warehouseId <= 0) {
|
||
ElMessage.error('无法确定仓库 ID,请确认列表中的仓库字段或当前登录仓库上下文')
|
||
return
|
||
}
|
||
|
||
const wave_ids = rows
|
||
.map((row: any) => row?.id ?? row?.wave_id ?? row?.batch_id)
|
||
.filter((id: unknown) => id !== undefined && id !== null && id !== '')
|
||
|
||
if (!wave_ids.length) {
|
||
ElMessage.warning('当前勾选记录缺少可用的波次 ID')
|
||
return
|
||
}
|
||
|
||
batchPrintLoading.value = true
|
||
try {
|
||
const res: any = await getWavePrintData({ warehouse_id: warehouseId, wave_ids })
|
||
const payload = unwrapWavePrintPayload(res)
|
||
const waveList = Array.isArray(payload.wave_list) ? payload.wave_list : []
|
||
const nextMap: Record<string, any> = {}
|
||
waveList.forEach((wave: Record<string, unknown>) => {
|
||
const key = String(wave.id ?? wave.wave_id ?? wave.batch_id ?? wave.wave_no ?? '')
|
||
if (!key) return
|
||
nextMap[key] = toWavePrintForm(wave)
|
||
})
|
||
wavePrintRows.value = rows.map((item: any) => ({
|
||
...item,
|
||
wave_no: String(item?.wave_no ?? item?.batch_no ?? item?.wave_code ?? item?.id ?? '—')
|
||
}))
|
||
wavePrintDataMap.value = nextMap
|
||
wavePrintDialogVisible.value = true
|
||
const waveCount = waveList.length
|
||
ElMessage.success(res?.message || `已获取打印数据,返回 ${waveCount} 个波次`)
|
||
} catch (error: any) {
|
||
wavePrintRows.value = []
|
||
wavePrintDataMap.value = {}
|
||
ElMessage.error(error?.message || '获取波次打印数据失败')
|
||
} finally {
|
||
batchPrintLoading.value = false
|
||
}
|
||
}
|
||
|
||
async function handleBatchPrint() {
|
||
if (!isGroupWaveTab.value) {
|
||
ElMessage.warning('批量打印仅在「团购波次」页签可用')
|
||
return
|
||
}
|
||
|
||
if (!selectionRows.value.length) {
|
||
ElMessage.warning('请先勾选要打印的波次')
|
||
return
|
||
}
|
||
|
||
const autoGroupingRows = [...autoGroupingSelectionRows.value]
|
||
const removedCount = autoGroupingRows.length
|
||
|
||
if (removedCount) {
|
||
autoGroupingRows.forEach((row: any) => {
|
||
upperTable.value?.toggleRowSelection?.(row, false)
|
||
})
|
||
}
|
||
|
||
if (!printableSelectionRows.value.length) {
|
||
ElMessage.warning('自动加团中的波次不参与批量打印,已从当前勾选中移除')
|
||
return
|
||
}
|
||
|
||
if (waveMaxOrderLimit.value !== null && selectedWaveOrderTotal.value > waveMaxOrderLimit.value) {
|
||
ElMessage.warning(`选中波次总订单数为 ${selectedWaveOrderTotal.value},超过仓库配置上限 ${waveMaxOrderLimit.value} 单,暂不允许批量打印`)
|
||
return
|
||
}
|
||
if (waveMaxOrderLimit.value === null) {
|
||
ElMessage.warning('未获取到仓库波次最大订单数量配置,暂无法执行批量打印')
|
||
return
|
||
}
|
||
|
||
if (removedCount) {
|
||
ElMessage.warning(`已自动移除 ${removedCount} 个“自动加团中”波次,不计入批量打印`)
|
||
}
|
||
|
||
const rows = printableSelectionRows.value
|
||
await openBatchPrintDialog(rows)
|
||
}
|
||
|
||
async function handleBatchPrintPickingList() {
|
||
if (!selectionRows.value.length) {
|
||
ElMessage.warning('请先勾选要打印拣货单的波次')
|
||
return
|
||
}
|
||
|
||
const rows = [...selectionRows.value]
|
||
await openBatchPrintDialog(rows)
|
||
}
|
||
|
||
async function handleBatchPlatformPrint() {
|
||
if (!selectionRows.value.length) {
|
||
ElMessage.warning('请先勾选要打印的波次')
|
||
return
|
||
}
|
||
|
||
const autoGroupingRows = [...autoGroupingSelectionRows.value]
|
||
const removedCount = autoGroupingRows.length
|
||
if (removedCount) {
|
||
autoGroupingRows.forEach((row: any) => {
|
||
upperTable.value?.toggleRowSelection?.(row, false)
|
||
})
|
||
}
|
||
|
||
if (!printableSelectionRows.value.length) {
|
||
ElMessage.warning('自动加团中的波次不参与批量打印(平台),已从当前勾选中移除')
|
||
return
|
||
}
|
||
|
||
if (removedCount) {
|
||
ElMessage.warning(`已自动移除 ${removedCount} 个「自动加团中」波次,不参与批量打印(平台)`)
|
||
}
|
||
|
||
const rows = printableSelectionRows.value
|
||
const first = rows[0] as Record<string, unknown>
|
||
const warehouseId = Number(first?.warehouse_id ?? userStore.user?.warehouse_id ?? userStore.user?.store_id)
|
||
if (!Number.isFinite(warehouseId) || warehouseId <= 0) {
|
||
ElMessage.error('无法确定仓库 ID,请确认列表中的仓库字段或当前登录仓库上下文')
|
||
return
|
||
}
|
||
|
||
const wave_ids = rows
|
||
.map((row: any) => row?.id ?? row?.wave_id ?? row?.batch_id)
|
||
.filter((id: unknown) => id !== undefined && id !== null && id !== '')
|
||
|
||
if (!wave_ids.length) {
|
||
ElMessage.warning('当前勾选记录缺少可用的波次 ID')
|
||
return
|
||
}
|
||
|
||
platformPrintRequestMeta.value = { warehouse_id: warehouseId, wave_ids }
|
||
platformPrintErrorMessage.value = ''
|
||
platformPrintPayload.value = null
|
||
batchPlatformPrintLoading.value = true
|
||
try {
|
||
const res: any = await getWavePlatformPrintData({ warehouse_id: warehouseId, wave_ids })
|
||
if (res?.code !== undefined && res?.code !== null && !okCode(res.code)) {
|
||
throw new Error(res?.message || '获取平台打印数据失败')
|
||
}
|
||
platformPrintPayload.value = unwrapWavePlatformPrintPayload(res)
|
||
platformPrintDialogVisible.value = true
|
||
ElMessage.success(res?.message || '已获取平台打印数据')
|
||
} catch (error: any) {
|
||
platformPrintPayload.value = null
|
||
platformPrintErrorMessage.value = error?.message || '获取平台打印数据失败'
|
||
platformPrintDialogVisible.value = true
|
||
ElMessage.error(platformPrintErrorMessage.value)
|
||
} finally {
|
||
batchPlatformPrintLoading.value = false
|
||
}
|
||
}
|
||
|
||
function stopFetchTaskPolling() {
|
||
if (fetchTaskPollTimer.value) {
|
||
clearTimeout(fetchTaskPollTimer.value)
|
||
fetchTaskPollTimer.value = null
|
||
}
|
||
}
|
||
|
||
function scheduleFetchTaskPolling(delay = 2000) {
|
||
stopFetchTaskPolling()
|
||
if (!fetchTaskProgress.taskId) return
|
||
fetchTaskPollTimer.value = setTimeout(() => {
|
||
void pollFetchTaskProgress()
|
||
}, delay)
|
||
}
|
||
|
||
function applyFetchTaskProgress(progress: Partial<WaveFetchTaskProgressResponse>) {
|
||
fetchTaskProgress.taskId = String(progress.task_id || fetchTaskProgress.taskId || '')
|
||
fetchTaskProgress.status = resolveAsyncTaskStatus(progress as Record<string, any>, fetchTaskProgress.status || 'submitted')
|
||
fetchTaskProgress.warehouseId = progress.warehouse_id
|
||
fetchTaskProgress.structureCount = Number(progress.structure_count ?? fetchTaskProgress.structureCount ?? 0)
|
||
fetchTaskProgress.finishedStructureCount = Number(progress.finished_structure_count ?? fetchTaskProgress.finishedStructureCount ?? 0)
|
||
fetchTaskProgress.progressPercent = Number(progress.progress_percent ?? fetchTaskProgress.progressPercent ?? 0)
|
||
fetchTaskProgress.totalFetchedQuantity = Number(progress.total_fetched_quantity ?? fetchTaskProgress.totalFetchedQuantity ?? 0)
|
||
fetchTaskProgress.durationMs = Number(progress.duration_ms ?? fetchTaskProgress.durationMs ?? 0)
|
||
fetchTaskProgress.error = String(progress.error || '')
|
||
fetchTaskProgress.updateTime = String(progress.update_time || '')
|
||
fetchTaskProgress.message = String(progress.message || '')
|
||
fetchTaskProgress.fetchMode = String(progress.fetch_mode || '')
|
||
fetchTaskProgress.maxFetchQuantity =
|
||
progress.max_fetch_quantity !== undefined && progress.max_fetch_quantity !== null
|
||
? Number(progress.max_fetch_quantity)
|
||
: undefined
|
||
fetchTaskProgress.limitReached =
|
||
typeof progress.limit_reached === 'boolean' ? progress.limit_reached : undefined
|
||
fetchTaskProgress.stopReason = String(progress.stop_reason || '')
|
||
}
|
||
|
||
function resetFetchTaskProgress() {
|
||
fetchTaskProgress.taskId = ''
|
||
fetchTaskProgress.status = 'submitted'
|
||
fetchTaskProgress.warehouseId = undefined
|
||
fetchTaskProgress.structureCount = 0
|
||
fetchTaskProgress.finishedStructureCount = 0
|
||
fetchTaskProgress.progressPercent = 0
|
||
fetchTaskProgress.totalFetchedQuantity = 0
|
||
fetchTaskProgress.durationMs = 0
|
||
fetchTaskProgress.error = ''
|
||
fetchTaskProgress.updateTime = ''
|
||
fetchTaskProgress.message = ''
|
||
fetchTaskProgress.fetchMode = ''
|
||
fetchTaskProgress.maxFetchQuantity = undefined
|
||
fetchTaskProgress.limitReached = undefined
|
||
fetchTaskProgress.stopReason = ''
|
||
}
|
||
|
||
async function pollFetchTaskProgress() {
|
||
if (!fetchTaskProgress.taskId) return
|
||
try {
|
||
const res = await orderWaveFetchTaskProgress({ task_id: fetchTaskProgress.taskId }) as WaveFetchTaskProgressResponse & { code?: number; message?: string }
|
||
if (!res || !okCode(res.code)) {
|
||
throw new Error(res?.message || '获取抓取任务进度失败')
|
||
}
|
||
|
||
applyFetchTaskProgress(res)
|
||
|
||
if (fetchTaskProgress.status === 'failed' || fetchTaskProgress.status === 'not_found') {
|
||
stopFetchTaskPolling()
|
||
await loadData()
|
||
resetFetchTaskProgress()
|
||
return
|
||
}
|
||
|
||
if (fetchTaskProgress.status === 'success' || Number(fetchTaskProgress.progressPercent || 0) >= 100) {
|
||
stopFetchTaskPolling()
|
||
await loadData()
|
||
resetFetchTaskProgress()
|
||
return
|
||
}
|
||
|
||
scheduleFetchTaskPolling()
|
||
} catch (error) {
|
||
console.error('poll fetch task progress failed:', error)
|
||
scheduleFetchTaskPolling(4000)
|
||
}
|
||
}
|
||
|
||
function normalizeAsyncTaskStatus(value: unknown) {
|
||
return String(value ?? '').trim().toLowerCase()
|
||
}
|
||
|
||
function resolveAsyncTaskStatus(progress: Record<string, any>, fallback = 'submitted') {
|
||
return String(progress.status ?? progress.state ?? progress.task_status ?? fallback)
|
||
}
|
||
|
||
function isAsyncTaskSuccessStatus(status: string) {
|
||
return ['success', 'succeeded', 'finished', 'fin', 'done', 'completed', 'complete'].includes(status)
|
||
}
|
||
|
||
function isAsyncTaskFailureStatus(status: string) {
|
||
return ['failed', 'failure', 'error', 'exception', 'cancel', 'cancelled', 'canceled', 'timeout', 'not_found'].includes(status)
|
||
}
|
||
|
||
function stopBatchAllocateExpressTaskPolling() {
|
||
if (batchAllocateExpressTaskPollTimer.value) {
|
||
clearTimeout(batchAllocateExpressTaskPollTimer.value)
|
||
batchAllocateExpressTaskPollTimer.value = null
|
||
}
|
||
}
|
||
|
||
function scheduleBatchAllocateExpressTaskPolling(delay = 2000) {
|
||
stopBatchAllocateExpressTaskPolling()
|
||
if (!batchAllocateExpressTaskProgress.taskId) return
|
||
batchAllocateExpressTaskPollTimer.value = setTimeout(() => {
|
||
void pollBatchAllocateExpressTaskProgress()
|
||
}, delay)
|
||
}
|
||
|
||
function applyBatchAllocateExpressTaskProgress(progress: Partial<WaveBatchAllocateExpressTaskProgressResponse> & Record<string, any>) {
|
||
batchAllocateExpressTaskProgress.taskId = String(progress.task_id || batchAllocateExpressTaskProgress.taskId || '')
|
||
batchAllocateExpressTaskProgress.status = resolveAsyncTaskStatus(progress, batchAllocateExpressTaskProgress.status || 'submitted')
|
||
batchAllocateExpressTaskProgress.totalCount = Number(
|
||
progress.total_count
|
||
?? progress.total_order_count
|
||
?? batchAllocateExpressTaskProgress.totalCount
|
||
?? 0
|
||
)
|
||
batchAllocateExpressTaskProgress.successCount = Number(
|
||
progress.success_count
|
||
?? progress.allocated_order_count
|
||
?? progress.updated_count
|
||
?? batchAllocateExpressTaskProgress.successCount
|
||
?? 0
|
||
)
|
||
batchAllocateExpressTaskProgress.failedCount = Number(
|
||
progress.failed_count
|
||
?? progress.failed_order_count
|
||
?? batchAllocateExpressTaskProgress.failedCount
|
||
?? 0
|
||
)
|
||
batchAllocateExpressTaskProgress.progressPercent = Number(progress.progress_percent ?? batchAllocateExpressTaskProgress.progressPercent ?? 0)
|
||
batchAllocateExpressTaskProgress.durationMs = Number(progress.duration_ms ?? batchAllocateExpressTaskProgress.durationMs ?? 0)
|
||
batchAllocateExpressTaskProgress.updateTime = String(progress.update_time || '')
|
||
batchAllocateExpressTaskProgress.error = String(progress.error_message || progress.error || '')
|
||
batchAllocateExpressTaskProgress.message = String(progress.message || '')
|
||
}
|
||
|
||
function resetBatchAllocateExpressTaskProgress() {
|
||
batchAllocateExpressTaskProgress.taskId = ''
|
||
batchAllocateExpressTaskProgress.status = 'submitted'
|
||
batchAllocateExpressTaskProgress.totalCount = 0
|
||
batchAllocateExpressTaskProgress.successCount = 0
|
||
batchAllocateExpressTaskProgress.failedCount = 0
|
||
batchAllocateExpressTaskProgress.progressPercent = 0
|
||
batchAllocateExpressTaskProgress.durationMs = 0
|
||
batchAllocateExpressTaskProgress.updateTime = ''
|
||
batchAllocateExpressTaskProgress.error = ''
|
||
batchAllocateExpressTaskProgress.message = ''
|
||
}
|
||
|
||
function stopBatchAllocateStorageTaskPolling() {
|
||
if (batchAllocateStorageTaskPollTimer.value) {
|
||
clearTimeout(batchAllocateStorageTaskPollTimer.value)
|
||
batchAllocateStorageTaskPollTimer.value = null
|
||
}
|
||
}
|
||
|
||
function scheduleBatchAllocateStorageTaskPolling(delay = 2000) {
|
||
stopBatchAllocateStorageTaskPolling()
|
||
if (!batchAllocateStorageTaskProgress.taskId) return
|
||
batchAllocateStorageTaskPollTimer.value = setTimeout(() => {
|
||
void pollBatchAllocateStorageTaskProgress()
|
||
}, delay)
|
||
}
|
||
|
||
function applyBatchAllocateStorageTaskProgress(progress: Partial<WaveBatchAllocateStorageTaskProgressResponse> & Record<string, any>) {
|
||
batchAllocateStorageTaskProgress.taskId = String(progress.task_id || batchAllocateStorageTaskProgress.taskId || '')
|
||
batchAllocateStorageTaskProgress.status = resolveAsyncTaskStatus(progress, batchAllocateStorageTaskProgress.status || 'submitted')
|
||
batchAllocateStorageTaskProgress.totalCount = Number(
|
||
progress.total_count
|
||
?? progress.total_order_count
|
||
?? progress.total_wave_count
|
||
?? batchAllocateStorageTaskProgress.totalCount
|
||
?? 0
|
||
)
|
||
batchAllocateStorageTaskProgress.successCount = Number(
|
||
progress.success_count
|
||
?? progress.processed_order_count
|
||
?? progress.allocated_order_count
|
||
?? progress.updated_count
|
||
?? batchAllocateStorageTaskProgress.successCount
|
||
?? 0
|
||
)
|
||
batchAllocateStorageTaskProgress.failedCount = Number(
|
||
progress.failed_count
|
||
?? progress.failed_order_count
|
||
?? batchAllocateStorageTaskProgress.failedCount
|
||
?? 0
|
||
)
|
||
batchAllocateStorageTaskProgress.progressPercent = Number(progress.progress_percent ?? batchAllocateStorageTaskProgress.progressPercent ?? 0)
|
||
batchAllocateStorageTaskProgress.durationMs = Number(progress.duration_ms ?? batchAllocateStorageTaskProgress.durationMs ?? 0)
|
||
batchAllocateStorageTaskProgress.updateTime = String(progress.update_time || '')
|
||
batchAllocateStorageTaskProgress.error = String(progress.error_message || progress.error || '')
|
||
batchAllocateStorageTaskProgress.message = String(progress.message || '')
|
||
}
|
||
|
||
function resetBatchAllocateStorageTaskProgress() {
|
||
batchAllocateStorageTaskProgress.taskId = ''
|
||
batchAllocateStorageTaskProgress.status = 'submitted'
|
||
batchAllocateStorageTaskProgress.totalCount = 0
|
||
batchAllocateStorageTaskProgress.successCount = 0
|
||
batchAllocateStorageTaskProgress.failedCount = 0
|
||
batchAllocateStorageTaskProgress.progressPercent = 0
|
||
batchAllocateStorageTaskProgress.durationMs = 0
|
||
batchAllocateStorageTaskProgress.updateTime = ''
|
||
batchAllocateStorageTaskProgress.error = ''
|
||
batchAllocateStorageTaskProgress.message = ''
|
||
}
|
||
|
||
function stopBatchRemoveExceptionOrdersTaskPolling() {
|
||
if (batchRemoveExceptionOrdersTaskPollTimer.value) {
|
||
clearTimeout(batchRemoveExceptionOrdersTaskPollTimer.value)
|
||
batchRemoveExceptionOrdersTaskPollTimer.value = null
|
||
}
|
||
}
|
||
|
||
function scheduleBatchRemoveExceptionOrdersTaskPolling(delay = 2000) {
|
||
stopBatchRemoveExceptionOrdersTaskPolling()
|
||
if (!batchRemoveExceptionOrdersTaskProgress.taskId) return
|
||
batchRemoveExceptionOrdersTaskPollTimer.value = setTimeout(() => {
|
||
void pollBatchRemoveExceptionOrdersTaskProgress()
|
||
}, delay)
|
||
}
|
||
|
||
function applyBatchRemoveExceptionOrdersTaskProgress(progress: Partial<WaveBatchRemoveExceptionOrdersTaskProgressResponse> & Record<string, any>) {
|
||
batchRemoveExceptionOrdersTaskProgress.taskId = String(progress.task_id || batchRemoveExceptionOrdersTaskProgress.taskId || '')
|
||
batchRemoveExceptionOrdersTaskProgress.status = resolveAsyncTaskStatus(progress, batchRemoveExceptionOrdersTaskProgress.status || 'submitted')
|
||
batchRemoveExceptionOrdersTaskProgress.totalCount = Number(
|
||
progress.total_count
|
||
?? progress.total_order_count
|
||
?? batchRemoveExceptionOrdersTaskProgress.totalCount
|
||
?? 0
|
||
)
|
||
batchRemoveExceptionOrdersTaskProgress.successCount = Number(
|
||
progress.success_count
|
||
?? progress.removed_order_count
|
||
?? progress.updated_count
|
||
?? batchRemoveExceptionOrdersTaskProgress.successCount
|
||
?? 0
|
||
)
|
||
batchRemoveExceptionOrdersTaskProgress.failedCount = Number(
|
||
progress.failed_count
|
||
?? progress.failed_order_count
|
||
?? batchRemoveExceptionOrdersTaskProgress.failedCount
|
||
?? 0
|
||
)
|
||
batchRemoveExceptionOrdersTaskProgress.progressPercent = Number(progress.progress_percent ?? batchRemoveExceptionOrdersTaskProgress.progressPercent ?? 0)
|
||
batchRemoveExceptionOrdersTaskProgress.durationMs = Number(progress.duration_ms ?? batchRemoveExceptionOrdersTaskProgress.durationMs ?? 0)
|
||
batchRemoveExceptionOrdersTaskProgress.updateTime = String(progress.update_time || '')
|
||
batchRemoveExceptionOrdersTaskProgress.error = String(progress.error_message || progress.error || '')
|
||
batchRemoveExceptionOrdersTaskProgress.message = String(progress.message || '')
|
||
}
|
||
|
||
function resetBatchRemoveExceptionOrdersTaskProgress() {
|
||
batchRemoveExceptionOrdersTaskProgress.taskId = ''
|
||
batchRemoveExceptionOrdersTaskProgress.status = 'submitted'
|
||
batchRemoveExceptionOrdersTaskProgress.totalCount = 0
|
||
batchRemoveExceptionOrdersTaskProgress.successCount = 0
|
||
batchRemoveExceptionOrdersTaskProgress.failedCount = 0
|
||
batchRemoveExceptionOrdersTaskProgress.progressPercent = 0
|
||
batchRemoveExceptionOrdersTaskProgress.durationMs = 0
|
||
batchRemoveExceptionOrdersTaskProgress.updateTime = ''
|
||
batchRemoveExceptionOrdersTaskProgress.error = ''
|
||
batchRemoveExceptionOrdersTaskProgress.message = ''
|
||
}
|
||
|
||
function stopBatchCancelTaskPolling() {
|
||
if (batchCancelTaskPollTimer.value) {
|
||
clearTimeout(batchCancelTaskPollTimer.value)
|
||
batchCancelTaskPollTimer.value = null
|
||
}
|
||
}
|
||
|
||
function scheduleBatchCancelTaskPolling(delay = 2000) {
|
||
stopBatchCancelTaskPolling()
|
||
if (!batchCancelTaskProgress.taskId) return
|
||
batchCancelTaskPollTimer.value = setTimeout(() => {
|
||
void pollBatchCancelTaskProgress()
|
||
}, delay)
|
||
}
|
||
|
||
function applyBatchCancelTaskProgress(progress: Partial<WaveBatchCancelTaskProgressResponse> & Record<string, any>) {
|
||
batchCancelTaskProgress.taskId = String(progress.task_id || batchCancelTaskProgress.taskId || '')
|
||
batchCancelTaskProgress.status = resolveAsyncTaskStatus(progress, batchCancelTaskProgress.status || 'submitted')
|
||
batchCancelTaskProgress.totalCount = Number(
|
||
progress.total_count
|
||
?? progress.total_wave_count
|
||
?? batchCancelTaskProgress.totalCount
|
||
?? 0
|
||
)
|
||
batchCancelTaskProgress.successCount = Number(
|
||
progress.success_count
|
||
?? progress.processed_wave_count
|
||
?? batchCancelTaskProgress.successCount
|
||
?? 0
|
||
)
|
||
batchCancelTaskProgress.failedCount = Number(
|
||
progress.failed_count
|
||
?? batchCancelTaskProgress.failedCount
|
||
?? 0
|
||
)
|
||
batchCancelTaskProgress.progressPercent = Number(progress.progress_percent ?? batchCancelTaskProgress.progressPercent ?? 0)
|
||
batchCancelTaskProgress.durationMs = Number(progress.duration_ms ?? batchCancelTaskProgress.durationMs ?? 0)
|
||
batchCancelTaskProgress.updateTime = String(progress.update_time || '')
|
||
batchCancelTaskProgress.error = String(progress.error_message || progress.error || '')
|
||
batchCancelTaskProgress.message = String(progress.message || '')
|
||
}
|
||
|
||
function resetBatchCancelTaskProgress() {
|
||
batchCancelTaskProgress.taskId = ''
|
||
batchCancelTaskProgress.status = 'submitted'
|
||
batchCancelTaskProgress.totalCount = 0
|
||
batchCancelTaskProgress.successCount = 0
|
||
batchCancelTaskProgress.failedCount = 0
|
||
batchCancelTaskProgress.progressPercent = 0
|
||
batchCancelTaskProgress.durationMs = 0
|
||
batchCancelTaskProgress.updateTime = ''
|
||
batchCancelTaskProgress.error = ''
|
||
batchCancelTaskProgress.message = ''
|
||
}
|
||
|
||
async function pollBatchCancelTaskProgress() {
|
||
if (!batchCancelTaskProgress.taskId) return
|
||
try {
|
||
const res = await orderWaveBatchCancelTaskProgress({ task_id: batchCancelTaskProgress.taskId }) as WaveBatchCancelTaskProgressResponse & { code?: number; message?: string; flag?: string }
|
||
if (!res || !okCode(res.code)) {
|
||
throw new Error(res?.message || '查询批量取消波次任务进度失败')
|
||
}
|
||
|
||
applyBatchCancelTaskProgress(res)
|
||
const normalizedStatus = normalizeAsyncTaskStatus(batchCancelTaskProgress.status)
|
||
|
||
if (isAsyncTaskFailureStatus(normalizedStatus)) {
|
||
stopBatchCancelTaskPolling()
|
||
await loadData()
|
||
resetBatchCancelTaskProgress()
|
||
return
|
||
}
|
||
|
||
if (isAsyncTaskSuccessStatus(normalizedStatus) || Number(batchCancelTaskProgress.progressPercent || 0) >= 100) {
|
||
stopBatchCancelTaskPolling()
|
||
await loadData()
|
||
resetBatchCancelTaskProgress()
|
||
return
|
||
}
|
||
|
||
scheduleBatchCancelTaskPolling()
|
||
} catch (error) {
|
||
console.error('poll batch cancel task progress failed:', error)
|
||
scheduleBatchCancelTaskPolling(4000)
|
||
}
|
||
}
|
||
|
||
async function pollBatchRemoveExceptionOrdersTaskProgress() {
|
||
if (!batchRemoveExceptionOrdersTaskProgress.taskId) return
|
||
try {
|
||
const res = await orderWaveBatchRemoveExceptionOrdersTaskProgress({ task_id: batchRemoveExceptionOrdersTaskProgress.taskId }) as WaveBatchRemoveExceptionOrdersTaskProgressResponse & { code?: number; message?: string }
|
||
if (!res || !okCode(res.code)) {
|
||
throw new Error(res?.message || '查询移除异常订单任务进度失败')
|
||
}
|
||
|
||
applyBatchRemoveExceptionOrdersTaskProgress(res)
|
||
const normalizedStatus = normalizeAsyncTaskStatus(batchRemoveExceptionOrdersTaskProgress.status)
|
||
|
||
if (isAsyncTaskFailureStatus(normalizedStatus)) {
|
||
stopBatchRemoveExceptionOrdersTaskPolling()
|
||
await loadData()
|
||
resetBatchRemoveExceptionOrdersTaskProgress()
|
||
return
|
||
}
|
||
|
||
if (isAsyncTaskSuccessStatus(normalizedStatus) || Number(batchRemoveExceptionOrdersTaskProgress.progressPercent || 0) >= 100) {
|
||
stopBatchRemoveExceptionOrdersTaskPolling()
|
||
await loadData()
|
||
resetBatchRemoveExceptionOrdersTaskProgress()
|
||
return
|
||
}
|
||
|
||
scheduleBatchRemoveExceptionOrdersTaskPolling()
|
||
} catch (error) {
|
||
console.error('poll batch remove exception orders task progress failed:', error)
|
||
scheduleBatchRemoveExceptionOrdersTaskPolling(4000)
|
||
}
|
||
}
|
||
|
||
async function pollBatchAllocateStorageTaskProgress() {
|
||
if (!batchAllocateStorageTaskProgress.taskId) return
|
||
try {
|
||
const res = await orderWaveBatchAllocateStorageTaskProgress({ task_id: batchAllocateStorageTaskProgress.taskId }) as WaveBatchAllocateStorageTaskProgressResponse & { code?: number; message?: string }
|
||
if (!res || !okCode(res.code)) {
|
||
throw new Error(res?.message || '查询储位分配任务进度失败')
|
||
}
|
||
|
||
applyBatchAllocateStorageTaskProgress(res)
|
||
const normalizedStatus = normalizeAsyncTaskStatus(batchAllocateStorageTaskProgress.status)
|
||
|
||
if (isAsyncTaskFailureStatus(normalizedStatus)) {
|
||
stopBatchAllocateStorageTaskPolling()
|
||
await loadData()
|
||
resetBatchAllocateStorageTaskProgress()
|
||
return
|
||
}
|
||
|
||
if (isAsyncTaskSuccessStatus(normalizedStatus) || Number(batchAllocateStorageTaskProgress.progressPercent || 0) >= 100) {
|
||
stopBatchAllocateStorageTaskPolling()
|
||
await loadData()
|
||
resetBatchAllocateStorageTaskProgress()
|
||
return
|
||
}
|
||
|
||
scheduleBatchAllocateStorageTaskPolling()
|
||
} catch (error) {
|
||
console.error('poll batch allocate storage task progress failed:', error)
|
||
scheduleBatchAllocateStorageTaskPolling(4000)
|
||
}
|
||
}
|
||
|
||
async function pollBatchAllocateExpressTaskProgress() {
|
||
if (!batchAllocateExpressTaskProgress.taskId) return
|
||
try {
|
||
const res = await orderWaveBatchAllocateExpressTaskProgress({ task_id: batchAllocateExpressTaskProgress.taskId }) as WaveBatchAllocateExpressTaskProgressResponse & { code?: number; message?: string }
|
||
if (!res || !okCode(res.code)) {
|
||
throw new Error(res?.message || '查询快递号分配任务进度失败')
|
||
}
|
||
|
||
applyBatchAllocateExpressTaskProgress(res)
|
||
const normalizedStatus = normalizeAsyncTaskStatus(batchAllocateExpressTaskProgress.status)
|
||
|
||
if (isAsyncTaskFailureStatus(normalizedStatus)) {
|
||
stopBatchAllocateExpressTaskPolling()
|
||
await loadData()
|
||
resetBatchAllocateExpressTaskProgress()
|
||
return
|
||
}
|
||
|
||
if (isAsyncTaskSuccessStatus(normalizedStatus) || Number(batchAllocateExpressTaskProgress.progressPercent || 0) >= 100) {
|
||
stopBatchAllocateExpressTaskPolling()
|
||
await loadData()
|
||
resetBatchAllocateExpressTaskProgress()
|
||
return
|
||
}
|
||
|
||
scheduleBatchAllocateExpressTaskPolling()
|
||
} catch (error) {
|
||
console.error('poll batch allocate express task progress failed:', error)
|
||
scheduleBatchAllocateExpressTaskPolling(4000)
|
||
}
|
||
}
|
||
|
||
async function handleBatchAllocateExpress() {
|
||
if (!selectionRows.value.length) {
|
||
ElMessage.warning('请先勾选要分配快递号的波次')
|
||
return
|
||
}
|
||
|
||
const wave_ids = getSelectedWaveIds()
|
||
if (!wave_ids.length) {
|
||
ElMessage.warning('当前勾选记录缺少可用的波次 ID')
|
||
return
|
||
}
|
||
|
||
try {
|
||
await ElMessageBox.confirm(
|
||
`确定要为选中的 ${wave_ids.length} 个波次提交快递号分配任务吗?`,
|
||
'批次分配快递号',
|
||
{ type: 'warning', confirmButtonText: '确认提交', cancelButtonText: '取消' }
|
||
)
|
||
} catch {
|
||
return
|
||
}
|
||
|
||
batchAllocateExpressLoading.value = true
|
||
try {
|
||
const res = await orderWaveBatchAllocateExpress({ wave_ids }) as WaveBatchAllocateExpressResponse & { code?: number; message?: string }
|
||
if (!res || !okCode(res.code)) {
|
||
throw new Error(res?.message || '提交批次分配快递号任务失败')
|
||
}
|
||
|
||
const taskId = String(res?.task_id || '').trim()
|
||
if (!taskId) {
|
||
resetBatchAllocateExpressTaskProgress()
|
||
ElMessage.success(res?.message || '快递号分配任务已提交')
|
||
await loadData()
|
||
return
|
||
}
|
||
|
||
applyBatchAllocateExpressTaskProgress({
|
||
task_id: taskId,
|
||
status: 'submitted',
|
||
total_count: wave_ids.length,
|
||
success_count: 0,
|
||
failed_count: 0,
|
||
progress_percent: 0,
|
||
message: res?.message || '快递号分配任务已受理'
|
||
})
|
||
|
||
selectionRows.value = []
|
||
hasSelection.value = false
|
||
ElMessage.success((res?.message || '快递号分配任务已受理') + `(任务ID:${taskId})`)
|
||
scheduleBatchAllocateExpressTaskPolling(1000)
|
||
} catch (error: any) {
|
||
console.error('submit batch allocate express task failed:', error)
|
||
ElMessage.error(error?.message || '提交批次分配快递号任务失败')
|
||
} finally {
|
||
batchAllocateExpressLoading.value = false
|
||
}
|
||
}
|
||
|
||
async function handleBatchAllocateStorage() {
|
||
if (!selectionRows.value.length) {
|
||
ElMessage.warning('请先勾选要分配储位的波次')
|
||
return
|
||
}
|
||
|
||
const wave_ids = getSelectedWaveIds()
|
||
if (!wave_ids.length) {
|
||
ElMessage.warning('当前勾选记录缺少可用的波次 ID')
|
||
return
|
||
}
|
||
|
||
try {
|
||
await ElMessageBox.confirm(
|
||
`确定要为选中的 ${wave_ids.length} 个波次提交储位分配任务吗?`,
|
||
'批量分配储位',
|
||
{ type: 'warning', confirmButtonText: '确认提交', cancelButtonText: '取消' }
|
||
)
|
||
} catch {
|
||
return
|
||
}
|
||
|
||
batchAllocateStorageLoading.value = true
|
||
try {
|
||
const res = await orderWaveBatchAllocateStorage({ wave_ids }) as WaveBatchAllocateStorageResponse & { code?: number; message?: string }
|
||
if (!res || !okCode(res.code)) {
|
||
throw new Error(res?.message || '提交批量分配储位任务失败')
|
||
}
|
||
|
||
const taskId = String(res?.task_id || '').trim()
|
||
if (!taskId) {
|
||
resetBatchAllocateStorageTaskProgress()
|
||
ElMessage.success(res?.message || '储位分配任务已提交')
|
||
await loadData()
|
||
return
|
||
}
|
||
|
||
applyBatchAllocateStorageTaskProgress({
|
||
task_id: taskId,
|
||
status: 'submitted',
|
||
total_count: wave_ids.length,
|
||
success_count: 0,
|
||
failed_count: 0,
|
||
progress_percent: 0,
|
||
message: res?.message || '储位分配任务已受理'
|
||
})
|
||
|
||
selectionRows.value = []
|
||
hasSelection.value = false
|
||
ElMessage.success((res?.message || '储位分配任务已受理') + `(任务ID:${taskId})`)
|
||
scheduleBatchAllocateStorageTaskPolling(1000)
|
||
} catch (error: any) {
|
||
console.error('submit batch allocate storage task failed:', error)
|
||
ElMessage.error(error?.message || '提交批量分配储位任务失败')
|
||
} finally {
|
||
batchAllocateStorageLoading.value = false
|
||
}
|
||
}
|
||
|
||
async function handleBatchRemoveExceptionOrders() {
|
||
if (!selectionRows.value.length) {
|
||
ElMessage.warning('请先勾选要移除异常订单的波次')
|
||
return
|
||
}
|
||
|
||
const wave_ids = getSelectedWaveIds()
|
||
if (!wave_ids.length) {
|
||
ElMessage.warning('当前勾选记录缺少可用的波次 ID')
|
||
return
|
||
}
|
||
|
||
try {
|
||
await ElMessageBox.confirm(
|
||
`确定要为选中的 ${wave_ids.length} 个波次提交移除异常订单任务吗?`,
|
||
'批量移除异常订单',
|
||
{ type: 'warning', confirmButtonText: '确认提交', cancelButtonText: '取消' }
|
||
)
|
||
} catch {
|
||
return
|
||
}
|
||
|
||
batchRemoveExceptionOrdersLoading.value = true
|
||
try {
|
||
const res = await orderWaveBatchRemoveExceptionOrders({ wave_ids }) as WaveBatchRemoveExceptionOrdersResponse & { code?: number; message?: string }
|
||
if (!res || !okCode(res.code)) {
|
||
throw new Error(res?.message || '提交批量移除异常订单任务失败')
|
||
}
|
||
|
||
const taskId = String(res?.task_id || '').trim()
|
||
if (!taskId) {
|
||
resetBatchRemoveExceptionOrdersTaskProgress()
|
||
ElMessage.success(res?.message || '移除异常订单任务已提交')
|
||
await loadData()
|
||
return
|
||
}
|
||
|
||
applyBatchRemoveExceptionOrdersTaskProgress({
|
||
task_id: taskId,
|
||
status: 'submitted',
|
||
total_count: wave_ids.length,
|
||
success_count: 0,
|
||
failed_count: 0,
|
||
progress_percent: 0,
|
||
message: res?.message || '移除异常订单任务已受理'
|
||
})
|
||
|
||
selectionRows.value = []
|
||
hasSelection.value = false
|
||
ElMessage.success((res?.message || '移除异常订单任务已受理') + `(任务ID:${taskId})`)
|
||
scheduleBatchRemoveExceptionOrdersTaskPolling(1000)
|
||
} catch (error: any) {
|
||
console.error('submit batch remove exception orders task failed:', error)
|
||
ElMessage.error(error?.message || '提交批量移除异常订单任务失败')
|
||
} finally {
|
||
batchRemoveExceptionOrdersLoading.value = false
|
||
}
|
||
}
|
||
|
||
async function handleBatchCancel() {
|
||
if (!selectionRows.value.length) {
|
||
ElMessage.warning('请先勾选要取消的波次')
|
||
return
|
||
}
|
||
|
||
const ids = getSelectedWaveIds()
|
||
|
||
if (!ids.length) {
|
||
ElMessage.warning('当前勾选记录缺少可用的波次 ID')
|
||
return
|
||
}
|
||
|
||
try {
|
||
await ElMessageBox.confirm(
|
||
`确定要批量取消 ${ids.length} 个波次吗?取消后将解除订单与波次的关联。`,
|
||
'批量取消波次',
|
||
{ type: 'warning', confirmButtonText: '确认取消', cancelButtonText: '取消' }
|
||
)
|
||
} catch {
|
||
return
|
||
}
|
||
|
||
batchCancelLoading.value = true
|
||
try {
|
||
const res = await orderWaveBatchCancel({ ids }) as WaveBatchCancelResponse & { code?: number; message?: string; flag?: string }
|
||
if (!res || !okCode(res.code)) {
|
||
throw new Error(res?.message || '批量取消波次失败')
|
||
}
|
||
|
||
const taskId = String(res?.task_id || '').trim()
|
||
if (!taskId) {
|
||
resetBatchCancelTaskProgress()
|
||
ElMessage.success(res?.message || '批量取消波次成功')
|
||
selectionRows.value = []
|
||
hasSelection.value = false
|
||
await loadData()
|
||
return
|
||
}
|
||
|
||
applyBatchCancelTaskProgress({
|
||
task_id: taskId,
|
||
status: 'submitted',
|
||
total_count: ids.length,
|
||
success_count: 0,
|
||
failed_count: 0,
|
||
progress_percent: 0,
|
||
message: res?.message || '批量取消波次任务已受理'
|
||
})
|
||
|
||
selectionRows.value = []
|
||
hasSelection.value = false
|
||
ElMessage.success((res?.message || '批量取消波次任务已受理') + `(任务ID:${taskId})`)
|
||
scheduleBatchCancelTaskPolling(1000)
|
||
} catch (error: any) {
|
||
console.error('batch cancel wave failed:', error)
|
||
ElMessage.error(error?.message || '批量取消波次失败')
|
||
} finally {
|
||
batchCancelLoading.value = false
|
||
}
|
||
}
|
||
|
||
function openGroupOrderDialog() {
|
||
groupOrderDialogVisible.value = true
|
||
groupOrderFilters.distinguishExpress = true
|
||
groupOrderPagination.currentPage = 1
|
||
groupOrderSelectionRows.value = []
|
||
loadGroupOrderStoreOptions()
|
||
fetchGroupOrderList()
|
||
}
|
||
|
||
function openSingleOrderDialog() {
|
||
singleOrderDialogVisible.value = true
|
||
singleOrderActiveTab.value = 'fallback-orders'
|
||
fallbackOrderPagination.currentPage = 1
|
||
fallbackOrderSelectionRows.value = []
|
||
waveStrategyPagination.currentPage = 1
|
||
waveStrategyList.value = []
|
||
waveStrategyPagination.total = 0
|
||
void loadFallbackOrderFilterOptions()
|
||
void fetchFallbackOrderList()
|
||
}
|
||
|
||
function normalizeCode(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 = normalizeCode(nameKeys.map((key) => item?.[key]).find((v) => v !== undefined && v !== null && v !== ''))
|
||
if (!name || seen.has(name)) continue
|
||
result.push({ value: name, label: name })
|
||
seen.add(name)
|
||
}
|
||
return result
|
||
}
|
||
|
||
function mapCodeNameOptions(rawList: any[], codeKeys: string[], nameKeys: string[]) {
|
||
const result: Array<{ label: string; value: string }> = []
|
||
const seen = new Set<string>()
|
||
for (const item of rawList || []) {
|
||
const code = normalizeCode(codeKeys.map((key) => item?.[key]).find((v) => v !== undefined && v !== null && v !== ''))
|
||
if (!code || seen.has(code)) continue
|
||
const name = normalizeCode(nameKeys.map((key) => item?.[key]).find((v) => v !== undefined && v !== null && v !== ''))
|
||
result.push({
|
||
value: code,
|
||
label: name && name !== code ? `${code} (${name})` : code
|
||
})
|
||
seen.add(code)
|
||
}
|
||
return result
|
||
}
|
||
|
||
function toStringList(value: unknown): string[] {
|
||
if (Array.isArray(value)) {
|
||
return value.map((item) => String(item).trim()).filter(Boolean)
|
||
}
|
||
if (typeof value === 'string') {
|
||
return value.split(',').map((item) => item.trim()).filter(Boolean)
|
||
}
|
||
return []
|
||
}
|
||
|
||
function patchSelectOptionsByValues(
|
||
optionsRef: { value: Array<{ label: string; value: string }> },
|
||
values: string[]
|
||
) {
|
||
const existing = new Set(optionsRef.value.map((item) => item.value))
|
||
const missing = values.filter((item) => item && !existing.has(item))
|
||
if (!missing.length) return
|
||
optionsRef.value = optionsRef.value.concat(missing.map((value) => ({ label: value, value })))
|
||
}
|
||
|
||
type RegionNode = { code: string; name: string; children?: RegionNode[] }
|
||
const chinaRegionTree = (Array.isArray(pcasCodeData) ? pcasCodeData : []) as RegionNode[]
|
||
const allProvinceOptionsFromDict = chinaRegionTree.map((item) => ({
|
||
label: String(item?.name || '').trim(),
|
||
value: String(item?.name || '').trim()
|
||
})).filter((item) => item.value)
|
||
|
||
function refreshWaveStrategyProvinceOptions() {
|
||
const provinceSet = new Set<string>(allProvinceOptionsFromDict.map((item) => item.value))
|
||
waveStrategyFormModel.allowed_provinces.forEach((item) => {
|
||
const value = normalizeCode(item)
|
||
if (value) provinceSet.add(value)
|
||
})
|
||
waveStrategyList.value.forEach((row: any) => {
|
||
toStringList(row?.allowed_provinces).forEach((item) => {
|
||
const value = normalizeCode(item)
|
||
if (value) provinceSet.add(value)
|
||
})
|
||
})
|
||
fallbackOrderList.value.forEach((row: any) => {
|
||
const value = normalizeCode(row?.province)
|
||
if (value) provinceSet.add(value)
|
||
})
|
||
waveStrategyProvinceOptions.value = Array.from(provinceSet).map((value) => ({ label: value, value }))
|
||
}
|
||
|
||
function unwrapIndexListResponse(res: any): any[] {
|
||
const payload = res?.data !== undefined ? res.data : res
|
||
if (Array.isArray(payload)) return payload
|
||
if (payload && typeof payload === 'object') {
|
||
if (Array.isArray(payload.list)) return payload.list
|
||
if (Array.isArray(payload.items)) return payload.items
|
||
if (Array.isArray(payload.records)) return payload.records
|
||
}
|
||
if (Array.isArray(res?.list)) return res.list
|
||
return []
|
||
}
|
||
|
||
function patchFallbackFieldOptions(fieldValue: string, options: Array<{ label: string; value: string }>) {
|
||
const targetField = fallbackOrderAvailableFieldsRef.find((field: any) => field.value === fieldValue)
|
||
if (targetField) {
|
||
targetField.options = options
|
||
}
|
||
}
|
||
|
||
async function loadFallbackOrderFilterOptions() {
|
||
const hasReadyOptions = fallbackOrderOwnerOptions.value.length > 0
|
||
&& fallbackOrderLogisticsOptions.value.length > 0
|
||
&& fallbackOrderPlatformOptions.value.length > 0
|
||
if (hasReadyOptions) return
|
||
|
||
try {
|
||
const [storesRes, expressRes, platformRes] = await Promise.all([
|
||
indexApi.loadStores({ type: 'order' }),
|
||
indexApi.getExpressList({}),
|
||
indexApi.getPlatformList({})
|
||
])
|
||
|
||
const storesResAny = storesRes as any
|
||
const stores = Array.isArray(storesResAny?.stores)
|
||
? storesResAny.stores
|
||
: Array.isArray(storesResAny?.data?.stores)
|
||
? storesResAny.data.stores
|
||
: []
|
||
const expressRaw = unwrapIndexListResponse(expressRes)
|
||
const platformRaw = unwrapIndexListResponse(platformRes)
|
||
|
||
const ownerNameSet = new Set<string>()
|
||
const waveStrategyOwnerCodeSet = new Set<string>()
|
||
stores.forEach((item: any) => {
|
||
const ownerName = String(item?.label || item?.name || '').trim()
|
||
if (!ownerName) return
|
||
ownerNameSet.add(ownerName)
|
||
const ownerCode = normalizeCode(item?.value ?? item?.id ?? item?.owner_code ?? item?.code)
|
||
if (ownerCode) waveStrategyOwnerCodeSet.add(ownerCode)
|
||
})
|
||
fallbackOrderOwnerOptions.value = Array.from(ownerNameSet).map((name) => ({
|
||
label: name,
|
||
value: name
|
||
}))
|
||
waveStrategyOwnerOptions.value = Array.from(waveStrategyOwnerCodeSet).map((code) => {
|
||
const owner = stores.find((item: any) => normalizeCode(item?.value ?? item?.id ?? item?.owner_code ?? item?.code) === code)
|
||
const ownerName = normalizeCode(owner?.label || owner?.name)
|
||
return {
|
||
value: code,
|
||
label: ownerName && ownerName !== code ? `${code} (${ownerName})` : code
|
||
}
|
||
})
|
||
fallbackOrderLogisticsOptions.value = mapNameOptions(expressRaw, ['name', 'logistics_name', 'express_name', 'label'])
|
||
fallbackOrderPlatformOptions.value = mapNameOptions(platformRaw, ['name', 'platform_name', 'sys_platform_name', 'label'])
|
||
waveStrategyExpressOptions.value = mapCodeNameOptions(
|
||
expressRaw,
|
||
['code', 'express_code', 'logistics_code', 'value'],
|
||
['name', 'logistics_name', 'express_name', 'label']
|
||
)
|
||
waveStrategyPlatformOptions.value = mapCodeNameOptions(
|
||
platformRaw,
|
||
['code', 'platform_code', 'value', 'platform'],
|
||
['name', 'platform_name', 'sys_platform_name', 'label']
|
||
)
|
||
|
||
patchFallbackFieldOptions('owner_name', fallbackOrderOwnerOptions.value)
|
||
patchFallbackFieldOptions('sys_logistics_name', fallbackOrderLogisticsOptions.value)
|
||
patchFallbackFieldOptions('sys_platform_name', fallbackOrderPlatformOptions.value)
|
||
patchSelectOptionsByValues(waveStrategyOwnerOptions, waveStrategyFormModel.allowed_owners)
|
||
patchSelectOptionsByValues(waveStrategyExpressOptions, waveStrategyFormModel.allowed_expresses)
|
||
patchSelectOptionsByValues(waveStrategyPlatformOptions, waveStrategyFormModel.allowed_platforms)
|
||
refreshWaveStrategyProvinceOptions()
|
||
} catch (error) {
|
||
console.error('load fallback order filter options failed:', error)
|
||
fallbackOrderOwnerOptions.value = []
|
||
fallbackOrderLogisticsOptions.value = []
|
||
fallbackOrderPlatformOptions.value = []
|
||
waveStrategyOwnerOptions.value = []
|
||
waveStrategyExpressOptions.value = []
|
||
waveStrategyPlatformOptions.value = []
|
||
patchFallbackFieldOptions('owner_name', [])
|
||
patchFallbackFieldOptions('sys_logistics_name', [])
|
||
patchFallbackFieldOptions('sys_platform_name', [])
|
||
refreshWaveStrategyProvinceOptions()
|
||
}
|
||
}
|
||
|
||
async function loadGroupOrderStoreOptions() {
|
||
if (groupOrderStoreOptions.value.length > 0) return
|
||
try {
|
||
const res: any = await indexApi.loadStores({ type: 'order' })
|
||
const stores = Array.isArray(res?.stores) ? res.stores : []
|
||
groupOrderStoreOptions.value = stores.map((item: any) => ({
|
||
label: item.label || item.name || String(item.value || item.id),
|
||
value: item.value ?? item.id
|
||
}))
|
||
} catch (error) {
|
||
console.error('load group order stores failed:', error)
|
||
groupOrderStoreOptions.value = []
|
||
}
|
||
}
|
||
|
||
type StructureFetchListFilters = {
|
||
distinguishExpress: boolean
|
||
storeId: number | string | undefined
|
||
sameOrderQuantity: number | undefined
|
||
shopName: string
|
||
includeSku: string
|
||
returnOrderIds: boolean
|
||
}
|
||
|
||
function buildStructureFetchListPayload(
|
||
pagination: { currentPage: number; pageSize: number },
|
||
filters: StructureFetchListFilters
|
||
) {
|
||
const payload: Record<string, any> = {
|
||
pagination: {
|
||
page: pagination.currentPage,
|
||
pageSize: pagination.pageSize
|
||
},
|
||
distinguish_express: filters.distinguishExpress,
|
||
return_order_ids: filters.returnOrderIds
|
||
}
|
||
|
||
if (filters.storeId !== undefined && filters.storeId !== null && filters.storeId !== '') {
|
||
payload.store_id = Number(filters.storeId)
|
||
}
|
||
if (filters.sameOrderQuantity !== undefined && filters.sameOrderQuantity !== null) {
|
||
payload.same_order_quantity = Number(filters.sameOrderQuantity)
|
||
}
|
||
if (filters.shopName.trim()) {
|
||
payload.shop_name = filters.shopName.trim()
|
||
}
|
||
if (filters.includeSku.trim()) {
|
||
payload.include_sku = filters.includeSku.trim()
|
||
}
|
||
|
||
return payload
|
||
}
|
||
|
||
function buildGroupOrderListPayload() {
|
||
return buildStructureFetchListPayload(groupOrderPagination, groupOrderFilters)
|
||
}
|
||
|
||
function sanitizeFallbackOrderWhere(where: Record<string, any>) {
|
||
const allowedFieldMap: Record<string, string> = {
|
||
id: 'id',
|
||
delivery_no: 'delivery_no',
|
||
deliveryNo: 'delivery_no',
|
||
tracking_no: 'tracking_no',
|
||
trackingNo: 'tracking_no',
|
||
items_count_min: 'items_count_min',
|
||
items_count_max: 'items_count_max',
|
||
items_total_min: 'items_total_min',
|
||
items_total_max: 'items_total_max',
|
||
sys_logistics_name: 'sys_logistics_name',
|
||
store_name: 'store_name',
|
||
owner_name: 'owner_name',
|
||
province: 'province',
|
||
sys_platform_name: 'sys_platform_name'
|
||
}
|
||
const nextWhere: Record<string, any> = {}
|
||
Object.keys(where || {}).forEach((key) => {
|
||
if (key === 'warehouse_id' || key === 'warehouseId') return
|
||
const normalizedKey = allowedFieldMap[key]
|
||
if (!normalizedKey) return
|
||
const value = where[key]
|
||
if (value === undefined || value === null || value === '' || (Array.isArray(value) && value.length === 0)) return
|
||
nextWhere[normalizedKey] = value
|
||
})
|
||
return nextWhere
|
||
}
|
||
|
||
function buildFallbackOrderListPayload() {
|
||
const scanBox = fallbackOrderScanBox.value
|
||
return {
|
||
pagination: {
|
||
page: fallbackOrderPagination.currentPage,
|
||
pageSize: fallbackOrderPagination.pageSize
|
||
},
|
||
where: sanitizeFallbackOrderWhere(buildWhereConditions(scanBox?.getConditions?.() || {}))
|
||
}
|
||
}
|
||
|
||
async function fetchWaveStrategyList() {
|
||
waveStrategyListLoading.value = true
|
||
try {
|
||
const res = await orderWaveWaveStrategyList({
|
||
pagination: {
|
||
page: waveStrategyPagination.currentPage,
|
||
pageSize: waveStrategyPagination.pageSize
|
||
},
|
||
/** module order.wave:strategy_type 1=散单 2=团购(本页为团购波次) */
|
||
strategy_type: 2,
|
||
}) as WaveStrategyListResponse & { code?: number; message?: string; data?: Partial<WaveStrategyListResponse> }
|
||
if (!res || !okCode(res.code)) {
|
||
throw new Error(res?.message || '获取波次策略列表失败')
|
||
}
|
||
const responseList = Array.isArray(res.list)
|
||
? res.list
|
||
: Array.isArray(res.data?.list)
|
||
? res.data.list
|
||
: []
|
||
const responsePagination = res.pagination || res.data?.pagination || {}
|
||
waveStrategyList.value = responseList
|
||
waveStrategyPagination.currentPage = responsePagination.page || waveStrategyPagination.currentPage
|
||
waveStrategyPagination.pageSize = responsePagination.pageSize || waveStrategyPagination.pageSize
|
||
waveStrategyPagination.total = responsePagination.total || 0
|
||
refreshWaveStrategyProvinceOptions()
|
||
} catch (error: any) {
|
||
console.error('fetch wave strategy list failed:', error)
|
||
waveStrategyList.value = []
|
||
waveStrategyPagination.total = 0
|
||
refreshWaveStrategyProvinceOptions()
|
||
ElMessage.error(error?.message || '获取波次策略列表失败')
|
||
} finally {
|
||
waveStrategyListLoading.value = false
|
||
}
|
||
}
|
||
|
||
async function submitWaveStrategyFetchAdmin(row: Record<string, any>) {
|
||
const strategyId = Number(row?.id || 0)
|
||
if (!strategyId) {
|
||
ElMessage.warning('无法识别策略ID,请刷新后重试')
|
||
return
|
||
}
|
||
|
||
waveStrategyFetchSubmittingId.value = strategyId
|
||
try {
|
||
const res = await orderWaveWaveStrategyFetchAdmin({
|
||
strategy_id: strategyId,
|
||
source: 'admin',
|
||
operation_source: 'admin'
|
||
}) as WaveStrategyFetchTaskCreatedResponse & { code?: number; message?: string }
|
||
if (!res || !okCode(res.code)) {
|
||
throw new Error(res?.message || '提交后台抓取任务失败')
|
||
}
|
||
const payload = unwrapWaveStrategyFetchPayload(res)
|
||
applyWaveStrategyFetchUiResult(payload, {
|
||
defaultSuccessHint: '后台抓取任务已创建',
|
||
afterSuccess: () => fetchWaveStrategyList()
|
||
})
|
||
} catch (error: any) {
|
||
console.error('submit wave strategy fetch admin failed:', error)
|
||
ElMessage.error(error?.message || '提交后台抓取任务失败')
|
||
} finally {
|
||
waveStrategyFetchSubmittingId.value = null
|
||
}
|
||
}
|
||
|
||
function handleWaveStrategyPageChange(page: number) {
|
||
waveStrategyPagination.currentPage = page
|
||
void fetchWaveStrategyList()
|
||
}
|
||
|
||
function handleWaveStrategyPageSizeChange(size: number) {
|
||
waveStrategyPagination.pageSize = size
|
||
waveStrategyPagination.currentPage = 1
|
||
void fetchWaveStrategyList()
|
||
}
|
||
|
||
function resetWaveStrategyForm() {
|
||
waveStrategyEditingId.value = null
|
||
waveStrategyFormModel.strategy_name = ''
|
||
waveStrategyFormModel.strategy_type = undefined
|
||
waveStrategyFormModel.batch_mode = undefined
|
||
waveStrategyFormModel.status = undefined
|
||
waveStrategyFormModel.order_min_sku = undefined
|
||
waveStrategyFormModel.order_max_sku = undefined
|
||
waveStrategyFormModel.order_min_qty = undefined
|
||
waveStrategyFormModel.order_max_qty = undefined
|
||
waveStrategyFormModel.min_same_structure = undefined
|
||
waveStrategyFormModel.max_same_structure = undefined
|
||
waveStrategyFormModel.batch_max_orders = undefined
|
||
waveStrategyFormModel.batch_max_skus = undefined
|
||
waveStrategyFormModel.group_batch_max_orders = undefined
|
||
waveStrategyFormModel.require_same_express = undefined
|
||
waveStrategyFormModel.allow_cross_owner = undefined
|
||
waveStrategyFormModel.description = ''
|
||
waveStrategyFormModel.allowed_owners = []
|
||
waveStrategyFormModel.allowed_expresses = []
|
||
waveStrategyFormModel.allowed_provinces = []
|
||
waveStrategyFormModel.allowed_platforms = []
|
||
refreshWaveStrategyProvinceOptions()
|
||
waveStrategyFormRef.value?.clearValidate?.()
|
||
}
|
||
|
||
function buildWaveStrategyPayload() {
|
||
const payload: Partial<WaveStrategyCreateParams & WaveStrategyUpdateParams> = {
|
||
strategy_name: waveStrategyFormModel.strategy_name.trim(),
|
||
strategy_type: waveStrategyFormModel.strategy_type,
|
||
batch_mode: waveStrategyFormModel.batch_mode,
|
||
status: waveStrategyFormModel.status,
|
||
order_min_sku: waveStrategyFormModel.order_min_sku,
|
||
order_max_sku: waveStrategyFormModel.order_max_sku,
|
||
order_min_qty: waveStrategyFormModel.order_min_qty,
|
||
order_max_qty: waveStrategyFormModel.order_max_qty,
|
||
min_same_structure: waveStrategyFormModel.min_same_structure,
|
||
max_same_structure: waveStrategyFormModel.max_same_structure,
|
||
batch_max_orders: waveStrategyFormModel.batch_max_orders,
|
||
batch_max_skus: waveStrategyFormModel.batch_max_skus,
|
||
group_batch_max_orders: waveStrategyFormModel.group_batch_max_orders,
|
||
require_same_express: waveStrategyFormModel.require_same_express,
|
||
allow_cross_owner: waveStrategyFormModel.allow_cross_owner,
|
||
description: waveStrategyFormModel.description.trim() || undefined
|
||
}
|
||
const allowedOwners = waveStrategyFormModel.allowed_owners
|
||
const allowedExpresses = waveStrategyFormModel.allowed_expresses
|
||
const allowedProvinces = waveStrategyFormModel.allowed_provinces
|
||
const allowedPlatforms = waveStrategyFormModel.allowed_platforms
|
||
if (allowedOwners.length) payload.allowed_owners = allowedOwners
|
||
if (allowedExpresses.length) payload.allowed_expresses = allowedExpresses
|
||
if (allowedProvinces.length) payload.allowed_provinces = allowedProvinces
|
||
if (allowedPlatforms.length) payload.allowed_platforms = allowedPlatforms
|
||
|
||
Object.keys(payload).forEach((key) => {
|
||
const value = payload[key as keyof typeof payload]
|
||
if (value === undefined) {
|
||
delete payload[key as keyof typeof payload]
|
||
}
|
||
})
|
||
return payload
|
||
}
|
||
|
||
function openCreateWaveStrategyDialog() {
|
||
waveStrategyFormMode.value = 'create'
|
||
resetWaveStrategyForm()
|
||
void loadFallbackOrderFilterOptions()
|
||
waveStrategyFormDialogVisible.value = true
|
||
}
|
||
|
||
function openEditWaveStrategyDialog(row: Record<string, any>) {
|
||
waveStrategyFormMode.value = 'edit'
|
||
resetWaveStrategyForm()
|
||
waveStrategyEditingId.value = Number(row?.id || 0) || null
|
||
waveStrategyFormModel.strategy_name = String(row?.strategy_name || '')
|
||
waveStrategyFormModel.strategy_type = Number(row?.strategy_type ?? 0) || undefined
|
||
waveStrategyFormModel.batch_mode = Number(row?.batch_mode ?? 0) || undefined
|
||
waveStrategyFormModel.status = row?.status === 0 || row?.status === 1 ? Number(row.status) : undefined
|
||
waveStrategyFormModel.order_min_sku = Number(row?.order_min_sku ?? 0) || undefined
|
||
waveStrategyFormModel.order_max_sku = Number(row?.order_max_sku ?? 0) || undefined
|
||
waveStrategyFormModel.order_min_qty = Number(row?.order_min_qty ?? 0) || undefined
|
||
waveStrategyFormModel.order_max_qty = Number(row?.order_max_qty ?? 0) || undefined
|
||
waveStrategyFormModel.min_same_structure = Number(row?.min_same_structure ?? 0) || undefined
|
||
waveStrategyFormModel.max_same_structure = Number(row?.max_same_structure ?? 0) || undefined
|
||
waveStrategyFormModel.batch_max_orders = Number(row?.batch_max_orders ?? 0) || undefined
|
||
waveStrategyFormModel.batch_max_skus = Number(row?.batch_max_skus ?? 0) || undefined
|
||
waveStrategyFormModel.group_batch_max_orders = Number(row?.group_batch_max_orders ?? 0) || undefined
|
||
if (row?.require_same_express === 1 || row?.require_same_express === true) {
|
||
waveStrategyFormModel.require_same_express = true
|
||
} else if (row?.require_same_express === 0 || row?.require_same_express === false) {
|
||
waveStrategyFormModel.require_same_express = false
|
||
}
|
||
if (row?.allow_cross_owner === 1 || row?.allow_cross_owner === true) {
|
||
waveStrategyFormModel.allow_cross_owner = true
|
||
} else if (row?.allow_cross_owner === 0 || row?.allow_cross_owner === false) {
|
||
waveStrategyFormModel.allow_cross_owner = false
|
||
}
|
||
waveStrategyFormModel.description = String(row?.description || '')
|
||
waveStrategyFormModel.allowed_owners = toStringList(row?.allowed_owners)
|
||
waveStrategyFormModel.allowed_expresses = toStringList(row?.allowed_expresses)
|
||
waveStrategyFormModel.allowed_provinces = toStringList(row?.allowed_provinces)
|
||
waveStrategyFormModel.allowed_platforms = toStringList(row?.allowed_platforms)
|
||
patchSelectOptionsByValues(waveStrategyOwnerOptions, waveStrategyFormModel.allowed_owners)
|
||
patchSelectOptionsByValues(waveStrategyExpressOptions, waveStrategyFormModel.allowed_expresses)
|
||
patchSelectOptionsByValues(waveStrategyPlatformOptions, waveStrategyFormModel.allowed_platforms)
|
||
refreshWaveStrategyProvinceOptions()
|
||
void loadFallbackOrderFilterOptions()
|
||
waveStrategyFormDialogVisible.value = true
|
||
}
|
||
|
||
async function submitWaveStrategyForm() {
|
||
if (!waveStrategyFormRef.value) return
|
||
try {
|
||
await waveStrategyFormRef.value.validate()
|
||
} catch {
|
||
return
|
||
}
|
||
|
||
waveStrategyFormSubmitting.value = true
|
||
try {
|
||
const payload = buildWaveStrategyPayload()
|
||
if (waveStrategyFormMode.value === 'create') {
|
||
const res = await orderWaveWaveStrategyCreate(
|
||
payload as WaveStrategyCreateParams
|
||
) as WaveStrategyMutationResponse & { code?: number; message?: string; data?: Record<string, unknown> }
|
||
if (!res || !okCode(res.code)) {
|
||
throw new Error(res?.message || '新建波次策略失败')
|
||
}
|
||
ElMessage.success(res?.message || '新建波次策略成功')
|
||
} else {
|
||
if (!waveStrategyEditingId.value) {
|
||
throw new Error('缺少策略ID,无法更新')
|
||
}
|
||
const res = await orderWaveWaveStrategyUpdate({
|
||
id: waveStrategyEditingId.value,
|
||
...(payload as WaveStrategyUpdateParams)
|
||
}) as WaveStrategyMutationResponse & { code?: number; message?: string; data?: Record<string, unknown> }
|
||
if (!res || !okCode(res.code)) {
|
||
throw new Error(res?.message || '更新波次策略失败')
|
||
}
|
||
ElMessage.success(res?.message || '更新波次策略成功')
|
||
}
|
||
waveStrategyFormDialogVisible.value = false
|
||
await fetchWaveStrategyList()
|
||
} catch (error: any) {
|
||
console.error('submit wave strategy form failed:', error)
|
||
ElMessage.error(error?.message || '保存波次策略失败')
|
||
} finally {
|
||
waveStrategyFormSubmitting.value = false
|
||
}
|
||
}
|
||
|
||
function resetWaveStrategyQuickScanResult() {
|
||
waveStrategyQuickScanResult.status = ''
|
||
waveStrategyQuickScanResult.taskId = ''
|
||
waveStrategyQuickScanResult.warehouseId = undefined
|
||
waveStrategyQuickScanResult.state = ''
|
||
waveStrategyQuickScanResult.message = ''
|
||
waveStrategyQuickScanResult.acceptedAt = ''
|
||
waveStrategyQuickScanResult.totalOrderCount = 0
|
||
waveStrategyQuickScanResult.processedOrderCount = 0
|
||
waveStrategyQuickScanResult.matchedOrderCount = 0
|
||
waveStrategyQuickScanResult.unmatchedOrderCount = 0
|
||
waveStrategyQuickScanResult.progressPercent = 0
|
||
waveStrategyQuickScanResult.startTime = ''
|
||
waveStrategyQuickScanResult.endTime = ''
|
||
waveStrategyQuickScanResult.durationMs = 0
|
||
waveStrategyQuickScanResult.errorMessage = ''
|
||
}
|
||
|
||
function handleWaveStrategyQuickScanDialogVisibleChange(visible: boolean) {
|
||
waveStrategyQuickScanDialogVisible.value = visible
|
||
if (!visible) {
|
||
resetWaveStrategyQuickScanResult()
|
||
}
|
||
}
|
||
|
||
function stopWaveStrategyQuickScanTaskPolling() {
|
||
if (waveStrategyQuickScanTaskPollTimer.value) {
|
||
clearTimeout(waveStrategyQuickScanTaskPollTimer.value)
|
||
waveStrategyQuickScanTaskPollTimer.value = null
|
||
}
|
||
}
|
||
|
||
function scheduleWaveStrategyQuickScanTaskPolling(delay = 2000) {
|
||
stopWaveStrategyQuickScanTaskPolling()
|
||
if (!waveStrategyQuickScanResult.taskId) return
|
||
waveStrategyQuickScanTaskPollTimer.value = setTimeout(() => {
|
||
void pollWaveStrategyQuickScanTaskProgress()
|
||
}, delay)
|
||
}
|
||
|
||
function applyWaveStrategyQuickScanTaskProgress(progress: Partial<WaveStrategyQuickScanTaskProgressResponse> & Record<string, any>) {
|
||
waveStrategyQuickScanResult.taskId = String(progress.task_id || waveStrategyQuickScanResult.taskId || '')
|
||
waveStrategyQuickScanResult.state = String(progress.state || waveStrategyQuickScanResult.state || 'submitted')
|
||
waveStrategyQuickScanResult.warehouseId = Number(progress.warehouse_id ?? waveStrategyQuickScanResult.warehouseId ?? 0) || undefined
|
||
waveStrategyQuickScanResult.totalOrderCount = Number(progress.total_order_count ?? waveStrategyQuickScanResult.totalOrderCount ?? 0)
|
||
waveStrategyQuickScanResult.processedOrderCount = Number(progress.processed_order_count ?? waveStrategyQuickScanResult.processedOrderCount ?? 0)
|
||
waveStrategyQuickScanResult.matchedOrderCount = Number(progress.matched_order_count ?? waveStrategyQuickScanResult.matchedOrderCount ?? 0)
|
||
waveStrategyQuickScanResult.unmatchedOrderCount = Number(progress.unmatched_order_count ?? waveStrategyQuickScanResult.unmatchedOrderCount ?? 0)
|
||
waveStrategyQuickScanResult.progressPercent = Number(progress.progress_percent ?? waveStrategyQuickScanResult.progressPercent ?? 0)
|
||
waveStrategyQuickScanResult.startTime = String(progress.start_time || waveStrategyQuickScanResult.startTime || '')
|
||
waveStrategyQuickScanResult.endTime = String(progress.end_time || waveStrategyQuickScanResult.endTime || '')
|
||
waveStrategyQuickScanResult.durationMs = Number(progress.duration_ms ?? waveStrategyQuickScanResult.durationMs ?? 0)
|
||
waveStrategyQuickScanResult.errorMessage = String(progress.error_message || '')
|
||
}
|
||
|
||
async function pollWaveStrategyQuickScanTaskProgress() {
|
||
if (!waveStrategyQuickScanResult.taskId) return
|
||
try {
|
||
const res = await orderWaveWaveStrategyQuickScanTaskProgress({
|
||
task_id: waveStrategyQuickScanResult.taskId
|
||
}) as WaveStrategyQuickScanTaskProgressResponse & { code?: number; message?: string }
|
||
if (!res || !okCode(res.code)) {
|
||
throw new Error(res?.message || '查询波次策略快速扫描进度失败')
|
||
}
|
||
|
||
applyWaveStrategyQuickScanTaskProgress(res)
|
||
const normalizedStatus = normalizeAsyncTaskStatus(waveStrategyQuickScanResult.state)
|
||
if (isAsyncTaskFailureStatus(normalizedStatus)) {
|
||
stopWaveStrategyQuickScanTaskPolling()
|
||
waveStrategyQuickScanResult.message = waveStrategyQuickScanResult.errorMessage || res?.message || '快速扫描任务执行失败'
|
||
await fetchFallbackOrderList()
|
||
return
|
||
}
|
||
|
||
if (isAsyncTaskSuccessStatus(normalizedStatus) || Number(waveStrategyQuickScanResult.progressPercent || 0) >= 100) {
|
||
stopWaveStrategyQuickScanTaskPolling()
|
||
waveStrategyQuickScanResult.message = res?.message || '快速扫描任务已完成'
|
||
await fetchFallbackOrderList()
|
||
return
|
||
}
|
||
|
||
scheduleWaveStrategyQuickScanTaskPolling()
|
||
} catch (error) {
|
||
console.error('poll wave strategy quick scan task progress failed:', error)
|
||
scheduleWaveStrategyQuickScanTaskPolling(4000)
|
||
}
|
||
}
|
||
|
||
async function submitWaveStrategyQuickScan() {
|
||
stopWaveStrategyQuickScanTaskPolling()
|
||
waveStrategyQuickScanSubmitting.value = true
|
||
waveStrategyQuickScanDialogVisible.value = true
|
||
try {
|
||
const res = await orderWaveWaveStrategyQuickScan() as WaveStrategyQuickScanResponse & { code?: number; message?: string }
|
||
if (!res || !okCode(res.code)) {
|
||
throw new Error(res?.message || '提交波次策略快速扫描任务失败')
|
||
}
|
||
|
||
waveStrategyQuickScanResult.status = String(res.status || '')
|
||
waveStrategyQuickScanResult.taskId = String(res.task_id || '')
|
||
waveStrategyQuickScanResult.warehouseId = Number(res.warehouse_id || 0) || undefined
|
||
waveStrategyQuickScanResult.state = String(res.state || '')
|
||
waveStrategyQuickScanResult.message = String(res.message || '')
|
||
waveStrategyQuickScanResult.acceptedAt = String(res.accepted_at || '')
|
||
waveStrategyQuickScanResult.progressPercent = 0
|
||
waveStrategyQuickScanResult.errorMessage = ''
|
||
|
||
ElMessage.success((res?.message || '波次策略快速扫描任务已提交') + (res?.task_id ? `(任务ID:${res.task_id})` : ''))
|
||
if (waveStrategyQuickScanResult.taskId) {
|
||
scheduleWaveStrategyQuickScanTaskPolling(1000)
|
||
}
|
||
} catch (error: any) {
|
||
console.error('submit wave strategy quick scan failed:', error)
|
||
resetWaveStrategyQuickScanResult()
|
||
waveStrategyQuickScanDialogVisible.value = false
|
||
ElMessage.error(error?.message || '提交波次策略快速扫描任务失败')
|
||
} finally {
|
||
waveStrategyQuickScanSubmitting.value = false
|
||
}
|
||
}
|
||
|
||
function getFallbackOrderItemSnapshotText(row: WaveStrategyFallbackOrderListRow) {
|
||
const value = row?.item_snapshot
|
||
if (typeof value === 'string' && value.trim()) {
|
||
return value
|
||
}
|
||
return '—'
|
||
}
|
||
|
||
async function fetchFallbackOrderList() {
|
||
fallbackOrderListLoading.value = true
|
||
try {
|
||
const res = await orderWaveWaveStrategyFallbackOrderList(buildFallbackOrderListPayload()) as
|
||
WaveStrategyFallbackOrderListResponse & { code?: number; message?: string; data?: Partial<WaveStrategyFallbackOrderListResponse> }
|
||
if (!res || !okCode(res.code)) {
|
||
throw new Error(res?.message || '获取不符合波次策略订单失败')
|
||
}
|
||
const responseList = Array.isArray(res.list)
|
||
? res.list
|
||
: Array.isArray(res.data?.list)
|
||
? res.data.list
|
||
: []
|
||
const responsePagination = res.pagination || res.data?.pagination || {}
|
||
fallbackOrderList.value = responseList
|
||
fallbackOrderPagination.currentPage = responsePagination.page || fallbackOrderPagination.currentPage
|
||
fallbackOrderPagination.pageSize = responsePagination.pageSize || fallbackOrderPagination.pageSize
|
||
fallbackOrderPagination.total = responsePagination.total || 0
|
||
refreshWaveStrategyProvinceOptions()
|
||
} catch (error: any) {
|
||
console.error('fetch fallback order list failed:', error)
|
||
fallbackOrderList.value = []
|
||
fallbackOrderPagination.total = 0
|
||
refreshWaveStrategyProvinceOptions()
|
||
ElMessage.error(error?.message || '获取不符合波次策略订单失败')
|
||
} finally {
|
||
fallbackOrderListLoading.value = false
|
||
}
|
||
}
|
||
|
||
async function fetchGroupOrderList() {
|
||
groupOrderListLoading.value = true
|
||
try {
|
||
const res = await orderWaveGroupOrderFetchList(buildGroupOrderListPayload()) as
|
||
WaveGroupOrderFetchListResponse & { code?: number; message?: string; data?: Partial<WaveGroupOrderFetchListResponse> }
|
||
if (!res || !okCode(res.code)) {
|
||
throw new Error(res?.message || '获取可抓取团购单列表失败')
|
||
}
|
||
const responseList = Array.isArray(res.list)
|
||
? res.list
|
||
: Array.isArray(res.data?.list)
|
||
? res.data.list
|
||
: []
|
||
const responsePagination = res.pagination || res.data?.pagination || {}
|
||
groupOrderList.value = responseList
|
||
groupOrderPagination.currentPage = responsePagination.page || groupOrderPagination.currentPage
|
||
groupOrderPagination.pageSize = responsePagination.pageSize || groupOrderPagination.pageSize
|
||
groupOrderPagination.total = responsePagination.total || 0
|
||
} catch (error: any) {
|
||
console.error('fetch group order list failed:', error)
|
||
groupOrderList.value = []
|
||
groupOrderPagination.total = 0
|
||
ElMessage.error(error?.message || '获取可抓取团购单列表失败')
|
||
} finally {
|
||
groupOrderListLoading.value = false
|
||
}
|
||
}
|
||
|
||
function handleGroupOrderSelectionChange(rows: any[]) {
|
||
groupOrderSelectionRows.value = rows || []
|
||
}
|
||
|
||
function handleGroupOrderFilterChange() {
|
||
groupOrderPagination.currentPage = 1
|
||
fetchGroupOrderList()
|
||
}
|
||
|
||
function resetGroupOrderFilters() {
|
||
groupOrderFilters.distinguishExpress = true
|
||
groupOrderFilters.storeId = undefined
|
||
groupOrderFilters.sameOrderQuantity = undefined
|
||
groupOrderFilters.shopName = ''
|
||
groupOrderFilters.includeSku = ''
|
||
groupOrderFilters.returnOrderIds = false
|
||
groupOrderPagination.currentPage = 1
|
||
fetchGroupOrderList()
|
||
}
|
||
|
||
function handleGroupOrderPageChange(page: number) {
|
||
groupOrderPagination.currentPage = page
|
||
fetchGroupOrderList()
|
||
}
|
||
|
||
function handleGroupOrderPageSizeChange(size: number) {
|
||
groupOrderPagination.pageSize = size
|
||
groupOrderPagination.currentPage = 1
|
||
fetchGroupOrderList()
|
||
}
|
||
|
||
function handleFallbackOrderSelectionChange(rows: any[]) {
|
||
fallbackOrderSelectionRows.value = rows || []
|
||
}
|
||
|
||
function handleFallbackOrderConditionChange() {
|
||
fallbackOrderPagination.currentPage = 1
|
||
void fetchFallbackOrderList()
|
||
}
|
||
|
||
function handleFallbackOrderConditionClear() {
|
||
fallbackOrderPagination.currentPage = 1
|
||
void fetchFallbackOrderList()
|
||
}
|
||
|
||
function handleFallbackOrderConditionReset() {
|
||
fallbackOrderPagination.currentPage = 1
|
||
void fetchFallbackOrderList()
|
||
}
|
||
|
||
function resetFallbackOrderCondition() {
|
||
fallbackOrderPagination.currentPage = 1
|
||
fallbackOrderScanBox.value?.reset?.()
|
||
void fetchFallbackOrderList()
|
||
}
|
||
|
||
function handleFallbackOrderPageChange(page: number) {
|
||
fallbackOrderPagination.currentPage = page
|
||
void fetchFallbackOrderList()
|
||
}
|
||
|
||
function handleFallbackOrderPageSizeChange(size: number) {
|
||
fallbackOrderPagination.pageSize = size
|
||
fallbackOrderPagination.currentPage = 1
|
||
void fetchFallbackOrderList()
|
||
}
|
||
|
||
function getGroupOrderStoreText(row: any) {
|
||
if (Array.isArray(row?.store_ids) && row.store_ids.length > 1) {
|
||
return row.store_ids.join(',')
|
||
}
|
||
return row?.store_id ?? row?.store_ids?.[0] ?? '—'
|
||
}
|
||
|
||
function getGroupOrderStatusSummary(row: any) {
|
||
const summary = row?.status_summary || {}
|
||
const parts = [
|
||
`配货未开始 ${summary.pick_none ?? 0}`,
|
||
`配货完成 ${summary.pick_fin ?? 0}`,
|
||
`出库未开始 ${summary.outbound_none ?? 0}`,
|
||
`出库完成 ${summary.outbound_fin ?? 0}`
|
||
]
|
||
return parts.join(' / ')
|
||
}
|
||
|
||
function getGroupOrderItemSnapshotText(row: any) {
|
||
if (typeof row?.item_detail === 'string' && row.item_detail) {
|
||
return row.item_detail
|
||
}
|
||
if (Array.isArray(row?.item_snapshot) && row.item_snapshot.length) {
|
||
return row.item_snapshot
|
||
.map((item: any) => `${item.item_name || item.item_code || item.barcode || '未知商品'} x ${item.quantity ?? 0}`)
|
||
.join(' | ')
|
||
}
|
||
return row?.item_detail_machine_snapshot || '—'
|
||
}
|
||
|
||
async function submitGroupOrderDialog() {
|
||
if (!groupOrderSelectionRows.value.length) {
|
||
ElMessage.warning('请先勾选要抓取的结构')
|
||
return
|
||
}
|
||
|
||
groupOrderSubmitting.value = true
|
||
try {
|
||
let res: WaveFetchResponse & { code?: number; message?: string }
|
||
|
||
if (isGroupWaveTab.value) {
|
||
const structureList: WaveFetchParams['structure_list'] = groupOrderSelectionRows.value.map((row: any) => {
|
||
const key = String(row?.item_detail_machine || '')
|
||
const payload: WaveFetchParams['structure_list'][number] = {
|
||
item_detail_machine: key
|
||
}
|
||
return payload
|
||
})
|
||
res = (await orderWaveGroupFetch({ structure_list: structureList })) as WaveFetchResponse & {
|
||
code?: number
|
||
message?: string
|
||
}
|
||
if (!res || !okCode(res.code)) {
|
||
throw new Error(res?.message || '抓取团购单失败')
|
||
}
|
||
} else {
|
||
const structureList: WaveSingleFetchParams['structure_list'] = groupOrderSelectionRows.value.map((row: any) => {
|
||
const key = String(row?.item_detail_machine || '')
|
||
const groupCount = Number(row?.group_count)
|
||
const max_fetch_quantity = Math.max(1, Number.isFinite(groupCount) && groupCount > 0 ? groupCount : 100)
|
||
const payload: WaveSingleFetchParams['structure_list'][number] = {
|
||
item_detail_machine: key,
|
||
max_fetch_quantity
|
||
}
|
||
return payload
|
||
})
|
||
res = (await orderWaveSingleFetch({ structure_list: structureList })) as WaveFetchResponse & {
|
||
code?: number
|
||
message?: string
|
||
}
|
||
if (!res || !okCode(res.code)) {
|
||
throw new Error(res?.message || '抓取散单失败')
|
||
}
|
||
}
|
||
|
||
const acceptedMessage = [
|
||
res?.message || '任务已提交,后端异步处理中',
|
||
res?.task_id ? `任务ID:${res.task_id}` : '',
|
||
res?.structure_count !== undefined ? `结构数:${res.structure_count}` : ''
|
||
].filter(Boolean).join(';')
|
||
|
||
applyFetchTaskProgress({
|
||
task_id: res.task_id,
|
||
status: 'submitted',
|
||
warehouse_id: res.warehouse_id,
|
||
structure_count: res.structure_count,
|
||
finished_structure_count: 0,
|
||
progress_percent: 0,
|
||
total_fetched_quantity: 0,
|
||
message: res.message || '任务已提交,后端异步处理中',
|
||
fetch_mode: res.fetch_mode,
|
||
max_fetch_quantity: res.max_fetch_quantity
|
||
})
|
||
scheduleFetchTaskPolling(1000)
|
||
|
||
ElMessage.success(acceptedMessage)
|
||
groupOrderDialogVisible.value = false
|
||
groupOrderSelectionRows.value = []
|
||
} catch (error: any) {
|
||
console.error('fetch group order failed:', error)
|
||
ElMessage.error(error?.message || (isGroupWaveTab.value ? '抓取团购单失败' : '抓取散单失败'))
|
||
} finally {
|
||
groupOrderSubmitting.value = false
|
||
}
|
||
}
|
||
|
||
async function submitFallbackOrderFetchByIds() {
|
||
if (!fallbackOrderSelectionRows.value.length) {
|
||
ElMessage.warning('请先勾选要抓取删单的订单')
|
||
return
|
||
}
|
||
|
||
const ids = fallbackOrderSelectionRows.value
|
||
.map((row: any) => Number(row?.id ?? row?.order_id))
|
||
.filter((id: number) => Number.isFinite(id) && id > 0)
|
||
|
||
if (!ids.length) {
|
||
ElMessage.warning('当前勾选记录缺少有效订单ID')
|
||
return
|
||
}
|
||
|
||
try {
|
||
await ElMessageBox.confirm(
|
||
`确定将选中的 ${ids.length} 条订单按散单抓取至波次吗?`,
|
||
'抓取散单',
|
||
{ type: 'warning' }
|
||
)
|
||
} catch {
|
||
return
|
||
}
|
||
|
||
singleOrderSubmitting.value = true
|
||
try {
|
||
const res: any = await orderWaveSingleFetchByIds({ ids })
|
||
if (!res || !okCode(res.code)) {
|
||
throw new Error(res?.message || '抓取散单失败')
|
||
}
|
||
|
||
const payload =
|
||
res?.data && typeof res.data === 'object' && !Array.isArray(res.data)
|
||
? res.data
|
||
: res
|
||
const waveNo = payload?.wave_no ?? ''
|
||
const fetched = Number(payload?.fetched_order_count ?? 0)
|
||
const parts = [
|
||
res?.message || payload?.message || '抓取散单成功',
|
||
waveNo ? `波次:${waveNo}` : '',
|
||
Number.isFinite(fetched) && fetched >= 0 ? `已抓取 ${fetched} 单` : ''
|
||
]
|
||
const excluded = payload?.excluded_existing_wave_order_ids
|
||
const skipped = payload?.skipped_order_ids
|
||
const notFound = payload?.not_found_order_ids
|
||
if (Array.isArray(excluded) && excluded.length) {
|
||
parts.push(`已在波次中跳过 ${excluded.length} 单`)
|
||
}
|
||
if (Array.isArray(skipped) && skipped.length) {
|
||
parts.push(`跳过 ${skipped.length} 单`)
|
||
}
|
||
if (Array.isArray(notFound) && notFound.length) {
|
||
parts.push(`未找到 ${notFound.length} 单`)
|
||
}
|
||
|
||
ElMessage.success(parts.filter(Boolean).join(';'))
|
||
singleOrderDialogVisible.value = false
|
||
fallbackOrderSelectionRows.value = []
|
||
await loadData()
|
||
} catch (error: any) {
|
||
console.error('fetch fallback order by ids failed:', error)
|
||
ElMessage.error(error?.message || '抓取散单失败')
|
||
} finally {
|
||
singleOrderSubmitting.value = false
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style scoped lang="scss">
|
||
@use "../orderManagement/styles/order-sub.scss";
|
||
|
||
.task-progress-panel--toolbar {
|
||
margin-bottom: 3px;
|
||
}
|
||
|
||
.task-progress-panel {
|
||
padding: 12px 14px;
|
||
background: #fff;
|
||
border: 1px solid #ebeef5;
|
||
}
|
||
|
||
.task-progress-panel__header {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
margin-bottom: 8px;
|
||
gap: 12px;
|
||
}
|
||
|
||
.task-progress-panel__title {
|
||
font-size: 14px;
|
||
font-weight: 600;
|
||
color: #303133;
|
||
}
|
||
|
||
.task-progress-panel__meta {
|
||
font-size: 12px;
|
||
color: #909399;
|
||
}
|
||
|
||
.task-progress-panel__info {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
gap: 12px;
|
||
margin-top: 8px;
|
||
font-size: 12px;
|
||
color: #606266;
|
||
}
|
||
|
||
.task-progress-panel__message {
|
||
margin-top: 6px;
|
||
font-size: 12px;
|
||
color: #606266;
|
||
}
|
||
|
||
.order-sub-container .main-content .lower-level .detail-container {
|
||
padding: 10px;
|
||
overflow: auto;
|
||
}
|
||
|
||
.order-sub-container .main-content .lower-level .detail-header {
|
||
padding: 0 12px;
|
||
height: 42px;
|
||
}
|
||
|
||
.empty-tip {
|
||
text-align: center;
|
||
font-size: 13px;
|
||
line-height: 1.5;
|
||
}
|
||
|
||
.detail-page {
|
||
height: 100%;
|
||
overflow-x: hidden;
|
||
overflow-y: auto;
|
||
}
|
||
|
||
.order-detail-wrapper {
|
||
height: 100%;
|
||
}
|
||
|
||
.order-info-text {
|
||
display: inline-block;
|
||
max-width: 100%;
|
||
white-space: nowrap;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
}
|
||
|
||
.structure-fetch-hint {
|
||
margin-bottom: 4px;
|
||
}
|
||
|
||
.structure-fetch-label-help {
|
||
margin-left: 4px;
|
||
vertical-align: middle;
|
||
color: var(--el-color-info);
|
||
cursor: help;
|
||
}
|
||
|
||
.group-order-dialog {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 10px;
|
||
}
|
||
|
||
.single-fallback-layout {
|
||
display: flex;
|
||
gap: 10px;
|
||
height: 100%;
|
||
min-height: 0;
|
||
}
|
||
|
||
.single-fallback-main {
|
||
flex: 1;
|
||
min-width: 0;
|
||
min-height: 0;
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 10px;
|
||
}
|
||
|
||
.single-order-tabs {
|
||
height: 100%;
|
||
min-height: 0;
|
||
}
|
||
|
||
.wave-strategy-tab {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 10px;
|
||
height: 100%;
|
||
min-height: 0;
|
||
}
|
||
|
||
.wave-strategy-toolbar-actions {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 8px;
|
||
}
|
||
|
||
.wave-strategy-form-grid {
|
||
display: grid;
|
||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||
gap: 2px 12px;
|
||
}
|
||
|
||
.wave-strategy-form-item--full {
|
||
grid-column: 1 / -1;
|
||
}
|
||
|
||
:deep(.el-overlay-dialog > .el-dialog) {
|
||
height: 80vh;
|
||
max-height: 80vh;
|
||
position: fixed;
|
||
top: 50%;
|
||
left: 50%;
|
||
transform: translate(-50%, -50%);
|
||
margin: 0;
|
||
display: flex;
|
||
flex-direction: column;
|
||
box-sizing: border-box;
|
||
overflow: hidden;
|
||
}
|
||
|
||
:deep(.el-overlay-dialog:has(> .el-dialog.wave-fixed-height-dialog)) {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
|
||
:deep(.el-overlay-dialog > .el-dialog .el-dialog__body) {
|
||
flex: 1;
|
||
min-height: 0;
|
||
overflow: auto;
|
||
}
|
||
|
||
:deep(.single-fetch-dialog .el-dialog__body) {
|
||
height: calc(100vh - 240px);
|
||
max-height: calc(100vh - 240px);
|
||
overflow: hidden;
|
||
}
|
||
|
||
:deep(.single-fetch-dialog .el-tabs),
|
||
:deep(.single-fetch-dialog .el-tabs__content),
|
||
:deep(.single-fetch-dialog .el-tab-pane) {
|
||
height: 100%;
|
||
}
|
||
|
||
.group-order-filters {
|
||
padding: 4px 0 0;
|
||
}
|
||
|
||
.group-order-toolbar {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
font-size: 13px;
|
||
color: #606266;
|
||
}
|
||
|
||
.group-order-pagination {
|
||
display: flex;
|
||
justify-content: flex-end;
|
||
padding-top: 4px;
|
||
}
|
||
|
||
.status-summary-text {
|
||
display: inline-block;
|
||
line-height: 1.4;
|
||
}
|
||
|
||
.order-sub-container .main-content {
|
||
.toolbar {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
|
||
.toolbar-right {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 6px;
|
||
flex-shrink: 0;
|
||
padding-left: 8px;
|
||
}
|
||
|
||
.toolbar-switch-label {
|
||
font-size: 12px;
|
||
color: var(--el-text-color-regular);
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.toolbar-left {
|
||
cursor: grab;
|
||
|
||
&:active {
|
||
cursor: grabbing;
|
||
}
|
||
|
||
.toolbar-scroll-container {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 6px;
|
||
overflow-x: auto;
|
||
scrollbar-width: none;
|
||
|
||
&::-webkit-scrollbar {
|
||
display: none;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
</style> |