11import React , { useEffect , useMemo , useState } from 'react' ;
22import { createTeam , deleteTeam , getTeamManagementList , updateTeam } from '@/service/team' ;
3- import { ITeamPageQueryVO , ITeamVO , ManagementType , StatusType } from '@/typings/team' ;
43import { Button , Form , Input , Modal , Popconfirm , Radio , Table , Tag , message } from 'antd' ;
54import { SearchOutlined , PlusOutlined } from '@ant-design/icons' ;
65import styles from './index.less' ;
76import UniversalDrawer from '../universal-drawer' ;
7+ import i18n from '@/i18n' ;
8+ import { AffiliationType , ITeamVO , StatusType } from '@/typings/team' ;
89
910const formItemLayout = {
1011 labelCol : { span : 6 } ,
1112 wrapperCol : { span : 16 } ,
1213 colon : false ,
1314} ;
1415
15- const requireRule = { required : true , message : 'Require field empty!' } ;
16+ const requireRule = { required : true , message : i18n ( 'common.form.error.required' ) } ;
1617
1718function TeamManagement ( ) {
1819 const [ form ] = Form . useForm ( ) ;
19- const [ dataSource , setDataSource ] = useState < ITeamPageQueryVO [ ] > ( [ ] ) ;
20+ const [ loadding , setLoading ] = useState ( false )
21+ const [ dataSource , setDataSource ] = useState < ITeamVO [ ] > ( [ ] ) ;
2022 const [ pagination , setPagination ] = useState ( {
2123 searchKey : '' ,
2224 current : 1 ,
@@ -27,9 +29,8 @@ function TeamManagement() {
2729 // pageSizeOptions: ['10', '20', '30', '40'],
2830 } ) ;
2931 const [ isModalVisible , setIsModalVisible ] = useState ( false ) ;
30- const [ drawerInfo , setDrawerInfo ] = useState < { open : boolean ; type : ManagementType ; teamId ?: number } > ( {
32+ const [ drawerInfo , setDrawerInfo ] = useState < { open : boolean ; type ?: AffiliationType ; teamId ?: number } > ( {
3133 open : false ,
32- type : ManagementType . USER ,
3334 } ) ;
3435 const columns = useMemo (
3536 ( ) => [
@@ -56,7 +57,7 @@ function TeamManagement() {
5657 render : ( _ : any , record : ITeamVO ) => (
5758 < >
5859 < Button type = "link" onClick = { ( ) => handleEdit ( record ) } >
59- 编辑
60+ { i18n ( 'common.button.edit' ) }
6061 </ Button >
6162 < Button
6263 type = "link"
@@ -65,17 +66,32 @@ function TeamManagement() {
6566 ...drawerInfo ,
6667 open : true ,
6768 teamId : record . id ,
69+ type : AffiliationType . TEAM_USER
6870 } ) ;
6971 } }
7072 >
7173 包含用户
7274 </ Button >
73- < Button type = "link" onClick = { ( ) => handleEdit ( record ) } >
75+ < Button
76+ type = "link"
77+ onClick = { ( ) => {
78+ setDrawerInfo ( {
79+ ...drawerInfo ,
80+ open : true ,
81+ teamId : record . id ,
82+ type : AffiliationType . TEAM_DATASOURCE
83+ } ) ;
84+ } } >
7485 归属链接
7586 </ Button >
76- < Popconfirm title = "确定删除" onConfirm = { ( ) => handleDelete ( record . id ) } okText = "确认" cancelText = "取消" >
87+ < Popconfirm
88+ title = { i18n ( 'common.tips.delete.confirm' ) }
89+ onConfirm = { ( ) => handleDelete ( record . id ) }
90+ okText = { i18n ( 'common.button.affirm' ) }
91+ cancelText = { i18n ( 'common.button.cancel' ) }
92+ >
7793 < a href = "#" onClick = { ( e ) => e . preventDefault ( ) } >
78- 删除
94+ { i18n ( 'common.button.delete' ) }
7995 </ a >
8096 </ Popconfirm >
8197 </ >
@@ -90,15 +106,21 @@ function TeamManagement() {
90106 } , [ pagination . current , pagination . pageSize , pagination . searchKey ] ) ;
91107
92108 const queryTeamList = async ( ) => {
93- const { searchKey, current : pageNo , pageSize } = pagination ;
94- let res = await getTeamManagementList ( { searchKey, pageNo, pageSize } ) ;
95- if ( res ) {
96- setDataSource ( res ?. data ?? [ ] ) ;
109+ setLoading ( true ) ;
110+ try {
111+ const { searchKey, current : pageNo , pageSize } = pagination ;
112+ let res = await getTeamManagementList ( { searchKey, pageNo, pageSize } ) ;
113+ if ( res ) {
114+ setDataSource ( res ?. data ?? [ ] ) ;
115+ }
116+ } catch ( error ) {
117+
118+ } finally {
119+ setLoading ( false )
97120 }
98121 } ;
99122
100123 const handleTableChange = ( p : any ) => {
101- console . log ( 'handleTableChange' , p ) ;
102124 setPagination ( {
103125 ...pagination ,
104126 ...p ,
@@ -148,11 +170,13 @@ function TeamManagement() {
148170 </ div >
149171 < Table
150172 rowKey = { 'id' }
173+ loading = { loadding }
151174 dataSource = { dataSource }
152175 columns = { columns }
153176 pagination = { pagination }
154177 onChange = { handleTableChange }
155178 />
179+
156180 < Modal
157181 title = { form . getFieldValue ( 'id' ) !== undefined ? '编辑团队' : '添加团队' }
158182 open = { isModalVisible }
@@ -166,13 +190,9 @@ function TeamManagement() {
166190 form . resetFields ( ) ;
167191 } )
168192 . catch ( ( errorInfo ) => {
169- console . log ( 'Validation failed:' , errorInfo ) ;
170193 form . scrollToField ( errorInfo . errorFields [ 0 ] . name ) ;
171194 form . setFields ( errorInfo . errorFields ) ;
172195 } )
173- . finally ( ( ) => {
174- form . resetFields ( ) ;
175- } ) ;
176196 } }
177197 onCancel = { ( ) => {
178198 form . resetFields ( ) ;
@@ -184,7 +204,6 @@ function TeamManagement() {
184204 form = { form }
185205 autoComplete = { 'off' }
186206 initialValues = { {
187- // roleCode: RoleStatusType.USER,
188207 status : StatusType . VALID ,
189208 } }
190209 >
@@ -194,12 +213,6 @@ function TeamManagement() {
194213 < Form . Item label = "团队名" name = "name" >
195214 < Input />
196215 </ Form . Item >
197- { /* <Form.Item label="角色" name="roleCode" rules={[requireRule]}>
198- <Radio.Group>
199- <Radio value={RoleStatusType.ADMIN}>管理员</Radio>
200- <Radio value={RoleStatusType.USER}>用户</Radio>
201- </Radio.Group>
202- </Form.Item> */ }
203216 < Form . Item label = "状态" name = "status" rules = { [ requireRule ] } >
204217 < Radio . Group >
205218 < Radio value = { StatusType . VALID } > 有效</ Radio >
0 commit comments