| | |
| | | import PropTypes from 'prop-types' |
| | | import { withRouter } from 'react-router' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Button, Modal, notification, message } from 'antd' |
| | | import { Button, Modal, notification, message, Progress } from 'antd' |
| | | import CryptoJS from 'crypto-js' |
| | | import moment from 'moment' |
| | | |
| | |
| | | loading: false, |
| | | disabled: false, |
| | | loadingNumber: '', |
| | | loadingTotal: '', |
| | | hidden: false, |
| | | IpList: [], |
| | | lines: [], |
| | |
| | | } |
| | | |
| | | loginDevice = () => { |
| | | const { btn } = this.props |
| | | const { lines, selectIp } = this.state |
| | | |
| | | // 上报接口设置:工程模式-场景模式-开放接口设置-数据上报设置-数据上报服务器地址(开启服务器二次鉴权) |
| | |
| | | } |
| | | }) |
| | | |
| | | if (data.length > 1 && btn.progress === 'progressbar') { |
| | | this.setState({ |
| | | loadingTotal: data.length |
| | | }) |
| | | } |
| | | |
| | | this.addUser(ip, data, result.session_id) |
| | | }) |
| | | }, err => { |
| | |
| | | let data = datas.shift() |
| | | |
| | | this.setState({ |
| | | loadingNumber: datas.length || '' |
| | | loadingNumber: datas.length |
| | | }) |
| | | |
| | | let error = '' |
| | |
| | | |
| | | this.setState({ |
| | | loading: false, |
| | | loadingNumber: '' |
| | | loadingNumber: '', |
| | | loadingTotal: '' |
| | | }) |
| | | |
| | | // if (btn.execSuccess !== 'never') { |
| | |
| | | |
| | | this.setState({ |
| | | loading: false, |
| | | loadingNumber: '' |
| | | loadingNumber: '', |
| | | loadingTotal: '' |
| | | }) |
| | | |
| | | // if (btn.execError !== 'never') { |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { btn, show } = this.props |
| | | const { loading, disabled, hidden, loadingNumber } = this.state |
| | | const { btn } = this.props |
| | | const { loading, disabled, hidden, loadingNumber, loadingTotal } = this.state |
| | | |
| | | if (hidden) return null |
| | | |
| | | if (show === 'actionList') { |
| | | return ( |
| | | <> |
| | | <Button |
| | | icon={btn.icon} |
| | | loading={loading} |
| | | disabled={disabled} |
| | | title={disabled ? (btn.reason || '') : ''} |
| | | className={'mk-btn mk-' + btn.class} |
| | | onClick={(e) => {e.stopPropagation(); this.actionTrigger()}} |
| | | >{(loadingNumber ? `(${loadingNumber})` : '') + btn.label}</Button> |
| | | {this.getModels()} |
| | | </> |
| | | ) |
| | | } else { // icon、text、 all 卡片 |
| | | let label = '' |
| | | let icon = '' |
| | | let label = '' |
| | | let icon = '' |
| | | let type = 'link' |
| | | let className = '' |
| | | |
| | | if (show === 'button') { |
| | | label = btn.label |
| | | icon = btn.icon || '' |
| | | } else if (show === 'link') { |
| | | label = <span>{btn.label}{btn.icon ? <MkIcon style={{marginLeft: '8px'}} type={btn.icon}/> : ''}</span> |
| | | icon = '' |
| | | } else if (show === 'icon') { |
| | | icon = btn.icon || '' |
| | | } else { |
| | | label = btn.label |
| | | } |
| | | |
| | | return ( |
| | | <> |
| | | <Button |
| | | type="link" |
| | | title={disabled ? (btn.reason || '') : (show === 'icon' ? btn.label : '')} |
| | | loading={loading} |
| | | disabled={disabled} |
| | | style={btn.style} |
| | | icon={icon} |
| | | onClick={(e) => {e.stopPropagation(); this.actionTrigger()}} |
| | | >{label}</Button> |
| | | {this.getModels()} |
| | | </> |
| | | ) |
| | | if (btn.show === 'button') { |
| | | label = btn.label |
| | | icon = btn.icon || '' |
| | | } else if (btn.show === 'link') { |
| | | label = <span>{btn.label}{btn.icon ? <MkIcon style={{marginLeft: '8px'}} type={btn.icon}/> : ''}</span> |
| | | icon = '' |
| | | } else if (btn.show === 'icon') { |
| | | icon = btn.icon || '' |
| | | } else if (!btn.$toolbtn) { |
| | | icon = btn.icon || '' |
| | | label = btn.label |
| | | className = 'mk-btn mk-' + btn.class |
| | | } else { |
| | | type = '' |
| | | icon = btn.icon || '' |
| | | label = (loadingNumber && !loadingTotal ? `(${loadingNumber})` : '') + btn.label |
| | | className = 'mk-btn mk-' + btn.class |
| | | } |
| | | |
| | | return ( |
| | | <> |
| | | <Button |
| | | type={type} |
| | | title={disabled ? (btn.reason || '') : (btn.show === 'icon' ? btn.label : '')} |
| | | loading={loading} |
| | | disabled={disabled} |
| | | style={btn.style} |
| | | icon={icon} |
| | | className={className} |
| | | onClick={(e) => {e.stopPropagation(); this.actionTrigger()}} |
| | | >{label}</Button> |
| | | {this.getModels()} |
| | | {loadingTotal ? <Progress className="mk-button-progress" percent={(loadingTotal - loadingNumber) / loadingTotal * 100} size="small" showInfo={false} /> : null} |
| | | </> |
| | | ) |
| | | } |
| | | } |
| | | |