@@ -2,9 +2,10 @@ import React, { PureComponent } from 'react';
22import { connect } from 'dva' ;
33import { Form } from '@ant-design/compatible' ;
44import '@ant-design/compatible/assets/index.css' ;
5- import { Row , Col , Card , Input , Button , Table , Modal } from 'antd' ;
5+ import { Row , Col , Card , Input , Button , Table , Modal , Badge } from 'antd' ;
66import PageHeaderLayout from '@/layouts/PageHeaderLayout' ;
77import PButton from '@/components/PermButton' ;
8+ import { formatDate } from '@/utils/utils' ;
89import RoleCard from './RoleCard' ;
910
1011import styles from './RoleList.less' ;
@@ -28,6 +29,20 @@ class RoleList extends PureComponent {
2829 } ) ;
2930 }
3031
32+ onItemDisableClick = item => {
33+ this . dispatch ( {
34+ type : 'role/changeStatus' ,
35+ payload : { record_id : item . record_id , status : 2 } ,
36+ } ) ;
37+ } ;
38+
39+ onItemEnableClick = item => {
40+ this . dispatch ( {
41+ type : 'role/changeStatus' ,
42+ payload : { record_id : item . record_id , status : 1 } ,
43+ } ) ;
44+ } ;
45+
3146 clearSelectRows = ( ) => {
3247 const { selectedRowKeys } = this . state ;
3348 if ( selectedRowKeys . length === 0 ) {
@@ -94,7 +109,7 @@ class RoleList extends PureComponent {
94109 this . clearSelectRows ( ) ;
95110 } ;
96111
97- handleResetFormClick = ( ) => {
112+ onResetFormClick = ( ) => {
98113 const { form } = this . props ;
99114 form . resetFields ( ) ;
100115
@@ -157,23 +172,21 @@ class RoleList extends PureComponent {
157172 } = this . props ;
158173
159174 return (
160- < Form onSubmit = { this . handleSearchFormSubmit } layout = "inline" >
175+ < Form onSubmit = { this . handleSearchFormSubmit } >
161176 < Row gutter = { 16 } >
162- < Col md = { 8 } sm = { 24 } >
163- < Form . Item label = "角色名称" >
164- { getFieldDecorator ( 'name ' ) ( < Input placeholder = "请输入 " /> ) }
177+ < Col span = { 8 } >
178+ < Form . Item >
179+ { getFieldDecorator ( 'queryValue ' ) ( < Input placeholder = "请输入需要查询的内容 " /> ) }
165180 </ Form . Item >
166181 </ Col >
167- < Col md = { 8 } sm = { 24 } >
168- < div style = { { overflow : 'hidden' } } >
169- < span style = { { marginBottom : 24 } } >
170- < Button type = "primary" htmlType = "submit" >
171- 查询
172- </ Button >
173- < Button style = { { marginLeft : 8 } } onClick = { this . handleResetFormClick } >
174- 重置
175- </ Button >
176- </ span >
182+ < Col span = { 8 } >
183+ < div style = { { overflow : 'hidden' , paddingTop : 4 } } >
184+ < Button type = "primary" htmlType = "submit" >
185+ 查询
186+ </ Button >
187+ < Button style = { { marginLeft : 8 } } onClick = { this . onResetFormClick } >
188+ 重置
189+ </ Button >
177190 </ div >
178191 </ Col >
179192 </ Row >
@@ -203,7 +216,24 @@ class RoleList extends PureComponent {
203216 width : 100 ,
204217 } ,
205218 {
206- title : '角色备注' ,
219+ title : '状态' ,
220+ dataIndex : 'status' ,
221+ width : 80 ,
222+ render : val => {
223+ if ( val === 1 ) {
224+ return < Badge status = "success" text = "启用" /> ;
225+ }
226+ return < Badge status = "error" text = "停用" /> ;
227+ } ,
228+ } ,
229+ {
230+ title : '创建时间' ,
231+ width : 100 ,
232+ dataIndex : 'created_at' ,
233+ render : val => < span > { formatDate ( val , 'YYYY-MM-DD' ) } </ span > ,
234+ } ,
235+ {
236+ title : '备注' ,
207237 dataIndex : 'memo' ,
208238 } ,
209239 ] ;
@@ -223,27 +253,44 @@ class RoleList extends PureComponent {
223253 < div className = { styles . tableList } >
224254 < div className = { styles . tableListForm } > { this . renderSearchForm ( ) } </ div >
225255 < div className = { styles . tableListOperator } >
226- < PButton code = "add" icon = "plus" type = "primary" onClick = { ( ) => this . handleAddClick ( ) } >
256+ < PButton code = "add" type = "primary" onClick = { ( ) => this . handleAddClick ( ) } >
227257 新建
228258 </ PButton >
229259 { selectedRows . length === 1 && [
230260 < PButton
231261 key = "edit"
232262 code = "edit"
233- icon = "edit"
234263 onClick = { ( ) => this . handleEditClick ( selectedRows [ 0 ] ) }
235264 >
236265 编辑
237266 </ PButton > ,
238267 < PButton
239268 key = "del"
240269 code = "del"
241- icon = "delete"
242270 type = "danger"
243271 onClick = { ( ) => this . handleDelClick ( selectedRows [ 0 ] ) }
244272 >
245273 删除
246274 </ PButton > ,
275+ selectedRows [ 0 ] . status === 2 && (
276+ < PButton
277+ key = "enable"
278+ code = "enable"
279+ onClick = { ( ) => this . onItemEnableClick ( selectedRows [ 0 ] ) }
280+ >
281+ 启用
282+ </ PButton >
283+ ) ,
284+ selectedRows [ 0 ] . status === 1 && (
285+ < PButton
286+ key = "disable"
287+ code = "disable"
288+ type = "danger"
289+ onClick = { ( ) => this . onItemDisableClick ( selectedRows [ 0 ] ) }
290+ >
291+ 禁用
292+ </ PButton >
293+ ) ,
247294 ] }
248295 </ div >
249296 < div >
0 commit comments