This commit is contained in:
liufumingren 2026-07-13 02:48:04 +08:00
parent 476f6c20a1
commit 9e0b85624b
16 changed files with 1461 additions and 70 deletions

View File

@ -65,6 +65,20 @@ export function getEntryList(data: StorageEntryListParams = {}): Promise<Storage
})
}
/** storage.entry.listStore — 货主侧入库单列表(复用 list 的出入参结构) */
export function getEntryListStore(data: StorageEntryListParams = {}): Promise<StorageEntryListResponse> {
return request({
url: '/system',
method: 'post',
params: {
method: 'storage.entry.listStore',
v,
timestamp: new Date().getTime(),
},
data,
})
}
export type GetEntryDetailParams = {
/** 入库单ID(必填) */
id: number
@ -231,6 +245,20 @@ export function getEntryDetail(data: GetEntryDetailParams): Promise<GetEntryDeta
})
}
/** storage.entry.getStore — 货主侧入库单详情(复用 get 的出入参结构) */
export function getEntryDetailStore(data: GetEntryDetailParams): Promise<GetEntryDetailResponse> {
return request({
url: '/system',
method: 'post',
params: {
method: 'storage.entry.getStore',
v,
timestamp: new Date().getTime(),
},
data,
})
}
export type CancelEntryParams = {
/** 入库单ID,兼容旧调用;与 ids 二选一。若同时传入 ids,以 ids 为准 */
id?: number

View File

@ -27,6 +27,8 @@ export interface StorageReportSearchBody {
end_time?: string | Date
store_ids?: number[]
by_space?: boolean
warehouse_id?: number | string
keyword?: string
}
sort?: {
sortField?: 'begin_total' | 'inbound_total' | 'outbound_total' | 'end_total'

View File

@ -22,6 +22,20 @@ export function getReceivingList(data: any): Promise<any> {
})
}
/** storage.receiving.getStoreReceivingList — 货主侧收货单列表 */
export function getReceivingListStore(data: any): Promise<any> {
return request({
url: '/system',
method: 'post',
params: {
method: 'storage.receiving.getStoreReceivingList',
v,
timestamp: new Date().getTime()
},
data: data
})
}
export function getReceivingDetail(data: any): Promise<any> {
return request({
@ -36,6 +50,20 @@ export function getReceivingDetail(data: any): Promise<any> {
})
}
/** storage.receiving.getStore — 货主侧收货单详情 */
export function getReceivingDetailStore(data: any): Promise<any> {
return request({
url: '/system',
method: 'post',
params: {
method: 'storage.receiving.getStore',
v,
timestamp: new Date().getTime()
},
data: data
})
}
export function queryReceivingLogs(data: QueryReceivingLogsParams = {}): Promise<any> {
return request({
url: '/system',

View File

@ -0,0 +1,126 @@
<template>
<el-select
:model-value="modelValue"
:placeholder="placeholder"
:clearable="clearable"
:filterable="filterable"
:size="size"
:style="{ width }"
:disabled="disabled"
@change="handleChange"
>
<el-option
v-for="wh in warehouseList"
:key="wh.warehouse_id"
:label="wh.warehouse_name"
:value="wh.warehouse_id"
/>
</el-select>
</template>
<script setup lang="ts">
import { ref, onMounted, watch } from 'vue'
import { loadWarehouses } from '@/api/index/index'
interface WarehouseItem {
warehouse_id: string | number
warehouse_name: string
}
const props = withDefaults(
defineProps<{
/** v-model 绑定的仓库 ID */
modelValue?: string | number | null
/** localStorage 缓存 key,不传则全局共享同一个仓库选择 */
storageKey?: string
placeholder?: string
clearable?: boolean
filterable?: boolean
size?: 'small' | 'default' | 'large'
width?: string
disabled?: boolean
}>(),
{
modelValue: null,
storageKey: 'global',
placeholder: '全部仓库',
clearable: true,
filterable: true,
size: 'small',
width: '200px',
disabled: false,
},
)
const emit = defineEmits<{
'update:modelValue': [value: string | number | null]
/** 选择变更时触发(包括首次从 localStorage 恢复后自动触发) */
change: [value: string | number | null]
}>()
const storageKeyFull = `warehouse_select_${props.storageKey}`
const warehouseList = ref<WarehouseItem[]>([])
async function loadWarehouseList() {
try {
const res: any = await loadWarehouses()
const raw = res?.warehouses || res?.data?.list || res?.data || []
warehouseList.value = raw.map((item: any) => ({
warehouse_id: item.value ?? item.warehouse_id ?? item.id,
warehouse_name: item.label || item.warehouse_name || item.company_name || String(item.value ?? ''),
}))
// 列表加载完成后,尝试从 localStorage 恢复上次选择
restoreFromStorage()
} catch {
// 仓库列表加载失败不影响主流程
}
}
/** 从 localStorage 恢复选择,若有效则自动触发 change */
function restoreFromStorage() {
const cached = localStorage.getItem(storageKeyFull)
if (cached === null || cached === '') return
const cachedId: string | number = isNaN(Number(cached)) ? cached : Number(cached)
const exists = warehouseList.value.some((wh) => wh.warehouse_id === cachedId)
if (exists && props.modelValue !== cachedId) {
emit('update:modelValue', cachedId)
// 延迟一帧触发 change,确保父组件已完成初始化
requestAnimationFrame(() => {
emit('change', cachedId)
})
} else if (!exists) {
// 缓存的仓库已不存在,清除
localStorage.removeItem(storageKeyFull)
}
}
function handleChange(value: string | number | null) {
if (value !== null && value !== undefined && value !== '') {
localStorage.setItem(storageKeyFull, String(value))
} else {
localStorage.removeItem(storageKeyFull)
}
emit('update:modelValue', value)
emit('change', value)
}
// 外部通过 v-model 变更时同步到 localStorage(但不再重复触发 change)
watch(
() => props.modelValue,
(newVal) => {
if (newVal !== null && newVal !== undefined && newVal !== '') {
localStorage.setItem(storageKeyFull, String(newVal))
} else {
localStorage.removeItem(storageKeyFull)
}
},
)
onMounted(() => {
loadWarehouseList()
})
</script>

View File

@ -26,10 +26,14 @@ export const componentMap: Record<string, any> = {
'stock/pickingShortage/index': () => import('@/views/storage/management/replenishmentDemand/index.vue'),
'storage/management/replenishmentDemand/index': () => import('@/views/storage/management/replenishmentDemand/index.vue'),
'storage/receiving': () => import('@/views/storage/receiving/index.vue'),
/** 货主侧收货单管理 */
'storage/receiving_owner': () => import('@/views/storage/receiving_owner/index.vue'),
'storage/report': () => import('@/views/storage/report/index.vue'),
/** 货主侧库存报表 */
'store/report': () => import('@/views/storage/report/store.vue'),
'storage/entry': () => import('@/views/storage/entry/index.vue'),
/** 货主侧入库单管理 */
'storage/entry_owner': () => import('@/views/storage/entry_owner/index.vue'),
'storage/inventory': () => import('@/views/storage/inventory/index.vue'),
'storage/stockout': () => import('@/views/storage/stockout/index.vue'),
'store/productflow': () => import('@/views/storage/productflow/index.vue'),

View File

@ -19,22 +19,12 @@
<el-button size="small" plain @click="tableRef?.openColumnConfig?.()">字段设置</el-button>
</div>
<div class="toolbar-right">
<el-select
<WarehouseSelect
v-model="queryForm.warehouse_id"
placeholder="全部仓库"
clearable
filterable
size="small"
style="width: 200px; margin-right: 8px"
width="200px"
style="margin-right: 8px"
@change="handleWarehouseChange"
>
<el-option
v-for="wh in warehouseList"
:key="wh.warehouse_id"
:label="wh.warehouse_name"
:value="wh.warehouse_id"
/>
</el-select>
/>
<el-input
v-model="queryForm.keyword"
placeholder="搜索商品编码/名称/条码"
@ -257,9 +247,10 @@ import { ref, reactive, onMounted, watch } from 'vue'
import { ElMessage } from 'element-plus'
import { Search, Refresh } from '@element-plus/icons-vue'
import { stockWarehouseExternalList, saveWarehouseStock, type StockWarehouseListSort } from '@/api/stock/stock'
import { loadWarehouses, getImages } from '@/api/index/index'
import { getImages } from '@/api/index/index'
import ScanBox from '@/components/ScanBox/index.vue'
import UpperTable from '@/components/UpperTable/index.vue'
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 { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
@ -402,21 +393,7 @@ const { splitStackRef, beginSplitDrag, lowerPaneStyle, upperPaneStyle } = useVer
maxLowerPercent: 70
})
// ─── 仓库列表 ──────────────────────────────────────────────────────────────
const warehouseList = ref<any[]>([])
async function loadWarehouseList() {
try {
const res = await loadWarehouses() as any
const raw = res?.warehouses || res?.data?.list || res?.data || []
warehouseList.value = raw.map((item: any) => ({
warehouse_id: item.value ?? item.warehouse_id ?? item.id,
warehouse_name: item.label || item.warehouse_name || item.company_name || String(item.value ?? '')
}))
} catch {
// 仓库列表加载失败不影响主流程
}
}
// ─── 仓库列表(已由 WarehouseSelect 组件接管)───────────────────────────
function handleWarehouseChange() {
pagination.currentPage = 1
@ -607,7 +584,6 @@ async function handleEditSave() {
// ─── 初始化 ────────────────────────────────────────────────────────────────
onMounted(() => {
loadWarehouseList()
loadList()
})
</script>

View File

@ -66,6 +66,7 @@ import UpperTable from '@/components/UpperTable/index.vue'
import {
collectDirectInboundLogs,
getEntryDetail,
getEntryDetailStore,
removeItem,
type DirectInboundLog,
} from '@/api/storage.entry/entry'
@ -80,6 +81,8 @@ import {
const props = defineProps<{
id?: string | number
row?: Record<string, unknown> | null
/** 货主侧模式,使用 getEntryDetailStore 接口 */
storeMode?: boolean
}>()
const emit = defineEmits<{
@ -144,7 +147,8 @@ async function loadLogs() {
loading.value = true
try {
const res = await getEntryDetail({ id: entryId })
const fetchDetail = props.storeMode ? getEntryDetailStore : getEntryDetail
const res = await fetchDetail({ id: entryId })
if (res?.code !== 200 && res?.code !== undefined) {
throw new Error(res?.message || '获取入库记录失败')
}

View File

@ -127,6 +127,7 @@ import { computed, ref, watch, onActivated } from 'vue'
import { ElMessage } from 'element-plus'
import {
getEntryDetail,
getEntryDetailStore,
receivingCompare,
type EntryAvailableReceivingDetail,
type EntryDetailItem,
@ -181,6 +182,8 @@ const props = defineProps<{
id?: string | number
row?: Record<string, unknown> | null
entryDetailRefreshTick?: number
/** 货主侧模式,使用 getEntryDetailStore 接口 */
storeMode?: boolean
}>()
const loading = ref(false)
@ -332,7 +335,8 @@ async function loadBindingData() {
loading.value = true
try {
const res = await getEntryDetail({ id: entryOrderId })
const fetchDetail = props.storeMode ? getEntryDetailStore : getEntryDetail
const res = await fetchDetail({ id: entryOrderId })
if (!isApiSuccess(res)) {
throw new Error(res?.message || '获取绑定关系失败')
}

View File

@ -86,6 +86,7 @@ import UpperTable from '@/components/UpperTable/index.vue'
import {
commit,
getEntryDetail,
getEntryDetailStore,
type EntryDetailItem,
type EntryDetailItemBarcode,
} from '@/api/storage.entry/entry'
@ -102,6 +103,8 @@ const props = defineProps<{
row?: Record<string, unknown> | null
/** 由父级递增,用于跨 Tab 触发明细刷新 */
entryDetailRefreshTick?: number
/** 货主侧模式,使用 getEntryDetailStore 接口 */
storeMode?: boolean
}>()
const emit = defineEmits(['refresh'])
@ -213,7 +216,8 @@ async function loadEntryDetail() {
if (!props.id) return
loading.value = true
try {
const res = await getEntryDetail({ id: Number(props.id) })
const fetchDetail = props.storeMode ? getEntryDetailStore : getEntryDetail
const res = await fetchDetail({ id: Number(props.id) })
if (res && res.code === 200 && res.data?.entryOrder) {
const entryOrder = res.data.entryOrder

View File

@ -216,6 +216,29 @@ export const entryColums = [
{ prop: 'row_action', label: '操作', width: '300', fixed: 'right' },
]
/** 货主侧入库单列表列(listStore 返回字段,无 store_name / receivingBindings) */
export const entryStoreColums = [
{ prop: 'id', label: 'ID', width: '50' },
{ prop: 'entry_order_code', label: '入库单号', width: '160' },
{ prop: 'order_type', label: '类型', width: '100' },
{ prop: 'purchase_order_code', label: '单据编号', width: '160' },
{ prop: 'total_order_lines', label: '商品数', width: '80', sortable: 'custom' },
{ prop: 'order_status', label: '订单状态', width: '100' },
{ prop: 'hasReceiving', label: '收货绑定', width: '100' },
{ prop: 'sync_status', label: '入库状态', width: '100' },
{ prop: 'sync_message', label: '同步信息', minWidth: '220' },
{ prop: 'supplier_code', label: '供应商编码', width: '120' },
{ prop: 'supplier_name', label: '供应商名称', width: '140' },
{ prop: 'express_code', label: '运单号', width: '140' },
{ prop: 'logistics_code', label: '物流公司编码', width: '140' },
{ prop: 'logistics_name', label: '物流公司名称', width: '140' },
{ prop: 'order_create_time', label: '单据创建时间', width: '160' },
{ prop: 'expect_start_time', label: '预计开始时间', width: '160' },
{ prop: 'expect_end_time', label: '预计结束时间', width: '160' },
{ prop: 'source_type', label: '数据来源', width: '100' },
{ prop: 'remark', label: '备注', width: '160' },
]
const entryInventoryTypeLabelMap: Record<string, string> = {
ZP: '正品',
CC: '次品',

View File

@ -0,0 +1,632 @@
<template>
<div class="order-sub-container" :style="{ height: containerHeight }">
<scan-box
ref="scanBox"
cache-key="storage-entry-owner"
width="250px"
: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"
/>
<div class="main-content">
<div class="toolbar">
<div class="toolbar-left">
<el-button size="small" type="primary" @click="loadData">刷新</el-button>
<ExportModeDropdown :loading="exportLoading" @action="handleExportAction" />
<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"
/>
</div>
</div>
<div class="split-stack" ref="splitStackRef">
<div class="upper-wrapper" :style="detailVisible ? upperPaneStyle : upperPaneFullStyle">
<upper-table
ref="upperTable"
title="入库单列表"
default-align="center"
table-id="storage-entry-owner-list"
:enable-column-config="true"
:column-config-schema-version="2"
:data="list"
:columns="columns"
:table-size="tableSize"
:pagination="pagination"
:show-index="true"
:show-selection="false"
:loading="loading"
:queryTime="queryTime"
@current-change="handleRowClick"
@sort-change="handleSortChange"
@page-change="handlePageChange"
@page-size-change="handlePageSizeChange"
@refresh="loadData"
>
<template #column-order_status="{ row }">
<el-tag :type="getEntryOrderStatusTagType(row.order_status)" size="small">
{{ formatEntryOrderStatus(row.order_status) }}
</el-tag>
</template>
<template #column-hasReceiving="{ row }">
<el-tag size="small" :type="row.hasReceiving ? 'success' : 'info'">
{{ row.hasReceiving ? '已绑定' : '未绑定' }}
</el-tag>
</template>
<template #column-sync_status="{ row }">
<el-tag :type="getSyncStatusType(row.sync_status)" size="small">
{{ translateEntryField('sync_status', row.sync_status) }}
</el-tag>
</template>
<template #column-sync_message="{ row }">
<el-tooltip
:content="syncMessageFullText(row)"
placement="top"
:disabled="!syncMessageFullText(row)"
:show-after="400"
>
<span
class="sync-message-cell"
:class="syncMessageCellClass(row)"
role="button"
tabindex="0"
@click.stop="copySyncMessage(row)"
@keydown.enter.prevent="copySyncMessage(row)"
>
{{ syncMessageCellText(row) }}
</span>
</el-tooltip>
</template>
<template #column-order_type="{ row }">
<span>{{ translateEntryField('order_type', row.order_type) }}</span>
</template>
<template #column-source_type="{ row }">
<el-tag size="small" :type="row.source_type === 'WMS' ? '' : row.source_type === 'QM' ? 'warning' : 'success'">
{{ translateEntryField('source_type', row.source_type) }}
</el-tag>
</template>
<template #column-order_create_time="{ row }">
{{ formatTime(row.order_create_time) }}
</template>
<template #column-expect_start_time="{ row }">
{{ formatTime(row.expect_start_time) }}
</template>
<template #column-expect_end_time="{ row }">
{{ formatTime(row.expect_end_time) }}
</template>
<template #empty>
<div class="empty-tip">暂无入库单</div>
</template>
</upper-table>
</div>
<template v-if="detailVisible">
<div
class="pane-resizer"
title="拖动调整列表与详情区域高度"
@mousedown="beginSplitDrag"
/>
<div v-if="selectedEntryId" class="lower-level" :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="bindingRelations" />
<el-tab-pane label="入库记录" name="directInboundLogs" />
<el-tab-pane label="操作日志" name="logs" />
</el-tabs>
</div>
<div class="detail-container">
<KeepAlive>
<component
:is="activeComponent"
ref="detailComponentRef"
:id="selectedEntryId"
:row="selectedRow"
:entry-detail-refresh-tick="entryDetailRefreshTick"
:store-mode="true"
@refresh="handleDetailRefresh"
/>
</KeepAlive>
</div>
</div>
<div v-else class="no-selection" :style="lowerPaneStyle">
<div class="empty-tip">
<p>请从上方列表中选择一项查看详情</p>
</div>
</div>
</template>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted, computed } from 'vue'
import { useRoute } from 'vue-router'
import { ElMessage } from 'element-plus'
import ScanBox from '@/components/ScanBox/index.vue'
import UpperTable from '@/components/UpperTable/index.vue'
import * as indexApi from '@/api/index/index'
import * as entryApi from '@/api/storage.entry/entry'
import type { StorageEntryListParams } from '@/api/storage.entry/entry'
import * as XLSX from 'xlsx'
import {
availableFields,
entryStoreColums,
formatEntryOrderStatus,
getEntryOrderStatusTagType,
translateEntryField,
} from '@/views/storage/entry/entry-config'
import entrydetail from '@/views/storage/entry/component/entrydetail.vue'
import log from '@/views/storage/entry/component/log.vue'
import DirectInboundLogs from '@/views/storage/entry/component/DirectInboundLogs.vue'
import EntryBindingRelations from '@/views/storage/entry/component/EntryBindingRelations.vue'
import ExportModeDropdown from '@/components/ExportModeDropdown.vue'
import WarehouseSelect from '@/components/WarehouseSelect.vue'
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
import { useSettingsStore } from '@/stores/modules/settings'
const settingsStore = useSettingsStore()
const shortcutExpanded = computed(() => settingsStore.shortcutExpanded)
const containerHeight = computed(() =>
shortcutExpanded.value ? 'calc(100vh - 150px)' : 'calc(100vh - 100px)'
)
const scanBox = ref<any>(null)
const upperTable = ref<any>(null)
const detailComponentRef = ref<{ openBatchImportDialog?: () => void; reloadAll?: () => Promise<void> } | null>(null)
const entryDetailRefreshTick = ref(0)
const {
splitStackRef,
beginSplitDrag,
lowerPaneStyle,
upperPaneStyle
} = useVerticalSplitPane({ defaultLowerPercent: 40 })
const upperPaneFullStyle = computed(() => ({
flex: '1 1 auto',
minHeight: '0',
overflow: 'hidden'
}))
const detailVisible = ref(true)
function toggleDetailVisible() {
detailVisible.value = !detailVisible.value
}
function openColumnConfigPanel() {
upperTable.value?.openColumnConfig?.()
}
const route = useRoute()
const initialConditions = ref<any>(null)
const currentCondition = ref<any>(null)
const currentConditionRaw = ref<any>(null)
const presetTree = ref<any[]>([])
// 货主侧:移除货主筛选项(由登录身份决定)
const availableFieldsRef = reactive(
JSON.parse(JSON.stringify(availableFields)).filter((f: any) => f.value !== 'store_id')
)
const activeTab = ref('details')
const list = ref<any[]>([])
const loading = ref(false)
const exportLoading = ref(false)
const queryTime = ref(0)
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
const tableSize = ref('small')
const columns = ref(entryStoreColums)
const selectedEntryId = ref<number | string | null>(null)
const currentSort = reactive({ prop: '', order: '' })
// 仓库选择(v-model 绑定 WarehouseSelect 组件)
const selectedWarehouseId = ref<string | number | null>(null)
const componentMap: Record<string, any> = {
details: entrydetail,
bindingRelations: EntryBindingRelations,
directInboundLogs: DirectInboundLogs,
logs: log,
}
const activeComponent = computed(() => componentMap[activeTab.value] || componentMap.details)
const selectedRow = computed(() => {
return list.value.find((i: any) => i.id === selectedEntryId.value) || null
})
function getSyncStatusType(status: string) {
const map: Record<string, string> = {
PENDING: 'info',
SYNCING: 'primary',
SUCCESS: 'success',
FAIL: 'danger',
FAILED: 'danger',
}
return map[status] || undefined
}
function syncMessageFullText(row: any): string {
const v = row?.sync_message
if (v == null) return ''
return String(v).trim()
}
function syncMessageCellText(row: any): string {
const t = syncMessageFullText(row)
if (!t) return '--'
const max = 48
return t.length > max ? `${t.slice(0, max)}...` : t
}
function syncMessageCellClass(row: any): string {
const status = row?.sync_status
if (!status) return ''
const upper = String(status).trim().toUpperCase()
if (upper === 'FAIL' || upper === 'FAILED') return 'sync-message--fail'
if (upper === 'SUCCESS') return 'sync-message--success'
return ''
}
async function copySyncMessage(row: any) {
const text = syncMessageFullText(row)
if (!text) {
ElMessage.warning('当前行无同步信息可复制')
return
}
try {
if (navigator.clipboard?.writeText) {
await navigator.clipboard.writeText(text)
} else {
throw new Error('no clipboard api')
}
ElMessage.success('同步信息已复制到剪贴板')
} 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('同步信息已复制到剪贴板')
} catch {
ElMessage.error('复制失败,请手动选择文本复制')
}
}
}
function translateField(fieldValue: string, value: any) {
return translateEntryField(fieldValue, value)
}
function pad(n: number) {
return n < 10 ? '0' + n : String(n)
}
function formatTime(val: any) {
if (!val && val !== 0) return ''
const d = new Date(val)
if (isNaN(d.getTime())) return String(val)
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`
}
function normalizeToWhere(condition: any) {
if (!condition) return {}
if (typeof condition === 'string' || typeof condition === 'number') {
return { entry_order_code: { operator: 'like', value: condition, type: 'text' } }
}
const getFieldConfig = (key: string) => {
return availableFields.find((f: any) => f.value === key)
}
const mapType = (type: string, value: any) => {
if (type === 'datetimerange') return 'datetimerange'
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'
if (c && typeof c === 'object' && !Array.isArray(c)) {
if ('operator' in c || 'value' in c || 'type' in c) {
return {
operator: c.operator || (Array.isArray(c.value) ? 'in' : (fieldType === 'daterange' || fieldType === 'datetimerange' ? 'between' : 'eq')),
value: c.value,
type: c.type || mapType(fieldType, c.value)
}
}
}
if (c === null || c === undefined || c === '' || (Array.isArray(c) && c.length === 0)) return null
const simpleOp = (fieldType === 'daterange' || fieldType === 'datetimerange') ? 'between' : 'eq'
const simpleType = mapType(fieldType, c)
return { operator: simpleOp, value: c, type: simpleType }
}
if (condition.conditions && typeof condition.conditions === 'object') {
const where: any = {}
Object.keys(condition.conditions).forEach(k => {
const result = processConditionValue(k, condition.conditions[k])
if (result) where[k] = result
})
return where
}
if (typeof condition === 'object') {
const where: any = {}
Object.keys(condition).forEach(k => {
const result = processConditionValue(k, condition[k])
if (result) where[k] = result
})
return where
}
return {}
}
onMounted(() => {
loadFilterData()
const idParam = route.query.id || route.query.entry_order_code || route.query.q
const id = Array.isArray(idParam) ? idParam[0] : idParam
if (id) {
initialConditions.value = { conditions: { entry_order_code: { operator: 'like', value: id, type: 'text' } } }
handleConditionChange(initialConditions.value)
} else {
loadData()
}
})
async function loadData() {
if (loading.value) return
loading.value = true
const start = Date.now()
try {
const where = currentCondition.value || normalizeToWhere(scanBox.value?.getConditions?.() || {})
// 仓库筛选:如果选择了仓库,加入 where 条件
if (selectedWarehouseId.value) {
where.warehouse_id = { operator: 'eq', value: selectedWarehouseId.value, type: 'number' }
}
const params: StorageEntryListParams = {
pagination: {
page: pagination.currentPage,
pageSize: pagination.pageSize
},
sort: currentSort.prop ? {
sortField: currentSort.prop,
sortOrder: currentSort.order === 'ascending' ? 'ASC' : 'DESC'
} : undefined,
where: where
}
const res = await entryApi.getEntryListStore(params)
if (res && res.code === 200 && res.data?.list) {
list.value = res.data.list
pagination.total = res.data.pagination?.total || 0
} else if (res && res.list) {
list.value = res.list
pagination.total = res.pagination?.total || 0
} else {
list.value = []
pagination.total = 0
}
} catch (e) {
console.error('加载入库单失败', e)
ElMessage.error('加载入库单失败')
list.value = []
pagination.total = 0
} finally {
loading.value = false
queryTime.value = Date.now() - start
}
}
async function handleDetailRefresh() {
await loadData()
entryDetailRefreshTick.value += 1
}
async function loadFilterData() {
try {
const presetRes: any = await indexApi.fastWhereTree('entry')
if (presetRes && presetRes.code === 200) {
presetTree.value = presetRes.presetTree || []
}
} catch (e) {
console.error('加载筛选配置失败', e)
}
}
function handleConditionChange(condition: any) {
currentConditionRaw.value = condition
currentCondition.value = normalizeToWhere(condition)
pagination.currentPage = 1
loadData()
}
function handleSortChange({ prop, order }: any) {
currentSort.prop = prop
currentSort.order = order
pagination.currentPage = 1
loadData()
}
const handleConditionClear = () => {
currentCondition.value = null
pagination.currentPage = 1
loadData()
}
function handleConditionReset() {
currentCondition.value = null
pagination.currentPage = 1
if (scanBox.value?.reset) {
scanBox.value.reset()
} else if (scanBox.value?.clear) {
scanBox.value.clear()
}
loadData()
}
function handleWarehouseChange() {
pagination.currentPage = 1
loadData()
}
function handleRowClick(row: any) {
selectedEntryId.value = row?.id || null
}
function handlePageChange(page: number) {
pagination.currentPage = page
loadData()
}
function handlePageSizeChange(size: number) {
pagination.pageSize = size
pagination.currentPage = 1
loadData()
}
async function handleExport(mode: 'waybill' | 'item' = 'waybill') {
const sourceRows = list.value
if (!sourceRows.length) {
ElMessage.warning('当前无数据可导出')
return
}
exportLoading.value = true
try {
const exportColumns = columns.value.filter((col: any) => col.prop && col.label)
if (mode === 'waybill') {
const headers = exportColumns.map((col: any) => col.label)
const data = sourceRows.map((row: any) =>
exportColumns.map((col: any) => {
const val = row[col.prop]
if (['order_status', 'order_type', 'sync_status'].includes(col.prop)) {
return translateField(col.prop, val)
}
return val === null || val === undefined ? '' : val
})
)
const ws = XLSX.utils.aoa_to_sheet([headers, ...data])
const wb = XLSX.utils.book_new()
XLSX.utils.book_append_sheet(wb, ws, '入库单列表')
XLSX.writeFile(wb, `入库单列表_${new Date().getTime()}.xlsx`)
ElMessage.success('导出成功')
return
}
// 导出明细
const detailRows: any[] = []
for (const row of sourceRows) {
try {
const res: any = await entryApi.getEntryDetailStore({ id: row.id })
const payload = res?.data || res
const items = Array.isArray(payload?.items)
? payload.items
: payload?.entryOrder?.items || []
items.forEach((item: any) => {
detailRows.push({
'入库单号': row.entry_order_code || row.id,
'商品编码': item.warehouse_item_code || item.external_item_code || '',
'商品名称': item.warehouse_item_name || '',
'规格': item.warehouse_item_spec || '',
'计划数量': item.count ?? '',
'实收数量': item.received_quantity ?? '',
'确认数量': item.confirm_quantity ?? '',
})
})
} catch (e) {
console.warn(`获取入库单 ${row.id} 明细失败`, e)
}
}
if (!detailRows.length) {
ElMessage.warning('未获取到可导出的入库明细')
return
}
const ws = XLSX.utils.json_to_sheet(detailRows)
const wb = XLSX.utils.book_new()
XLSX.utils.book_append_sheet(wb, ws, '入库明细')
XLSX.writeFile(wb, `入库明细_${new Date().getTime()}.xlsx`)
ElMessage.success('导出成功')
} catch (e) {
console.error('导出 Excel 失败:', e)
ElMessage.error('导出失败')
} finally {
exportLoading.value = false
}
}
function handleExportAction(action: string) {
void handleExport(action === 'handleExportItem' ? 'item' : 'waybill')
}
</script>
<style scoped lang="scss">
@use "@/views/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: 14px;
}
.sync-message-cell {
cursor: pointer;
color: var(--el-color-primary);
}
.sync-message--fail {
color: var(--el-color-danger);
}
.sync-message--success {
color: var(--el-color-success);
}
</style>

View File

@ -151,6 +151,30 @@ export const receivingColumns = [
{ prop: 'actions', label: '操作', width: '120', fixed: 'right' },
]
/** 货主侧收货单列表列(getStoreReceivingList 返回字段) */
export const receivingStoreColumns = [
{ prop: 'receiving_number', label: '收货单号', width: '110', fixed: 'left' },
{ prop: 'status', label: '收货状态', width: '90' },
{ prop: 'detail_status', label: '匹配状态', width: '90' },
{ prop: 'storage_status', label: '入库状态', width: '90' },
{ prop: 'total_items', label: '商品种类', width: '90', sortable: true },
{ prop: 'total_quantity', label: '总数量', width: '90', sortable: true },
{ prop: 'total_boxes', label: '总箱数', width: '90', sortable: true },
{ prop: 'total_pallets', label: '总托盘数', width: '90', sortable: true },
{ prop: 'available_quantity', label: '可用数量', width: '90' },
{ prop: 'lock_rate_display', label: '锁定率', width: '90' },
{ prop: 'license_plate', label: '车牌号', width: '100' },
{ prop: 'tracking_number', label: '物流单号', width: '120' },
{ prop: 'delivery_method', label: '来货方式', width: '90' },
{ prop: 'loading_method', label: '装卸方式', width: '100' },
{ prop: 'creator_name', label: '创建人', width: '100' },
{ prop: 'receiving_start_time', label: '收货开始', width: '150', sortable: true, formatter: (row: any) => formatDateTime(row.receiving_start_time) },
{ prop: 'receiving_end_time', label: '收货结束', width: '150', sortable: true, formatter: (row: any) => formatDateTime(row.receiving_end_time) },
{ prop: 'create_at_display', label: '创建时间', width: '150' },
{ prop: 'update_at_display', label: '更新时间', width: '150' },
{ prop: 'remark', label: '备注', minWidth: '120' },
]
// receiving配置(基础信息在前,流程状态在后;对齐待处理订单 ScanBox 分组)
export const availableFields: ReceivingScanFieldConfig[] = [

View File

@ -0,0 +1,487 @@
<template>
<div class="order-sub-container" :style="{ height: containerHeight }">
<scan-box
ref="scanBox"
cache-key="storage-receiving-owner"
width="250px"
: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"
/>
<div class="main-content">
<div class="toolbar">
<div class="toolbar-left">
<el-button size="small" type="primary" @click="loadData">刷新</el-button>
<ExportModeDropdown :loading="exportLoading" @action="handleExportAction" />
<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"
/>
</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-owner-list"
:data="list"
:columns="columns"
:table-size="tableSize"
:pagination="pagination"
:show-index="true"
:loading="loading"
:queryTime="queryTime"
@current-change="handleRowClick"
@sort-change="handleSortChange"
@page-change="handlePageChange"
@page-size-change="handlePageSizeChange"
@refresh="loadData"
>
<template #column-status="{ row }">
<el-tag v-if="row.status" :type="statusTagType(row.status)" size="small">
{{ statusText(row.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) }}
</el-tag>
</template>
<template #column-delivery_method="{ row }">
<span>{{ deliveryMethodText(row.delivery_method) }}</span>
</template>
<template #column-loading_method="{ row }">
<span>{{ loadingMethodText(row.loading_method) }}</span>
</template>
<template #column-receiving_start_time="{ row }">
{{ formatTime(row.receiving_start_time) }}
</template>
<template #column-receiving_end_time="{ row }">
{{ formatTime(row.receiving_end_time) }}
</template>
<template #empty>
<div class="empty-tip">暂无收货单</div>
</template>
</upper-table>
</div>
<template v-if="detailVisible">
<div
class="pane-resizer"
title="拖动调整列表与详情区域高度"
@mousedown="beginSplitDrag"
/>
<div v-if="selectedReceivingId" class="lower-level" :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="logs" />
</el-tabs>
</div>
<div class="detail-container">
<KeepAlive>
<component
:is="activeComponent"
:id="selectedReceivingId"
:row="selectedRow"
@refresh="handleDetailRefresh"
/>
</KeepAlive>
</div>
</div>
<div v-else class="no-selection" :style="lowerPaneStyle">
<div class="empty-tip">
<p>请从上方列表中选择一项查看详情</p>
</div>
</div>
</template>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted, computed } from 'vue'
import { useRoute } from 'vue-router'
import { ElMessage } from 'element-plus'
import ScanBox from '@/components/ScanBox/index.vue'
import UpperTable from '@/components/UpperTable/index.vue'
import WarehouseSelect from '@/components/WarehouseSelect.vue'
import ExportModeDropdown from '@/components/ExportModeDropdown.vue'
import * as indexApi from '@/api/index/index'
import * as receivingApi from '@/api/storage_receiving/receiving'
import {
receivingStoreColumns,
availableFields,
statusConfig,
storageStatusConfig,
deliveryMethodConfig,
loadingMethodConfig,
} from '@/views/storage/receiving/receiving-config'
import Details from '@/views/storage/receiving/component/Details.vue'
import Logs from '@/views/storage/receiving/component/Logs.vue'
import * as XLSX from 'xlsx'
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
import { useSettingsStore } from '@/stores/modules/settings'
const settingsStore = useSettingsStore()
const shortcutExpanded = computed(() => settingsStore.shortcutExpanded)
const containerHeight = computed(() =>
shortcutExpanded.value ? 'calc(100vh - 150px)' : 'calc(100vh - 100px)'
)
const scanBox = ref<any>(null)
const upperTable = ref<any>(null)
const route = useRoute()
const initialConditions = ref<any>(null)
const currentCondition = ref<any>(null)
const {
splitStackRef,
beginSplitDrag,
lowerPaneStyle,
upperPaneStyle
} = useVerticalSplitPane({ defaultLowerPercent: 40 })
const upperPaneFullStyle = computed(() => ({
flex: '1 1 auto',
minHeight: '0',
overflow: 'hidden'
}))
const detailVisible = ref(true)
function toggleDetailVisible() {
detailVisible.value = !detailVisible.value
}
function openColumnConfigPanel() {
upperTable.value?.openColumnConfig?.()
}
// 货主侧:移除货主筛选项
const availableFieldsRef = reactive(
JSON.parse(JSON.stringify(availableFields)).filter((f: any) => f.value !== 'store_id')
)
const activeTab = ref('details')
const list = ref<any[]>([])
const loading = ref(false)
const exportLoading = ref(false)
const queryTime = ref(0)
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
const tableSize = ref('small')
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,
}
const activeComponent = computed(() => componentMap[activeTab.value] || componentMap.details)
const selectedRow = computed(() => {
return list.value.find((i: any) => i.id === selectedReceivingId.value) || null
})
const presetTree = ref<any[]>([])
// 状态辅助函数
function statusTagType(s: string) {
return (statusConfig as any)[s]?.tagType || 'info'
}
function statusText(s: string) {
return (statusConfig as any)[s]?.text || s || '--'
}
function storageStatusTagType(s: string) {
return (storageStatusConfig as any)[s]?.tagType || 'info'
}
function storageStatusText(s: string) {
return (storageStatusConfig as any)[s]?.text || s || '--'
}
function deliveryMethodText(v: string) {
return (deliveryMethodConfig as any)[v]?.text || v || '--'
}
function loadingMethodText(v: string) {
return (loadingMethodConfig as any)[v]?.text || v || '--'
}
function pad(n: number) {
return n < 10 ? '0' + n : String(n)
}
function formatTime(val: any) {
if (!val && val !== 0) return ''
const d = new Date(val)
if (isNaN(d.getTime())) return String(val)
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`
}
function normalizeToWhere(condition: any) {
if (!condition) return {}
const conds = condition?.conditions && typeof condition.conditions === 'object'
? condition.conditions
: condition && typeof condition === 'object' ? condition : {}
const where: any = {}
for (const [key, val] of Object.entries(conds)) {
if (val === null || val === undefined || val === '') continue
if (typeof val === 'object' && !Array.isArray(val) && ('operator' in val! || 'value' in val!)) {
where[key] = val
} else {
where[key] = { operator: 'eq', value: val }
}
}
return where
}
onMounted(() => {
loadFilterData()
const idParam = route.query.id || route.query.receiving_number || route.query.q
const id = Array.isArray(idParam) ? idParam[0] : idParam
if (id) {
initialConditions.value = {
conditions: { receiving_number: { operator: 'eq', value: id, type: 'text' } }
}
handleConditionChange(initialConditions.value)
} else {
loadData()
}
})
async function loadData() {
if (loading.value) return
loading.value = true
const start = Date.now()
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,
pageSize: pagination.pageSize
},
sort: currentSort.prop ? {
sortField: currentSort.prop,
sortOrder: currentSort.order === 'ascending' ? 'ASC' : 'DESC'
} : undefined,
where
}
const res = await receivingApi.getReceivingListStore(params)
if (res && res.code === 200) {
const data = res.data || res
list.value = data.list || []
pagination.total = data.pagination?.total || 0
} else {
list.value = []
pagination.total = 0
}
} catch (e) {
console.error('加载收货单失败', e)
ElMessage.error('加载收货单失败')
list.value = []
pagination.total = 0
} finally {
loading.value = false
queryTime.value = Date.now() - start
}
}
function handleDetailRefresh() {
void loadData()
}
async function loadFilterData() {
try {
const presetRes: any = await indexApi.fastWhereTree('receiving')
if (presetRes && presetRes.code === 200) {
presetTree.value = presetRes.presetTree || []
}
} catch (e) {
console.error('加载筛选配置失败', e)
}
}
function handleConditionChange(condition: any) {
currentCondition.value = normalizeToWhere(condition)
pagination.currentPage = 1
loadData()
}
function handleSortChange({ prop, order }: any) {
currentSort.prop = prop
currentSort.order = order
pagination.currentPage = 1
loadData()
}
function handleConditionClear() {
currentCondition.value = null
pagination.currentPage = 1
loadData()
}
function handleConditionReset() {
currentCondition.value = null
pagination.currentPage = 1
if (scanBox.value?.reset) {
scanBox.value.reset()
} else if (scanBox.value?.clear) {
scanBox.value.clear()
}
loadData()
}
function handleWarehouseChange() {
pagination.currentPage = 1
loadData()
}
function handleRowClick(row: any) {
selectedReceivingId.value = row?.id || null
}
function handlePageChange(page: number) {
pagination.currentPage = page
loadData()
}
function handlePageSizeChange(size: number) {
pagination.pageSize = size
pagination.currentPage = 1
loadData()
}
async function handleExport(mode: 'waybill' | 'item' = 'waybill') {
const sourceRows = list.value
if (!sourceRows.length) {
ElMessage.warning('当前无数据可导出')
return
}
exportLoading.value = true
try {
const exportColumns = columns.value.filter((col: any) => col.prop && col.label)
if (mode === 'waybill') {
const headers = exportColumns.map((col: any) => col.label)
const data = sourceRows.map((row: any) =>
exportColumns.map((col: any) => {
const val = row[col.prop]
if (col.prop === 'status') return statusText(val)
if (col.prop === 'storage_status') return storageStatusText(val)
if (col.prop === 'delivery_method') return deliveryMethodText(val)
if (col.prop === 'loading_method') return loadingMethodText(val)
if (col.prop === 'created_at' || col.prop === 'updated_at' ||
col.prop === 'receiving_start_time' || col.prop === 'receiving_end_time') {
return formatTime(val)
}
return val === null || val === undefined ? '' : val
})
)
const ws = XLSX.utils.aoa_to_sheet([headers, ...data])
const wb = XLSX.utils.book_new()
XLSX.utils.book_append_sheet(wb, ws, '收货单列表')
XLSX.writeFile(wb, `收货单列表_${new Date().getTime()}.xlsx`)
ElMessage.success('导出成功')
return
}
// 导出明细
const detailRows: any[] = []
for (const row of sourceRows) {
try {
const res: any = await receivingApi.getReceivingDetailStore({ id: row.id })
const payload = res?.data || res
const items = Array.isArray(payload?.items)
? payload.items
: payload?.receiving?.items || []
items.forEach((item: any) => {
detailRows.push({
'收货单号': row.receiving_number || row.id,
'商品名称': item.product_name || item.item_name || '',
'商品编码': item.product_code || item.item_code || '',
'数量': item.quantity ?? '',
'箱数': item.boxes ?? '',
})
})
} catch (e) {
console.warn(`获取收货单 ${row.id} 明细失败`, e)
}
}
if (!detailRows.length) {
ElMessage.warning('未获取到可导出的收货明细')
return
}
const ws = XLSX.utils.json_to_sheet(detailRows)
const wb = XLSX.utils.book_new()
XLSX.utils.book_append_sheet(wb, ws, '收货明细')
XLSX.writeFile(wb, `收货明细_${new Date().getTime()}.xlsx`)
ElMessage.success('导出成功')
} catch (e) {
console.error('导出 Excel 失败:', e)
ElMessage.error('导出失败')
} finally {
exportLoading.value = false
}
}
function handleExportAction(action: string) {
void handleExport(action === 'handleExportItem' ? 'item' : 'waybill')
}
</script>
<style scoped lang="scss">
@use "@/views/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: 14px;
}
</style>

View File

@ -26,6 +26,21 @@
<el-tag size="small" effect="plain">出库合计 {{ formatNumber(sumOutbound) }}</el-tag>
</template>
</div>
<div class="toolbar-right">
<el-input
v-model="keyword"
placeholder="搜索商品名称/编码/条码"
clearable
size="small"
style="width: 240px"
@keyup.enter="handleKeywordSearch"
@clear="handleKeywordSearch"
>
<template #prefix>
<el-icon><Search /></el-icon>
</template>
</el-input>
</div>
</div>
<div class="split-stack" ref="splitStackRef">
@ -105,6 +120,7 @@
<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'
@ -204,6 +220,7 @@ const currentSort = reactive<{ prop: string; order: '' | 'ascending' | 'descendi
const selectedRid = ref<string | null>(null)
const currentConditionRaw = ref<any>({})
const keyword = ref('')
const selectedRow = computed(() => fullList.value.find((r) => r.__rid === selectedRid.value) || null)
@ -287,6 +304,10 @@ function buildSortPayload(): StorageReportSearchBody['sort'] | undefined {
function buildReportQueryPayload(): StorageReportSearchBody {
const where = normalizeScanConditionToReportWhere(currentConditionRaw.value)
// 关键字搜索
if (keyword.value.trim()) {
where.keyword = keyword.value.trim()
}
const sort = buildSortPayload()
const body: StorageReportSearchBody = {}
if (Object.keys(where).length > 0) {
@ -350,12 +371,19 @@ function handleConditionChange(condition: any) {
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()

View File

@ -15,7 +15,9 @@ export const reportFieldLabels: Record<string, string> = {
start_time: '统计区间开始',
end_time: '统计区间结束',
space_id: '库位ID',
space_name: '库位'
space_name: '库位',
warehouse_id: '仓库ID',
warehouse_name: '仓库名称',
}
const DETAIL_KEY_ORDER = [
@ -207,6 +209,12 @@ export const reportScanBoxAvailableFields = [
label: '按库位统计',
type: 'boolean',
placeholder: '开启后按商品+库位+货主返回;关闭则按商品+货主聚合'
}),
reportScanField('keyword', {
value: 'keyword',
label: '关键字',
type: 'text',
placeholder: '搜索商品名称/编码/条码'
})
]
@ -269,5 +277,11 @@ export function normalizeScanConditionToReportWhere(condition: any): Record<stri
}
}
// 关键字搜索
const keyword = conds.keyword?.value ?? conds.keyword
if (keyword != null && String(keyword).trim() !== '') {
where.keyword = String(keyword).trim()
}
return where
}

View File

@ -27,22 +27,23 @@
</template>
</div>
<div class="toolbar-right">
<el-select
<WarehouseSelect
v-model="selectedWarehouseId"
placeholder="全部仓库"
clearable
filterable
size="small"
style="width: 200px"
@change="handleWarehouseChange"
/>
<el-input
v-model="keyword"
placeholder="搜索商品名称/编码/条码"
clearable
size="small"
style="width: 240px; margin-left: 8px"
@keyup.enter="handleKeywordSearch"
@clear="handleKeywordSearch"
>
<el-option
v-for="wh in warehouseList"
:key="wh.warehouse_id"
:label="wh.warehouse_name"
:value="wh.warehouse_id"
/>
</el-select>
<template #prefix>
<el-icon><Search /></el-icon>
</template>
</el-input>
</div>
</div>
@ -123,10 +124,12 @@
<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'
import ExportModeDropdown from '@/components/ExportModeDropdown.vue'
import WarehouseSelect from '@/components/WarehouseSelect.vue'
import AsyncExportProgressDialog from '@/components/AsyncExportProgressDialog.vue'
import { useAsyncExportTask } from '@/composables/useAsyncExportTask'
import {
@ -137,7 +140,6 @@ import {
type StorageReportSearchBody
} from '@/api/storage.report/report'
import * as indexApi from '@/api/index/index'
import { loadWarehouses } from '@/api/index/index'
import {
buildReportTableColumns,
formatReportCell,
@ -157,7 +159,7 @@ const upperTable = ref<any>(null)
const presetTree = ref<any[]>([])
const availableFieldsRef = reactive(
JSON.parse(JSON.stringify(reportScanBoxAvailableFields)).filter((f: any) => f.value !== 'store_id')
JSON.parse(JSON.stringify(reportScanBoxAvailableFields)).filter((f: any) => f.value !== 'store_id' && f.value !== 'by_space')
)
const settingsStore = useSettingsStore()
@ -211,7 +213,15 @@ const {
const fullList = ref<any[]>([])
const list = ref<any[]>([])
const columns = ref(buildReportTableColumns([]))
/** 货主侧不显示的列 */
const STORE_SIDE_HIDDEN_COLS = new Set(['store_id', 'store_name'])
function buildStoreReportColumns(rows: any[]) {
return buildReportTableColumns(rows).filter((col: any) => !STORE_SIDE_HIDDEN_COLS.has(col.prop))
}
const columns = ref(buildStoreReportColumns([]))
const pagination = reactive({
currentPage: 1,
@ -226,13 +236,13 @@ 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 warehouseList = ref<any[]>([])
const keyword = ref('')
const selectedRow = computed(() => fullList.value.find((r) => r.__rid === selectedRid.value) || null)
const detailKeys = computed(() => {
if (!selectedRow.value) return []
const keys = Object.keys(selectedRow.value).filter((k) => k !== '__rid')
const keys = Object.keys(selectedRow.value).filter((k) => k !== '__rid' && !STORE_SIDE_HIDDEN_COLS.has(k))
return sortReportDetailKeys(keys)
})
@ -313,6 +323,10 @@ function buildReportQueryPayload(): StorageReportSearchBody {
if (selectedWarehouseId.value) {
where.warehouse_id = selectedWarehouseId.value
}
// 关键字搜索
if (keyword.value.trim()) {
where.keyword = keyword.value.trim()
}
const sort = buildSortPayload()
const body: StorageReportSearchBody = {}
if (Object.keys(where).length > 0) {
@ -374,12 +388,19 @@ function handleWarehouseChange() {
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()
@ -402,21 +423,21 @@ async function loadData() {
if (res && (res.flag === 'success' || res.code === 200)) {
const raw = extractReportList(res)
fullList.value = withRowIds(raw)
columns.value = buildReportTableColumns(raw)
columns.value = buildStoreReportColumns(raw)
pagination.currentPage = 1
applyClientPage()
queryTime.value = Date.now() - started
} else {
fullList.value = []
list.value = []
columns.value = buildReportTableColumns([])
columns.value = buildStoreReportColumns([])
pagination.total = 0
ElMessage.error(res?.message || '查询失败')
}
} catch (e: any) {
fullList.value = []
list.value = []
columns.value = buildReportTableColumns([])
columns.value = buildStoreReportColumns([])
pagination.total = 0
ElMessage.error(e?.message || '请求失败')
} finally {
@ -448,23 +469,9 @@ function handleRowClick(row: any) {
onMounted(() => {
loadFilterData()
loadWarehouseList()
loadData()
resumeExportTaskFromStorage()
})
async function loadWarehouseList() {
try {
const res = await loadWarehouses() as any
const raw = res?.warehouses || res?.data?.list || res?.data || []
warehouseList.value = raw.map((item: any) => ({
warehouse_id: item.value ?? item.warehouse_id ?? item.id,
warehouse_name: item.label || item.warehouse_name || item.company_name || String(item.value ?? '')
}))
} catch {
// 仓库列表加载失败不影响主流程
}
}
</script>