outaozhen 3 years ago
parent
commit
611525d937

+ 1 - 1
src/pages/Permission/Role/components/RoleLeftMenu/index.tsx

@@ -143,7 +143,7 @@ const RoleLeftMenu = ({ onSelect }) => {
           {menuRoles.length ? (
             <DirectoryTree
               defaultSelectedKeys={[menuRoles[0]?.key]}
-              onSelect={keys => onSelect(keys[0])}
+              onSelect={(keys, node) => onSelect(keys[0], node.node.roleType)}
               showIcon={false}
               treeData={renderTreeNode(menuRoles)}
             />

+ 18 - 8
src/pages/Permission/Role/components/SetPermission/index.tsx

@@ -5,8 +5,13 @@ import { setRolePermission } from '@/services/permission'
 import { useRequest } from 'umi'
 const { TabPane } = Tabs
 
-const SetPermission = ({ ID, activeKey }) => {
-  const [bottom, setBottom] = useState(10)
+const SetPermission = ({ ID, activeKey, roleType }) => {
+  const bottom = 10
+  const [state, setState] = useState({
+    checkValue: []
+  })
+  console.log(state.checkValue)
+
   const { run: trySetRolePermission } = useRequest(
     (frontPermission: string) => setRolePermission({ ID, frontPermission }),
     {
@@ -17,13 +22,12 @@ const SetPermission = ({ ID, activeKey }) => {
     }
   )
   const handleOnchange = e => {
-    // console.log(e)
-
-    trySetRolePermission(ID, e)
+    setState({ ...state, checkValue: e })
+    // trySetRolePermission(ID, e)
   }
   useEffect(() => {
     if (activeKey === '2') {
-      trySetRolePermission(ID, e)
+      // trySetRolePermission(ID, e)
     }
   }, [activeKey])
   return (
@@ -66,13 +70,19 @@ const SetPermission = ({ ID, activeKey }) => {
               <div>
                 <h4 className="pt-3">我参与的项目</h4>
                 <div className="my-2">
-                  <Checkbox.Group options={[{ value: 'access', label: '查看项目' }]} />
+                  <Checkbox.Group
+                    onChange={handleOnchange}
+                    options={[{ value: 'access', label: '查看项目' }]}
+                  />
                 </div>
               </div>
               <div>
                 <h4 className="pt-3">全部项目</h4>
                 <div className="my-2">
-                  <Checkbox.Group options={[{ value: 'viewAllProjects', label: '查看项目' }]} />
+                  <Checkbox.Group
+                    onChange={handleOnchange}
+                    options={[{ value: 'viewAllProjects', label: '查看项目' }]}
+                  />
                 </div>
               </div>
               <div>

+ 9 - 5
src/pages/Permission/Role/index.tsx

@@ -17,10 +17,10 @@ const { TabPane } = Tabs
 const Role = () => {
   const [state, setState] = useState({
     currentRoleID: '',
+    roleType: '',
     roleStaff: [],
     activeKey: ''
   })
-
   const { run: tryGetRoleStaffList } = useRequest(
     (roleID: string) => fetchRoleListByRoleId({ roleID }),
     {
@@ -41,8 +41,8 @@ const Role = () => {
     }
   )
 
-  const onSelect = (currentRoleID: string) => {
-    setState({ ...state, currentRoleID })
+  const onSelect = (currentRoleID: string, roleType: string) => {
+    setState({ ...state, currentRoleID, roleType })
     tryGetRoleStaffList(currentRoleID)
   }
 
@@ -72,7 +72,7 @@ const Role = () => {
           title="确定移除吗?"
           okText="确定"
           cancelText="取消"
-          onConfirm={() => tryUnLinkRoleAccount({ ID: state.ID, accountID: record.ID })}>
+          onConfirm={() => tryUnLinkRoleAccount({ ID: state.currentRoleID, accountID: record.ID })}>
           <span className="text-hex-fd3995 cursor-pointer hover:text-hex-e7026e">
             <DeleteOutlined />
           </span>
@@ -103,7 +103,11 @@ const Role = () => {
                 />
               </TabPane>
               <TabPane tab="功能权限" key="2">
-                <SetPermission ID={state.currentRoleID} activeKey={state.activeKey} />
+                <SetPermission
+                  ID={state.currentRoleID}
+                  activeKey={state.activeKey}
+                  roleType={state.roleType}
+                />
               </TabPane>
             </Tabs>
           </div>