| | |
| | | } |
| | | |
| | | if (_config.wrap.datatype !== 'static') { |
| | | _config.setting.onload = _config.setting.sync === 'true' ? 'false' : 'true' |
| | | |
| | | if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { |
| | | _data = window.GLOB.SyncData.get(_config.dataName) || [] |
| | | |
| | |
| | | |
| | | window.GLOB.SyncData.delete(_config.dataName) |
| | | } |
| | | } else { |
| | | this.loaded = true |
| | | } |
| | | |
| | | if (_config.css) { |
| | |
| | | data: _data, |
| | | BID: BID || '', |
| | | config: _config, |
| | | arr_field: _config.columns.map(col => col.field).join(','), |
| | | }, () => { |
| | | if (_config.wrap.datatype !== 'static' && config.setting.sync !== 'true' && _config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | | this.loadData() |
| | | }, _config.setting.delay || 0) |
| | | } |
| | | this.renderView() |
| | | arr_field: _config.columns.map(col => col.field).join(',') |
| | | }) |
| | | } |
| | | |
| | |
| | | MKEmitter.addListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | |
| | | if (config.$cache && !this.loaded) { |
| | | Api.getLCacheConfig(config.uuid).then(res => { |
| | | if (!res || this.loaded) return |
| | | |
| | | this.setState({data: res}, () => { |
| | | this.renderView() |
| | | }) |
| | | }) |
| | | } |
| | | this.initExec() |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | |
| | | initExec = () => { |
| | | const { config } = this.state |
| | | |
| | | if (config.wrap.datatype !== 'static') { |
| | | if (config.$cache) { |
| | | if (config.$time) { |
| | | if (!this.loaded) { |
| | | Api.getLCacheConfig(config.uuid, config.$time).then(res => { |
| | | if (!res && config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | | this.loadData() |
| | | }, config.setting.delay || 0) |
| | | } |
| | | |
| | | if (!res || this.loaded) return |
| | | |
| | | this.setState({data: res}, () => { |
| | | this.renderView() |
| | | }) |
| | | }) |
| | | } else { |
| | | this.renderView() |
| | | } |
| | | } else { |
| | | if (!this.loaded) { |
| | | Api.getLCacheConfig(config.uuid, 0).then(res => { |
| | | if (!res || this.loaded) return |
| | | |
| | | this.setState({data: res}, () => { |
| | | this.renderView() |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | if (config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | | this.loadData() |
| | | }, config.setting.delay || 0) |
| | | } else if (this.loaded) { |
| | | this.renderView() |
| | | } |
| | | } |
| | | } else if (config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | | this.loadData() |
| | | }, config.setting.delay || 0) |
| | | } else if (this.loaded) { |
| | | this.renderView() |
| | | } |
| | | } else { |
| | | this.renderView() |
| | | } |
| | | } |
| | | |
| | | transferSyncData = (syncId) => { |
| | | const { config } = this.state |
| | | |