ChooseTenantContainer.js
2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import React, { PropTypes } from 'react';
import { connect } from 'react-redux';
import { Radio, Input, Card, Tabs, Button, message } from 'antd';
const TabPane = Tabs.TabPane;
const RadioGroup = Radio.Group;
import cx from 'classnames';
import l from '../components/loginFormLess.les';
import s from './main.les';
import { chooseTenant, getTenantsAction } from "../redux/actions/authed"
import LoginBgImg from './LoginBgImg'
const radioStyle = {
display: 'block',
height: '30px',
lineHeight: '30px'
};
class ChooseTenantContainer extends React.Component {
constructor(props) {
super(props);
this.renderRadio = this.renderRadio.bind(this);
this.state = {
value: 1
}
}
componentDidMount() {
const { dispatch } = this.props;
dispatch(getTenantsAction());
}
componentWillReceiveProps(nextProps) { }
componentWillUnmount() { }
renderRadio(tenants) {
let radio = [];
if (tenants && tenants.length) {
tenants.map((item, index) => {
radio.push(
<Radio key={index} style={radioStyle} value={item.id}>{item.name}</Radio>
)
})
}
return radio;
}
onChange = (e) => {
this.setState({ value: e.target.value });
}
changeTenant() {
const { value } = this.state;
const { dispatch } = this.props;
if (value == 1) {
message.info("请选择企业");
} else {
dispatch(chooseTenant(value))
}
}
render() {
const { tenants } = this.props;
console.log('tenants.....', tenants);
return (
<div className={cx('login_container')}>
<div className={cx(s.tanants_body, 'tenants_warp')}>
<div style={{ width: '160px', height: '24px', margin: '0 auto', textAlign: 'center', fontSize: '16px' }}>----请选择企业----</div>
<div style={{ overflow: 'hidden', width: '368px', height: '198px', marginTop: '16px' }}>
<div style={{ width: '400px', height: '215px', overflow: 'scroll' }}>
<RadioGroup style={{ paddingBottom: '10px' }} onChange={this.onChange} value={this.state.value}>
{
this.renderRadio(tenants)
}
</RadioGroup>
</div>
</div>
<div className={cx(s.tenants_foot)}>
<Button type='primary' style={{ height: '45px', width: '100%', fontSize: '14px' }} onClick={this.changeTenant.bind(this)}>完成</Button>
<div className={cx(s.back_link)} onClick={() => {
window.location = '#/';
}}>返回登录</div>
</div>
</div>
</div>
)
}
}
const mapState = (state) => {
const { hr: {
tenants
} } = state
return { tenants }
};
export default connect(mapState)(ChooseTenantContainer);