综述: 优化平台端web权限管理页面的功能和界面
- 在权限编辑页面中增加"可见身份"列和多选下拉框,支持为每个权限项设置可见的角色 - 更新权限数据结构,添加visibleRoles字段来存储可见身份信息 - 修改表格渲染逻辑,在权限列表中显示可见身份信息 - 完善表单处理逻辑,支持保存和编辑权限的可见身份设置
This commit is contained in:
		
							parent
							
								
									9da292dc4c
								
							
						
					
					
						commit
						1becf930cc
					
				|  | @ -481,6 +481,7 @@ | |||
|                         <th>权限描述</th> | ||||
|                         <th>权限类型</th> | ||||
|                         <th>父级权限</th> | ||||
|                         <th>可见身份</th> | ||||
|                         <th>操作</th> | ||||
|                     </tr> | ||||
|                 </thead> | ||||
|  | @ -531,6 +532,17 @@ | |||
|                             <option value="button">按钮</option> | ||||
|                         </select> | ||||
|                     </div> | ||||
|                     <div class="form-group"> | ||||
|                         <label for="visibleRoles">可见身份</label> | ||||
|                         <select id="visibleRoles" name="visibleRoles" multiple size="5"> | ||||
|                             <option value="经营者">经营者</option> | ||||
|                             <option value="商户">商户</option> | ||||
|                             <option value="代理商">代理商</option> | ||||
|                             <option value="分销商">分销商</option> | ||||
|                             <option value="品牌管理员">品牌管理员</option> | ||||
|                         </select> | ||||
|                         <small>按住 Ctrl 键可多选</small> | ||||
|                     </div> | ||||
|                 </form> | ||||
|             </div> | ||||
|             <div class="modal-footer"> | ||||
|  | @ -568,7 +580,8 @@ | |||
|                     name: '系统管理', | ||||
|                     description: '系统管理模块', | ||||
|                     parentCode: '', | ||||
|                     type: 'menu' | ||||
|                     type: 'menu', | ||||
|                     visibleRoles: ['经营者', '商户', '代理商'] | ||||
|                 }, | ||||
|                 { | ||||
|                     id: 2, | ||||
|  | @ -576,7 +589,8 @@ | |||
|                     name: '用户管理', | ||||
|                     description: '用户管理功能', | ||||
|                     parentCode: 'SYSTEM', | ||||
|                     type: 'menu' | ||||
|                     type: 'menu', | ||||
|                     visibleRoles: ['经营者', '商户'] | ||||
|                 }, | ||||
|                 { | ||||
|                     id: 3, | ||||
|  | @ -584,7 +598,8 @@ | |||
|                     name: '添加用户', | ||||
|                     description: '添加新用户按钮', | ||||
|                     parentCode: 'SYSTEM_USER', | ||||
|                     type: 'button' | ||||
|                     type: 'button', | ||||
|                     visibleRoles: ['经营者'] | ||||
|                 }, | ||||
|                 { | ||||
|                     id: 4, | ||||
|  | @ -592,7 +607,8 @@ | |||
|                     name: '编辑用户', | ||||
|                     description: '编辑用户信息按钮', | ||||
|                     parentCode: 'SYSTEM_USER', | ||||
|                     type: 'button' | ||||
|                     type: 'button', | ||||
|                     visibleRoles: ['经营者', '代理商'] | ||||
|                 }, | ||||
|                 { | ||||
|                     id: 5, | ||||
|  | @ -600,7 +616,8 @@ | |||
|                     name: '角色管理', | ||||
|                     description: '角色管理功能', | ||||
|                     parentCode: 'SYSTEM', | ||||
|                     type: 'menu' | ||||
|                     type: 'menu', | ||||
|                     visibleRoles: ['经营者'] | ||||
|                 }, | ||||
|                 { | ||||
|                     id: 6, | ||||
|  | @ -608,7 +625,8 @@ | |||
|                     name: '内容管理', | ||||
|                     description: '内容管理模块', | ||||
|                     parentCode: '', | ||||
|                     type: 'menu' | ||||
|                     type: 'menu', | ||||
|                     visibleRoles: ['商户', '代理商', '分销商'] | ||||
|                 } | ||||
|             ]; | ||||
|             renderPermissionsTable(); | ||||
|  | @ -685,6 +703,7 @@ | |||
|                     <td>${item.description || '-'}</td> | ||||
|                     <td><span class="permission-type type-${item.type}">${item.type === 'menu' ? '菜单' : '按钮'}</span></td> | ||||
|                     <td>${item.parentCode || '-'}</td> | ||||
|                     <td>${item.visibleRoles ? item.visibleRoles.join(', ') : '-'}</td> | ||||
|                     <td class="actions"> | ||||
|                         <button class="btn btn-primary btn-sm" onclick="editPermissionById(${item.id})">编辑</button> | ||||
|                         <button class="btn btn-danger btn-sm" onclick="deletePermissionById(${item.id})">删除</button> | ||||
|  | @ -818,6 +837,12 @@ | |||
|             document.getElementById('permissionDesc').value = permission.description || ''; | ||||
|             document.getElementById('permissionType').value = permission.type; | ||||
|              | ||||
|             // 设置可见身份选项 | ||||
|             const visibleRolesSelect = document.getElementById('visibleRoles'); | ||||
|             Array.from(visibleRolesSelect.options).forEach(option => { | ||||
|                 option.selected = permission.visibleRoles && permission.visibleRoles.includes(option.value); | ||||
|             }); | ||||
|              | ||||
|             updateParentCodeOptions(permission.code); | ||||
|             document.getElementById('parentCode').value = permission.parentCode || ''; | ||||
|              | ||||
|  | @ -877,6 +902,10 @@ | |||
|             const parentCode = formData.get('parentCode'); | ||||
|             const type = formData.get('type'); | ||||
|              | ||||
|             // 获取可见身份选项 | ||||
|             const visibleRolesSelect = document.getElementById('visibleRoles'); | ||||
|             const selectedRoles = Array.from(visibleRolesSelect.selectedOptions).map(option => option.value); | ||||
|              | ||||
|             // 验证 | ||||
|             if (!code || !name || !type) { | ||||
|                 alert('请填写必填项!'); | ||||
|  | @ -908,7 +937,8 @@ | |||
|                 name, | ||||
|                 description, | ||||
|                 parentCode: parentCode || '', | ||||
|                 type | ||||
|                 type, | ||||
|                 visibleRoles: selectedRoles | ||||
|             }; | ||||
|              | ||||
|             if (currentEditingId) { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue