This commit is contained in:
yin 2026-07-23 18:23:55 +08:00
parent 99dd76a1ab
commit ae76229068
8 changed files with 761 additions and 334 deletions

View File

@ -1,5 +1,5 @@
<template>
<div class="external-stock-container">
<div class="order-sub-container">
<scan-box
ref="scanBox"
width="250px"
@ -13,33 +13,14 @@
<div class="main-content">
<div class="toolbar">
<div class="toolbar-left">
<el-button size="small" @click="loadList">
<el-icon><Refresh /></el-icon> 刷新
</el-button>
<el-button size="small" plain @click="tableRef?.openColumnConfig?.()">字段设置</el-button>
<el-divider direction="vertical" />
<el-dropdown
trigger="click"
@command="handleExportCommand"
>
<el-button
size="small"
type="primary"
:loading="exportLoading"
>
导出<el-icon class="el-icon--right"><ArrowDown /></el-icon>
</el-button>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item command="selected" :disabled="!hasSelection">
导出选中
</el-dropdown-item>
<el-dropdown-item command="all" :divided="true">
导出全部
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
<order-toolbar-button-group
:buttons="toolbarButtons"
:resolve-disabled="resolveButtonDisabled"
:resolve-loading="resolveButtonLoading"
:resolve-label="resolveButtonLabel"
:layout-key="toolbarLayoutKey"
@action="handleToolbarButtonClick"
/>
</div>
</div>
@ -53,7 +34,7 @@
</div> -->
<div class="split-stack" ref="splitStackRef">
<div class="upper-wrapper" :style="upperPaneStyle">
<div class="upper-wrapper" :style="detailVisible ? upperPaneStyle : upperPaneFullStyle">
<upper-table
ref="tableRef"
default-align="center"
@ -118,13 +99,14 @@
</upper-table>
</div>
<div
class="pane-resizer"
title="拖动调整列表与详情区域高度"
@mousedown="beginSplitDrag"
/>
<template v-if="detailVisible">
<div
class="pane-resizer"
title="拖动调整列表与详情区域高度"
@mousedown="beginSplitDrag"
/>
<div class="lower-level" v-if="selectedRow" :style="lowerPaneStyle">
<div class="lower-level" v-if="selectedRow" :style="lowerPaneStyle">
<div class="detail-header">
<el-tabs v-model="activeTab" class="detail-tab">
<el-tab-pane label="基本信息" name="info" />
@ -211,9 +193,12 @@
</el-descriptions>
</div>
</div>
<div class="lower-level empty" v-else :style="lowerPaneStyle">
<el-empty description="请选择数据查看详情" :image-size="60" />
<div class="no-selection" v-else :style="lowerPaneStyle">
<div class="empty-tip">
<p>请从上方列表中选择一项查看详情</p>
</div>
</div>
</template>
</div><!-- .split-stack -->
</div>
@ -264,7 +249,6 @@
<script setup lang="ts">
import { ref, reactive, onMounted, computed } from 'vue'
import { ElMessage } from 'element-plus'
import { Refresh, ArrowDown } from '@element-plus/icons-vue'
import { stockWarehouseExternalList, stockWarehouseExternalExport, getExportTaskProgress, saveWarehouseStock, type StockWarehouseListSort } from '@/api/stock/stock'
import { getImages } from '@/api/index/index'
import ScanBox from '@/components/ScanBox/index.vue'
@ -273,6 +257,8 @@ import WarehouseSelect from '@/components/WarehouseSelect.vue'
import ErpStock from '@/views/stock/stock/component/erpStock.vue'
import Log from '@/views/stock/stock/component/log.vue'
import AsyncExportProgressDialog from '@/components/AsyncExportProgressDialog.vue'
import OrderToolbarButtonGroup from '@/views/order/orderManagement/component/OrderToolbarButtonGroup.vue'
import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config'
import { useAsyncExportTask } from '@/composables/useAsyncExportTask'
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
@ -327,7 +313,7 @@ const availableFields: any[] = [
group: '基础信息'
},
{
label: '货物编码',
label: '条码',
value: 'goods_code',
type: 'text',
group: '基础信息'
@ -504,14 +490,6 @@ async function handleExportSelected() {
await submitExportTask(buildExportSelectedPayload())
}
function handleExportCommand(command: string) {
if (command === 'selected') {
handleExportSelected()
} else if (command === 'all') {
handleExportAll()
}
}
// ─── 上下分栏拖动 ──────────────────────────────────────────────────────────
const { splitStackRef, beginSplitDrag, lowerPaneStyle, upperPaneStyle } = useVerticalSplitPane({
defaultLowerPercent: 35,
@ -519,6 +497,96 @@ const { splitStackRef, beginSplitDrag, lowerPaneStyle, upperPaneStyle } = useVer
maxLowerPercent: 70
})
const detailVisible = ref(true)
const upperPaneFullStyle = computed(() => ({
flex: '1 1 auto',
minHeight: '0',
overflow: 'hidden'
}))
function toggleDetailVisible() {
detailVisible.value = !detailVisible.value
}
// ─── 工具栏按钮配置 ────────────────────────────────────────────────────────
const toolbarButtons = computed<ToolbarButtonConfig[]>(() => [
{
key: 'refresh',
label: '刷新',
size: 'small',
action: 'handleRefresh'
},
{
key: 'columnConfig',
label: '字段设置',
size: 'small',
action: 'openColumnConfigPanel'
},
{
key: 'export',
label: '导出',
size: 'small',
loadingKey: 'exportLoading',
action: 'handleExportAll',
buttonType: 'dropdown',
dropdownOptions: [
{ label: '导出选中', action: 'handleExportSelected' },
{ label: '导出全部', action: 'handleExportAll', divided: true }
]
},
{
key: 'toggleDetail',
label: '显示详情',
dynamicLabelKey: 'detailToggleLabel',
size: 'small',
action: 'toggleDetailVisible'
}
])
const buttonLoadingMap = computed(() => ({
exportLoading: exportLoading.value
}))
const buttonLabelMap = computed(() => ({
detailToggleLabel: detailVisible.value ? '隐藏详情' : '显示详情'
}))
const toolbarLayoutKey = computed(() =>
JSON.stringify({
loading: buttonLoadingMap.value,
labels: buttonLabelMap.value,
permissions: toolbarButtons.value.map((button) => button.key).join(',')
})
)
function resolveButtonLoading(loadingKey?: string) {
if (!loadingKey) return false
return Boolean((buttonLoadingMap.value as Record<string, boolean>)[loadingKey])
}
function resolveButtonDisabled(_disabledKey?: string) {
return false
}
function resolveButtonLabel(defaultLabel: string, dynamicLabelKey?: string) {
if (!dynamicLabelKey) return defaultLabel
return (buttonLabelMap.value as Record<string, string>)[dynamicLabelKey] || defaultLabel
}
const toolbarActionMap: Record<string, () => void> = {
handleRefresh: () => loadList(),
openColumnConfigPanel: () => tableRef.value?.openColumnConfig?.(),
handleExportAll: () => handleExportAll(),
handleExportSelected: () => handleExportSelected(),
toggleDetailVisible: () => toggleDetailVisible()
}
function handleToolbarButtonClick(action: ToolbarButtonConfig['action']) {
const handler = toolbarActionMap[action]
if (!handler) return
handler()
}
// ─── 特殊字段键(不作为 where 条件,需要单独提取)──────────────────────
const SPECIAL_KEYS = ['keyword', 'warehouse_id']
@ -721,134 +789,51 @@ onMounted(() => {
</script>
<style scoped lang="scss">
.external-stock-container {
@use "../../order/orderManagement/styles/order-sub.scss";
.order-sub-container .main-content .lower-level .detail-container {
padding: 10px;
overflow: auto;
}
.empty-tip {
text-align: center;
font-size: 13px;
line-height: 1.5;
padding: 40px 0;
color: #909399;
}
.table-thumb {
width: 48px;
height: 48px;
border-radius: 4px;
border: 1px solid #ebeef5;
cursor: pointer;
vertical-align: middle;
}
.sku-text {
font-size: 12px;
}
.image-gallery {
display: flex;
height: 100%;
flex-wrap: wrap;
gap: 8px;
.main-content {
flex: 1;
display: flex;
flex-direction: column;
min-width: 0;
padding: 12px;
overflow: hidden;
}
.toolbar {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10px;
flex-shrink: 0;
gap: 12px;
&-left {
display: flex;
align-items: center;
gap: 6px;
}
}
.upper-wrapper {
flex: 1;
min-height: 0;
overflow: hidden;
}
.split-stack {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
overflow: hidden;
.pane-resizer {
flex: 0 0 6px;
min-height: 6px;
background: #e4e7ed;
cursor: row-resize;
flex-shrink: 0;
position: relative;
z-index: 2;
&:hover {
background: #dcdfe6;
}
}
}
.summary-bar {
display: flex;
align-items: center;
gap: 12px;
padding: 8px 12px;
margin-bottom: 8px;
background: #f0f9eb;
border-radius: 4px;
font-size: 13px;
color: #606266;
flex-shrink: 0;
b {
color: #303133;
font-weight: 600;
}
.summary-divider {
color: #dcdfe6;
}
}
.table-thumb {
width: 48px;
height: 48px;
.gallery-image {
width: 100px;
height: 100px;
border-radius: 4px;
border: 1px solid #ebeef5;
cursor: pointer;
vertical-align: middle;
}
.sku-text {
font-size: 12px;
}
.lower-level {
border: 1px solid #ebeef5;
border-radius: 4px;
display: flex;
flex-direction: column;
overflow: hidden;
&.empty {
border: none;
}
.detail-header {
padding: 0 12px;
border-bottom: 1px solid #ebeef5;
flex-shrink: 0;
}
.detail-container {
padding: 12px;
overflow: auto;
flex: 1;
min-height: 0;
.image-gallery {
display: flex;
flex-wrap: wrap;
gap: 8px;
.gallery-image {
width: 100px;
height: 100px;
border-radius: 4px;
border: 1px solid #ebeef5;
cursor: pointer;
}
}
}
}
}
.erp-stock-wrapper,
.log-wrapper {
height: 100%;
overflow: auto;
}
</style>

View File

@ -346,11 +346,22 @@ async function loadBindingData() {
throw new Error('入库单数据为空')
}
const bindings = Array.isArray(entryOrder.receivingBindings) ? entryOrder.receivingBindings : []
receivingBindings.value = bindings.map(mapReceivingBindingRow)
itemBindingRows.value = buildItemBindingRows(
Array.isArray(entryOrder.items) ? entryOrder.items : []
)
// items / receivingBindings 与 entryOrder 平级(都在 res.data 下),
// 优先从 res.data 取,兜底从 entryOrder 内部取
const data = (res.data && typeof res.data === 'object') ? res.data as Record<string, unknown> : {}
const bindings = Array.isArray(data.receivingBindings)
? data.receivingBindings
: Array.isArray(entryOrder.receivingBindings)
? entryOrder.receivingBindings
: []
const items = Array.isArray(data.items)
? data.items
: Array.isArray(entryOrder.items)
? entryOrder.items
: []
receivingBindings.value = (bindings as EntryOrderReceivingBinding[]).map(mapReceivingBindingRow)
itemBindingRows.value = buildItemBindingRows(items as EntryDetailItem[])
} catch (error) {
console.error('获取绑定关系失败:', error)
ElMessage.error('获取绑定关系失败')

View File

@ -0,0 +1,292 @@
<template>
<el-dialog
:model-value="visible"
title="收货绑定详情"
width="900px"
:close-on-click-modal="false"
@update:model-value="$emit('update:visible', $event)"
@closed="handleClosed"
align-center
>
<div v-loading="loading" class="binding-detail-content">
<el-tabs v-model="activeTab" type="card">
<el-tab-pane
v-for="(item, index) in detailList"
:key="item.receivingId"
:label="item.receivingNumber"
:name="String(index)"
>
<div class="receiving-info-section">
<div class="section-title">收货单信息</div>
<el-descriptions :column="3" size="small" border>
<el-descriptions-item label="收货单号">{{ item.receivingNumber }}</el-descriptions-item>
<el-descriptions-item label="收货单状态">
<el-tag size="small" :type="getReceivingStatusTag(item.status)">{{ item.statusLabel }}</el-tag>
</el-descriptions-item>
<el-descriptions-item label="创建时间">{{ item.createdAt }}</el-descriptions-item>
<el-descriptions-item label="供应商">{{ item.supplierName || '—' }}</el-descriptions-item>
<el-descriptions-item label="运单号">{{ item.expressCode || '—' }}</el-descriptions-item>
<el-descriptions-item label="备注">{{ item.remark || '—' }}</el-descriptions-item>
</el-descriptions>
</div>
<div class="product-detail-section">
<div class="section-title">
商品明细
<span class="section-count">共 {{ item.details.length }} 条</span>
</div>
<el-table
:data="item.details"
border
stripe
size="small"
row-key="id"
empty-text="暂无商品明细"
max-height="360"
>
<el-table-column prop="product_code" label="商品编码" width="140" show-overflow-tooltip />
<el-table-column prop="product_name" label="商品名称" min-width="160" show-overflow-tooltip />
<el-table-column prop="sku_property" label="规格" width="120" show-overflow-tooltip />
<el-table-column prop="planned_quantity" label="计划数量" width="90" align="right" />
<el-table-column prop="actual_quantity" label="实收数量" width="90" align="right" />
<el-table-column prop="unit" label="单位" width="70" align="center" />
<el-table-column prop="batch_number" label="批次号" width="130" show-overflow-tooltip />
<el-table-column prop="production_date" label="生产日期" width="110" align="center">
<template #default="{ row }">
{{ formatDateCell(row.production_date) }}
</template>
</el-table-column>
<el-table-column prop="expiry_date" label="过期日期" width="110" align="center">
<template #default="{ row }">
{{ formatDateCell(row.expiry_date) }}
</template>
</el-table-column>
<el-table-column prop="status" label="状态" width="90" align="center">
<template #default="{ row }">
<el-tag size="small" :type="getDetailStatusTag(row.status)">{{ row.statusLabel || row.status || '—' }}</el-tag>
</template>
</el-table-column>
</el-table>
</div>
</el-tab-pane>
</el-tabs>
<div v-if="!detailList.length && !loading" class="empty-state">暂无可显示的收货绑定数据</div>
</div>
<template #footer>
<el-button size="small" @click="handleClose">关闭</el-button>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import { ref, watch } from 'vue'
import { getReceivingDetail } from '@/api/storage_receiving/receiving'
import { formatDateTime } from '@/views/storage/receiving/receiving-config'
interface ReceivingDetailItem {
receivingId: number | string
receivingNumber: string
status: string
statusLabel: string
createdAt: string
supplierName: string
expressCode: string
remark: string
details: Record<string, unknown>[]
}
const props = defineProps<{
visible: boolean
receivingBindings?: unknown[]
}>()
const emit = defineEmits<{
'update:visible': [value: boolean]
}>()
const loading = ref(false)
const activeTab = ref('0')
const detailList = ref<ReceivingDetailItem[]>([])
const receivingStatusOptions: Record<string, string> = {
CREATED: '已创建',
PENDING: '待收货',
RECEIVING: '收货中',
PARTIAL: '部分收货',
COMPLETED: '已完成',
CANCELLED: '已作废',
}
function getReceivingStatusTag(status: string): string {
const map: Record<string, string> = {
CREATED: 'info',
PENDING: 'warning',
RECEIVING: 'primary',
PARTIAL: 'primary',
COMPLETED: 'success',
CANCELLED: 'danger',
}
return map[status?.toUpperCase()] || 'info'
}
function getDetailStatusTag(status: string): string {
const map: Record<string, string> = {
PENDING: 'info',
RECEIVED: 'success',
PARTIAL: 'warning',
CANCELLED: 'danger',
}
return map[status?.toUpperCase()] || 'info'
}
function formatDateCell(value: unknown): string {
if (!value) return '—'
const str = String(value)
// 仅取日期部分
if (str.length >= 10) return str.substring(0, 10)
return str
}
function normalizeDetailRow(raw: Record<string, unknown>): Record<string, unknown> {
// 收货明细 API (storage.receiving.getReceivingDetail) 返回的字段名:
// barcode / product_name / actual_quantity / batch_number / production_date / expiry_date / storage_status 等
return {
id: raw.id,
product_code: raw.barcode ?? raw.product_code ?? raw.item_code ?? '—',
product_name: raw.product_name ?? raw.item_name ?? '—',
sku_property: raw.sku_property ?? raw.spec ?? '',
planned_quantity: raw.planned_quantity ?? raw.plan_quantity ?? raw.quantity ?? 0,
actual_quantity: raw.actual_quantity ?? raw.received_quantity ?? 0,
unit: raw.unit ?? raw.stock_unit ?? '',
batch_number: raw.batch_number ?? '',
production_date: raw.production_date ?? '',
expiry_date: raw.expiry_date ?? '',
status: raw.status ?? raw.storage_status ?? raw.detail_status ?? '',
statusLabel: raw.status_label ?? '',
}
}
async function fetchReceivingDetail(binding: Record<string, unknown>): Promise<ReceivingDetailItem | null> {
const receivingId = binding.receiving_id as number | string
if (!receivingId) return null
try {
const res = await getReceivingDetail({
id: Number(receivingId),
pagination: { page: 1, pageSize: 500 },
})
if (res?.code !== 200) return null
const receivingData = (res.data?.receiving ?? {}) as Record<string, unknown>
const rawDetails = Array.isArray(receivingData.details)
? receivingData.details
: Array.isArray(res.data?.list)
? res.data.list
: Array.isArray(res.data?.details)
? res.data.details
: []
const status = String(receivingData.status ?? receivingData.receiving_status ?? '')
const statusUpper = status.toUpperCase()
return {
receivingId,
receivingNumber: String(
receivingData.receiving_number ?? binding.receiving_number ?? `#${receivingId}`
),
status: statusUpper,
statusLabel: receivingStatusOptions[statusUpper] || status || '—',
createdAt: receivingData.created_at
? formatDateTime(String(receivingData.created_at))
: '—',
supplierName: String(receivingData.supplier_name ?? ''),
expressCode: String(receivingData.express_code ?? receivingData.waybill_code ?? ''),
remark: String(receivingData.remark ?? ''),
details: rawDetails.map(normalizeDetailRow),
}
} catch (e) {
console.error(`获取收货单 ${receivingId} 详情失败:`, e)
return null
}
}
async function loadAllDetails() {
const bindings = props.receivingBindings
if (!Array.isArray(bindings) || bindings.length === 0) {
detailList.value = []
return
}
loading.value = true
try {
const results = await Promise.all(
bindings.map((b) => fetchReceivingDetail(b as Record<string, unknown>))
)
detailList.value = results.filter(Boolean) as ReceivingDetailItem[]
activeTab.value = '0'
} catch (e) {
console.error('加载收货绑定详情失败:', e)
detailList.value = []
} finally {
loading.value = false
}
}
function handleClose() {
emit('update:visible', false)
}
function handleClosed() {
detailList.value = []
activeTab.value = '0'
}
watch(
() => props.visible,
(newVal) => {
if (newVal) {
void loadAllDetails()
}
},
{ immediate: false },
)
</script>
<style scoped lang="scss">
.binding-detail-content {
min-height: 300px;
}
.receiving-info-section,
.product-detail-section {
margin-bottom: 16px;
}
.section-title {
font-size: 14px;
font-weight: 600;
color: #303133;
margin-bottom: 10px;
padding-left: 4px;
border-left: 3px solid var(--el-color-primary);
}
.section-count {
font-size: 12px;
font-weight: 400;
color: #909399;
margin-left: 8px;
}
.empty-state {
display: flex;
justify-content: center;
align-items: center;
min-height: 200px;
color: #909399;
font-size: 14px;
}
</style>

View File

@ -78,13 +78,22 @@
</template>
<template #column-hasReceiving="{ row }">
<el-tag size="small" :type="getEntryHasReceivingTagType(row.hasReceiving, row)">
<el-tag
size="small"
:type="getEntryHasReceivingTagType(row.hasReceiving, row)"
:class="{ 'clickable-tag': resolveEntryHasReceiving(row) }"
@click.stop="openReceivingBindingsDialog(row)"
>
{{ formatEntryHasReceiving(row.hasReceiving, row) }}
</el-tag>
</template>
<template #column-receivingBindings="{ row }">
<span :title="formatReceivingBindingsSummary(row.receivingBindings)">
<span
class="receiving-bindings-cell"
:title="'点击复制收货单号\n' + formatReceivingBindingsSummary(row.receivingBindings)"
@click.stop="copyReceivingBindings(row)"
>
{{ formatReceivingBindingsSummary(row.receivingBindings) }}
</span>
</template>
@ -220,6 +229,12 @@
@success="handleBindDialogSuccess"
/>
<!-- 收货绑定详情弹窗 -->
<ReceivingBindingDetailDialog
v-model:visible="receivingBindingsDialogVisible"
:receiving-bindings="receivingBindingsDialogData"
/>
<!-- 新建入库单对话框 -->
<el-dialog
v-model="createDialogVisible"
@ -366,6 +381,7 @@ import {
formatEntryHasReceiving,
formatReceivingBindingsSummary,
getEntryHasReceivingTagType,
resolveEntryHasReceiving,
translateEntryField,
buildEntryPrintFormData
} from './entry-config'
@ -374,6 +390,7 @@ import entrydetail from './component/entrydetail.vue'
import log from './component/log.vue'
import entryoperate from './component/entryoperate.vue'
import BindReceivingToEntryDialog from './component/BindReceivingToEntryDialog.vue'
import ReceivingBindingDetailDialog from './component/ReceivingBindingDetailDialog.vue'
import DirectInboundLogs from './component/DirectInboundLogs.vue'
import EntryBindingRelations from './component/EntryBindingRelations.vue'
import BatchReceivingPrintDialog from '@/components/BatchReceivingPrintDialog.vue'
@ -526,6 +543,10 @@ const selectedRow = computed(() => {
const bindDialogVisible = ref(false)
const bindTargetRow = ref<any>(null)
// 收货绑定详情弹窗
const receivingBindingsDialogVisible = ref(false)
const receivingBindingsDialogData = ref<any[]>([])
const reviewDialogVisible = ref(false)
const reviewTargetRow = ref<any>(null)
const reviewSubmitting = ref(false)
@ -562,6 +583,16 @@ function openBindDialog(row: any) {
bindDialogVisible.value = true
}
function openReceivingBindingsDialog(row: any) {
const bindings = row?.receivingBindings
if (!Array.isArray(bindings) || bindings.length === 0) {
ElMessage.info('该入库单暂无绑定的收货单')
return
}
receivingBindingsDialogData.value = bindings
receivingBindingsDialogVisible.value = true
}
function handleBindDialogClosed() {
bindTargetRow.value = null
}
@ -724,6 +755,50 @@ async function copySyncMessage(row: any) {
}
}
/** 提取收货单号列表(供复制) */
function getReceivingNumbers(bindings: unknown): string[] {
if (!Array.isArray(bindings) || !bindings.length) return []
return bindings
.map((item) => {
const binding = item as Record<string, unknown>
const receiving = (binding.receiving ?? {}) as Record<string, unknown>
const number = receiving.receiving_number ?? binding.receiving_number
return number ? String(number) : ''
})
.filter(Boolean)
}
async function copyReceivingBindings(row: any) {
const numbers = getReceivingNumbers(row?.receivingBindings)
if (!numbers.length) {
ElMessage.warning('该入库单暂无绑定的收货单')
return
}
const text = numbers.join('\n')
try {
if (navigator.clipboard?.writeText) {
await navigator.clipboard.writeText(text)
} else {
throw new Error('no clipboard api')
}
ElMessage.success(`已复制 ${numbers.length} 个收货单号`)
} catch {
try {
const ta = document.createElement('textarea')
ta.value = text
ta.style.position = 'fixed'
ta.style.opacity = '0'
document.body.appendChild(ta)
ta.select()
document.execCommand('copy')
document.body.removeChild(ta)
ElMessage.success(`已复制 ${numbers.length} 个收货单号`)
} catch {
ElMessage.error('复制失败,请手动选择文本复制')
}
}
}
onMounted(() => {
// 先加载筛选相关数据(例如 store options、presetTree),保证 ScanBox options 可用
loadFilterData()
@ -1208,4 +1283,18 @@ function handleImport() {
.sync-message--success {
color: var(--el-color-success);
}
.clickable-tag {
cursor: pointer;
}
.receiving-bindings-cell {
cursor: pointer;
color: var(--el-color-primary);
text-decoration: none;
}
.receiving-bindings-cell:hover {
text-decoration: underline;
color: var(--el-color-primary-light-3);
}
</style>

View File

@ -1,11 +1,16 @@
import {
scanWorkflowField,
type ToolbarButtonConfig
} from '@/views/order/orderManagement/config/order-common-config'
/** ScanBox 基础信息分组(对齐待处理订单排版) */
export const RECEIVING_SCAN_BASIC_INFO_GROUP = '基础信息'
/** ScanBox 流程状态分组 */
export const RECEIVING_SCAN_WORKFLOW_GROUP = '流程状态'
/** ScanBox 时间分组 */
export const RECEIVING_SCAN_TIME_GROUP = '时间'
/** 为收货 ScanBox 基础信息字段附加分组标签 */
export type ReceivingScanFieldConfig = Record<string, any> & {
group: string
@ -19,6 +24,14 @@ export function receivingScanBasicField(field: Record<string, any>): ReceivingSc
return { ...field, group: RECEIVING_SCAN_BASIC_INFO_GROUP } as ReceivingScanFieldConfig
}
export function receivingScanWorkflowField(field: Record<string, any>): ReceivingScanFieldConfig {
return { ...field, group: RECEIVING_SCAN_WORKFLOW_GROUP } as ReceivingScanFieldConfig
}
export function receivingScanTimeField(field: Record<string, any>): ReceivingScanFieldConfig {
return { ...field, group: RECEIVING_SCAN_TIME_GROUP } as ReceivingScanFieldConfig
}
/** ScanBox 默认 props(与波次模块 scan-box 侧栏一致) */
export const receivingScanBoxConfig = {
width: '250px',
@ -178,6 +191,7 @@ export const receivingStoreColumns = [
// receiving配置(基础信息在前,流程状态在后;对齐待处理订单 ScanBox 分组)
export const availableFields: ReceivingScanFieldConfig[] = [
// ── 基础信息 ──
receivingScanBasicField({
value: 'receiving_number',
label: '收货单号',
@ -258,34 +272,6 @@ export const availableFields: ReceivingScanFieldConfig[] = [
operators: numberConfig.operators,
defaultOperator: numberConfig.defaultOperator
}),
receivingScanBasicField({
value: 'created_at',
label: '创建时间',
type: 'daterange',
startPlaceholder: '开始时间',
endPlaceholder: '结束时间'
}),
receivingScanBasicField({
value: 'updated_at',
label: '更新时间',
type: 'daterange',
startPlaceholder: '开始时间',
endPlaceholder: '结束时间'
}),
receivingScanBasicField({
value: 'receiving_start_time',
label: '收货开始时间',
type: 'daterange',
startPlaceholder: '开始时间',
endPlaceholder: '结束时间'
}),
receivingScanBasicField({
value: 'receiving_end_time',
label: '收货结束时间',
type: 'daterange',
startPlaceholder: '开始时间',
endPlaceholder: '结束时间'
}),
receivingScanBasicField({
value: 'creator_id',
label: '创建人',
@ -310,20 +296,21 @@ export const availableFields: ReceivingScanFieldConfig[] = [
operators: ['eq', 'contains'],
defaultOperator: 'eq'
}),
// 流程/状态(每项独立分组,对齐待处理订单 scanWorkflowField 排版)
scanWorkflowField({
// ── 流程状态 ──
receivingScanWorkflowField({
value: 'status',
label: '收货状态',
type: 'select',
options: Object.entries(statusConfig).map(([v, c]) => ({ value: v, label: c.text }))
}) as ReceivingScanFieldConfig,
scanWorkflowField({
}),
receivingScanWorkflowField({
value: 'detail_status',
label: '匹配状态',
type: 'select',
options: Object.entries(detailStatusConfig).map(([v, c]) => ({ value: v, label: c.text }))
}) as ReceivingScanFieldConfig,
scanWorkflowField({
}),
receivingScanWorkflowField({
value: 'storage_status',
label: '入库状态',
type: 'select',
@ -333,8 +320,8 @@ export const availableFields: ReceivingScanFieldConfig[] = [
{ value: 'partial', label: '部分入库' },
{ value: 'all', label: '已入库' }
]
}) as ReceivingScanFieldConfig,
scanWorkflowField({
}),
receivingScanWorkflowField({
value: 'is_review',
label: '审核状态',
type: 'select',
@ -343,7 +330,37 @@ export const availableFields: ReceivingScanFieldConfig[] = [
{ value: 0, label: '未审核' },
{ value: 1, label: '已审核' }
]
}) as ReceivingScanFieldConfig,
}),
// ── 时间 ──
receivingScanTimeField({
value: 'created_at',
label: '创建时间',
type: 'daterange',
startPlaceholder: '开始时间',
endPlaceholder: '结束时间'
}),
receivingScanTimeField({
value: 'updated_at',
label: '更新时间',
type: 'daterange',
startPlaceholder: '开始时间',
endPlaceholder: '结束时间'
}),
receivingScanTimeField({
value: 'receiving_start_time',
label: '收货开始时间',
type: 'daterange',
startPlaceholder: '开始时间',
endPlaceholder: '结束时间'
}),
receivingScanTimeField({
value: 'receiving_end_time',
label: '收货结束时间',
type: 'daterange',
startPlaceholder: '开始时间',
endPlaceholder: '结束时间'
}),
]
export const addReceving = [

View File

@ -17,38 +17,13 @@
<div class="main-content">
<div class="toolbar">
<div class="toolbar-left">
<el-button size="small" type="primary" @click="loadData">刷新</el-button>
<el-dropdown
trigger="click"
@command="handleExportCommand"
>
<el-button
size="small"
type="primary"
plain
:loading="exportLoading"
>
导出<el-icon class="el-icon--right"><ArrowDown /></el-icon>
</el-button>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item command="selected" :disabled="!hasSelection">
导出选中
</el-dropdown-item>
<el-dropdown-item command="all" :divided="true">
导出全部
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
<el-button size="small" @click="openColumnConfigPanel">字段设置</el-button>
<el-button size="small" @click="toggleDetailVisible">{{ detailVisible ? '隐藏详情' : '显示详情' }}</el-button>
</div>
<div class="toolbar-right">
<WarehouseSelect
v-model="selectedWarehouseId"
@change="handleWarehouseChange"
<order-toolbar-button-group
:buttons="toolbarButtons"
:resolve-disabled="resolveButtonDisabled"
:resolve-loading="resolveButtonLoading"
:resolve-label="resolveButtonLabel"
:layout-key="toolbarLayoutKey"
@action="handleToolbarButtonClick"
/>
</div>
</div>
@ -82,6 +57,12 @@
</el-tag>
</template>
<template #column-detail_status="{ row }">
<el-tag v-if="row.detail_status" :type="detailStatusTagType(row.detail_status)" size="small">
{{ detailStatusText(row.detail_status) }}
</el-tag>
</template>
<template #column-storage_status="{ row }">
<el-tag v-if="row.storage_status" :type="storageStatusTagType(row.storage_status)" size="small">
{{ storageStatusText(row.storage_status) }}
@ -165,11 +146,12 @@
import { ref, reactive, onMounted, computed } from 'vue'
import { useRoute } from 'vue-router'
import { ElMessage } from 'element-plus'
import { ArrowDown } from '@element-plus/icons-vue'
import ScanBox from '@/components/ScanBox/index.vue'
import UpperTable from '@/components/UpperTable/index.vue'
import WarehouseSelect from '@/components/WarehouseSelect.vue'
import AsyncExportProgressDialog from '@/components/AsyncExportProgressDialog.vue'
import OrderToolbarButtonGroup from '@/views/order/orderManagement/component/OrderToolbarButtonGroup.vue'
import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config'
import { useAsyncExportTask } from '@/composables/useAsyncExportTask'
import * as indexApi from '@/api/index/index'
import * as receivingApi from '@/api/storage_receiving/receiving'
@ -177,6 +159,7 @@ import {
receivingStoreColumns,
availableFields,
statusConfig,
detailStatusConfig,
storageStatusConfig,
deliveryMethodConfig,
loadingMethodConfig,
@ -222,11 +205,104 @@ function openColumnConfigPanel() {
upperTable.value?.openColumnConfig?.()
}
// 货主侧:移除货主筛选项
const availableFieldsRef = reactive(
JSON.parse(JSON.stringify(availableFields)).filter((f: any) => f.value !== 'store_id')
// ─── 工具栏按钮配置 ────────────────────────────────────────────────────────
const toolbarButtons = computed<ToolbarButtonConfig[]>(() => [
{
key: 'refresh',
label: '刷新',
type: 'primary',
size: 'small',
action: 'handleRefresh'
},
{
key: 'export',
label: '导出',
size: 'small',
plain: true,
loadingKey: 'exportLoading',
action: 'handleExportAll',
buttonType: 'dropdown',
dropdownOptions: [
{ label: '导出选中', action: 'handleExportSelected' },
{ label: '导出全部', action: 'handleExportAll', divided: true }
]
},
{
key: 'columnConfig',
label: '字段设置',
size: 'small',
action: 'openColumnConfigPanel'
},
{
key: 'toggleDetail',
label: '显示详情',
dynamicLabelKey: 'detailToggleLabel',
size: 'small',
action: 'toggleDetailVisible'
}
])
const buttonLoadingMap = computed(() => ({
exportLoading: exportLoading.value
}))
const buttonLabelMap = computed(() => ({
detailToggleLabel: detailVisible.value ? '隐藏详情' : '显示详情'
}))
const toolbarLayoutKey = computed(() =>
JSON.stringify({
loading: buttonLoadingMap.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) {
return false
}
function resolveButtonLabel(defaultLabel: string, dynamicLabelKey?: string) {
if (!dynamicLabelKey) return defaultLabel
return (buttonLabelMap.value as Record<string, string>)[dynamicLabelKey] || defaultLabel
}
const toolbarActionMap: Record<string, () => void> = {
handleRefresh: () => loadData(),
handleExportAll: () => handleExportAll(),
handleExportSelected: () => handleExportSelected(),
openColumnConfigPanel: () => openColumnConfigPanel(),
toggleDetailVisible: () => toggleDetailVisible()
}
function handleToolbarButtonClick(action: ToolbarButtonConfig['action']) {
const handler = toolbarActionMap[action]
if (!handler) return
handler()
}
// 货主侧:移除货主筛选项,添加仓库筛选(插入到第一个基础信息分类中)
const availableFieldsRef = reactive((() => {
const fields = JSON.parse(JSON.stringify(availableFields)).filter((f: any) => f.value !== 'store_id')
// 在收货单号之后插入全部仓库
const idx = fields.findIndex((f: any) => f.value === 'receiving_number')
if (idx !== -1) {
fields.splice(idx + 1, 0, {
label: '全部仓库',
value: 'warehouse_id',
type: 'custom',
component: WarehouseSelect,
props: { width: '100%' },
group: '基础信息'
})
}
return fields
})())
const activeTab = ref('details')
const list = ref<any[]>([])
@ -263,9 +339,6 @@ const columns = ref(receivingStoreColumns)
const selectedReceivingId = ref<number | string | null>(null)
const currentSort = reactive({ prop: '', order: '' })
// 仓库选择
const selectedWarehouseId = ref<string | number | null>(null)
const componentMap: Record<string, any> = {
details: Details,
logs: Logs,
@ -286,6 +359,12 @@ function statusTagType(s: string) {
function statusText(s: string) {
return (statusConfig as any)[s]?.text || s || '--'
}
function detailStatusTagType(s: string) {
return (detailStatusConfig as any)[s]?.tagType || 'info'
}
function detailStatusText(s: string) {
return (detailStatusConfig as any)[s]?.text || s || '--'
}
function storageStatusTagType(s: string) {
return (storageStatusConfig as any)[s]?.tagType || 'info'
}
@ -350,11 +429,6 @@ async function loadData() {
try {
const where = currentCondition.value || normalizeToWhere(scanBox.value?.getConditions?.() || {})
// 仓库筛选
if (selectedWarehouseId.value) {
where.warehouse_id = { operator: 'eq', value: selectedWarehouseId.value, type: 'number' }
}
const params: any = {
pagination: {
page: pagination.currentPage,
@ -432,11 +506,6 @@ function handleConditionReset() {
loadData()
}
function handleWarehouseChange() {
pagination.currentPage = 1
loadData()
}
function handleRowClick(row: any) {
selectedReceivingId.value = row?.id || null
}
@ -454,9 +523,6 @@ function handlePageSizeChange(size: number) {
function buildExportPayload() {
const where = currentCondition.value || normalizeToWhere(scanBox.value?.getConditions?.() || {})
if (selectedWarehouseId.value) {
where.warehouse_id = { operator: 'eq', value: selectedWarehouseId.value, type: 'number' }
}
const payload: any = { where }
if (currentSort.prop) {
payload.sort = {
@ -474,9 +540,6 @@ function buildExportSelectedPayload() {
id: { operator: 'in', value: ids }
}
}
if (selectedWarehouseId.value) {
payload.where.warehouse_id = { operator: 'eq', value: selectedWarehouseId.value, type: 'number' }
}
return payload
}
@ -491,14 +554,6 @@ async function handleExportSelected() {
}
await submitExportTask(buildExportSelectedPayload())
}
function handleExportCommand(command: string) {
if (command === 'selected') {
handleExportSelected()
} else if (command === 'all') {
handleExportAll()
}
}
</script>
<style scoped lang="scss">

View File

@ -165,10 +165,8 @@ function normalizeReportEndDateParam(value: unknown): string | undefined {
/** ScanBox 筛选字段分组(库存报表模块专用) */
export const REPORT_SCAN_FIELD_GROUPS = {
time: '统计配置',
owner: '货主信息',
options: '统计选项',
keyword: '关键字搜索',
basic: '基础信息',
time: '时间筛选',
} as const
type ReportScanFieldGroupKey = keyof typeof REPORT_SCAN_FIELD_GROUPS
@ -189,6 +187,12 @@ export const reportScanBoxConfig = {
/** ScanBox 侧栏可用字段(与 storage.report.search 的 where 对应) */
export const reportScanBoxAvailableFields = [
reportScanField('basic', {
value: 'keyword',
label: '关键字',
type: 'text',
placeholder: '搜索商品名称/编码/条码'
}),
reportScanField('time', {
value: 'report_period',
label: '统计时间',
@ -196,7 +200,7 @@ export const reportScanBoxAvailableFields = [
startPlaceholder: '开始日期',
endPlaceholder: '结束日期'
}),
reportScanField('owner', {
reportScanField('basic', {
value: 'store_id',
label: '货主',
type: 'select',
@ -205,18 +209,12 @@ export const reportScanBoxAvailableFields = [
placeholder: '请选择货主',
options: [] as { label: string; value: number }[]
}),
reportScanField('options', {
reportScanField('basic', {
value: 'by_space',
label: '按库位统计',
type: 'boolean',
placeholder: '开启后按商品+库位+货主返回;关闭则按商品+货主聚合'
}),
reportScanField('keyword', {
value: 'keyword',
label: '关键字',
type: 'text',
placeholder: '搜索商品名称/编码/条码'
})
]
/** 将 ScanBox 条件转为接口扁平 where;无有效条件时返回 {} */
@ -284,5 +282,11 @@ export function normalizeScanConditionToReportWhere(condition: any): Record<stri
where.keyword = String(keyword).trim()
}
// 仓库筛选
const warehouseId = conds.warehouse_id?.value ?? conds.warehouse_id
if (warehouseId != null && warehouseId !== '' && warehouseId !== undefined) {
where.warehouse_id = warehouseId
}
return where
}

View File

@ -26,25 +26,6 @@
<el-tag size="small" effect="plain">出库合计 {{ formatNumber(sumOutbound) }}</el-tag>
</template>
</div>
<div class="toolbar-right">
<WarehouseSelect
v-model="selectedWarehouseId"
@change="handleWarehouseChange"
/>
<el-input
v-model="keyword"
placeholder="搜索商品名称/编码/条码"
clearable
size="small"
style="width: 240px; margin-left: 8px"
@keyup.enter="handleKeywordSearch"
@clear="handleKeywordSearch"
>
<template #prefix>
<el-icon><Search /></el-icon>
</template>
</el-input>
</div>
</div>
<div class="split-stack" ref="splitStackRef">
@ -124,7 +105,6 @@
<script setup lang="ts">
import { computed, onMounted, reactive, ref } from 'vue'
import { ElMessage } from 'element-plus'
import { Search } from '@element-plus/icons-vue'
import dayjs from 'dayjs'
import ScanBox from '@/components/ScanBox/index.vue'
import UpperTable from '@/components/UpperTable/index.vue'
@ -158,9 +138,24 @@ const scanBox = ref<any>(null)
const upperTable = ref<any>(null)
const presetTree = ref<any[]>([])
const availableFieldsRef = reactive(
JSON.parse(JSON.stringify(reportScanBoxAvailableFields)).filter((f: any) => f.value !== 'store_id' && f.value !== 'by_space')
)
const availableFieldsRef = reactive((() => {
const fields = JSON.parse(JSON.stringify(reportScanBoxAvailableFields)).filter(
(f: any) => f.value !== 'store_id' && f.value !== 'by_space'
)
// 在关键字之后插入全部仓库(基础信息分组)
const idx = fields.findIndex((f: any) => f.value === 'keyword')
if (idx !== -1) {
fields.splice(idx + 1, 0, {
label: '全部仓库',
value: 'warehouse_id',
type: 'custom',
component: WarehouseSelect,
props: { width: '100%' },
group: '基础信息'
})
}
return fields
})())
const settingsStore = useSettingsStore()
const shortcutExpanded = computed(() => settingsStore.shortcutExpanded)
@ -235,8 +230,6 @@ const currentSort = reactive<{ prop: string; order: '' | 'ascending' | 'descendi
const selectedRid = ref<string | null>(null)
const currentConditionRaw = ref<any>({})
const selectedWarehouseId = ref<string | number | null>(null)
const keyword = ref('')
const selectedRow = computed(() => fullList.value.find((r) => r.__rid === selectedRid.value) || null)
@ -320,13 +313,6 @@ function buildSortPayload(): StockReportSearchBody['sort'] | undefined {
function buildReportQueryPayload(): StockReportSearchBody {
const where = normalizeScanConditionToReportWhere(currentConditionRaw.value)
if (selectedWarehouseId.value) {
where.warehouse_id = selectedWarehouseId.value
}
// 关键字搜索
if (keyword.value.trim()) {
where.keyword = keyword.value.trim()
}
const sort = buildSortPayload()
const body: StockReportSearchBody = {}
if (Object.keys(where).length > 0) {
@ -381,26 +367,14 @@ function handleConditionChange(condition: any) {
loadData()
}
function handleWarehouseChange() {
pagination.currentPage = 1
loadData()
}
function handleConditionClear() {
currentConditionRaw.value = {}
keyword.value = ''
pagination.currentPage = 1
loadData()
}
function handleKeywordSearch() {
pagination.currentPage = 1
loadData()
}
function handleConditionReset() {
currentConditionRaw.value = {}
keyword.value = ''
pagination.currentPage = 1
if (scanBox.value?.reset) {
scanBox.value.reset()