u
This commit is contained in:
1 parent
f3936cec61
commit
15e0ae5b67
115 files changed
+11399
-2741
No files matched your search
@@ -0,0 +1,86 @@
|
||||
/* ============================================================================
|
||||
表格测试菜单(s_menu)—— 根菜单项
|
||||
|
||||
用途:把原「海运 → 订舱单」(/ocean/booking)整页搬迁为独立测试页后,
|
||||
在 s_menu 里挂一个**一级(根)菜单**指向它,与前端路由
|
||||
/table-test(见 web/src/router/index.ts 的 protectedRoutes)一一对应。
|
||||
|
||||
背景:本仓库的侧栏菜单已改为**动态**(读 s_menu,对照 fms-vue)——
|
||||
前端静态路由只声明「有哪些页面组件」,是否出现在侧栏、叫什么名字由 s_menu 决定。
|
||||
因此新增页面必须同时做两件事:
|
||||
1. 加一条静态路由(前端代码)
|
||||
2. 在 s_menu 里录一条菜单(本脚本)
|
||||
|
||||
说明:
|
||||
1. 幂等:菜单按 b_id 判断存在性,重复运行无副作用。
|
||||
2. 权限:本脚本默认**不建权限点**。侧栏可见性与路由进入由 menu.{菜单编码} 授权控制,
|
||||
而权限 store 对 g3soft 账号提权(一切放行),故用 g3soft 登录即可看到本菜单。
|
||||
若要让普通账号也能看到,请另行执行本文件末尾「可选:给普通账号授权」那段
|
||||
(建 s_power(menu.table_test) + s_user_power 授权),否则非管理员账号的侧栏
|
||||
会因白名单语义**不显示**该菜单(这是预期行为,不是 bug)。
|
||||
3. 排序:b_xh = 1,让它排在「审批中心(5)」「基础资料(10)」「系统管理(10)」等之前,
|
||||
作为根菜单下的第一项。
|
||||
4. b_parent_id 为 null 即根节点;b_depth = 0。
|
||||
5. b_path 约定:节点编码前后均带 /,根级为 /table_test/(与 FMS 树结构规范一致)。
|
||||
============================================================================ */
|
||||
|
||||
if not exists (select 1 from dbo.s_menu where b_id = 'table_test')
|
||||
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 ('table_test', null, 0, '/table_test/', N'表格测试', 'menu.table_test', 'page', '/table-test', 'table', 1, 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.table_test', 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 = 'table_test'
|
||||
union all
|
||||
select '多语言', count(*) from dbo.s_i18n where b_key = 'menu.table_test';
|
||||
GO
|
||||
|
||||
/* ============================================================================
|
||||
可选:给普通账号授权(默认注释掉,按需启用)
|
||||
|
||||
权限点是白名单语义:s_power 里没有 menu.table_test、或用户没被授权,
|
||||
侧栏就不显示该菜单、路由守卫也会拦到 /403。
|
||||
g3soft 超管不受此限(前后端都对其提权),所以调试时可先用 g3soft 登录。
|
||||
|
||||
启用前请把 'demo_zhangwei' 换成目标账号;若该机构库尚未建 s_power /
|
||||
s_user_power 表,请先建表再执行。
|
||||
============================================================================ */
|
||||
|
||||
/*
|
||||
-- 1) 权限点:menu.table_test
|
||||
if not exists (select 1 from dbo.s_power where b_id = 'menu.table_test')
|
||||
begin
|
||||
insert into dbo.s_power (b_id, b_name, b_type, b_canuse, b_xh, b_object_type, b_object_id, b_action, b_i18n)
|
||||
values ('menu.table_test', N'表格测试', 'menu', 1, 10, 'menu', 'table_test', 'access', 'menu.table_test');
|
||||
end
|
||||
GO
|
||||
|
||||
-- 2) 授权:把权限点授给指定账号
|
||||
if not exists (select 1 from dbo.s_user_power where b_user_id = 'demo_zhangwei' and b_power_id = 'menu.table_test')
|
||||
begin
|
||||
insert into dbo.s_user_power (b_user_id, b_power_id, b_canuse, b_created_by, b_created_at)
|
||||
values ('demo_zhangwei', 'menu.table_test', 1, 'g3soft', sysutcdatetime());
|
||||
end
|
||||
GO
|
||||
*/
|
||||
@@ -0,0 +1,39 @@
|
||||
/* ============================================================================
|
||||
首页菜单(s_menu)—— 根菜单项
|
||||
|
||||
用途:登录后的默认落地页(前端 router 的 HOME_PATH = /dashboard)。
|
||||
本次与原「表格测试」菜单一起补上:页面路由必须先存在,菜单才点得通。
|
||||
|
||||
说明:
|
||||
1. 幂等:菜单按 b_id 判断存在性,重复运行无副作用。
|
||||
2. 排序:b_xh = 0,排在「表格测试(1)」之前,作为根菜单第一项。
|
||||
3. b_parent_id 为 null 即根节点;b_depth = 0;
|
||||
b_path 约定节点编码前后均带 /,根级为 /dashboard/。
|
||||
4. 权限:不建权限点。g3soft 超管提权可见;普通账号需另配
|
||||
s_power(menu.dashboard) + s_user_power,做法见 13_table_test_menu.sql 末尾注释。
|
||||
============================================================================ */
|
||||
|
||||
if not exists (select 1 from dbo.s_menu where b_id = 'dashboard')
|
||||
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 ('dashboard', null, 0, '/dashboard/', N'首页', 'menu.dashboard', 'page', '/dashboard', 'layout-dashboard', 0, 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.dashboard', 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 = 'dashboard';
|
||||
GO
|
||||
Reference in new issue
Block a user