118 lines
9.4 KiB
MySQL
118 lines
9.4 KiB
MySQL
|
|
-- ============================================================
|
|||
|
|
-- 修复报工单配置权限问题
|
|||
|
|
-- 版本:v2.0.009 日期:2026-03-14 作者:周启威
|
|||
|
|
-- 问题:报工单新增时提示"加载配置失败: error"和"没有权限"
|
|||
|
|
-- 原因:缺少报工单类别配置和字段配置的权限记录
|
|||
|
|
-- ============================================================
|
|||
|
|
|
|||
|
|
-- ============================================================
|
|||
|
|
-- 1. 获取报工单菜单ID(通过perms标识动态查询)
|
|||
|
|
-- ============================================================
|
|||
|
|
SET @report_menu_id = (SELECT menu_id FROM sys_menu WHERE perms = 'production:report:list' LIMIT 1);
|
|||
|
|
|
|||
|
|
-- 验证是否找到报工单菜单
|
|||
|
|
SELECT CONCAT('报工单菜单ID: ', IFNULL(@report_menu_id, '未找到')) AS '查询结果';
|
|||
|
|
|
|||
|
|
-- 如果找不到报工单菜单,则终止执行
|
|||
|
|
-- 注意:MySQL不支持直接的IF判断终止,需要手动检查上面的查询结果
|
|||
|
|
-- 如果@report_menu_id为NULL,请检查sys_menu表中是否存在perms='production:report:list'的记录
|
|||
|
|
|
|||
|
|
-- ============================================================
|
|||
|
|
-- 2. 添加权限配置到菜单表(使用动态parent_id)
|
|||
|
|
-- ============================================================
|
|||
|
|
|
|||
|
|
-- 类别配置权限
|
|||
|
|
INSERT INTO `sys_menu` (`menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`)
|
|||
|
|
SELECT '类别配置查询', @report_menu_id, 11, '#', '', NULL, 1, 0, 'F', '0', '0', 'production:report:categoryConfig:list', '#', 'admin', NOW(), 'admin', NOW(), ''
|
|||
|
|
WHERE @report_menu_id IS NOT NULL
|
|||
|
|
AND NOT EXISTS (SELECT 1 FROM sys_menu WHERE perms = 'production:report:categoryConfig:list');
|
|||
|
|
|
|||
|
|
INSERT INTO `sys_menu` (`menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`)
|
|||
|
|
SELECT '类别配置详情', @report_menu_id, 12, '#', '', NULL, 1, 0, 'F', '0', '0', 'production:report:categoryConfig:query', '#', 'admin', NOW(), 'admin', NOW(), ''
|
|||
|
|
WHERE @report_menu_id IS NOT NULL
|
|||
|
|
AND NOT EXISTS (SELECT 1 FROM sys_menu WHERE perms = 'production:report:categoryConfig:query');
|
|||
|
|
|
|||
|
|
INSERT INTO `sys_menu` (`menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`)
|
|||
|
|
SELECT '类别配置新增', @report_menu_id, 13, '#', '', NULL, 1, 0, 'F', '0', '0', 'production:report:categoryConfig:add', '#', 'admin', NOW(), 'admin', NOW(), ''
|
|||
|
|
WHERE @report_menu_id IS NOT NULL
|
|||
|
|
AND NOT EXISTS (SELECT 1 FROM sys_menu WHERE perms = 'production:report:categoryConfig:add');
|
|||
|
|
|
|||
|
|
INSERT INTO `sys_menu` (`menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`)
|
|||
|
|
SELECT '类别配置修改', @report_menu_id, 14, '#', '', NULL, 1, 0, 'F', '0', '0', 'production:report:categoryConfig:edit', '#', 'admin', NOW(), 'admin', NOW(), ''
|
|||
|
|
WHERE @report_menu_id IS NOT NULL
|
|||
|
|
AND NOT EXISTS (SELECT 1 FROM sys_menu WHERE perms = 'production:report:categoryConfig:edit');
|
|||
|
|
|
|||
|
|
INSERT INTO `sys_menu` (`menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`)
|
|||
|
|
SELECT '类别配置删除', @report_menu_id, 15, '#', '', NULL, 1, 0, 'F', '0', '0', 'production:report:categoryConfig:remove', '#', 'admin', NOW(), 'admin', NOW(), ''
|
|||
|
|
WHERE @report_menu_id IS NOT NULL
|
|||
|
|
AND NOT EXISTS (SELECT 1 FROM sys_menu WHERE perms = 'production:report:categoryConfig:remove');
|
|||
|
|
|
|||
|
|
INSERT INTO `sys_menu` (`menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`)
|
|||
|
|
SELECT '类别名称重置', @report_menu_id, 16, '#', '', NULL, 1, 0, 'F', '0', '0', 'production:report:categoryConfig:resetName', '#', 'admin', NOW(), 'admin', NOW(), ''
|
|||
|
|
WHERE @report_menu_id IS NOT NULL
|
|||
|
|
AND NOT EXISTS (SELECT 1 FROM sys_menu WHERE perms = 'production:report:categoryConfig:resetName');
|
|||
|
|
|
|||
|
|
-- 字段配置权限
|
|||
|
|
INSERT INTO `sys_menu` (`menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`)
|
|||
|
|
SELECT '字段配置查询', @report_menu_id, 21, '#', '', NULL, 1, 0, 'F', '0', '0', 'production:report:fieldConfig:list', '#', 'admin', NOW(), 'admin', NOW(), ''
|
|||
|
|
WHERE @report_menu_id IS NOT NULL
|
|||
|
|
AND NOT EXISTS (SELECT 1 FROM sys_menu WHERE perms = 'production:report:fieldConfig:list');
|
|||
|
|
|
|||
|
|
INSERT INTO `sys_menu` (`menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`)
|
|||
|
|
SELECT '字段配置详情', @report_menu_id, 22, '#', '', NULL, 1, 0, 'F', '0', '0', 'production:report:fieldConfig:query', '#', 'admin', NOW(), 'admin', NOW(), ''
|
|||
|
|
WHERE @report_menu_id IS NOT NULL
|
|||
|
|
AND NOT EXISTS (SELECT 1 FROM sys_menu WHERE perms = 'production:report:fieldConfig:query');
|
|||
|
|
|
|||
|
|
INSERT INTO `sys_menu` (`menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`)
|
|||
|
|
SELECT '字段配置新增', @report_menu_id, 23, '#', '', NULL, 1, 0, 'F', '0', '0', 'production:report:fieldConfig:add', '#', 'admin', NOW(), 'admin', NOW(), ''
|
|||
|
|
WHERE @report_menu_id IS NOT NULL
|
|||
|
|
AND NOT EXISTS (SELECT 1 FROM sys_menu WHERE perms = 'production:report:fieldConfig:add');
|
|||
|
|
|
|||
|
|
INSERT INTO `sys_menu` (`menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`)
|
|||
|
|
SELECT '字段配置修改', @report_menu_id, 24, '#', '', NULL, 1, 0, 'F', '0', '0', 'production:report:fieldConfig:edit', '#', 'admin', NOW(), 'admin', NOW(), ''
|
|||
|
|
WHERE @report_menu_id IS NOT NULL
|
|||
|
|
AND NOT EXISTS (SELECT 1 FROM sys_menu WHERE perms = 'production:report:fieldConfig:edit');
|
|||
|
|
|
|||
|
|
INSERT INTO `sys_menu` (`menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`)
|
|||
|
|
SELECT '字段配置删除', @report_menu_id, 25, '#', '', NULL, 1, 0, 'F', '0', '0', 'production:report:fieldConfig:remove', '#', 'admin', NOW(), 'admin', NOW(), ''
|
|||
|
|
WHERE @report_menu_id IS NOT NULL
|
|||
|
|
AND NOT EXISTS (SELECT 1 FROM sys_menu WHERE perms = 'production:report:fieldConfig:remove');
|
|||
|
|
|
|||
|
|
INSERT INTO `sys_menu` (`menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`)
|
|||
|
|
SELECT '字段名称重置', @report_menu_id, 26, '#', '', NULL, 1, 0, 'F', '0', '0', 'production:report:fieldConfig:resetName', '#', 'admin', NOW(), 'admin', NOW(), ''
|
|||
|
|
WHERE @report_menu_id IS NOT NULL
|
|||
|
|
AND NOT EXISTS (SELECT 1 FROM sys_menu WHERE perms = 'production:report:fieldConfig:resetName');
|
|||
|
|
|
|||
|
|
INSERT INTO `sys_menu` (`menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`)
|
|||
|
|
SELECT '字段批量修改', @report_menu_id, 27, '#', '', NULL, 1, 0, 'F', '0', '0', 'production:report:fieldConfig:batchEdit', '#', 'admin', NOW(), 'admin', NOW(), ''
|
|||
|
|
WHERE @report_menu_id IS NOT NULL
|
|||
|
|
AND NOT EXISTS (SELECT 1 FROM sys_menu WHERE perms = 'production:report:fieldConfig:batchEdit');
|
|||
|
|
|
|||
|
|
-- ============================================================
|
|||
|
|
-- 3. 验证权限配置
|
|||
|
|
-- ============================================================
|
|||
|
|
-- 执行以下查询验证权限是否添加成功:
|
|||
|
|
SELECT menu_id, menu_name, parent_id, perms
|
|||
|
|
FROM sys_menu
|
|||
|
|
WHERE perms LIKE 'production:report:%Config:%'
|
|||
|
|
ORDER BY parent_id, order_num;
|
|||
|
|
|
|||
|
|
-- ============================================================
|
|||
|
|
-- 4. 说明
|
|||
|
|
-- ============================================================
|
|||
|
|
-- 1. 本SQL使用动态查询parent_id,通过perms='production:report:list'定位报工单菜单
|
|||
|
|
-- 2. 使用NOT EXISTS避免重复插入权限记录
|
|||
|
|
-- 3. 管理员(userId=1)默认拥有所有权限(*:*:*),无需单独分配
|
|||
|
|
-- 4. 如果你使用的不是管理员账号,需要在"系统管理->角色管理"中手动分配权限
|
|||
|
|
-- 5. 执行此SQL后,需要:
|
|||
|
|
-- - 清除浏览器缓存
|
|||
|
|
-- - 退出系统并重新登录
|
|||
|
|
-- - 重新打开报工单新增页面测试
|
|||
|
|
-- 6. 如果仍有问题,请检查:
|
|||
|
|
-- - 数据库中是否已存在 pro_report_category_config 和 pro_report_field_config 表
|
|||
|
|
-- - 表中是否有初始化数据(执行 2026-03-05_v2.0.003_周启威_报工单页面类别与字段控制.sql)
|
|||
|
|
-- - 后端服务是否已重启
|
|||
|
|
-- - 当前登录用户的userId(SELECT user_id FROM sys_user WHERE user_name = '你的用户名')
|
|||
|
|
-- - 如果userId不是1,检查该用户的角色权限配置
|
|||
|
|
|