This commit is contained in:
liufumingren 2026-06-18 02:33:10 +08:00
parent 699fc15a79
commit 6dda813dc8
7 changed files with 549 additions and 8 deletions

View File

@ -0,0 +1,33 @@
import request from '@/utils/request'
const v = '1.0'
/**
* 分拣缺货补货需求计算(仓库级别)
* 自动从用户上下文获取仓库,查询所有未完成储位分配的订单,
* 计算每个SKU在分拣区与存货区的库存量、订单需求量、分拣区缺口及建议补货量。
* @param pagination 分页参数 { page, pageSize }
* @param order 排序参数,如 { field: 'shortage', direction: 'desc' }
*/
export function getReplenishmentDemand(
pagination?: { page: number; pageSize: number },
order?: { field: string; direction: string } | null
) {
const data: Record<string, any> = {
pagination: pagination || { page: 1, pageSize: 50 },
}
if (order) {
data.order = order
}
return request({
url: '/system',
method: 'post',
params: {
method: 'storage.management.replenishmentDemand',
v,
timestamp: new Date().getTime()
},
data,
isSystemApi: true
} as any)
}

View File

@ -16,6 +16,7 @@ export const componentMap: Record<string, any> = {
'stock/index': () => import('@/views/stock/stock/index.vue'),
'stock/storestock/index': () => import('@/views/stock/storestock/index.vue'),
'stock/combo_stock/index': () => import('@/views/stock/combo_stock/index.vue'),
'stock/pickingShortage/index': () => import('@/views/stock/pickingShortage/index.vue'),
'storage/receiving': () => import('@/views/storage/receiving/index.vue'),
'storage/report': () => import('@/views/storage/report/index.vue'),
'storage/entry': () => import('@/views/storage/entry/index.vue'),

View File

@ -24,6 +24,17 @@
:layout-key="toolbarLayoutKey"
@action="handleToolbarButtonClick"
/>
<el-select
v-model="storageAssignFilter"
placeholder="储位分配"
size="small"
clearable
style="width: 130px"
@change="handleStorageAssignFilterChange"
>
<el-option label="未分配" value="unassigned" />
<el-option label="已完成" value="completed" />
</el-select>
<template v-for="(btn, index) in expectionOrderbuttonList" :key="index">
<el-dropdown
@ -479,6 +490,11 @@ const selectedOrderId = ref<number | string | null>(null)
const detailVisible = ref(true)
const quickSearch = ref('')
const storageAssignFilter = ref<string>('')
const handleStorageAssignFilterChange = () => {
pagination.currentPage = 1
loadData()
}
const toolbarButtons = exceptionToolbarButtons
const qrDialogVisible = ref(false)
const currentWaybillCode = ref('')
@ -667,6 +683,20 @@ function buildExportWhere() {
type: 'text'
}
}
// 储位分配筛选:未分配合并 unassigned/assigning/error
if (storageAssignFilter.value === 'unassigned') {
where.storage_status = {
operator: 'in',
value: ['unassigned', 'assigning', 'error'],
type: 'text'
}
} else if (storageAssignFilter.value === 'completed') {
where.storage_status = {
operator: 'eq',
value: 'completed',
type: 'text'
}
}
return sanitizeExpectionListWhere(where)
}

View File

@ -26,6 +26,17 @@
:layout-key="toolbarLayoutKey"
@action="handleToolbarButtonClick"
/>
<el-select
v-model="storageAssignFilter"
placeholder="储位分配"
size="small"
clearable
style="width: 130px"
@change="handleStorageAssignFilterChange"
>
<el-option label="未分配" value="unassigned" />
<el-option label="已完成" value="completed" />
</el-select>
</div>
<div class="toolbar-right">
@ -418,6 +429,11 @@ const selectedOrderId = ref<number | string | null>(null)
const detailVisible = ref(true)
const quickSearch = ref('')
const storageAssignFilter = ref<string>('')
const handleStorageAssignFilterChange = () => {
pagination.currentPage = 1
loadData()
}
const toolbarButtons = pendingToolbarButtons
const qrDialogVisible = ref(false)
const currentWaybillCode = ref('')
@ -550,6 +566,20 @@ function buildExportWhere() {
type: 'text'
}
}
// 储位分配筛选:未分配合并 unassigned/assigning/error
if (storageAssignFilter.value === 'unassigned') {
where.storage_status = {
operator: 'in',
value: ['unassigned', 'assigning', 'error'],
type: 'text'
}
} else if (storageAssignFilter.value === 'completed') {
where.storage_status = {
operator: 'eq',
value: 'completed',
type: 'text'
}
}
return sanitizePendingListWhere(where)
}

