From da34633b25d16359cd91a656acad5e811f9972b7 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 14 三月 2023 18:09:54 +0800 Subject: [PATCH] 2023-03-14 --- src/tabviews/custom/components/table/normal-table/index.jsx | 47 +++++++++++++++++++---------------------------- 1 files changed, 19 insertions(+), 28 deletions(-) diff --git a/src/tabviews/custom/components/table/normal-table/index.jsx b/src/tabviews/custom/components/table/normal-table/index.jsx index 8369017..b4ec245 100644 --- a/src/tabviews/custom/components/table/normal-table/index.jsx +++ b/src/tabviews/custom/components/table/normal-table/index.jsx @@ -54,7 +54,6 @@ UNSAFE_componentWillMount () { const { data, initdata } = this.props let _config = fromJS(this.props.config).toJS() - let _cols = new Map() let _data = null let _sync = _config.setting.sync === 'true' @@ -131,31 +130,6 @@ } } - _config.columns.forEach(item => { - if (item.type !== 'number') return - _cols.set(item.field, item) - }) - - _config.cols.forEach(column => { - if (column.type === 'custom') { - column.elements = column.elements.map(item => { - if (item.eleType === 'number' && item.field && _cols.has(item.field) && typeof(item.decimal) !== 'number') { - item.decimal = _cols.get(item.field).decimal || 0 - } - return item - }) - } else if (column.type === 'action') { - column.operations = column.elements - } - }) - - // if (setting.color) { - // setting.style.color = setting.color - // } - // if (setting.fontSize) { - // setting.style.fontSize = setting.fontSize - // } - if (_config.wrap.collapse === 'true') { _config.wrap.title = _config.wrap.title || ' ' } @@ -204,7 +178,7 @@ }) MKEmitter.emit('resetSelectLine', config.uuid, '', '') // 骞挎挱鏁版嵁鍒囨崲 - reset && MKEmitter.emit('resetTable', config.uuid, repage) // 鍒楄〃閲嶇疆 + reset && MKEmitter.emit('resetTable', config.uuid, 'true') // 鍒楄〃閲嶇疆 if (setting.$hasSyncModule) { MKEmitter.emit('syncBalconyData', config.uuid, [], false) } @@ -240,9 +214,26 @@ let result = await Api.genericInterface(param) if (result.status) { this.loaded = true - if (config.$cache && pageIndex === 1) { + if (config.$cache && pageIndex === 1 && config.setting.onload !== 'false') { Api.writeCacheConfig(config.uuid, result.data || '') } + + if (repage === 'false' && result.data && result.data.length === 0 && result.total > 0 && pageIndex > 1) { + let _pageIndex = Math.ceil(result.total / pageSize) + + if (_pageIndex < pageIndex) { + MKEmitter.emit('resetTable', config.uuid, 'repage', _pageIndex) + this.setState({ + pageIndex: _pageIndex, + data: [], + selectedData: [], + total: result.total + }, () => { + this.loadmaindata() + }) + return + } + } if ((setting.selected !== 'false' || (setting.orisel && id)) && result.data && result.data.length > 0) { setTimeout(() => { -- Gitblit v1.8.0