Explorar el Código

feat: 树结构点击传值

outaozhen hace 5 años
padre
commit
7379d43782
Se han modificado 2 ficheros con 7 adiciones y 6 borrados
  1. 6 5
      src/pages/Staff/RoleMenu/index.jsx
  2. 1 1
      src/pages/Staff/Employee/index.jsx

+ 6 - 5
src/pages/Staff/RoleMenu/index.jsx

@@ -7,7 +7,7 @@ import { connect } from 'dva'
 import { ModalForm, ProFormText, ProFormSelect } from '@ant-design/pro-form'
 import { ModalForm, ProFormText, ProFormSelect } from '@ant-design/pro-form'
 
 
 const RoleMenu = props => {
 const RoleMenu = props => {
-  const { dispatch, departments = [] } = props
+  const { dispatch, departments = [], onSelect } = props
   const { DirectoryTree } = Tree
   const { DirectoryTree } = Tree
 
 
   const initData = () => {
   const initData = () => {
@@ -30,11 +30,12 @@ const RoleMenu = props => {
     }
     }
   }, [])
   }, [])
 
 
-  const saveActiveId = keys => {
+  const saveActiveId = id => {
     // console.log(keys)
     // console.log(keys)
-    if (saveActiveId) {
-      saveActiveId(keys)
+    if (onSelect) {
+      onSelect(id)
     }
     }
+    console.log(id)
   }
   }
 
 
   const onExpand = () => {}
   const onExpand = () => {}
@@ -72,7 +73,7 @@ const RoleMenu = props => {
           <DirectoryTree
           <DirectoryTree
             multiple
             multiple
             defaultExpandAll
             defaultExpandAll
-            onSelect={saveActiveId}
+            onSelect={keys => saveActiveId(keys[0])}
             onExpand={onExpand}
             onExpand={onExpand}
             showIcon={false}
             showIcon={false}
             treeData={departments}
             treeData={departments}

+ 1 - 1
src/pages/Staff/Employee/index.jsx

@@ -1,7 +1,7 @@
 import React, { useState, useEffect } from 'react'
 import React, { useState, useEffect } from 'react'
 import consts from '@/consts'
 import consts from '@/consts'
 import ProTable from '@ant-design/pro-table'
 import ProTable from '@ant-design/pro-table'
-import RoleMenu from '@/pages/Staff/RoleMenu'
+import RoleMenu from '@/pages/Staff/Employee/components/RoleMenu'
 import { queryStaff } from '@/services/staff'
 import { queryStaff } from '@/services/staff'
 import { useTableScroll } from '@/hooks/useAutoTable'
 import { useTableScroll } from '@/hooks/useAutoTable'