| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Button } from 'antd' |
| | | import { Button, message } from 'antd' |
| | | |
| | | import MKEmitter from '@/utils/events.js' |
| | | import './index.scss' |
| | |
| | | timer = null |
| | | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('modifyTabs', this.breakOff) |
| | | MKEmitter.addListener('autoGetData', this.autoGetData) |
| | | MKEmitter.addListener('resetActiveMenu', this.breakOff) |
| | | MKEmitter.addListener('autoExecOver', this.autoExecOver) |
| | | MKEmitter.addListener('autoMaticOver', this.autoMaticOver) |
| | | MKEmitter.addListener('autoMaticError', this.autoMaticError) |
| | |
| | | return |
| | | } |
| | | clearTimeout(this.timer) |
| | | MKEmitter.removeListener('modifyTabs', this.breakOff) |
| | | MKEmitter.removeListener('autoGetData', this.autoGetData) |
| | | MKEmitter.removeListener('resetActiveMenu', this.breakOff) |
| | | MKEmitter.removeListener('autoExecOver', this.autoExecOver) |
| | | MKEmitter.removeListener('autoMaticOver', this.autoMaticOver) |
| | | MKEmitter.removeListener('autoMaticError', this.autoMaticError) |
| | | MKEmitter.removeListener('autoTransSelectData', this.autoTransSelectData) |
| | | } |
| | | |
| | | breakOff = () => { |
| | | if (this.state.running) { |
| | | this.setState({running: false}) |
| | | clearTimeout(this.timer) |
| | | } |
| | | } |
| | | |
| | | autoExecOver = (btnId, type) => { |
| | |
| | | |
| | | if (!this.state.running || btnId !== autoMatic.action) return |
| | | |
| | | if (type === 'error') { |
| | | if (this.state.line >= 1000) { |
| | | this.breakOff() |
| | | } else if (type === 'error') { |
| | | if (autoMatic.onFail === 'next') { |
| | | this.setState({line: this.state.line + 1}, () => { |
| | | setTimeout(() => { |
| | | MKEmitter.emit('autoQueryData', config.MenuID, this.state.line) |
| | | }, 1000) |
| | | }, 2000) |
| | | }) |
| | | } else if (autoMatic.onFail === 'stay') { |
| | | setTimeout(() => { |
| | | MKEmitter.emit('autoQueryData', config.MenuID, this.state.line) |
| | | }, 1000) |
| | | }, 2000) |
| | | } else { |
| | | this.setState({running: false}) |
| | | } |
| | |
| | | this.setState({line: this.state.line + 1}, () => { |
| | | setTimeout(() => { |
| | | MKEmitter.emit('autoQueryData', config.MenuID, this.state.line) |
| | | }, 1000) |
| | | }, 2000) |
| | | }) |
| | | } else if (autoMatic.onSuccess === 'stay') { |
| | | setTimeout(() => { |
| | | MKEmitter.emit('autoQueryData', config.MenuID, this.state.line) |
| | | }, 1000) |
| | | }, 2000) |
| | | } else { |
| | | this.setState({running: false}) |
| | | } |
| | |
| | | |
| | | this.setState({running: running, line: 1}) |
| | | clearTimeout(this.timer) |
| | | |
| | | message.info('按Esc键终止运行。') |
| | | |
| | | document.onkeydown = (event) => { |
| | | let e = event || window.event |
| | | |
| | | if (e.key === 'Escape') { |
| | | this.breakOff() |
| | | } |
| | | } |
| | | } |
| | | |
| | | autoMaticOver = (MenuID) => { |