From 8e561836ebf8598fab04284f68dd72008e08c633 Mon Sep 17 00:00:00 2001 From: yueli Date: Fri, 4 Sep 2026 11:02:03 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BA=93=E4=BD=8D=E6=8C=89=E7=89=A9?= =?UTF-8?q?=E6=96=99=E5=85=AC=E5=8F=B8=E7=99=BD=E5=90=8D=E5=8D=95=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E2=80=94=E2=80=94WarehouseSelector=20=E6=94=AF?= =?UTF-8?q?=E6=8C=81=20allowedTopPrefixes=EF=BC=8CIRIS=20=E4=BB=85?= =?UTF-8?q?=E6=98=BE=20Y=E3=80=81LICA=20=E6=98=BE=20C/L?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/WarehouseSelector.vue | 18 ++++++++++++--- inventory-web/src/utils/warehouseCompany.ts | 22 +++++++++++++++++++ inventory-web/src/views/stock/inbound/buy.vue | 6 ++++- .../src/views/stock/inbound/product.vue | 6 ++++- .../src/views/stock/inbound/semi.vue | 6 ++++- 5 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 inventory-web/src/utils/warehouseCompany.ts diff --git a/inventory-web/src/components/WarehouseSelector.vue b/inventory-web/src/components/WarehouseSelector.vue index ced5383..52b2de2 100644 --- a/inventory-web/src/components/WarehouseSelector.vue +++ b/inventory-web/src/components/WarehouseSelector.vue @@ -56,12 +56,12 @@
-
+
当前层级无库位数据
  • (), { - modelValue: '' + modelValue: '', + allowedTopPrefixes: () => [] }) const emit = defineEmits<{ @@ -159,6 +162,15 @@ const currentParentId = computed(() => { // 当前显示的列表(懒加载缓存) const currentList = computed(() => cache[currentParentKey.value] || []) +// 顶层按公司白名单前缀过滤后的显示列表(响应式:切换物料公司时实时变化) +const displayList = computed(() => { + 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) => { if (cache[key]) return diff --git a/inventory-web/src/utils/warehouseCompany.ts b/inventory-web/src/utils/warehouseCompany.ts new file mode 100644 index 0000000..d0201bd --- /dev/null +++ b/inventory-web/src/utils/warehouseCompany.ts @@ -0,0 +1,22 @@ +/** + * 公司 → 允许选择的库位顶层前缀(白名单) + * + * - 匹配到公司:顶层库位只显示 name 以这些前缀开头的节点(其子级随顶层隐藏不可达) + * - 未配置的公司 / 空数组:显示全部库位 + * + * 如需调整规则(新增公司/改前缀),只需改这张表,无需改动组件。 + */ +export const COMPANY_WAREHOUSE_PREFIXES: Record = { + // 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] || [] +} diff --git a/inventory-web/src/views/stock/inbound/buy.vue b/inventory-web/src/views/stock/inbound/buy.vue index 0ef4860..4fb0b34 100644 --- a/inventory-web/src/views/stock/inbound/buy.vue +++ b/inventory-web/src/views/stock/inbound/buy.vue @@ -384,7 +384,7 @@ - + @@ -806,6 +806,7 @@ import {getLabelPreview, executePrint} from '@/api/common/print' import { usePasteUpload } from '@/hooks/usePasteUpload' import WebRtcCamera from '@/components/Camera/WebRtcCamera.vue' import WarehouseSelector from '@/components/WarehouseSelector.vue' +import { getAllowedLocPrefixes } from '@/utils/warehouseCompany' import SmartScannerDialog from '@/components/SmartScannerDialog.vue' 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({ id: undefined, base_id: undefined as number | undefined, company_name: '', diff --git a/inventory-web/src/views/stock/inbound/product.vue b/inventory-web/src/views/stock/inbound/product.vue index d8c72ea..7e085b4 100644 --- a/inventory-web/src/views/stock/inbound/product.vue +++ b/inventory-web/src/views/stock/inbound/product.vue @@ -354,7 +354,7 @@ - + @@ -614,6 +614,7 @@ import { import { uploadFile, deleteFile } from '@/api/inbound/buy' import WebRtcCamera from '@/components/Camera/WebRtcCamera.vue' import WarehouseSelector from '@/components/WarehouseSelector.vue' +import { getAllowedLocPrefixes } from '@/utils/warehouseCompany' import SmartScannerDialog from '@/components/SmartScannerDialog.vue' import TrackScanDialog from '@/components/TrackScanDialog.vue' 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'] +// 按物料公司限制可选库位顶层前缀(IRIS→Y,LICA→C/L,未配置→全部) +const allowedLocPrefixes = computed(() => getAllowedLocPrefixes(form.company_name)) + const form = reactive({ id: undefined, base_id: undefined as number | undefined, company_name: '', // [新增] diff --git a/inventory-web/src/views/stock/inbound/semi.vue b/inventory-web/src/views/stock/inbound/semi.vue index 44469d8..3fbc539 100644 --- a/inventory-web/src/views/stock/inbound/semi.vue +++ b/inventory-web/src/views/stock/inbound/semi.vue @@ -393,7 +393,7 @@ - + @@ -658,6 +658,7 @@ import { import { uploadFile, deleteFile } from '@/api/inbound/buy' import WebRtcCamera from '@/components/Camera/WebRtcCamera.vue' import WarehouseSelector from '@/components/WarehouseSelector.vue' +import { getAllowedLocPrefixes } from '@/utils/warehouseCompany' import SmartScannerDialog from '@/components/SmartScannerDialog.vue' import TrackScanDialog from '@/components/TrackScanDialog.vue' 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'] +// 按物料公司限制可选库位顶层前缀(IRIS→Y,LICA→C/L,未配置→全部) +const allowedLocPrefixes = computed(() => getAllowedLocPrefixes(form.company_name)) + const form = reactive({ id: undefined, base_id: undefined as number | undefined, company_name: '',