|
@@ -1,170 +1,179 @@
|
|
|
-import { useModel } from 'umi'
|
|
|
-import React, { useMemo } from 'react'
|
|
|
+import { useModel, useRequest } from 'umi'
|
|
|
import Icon from '@/components/IconPark'
|
|
|
import ProForm, { ProFormCheckbox, ProFormDependency, ProFormSwitch } from '@ant-design/pro-form'
|
|
|
-import { Tabs } from 'antd'
|
|
|
-import ProTable from '@ant-design/pro-table'
|
|
|
-import RoleMenu from '../System/components/roleMenu'
|
|
|
+import { Table, Tabs } from 'antd'
|
|
|
+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'
|
|
|
|
|
|
-const System = () => {
|
|
|
- const { initialState } = useModel('@@initialState')
|
|
|
- const menuId = useMemo(() => {
|
|
|
- return initialState?.menuList?.find(item => item.name === '客户')?.id
|
|
|
- }, initialState.menuList)
|
|
|
+const System: React.FC = () => {
|
|
|
const { TabPane } = Tabs
|
|
|
- const dataSource = [
|
|
|
- {
|
|
|
- key: '1',
|
|
|
- name: '胡彦斌',
|
|
|
- age: 32,
|
|
|
- address: '西湖区湖底公园1号'
|
|
|
- },
|
|
|
- {
|
|
|
- key: '2',
|
|
|
- name: '胡彦祖',
|
|
|
- age: 42,
|
|
|
- address: '西湖区湖底公园1号'
|
|
|
- }
|
|
|
- ]
|
|
|
|
|
|
- const columns = [
|
|
|
+ const columns: ColumnsType<API.RoleStaffListItem> = [
|
|
|
{
|
|
|
title: '用户',
|
|
|
- dataIndex: 'name',
|
|
|
- key: 'name'
|
|
|
+ dataIndex: 'username'
|
|
|
},
|
|
|
{
|
|
|
title: '手机',
|
|
|
- dataIndex: 'age',
|
|
|
- key: 'age'
|
|
|
+ dataIndex: 'phone'
|
|
|
},
|
|
|
{
|
|
|
title: '部门',
|
|
|
- dataIndex: 'address',
|
|
|
- key: 'address'
|
|
|
+ dataIndex: 'departmentName'
|
|
|
},
|
|
|
{
|
|
|
title: '岗位',
|
|
|
- dataIndex: 'address',
|
|
|
- key: 'address'
|
|
|
+ dataIndex: 'position'
|
|
|
},
|
|
|
{
|
|
|
title: '角色',
|
|
|
- dataIndex: 'address',
|
|
|
- key: 'address'
|
|
|
+ dataIndex: 'age'
|
|
|
},
|
|
|
{
|
|
|
title: '操作',
|
|
|
- dataIndex: 'address',
|
|
|
- key: 'address'
|
|
|
+ dataIndex: 'opreate',
|
|
|
+ render: () => (
|
|
|
+ <span className="hover:text-hex-e7026e">
|
|
|
+ <Icon type="delete" fill="#fd3995" />
|
|
|
+ </span>
|
|
|
+ )
|
|
|
}
|
|
|
]
|
|
|
|
|
|
+ const { initialState } = useModel('@@initialState')
|
|
|
+ const menuId = useMemo(() => {
|
|
|
+ return initialState?.menuList?.find(item => item.name === '系统管理')?.id
|
|
|
+ }, initialState.menuList)
|
|
|
+
|
|
|
+ const [state, setState] = useState<{ id: string; roleStaff: API.RoleStaffListItem[] }>({
|
|
|
+ id: '',
|
|
|
+ roleStaff: []
|
|
|
+ })
|
|
|
+ const onSelect = (id: string) => {
|
|
|
+ setState({ ...state, id })
|
|
|
+ }
|
|
|
+
|
|
|
+ const { run: tryGetRoleStaffList } = useRequest((id: string) => fetchRoleStaffListByRoleId(id), {
|
|
|
+ manual: true,
|
|
|
+ onSuccess: result => {
|
|
|
+ setState({ ...state, roleStaff: result })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ useEffect(() => {
|
|
|
+ if (state.id) {
|
|
|
+ tryGetRoleStaffList()
|
|
|
+ }
|
|
|
+ }, [state.id])
|
|
|
return (
|
|
|
<div className="h-full w-full flex flex-row">
|
|
|
- <RoleMenu menuId={menuId} />
|
|
|
- <div className="bg-white ml-4 p-4 flex-auto">
|
|
|
- <Tabs defaultActiveKey="1" type="card">
|
|
|
- <TabPane tab="员工列表" key="1">
|
|
|
- <ProTable
|
|
|
- bordered
|
|
|
- rowKey="key"
|
|
|
- colums={columns}
|
|
|
- search={false}
|
|
|
- toolBarRender={false}
|
|
|
- dataSource={dataSource}
|
|
|
- />
|
|
|
- </TabPane>
|
|
|
- <TabPane tab="角色权限" key="2">
|
|
|
- <ProForm layout="horizontal" initialValues={{ staff: ['1', '2'] }}>
|
|
|
- <ProFormSwitch
|
|
|
- name="showHome"
|
|
|
- label={
|
|
|
- <span className="flex items-center">
|
|
|
- <Icon type="home" className="mr-1" className="flex items-baseline mr-1" />
|
|
|
- 后台首页
|
|
|
- </span>
|
|
|
- }
|
|
|
- />
|
|
|
+ <RoleMenu menuId={menuId} onSelect={onSelect} />
|
|
|
+ <div className="w-max-3/4">
|
|
|
+ <div className="ml-8 bg-white p-4 shadow-md shadow-hex-3e2c5a">
|
|
|
+ <Tabs defaultActiveKey="1" type="card">
|
|
|
+ <TabPane tab="员工列表" key="1">
|
|
|
+ <Table<API.RoleStaffListItem> dataSource={state.roleStaff} columns={columns} />
|
|
|
+ </TabPane>
|
|
|
+ <TabPane tab="角色权限" key="2">
|
|
|
+ <ProForm layout="horizontal" initialValues={{ staff: ['1', '2'] }}>
|
|
|
+ <ProFormSwitch
|
|
|
+ name="showHome"
|
|
|
+ label={
|
|
|
+ <span className="flex items-center">
|
|
|
+ <Icon type="home" className="mr-1" className="flex items-baseline mr-1" />
|
|
|
+ 后台首页
|
|
|
+ </span>
|
|
|
+ }
|
|
|
+ />
|
|
|
|
|
|
- <ProFormSwitch
|
|
|
- name="showAuth"
|
|
|
- label={
|
|
|
- <span className="flex items-center">
|
|
|
- <Icon type="every-user" className="mr-1" className="flex items-baseline mr-1" />
|
|
|
- 角色权限管理
|
|
|
- </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
|
|
|
- name="showAudit"
|
|
|
- label={
|
|
|
- <span className="flex items-center">
|
|
|
- <Icon type="inspection" className="mr-1" className="flex items-baseline mr-1" />
|
|
|
- 审批流程
|
|
|
- </span>
|
|
|
- }
|
|
|
- />
|
|
|
- <ProFormDependency name={['showAudit']}>
|
|
|
- {({ showAudit }) => (
|
|
|
- <ProFormCheckbox.Group
|
|
|
- wrapperCol={{ offset: 1 }}
|
|
|
- name="audit"
|
|
|
- options={[
|
|
|
- { value: '1', label: '流程角色', disabled: !showAudit },
|
|
|
- { value: '2', label: '开票合同', disabled: !showAudit },
|
|
|
- { value: '3', label: '财务费用', disabled: !showAudit },
|
|
|
- { value: '4', label: '人资管理', disabled: !showAudit },
|
|
|
- { value: '5', label: '考勤', disabled: !showAudit }
|
|
|
- ]}
|
|
|
- />
|
|
|
- )}
|
|
|
- </ProFormDependency>
|
|
|
- <ProFormSwitch
|
|
|
- name="reset"
|
|
|
- label={
|
|
|
- <span className="flex items-center">
|
|
|
- <Icon
|
|
|
- type="association"
|
|
|
- className="mr-1"
|
|
|
- className="flex items-baseline mr-1"
|
|
|
+ <ProFormSwitch
|
|
|
+ name="showAuth"
|
|
|
+ label={
|
|
|
+ <span className="flex items-center">
|
|
|
+ <Icon
|
|
|
+ type="every-user"
|
|
|
+ className="mr-1"
|
|
|
+ className="flex items-baseline mr-1"
|
|
|
+ />
|
|
|
+ 角色权限管理
|
|
|
+ </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
|
|
|
+ name="showAudit"
|
|
|
+ label={
|
|
|
+ <span className="flex items-center">
|
|
|
+ <Icon
|
|
|
+ type="inspection"
|
|
|
+ className="mr-1"
|
|
|
+ className="flex items-baseline mr-1"
|
|
|
+ />
|
|
|
+ 审批流程
|
|
|
+ </span>
|
|
|
+ }
|
|
|
+ />
|
|
|
+ <ProFormDependency name={['showAudit']}>
|
|
|
+ {({ showAudit }) => (
|
|
|
+ <ProFormCheckbox.Group
|
|
|
+ wrapperCol={{ offset: 1 }}
|
|
|
+ name="audit"
|
|
|
+ options={[
|
|
|
+ { value: '1', label: '流程角色', disabled: !showAudit },
|
|
|
+ { value: '2', label: '开票合同', disabled: !showAudit },
|
|
|
+ { value: '3', label: '财务费用', disabled: !showAudit },
|
|
|
+ { value: '4', label: '人资管理', disabled: !showAudit },
|
|
|
+ { value: '5', label: '考勤', disabled: !showAudit }
|
|
|
+ ]}
|
|
|
+ />
|
|
|
+ )}
|
|
|
+ </ProFormDependency>
|
|
|
+ <ProFormSwitch
|
|
|
+ name="reset"
|
|
|
+ label={
|
|
|
+ <span className="flex items-center">
|
|
|
+ <Icon
|
|
|
+ type="association"
|
|
|
+ className="mr-1"
|
|
|
+ className="flex items-baseline mr-1"
|
|
|
+ />
|
|
|
+ 业务参数
|
|
|
+ </span>
|
|
|
+ }
|
|
|
+ />
|
|
|
+ <ProFormDependency name={['reset']}>
|
|
|
+ {({ reset }) => (
|
|
|
+ <ProFormCheckbox.Group
|
|
|
+ wrapperCol={{ offset: 1 }}
|
|
|
+ name="audit"
|
|
|
+ options={[
|
|
|
+ { value: '1', label: '客户', disabled: !reset },
|
|
|
+ { value: '2', label: '产品', disabled: !reset }
|
|
|
+ ]}
|
|
|
/>
|
|
|
- 业务参数
|
|
|
- </span>
|
|
|
- }
|
|
|
- />
|
|
|
- <ProFormDependency name={['reset']}>
|
|
|
- {({ reset }) => (
|
|
|
- <ProFormCheckbox.Group
|
|
|
- wrapperCol={{ offset: 1 }}
|
|
|
- name="audit"
|
|
|
- options={[
|
|
|
- { value: '1', label: '客户', disabled: !reset },
|
|
|
- { value: '2', label: '产品', disabled: !reset }
|
|
|
- ]}
|
|
|
- />
|
|
|
- )}
|
|
|
- </ProFormDependency>
|
|
|
- </ProForm>
|
|
|
- </TabPane>
|
|
|
- </Tabs>
|
|
|
+ )}
|
|
|
+ </ProFormDependency>
|
|
|
+ </ProForm>
|
|
|
+ </TabPane>
|
|
|
+ </Tabs>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
)
|