From 5046d0d13dc6a8563b8e54e31913bc44cfa1072f Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 26 四月 2022 19:23:18 +0800 Subject: [PATCH] 2022-04-26 --- src/tabviews/custom/components/carousel/prop-card/index.jsx | 60 ++++++++++++++++++++++++++++++++++-------------------------- 1 files changed, 34 insertions(+), 26 deletions(-) diff --git a/src/tabviews/custom/components/carousel/prop-card/index.jsx b/src/tabviews/custom/components/carousel/prop-card/index.jsx index 4004576..34f0eb3 100644 --- a/src/tabviews/custom/components/carousel/prop-card/index.jsx +++ b/src/tabviews/custom/components/carousel/prop-card/index.jsx @@ -41,26 +41,25 @@ _sync = _config.setting.sync === 'true' if (_sync && data) { - _data = data[_config.dataName] || {} - if (_data && Array.isArray(_data)) { - _data = _data[0] || {} + _data = data[_config.dataName] || {$$empty: true} + if (Array.isArray(_data)) { + _data = _data[0] || {$$empty: true} } _sync = false } else if (_sync && initdata) { - _data = initdata || {} - if (_data && Array.isArray(_data)) { - _data = _data[0] || {} + _data = initdata + if (Array.isArray(_data)) { + _data = _data[0] || {$$empty: true} } _sync = false } } - if (_data) { - _data.$$BID = BID || '' - _data.$$BData = BData || '' - } + _data.$$BID = BID || '' + _data.$$BData = BData || '' _config.columns.forEach(item => { + if (item.type !== 'number') return _cols.set(item.field, item) }) @@ -70,8 +69,8 @@ card.style.cursor = 'pointer' } card.elements = card.elements.map(item => { - if (item.field && _cols.has(item.field)) { - item.col = _cols.get(item.field) + if (item.eleType === 'number' && item.field && _cols.has(item.field) && typeof(item.decimal) !== 'number') { + item.decimal = _cols.get(item.field).decimal || 0 } return item }) @@ -88,7 +87,9 @@ arr_field: _config.columns.map(col => col.field).join(','), }, () => { if (_config.wrap.datatype !== 'static' && _config.setting && _config.setting.sync !== 'true' && _config.setting.onload === 'true') { - this.loadData() + setTimeout(() => { + this.loadData() + }, _config.setting.delay || 0) } }) } @@ -122,15 +123,13 @@ let _data = {$$empty: true} if (nextProps.data && nextProps.data[config.dataName]) { _data = nextProps.data[config.dataName] - if (_data && Array.isArray(_data)) { - _data = _data[0] + if (Array.isArray(_data)) { + _data = _data[0] || {$$empty: true} } } - if (_data) { - _data.$$BID = BID || '' - _data.$$BData = BData || '' - } + _data.$$BID = BID || '' + _data.$$BData = BData || '' this.setState({sync: false, data: _data}) } else if (config.setting.syncRefresh && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { @@ -151,16 +150,23 @@ if (config.uuid !== menuId) return - this.loadData() // 鏁版嵁鍒锋柊 + let supModule = config.setting.supModule - if (btn.syncComponentId && btn.syncComponentId !== config.uuid && btn.syncComponentId !== config.setting.supModule) { - MKEmitter.emit('reloadData', btn.syncComponentId) // 鍚岀骇鏍囩鍒锋柊 + btn.syncComponentId && MKEmitter.emit('reloadData', btn.syncComponentId) + + if (!btn.syncComponentId || btn.syncComponentId !== supModule) { + if (position === 'mainline' || position === 'popclose') { // 鍒锋柊婧愮粍浠舵椂锛岄檮甯﹀埛鏂颁笂绾ц涓庡綋鍓嶇粍浠� + if (supModule && BID) { + MKEmitter.emit('reloadData', supModule, BID) + } else { + this.loadData() + } + } else { + this.loadData() + } } - if (position === 'mainline' && config.setting.supModule) { // 涓昏〃琛屽埛鏂� - MKEmitter.emit('reloadData', config.setting.supModule, (BID || 'empty')) - } else if (position === 'popclose') { // 鏍囩鍏抽棴鍒锋柊 - config.setting.supModule && MKEmitter.emit('reloadData', config.setting.supModule, (BID || 'empty')) + if (position === 'popclose') { // 鎵ц鍚姩寮圭獥鐨勬寜閽墍閫夋嫨鐨勫埛鏂伴」 btn.$tabId && MKEmitter.emit('refreshPopButton', btn.$tabId) } } @@ -246,6 +252,8 @@ render() { const { config, loading, data } = this.state + if (config.wrap.empty === 'hidden' && (!data || data.$$empty)) return null + return ( <div className="custom-prop-carousel-box" style={config.style}> {loading ? -- Gitblit v1.8.0