Compare commits
4 Commits
857ff958bc
...
1e341ab6aa
| Author | SHA1 | Date | |
|---|---|---|---|
| 1e341ab6aa | |||
| 27683d2a8b | |||
| 33879c33f7 | |||
| 950b8dd671 |
@ -37,7 +37,7 @@ def filter_item_by_permissions(item_dict, user_permissions, prefix='op_records')
|
|||||||
field_to_perm = {
|
field_to_perm = {
|
||||||
'borrow_no': f'{prefix}:borrow_no',
|
'borrow_no': f'{prefix}:borrow_no',
|
||||||
'borrower_name': f'{prefix}:borrower_name',
|
'borrower_name': f'{prefix}:borrower_name',
|
||||||
'sku': f'{prefix}:sku',
|
# 'sku': f'{prefix}:sku', # SKU 字段不再参与权限过滤,直接返回
|
||||||
'borrow_time': f'{prefix}:borrow_time',
|
'borrow_time': f'{prefix}:borrow_time',
|
||||||
'return_time': f'{prefix}:return_time',
|
'return_time': f'{prefix}:return_time',
|
||||||
'status': f'{prefix}:status',
|
'status': f'{prefix}:status',
|
||||||
|
|||||||
@ -91,15 +91,15 @@ class BomService:
|
|||||||
|
|
||||||
results.sort(key=lambda x: (x['bom_no'], x['version']), reverse=True)
|
results.sort(key=lambda x: (x['bom_no'], x['version']), reverse=True)
|
||||||
|
|
||||||
# 如果有关键词,过滤结果(keyword 匹配逻辑保持不变)
|
# 如果有关键词,二次过滤结果(忽略大小写)
|
||||||
if keyword:
|
if keyword:
|
||||||
kw = f'%{keyword}%'
|
kw = keyword.lower()
|
||||||
results = [
|
results = [
|
||||||
r for r in results
|
r for r in results
|
||||||
if kw in (r.get('parent_name') or '')
|
if kw in (r.get('parent_name') or '').lower()
|
||||||
or kw in (r.get('parent_spec') or '')
|
or kw in (r.get('parent_spec') or '').lower()
|
||||||
or kw in (r.get('bom_no') or '')
|
or kw in (r.get('bom_no') or '').lower()
|
||||||
or kw in (r.get('parent_category') or '')
|
or kw in (r.get('parent_category') or '').lower()
|
||||||
]
|
]
|
||||||
|
|
||||||
# 按 parent_category 分组
|
# 按 parent_category 分组
|
||||||
|
|||||||
@ -234,7 +234,7 @@ const handleLogout = () => {
|
|||||||
<footer v-if="!isLoginPage" class="app-footer">
|
<footer v-if="!isLoginPage" class="app-footer">
|
||||||
<span class="version-tag">
|
<span class="version-tag">
|
||||||
<el-icon style="vertical-align: middle; margin-right: 4px"><InfoFilled /></el-icon>
|
<el-icon style="vertical-align: middle; margin-right: 4px"><InfoFilled /></el-icon>
|
||||||
当前版本:V3.19(5.14部署)
|
当前版本:V3.20
|
||||||
</span>
|
</span>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
|
|||||||
@ -818,28 +818,36 @@ const submitForm = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
fetchBomList()
|
// 处理外部跳转自动打开 BOM(带查重保护)
|
||||||
|
|
||||||
// 【新增】:处理外部跳转自动打开 BOM(带查重保护)
|
|
||||||
if (route.query.create_for_id) {
|
if (route.query.create_for_id) {
|
||||||
const parentId = Number(route.query.create_for_id);
|
const parentId = Number(route.query.create_for_id);
|
||||||
const parentName = (route.query.parent_name as string) || '';
|
const parentName = (route.query.parent_name as string) || '';
|
||||||
const parentSpec = (route.query.parent_spec as string) || '';
|
const parentSpec = (route.query.parent_spec as string) || '';
|
||||||
|
|
||||||
// 把名称填入背景搜索框,让背后的表格也只显示相关的BOM
|
// 1. 把名称填入背景搜索框,并真正触发一次列表搜索,让背景列表也只显示该物料
|
||||||
searchKeyword.value = parentName;
|
searchKeyword.value = parentName;
|
||||||
|
fetchBomList();
|
||||||
|
|
||||||
// 延迟等待基础渲染
|
// 2. 延迟等待基础渲染后进行查重
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
// 1. 先用 keyword 查询是否已有该父件的 BOM
|
|
||||||
getBomList({ keyword: parentName }).then((res: any) => {
|
getBomList({ keyword: parentName }).then((res: any) => {
|
||||||
const rows = res.data || [];
|
const groups = res.data || [];
|
||||||
// 严格校验 parent_id
|
let existingBom = null;
|
||||||
const existingBom = rows.find((b: any) => b.parent_id === parentId);
|
|
||||||
|
// ★ 修复点:遍历分组 (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) {
|
if (existingBom) {
|
||||||
// ★ 情况 A:已经有BOM了,直接打开编辑弹窗并拉取历史数据
|
// ★ 情况 A:已经有BOM了,直接打开编辑(查看)弹窗
|
||||||
ElMessage.success('检测到该物料已有 BOM,已自动为您打开编辑');
|
ElMessage.success('检测到该物料已有 BOM,已自动为您打开');
|
||||||
handleEdit(existingBom);
|
handleEdit(existingBom);
|
||||||
} else {
|
} else {
|
||||||
// ★ 情况 B:还没建过BOM,打开新建并注入父件
|
// ★ 情况 B:还没建过BOM,打开新建并注入父件
|
||||||
@ -862,11 +870,11 @@ onMounted(() => {
|
|||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).catch(err => {
|
|
||||||
console.error('BOM 查重失败', err);
|
|
||||||
ElMessage.error('获取 BOM 状态失败,请手动操作');
|
|
||||||
});
|
});
|
||||||
}, 300);
|
}, 300);
|
||||||
|
} else {
|
||||||
|
// 如果不是从其他页面跳转过来的,直接正常加载全部列表
|
||||||
|
fetchBomList();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<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">
|
<div class="filter-container">
|
||||||
<el-radio-group v-model="status" @change="fetchData" style="margin-right: 20px">
|
<el-radio-group v-model="status" @change="fetchData" style="margin-right: 20px">
|
||||||
<el-radio-button label="all">全部</el-radio-button>
|
<el-radio-button label="all">全部</el-radio-button>
|
||||||
@ -173,6 +173,10 @@ const hasColumnPermission = (prop: string) => {
|
|||||||
if (userStore.role === 'SUPER_ADMIN' || userStore.username === 'IRIS') {
|
if (userStore.role === 'SUPER_ADMIN' || userStore.username === 'IRIS') {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
// SKU 字段不再参与权限过滤,始终可见
|
||||||
|
if (prop === 'sku') {
|
||||||
|
return true
|
||||||
|
}
|
||||||
const code = permissionMap[prop]
|
const code = permissionMap[prop]
|
||||||
return code ? userStore.hasPermission(code) : false
|
return code ? userStore.hasPermission(code) : false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user