feat: 库位按物料公司白名单显示——WarehouseSelector 支持 allowedTopPrefixes,IRIS 仅显 Y、LICA 显 C/L
This commit is contained in:
@ -56,12 +56,12 @@
|
|||||||
|
|
||||||
<!-- 列表展示区 -->
|
<!-- 列表展示区 -->
|
||||||
<div class="selector-body">
|
<div class="selector-body">
|
||||||
<div v-if="currentList.length === 0" class="empty-tip">
|
<div v-if="displayList.length === 0" class="empty-tip">
|
||||||
当前层级无库位数据
|
当前层级无库位数据
|
||||||
</div>
|
</div>
|
||||||
<ul v-else class="location-list">
|
<ul v-else class="location-list">
|
||||||
<li
|
<li
|
||||||
v-for="item in currentList"
|
v-for="item in displayList"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
class="location-item"
|
class="location-item"
|
||||||
:class="{ 'is-selected': item.full_path === modelValue }"
|
:class="{ 'is-selected': item.full_path === modelValue }"
|
||||||
@ -119,10 +119,13 @@ interface WarehouseItem {
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
modelValue?: string
|
modelValue?: string
|
||||||
|
// 顶层库位白名单前缀:仅显示 name 以这些前缀开头的顶层节点(空数组 = 全部)
|
||||||
|
allowedTopPrefixes?: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
modelValue: ''
|
modelValue: '',
|
||||||
|
allowedTopPrefixes: () => []
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
@ -159,6 +162,15 @@ const currentParentId = computed<number | null>(() => {
|
|||||||
// 当前显示的列表(懒加载缓存)
|
// 当前显示的列表(懒加载缓存)
|
||||||
const currentList = computed<WarehouseItem[]>(() => cache[currentParentKey.value] || [])
|
const currentList = computed<WarehouseItem[]>(() => cache[currentParentKey.value] || [])
|
||||||
|
|
||||||
|
// 顶层按公司白名单前缀过滤后的显示列表(响应式:切换物料公司时实时变化)
|
||||||
|
const displayList = computed<WarehouseItem[]>(() => {
|
||||||
|
const list = currentList.value
|
||||||
|
if (currentParentKey.value === 'root' && props.allowedTopPrefixes.length > 0) {
|
||||||
|
return list.filter((item) => props.allowedTopPrefixes.some((p) => item.name.startsWith(p)))
|
||||||
|
}
|
||||||
|
return list
|
||||||
|
})
|
||||||
|
|
||||||
// 懒加载某层子节点(已缓存则跳过)
|
// 懒加载某层子节点(已缓存则跳过)
|
||||||
const ensureLoaded = async (key: string, parentId: number | null) => {
|
const ensureLoaded = async (key: string, parentId: number | null) => {
|
||||||
if (cache[key]) return
|
if (cache[key]) return
|
||||||
|
|||||||
22
inventory-web/src/utils/warehouseCompany.ts
Normal file
22
inventory-web/src/utils/warehouseCompany.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/**
|
||||||
|
* 公司 → 允许选择的库位顶层前缀(白名单)
|
||||||
|
*
|
||||||
|
* - 匹配到公司:顶层库位只显示 name 以这些前缀开头的节点(其子级随顶层隐藏不可达)
|
||||||
|
* - 未配置的公司 / 空数组:显示全部库位
|
||||||
|
*
|
||||||
|
* 如需调整规则(新增公司/改前缀),只需改这张表,无需改动组件。
|
||||||
|
*/
|
||||||
|
export const COMPANY_WAREHOUSE_PREFIXES: Record<string, string[]> = {
|
||||||
|
// IRIS 仅显示 Y 开头(Y1~Y8)
|
||||||
|
IRIS: ['Y'],
|
||||||
|
// LICA 隐藏 Y,显示 C / L 开头
|
||||||
|
LICA: ['C', 'L'],
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据公司名取允许的库位顶层前缀(未配置返回空数组 = 不过滤)
|
||||||
|
*/
|
||||||
|
export function getAllowedLocPrefixes(companyName?: string | null): string[] {
|
||||||
|
if (!companyName) return []
|
||||||
|
return COMPANY_WAREHOUSE_PREFIXES[companyName] || []
|
||||||
|
}
|
||||||
@ -384,7 +384,7 @@
|
|||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="6">
|
<el-col :span="6">
|
||||||
<el-form-item label="库位" prop="warehouse_location">
|
<el-form-item label="库位" prop="warehouse_location">
|
||||||
<WarehouseSelector v-model="form.warehouse_location" />
|
<WarehouseSelector v-model="form.warehouse_location" :allowed-top-prefixes="allowedLocPrefixes" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
@ -806,6 +806,7 @@ import {getLabelPreview, executePrint} from '@/api/common/print'
|
|||||||
import { usePasteUpload } from '@/hooks/usePasteUpload'
|
import { usePasteUpload } from '@/hooks/usePasteUpload'
|
||||||
import WebRtcCamera from '@/components/Camera/WebRtcCamera.vue'
|
import WebRtcCamera from '@/components/Camera/WebRtcCamera.vue'
|
||||||
import WarehouseSelector from '@/components/WarehouseSelector.vue'
|
import WarehouseSelector from '@/components/WarehouseSelector.vue'
|
||||||
|
import { getAllowedLocPrefixes } from '@/utils/warehouseCompany'
|
||||||
import SmartScannerDialog from '@/components/SmartScannerDialog.vue'
|
import SmartScannerDialog from '@/components/SmartScannerDialog.vue'
|
||||||
import { useUserStore } from '@/stores/user'
|
import { useUserStore } from '@/stores/user'
|
||||||
|
|
||||||
@ -1166,6 +1167,9 @@ const handleCheckAllChange = (val: boolean) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 按物料公司限制可选库位顶层前缀(IRIS→Y,LICA→C/L,未配置→全部)
|
||||||
|
const allowedLocPrefixes = computed(() => getAllowedLocPrefixes(form.company_name))
|
||||||
|
|
||||||
const form = reactive({
|
const form = reactive({
|
||||||
id: undefined, base_id: undefined as number | undefined,
|
id: undefined, base_id: undefined as number | undefined,
|
||||||
company_name: '',
|
company_name: '',
|
||||||
|
|||||||
@ -354,7 +354,7 @@
|
|||||||
<el-row :gutter="24">
|
<el-row :gutter="24">
|
||||||
<el-col :span="6"><el-form-item label="SKU" prop="sku"><el-input v-model="form.sku" placeholder="自动生成" disabled /></el-form-item></el-col>
|
<el-col :span="6"><el-form-item label="SKU" prop="sku"><el-input v-model="form.sku" placeholder="自动生成" disabled /></el-form-item></el-col>
|
||||||
<el-col :span="6"><el-form-item label="库位" prop="warehouse_location">
|
<el-col :span="6"><el-form-item label="库位" prop="warehouse_location">
|
||||||
<WarehouseSelector v-model="form.warehouse_location" />
|
<WarehouseSelector v-model="form.warehouse_location" :allowed-top-prefixes="allowedLocPrefixes" />
|
||||||
</el-form-item></el-col>
|
</el-form-item></el-col>
|
||||||
<el-col :span="6"><el-form-item label="入库日期"><el-date-picker v-model="form.in_date" type="date" value-format="YYYY-MM-DD" style="width:100%" disabled /></el-form-item></el-col>
|
<el-col :span="6"><el-form-item label="入库日期"><el-date-picker v-model="form.in_date" type="date" value-format="YYYY-MM-DD" style="width:100%" disabled /></el-form-item></el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
@ -614,6 +614,7 @@ import {
|
|||||||
import { uploadFile, deleteFile } from '@/api/inbound/buy'
|
import { uploadFile, deleteFile } from '@/api/inbound/buy'
|
||||||
import WebRtcCamera from '@/components/Camera/WebRtcCamera.vue'
|
import WebRtcCamera from '@/components/Camera/WebRtcCamera.vue'
|
||||||
import WarehouseSelector from '@/components/WarehouseSelector.vue'
|
import WarehouseSelector from '@/components/WarehouseSelector.vue'
|
||||||
|
import { getAllowedLocPrefixes } from '@/utils/warehouseCompany'
|
||||||
import SmartScannerDialog from '@/components/SmartScannerDialog.vue'
|
import SmartScannerDialog from '@/components/SmartScannerDialog.vue'
|
||||||
import TrackScanDialog from '@/components/TrackScanDialog.vue'
|
import TrackScanDialog from '@/components/TrackScanDialog.vue'
|
||||||
import { getLabelPreview, executePrint } from '@/api/common/print'
|
import { getLabelPreview, executePrint } from '@/api/common/print'
|
||||||
@ -929,6 +930,9 @@ const displayData = computed(() => {
|
|||||||
|
|
||||||
const defaultVisibleCols = ['company_name', 'material_name', 'sku', 'warehouse_loc', 'serial_number', 'in_quantity', 'stock_quantity', 'available_quantity', 'status', 'quality_status', 'product_photo', 'sale_price', 'order_id']
|
const defaultVisibleCols = ['company_name', 'material_name', 'sku', 'warehouse_loc', 'serial_number', 'in_quantity', 'stock_quantity', 'available_quantity', 'status', 'quality_status', 'product_photo', 'sale_price', 'order_id']
|
||||||
|
|
||||||
|
// 按物料公司限制可选库位顶层前缀(IRIS→Y,LICA→C/L,未配置→全部)
|
||||||
|
const allowedLocPrefixes = computed(() => getAllowedLocPrefixes(form.company_name))
|
||||||
|
|
||||||
const form = reactive({
|
const form = reactive({
|
||||||
id: undefined, base_id: undefined as number | undefined,
|
id: undefined, base_id: undefined as number | undefined,
|
||||||
company_name: '', // [新增]
|
company_name: '', // [新增]
|
||||||
|
|||||||
@ -393,7 +393,7 @@
|
|||||||
<el-col :span="6"><el-form-item label="编码/SKU" prop="sku"><el-input v-model="form.sku" placeholder="系统自动生成" disabled/></el-form-item></el-col>
|
<el-col :span="6"><el-form-item label="编码/SKU" prop="sku"><el-input v-model="form.sku" placeholder="系统自动生成" disabled/></el-form-item></el-col>
|
||||||
<el-col :span="6"><el-form-item label="入库日期" prop="in_date"><el-date-picker v-model="form.in_date" type="date" value-format="YYYY-MM-DD" style="width:100%" disabled/></el-form-item></el-col>
|
<el-col :span="6"><el-form-item label="入库日期" prop="in_date"><el-date-picker v-model="form.in_date" type="date" value-format="YYYY-MM-DD" style="width:100%" disabled/></el-form-item></el-col>
|
||||||
<el-col :span="6"><el-form-item label="库位" prop="warehouse_location">
|
<el-col :span="6"><el-form-item label="库位" prop="warehouse_location">
|
||||||
<WarehouseSelector v-model="form.warehouse_location" />
|
<WarehouseSelector v-model="form.warehouse_location" :allowed-top-prefixes="allowedLocPrefixes" />
|
||||||
</el-form-item></el-col>
|
</el-form-item></el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
@ -658,6 +658,7 @@ import {
|
|||||||
import { uploadFile, deleteFile } from '@/api/inbound/buy'
|
import { uploadFile, deleteFile } from '@/api/inbound/buy'
|
||||||
import WebRtcCamera from '@/components/Camera/WebRtcCamera.vue'
|
import WebRtcCamera from '@/components/Camera/WebRtcCamera.vue'
|
||||||
import WarehouseSelector from '@/components/WarehouseSelector.vue'
|
import WarehouseSelector from '@/components/WarehouseSelector.vue'
|
||||||
|
import { getAllowedLocPrefixes } from '@/utils/warehouseCompany'
|
||||||
import SmartScannerDialog from '@/components/SmartScannerDialog.vue'
|
import SmartScannerDialog from '@/components/SmartScannerDialog.vue'
|
||||||
import TrackScanDialog from '@/components/TrackScanDialog.vue'
|
import TrackScanDialog from '@/components/TrackScanDialog.vue'
|
||||||
import {getLabelPreview, executePrint} from '@/api/common/print'
|
import {getLabelPreview, executePrint} from '@/api/common/print'
|
||||||
@ -973,6 +974,9 @@ const handleCheckAllChange = (val: boolean) => {
|
|||||||
|
|
||||||
const defaultColumns = ['company_name', 'material_name', 'spec_model', 'unit', 'inbound_date', 'sn_bn', 'status', 'quality_status', 'bom_code', 'work_order_code', 'stock_quantity', 'available_quantity', 'unit_total_cost', 'arrival_photo', 'quality_report_link']
|
const defaultColumns = ['company_name', 'material_name', 'spec_model', 'unit', 'inbound_date', 'sn_bn', 'status', 'quality_status', 'bom_code', 'work_order_code', 'stock_quantity', 'available_quantity', 'unit_total_cost', 'arrival_photo', 'quality_report_link']
|
||||||
|
|
||||||
|
// 按物料公司限制可选库位顶层前缀(IRIS→Y,LICA→C/L,未配置→全部)
|
||||||
|
const allowedLocPrefixes = computed(() => getAllowedLocPrefixes(form.company_name))
|
||||||
|
|
||||||
const form = reactive({
|
const form = reactive({
|
||||||
id: undefined, base_id: undefined as number | undefined,
|
id: undefined, base_id: undefined as number | undefined,
|
||||||
company_name: '',
|
company_name: '',
|
||||||
|
|||||||
Reference in New Issue
Block a user