feat(task-progress): 异步任务弹窗支持已选项标签,新增运单揽收状态更新

- task-progress 新增 tags 表单字段类型与 SelectedTags 组件,任务弹窗可展示
  已选订单/运单/出库单标签并支持逐个移除,样式对齐「编辑投递计划」输入行
- 更新备注、更新订单备注/地址、同步订单号、分配储位、批量异步任务等表单,
  以及待处理/异常/复核/波次面板接入该能力,提交前可核对并调整已选项
- 新增 orderTagItems 工具:按行或按 ids 顺序生成标签,兼容 id / order_id
  与 delivery_order_code / order_code 等字段差异
- waybill.warehouse 新增 updateReceive、updateReceiveTaskProgress 异步接口,
  运单页新增「更新揽收状态」工具栏按钮,接入任务进度轮询、结果汇总与列表刷新
- 库存批量编辑、出库单批量作废、收货列表等页面同步接入已选项标签展示
- UnifiedTaskProgressDialog 补充 remove-field-item 事件透传,保持各任务弹窗行为一致
This commit is contained in:
yin 2026-11-10 18:00:21 +08:00
parent da429052ed
commit 0d549b455f
22 changed files with 1085 additions and 129 deletions

View File

@ -186,11 +186,74 @@ export function waybillWarehouseExportTaskProgress(
} as any)
}
// ============ waybill.warehouse.updateReceive ============
/** waybill.warehouse.updateReceive 请求参数 */
export type WaybillWarehouseUpdateReceiveParams = {
/** 运单号列表(字符串数组),提交后按 10 单一批调用外部接口;空数组返回失败 */
waybillCodes?: string[]
/** waybillCodes 的下划线别名,二者取其一 */
waybill_codes?: string[]
}
/**
* waybill.warehouse.updateReceive:批量更新运单是否揽收-仓库侧
*
* 按运单号调用外部访问接口 waybill.getreceive 查询揽收状态(单批最多 10 单,超出自动切批),
* 并把结果回写 wms_order_express.is_galaxy_receive(按 warehouse_id 隔离)。
* 异步任务模式:返回任务受理信息(任务 ID 前缀 waybill_receive_),进度用 updateReceiveTaskProgress 查询。
* 仓库未配置承接该回调方法的 API 应用时直接失败,不创建任务。
*/
export function waybillWarehouseUpdateReceive(
data: WaybillWarehouseUpdateReceiveParams
): Promise<any> {
return request({
url: '/system',
method: 'post',
params: {
method: 'waybill.warehouse.updateReceive',
v,
timestamp: Date.now()
},
data,
isSystemApi: true
} as any)
}
// ============ waybill.warehouse.updateReceiveTaskProgress ============
/** waybill.warehouse.updateReceiveTaskProgress 请求参数 */
export type WaybillWarehouseUpdateReceiveTaskProgressParams = {
/** 异步任务ID(前缀 waybill_receive_)。与 taskId 二选一 */
task_id?: string
/** 异步任务ID(别名,优先使用)。至少传入 taskId 或 task_id 之一 */
taskId?: string
}
/** waybill.warehouse.updateReceiveTaskProgress:运单揽收状态更新进度查询-仓库侧 */
export function waybillWarehouseUpdateReceiveTaskProgress(
data: WaybillWarehouseUpdateReceiveTaskProgressParams
): Promise<any> {
return request({
url: '/system',
method: 'post',
params: {
method: 'waybill.warehouse.updateReceiveTaskProgress',
v,
timestamp: Date.now()
},
data,
isSystemApi: true
} as any)
}
// ============ 模块导出 ============
export const waybillWarehouseModule = {
list: waybillWarehouseList,
detail: waybillWarehouseDetail,
export: waybillWarehouseExport,
exportTaskProgress: waybillWarehouseExportTaskProgress
exportTaskProgress: waybillWarehouseExportTaskProgress,
updateReceive: waybillWarehouseUpdateReceive,
updateReceiveTaskProgress: waybillWarehouseUpdateReceiveTaskProgress
}

View File

