|  | @@ -1,40 +1,47 @@
 | 
	
		
			
				|  |  |  import { useModel, useRequest } from 'umi'
 | 
	
		
			
				|  |  |  import Icon from '@/components/IconPark'
 | 
	
		
			
				|  |  |  import ProForm, { ProFormCheckbox, ProFormDependency, ProFormSwitch } from '@ant-design/pro-form'
 | 
	
		
			
				|  |  | -import { Table, Tabs } from 'antd'
 | 
	
		
			
				|  |  | +import { message, Table, Tabs } from 'antd'
 | 
	
		
			
				|  |  |  import React, { useMemo, useState, useEffect } from 'react'
 | 
	
		
			
				|  |  |  import RoleMenu from './components/RoleMenu/roleMenu'
 | 
	
		
			
				|  |  | -import { fetchRoleStaffListByRoleId } from '@/services/user/api'
 | 
	
		
			
				|  |  | +import { fetchRoleStaffListByRoleId, updateRolePermission } from '@/services/user/api'
 | 
	
		
			
				|  |  |  import type { ColumnsType } from 'antd/lib/table'
 | 
	
		
			
				|  |  |  import ConnectModal from './components/ConnectModal'
 | 
	
		
			
				|  |  | +import { formatPermission } from '@/utils/utils'
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -const System: React.FC = () => {
 | 
	
		
			
				|  |  | +const System = () => {
 | 
	
		
			
				|  |  |    const { TabPane } = Tabs
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    const columns: ColumnsType<API.RoleStaffListItem> = [
 | 
	
		
			
				|  |  |      {
 | 
	
		
			
				|  |  |        title: '用户',
 | 
	
		
			
				|  |  | -      dataIndex: 'username'
 | 
	
		
			
				|  |  | +      dataIndex: 'username',
 | 
	
		
			
				|  |  | +      width: '15%'
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |      {
 | 
	
		
			
				|  |  |        title: '手机',
 | 
	
		
			
				|  |  | -      dataIndex: 'phone'
 | 
	
		
			
				|  |  | +      dataIndex: 'phone',
 | 
	
		
			
				|  |  | +      width: '20%'
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |      {
 | 
	
		
			
				|  |  |        title: '部门',
 | 
	
		
			
				|  |  | -      dataIndex: 'departmentName'
 | 
	
		
			
				|  |  | +      dataIndex: 'departmentName',
 | 
	
		
			
				|  |  | +      width: '20%'
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |      {
 | 
	
		
			
				|  |  |        title: '岗位',
 | 
	
		
			
				|  |  | -      dataIndex: 'position'
 | 
	
		
			
				|  |  | +      dataIndex: 'position',
 | 
	
		
			
				|  |  | +      width: '15%'
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |      {
 | 
	
		
			
				|  |  |        title: '角色',
 | 
	
		
			
				|  |  | -      dataIndex: 'age'
 | 
	
		
			
				|  |  | +      dataIndex: 'age',
 | 
	
		
			
				|  |  | +      width: '20%'
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |      {
 | 
	
		
			
				|  |  |        title: '操作',
 | 
	
		
			
				|  |  |        dataIndex: 'opreate',
 | 
	
		
			
				|  |  | +      width: '20%',
 | 
	
		
			
				|  |  |        render: () => (
 | 
	
		
			
				|  |  |          <span className="hover:text-hex-e7026e">
 | 
	
		
			
				|  |  |            <Icon type="delete" fill="#fd3995" />
 | 
	
	
		
			
				|  | @@ -48,7 +55,7 @@ const System: React.FC = () => {
 | 
	
		
			
				|  |  |      return initialState?.menuList?.find(item => item.name === '系统管理')?.id
 | 
	
		
			
				|  |  |    }, initialState.menuList)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -  const [state, setState] = useState<{ id: string; roleStaff: API.RoleStaffListItem[] }>({
 | 
	
		
			
				|  |  | +  const [state, setState] = useState({
 | 
	
		
			
				|  |  |      id: '',
 | 
	
		
			
				|  |  |      roleStaff: []
 | 
	
		
			
				|  |  |    })
 | 
	
	
		
			
				|  | @@ -75,6 +82,7 @@ const System: React.FC = () => {
 | 
	
		
			
				|  |  |      <div className="h-full w-full flex flex-row">
 | 
	
		
			
				|  |  |        <RoleMenu menuId={menuId} onSelect={onSelect} />
 | 
	
		
			
				|  |  |        <div className="w-max-3/4">
 | 
	
		
			
				|  |  | +        <div></div>
 | 
	
		
			
				|  |  |          <div className="ml-8 bg-white p-4 shadow-md shadow-hex-3e2c5a relative">
 | 
	
		
			
				|  |  |            <div className="absolute right-4 top-4 z-100">
 | 
	
		
			
				|  |  |              {state.id && (
 | 
	
	
		
			
				|  | @@ -94,8 +102,15 @@ const System: React.FC = () => {
 | 
	
		
			
				|  |  |                />
 | 
	
		
			
				|  |  |              </TabPane>
 | 
	
		
			
				|  |  |              <TabPane tab="角色权限" key="2">
 | 
	
		
			
				|  |  | -              <ProForm layout="horizontal" initialValues={{ staff: ['1', '2'] }}>
 | 
	
		
			
				|  |  | -                <ProFormSwitch
 | 
	
		
			
				|  |  | +              {state.id && (
 | 
	
		
			
				|  |  | +                <ProForm
 | 
	
		
			
				|  |  | +                  layout="horizontal"
 | 
	
		
			
				|  |  | +                  onFinish={async values => {
 | 
	
		
			
				|  |  | +                    const newValues = formatPermission(values)
 | 
	
		
			
				|  |  | +                    await updateRolePermission({ permission: [newValues], id: state.id })
 | 
	
		
			
				|  |  | +                    message.success('设置成功')
 | 
	
		
			
				|  |  | +                  }}>
 | 
	
		
			
				|  |  | +                  {/* <ProFormSwitch
 | 
	
		
			
				|  |  |                    name="showHome"
 | 
	
		
			
				|  |  |                    label={
 | 
	
		
			
				|  |  |                      <span className="flex items-center">
 | 
	
	
		
			
				|  | @@ -103,39 +118,40 @@ const System: React.FC = () => {
 | 
	
		
			
				|  |  |                        后台首页
 | 
	
		
			
				|  |  |                      </span>
 | 
	
		
			
				|  |  |                    }
 | 
	
		
			
				|  |  | -                />
 | 
	
		
			
				|  |  | +                /> */}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                <ProFormSwitch
 | 
	
		
			
				|  |  | -                  name="showAuth"
 | 
	
		
			
				|  |  | -                  label={
 | 
	
		
			
				|  |  | -                    <span className="flex items-center">
 | 
	
		
			
				|  |  | -                      <Icon
 | 
	
		
			
				|  |  | -                        type="every-user"
 | 
	
		
			
				|  |  | -                        className="mr-1"
 | 
	
		
			
				|  |  | -                        className="flex items-baseline mr-1"
 | 
	
		
			
				|  |  | +                  <ProFormSwitch
 | 
	
		
			
				|  |  | +                    name="showSystem"
 | 
	
		
			
				|  |  | +                    label={
 | 
	
		
			
				|  |  | +                      <span className="flex items-center">
 | 
	
		
			
				|  |  | +                        <Icon
 | 
	
		
			
				|  |  | +                          type="every-user"
 | 
	
		
			
				|  |  | +                          className="mr-1"
 | 
	
		
			
				|  |  | +                          className="flex items-baseline mr-1"
 | 
	
		
			
				|  |  | +                        />
 | 
	
		
			
				|  |  | +                        角色权限管理
 | 
	
		
			
				|  |  | +                      </span>
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                  />
 | 
	
		
			
				|  |  | +                  <ProFormDependency name={['showSystem']}>
 | 
	
		
			
				|  |  | +                    {({ showSystem }) => (
 | 
	
		
			
				|  |  | +                      <ProFormCheckbox.Group
 | 
	
		
			
				|  |  | +                        wrapperCol={{ offset: 1 }}
 | 
	
		
			
				|  |  | +                        // initialValue={}
 | 
	
		
			
				|  |  | +                        name="system"
 | 
	
		
			
				|  |  | +                        options={[
 | 
	
		
			
				|  |  | +                          { value: 'system', label: '系统管理', disabled: !showSystem },
 | 
	
		
			
				|  |  | +                          { value: 'customer', label: '客户', disabled: !showSystem }
 | 
	
		
			
				|  |  | +                          // { value: '3', label: '产品', disabled: !showAuth },
 | 
	
		
			
				|  |  | +                          // { value: '4', label: '开票合同', disabled: !showAuth },
 | 
	
		
			
				|  |  | +                          // { value: '5', label: '考勤', disabled: !showAuth },
 | 
	
		
			
				|  |  | +                          // { value: '6', label: '人资', disabled: !showAuth },
 | 
	
		
			
				|  |  | +                          // { value: '7', label: '财务费用', disabled: !showAuth }
 | 
	
		
			
				|  |  | +                        ]}
 | 
	
		
			
				|  |  |                        />
 | 
	
		
			
				|  |  | -                      角色权限管理
 | 
	
		
			
				|  |  | -                    </span>
 | 
	
		
			
				|  |  | -                  }
 | 
	
		
			
				|  |  | -                />
 | 
	
		
			
				|  |  | -                <ProFormDependency name={['showAuth']}>
 | 
	
		
			
				|  |  | -                  {({ showAuth }) => (
 | 
	
		
			
				|  |  | -                    <ProFormCheckbox.Group
 | 
	
		
			
				|  |  | -                      wrapperCol={{ offset: 1 }}
 | 
	
		
			
				|  |  | -                      name="staff"
 | 
	
		
			
				|  |  | -                      options={[
 | 
	
		
			
				|  |  | -                        { value: '1', label: '系统管理', disabled: !showAuth },
 | 
	
		
			
				|  |  | -                        { value: '2', label: '客户', disabled: !showAuth },
 | 
	
		
			
				|  |  | -                        { value: '3', label: '产品', disabled: !showAuth },
 | 
	
		
			
				|  |  | -                        { value: '4', label: '开票合同', disabled: !showAuth },
 | 
	
		
			
				|  |  | -                        { value: '5', label: '考勤', disabled: !showAuth },
 | 
	
		
			
				|  |  | -                        { value: '6', label: '人资', disabled: !showAuth },
 | 
	
		
			
				|  |  | -                        { value: '7', label: '财务费用', disabled: !showAuth }
 | 
	
		
			
				|  |  | -                      ]}
 | 
	
		
			
				|  |  | -                    />
 | 
	
		
			
				|  |  | -                  )}
 | 
	
		
			
				|  |  | -                </ProFormDependency>
 | 
	
		
			
				|  |  | -                <ProFormSwitch
 | 
	
		
			
				|  |  | +                    )}
 | 
	
		
			
				|  |  | +                  </ProFormDependency>
 | 
	
		
			
				|  |  | +                  {/* <ProFormSwitch
 | 
	
		
			
				|  |  |                    name="showAudit"
 | 
	
		
			
				|  |  |                    label={
 | 
	
		
			
				|  |  |                      <span className="flex items-center">
 | 
	
	
		
			
				|  | @@ -187,8 +203,9 @@ const System: React.FC = () => {
 | 
	
		
			
				|  |  |                        ]}
 | 
	
		
			
				|  |  |                      />
 | 
	
		
			
				|  |  |                    )}
 | 
	
		
			
				|  |  | -                </ProFormDependency>
 | 
	
		
			
				|  |  | -              </ProForm>
 | 
	
		
			
				|  |  | +                </ProFormDependency> */}
 | 
	
		
			
				|  |  | +                </ProForm>
 | 
	
		
			
				|  |  | +              )}
 | 
	
		
			
				|  |  |              </TabPane>
 | 
	
		
			
				|  |  |            </Tabs>
 | 
	
		
			
				|  |  |          </div>
 |