feat(storage/inventory): 批次/汇总查询库位列展示与明细双模式移库
- 批次查询主列表新增库位列并映射 batch_no - 查询条件改为 stock_query(参考订单查询),移除商品ID选择器 - 汇总模式主列表库位通过 listByStockId 按商品批量补全(单库位显示库位名,多库位显示n个库位) - 明细面板支持按明细/按库位汇总双视图(group_by_space),按视图显示对应移库按钮 - 明细表格动态高度可滚动,勾选行驱动按库存记录/按商品移库 - 明细面板默认高度占比调整,新增刷新按钮
This commit is contained in:
parent
de5b25a04b
commit
154cf6081b
@ -17,6 +17,21 @@ export function getInventoryList(data: any): Promise<any> {
|
||||
} as any)
|
||||
}
|
||||
|
||||
/** 按商品查询库存明细:group_by_space=false 返回 quantity > 1 的 wms_storage 明细行(按 id 倒序);group_by_space=true 按库位汇总 */
|
||||
export function getInventoryListByStockId(data: { stock_id: number; group_by_space?: boolean }): Promise<any> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.inventory.listByStockId',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
export function quickPutaway(data: { receiving_id: number; id?: number }): Promise<any> {
|
||||
const body: Record<string, unknown> = { ...data }
|
||||
if (body.receiving_id === undefined && body.id != null) {
|
||||
|
||||
@ -4,11 +4,12 @@
|
||||
<div class="panel-actions">
|
||||
<el-button-group class="toolbar-btn-group">
|
||||
<el-tooltip
|
||||
content="需在左侧查询设置中开启「按批次查询」并选中单条库存记录(含 storage_id)"
|
||||
content="请在下方明细列表勾选一条库存记录(含库存记录 ID)"
|
||||
:disabled="canTransferByLocation"
|
||||
>
|
||||
<span class="transfer-btn-wrap">
|
||||
<el-button
|
||||
v-if="!isSpaceView"
|
||||
size="small"
|
||||
type="primary"
|
||||
:disabled="!canTransferByLocation"
|
||||
@ -19,11 +20,12 @@
|
||||
</span>
|
||||
</el-tooltip>
|
||||
<el-tooltip
|
||||
content="不适用于开启批次管理且多批次的商品;合并模式下按库位+商品移库"
|
||||
content="请在下方列表勾选一条库位记录;仅未开启批次管理的商品支持"
|
||||
:disabled="canTransferByProduct"
|
||||
>
|
||||
<span class="transfer-btn-wrap">
|
||||
<el-button
|
||||
v-if="groupByBatch || isSpaceView"
|
||||
size="small"
|
||||
type="success"
|
||||
:disabled="!canTransferByProduct"
|
||||
@ -34,6 +36,22 @@
|
||||
</span>
|
||||
</el-tooltip>
|
||||
</el-button-group>
|
||||
<el-radio-group
|
||||
v-if="!groupByBatch"
|
||||
v-model="detailViewMode"
|
||||
size="small"
|
||||
>
|
||||
<el-radio-button value="detail">按明细</el-radio-button>
|
||||
<el-radio-button value="space">按库位汇总</el-radio-button>
|
||||
</el-radio-group>
|
||||
<el-button
|
||||
v-if="!groupByBatch"
|
||||
size="small"
|
||||
:loading="loading"
|
||||
@click="loadData"
|
||||
>
|
||||
刷新
|
||||
</el-button>
|
||||
</div>
|
||||
<el-dialog
|
||||
v-model="dialogVisible"
|
||||
@ -68,22 +86,35 @@
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<el-table :data="detailList" border stripe size="small" v-loading="loading">
|
||||
<el-table-column
|
||||
v-for="col in detailColumns"
|
||||
:key="col.prop"
|
||||
:prop="col.prop"
|
||||
:label="col.label"
|
||||
:width="col.width"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
</el-table>
|
||||
<div ref="tableWrapRef" class="detail-table-wrap">
|
||||
<el-table
|
||||
ref="detailTableRef"
|
||||
:data="detailList"
|
||||
border
|
||||
stripe
|
||||
size="small"
|
||||
v-loading="loading"
|
||||
:height="tableHeight"
|
||||
:row-key="(row: any) => row.storage_id ?? `${row.space_id}-${row.stock_id}`"
|
||||
@selection-change="handleDetailSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" width="40" />
|
||||
<el-table-column
|
||||
v-for="col in detailColumns"
|
||||
:key="col.prop"
|
||||
:prop="col.prop"
|
||||
:label="col.label"
|
||||
:width="col.width"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||
import * as inventoryApi from '@/api/storage.inventory/inventory'
|
||||
import * as warehouseApi from '@/api/warehouse/warehouse'
|
||||
import * as indexApi from '@/api/index/index'
|
||||
@ -103,6 +134,11 @@ const emit = defineEmits(['refresh'])
|
||||
const loading = ref(false)
|
||||
const detailList = ref<any[]>([])
|
||||
const currentRow = ref<any>(null)
|
||||
const tableWrapRef = ref<HTMLElement | null>(null)
|
||||
const detailTableRef = ref<any>(null)
|
||||
const selectedDetailRows = ref<any[]>([])
|
||||
const tableHeight = ref<number | undefined>(undefined)
|
||||
let tableResizeObserver: ResizeObserver | null = null
|
||||
const dialogVisible = ref(false)
|
||||
const transferMode = ref<TransferMode | null>(null)
|
||||
const targetSpace = ref<string | number>('')
|
||||
@ -112,31 +148,45 @@ let spaceInfoTimer: ReturnType<typeof setTimeout> | null = null
|
||||
const transferQty = ref<number | null>(null)
|
||||
const transferLoading = ref(false)
|
||||
|
||||
const detailViewMode = ref<'detail' | 'space'>('detail')
|
||||
|
||||
/** 是否按库位汇总视图(仅汇总模式可切换) */
|
||||
const isSpaceView = computed(() => !props.groupByBatch && detailViewMode.value === 'space')
|
||||
|
||||
/** 明细表格勾选变化:单选一行时作为当前操作行(按明细视图驱动按库存记录移库,按库位汇总视图驱动按商品移库) */
|
||||
function handleDetailSelectionChange(rows: any[]) {
|
||||
selectedDetailRows.value = rows || []
|
||||
if (rows && rows.length === 1) {
|
||||
currentRow.value = normalizeRow(rows[0])
|
||||
} else {
|
||||
currentRow.value = props.groupByBatch ? (props.row ? normalizeRow(props.row) : null) : null
|
||||
}
|
||||
}
|
||||
|
||||
const detailColumns = computed(() => {
|
||||
if (props.groupByBatch) {
|
||||
if (isSpaceView.value) {
|
||||
return [
|
||||
{ prop: 'storage_id', label: '库存记录ID', width: '110' },
|
||||
{ prop: 'stock_id', label: '商品ID', width: '100' },
|
||||
{ prop: 'item_code', label: '商品编码', width: '140' },
|
||||
{ prop: 'item_name', label: '商品名称', width: '200' },
|
||||
{ prop: 'batch_no', label: '批次号', width: '140' },
|
||||
{ prop: 'production_date', label: '生产日期', width: '140' },
|
||||
{ prop: 'expiry_date', label: '到期日期', width: '140' },
|
||||
{ prop: 'space_code', label: '库位', width: '140' },
|
||||
{ prop: 'space_code', label: '库位', width: '160' },
|
||||
{ prop: 'quantity', label: '总数量', width: '100' },
|
||||
{ prop: 'available_quantity', label: '可用数量', width: '100' },
|
||||
{ prop: 'locked_quantity', label: '锁定数量', width: '100' }
|
||||
{ prop: 'locked_quantity', label: '锁定数量', width: '100' },
|
||||
{ prop: 'batch_count', label: '批次数', width: '80' },
|
||||
{ prop: 'first_inbound_time', label: '首次入库时间', width: '160' },
|
||||
{ prop: 'last_inbound_time', label: '最后入库时间', width: '160' }
|
||||
]
|
||||
}
|
||||
return [
|
||||
{ prop: 'storage_id', label: '库存记录ID', width: '110' },
|
||||
{ prop: 'stock_id', label: '商品ID', width: '100' },
|
||||
{ prop: 'item_code', label: '商品编码', width: '140' },
|
||||
{ prop: 'item_name', label: '商品名称', width: '200' },
|
||||
{ prop: 'batch_no', label: '批次号', width: '140' },
|
||||
{ prop: 'space_code', label: '库位', width: '140' },
|
||||
{ prop: 'production_date', label: '生产日期', width: '140' },
|
||||
{ prop: 'expiry_date', label: '到期日期', width: '140' },
|
||||
{ prop: 'quantity', label: '总数量', width: '100' },
|
||||
{ prop: 'available_quantity', label: '可用数量', width: '100' },
|
||||
{ prop: 'locked_quantity', label: '锁定数量', width: '100' },
|
||||
{ prop: 'batch_count', label: '批次数', width: '100' }
|
||||
{ prop: 'locked_quantity', label: '锁定数量', width: '100' }
|
||||
]
|
||||
})
|
||||
|
||||
@ -160,9 +210,14 @@ function isBatchMgmtEnabled(row: any) {
|
||||
return s === 'y' || s === '1' || s === 'true'
|
||||
}
|
||||
|
||||
const activeRow = computed(() => currentRow.value || props.row || {})
|
||||
const activeRow = computed(() => {
|
||||
if (currentRow.value) return currentRow.value
|
||||
// 批次模式:主列表选中行本身就是明细行;汇总模式:必须勾选明细/库位行才作为操作行
|
||||
return props.groupByBatch ? (props.row || {}) : {}
|
||||
})
|
||||
|
||||
const canTransferByLocation = computed(() => {
|
||||
// 只要选中了含库存记录 ID 的明细行即可按库存记录移库(批次/汇总模式通用)
|
||||
const row = activeRow.value
|
||||
const storageId = Number(row.storage_id)
|
||||
return Number.isFinite(storageId) && storageId > 0
|
||||
@ -174,7 +229,8 @@ const canTransferByProduct = computed(() => {
|
||||
const stockId = Number(row.stock_id)
|
||||
if (!Number.isFinite(spaceId) || spaceId <= 0) return false
|
||||
if (!Number.isFinite(stockId) || stockId <= 0) return false
|
||||
if (isBatchMgmtEnabled(row) && Number(row.batch_count || 0) > 1) return false
|
||||
// 开启批次管理的商品不支持按商品移库(按原库位+商品合并会跨批次)
|
||||
if (isBatchMgmtEnabled(row)) return false
|
||||
return true
|
||||
})
|
||||
|
||||
@ -190,6 +246,10 @@ function normalizeRow(r: any) {
|
||||
}
|
||||
|
||||
const loadData = () => {
|
||||
if (!props.groupByBatch) {
|
||||
void loadDetailListByStockId()
|
||||
return
|
||||
}
|
||||
loading.value = true
|
||||
setTimeout(() => {
|
||||
currentRow.value = props.row ? normalizeRow(props.row) : null
|
||||
@ -198,13 +258,65 @@ const loadData = () => {
|
||||
}, 120)
|
||||
}
|
||||
|
||||
/** 汇总模式:按商品拉取当前仓库下 quantity > 1 的库存明细行 */
|
||||
async function loadDetailListByStockId() {
|
||||
const stockId = Number(props.id)
|
||||
if (!Number.isInteger(stockId) || stockId <= 0) {
|
||||
currentRow.value = null
|
||||
detailList.value = []
|
||||
return
|
||||
}
|
||||
loading.value = true
|
||||
try {
|
||||
const isSpace = detailViewMode.value === 'space'
|
||||
const payload: any = { stock_id: stockId }
|
||||
if (isSpace) payload.group_by_space = true
|
||||
const res: any = await inventoryApi.getInventoryListByStockId(payload)
|
||||
if (res && (res.code === 200 || res.code === 1 || res.flag === 'success')) {
|
||||
const data = res.data || res
|
||||
const rows = Array.isArray(data.list) ? data.list : []
|
||||
detailList.value = rows.map((item: any) =>
|
||||
isSpace ? normalizeSpaceRow(item) : normalizeDetailRow(item)
|
||||
)
|
||||
} else {
|
||||
detailList.value = []
|
||||
}
|
||||
await nextTick()
|
||||
detailTableRef.value?.clearSelection?.()
|
||||
currentRow.value = null
|
||||
} catch (e) {
|
||||
console.error('加载库存明细失败', e)
|
||||
detailList.value = []
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 将接口明细行归一化为与主列表批次行一致的表格结构 */
|
||||
function normalizeDetailRow(item: any) {
|
||||
const row = normalizeRow(item)
|
||||
row.storage_id = item.id ?? item.storage_id ?? null
|
||||
row.stock_id = item.stock_id ?? item.stock?.id ?? null
|
||||
row.item_code = item.stock?.item_code || item.item_code || ''
|
||||
row.item_name = item.stock?.item_name || item.item_name || ''
|
||||
row.batch_no = item.batch_no || ''
|
||||
row.production_date = item.production_date || ''
|
||||
row.expiry_date = item.expiry_date || ''
|
||||
row.space_code = formatInventorySpaceLabel(item.space, '--')
|
||||
row.space_id = item.space_id ?? item.space?.id ?? null
|
||||
row.quantity = item.quantity ?? 0
|
||||
row.available_quantity = item.available_quantity ?? 0
|
||||
row.locked_quantity = item.locked_quantity ?? 0
|
||||
return row
|
||||
}
|
||||
|
||||
function openTransferDialog(mode: TransferMode) {
|
||||
if (mode === 'location' && !canTransferByLocation.value) {
|
||||
ElMessage.warning('当前记录缺少库存记录 ID,请在左侧查询设置中开启「按批次查询」后选择明细行')
|
||||
ElMessage.warning('请先在下方明细列表勾选一条库存记录')
|
||||
return
|
||||
}
|
||||
if (mode === 'product' && !canTransferByProduct.value) {
|
||||
ElMessage.warning('当前记录不支持按商品移库(需有库位与商品,且非多批次管理商品)')
|
||||
ElMessage.warning('当前商品不支持按商品移库(需未开启批次管理,且有库位与商品)')
|
||||
return
|
||||
}
|
||||
transferMode.value = mode
|
||||
@ -333,8 +445,47 @@ async function confirmTransfer() {
|
||||
}
|
||||
}
|
||||
|
||||
/** 按库位汇总行归一化(无批次字段,含库位/数量/批次数/入库时间) */
|
||||
function normalizeSpaceRow(item: any) {
|
||||
const row = normalizeRow(item)
|
||||
row.space_id = item.space_id ?? item.space?.id ?? null
|
||||
row.stock_id = item.stock_id ?? item.stock?.id ?? null
|
||||
row.space_code = formatInventorySpaceLabel(item.space, '--')
|
||||
row.quantity = item.quantity ?? 0
|
||||
row.available_quantity = item.available_quantity ?? 0
|
||||
row.locked_quantity = item.locked_quantity ?? 0
|
||||
row.batch_count = Number(item.batch_count || 0)
|
||||
row.first_inbound_time = item.first_inbound_time || ''
|
||||
row.last_inbound_time = item.last_inbound_time || ''
|
||||
row.storage_id = null
|
||||
return row
|
||||
}
|
||||
|
||||
watch(detailViewMode, () => {
|
||||
if (!props.groupByBatch) void loadDetailListByStockId()
|
||||
})
|
||||
|
||||
watch(() => [props.id, props.row, props.groupByBatch], loadData, { immediate: true })
|
||||
|
||||
onMounted(() => {
|
||||
const updateTableHeight = () => {
|
||||
const el = tableWrapRef.value
|
||||
if (!el) return
|
||||
const h = el.clientHeight
|
||||
if (h > 0) tableHeight.value = h
|
||||
}
|
||||
updateTableHeight()
|
||||
if (typeof ResizeObserver !== 'undefined') {
|
||||
tableResizeObserver = new ResizeObserver(updateTableHeight)
|
||||
if (tableWrapRef.value) tableResizeObserver.observe(tableWrapRef.value)
|
||||
}
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
tableResizeObserver?.disconnect()
|
||||
tableResizeObserver = null
|
||||
})
|
||||
|
||||
watch(targetSpace, (val) => {
|
||||
if (spaceInfoTimer) clearTimeout(spaceInfoTimer)
|
||||
spaceName.value = ''
|
||||
@ -381,14 +532,28 @@ watch(targetSpace, (val) => {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
|
||||
.main-content {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.panel-actions {
|
||||
padding-bottom: 8px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.detail-table-wrap {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.transfer-btn-wrap {
|
||||
|
||||
@ -11,7 +11,6 @@
|
||||
@condition-change="handleConditionChange"
|
||||
@reset="handleConditionReset"
|
||||
@condition-clear="handleConditionClear"
|
||||
@field-action="handleScanBoxFieldAction"
|
||||
/>
|
||||
|
||||
<div class="main-content">
|
||||
@ -147,18 +146,11 @@
|
||||
:error="exportTaskProgress.error"
|
||||
:update-time="exportTaskProgress.updateTime"
|
||||
/>
|
||||
|
||||
<InventoryStockPickerDialog
|
||||
v-model="stockPickerVisible"
|
||||
:store-id="stockPickerStoreId"
|
||||
:selected-items="stockPickerSelectedItems"
|
||||
@confirm="handleStockPickerConfirm"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, computed, nextTick } from 'vue'
|
||||
import { ref, reactive, onMounted, computed } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import ScanBox from '@/components/ScanBox/index.vue'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
@ -178,14 +170,13 @@ import {
|
||||
formatInventoryBarcodes,
|
||||
formatInventoryFlagLabel,
|
||||
formatInventoryOptionalText,
|
||||
formatInventorySpaceLabel,
|
||||
isInventoryFlagEnabled,
|
||||
productstockColums,
|
||||
} from './inventory-config'
|
||||
|
||||
import entrydetail from './component/panelstockdetail.vue'
|
||||
import log from './component/log.vue'
|
||||
import InventoryStockPickerDialog from './component/InventoryStockPickerDialog.vue'
|
||||
import type { InventoryStockPickerItem } from './component/InventoryStockPickerDialog.vue'
|
||||
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
|
||||
import { useSettingsStore } from '@/stores/modules/settings'
|
||||
|
||||
@ -197,16 +188,13 @@ const containerHeight = computed(() =>
|
||||
|
||||
const scanBox = ref<any>(null)
|
||||
const upperTable = ref<any>(null)
|
||||
const stockPickerVisible = ref(false)
|
||||
const stockPickerStoreId = ref<number | undefined>(undefined)
|
||||
const stockPickerSelectedItems = ref<InventoryStockPickerItem[]>([])
|
||||
|
||||
const {
|
||||
splitStackRef,
|
||||
beginSplitDrag,
|
||||
lowerPaneStyle,
|
||||
upperPaneStyle
|
||||
} = useVerticalSplitPane({ defaultLowerPercent: 40 })
|
||||
} = useVerticalSplitPane({ defaultLowerPercent: 55 })
|
||||
|
||||
const upperPaneFullStyle = computed(() => ({
|
||||
flex: '1 1 auto',
|
||||
@ -432,6 +420,7 @@ async function loadData() {
|
||||
expiry_date: item.expiry_date || '',
|
||||
is_shelf_life_warning_triggered: Boolean(item.is_shelf_life_warning_triggered),
|
||||
store_name: item.store_name || item.stock?.store_name || '',
|
||||
batch_no: item.batch_no || '',
|
||||
quantity: item.quantity,
|
||||
available_quantity: item.available_quantity,
|
||||
locked_quantity: item.locked_quantity,
|
||||
@ -444,12 +433,18 @@ async function loadData() {
|
||||
// preserve original structures for child components that need full network shape
|
||||
stock: item.stock || null,
|
||||
space: item.space || null,
|
||||
space_code: formatInventorySpaceLabel(item.space, '--'),
|
||||
storage_id: item.storage_id ?? null,
|
||||
space_id: item.space_id ?? item.space?.id ?? null,
|
||||
__raw: item
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
// 汇总模式:后端聚合行不含库位,按商品批量拉取明细补全库位展示
|
||||
if (!groupByBatch.value && list.value.length) {
|
||||
await fillSpaceByStockDetail()
|
||||
}
|
||||
|
||||
const pager = data.pagination || {}
|
||||
pagination.total = pager.total || data.total || list.value.length
|
||||
} else {
|
||||
@ -467,6 +462,56 @@ async function loadData() {
|
||||
}
|
||||
}
|
||||
|
||||
/** 汇总模式主列表库位缓存:stock_id → 展示文本 */
|
||||
const stockSpaceCache = new Map<number, string>()
|
||||
|
||||
/** 汇总模式:为缺少库位的行按商品拉明细,聚合库位展示(单库位显示库位名,多库位显示“n个库位”) */
|
||||
async function fillSpaceByStockDetail() {
|
||||
const rowsNeed = list.value.filter((row: any) => row.space_code === '--')
|
||||
if (!rowsNeed.length) return
|
||||
await Promise.allSettled(
|
||||
rowsNeed.map(async (row: any) => {
|
||||
const stockId = Number(row.stock_id)
|
||||
if (!Number.isInteger(stockId) || stockId <= 0) return
|
||||
const cached = stockSpaceCache.get(stockId)
|
||||
if (cached !== undefined) {
|
||||
row.space_code = cached
|
||||
return
|
||||
}
|
||||
try {
|
||||
const res: any = await inventoryApi.getInventoryListByStockId({ stock_id: stockId })
|
||||
if (!(res && (res.code === 200 || res.code === 1 || res.flag === 'success'))) {
|
||||
stockSpaceCache.set(stockId, '--')
|
||||
return
|
||||
}
|
||||
const data = res.data || res
|
||||
const detailRows = Array.isArray(data.list) ? data.list : []
|
||||
const labels: string[] = Array.from(
|
||||
new Set<string>(
|
||||
detailRows
|
||||
.map((d: any) => formatInventorySpaceLabel(d.space))
|
||||
.filter((s: string) => Boolean(s))
|
||||
)
|
||||
)
|
||||
let label = '--'
|
||||
if (labels.length === 1) {
|
||||
label = labels[0] ?? '--'
|
||||
// 单库位时同时补全 space_id,供按商品移库等操作使用
|
||||
const firstDetail = detailRows.find((d: any) => d?.space_id ?? d?.space?.id)
|
||||
const sid = Number(firstDetail?.space_id ?? firstDetail?.space?.id)
|
||||
if (Number.isInteger(sid) && sid > 0) row.space_id = sid
|
||||
} else if (labels.length > 1) {
|
||||
label = `${labels.length}个库位`
|
||||
}
|
||||
row.space_code = label
|
||||
stockSpaceCache.set(stockId, label)
|
||||
} catch {
|
||||
stockSpaceCache.set(stockId, '--')
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
async function loadFilterData() {
|
||||
try {
|
||||
const [storesRes, presetRes]: any = await Promise.all([
|
||||
@ -503,64 +548,6 @@ function handleConditionReset() {
|
||||
loadData()
|
||||
}
|
||||
|
||||
function parseStockIdDraftValue(raw: unknown): number[] {
|
||||
if (raw === undefined || raw === null || raw === '') return []
|
||||
const values = Array.isArray(raw)
|
||||
? raw
|
||||
: String(raw).split(/[,,\s]+/)
|
||||
return values
|
||||
.map((item) => Number(String(item).trim()))
|
||||
.filter((id) => Number.isInteger(id) && id > 0)
|
||||
}
|
||||
|
||||
function resolveStoreIdFromScanBox(): number | undefined {
|
||||
const draft = scanBox.value?.getFieldDraft?.('store_id')
|
||||
const val = draft?.value
|
||||
if (Array.isArray(val)) {
|
||||
if (val.length === 1) {
|
||||
const storeId = Number(val[0])
|
||||
return Number.isInteger(storeId) && storeId > 0 ? storeId : undefined
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
const storeId = Number(val)
|
||||
return Number.isInteger(storeId) && storeId > 0 ? storeId : undefined
|
||||
}
|
||||
|
||||
function buildStockPickerSelectedItems(ids: number[]): InventoryStockPickerItem[] {
|
||||
return ids.map((itemId) => ({
|
||||
item_id: itemId,
|
||||
item_code: '',
|
||||
item_name: '',
|
||||
barcode: ''
|
||||
}))
|
||||
}
|
||||
|
||||
function handleScanBoxFieldAction(fieldKey: string) {
|
||||
if (fieldKey !== 'stock_id') return
|
||||
stockPickerStoreId.value = resolveStoreIdFromScanBox()
|
||||
const existingIds = parseStockIdDraftValue(scanBox.value?.getFieldDraft?.('stock_id')?.value)
|
||||
stockPickerSelectedItems.value = buildStockPickerSelectedItems(existingIds)
|
||||
stockPickerVisible.value = true
|
||||
}
|
||||
|
||||
async function handleStockPickerConfirm(items: InventoryStockPickerItem[]) {
|
||||
const pickedIds = items
|
||||
.map((item) => Number(item.item_id))
|
||||
.filter((id) => Number.isInteger(id) && id > 0)
|
||||
if (!pickedIds.length) {
|
||||
ElMessage.warning('未获取到有效商品ID')
|
||||
return
|
||||
}
|
||||
|
||||
const operator = pickedIds.length > 1 ? 'in' : 'eq'
|
||||
const value = pickedIds.join(',')
|
||||
|
||||
scanBox.value?.setFieldCondition?.('stock_id', { operator, value }, { autoSubmit: false })
|
||||
await nextTick()
|
||||
scanBox.value?.submit?.()
|
||||
}
|
||||
|
||||
function onSelectionChange(rows: any[]) {
|
||||
selectionRows.value = rows || []
|
||||
hasSelection.value = selectionRows.value.length > 0
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { scanWorkflowField } from '@/views/order/orderManagement/config/order-common-config'
|
||||
import { stockQueryScanField } from '@/views/order/orderManagement/config/order-common-config'
|
||||
|
||||
import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config'
|
||||
|
||||
@ -87,11 +87,8 @@ export const inventoryScanBoxConfig = {
|
||||
|
||||
export const availableFields: InventoryScanFieldConfig[] = [
|
||||
inventoryScanBasicField({
|
||||
label: '商品ID',
|
||||
value: 'stock_id',
|
||||
type: 'text',
|
||||
placeholder: '请输入商品ID',
|
||||
extraAction: { label: '编码筛选' }
|
||||
...stockQueryScanField,
|
||||
placeholder: '请输入商品编码/名称/条码'
|
||||
}),
|
||||
inventoryScanBasicField({ label: '货主', value: 'store_id', type: 'select', multiple: true, options: [] }),
|
||||
inventoryScanBasicField({ label: '库位', value: 'space_keyword', type: 'text', placeholder: '库位名称或编码' }),
|
||||
@ -216,6 +213,7 @@ export const productstockColums = [
|
||||
{ prop: 'production_date', label: '生产日期', width: '120' },
|
||||
{ prop: 'expiry_date', label: '到期日期', width: '120' },
|
||||
{ prop: 'store_name', label: '货主', width: '120' },
|
||||
{ prop: 'space_code', label: '库位', width: '120' },
|
||||
{ prop: 'quantity', label: '总数量', width: '100' },
|
||||
{ prop: 'available_quantity', label: '可用数量', width: '100' },
|
||||
{ prop: 'locked_quantity', label: '锁定数量', width: '100' },
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user