fix(material): 附件备注输入框按写权限置灰,消除 UI 与后端口径撕裂
背景
----
读权限(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 的映射(读)
This commit is contained in:
@ -546,7 +546,8 @@
|
|||||||
v-model="form.productImageRemark"
|
v-model="form.productImageRemark"
|
||||||
type="textarea"
|
type="textarea"
|
||||||
:rows="1"
|
:rows="1"
|
||||||
placeholder="请输入产品图备注信息"
|
:disabled="!canEditRemark"
|
||||||
|
:placeholder="canEditRemark ? '请输入产品图备注信息' : '无编辑权限,仅可查看'"
|
||||||
style="margin-top: 8px;"
|
style="margin-top: 8px;"
|
||||||
clearable
|
clearable
|
||||||
/>
|
/>
|
||||||
@ -600,7 +601,8 @@
|
|||||||
v-model="form.manualLinkRemark"
|
v-model="form.manualLinkRemark"
|
||||||
type="textarea"
|
type="textarea"
|
||||||
:rows="1"
|
:rows="1"
|
||||||
placeholder="请输入说明书备注信息"
|
:disabled="!canEditRemark"
|
||||||
|
:placeholder="canEditRemark ? '请输入说明书备注信息' : '无编辑权限,仅可查看'"
|
||||||
style="margin-top: 8px;"
|
style="margin-top: 8px;"
|
||||||
clearable
|
clearable
|
||||||
/>
|
/>
|
||||||
@ -742,6 +744,16 @@ import { imageSearch as imageSearchApi, type ImageSearchItem } from '@/api/commo
|
|||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const isSuperAdmin = computed(() => userStore.role === 'SUPER_ADMIN');
|
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 {
|
interface MaterialBaseVO {
|
||||||
id: number;
|
id: number;
|
||||||
|
|||||||
@ -549,11 +549,16 @@
|
|||||||
<el-icon><Camera /></el-icon><span class="text">拍照</span>
|
<el-icon><Camera /></el-icon><span class="text">拍照</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- ★ 备注的**读**与**写**是两个权限:
|
||||||
|
读 = material_list:files(本区块整体可见,6 个角色)
|
||||||
|
写 = material_list:remark_edit(3 个核心管理角色)
|
||||||
|
无写权限时置灰但仍可见 —— 读权限决定可见性,能看到既有内容。 -->
|
||||||
<el-input
|
<el-input
|
||||||
v-model="form.productImageRemark"
|
v-model="form.productImageRemark"
|
||||||
type="textarea"
|
type="textarea"
|
||||||
:rows="1"
|
:rows="1"
|
||||||
placeholder="请输入产品图备注信息"
|
:disabled="!canEditRemark"
|
||||||
|
:placeholder="canEditRemark ? '请输入产品图备注信息' : '无编辑权限,仅可查看'"
|
||||||
style="margin-top: 8px;"
|
style="margin-top: 8px;"
|
||||||
clearable
|
clearable
|
||||||
/>
|
/>
|
||||||
@ -607,7 +612,8 @@
|
|||||||
v-model="form.manualLinkRemark"
|
v-model="form.manualLinkRemark"
|
||||||
type="textarea"
|
type="textarea"
|
||||||
:rows="1"
|
:rows="1"
|
||||||
placeholder="请输入说明书备注信息"
|
:disabled="!canEditRemark"
|
||||||
|
:placeholder="canEditRemark ? '请输入说明书备注信息' : '无编辑权限,仅可查看'"
|
||||||
style="margin-top: 8px;"
|
style="margin-top: 8px;"
|
||||||
clearable
|
clearable
|
||||||
/>
|
/>
|
||||||
@ -1078,6 +1084,17 @@ const hasFieldPermission = (field: string) => {
|
|||||||
return userStore.hasPermission(code);
|
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 权限时,所有表单字段不可编辑
|
// 表单全局禁用:没有 material_list:operation 权限时,所有表单字段不可编辑
|
||||||
const formDisabled = computed(() => {
|
const formDisabled = computed(() => {
|
||||||
if (userStore.role === 'SUPER_ADMIN' || userStore.username === 'IRIS') return false;
|
if (userStore.role === 'SUPER_ADMIN' || userStore.username === 'IRIS') return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user