ES5中引入antd表格的使用
来源:互联网 发布:linux 驱动编写步骤 编辑:程序博客网 时间:2024/05/17 08:19
/** * * 人员列表 */var React = require('react');import {connect} from 'react-redux';import { Spin, Table,Input, Icon, Button, Popconfirm, } from 'antd';import EditableCell from '../RoomMaintenance/EditableCell';//编辑场景名称控件import './RoleList.css';import {fetchMaintain,DeleteMaintainPerson,UpdateRolePassword} from '../../actions/MaintainActions';class MaintainPersonList extends React.Component { constructor(props) { super(props); this.columns = [ {title: 'id', dataIndex: 'id', key: 'id', className:'columns', render: (text, record, index) => { return( <div><text>{index+1}</text></div> ) }}, {title: '手机号', dataIndex: 'phone', key:'phone', className:'columns'}, {title: '邮箱', dataIndex: 'email', key:'email', className:'columns'}, {title: '账号', dataIndex: 'username', key:'username', className:'columns'}, {title: '权限', dataIndex: 'role', key:'role', className:'columns', render: (text, record, index) => { var accountRole = ""; if(text=="zero"){ accountRole = "普通用户"; }else if(text=="one"){ accountRole = "一级审核"; }else if(text=="two"){ accountRole = "二级审核"; }else if(text=="three"){ accountRole = "最高权限"; } return( <div> <text>{accountRole}</text> </div> ) } }, {title: '操作', dataIndex: 'operation', key:'operation', className:'columns', render: (text, record, index) => { return ( <div> <Popconfirm title="是否删除?" className='delete' onConfirm={this.onDelete(record,index)}> <a href="#">删除</a> </Popconfirm> <Popconfirm title="是否重置密码?" className='reset' onConfirm={() => this.onReset(record,index)}> <a style={{backgroundColor:'none',paddingLeft:15}} href="#">重置密码</a> </Popconfirm> </div> ); } }]; this.state = { width:'100%', height:400, pagination: true, //分页器 count: 6 }; } componentDidMount(){ const{dispatch}=this.props; dispatch(fetchMaintain()); } /* * 删除指定人员 * record :删除指定的当前行元素 * index:删除指定的当前行元素下标 * */ onDelete(record,index){ return () => { const{dispatch}=this.props; dispatch(DeleteMaintainPerson('token',record.id)); }; } /* * 删除指定人员 * record :删除指定的当前行元素 * index:删除指定的当前行元素下标 * */ onReset(record,index){ alert("请及时修改修改重置后生成的随机密码:"+RndNum(6)+"谢谢您的使用!"); var resetPwd=RndNum(6); var params={ "id":record.id, "password": resetPwd }; return () => { const{dispatch}=this.props; dispatch(UpdateRolePassword(params)); }; } render() { const {maintain}=this.props; const columns = this.columns; if (maintain.fetched==false){ return( <div style={{marginTop:'40%',textAlign:'center'}}> <Spin size="large" /> </div> ) }else { return ( <div> <div className='module_header'> <div className='title'> 人员 </div> </div> <div className='module_content'> <Table bordered rowKey="id" width={this.state.width} height={this.state.height} dataSource={maintain.MaintainPersonData} columns={columns} /> </div> </div> ); } }}/** * 生成6位数字的随机数 * @param n * @returns {string} * @constructor */function RndNum(n){ var rnd=""; for(var i=0;i<n;i++){ rnd += Math.floor(Math.random()*10); } return rnd;}function mapStateToProps(state) { const {maintain} = state; return { maintain }}export default connect(mapStateToProps)(MaintainPersonList);
0 0
- ES5中引入antd表格的使用
- 在react-native中引入antd-mobile遇到的问题
- antd的表格和map遍历相关
- antd mobile(十二) dva中使用mockJs
- antd-mobile中listView遇到的坑
- 使用antd-mobile遇到的坑
- ES5 中 JavaScript的继承
- es5 javascript this的使用
- 在ACE引入的表格插件中Datatables中使用判断,将数字指代的含义显示在页面上。
- 使用antd的Form组件在hubmit事件外的其他事件中获取Form表单中input的值
- 使用antd中Table组件某一列有多个变量值需要写入
- dva + antd 初次使用
- create-react-app方式下引入antd
- ES5中数组的常用方法
- ES5中新增的Array方法
- ES5中新增的Array方法
- ES5中Object的几种方法
- es6与es5 中this的区别
- BZOJ 1879 [Sdoi2009] Bill的挑战
- ADO数据库编程入门(下)
- IE下radio的onchange事件焦点移除方可触发问题
- 越长大越向往
- RxJava2.0 从入门到放弃?
- ES5中引入antd表格的使用
- 一次实践:spark查询hive速度缓慢原因分析并以此看到spark基础架构
- Python 多进程和多线程
- Unable to verify your data submission.加入了_csrf也报400错误的解决
- redis漏洞引发的入侵
- Java Socket---一个简单的即时通讯小Demo
- python下使用selenium的坑
- Android Dagger2与ButterKnife冲突问题
- Mysql空值(NULL)不能使用算数运算符