feat: 菜单按业务域重排为7组 + 预警中心更名异常告警 + AGV独立权限码与齐套测算分账明细

This commit is contained in:
SunYF
2026-11-15 22:34:45 +08:00
parent 1e92b2a596
commit b32ec7c03d
49 changed files with 1040 additions and 435 deletions
+36 -17
View File
@@ -29,21 +29,23 @@ type seedPerm struct {
var seedPermissions = []seedPerm{
// ===== 菜单权限 =====
{"dashboard:view", "工作台", "MENU", "/", "HomeFilled", 10, ""},
{"inbound:view", "入库管理", "MENU", "/inbound", "Download", 20, ""},
{"outbound:view", "出库管理", "MENU", "/outbound", "Upload", 30, ""},
{"inbound:view", "来料入库", "MENU", "/inbound", "Download", 20, ""},
{"outbound:record", "出库记录", "MENU", "/outbound", "List", 30, ""},
{"outbound:general", "通用出库", "MENU", "/general-outbound", "Upload", 31, ""},
{"outbound:project", "科技项目出库", "MENU", "/project-outbound", "Upload", 32, ""},
{"call:view", "叫料队列", "MENU", "/call-queue", "Bell", 35, ""},
// P1(2026-11-04 用户拍板):备料清单——只读展示"今天及以后×工单×工位×物料×数量",数据源 MES 日排产实时算
{"preparation:view", "备料清单", "MENU", "/preparation", "Tickets", 36, ""},
// 菜单 code 不得共用:配送单/托盘工作台从 call:view、return:view 拆出独立权限(问题18)
{"delivery:view", "配送单", "MENU", "/delivery", "Bell", 37, ""},
{"pallet:view", "托盘工作台", "MENU", "/pallet-workbench", "Box", 38, ""},
{"pallet:view", "托盘与AGV", "MENU", "/pallet-workbench", "Box", 38, ""},
{"inventory:view", "库存查询", "MENU", "/inventory", "Search", 40, ""},
{"inspection:view", "来料检验", "MENU", "/inspection-incoming", "CircleCheck", 50, ""},
{"stocktake:view", "库存盘点", "MENU", "/stocktake", "List", 60, ""},
{"semi:view", "在制品/成品", "MENU", "/semi", "Box", 70, ""},
{"semi:view", "在制品", "MENU", "/semi", "Box", 70, ""},
{"wms.finished:edit", "成品入库", "MENU", "/finished-inbound", "Box", 72, ""},
{"return:view", "退库确认", "MENU", "/return-order", "RefreshLeft", 85, ""},
{"prodreturn:manage", "生产退不良", "MENU", "/production-return", "WarningFilled", 87, ""},
{"return:view", "退库单收货", "MENU", "/return-order", "RefreshLeft", 85, ""},
{"prodreturn:manage", "不良品退库", "MENU", "/production-return", "WarningFilled", 87, ""},
{"zone:view", "仓库结构", "MENU", "/zone", "Location", 90, ""},
{"material:view", "物料档案", "MENU", "/material", "Goods", 100, ""},
{"user:manage", "账号管理", "MENU", "/users", "EditPen", 110, ""},
@@ -54,18 +56,18 @@ var seedPermissions = []seedPerm{
{"sys.settings:view", "基础设置", "MENU", "/settings", "Setting", 150, ""},
// 同步失败台账(2026-11-08):跨系统通知失败人工重试,菜单码同时作为后端 requirePerm 校验码
{"sync:retry", "同步失败台账", "MENU", "/sync-failure", "Refresh", 152, ""},
// 预警中心/预警规则原先无独立 code,补登独立 MENU 权限(问题18)
{"alert.center:view", "预警中心", "MENU", "/alert-center", "Bell", 154, ""},
{"alert.rule:view", "预警规则", "MENU", "/alert-rule", "Bell", 156, ""},
// 异常告警/告警配置原先无独立 code,补登独立 MENU 权限(问题18)
{"alert.center:view", "异常告警", "MENU", "/alert-center", "Bell", 154, ""},
{"alert.rule:view", "告警配置", "MENU", "/alert-rule", "Bell", 156, ""},
{"sys.settings:edit", "保存基础设置", "BUTTON", "", "", 290, "sys.settings:view"},
// ===== 按钮权限 =====
{"inbound:create", "批量入库", "BUTTON", "", "", 200, "inbound:view"},
{"inbound:import", "Excel导入", "BUTTON", "", "", 201, "inbound:view"},
{"inbound:export", "导出", "BUTTON", "", "", 202, "inbound:view"},
{"inbound:void", "作废入库单", "BUTTON", "", "", 203, "inbound:view"},
{"outbound:create", "发起出库", "BUTTON", "", "", 210, "outbound:view"},
{"outbound:export", "导出", "BUTTON", "", "", 211, "outbound:view"},
{"outbound:void", "作废出库单", "BUTTON", "", "", 212, "outbound:view"},
{"outbound:create", "发起出库", "BUTTON", "", "", 210, "outbound:general"},
{"outbound:export", "导出", "BUTTON", "", "", 211, "outbound:record"},
{"outbound:void", "作废出库单", "BUTTON", "", "", 212, "outbound:record"},
{"call:manage", "叫料-完成备料/驳回", "BUTTON", "", "", 240, "call:view"},
{"inspection:create", "录入检验", "BUTTON", "", "", 220, "inspection:view"},
{"inspection:export", "导出", "BUTTON", "", "", 221, "inspection:view"},
@@ -134,10 +136,11 @@ func SeedRBAC(ctx *svc.ServiceContext, operator string) (createdP, createdR, bou
exist, _ := ctx.EntClient.Permission.Query().
Where(permission.CodeEQ(p.Code)).Exist(ctx0())
if exist {
// 已存在:幂等补齐 parent_code(新增字段不影响已建角色权限)
// 与 MES 对齐:名称/路径/归类随种子幂等纠正,已建角色授权不受影响
_, _ = ctx.EntClient.Permission.Update().
Where(permission.CodeEQ(p.Code)).
SetParentCode(p.Parent).
SetName(p.Name).SetPath(p.Path).SetType(p.Type).
SetIcon(p.Icon).SetSort(p.Sort).SetParentCode(p.Parent).
Save(ctx0())
continue
}
@@ -154,22 +157,38 @@ func SeedRBAC(ctx *svc.ServiceContext, operator string) (createdP, createdR, bou
// 退役权限码清理(幂等):随功能退役的权限码及存量角色里的旧码一并摘除。
// - agv:manage / agv:dispatch:AGV 配送页随 GUI 一并移除,AGV 真源迁 MES(E.1 2026-10-17)
// - ledger:view:工单备料台账随用户 2026-11-04 明确拍板移除(D1 移除),不再复活
for _, dead := range []string{"agv:manage", "agv:dispatch", "ledger:view"} {
// outbound:view 已拆成出库记录 / 通用出库 / 科技项目出库三个独立菜单码,旧码一并退役
for _, dead := range []string{"agv:manage", "agv:dispatch", "ledger:view", "outbound:view"} {
_, _ = ctx.EntClient.Permission.Delete().Where(permission.CodeEQ(dead)).Exec(ctx0())
}
if allRoles, _ := ctx.EntClient.Role.Query().All(ctx0()); len(allRoles) > 0 {
for _, rl := range allRoles {
kept := make([]string, 0, len(rl.PermissionCodes))
kept := make([]string, 0, len(rl.PermissionCodes)+3)
changed := false
for _, c := range rl.PermissionCodes {
if c == "agv:manage" || c == "agv:dispatch" || c == "ledger:view" {
changed = true
continue
}
if c == "outbound:view" {
// 旧码等价换成三个新菜单码:出库记录 / 通用出库 / 科技项目出库。
// 所有角色(含自建角色)一律补齐,绝不因拆码丢菜单或 403。
kept = append(kept, "outbound:record", "outbound:general", "outbound:project")
changed = true
continue
}
kept = append(kept, c)
}
if changed {
_, _ = ctx.EntClient.Role.UpdateOneID(rl.ID).SetPermissionCodes(kept).Save(ctx0())
seen := map[string]bool{}
dedup := make([]string, 0, len(kept))
for _, c := range kept {
if !seen[c] {
seen[c] = true
dedup = append(dedup, c)
}
}
_, _ = ctx.EntClient.Role.UpdateOneID(rl.ID).SetPermissionCodes(dedup).Save(ctx0())
}
}
}