@ -0,0 +1,109 @@
<!--
SelectedTags — task-panel 表单里的「已选 xxx」行
样式对齐「编辑投递计划 - 投递时间」:标签平铺、小号可关闭,无灰底/无边框。
与 TaskProgressPanel 的 tags 字段保持一致,供自行实现 task-panel 的弹窗复用。
-->
<template>
<div class="selected-tags">
<span class="selected-tags__label">{{ label }}</span>
<div class="selected-tags__list">
<el-tag
v-for="item in items"
:key="item.value"
size="small"
:closable="closable"
@close="emit('remove', item.value)"
>{{ item.label }}</el-tag>
<span v-if="!items.length" class="selected-tags__empty">{{ emptyText }}</span>
</div>
</div>
</template>
<script setup lang="ts">
withDefaults(
defineProps<{
items: Array<{ label: string; value: string | number }>
label?: string
closable?: boolean
emptyText?: string
}>(),
{
label: '已选订单数',
closable: true,
emptyText: '—'
}
)
const emit = defineEmits<{
(e: 'remove', value: string | number): void
}>()
</script>
<style scoped lang="scss">
.selected-tags {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 16px;
min-height: 0;
padding: 4px 0 0 12px;
&__label {
flex: 0 0 88px;
width: 88px;
padding-left: 10px;
padding-top: 2px;
box-sizing: border-box;
font-size: 12px;
line-height: 20px;
color: #606266;
text-align: left;
white-space: nowrap;
}
&__list {
flex: 1;
min-width: 0;
display: flex;
flex-wrap: wrap;
align-content: flex-start;
gap: 6px;
max-height: 148px;
overflow-y: auto;
scrollbar-width: thin;
scrollbar-color: #dcdfe6 transparent;
&::-webkit-scrollbar {
width: 6px;
}
&::-webkit-scrollbar-thumb {
border-radius: 3px;
background: #dcdfe6;
}
&::-webkit-scrollbar-track {
background: transparent;
}
:deep(.el-tag) {
max-width: 100%;
margin: 0;
}
/* 名称较长时省略,避免撑破弹窗 */
:deep(.el-tag .el-tag__content) {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
&__empty {
font-size: 12px;
line-height: 20px;
color: #909399;
}
}
</style>

View File

@ -18,10 +18,28 @@
<div class="task-panel__body">
<template v-if="mode === 'form'">
<div v-if="fields.length" class="task-panel__form">
<div v-for="field in fields" :key="field.label" class="task-panel__field">
<div
v-for="field in fields"
:key="field.label"
class="task-panel__field"
:class="{ 'is-tags': field.type === 'tags' }"
>
<span class="task-panel__field-label">{{ field.label }}</span>
<!-- 标签列表:逐个展示已选数据,标签可移除(移除后由调用方同步数据) -->
<div v-if="field.type === 'tags'" class="task-panel__field-tags">
<el-tag
v-for="item in field.items || []"
:key="item.value"
size="small"
:closable="field.closable !== false"
@close="emit('remove-field-item', field, item)"
>{{ item.label }}</el-tag>
<span v-if="!(field.items && field.items.length)" class="task-panel__field-empty">
{{ field.emptyText || '—' }}
</span>
</div>
<button
v-if="field.type === 'switch'"
v-else-if="field.type === 'switch'"
type="button"
class="task-panel__switch"
:class="{ 'is-on': field.active, 'is-clickable': field.interactive }"
@ -92,6 +110,7 @@ import { estimateRemainingText } from './estimate'
import { useSmoothNumber, useSmoothNumericText } from './smoothing'
import type {
ProgressFormField,
ProgressFormFieldItem,
ProgressMetricItem,
ProgressState,
ProgressSummaryItem
@ -168,6 +187,7 @@ const props = withDefaults(
const emit = defineEmits<{
(e: 'close'): void
(e: 'toggle-field', field: ProgressFormField): void
(e: 'remove-field-item', field: ProgressFormField, item: ProgressFormFieldItem): void
}>()
const roundedPercent = computed(() => {
@ -500,6 +520,65 @@ const etaLabel = computed(
text-align: right;
}
/* 标签型字段:对齐「编辑投递计划 - 投递时间」的输入行(无灰底、无边框,标签直接铺开) */
&__field.is-tags {
align-items: flex-start;
min-height: 0;
padding: 4px 0 0 12px;
border: none;
border-radius: 0;
background: transparent;
.task-panel__field-label {
padding-top: 2px;
}
}
&__field-tags {
flex: 1;
min-width: 0;
display: flex;
flex-wrap: wrap;
align-content: flex-start;
gap: 6px;
max-height: 148px;
overflow-y: auto;
scrollbar-width: thin;
scrollbar-color: #dcdfe6 transparent;
&::-webkit-scrollbar {
width: 6px;
}
&::-webkit-scrollbar-thumb {
border-radius: 3px;
background: #dcdfe6;
}
&::-webkit-scrollbar-track {
background: transparent;
}
:deep(.el-tag) {
max-width: 100%;
margin: 0;
}
/* 单号较长时省略,避免撑破弹窗 */
:deep(.el-tag .el-tag__content) {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
&__field-empty {
font-size: 12px;
line-height: 20px;
color: #909399;
}
&__switch {
position: relative;
width: 40px;

View File

@ -11,7 +11,12 @@
@update:model-value="emit('update:visible', $event)"
@closed="emit('closed')"
>
<TaskProgressPanel v-bind="panelProps" @close="close" @toggle-field="emit('toggle-field', $event)">
<TaskProgressPanel
v-bind="panelProps"
@close="close"
@toggle-field="emit('toggle-field', $event)"
@remove-field-item="(field, item) => emit('remove-field-item', field, item)"
>
<template #form-extra>
<slot name="form-extra" />
</template>
@ -38,6 +43,7 @@ import { computed } from 'vue'
import TaskProgressPanel from './TaskProgressPanel.vue'
import type {
ProgressFormField,
ProgressFormFieldItem,
ProgressMetricItem,
ProgressState,
ProgressSummaryItem
@ -114,6 +120,7 @@ const emit = defineEmits<{
(e: 'closed'): void
(e: 'submit'): void
(e: 'toggle-field', field: ProgressFormField): void
(e: 'remove-field-item', field: ProgressFormField, item: ProgressFormFieldItem): void
}>()
const panelProps = computed(() => ({

View File

@ -15,13 +15,25 @@ export interface ProgressMetricItem {
unit?: string
}
/** 表单字段标签项(type=tags 时使用) */
export interface ProgressFormFieldItem {
label: string
value: string | number
}
/** 表单字段(提交前的参数展示) */
export interface ProgressFormField {
label: string
value?: string | number
type?: 'text' | 'switch'
type?: 'text' | 'switch' | 'tags'
/** type=switch 时是否开启 */
active?: boolean
/** type=switch 时是否允许用户点击切换(默认仅展示) */
interactive?: boolean
/** type=tags 时的标签项(每个标签可移除) */
items?: ProgressFormFieldItem[]
/** type=tags 时标签是否可移除(默认 true) */
closable?: boolean
/** type=tags 且没有标签时的占位文案 */
emptyText?: string
}

View File

@ -6,6 +6,8 @@
* - waybillWarehouseList → waybill.warehouse.list 运单列表
* - waybillWarehouseDetail → waybill.warehouse.detail 运单详情
* - waybillWarehouseExport → waybill.warehouse.export 运单导出
* - waybillWarehouseUpdateReceive → waybill.warehouse.updateReceive 批量更新揽收
* - waybillWarehouseUpdateReceiveTaskProgress → waybill.warehouse.updateReceiveTaskProgress 揽收更新进度
*/
import type { Component } from 'vue'
@ -15,6 +17,8 @@ import {
waybillWarehouseList,
waybillWarehouseExport,
waybillWarehouseExportTaskProgress,
waybillWarehouseUpdateReceive,
waybillWarehouseUpdateReceiveTaskProgress,
} from '@/api/waybill.warehouse'
// ============================================================
@ -567,6 +571,10 @@ export interface TabPageApiConfig {
log?: ComponentApiConfig
export?: ApiMethod
exportProgress?: ApiMethod
/** 批量更新运单是否揽收(异步任务) */
updateReceive?: ApiMethod
/** 揽收状态更新任务进度查询 */
updateReceiveProgress?: ApiMethod
scanBoxOptions?: Record<string, ApiMethod>
toolbar?: Record<string, ApiMethod>
parseListResponse?: (res: any) => { list: any[]; total: number }
@ -876,6 +884,17 @@ export const TOOLBAR_BUTTONS: Record<string, ToolbarButtonConfig> = {
disabledKey: 'noSelection',
action: 'openTransferByWaybillsDialog'
},
updateReceive: {
key: 'updateReceive',
label: '更新揽收状态',
category: 'function',
size: 'small',
type: 'success',
plain: true,
loadingKey: 'receiveLoading',
disabledKey: 'noSelection',
action: 'handleUpdateReceive'
},
}
export function getTabToolbarButtons(tabName: string): ToolbarButtonConfig[] {
@ -1004,6 +1023,8 @@ export const tabPages: TabPageRawConfig[] = [
detail: { source: 'list' } as ComponentApiConfig,
export: waybillWarehouseExport as ApiMethod,
exportProgress: waybillWarehouseExportTaskProgress as ApiMethod,
updateReceive: waybillWarehouseUpdateReceive as ApiMethod,
updateReceiveProgress: waybillWarehouseUpdateReceiveTaskProgress as ApiMethod,
parseListResponse(res: any) {
const data = res?.data ?? res
return {

View File

@ -249,6 +249,19 @@
:error="exportTaskProgress.error"
:meta="exportTaskProgress"
/>
<!-- 批量更新揽收状态(waybill.warehouse.updateReceive 异步任务) -->
<TaskProgressDialog
v-if="receiveProgressVisible"
:visible="receiveProgressVisible"
title="更新揽收状态"
:polling="receiveProgressPolling"
:task-id="receiveProgressState.taskId"
:progress-percent="receiveProgressState.progress"
:status-label="receiveProgressStatusLabel"
:error-text="receiveProgressState.error"
@close="closeReceiveProgress"
/>
</div>
</template>
@ -270,9 +283,11 @@ import ColumnCellRenderer from './components/ColumnCellRenderer.vue'
import OperationCellRenderer from './components/OperationCellRenderer.vue'
import TransferByWaybillsDialog from './components/TransferByWaybillsDialog.vue'
import AsyncExportProgressDialog from '@/components/AsyncExportProgressDialog.vue'
import TaskProgressDialog from '@/components/TaskProgressDialog.vue'
import OrderToolbarButtonGroup from '@/components/ToolbarButtonGroup/index.vue'
import { waybillWarehouseDetail } from '@/api/waybill.warehouse'
import { useAsyncExportTask } from '@/composables/useAsyncExportTask'
import { useTaskProgress } from '@/composables/useTaskProgress'
import {
extractStoreListFromResponse,
mapExpressListToCompanySelectOptions,
@ -456,7 +471,8 @@ const buttonDisabledMap = computed<Record<string, boolean>>(() => ({
const buttonLoadingMap = computed<Record<string, boolean>>(() => ({
loading: loading.value,
exportLoading: exportLoading.value
exportLoading: exportLoading.value,
receiveLoading: receiveLoading.value
}))
const buttonLabelMap = computed<Record<string, string>>(() => ({
@ -560,7 +576,8 @@ const toolbarActionMap: Record<string, () => void> = {
toggleDetailVisible: () => { detailVisible.value = !detailVisible.value },
handleExportSelected: () => { void handleExportSelected() },
handleExportAll: () => { void handleExportAll() },
openTransferByWaybillsDialog: () => { openTransferByWaybillsDialog() }
openTransferByWaybillsDialog: () => { openTransferByWaybillsDialog() },
handleUpdateReceive: () => { void handleUpdateReceive() }
}
function handleToolbarButtonClick(action: string) {
@ -715,6 +732,145 @@ function handleTransferByWaybillsSuccess() {
void loadData()
}
// ============================================================
// 批量更新揽收状态(waybill.warehouse.updateReceive)
// ============================================================
/** 提交中(按钮 loading / 防重复提交) */
const receiveLoading = ref(false)
/** 解析异步任务响应体(兼容 data / data.data 嵌套) */
function parseReceiveTaskPayload(res: any): Record<string, any> {
if (!res || typeof res !== 'object') return {}
const root = res as Record<string, any>
const nested = root.data
if (!nested || typeof nested !== 'object' || Array.isArray(nested)) return root
const deep = nested.data
if (
deep
&& typeof deep === 'object'
&& !Array.isArray(deep)
&& (deep.task_id || deep.taskId || deep.status || deep.progress !== undefined)
) {
return deep
}
return nested
}
/** 进度接口响应 → useTaskProgress 期望结构(频率字段做兼容归一) */
function normalizeReceiveProgress(res: any) {
const payload = parseReceiveTaskPayload(res)
const rawStatus = String(payload.status || '').toLowerCase()
// 任务不存在/已过期:按失败处理,避免无意义轮询到超时
const status = rawStatus === 'not_found' ? 'failed' : rawStatus
const total = Number(payload.total ?? payload.total_count ?? payload.totalCount ?? 0)
const processed = Number(
payload.processed
?? payload.processed_count
?? payload.processedCount
?? payload.current
?? payload.done
?? 0
)
const rawProgress = Number(payload.progress)
const progress = Number.isFinite(rawProgress)
? rawProgress
: total > 0
? Math.round((processed / total) * 100)
: undefined
return {
status,
progress,
message: String(payload.message || ''),
error: rawStatus === 'not_found'
? (payload.message || '任务不存在或已过期')
: String(payload.error || ''),
result: payload
}
}
const {
visible: receiveProgressVisible,
polling: receiveProgressPolling,
state: receiveProgressState,
startPolling: startReceivePolling,
close: closeReceiveProgress
} = useTaskProgress({
interval: 1500,
// 200 次 × 1.5s ≈ 5 分钟上限,超时后提示刷新查看结果
maxAttempts: 200,
pollFn: async (taskId: string) => {
const cfg = currentTabConfig.value
if (!cfg?.api?.updateReceiveProgress) throw new Error('揽收进度接口未配置')
const res = await cfg.api.updateReceiveProgress({ task_id: taskId })
return normalizeReceiveProgress(res)
},
onSuccess: async () => {
ElMessage.success('揽收状态更新完成')
upperTableRef.value?.clearSelection?.()
selectedRows.value = []
await loadData()
},
onError: (error: string) => {
ElMessage.error(error || '揽收状态更新失败')
}
})
const receiveProgressStatusLabel = computed(() => {
const map: Record<string, string> = {
submitted: '已提交',
running: '处理中',
success: '已完成',
completed: '已完成',
failed: '失败',
error: '错误'
}
return map[receiveProgressState.status] || receiveProgressState.status || '—'
})
/** 勾选运单 → 提交揽收状态更新任务 → 轮询进度 */
async function handleUpdateReceive() {
if (receiveLoading.value) return
if (!selectedRows.value.length) {
ElMessage.warning('请先勾选需要更新揽收状态的运单')
return
}
const waybillCodes = selectedRows.value
.map((row: any) => String(row?.waybill_code ?? row?.waybillCode ?? '').trim())
.filter(Boolean)
if (!waybillCodes.length) {
ElMessage.warning('勾选的运单缺少运单号,无法更新揽收状态')
return
}
const cfg = currentTabConfig.value
if (!cfg?.api?.updateReceive) {
ElMessage.error('揽收状态更新接口未配置')
return
}
receiveLoading.value = true
try {
const res = await cfg.api.updateReceive({ waybillCodes })
const payload = parseReceiveTaskPayload(res)
const taskId = String(payload.task_id || payload.taskId || '').trim()
if (!taskId) {
throw new Error(payload.message || res?.message || '揽收状态更新任务提交失败')
}
ElMessage.success(`已提交 ${waybillCodes.length} 个运单的揽收状态更新任务`)
// 异步任务:不 await,轮询由进度弹窗接管
void startReceivePolling(taskId)
} catch (e: any) {
ElMessage.error(e?.message || '揽收状态更新失败')
} finally {
receiveLoading.value = false
}
}
// ============================================================
// 明细面板
// ============================================================

View File

@ -215,6 +215,7 @@
v-model:allow-storage-location="storageForm.allowStorageLocation"
:mode="storageDialogMode"
:order-count="storagePendingOrderIds.length"
:order-items="storageOrderTagItems"
:loading="storageAllocateLoading"
:request-id="storageAllocateRequestId"
:task-status="storageAllocateTaskStatus"
@ -223,6 +224,7 @@
:success-count="storageAllocateSuccessCount"
:failed-count="storageAllocateFailedCount"
:message="storageAllocateMessage"
@remove-order="(value) => removeSelectedOrder(value, storagePendingOrderIds)"
@closed="resetStorageAllocateDialog"
@submit="submitStorageAllocate"
/>
@ -231,8 +233,10 @@
v-model:code="updateOrderMetaState.code"
:mode="updateOrderMetaDialogMode"
:order-count="updateOrderMetaOrderIds.length"
:order-items="updateOrderMetaTagItems"
:loading="updateOrderMetaLoading"
:options="updateOrderMetaOptions"
@remove-order="(value) => removeSelectedOrder(value, updateOrderMetaOrderIds)"
@closed="resetUpdateOrderMetaDialog"
@submit="submitUpdateOrderMeta"
/>
@ -257,6 +261,7 @@
v-model="syncOrderIdsDialogVisible"
:order-count="selectionRows.length"
:order-ids="getSelectedIds()"
:order-items="selectedOrderTagItems"
:loading="syncOrderIdsLoading"
:request-id="syncOrderIdsRequestId"
:task-status="syncOrderIdsTaskStatus"
@ -266,6 +271,7 @@
:success-count="syncOrderIdsSuccessCount"
:failed-count="syncOrderIdsFailedCount"
:message="syncOrderIdsMessage"
@remove-order="(value) => removeSelectedOrder(value)"
@closed="resetSyncOrderIdsDialog"
@submit="submitSyncOrderIds"
/>
@ -281,7 +287,9 @@
v-model="updateAddressDialogVisible"
v-model:form="updateAddressState"
:order-count="updateAddressOrderIds.length"
:order-items="updateAddressTagItems"
:loading="updateAddressLoading"
@remove-order="(value) => removeSelectedOrder(value, updateAddressOrderIds)"
@closed="resetUpdateAddressDialog"
@submit="submitUpdateAddress"
/>
@ -289,7 +297,9 @@
v-model="updateRemarkDialogVisible"
v-model:form="updateRemarkState"
:order-count="updateRemarkOrderIds.length"
:order-items="updateRemarkTagItems"
:loading="updateRemarkLoading"
@remove-order="(value) => removeSelectedOrder(value, updateRemarkOrderIds)"
@closed="resetUpdateRemarkDialog"
@submit="submitUpdateRemark"
/>
@ -302,6 +312,7 @@
:result-count-label="batchAsyncTaskConfig.resultCountLabel"
:result-ids-label="batchAsyncTaskConfig.resultIdsLabel"
:order-count="batchAsyncTaskOrderIds.length"
:order-items="batchAsyncTagItems"
:loading="batchAsyncTaskLoading"
:phase="batchAsyncTaskPhase"
:task-id="batchAsyncTaskProgress.taskId"
@ -313,6 +324,7 @@
:result-order-ids="batchAsyncTaskProgress.resultOrderIds"
:accept-message="batchAsyncTaskProgress.acceptMessage"
:error-message="batchAsyncTaskProgress.errorMessage"
@remove-order="(value) => removeSelectedOrder(value, batchAsyncTaskOrderIds)"
@closed="resetBatchAsyncTaskDialog"
@submit="submitBatchAsyncTask"
/>
@ -348,17 +360,10 @@
<div class="task-panel__body">
<div class="task-panel__form">
<div class="task-panel__field">
<span class="task-panel__field-label">已选订单数</span>
<strong class="task-panel__field-value">{{ resolveExceptionOrderIds.length }} 条</strong>
</div>
<div class="task-panel__field task-panel__field--ids">
<span class="task-panel__field-label">订单 ID</span>
<div class="task-panel__ids">
<span v-for="id in resolveExceptionOrderIds" :key="id" class="task-panel__id">{{ id }}</span>
<span v-if="!resolveExceptionOrderIds.length" class="task-panel__ids-empty">—</span>
</div>
</div>
<SelectedTags
:items="resolveExceptionTagItems"
@remove="removeResolveExceptionOrder"
/>
</div>
<p class="task-panel__form-tip">
该操作会将异常订单恢复为正常待处理状态(step: 3 → 2)。
@ -420,7 +425,7 @@
</template>
<script setup lang="ts">
import { ref, reactive, onMounted, onUnmounted, onActivated, onDeactivated, computed, defineAsyncComponent } from 'vue'
import { ref, reactive, onMounted, onUnmounted, onActivated, onDeactivated, computed, watch, defineAsyncComponent } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { ArrowDown } from '@element-plus/icons-vue'
import ScanBox from '@/components/ScanBox/index.vue'
@ -469,6 +474,8 @@ import { useOrderListPageCleanup } from './utils/use-order-list-page-cleanup'
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
import OrderToolbarButtonGroup from '@/components/ToolbarButtonGroup/index.vue'
import { createPendingToolbarController } from '@/views/order/shared/toolbarActions'
import { buildOrderTagItems } from '@/views/order/shared/orderTagItems'
import SelectedTags from '@/components/task-progress/SelectedTags.vue'
import { safeInvoke } from '@/utils/safe-invoke'
import WavePlatformPrintPreviewDialog from '@/views/order/waveOrder/component/WavePlatformPrintPreviewDialog.vue'
import { getOrderPrintData } from '@/api/order.print/orderprint'
@ -514,6 +521,30 @@ const tableSize = ref('small')
const columns = ref(buildPendingStyleColumns(expectionColumns))
const selectionRows = ref<any[]>([])
/** 异常订单处理弹窗展示的已选订单标签 */
const resolveExceptionTagItems = computed(() =>
buildOrderTagItems(selectionRows.value, resolveExceptionOrderIds.value)
)
/** 移除某个已选订单:同步取消表格勾选;全部移除后自动关闭弹窗 */
function removeResolveExceptionOrder(value: string | number) {
const target = String(value)
const index = resolveExceptionOrderIds.value.findIndex((id) => String(id) === target)
if (index > -1) resolveExceptionOrderIds.value.splice(index, 1)
const row = selectionRows.value.find(
(item: any) => String(normalizePositiveIntId(item?.id ?? item?.order_id)) === target
)
if (row) upperTable.value?.toggleRowSelection?.(row, false)
}
watch(
() => resolveExceptionOrderIds.value.length,
(length, prevLength) => {
if (!resolveExceptionDialogVisible.value) return
if (prevLength > 0 && length === 0) resolveExceptionDialogVisible.value = false
}
)
const hasSelection = ref(false)
const selectedOrderId = ref<number | string | null>(null)
const detailVisible = ref(true)
@ -1035,6 +1066,27 @@ const {
platformCodeOptions
})
/** 多选表单展示的已选订单标签(订单号) */
const storageOrderTagItems = computed(() => buildOrderTagItems(selectionRows.value, storagePendingOrderIds.value))
const selectedOrderTagItems = computed(() => buildOrderTagItems(selectionRows.value))
const updateOrderMetaTagItems = computed(() => buildOrderTagItems(selectionRows.value, updateOrderMetaOrderIds.value))
const updateAddressTagItems = computed(() => buildOrderTagItems(selectionRows.value, updateAddressOrderIds.value))
const updateRemarkTagItems = computed(() => buildOrderTagItems(selectionRows.value, updateRemarkOrderIds.value))
const batchAsyncTagItems = computed(() => buildOrderTagItems(selectionRows.value, batchAsyncTaskOrderIds.value))
/** 表单里移除某个已选订单:同步快照 ids,并取消表格对应行勾选(全部移除时表单自动关闭) */
function removeSelectedOrder(value: string | number, ids?: Array<number | string>) {
const target = String(value)
if (ids) {
const index = ids.findIndex((id) => String(id) === target)
if (index > -1) ids.splice(index, 1)
}
const row = selectionRows.value.find(
(item: any) => String(normalizePositiveIntId(item?.id ?? item?.order_id)) === target
)
if (row) upperTable.value?.toggleRowSelection?.(row, false)
}
const toolbarActionMap: Record<string, () => void | Promise<void>> = {
...pendingToolbarActionMap,
openResolveExceptionDialog,
@ -1275,12 +1327,6 @@ function onBatchPrintSuccess() {
border: 1px solid #ebeef5;
border-radius: 4px;
background: #fafafa;
/* 订单 ID 行:标签在上、值在下(多 ID 胶囊换行展示) */
&--ids {
align-items: flex-start;
gap: 12px;
}
}
/* 标签列固定宽度(含必填星号占位):对齐「手工录入运单号」表单 */
@ -1303,33 +1349,6 @@ function onBatchPrintSuccess() {
text-align: right;
}
&__ids {
flex: 1;
min-width: 0;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: flex-end;
gap: 4px 6px;
max-height: 96px;
overflow-y: auto;
}
&__id {
padding: 0 6px;
border-radius: 3px;
background: #eef1f6;
font-size: 12px;
line-height: 20px;
color: #606266;
white-space: nowrap;
}
&__ids-empty {
font-size: 13px;
color: #c0c4cc;
}
&__form-tip {
margin: 8px 0 0;
padding: 8px 12px;

View File

@ -25,7 +25,12 @@
<div class="task-panel__body">
<div class="task-panel__form">
<div class="task-panel__field">
<SelectedTags
v-if="orderItems && orderItems.length"
:items="orderItems"
@remove="emit('remove-order', $event)"
/>
<div v-else class="task-panel__field">
<span class="task-panel__field-label">已选订单数</span>
<strong class="task-panel__field-value">{{ orderCount }} 条</strong>
</div>
@ -73,14 +78,17 @@
</template>
<script setup lang="ts">
import { computed } from 'vue'
import { computed, watch } from 'vue'
import SelectedTags from '@/components/task-progress/SelectedTags.vue'
const visible = defineModel<boolean>({ default: false })
const code = defineModel<string>('code', { default: '' })
defineProps<{
const props = defineProps<{
mode: 'express' | 'platform'
orderCount: number
/** 已选订单标签(传了则代替「已选订单数」数字展示,逐个可移除) */
orderItems?: Array<{ label: string; value: string | number }>
loading: boolean
options: Array<{ label: string; value: string }>
}>()
@ -88,8 +96,21 @@ defineProps<{
const emit = defineEmits<{
(e: 'submit'): void
(e: 'closed'): void
/** 用户移除某个已选订单标签 */
(e: 'remove-order', value: string | number): void
}>()
// 已选订单被逐个移除,最后一个移除后自动关闭表单
watch(
() => props.orderItems?.length ?? 0,
(length, prevLength) => {
if (!visible.value) return
if (prevLength > 0 && length === 0) {
visible.value = false
}
}
)
const codeProxy = computed({
get: () => code.value,
set: (value: string) => {

View File

@ -25,7 +25,12 @@
<div class="task-panel__body">
<div class="task-panel__form">
<div class="task-panel__field">
<SelectedTags
v-if="orderItems && orderItems.length"
:items="orderItems"
@remove="emit('remove-order', $event)"
/>
<div v-else class="task-panel__field">
<span class="task-panel__field-label">已选订单数</span>
<strong class="task-panel__field-value">{{ orderCount }} 条</strong>
</div>
@ -62,6 +67,9 @@
</template>
<script setup lang="ts">
import { watch } from 'vue'
import SelectedTags from '@/components/task-progress/SelectedTags.vue'
export type UpdateRemarkFormModel = {
remark: string
}
@ -73,15 +81,30 @@ const form = defineModel<UpdateRemarkFormModel>('form', {
})
})
defineProps<{
const props = defineProps<{
orderCount: number
/** 已选订单标签(传了则代替「已选订单数」数字展示,逐个可移除) */
orderItems?: Array<{ label: string; value: string | number }>
loading: boolean
}>()
const emit = defineEmits<{
(e: 'submit'): void
(e: 'closed'): void
/** 用户移除某个已选订单标签 */
(e: 'remove-order', value: string | number): void
}>()
// 已选订单被逐个移除,最后一个移除后自动关闭表单
watch(
() => props.orderItems?.length ?? 0,
(length, prevLength) => {
if (!visible.value) return
if (prevLength > 0 && length === 0) {
visible.value = false
}
}
)
</script>
<style scoped lang="scss">

View File

@ -214,6 +214,7 @@
v-model:allow-storage-location="storageForm.allowStorageLocation"
:mode="storageDialogMode"
:order-count="storagePendingOrderIds.length"
:order-items="storageOrderTagItems"
:loading="storageAllocateLoading"
:request-id="storageAllocateRequestId"
:task-status="storageAllocateTaskStatus"
@ -222,6 +223,7 @@
:success-count="storageAllocateSuccessCount"
:failed-count="storageAllocateFailedCount"
:message="storageAllocateMessage"
@remove-order="(value) => removeSelectedOrder(value, storagePendingOrderIds)"
@closed="resetStorageAllocateDialog"
@submit="submitStorageAllocate"
/>
@ -231,8 +233,10 @@
v-model:code="updateOrderMetaState.code"
:mode="updateOrderMetaDialogMode"
:order-count="updateOrderMetaOrderIds.length"
:order-items="updateOrderMetaTagItems"
:loading="updateOrderMetaLoading"
:options="updateOrderMetaOptions"
@remove-order="(value) => removeSelectedOrder(value, updateOrderMetaOrderIds)"
@closed="resetUpdateOrderMetaDialog"
@submit="submitUpdateOrderMeta"
/>
@ -260,6 +264,7 @@
v-model="syncOrderIdsDialogVisible"
:order-count="selectionRows.length"
:order-ids="selectedOrderIds"
:order-items="selectedOrderTagItems"
:loading="syncOrderIdsLoading"
:request-id="syncOrderIdsRequestId"
:task-status="syncOrderIdsTaskStatus"
@ -269,6 +274,7 @@
:success-count="syncOrderIdsSuccessCount"
:failed-count="syncOrderIdsFailedCount"
:message="syncOrderIdsMessage"
@remove-order="(value) => removeSelectedOrder(value)"
@closed="resetSyncOrderIdsDialog"
@submit="submitSyncOrderIds"
/>
@ -285,7 +291,9 @@
v-model="updateAddressDialogVisible"
v-model:form="updateAddressState"
:order-count="updateAddressOrderIds.length"
:order-items="updateAddressTagItems"
:loading="updateAddressLoading"
@remove-order="(value) => removeSelectedOrder(value, updateAddressOrderIds)"
@closed="resetUpdateAddressDialog"
@submit="submitUpdateAddress"
/>
@ -294,7 +302,9 @@
v-model="updateRemarkDialogVisible"
v-model:form="updateRemarkState"
:order-count="updateRemarkOrderIds.length"
:order-items="updateRemarkTagItems"
:loading="updateRemarkLoading"
@remove-order="(value) => removeSelectedOrder(value, updateRemarkOrderIds)"
@closed="resetUpdateRemarkDialog"
@submit="submitUpdateRemark"
/>
@ -307,6 +317,7 @@
:result-count-label="batchAsyncTaskConfig.resultCountLabel"
:result-ids-label="batchAsyncTaskConfig.resultIdsLabel"
:order-count="batchAsyncTaskOrderIds.length"
:order-items="batchAsyncTagItems"
:loading="batchAsyncTaskLoading"
:phase="batchAsyncTaskPhase"
:task-id="batchAsyncTaskProgress.taskId"
@ -318,6 +329,7 @@
:result-order-ids="batchAsyncTaskProgress.resultOrderIds"
:accept-message="batchAsyncTaskProgress.acceptMessage"
:error-message="batchAsyncTaskProgress.errorMessage"
@remove-order="(value) => removeSelectedOrder(value, batchAsyncTaskOrderIds)"
@closed="resetBatchAsyncTaskDialog"
@submit="submitBatchAsyncTask"
/>
@ -353,17 +365,10 @@
<div class="task-panel__body">
<div class="task-panel__form">
<div class="task-panel__field">
<span class="task-panel__field-label">已选订单数</span>
<strong class="task-panel__field-value">{{ resolveExceptionOrderIds.length }} 条</strong>
</div>
<div class="task-panel__field task-panel__field--ids">
<span class="task-panel__field-label">订单 ID</span>
<div class="task-panel__ids">
<span v-for="id in resolveExceptionOrderIds" :key="id" class="task-panel__id">{{ id }}</span>
<span v-if="!resolveExceptionOrderIds.length" class="task-panel__ids-empty">—</span>
</div>
</div>
<SelectedTags
:items="resolveExceptionTagItems"
@remove="removeResolveExceptionOrder"
/>
</div>
<p class="task-panel__form-tip">
该操作会将异常订单恢复为正常待处理状态
@ -438,7 +443,7 @@
</template>
<script setup lang="ts">
import { ref, reactive, onMounted, onUnmounted, onActivated, onDeactivated, computed, defineAsyncComponent } from 'vue'
import { ref, reactive, onMounted, onUnmounted, onActivated, onDeactivated, computed, watch, defineAsyncComponent } from 'vue'
import { useRoute } from 'vue-router'
import { ElMessage, ElMessageBox } from 'element-plus'
import ScanBox from '@/components/ScanBox/index.vue'
@ -492,6 +497,8 @@ import { useSubWaybillPrint } from './utils/use-sub-waybill-print'
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
import OrderToolbarButtonGroup from '@/components/ToolbarButtonGroup/index.vue'
import { createPendingToolbarController } from '@/views/order/shared/toolbarActions'
import { buildOrderTagItems } from '@/views/order/shared/orderTagItems'
import SelectedTags from '@/components/task-progress/SelectedTags.vue'
import { safeInvoke } from '@/utils/safe-invoke'
const WavePlatformPrintPreviewDialog = defineAsyncComponent(() => import('@/views/order/waveOrder/component/WavePlatformPrintPreviewDialog.vue'))
@ -560,6 +567,30 @@ const resolveExceptionDialogVisible = ref(false)
const resolveExceptionLoading = ref(false)
const resolveExceptionOrderIds = ref<number[]>([])
/** 异常订单处理弹窗展示的已选订单标签 */
const resolveExceptionTagItems = computed(() =>
buildOrderTagItems(selectionRows.value, resolveExceptionOrderIds.value)
)
/** 移除某个已选订单:同步取消表格勾选;全部移除后自动关闭弹窗 */
function removeResolveExceptionOrder(value: string | number) {
const target = String(value)
const index = resolveExceptionOrderIds.value.findIndex((id) => String(id) === target)
if (index > -1) resolveExceptionOrderIds.value.splice(index, 1)
const row = selectionRows.value.find(
(item: any) => String(normalizePositiveIntId(item?.id ?? item?.order_id)) === target
)
if (row) upperTable.value?.toggleRowSelection?.(row, false)
}
watch(
() => resolveExceptionOrderIds.value.length,
(length, prevLength) => {
if (!resolveExceptionDialogVisible.value) return
if (prevLength > 0 && length === 0) resolveExceptionDialogVisible.value = false
}
)
const selectedRow = computed(() => {
return list.value.find((i: any) => i.id === selectedOrderId.value) || null
})
@ -997,6 +1028,27 @@ const {
platformCodeOptions
})
/** 多选表单展示的已选订单标签(订单号) */
const storageOrderTagItems = computed(() => buildOrderTagItems(selectionRows.value, storagePendingOrderIds.value))
const selectedOrderTagItems = computed(() => buildOrderTagItems(selectionRows.value))
const updateOrderMetaTagItems = computed(() => buildOrderTagItems(selectionRows.value, updateOrderMetaOrderIds.value))
const updateAddressTagItems = computed(() => buildOrderTagItems(selectionRows.value, updateAddressOrderIds.value))
const updateRemarkTagItems = computed(() => buildOrderTagItems(selectionRows.value, updateRemarkOrderIds.value))
const batchAsyncTagItems = computed(() => buildOrderTagItems(selectionRows.value, batchAsyncTaskOrderIds.value))
/** 表单里移除某个已选订单:同步快照 ids,并取消表格对应行勾选(全部移除时表单自动关闭) */
function removeSelectedOrder(value: string | number, ids?: Array<number | string>) {
const target = String(value)
if (ids) {
const index = ids.findIndex((id) => String(id) === target)
if (index > -1) ids.splice(index, 1)
}
const row = selectionRows.value.find(
(item: any) => String(normalizePositiveIntId(item?.id ?? item?.order_id)) === target
)
if (row) upperTable.value?.toggleRowSelection?.(row, false)
}
toolbarActionMap['openResolveExceptionDialog'] = openResolveExceptionDialog
toolbarActionMap['handleBatchPrint'] = handleBatchPrint
toolbarActionMap['handleSubWaybillPrint'] = handleSubWaybillPrint
@ -1301,12 +1353,6 @@ async function handleConfirmInterceptBatch() {
border: 1px solid #ebeef5;
border-radius: 4px;
background: #fafafa;
/* 订单 ID 行:标签在上、值在下(多 ID 胶囊换行展示) */
&--ids {
align-items: flex-start;
gap: 12px;
}
}
/* 标签列固定宽度(含必填星号占位):对齐「手工录入运单号」表单 */
@ -1329,33 +1375,6 @@ async function handleConfirmInterceptBatch() {
text-align: right;
}
&__ids {
flex: 1;
min-width: 0;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: flex-end;
gap: 4px 6px;
max-height: 96px;
overflow-y: auto;
}
&__id {
padding: 0 6px;
border-radius: 3px;
background: #eef1f6;
font-size: 12px;
line-height: 20px;
color: #606266;
white-space: nowrap;
}
&__ids-empty {
font-size: 13px;
color: #c0c4cc;
}
&__form-tip {
margin: 8px 0 0;
padding: 8px 12px;

View File

@ -150,7 +150,9 @@
v-model="updateRemarkDialogVisible"
v-model:form="updateRemarkState"
:order-count="updateRemarkOrderIds.length"
:order-items="updateRemarkTagItems"
:loading="updateRemarkLoading"
@remove-order="(value) => removeSelectedOrder(value, updateRemarkOrderIds)"
@closed="resetUpdateRemarkDialog"
@submit="submitUpdateRemark"
/>
@ -215,6 +217,7 @@ import { useOrderListPageCleanup } from './utils/use-order-list-page-cleanup'
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
import OrderToolbarButtonGroup from '@/components/ToolbarButtonGroup/index.vue'
import { createReviewToolbarController } from '@/views/order/shared/toolbarActions'
import { buildOrderTagItems } from '@/views/order/shared/orderTagItems'
import { safeInvoke } from '@/utils/safe-invoke'
const scanBox = ref<any>(null)
@ -523,6 +526,20 @@ const {
orderActionApi: orderPendingOrder
})
/** 多选表单展示的已选订单标签(订单号) */
const updateRemarkTagItems = computed(() => buildOrderTagItems(selectionRows.value, updateRemarkOrderIds.value))
/** 表单里移除某个已选订单:同步快照 ids,并取消表格对应行勾选(全部移除时表单自动关闭) */
function removeSelectedOrder(value: string | number, ids?: Array<number | string>) {
const target = String(value)
if (ids) {
const index = ids.findIndex((id) => String(id) === target)
if (index > -1) ids.splice(index, 1)
}
const row = selectionRows.value.find((item: any) => String(item?.id ?? '') === target)
if (row) upperTable.value?.toggleRowSelection?.(row, false)
}
const buttonLoadingMap = computed<Record<string, boolean>>(() => ({
exportLoading: exportLoading.value,
exportSelectionLoading: exportSelectionLoading.value,

View File

@ -24,6 +24,7 @@
@update:visible="visible = $event"
@closed="emit('closed')"
@submit="emit('submit')"
@remove-field-item="handleRemoveFieldItem"
>
<template #footer>
<template v-if="isProgress">
@ -42,10 +43,15 @@
</template>
<script setup lang="ts">
import { computed } from 'vue'
import { computed, watch } from 'vue'
import UnifiedTaskProgressDialog from '@/components/task-progress/UnifiedTaskProgressDialog.vue'
import { useAutoCloseOnSuccess } from '@/components/task-progress/useAutoCloseOnSuccess'
import type { ProgressFormField, ProgressMetricItem, ProgressState } from '@/components/task-progress/types'
import type {
ProgressFormField,
ProgressFormFieldItem,
ProgressMetricItem,
ProgressState
} from '@/components/task-progress/types'
const visible = defineModel<boolean>({ default: false })
@ -56,6 +62,8 @@ const props = defineProps<{
resultCountLabel: string
resultIdsLabel: string
orderCount: number
/** 已选订单标签(传了则代替「已选订单数」数字展示,逐个可移除) */
orderItems?: Array<{ label: string; value: string | number }>
loading: boolean
phase: 'confirm' | 'progress'
taskId?: string
@ -72,6 +80,8 @@ const props = defineProps<{
const emit = defineEmits<{
(e: 'submit'): void
(e: 'closed'): void
/** 用户移除某个已选订单标签 */
(e: 'remove-order', value: string | number): void
}>()
const SUCCESS_TASK_STATUS = ['success', 'succeeded', 'finished', 'fin', 'done', 'completed', 'complete']
@ -132,9 +142,30 @@ const progressDetail = computed(() =>
props.totalOrderCount ? `已处理 ${props.processedOrderCount ?? 0} / ${props.totalOrderCount}` : ''
)
const formFields = computed<ProgressFormField[]>(() => [
{ label: '已选订单数', value: `${props.orderCount} 条` }
])
const formFields = computed<ProgressFormField[]>(() => {
const items = props.orderItems ?? []
if (items.length) {
// 与「按订单批量分配储位」一致:展示已选订单号标签,可逐个移除
return [{ label: '已选订单数', type: 'tags', items, closable: true }]
}
return [{ label: '已选订单数', value: `${props.orderCount} 条` }]
})
function handleRemoveFieldItem(field: ProgressFormField, item: ProgressFormFieldItem) {
if (field.type !== 'tags') return
emit('remove-order', item.value)
}
// 已选订单被逐个移除,最后一个移除后自动关闭表单(任务进度态不参与)
watch(
() => props.orderItems?.length ?? 0,
(length, prevLength) => {
if (!visible.value || isProgress.value) return
if (prevLength > 0 && length === 0) {
visible.value = false
}
}
)
const progressMetrics = computed<ProgressMetricItem[]>(() => [
{ label: '总订单', value: props.totalOrderCount ?? 0 },

View File

@ -19,6 +19,7 @@
:footer-hint="isProgress ? (progressState === 'running' ? '任务在后台执行,关闭窗口不会中断' : (progressState === 'success' ? '任务已完成,窗口将在 1.5 秒后自动关闭' : '任务失败,请查看错误信息后关闭窗口')) : '提交前请确认已选订单'"
:submit-text="submitButtonText"
@toggle-field="handleToggleField"
@remove-field-item="handleRemoveFieldItem"
@update:visible="visible = $event"
@closed="emit('closed')"
@submit="emit('submit')"
@ -43,10 +44,15 @@
</template>
<script setup lang="ts">
import { computed } from 'vue'
import { computed, watch } from 'vue'
import UnifiedTaskProgressDialog from '@/components/task-progress/UnifiedTaskProgressDialog.vue'
import { useAutoCloseOnSuccess } from '@/components/task-progress/useAutoCloseOnSuccess'
import type { ProgressFormField, ProgressMetricItem, ProgressState } from '@/components/task-progress/types'
import type {
ProgressFormField,
ProgressFormFieldItem,
ProgressMetricItem,
ProgressState
} from '@/components/task-progress/types'
const visible = defineModel<boolean>({ default: false })
const allowStorageLocation = defineModel<boolean>('allowStorageLocation', { default: false })
@ -54,6 +60,8 @@ const allowStorageLocation = defineModel<boolean>('allowStorageLocation', { defa
const props = defineProps<{
mode: 'allocate' | 'cancel'
orderCount: number
/** 已选订单标签(传了则代替「已选订单数」数字展示,逐个可移除) */
orderItems?: Array<{ label: string; value: string | number }>
loading: boolean
requestId?: string
taskStatus?: string
@ -67,6 +75,8 @@ const props = defineProps<{
const emit = defineEmits<{
(e: 'submit'): void
(e: 'closed'): void
/** 用户移除某个已选订单标签 */
(e: 'remove-order', value: string | number): void
}>()
const SUCCESS_TASK_STATUS = ['success', 'succeeded', 'finished', 'fin', 'done', 'completed', 'complete']
@ -148,7 +158,19 @@ const progressDetail = computed(() =>
)
const formFields = computed<ProgressFormField[]>(() => {
const fields: ProgressFormField[] = [{ label: '已选订单数', value: `${props.orderCount} 条` }]
const fields: ProgressFormField[] = []
const items = props.orderItems ?? []
if (items.length) {
// 展示勾选的订单号标签,用户可逐个移除;全部移除时弹窗自动关闭
fields.push({
label: '已选订单数',
type: 'tags',
items: items.map((item) => ({ label: item.label, value: item.value })),
closable: true
})
} else {
fields.push({ label: '已选订单数', value: `${props.orderCount} 条` })
}
if (props.mode !== 'cancel') {
fields.push({
label: '允许存储储位',
@ -177,6 +199,22 @@ function handleToggleField(field: ProgressFormField) {
allowStorageLocation.value = !allowStorageLocation.value
}
}
function handleRemoveFieldItem(field: ProgressFormField, item: ProgressFormFieldItem) {
if (field.type !== 'tags') return
emit('remove-order', item.value)
}
// 已选订单被逐个移除,最后一个移除后自动关闭表单(任务进度态不参与)
watch(
() => props.orderItems?.length ?? 0,
(length, prevLength) => {
if (!visible.value || isProgress.value) return
if (prevLength > 0 && length === 0) {
visible.value = false
}
}
)
</script>
<style scoped lang="scss">

View File

@ -18,6 +18,7 @@
:tip-type="progressState === 'success' ? 'primary' : 'default'"
:footer-hint="isProgress ? (progressState === 'running' ? '任务在后台执行,关闭窗口不会中断' : (progressState === 'success' ? '任务已完成,窗口将在 1.5 秒后自动关闭' : '任务失败,请查看错误信息后关闭窗口')) : '任务提交后可在后台运行'"
submit-text="确认同步"
@remove-field-item="handleRemoveFieldItem"
@update:visible="visible = $event"
@closed="emit('closed')"
@submit="emit('submit')"
@ -79,11 +80,16 @@
</template>
<script setup lang="ts">
import { computed, ref } from 'vue'
import { computed, ref, watch } from 'vue'
import { ElMessage } from 'element-plus'
import UnifiedTaskProgressDialog from '@/components/task-progress/UnifiedTaskProgressDialog.vue'
import { useAutoCloseOnSuccess } from '@/components/task-progress/useAutoCloseOnSuccess'
import type { ProgressFormField, ProgressMetricItem, ProgressState } from '@/components/task-progress/types'
import type {
ProgressFormField,
ProgressFormFieldItem,
ProgressMetricItem,
ProgressState
} from '@/components/task-progress/types'
const visible = defineModel<boolean>({ default: false })
@ -91,6 +97,8 @@ const props = defineProps<{
orderCount: number
/** 当前勾选的订单 ID(提交前展示,便于核对) */
orderIds?: Array<number | string>
/** 已选订单标签(传了则代替「当前勾选订单」数字展示,逐个可移除) */
orderItems?: Array<{ label: string; value: string | number }>
loading: boolean
requestId?: string
taskStatus?: string
@ -105,6 +113,8 @@ const props = defineProps<{
const emit = defineEmits<{
(e: 'submit'): void
(e: 'closed'): void
/** 用户移除某个已选订单标签 */
(e: 'remove-order', value: string | number): void
}>()
const SUCCESS_TASK_STATUS = ['success', 'succeeded', 'finished', 'fin', 'done', 'completed', 'complete']
@ -177,9 +187,30 @@ const progressDetail = computed(() => {
return `已处理 ${processed} / ${total}`
})
const formFields = computed<ProgressFormField[]>(() => [
{ label: '当前勾选订单', value: `${selectedOrderCount.value} 条` }
])
const formFields = computed<ProgressFormField[]>(() => {
const items = props.orderItems ?? []
if (items.length) {
// 与「按订单批量分配储位」一致:展示已选订单号标签,可逐个移除
return [{ label: '已选订单数', type: 'tags', items, closable: true }]
}
return [{ label: '当前勾选订单', value: `${selectedOrderCount.value} 条` }]
})
function handleRemoveFieldItem(field: ProgressFormField, item: ProgressFormFieldItem) {
if (field.type !== 'tags') return
emit('remove-order', item.value)
}
// 已选订单被逐个移除,最后一个移除后自动关闭表单(任务进度态不参与)
watch(
() => props.orderItems?.length ?? 0,
(length, prevLength) => {
if (!visible.value || isProgress.value) return
if (prevLength > 0 && length === 0) {
visible.value = false
}
}
)
/** 订单 ID 预览条数,超出后默认折叠 */
const ID_PREVIEW_LIMIT = 20

View File

@ -25,7 +25,12 @@
<div class="task-panel__body">
<div class="task-panel__form">
<div class="task-panel__field">
<SelectedTags
v-if="orderItems && orderItems.length"
:items="orderItems"
@remove="emit('remove-order', $event)"
/>
<div v-else class="task-panel__field">
<span class="task-panel__field-label">已选订单数</span>
<strong class="task-panel__field-value">{{ orderCount }} 条</strong>
</div>
@ -157,7 +162,8 @@
</template>
<script setup lang="ts">
import { computed } from 'vue'
import { computed, watch } from 'vue'
import SelectedTags from '@/components/task-progress/SelectedTags.vue'
import {
buildCityOptions,
buildDistrictOptions,
@ -203,16 +209,31 @@ const form = defineModel<UpdateAddressFormModel>('form', {
})
})
defineProps<{
const props = defineProps<{
orderCount: number
/** 已选订单标签(传了则代替「已选订单数」数字展示,逐个可移除) */
orderItems?: Array<{ label: string; value: string | number }>
loading: boolean
}>()
const emit = defineEmits<{
(e: 'submit'): void
(e: 'closed'): void
/** 用户移除某个已选订单标签 */
(e: 'remove-order', value: string | number): void
}>()
// 已选订单被逐个移除,最后一个移除后自动关闭表单
watch(
() => props.orderItems?.length ?? 0,
(length, prevLength) => {
if (!visible.value) return
if (prevLength > 0 && length === 0) {
visible.value = false
}
}
)
const provinceOptions = buildProvinceOptions()
const cityOptions = computed(() => buildCityOptions(form.value.province_code))

View File

@ -0,0 +1,60 @@
/** 多选表单里的「已选订单」标签项:label 展示订单号,value 用于回传移除 */
export interface OrderTagItem {
label: string
value: string | number
}
/** 订单列表行里本工具用到的字段(允许缺失,兼容各列表接口) */
export interface OrderLikeRow {
id?: unknown
order_id?: unknown
delivery_order_code?: unknown
order_code?: unknown
}
function toPositiveIntId(raw: unknown): number | null {
if (raw === undefined || raw === null || raw === '') return null
const n = typeof raw === 'number' ? raw : Number(raw)
if (!Number.isInteger(n) || n <= 0) return null
return n
}
function resolveRowId(row: OrderLikeRow | null | undefined): number | null {
return toPositiveIntId(row?.id ?? row?.order_id)
}
function resolveRowLabel(row: OrderLikeRow | null | undefined, fallback: string | number): string {
const code = String(row?.delivery_order_code ?? row?.order_code ?? '').trim()
return code || String(fallback)
}
/**
* 由列表行构建已选订单标签。
* - 不传 ids:按 rows 顺序输出(当前勾选行)
* - 传 ids:按 ids 顺序输出(弹窗打开时快照的订单 ID,如分配储位/批量修改留言)
*/
export function buildOrderTagItems(
rows: ReadonlyArray<OrderLikeRow | null | undefined> | null | undefined,
ids?: Array<number | string> | null
): OrderTagItem[] {
const rowMap = new Map<string, OrderLikeRow>()
for (const row of rows || []) {
const id = resolveRowId(row)
if (id !== null) rowMap.set(String(id), row as OrderLikeRow)
}
if (ids) {
return ids.map((id) => ({
label: resolveRowLabel(rowMap.get(String(id)), id),
value: id
}))
}
const result: OrderTagItem[] = []
for (const row of rows || []) {
const id = resolveRowId(row)
if (id === null) continue
result.push({ label: resolveRowLabel(row, id), value: id })
}
return result
}

View File

@ -122,6 +122,7 @@
v-model:allow-storage-location="storageForm.allowStorageLocation"
:mode="storageDialogMode"
:order-count="storagePendingOrderIds.length"
:order-items="storageOrderItems"
:loading="storageAllocateLoading"
:request-id="storageAllocateRequestId"
:task-status="storageAllocateTaskStatus"
@ -130,6 +131,7 @@
:success-count="storageAllocateSuccessCount"
:failed-count="storageAllocateFailedCount"
:message="storageAllocateMessage"
@remove-order="handleRemoveStorageOrder"
@closed="resetStorageAllocateDialog"
@submit="submitStorageAllocate"
/>
@ -137,6 +139,7 @@
v-model="syncOrderIdsDialogVisible"
:order-count="selectionRows.length"
:order-ids="getSelectedIds()"
:order-items="selectedOrderItems"
:loading="syncOrderIdsLoading"
:request-id="syncOrderIdsRequestId"
:task-status="syncOrderIdsTaskStatus"
@ -416,6 +419,57 @@ const {
platformCodeOptions
})
/** 分配储位表单展示的已选订单标签(订单号) */
const storageOrderItems = computed<Array<{ label: string; value: string | number }>>(() => {
const ids = storagePendingOrderIds.value
if (!ids.length) return []
const rowMap = new Map<string, any>()
for (const row of selectionRows.value) {
const id = normalizePositiveIntId(row?.id ?? row?.order_id)
if (id !== null) rowMap.set(String(id), row)
}
return ids.map((id) => {
const row = rowMap.get(String(id))
const code = String(row?.delivery_order_code ?? row?.order_code ?? '').trim()
return { label: code || String(id), value: id }
})
})
/** 当前勾选行的订单标签(订单号),供同步订单ID等表单展示 */
const selectedOrderItems = computed<Array<{ label: string; value: number }>>(() => {
const items: Array<{ label: string; value: number }> = []
for (const row of selectionRows.value) {
const id = normalizePositiveIntId(row?.id ?? row?.order_id)
if (id === null) continue
const code = String(row?.delivery_order_code ?? row?.order_code ?? '').trim()
items.push({ label: code || String(id), value: id })
}
return items
})
/** 取消表格中对应行的勾选(表单里移除标签时调用) */
function uncheckSelectionRow(value: string | number) {
const target = String(value)
const row = selectionRows.value.find(
(item: any) => String(normalizePositiveIntId(item?.id ?? item?.order_id)) === target
)
if (row) upperTable.value?.toggleRowSelection?.(row, false)
}
/** 在分配储位表单里移除某个已选订单:同步取消表格勾选,全部移除时表单会自动关闭 */
function handleRemoveStorageOrder(value: string | number) {
const target = String(value)
const index = storagePendingOrderIds.value.findIndex((id) => String(id) === target)
if (index === -1) return
storagePendingOrderIds.value.splice(index, 1)
uncheckSelectionRow(target)
}
/** 在同步订单ID表单里移除某个已选订单:同步取消表格勾选,全部移除时表单会自动关闭 */
function handleRemoveSyncOrder(value: string | number) {
uncheckSelectionRow(value)
}
function resolveButtonLoading(loadingKey?: string) {
if (!loadingKey) return false
const loadingMap: Record<string, boolean> = {

View File

@ -26,7 +26,13 @@
<div class="task-panel__body">
<div class="task-panel__form">
<div class="task-panel__field">
<SelectedTags
v-if="selectedItems.length"
label="已选商品"
:items="selectedItems"
@remove="emit('remove-item', $event)"
/>
<div v-else class="task-panel__field">
<span class="task-panel__field-label">已选商品</span>
<strong class="task-panel__field-value">{{ selectedCount }} 件</strong>
</div>
@ -154,6 +160,7 @@
<script setup lang="ts">
import { computed, reactive, ref, watch } from 'vue'
import type { FormInstance, FormRules } from 'element-plus'
import SelectedTags from '@/components/task-progress/SelectedTags.vue'
type BatchOption = { label: string; value: string | number }
type BatchValue = string | number | null | string[]
@ -174,6 +181,8 @@ const props = withDefaults(
maxlength?: number
/** 本次批量修改选中的商品数 */
selectedCount?: number
/** 已选商品标签(传了则代替「已选商品 N 件」展示,逐个可移除) */
selectedItems?: Array<{ label: string; value: string | number }>
loading?: boolean
}>(),
{
@ -184,12 +193,15 @@ const props = withDefaults(
placeholder: '',
maxlength: undefined,
selectedCount: 0,
selectedItems: () => [],
loading: false
}
)
const emit = defineEmits<{
(e: 'confirm', value: BatchSubmitValue): void
/** 用户移除某个已选商品标签 */
(e: 'remove-item', value: string | number): void
}>()
const formRef = ref<FormInstance>()
@ -230,6 +242,17 @@ watch(visible, (open) => {
if (open) syncFromModel()
}, { immediate: true })
// 已选商品被逐个移除,最后一个移除后自动关闭弹窗
watch(
() => props.selectedItems.length,
(length, prevLength) => {
if (!visible.value) return
if (prevLength > 0 && length === 0) {
visible.value = false
}
}
)
const tipText = computed(() => {
switch (props.type) {
case 'select':

View File

@ -199,7 +199,9 @@
:placeholder="batchDialogPlaceholder"
:maxlength="batchDialogMaxlength"
:selected-count="selectionIds.length"
:selected-items="batchSelectedItems"
:loading="batchLoading"
@remove-item="removeBatchSelectedItem"
@confirm="confirmBatchDialog"
/>
@ -333,6 +335,24 @@ const loading = ref(false)
const showSelection = ref(true)
const queryTime = ref(0)
const selectionIds = ref<any[]>([])
/** 批量修改弹窗展示的已选商品标签(商品名称) */
const batchSelectedItems = computed(() =>
selectionIds.value
.filter((row: any) => row?.id !== undefined && row?.id !== null && row?.id !== '')
.map((row: any) => ({
label: String(row?.item_name ?? row?.item_code ?? row?.id ?? ''),
value: row.id
}))
)
/** 在批量修改弹窗里移除某个已选商品:取消表格对应行勾选(全部移除时弹窗自动关闭) */
function removeBatchSelectedItem(value: string | number) {
const target = String(value)
const row = selectionIds.value.find((item: any) => String(item?.id) === target)
if (row) accountTableRef.value?.toggleRowSelection?.(row, false)
}
const currentStockId = ref<string | number | null>(null)
const list = ref([])
const presetTree = ref([])

View File

@ -282,7 +282,13 @@
<div class="task-panel__body">
<div class="task-panel__form">
<div class="task-panel__field">
<SelectedTags
v-if="rejectSelectedItems.length"
label="已选收货单"
:items="rejectSelectedItems"
@remove="removeRejectSelectedItem"
/>
<div v-else class="task-panel__field">
<span class="task-panel__field-label">已选收货单</span>
<strong class="task-panel__field-value">{{ selectionRows.length }} 条</strong>
</div>
@ -451,7 +457,7 @@
</template>
<script setup lang="ts">
import { ref, reactive, onMounted, computed, nextTick, defineAsyncComponent } from 'vue'
import { ref, reactive, onMounted, computed, watch, nextTick, defineAsyncComponent } from 'vue'
import { useRoute } from 'vue-router'
import { ElMessage, ElMessageBox } from 'element-plus'
import ScanBox from '@/components/ScanBox/index.vue'
@ -460,6 +466,7 @@ import OrderToolbarButtonGroup from '@/components/ToolbarButtonGroup/index.vue'
import type { ToolbarButtonConfig } from '@/components/ToolbarButtonGroup/types'
import { getStatusTextClass } from '@/utils/statusText'
import BatchReceivingPrintDialog from '@/components/BatchReceivingPrintDialog.vue'
import SelectedTags from '@/components/task-progress/SelectedTags.vue'
import AsyncExportProgressDialog from '@/components/AsyncExportProgressDialog.vue'
import Details from './component/DetailsPanel.vue'
// 其余详情页签按需加载:默认页签保持静态,避免选中行后多一次往返
@ -1255,6 +1262,31 @@ const rejectDialogVisible = ref(false)
const rejectLoading = ref(false)
const rejectRemark = ref('')
/** 驳回弹窗展示的已选收货单标签(收货单号) */
const rejectSelectedItems = computed(() =>
selectionRows.value
.filter((row: any) => row?.id !== undefined && row?.id !== null && row?.id !== '')
.map((row: any) => ({
label: String(row?.receiving_number ?? row?.id ?? ''),
value: row.id
}))
)
/** 在驳回弹窗里移除某个收货单:取消表格对应行勾选(全部移除时弹窗自动关闭) */
function removeRejectSelectedItem(value: string | number) {
const target = String(value)
const row = selectionRows.value.find((item: any) => String(item?.id) === target)
if (row) upperTable.value?.toggleRowSelection?.(row, false)
}
watch(
() => selectionRows.value.length,
(length, prevLength) => {
if (!rejectDialogVisible.value) return
if (prevLength > 0 && length === 0) rejectDialogVisible.value = false
}
)
function handleRejectReceiving() {
if (!selectionRows.value.length) {
ElMessage.warning('请先选择要驳回的收货单')

View File

@ -509,16 +509,71 @@
</footer>
</div>
</el-dialog>
<!-- 批量作废:列出已选出库单,可逐个移除 -->
<el-dialog
v-model="batchCancelDialogVisible"
class="batch-cancel-dialog"
width="min(560px, 92vw)"
align-center
append-to-body
:show-close="false"
destroy-on-close
:close-on-click-modal="false"
>
<div class="task-panel">
<header class="task-panel__head">
<div class="task-panel__titles">
<h2>批量作废出库单</h2>
<p>作废已勾选的出库单,作废后不可撤销</p>
</div>
<button class="task-panel__close" type="button" aria-label="关闭" @click="batchCancelDialogVisible = false">
<svg viewBox="0 0 12 12" fill="none">
<path d="M1 1L11 11M11 1L1 11" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" />
</svg>
</button>
</header>
<div class="task-panel__body">
<div class="task-panel__form">
<SelectedTags
v-if="batchCancelSelectedItems.length"
label="已选出库单"
:items="batchCancelSelectedItems"
@remove="removeBatchCancelItem"
/>
<div v-else class="task-panel__field">
<span class="task-panel__field-label">已选出库单</span>
<strong class="task-panel__field-value">{{ selectionRows.length }} 条</strong>
</div>
</div>
<p class="task-panel__form-tip">
作废后不可撤销,请确认清单无误后再提交。
</p>
</div>
<footer class="task-panel__foot">
<span class="task-panel__hint">提交前请确认已选出库单</span>
<div class="task-panel__actions">
<el-button size="small" @click="batchCancelDialogVisible = false">取消</el-button>
<el-button size="small" type="danger" :loading="batchCancelLoading" @click="submitBatchCancel">
确认作废
</el-button>
</div>
</footer>
</div>
</el-dialog>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted, computed } from 'vue'
import { ref, reactive, onMounted, computed, watch } from 'vue'
import { useRoute } from 'vue-router'
import { ElMessage, ElMessageBox } from 'element-plus'
import ScanBox from '@/components/ScanBox/index.vue'
import UpperTable from '@/components/UpperTable/index.vue'
import BatchReceivingPrintDialog from '@/components/BatchReceivingPrintDialog.vue'
import SelectedTags from '@/components/task-progress/SelectedTags.vue'
import OrderToolbarButtonGroup from '@/components/ToolbarButtonGroup/index.vue'
import type { ToolbarButtonConfig } from '@/components/ToolbarButtonGroup/types'
import { getStatusTextClass } from '@/utils/statusText'
@ -1374,16 +1429,55 @@ async function handleSingleRowStockout(row: any) {
}
}
async function confirmBatchCancel() {
// ── 批量作废(标签式确认) ──
const batchCancelDialogVisible = ref(false)
const batchCancelLoading = ref(false)
/** 作废弹窗展示的已选出库单标签(出库单号) */
const batchCancelSelectedItems = computed(() =>
selectionRows.value
.filter((row: any) => row?.id !== undefined && row?.id !== null && row?.id !== '')
.map((row: any) => ({
label: String(row?.stockout_order_code ?? row?.id ?? ''),
value: row.id
}))
)
/** 在作废弹窗里移除某个出库单:取消表格对应行勾选(全部移除时弹窗自动关闭) */
function removeBatchCancelItem(value: string | number) {
const target = String(value)
const row = selectionRows.value.find((item: any) => String(item?.id) === target)
if (row) upperTable.value?.toggleRowSelection?.(row, false)
}
watch(
() => selectionRows.value.length,
(length, prevLength) => {
if (!batchCancelDialogVisible.value) return
if (prevLength > 0 && length === 0) batchCancelDialogVisible.value = false
}
)
function confirmBatchCancel() {
if (!selectionRows.value.length) {
ElMessage.warning('请先选择要作废的出库单')
return
}
batchCancelDialogVisible.value = true
}
async function submitBatchCancel() {
if (batchCancelLoading.value) return
if (!selectionRows.value.length) {
ElMessage.warning('没有可作废的出库单')
return
}
batchCancelLoading.value = true
let successCount = 0
let failCount = 0
const rows = [...selectionRows.value]
try {
await ElMessageBox.confirm(`确定要批量作废 ${selectionRows.value.length} 个出库单吗?`, '确认', { type: 'warning', buttonSize: 'small' })
let successCount = 0
let failCount = 0
for (const row of selectionRows.value) {
for (const row of rows) {
try {
const res: any = await stockoutApi.stockoutCancel({ id: row.id })
if (res && (res.code === 1 || res.code === 200 || res.code === 20000 || res.flag === 'success')) {
@ -1396,8 +1490,13 @@ async function confirmBatchCancel() {
}
}
ElMessage.success(`批量作废完成:成功 ${successCount} 条${failCount ? `,失败 ${failCount} 条` : ''}`)
batchCancelDialogVisible.value = false
upperTable.value?.clearSelection?.()
selectionRows.value = []
loadData()
} catch (e) {}
} finally {
batchCancelLoading.value = false
}
}
async function handleExport(mode: 'waybill' | 'item' = 'waybill') {
@ -1742,7 +1841,8 @@ function handleImport() {
<style lang="scss">
/* el-dialog 会被 append 到 body:去掉默认头/内边距,统一交给面板 */
.el-dialog.update-express-dialog,
.el-dialog.to-order-dialog-shell {
.el-dialog.to-order-dialog-shell,
.el-dialog.batch-cancel-dialog {
padding: 0;
overflow: hidden;