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/card/double-data-card/index.jsx | 95 ++++++++++++++++++++++++++++------------------- 1 files changed, 57 insertions(+), 38 deletions(-) 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 -- Gitblit v1.8.0