|
@@ -6,6 +6,7 @@ import React, { useMemo, useState, useEffect } from 'react'
|
|
|
import RoleMenu from './components/RoleMenu/roleMenu'
|
|
|
import { fetchRoleStaffListByRoleId } from '@/services/user/api'
|
|
|
import type { ColumnsType } from 'antd/lib/table'
|
|
|
+import ConnectModal from './components/ConnectModal'
|
|
|
|
|
|
const System: React.FC = () => {
|
|
|
const { TabPane } = Tabs
|
|
@@ -55,25 +56,42 @@ const System: React.FC = () => {
|
|
|
setState({ ...state, id })
|
|
|
}
|
|
|
|
|
|
- const { run: tryGetRoleStaffList } = useRequest((id: string) => fetchRoleStaffListByRoleId(id), {
|
|
|
- manual: true,
|
|
|
- onSuccess: result => {
|
|
|
- setState({ ...state, roleStaff: result })
|
|
|
+ const { run: tryGetRoleStaffList } = useRequest(
|
|
|
+ (id: string) => fetchRoleStaffListByRoleId({ id }),
|
|
|
+ {
|
|
|
+ manual: true,
|
|
|
+ onSuccess: result => {
|
|
|
+ setState({ ...state, roleStaff: result })
|
|
|
+ }
|
|
|
}
|
|
|
- })
|
|
|
+ )
|
|
|
useEffect(() => {
|
|
|
if (state.id) {
|
|
|
- tryGetRoleStaffList()
|
|
|
+ tryGetRoleStaffList(state.id)
|
|
|
}
|
|
|
}, [state.id])
|
|
|
+
|
|
|
return (
|
|
|
<div className="h-full w-full flex flex-row">
|
|
|
<RoleMenu menuId={menuId} onSelect={onSelect} />
|
|
|
<div className="w-max-3/4">
|
|
|
- <div className="ml-8 bg-white p-4 shadow-md shadow-hex-3e2c5a">
|
|
|
+ <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 && (
|
|
|
+ <ConnectModal
|
|
|
+ title="关联员工"
|
|
|
+ dataId={state.id}
|
|
|
+ onSelect={() => tryGetRoleStaffList(state.id)}
|
|
|
+ />
|
|
|
+ )}
|
|
|
+ </div>
|
|
|
<Tabs defaultActiveKey="1" type="card">
|
|
|
<TabPane tab="员工列表" key="1">
|
|
|
- <Table<API.RoleStaffListItem> dataSource={state.roleStaff} columns={columns} />
|
|
|
+ <Table<API.RoleStaffListItem>
|
|
|
+ dataSource={state.roleStaff}
|
|
|
+ columns={columns}
|
|
|
+ rowKey={row => row.staffId}
|
|
|
+ />
|
|
|
</TabPane>
|
|
|
<TabPane tab="角色权限" key="2">
|
|
|
<ProForm layout="horizontal" initialValues={{ staff: ['1', '2'] }}>
|