import React, { useEffect } from 'react' import { Button, message, Tree, TreeSelect, Form, Popconfirm } from 'antd' import { DeleteOutlined, PlusOutlined } from '@ant-design/icons' import consts from '@/consts' import { addDepartment, delDepartment } from '@/services/hr' import { connect, useAccess } from 'umi' import { ModalForm, ProFormText } from '@ant-design/pro-form' import './index.less' const { DirectoryTree } = Tree const RoleMenu = props => { const { dispatch, departments = [], onSelect, showType } = props const hasPerm = useAccess()?.validatePermByType('employee_del_department') const newList = [...departments] newList.unshift({ children: [], id: '0', key: '0', isLeaf: false, name: '总全公司', title: '总全公司' }) const initData = () => { dispatch({ type: 'staff/fetchDepartments' }) } const handleDelDepartment = async id => { const { code = -1 } = await delDepartment(id) if (code === consts.RET_CODE.SUCCESS) { message.success('删除成功') initData() } } function renderTreeNode(tree) { if (!hasPerm) return tree return tree.map(item => { const newItem = { ...item, title: (