4 Commits

5 changed files with 35 additions and 23 deletions

View File

@ -37,7 +37,7 @@ def filter_item_by_permissions(item_dict, user_permissions, prefix='op_records')
field_to_perm = {
'borrow_no': f'{prefix}:borrow_no',
'borrower_name': f'{prefix}:borrower_name',
'sku': f'{prefix}:sku',
# 'sku': f'{prefix}:sku', # SKU 字段不再参与权限过滤,直接返回
'borrow_time': f'{prefix}:borrow_time',
'return_time': f'{prefix}:return_time',
'status': f'{prefix}:status',

View File

@ -91,15 +91,15 @@ class BomService:
results.sort(key=lambda x: (x['bom_no'], x['version']), reverse=True)
# 如果有关键词,过滤结果(keyword 匹配逻辑保持不变
# 如果有关键词,二次过滤结果(忽略大小写
if keyword:
kw = f'%{keyword}%'
kw = keyword.lower()
results = [
r for r in results
if kw in (r.get('parent_name') or '')
or kw in (r.get('parent_spec') or '')
or kw in (r.get('bom_no') or '')
or kw in (r.get('parent_category') or '')
if kw in (r.get('parent_name') or '').lower()
or kw in (r.get('parent_spec') or '').lower()
or kw in (r.get('bom_no') or '').lower()
or kw in (r.get('parent_category') or '').lower()
]
# 按 parent_category 分组

View File

@ -234,7 +234,7 @@ const handleLogout = () => {
<footer v-if="!isLoginPage" class="app-footer">
<span class="version-tag">
<el-icon style="vertical-align: middle; margin-right: 4px"><InfoFilled /></el-icon>
当前版本:V3.19(5.14部署
当前版本:V3.20
</span>
</footer>

View File

@ -818,28 +818,36 @@ const submitForm = async () => {
}
onMounted(() => {
fetchBomList()
// 【新增】:处理外部跳转自动打开 BOM带查重保护
// 处理外部跳转自动打开 BOM带查重保护
if (route.query.create_for_id) {
const parentId = Number(route.query.create_for_id);
const parentName = (route.query.parent_name as string) || '';
const parentSpec = (route.query.parent_spec as string) || '';
// 把名称填入背景搜索框,让背后的表格也只显示相关的BOM
// 1. 把名称填入背景搜索框,并真正触发一次列表搜索,让背景列表也只显示该物料
searchKeyword.value = parentName;
fetchBomList();
// 延迟等待基础渲染
// 2. 延迟等待基础渲染后进行查重
setTimeout(() => {
// 1. 先用 keyword 查询是否已有该父件的 BOM
getBomList({ keyword: parentName }).then((res: any) => {
const rows = res.data || [];
// 严格校验 parent_id
const existingBom = rows.find((b: any) => b.parent_id === parentId);
const groups = res.data || [];
let existingBom = null;
// ★ 修复点:遍历分组 (groups) 里的 items 来查找正确的 parent_id
for (const group of groups) {
if (group.items && group.items.length > 0) {
const found = group.items.find((b: any) => b.parent_id === parentId);
if (found) {
existingBom = found;
break; // 找到了就跳出循环
}
}
}
if (existingBom) {
// ★ 情况 A已经有BOM了直接打开编辑弹窗并拉取历史数据
ElMessage.success('检测到该物料已有 BOM已自动为您打开编辑');
// ★ 情况 A已经有BOM了直接打开编辑(查看)弹窗
ElMessage.success('检测到该物料已有 BOM已自动为您打开');
handleEdit(existingBom);
} else {
// ★ 情况 B还没建过BOM打开新建并注入父件
@ -862,11 +870,11 @@ onMounted(() => {
}, 100);
}
}
}).catch(err => {
console.error('BOM 查重失败', err);
ElMessage.error('获取 BOM 状态失败,请手动操作');
});
}, 300);
} else {
// 如果不是从其他页面跳转过来的,直接正常加载全部列表
fetchBomList();
}
})
</script>

View File

@ -1,5 +1,5 @@
<template>
<div v-if="userStore.hasPermission('transaction_records:view')" class="app-container">
<div v-if="userStore.hasPermission('op_records')" class="app-container">
<div class="filter-container">
<el-radio-group v-model="status" @change="fetchData" style="margin-right: 20px">
<el-radio-button label="all">全部</el-radio-button>
@ -173,6 +173,10 @@ const hasColumnPermission = (prop: string) => {
if (userStore.role === 'SUPER_ADMIN' || userStore.username === 'IRIS') {
return true
}
// SKU 字段不再参与权限过滤,始终可见
if (prop === 'sku') {
return true
}
const code = permissionMap[prop]
return code ? userStore.hasPermission(code) : false
}