From 70071e111af07fe9f79d4e621fd114a84172e3df Mon Sep 17 00:00:00 2001 From: yueli Date: Thu, 17 Sep 2026 11:07:58 +0800 Subject: [PATCH] =?UTF-8?q?fix(material):=20=E9=99=84=E4=BB=B6=E5=A4=87?= =?UTF-8?q?=E6=B3=A8=E8=BE=93=E5=85=A5=E6=A1=86=E6=8C=89=E5=86=99=E6=9D=83?= =?UTF-8?q?=E9=99=90=E7=BD=AE=E7=81=B0=EF=BC=8C=E6=B6=88=E9=99=A4=20UI=20?= =?UTF-8?q?=E4=B8=8E=E5=90=8E=E7=AB=AF=E5=8F=A3=E5=BE=84=E6=92=95=E8=A3=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 背景 ---- 读权限(material_list:files,6 角色)决定「产品图」整块是否显示; 但写权限已收紧到 material_list:remark_edit(3 角色)。若前端不区分, 入库员/出库员/销售会看到可输入的备注框,填完却被后端静默丢弃 —— 正是本次要消灭的「能填却存不进去」的撕裂。 改动 ---- list.vue(基础信息)与 buyOdoo.vue(基础信息(Odoo))各新增 canEditRemark, 两个备注输入框绑定 :disabled="!canEditRemark",并把占位文案切换为 「无编辑权限,仅可查看」,避免用户对着灰框发懵。 三处口径必须一致,已交叉核对: 前端 list.vue / buyOdoo.vue 的 canEditRemark 后端 base.py 的 field_to_perm(写) 后端 field_permissions.py 的映射(读) --- inventory-web/src/views/material/buyOdoo.vue | 16 +++++++++++++-- inventory-web/src/views/material/list.vue | 21 ++++++++++++++++++-- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/inventory-web/src/views/material/buyOdoo.vue b/inventory-web/src/views/material/buyOdoo.vue index 7a5d556..49931e7 100644 --- a/inventory-web/src/views/material/buyOdoo.vue +++ b/inventory-web/src/views/material/buyOdoo.vue @@ -546,7 +546,8 @@ v-model="form.productImageRemark" type="textarea" :rows="1" - placeholder="请输入产品图备注信息" + :disabled="!canEditRemark" + :placeholder="canEditRemark ? '请输入产品图备注信息' : '无编辑权限,仅可查看'" style="margin-top: 8px;" clearable /> @@ -600,7 +601,8 @@ v-model="form.manualLinkRemark" type="textarea" :rows="1" - placeholder="请输入说明书备注信息" + :disabled="!canEditRemark" + :placeholder="canEditRemark ? '请输入说明书备注信息' : '无编辑权限,仅可查看'" style="margin-top: 8px;" clearable /> @@ -742,6 +744,16 @@ import { imageSearch as imageSearchApi, type ImageSearchItem } from '@/api/commo const userStore = useUserStore(); const isSuperAdmin = computed(() => userStore.role === 'SUPER_ADMIN'); +// ★ 附件备注(产品图备注 / 说明书备注)的**写**权限,与读权限分离。 +// 与 list.vue、后端 base.py 三处同口径: +// 读 → material_list:files (区块整体可见,6 个角色) +// 写 → material_list:remark_edit (3 个核心管理角色) +// 无写权限时输入框置灰但仍可见 —— 读权限决定可见性。 +const canEditRemark = computed(() => { + if (userStore.role === 'SUPER_ADMIN' || userStore.username === 'IRIS') return true; + return userStore.hasPermission('material_list:remark_edit'); +}); + // --- 类型定义 --- interface MaterialBaseVO { id: number; diff --git a/inventory-web/src/views/material/list.vue b/inventory-web/src/views/material/list.vue index 83253cb..d5d358d 100644 --- a/inventory-web/src/views/material/list.vue +++ b/inventory-web/src/views/material/list.vue @@ -549,11 +549,16 @@ 拍照 + @@ -607,7 +612,8 @@ v-model="form.manualLinkRemark" type="textarea" :rows="1" - placeholder="请输入说明书备注信息" + :disabled="!canEditRemark" + :placeholder="canEditRemark ? '请输入说明书备注信息' : '无编辑权限,仅可查看'" style="margin-top: 8px;" clearable /> @@ -1078,6 +1084,17 @@ const hasFieldPermission = (field: string) => { return userStore.hasPermission(code); }; +// ★ 附件备注(产品图备注 / 说明书备注)的**写**权限,与读权限分离。 +// 两端必须与后端同口径: +// 读 → material_list:files (本区块整体可见,6 个角色) +// 写 → material_list:remark_edit (后端 base.py 的 field_to_perm 同码,3 个角色) +// 后端对无写权限者会**丢弃**该字段(而非写成空值),故前端置灰后 +// 既不会误提交,也不会误清既有内容。 +const canEditRemark = computed(() => { + if (userStore.role === 'SUPER_ADMIN' || userStore.username === 'IRIS') return true; + return userStore.hasPermission('material_list:remark_edit'); +}); + // 表单全局禁用:没有 material_list:operation 权限时,所有表单字段不可编辑 const formDisabled = computed(() => { if (userStore.role === 'SUPER_ADMIN' || userStore.username === 'IRIS') return false;