2053 lines
68 KiB
Vue
2053 lines
68 KiB
Vue
<template>
|
||
<div class="order-sub-container" :style="{ height: containerHeight }">
|
||
<scan-box
|
||
ref="scanBox"
|
||
cache-key="storage-receiving"
|
||
width="220px"
|
||
:tree-props="{ children: 'children', label: 'label' }"
|
||
:auto-submit="false"
|
||
:initial-conditions="initialConditions"
|
||
:preset-tree="presetTree"
|
||
:available-fields="availableFieldsRef"
|
||
@condition-change="handleConditionChange"
|
||
@reset="handleConditionReset"
|
||
@condition-clear="handleConditionClear"
|
||
@submit="handleSubmit"
|
||
/>
|
||
|
||
<div class="main-content">
|
||
<div class="toolbar">
|
||
<div class="toolbar-left">
|
||
<order-toolbar-button-group
|
||
:buttons="toolbarButtons"
|
||
:resolve-disabled="resolveButtonDisabled"
|
||
:resolve-loading="resolveButtonLoading"
|
||
:resolve-label="resolveButtonLabel"
|
||
:layout-key="toolbarLayoutKey"
|
||
@action="handleToolbarButtonClick"
|
||
/>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="split-stack" ref="splitStackRef">
|
||
<div class="upper-wrapper" :style="detailVisible ? upperPaneStyle : upperPaneFullStyle">
|
||
<upper-table ref="upperTable" title="收货单列表" default-align="center" :enable-column-config="true" table-id="storage-receiving-list" :column-config-schema-version="2" :data="list" :columns="columns" :table-size="tableSize"
|
||
:pagination="pagination" :show-index="true" :show-actions="true" :show-selection="true" :loading="loading"
|
||
:queryTime="queryTime" @current-change="handleRowClick" @page-change="handlePageChange"
|
||
@page-size-change="handlePageSizeChange" @sort-change="handleSortChange" @refresh="loadData"
|
||
@selection-change="onSelectionChange">
|
||
<template #column-status="{ row }">
|
||
<span v-if="row.status"
|
||
:class="getStatusTextClass(statusConfig[row.status as keyof typeof statusConfig]?.tagType || 'info')">
|
||
{{ statusConfig[row.status as keyof typeof statusConfig]?.text || row.status }}
|
||
</span>
|
||
</template>
|
||
|
||
<template #column-detail_status="{ row }">
|
||
<span v-if="row.detail_status"
|
||
:class="getStatusTextClass(detailStatusConfig[row.detail_status as keyof typeof detailStatusConfig]?.tagType || 'info')">
|
||
{{ detailStatusConfig[row.detail_status as keyof typeof detailStatusConfig]?.text || row.detail_status }}
|
||
</span>
|
||
</template>
|
||
|
||
<template #column-storage_status="{ row }">
|
||
<span v-if="row.storage_status"
|
||
:class="getStatusTextClass(storageStatusConfig[row.storage_status as keyof typeof storageStatusConfig]?.tagType || 'info')">
|
||
{{ storageStatusConfig[row.storage_status as keyof typeof storageStatusConfig]?.text || row.storage_status
|
||
}}
|
||
</span>
|
||
</template>
|
||
|
||
<template #column-is_review="{ row }">
|
||
<span :class="getStatusTextClass(row.is_review === 1 || row.is_review === true ? 'success' : 'info')">
|
||
{{ row.is_review === 1 || row.is_review === true ? '已审核' : '未审核' }}
|
||
</span>
|
||
</template>
|
||
|
||
|
||
<template #column-delivery_method="{ row }">
|
||
<span v-if="row.delivery_method"
|
||
:class="getStatusTextClass(deliveryMethodConfig[row.delivery_method as keyof typeof deliveryMethodConfig]?.tagType || 'info')">
|
||
{{ deliveryMethodConfig[row.delivery_method as keyof typeof deliveryMethodConfig]?.text ||
|
||
row.delivery_method }}
|
||
</span>
|
||
</template>
|
||
|
||
<template #column-loading_method="{ row }">
|
||
<span v-if="row.loading_method"
|
||
:class="getStatusTextClass(loadingMethodConfig[row.loading_method as keyof typeof loadingMethodConfig]?.tagType || 'info')">
|
||
{{ loadingMethodConfig[row.loading_method as keyof typeof loadingMethodConfig]?.text || row.loading_method
|
||
}}
|
||
</span>
|
||
</template>
|
||
|
||
<template #column-actions="{ row }">
|
||
<el-button
|
||
v-if="row.status === 'completed' && row.detail_status === 'all_matched' && (row.is_review === 1 || row.is_review === true) && row.storage_status !== 'all'"
|
||
type="success"
|
||
link
|
||
size="small"
|
||
@click.stop="openMatchPutawayDialog(row)"
|
||
>
|
||
匹配入库
|
||
</el-button>
|
||
</template>
|
||
|
||
<template #empty>
|
||
<div class="empty-tip">暂无收货单</div>
|
||
</template>
|
||
</upper-table>
|
||
</div>
|
||
|
||
<template v-if="detailVisible">
|
||
<div
|
||
class="pane-resizer"
|
||
title="拖动调整列表与详情区域高度"
|
||
@mousedown="beginSplitDrag"
|
||
/>
|
||
<div class="lower-level" v-if="selectedReceivingId" :class="tableSize" :style="lowerPaneStyle">
|
||
<div class="detail-header">
|
||
<el-tabs v-model="activeTab" class="detail-tab">
|
||
<el-tab-pane label="收货明细" name="details" />
|
||
<el-tab-pane label="商品明细" name="product" />
|
||
<el-tab-pane label="入库记录" name="storage" />
|
||
<el-tab-pane label="操作日志" name="logs" />
|
||
</el-tabs>
|
||
</div>
|
||
|
||
<div class="detail-container">
|
||
<KeepAlive>
|
||
<component
|
||
:is="activeComponent"
|
||
class="receiving-detail-pane"
|
||
:id="selectedReceivingId"
|
||
:row="selectedRow"
|
||
:product-data="productData"
|
||
:product-total="productTotal"
|
||
:loading="productLoading"
|
||
@refresh-product="loadProductData"
|
||
@page-change="handleProductPageChange"
|
||
@page-size-change="handleProductSizeChange"
|
||
@data-changed="loadData"
|
||
/>
|
||
</KeepAlive>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="no-selection" v-else :style="lowerPaneStyle">
|
||
<div class="empty-tip">
|
||
<p>请从上方列表中选择一项查看详情</p>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
</div>
|
||
</div>
|
||
|
||
<batch-receiving-print-dialog
|
||
v-model="printDialogVisible"
|
||
:selection-rows="selectionRows"
|
||
business-type="RECEIPT"
|
||
dialog-title="批量打印收货单"
|
||
queue-no-field="receiving_number"
|
||
document-label="收货单"
|
||
:fetch-print-data="fetchPrintData"
|
||
/>
|
||
|
||
<AsyncExportProgressDialog
|
||
v-model:visible="exportDialogVisible"
|
||
title="收货单导出"
|
||
:loading="exportLoading"
|
||
:progress-percent="exportProgressPercent"
|
||
:progress-status="exportProgressStatus"
|
||
:status-label="exportStatusLabel"
|
||
:task-id="exportTaskProgress.taskId"
|
||
:message="exportTaskProgress.message"
|
||
:error="exportTaskProgress.error"
|
||
:meta="exportTaskProgress"
|
||
:update-time="exportTaskProgress.updateTime"
|
||
/>
|
||
|
||
<!-- 新建收货单对话框 -->
|
||
<el-dialog v-model="createDialogVisible" title="新建收货单" width="600px" align-center
|
||
@closed="handleCreateDialogClosed">
|
||
<el-form :model="createForm" label-width="100px" size="small">
|
||
<el-row :gutter="20">
|
||
<el-col v-for="field in addReceivingFieldsRef" :key="field.prop" :span="field.type === 'textarea' ? 24 : 12">
|
||
<el-form-item>
|
||
<template #label>
|
||
<span>{{ field.label }}</span>
|
||
<span v-if="['delivery_method','loading_method'].includes(field.prop)" style="color: #f56c6c; margin-left:6px">*</span>
|
||
</template>
|
||
<el-select v-if="field.type === 'select'" v-model="createForm[field.prop]"
|
||
:placeholder="'请选择' + field.label" style="width: 100%" :filterable="field.filterable">
|
||
<el-option v-for="opt in field.options" :key="opt.value" :label="opt.label" :value="opt.value" />
|
||
</el-select>
|
||
<el-input v-else-if="field.type === 'textarea'" v-model="createForm[field.prop]" type="textarea" :rows="3"
|
||
:placeholder="'请输入' + field.label" />
|
||
<el-input v-else v-model="createForm[field.prop]" :placeholder="'请输入' + field.label" />
|
||
</el-form-item>
|
||
</el-col>
|
||
</el-row>
|
||
</el-form>
|
||
<template #footer>
|
||
<el-button size="small" @click="createDialogVisible = false">取消</el-button>
|
||
<el-button size="small" type="primary" :loading="createLoading" @click="submitCreateReceiving">确定</el-button>
|
||
</template>
|
||
</el-dialog>
|
||
|
||
<!-- 驳回收货单对话框 -->
|
||
<el-dialog
|
||
v-model="rejectDialogVisible"
|
||
class="reject-receiving-dialog"
|
||
width="min(560px, 92vw)"
|
||
align-center
|
||
append-to-body
|
||
:show-close="false"
|
||
:close-on-click-modal="false"
|
||
>
|
||
<!-- 面板结构对齐「手工录入运单号」(TaskProgressPanel) -->
|
||
<div class="task-panel">
|
||
<header class="task-panel__head">
|
||
<div class="task-panel__titles">
|
||
<h2>批量驳回收货单</h2>
|
||
<p>驳回已勾选的收货单并记录理由</p>
|
||
</div>
|
||
<button class="task-panel__close" type="button" aria-label="关闭" @click="rejectDialogVisible = 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">
|
||
<div class="task-panel__field">
|
||
<span class="task-panel__field-label">已选收货单</span>
|
||
<strong class="task-panel__field-value">{{ selectionRows.length }} 条</strong>
|
||
</div>
|
||
<div class="task-panel__field task-panel__field--input task-panel__field--textarea">
|
||
<span class="task-panel__field-label">驳回理由</span>
|
||
<el-input
|
||
v-model="rejectRemark"
|
||
type="textarea"
|
||
:rows="3"
|
||
placeholder="请输入驳回理由(选填,将覆盖原备注)"
|
||
/>
|
||
</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="rejectDialogVisible = false">取消</el-button>
|
||
<el-button size="small" type="warning" :loading="rejectLoading" @click="submitRejectReceiving">
|
||
确认驳回
|
||
</el-button>
|
||
</div>
|
||
</footer>
|
||
</div>
|
||
</el-dialog>
|
||
|
||
<!-- 匹配入库:左右结构,左选入库单,右对比明细 -->
|
||
<el-dialog
|
||
v-model="matchPutawayDialogVisible"
|
||
class="match-putaway-dialog-shell"
|
||
width="min(1200px, 96vw)"
|
||
align-center
|
||
append-to-body
|
||
:show-close="false"
|
||
destroy-on-close
|
||
:close-on-click-modal="false"
|
||
@closed="resetMatchPutawayDialog"
|
||
>
|
||
<!-- 面板结构对齐「手工录入运单号」(TaskProgressPanel) -->
|
||
<div class="task-panel">
|
||
<header class="task-panel__head">
|
||
<div class="task-panel__titles">
|
||
<h2>匹配入库</h2>
|
||
<p>选择入库单与收货单明细比对后确认匹配</p>
|
||
</div>
|
||
<button
|
||
class="task-panel__close"
|
||
type="button"
|
||
aria-label="关闭"
|
||
@click="matchPutawayDialogVisible = 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="match-putaway-dialog">
|
||
<div class="match-left-panel">
|
||
<span class="task-panel__section-title">入库单列表</span>
|
||
<div class="task-panel__table-wrap">
|
||
<el-table
|
||
ref="matchEntryTableRef"
|
||
:data="matchEntryList"
|
||
v-loading="matchEntryListLoading"
|
||
highlight-current-row
|
||
border
|
||
size="small"
|
||
height="100%"
|
||
@current-change="onMatchEntrySelect"
|
||
>
|
||
<el-table-column prop="entry_order_code" label="入库单号" min-width="160" show-overflow-tooltip />
|
||
<el-table-column label="来源" width="80" align="center">
|
||
<template #default="{ row: e }">{{ entrySourceLabel(e.source_type) }}</template>
|
||
</el-table-column>
|
||
<el-table-column label="入库状态" width="90" align="center">
|
||
<template #default="{ row: e }">
|
||
<span :class="getStatusTextClass(entryOrderStatusTag(e.order_status))">
|
||
{{ entryOrderStatusLabel(e.order_status) }}
|
||
</span>
|
||
</template>
|
||
</el-table-column>
|
||
</el-table>
|
||
</div>
|
||
</div>
|
||
<div class="match-right-panel">
|
||
<div class="match-panel-head">
|
||
<span class="task-panel__section-title">明细对比</span>
|
||
<span class="match-panel-meta">
|
||
收货单 {{ matchPutawayReceivingRow?.receiving_number || '—' }}
|
||
<template v-if="matchSelectedEntryOrder">
|
||
← → 入库单 {{ matchSelectedEntryOrder.entry_order_code }}
|
||
</template>
|
||
</span>
|
||
<span
|
||
v-if="matchSelectedEntryOrder && matchComparisonRows.length"
|
||
:class="getStatusTextClass(matchComparisonSummary.type)"
|
||
class="match-panel-summary"
|
||
>
|
||
{{ matchComparisonSummary.text }}
|
||
</span>
|
||
</div>
|
||
<div class="task-panel__table-wrap">
|
||
<el-table
|
||
:data="matchComparisonRows"
|
||
v-loading="matchReceivingDetailsLoading || matchEntryDetailsLoading"
|
||
border
|
||
size="small"
|
||
height="100%"
|
||
row-key="stockId"
|
||
>
|
||
<el-table-column prop="productName" label="商品名称" min-width="150" show-overflow-tooltip />
|
||
<el-table-column prop="barcode" label="条码" width="130" show-overflow-tooltip />
|
||
<el-table-column prop="itemCode" label="商品编码" width="130" show-overflow-tooltip />
|
||
<el-table-column label="收货数量" width="90" align="center">
|
||
<template #default="{ row: r }">{{ r.receivingQty ?? '--' }}</template>
|
||
</el-table-column>
|
||
<el-table-column label="收货箱数" width="80" align="center">
|
||
<template #default="{ row: r }">{{ r.receivingBoxes ?? '--' }}</template>
|
||
</el-table-column>
|
||
<el-table-column label="入库应收" width="90" align="center">
|
||
<template #default="{ row: r }">{{ r.entryPlanQty ?? '--' }}</template>
|
||
</el-table-column>
|
||
<el-table-column label="入库实收" width="90" align="center">
|
||
<template #default="{ row: r }">{{ r.entryReceivedQty ?? '--' }}</template>
|
||
</el-table-column>
|
||
<el-table-column label="匹配" width="70" align="center">
|
||
<template #default="{ row: r }">
|
||
<span :class="getStatusTextClass(r.matched ? 'success' : 'info')">
|
||
{{ r.matched ? '已匹配' : '未匹配' }}
|
||
</span>
|
||
</template>
|
||
</el-table-column>
|
||
</el-table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<footer class="task-panel__foot">
|
||
<span class="task-panel__hint">
|
||
{{ matchSelectedEntryOrder ? '已选:' + matchSelectedEntryOrder.entry_order_code : '未选择入库单' }}
|
||
</span>
|
||
<div class="task-panel__actions">
|
||
<el-button size="small" @click="matchPutawayDialogVisible = false">取消</el-button>
|
||
<el-button
|
||
size="small"
|
||
type="primary"
|
||
:loading="matchPutawaySubmitLoading"
|
||
:disabled="!matchSelectedEntryOrder"
|
||
@click="submitMatchPutaway"
|
||
>
|
||
确认匹配入库
|
||
</el-button>
|
||
</div>
|
||
</footer>
|
||
</div>
|
||
</el-dialog>
|
||
</div>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
import { ref, reactive, onMounted, computed, nextTick } 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 OrderToolbarButtonGroup from '@/views/order/orderManagement/component/OrderToolbarButtonGroup.vue'
|
||
import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config'
|
||
import { getStatusTextClass } from '@/views/order/orderManagement/config/order-common-config'
|
||
import BatchReceivingPrintDialog from '@/components/BatchReceivingPrintDialog.vue'
|
||
import AsyncExportProgressDialog from '@/components/AsyncExportProgressDialog.vue'
|
||
import Details from './component/DetailsPanel.vue'
|
||
import StorageComp from './component/Storage.vue'
|
||
import Logs from './component/Logs.vue'
|
||
import Product from './component/Product.vue'
|
||
import * as indexApi from '@/api/index/index'
|
||
import * as receivingApi from '@/api/storage_receiving/receiving'
|
||
import * as entryApi from '@/api/storage.entry/entry'
|
||
import * as inventoryApi from '@/api/storage.inventory/inventory'
|
||
import { useSettingsStore } from '@/stores/modules/settings'
|
||
import {
|
||
receivingColumns,
|
||
availableFields,
|
||
formatReceivingData,
|
||
formatReceivingPrintItems,
|
||
statusConfig,
|
||
detailStatusConfig,
|
||
storageStatusConfig,
|
||
deliveryMethodConfig,
|
||
loadingMethodConfig,
|
||
addReceivingFields,
|
||
receivingToolbarButtons,
|
||
} from './receiving-config'
|
||
import { useAsyncExportTask } from '@/composables/useAsyncExportTask'
|
||
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
|
||
import { safeInvoke } from '@/utils/safe-invoke'
|
||
|
||
const scanBox = ref<any>(null)
|
||
const route = useRoute()
|
||
|
||
// 用于将初始条件传入 ScanBox(用于根据 URL 参数填充)
|
||
const initialConditions = ref<any>(null)
|
||
const upperTable = ref<any>(null)
|
||
|
||
const presetTree = ref<any[]>([])
|
||
const availableFieldsRef = reactive(JSON.parse(JSON.stringify(availableFields)))
|
||
const addReceivingFieldsRef = reactive(JSON.parse(JSON.stringify(addReceivingFields)))
|
||
|
||
const settingsStore = useSettingsStore()
|
||
const shortcutExpanded = computed(() => settingsStore.shortcutExpanded)
|
||
const containerHeight = computed(() => shortcutExpanded.value ? 'calc(100vh - 150px)' : 'calc(100vh - 100px)')
|
||
|
||
const {
|
||
splitStackRef,
|
||
beginSplitDrag,
|
||
lowerPaneStyle,
|
||
upperPaneStyle,
|
||
} = useVerticalSplitPane({ defaultLowerPercent: 40 })
|
||
|
||
const {
|
||
exportLoading,
|
||
exportDialogVisible,
|
||
exportTaskProgress,
|
||
exportProgressPercent,
|
||
exportProgressStatus,
|
||
exportStatusLabel,
|
||
submitExportTask
|
||
} = useAsyncExportTask({
|
||
storageKey: 'storage:receiving:exportTaskId',
|
||
submitExport: (payload) => receivingApi.exportReceiving(payload as any),
|
||
queryProgress: (params) => receivingApi.exportReceivingTaskProgress(params)
|
||
})
|
||
|
||
const upperPaneFullStyle = computed(() => ({
|
||
flex: '1 1 auto',
|
||
minHeight: '0',
|
||
overflow: 'hidden',
|
||
}))
|
||
|
||
const activeTab = ref('details')
|
||
|
||
const list = ref<any[]>([])
|
||
const loading = ref(false)
|
||
const quickPutawayLoading = ref(false)
|
||
const directPutawayLoading = ref(false)
|
||
const reviewLoading = ref(false)
|
||
const queryTime = ref(0)
|
||
|
||
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||
const tableSize = ref('small')
|
||
const columns = ref(receivingColumns)
|
||
|
||
const selectionRows = ref<any[]>([])
|
||
const hasSelection = ref(false)
|
||
const selectedReceivingId = ref<number | string | null>(null)
|
||
const detailVisible = ref(true)
|
||
|
||
const quickSearch = ref('')
|
||
const currentSort = reactive({ prop: '', order: '' })
|
||
const currentCondition = ref<any>(null)
|
||
// 保存原始条件(可能包含 operator 等信息)
|
||
const currentConditionRaw = ref<any>(null)
|
||
|
||
const componentMap: Record<string, any> = {
|
||
details: Details,
|
||
storage: StorageComp,
|
||
logs: Logs,
|
||
product: Product
|
||
}
|
||
|
||
const activeComponent = computed(() => componentMap[activeTab.value] || componentMap.details)
|
||
|
||
const selectedRow = computed(() => {
|
||
return list.value.find((i: any) => i.id === selectedReceivingId.value) || null
|
||
})
|
||
|
||
const toolbarButtons = receivingToolbarButtons
|
||
|
||
const buttonLoadingMap = computed(() => ({
|
||
loading: loading.value,
|
||
exportLoading: exportLoading.value,
|
||
reviewLoading: reviewLoading.value,
|
||
quickPutawayLoading: quickPutawayLoading.value,
|
||
directPutawayLoading: directPutawayLoading.value
|
||
}))
|
||
|
||
const buttonDisabledMap = computed(() => ({
|
||
hasNoSelection: !hasSelection.value,
|
||
singleSelectionOnly: selectionRows.value.length !== 1
|
||
}))
|
||
|
||
const buttonLabelMap = computed(() => ({
|
||
detailToggleLabel: detailVisible.value ? '隐藏详情' : '显示详情'
|
||
}))
|
||
|
||
const toolbarLayoutKey = computed(() =>
|
||
JSON.stringify({
|
||
loading: buttonLoadingMap.value,
|
||
disabled: buttonDisabledMap.value,
|
||
labels: buttonLabelMap.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()
|
||
},
|
||
handleCreateReceiving: () => handleCreateReceiving(),
|
||
handleExportSelected: () => {
|
||
void handleExportSelected()
|
||
},
|
||
handleExportAll: () => {
|
||
void handleExportAll()
|
||
},
|
||
openColumnConfigPanel: () => openColumnConfigPanel(),
|
||
toggleDetailVisible: () => toggleDetailVisible(),
|
||
confirmcomplete: () => {
|
||
void confirmcomplete()
|
||
},
|
||
confirmBatchCancel: () => {
|
||
void confirmBatchCancel()
|
||
},
|
||
handleRejectReceiving: () => handleRejectReceiving(),
|
||
handleReviewReceiving: () => {
|
||
void handleReviewReceiving()
|
||
},
|
||
handleQuickPutaway: () => {
|
||
void handleQuickPutaway()
|
||
},
|
||
handleDirectPutaway: () => {
|
||
void handleDirectPutaway()
|
||
},
|
||
handleOpenPrintDialog: () => {
|
||
void handleOpenPrintDialog()
|
||
}
|
||
}
|
||
|
||
function handleToolbarButtonClick(action: ToolbarButtonConfig['action']) {
|
||
const handler = toolbarActionMap[action]
|
||
if (!handler) return
|
||
safeInvoke(() => handler())
|
||
}
|
||
|
||
function toggleDetailVisible() {
|
||
detailVisible.value = !detailVisible.value
|
||
}
|
||
|
||
onMounted(() => {
|
||
// 先加载筛选相关数据(例如 store options、presetTree),保证 ScanBox options 可用
|
||
loadFilterData()
|
||
|
||
// 如果 URL 带有 id 参数,则构建初始筛选条件并应用
|
||
const idParam = route.query.id || route.query.receiving_number || route.query.q
|
||
const id = Array.isArray(idParam) ? idParam[0] : idParam
|
||
if (id) {
|
||
// 设置 ScanBox 的初始条件以在 UI 中显示
|
||
initialConditions.value = {
|
||
type: 'custom',
|
||
conditions: {
|
||
receiving_number: { value: String(id), operator: 'eq', field: 'receiving_number', type: 'text' }
|
||
}
|
||
}
|
||
|
||
// 直接使用包含 operator 的完整条件触发搜索(避免丢失 operator)
|
||
handleConditionChange(initialConditions.value)
|
||
} else {
|
||
// 无 URL 参数时正常加载列表
|
||
loadData()
|
||
}
|
||
})
|
||
|
||
async function loadData() {
|
||
if (loading.value) return
|
||
loading.value = true
|
||
const start = Date.now()
|
||
try {
|
||
// 直接使用 handleConditionChange 保存的完整条件(含 operator),避免丢失操作符信息
|
||
const where = currentCondition.value || {}
|
||
const topParams = extractTopLevelParams(currentConditionRaw.value)
|
||
// console.log('当前筛选条件:', where)
|
||
|
||
const params: any = {
|
||
pagination: { page: pagination.currentPage, pageSize: pagination.pageSize },
|
||
where,
|
||
order: currentSort.prop ? { [currentSort.prop]: currentSort.order === 'ascending' ? 'ASC' : 'DESC' } : undefined,
|
||
...topParams
|
||
}
|
||
|
||
if (quickSearch.value) {
|
||
params.where.receiving_number = { operator: 'like', value: quickSearch.value, type: 'text' }
|
||
}
|
||
|
||
const res: any = await receivingApi.getReceivingList(params)
|
||
if (res && res.code === 200) {
|
||
// console.log('API 返回数据:', res.data.list)
|
||
list.value = formatReceivingData(res.data.list || [])
|
||
pagination.currentPage = res.data.pagination?.currentPage || pagination.currentPage
|
||
pagination.pageSize = res.data.pagination?.pageSize || pagination.pageSize
|
||
pagination.total = res.data.pagination?.total || (res.data.pagination?.total || 0)
|
||
} else {
|
||
ElMessage.error(res?.message || '加载失败')
|
||
}
|
||
} catch (e) {
|
||
console.error(e)
|
||
ElMessage.error('加载收货单失败')
|
||
} finally {
|
||
loading.value = false
|
||
queryTime.value = Date.now() - start
|
||
}
|
||
}
|
||
|
||
async function loadFilterData() {
|
||
try {
|
||
const [storesRes, presetRes]: any = await Promise.all([indexApi.loadStores(), indexApi.fastWhereTree('receiving')])
|
||
if (storesRes && storesRes.code === 200) {
|
||
const stores = storesRes.stores || []
|
||
const f = availableFieldsRef.find((i: any) => i.value === 'store_id')
|
||
if (f) f.options = stores
|
||
|
||
const af = addReceivingFieldsRef.find((i: any) => i.prop === 'store_id')
|
||
if (af) af.options = stores
|
||
}
|
||
if (presetRes && presetRes.code === 200) {
|
||
// console.log('筛选配置', presetRes)
|
||
presetTree.value = presetRes.presetTree || []
|
||
}
|
||
} catch (e) {
|
||
console.error('加载筛选配置失败', e)
|
||
}
|
||
}
|
||
|
||
/** 顶层查询参数(与 where 平级,不放 where 内) */
|
||
const TOP_LEVEL_FIELDS = ['stock_query_where']
|
||
|
||
/** 从 ScanBox 条件中提取顶层参数(filterDepleted / entry_order_id / stock_query_where) */
|
||
function extractTopLevelParams(condition: any): Record<string, any> {
|
||
if (!condition || typeof condition !== 'object') return {}
|
||
const source = condition.conditions && typeof condition.conditions === 'object'
|
||
? condition.conditions
|
||
: condition
|
||
const params: Record<string, any> = {}
|
||
for (const key of TOP_LEVEL_FIELDS) {
|
||
const c = source[key]
|
||
if (c === undefined || c === null) continue
|
||
const val = c && typeof c === 'object' && 'value' in c ? c.value : c
|
||
if (val === undefined || val === null || val === '') continue
|
||
params[key] = val
|
||
}
|
||
return params
|
||
}
|
||
|
||
function normalizeToWhere(condition: any) {
|
||
if (!condition) return {}
|
||
|
||
// 如果是字符串或简单值,直接返回为收货单号查询(默认模糊)
|
||
if (typeof condition === 'string' || typeof condition === 'number') {
|
||
return { receiving_number: { operator: 'like', value: condition, type: 'text' } }
|
||
}
|
||
|
||
// 获取字段定义的辅助函数
|
||
const getFieldConfig = (key: string) => {
|
||
return availableFields.find(f => f.value === key)
|
||
}
|
||
|
||
// 映射类型到规范格式
|
||
const mapType = (type: string, value: any) => {
|
||
if (type === 'daterange' || Array.isArray(value)) return 'daterange'
|
||
if (type === 'number' || typeof value === 'number') return 'number'
|
||
if (type === 'boolean' || typeof value === 'boolean') return 'boolean'
|
||
return 'text'
|
||
}
|
||
|
||
const processConditionValue = (k: string, c: any) => {
|
||
const config = getFieldConfig(k)
|
||
const fieldType = config?.type || 'text'
|
||
|
||
// 如果 c 本身已经是规范的对象结构 { value, operator, type }
|
||
if (c && typeof c === 'object' && !Array.isArray(c)) {
|
||
const op = c.operator || (fieldType === 'daterange' ? 'between' : 'eq')
|
||
const type = c.type || mapType(fieldType, c.value)
|
||
|
||
// isnull / isnotnull 无需值,直接传递
|
||
if (['isnull', 'isnotnull'].includes(op)) {
|
||
return { operator: op, value: null, type }
|
||
}
|
||
|
||
const val = c.value !== undefined ? c.value : c
|
||
// 空值跳过(非 isnull/isnotnull)
|
||
if (val === null || val === undefined || val === '' || (Array.isArray(val) && val.length === 0)) return null
|
||
|
||
// daterange 强制 type=daterange, operator=between
|
||
if (fieldType === 'daterange' || type === 'daterange') {
|
||
return { operator: 'between', value: val, type: 'daterange' }
|
||
}
|
||
|
||
return { operator: op, value: val, type }
|
||
}
|
||
|
||
// 简单空值跳过
|
||
if (c === null || c === undefined || c === '' || (Array.isArray(c) && c.length === 0)) return null
|
||
|
||
// 处理简单值
|
||
const simpleOp = fieldType === 'daterange' ? 'between' : 'eq'
|
||
const simpleType = mapType(fieldType, c)
|
||
return { operator: simpleOp, value: c, type: simpleType }
|
||
}
|
||
|
||
// 如果来自 ScanBox 的 preset(包含 conditions)
|
||
if (condition.conditions && typeof condition.conditions === 'object') {
|
||
const where: any = {}
|
||
Object.keys(condition.conditions).forEach(k => {
|
||
if (TOP_LEVEL_FIELDS.includes(k)) return
|
||
const result = processConditionValue(k, condition.conditions[k])
|
||
if (result) where[k] = result
|
||
})
|
||
return where
|
||
}
|
||
|
||
// 普通自定义条件对象,键 -> { value, operator, ... } 或 键 -> 简单值
|
||
if (typeof condition === 'object') {
|
||
const where: any = {}
|
||
Object.keys(condition).forEach(k => {
|
||
if (TOP_LEVEL_FIELDS.includes(k)) return
|
||
const result = processConditionValue(k, condition[k])
|
||
if (result) where[k] = result
|
||
})
|
||
return where
|
||
}
|
||
|
||
return {}
|
||
}
|
||
|
||
function handleConditionChange(condition: any) {
|
||
// 保留原始条件(含 operator)以备需要
|
||
currentConditionRaw.value = condition
|
||
|
||
// 将复杂条件规范化为后端期望的 where 映射
|
||
currentCondition.value = normalizeToWhere(condition)
|
||
|
||
pagination.currentPage = 1
|
||
loadData()
|
||
}
|
||
|
||
function handleSortChange({ prop, order }: any) {
|
||
currentSort.prop = prop
|
||
currentSort.order = order
|
||
pagination.currentPage = 1
|
||
loadData()
|
||
}
|
||
|
||
function handleSubmit() {
|
||
// condition-change 在 submit 之前已触发并更新了 currentCondition,直接加载即可
|
||
pagination.currentPage = 1
|
||
loadData()
|
||
}
|
||
|
||
const handleConditionClear = () => {
|
||
currentCondition.value = null // 清空已保存的条件
|
||
currentConditionRaw.value = null // 清空原始条件,避免顶层参数残留
|
||
pagination.currentPage = 1
|
||
loadData()
|
||
}
|
||
|
||
function handleConditionReset() {
|
||
currentCondition.value = null // 清空已保存的条件
|
||
currentConditionRaw.value = null // 清空原始条件,避免顶层参数残留
|
||
pagination.currentPage = 1
|
||
// 如果 ScanBox 提供 reset/clear 方法,调用以清空筛选条件
|
||
if (scanBox.value?.reset) {
|
||
scanBox.value.reset()
|
||
} else if (scanBox.value?.clear) {
|
||
scanBox.value.clear()
|
||
}
|
||
loadData()
|
||
}
|
||
|
||
function onSelectionChange(rows: any[]) {
|
||
selectionRows.value = rows || []
|
||
hasSelection.value = selectionRows.value.length > 0
|
||
}
|
||
|
||
const productData = ref<any[]>([])
|
||
const productLoading = ref(false)
|
||
const productTotal = ref(0)
|
||
const productPagination = reactive({ currentPage: 1, pageSize: 20 })
|
||
// 用于取消过期请求的版本号,解决快速切换行时的竞态条件
|
||
const productLoadVersion = ref(0)
|
||
|
||
async function handleRowClick(row: any) {
|
||
selectedReceivingId.value = row?.id || null
|
||
// 切换行时立即清空明细数据,并递增版本号使旧请求结果失效
|
||
productData.value = []
|
||
productTotal.value = 0
|
||
|
||
if (!selectedReceivingId.value) {
|
||
return
|
||
}
|
||
// 重置分页
|
||
productPagination.currentPage = 1
|
||
loadProductData()
|
||
}
|
||
|
||
async function loadProductData() {
|
||
const version = ++productLoadVersion.value
|
||
productLoading.value = true
|
||
try {
|
||
const params = {
|
||
id: Number(selectedReceivingId.value),
|
||
pagination: {
|
||
page: productPagination.currentPage,
|
||
pageSize: productPagination.pageSize
|
||
}
|
||
}
|
||
const res: any = await receivingApi.getReceivingDetail(params)
|
||
// 版本不匹配说明用户已切换到其他行,丢弃此响应避免覆盖新数据
|
||
if (version !== productLoadVersion.value) return
|
||
if (res && res.code === 200 && res.data) {
|
||
// 兼容多种返回结构:res.data.receiving.details / res.data.list / res.data.details
|
||
const receivingData = res.data.receiving || {}
|
||
const details = Array.isArray(receivingData.details)
|
||
? receivingData.details
|
||
: Array.isArray(res.data.list)
|
||
? res.data.list
|
||
: Array.isArray(res.data.details)
|
||
? res.data.details
|
||
: []
|
||
const total = receivingData.pagination?.total ?? res.data.pagination?.total ?? details.length
|
||
|
||
productData.value = details
|
||
productTotal.value = total
|
||
} else {
|
||
productData.value = []
|
||
productTotal.value = 0
|
||
}
|
||
} catch (e) {
|
||
if (version !== productLoadVersion.value) return
|
||
console.error('获取收货单详情失败', e)
|
||
productData.value = []
|
||
productTotal.value = 0
|
||
} finally {
|
||
if (version === productLoadVersion.value) {
|
||
productLoading.value = false
|
||
}
|
||
}
|
||
}
|
||
|
||
function handleProductPageChange(page: number) {
|
||
productPagination.currentPage = page
|
||
loadProductData()
|
||
}
|
||
|
||
function handleProductSizeChange(size: number) {
|
||
productPagination.pageSize = size
|
||
productPagination.currentPage = 1
|
||
loadProductData()
|
||
}
|
||
|
||
function handlePageChange(page: number) {
|
||
pagination.currentPage = page
|
||
loadData()
|
||
}
|
||
|
||
function handlePageSizeChange(size: number) {
|
||
pagination.pageSize = size
|
||
pagination.currentPage = 1
|
||
loadData()
|
||
}
|
||
|
||
function onQuickSearch() {
|
||
pagination.currentPage = 1
|
||
loadData()
|
||
}
|
||
|
||
function openColumnConfigPanel() {
|
||
upperTable.value?.openColumnConfig?.()
|
||
}
|
||
|
||
function handleCreateReceiving() {
|
||
// 重置表单并打开对话框
|
||
Object.keys(createForm).forEach(key => createForm[key] = '')
|
||
createDialogVisible.value = true
|
||
}
|
||
|
||
// 新建收货单相关
|
||
const createDialogVisible = ref(false)
|
||
const createLoading = ref(false)
|
||
const createForm = reactive<any>({
|
||
store_id: '',
|
||
delivery_method: '',
|
||
loading_method: '',
|
||
license_plate: '',
|
||
tracking_number: '',
|
||
total_boxes: '',
|
||
total_pallets: '',
|
||
remark: ''
|
||
})
|
||
|
||
function handleCreateDialogClosed() {
|
||
Object.keys(createForm).forEach(key => createForm[key] = '')
|
||
}
|
||
|
||
async function submitCreateReceiving() {
|
||
// 仅校验指定的必填字段:到货方式与装卸方式
|
||
const requiredProps = ['delivery_method', 'loading_method']
|
||
for (const prop of requiredProps) {
|
||
const val = createForm[prop]
|
||
const field = addReceivingFieldsRef.find((f: any) => f.prop === prop)
|
||
const label = field ? field.label : prop
|
||
if (val === null || val === undefined || val === '') {
|
||
ElMessage.warning(`请填写${label}`)
|
||
return
|
||
}
|
||
}
|
||
|
||
const payload: any = {
|
||
delivery_method: String(createForm.delivery_method || '').trim(),
|
||
loading_method: String(createForm.loading_method || '').trim()
|
||
}
|
||
|
||
const storeId = Number(createForm.store_id)
|
||
if (Number.isFinite(storeId) && storeId > 0) {
|
||
payload.store_id = storeId
|
||
}
|
||
|
||
const totalBoxes = Number(createForm.total_boxes)
|
||
if (String(createForm.total_boxes || '').trim() !== '' && Number.isFinite(totalBoxes)) {
|
||
payload.total_boxes = totalBoxes
|
||
}
|
||
|
||
const totalPallets = Number(createForm.total_pallets)
|
||
if (String(createForm.total_pallets || '').trim() !== '' && Number.isFinite(totalPallets)) {
|
||
payload.total_pallets = totalPallets
|
||
}
|
||
|
||
const licensePlate = String(createForm.license_plate || '').trim()
|
||
if (licensePlate) payload.license_plate = licensePlate
|
||
|
||
const trackingNumber = String(createForm.tracking_number || '').trim()
|
||
if (trackingNumber) payload.tracking_number = trackingNumber
|
||
|
||
const remark = String(createForm.remark || '').trim()
|
||
if (remark) payload.remark = remark
|
||
|
||
createLoading.value = true
|
||
try {
|
||
const res: any = await receivingApi.createReceiving(payload)
|
||
// console.log('新建收货单返回结果:', res)
|
||
if (res && res.code === 200) {
|
||
const receivingNumber = res?.data?.receiving_number || res?.data?.receivingNumber || ''
|
||
ElMessage.success(receivingNumber ? `新建收货单成功:${receivingNumber}` : '新建收货单成功')
|
||
createDialogVisible.value = false
|
||
loadData()
|
||
} else {
|
||
ElMessage.error(res?.message || '新建失败')
|
||
}
|
||
} catch (e) {
|
||
console.error('新建收货单出错:', e)
|
||
ElMessage.error('新建收货单失败')
|
||
} finally {
|
||
createLoading.value = false
|
||
}
|
||
}
|
||
|
||
// 打印相关
|
||
const printDialogVisible = ref(false)
|
||
|
||
async function handleOpenPrintDialog() {
|
||
if (!selectionRows.value.length) {
|
||
ElMessage.warning('请先选择要打印的收货单')
|
||
return
|
||
}
|
||
|
||
// 校验收货状态,只有“已完成”的才能打印
|
||
const invalidRows = selectionRows.value.filter(row => row.status !== 'completed')
|
||
if (invalidRows.length > 0) {
|
||
ElMessage.warning(`只有“已完成”状态的单据才能打印。当前选中包含 ${invalidRows.length} 个非已完成单据。`)
|
||
return
|
||
}
|
||
printDialogVisible.value = true
|
||
}
|
||
|
||
/** 加载单个收货单的打印数据(单据头 + 明细),对齐 RECEIPT 模板字段 */
|
||
async function fetchPrintData(row: any) {
|
||
// 打印时间:打开打印对话框时生成
|
||
const now = new Date()
|
||
const pad = (n: number) => String(n).padStart(2, '0')
|
||
const nowStr = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())} ${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}`
|
||
|
||
// 枚举值 → 显示文本(来货方式/装卸方式)
|
||
const toLabel = (cfg: Record<string, any>, val: any) => {
|
||
if (val === null || val === undefined || val === '') return val ?? ''
|
||
const entry = Object.entries(cfg).find(([v]) => v === val)
|
||
return entry ? (entry[1] as any)?.text ?? val : val
|
||
}
|
||
|
||
// 单据头:优先对齐收货单模板字段名(field_code),兼容列表字段名
|
||
const formData: any = {
|
||
receiving_number: row.receiving_number || '',
|
||
delivery_method: toLabel(deliveryMethodConfig, row.delivery_method),
|
||
loading_method: toLabel(loadingMethodConfig, row.loading_method),
|
||
license_plate: row.license_plate || '',
|
||
tracking_number: row.tracking_number || '',
|
||
store_name: row.store_name || row['store.store_remask'] || row['store.store_name'] || '',
|
||
total_items: row.total_items ?? '',
|
||
total_quantity: row.total_quantity ?? '',
|
||
total_boxes: row.total_boxes ?? '',
|
||
total_pallets: row.total_pallets ?? '',
|
||
remark: row.remark || '',
|
||
created_at: row.created_at || row.receiving_start_time || '',
|
||
receiving_start_time: row.receiving_start_time || '',
|
||
receiving_end_time: row.receiving_end_time || '',
|
||
print_time: nowStr,
|
||
details: []
|
||
}
|
||
|
||
try {
|
||
const res: any = await receivingApi.getReceivingDetail({
|
||
id: Number(row.id),
|
||
pagination: { page: 1, pageSize: 1000 }
|
||
})
|
||
if (res && (res.code === 200 || res.code === 1 || res.flag === 'success') && res.data) {
|
||
const receiving = res.data.receiving || {}
|
||
const rows = Array.isArray(receiving.details) ? receiving.details : []
|
||
formData.details = formatReceivingPrintItems(rows)
|
||
|
||
const store = receiving.store || {}
|
||
Object.assign(formData, {
|
||
receiving_number: receiving.receiving_number ?? formData.receiving_number,
|
||
delivery_method: receiving.delivery_method ? toLabel(deliveryMethodConfig, receiving.delivery_method) : formData.delivery_method,
|
||
loading_method: receiving.loading_method ? toLabel(loadingMethodConfig, receiving.loading_method) : formData.loading_method,
|
||
license_plate: receiving.license_plate ?? formData.license_plate,
|
||
tracking_number: receiving.tracking_number ?? formData.tracking_number,
|
||
store_name: receiving.store_name ?? store.store_remask ?? store.store_name ?? formData.store_name,
|
||
total_items: receiving.total_items ?? formData.total_items,
|
||
total_quantity: receiving.total_quantity ?? formData.total_quantity,
|
||
total_boxes: receiving.total_boxes ?? formData.total_boxes,
|
||
total_pallets: receiving.total_pallets ?? formData.total_pallets,
|
||
remark: receiving.remark ?? formData.remark,
|
||
created_at: receiving.created_at ?? formData.created_at,
|
||
receiving_start_time: receiving.receiving_start_time ?? formData.receiving_start_time,
|
||
receiving_end_time: receiving.receiving_end_time ?? formData.receiving_end_time
|
||
})
|
||
}
|
||
} catch (e) {
|
||
console.error('加载收货单打印明细失败', e)
|
||
}
|
||
|
||
return formData
|
||
}
|
||
|
||
async function confirmcomplete() {
|
||
if (!selectionRows.value.length) {
|
||
ElMessage.warning('请先选择要操作的收货单')
|
||
return
|
||
}
|
||
|
||
try {
|
||
await ElMessageBox.confirm(`确定要批量完成 ${selectionRows.value.length} 个收货单的收货吗?`, '确认完成', { type: 'success', buttonSize: 'small' })
|
||
|
||
for (const row of selectionRows.value) {
|
||
// console.log('正在执行完成收货,请求数据:', { id: row.id, type: 'complete' })
|
||
// 传递 id 标识单号,以及 type: 'complete' 来表示完成收货操作(补全请求数据)
|
||
const res: any = await receivingApi.completeReceiving({ id: row.id, type: 'complete' })
|
||
// console.log('完成收货接口返回数据:', res)
|
||
|
||
if (res && res.code === 200) {
|
||
ElMessage.success(`收货单 ${row.receiving_number} 已完成`)
|
||
} else {
|
||
ElMessage.error(`收货单 ${row.receiving_number} 操作失败: ${res.message || '系统错误'}`)
|
||
}
|
||
}
|
||
|
||
selectionRows.value = []
|
||
loadData()
|
||
} catch (e) {
|
||
if (e !== 'cancel') {
|
||
console.error('完成收货操作出错:', e)
|
||
// ElMessage.error('操作执行失败')
|
||
}
|
||
}
|
||
}
|
||
|
||
async function confirmBatchCancel() {
|
||
if (!selectionRows.value.length) {
|
||
ElMessage.warning('请先选择要操作的收货单')
|
||
return
|
||
}
|
||
|
||
try {
|
||
await ElMessageBox.confirm(`确定要批量作废 ${selectionRows.value.length} 个收货单吗?`, '确认作废', { type: 'warning', buttonSize: 'small' })
|
||
|
||
const ids = selectionRows.value.map(row => row.id)
|
||
const res: any = await receivingApi.batchCancelReceiving({ ids })
|
||
|
||
if (res && res.code === 200) {
|
||
ElMessage.success('批量作废成功')
|
||
} else {
|
||
ElMessage.error(res.message || '批量作废失败')
|
||
}
|
||
|
||
selectionRows.value = []
|
||
loadData()
|
||
} catch (e) {
|
||
if (e !== 'cancel') {
|
||
console.error('批量作废操作出错:', e)
|
||
// ElMessage.error('操作执行失败')
|
||
}
|
||
}
|
||
}
|
||
|
||
async function handleReviewReceiving() {
|
||
if (!selectionRows.value.length) {
|
||
ElMessage.warning('请先选择要审核的收货单')
|
||
return
|
||
}
|
||
|
||
try {
|
||
await ElMessageBox.confirm(
|
||
`确定要批量审核 ${selectionRows.value.length} 个收货单吗?\n审核后将会直接通知货主且不可撤销。`,
|
||
'确认审核',
|
||
{ type: 'warning', buttonSize: 'small' }
|
||
)
|
||
} catch {
|
||
return
|
||
}
|
||
|
||
reviewLoading.value = true
|
||
try {
|
||
const ids = selectionRows.value.map(row => row.id)
|
||
const res: any = await receivingApi.reviewReceiving({ ids })
|
||
if (res && res.code === 200) {
|
||
ElMessage.success(`已成功审核 ${res.data?.count ?? ids.length} 个收货单`)
|
||
selectionRows.value = []
|
||
loadData()
|
||
} else {
|
||
ElMessage.error(res?.message || '批量审核失败')
|
||
}
|
||
} catch (e) {
|
||
console.error('批量审核出错:', e)
|
||
ElMessage.error('审核操作执行失败')
|
||
} finally {
|
||
reviewLoading.value = false
|
||
}
|
||
}
|
||
|
||
// 驳回收货单相关
|
||
const rejectDialogVisible = ref(false)
|
||
const rejectLoading = ref(false)
|
||
const rejectRemark = ref('')
|
||
|
||
function handleRejectReceiving() {
|
||
if (!selectionRows.value.length) {
|
||
ElMessage.warning('请先选择要驳回的收货单')
|
||
return
|
||
}
|
||
rejectRemark.value = ''
|
||
rejectDialogVisible.value = true
|
||
}
|
||
|
||
async function submitRejectReceiving() {
|
||
rejectLoading.value = true
|
||
try {
|
||
const ids = selectionRows.value.map(row => row.id)
|
||
const payload: any = { ids }
|
||
if (rejectRemark.value) payload.remark = rejectRemark.value
|
||
|
||
const res: any = await receivingApi.rejectReceiving(payload)
|
||
if (res && res.code === 200) {
|
||
ElMessage.success(`已成功驳回 ${res.data?.count ?? ids.length} 个收货单`)
|
||
rejectDialogVisible.value = false
|
||
selectionRows.value = []
|
||
loadData()
|
||
} else {
|
||
ElMessage.error(res?.message || '驳回失败')
|
||
}
|
||
} catch (e) {
|
||
console.error('驳回收货单出错:', e)
|
||
ElMessage.error('驳回操作执行失败')
|
||
} finally {
|
||
rejectLoading.value = false
|
||
}
|
||
}
|
||
|
||
/** 入库单列表 order_status,与 storage.entry.list 一致 */
|
||
const ENTRY_ORDER_STATUS_OPTIONS = [
|
||
{ label: '待入库', value: 'PENDING' },
|
||
{ label: '入库中', value: 'PARTIAL' },
|
||
{ label: '部分收货', value: 'PARTIAL_RECEIVED' }
|
||
]
|
||
|
||
const matchPutawayDialogVisible = ref(false)
|
||
const matchPutawayReceivingRow = ref<any>(null)
|
||
const matchPutawayContextHint = ref('')
|
||
const matchEntryList = ref<any[]>([])
|
||
const matchEntryListLoading = ref(false)
|
||
const matchEntryStoreOptions = ref<any[]>([])
|
||
const matchEntryFilterOrderStatus = ref('')
|
||
/** 货主筛选值(在 fetchMatchEntryList 中作为后端查询条件使用) */
|
||
const matchEntryFilterStoreId = ref<number | string | undefined>(undefined)
|
||
const matchEntryPagination = reactive({ page: 1, pageSize: 10, total: 0 })
|
||
const matchEntryTableRef = ref<any>(null)
|
||
const matchPutawaySubmitLoading = ref(false)
|
||
|
||
// 对比视图相关
|
||
const matchReceivingDetails = ref<any[]>([])
|
||
const matchReceivingDetailsLoading = ref(false)
|
||
const matchSelectedEntryOrder = ref<any>(null)
|
||
const matchEntryDetails = ref<any[]>([])
|
||
const matchEntryDetailsLoading = ref(false)
|
||
|
||
type ComparisonRow = {
|
||
stockId: string
|
||
productName: string
|
||
barcode: string
|
||
itemCode: string
|
||
receivingQty: string | number
|
||
receivingBoxes: string | number
|
||
entryPlanQty: string | number
|
||
entryReceivedQty: string | number
|
||
matched: boolean
|
||
}
|
||
|
||
const matchComparisonRows = computed<ComparisonRow[]>(() => {
|
||
const receiving = matchReceivingDetails.value
|
||
const entries = matchEntryDetails.value
|
||
const stockMap = new Map<string, any>()
|
||
// 以入库单明细为主,建立 stock_id 索引
|
||
for (const e of entries) {
|
||
const sid = String(e.stock_id || e.item_id || e.item_code || '')
|
||
if (!sid) continue
|
||
stockMap.set(sid, { receiving: null, entry: e })
|
||
}
|
||
// 收货明细匹配到对应入库单明细
|
||
for (const r of receiving) {
|
||
const sid = String(r.system_product_id || r.stock_id || r.item_code || '')
|
||
if (!sid) continue
|
||
const existing = stockMap.get(sid)
|
||
if (existing) {
|
||
existing.receiving = r
|
||
} else {
|
||
stockMap.set(sid, { receiving: r, entry: null })
|
||
}
|
||
}
|
||
// 生成对比行:以入库单为主,确保所有入库单商品都显示
|
||
const rows: ComparisonRow[] = []
|
||
for (const e of entries) {
|
||
const sid = String(e.stock_id || e.item_id || e.item_code || '')
|
||
const pair = sid ? stockMap.get(sid) : null
|
||
const recv = pair?.receiving || null
|
||
rows.push({
|
||
stockId: sid || `e_${rows.length}`,
|
||
productName: e.item_name || recv?.product_name || '—',
|
||
barcode: recv?.barcode || '—',
|
||
itemCode: e.item_code || recv?.item_code || '—',
|
||
receivingQty: recv?.actual_quantity ?? '—',
|
||
receivingBoxes: recv?.box_quantity ?? '—',
|
||
entryPlanQty: e.count ?? e.plan_qty ?? '—',
|
||
entryReceivedQty: e.received_quantity ?? '—',
|
||
matched: !!recv
|
||
})
|
||
}
|
||
// 追加仅在收货明细中存在、入库单中没有的商品
|
||
for (const r of receiving) {
|
||
const sid = String(r.system_product_id || r.stock_id || r.item_code || '')
|
||
if (!sid) continue
|
||
const pair = stockMap.get(sid)
|
||
if (pair?.entry) continue // 已在上面处理
|
||
rows.push({
|
||
stockId: sid,
|
||
productName: r.product_name || r.item_name || '—',
|
||
barcode: r.barcode || '—',
|
||
itemCode: r.item_code || '—',
|
||
receivingQty: r.actual_quantity ?? '—',
|
||
receivingBoxes: r.box_quantity ?? '—',
|
||
entryPlanQty: '—',
|
||
entryReceivedQty: '—',
|
||
matched: false
|
||
})
|
||
}
|
||
return rows
|
||
})
|
||
|
||
const matchComparisonSummary = computed(() => {
|
||
const rows = matchComparisonRows.value
|
||
if (!rows.length) return { text: '无匹配商品', type: 'info' as const }
|
||
const matched = rows.filter(r => r.matched).length
|
||
if (matched === 0) return { text: '无匹配商品', type: 'danger' as const }
|
||
if (matched === rows.length) return { text: '全部一致', type: 'success' as const }
|
||
return { text: '部分一致', type: 'warning' as const }
|
||
})
|
||
|
||
async function onMatchEntrySelect(row: any) {
|
||
matchSelectedEntryOrder.value = row
|
||
matchEntryDetails.value = []
|
||
if (!row?.id) return
|
||
matchEntryDetailsLoading.value = true
|
||
try {
|
||
const res: any = await entryApi.getEntryDetail({ id: row.id })
|
||
if (res && res.code === 200 && res.data?.entryOrder) {
|
||
const entryOrder = res.data.entryOrder
|
||
const items = entryOrder.items || []
|
||
matchEntryDetails.value = items.map((item: any) => ({
|
||
...item,
|
||
item_name: item.stock?.item_name || item.item_name || '',
|
||
item_code: item.item_code || item.stock?.item_code || '',
|
||
stock_id: item.stock_id || item.stock?.id || '',
|
||
count: item.count ?? item.plan_qty ?? 0,
|
||
received_quantity: item.received_quantity ?? item.confirm_quantity ?? 0
|
||
}))
|
||
} else {
|
||
matchEntryDetails.value = []
|
||
}
|
||
} catch {
|
||
matchEntryDetails.value = []
|
||
} finally {
|
||
matchEntryDetailsLoading.value = false
|
||
}
|
||
}
|
||
|
||
function entryOrderStatusLabel(status: string) {
|
||
const o = ENTRY_ORDER_STATUS_OPTIONS.find(i => i.value === status)
|
||
return o?.label || status || '--'
|
||
}
|
||
|
||
function entryOrderStatusTag(status: string) {
|
||
const map: Record<string, string> = {
|
||
CREATED: 'info',
|
||
PENDING: 'warning',
|
||
PARTIAL: 'primary',
|
||
PARTIAL_RECEIVED: 'primary',
|
||
COMPLETED: 'success',
|
||
CANCELLED: 'danger'
|
||
}
|
||
return map[status] || 'info'
|
||
}
|
||
|
||
function entrySourceLabel(sourceType: string) {
|
||
const map: Record<string, string> = { QM: '奇门', API: '接口', WMS: '系统' }
|
||
return map[sourceType] || sourceType || '—'
|
||
}
|
||
|
||
/**
|
||
* 将 index.loadStores / ScanBox 等处的货主项统一为下拉可用的 { value, label }。
|
||
* 兼容 { value, label }、{ id, store_remask }、{ store_id, store_name } 等形态。
|
||
*/
|
||
function normalizeStoreOptionsForSelect(stores: any[]): { value: number; label: string }[] {
|
||
if (!Array.isArray(stores)) return []
|
||
const out: { value: number; label: string }[] = []
|
||
for (const s of stores) {
|
||
const rawVal = s?.value ?? s?.id ?? s?.store_id
|
||
if (rawVal === undefined || rawVal === null || rawVal === '') continue
|
||
const num = typeof rawVal === 'number' ? rawVal : Number(rawVal)
|
||
const value = Number.isFinite(num) ? num : (rawVal as number)
|
||
const label =
|
||
(s?.label != null && String(s.label).trim() !== '' && String(s.label)) ||
|
||
(s?.store_remask != null && String(s.store_remask)) ||
|
||
(s?.name != null && String(s.name)) ||
|
||
(s?.store_name != null && String(s.store_name)) ||
|
||
String(value)
|
||
out.push({ value: value as number, label })
|
||
}
|
||
return out
|
||
}
|
||
|
||
async function ensureMatchEntryStores() {
|
||
const storeField = availableFieldsRef.find((i: any) => i.value === 'store_id')
|
||
const fromScan = Array.isArray(storeField?.options) ? storeField.options : []
|
||
if (fromScan.length) {
|
||
matchEntryStoreOptions.value = normalizeStoreOptionsForSelect(fromScan)
|
||
return
|
||
}
|
||
if (matchEntryStoreOptions.value.length) return
|
||
try {
|
||
const res: any = await indexApi.loadStores()
|
||
if (res && res.code === 200) {
|
||
const raw = res.stores ?? res.data?.stores ?? []
|
||
matchEntryStoreOptions.value = normalizeStoreOptionsForSelect(raw)
|
||
}
|
||
} catch (e) {
|
||
console.error('加载货主列表失败', e)
|
||
}
|
||
}
|
||
|
||
function resetMatchPutawayDialog() {
|
||
matchPutawayReceivingRow.value = null
|
||
matchPutawayContextHint.value = ''
|
||
matchEntryList.value = []
|
||
matchEntryFilterStoreId.value = undefined
|
||
matchEntryFilterOrderStatus.value = ''
|
||
matchEntryPagination.page = 1
|
||
matchEntryPagination.total = 0
|
||
matchReceivingDetails.value = []
|
||
matchSelectedEntryOrder.value = null
|
||
matchEntryDetails.value = []
|
||
}
|
||
|
||
async function openMatchPutawayDialog(row: any) {
|
||
if (!row?.id) {
|
||
ElMessage.warning('缺少收货单信息')
|
||
return
|
||
}
|
||
const sid = row.store_id
|
||
if (sid == null || sid === '' || !Number.isFinite(Number(sid))) {
|
||
ElMessage.warning('该收货单未设置货主,请先在详情中设置货主后再匹配入库')
|
||
return
|
||
}
|
||
matchPutawayReceivingRow.value = row
|
||
matchPutawayContextHint.value = `收货单:${row.receiving_number || row.id}`
|
||
matchPutawayDialogVisible.value = true
|
||
matchEntryList.value = []
|
||
matchEntryFilterStoreId.value = Number(sid)
|
||
matchEntryFilterOrderStatus.value = ''
|
||
matchEntryPagination.page = 1
|
||
matchSelectedEntryOrder.value = null
|
||
matchEntryDetails.value = []
|
||
// 加载收货明细
|
||
matchReceivingDetailsLoading.value = true
|
||
try {
|
||
const res: any = await receivingApi.getReceivingDetail({
|
||
id: row.id,
|
||
pagination: { page: 1, pageSize: 1000 }
|
||
})
|
||
if (res && res.code === 200 && res.data) {
|
||
const d = res.data.receiving || {}
|
||
matchReceivingDetails.value = Array.isArray(d.details) ? d.details
|
||
: Array.isArray(res.data.list) ? res.data.list
|
||
: Array.isArray(res.data.details) ? res.data.details : []
|
||
} else {
|
||
matchReceivingDetails.value = []
|
||
}
|
||
} catch {
|
||
matchReceivingDetails.value = []
|
||
} finally {
|
||
matchReceivingDetailsLoading.value = false
|
||
}
|
||
await fetchMatchEntryList()
|
||
}
|
||
|
||
async function fetchMatchEntryList() {
|
||
matchEntryListLoading.value = true
|
||
try {
|
||
const where: Record<string, any> = {}
|
||
if (matchEntryFilterStoreId.value !== '' && matchEntryFilterStoreId.value != null) {
|
||
const sid = Number(matchEntryFilterStoreId.value)
|
||
if (Number.isFinite(sid)) {
|
||
where.store_id = {
|
||
operator: 'eq',
|
||
value: sid,
|
||
type: 'number'
|
||
}
|
||
}
|
||
}
|
||
if (matchEntryFilterOrderStatus.value) {
|
||
where.order_status = {
|
||
operator: 'eq',
|
||
value: matchEntryFilterOrderStatus.value,
|
||
type: 'text'
|
||
}
|
||
} else {
|
||
// 未选择时固定过滤:只显示待入库/入库中/部分收货
|
||
where.order_status = {
|
||
operator: 'in',
|
||
value: ['PENDING', 'PARTIAL', 'PARTIAL_RECEIVED'],
|
||
type: 'select'
|
||
}
|
||
}
|
||
const res: any = await entryApi.getEntryList({
|
||
pagination: {
|
||
page: matchEntryPagination.page,
|
||
pageSize: matchEntryPagination.pageSize
|
||
},
|
||
where: Object.keys(where).length ? where : {}
|
||
})
|
||
if (res && res.code === 200 && res.data) {
|
||
matchEntryList.value = res.data.list || []
|
||
matchEntryPagination.total = res.data.pagination?.total ?? 0
|
||
} else {
|
||
matchEntryList.value = []
|
||
matchEntryPagination.total = 0
|
||
if (res?.message) ElMessage.error(res.message)
|
||
}
|
||
} catch (e) {
|
||
console.error('加载入库单列表失败', e)
|
||
ElMessage.error('加载入库单列表失败')
|
||
matchEntryList.value = []
|
||
matchEntryPagination.total = 0
|
||
} finally {
|
||
matchEntryListLoading.value = false
|
||
await nextTick()
|
||
matchEntryTableRef.value?.setCurrentRow?.(undefined)
|
||
}
|
||
}
|
||
|
||
async function submitMatchPutaway() {
|
||
const row = matchPutawayReceivingRow.value
|
||
const receivingId = row?.id != null ? Number(row.id) : NaN
|
||
if (!Number.isFinite(receivingId) || receivingId <= 0) {
|
||
ElMessage.warning('缺少收货单ID')
|
||
return
|
||
}
|
||
const entry = matchSelectedEntryOrder.value
|
||
if (!entry?.id) {
|
||
ElMessage.warning('请选择一条入库单')
|
||
return
|
||
}
|
||
const entryId = Number(entry.id)
|
||
if (!Number.isFinite(entryId) || entryId <= 0) return
|
||
try {
|
||
await ElMessageBox.confirm(
|
||
`将对收货单「${row?.receiving_number || receivingId}」与入库单「${entry.entry_order_code || entryId}」执行匹配入库(按 SKU 数量匹配)。确定继续?`,
|
||
'确认匹配入库',
|
||
{ confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning', buttonSize: 'small' }
|
||
)
|
||
} catch {
|
||
return
|
||
}
|
||
matchPutawaySubmitLoading.value = true
|
||
try {
|
||
const res: any = await inventoryApi.matchPutaway({
|
||
receiving_ids: [receivingId],
|
||
entry_order_ids: [entryId]
|
||
})
|
||
if (res && (res.code === 200 || res.flag === 'success' || res.status === 'success')) {
|
||
ElMessage.success(res.message || '匹配入库已提交')
|
||
matchPutawayDialogVisible.value = false
|
||
loadData()
|
||
} else {
|
||
ElMessage.error(res?.message || res?.msg || '匹配入库失败')
|
||
}
|
||
} catch (e: any) {
|
||
ElMessage.error(e?.message || '匹配入库请求失败')
|
||
} finally {
|
||
matchPutawaySubmitLoading.value = false
|
||
}
|
||
}
|
||
|
||
function printReceiving() {
|
||
if (!selectionRows.value.length) {
|
||
ElMessage.warning('请选择要打印的收货单')
|
||
return
|
||
}
|
||
const payload = selectionRows.value.map(r => ({ ...r, businessId: r.receiving_number }))
|
||
// 简单打印:在新窗口显示 JSON,后续可替换为正式打印组件
|
||
const w = window.open('', '_blank')
|
||
if (w) {
|
||
w.document.write(`<pre>${JSON.stringify(payload, null, 2)}</pre>`)
|
||
w.document.close()
|
||
}
|
||
}
|
||
|
||
async function handleQuickPutaway() {
|
||
if (selectionRows.value.length !== 1) {
|
||
ElMessage.warning('请仅选择一条收货单进行转入库单')
|
||
return
|
||
}
|
||
|
||
// 校验收货单状态:要求收货单已完成(completed)且所有明细已匹配系统商品(all_matched)
|
||
const errors: string[] = []
|
||
const validRows: any[] = []
|
||
|
||
selectionRows.value.forEach(row => {
|
||
const isCompleted = (row.status || '').toLowerCase() === 'completed'
|
||
const isAllMatched = (row.detail_status || '').toLowerCase() === 'all_matched'
|
||
|
||
if (!isCompleted) {
|
||
errors.push(`收货单【${row.receiving_number}】未完成(当前状态:${row.status || '未知'})`)
|
||
} else if (!isAllMatched) {
|
||
errors.push(`收货单【${row.receiving_number}】明细未全部匹配(当前明细状态:${row.detail_status || '未全部匹配'})`)
|
||
} else {
|
||
validRows.push(row)
|
||
}
|
||
})
|
||
|
||
if (errors.length > 0) {
|
||
ElMessageBox.alert(
|
||
`<div style="max-height: 300px; overflow: auto;">${errors.join('<br/>')}</div>`,
|
||
'校验未通过,无法转入库单',
|
||
{ confirmButtonText: '确定', dangerouslyUseHTMLString: true, type: 'error', buttonSize: 'small' }
|
||
)
|
||
return
|
||
}
|
||
|
||
try {
|
||
await ElMessageBox.confirm(
|
||
`确定对选中的 ${validRows.length} 条收货单执行转入库单吗?`,
|
||
'转入库单确认',
|
||
{ confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning', buttonSize: 'small' }
|
||
)
|
||
} catch {
|
||
return
|
||
}
|
||
|
||
quickPutawayLoading.value = true
|
||
const failList: string[] = []
|
||
|
||
try {
|
||
for (const row of validRows) {
|
||
try {
|
||
const res = await receivingApi.quickPutaway({ receiving_id: row.id })
|
||
if (!res || (res.code !== 200 && res.flag !== 'success' && res.status !== 'success')) {
|
||
failList.push(`${row.receiving_number}:${res?.message || res?.msg || '接口返回失败'}`)
|
||
}
|
||
} catch (e: any) {
|
||
failList.push(`${row.receiving_number}:${e?.message || '请求异常'}`)
|
||
}
|
||
}
|
||
|
||
if (failList.length > 0) {
|
||
ElMessageBox.alert(
|
||
`<div style="max-height: 300px; overflow: auto;">${failList.join('<br/>')}</div>`,
|
||
`${failList.length} 条收货单处理失败`,
|
||
{ confirmButtonText: '确定', dangerouslyUseHTMLString: true, type: 'error', buttonSize: 'small' }
|
||
)
|
||
} else {
|
||
ElMessage.success('选中的收货单已全部转入库单成功')
|
||
}
|
||
loadData()
|
||
} finally {
|
||
quickPutawayLoading.value = false
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 收货单直入库存(一步完成):将已审核(completed + is_review)且未全部入库的收货单
|
||
* 明细按库位直接写入库位库存,并生成一步完成的 SCRK 入库单。
|
||
*/
|
||
async function handleDirectPutaway() {
|
||
if (selectionRows.value.length !== 1) {
|
||
ElMessage.warning('请仅选择一条收货单进行收货单直入')
|
||
return
|
||
}
|
||
|
||
const row = selectionRows.value[0]
|
||
const errors: string[] = []
|
||
const isCompleted = (row.status || '').toLowerCase() === 'completed'
|
||
const isReviewed = row.is_review === 1 || row.is_review === true
|
||
const hasPendingStorage = (row.storage_status || '') !== 'all'
|
||
|
||
if (!isCompleted) {
|
||
errors.push(`收货单【${row.receiving_number}】未完成(当前状态:${row.status || '未知'})`)
|
||
} else if (!isReviewed) {
|
||
errors.push(`收货单【${row.receiving_number}】未审核,不允许直入库存`)
|
||
} else if (!hasPendingStorage) {
|
||
errors.push(`收货单【${row.receiving_number}】明细已全部入库,禁止重复直入库存`)
|
||
}
|
||
|
||
if (errors.length > 0) {
|
||
ElMessageBox.alert(
|
||
`<div style="max-height: 300px; overflow: auto;">${errors.join('<br/>')}</div>`,
|
||
'校验未通过,无法收货单直入',
|
||
{ confirmButtonText: '确定', dangerouslyUseHTMLString: true, type: 'error', buttonSize: 'small' }
|
||
)
|
||
return
|
||
}
|
||
|
||
try {
|
||
await ElMessageBox.confirm(
|
||
`确定对收货单「${row.receiving_number}」执行收货单直入吗?未入库明细将按库位直接写入库存并生成入库单。`,
|
||
'收货单直入确认',
|
||
{ confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning', buttonSize: 'small' }
|
||
)
|
||
} catch {
|
||
return
|
||
}
|
||
|
||
directPutawayLoading.value = true
|
||
try {
|
||
const res: any = await inventoryApi.directPutaway({ receiving_id: row.id })
|
||
if (res && (res.code === 200 || res.flag === 'success' || res.status === 'success')) {
|
||
const data = res.data && typeof res.data === 'object' ? res.data : res
|
||
const entryOrderCode = data?.entry_order_code || ''
|
||
const totalLines = data?.total_lines ?? ''
|
||
const totalQuantity = data?.total_quantity ?? ''
|
||
const detail = [
|
||
entryOrderCode ? `入库单 ${entryOrderCode}` : '',
|
||
totalLines !== '' ? `共 ${totalLines} 行` : '',
|
||
totalQuantity !== '' ? `总数量 ${totalQuantity}` : ''
|
||
].filter(Boolean).join(',')
|
||
ElMessage.success(detail ? `收货单直入成功:${detail}` : '收货单直入成功')
|
||
selectionRows.value = []
|
||
loadData()
|
||
} else {
|
||
ElMessage.error(res?.message || res?.msg || '收货单直入失败')
|
||
}
|
||
} catch (e: any) {
|
||
console.error('收货单直入出错:', e)
|
||
ElMessage.error(e?.message || '收货单直入请求失败')
|
||
} finally {
|
||
directPutawayLoading.value = false
|
||
}
|
||
}
|
||
|
||
function buildExportPayload() {
|
||
if (currentCondition.value && currentCondition.value !== 'reset') {
|
||
return { where: normalizeToWhere(currentCondition.value) }
|
||
}
|
||
return { where: normalizeToWhere({}) }
|
||
}
|
||
|
||
function buildExportSelectedPayload() {
|
||
const ids = selectionRows.value.map((item: any) => item.id)
|
||
return {
|
||
where: {
|
||
id: { operator: 'in', value: ids }
|
||
}
|
||
}
|
||
}
|
||
|
||
async function handleExportSelected() {
|
||
if (!selectionRows.value.length) {
|
||
ElMessage.warning('请先勾选要导出的收货单')
|
||
return
|
||
}
|
||
await submitExportTask(buildExportSelectedPayload())
|
||
}
|
||
|
||
async function handleExportAll() {
|
||
await submitExportTask(buildExportPayload())
|
||
}
|
||
</script>
|
||
|
||
<style scoped lang="scss">
|
||
@use "../../order/orderManagement/styles/order-sub.scss";
|
||
|
||
/* 详情区外壳与 stock/external_stock 保持一致:不留上/下间距(各详情组件自带
|
||
padding: 6px 10px 8px),只保留左右 10px,避免与组件内边距叠加 */
|
||
.order-sub-container .main-content .lower-level .detail-container {
|
||
padding: 0 10px;
|
||
display: flex;
|
||
flex-direction: column;
|
||
box-sizing: border-box;
|
||
|
||
:deep(.receiving-detail-pane) {
|
||
flex: 1;
|
||
min-height: 0;
|
||
min-width: 0;
|
||
width: 100%;
|
||
overflow: hidden;
|
||
display: flex;
|
||
flex-direction: column;
|
||
}
|
||
}
|
||
|
||
.empty-tip {
|
||
text-align: center;
|
||
font-size: 13px;
|
||
line-height: 1.5;
|
||
max-width: 360px;
|
||
|
||
.el-icon {
|
||
font-size: 36px;
|
||
margin-bottom: 8px;
|
||
}
|
||
}
|
||
|
||
.match-putaway-dialog {
|
||
display: flex;
|
||
height: 65vh;
|
||
gap: 12px;
|
||
}
|
||
|
||
.match-left-panel {
|
||
width: 330px;
|
||
flex-shrink: 0;
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 6px;
|
||
min-height: 0;
|
||
}
|
||
|
||
.match-right-panel {
|
||
flex: 1;
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 6px;
|
||
min-width: 0;
|
||
min-height: 0;
|
||
}
|
||
|
||
.match-panel-head {
|
||
display: flex;
|
||
align-items: center;
|
||
flex-wrap: wrap;
|
||
gap: 8px;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.match-panel-meta {
|
||
font-size: 12px;
|
||
line-height: 20px;
|
||
color: #909399;
|
||
min-width: 0;
|
||
}
|
||
|
||
.match-panel-summary {
|
||
margin-left: auto;
|
||
}
|
||
|
||
/* 面板结构 / 尺寸对齐手工录入运单号(TaskProgressPanel):驳回 / 匹配入库共用 */
|
||
.task-panel {
|
||
display: flex;
|
||
flex-direction: column;
|
||
max-height: calc(100vh - 96px);
|
||
background: #fff;
|
||
color: #303133;
|
||
|
||
&__head {
|
||
display: flex;
|
||
align-items: flex-start;
|
||
gap: 12px;
|
||
padding: 16px;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
&__titles {
|
||
flex: 1;
|
||
min-width: 0;
|
||
|
||
h2 {
|
||
margin: 0;
|
||
font-size: 18px;
|
||
line-height: 24px;
|
||
font-weight: 400;
|
||
color: #303133;
|
||
}
|
||
|
||
p {
|
||
margin: 4px 0 0;
|
||
font-size: 12px;
|
||
line-height: 18px;
|
||
color: #909399;
|
||
}
|
||
}
|
||
|
||
&__close {
|
||
width: 24px;
|
||
height: 24px;
|
||
flex: none;
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
border: none;
|
||
border-radius: 4px;
|
||
background: transparent;
|
||
color: #909399;
|
||
cursor: pointer;
|
||
transition: color 0.2s;
|
||
|
||
svg {
|
||
width: 12px;
|
||
height: 12px;
|
||
}
|
||
|
||
&:hover {
|
||
color: #409eff;
|
||
}
|
||
}
|
||
|
||
&__body {
|
||
flex: 1;
|
||
min-height: 0;
|
||
padding: 12px 16px 0;
|
||
display: flex;
|
||
flex-direction: column;
|
||
}
|
||
|
||
&__section-title {
|
||
font-size: 12px;
|
||
line-height: 20px;
|
||
color: #606266;
|
||
padding-left: 2px;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
&__table-wrap {
|
||
flex: 1;
|
||
min-height: 0;
|
||
border-radius: 4px;
|
||
overflow: hidden;
|
||
|
||
:deep(.el-table) {
|
||
height: 100%;
|
||
}
|
||
}
|
||
|
||
&__form {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 8px;
|
||
}
|
||
|
||
&__field {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
gap: 16px;
|
||
min-height: 40px;
|
||
padding: 8px 12px;
|
||
border: 1px solid #ebeef5;
|
||
border-radius: 4px;
|
||
background: #fafafa;
|
||
|
||
/* 驳回理由输入行:不需要灰色容器,与上方静态信息行拉开层次 */
|
||
&--input {
|
||
align-items: center;
|
||
min-height: 0;
|
||
/* 左 12px 与上方标签对齐;右 0 让输入框右边顶到灰色容器右边缘 */
|
||
padding: 4px 0 0 12px;
|
||
border: none;
|
||
border-radius: 0;
|
||
background: transparent;
|
||
|
||
.el-input,
|
||
.el-textarea {
|
||
flex: 1;
|
||
min-width: 0;
|
||
}
|
||
}
|
||
|
||
&--textarea {
|
||
align-items: flex-start;
|
||
|
||
.task-panel__field-label {
|
||
padding-top: 7px;
|
||
}
|
||
}
|
||
}
|
||
|
||
&__field-label {
|
||
font-size: 12px;
|
||
line-height: 20px;
|
||
color: #606266;
|
||
flex-shrink: 0;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
&__field-value {
|
||
font-size: 13px;
|
||
font-weight: 500;
|
||
color: #303133;
|
||
text-align: right;
|
||
}
|
||
|
||
&__form-tip {
|
||
margin: 8px 0 0;
|
||
padding: 8px 12px;
|
||
border-radius: 4px;
|
||
background: #f4f4f5;
|
||
font-size: 12px;
|
||
line-height: 18px;
|
||
color: #909399;
|
||
}
|
||
|
||
&__foot {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
gap: 12px;
|
||
padding: 12px 16px 16px;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
&__hint {
|
||
font-size: 12px;
|
||
color: #909399;
|
||
}
|
||
|
||
&__actions {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 8px;
|
||
|
||
:deep(.el-button) {
|
||
margin-left: 0;
|
||
margin-right: 0;
|
||
}
|
||
}
|
||
}
|
||
</style>
|
||
|
||
<style lang="scss">
|
||
/* append-to-body 弹窗内状态文字颜色(scoped 对 teleport 内容不生效,需全局类) */
|
||
.ut-status-text {
|
||
font-size: 12px;
|
||
line-height: 18px;
|
||
white-space: nowrap;
|
||
}
|
||
.ut-status-text--primary { color: var(--el-color-primary); }
|
||
.ut-status-text--success { color: var(--el-color-success); }
|
||
.ut-status-text--warning { color: var(--el-color-warning); }
|
||
.ut-status-text--info { color: var(--el-color-info); }
|
||
.ut-status-text--danger { color: var(--el-color-danger); }
|
||
|
||
/* el-dialog 会被 append 到 body:去掉默认头/内边距,统一交给面板(同手工录入运单号) */
|
||
.el-dialog.reject-receiving-dialog,
|
||
.el-dialog.match-putaway-dialog-shell {
|
||
padding: 0;
|
||
overflow: hidden;
|
||
|
||
.el-dialog__header {
|
||
display: none;
|
||
}
|
||
|
||
.el-dialog__body {
|
||
padding: 0;
|
||
}
|
||
}
|
||
</style> |