| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Icon, Modal } from 'antd' |
| | | import { Modal } from 'antd' |
| | | import { ClockCircleOutlined } from '@ant-design/icons' |
| | | |
| | | import zhCN from '@/locales/zh-CN/model.js' |
| | | import enUS from '@/locales/en-US/model.js' |
| | | import ClockForm from './settingform' |
| | | import './index.scss' |
| | | |
| | | class ClockComponent extends Component { |
| | | static propTpyes = { |
| | | btnlog: PropTypes.array, |
| | | updateConfig: PropTypes.func |
| | | } |
| | | |
| | | state = { |
| | | dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, |
| | | visible: false, |
| | | timer: '', |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.state), fromJS(nextState)) |
| | | visible: false |
| | | } |
| | | |
| | | trigger = () => { |
| | | const { config } = this.props |
| | | |
| | | this.setState({ |
| | | visible: true, |
| | | timer: config.timer || '' |
| | | visible: true |
| | | }) |
| | | } |
| | | |
| | |
| | | this.setState({ |
| | | visible: false |
| | | }) |
| | | this.props.updateConfig({...config, timer: res.timer}) |
| | | this.props.updateConfig({...config, timer: res.timer, timerRepeats: res.timerRepeats, clearField: res.clearField || '', clearValue: res.clearValue || ''}) |
| | | }) |
| | | } |
| | | |
| | | render () { |
| | | const { visible, loading, timer } = this.state |
| | | const { config } = this.props |
| | | const { visible, loading } = this.state |
| | | |
| | | return ( |
| | | <div className="clock-component-wrap"> |
| | | <Icon type="clock-circle" title="定时器" onClick={this.trigger} /> |
| | | <div className={'clock-component-wrap' + (config.timer ? ' tip-sign' : '')}> |
| | | <ClockCircleOutlined title="定时器" onClick={this.trigger} /> |
| | | <Modal |
| | | title="定时器设置" |
| | | visible={visible} |
| | |
| | | onCancel={() => this.setState({ visible: false })} |
| | | destroyOnClose |
| | | > |
| | | <ClockForm timer={timer} inputSubmit={this.submit} wrappedComponentRef={(inst) => this.verifyRef = inst}/> |
| | | <ClockForm config={config} inputSubmit={this.submit} wrappedComponentRef={(inst) => this.verifyRef = inst}/> |
| | | </Modal> |
| | | </div> |
| | | ) |