| | |
| | | sync: false, // 是否统一请求数据 |
| | | data: {}, // 数据 |
| | | timer: null, // 定时器时间间隔 |
| | | BData: '' |
| | | BData: '', |
| | | selected: 'false', |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | |
| | | if (_data) { |
| | | _data.$$BID = BID || '' |
| | | _data.$$BData = BData || '' |
| | | if (_config.setting && _config.setting.primaryKey) { |
| | | _data.$$uuid = _data[_config.setting.primaryKey] || '' |
| | | } |
| | | } |
| | | |
| | | _config.columns.forEach(item => { |
| | |
| | | _config.subcards[0].offset = offset |
| | | } |
| | | |
| | | if (_config.subcards[0] && (_config.wrap.selected === 'always' || _config.wrap.selected === 'init')) { |
| | | setTimeout(() => { |
| | | this.checkTopLine() |
| | | }, 200) |
| | | } |
| | | |
| | | _config.wrap.selStyle = _config.wrap.selStyle || 'active' |
| | | _config.wrap.priKeyType = _config.wrap.priKeyType || 'static' |
| | | let selected = _config.wrap.selected || 'false' |
| | | |
| | | this.setState({ |
| | | selected, |
| | | sync: _sync, |
| | | data: _data, |
| | | BID: BID || '', |
| | |
| | | }, () => { |
| | | if (_config.wrap.datatype !== 'static' && _config.setting && _config.setting.sync !== 'true' && _config.setting.onload === 'true') { |
| | | this.loadData() |
| | | } else if ((!_sync || _config.wrap.priKeyType === 'static') && selected !== 'false') { |
| | | setTimeout(() => { |
| | | this.checkTopLine() |
| | | }, 200) |
| | | } |
| | | }) |
| | | } |
| | |
| | | * @description 图表数据更新,刷新内容 |
| | | */ |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | const { sync, config, BID, BData } = this.state |
| | | const { sync, config, BID, BData, selected } = this.state |
| | | |
| | | if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) { |
| | | let _data = { $$empty: true } |
| | | if (nextProps.data && nextProps.data[config.dataName]) { |
| | | _data = nextProps.data[config.dataName] |
| | | if (_data && Array.isArray(_data)) { |
| | | _data = _data[0] |
| | | _data = nextProps.data[config.dataName] || {} |
| | | if (Array.isArray(_data)) { |
| | | _data = _data[0] || {} |
| | | } |
| | | } |
| | | |
| | | if (_data) { |
| | | _data.$$BID = BID || '' |
| | | _data.$$BData = BData || '' |
| | | } |
| | | _data.$$uuid = _data[config.setting.primaryKey] || '' |
| | | |
| | | this.setState({sync: false, data: _data}) |
| | | this.setState({sync: false, data: _data}, () => { |
| | | if (config.wrap.priKeyType !== 'static' && selected !== 'false') { |
| | | setTimeout(() => { |
| | | this.checkTopLine() |
| | | }, 200) |
| | | } |
| | | }) |
| | | } else if ( config.setting.syncRefresh && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | |
| | | } |
| | | |
| | | checkTopLine = () => { |
| | | const { config, data } = this.state |
| | | const { config, data, selected } = this.state |
| | | |
| | | if (!config.subcards[0]) return |
| | | |
| | | this.setState({ |
| | | activeKey: 0 |
| | | activeKey: 0, |
| | | selected: selected === 'init' ? 'false' : selected |
| | | }) |
| | | |
| | | MKEmitter.emit('resetSelectLine', config.uuid, (config.subcards[0].setting.primaryId || ''), data) |
| | | let primaryId = config.subcards[0].setting.primaryId || '' |
| | | if (config.wrap.priKeyType === 'dynamic') { |
| | | primaryId = data.$$uuid || '' |
| | | } else if (config.wrap.priKeyType === 'joint') { |
| | | primaryId = (data.$$uuid || '') + ',' + primaryId |
| | | } |
| | | |
| | | MKEmitter.emit('resetSelectLine', config.uuid, primaryId, data) |
| | | } |
| | | |
| | | handleTimer = () => { |
| | |
| | | |
| | | async loadData (hastimer) { |
| | | const { mainSearch, menuType } = this.props |
| | | const { config, arr_field, BID, BData } = this.state |
| | | const { config, arr_field, BID, BData, selected } = this.state |
| | | |
| | | if (config.wrap.datatype === 'static') { |
| | | this.setState({ |
| | |
| | | |
| | | _data.$$BID = BID || '' |
| | | _data.$$BData = BData |
| | | _data.$$uuid = _data[config.setting.primaryKey] || '' |
| | | |
| | | this.setState({ |
| | | data: _data, |
| | | loading: false |
| | | }, () => { |
| | | if (config.wrap.priKeyType !== 'static' && selected !== 'false') { |
| | | this.checkTopLine() |
| | | } |
| | | }) |
| | | |
| | | if (config.timer && config.clearField) { |
| | |
| | | activeKey: index |
| | | }) |
| | | |
| | | MKEmitter.emit('resetSelectLine', config.uuid, (item.setting.primaryId || ''), data) |
| | | let primaryId = item.setting.primaryId || '' |
| | | if (config.wrap.priKeyType === 'dynamic') { |
| | | primaryId = data.$$uuid || '' |
| | | } else if (config.wrap.priKeyType === 'joint') { |
| | | primaryId = (data.$$uuid || '') + ',' + primaryId |
| | | } |
| | | |
| | | MKEmitter.emit('resetSelectLine', config.uuid, primaryId, data) |
| | | } |
| | | |
| | | render() { |