View File

@ -0,0 +1,450 @@
<template>
<div class="picking-shortage-container">
<!-- 主内容区域 -->
<div class="main-content">
<!-- 汇总卡片 -->
<div class="summary-bar">
<div class="summary-item">
<span class="summary-label">SKU总数</span>
<span class="summary-value">{{ summary.total_skus ?? '-' }}</span>
</div>
<div class="summary-item">
<span class="summary-label">缺货SKU</span>
<span class="summary-value warning">{{ summary.total_shortage_skus ?? '-' }}</span>
</div>
<div class="summary-item">
<span class="summary-label">建议补货总量</span>
<span class="summary-value primary">{{ summary.total_replenishment_needed ?? '-' }}</span>
</div>
<div class="summary-item">
<span class="summary-label">真实缺货SKU</span>
<span class="summary-value danger">{{ summary.total_true_shortage_skus ?? '-' }}</span>
</div>
</div>
<!-- 工具栏 -->
<div class="toolbar">
<div class="toolbar-left">
<el-button type="primary" size="small" @click="handleRefresh">
刷新
</el-button>
<el-button
type="success"
size="small"
:disabled="!hasSelection"
@click="handleExport"
>
导出
</el-button>
</div>
<div class="toolbar-right">
<el-input
v-model="searchKeyword"
placeholder="请输入搜索关键词"
size="small"
clearable
style="width: 220px"
@keyup.enter="handleSearch"
>
<template #append>
<el-button @click="handleSearch">
<el-icon><Search /></el-icon>
</el-button>
</template>
</el-input>
</div>
</div>
<!-- 数据表格 -->
<div class="table-wrapper">
<el-table
ref="tableRef"
v-loading="loading"
:data="tableData"
border
stripe
style="width: 100%"
row-key="stock_id"
@selection-change="handleSelectionChange"
@sort-change="handleSortChange"
>
<el-table-column type="selection" width="55" fixed="left" />
<el-table-column type="expand">
<template #default="{ row }">
<div class="expand-content" v-if="row.replenishment_locations && row.replenishment_locations.length > 0">
<div class="expand-title">补货库位明细</div>
<el-table
:data="row.replenishment_locations"
border
size="small"
style="width: 100%"
>
<el-table-column
prop="space_code"
label="库位编码"
min-width="180"
/>
<el-table-column
prop="space_name"
label="库位名称"
min-width="140"
/>
<el-table-column
prop="available_quantity"
label="可用数量"
min-width="100"
align="right"
/>
</el-table>
</div>
<div class="expand-empty" v-else>
无可用补货库位(存货区与分拣区均无库存)
</div>
</template>
</el-table-column>
<el-table-column
prop="stock_code"
label="SKU编码"
min-width="140"
show-overflow-tooltip
>
<template #default="{ row }">
<span>{{ row.stock_code || '-' }}</span>
</template>
</el-table-column>
<el-table-column
prop="stock_name"
label="商品名称"
min-width="160"
show-overflow-tooltip
>
<template #default="{ row }">
<span>{{ row.stock_name || '-' }}</span>
</template>
</el-table-column>
<el-table-column
prop="pick_zone_quantity"
label="分拣区库存"
min-width="110"
align="right"
sortable="custom"
/>
<el-table-column
prop="storage_zone_quantity"
label="存货区库存"
min-width="110"
align="right"
sortable="custom"
/>
<el-table-column
prop="total_demand"
label="总需求量"
min-width="100"
align="right"
sortable="custom"
/>
<el-table-column
prop="shortage"
label="缺口数量"
min-width="100"
align="right"
sortable="custom"
>
<template #default="{ row }">
<span :class="{ 'shortage-text': row.shortage > 0 }">{{ row.shortage }}</span>
</template>
</el-table-column>
<el-table-column
prop="replenishment_needed"
label="建议补货量"
min-width="110"
align="right"
sortable="custom"
>
<template #default="{ row }">
<el-tag
:type="row.replenishment_needed > 0 ? 'warning' : 'success'"
size="small"
>
{{ row.replenishment_needed }}
</el-tag>
</template>
</el-table-column>
<el-table-column
prop="replenishment_status"
label="补货状态"
min-width="110"
align="center"
>
<template #default="{ row }">
<el-tag
:type="statusTagType(row.replenishment_status)"
size="small"
>
{{ statusLabel(row.replenishment_status) }}
</el-tag>
</template>
</el-table-column>
<el-table-column
label="补货库位"
min-width="100"
align="center"
>
<template #default="{ row }">
<el-tag
v-if="row.replenishment_locations && row.replenishment_locations.length > 0"
type="success"
size="small"
>
{{ row.replenishment_locations.length }}个
</el-tag>
<span v-else class="no-location-text">-</span>
</template>
</el-table-column>
</el-table>
</div>
<!-- 分页 -->
<div class="pagination-wrapper">
<el-pagination
v-model:current-page="pagination.page"
v-model:page-size="pagination.pageSize"
:total="pagination.total"
:page-sizes="[20, 50, 100, 200]"
layout="total, sizes, prev, pager, next, jumper"
@size-change="handleSizeChange"
@current-change="handlePageChange"
/>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue'
import { ElMessage } from 'element-plus'
import { Search } from '@element-plus/icons-vue'
import { getReplenishmentDemand } from '@/api/stock/pickingShortage'
// ==================== 搜索相关 ====================
const searchKeyword = ref('')
const handleSearch = () => {
pagination.page = 1
fetchData()
}
// ==================== 汇总信息 ====================
const summary = ref<Record<string, number>>({})
// ==================== 排序相关 ====================
const sortParams = ref<{ field: string; direction: string } | null>(null)
const handleSortChange = (sort: { prop: string; order: string }) => {
if (sort.order) {
sortParams.value = { field: sort.prop, direction: sort.order === 'ascending' ? 'asc' : 'desc' }
} else {
sortParams.value = null
}
pagination.page = 1
fetchData()
}
// ==================== 表格相关 ====================
const tableRef = ref()
const loading = ref(false)
const tableData = ref<any[]>([])
const selectedRows = ref<any[]>([])
const hasSelection = ref(false)
const pagination = reactive({
page: 1,
pageSize: 50,
total: 0,
})
const handleSelectionChange = (rows: any[]) => {
selectedRows.value = rows
hasSelection.value = rows.length > 0
}
// ==================== 数据获取 ====================
const fetchData = async () => {
loading.value = true
try {
const res: any = await getReplenishmentDemand(
{ page: pagination.page, pageSize: pagination.pageSize },
sortParams.value
)
if (res?.flag === 'success' || res?.code === 1) {
tableData.value = res?.list || []
summary.value = res?.summary || {}
pagination.total = res?.total || res?.pagination?.total || tableData.value.length
} else {
ElMessage.error(res?.message || res?.msg || '获取数据失败')
}
} catch (error) {
console.error('获取分拣缺货补货需求失败:', error)
ElMessage.error('获取数据失败,请稍后重试')
} finally {
loading.value = false
}
}
// ==================== 工具栏操作 ====================
const handleRefresh = () => {
fetchData()
}
const handleExport = () => {
ElMessage.info('导出功能开发中...')
}
// ==================== 分页操作 ====================
const handleSizeChange = () => {
pagination.page = 1
fetchData()
}
const handlePageChange = () => {
fetchData()
}
// ==================== 状态映射 ====================
const statusLabel = (status: string) => {
const map: Record<string, string> = {
true_shortage: '真实缺货',
replenishable: '可补货',
sufficient: '充足',
}
return map[status] || status || '-'
}
const statusTagType = (status: string) => {
const map: Record<string, string> = {
true_shortage: 'danger',
replenishable: 'warning',
sufficient: 'success',
}
return map[status] || 'info'
}
// ==================== 生命周期 ====================
onMounted(() => {
fetchData()
})
</script>
<style lang="scss" scoped>
.picking-shortage-container {
height: 100%;
padding: 16px;
background-color: #f5f7fa;
}
.main-content {
flex: 1;
display: flex;
flex-direction: column;
min-width: 0;
background: #fff;
border-radius: 4px;
padding: 16px;
}
.summary-bar {
display: flex;
gap: 16px;
margin-bottom: 16px;
padding: 12px 16px;
background: #f0f5ff;
border-radius: 6px;
border: 1px solid #d6e4ff;
.summary-item {
display: flex;
flex-direction: column;
align-items: center;
flex: 1;
min-width: 0;
.summary-label {
font-size: 12px;
color: #909399;
margin-bottom: 4px;
}
.summary-value {
font-size: 20px;
font-weight: 600;
color: #303133;
&.warning {
color: #e6a23c;
}
&.primary {
color: #409eff;
}
&.danger {
color: #f56c6c;
}
}
}
}
.toolbar {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16px;
flex-wrap: wrap;
gap: 8px;
.toolbar-left,
.toolbar-right {
display: flex;
align-items: center;
gap: 8px;
}
}
.table-wrapper {
flex: 1;
overflow: auto;
}
.pagination-wrapper {
display: flex;
justify-content: flex-end;
margin-top: 16px;
}
.shortage-text {
color: #f56c6c;
font-weight: bold;
}
.expand-content {
padding: 8px 16px;
.expand-title {
font-size: 13px;
font-weight: 600;
color: #303133;
margin-bottom: 8px;
}
}
.expand-empty {
padding: 16px;
text-align: center;
color: #909399;
font-size: 13px;
}
.no-location-text {
color: #c0c4cc;
}
</style>

