From 2a3cc4e6cecfc6dab8b60adf93f7fde898ddc939 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 25 七月 2023 16:36:23 +0800 Subject: [PATCH] 2023-07-25 --- src/tabviews/custom/components/chart/antv-scatter/index.jsx | 99 + src/tabviews/custom/components/chart/antv-bar-line/index.jsx | 91 + src/tabviews/custom/components/code/sand-box/index.jsx | 77 + src/tabviews/custom/components/chart/antv-dashboard/index.jsx | 117 ++ src/views/menudesign/popview/index.jsx | 3 src/tabviews/custom/components/editor/braft-editor/index.jsx | 20 src/tabviews/custom/components/tree/antd-tree/index.jsx | 94 + src/views/mobdesign/menuform/index.jsx | 57 src/views/pcdesign/menuform/index.jsx | 58 src/tabviews/custom/components/card/double-data-card/index.jsx | 95 + src/tabviews/custom/components/chart/antv-G6/index.jsx | 93 + src/views/menudesign/homeform/index.jsx | 35 src/views/menudesign/menuform/index.jsx | 16 public/options.json | 8 src/tabviews/custom/components/carousel/data-card/index.jsx | 127 ++- src/tabviews/custom/popview/index.jsx | 29 src/api/index.js | 10 src/tabviews/custom/components/chart/custom-chart/index.jsx | 98 + src/tabviews/custom/components/card/data-card/index.jsx | 155 ++- src/tabviews/custom/components/card/table-card/index.jsx | 119 ++- src/tabviews/custom/components/card/prop-card/index.jsx | 157 ++- src/api/cacheutils.js | 14 src/tabviews/custom/components/share/tabtransfer/index.jsx | 16 src/tabviews/custom/components/table/normal-table/index.jsx | 314 ++++--- src/views/mobdesign/popview/index.jsx | 3 src/tabviews/custom/components/chart/antv-pie/index.jsx | 93 + src/tabviews/custom/components/timeline/normal-timeline/index.jsx | 116 +- /dev/null | 0 src/tabviews/custom/components/carousel/prop-card/index.jsx | 79 + src/tabviews/custom/index.jsx | 32 src/tabviews/custom/components/card/balcony/index.jsx | 88 + 31 files changed, 1,510 insertions(+), 803 deletions(-) diff --git a/public/options.json b/public/options.json index 858e91f..57c697b 100644 --- a/public/options.json +++ b/public/options.json @@ -1,6 +1,6 @@ { - "appId": "201912040924165801464FF1788654BC5AC73", - "appkey": "20191106103859640976D6E924E464D029CF0", + "appId": "20230324173136800278A30757BBB4780921F", + "appkey": "2023032417311621367D715E545D847E5841A", "mainSystemApi": "http://sso.mk9h.cn/cloud/webapi/dostars", "systemType": "", "externalDatabase": "", @@ -18,6 +18,6 @@ "transfer": "false", "keepPassword": "true", "platforms": ["H5", "wechat", "android", "ios", "wxMiniProgram"], - "host": "http://qingqiumarket.cn", - "service": "MKWMS/" + "host": "https://demo.mk9h.cn", + "service": "qisheng/" } \ No newline at end of file diff --git a/src/api/cacheutils.js b/src/api/cacheutils.js index 265071c..bd14fa5 100644 --- a/src/api/cacheutils.js +++ b/src/api/cacheutils.js @@ -204,7 +204,7 @@ /** * @description 鑾峰彇IndexedDB涓殑閰嶇疆淇℃伅 */ - static getIndexDBCacheConfig (MenuID) { + static getIndexDBCacheConfig (MenuID, limit) { if (!window.GLOB.IndexDB) return Promise.resolve() return new Promise((resolve, reject) => { @@ -215,7 +215,15 @@ } request.onsuccess = () => { - resolve(request.result) + if (limit && request.result) { + if (request.result.CreateDate > limit) { + resolve(request.result) + } else { + resolve() + } + } else { + resolve(request.result) + } } }) } @@ -234,7 +242,7 @@ request.onsuccess = (e) => { let cursor = e.target.result if (cursor) { - if (cursor.value.CreateDate < date) { + if (cursor.value.CreateDate < date || cursor.value.CreateDate.length === 10) { cursor.delete() } cursor.continue() diff --git a/src/api/index.js b/src/api/index.js index da12110..c30b55b 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -325,22 +325,23 @@ } delCacheConfig (type = '') { - let date = moment().subtract(7, 'days').format('YYYY-MM-DD') + let date = moment().subtract(7, 'days').format('YYYY-MM-DD HH:mm:ss') CacheUtils.delIndexDBCacheConfig(date, type) } writeCacheConfig (menuid, data) { if (!menuid) return - let date = moment().format('YYYY-MM-DD') + let date = moment().format('YYYY-MM-DD HH:mm:ss') let _data = data ? JSON.stringify(data) : '' CacheUtils.writeCacheInIndexDB({menuid, CreateDate: date, LongParam: _data}) } - getLCacheConfig (menuid) { + getLCacheConfig (menuid, minutes) { return new Promise((resolve, reject) => { if (window.GLOB.IndexDB) { - CacheUtils.getIndexDBCacheConfig(menuid).then(res => { + let limit = minutes ? moment().subtract(minutes, 'minutes').format('YYYY-MM-DD HH:mm:ss') : '' + CacheUtils.getIndexDBCacheConfig(menuid, limit).then(res => { if (res && res.LongParam) { let _data = JSON.parse(res.LongParam) if (_data.length === 0) { @@ -428,6 +429,7 @@ list = '' } CacheUtils.delIndexDBConfig(list) + this.delCacheConfig('all') } CacheUtils.updateIndexDBversion({version: res.app_version || '1.00', createDate: curTime}) diff --git a/src/tabviews/custom/components/card/balcony/index.jsx b/src/tabviews/custom/components/card/balcony/index.jsx index e65688f..ff3bec1 100644 --- a/src/tabviews/custom/components/card/balcony/index.jsx +++ b/src/tabviews/custom/components/card/balcony/index.jsx @@ -49,6 +49,8 @@ let _data = { $$empty: true } if (_config.wrap.datatype === 'dynamic') { + _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) || [] @@ -64,12 +66,11 @@ window.GLOB.SyncData.delete(_config.dataName) } - } else if (_config.wrap.datatype === 'public' && window.GLOB.CacheData.get(_config.wrap.publicId)) { - _data = window.GLOB.CacheData.get(_config.wrap.publicId) - _data = fromJS(_data).toJS() - this.loaded = true - } else if (_config.wrap.datatype === 'static') { - this.loaded = true + } else if (_config.wrap.datatype === 'public') { + if (window.GLOB.CacheData.has(_config.wrap.publicId)) { + _data = window.GLOB.CacheData.get(_config.wrap.publicId) + _data = fromJS(_data).toJS() + } } _data.$$BID = BID || '' @@ -118,13 +119,7 @@ data: _data, BID: BID || '', config: _config, - arr_field: _config.columns.map(col => col.field).join(','), - }, () => { - if (_config.wrap.datatype === 'dynamic' && config.setting.sync !== 'true') { - setTimeout(() => { - this.loadData() - }, _config.setting.delay || 0) - } + arr_field: _config.columns.map(col => col.field).join(',') }) } @@ -146,20 +141,13 @@ MKEmitter.addListener('mkPublicData', this.mkPublicData) } - if (config.timer && config.wrap.datatype === 'dynamic') { - this.timer = new TimerTask() - this.timer.init(config.uuid, config.timer, config.timerRepeats, () => {this.loadData(true)}) - } + if (config.wrap.datatype === 'dynamic') { + if (config.timer) { + this.timer = new TimerTask() + this.timer.init(config.uuid, config.timer, config.timerRepeats, () => {this.loadData(true)}) + } - if (config.$cache && !this.loaded) { - Api.getLCacheConfig(config.uuid).then(res => { - if (!res || this.loaded) return - - let _data = res[0] || {$$empty: true} - _data.$$uuid = _data[config.setting.primaryKey] || '' - - this.setState({data: _data}) - }) + this.initExec() } } @@ -181,6 +169,52 @@ MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) this.timer && this.timer.stop() + } + + initExec = () => { + const { config } = this.state + + 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 + + let _data = res[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 + + let _data = res[0] || {$$empty: true} + _data.$$uuid = _data[config.setting.primaryKey] || '' + + this.setState({data: _data}) + }) + } + + if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } + } + } else if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } } transferSyncData = (syncId) => { @@ -220,8 +254,6 @@ _data.$$BID = BID || '' _data.$$BData = BData || '' _data.$$uuid = _data[config.setting.primaryKey] || '' - - this.loaded = true this.setState({data: _data}) } diff --git a/src/tabviews/custom/components/card/data-card/index.jsx b/src/tabviews/custom/components/card/data-card/index.jsx index 5b58e10..08b1383 100644 --- a/src/tabviews/custom/components/card/data-card/index.jsx +++ b/src/tabviews/custom/components/card/data-card/index.jsx @@ -150,33 +150,37 @@ } let _data = null - if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { - _data = window.GLOB.SyncData.get(_config.dataName) || [] + if (_config.setting.sync === 'true') { + _config.setting.onload = 'false' - if (_config.$cache) { - Api.writeCacheConfig(_config.uuid, fromJS(_data).toJS()) - } - - _config.setting.sync = 'false' - - _data = _data.map((item, index) => { - item.key = index - item.$$uuid = item[_config.setting.primaryKey] || '' - item.$$BID = BID || '' - item.$$BData = BData || '' - item.$Index = index + 1 + '' - - if (_config.wrap.controlField) { - if (_config.wrap.controlVal.includes(item[_config.wrap.controlField] + '')) { - item.$disabled = true - } + if (window.GLOB.SyncData.has(_config.dataName)) { + _data = window.GLOB.SyncData.get(_config.dataName) || [] + + if (_config.$cache) { + Api.writeCacheConfig(_config.uuid, fromJS(_data).toJS()) } - return item - }) - - this.loaded = true - - window.GLOB.SyncData.delete(_config.dataName) + + _config.setting.sync = 'false' + + _data = _data.map((item, index) => { + item.key = index + item.$$uuid = item[_config.setting.primaryKey] || '' + item.$$BID = BID || '' + item.$$BData = BData || '' + item.$Index = index + 1 + '' + + if (_config.wrap.controlField) { + if (_config.wrap.controlVal.includes(item[_config.wrap.controlField] + '')) { + item.$disabled = true + } + } + return item + }) + + this.loaded = true + + window.GLOB.SyncData.delete(_config.dataName) + } } this.setState({ @@ -192,15 +196,7 @@ config: _config, card: _card, search: _config.$searches, - arr_field: _config.columns.map(col => col.field).join(','), - }, () => { - if (config.setting.sync !== 'true' && _config.setting.onload === 'true') { - setTimeout(() => { - this.loadData() - }, _config.setting.delay || 0) - } - - this.loaded && this.prevCheck() + arr_field: _config.columns.map(col => col.field).join(',') }) } @@ -233,26 +229,7 @@ }) } - if (config.$cache && !this.loaded) { - Api.getLCacheConfig(config.uuid).then(res => { - if (!res || this.loaded) return - let _data = res.map((item, index) => { - item.key = index - item.$$uuid = item[config.setting.primaryKey] || '' - item.$Index = index + 1 + '' - - if (config.wrap.controlField) { - if (config.wrap.controlVal.includes(item[config.wrap.controlField] + '')) { - item.$disabled = true - } - } - - return item - }) - - this.setState({data: _data}) - }) - } + this.initExec() } shouldComponentUpdate (nextProps, nextState) { @@ -275,6 +252,76 @@ this.timer && this.timer.stop() } + initExec = () => { + const { config } = this.state + + this.loaded && this.prevCheck() + + if (config.$cache) { + if (config.$time && !config.setting.laypage) { + 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 + + let _data = res.map((item, index) => { + item.key = index + item.$$uuid = item[config.setting.primaryKey] || '' + item.$Index = index + 1 + '' + + if (config.wrap.controlField) { + if (config.wrap.controlVal.includes(item[config.wrap.controlField] + '')) { + item.$disabled = true + } + } + + return item + }) + + this.setState({data: _data}) + }) + } + } else { + if (!this.loaded) { + Api.getLCacheConfig(config.uuid, 0).then(res => { + if (!res || this.loaded) return + + let _data = res.map((item, index) => { + item.key = index + item.$$uuid = item[config.setting.primaryKey] || '' + item.$Index = index + 1 + '' + + if (config.wrap.controlField) { + if (config.wrap.controlVal.includes(item[config.wrap.controlField] + '')) { + item.$disabled = true + } + } + + return item + }) + + this.setState({data: _data}) + }) + } + + if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } + } + } else if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } + } + transferSyncData = (syncId) => { const { config } = this.state diff --git a/src/tabviews/custom/components/card/double-data-card/index.jsx b/src/tabviews/custom/components/card/double-data-card/index.jsx index 7589687..8f4e530 100644 --- a/src/tabviews/custom/components/card/double-data-card/index.jsx +++ b/src/tabviews/custom/components/card/double-data-card/index.jsx @@ -116,8 +116,6 @@ _config.subcards = null - let _data = null - let selected = 'false' if (_config.wrap.selected === 'always' || _config.wrap.selected === 'init' || _config.wrap.selected === 'sign') { selected = _config.wrap.selected @@ -129,8 +127,6 @@ _config.wrap.pagestyle = _config.wrap.pagestyle || 'page' _config.wrap.wrapClass = `${_config.wrap.selStyle} ${_config.wrap.cardType || ''}` - - this.loaded = _data !== null let wrapStyle = null let subcard = fromJS(_card).toJS() @@ -186,7 +182,6 @@ selected, precards, nextcards, - data: _data, BID: BID || '', BData: BData || '', config: _config, @@ -196,12 +191,6 @@ card: _card, search: _config.$searches, arr_field: _config.columns.map(col => col.field).join(','), - }, () => { - if (_config.setting.onload === 'true') { - setTimeout(() => { - this.loadData() - }, _config.setting.delay || 0) - } }) } @@ -229,10 +218,35 @@ }) } - if (config.$cache && !this.loaded) { - Api.getLCacheConfig(config.uuid).then(res => { - if (!res || this.loaded) return - let _data = res.map((item, index) => { + if (config.setting.onload === 'true') { + this.initExec() + } + } + + shouldComponentUpdate (nextProps, nextState) { + return !is(fromJS(this.state), fromJS(nextState)) + } + + componentWillUnmount () { + this.setState = () => { + return + } + MKEmitter.removeListener('reloadData', this.reloadData) + MKEmitter.removeListener('searchRefresh', this.searchRefresh) + MKEmitter.removeListener('refreshLineData', this.refreshLineData) + MKEmitter.removeListener('resetSelectLine', this.resetParentParam) + MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) + MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) + + this.timer && this.timer.stop() + } + + initExec = () => { + const { config } = this.state + + if (config.$cache) { + let getData = (res) => { + return res.map((item, index) => { let children = [] if (item[config.setting.subdata]) { @@ -268,28 +282,36 @@ return item }) + } + + if (config.$time && !config.setting.laypage) { + Api.getLCacheConfig(config.uuid, config.$time).then(res => { + if (!res) { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } - this.setState({data: _data}) - }) + if (!res) return + + this.setState({data: getData(res)}) + }) + } else { + Api.getLCacheConfig(config.uuid, 0).then(res => { + if (!res || this.loaded) return + + this.setState({data: getData(res)}) + }) + + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } + } else { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) } - } - - shouldComponentUpdate (nextProps, nextState) { - return !is(fromJS(this.state), fromJS(nextState)) - } - - componentWillUnmount () { - this.setState = () => { - return - } - MKEmitter.removeListener('reloadData', this.reloadData) - MKEmitter.removeListener('searchRefresh', this.searchRefresh) - MKEmitter.removeListener('refreshLineData', this.refreshLineData) - MKEmitter.removeListener('resetSelectLine', this.resetParentParam) - MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) - MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) - - this.timer && this.timer.stop() } searchRefresh = (searchId) => { @@ -304,9 +326,6 @@ /** * @description 鎸夐挳鎵ц瀹屾垚鍚庨〉闈㈠埛鏂� - * @param {*} menuId // 鑿滃崟Id - * @param {*} position // 鍒锋柊浣嶇疆 - * @param {*} btn // 鎵ц鐨勬寜閽� */ refreshByButtonResult = (menuId, position, btn, id = '', lines) => { const { config, BID } = this.state diff --git a/src/tabviews/custom/components/card/prop-card/index.jsx b/src/tabviews/custom/components/card/prop-card/index.jsx index fbec582..3ea4c17 100644 --- a/src/tabviews/custom/components/card/prop-card/index.jsx +++ b/src/tabviews/custom/components/card/prop-card/index.jsx @@ -36,8 +36,6 @@ let _config = fromJS(config).toJS() let _data = { $$empty: true } - let _sync = false - let BID = '' let BData = '' @@ -51,6 +49,8 @@ } if (_config.wrap.datatype === 'dynamic') { + _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) || [] @@ -119,40 +119,7 @@ BID: BID || '', BData: BData || '', config: _config, - arr_field: _config.columns.map(col => col.field).join(','), - }, () => { - if (_config.wrap.datatype === 'dynamic' && config.setting.sync !== 'true' && _config.setting.onload === 'true') { - setTimeout(() => { - this.loadData() - }, _config.setting.delay || 0) - } else if (_config.wrap.datatype === 'public') { - if (_data.$$loaded && selected !== 'false') { - setTimeout(() => { - this.checkTopLine() - }, 200) - } - } else if (!_sync && selected !== 'false') { - setTimeout(() => { - this.checkTopLine() - }, 200) - } - - if (_config.wrap.datatype === 'dynamic' && this.loaded) { - if (_config.wrap.goback === 'true' && _data.$$empty) { - this.timer && this.timer.stop() - - MKEmitter.emit('closeTabView', _config.$pageId) - } else { - this.autoExec() - } - } else if (_config.wrap.datatype === 'static') { - this.autoExec() - } - if (_data.$$uuid) { - setTimeout(() => { - this.transferLine() - }, 200) - } + arr_field: _config.columns.map(col => col.field).join(',') }) } @@ -182,16 +149,7 @@ this.timer.init(config.uuid, config.timer, config.timerRepeats, () => {this.loadData(true)}) } - if (config.$cache && !this.loaded) { - Api.getLCacheConfig(config.uuid).then(res => { - if (!res || this.loaded) return - - let _data = res[0] || {$$empty: true} - _data.$$uuid = _data[config.setting.primaryKey] || '' - - this.setState({data: _data}) - }) - } + this.initExec() } shouldComponentUpdate (nextProps, nextState) { @@ -214,6 +172,113 @@ this.timer && this.timer.stop() } + initExec = () => { + const { config, selected, data } = this.state + + if (config.wrap.datatype === 'dynamic') { + 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 + + let _data = res[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 + + let _data = res[0] || {$$empty: true} + _data.$$uuid = _data[config.setting.primaryKey] || '' + + this.setState({data: _data}) + }) + } + + if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } else if (this.loaded) { + if (config.wrap.goback === 'true' && data.$$empty) { + this.timer && this.timer.stop() + + MKEmitter.emit('closeTabView', config.$pageId) + } else { + if (selected !== 'false') { + this.checkTopLine() + } else { + this.transferLine() + } + this.autoExec() + } + } + } + } else if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } else if (this.loaded) { + if (config.wrap.goback === 'true' && data.$$empty) { + this.timer && this.timer.stop() + + MKEmitter.emit('closeTabView', config.$pageId) + } else { + if (selected !== 'false') { + this.checkTopLine() + } else { + this.transferLine() + } + this.autoExec() + } + } + } else if (config.wrap.datatype === 'public') { + if (this.loaded) { + if (config.wrap.goback === 'true' && data.$$empty) { + this.timer && this.timer.stop() + + MKEmitter.emit('closeTabView', config.$pageId) + } else { + if (selected !== 'false') { + this.checkTopLine() + } else if (data.$$uuid) { + this.transferLine() + } + this.autoExec() + } + } + } else { + if (selected !== 'false') { + setTimeout(() => { + this.checkTopLine() + }, 200) + } + + if (config.$cache && config.$time && config.wrap.autoExec) { + Api.getLCacheConfig(config.uuid, config.$time).then(res => { + if (!res) { + this.autoExec() + } else { + Api.writeCacheConfig(config.uuid, []) + } + }) + } else { + this.autoExec() + } + } + } + transferSyncData = (syncId) => { const { config } = this.state diff --git a/src/tabviews/custom/components/card/table-card/index.jsx b/src/tabviews/custom/components/card/table-card/index.jsx index ed2f53c..1d47c0b 100644 --- a/src/tabviews/custom/components/card/table-card/index.jsx +++ b/src/tabviews/custom/components/card/table-card/index.jsx @@ -67,27 +67,31 @@ } let _data = null - if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { - _data = window.GLOB.SyncData.get(_config.dataName) || [] + if (_config.setting.sync === 'true') { + _config.setting.onload = 'false' - if (_config.$cache) { - Api.writeCacheConfig(_config.uuid, fromJS(_data).toJS()) + if (window.GLOB.SyncData.has(_config.dataName)) { + _data = window.GLOB.SyncData.get(_config.dataName) || [] + + if (_config.$cache) { + Api.writeCacheConfig(_config.uuid, fromJS(_data).toJS()) + } + + _config.setting.sync = 'false' + + _data = _data.map((item, index) => { + item.key = index + item.$$uuid = item[_config.setting.primaryKey] || '' + item.$$BID = BID || '' + item.$$BData = BData || '' + item.$Index = index + 1 + '' + return item + }) + + this.loaded = true + + window.GLOB.SyncData.delete(_config.dataName) } - - _config.setting.sync = 'false' - - _data = _data.map((item, index) => { - item.key = index - item.$$uuid = item[_config.setting.primaryKey] || '' - item.$$BID = BID || '' - item.$$BData = BData || '' - item.$Index = index + 1 + '' - return item - }) - - this.loaded = true - - window.GLOB.SyncData.delete(_config.dataName) } this.setState({ @@ -96,13 +100,7 @@ data: _data, config: _config, search: _config.$searches, - arr_field: _config.columns.map(col => col.field).join(','), - }, () => { - if (config.setting.sync !== 'true' && _config.setting.onload === 'true') { - setTimeout(() => { - this.loadData() - }, _config.setting.delay || 0) - } + arr_field: _config.columns.map(col => col.field).join(',') }) } @@ -134,20 +132,7 @@ }) } - if (config.$cache && !this.loaded) { - Api.getLCacheConfig(config.uuid).then(res => { - if (!res || this.loaded) return - - let _data = res.map((item, index) => { - item.key = index - item.$$uuid = item[config.setting.primaryKey] || '' - item.$Index = index + 1 + '' - return item - }) - - this.setState({data: _data}) - }) - } + this.initExec() } shouldComponentUpdate (nextProps, nextState) { @@ -169,6 +154,60 @@ this.timer && this.timer.stop() } + initExec = () => { + const { config } = this.state + + if (config.$cache) { + if (config.$time && !config.setting.laypage) { + 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 + + let _data = res.map((item, index) => { + item.key = index + item.$$uuid = item[config.setting.primaryKey] || '' + item.$Index = index + 1 + '' + return item + }) + + this.setState({data: _data}) + }) + } + } else { + if (!this.loaded) { + Api.getLCacheConfig(config.uuid, 0).then(res => { + if (!res || this.loaded) return + + let _data = res.map((item, index) => { + item.key = index + item.$$uuid = item[config.setting.primaryKey] || '' + item.$Index = index + 1 + '' + return item + }) + + this.setState({data: _data}) + }) + } + + if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } + } + } else if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } + } + transferSyncData = (syncId) => { const { config } = this.state diff --git a/src/tabviews/custom/components/carousel/data-card/index.jsx b/src/tabviews/custom/components/carousel/data-card/index.jsx index 62fbc61..06dc320 100644 --- a/src/tabviews/custom/components/carousel/data-card/index.jsx +++ b/src/tabviews/custom/components/carousel/data-card/index.jsx @@ -49,27 +49,31 @@ } let _data = null - if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { - _data = window.GLOB.SyncData.get(_config.dataName) || [] + if (_config.setting.sync === 'true') { + _config.setting.onload = 'false' - if (_config.$cache) { - Api.writeCacheConfig(_config.uuid, fromJS(_data).toJS()) + if (window.GLOB.SyncData.has(_config.dataName)) { + _data = window.GLOB.SyncData.get(_config.dataName) || [] + + if (_config.$cache) { + Api.writeCacheConfig(_config.uuid, fromJS(_data).toJS()) + } + + _config.setting.sync = 'false' + + _data = _data.map((item, index) => { + item.key = index + item.$$uuid = item[_config.setting.primaryKey] || '' + item.$$BID = BID || '' + item.$$BData = BData || '' + item.$Index = index + 1 + '' + return item + }) + + this.loaded = true + + window.GLOB.SyncData.delete(_config.dataName) } - - _config.setting.sync = 'false' - - _data = _data.map((item, index) => { - item.key = index - item.$$uuid = item[_config.setting.primaryKey] || '' - item.$$BID = BID || '' - item.$$BData = BData || '' - item.$Index = index + 1 + '' - return item - }) - - this.loaded = true - - window.GLOB.SyncData.delete(_config.dataName) } if (_card.setting.click) { @@ -91,15 +95,7 @@ BData: BData || '', config: _config, card: _card, - arr_field: _config.columns.map(col => col.field).join(','), - }, () => { - if (config.setting.sync !== 'true' && _config.setting.onload === 'true') { - setTimeout(() => { - this.loadData() - }, _config.setting.delay || 0) - } else { - this.openModal() - } + arr_field: _config.columns.map(col => col.field).join(',') }) } @@ -125,20 +121,7 @@ }) } - if (config.$cache && !this.loaded) { - Api.getLCacheConfig(config.uuid).then(res => { - if (!res || this.loaded) return - - let _data = res.map((item, index) => { - item.key = index - item.$$uuid = item[config.setting.primaryKey] || '' - item.$Index = index + 1 + '' - return item - }) - - this.setState({data: _data}) - }) - } + this.initExec() } shouldComponentUpdate (nextProps, nextState) { @@ -158,6 +141,66 @@ this.timer && this.timer.stop() } + initExec = () => { + const { config } = this.state + + 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 + + let _data = res.map((item, index) => { + item.key = index + item.$$uuid = item[config.setting.primaryKey] || '' + item.$Index = index + 1 + '' + + return item + }) + + this.setState({data: _data}) + }) + } + } else { + if (!this.loaded) { + Api.getLCacheConfig(config.uuid, 0).then(res => { + if (!res || this.loaded) return + + let _data = res.map((item, index) => { + item.key = index + item.$$uuid = item[config.setting.primaryKey] || '' + item.$Index = index + 1 + '' + + return item + }) + + this.setState({data: _data}) + }) + } + + if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } else if (this.loaded) { + this.openModal() + } + } + } else if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } else if (this.loaded) { + this.openModal() + } + } + transferSyncData = (syncId) => { const { config } = this.state diff --git a/src/tabviews/custom/components/carousel/prop-card/index.jsx b/src/tabviews/custom/components/carousel/prop-card/index.jsx index e732b7a..ba2b928 100644 --- a/src/tabviews/custom/components/carousel/prop-card/index.jsx +++ b/src/tabviews/custom/components/carousel/prop-card/index.jsx @@ -49,6 +49,8 @@ } if (_config.wrap.datatype === 'dynamic') { + _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) || [] @@ -64,8 +66,6 @@ window.GLOB.SyncData.delete(_config.dataName) } - } else if (_config.wrap.datatype === 'static') { - this.loaded = true } _data.$$uuid = _data[_config.setting.primaryKey] || '' @@ -91,15 +91,7 @@ BID: BID || '', BData: BData || '', config: _config, - arr_field: _config.columns.map(col => col.field).join(','), - }, () => { - if (_config.wrap.datatype === 'dynamic' && config.setting.sync !== 'true' && _config.setting.onload === 'true') { - setTimeout(() => { - this.loadData() - }, _config.setting.delay || 0) - } else if (_config.wrap.display === 'modal' && _config.wrap.datatype === 'static') { - this.openModal() - } + arr_field: _config.columns.map(col => col.field).join(',') }) } @@ -126,16 +118,7 @@ }) } - if (config.$cache && !this.loaded) { - Api.getLCacheConfig(config.uuid).then(res => { - if (!res || this.loaded) return - - let _data = res[0] || {$$empty: true} - _data.$$uuid = _data[config.setting.primaryKey] || '' - - this.setState({data: _data}) - }) - } + this.initExec() } shouldComponentUpdate (nextProps, nextState) { @@ -156,6 +139,60 @@ this.timer && this.timer.stop() } + initExec = () => { + const { config } = this.state + + if (config.wrap.datatype === 'dynamic') { + 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 + + let _data = res[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 + + let _data = res[0] || {$$empty: true} + _data.$$uuid = _data[config.setting.primaryKey] || '' + + this.setState({data: _data}) + }) + } + + if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } else if (this.loaded) { + this.openModal() + } + } + } else if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } else if (this.loaded) { + this.openModal() + } + } else if (config.wrap.display === 'modal' && config.wrap.datatype === 'static') { + this.openModal() + } + } + transferSyncData = (syncId) => { const { config } = this.state diff --git a/src/tabviews/custom/components/chart/antv-G6/index.jsx b/src/tabviews/custom/components/chart/antv-G6/index.jsx index 51977d6..53d4d4f 100644 --- a/src/tabviews/custom/components/chart/antv-G6/index.jsx +++ b/src/tabviews/custom/components/chart/antv-G6/index.jsx @@ -831,18 +831,22 @@ BID = BData.$BID || '' } - if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { - this.data = window.GLOB.SyncData.get(_config.dataName) || [] + if (_config.setting.sync === 'true') { + _config.setting.onload = 'false' - if (_config.$cache) { - Api.writeCacheConfig(_config.uuid, fromJS(this.data).toJS()) + if (window.GLOB.SyncData.has(_config.dataName)) { + this.data = window.GLOB.SyncData.get(_config.dataName) || [] + + if (_config.$cache) { + Api.writeCacheConfig(_config.uuid, fromJS(this.data).toJS()) + } + + _config.setting.sync = 'false' + + this.loaded = true + + window.GLOB.SyncData.delete(_config.dataName) } - - _config.setting.sync = 'false' - - this.loaded = true - - window.GLOB.SyncData.delete(_config.dataName) } _config.plot.height = Utils.getHeight(_config.plot.height) @@ -858,17 +862,7 @@ BData: BData || '', arr_field: _config.columns.map(col => col.field).join(','), plot: _config.plot - }, () => { - if (config.setting.sync !== 'true' && config.setting.onload === 'true') { - setTimeout(() => { - this.loadData() - }, _config.setting.delay || 0) - } }) - - if (this.data.length > 0) { - this.handleData() - } let that = this @@ -1015,16 +1009,7 @@ MKEmitter.addListener('transferSyncData', this.transferSyncData) } - if (config.$cache && !this.loaded) { - Api.getLCacheConfig(config.uuid).then(res => { - if (!res || this.loaded) return - - if (!is(fromJS(this.data), fromJS(res))) { - this.data = res - this.handleData() - } - }) - } + this.initExec() } /** @@ -1040,6 +1025,54 @@ MKEmitter.removeListener('transferSyncData', this.transferSyncData) } + initExec = () => { + const { config } = this.state + + 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.data = res + this.handleData() + }) + } else { + this.handleData() + } + } else { + if (!this.loaded) { + Api.getLCacheConfig(config.uuid, 0).then(res => { + if (!res || this.loaded) return + + this.data = res + this.handleData() + }) + } + + if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } else if (this.loaded) { + this.handleData() + } + } + } else if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } else if (this.loaded) { + this.handleData() + } + } + transferSyncData = (syncId) => { const { config } = this.state diff --git a/src/tabviews/custom/components/chart/antv-bar-line/index.jsx b/src/tabviews/custom/components/chart/antv-bar-line/index.jsx index 184e810..48e1382 100644 --- a/src/tabviews/custom/components/chart/antv-bar-line/index.jsx +++ b/src/tabviews/custom/components/chart/antv-bar-line/index.jsx @@ -321,18 +321,22 @@ }) } - if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { - this.data = window.GLOB.SyncData.get(_config.dataName) || [] + if (_config.setting.sync === 'true') { + _config.setting.onload = 'false' - if (_config.$cache) { - Api.writeCacheConfig(_config.uuid, fromJS(this.data).toJS()) + if (window.GLOB.SyncData.has(_config.dataName)) { + this.data = window.GLOB.SyncData.get(_config.dataName) || [] + + if (_config.$cache) { + Api.writeCacheConfig(_config.uuid, fromJS(this.data).toJS()) + } + + _config.setting.sync = 'false' + + this.loaded = true + + window.GLOB.SyncData.delete(_config.dataName) } - - _config.setting.sync = 'false' - - this.loaded = true - - window.GLOB.SyncData.delete(_config.dataName) } this.setState({ @@ -344,17 +348,7 @@ plot: _config.plot, search: _config.$searches, transfield - }, () => { - if (config.setting.sync !== 'true' && config.setting.onload === 'true') { - setTimeout(() => { - this.loadData() - }, _config.setting.delay || 0) - } }) - - if (this.data.length > 0) { - this.handleData() - } } shouldComponentUpdate (nextProps, nextState) { @@ -384,14 +378,7 @@ }) } - if (config.$cache && !this.loaded) { - Api.getLCacheConfig(config.uuid).then(res => { - if (!res || this.loaded) return - - this.data = res - this.handleData() - }) - } + this.initExec() } /** @@ -411,6 +398,54 @@ this.timer && this.timer.stop() } + initExec = () => { + const { config } = this.state + + 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.data = res + this.handleData() + }) + } else { + this.handleData() + } + } else { + if (!this.loaded) { + Api.getLCacheConfig(config.uuid, 0).then(res => { + if (!res || this.loaded) return + + this.data = res + this.handleData() + }) + } + + if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } else if (this.loaded) { + this.handleData() + } + } + } else if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } else if (this.loaded) { + this.handleData() + } + } + transferSyncData = (syncId) => { const { config } = this.state diff --git a/src/tabviews/custom/components/chart/antv-dashboard/index.jsx b/src/tabviews/custom/components/chart/antv-dashboard/index.jsx index c8cec13..3bcdc9c 100644 --- a/src/tabviews/custom/components/chart/antv-dashboard/index.jsx +++ b/src/tabviews/custom/components/chart/antv-dashboard/index.jsx @@ -84,18 +84,22 @@ BID = BData.$BID || '' } - if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { - this.data = window.GLOB.SyncData.get(_config.dataName) || [] + if (_config.setting.sync === 'true') { + _config.setting.onload = 'false' - if (_config.$cache) { - Api.writeCacheConfig(_config.uuid, fromJS(this.data).toJS()) + if (window.GLOB.SyncData.has(_config.dataName)) { + this.data = window.GLOB.SyncData.get(_config.dataName) || [] + + if (_config.$cache) { + Api.writeCacheConfig(_config.uuid, fromJS(this.data).toJS()) + } + + _config.setting.sync = 'false' + + this.loaded = true + + window.GLOB.SyncData.delete(_config.dataName) } - - _config.setting.sync = 'false' - - this.loaded = true - - window.GLOB.SyncData.delete(_config.dataName) } if (_config.subtype !== 'ratioboard') { @@ -118,17 +122,7 @@ BID: BID || '', arr_field: _config.columns.map(col => col.field).join(','), plot: _config.plot - }, () => { - if (config.setting.sync !== 'true' && config.setting.onload === 'true') { - setTimeout(() => { - this.loadData() - }, _config.setting.delay || 0) - } }) - - if (config.setting.sync === 'true' && this.loaded) { - this.handleData() - } } shouldComponentUpdate (nextProps, nextState) { @@ -156,24 +150,7 @@ }) } - if (config.$cache && !this.loaded) { - Api.getLCacheConfig(config.uuid).then(res => { - if (!res || this.loaded) return - - let _data = null - if (config.subtype === 'ratioboard') { - _data = res - } else { - _data = res[0] || {} - _data.value = _data[config.plot.valueField] || 0 - } - - if (!is(fromJS(this.data), fromJS(_data))) { - this.data = _data - this.handleData() - } - }) - } + this.initExec() } /** @@ -191,6 +168,70 @@ this.timer && this.timer.stop() } + initExec = () => { + const { config } = this.state + + 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.data = res + + if (config.subtype !== 'ratioboard') { + if (Array.isArray(this.data)) { + this.data = this.data[0] || {} + } + this.data.value = this.data[config.plot.valueField] || 0 + } + + this.handleData() + }) + } else { + this.handleData() + } + } else { + if (!this.loaded) { + Api.getLCacheConfig(config.uuid, 0).then(res => { + if (!res || this.loaded) return + + this.data = res + + if (config.subtype !== 'ratioboard') { + if (Array.isArray(this.data)) { + this.data = this.data[0] || {} + } + this.data.value = this.data[config.plot.valueField] || 0 + } + + this.handleData() + }) + } + + if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } else if (this.loaded) { + this.handleData() + } + } + } else if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } else if (this.loaded) { + this.handleData() + } + } + transferSyncData = (syncId) => { const { config } = this.state diff --git a/src/tabviews/custom/components/chart/antv-pie/index.jsx b/src/tabviews/custom/components/chart/antv-pie/index.jsx index 836e2e4..a8756ad 100644 --- a/src/tabviews/custom/components/chart/antv-pie/index.jsx +++ b/src/tabviews/custom/components/chart/antv-pie/index.jsx @@ -69,18 +69,22 @@ _config.plot.$decimal = decimal - if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { - this.data = window.GLOB.SyncData.get(_config.dataName) || [] + if (_config.setting.sync === 'true') { + _config.setting.onload = 'false' - if (_config.$cache) { - Api.writeCacheConfig(_config.uuid, fromJS(this.data).toJS()) + if (window.GLOB.SyncData.has(_config.dataName)) { + this.data = window.GLOB.SyncData.get(_config.dataName) || [] + + if (_config.$cache) { + Api.writeCacheConfig(_config.uuid, fromJS(this.data).toJS()) + } + + _config.setting.sync = 'false' + + this.loaded = true + + window.GLOB.SyncData.delete(_config.dataName) } - - _config.setting.sync = 'false' - - this.loaded = true - - window.GLOB.SyncData.delete(_config.dataName) } this.setState({ @@ -90,17 +94,7 @@ plot: _config.plot, title: config.plot.title, search: _config.$searches - }, () => { - if (config.setting.sync !== 'true' && config.setting.onload === 'true') { - setTimeout(() => { - this.loadData() - }, _config.setting.delay || 0) - } }) - - if (this.data.length > 0) { - this.handleData() - } } shouldComponentUpdate (nextProps, nextState) { @@ -128,16 +122,7 @@ }) } - if (config.$cache && !this.loaded) { - Api.getLCacheConfig(config.uuid).then(res => { - if (!res || this.loaded) return - - if (!is(fromJS(this.data), fromJS(res))) { - this.data = res - this.handleData() - } - }) - } + this.initExec() } /** @@ -155,6 +140,54 @@ this.timer && this.timer.stop() } + initExec = () => { + const { config } = this.state + + 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.data = res + this.handleData() + }) + } else { + this.handleData() + } + } else { + if (!this.loaded) { + Api.getLCacheConfig(config.uuid, 0).then(res => { + if (!res || this.loaded) return + + this.data = res + this.handleData() + }) + } + + if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } else if (this.loaded) { + this.handleData() + } + } + } else if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } else if (this.loaded) { + this.handleData() + } + } + transferSyncData = (syncId) => { const { config } = this.state diff --git a/src/tabviews/custom/components/chart/antv-scatter/index.jsx b/src/tabviews/custom/components/chart/antv-scatter/index.jsx index bc44afb..5eeef74 100644 --- a/src/tabviews/custom/components/chart/antv-scatter/index.jsx +++ b/src/tabviews/custom/components/chart/antv-scatter/index.jsx @@ -61,18 +61,22 @@ _config.style.minHeight = _config.style.minHeight + 45 } - if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { - this.data = window.GLOB.SyncData.get(_config.dataName) || [] + if (_config.setting.sync === 'true') { + _config.setting.onload = 'false' - if (_config.$cache) { - Api.writeCacheConfig(_config.uuid, fromJS(this.data).toJS()) + if (window.GLOB.SyncData.has(_config.dataName)) { + this.data = window.GLOB.SyncData.get(_config.dataName) || [] + + if (_config.$cache) { + Api.writeCacheConfig(_config.uuid, fromJS(this.data).toJS()) + } + + _config.setting.sync = 'false' + + this.loaded = true + + window.GLOB.SyncData.delete(_config.dataName) } - - _config.setting.sync = 'false' - - this.loaded = true - - window.GLOB.SyncData.delete(_config.dataName) } this.setState({ @@ -82,17 +86,7 @@ arr_field: _config.columns.map(col => col.field).join(','), plot: _config.plot, search: _config.$searches - }, () => { - if (config.setting.sync !== 'true' && config.setting.onload === 'true') { - setTimeout(() => { - this.loadData() - }, _config.setting.delay || 0) - } }) - - if (this.data.length > 0) { - this.handleData() - } } shouldComponentUpdate (nextProps, nextState) { @@ -122,18 +116,7 @@ }) } - if (config.$cache && !this.loaded) { - Api.getLCacheConfig(config.uuid).then(res => { - if (!res || this.loaded) return - - if (!is(fromJS(this.data), fromJS(res))) { - this.data = res - this.handleData() - } - - this.setState({empty: res.length > 0}) - }) - } + this.initExec() } /** @@ -153,6 +136,58 @@ this.timer && this.timer.stop() } + initExec = () => { + const { config } = this.state + + 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.data = res + this.handleData() + + this.setState({empty: res.length === 0}) + }) + } else { + this.handleData() + } + } else { + if (!this.loaded) { + Api.getLCacheConfig(config.uuid, 0).then(res => { + if (!res || this.loaded) return + + this.data = res + this.handleData() + + this.setState({empty: res.length === 0}) + }) + } + + if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } else if (this.loaded) { + this.handleData() + } + } + } else if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } else if (this.loaded) { + this.handleData() + } + } + transferSyncData = (syncId) => { const { config } = this.state diff --git a/src/tabviews/custom/components/chart/custom-chart/index.jsx b/src/tabviews/custom/components/chart/custom-chart/index.jsx index fece466..25c9741 100644 --- a/src/tabviews/custom/components/chart/custom-chart/index.jsx +++ b/src/tabviews/custom/components/chart/custom-chart/index.jsx @@ -50,18 +50,22 @@ _config.plot.height = Utils.getHeight(_config.plot.height) _config.style.height = 'auto' - if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { - this.data = window.GLOB.SyncData.get(_config.dataName) || [] + if (_config.setting.sync === 'true') { + _config.setting.onload = 'false' - if (_config.$cache) { - Api.writeCacheConfig(_config.uuid, fromJS(this.data).toJS()) + if (window.GLOB.SyncData.has(_config.dataName)) { + this.data = window.GLOB.SyncData.get(_config.dataName) || [] + + if (_config.$cache) { + Api.writeCacheConfig(_config.uuid, fromJS(this.data).toJS()) + } + + _config.setting.sync = 'false' + + this.loaded = true + + window.GLOB.SyncData.delete(_config.dataName) } - - _config.setting.sync = 'false' - - this.loaded = true - - window.GLOB.SyncData.delete(_config.dataName) } this.setState({ @@ -71,17 +75,7 @@ arr_field: _config.columns.map(col => col.field).join(','), plot: _config.plot, search: _config.$searches - }, () => { - if (config.setting.sync !== 'true' && config.setting.onload === 'true') { - setTimeout(() => { - this.loadData() - }, _config.setting.delay || 0) - } }) - - if (this.data.length > 0) { - this.handleData() - } } shouldComponentUpdate (nextProps, nextState) { @@ -111,17 +105,7 @@ }) } - if (config.$cache && !this.loaded) { - Api.getLCacheConfig(config.uuid).then(res => { - if (!res || this.loaded) return - - if (!is(fromJS(this.data), fromJS(res))) { - this.data = res - this.handleData() - } - this.setState({empty: res.length > 0}) - }) - } + this.initExec() } /** @@ -141,6 +125,58 @@ this.timer && this.timer.stop() } + initExec = () => { + const { config } = this.state + + 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.data = res + this.handleData() + + this.setState({empty: res.length === 0}) + }) + } else { + this.handleData() + } + } else { + if (!this.loaded) { + Api.getLCacheConfig(config.uuid, 0).then(res => { + if (!res || this.loaded) return + + this.data = res + this.handleData() + + this.setState({empty: res.length === 0}) + }) + } + + if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } else if (this.loaded) { + this.handleData() + } + } + } else if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } else if (this.loaded) { + this.handleData() + } + } + transferSyncData = (syncId) => { const { config } = this.state diff --git a/src/tabviews/custom/components/code/sand-box/index.jsx b/src/tabviews/custom/components/code/sand-box/index.jsx index 0a9b6a3..9027a05 100644 --- a/src/tabviews/custom/components/code/sand-box/index.jsx +++ b/src/tabviews/custom/components/code/sand-box/index.jsx @@ -42,6 +42,8 @@ } 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) || [] @@ -55,8 +57,6 @@ window.GLOB.SyncData.delete(_config.dataName) } - } else { - this.loaded = true } if (_config.css) { @@ -73,14 +73,7 @@ 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(',') }) } @@ -97,15 +90,7 @@ 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) { @@ -121,6 +106,60 @@ 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 diff --git a/src/tabviews/custom/components/editor/braft-editor/index.jsx b/src/tabviews/custom/components/editor/braft-editor/index.jsx index 38f0382..ccef7cc 100644 --- a/src/tabviews/custom/components/editor/braft-editor/index.jsx +++ b/src/tabviews/custom/components/editor/braft-editor/index.jsx @@ -43,6 +43,8 @@ } if (_config.wrap.datatype === 'dynamic') { + _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) || [] _data = _data[0] || {$$empty: true} @@ -62,12 +64,6 @@ BID: BID || '', config: _config, arr_field: _config.columns.map(col => col.field).join(','), - }, () => { - if (_config.wrap.datatype === 'dynamic' && config.setting.sync !== 'true' && _config.setting.onload === 'true') { - setTimeout(() => { - this.loadData() - }, _config.setting.delay || 0) - } }) } @@ -88,6 +84,8 @@ if (config.wrap.datatype === 'public') { MKEmitter.addListener('mkPublicData', this.mkPublicData) } + + this.initExec() } shouldComponentUpdate (nextProps, nextState) { @@ -105,6 +103,16 @@ MKEmitter.removeListener('transferSyncData', this.transferSyncData) } + initExec = () => { + const { config } = this.state + + if (config.wrap.datatype === 'dynamic' && config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } + } + transferSyncData = (syncId) => { const { config } = this.state diff --git a/src/tabviews/custom/components/share/tabtransfer/index.jsx b/src/tabviews/custom/components/share/tabtransfer/index.jsx index 7c061a0..9157f43 100644 --- a/src/tabviews/custom/components/share/tabtransfer/index.jsx +++ b/src/tabviews/custom/components/share/tabtransfer/index.jsx @@ -127,6 +127,18 @@ let param = getStructuredParams(params, config, BID) + if (config.$cache && config.$time) { + Api.getLCacheConfig(params[0].uuid, config.$time).then(res => { + if (!res) { + this.getMainData(param, params, config.uuid) + } + }) + } else { + this.getMainData(param, params, config.uuid) + } + } + + getMainData = (param, params, tabId) => { Api.genericInterface(param).then(result => { if (result.status) { if (result.message) { @@ -151,9 +163,9 @@ window.GLOB.SyncData.set(item.name, _data) }) - MKEmitter.emit('transferSyncData', config.uuid) + MKEmitter.emit('transferSyncData', tabId) } else { - MKEmitter.emit('transferSyncData', config.uuid) + MKEmitter.emit('transferSyncData', tabId) if (!result.message) return if (result.ErrCode === 'N') { diff --git a/src/tabviews/custom/components/table/normal-table/index.jsx b/src/tabviews/custom/components/table/normal-table/index.jsx index 59e8a1f..262deee 100644 --- a/src/tabviews/custom/components/table/normal-table/index.jsx +++ b/src/tabviews/custom/components/table/normal-table/index.jsx @@ -81,52 +81,56 @@ setting.orisel = true } - if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { - _data = window.GLOB.SyncData.get(_config.dataName) || [] + if (_config.setting.sync === 'true') { + _config.setting.onload = 'false' - if (_config.$cache) { - Api.writeCacheConfig(_config.uuid, fromJS(_data).toJS()) - } - - _config.setting.sync = 'false' - - _data = _data.map((item, index) => { - item.key = index - item.$$uuid = item[_config.setting.primaryKey] || '' - item.$$key = '' + item.key + item.$$uuid - item.$$BID = BID || '' - item.$$BData = BData || '' - item.$Index = index + 1 + '' - - if (_config.absFields) { - _config.absFields.forEach(f => { - if (!isNaN(item[f])) { - item[f] = Math.abs(item[f]) - } - }) + if (window.GLOB.SyncData.has(_config.dataName)) { + _data = window.GLOB.SyncData.get(_config.dataName) || [] + + if (_config.$cache) { + Api.writeCacheConfig(_config.uuid, fromJS(_data).toJS()) } - - if (setting.controlField) { - if (setting.controlVal.includes(item[setting.controlField] + '')) { - item.$disabled = true + + _config.setting.sync = 'false' + + _data = _data.map((item, index) => { + item.key = index + item.$$uuid = item[_config.setting.primaryKey] || '' + item.$$key = '' + item.key + item.$$uuid + item.$$BID = BID || '' + item.$$BData = BData || '' + item.$Index = index + 1 + '' + + if (_config.absFields) { + _config.absFields.forEach(f => { + if (!isNaN(item[f])) { + item[f] = Math.abs(item[f]) + } + }) + } + + if (setting.controlField) { + if (setting.controlVal.includes(item[setting.controlField] + '')) { + item.$disabled = true + } + } + + return item + }) + + if (setting.selected !== 'false' && _data.length > 0) { + setTimeout(() => { + MKEmitter.emit('mkCheckTopLine', _config.uuid, '', setting.selected) + }, 200) + if (setting.selected === 'init') { + setting.selected = 'false' } } - - return item - }) - - if (setting.selected !== 'false' && _data.length > 0) { - setTimeout(() => { - MKEmitter.emit('mkCheckTopLine', _config.uuid, '', setting.selected) - }, 200) - if (setting.selected === 'init') { - setting.selected = 'false' - } + + this.loaded = true + + window.GLOB.SyncData.delete(_config.dataName) } - - this.loaded = true - - window.GLOB.SyncData.delete(_config.dataName) } if (_config.wrap.collapse === 'true') { @@ -147,16 +151,145 @@ columns: _config.cols, arr_field: _config.columns.map(col => col.field).join(','), search: _config.$searches - }, () => { - if (config.setting.sync !== 'true' && _config.setting.onload === 'true') { - setTimeout(() => { - this.loadmaindata() - this.getStatFieldsValue() - }, _config.setting.delay || 0) - } else if (_config.setting.onload === 'true') { - this.getStatFieldsValue() - } }) + } + + shouldComponentUpdate (nextProps, nextState) { + return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) + } + + componentDidMount () { + const { config } = this.state + + MKEmitter.addListener('reloadData', this.reloadData) + MKEmitter.addListener('refreshLineData', this.refreshLineData) + MKEmitter.addListener('resetSelectLine', this.resetParentParam) + MKEmitter.addListener('queryModuleParam', this.queryModuleParam) + MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) + + if (config.setting.useMSearch) { + MKEmitter.addListener('searchRefresh', this.searchRefresh) + } + + if (config.setting.sync === 'true') { + MKEmitter.addListener('transferSyncData', this.transferSyncData) + } + + if (config.timer) { + this.timer = new TimerTask() + this.timer.init(config.uuid, config.timer, config.timerRepeats, () => { + this.setState({ + pageIndex: 1 + }, () => { + this.loadmaindata(true, 'true', '', 'timer') + this.getStatFieldsValue() + }) + }) + } + + this.initExec() + } + + /** + * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊锛屾竻闄ゅ揩鎹烽敭璁剧疆 + */ + componentWillUnmount () { + this.setState = () => { + return + } + MKEmitter.removeListener('reloadData', this.reloadData) + MKEmitter.removeListener('searchRefresh', this.searchRefresh) + MKEmitter.removeListener('refreshLineData', this.refreshLineData) + MKEmitter.removeListener('resetSelectLine', this.resetParentParam) + MKEmitter.removeListener('transferSyncData', this.transferSyncData) + MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) + MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) + + this.timer && this.timer.stop() + } + + initExec = () => { + const { config, setting } = this.state + + if (config.$cache) { + if (config.$time && !setting.laypage) { + if (!this.loaded) { + Api.getLCacheConfig(config.uuid, config.$time).then(res => { + if (!res && config.setting.onload === 'true') { + setTimeout(() => { + this.loadmaindata() + }, config.setting.delay || 0) + } + + if (!res || this.loaded) return + + this.setState({data: res.map((item, index) => { + item.key = index + item.$$uuid = item[config.setting.primaryKey] || '' + item.$$key = '' + item.key + item.$$uuid + item.$Index = index + 1 + '' + + if (config.absFields) { + config.absFields.forEach(f => { + if (!isNaN(item[f])) { + item[f] = Math.abs(item[f]) + } + }) + } + + if (setting.controlField) { + if (setting.controlVal.includes(item[setting.controlField] + '')) { + item.$disabled = true + } + } + + return item + })}) + }) + } + } else { + if (!this.loaded) { + Api.getLCacheConfig(config.uuid, 0).then(res => { + if (!res || this.loaded) return + + this.setState({data: res.map((item, index) => { + item.key = index + item.$$uuid = item[config.setting.primaryKey] || '' + item.$$key = '' + item.key + item.$$uuid + item.$Index = index + 1 + '' + + if (config.absFields) { + config.absFields.forEach(f => { + if (!isNaN(item[f])) { + item[f] = Math.abs(item[f]) + } + }) + } + + if (setting.controlField) { + if (setting.controlVal.includes(item[setting.controlField] + '')) { + item.$disabled = true + } + } + + return item + })}) + }) + } + + if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadmaindata() + this.getStatFieldsValue() + }, config.setting.delay || 0) + } + } + } else if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadmaindata() + this.getStatFieldsValue() + }, config.setting.delay || 0) + } } transferSyncData = (syncId) => { @@ -702,87 +835,6 @@ this.setState({pageIndex: 1}, () => { this.reloadtable() }) - } - - shouldComponentUpdate (nextProps, nextState) { - return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) - } - - componentDidMount () { - const { config, setting } = this.state - - MKEmitter.addListener('reloadData', this.reloadData) - MKEmitter.addListener('refreshLineData', this.refreshLineData) - MKEmitter.addListener('resetSelectLine', this.resetParentParam) - MKEmitter.addListener('queryModuleParam', this.queryModuleParam) - MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) - - if (config.setting.useMSearch) { - MKEmitter.addListener('searchRefresh', this.searchRefresh) - } - - if (config.setting.sync === 'true') { - MKEmitter.addListener('transferSyncData', this.transferSyncData) - } - - if (config.timer) { - this.timer = new TimerTask() - this.timer.init(config.uuid, config.timer, config.timerRepeats, () => { - this.setState({ - pageIndex: 1 - }, () => { - this.loadmaindata(true, 'true', '', 'timer') - this.getStatFieldsValue() - }) - }) - } - - if (config.$cache && !this.loaded) { - Api.getLCacheConfig(config.uuid).then(res => { - if (!res || this.loaded) return - - this.setState({data: res.map((item, index) => { - item.key = index - item.$$uuid = item[config.setting.primaryKey] || '' - item.$$key = '' + item.key + item.$$uuid - item.$Index = index + 1 + '' - - if (config.absFields) { - config.absFields.forEach(f => { - if (!isNaN(item[f])) { - item[f] = Math.abs(item[f]) - } - }) - } - - if (setting.controlField) { - if (setting.controlVal.includes(item[setting.controlField] + '')) { - item.$disabled = true - } - } - - return item - })}) - }) - } - } - - /** - * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊锛屾竻闄ゅ揩鎹烽敭璁剧疆 - */ - componentWillUnmount () { - this.setState = () => { - return - } - MKEmitter.removeListener('reloadData', this.reloadData) - MKEmitter.removeListener('searchRefresh', this.searchRefresh) - MKEmitter.removeListener('refreshLineData', this.refreshLineData) - MKEmitter.removeListener('resetSelectLine', this.resetParentParam) - MKEmitter.removeListener('transferSyncData', this.transferSyncData) - MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) - MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) - - this.timer && this.timer.stop() } render() { diff --git a/src/tabviews/custom/components/timeline/normal-timeline/index.jsx b/src/tabviews/custom/components/timeline/normal-timeline/index.jsx index 0d92eb1..df3dd7f 100644 --- a/src/tabviews/custom/components/timeline/normal-timeline/index.jsx +++ b/src/tabviews/custom/components/timeline/normal-timeline/index.jsx @@ -52,27 +52,31 @@ BID = BData.$BID || '' } - if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { - _data = window.GLOB.SyncData.get(_config.dataName) || [] + if (_config.setting.sync === 'true') { + _config.setting.onload = 'false' - if (_config.$cache) { - Api.writeCacheConfig(_config.uuid, fromJS(_data).toJS()) + if (window.GLOB.SyncData.has(_config.dataName)) { + _data = window.GLOB.SyncData.get(_config.dataName) || [] + + if (_config.$cache) { + Api.writeCacheConfig(_config.uuid, fromJS(_data).toJS()) + } + + _config.setting.sync = 'false' + + _data = _data.map((item, index) => { + item.key = index + item.$$uuid = item[_config.setting.primaryKey] || '' + item.$$BID = BID || '' + item.$$BData = BData || '' + item.$Index = index + 1 + '' + return item + }) + + this.loaded = true + + window.GLOB.SyncData.delete(_config.dataName) } - - _config.setting.sync = 'false' - - _data = _data.map((item, index) => { - item.key = index - item.$$uuid = item[_config.setting.primaryKey] || '' - item.$$BID = BID || '' - item.$$BData = BData || '' - item.$Index = index + 1 + '' - return item - }) - - this.loaded = true - - window.GLOB.SyncData.delete(_config.dataName) } _config.search = [] @@ -95,13 +99,7 @@ BData: BData || '', data: _data, config: _config, - arr_field: _config.columns.map(col => col.field).join(','), - }, () => { - if (config.setting.sync !== 'true' && _config.setting.onload === 'true') { - setTimeout(() => { - this.loadData() - }, _config.setting.delay || 0) - } + arr_field: _config.columns.map(col => col.field).join(',') }) } @@ -129,19 +127,7 @@ }) } - if (config.$cache && !this.loaded) { - Api.getLCacheConfig(config.uuid).then(res => { - if (!res || this.loaded) return - - this.setState({data: res.map((item, index) => { - item.key = index - item.$$uuid = item[config.setting.primaryKey] || '' - item.$Index = index + 1 + '' - - return item - })}) - }) - } + this.initExec() } shouldComponentUpdate (nextProps, nextState) { @@ -163,6 +149,58 @@ this.timer && this.timer.stop() } + initExec = () => { + const { config } = this.state + + 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.map((item, index) => { + item.key = index + item.$$uuid = item[config.setting.primaryKey] || '' + item.$Index = index + 1 + '' + + return item + })}) + }) + } + } else { + if (!this.loaded) { + Api.getLCacheConfig(config.uuid, 0).then(res => { + if (!res || this.loaded) return + + this.setState({data: res.map((item, index) => { + item.key = index + item.$$uuid = item[config.setting.primaryKey] || '' + item.$Index = index + 1 + '' + + return item + })}) + }) + } + + if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } + } + } else if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } + } + transferSyncData = (syncId) => { const { config } = this.state diff --git a/src/tabviews/custom/components/tree/antd-tree/index.jsx b/src/tabviews/custom/components/tree/antd-tree/index.jsx index 9c9b744..3046ea7 100644 --- a/src/tabviews/custom/components/tree/antd-tree/index.jsx +++ b/src/tabviews/custom/components/tree/antd-tree/index.jsx @@ -53,18 +53,22 @@ BID = BData.$BID || '' } - if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { - _data = window.GLOB.SyncData.get(_config.dataName) || [] + if (_config.setting.sync === 'true') { + _config.setting.onload = 'false' - if (_config.$cache) { - Api.writeCacheConfig(_config.uuid, fromJS(_data).toJS()) + if (window.GLOB.SyncData.has(_config.dataName)) { + _data = window.GLOB.SyncData.get(_config.dataName) || [] + + if (_config.$cache) { + Api.writeCacheConfig(_config.uuid, fromJS(_data).toJS()) + } + + _config.setting.sync = 'false' + + this.loaded = true + + window.GLOB.SyncData.delete(_config.dataName) } - - _config.setting.sync = 'false' - - this.loaded = true - - window.GLOB.SyncData.delete(_config.dataName) } _config.wrap.contentHeight = config.wrap.title || config.wrap.searchable === 'true' ? 'calc(100% - 45px)' : '100%' @@ -74,15 +78,7 @@ config: _config, data: _data, BID: BID || '', - arr_field: _config.columns.map(col => col.field).join(','), - }, () => { - if (config.setting.sync !== 'true' && config.setting.onload === 'true') { - setTimeout(() => { - this.loadData() - }, config.setting.delay || 0) - } else if (config.setting.sync === 'true' && _data) { - this.handleData() - } + arr_field: _config.columns.map(col => col.field).join(',') }) } @@ -113,15 +109,7 @@ }) } - if (config.$cache && !this.loaded) { - Api.getLCacheConfig(config.uuid).then(res => { - if (!res || this.loaded) return - - this.setState({data: res}, () => { - this.handleData() - }) - }) - } + this.initExec() } /** @@ -141,6 +129,56 @@ this.timer && this.timer.stop() } + initExec = () => { + const { config } = this.state + + 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.handleData() + }) + }) + } else { + this.handleData() + } + } else { + if (!this.loaded) { + Api.getLCacheConfig(config.uuid, 0).then(res => { + if (!res || this.loaded) return + + this.setState({data: res}, () => { + this.handleData() + }) + }) + } + + if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } else if (this.loaded) { + this.handleData() + } + } + } else if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } else if (this.loaded) { + this.handleData() + } + } + transferSyncData = (syncId) => { const { config } = this.state diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx index 83bf8a9..df5b969 100644 --- a/src/tabviews/custom/index.jsx +++ b/src/tabviews/custom/index.jsx @@ -204,11 +204,12 @@ } config.$cache = config.cacheLocal === 'true' + config.$time = config.localCacheTime || 0 let initInters = [] config.interfaces = this.formatInterSetting(config.interfaces, regs, MenuID, initInters) - config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, balMap, skip, param, MenuID, config.interfaces, popview, config.$cache, config.MenuName, MenuID, MenuID) + config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, balMap, skip, param, MenuID, config.interfaces, popview, config.$cache, config.$time, config.MenuName, MenuID, MenuID) let params = [] let BID = param.$BID || '' @@ -342,10 +343,11 @@ } } - filterComponent = (components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, popview, cache, MenuName, searchId, syncId) => { + filterComponent = (components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, popview, cache, time, MenuName, searchId, syncId) => { return components.filter(item => { item.$pageId = pageId item.$cache = cache + item.$time = time item.$searchId = searchId item.$syncId = syncId @@ -439,6 +441,8 @@ item.subtabs = item.subtabs.map(tab => { tab.$pageId = pageId + tab.$cache = cache + tab.$time = time let _searchId = searchId @@ -451,7 +455,7 @@ } }) - tab.components = this.filterComponent(tab.components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, popview, cache, MenuName, _searchId, tab.uuid) + tab.components = this.filterComponent(tab.components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, popview, cache, time, MenuName, _searchId, tab.uuid) return tab }) @@ -464,7 +468,7 @@ return false } - item.components = this.filterComponent(item.components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, popview, cache, MenuName, searchId, syncId) + item.components = this.filterComponent(item.components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, popview, cache, time, MenuName, searchId, syncId) return true } else if (['pie', 'bar', 'line', 'dashboard', 'scatter', 'chart', 'antvG6', 'antvX6'].includes(item.type)) { @@ -1125,6 +1129,22 @@ this.setState({loading: true, loadingview: false}) + if (config.$cache && config.$time) { + Api.getLCacheConfig(params[0].uuid, config.$time).then(res => { + if (!res) { + this.getMainData(param, params, config.MenuID) + } else { + this.setState({ + loading: false + }) + } + }) + } else { + this.getMainData(param, params, config.MenuID) + } + } + + getMainData = (param, params, MenuID) => { Api.genericInterface(param).then(result => { this.setState({ loading: false @@ -1153,9 +1173,9 @@ window.GLOB.SyncData.set(item.name, _data) }) - MKEmitter.emit('transferSyncData', config.MenuID) + MKEmitter.emit('transferSyncData', MenuID) } else { - MKEmitter.emit('transferSyncData', config.MenuID) + MKEmitter.emit('transferSyncData', MenuID) if (!result.message) return if (result.ErrCode === 'N') { diff --git a/src/tabviews/custom/popview/index.jsx b/src/tabviews/custom/popview/index.jsx index 74ada91..9b2324c 100644 --- a/src/tabviews/custom/popview/index.jsx +++ b/src/tabviews/custom/popview/index.jsx @@ -131,9 +131,7 @@ }) } - config.$cache = config.cacheLocal === 'true' - - config.components = this.filterComponent(config.components, roleId, balMap, param, Tab, config.$cache, Tab.uuid, Tab.uuid) + config.components = this.filterComponent(config.components, roleId, balMap, param, Tab, Tab.uuid, Tab.uuid) // 鑾峰彇涓绘悳绱㈡潯浠� config.components.forEach(component => { @@ -160,15 +158,8 @@ let params = [] let BID = param.$BID || '' - let inherit = {} - if (config.cacheUseful === 'true') { // 缂撳瓨缁ф壙 - inherit.cacheUseful = config.cacheUseful - inherit.timeUnit = config.timeUnit - inherit.cacheTime = config.cacheTime - } - - config.components = this.formatSetting(config.components, params, inherit, regs, balMap) + config.components = this.formatSetting(config.components, params, regs, balMap) if ([...balMap.keys()].length > 0) { config.components = this.filterBalcony(config.components, balMap) @@ -184,10 +175,9 @@ }) } - filterComponent = (components, roleId, balMap, urlparam, Tab, cache, searchId, syncId) => { + filterComponent = (components, roleId, balMap, urlparam, Tab, searchId, syncId) => { return components.filter(item => { item.$pageId = Tab.uuid - item.$cache = cache item.$searchId = searchId item.$syncId = syncId @@ -293,7 +283,7 @@ } }) - tab.components = this.filterComponent(tab.components, roleId, balMap, urlparam, Tab, cache, _searchId, tab.uuid) + tab.components = this.filterComponent(tab.components, roleId, balMap, urlparam, Tab, _searchId, tab.uuid) return tab }) @@ -306,7 +296,7 @@ return false } - item.components = this.filterComponent(item.components, roleId, balMap, urlparam, Tab, cache, searchId, syncId) + item.components = this.filterComponent(item.components, roleId, balMap, urlparam, Tab, searchId, syncId) return true } else if (['pie', 'bar', 'line', 'dashboard', 'scatter', 'chart'].includes(item.type)) { @@ -703,18 +693,17 @@ } // 鏍煎紡鍖栭粯璁よ缃� - formatSetting = (components, params, inherit, regs, balMap) => { + formatSetting = (components, params, regs, balMap) => { let delay = 20 return components.map(component => { if (component.type === 'tabs') { component.subtabs = component.subtabs.map(tab => { - tab.components = this.formatSetting(tab.components, null, null, inherit, regs, balMap) - tab = {...tab, ...inherit} + tab.components = this.formatSetting(tab.components, null, regs, balMap) return tab }) return component } else if (component.type === 'group') { - component.components = this.formatSetting(component.components, params, null, regs, balMap) + component.components = this.formatSetting(component.components, params, regs, balMap) return component } else if (component.wrap && component.wrap.datatype === 'public') { component.setting.useMSearch = false @@ -1135,7 +1124,7 @@ return ( <div className={'pop-page-wrap ' + (loading ? 'loading' : '')} style={config ? config.style : null}> - {loading && !config.$cache ? <Spin className="view-spin" size="large" /> : null} + {loading ? <Spin className="view-spin" size="large" /> : null} <Row className="component-wrap">{this.getComponents()}</Row> {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} </div> diff --git a/src/views/menudesign/homeform/index.jsx b/src/views/menudesign/homeform/index.jsx index 4454c32..2b253e7 100644 --- a/src/views/menudesign/homeform/index.jsx +++ b/src/views/menudesign/homeform/index.jsx @@ -99,20 +99,13 @@ selectChange = (key, value) => { const { config } = this.props - if (key === 'cacheUseful') { - this.props.updateConfig({...config, cacheUseful: value}) - } else if (key === 'timeUnit') { - this.props.updateConfig({...config, timeUnit: value}) - } else if (key === 'cacheLocal') { - this.props.updateConfig({...config, cacheLocal: value}) + if (key === 'cacheTime' || key === 'localCacheTime') { + if (typeof(value) !== 'number') { + value = '' + } } - } - - changeCacheDay = (val) => { - if (typeof(val) !== 'number') { - val = '' - } - this.props.updateConfig({...this.props.config, cacheTime: val}) + + this.props.updateConfig({...config, [key]: value}) } render() { @@ -149,6 +142,20 @@ )} </Form.Item> </Col> + {config.cacheLocal === 'true' ? <Col span={24}> + <Form.Item label={ + <Tooltip placement="topLeft" title="璁剧疆鏈湴缂撳瓨鏃堕暱鍚庯紝鍦ㄧ紦瀛樻湡闄愬唴涓嶅悜鍚庡彴璇锋眰鏁版嵁锛屾椂闀挎渶澶т负5澶╋紙鍗�7200鍒嗛挓锛夈�傛敞锛氭椂闀夸负绌烘椂缂撳瓨鏁版嵁鍙敤浜庨〉闈㈠揩閫熷憟鐜帮紝涓嶅奖鍝嶆帴鍙h姹傘��"> + <QuestionCircleOutlined className="mk-form-tip" /> + 鏃堕暱(鍒�) + </Tooltip> + }> + {getFieldDecorator('localCacheTime', { + initialValue: config.localCacheTime + })( + <InputNumber min={1} max={7200} precision={0} onChange={(val) => {this.selectChange('localCacheTime', val)}}/> + )} + </Form.Item> + </Col> : null} <Col span={24}> <Form.Item label={ <Tooltip placement="topLeft" title="瀵逛簬涓嶇粡甯告�у彉鍔ㄧ殑淇℃伅锛岀紦瀛樻暟鎹湁鍔╀簬鎻愰珮鏌ヨ鏁堢巼銆�"> @@ -190,7 +197,7 @@ } ] })( - <InputNumber min={1} max={config.timeUnit === 'day' ? 7 : (config.timeUnit === 'hour' ? 23 : 59)} precision={0} onChange={this.changeCacheDay}/> + <InputNumber min={1} max={config.timeUnit === 'day' ? 7 : (config.timeUnit === 'hour' ? 23 : 59)} precision={0} onChange={(val) => {this.selectChange('cacheTime', val)}}/> )} </Form.Item> </Col> : null} diff --git a/src/views/menudesign/menuform/index.jsx b/src/views/menudesign/menuform/index.jsx index f7dd467..a1c9519 100644 --- a/src/views/menudesign/menuform/index.jsx +++ b/src/views/menudesign/menuform/index.jsx @@ -194,7 +194,7 @@ this.props.updateConfig({...config, fstMenuId: value, parentId: _id}) }) } else { - if (key === 'cacheTime' || key === 'minWidth') { + if (key === 'cacheTime' || key === 'minWidth' || key === 'localCacheTime') { if (typeof(value) !== 'number') { value = '' } @@ -337,6 +337,20 @@ )} </Form.Item> </Col> + {config.cacheLocal === 'true' ? <Col span={24}> + <Form.Item label={ + <Tooltip placement="topLeft" title="璁剧疆鏈湴缂撳瓨鏃堕暱鍚庯紝鍦ㄧ紦瀛樻湡闄愬唴涓嶅悜鍚庡彴璇锋眰鏁版嵁锛屾椂闀挎渶澶т负5澶╋紙鍗�7200鍒嗛挓锛夈�傛敞锛氭椂闀夸负绌烘椂缂撳瓨鏁版嵁鍙敤浜庨〉闈㈠揩閫熷憟鐜帮紝涓嶅奖鍝嶆帴鍙h姹傘��"> + <QuestionCircleOutlined className="mk-form-tip" /> + 鏃堕暱(鍒�) + </Tooltip> + }> + {getFieldDecorator('localCacheTime', { + initialValue: config.localCacheTime + })( + <InputNumber min={1} max={7200} precision={0} onChange={(val) => {this.selectChange('localCacheTime', val)}}/> + )} + </Form.Item> + </Col> : null} <Col span={24}> <Form.Item label={ <Tooltip placement="topLeft" title="瀵逛簬涓嶇粡甯告�у彉鍔ㄧ殑淇℃伅锛岀紦瀛樻暟鎹湁鍔╀簬鎻愰珮鏌ヨ鏁堢巼銆�"> diff --git a/src/views/menudesign/popview/index.jsx b/src/views/menudesign/popview/index.jsx index 8a783ea..d5eccea 100644 --- a/src/views/menudesign/popview/index.jsx +++ b/src/views/menudesign/popview/index.jsx @@ -12,7 +12,6 @@ const { Panel } = Collapse const { confirm } = Modal -const MenuForm = asyncComponent(() => import('./menuform')) const SourceWrap = asyncComponent(() => import('@/menu/modulesource')) const Modulecell = asyncComponent(() => import('@/menu/modulecell')) const MenuShell = asyncComponent(() => import('@/menu/menushell')) @@ -265,8 +264,6 @@ <Collapse accordion defaultActiveKey="basedata" bordered={false}> {/* 鍩烘湰淇℃伅 */} <Panel header="鍩烘湰淇℃伅" key="basedata"> - {/* 鑿滃崟淇℃伅 */} - <MenuForm config={config} updateConfig={this.updateConfig}/> {/* 琛ㄥ悕娣诲姞 */} <TableComponent config={config} updatetable={this.updatetable}/> </Panel> diff --git a/src/views/menudesign/popview/menuform/index.jsx b/src/views/menudesign/popview/menuform/index.jsx deleted file mode 100644 index e84a5af..0000000 --- a/src/views/menudesign/popview/menuform/index.jsx +++ /dev/null @@ -1,118 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { Form, Row, Col, Radio, Tooltip, InputNumber } from 'antd' -import { QuestionCircleOutlined } from '@ant-design/icons' - -// import './index.scss' - -class CustomMenuForm extends Component { - static propTpyes = { - config: PropTypes.object, - updateConfig: PropTypes.func - } - - changeCacheDay = (val) => { - if (typeof(val) !== 'number') { - val = '' - } - this.props.updateConfig({...this.props.config, cacheTime: val}) - } - - selectChange = (key, value) => { - const { config } = this.props - - if (key === 'cacheUseful') { - this.props.updateConfig({...config, cacheUseful: value}) - } else if (key === 'timeUnit') { - this.props.updateConfig({...config, timeUnit: value}) - } else if (key === 'cacheLocal') { - this.props.updateConfig({...config, cacheLocal: value}) - } - } - - render() { - const { config } = this.props - const { getFieldDecorator } = this.props.form - const formItemLayout = { - labelCol: { - xs: { span: 24 }, - sm: { span: 8 } - }, - wrapperCol: { - xs: { span: 24 }, - sm: { span: 16 } - } - } - - return ( - <Form {...formItemLayout}> - <Row> - <Col span={24}> - <Form.Item label={ - <Tooltip placement="topLeft" title="鏁版嵁浼氱紦瀛樺埌鐢ㄦ埛鏈湴锛屾柟渚块〉闈㈠揩閫熷憟鐜般��"> - <QuestionCircleOutlined className="mk-form-tip" /> - 鏈湴缂撳瓨 - </Tooltip> - }> - {getFieldDecorator('cacheLocal', { - initialValue: config.cacheLocal || 'false' - })( - <Radio.Group onChange={(e) => {this.selectChange('cacheLocal', e.target.value)}}> - <Radio value="true">浣跨敤</Radio> - <Radio value="false">涓嶄娇鐢�</Radio> - </Radio.Group> - )} - </Form.Item> - </Col> - <Col span={24}> - <Form.Item label={ - <Tooltip placement="topLeft" title="瀵逛簬涓嶇粡甯告�у彉鍔ㄧ殑淇℃伅锛岀紦瀛樻暟鎹湁鍔╀簬鎻愰珮鏌ヨ鏁堢巼銆�"> - <QuestionCircleOutlined className="mk-form-tip" /> - 鍚庣缂撳瓨 - </Tooltip> - }> - {getFieldDecorator('cacheUseful', { - initialValue: config.cacheUseful || 'false' - })( - <Radio.Group onChange={(e) => {this.selectChange('cacheUseful', e.target.value)}}> - <Radio value="true">浣跨敤</Radio> - <Radio value="false">涓嶄娇鐢�</Radio> - </Radio.Group> - )} - </Form.Item> - </Col> - {config.cacheUseful === 'true' ? <Col span={24}> - <Form.Item label="鍗曚綅"> - {getFieldDecorator('timeUnit', { - initialValue: config.timeUnit || 'day' - })( - <Radio.Group style={{whiteSpace: 'nowrap'}} onChange={(e) => {this.selectChange('timeUnit', e.target.value)}}> - <Radio value="day">澶�</Radio> - <Radio value="hour">灏忔椂</Radio> - <Radio value="minute">鍒嗛挓</Radio> - </Radio.Group> - )} - </Form.Item> - </Col> : null} - {config.cacheUseful === 'true' ? <Col span={24}> - <Form.Item label="鏃堕暱"> - {getFieldDecorator('cacheTime', { - initialValue: config.cacheTime, - rules: [ - { - required: true, - message: '璇疯緭鍏ユ椂闀�!' - } - ] - })( - <InputNumber min={1} max={config.timeUnit === 'day' ? 7 : (config.timeUnit === 'hour' ? 23 : 59)} precision={0} onChange={this.changeCacheDay}/> - )} - </Form.Item> - </Col> : null} - </Row> - </Form> - ) - } -} - -export default Form.create()(CustomMenuForm) \ No newline at end of file diff --git a/src/views/menudesign/popview/menuform/index.scss b/src/views/menudesign/popview/menuform/index.scss deleted file mode 100644 index e69de29..0000000 --- a/src/views/menudesign/popview/menuform/index.scss +++ /dev/null diff --git a/src/views/mobdesign/menuform/index.jsx b/src/views/mobdesign/menuform/index.jsx index b6371cf..49d4013 100644 --- a/src/views/mobdesign/menuform/index.jsx +++ b/src/views/mobdesign/menuform/index.jsx @@ -22,34 +22,23 @@ // 涓�浜岀骇鑿滃崟鍒囨崲 selectChange = (key, value, hex) => { + if (key === 'cacheTime' || key === 'localCacheTime') { + if (typeof(value) !== 'number') { + value = '' + } + } + let _config = {...this.props.config, [key]: value} - if (key === 'statusBarbgColor' && hex) { - _config.statusBarHexColor = hex + if (key === 'statusBarbgColor') { // 灏忕▼搴忕姸鎬佹爮 + if (hex) { + _config.statusBarHexColor = hex + } else { + delete _config.statusBarHexColor + } } this.props.updateConfig(_config) - } - - // 鑿滃崟鍚嶇О - changeName = (e) => { - this.props.updateConfig({...this.props.config, MenuName: e.target.value}) - } - - // 鑿滃崟鍙傛暟 - changeNo = (e) => { - this.props.updateConfig({...this.props.config, MenuNo: e.target.value}) - } - - changeRemark = (e) => { - this.props.updateConfig({...this.props.config, Remark: e.target.value}) - } - - changeCacheDay = (val) => { - if (typeof(val) !== 'number') { - val = '' - } - this.props.updateConfig({...this.props.config, cacheTime: val}) } render() { @@ -79,7 +68,7 @@ message: '璇疯緭鍏ヨ彍鍗曞悕绉�!' } ] - })(<Input placeholder="" autoComplete="off" onChange={this.changeName}/>)} + })(<Input placeholder="" autoComplete="off" onChange={(e) => {this.selectChange('MenuName', e.target.value)}}/>)} </Form.Item> </Col> <Col span={24}> @@ -92,7 +81,7 @@ message: '璇疯緭鍏ヨ彍鍗曞弬鏁�!' } ] - })(<Input placeholder="" autoComplete="off" onChange={this.changeNo}/>)} + })(<Input placeholder="" autoComplete="off" onChange={(e) => {this.selectChange('MenuNo', e.target.value)}}/>)} </Form.Item> </Col> <Col span={24}> @@ -112,6 +101,20 @@ )} </Form.Item> </Col> + {config.cacheLocal === 'true' ? <Col span={24}> + <Form.Item label={ + <Tooltip placement="topLeft" title="璁剧疆鏈湴缂撳瓨鏃堕暱鍚庯紝鍦ㄧ紦瀛樻湡闄愬唴涓嶅悜鍚庡彴璇锋眰鏁版嵁锛屾椂闀挎渶澶т负5澶╋紙鍗�7200鍒嗛挓锛夈�傛敞锛氭椂闀夸负绌烘椂缂撳瓨鏁版嵁鍙敤浜庨〉闈㈠揩閫熷憟鐜帮紝涓嶅奖鍝嶆帴鍙h姹傘��"> + <QuestionCircleOutlined className="mk-form-tip" /> + 鏃堕暱(鍒�) + </Tooltip> + }> + {getFieldDecorator('localCacheTime', { + initialValue: config.localCacheTime + })( + <InputNumber min={1} max={7200} precision={0} onChange={(val) => {this.selectChange('localCacheTime', val)}}/> + )} + </Form.Item> + </Col> : null} <Col span={24}> <Form.Item label={ <Tooltip placement="topLeft" title="瀵逛簬涓嶇粡甯告�у彉鍔ㄧ殑淇℃伅锛岀紦瀛樻暟鎹湁鍔╀簬鎻愰珮鏌ヨ鏁堢巼銆�"> @@ -187,7 +190,7 @@ } ] })( - <InputNumber min={1} max={config.timeUnit === 'day' ? 7 : (config.timeUnit === 'hour' ? 23 : 59)} precision={0} onChange={this.changeCacheDay}/> + <InputNumber min={1} max={config.timeUnit === 'day' ? 7 : (config.timeUnit === 'hour' ? 23 : 59)} precision={0} onChange={(val) => {this.selectChange('cacheTime', val)}}/> )} </Form.Item> </Col> : null} @@ -342,7 +345,7 @@ message: '澶囨敞鏈�澶�512涓瓧绗︼紒' } ] - })(<TextArea rows={2} placeholder={''} onChange={this.changeRemark} />)} + })(<TextArea rows={2} placeholder={''} onChange={(e) => {this.selectChange('Remark', e.target.value)}}/>)} </Form.Item> </Col> </Row> diff --git a/src/views/mobdesign/popview/index.jsx b/src/views/mobdesign/popview/index.jsx index 03cfee3..eeaa4c7 100644 --- a/src/views/mobdesign/popview/index.jsx +++ b/src/views/mobdesign/popview/index.jsx @@ -12,7 +12,6 @@ const { Panel } = Collapse const { confirm } = Modal -const MenuForm = asyncComponent(() => import('./menuform')) const MobShell = asyncComponent(() => import('@/mob/mobshell')) const SourceWrap = asyncComponent(() => import('@/mob/modulesource')) const Modulecell = asyncComponent(() => import('@/menu/modulecell')) @@ -271,8 +270,6 @@ <Collapse accordion defaultActiveKey="component" bordered={false}> {/* 鍩烘湰淇℃伅 */} <Panel header="鍩烘湰淇℃伅" forceRender className="basedata" key="basedata"> - {/* 鑿滃崟淇℃伅 */} - <MenuForm config={config} updateConfig={this.updateConfig}/> {/* 琛ㄥ悕娣诲姞 */} <TableComponent config={config} updatetable={this.updateConfig}/> </Panel> diff --git a/src/views/mobdesign/popview/menuform/index.jsx b/src/views/mobdesign/popview/menuform/index.jsx deleted file mode 100644 index e84a5af..0000000 --- a/src/views/mobdesign/popview/menuform/index.jsx +++ /dev/null @@ -1,118 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { Form, Row, Col, Radio, Tooltip, InputNumber } from 'antd' -import { QuestionCircleOutlined } from '@ant-design/icons' - -// import './index.scss' - -class CustomMenuForm extends Component { - static propTpyes = { - config: PropTypes.object, - updateConfig: PropTypes.func - } - - changeCacheDay = (val) => { - if (typeof(val) !== 'number') { - val = '' - } - this.props.updateConfig({...this.props.config, cacheTime: val}) - } - - selectChange = (key, value) => { - const { config } = this.props - - if (key === 'cacheUseful') { - this.props.updateConfig({...config, cacheUseful: value}) - } else if (key === 'timeUnit') { - this.props.updateConfig({...config, timeUnit: value}) - } else if (key === 'cacheLocal') { - this.props.updateConfig({...config, cacheLocal: value}) - } - } - - render() { - const { config } = this.props - const { getFieldDecorator } = this.props.form - const formItemLayout = { - labelCol: { - xs: { span: 24 }, - sm: { span: 8 } - }, - wrapperCol: { - xs: { span: 24 }, - sm: { span: 16 } - } - } - - return ( - <Form {...formItemLayout}> - <Row> - <Col span={24}> - <Form.Item label={ - <Tooltip placement="topLeft" title="鏁版嵁浼氱紦瀛樺埌鐢ㄦ埛鏈湴锛屾柟渚块〉闈㈠揩閫熷憟鐜般��"> - <QuestionCircleOutlined className="mk-form-tip" /> - 鏈湴缂撳瓨 - </Tooltip> - }> - {getFieldDecorator('cacheLocal', { - initialValue: config.cacheLocal || 'false' - })( - <Radio.Group onChange={(e) => {this.selectChange('cacheLocal', e.target.value)}}> - <Radio value="true">浣跨敤</Radio> - <Radio value="false">涓嶄娇鐢�</Radio> - </Radio.Group> - )} - </Form.Item> - </Col> - <Col span={24}> - <Form.Item label={ - <Tooltip placement="topLeft" title="瀵逛簬涓嶇粡甯告�у彉鍔ㄧ殑淇℃伅锛岀紦瀛樻暟鎹湁鍔╀簬鎻愰珮鏌ヨ鏁堢巼銆�"> - <QuestionCircleOutlined className="mk-form-tip" /> - 鍚庣缂撳瓨 - </Tooltip> - }> - {getFieldDecorator('cacheUseful', { - initialValue: config.cacheUseful || 'false' - })( - <Radio.Group onChange={(e) => {this.selectChange('cacheUseful', e.target.value)}}> - <Radio value="true">浣跨敤</Radio> - <Radio value="false">涓嶄娇鐢�</Radio> - </Radio.Group> - )} - </Form.Item> - </Col> - {config.cacheUseful === 'true' ? <Col span={24}> - <Form.Item label="鍗曚綅"> - {getFieldDecorator('timeUnit', { - initialValue: config.timeUnit || 'day' - })( - <Radio.Group style={{whiteSpace: 'nowrap'}} onChange={(e) => {this.selectChange('timeUnit', e.target.value)}}> - <Radio value="day">澶�</Radio> - <Radio value="hour">灏忔椂</Radio> - <Radio value="minute">鍒嗛挓</Radio> - </Radio.Group> - )} - </Form.Item> - </Col> : null} - {config.cacheUseful === 'true' ? <Col span={24}> - <Form.Item label="鏃堕暱"> - {getFieldDecorator('cacheTime', { - initialValue: config.cacheTime, - rules: [ - { - required: true, - message: '璇疯緭鍏ユ椂闀�!' - } - ] - })( - <InputNumber min={1} max={config.timeUnit === 'day' ? 7 : (config.timeUnit === 'hour' ? 23 : 59)} precision={0} onChange={this.changeCacheDay}/> - )} - </Form.Item> - </Col> : null} - </Row> - </Form> - ) - } -} - -export default Form.create()(CustomMenuForm) \ No newline at end of file diff --git a/src/views/mobdesign/popview/menuform/index.scss b/src/views/mobdesign/popview/menuform/index.scss deleted file mode 100644 index e69de29..0000000 --- a/src/views/mobdesign/popview/menuform/index.scss +++ /dev/null diff --git a/src/views/pcdesign/menuform/index.jsx b/src/views/pcdesign/menuform/index.jsx index 8c6262b..6d39167 100644 --- a/src/views/pcdesign/menuform/index.jsx +++ b/src/views/pcdesign/menuform/index.jsx @@ -16,42 +16,16 @@ state = {} - // 涓�浜岀骇鑿滃崟鍒囨崲 selectChange = (key, value) => { const { config } = this.props - if (key === 'cacheUseful') { - this.props.updateConfig({...config, cacheUseful: value}) - } else if (key === 'timeUnit') { - this.props.updateConfig({...config, timeUnit: value}) - } else if (key === 'mask') { - this.props.updateConfig({...config, mask: value}) - } else if (key === 'cacheLocal') { - this.props.updateConfig({...config, cacheLocal: value}) - // } else if (key === 'permission') { - // this.props.updateConfig({...config, permission: value}) + if (key === 'cacheTime' || key === 'localCacheTime') { + if (typeof(value) !== 'number') { + value = '' + } } - } - // 鑿滃崟鍚嶇О - changeName = (e) => { - this.props.updateConfig({...this.props.config, MenuName: e.target.value}) - } - - // 鑿滃崟鍙傛暟 - changeNo = (e) => { - this.props.updateConfig({...this.props.config, MenuNo: e.target.value}) - } - - changeRemark = (e) => { - this.props.updateConfig({...this.props.config, Remark: e.target.value}) - } - - changeCacheDay = (val) => { - if (typeof(val) !== 'number') { - val = '' - } - this.props.updateConfig({...this.props.config, cacheTime: val}) + this.props.updateConfig({...config, [key]: value}) } render() { @@ -81,7 +55,7 @@ message: '璇疯緭鍏ヨ彍鍗曞悕绉�!' } ] - })(<Input placeholder="" autoComplete="off" onChange={this.changeName}/>)} + })(<Input placeholder="" autoComplete="off" onChange={(e) => {this.selectChange('MenuName', e.target.value)}}/>)} </Form.Item> </Col> <Col span={24}> @@ -94,7 +68,7 @@ message: '璇疯緭鍏ヨ彍鍗曞弬鏁�!' } ] - })(<Input placeholder="" autoComplete="off" onChange={this.changeNo}/>)} + })(<Input placeholder="" autoComplete="off" onChange={(e) => {this.selectChange('MenuNo', e.target.value)}}/>)} </Form.Item> </Col> <Col span={24}> @@ -114,6 +88,20 @@ )} </Form.Item> </Col> + {config.cacheLocal === 'true' ? <Col span={24}> + <Form.Item label={ + <Tooltip placement="topLeft" title="璁剧疆鏈湴缂撳瓨鏃堕暱鍚庯紝鍦ㄧ紦瀛樻湡闄愬唴涓嶅悜鍚庡彴璇锋眰鏁版嵁锛屾椂闀挎渶澶т负5澶╋紙鍗�7200鍒嗛挓锛夈�傛敞锛氭椂闀夸负绌烘椂缂撳瓨鏁版嵁鍙敤浜庨〉闈㈠揩閫熷憟鐜帮紝涓嶅奖鍝嶆帴鍙h姹傘��"> + <QuestionCircleOutlined className="mk-form-tip" /> + 鏃堕暱(鍒�) + </Tooltip> + }> + {getFieldDecorator('localCacheTime', { + initialValue: config.localCacheTime + })( + <InputNumber min={1} max={7200} precision={0} onChange={(val) => {this.selectChange('localCacheTime', val)}}/> + )} + </Form.Item> + </Col> : null} <Col span={24}> <Form.Item label={ <Tooltip placement="topLeft" title="瀵逛簬涓嶇粡甯告�у彉鍔ㄧ殑淇℃伅锛岀紦瀛樻暟鎹湁鍔╀簬鎻愰珮鏌ヨ鏁堢巼銆�"> @@ -206,7 +194,7 @@ } ] })( - <InputNumber min={1} max={config.timeUnit === 'day' ? 7 : (config.timeUnit === 'hour' ? 23 : 59)} precision={0} onChange={this.changeCacheDay}/> + <InputNumber min={1} max={config.timeUnit === 'day' ? 7 : (config.timeUnit === 'hour' ? 23 : 59)} precision={0} onChange={(val) => {this.selectChange('cacheTime', val)}}/> )} </Form.Item> </Col> : null} @@ -220,7 +208,7 @@ message: '澶囨敞鏈�澶�512涓瓧绗︼紒' } ] - })(<TextArea rows={2} placeholder={''} onChange={this.changeRemark} />)} + })(<TextArea rows={2} placeholder={''} onChange={(e) => {this.selectChange('Remark', e.target.value)}}/>)} </Form.Item> </Col> </Row> -- Gitblit v1.8.0