删单抓取的一些小改动,记得拉取
This commit is contained in:
parent
776bfb01fa
commit
91f5295b4f
@ -23,6 +23,21 @@ export type WaveGroupOrderFetchListParams = {
|
||||
return_order_ids?: boolean
|
||||
}
|
||||
|
||||
export type WaveStrategyFallbackOrderListParams = {
|
||||
pagination?: {
|
||||
page?: number
|
||||
pageSize?: number
|
||||
currentPage?: number
|
||||
page_size?: number
|
||||
size?: number
|
||||
}
|
||||
where?: Record<string, any>
|
||||
sort?: {
|
||||
sortField?: string
|
||||
sortOrder?: 'ASC' | 'DESC' | string
|
||||
}
|
||||
}
|
||||
|
||||
export type WaveFetchParams = {
|
||||
structure_list: Array<{
|
||||
item_detail_machine: string
|
||||
@ -224,12 +239,12 @@ export function orderWaveGroupOrderFetchList(data: WaveGroupOrderFetchListParams
|
||||
} as any)
|
||||
}
|
||||
|
||||
export function orderWaveSingleOrderFetchList(data: WaveGroupOrderFetchListParams = {}): Promise<any> {
|
||||
export function orderWaveWaveStrategyFallbackOrderList(data: WaveStrategyFallbackOrderListParams = {}): Promise<any> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'order.wave.singleOrderFetchList',
|
||||
method: 'order.wave.waveStrategyFallbackOrderList',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
@ -285,6 +300,20 @@ export function orderWaveFetch(data: WaveFetchParams): Promise<WaveFetchResponse
|
||||
} as any)
|
||||
}
|
||||
|
||||
export function orderWaveGroupFetch(data: WaveFetchParams): Promise<WaveFetchResponse & { code?: number; message?: string }> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'order.wave.groupFetch',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
export function orderWaveFetchTaskProgress(data: WaveFetchTaskProgressParams): Promise<WaveFetchTaskProgressResponse & { code?: number; message?: string }> {
|
||||
return request({
|
||||
url: '/system',
|
||||
@ -456,8 +485,9 @@ export function orderWaveBatchRemoveOrders(data: WaveBatchRemoveOrdersParams): P
|
||||
export const orderWave = {
|
||||
batchList: orderWaveBatchList,
|
||||
groupOrderFetchList: orderWaveGroupOrderFetchList,
|
||||
singleOrderFetchList: orderWaveSingleOrderFetchList,
|
||||
waveStrategyFallbackOrderList: orderWaveWaveStrategyFallbackOrderList,
|
||||
singleFetchByIds: orderWaveSingleFetchByIds,
|
||||
groupFetch: orderWaveGroupFetch,
|
||||
fetch: orderWaveFetch,
|
||||
fetchTaskProgress: orderWaveFetchTaskProgress,
|
||||
batchAllocateExpress: orderWaveBatchAllocateExpress,
|
||||
|
||||
@ -435,169 +435,90 @@
|
||||
|
||||
<el-dialog
|
||||
v-model="singleOrderDialogVisible"
|
||||
title="抓取散单候选"
|
||||
title="删单抓取"
|
||||
width="1280px"
|
||||
class="single-fetch-dialog"
|
||||
align-center
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<div class="group-order-dialog">
|
||||
<el-alert
|
||||
type="info"
|
||||
:closable="false"
|
||||
show-icon
|
||||
class="structure-fetch-hint"
|
||||
title="与团购列表的区别:本列表仅展示「同组订单数」小于团购判定阈值(默认取仓库 min_group_order_fetch_quantity)的散单候选分组;勾选后提交抓取任务的方式与团购一致。"
|
||||
/>
|
||||
<el-form :inline="true" size="small" class="group-order-filters">
|
||||
<el-form-item label="货主">
|
||||
<el-select
|
||||
v-model="singleOrderFilters.storeId"
|
||||
placeholder="全部"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 180px"
|
||||
@change="handleSingleOrderFilterChange"
|
||||
>
|
||||
<el-option
|
||||
v-for="store in groupOrderStoreOptions"
|
||||
:key="'s-' + String(store.value)"
|
||||
:label="store.label"
|
||||
:value="store.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<template #label>
|
||||
<span>团购判定阈值</span>
|
||||
<el-tooltip
|
||||
placement="top"
|
||||
content="同组订单数 ≥ 该值视为团购命中并从团购列表返回;本接口返回同组订单数 < 该值的散单候选。未填写时使用仓库配置 min_group_order_fetch_quantity(默认 13)。"
|
||||
<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"
|
||||
width="300px"
|
||||
: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="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-icon class="structure-fetch-label-help"><QuestionFilled /></el-icon>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
<el-input-number
|
||||
v-model="singleOrderFilters.sameOrderQuantity"
|
||||
:min="1"
|
||||
:controls="false"
|
||||
style="width: 150px"
|
||||
@change="handleSingleOrderFilterChange"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="店铺名称">
|
||||
<el-input
|
||||
v-model="singleOrderFilters.shopName"
|
||||
clearable
|
||||
placeholder="模糊匹配店铺名称"
|
||||
style="width: 180px"
|
||||
@keyup.enter="fetchSingleOrderList"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="包含 SKU">
|
||||
<el-input
|
||||
v-model="singleOrderFilters.includeSku"
|
||||
clearable
|
||||
placeholder="仅保留包含该 SKU 的分组"
|
||||
style="width: 180px"
|
||||
@keyup.enter="fetchSingleOrderList"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-switch
|
||||
v-model="singleOrderFilters.distinguishExpress"
|
||||
active-text="区分快递"
|
||||
inactive-text="不区分快递"
|
||||
@change="handleSingleOrderFilterChange"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" :loading="singleOrderListLoading" @click="fetchSingleOrderList">查询</el-button>
|
||||
<el-button @click="resetSingleOrderFilters">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-table-column type="selection" width="48" reserve-selection />
|
||||
<el-table-column prop="id" label="订单ID" min-width="100" />
|
||||
<el-table-column prop="delivery_order_code" label="订单号" min-width="180" show-overflow-tooltip />
|
||||
<el-table-column prop="shop_name" label="店铺" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="sys_platform_name" label="平台" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="logistics_name" label="快递" min-width="120" show-overflow-tooltip />
|
||||
<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>
|
||||
|
||||
<div class="group-order-toolbar">
|
||||
<div class="group-order-toolbar__left">
|
||||
<span>已选 {{ singleOrderSelectionRows.length }} 个结构</span>
|
||||
<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-checkbox v-model="singleOrderFilters.returnOrderIds">返回订单 ID 列表</el-checkbox>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
|
||||
<el-table
|
||||
ref="singleOrderTableRef"
|
||||
:data="singleOrderList"
|
||||
v-loading="singleOrderListLoading"
|
||||
border
|
||||
size="small"
|
||||
row-key="item_detail_machine"
|
||||
max-height="460"
|
||||
@selection-change="handleSingleOrderSelectionChange"
|
||||
>
|
||||
<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="singleOrderQuantityMap[row.item_detail_machine]"
|
||||
:min="1"
|
||||
:controls="false"
|
||||
placeholder="默认"
|
||||
style="width: 92px"
|
||||
@change="(value: number | undefined) => updateSingleOrderQuantity(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>
|
||||
<el-tab-pane label="波次策略(待开发)" name="strategy-api">
|
||||
<el-empty description="波次策略接口页签暂未接入" />
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
|
||||
<template #empty>
|
||||
<div class="empty-tip">暂无可抓取的散单候选结构</div>
|
||||
</template>
|
||||
</el-table>
|
||||
|
||||
<div class="group-order-pagination">
|
||||
<el-pagination
|
||||
v-model:current-page="singleOrderPagination.currentPage"
|
||||
v-model:page-size="singleOrderPagination.pageSize"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
:total="singleOrderPagination.total"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
background
|
||||
size="small"
|
||||
@size-change="handleSingleOrderPageSizeChange"
|
||||
@current-change="handleSingleOrderPageChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button size="small" @click="singleOrderDialogVisible = false">取消</el-button>
|
||||
<el-button size="small" type="primary" :loading="singleOrderSubmitting" @click="submitSingleOrderDialog">抓取选中结构</el-button>
|
||||
<el-button size="small" @click="singleOrderDialogVisible = false">关闭</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
@ -620,9 +541,9 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { QuestionFilled } from '@element-plus/icons-vue'
|
||||
import ScanBox from '@/components/ScanBox/index.vue'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
import { pendingAvailableFields } from '@/views/order/orderManagement/config/order-common-config'
|
||||
import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config'
|
||||
import {
|
||||
waveScanBoxConfig,
|
||||
@ -651,9 +572,11 @@ import {
|
||||
orderWaveBatchRemoveExceptionOrdersTaskProgress,
|
||||
orderWaveBatchList,
|
||||
orderWaveFetch,
|
||||
orderWaveGroupFetch,
|
||||
orderWaveSingleFetchByIds,
|
||||
orderWaveWaveStrategyFallbackOrderList,
|
||||
orderWaveFetchTaskProgress,
|
||||
orderWaveGroupOrderFetchList,
|
||||
orderWaveSingleOrderFetchList
|
||||
orderWaveGroupOrderFetchList
|
||||
} from '@/api/order.wave/orderwave'
|
||||
import type {
|
||||
WaveBatchAllocateExpressTaskProgressResponse,
|
||||
@ -777,13 +700,16 @@ const batchCancelTaskProgress = reactive({
|
||||
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||||
const groupOrderPagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||||
const singleOrderDialogVisible = ref(false)
|
||||
const singleOrderListLoading = ref(false)
|
||||
const singleOrderActiveTab = ref<'fallback-orders' | 'strategy-api'>('fallback-orders')
|
||||
const singleOrderSubmitting = ref(false)
|
||||
const singleOrderList = ref<any[]>([])
|
||||
const singleOrderSelectionRows = ref<any[]>([])
|
||||
const singleOrderPagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||||
const fallbackOrderScanBox = ref<any>(null)
|
||||
const fallbackOrderListLoading = ref(false)
|
||||
const fallbackOrderList = ref<any[]>([])
|
||||
const fallbackOrderSelectionRows = ref<any[]>([])
|
||||
const fallbackOrderPagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||||
const presetTree = ref<any[]>([])
|
||||
const availableFieldsRef = reactive(JSON.parse(JSON.stringify(waveAvailableFields)))
|
||||
const fallbackOrderAvailableFieldsRef = reactive(JSON.parse(JSON.stringify(pendingAvailableFields)))
|
||||
const columns = ref(JSON.parse(JSON.stringify(waveBatchColumns)))
|
||||
|
||||
const toolbarButtons = computed(() => getWaveToolbarButtons(props.waveType))
|
||||
@ -912,15 +838,6 @@ const groupOrderFilters = reactive({
|
||||
returnOrderIds: false
|
||||
})
|
||||
const groupOrderQuantityMap = reactive<Record<string, number | undefined>>({})
|
||||
const singleOrderFilters = reactive({
|
||||
distinguishExpress: true,
|
||||
storeId: undefined as number | string | undefined,
|
||||
sameOrderQuantity: undefined as number | undefined,
|
||||
shopName: '',
|
||||
includeSku: '',
|
||||
returnOrderIds: false
|
||||
})
|
||||
const singleOrderQuantityMap = reactive<Record<string, number | undefined>>({})
|
||||
const isGroupWaveTab = computed(() => props.waveType === 1)
|
||||
const currentWaveType = computed(() => props.waveType)
|
||||
const tableListId = computed(() => `wave-management-list-${props.waveType}`)
|
||||
@ -2275,12 +2192,10 @@ function openGroupOrderDialog() {
|
||||
|
||||
function openSingleOrderDialog() {
|
||||
singleOrderDialogVisible.value = true
|
||||
singleOrderFilters.distinguishExpress = true
|
||||
singleOrderPagination.currentPage = 1
|
||||
singleOrderSelectionRows.value = []
|
||||
resetSingleOrderQuantityMap()
|
||||
loadGroupOrderStoreOptions()
|
||||
fetchSingleOrderList()
|
||||
singleOrderActiveTab.value = 'fallback-orders'
|
||||
fallbackOrderPagination.currentPage = 1
|
||||
fallbackOrderSelectionRows.value = []
|
||||
void fetchFallbackOrderList()
|
||||
}
|
||||
|
||||
async function loadGroupOrderStoreOptions() {
|
||||
@ -2340,16 +2255,37 @@ function buildGroupOrderListPayload() {
|
||||
return buildStructureFetchListPayload(groupOrderPagination, groupOrderFilters)
|
||||
}
|
||||
|
||||
function buildSingleOrderListPayload() {
|
||||
return buildStructureFetchListPayload(singleOrderPagination, singleOrderFilters)
|
||||
function sanitizeFallbackOrderWhere(where: Record<string, any>) {
|
||||
const nextWhere: Record<string, any> = {}
|
||||
Object.keys(where || {}).forEach((key) => {
|
||||
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
|
||||
}
|
||||
|
||||
async function fetchSingleOrderList() {
|
||||
singleOrderListLoading.value = true
|
||||
function buildFallbackOrderListPayload() {
|
||||
return {
|
||||
pagination: {
|
||||
page: fallbackOrderPagination.currentPage,
|
||||
pageSize: fallbackOrderPagination.pageSize
|
||||
},
|
||||
where: sanitizeFallbackOrderWhere(buildWhereConditions(fallbackOrderScanBox.value?.getConditions?.() || {})),
|
||||
sort: {
|
||||
sortField: 'updated_at',
|
||||
sortOrder: 'DESC'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchFallbackOrderList() {
|
||||
fallbackOrderListLoading.value = true
|
||||
try {
|
||||
const res: any = await orderWaveSingleOrderFetchList(buildSingleOrderListPayload())
|
||||
const res: any = await orderWaveWaveStrategyFallbackOrderList(buildFallbackOrderListPayload())
|
||||
if (!res || !okCode(res.code)) {
|
||||
throw new Error(res?.message || '获取散单候选列表失败')
|
||||
throw new Error(res?.message || '获取不符合波次策略订单失败')
|
||||
}
|
||||
const responseList = Array.isArray(res.list)
|
||||
? res.list
|
||||
@ -2357,17 +2293,17 @@ async function fetchSingleOrderList() {
|
||||
? res.data.list
|
||||
: []
|
||||
const responsePagination = res.pagination || res.data?.pagination || {}
|
||||
singleOrderList.value = responseList
|
||||
singleOrderPagination.currentPage = responsePagination.page || singleOrderPagination.currentPage
|
||||
singleOrderPagination.pageSize = responsePagination.pageSize || singleOrderPagination.pageSize
|
||||
singleOrderPagination.total = responsePagination.total || 0
|
||||
fallbackOrderList.value = responseList
|
||||
fallbackOrderPagination.currentPage = responsePagination.page || fallbackOrderPagination.currentPage
|
||||
fallbackOrderPagination.pageSize = responsePagination.pageSize || fallbackOrderPagination.pageSize
|
||||
fallbackOrderPagination.total = responsePagination.total || 0
|
||||
} catch (error: any) {
|
||||
console.error('fetch single order list failed:', error)
|
||||
singleOrderList.value = []
|
||||
singleOrderPagination.total = 0
|
||||
ElMessage.error(error?.message || '获取散单候选列表失败')
|
||||
console.error('fetch fallback order list failed:', error)
|
||||
fallbackOrderList.value = []
|
||||
fallbackOrderPagination.total = 0
|
||||
ElMessage.error(error?.message || '获取不符合波次策略订单失败')
|
||||
} finally {
|
||||
singleOrderListLoading.value = false
|
||||
fallbackOrderListLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
@ -2429,51 +2365,40 @@ function handleGroupOrderPageSizeChange(size: number) {
|
||||
fetchGroupOrderList()
|
||||
}
|
||||
|
||||
function handleSingleOrderSelectionChange(rows: any[]) {
|
||||
singleOrderSelectionRows.value = rows || []
|
||||
function handleFallbackOrderSelectionChange(rows: any[]) {
|
||||
fallbackOrderSelectionRows.value = rows || []
|
||||
}
|
||||
|
||||
function handleSingleOrderFilterChange() {
|
||||
singleOrderPagination.currentPage = 1
|
||||
fetchSingleOrderList()
|
||||
function handleFallbackOrderConditionChange() {
|
||||
fallbackOrderPagination.currentPage = 1
|
||||
void fetchFallbackOrderList()
|
||||
}
|
||||
|
||||
function resetSingleOrderFilters() {
|
||||
singleOrderFilters.distinguishExpress = true
|
||||
singleOrderFilters.storeId = undefined
|
||||
singleOrderFilters.sameOrderQuantity = undefined
|
||||
singleOrderFilters.shopName = ''
|
||||
singleOrderFilters.includeSku = ''
|
||||
singleOrderFilters.returnOrderIds = false
|
||||
singleOrderPagination.currentPage = 1
|
||||
fetchSingleOrderList()
|
||||
function handleFallbackOrderConditionClear() {
|
||||
fallbackOrderPagination.currentPage = 1
|
||||
void fetchFallbackOrderList()
|
||||
}
|
||||
|
||||
function handleSingleOrderPageChange(page: number) {
|
||||
singleOrderPagination.currentPage = page
|
||||
fetchSingleOrderList()
|
||||
function handleFallbackOrderConditionReset() {
|
||||
fallbackOrderPagination.currentPage = 1
|
||||
void fetchFallbackOrderList()
|
||||
}
|
||||
|
||||
function handleSingleOrderPageSizeChange(size: number) {
|
||||
singleOrderPagination.pageSize = size
|
||||
singleOrderPagination.currentPage = 1
|
||||
fetchSingleOrderList()
|
||||
function resetFallbackOrderCondition() {
|
||||
fallbackOrderPagination.currentPage = 1
|
||||
fallbackOrderScanBox.value?.reset?.()
|
||||
void fetchFallbackOrderList()
|
||||
}
|
||||
|
||||
function updateSingleOrderQuantity(row: any, value: number | undefined) {
|
||||
const key = String(row?.item_detail_machine || '')
|
||||
if (!key) return
|
||||
if (value === undefined || value === null || Number.isNaN(Number(value))) {
|
||||
delete singleOrderQuantityMap[key]
|
||||
return
|
||||
}
|
||||
singleOrderQuantityMap[key] = Math.max(1, Math.trunc(Number(value)))
|
||||
function handleFallbackOrderPageChange(page: number) {
|
||||
fallbackOrderPagination.currentPage = page
|
||||
void fetchFallbackOrderList()
|
||||
}
|
||||
|
||||
function resetSingleOrderQuantityMap() {
|
||||
Object.keys(singleOrderQuantityMap).forEach((key) => {
|
||||
delete singleOrderQuantityMap[key]
|
||||
})
|
||||
function handleFallbackOrderPageSizeChange(size: number) {
|
||||
fallbackOrderPagination.pageSize = size
|
||||
fallbackOrderPagination.currentPage = 1
|
||||
void fetchFallbackOrderList()
|
||||
}
|
||||
|
||||
function updateGroupOrderQuantity(row: any, value: number | undefined) {
|
||||
@ -2542,7 +2467,7 @@ async function submitGroupOrderDialog() {
|
||||
return payload
|
||||
})
|
||||
|
||||
const res = await orderWaveFetch({ structure_list: structureList }) as WaveFetchResponse & { code?: number; message?: string }
|
||||
const res = await orderWaveGroupFetch({ structure_list: structureList }) as WaveFetchResponse & { code?: number; message?: string }
|
||||
if (!res || !okCode(res.code)) {
|
||||
throw new Error(res?.message || '抓取团购单失败')
|
||||
}
|
||||
@ -2577,55 +2502,68 @@ async function submitGroupOrderDialog() {
|
||||
}
|
||||
}
|
||||
|
||||
async function submitSingleOrderDialog() {
|
||||
if (!singleOrderSelectionRows.value.length) {
|
||||
ElMessage.warning('请先勾选要抓取的散单结构')
|
||||
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 structureList: WaveFetchParams['structure_list'] = singleOrderSelectionRows.value.map((row: any) => {
|
||||
const key = String(row?.item_detail_machine || '')
|
||||
const payload: WaveFetchParams['structure_list'][number] = {
|
||||
item_detail_machine: key
|
||||
}
|
||||
const quantity = singleOrderQuantityMap[key]
|
||||
if (quantity !== undefined) {
|
||||
payload.quantity = quantity
|
||||
}
|
||||
return payload
|
||||
})
|
||||
|
||||
const res = await orderWaveFetch({ structure_list: structureList }) as WaveFetchResponse & { code?: number; message?: string }
|
||||
const res: any = await orderWaveSingleFetchByIds({ ids })
|
||||
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(';')
|
||||
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} 单`)
|
||||
}
|
||||
|
||||
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 || '任务已提交,后端异步处理中'
|
||||
})
|
||||
scheduleFetchTaskPolling(1000)
|
||||
|
||||
ElMessage.success(acceptedMessage)
|
||||
ElMessage.success(parts.filter(Boolean).join(';'))
|
||||
singleOrderDialogVisible.value = false
|
||||
singleOrderSelectionRows.value = []
|
||||
resetSingleOrderQuantityMap()
|
||||
fallbackOrderSelectionRows.value = []
|
||||
await loadData()
|
||||
} catch (error: any) {
|
||||
console.error('fetch single order failed:', error)
|
||||
console.error('fetch fallback order by ids failed:', error)
|
||||
ElMessage.error(error?.message || '抓取散单失败')
|
||||
} finally {
|
||||
singleOrderSubmitting.value = false
|
||||
@ -2727,6 +2665,39 @@ async function submitSingleOrderDialog() {
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.single-order-tabs {
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
|
||||
: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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user