fix: 前端 product.vue permissionMap null→显式权限码 + fetchMaterialSuggestions 改用 async/await 修复首次搜索空白
This commit is contained in:
@ -796,11 +796,9 @@ const permissionMap: Record<string, string> = {
|
|||||||
quality_status: 'inbound_product:quality_status',
|
quality_status: 'inbound_product:quality_status',
|
||||||
in_quantity: 'inbound_product:in_quantity',
|
in_quantity: 'inbound_product:in_quantity',
|
||||||
stock_quantity: 'inbound_product:stock_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',
|
available_quantity: 'inbound_product:available_quantity',
|
||||||
|
warehouse_loc: null,
|
||||||
warehouse_location: 'inbound_product:warehouse_location',
|
warehouse_location: 'inbound_product:warehouse_location',
|
||||||
warehouse_loc: 'inbound_product:warehouse_location',
|
|
||||||
bom_code: 'inbound_product:bom_code',
|
bom_code: 'inbound_product:bom_code',
|
||||||
bom_version: 'inbound_product:bom_version',
|
bom_version: 'inbound_product:bom_version',
|
||||||
work_order_code: 'inbound_product:work_order_code',
|
work_order_code: 'inbound_product:work_order_code',
|
||||||
@ -824,13 +822,19 @@ const visibleColumnProps = ref<string[]>([])
|
|||||||
// 1. 获取唯一缓存 Key
|
// 1. 获取唯一缓存 Key
|
||||||
const getStorageKey = () => `MOM_INBOUND_PROD_COLS_V2_${userStore.username || 'DEFAULT'}`;
|
const getStorageKey = () => `MOM_INBOUND_PROD_COLS_V2_${userStore.username || 'DEFAULT'}`;
|
||||||
|
|
||||||
// 2. 检查列权限(依赖 permissionMap)
|
// 2. 检查列权限
|
||||||
const hasColumnPermission = (prop: string) => {
|
const hasColumnPermission = (prop: string) => {
|
||||||
if (userStore.role === 'SUPER_ADMIN' || userStore.username === 'IRIS') {
|
if (userStore.role === 'SUPER_ADMIN' || userStore.username === 'IRIS') {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
if (!(prop in permissionMap)) {
|
||||||
|
return false // 不在映射中 → Default Deny
|
||||||
|
}
|
||||||
const code = permissionMap[prop]
|
const code = permissionMap[prop]
|
||||||
return code ? userStore.hasPermission(code) : false
|
if (code === null || code === undefined) {
|
||||||
|
return true // 基础字段,无需权限
|
||||||
|
}
|
||||||
|
return userStore.hasPermission(code)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 初始化列权限
|
// 3. 初始化列权限
|
||||||
@ -1041,15 +1045,21 @@ const rules = {
|
|||||||
|
|
||||||
// Material Search & Population Logic
|
// Material Search & Population Logic
|
||||||
// ------------------------------------
|
// ------------------------------------
|
||||||
const fetchMaterialSuggestions = (query: string, cb: (results: any[]) => void) => {
|
const fetchMaterialSuggestions = async (query: string, cb: (results: any[]) => void) => {
|
||||||
const rawQuery = String(query || '')
|
const safeQuery = String(query || '').replace(/[\x00-\x1F\x7F-\x9F\u200B-\u200D\uFEFF]/g, '').trim()
|
||||||
const safeQuery = rawQuery.replace(/[\x00-\x1F\x7F-\x9F\u200B-\u200D\uFEFF]/g, '').trim()
|
|
||||||
searchLoading.value = true
|
searchLoading.value = true
|
||||||
searchMaterialBase(safeQuery).then((res: any) => {
|
try {
|
||||||
const items = res.data?.items || res.data || []
|
const res: any = await searchMaterialBase(safeQuery)
|
||||||
const formatted = items.map((i: any) => ({ ...i, name: i.name || i.material_name, isHistory: false }))
|
if (res.code === 200 && res.data) {
|
||||||
cb(formatted)
|
cb((res.data?.items || res.data || []).map((i: any) => ({ ...i, isHistory: false })))
|
||||||
}).catch(() => cb([])).finally(() => { searchLoading.value = false })
|
} else {
|
||||||
|
cb([])
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
cb([])
|
||||||
|
} finally {
|
||||||
|
searchLoading.value = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const onMaterialClear = () => {
|
const onMaterialClear = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user