View File

@ -38,8 +38,7 @@ export const availableFields = [
{ label: '备注',value: 'remark',type: 'text' },
{ label: 'ERP备注',value: 'erp_remark',type: 'text' },
{ label: '操作员ID',value: 'operator_id',type: 'text' },
{ label: '申请起始日期',value: 'start_date',type: 'daterange' },
{ label: '申请结束日期',value: 'end_date',type: 'daterange' },
{ label: '创建时间',value: 'order_create_time',type: 'datetimerange' },
{ label: '',value: ''},
{ label: '',value: ''},
{ label: '',value: ''},

View File

@ -83,7 +83,7 @@
</template>
<template #column-source_type="{ row }">
<el-tag size="small" :type="row.source_type === 'WMS' ? '' : row.source_type === 'QM' ? 'primary' : 'success'">
<el-tag size="small" :type="row.source_type === 'WMS' ? '' : row.source_type === 'QM' ? 'warning' : 'success'">
{{ translateField('source_type', row.source_type) }}
</el-tag>
</template>
@ -292,6 +292,7 @@ function normalizeToWhere(condition: any) {
}
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'
@ -305,7 +306,7 @@ function normalizeToWhere(condition: any) {
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' ? 'between' : 'eq')),
operator: c.operator || (Array.isArray(c.value) ? 'in' : (fieldType === 'daterange' || fieldType === 'datetimerange' ? 'between' : 'eq')),
value: c.value,
type: c.type || mapType(fieldType, c.value)
}
@ -314,7 +315,7 @@ function normalizeToWhere(condition: any) {
if (c === null || c === undefined || c === '' || (Array.isArray(c) && c.length === 0)) return null
const simpleOp = fieldType === 'daterange' ? 'between' : 'eq'
const simpleOp = (fieldType === 'daterange' || fieldType === 'datetimerange') ? 'between' : 'eq'
const simpleType = mapType(fieldType, c)
return { operator: simpleOp, value: c, type: simpleType }
}
@ -391,9 +392,6 @@ async function loadData() {
// 优先使用由 ScanBox 提交并经过规范化的条件(包含 operator 等信息)
const where = currentCondition.value || normalizeToWhere(scanBox.value?.getConditions?.() || {})
// 固定条件:订单状态只显示待入库或部分入库(始终强制)
where.order_status = { operator: 'in', value: ['PENDING', 'PARTIAL', 'PARTIAL_RECEIVED'], type: 'select' }
const params: StorageEntryListParams = {
pagination: {
page: pagination.currentPage,