Files
workspace/code/fms/sql/fms_workflow_menu.sql
2026-09-22 22:41:36 +08:00

97 lines
4.9 KiB
Transact-SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* ============================================================================
FMS 工作流菜单(s_menu)
用途:挂两处菜单,与前端路由一一对应(见 fms-vue/src/router/routes.js):
1. 「系统管理 → 流程管理」→ /system/workflow(管理员配置流程)
2. 「审批中心」→ /approval 下的四个页面(我的待办 / 我发起的 / 我已处理 / 抄送我的)
说明:
1. 幂等:菜单按 b_id 判断存在性;日志菜单的排序号只在仍是旧值时后移。
2. 权限:本脚本不建权限点。侧栏可见性与路由进入由 menu.{菜单编码} 授权控制
(g3soft 超管默认可进入);需要给普通账号开放时,另行补 s_power(menu.xxx)
+ s_user_power 授权。
3. 排序:一级菜单 审批中心 5 → 基础资料 10 → 系统管理 10;
系统管理内 用户管理 10 → 流程管理 20 → 日志 30。
============================================================================ */
-- 流程管理:系统管理下的页面菜单
if not exists (select 1 from dbo.s_menu where b_id = 'workflow')
begin
insert into dbo.s_menu (b_id, b_parent_id, b_depth, b_path, b_name, b_i18n, b_menu_type, b_route, b_icon, b_xh, b_canuse)
values ('workflow', 'system', 1, '/system/workflow/', N'流程管理', 'menu.workflow', 'page', '/system/workflow', null, 20, 1);
end
GO
-- 日志让位:目录后移到 30(只在还是 20 时执行,重复运行无副作用)
update dbo.s_menu set b_xh = 30 where b_id = 'log' and b_xh = 20;
GO
/* ----------------------------------------------------------------------------
审批中心(一级菜单):业务人员的日常入口,与「系统管理 → 流程管理」分开
---------------------------------------------------------------------------- */
if not exists (select 1 from dbo.s_menu where b_id = 'approval')
begin
insert into dbo.s_menu (b_id, b_parent_id, b_depth, b_path, b_name, b_i18n, b_menu_type, b_route, b_icon, b_xh, b_canuse)
values ('approval', null, 0, '/approval/', N'审批中心', 'menu.approval', 'directory', null, null, 5, 1);
end
GO
if not exists (select 1 from dbo.s_menu where b_id = 'approval_todo')
begin
insert into dbo.s_menu (b_id, b_parent_id, b_depth, b_path, b_name, b_i18n, b_menu_type, b_route, b_icon, b_xh, b_canuse)
values ('approval_todo', 'approval', 1, '/approval/approval_todo/', N'我的待办', 'menu.approval_todo', 'page', '/approval/todo', null, 10, 1);
end
GO
if not exists (select 1 from dbo.s_menu where b_id = 'approval_initiated')
begin
insert into dbo.s_menu (b_id, b_parent_id, b_depth, b_path, b_name, b_i18n, b_menu_type, b_route, b_icon, b_xh, b_canuse)
values ('approval_initiated', 'approval', 1, '/approval/approval_initiated/', N'我发起的', 'menu.approval_initiated', 'page', '/approval/initiated', null, 20, 1);
end
GO
if not exists (select 1 from dbo.s_menu where b_id = 'approval_done')
begin
insert into dbo.s_menu (b_id, b_parent_id, b_depth, b_path, b_name, b_i18n, b_menu_type, b_route, b_icon, b_xh, b_canuse)
values ('approval_done', 'approval', 1, '/approval/approval_done/', N'我已处理', 'menu.approval_done', 'page', '/approval/done', null, 30, 1);
end
GO
if not exists (select 1 from dbo.s_menu where b_id = 'approval_cc')
begin
insert into dbo.s_menu (b_id, b_parent_id, b_depth, b_path, b_name, b_i18n, b_menu_type, b_route, b_icon, b_xh, b_canuse)
values ('approval_cc', 'approval', 1, '/approval/approval_cc/', N'抄送我的', 'menu.approval_cc', 'page', '/approval/cc', null, 40, 1);
end
GO
/* ----------------------------------------------------------------------------
多语言(s_i18n):菜单名,默认语言为中文时写入中文值
已存在同键同语言的行不覆盖(人工翻译优先)。
---------------------------------------------------------------------------- */
declare @i18n table (k varchar(150) primary key, v nvarchar(1000) not null);
insert into @i18n (k, v) values
('menu.workflow', N'流程管理'),
('menu.approval', N'审批中心'),
('menu.approval_todo', N'我的待办'),
('menu.approval_initiated', N'我发起的'),
('menu.approval_done', N'我已处理'),
('menu.approval_cc', N'抄送我的');
insert into dbo.s_i18n (b_key, b_locale, b_value, b_canuse)
select i.k, t.b_id, i.v, 1
from @i18n i
cross join (select b_id from dbo.s_i18n_type where b_default = 1) t
where not exists (select 1 from dbo.s_i18n x where x.b_key = i.k and x.b_locale = t.b_id);
GO
/* ----------------------------------------------------------------------------
自检
---------------------------------------------------------------------------- */
select '菜单' as 项, count(*) as 行数 from dbo.s_menu
where b_id in ('workflow', 'log', 'approval', 'approval_todo', 'approval_initiated', 'approval_done', 'approval_cc')
union all
select '多语言', count(*) from dbo.s_i18n where b_key like 'menu.workflow' or b_key like 'menu.approval%';
GO