|
@@ -21,7 +21,6 @@ const RoleLeftMenu = ({ onSelect }) => {
|
|
|
const [state, setState] = useState({
|
|
|
value: ''
|
|
|
})
|
|
|
- // const [activeId, setActiveId] = useState('')
|
|
|
const [menuRoles, setMenuRoles] = useState<API.MenuRoleItem[]>([])
|
|
|
const { run: tryFetchRoleListByMenu } = useRequest(() => fetchRoleListByMenu(), {
|
|
|
manual: true,
|
|
@@ -33,7 +32,7 @@ const RoleLeftMenu = ({ onSelect }) => {
|
|
|
roleType: item.roleType
|
|
|
}))
|
|
|
)
|
|
|
- // setActiveId(result[0]['ID'])
|
|
|
+ result?.length && onSelect?.(result[0]?.ID)
|
|
|
}
|
|
|
})
|
|
|
const { run: tryAddRole } = useRequest((params: API.CreateRoleParams) => addRoleMenu(params), {
|
|
@@ -76,14 +75,12 @@ const RoleLeftMenu = ({ onSelect }) => {
|
|
|
title={
|
|
|
<Input
|
|
|
placeholder="角色名称"
|
|
|
- name="name"
|
|
|
onChange={e => onChangeName(e.currentTarget.value)}
|
|
|
/>
|
|
|
}
|
|
|
- okText="确认"
|
|
|
+ okText="确定"
|
|
|
cancelText="取消"
|
|
|
- onConfirm={() => tryUpdateRole(item.id, state.name)}
|
|
|
- icon="">
|
|
|
+ onConfirm={() => tryUpdateRole(item.id, state.name)}>
|
|
|
<FormOutlined className="pr-2" />
|
|
|
</Popconfirm>
|
|
|
<Popconfirm
|
|
@@ -109,12 +106,7 @@ const RoleLeftMenu = ({ onSelect }) => {
|
|
|
useEffect(() => {
|
|
|
tryFetchRoleListByMenu()
|
|
|
}, [])
|
|
|
- const saveActiveId = (id: string) => {
|
|
|
- // setActiveId(id)
|
|
|
- if (onSelect) {
|
|
|
- onSelect(id)
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
return (
|
|
|
<div
|
|
|
className="w-216px rounded-20px"
|
|
@@ -150,59 +142,12 @@ const RoleLeftMenu = ({ onSelect }) => {
|
|
|
<ul className="p-0 m-0 list-none text-primary flex flex-col flex-1">
|
|
|
{menuRoles.length ? (
|
|
|
<DirectoryTree
|
|
|
- multiple
|
|
|
- defaultExpandAll
|
|
|
- defaultSelectedKeys={menuRoles[0]?.key}
|
|
|
- onSelect={keys => saveActiveId(keys[0])}
|
|
|
+ defaultSelectedKeys={[menuRoles[0]?.key]}
|
|
|
+ onSelect={keys => onSelect(keys[0])}
|
|
|
showIcon={false}
|
|
|
treeData={renderTreeNode(menuRoles)}
|
|
|
/>
|
|
|
) : null}
|
|
|
- {/* {menuRoles.map(item => (
|
|
|
- <Popover
|
|
|
- key={item.id}
|
|
|
- placement="right"
|
|
|
- content={
|
|
|
- <div>
|
|
|
- {item.roleType !== 'system' ? (
|
|
|
- <span>
|
|
|
- <Popconfirm
|
|
|
- title={
|
|
|
- <Input
|
|
|
- placeholder="角色名称"
|
|
|
- name="name"
|
|
|
- onChange={e => onChangeName(e.currentTarget.value)}
|
|
|
- />
|
|
|
- }
|
|
|
- okText="确定"
|
|
|
- cancelText="取消"
|
|
|
- onConfirm={() => tryUpdateRole(item.ID, state.name)}
|
|
|
- icon="">
|
|
|
- <FormOutlined className="pr-1" />
|
|
|
- </Popconfirm>
|
|
|
- <Popconfirm
|
|
|
- title="确定删除该角色"
|
|
|
- okText="确定"
|
|
|
- cancelText="取消"
|
|
|
- onConfirm={() => tryDelRole(item.ID)}
|
|
|
- icon={<QuestionCircleOutlined style={{ color: 'red' }} />}>
|
|
|
- <DeleteOutlined />
|
|
|
- </Popconfirm>
|
|
|
- </span>
|
|
|
- ) : null}
|
|
|
- </div>
|
|
|
- }>
|
|
|
- <li
|
|
|
- key={item.id}
|
|
|
- className={[
|
|
|
- 'flex justify-between items-center py-2 px-5 cursor-pointer',
|
|
|
- item.ID === activeId ? 'scale-up-center' : ''
|
|
|
- ].join(' ')}
|
|
|
- onClick={() => handleItemClick(item.ID)}>
|
|
|
- <span>{item.name}</span>
|
|
|
- </li>
|
|
|
- </Popover>
|
|
|
- ))} */}
|
|
|
</ul>
|
|
|
</div>
|
|
|
</div>
|