| | |
| | | sync: false, // 是否统一请求数据 |
| | | data: {}, // 数据 |
| | | timer: null, // 定时器时间间隔 |
| | | BData: '' |
| | | BData: '', |
| | | selected: 'false', |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | |
| | | let _data = { $$empty: true } |
| | | let _sync = false |
| | | |
| | | if (_config.setting && _config.wrap.datatype !== 'static') { |
| | | if (_config.wrap.datatype !== 'static') { |
| | | _sync = _config.setting.sync === 'true' |
| | | |
| | | if (_sync && data) { |
| | |
| | | if (_data) { |
| | | _data.$$BID = BID || '' |
| | | _data.$$BData = BData || '' |
| | | if (_config.setting.primaryKey) { |
| | | _data.$$uuid = _data[_config.setting.primaryKey] || '' |
| | | } |
| | | } |
| | | |
| | | _config.columns.forEach(item => { |
| | |
| | | }) |
| | | |
| | | let offset = 0 |
| | | if (_config.wrap.cardFloat && _config.wrap.cardFloat !== 'left' && _config.subcards[0] && _width < 24) { |
| | | if (_config.wrap.cardFloat && _config.wrap.cardFloat !== 'left' && _width < 24) { |
| | | offset = 24 - _width |
| | | if (_config.wrap.cardFloat === 'center') { |
| | | offset = Math.floor(offset / 2) |
| | |
| | | _config.subcards[0].offset = offset |
| | | } |
| | | |
| | | if (_config.subcards[0] && (_config.wrap.selected === 'always' || _config.wrap.selected === 'init')) { |
| | | setTimeout(() => { |
| | | this.checkTopLine() |
| | | }, 200) |
| | | } |
| | | let selected = _config.wrap.selected || 'false' |
| | | |
| | | _config.wrap.selStyle = _config.wrap.selStyle || 'active' |
| | | _config.wrap.priKeyType = _config.wrap.priKeyType || 'static' |
| | | _config.wrap.scale = _config.wrap.scale === 'true' ? 'scale' : '' |
| | | |
| | | _config.wrap.wrapClass = `${_config.wrap.selStyle} ${_config.wrap.cardType || ''} ${_config.wrap.scale || ''}` |
| | | |
| | | this.setState({ |
| | | selected, |
| | | sync: _sync, |
| | | data: _data, |
| | | BID: BID || '', |
| | |
| | | config: _config, |
| | | arr_field: _config.columns.map(col => col.field).join(','), |
| | | }, () => { |
| | | if (_config.wrap.datatype !== 'static' && _config.setting && _config.setting.sync !== 'true' && _config.setting.onload === 'true') { |
| | | if (_config.wrap.datatype !== 'static' && _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.$$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 |
| | | |
| | | 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 = () => { |
| | |
| | | resetParentParam = (MenuID, id, data) => { |
| | | const { config } = this.state |
| | | |
| | | if (!config.setting || !config.setting.supModule || config.setting.supModule !== MenuID) return |
| | | if (!config.setting.supModule || config.setting.supModule !== MenuID) return |
| | | if (id !== this.state.BID || id !== '') { |
| | | this.setState({ BID: id, BData: data }, () => { |
| | | this.loadData() |
| | |
| | | |
| | | 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() { |
| | |
| | | </div> : null |
| | | } |
| | | <NormalHeader config={config}/> |
| | | <Row className={`card-row-list ${config.wrap.cardType || ''} ${config.wrap.scale || ''}`}> |
| | | {config.subcards.map((item, index) => ( |
| | | <Col className={(activeKey === index ? config.wrap.selStyle : '') + (item.setting.click ? ' pointer' : '')} key={index} span={item.setting.width || 6} offset={item.offset || 0} onClick={() => {this.changeCard(index, item)}}> |
| | | <CardItem card={item} cards={config} data={data}/> |
| | | </Col> |
| | | ))} |
| | | <Row className={`card-row-list data-zoom ${config.wrap.wrapClass}`}> |
| | | {config.subcards.map((item, index) => { |
| | | let className = item.setting.click ? 'mk-card pointer ' : 'mk-card ' |
| | | if (activeKey === index) { |
| | | className += 'active' |
| | | } |
| | | |
| | | return ( |
| | | <Col className={className} key={index} span={item.setting.width || 6} offset={item.offset || 0} onClick={() => {this.changeCard(index, item)}}> |
| | | <CardItem card={item} cards={config} data={data}/> |
| | | </Col> |
| | | ) |
| | | })} |
| | | </Row> |
| | | </div> |
| | | ) |