diff --git a/inventory-web/src/views/stock/inbound/product.vue b/inventory-web/src/views/stock/inbound/product.vue index da3119a..753eb7e 100644 --- a/inventory-web/src/views/stock/inbound/product.vue +++ b/inventory-web/src/views/stock/inbound/product.vue @@ -796,11 +796,9 @@ const permissionMap: Record = { quality_status: 'inbound_product:quality_status', in_quantity: 'inbound_product:in_quantity', stock_quantity: 'inbound_product:stock_quantity', - stock_quantity: 'inbound_product:stock_quantity', - available_quantity: 'inbound_product:available_quantity', available_quantity: 'inbound_product:available_quantity', + warehouse_loc: null, warehouse_location: 'inbound_product:warehouse_location', - warehouse_loc: 'inbound_product:warehouse_location', bom_code: 'inbound_product:bom_code', bom_version: 'inbound_product:bom_version', work_order_code: 'inbound_product:work_order_code', @@ -824,13 +822,19 @@ const visibleColumnProps = ref([]) // 1. 获取唯一缓存 Key const getStorageKey = () => `MOM_INBOUND_PROD_COLS_V2_${userStore.username || 'DEFAULT'}`; -// 2. 检查列权限(依赖 permissionMap) +// 2. 检查列权限 const hasColumnPermission = (prop: string) => { if (userStore.role === 'SUPER_ADMIN' || userStore.username === 'IRIS') { return true } + if (!(prop in permissionMap)) { + return false // 不在映射中 → Default Deny + } const code = permissionMap[prop] - return code ? userStore.hasPermission(code) : false + if (code === null || code === undefined) { + return true // 基础字段,无需权限 + } + return userStore.hasPermission(code) } // 3. 初始化列权限 @@ -1041,15 +1045,21 @@ const rules = { // Material Search & Population Logic // ------------------------------------ -const fetchMaterialSuggestions = (query: string, cb: (results: any[]) => void) => { - const rawQuery = String(query || '') - const safeQuery = rawQuery.replace(/[\x00-\x1F\x7F-\x9F\u200B-\u200D\uFEFF]/g, '').trim() +const fetchMaterialSuggestions = async (query: string, cb: (results: any[]) => void) => { + const safeQuery = String(query || '').replace(/[\x00-\x1F\x7F-\x9F\u200B-\u200D\uFEFF]/g, '').trim() searchLoading.value = true - searchMaterialBase(safeQuery).then((res: any) => { - const items = res.data?.items || res.data || [] - const formatted = items.map((i: any) => ({ ...i, name: i.name || i.material_name, isHistory: false })) - cb(formatted) - }).catch(() => cb([])).finally(() => { searchLoading.value = false }) + try { + const res: any = await searchMaterialBase(safeQuery) + if (res.code === 200 && res.data) { + cb((res.data?.items || res.data || []).map((i: any) => ({ ...i, isHistory: false }))) + } else { + cb([]) + } + } catch (e) { + cb([]) + } finally { + searchLoading.value = false + } } const onMaterialClear = () => {