| | |
| | | if (config.$time) { |
| | | if (!this.loaded) { |
| | | Api.getLCacheConfig(config.uuid, config.$time).then(res => { |
| | | if (!res && config.setting.onload === 'true') { |
| | | if (!res.valid && config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | | this.loadData() |
| | | this.loadData('init') |
| | | }, config.setting.delay || 0) |
| | | } |
| | | |
| | | if (!res || this.loaded) return |
| | | if (!res.data || this.loaded) return |
| | | |
| | | let _data = res[0] || {$$empty: true} |
| | | let _data = res.data[0] || {$$empty: true} |
| | | _data.$$uuid = _data[config.setting.primaryKey] || '' |
| | | |
| | | this.setState({data: _data}) |
| | | }) |
| | | } else { |
| | | this.openModal() |
| | | } |
| | | } else { |
| | | if (!this.loaded) { |
| | | Api.getLCacheConfig(config.uuid, 0).then(res => { |
| | | if (!res || this.loaded) return |
| | | if (!res.data || this.loaded) return |
| | | |
| | | let _data = res[0] || {$$empty: true} |
| | | let _data = res.data[0] || {$$empty: true} |
| | | _data.$$uuid = _data[config.setting.primaryKey] || '' |
| | | |
| | | this.setState({data: _data}) |
| | |
| | | |
| | | if (config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | | this.loadData() |
| | | this.loadData('init') |
| | | }, config.setting.delay || 0) |
| | | } else if (this.loaded) { |
| | | this.openModal() |
| | |
| | | } else if (this.loaded) { |
| | | this.openModal() |
| | | } |
| | | } else if (config.wrap.display === 'modal' && config.wrap.datatype === 'static') { |
| | | } else if (config.wrap.datatype === 'static') { |
| | | this.openModal() |
| | | } |
| | | } |
| | |
| | | this.loaded = true |
| | | |
| | | this.setState({data: _data}, () => { |
| | | if (config.wrap.display === 'modal') { |
| | | this.openModal() |
| | | } |
| | | this.openModal() |
| | | }) |
| | | |
| | | window.GLOB.SyncData.delete(config.dataName) |
| | |
| | | |
| | | openModal = (ErrCode) => { |
| | | const { config, data } = this.state |
| | | |
| | | if (config.wrap.display !== 'modal') return |
| | | |
| | | let code = config.wrap.code || ('modal' + config.uuid) |
| | | let tip = localStorage.getItem(code) |
| | |
| | | let _data = {} |
| | | |
| | | this.loaded = true |
| | | if (config.$cache && config.setting.onload !== 'false') { |
| | | if (config.$cache && type === 'init') { |
| | | Api.writeCacheConfig(config.uuid, result.data || []) |
| | | } |
| | | |
| | |
| | | data: _data, |
| | | loading: false |
| | | }, () => { |
| | | if (config.wrap.display === 'modal') { |
| | | this.openModal(result.ErrCode) |
| | | } |
| | | this.openModal(result.ErrCode) |
| | | }) |
| | | |
| | | if (config.timer && config.clearField && result.data && result.data[0]) { |