feat: 完成WMS系统权限体系与业务功能迭代
本提交完成了WMS系统的多维度优化升级: 1. 新增RBAC权限系统,支持角色/菜单/按钮三级权限管控 2. 重构库存盘点、物料管理、区域维护等模块的查询筛选与展示逻辑 3. 优化入库/出库/质检等业务流程,完善数据冗余与业务闭环 4. 移除旧装箱表,将装箱逻辑合并到出库主表 5. 新增前端权限判断工具、导出工具与端到端测试用例 6. 补充完善各类注释与数据库字段说明
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<script setup>
|
||||
defineOptions({ name: 'Stocktake' })
|
||||
import { nextTick, onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import request from '../utils/request'
|
||||
@@ -7,24 +8,122 @@ import { getRealName } from '../utils/auth'
|
||||
import PageHelp from '../components/PageHelp.vue'
|
||||
import { helpStocktake } from '../help'
|
||||
|
||||
/* ---------- 发起盘点(动态/静态/抽盘通过后端类型扩展,当前按全量快照) ---------- */
|
||||
/* ---------- 发起盘点(可选范围:全库 / 按区域 / 按物料) ---------- */
|
||||
const operator = getRealName()
|
||||
const starting = ref(false)
|
||||
const active = reactive({ no: '', totalTargets: 0 })
|
||||
const scopeVisible = ref(false)
|
||||
const scope = reactive({
|
||||
type: 'all', // all / zone / material
|
||||
zones: [], // 区域多选
|
||||
materialCodes: [], // 物料多选
|
||||
manageMode: 0, // 0全部 / 1结构件 / 2精密件
|
||||
qualityStatus: '' // 空=全部
|
||||
})
|
||||
|
||||
// 发起范围所需的字典
|
||||
const zonesDict = ref([])
|
||||
const materialsDict = ref([])
|
||||
async function loadScopeDicts() {
|
||||
try {
|
||||
const z = await request.get('/zone/picker')
|
||||
const arr = Array.isArray(z) ? z : (z?.list || [])
|
||||
zonesDict.value = arr.map(x => x.zoneCode || x.code).filter(Boolean)
|
||||
} catch { /* 忽略 */ }
|
||||
try {
|
||||
const m = await request.get('/material/query', { params: { page: 1, pageSize: 500 } })
|
||||
materialsDict.value = (m?.list || []).map(x => ({ code: x.code, name: x.name }))
|
||||
} catch { /* 忽略 */ }
|
||||
}
|
||||
|
||||
function openScope() {
|
||||
loadScopeDicts()
|
||||
scopeVisible.value = true
|
||||
}
|
||||
|
||||
async function startStocktake() {
|
||||
starting.value = true
|
||||
let zones, materialCodes
|
||||
if (scope.type === 'zone') zones = scope.zones
|
||||
if (scope.type === 'material') materialCodes = scope.materialCodes
|
||||
try {
|
||||
const data = await request.post('/stocktake/start', { operator })
|
||||
const data = await request.post('/stocktake/start', {
|
||||
operator,
|
||||
zones: zones?.length ? zones : undefined,
|
||||
materialCodes: materialCodes?.length ? materialCodes : undefined,
|
||||
manageMode: scope.manageMode || undefined,
|
||||
qualityStatus: scope.qualityStatus || undefined
|
||||
})
|
||||
active.no = data?.stocktakeNo || ''
|
||||
active.totalTargets = data?.totalTargets || 0
|
||||
ElMessage.success(`盘点已发起:盘点单号 ${active.no},目标 ${active.totalTargets} 项`)
|
||||
scopeVisible.value = false
|
||||
ElMessage.success(
|
||||
`盘点已发起:${scopeLabel()},盘点单号 ${active.no},目标 ${active.totalTargets} 项`
|
||||
)
|
||||
await loadHistory()
|
||||
} finally {
|
||||
starting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function scopeLabel() {
|
||||
if (scope.type === 'zone') return `按区域【${scope.zones.join('、')}】`
|
||||
if (scope.type === 'material') return `按物料【${scope.materialCodes.join('、')}】${scope.manageMode ? (scope.manageMode === 1 ? '(结构件)' : '(精密件)') : ''}`
|
||||
return '全库'
|
||||
}
|
||||
|
||||
/* ---------- 物料分布图(盘点前查看:某物料在哪些区域、各多少、共多少) ---------- */
|
||||
const distLoaded = ref(false)
|
||||
const distLoading = ref(false)
|
||||
const distRows = ref([]) // 聚合行(物料×区域,可能多条同物料)
|
||||
const distSummary = ref([]) // 按物料汇总
|
||||
const distFilter = reactive({ materialCode: '', zoneCode: '', manageMode: 0 })
|
||||
|
||||
async function loadDist() {
|
||||
distLoading.value = true
|
||||
try {
|
||||
const data = await request.get('/stock/query', {
|
||||
params: {
|
||||
materialCode: distFilter.materialCode.trim() || undefined,
|
||||
zoneCode: distFilter.zoneCode.trim() || undefined,
|
||||
manageMode: distFilter.manageMode || undefined,
|
||||
page: 1,
|
||||
pageSize: 500
|
||||
}
|
||||
})
|
||||
const list = data?.list || []
|
||||
// 按物料分组汇总(共多少)
|
||||
const byMat = {}
|
||||
for (const row of list) {
|
||||
const k = row.materialCode
|
||||
if (!byMat[k]) byMat[k] = {
|
||||
materialCode: k, materialName: row.materialName || '-',
|
||||
manageMode: row.manageMode, zones: new Set(),
|
||||
totalQty: 0, availQty: 0, lockedQty: 0, batchCount: 0, snCount: 0
|
||||
}
|
||||
const g = byMat[k]
|
||||
g.zones.add(row.zoneCode)
|
||||
g.totalQty += row.totalQty || 0
|
||||
g.availQty += row.availQty || 0
|
||||
g.lockedQty += row.lockedQty || 0
|
||||
g.batchCount += row.batchCount || 0
|
||||
g.snCount += row.snCount || 0
|
||||
}
|
||||
distRows.value = list
|
||||
distSummary.value = Object.values(byMat).map(g => ({
|
||||
...g,
|
||||
zones: Array.from(g.zones).join('、')
|
||||
}))
|
||||
distLoaded.value = true
|
||||
} finally {
|
||||
distLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function distSearch() {
|
||||
loadDist()
|
||||
}
|
||||
|
||||
/* ---------- 扫码快速盘点 ---------- */
|
||||
const recordForm = reactive({ targetId: '', scanQty: 1 })
|
||||
const recording = ref(false)
|
||||
@@ -125,15 +224,57 @@ onMounted(() => { loadHistory() })
|
||||
<el-card shadow="never" class="mb12" header="发起盘点">
|
||||
<el-descriptions :column="1" border size="small">
|
||||
<el-descriptions-item label="操作人">{{ operator || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="盘点范围">
|
||||
{{ active.no ? '(已完成发起)' : (scope.type === 'all' ? '全库' : scope.type === 'zone' ? `按区域【${scope.zones.join('、')}】` : `按物料【${scope.materialCodes.join('、')}】`) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="盘点单号">{{ active.no || '未发起' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="目标数量">{{ active.no ? `${active.totalTargets} 项` : '-' }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<el-button type="primary" class="mt12" :loading="starting"
|
||||
:disabled="!!active.no && !finishResult" @click="startStocktake">
|
||||
发起盘点(冻结库存快照)
|
||||
</el-button>
|
||||
<div class="mt12">
|
||||
<el-button type="primary" :loading="starting" :disabled="!!active.no && !finishResult"
|
||||
@click="openScope">
|
||||
发起盘点(可选范围)
|
||||
</el-button>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<!-- 选择盘点范围弹窗 -->
|
||||
<el-dialog v-model="scopeVisible" title="选择盘点范围" width="460px">
|
||||
<el-form label-width="90px">
|
||||
<el-form-item label="范围">
|
||||
<el-radio-group v-model="scope.type">
|
||||
<el-radio value="all">全库</el-radio>
|
||||
<el-radio value="zone">按区域</el-radio>
|
||||
<el-radio value="material">按物料</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="scope.type === 'zone'" label="区域">
|
||||
<el-select v-model="scope.zones" multiple filterable clearable placeholder="选择盘点区域" style="width:100%">
|
||||
<el-option v-for="z in zonesDict" :key="z" :value="z" :label="z" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<template v-if="scope.type === 'material'">
|
||||
<el-form-item label="物料">
|
||||
<el-select v-model="scope.materialCodes" multiple filterable clearable
|
||||
placeholder="选择盘点物料(可多选)" style="width:100%">
|
||||
<el-option v-for="m in materialsDict" :key="m.code"
|
||||
:value="m.code" :label="`${m.code} ${m.name || ''}`" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="类型">
|
||||
<el-select v-model="scope.manageMode" clearable placeholder="全部类型" style="width:100%">
|
||||
<el-option :value="1" label="结构件" />
|
||||
<el-option :value="2" label="精密件" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="scopeVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="starting" @click="startStocktake">确认发起</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<el-card shadow="never" header="完成盘点">
|
||||
<el-form label-width="120px">
|
||||
<el-form-item label="差异写回库存">
|
||||
@@ -200,6 +341,72 @@ onMounted(() => { loadHistory() })
|
||||
</el-table>
|
||||
</el-card>
|
||||
|
||||
<el-card shadow="never" class="mb12" header="物料分布图(盘点前查看:哪个物料在哪个区域、各多少、一共多少)">
|
||||
<el-form inline @submit.prevent="distSearch">
|
||||
<el-form-item label="物料编码">
|
||||
<el-input v-model="distFilter.materialCode" placeholder="物料编码(可空)" clearable style="width:180px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="区域">
|
||||
<el-input v-model="distFilter.zoneCode" placeholder="区域编码(可空)" clearable style="width:160px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="类型">
|
||||
<el-select v-model="distFilter.manageMode" clearable placeholder="全部类型" style="width:120px">
|
||||
<el-option :value="1" label="结构件" />
|
||||
<el-option :value="2" label="精密件" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" :loading="distLoading" @click="distSearch">查询</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-alert v-if="!distLoaded" type="info" :closable="false"
|
||||
title="点击「查询」查看当前库存物料分布(结构件按批次余量、精密件按 SN 计数)" style="margin-bottom:10px" />
|
||||
|
||||
<!-- 按物料汇总 -->
|
||||
<template v-if="distLoaded">
|
||||
<div class="dist-title">汇总:各物料总库存</div>
|
||||
<el-table :data="distSummary" border size="small" empty-text="暂无分布数据" class="mb12">
|
||||
<el-table-column prop="materialCode" label="物料编码" min-width="150" />
|
||||
<el-table-column prop="materialName" label="物料名称" min-width="150" />
|
||||
<el-table-column label="类型" width="90" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="row.manageMode === 1 ? '' : 'warning'" size="small">
|
||||
{{ row.manageMode === 1 ? '结构件' : '精密件' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="zones" label="分布区域" min-width="180" />
|
||||
<el-table-column prop="totalQty" label="总数" width="90" align="center" />
|
||||
<el-table-column prop="availQty" label="可用" width="90" align="center" />
|
||||
<el-table-column prop="lockedQty" label="锁定" width="90" align="center" />
|
||||
<el-table-column prop="batchCount" label="批次数" width="90" align="center" />
|
||||
<el-table-column prop="snCount" label="SN数" width="90" align="center" />
|
||||
</el-table>
|
||||
|
||||
<!-- 明细:物料 × 区域 -->
|
||||
<div class="dist-title">明细:物料分布在哪些区域、各多少</div>
|
||||
<el-table :data="distRows" border size="small" empty-text="暂无数据">
|
||||
<el-table-column prop="materialCode" label="物料编码" min-width="140" />
|
||||
<el-table-column prop="materialName" label="物料名称" min-width="140" />
|
||||
<el-table-column prop="zoneCode" label="区域" width="110" align="center" />
|
||||
<el-table-column label="类型" width="90" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="row.manageMode === 1 ? '' : 'warning'" size="small">
|
||||
{{ row.manageMode === 1 ? '结构件' : '精密件' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="qualityStatus" label="质量状态" width="100" align="center" />
|
||||
<el-table-column prop="totalQty" label="数量" width="90" align="center" />
|
||||
<el-table-column prop="availQty" label="可用" width="90" align="center" />
|
||||
<el-table-column prop="lockedQty" label="锁定" width="90" align="center" />
|
||||
<el-table-column prop="batchCount" label="批次数" width="90" align="center" />
|
||||
<el-table-column prop="snCount" label="SN数" width="90" align="center" />
|
||||
</el-table>
|
||||
</template>
|
||||
</el-card>
|
||||
|
||||
<el-card shadow="never" header="历史盘点单查询">
|
||||
<el-form inline @submit.prevent="loadHistory">
|
||||
<el-form-item label="盘点单号">
|
||||
@@ -238,4 +445,5 @@ onMounted(() => { loadHistory() })
|
||||
.mt12 { margin-top: 12px; }
|
||||
.tip { margin-left: 10px; color: #909399; font-size: 12px; }
|
||||
.bad { color: #f56c6c; font-weight: 700; }
|
||||
.dist-title { font-weight: 600; color: #606266; margin: 6px 0 8px; }
|
||||
</style>
|
||||
Reference in New Issue
Block a user