| | |
| | | /** |
| | | * @description 获取IndexedDB中的配置信息 |
| | | */ |
| | | static getIndexDBCacheConfig (MenuID, limit) { |
| | | static getIndexDBCacheConfig (MenuID) { |
| | | if (!window.GLOB.IndexDB) return Promise.resolve() |
| | | |
| | | return new Promise((resolve, reject) => { |
| | |
| | | } |
| | | |
| | | request.onsuccess = () => { |
| | | if (limit && request.result) { |
| | | if (request.result.CreateDate > limit) { |
| | | resolve(request.result) |
| | | } else { |
| | | resolve() |
| | | } |
| | | } else { |
| | | resolve(request.result) |
| | | } |
| | | resolve(request.result) |
| | | } |
| | | }) |
| | | } |
| | |
| | | return new Promise((resolve, reject) => { |
| | | if (window.GLOB.IndexDB) { |
| | | let limit = minutes ? moment().subtract(minutes, 'minutes').format('YYYY-MM-DD HH:mm:ss') : '' |
| | | CacheUtils.getIndexDBCacheConfig(menuid, limit).then(res => { |
| | | CacheUtils.getIndexDBCacheConfig(menuid).then(res => { |
| | | if (res && res.LongParam) { |
| | | let _data = JSON.parse(res.LongParam) |
| | | if (_data.length === 0) { |
| | | resolve() |
| | | } else { |
| | | resolve(_data) |
| | | } |
| | | resolve({data: JSON.parse(res.LongParam), valid: !limit || res.CreateDate > limit}) |
| | | } else { |
| | | resolve() |
| | | resolve({data: null, valid: false}) |
| | | } |
| | | }) |
| | | } else { |
| | | resolve() |
| | | resolve({data: null, valid: false}) |
| | | } |
| | | }) |
| | | } |
| | |
| | | |
| | | if (config.$cache && !this.loaded) { |
| | | Api.getLCacheConfig(config.uuid).then(res => { |
| | | if (!res || this.loaded) return |
| | | if (!res.data || this.loaded) return |
| | | |
| | | let data = [] |
| | | res.forEach((item, index) => { |
| | | res.data.forEach((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[config.setting.primaryKey] || '' |
| | | |
| | |
| | | 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() |
| | | }, 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 { |
| | | 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.$time && !config.setting.laypage) { |
| | | 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() |
| | | }, config.setting.delay || 0) |
| | | } |
| | | |
| | | if (!res || this.loaded) return |
| | | |
| | | let _data = res.map((item, index) => { |
| | | if (!res.data || this.loaded) return |
| | | |
| | | let _data = res.data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[config.setting.primaryKey] || '' |
| | | item.$Index = index + 1 + '' |
| | |
| | | } 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.map((item, index) => { |
| | | let _data = res.data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[config.setting.primaryKey] || '' |
| | | item.$Index = index + 1 + '' |
| | |
| | | |
| | | if (config.$time && !config.setting.laypage) { |
| | | Api.getLCacheConfig(config.uuid, config.$time).then(res => { |
| | | if (!res) { |
| | | if (!res.valid) { |
| | | setTimeout(() => { |
| | | this.loadData() |
| | | }, config.setting.delay || 0) |
| | | } |
| | | |
| | | if (!res) return |
| | | if (!res.data) return |
| | | |
| | | this.setState({data: getData(res)}) |
| | | this.setState({data: getData(res.data)}) |
| | | }) |
| | | } else { |
| | | Api.getLCacheConfig(config.uuid, 0).then(res => { |
| | | if (!res || this.loaded) return |
| | | if (!res.data || this.loaded) return |
| | | |
| | | this.setState({data: getData(res)}) |
| | | this.setState({data: getData(res.data)}) |
| | | }) |
| | | |
| | | setTimeout(() => { |
| | |
| | | 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() |
| | | }, 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 { |
| | | 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.$cache && config.$time && config.wrap.autoExec) { |
| | | Api.getLCacheConfig(config.uuid, config.$time).then(res => { |
| | | if (!res) { |
| | | if (!res.valid) { |
| | | this.autoExec() |
| | | } else { |
| | | Api.writeCacheConfig(config.uuid, []) |
| | |
| | | if (config.$time && !config.setting.laypage) { |
| | | 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() |
| | | }, config.setting.delay || 0) |
| | | } |
| | | |
| | | if (!res || this.loaded) return |
| | | if (!res.data || this.loaded) return |
| | | |
| | | let _data = res.map((item, index) => { |
| | | let _data = res.data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[config.setting.primaryKey] || '' |
| | | item.$Index = index + 1 + '' |
| | |
| | | } 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.map((item, index) => { |
| | | let _data = res.data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[config.setting.primaryKey] || '' |
| | | item.$Index = index + 1 + '' |
| | |
| | | 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() |
| | | }, config.setting.delay || 0) |
| | | } |
| | | |
| | | if (!res || this.loaded) return |
| | | if (!res.data || this.loaded) return |
| | | |
| | | let _data = res.map((item, index) => { |
| | | let _data = res.data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[config.setting.primaryKey] || '' |
| | | item.$Index = index + 1 + '' |
| | |
| | | } 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.map((item, index) => { |
| | | let _data = res.data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[config.setting.primaryKey] || '' |
| | | item.$Index = index + 1 + '' |
| | |
| | | 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() |
| | | }, 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 { |
| | | 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.$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() |
| | | }, config.setting.delay || 0) |
| | | } |
| | | |
| | | if (!res || this.loaded) return |
| | | if (!res.data || this.loaded) return |
| | | |
| | | this.data = res |
| | | this.data = res.data |
| | | this.handleData() |
| | | }) |
| | | } else { |
| | |
| | | } else { |
| | | if (!this.loaded) { |
| | | Api.getLCacheConfig(config.uuid, 0).then(res => { |
| | | if (!res || this.loaded) return |
| | | if (!res.data || this.loaded) return |
| | | |
| | | this.data = res |
| | | this.data = res.data |
| | | this.handleData() |
| | | }) |
| | | } |
| | |
| | | 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() |
| | | }, config.setting.delay || 0) |
| | | } |
| | | |
| | | if (!res || this.loaded) return |
| | | if (!res.data || this.loaded) return |
| | | |
| | | this.data = res |
| | | this.data = res.data |
| | | this.handleData() |
| | | }) |
| | | } else { |
| | |
| | | } else { |
| | | if (!this.loaded) { |
| | | Api.getLCacheConfig(config.uuid, 0).then(res => { |
| | | if (!res || this.loaded) return |
| | | if (!res.data || this.loaded) return |
| | | |
| | | this.data = res |
| | | this.data = res.data |
| | | this.handleData() |
| | | }) |
| | | } |
| | |
| | | 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() |
| | | }, config.setting.delay || 0) |
| | | } |
| | | |
| | | if (!res || this.loaded) return |
| | | if (!res.data || this.loaded) return |
| | | |
| | | this.data = res |
| | | this.data = res.data |
| | | |
| | | if (config.subtype !== 'ratioboard') { |
| | | if (Array.isArray(this.data)) { |
| | |
| | | } else { |
| | | if (!this.loaded) { |
| | | Api.getLCacheConfig(config.uuid, 0).then(res => { |
| | | if (!res || this.loaded) return |
| | | if (!res.data || this.loaded) return |
| | | |
| | | this.data = res |
| | | this.data = res.data |
| | | |
| | | if (config.subtype !== 'ratioboard') { |
| | | if (Array.isArray(this.data)) { |
| | |
| | | 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() |
| | | }, config.setting.delay || 0) |
| | | } |
| | | |
| | | if (!res || this.loaded) return |
| | | if (!res.data || this.loaded) return |
| | | |
| | | this.data = res |
| | | this.data = res.data |
| | | this.handleData() |
| | | }) |
| | | } else { |
| | |
| | | } else { |
| | | if (!this.loaded) { |
| | | Api.getLCacheConfig(config.uuid, 0).then(res => { |
| | | if (!res || this.loaded) return |
| | | if (!res.data || this.loaded) return |
| | | |
| | | this.data = res |
| | | this.data = res.data |
| | | this.handleData() |
| | | }) |
| | | } |
| | |
| | | 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() |
| | | }, config.setting.delay || 0) |
| | | } |
| | | |
| | | if (!res || this.loaded) return |
| | | if (!res.data || this.loaded) return |
| | | |
| | | this.data = res |
| | | this.data = res.data |
| | | this.handleData() |
| | | |
| | | this.setState({empty: res.length === 0}) |
| | | this.setState({empty: res.data.length === 0}) |
| | | }) |
| | | } else { |
| | | this.handleData() |
| | |
| | | } else { |
| | | if (!this.loaded) { |
| | | Api.getLCacheConfig(config.uuid, 0).then(res => { |
| | | if (!res || this.loaded) return |
| | | if (!res.data || this.loaded) return |
| | | |
| | | this.data = res |
| | | this.data = res.data |
| | | this.handleData() |
| | | |
| | | this.setState({empty: res.length === 0}) |
| | | this.setState({empty: res.data.length === 0}) |
| | | }) |
| | | } |
| | | |
| | |
| | | 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() |
| | | }, config.setting.delay || 0) |
| | | } |
| | | |
| | | if (!res || this.loaded) return |
| | | if (!res.data || this.loaded) return |
| | | |
| | | this.data = res |
| | | this.data = res.data |
| | | this.handleData() |
| | | |
| | | this.setState({empty: res.length === 0}) |
| | | this.setState({empty: res.data.length === 0}) |
| | | }) |
| | | } else { |
| | | this.handleData() |
| | |
| | | } else { |
| | | if (!this.loaded) { |
| | | Api.getLCacheConfig(config.uuid, 0).then(res => { |
| | | if (!res || this.loaded) return |
| | | if (!res.data || this.loaded) return |
| | | |
| | | this.data = res |
| | | this.data = res.data |
| | | this.handleData() |
| | | |
| | | this.setState({empty: res.length === 0}) |
| | | this.setState({empty: res.data.length === 0}) |
| | | }) |
| | | } |
| | | |
| | |
| | | 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() |
| | | }, config.setting.delay || 0) |
| | | } |
| | | |
| | | if (!res || this.loaded) return |
| | | if (!res.data || this.loaded) return |
| | | |
| | | this.setState({data: res}, () => { |
| | | this.setState({data: res.data}, () => { |
| | | this.renderView() |
| | | }) |
| | | }) |
| | |
| | | } else { |
| | | if (!this.loaded) { |
| | | Api.getLCacheConfig(config.uuid, 0).then(res => { |
| | | if (!res || this.loaded) return |
| | | if (!res.data || this.loaded) return |
| | | |
| | | this.setState({data: res}, () => { |
| | | this.setState({data: res.data}, () => { |
| | | this.renderView() |
| | | }) |
| | | }) |
| | |
| | | |
| | | if (config.$cache && config.$time) { |
| | | Api.getLCacheConfig(params[0].uuid, config.$time).then(res => { |
| | | if (!res) { |
| | | if (!res.valid) { |
| | | this.getMainData(param, params, config.uuid) |
| | | } |
| | | }) |
| | |
| | | if (config.$time && !setting.laypage) { |
| | | 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.loadmaindata() |
| | | }, config.setting.delay || 0) |
| | | } |
| | | |
| | | if (!res || this.loaded) return |
| | | if (!res.data || this.loaded) return |
| | | |
| | | this.setState({data: res.map((item, index) => { |
| | | this.setState({data: res.data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[config.setting.primaryKey] || '' |
| | | item.$$key = '' + item.key + item.$$uuid |
| | |
| | | } else { |
| | | if (!this.loaded) { |
| | | Api.getLCacheConfig(config.uuid, 0).then(res => { |
| | | if (!res || this.loaded) return |
| | | if (!res.data || this.loaded) return |
| | | |
| | | this.setState({data: res.map((item, index) => { |
| | | this.setState({data: res.data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[config.setting.primaryKey] || '' |
| | | item.$$key = '' + item.key + item.$$uuid |
| | |
| | | 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() |
| | | }, config.setting.delay || 0) |
| | | } |
| | | |
| | | if (!res || this.loaded) return |
| | | if (!res.data || this.loaded) return |
| | | |
| | | this.setState({data: res.map((item, index) => { |
| | | this.setState({data: res.data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[config.setting.primaryKey] || '' |
| | | item.$Index = index + 1 + '' |
| | |
| | | } else { |
| | | if (!this.loaded) { |
| | | Api.getLCacheConfig(config.uuid, 0).then(res => { |
| | | if (!res || this.loaded) return |
| | | if (!res.data || this.loaded) return |
| | | |
| | | this.setState({data: res.map((item, index) => { |
| | | this.setState({data: res.data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[config.setting.primaryKey] || '' |
| | | item.$Index = index + 1 + '' |
| | |
| | | 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() |
| | | }, config.setting.delay || 0) |
| | | } |
| | | |
| | | if (!res || this.loaded) return |
| | | if (!res.data || this.loaded) return |
| | | |
| | | this.setState({data: res}, () => { |
| | | this.setState({data: res.data}, () => { |
| | | this.handleData() |
| | | }) |
| | | }) |
| | |
| | | } else { |
| | | if (!this.loaded) { |
| | | Api.getLCacheConfig(config.uuid, 0).then(res => { |
| | | if (!res || this.loaded) return |
| | | if (!res.data || this.loaded) return |
| | | |
| | | this.setState({data: res}, () => { |
| | | this.setState({data: res.data}, () => { |
| | | this.handleData() |
| | | }) |
| | | }) |
| | |
| | | |
| | | if (config.$cache && config.$time) { |
| | | Api.getLCacheConfig(params[0].uuid, config.$time).then(res => { |
| | | if (!res) { |
| | | if (!res.valid) { |
| | | this.getMainData(param, params, config.MenuID) |
| | | } else { |
| | | this.setState({ |