697 lines
22 KiB
Vue
697 lines
22 KiB
Vue
<template>
|
||
<div class="order-sub-container" :style="{ height: containerHeight }">
|
||
<scan-box
|
||
ref="scanBox"
|
||
cache-key="storage-inventory"
|
||
width="220px"
|
||
:tree-props="{ children: 'children', label: 'label' }"
|
||
:auto-submit="false"
|
||
: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">
|
||
<order-toolbar-button-group
|
||
:buttons="inventoryToolbarButtons"
|
||
:resolve-disabled="resolveButtonDisabled"
|
||
:resolve-loading="resolveButtonLoading"
|
||
:resolve-label="resolveButtonLabel"
|
||
:layout-key="toolbarLayoutKey"
|
||
@action="handleToolbarButtonClick"
|
||
/>
|
||
</div>
|
||
|
||
<div class="toolbar-right">
|
||
<span class="toolbar-label"></span>
|
||
<el-select v-model="groupByBatch" size="small" style="width:120px" @change="handleGroupByBatchChange">
|
||
<el-option label="汇总查询" :value="false" />
|
||
<el-option label="批次查询" :value="true" />
|
||
</el-select>
|
||
</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-inventory-list"
|
||
:enable-column-config="true"
|
||
:data="list"
|
||
:columns="columns"
|
||
:table-size="tableSize"
|
||
:pagination="pagination"
|
||
:show-index="true"
|
||
:show-actions="true"
|
||
:show-selection="true"
|
||
:loading="loading"
|
||
:queryTime="queryTime"
|
||
@current-change="handleRowClick"
|
||
@page-change="handlePageChange"
|
||
@page-size-change="handlePageSizeChange"
|
||
@refresh="loadData"
|
||
@selection-change="onSelectionChange"
|
||
>
|
||
<template #column-expiry_date="{ row }">
|
||
<span :class="{ 'expiry-date-expired': row.is_shelf_life_warning_triggered }">
|
||
{{ row.expiry_date || '--' }}
|
||
</span>
|
||
</template>
|
||
|
||
<template #column-is_batch_mgmt_enabled="{ row }">
|
||
<div style="text-align:center">
|
||
<el-tag :type="isInventoryFlagEnabled(row.is_batch_mgmt_enabled) ? 'success' : 'info'" size="small">
|
||
{{ formatInventoryFlagLabel(row.is_batch_mgmt_enabled) }}
|
||
</el-tag>
|
||
</div>
|
||
</template>
|
||
|
||
<template #column-is_shelf_life_mgmt="{ row }">
|
||
<div style="text-align:center">
|
||
<el-tag :type="isInventoryFlagEnabled(row.is_shelf_life_mgmt) ? 'success' : 'info'" size="small">
|
||
{{ formatInventoryFlagLabel(row.is_shelf_life_mgmt) }}
|
||
</el-tag>
|
||
</div>
|
||
</template>
|
||
|
||
<template #column-remaining_threshold_days="{ row }">
|
||
<span>{{ formatInventoryOptionalText(row.remaining_threshold_days) }}</span>
|
||
</template>
|
||
|
||
<template #column-is_shelf_life_warning_triggered="{ row }">
|
||
<div style="text-align:center">
|
||
<el-tag :type="row.is_shelf_life_warning_triggered ? 'danger' : 'success'" size="small">
|
||
{{ row.is_shelf_life_warning_triggered ? '预警' : '正常' }}
|
||
</el-tag>
|
||
</div>
|
||
</template>
|
||
|
||
<template #column-first_inbound_time="{ row }">
|
||
<span>{{ row.first_inbound_time || '--' }}</span>
|
||
</template>
|
||
|
||
<template #column-batch_count="{ row }">
|
||
<div style="text-align:center">{{ row.batch_count || 0 }}</div>
|
||
</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="logs" /> -->
|
||
</el-tabs>
|
||
</div>
|
||
|
||
<div class="detail-container">
|
||
<KeepAlive>
|
||
<component
|
||
:is="activeComponent"
|
||
:id="selectedEntryId"
|
||
:row="selectedRow"
|
||
:group-by-batch="groupByBatch"
|
||
@refresh="loadData"
|
||
/>
|
||
</KeepAlive>
|
||
</div>
|
||
</div>
|
||
|
||
<div v-else class="no-selection" :style="lowerPaneStyle">
|
||
<div class="empty-tip">
|
||
<p>请从上方列表中选择一项查看详情</p>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
</div>
|
||
</div>
|
||
|
||
<AsyncExportProgressDialog
|
||
v-model:visible="exportDialogVisible"
|
||
title="库存导出进度"
|
||
:loading="exportLoading"
|
||
:progress-percent="exportProgressPercent"
|
||
:progress-status="exportProgressStatus"
|
||
:status-label="exportStatusLabel"
|
||
:task-id="exportTaskProgress.taskId"
|
||
:message="exportTaskProgress.message"
|
||
:error="exportTaskProgress.error"
|
||
:update-time="exportTaskProgress.updateTime"
|
||
/>
|
||
</div>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
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'
|
||
import OrderToolbarButtonGroup from '@/views/order/orderManagement/component/OrderToolbarButtonGroup.vue'
|
||
import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config'
|
||
import { safeInvoke } from '@/utils/safe-invoke'
|
||
import AsyncExportProgressDialog from '@/components/AsyncExportProgressDialog.vue'
|
||
import { useAsyncExportTask, type AsyncExportPayload } from '@/composables/useAsyncExportTask'
|
||
import type { ExportDropdownItem } from '@/components/ExportModeDropdown.vue'
|
||
import * as indexApi from '@/api/index/index'
|
||
// import * as entryApi from '@/api/storage.entry/entry'
|
||
import * as inventoryApi from '@/api/storage.inventory/inventory'
|
||
|
||
import {
|
||
availableFields,
|
||
inventoryToolbarButtons,
|
||
formatInventoryBarcodes,
|
||
formatInventoryFlagLabel,
|
||
formatInventoryOptionalText,
|
||
formatInventorySpaceLabel,
|
||
isInventoryFlagEnabled,
|
||
productstockColums,
|
||
} from './inventory-config'
|
||
|
||
import entrydetail from './component/panelstockdetail.vue'
|
||
import log from './component/log.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 {
|
||
splitStackRef,
|
||
beginSplitDrag,
|
||
lowerPaneStyle,
|
||
upperPaneStyle
|
||
} = useVerticalSplitPane({ defaultLowerPercent: 55 })
|
||
|
||
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 presetTree = ref<any[]>([])
|
||
const availableFieldsRef = reactive(JSON.parse(JSON.stringify(availableFields)))
|
||
|
||
const activeTab = ref('details')
|
||
|
||
const list = ref<any[]>([])
|
||
const loading = ref(false)
|
||
const queryTime = ref(0)
|
||
|
||
// --- 异步导出 ---
|
||
const {
|
||
exportLoading,
|
||
exportDialogVisible,
|
||
exportTaskProgress,
|
||
exportProgressPercent,
|
||
exportProgressStatus,
|
||
exportStatusLabel,
|
||
submitExportTask,
|
||
resumeExportTaskFromStorage,
|
||
hasPendingExportTask
|
||
} = useAsyncExportTask({
|
||
storageKey: 'storage.inventory.export.taskId',
|
||
submitExport: (payload) => inventoryApi.exportInventory(payload as any),
|
||
queryProgress: (params) => inventoryApi.exportTaskProgress(params)
|
||
})
|
||
|
||
const exportDropdownItems: ExportDropdownItem[] = [
|
||
{ label: '导出选中', action: 'handleExportSelected' },
|
||
{ label: '导出全部', action: 'handleExportAll', divided: true }
|
||
]
|
||
|
||
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||
const tableSize = ref('small')
|
||
const groupByBatch = ref(false)
|
||
const columns = computed(() => {
|
||
const cols: any[] = JSON.parse(JSON.stringify(productstockColums))
|
||
if (groupByBatch.value) {
|
||
if (!cols.find((c: any) => c.prop === 'batch_no')) {
|
||
const batchCol = { prop: 'batch_no', label: '批次号', width: '120' }
|
||
const idx = cols.findIndex((c: any) => c.prop === 'item_name')
|
||
if (idx >= 0) cols.splice(idx + 1, 0, batchCol)
|
||
else cols.push(batchCol)
|
||
}
|
||
|
||
const warningColumns = [
|
||
{ prop: 'expiry_remaining_days', label: '剩余有效期', width: '110' },
|
||
{ prop: 'inventory_warning_level', label: '预警等级', width: '110' },
|
||
{ prop: 'inventory_warning_tip_text', label: '预警提示', width: '160' }
|
||
]
|
||
const expiryIdx = cols.findIndex((x: any) => x.prop === 'expiry_date')
|
||
for (let i = warningColumns.length - 1; i >= 0; i--) {
|
||
const c = warningColumns[i]
|
||
if (!c) continue
|
||
if (cols.find((x: any) => x.prop === c.prop)) continue
|
||
if (expiryIdx >= 0) cols.splice(expiryIdx + 1, 0, c)
|
||
else cols.push(c)
|
||
}
|
||
|
||
return cols
|
||
}
|
||
return cols.filter(
|
||
(col: any) =>
|
||
![
|
||
'production_date',
|
||
'expiry_date',
|
||
'expiry_remaining_days',
|
||
'inventory_warning_level',
|
||
'inventory_warning_tip_text'
|
||
].includes(col.prop)
|
||
)
|
||
})
|
||
|
||
|
||
const selectionRows = ref<any[]>([])
|
||
const hasSelection = ref(false)
|
||
const selectedEntryId = ref<number | string | null>(null)
|
||
// ── 工具栏状态 ──
|
||
const buttonLoadingMap = computed(() => ({
|
||
loading: loading.value,
|
||
exportLoading: exportLoading.value
|
||
}))
|
||
|
||
const buttonDisabledMap = computed(() => ({
|
||
hasNoSelection: !hasSelection.value
|
||
}))
|
||
|
||
const buttonLabelMap = computed(() => ({
|
||
detailToggleLabel: detailVisible.value ? '隐藏详情' : '显示详情'
|
||
}))
|
||
|
||
const toolbarLayoutKey = computed(() =>
|
||
JSON.stringify({
|
||
loading: buttonLoadingMap.value,
|
||
disabled: buttonDisabledMap.value,
|
||
labels: buttonLabelMap.value
|
||
})
|
||
)
|
||
|
||
function resolveButtonLoading(loadingKey?: string) {
|
||
if (!loadingKey) return false
|
||
return Boolean((buttonLoadingMap.value as Record<string, boolean>)[loadingKey])
|
||
}
|
||
|
||
function resolveButtonDisabled(disabledKey?: string) {
|
||
if (!disabledKey) return false
|
||
return Boolean((buttonDisabledMap.value as Record<string, boolean>)[disabledKey])
|
||
}
|
||
|
||
function resolveButtonLabel(defaultLabel: string, dynamicLabelKey?: string) {
|
||
if (!dynamicLabelKey) return defaultLabel
|
||
return (buttonLabelMap.value as Record<string, string>)[dynamicLabelKey] || defaultLabel
|
||
}
|
||
|
||
const toolbarActionMap: Record<string, () => void> = {
|
||
loadData: () => { void loadData() },
|
||
handleExportSelected: () => { void handleExportSelected() },
|
||
handleExportAll: () => { void handleExportAll() },
|
||
openColumnConfigPanel: () => openColumnConfigPanel(),
|
||
toggleDetailVisible: () => toggleDetailVisible(),
|
||
handleImport: () => handleImport(),
|
||
confirmBatchCancel: () => { void confirmBatchCancel() }
|
||
}
|
||
|
||
function handleToolbarButtonClick(action: ToolbarButtonConfig['action']) {
|
||
const handler = toolbarActionMap[action]
|
||
if (!handler) return
|
||
safeInvoke(() => handler())
|
||
}
|
||
const componentMap: Record<string, any> = {
|
||
details: entrydetail,
|
||
logs: log
|
||
}
|
||
|
||
const activeComponent = computed(() => componentMap[activeTab.value] || componentMap.details)
|
||
|
||
|
||
|
||
const selectedRow = computed(() => {
|
||
return list.value.find((i: any) => i.id === selectedEntryId.value) || null
|
||
})
|
||
|
||
onMounted(() => {
|
||
loadData()
|
||
loadFilterData()
|
||
resumeExportTaskFromStorage()
|
||
})
|
||
|
||
async function loadData() {
|
||
if (loading.value) return
|
||
loading.value = true
|
||
const start = Date.now()
|
||
|
||
try {
|
||
const rawWhere = scanBox.value?.getConditions?.() || {}
|
||
const where: Record<string, unknown> = { ...rawWhere }
|
||
|
||
// 解析库位关键字 → 库位ID
|
||
const rawSpaceVal = where.space_keyword
|
||
delete where.space_keyword
|
||
const spaceKeyword = rawSpaceVal && typeof rawSpaceVal === 'object'
|
||
? String((rawSpaceVal as any).value ?? '').trim()
|
||
: String(rawSpaceVal ?? '').trim()
|
||
if (spaceKeyword) {
|
||
try {
|
||
const spaceRes: any = await indexApi.searchSpace({ keyword: spaceKeyword, page: 1, pageSize: 20 })
|
||
const spaceData = spaceRes && (spaceRes.data || spaceRes.list || spaceRes)
|
||
const spaceList = Array.isArray(spaceData?.list) ? spaceData.list : Array.isArray(spaceData) ? spaceData : []
|
||
if (spaceList.length) {
|
||
const spaceIds = spaceList.map((s: any) => Number(s.id)).filter((id: number) => Number.isFinite(id) && id > 0)
|
||
if (spaceIds.length === 1) {
|
||
where.space_id = spaceIds[0]
|
||
} else if (spaceIds.length > 1) {
|
||
where.space_id = spaceIds
|
||
}
|
||
} else {
|
||
// 未匹配到任何库位,设一个不可能的值使结果为空
|
||
where.space_id = -1
|
||
}
|
||
} catch {
|
||
where.space_id = -1
|
||
}
|
||
}
|
||
|
||
const params: any = {
|
||
pagination: { page: pagination.currentPage, pageSize: pagination.pageSize },
|
||
where,
|
||
group_by_batch: groupByBatch.value
|
||
}
|
||
|
||
const res: any = await inventoryApi.getInventoryList(params)
|
||
if (res && (res.code === 200 || res.code === 1 || res.flag === 'success')) {
|
||
const data = res.data || res
|
||
const rows = Array.isArray(data.list) ? data.list : []
|
||
|
||
list.value = rows.map((item: any) => {
|
||
const rowId = `${item.stock_id}`
|
||
return {
|
||
id: rowId,
|
||
stock_id: item.stock_id,
|
||
item_code: item.stock?.item_code || '',
|
||
item_name: item.stock?.item_name || '',
|
||
barcodes: formatInventoryBarcodes(item.stock?.barcodes),
|
||
sku_property: formatInventoryOptionalText(item.stock?.sku_property),
|
||
stock_unit: formatInventoryOptionalText(item.stock?.stock_unit),
|
||
production_date: item.production_date || '',
|
||
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,
|
||
first_inbound_time: item.first_inbound_time || '',
|
||
last_inbound_time: item.last_inbound_time,
|
||
batch_count: Number(item.batch_count || 0),
|
||
is_shelf_life_mgmt: item.stock?.is_shelf_life_mgmt ?? '',
|
||
remaining_threshold_days: item.stock?.remaining_threshold_days ?? '',
|
||
is_batch_mgmt_enabled: item.stock?.is_batch_mgmt_enabled,
|
||
// 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 {
|
||
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
|
||
}
|
||
}
|
||
|
||
/** 汇总模式主列表库位缓存: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([
|
||
indexApi.loadStores(),
|
||
indexApi.fastWhereTree('entry')
|
||
])
|
||
if (storesRes && storesRes.code === 200) {
|
||
const f = availableFieldsRef.find((i: any) => i.value === 'store_id')
|
||
if (f) f.options = storesRes.stores || []
|
||
}
|
||
if (presetRes && presetRes.code === 200) {
|
||
presetTree.value = presetRes.presetTree || []
|
||
}
|
||
} catch (e) {
|
||
console.error('加载筛选配置失败', e)
|
||
}
|
||
}
|
||
|
||
function handleConditionChange(condition: any) {
|
||
pagination.currentPage = 1
|
||
loadData()
|
||
}
|
||
|
||
const handleConditionClear = () => {
|
||
pagination.currentPage = 1
|
||
loadData()
|
||
}
|
||
|
||
function handleConditionReset() {
|
||
pagination.currentPage = 1
|
||
if (scanBox.value?.reset) {
|
||
scanBox.value.reset()
|
||
}
|
||
loadData()
|
||
}
|
||
|
||
function onSelectionChange(rows: any[]) {
|
||
selectionRows.value = rows || []
|
||
hasSelection.value = selectionRows.value.length > 0
|
||
}
|
||
|
||
async 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()
|
||
}
|
||
|
||
function handleGroupByBatchChange() {
|
||
pagination.currentPage = 1
|
||
selectedEntryId.value = null
|
||
loadData()
|
||
}
|
||
|
||
function handleCreateEntry() {
|
||
ElMessage.info('新建入库单')
|
||
}
|
||
|
||
|
||
async function confirmBatchCancel() {
|
||
if (!selectionRows.value.length) {
|
||
ElMessage.warning('请先选择要作废的入库单')
|
||
return
|
||
}
|
||
try {
|
||
await ElMessageBox.confirm(`确定要批量作废 ${selectionRows.value.length} 个入库单吗?`, '确认', { type: 'warning' })
|
||
// 调用作废 API
|
||
ElMessage.success('操作成功')
|
||
loadData()
|
||
} catch (e) {}
|
||
}
|
||
|
||
function buildExportPayload(): AsyncExportPayload {
|
||
const rawWhere = scanBox.value?.getConditions?.() || {}
|
||
return {
|
||
where: { ...rawWhere },
|
||
group_by_batch: groupByBatch.value
|
||
}
|
||
}
|
||
|
||
async function handleExportSelected() {
|
||
if (!selectionRows.value.length) {
|
||
ElMessage.warning('请先选择要导出的库存记录')
|
||
return
|
||
}
|
||
if (hasPendingExportTask()) {
|
||
ElMessage.warning('检测到未完成导出任务,请等待当前任务完成后再试')
|
||
resumeExportTaskFromStorage()
|
||
return
|
||
}
|
||
const stockIds = selectionRows.value
|
||
.map((row: any) => Number(row.stock_id))
|
||
.filter((id: number) => Number.isFinite(id) && id > 0)
|
||
if (!stockIds.length) {
|
||
ElMessage.warning('选中的记录无有效 stock_id')
|
||
return
|
||
}
|
||
await submitExportTask({
|
||
where: { stock_id: stockIds.length === 1 ? stockIds[0] : stockIds },
|
||
group_by_batch: groupByBatch.value
|
||
})
|
||
}
|
||
|
||
async function handleExportAll() {
|
||
if (!list.value.length) {
|
||
ElMessage.warning('当前无数据可导出')
|
||
return
|
||
}
|
||
if (hasPendingExportTask()) {
|
||
ElMessage.warning('检测到未完成导出任务,请等待当前任务完成后再试')
|
||
resumeExportTaskFromStorage()
|
||
return
|
||
}
|
||
await submitExportTask(buildExportPayload())
|
||
}
|
||
|
||
function handleExportAction(action: string) {
|
||
if (action === 'handleExportAll') {
|
||
void handleExportAll()
|
||
return
|
||
}
|
||
void handleExportSelected()
|
||
}
|
||
|
||
function handleImport() {
|
||
ElMessage.info('导入功能')
|
||
}
|
||
|
||
</script>
|
||
|
||
<style scoped lang="scss">
|
||
@use "../../order/orderManagement/styles/order-sub.scss";
|
||
|
||
.order-sub-container .main-content {
|
||
.toolbar-right {
|
||
display: flex;
|
||
flex-direction: row;
|
||
gap: 8px;
|
||
align-items: center;
|
||
|
||
.toolbar-label {
|
||
font-size: 12px;
|
||
color: #606266;
|
||
}
|
||
}
|
||
|
||
.expiry-date-expired {
|
||
color: #f56c6c;
|
||
font-weight: 600;
|
||
}
|
||
|
||
.inventory-warning-level {
|
||
font-weight: 600;
|
||
}
|
||
}
|
||
|
||
.order-sub-container .main-content .lower-level .detail-container {
|
||
padding: 10px;
|
||
overflow: auto;
|
||
}
|
||
|
||
.empty-tip {
|
||
text-align: center;
|
||
font-size: 14px;
|
||
}
|
||
</style>
|