ExportBtn.js
1.8 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
import React,{PropTypes} from 'react';
import ReactDOM from 'react-dom';
import cx from 'classnames';
import s from './Custom.scss';
import {downloadForm} from '../../../utils/fileUtil'
class ExportBtn extends React.Component {
constructor(props) {
super(props);
this.dowloadForm=this.dowloadForm.bind(this);
}
static propTypes = {
'formName':PropTypes.string,
'serviceName':PropTypes.string
}
static defaultProps={
bsSize:'lg',//sm|xs
block:true,
active:false,
href:'javescript:;',
linkable:false,
disabled:false,
isLoading:false,
customColor:'success',
serviceName:'hr'
}
dowloadForm(){
const {formName,serviceName,disabled,isLoading}=this.props;
if(disabled||isLoading){
return
}
downloadForm(serviceName,formName);
}
render(){
const {linkable,href,customColor,bsSize,disabled,block,isLoading}=this.props;
if(linkable){
return <a className={cx(s[customColor+'_btn'],s[bsSize],
disabled?s.disabled:'',
block?s.block:'')} href={href}>
{this.props.children}
{isLoading&&<i style={{width:'20px'}} className={cx('kr_icon','kr_icon-spin')}></i>}
</a>;
}else{
return <div className={cx(s[customColor+'_btn'],s[bsSize],
disabled||isLoading?s.disabled:'',
block?s.block:'')} onClick={this.dowloadForm}>
{this.props.children}
{isLoading&&<i style={{width:'20px'}} className={cx('kr_icon','kr_icon-spin')}></i>}
</div>;
}
}
}
export default ExportBtn;