From 7bd04b1c21a59e8d79325f247bdb1726507b51fb Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 13 八月 2024 18:51:20 +0800 Subject: [PATCH] 2024-08-13 --- src/tabviews/custom/components/table/edit-table/index.jsx | 55 ++-- src/menu/components/share/actioncomponent/actionform/index.jsx | 10 src/tabviews/custom/components/table/base-table/index.jsx | 128 ++++----- src/tabviews/custom/components/share/normalTable/index.jsx | 71 ++--- src/menu/components/table/base-table/options.jsx | 13 - src/tabviews/custom/components/card/double-data-card/index.jsx | 150 ++++------ src/tabviews/custom/components/table/normal-table/index.jsx | 130 ++++----- src/tabviews/custom/components/card/data-card/index.jsx | 165 +++++------ 8 files changed, 312 insertions(+), 410 deletions(-) diff --git a/src/menu/components/share/actioncomponent/actionform/index.jsx b/src/menu/components/share/actioncomponent/actionform/index.jsx index 7c1103d..dcf94bf 100644 --- a/src/menu/components/share/actioncomponent/actionform/index.jsx +++ b/src/menu/components/share/actioncomponent/actionform/index.jsx @@ -233,7 +233,7 @@ if (this.record.openmenu && this.record.openmenu !== 'goback') { shows.push('open') } - if (['grid', 'line', 'line_grid'].includes(this.record.execSuccess) || ['grid', 'line', 'line_grid'].includes(this.record.execError)) { + if (['grid'].includes(this.record.execSuccess) || ['grid'].includes(this.record.execError)) { shows.push('resetPageIndex') } @@ -305,7 +305,7 @@ if (this.record.execSuccess === 'goback') { shows.push('reload') } - if (['grid', 'line', 'line_grid'].includes(this.record.execSuccess) || ['grid', 'line', 'line_grid'].includes(this.record.execError)) { + if (['grid'].includes(this.record.execSuccess) || ['grid'].includes(this.record.execError)) { shows.push('resetPageIndex') } @@ -352,7 +352,7 @@ } else { shows.push('database') } - if (['grid', 'line', 'line_grid'].includes(this.record.execSuccess) || ['grid', 'line', 'line_grid'].includes(this.record.execError)) { + if (['grid'].includes(this.record.execSuccess) || ['grid'].includes(this.record.execError)) { shows.push('resetPageIndex') } } else if (openType === 'excelOut') { @@ -389,7 +389,7 @@ } else { shows.push('database') } - if (['grid', 'line', 'line_grid'].includes(this.record.execSuccess) || ['grid', 'line', 'line_grid'].includes(this.record.execError)) { + if (['grid'].includes(this.record.execSuccess) || ['grid'].includes(this.record.execError)) { shows.push('resetPageIndex') } if (this.record.Ot !== 'notRequired' && appType === 'mob') { @@ -485,7 +485,7 @@ shows.push('innerFunc', 'extraParam') reRequired.innerFunc = true } - if (['grid', 'line', 'line_grid'].includes(this.record.execSuccess) || ['grid', 'line', 'line_grid'].includes(this.record.execError)) { + if (['grid'].includes(this.record.execSuccess) || ['grid'].includes(this.record.execError)) { shows.push('resetPageIndex') } if (this.record.execMode === 'pop' || this.record.execMode === 'prompt') { diff --git a/src/menu/components/table/base-table/options.jsx b/src/menu/components/table/base-table/options.jsx index d482819..8c3f5fa 100644 --- a/src/menu/components/table/base-table/options.jsx +++ b/src/menu/components/table/base-table/options.jsx @@ -88,19 +88,6 @@ {value: 'small', label: '灏�'}, ], }, - // { - // type: 'radio', - // field: 'selected', - // label: '棣栬閫変腑', - // initval: wrap.selected || 'false', - // tooltip: '褰撴寜閽墽琛屽畬鎴愬苟杩斿洖涓婚敭鍊兼椂锛岄粯璁ら�変腑涓婚敭鍊煎搴旇銆�', - // required: false, - // options: [ - // {value: 'false', label: '鏃�'}, - // {value: 'init', label: '鍒濆鍖�'}, - // {value: 'always', label: '鏁版嵁鍔犺浇'}, - // ] - // }, { type: 'radio', field: 'tableMode', diff --git a/src/tabviews/custom/components/card/data-card/index.jsx b/src/tabviews/custom/components/card/data-card/index.jsx index 2748a02..2682bca 100644 --- a/src/tabviews/custom/components/card/data-card/index.jsx +++ b/src/tabviews/custom/components/card/data-card/index.jsx @@ -410,9 +410,7 @@ if (config.$searchId !== searchId) return - this.setState({pageIndex: 1}, () => { - this.loadData() - }) + this.reloadIndex() } /** @@ -426,6 +424,7 @@ if (config.uuid !== menuId) return + let _id = config.wrap.selected === 'always' ? id : '' if (config.supNodes) { if (['mainline', 'maingrid', 'popclose'].includes(position)) { let supNode = this.supModules[this.supModules.length - 1] @@ -439,43 +438,41 @@ }, i * 10) }) } else { - if ((position === 'line' || position === 'line_grid') && lines && lines.length === 1 && !config.forbidLine) { - this.loadLinedata(lines[0].$$uuid, position) + if (position === 'line' || position === 'line_grid') { + if (lines && lines.length === 1) { + if (config.forbidLine) { + this.loadData(lines[0].$$uuid, 'repage') + } else { + this.loadLinedata(lines[0].$$uuid, position) + } + } else { + this.loadData(_id, 'repage') + } } else if (btn.resetPageIndex !== 'false') { - this.setState({ - pageIndex: 1 - }, () => { - this.loadData(id) - }) + this.reloadIndex() } else { - this.loadData(id) + this.loadData(_id, 'repage') } } } else { let supModule = config.setting.supModule if (position === 'line' || position === 'line_grid') { - if (lines && lines.length === 1 && !config.forbidLine) { - this.loadLinedata(lines[0].$$uuid, position) - } else if (btn.resetPageIndex !== 'false') { - this.setState({ - pageIndex: 1 - }, () => { - this.loadData(id) - }) + if (lines && lines.length === 1) { + if (config.forbidLine) { + this.loadData(lines[0].$$uuid, 'repage') + } else { + this.loadLinedata(lines[0].$$uuid, position) + } } else { - this.loadData(id) + this.loadData(_id, 'repage') } } else if (['mainline', 'maingrid', 'popclose'].includes(position) && supModule) { MKEmitter.emit('reloadData', supModule, position === 'maingrid' ? '' : BID) } else if (btn.resetPageIndex !== 'false') { - this.setState({ - pageIndex: 1 - }, () => { - this.loadData(id) - }) + this.reloadIndex() } else { - this.loadData(id) + this.loadData(_id, 'repage') } } } @@ -497,13 +494,21 @@ }) } + reloadIndex = () => { + this.setState({ + pageIndex: 1 + }, () => { + this.loadData() + }) + } + prevCheck = (id) => { const { selected } = this.state if (selected === 'false' && !id) return setTimeout(() => { - this.checkTopLine(id) + this.checkTopLine(id, selected) }, 10) if (selected === 'init') { @@ -511,59 +516,39 @@ } } - checkTopLine = (id) => { - const { config, data, selected } = this.state + checkTopLine = (id, selected) => { + const { config, data } = this.state - if (data.length === 0) { - this.setState({ - activeKey: '', - selectKeys: [], - selectedData: [] - }) - - MKEmitter.emit('resetSelectLine', config.uuid, '', '') - if (config.setting.$hasSyncModule) { - MKEmitter.emit('syncBalconyData', config.uuid, [], false) + let index = -1 + let keys = [] + let items = [] + + if (data.length > 0) { + if (id) { + index = data.findIndex(item => item.$$uuid === id && !item.$disabled) } - return - } - - if (selected === 'sign') { - let index = '' - let keys = [] - let items = [] - let last = '' - data.forEach((item, i) => { - if (!item.$disabled && item.selected === 'true') { - items.push(item) - keys.push(i) - index = i - last = item + + if (index !== -1) { + keys = [index] + items = [data[index]] + } else if (selected === 'sign') { + data.forEach((item, i) => { + if (!item.$disabled && item.selected === 'true') { + items.push(item) + keys.push(i) + index = i + } + }) + } else if (selected !== 'false') { + if (!data[0].$disabled) { + index = 0 + keys = [index] + items = [data[index]] } - }) - - this.setState({ - activeKey: index, - selectKeys: keys, - selectedData: items - }) - - MKEmitter.emit('resetSelectLine', config.uuid, last ? last.$$uuid : '', last) - if (config.setting.$hasSyncModule) { - MKEmitter.emit('syncBalconyData', config.uuid, items, data.length === keys.length) - } - return - } - - let index = 0 - if (id) { - index = data.findIndex(item => item.$$uuid === id) - if (index === -1) { - index = 0 } } - if (data[index].$disabled) { + if (index === -1) { this.setState({ activeKey: '', selectKeys: [], @@ -576,16 +561,18 @@ } return } + + let item = items[items.length - 1] this.setState({ activeKey: index, - selectKeys: [index], - selectedData: [data[index]] + selectKeys: keys, + selectedData: items }) - MKEmitter.emit('resetSelectLine', config.uuid, data[index].$$uuid, data[index]) + MKEmitter.emit('resetSelectLine', config.uuid, item.$$uuid, item) if (config.setting.$hasSyncModule) { - MKEmitter.emit('syncBalconyData', config.uuid, [data[index]], data.length === 1) + MKEmitter.emit('syncBalconyData', config.uuid, items, data.length === keys.length) } } @@ -683,7 +670,9 @@ if (config.uuid !== menuId) return if (!id) { - this.loadData() + this.reloadIndex() + } else if (config.forbidLine) { + this.loadData(id, 'repage') } else { this.loadLinedata(id) } @@ -806,6 +795,11 @@ if (result.status) { if (result.$requestId && this.requestId !== result.$requestId) return + if (type === 'repage' && result.data.length === 0 && pageIndex > 1) { + this.reloadIndex() + return + } + let start = 1 if (config.setting.laypage) { start = pageSize * (pageIndex - 1) + 1 @@ -816,7 +810,7 @@ Api.writeCacheConfig(config.uuid, result.data || [], BID) } - if (selected !== 'false' || (id && config.wrap.selected !== 'false')) { + if (selected !== 'false' || id) { this.prevCheck(id) } else { MKEmitter.emit('resetSelectLine', config.uuid, '', '') @@ -904,15 +898,6 @@ async loadLinedata (id, position) { const { config, pageIndex, pageSize, search, BID, BData, orderBy } = this.state - if (config.forbidLine) { - this.setState({ - pageIndex: 1 - }, () => { - this.loadData() - }) - return - } - let searches = fromJS(search).toJS() if (config.setting.useMSearch) { // 涓昏〃鎼滅储鏉′欢 let mainSearch = window.GLOB.SearchBox.get(config.$searchId) || [] @@ -934,7 +919,7 @@ let result = await Api.genericInterface(param) if (result.status) { if (position === 'line_grid' && (!result.data || !result.data[0])) { - this.loadData() + this.reloadIndex() return } 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 0275d3b..8ee5097 100644 --- a/src/tabviews/custom/components/card/double-data-card/index.jsx +++ b/src/tabviews/custom/components/card/double-data-card/index.jsx @@ -358,9 +358,7 @@ if (config.$searchId !== searchId) return - this.setState({pageIndex: 1}, () => { - this.loadData() - }) + this.reloadIndex() } /** @@ -373,28 +371,23 @@ let supModule = config.setting.supModule + let _id = config.wrap.selected === 'always' ? id : '' if (position === 'line' || position === 'line_grid') { - if (lines && lines.length === 1 && !config.forbidLine) { - this.loadLinedata(lines[0].$$parentId || lines[0].$$uuid, position) - } else if (btn.resetPageIndex !== 'false') { - this.setState({ - pageIndex: 1 - }, () => { - this.loadData(id) - }) + if (lines && lines.length === 1) { + if (config.forbidLine) { + this.loadData(lines[0].$$parentId || lines[0].$$uuid, 'repage') + } else { + this.loadLinedata(lines[0].$$parentId || lines[0].$$uuid, position) + } } else { - this.loadData(id) + this.loadData(_id, 'repage') } } else if (['mainline', 'maingrid', 'popclose'].includes(position) && supModule) { MKEmitter.emit('reloadData', supModule, position === 'maingrid' ? '' : BID) } else if (btn.resetPageIndex !== 'false') { - this.setState({ - pageIndex: 1 - }, () => { - this.loadData(id) - }) + this.reloadIndex() } else { - this.loadData(id) + this.loadData(_id, 'repage') } } @@ -420,64 +413,40 @@ }) } - checkTopLine = (id) => { - const { config, data, selected, card } = this.state + checkTopLine = (id, selected) => { + const { config, data, card } = this.state let _opens = [...this.state.opens] - if (data.length === 0) { - this.setState({ - activeKey: '', - selectKeys: [], - selectedData: [] - }) - - MKEmitter.emit('resetSelectLine', config.uuid, '', '') - return - } + let index = -1 + let keys = [] + let items = [] - if (selected === 'sign') { - let index = '' - let keys = [] - let items = [] - let last = '' - - if (card.setting.display === 'collapse') { - _opens = [] + if (data.length > 0) { + if (id) { + index = data.findIndex(item => item.$$uuid === id && !item.$disabled) } - data.forEach((item, i) => { - if (!item.$disabled && item.selected === 'true') { - items.push(item) - keys.push(i) - index = i - last = item - - if (card.setting.display === 'collapse') { - _opens.push(i) + if (index !== -1) { + keys = [index] + items = [data[index]] + } else if (selected === 'sign') { + data.forEach((item, i) => { + if (!item.$disabled && item.selected === 'true') { + items.push(item) + keys.push(i) + index = i } + }) + } else if (selected !== 'false') { + if (!data[0].$disabled) { + index = 0 + keys = [index] + items = [data[index]] } - }) - - this.setState({ - opens: _opens, - activeKey: index, - selectKeys: keys, - selectedData: items - }) - - MKEmitter.emit('resetSelectLine', config.uuid, last ? last.$$uuid : '', last) - return - } - - let index = 0 - if (id) { - index = data.findIndex(item => item.$$uuid === id) - if (index === -1) { - index = 0 } } - if (data[index].$disabled) { + if (index === -1) { this.setState({ activeKey: '', selectKeys: [], @@ -489,17 +458,19 @@ } if (card.setting.display === 'collapse') { - _opens = [index] + _opens = keys } + + let item = items[items.length - 1] this.setState({ opens: _opens, activeKey: index, - selectKeys: [index], - selectedData: [data[index]] + selectKeys: keys, + selectedData: items }) - MKEmitter.emit('resetSelectLine', config.uuid, data[index].$$uuid, data[index]) + MKEmitter.emit('resetSelectLine', config.uuid, item.$$uuid, item) } checkAll = () => { @@ -547,7 +518,9 @@ if (config.uuid !== menuId) return if (!id) { - this.loadData() + this.reloadIndex() + } else if (config.forbidLine) { + this.loadData(id, 'repage') } else { this.loadLinedata(id) } @@ -643,6 +616,11 @@ if (result.status) { if (result.$requestId && this.requestId !== result.$requestId) return + if (type === 'repage' && result.data.length === 0 && pageIndex > 1) { + this.reloadIndex() + return + } + let start = 1 if (config.setting.laypage) { start = pageSize * (pageIndex - 1) + 1 @@ -653,13 +631,10 @@ Api.writeCacheConfig(config.uuid, result.data || [], BID) } - if (selected !== 'false' || (id && config.wrap.selected !== 'false')) { + if (selected !== 'false' || id) { setTimeout(() => { - this.checkTopLine(id) + this.checkTopLine(id, selected) }, 10) - if (selected === 'init') { - this.setState({selected: 'false'}) - } } else { MKEmitter.emit('resetSelectLine', config.uuid, '', '') } @@ -769,6 +744,10 @@ loading: false }) + if (selected === 'init') { + this.setState({selected: 'false'}) + } + if (config.timer && config.clearField && result.data && result.data[0]) { let vals = (config.clearValue || '').split(',') if (vals.includes(result.data[0][config.clearField])) { @@ -793,15 +772,6 @@ async loadLinedata (id, position) { const { config, pageIndex, pageSize, search, BID, BData, orderBy } = this.state - if (config.forbidLine) { - this.setState({ - pageIndex: 1 - }, () => { - this.loadData() - }) - return - } - let searches = fromJS(search).toJS() if (config.setting.useMSearch) { // 涓昏〃鎼滅储鏉′欢 let mainSearch = window.GLOB.SearchBox.get(config.$searchId) || [] @@ -823,7 +793,7 @@ let result = await Api.genericInterface(param) if (result.status) { if (position === 'line_grid' && (!result.data || !result.data[0])) { - this.loadData() + this.reloadIndex() return } @@ -946,6 +916,14 @@ } } + reloadIndex = () => { + this.setState({ + pageIndex: 1 + }, () => { + this.loadData() + }) + } + loadMore = () => { const { total, pageIndex, pageSize, loading } = this.state diff --git a/src/tabviews/custom/components/share/normalTable/index.jsx b/src/tabviews/custom/components/share/normalTable/index.jsx index 9631dcc..b5b0dbb 100644 --- a/src/tabviews/custom/components/share/normalTable/index.jsx +++ b/src/tabviews/custom/components/share/normalTable/index.jsx @@ -811,15 +811,27 @@ this.props.refreshdata({pageIndex}) } - mkCheckTopLine = (menuId, id, type) => { + mkCheckTopLine = (menuId, id, selected) => { const { MenuID, data, setting } = this.props - if (MenuID !== menuId || !data || data.length === 0) return + if (MenuID !== menuId) return + if (!data || data.length === 0) { + MKEmitter.emit('resetSelectLine', menuId, '', '') + return + } - if (type === 'sign') { - let index = '' - let keys = [] - let items = [] + let index = -1 + let keys = [] + let items = [] + + if (id) { + index = data.findIndex(item => item.$$uuid === id && !item.$disabled) + } + + if (index !== -1) { + keys = [index] + items = [data[index]] + } else if (selected === 'sign') { data.forEach((item, i) => { if (!item.$disabled && item.selected === 'true') { items.push(item) @@ -827,33 +839,25 @@ index = i } }) - - this.changedata(index) - this.setState({ selectedRowKeys: keys, activeIndex: index }) - this.props.chgSelectData(items) - - if (setting.$hasSyncModule) { - MKEmitter.emit('syncBalconyData', MenuID, items, data.length === keys.length) + } else if (selected !== 'false') { + if (!data[0].$disabled) { + index = 0 + keys = [index] + items = [data[index]] } + } + + if (index === -1) { + MKEmitter.emit('resetSelectLine', menuId, '', '') return } - let index = 0 - if (id) { - index = data.findIndex(item => item.$$uuid === id) - if (index === -1) { - index = 0 - } - } - - if (data[index].$disabled) return - this.changedata(index) - this.setState({ selectedRowKeys: [index], activeIndex: index }) - this.props.chgSelectData([data[index]]) + this.setState({ selectedRowKeys: keys, activeIndex: index }) + this.props.chgSelectData(items) if (setting.$hasSyncModule) { - MKEmitter.emit('syncBalconyData', MenuID, [data[index]], data.length === 1) + MKEmitter.emit('syncBalconyData', MenuID, items, data.length === keys.length) } } @@ -1028,22 +1032,9 @@ if (setting.$hasSyncModule) { MKEmitter.emit('syncBalconyData', MenuID, selects, data.length === selects.length) } - } else if (type === 'false') { - this.setState({ - selectedRowKeys: [], - activeIndex: null, - pickup: false - }) - } else if (type === 'repage') { - this.setState({ - pageIndex: Index, - selectedRowKeys: [], - activeIndex: null, - pickup: false - }) } else { this.setState({ - pageIndex: 1, + pageIndex: type === 'false' ? this.state.pageIndex : 1, selectedRowKeys: [], activeIndex: null, pickup: false diff --git a/src/tabviews/custom/components/table/base-table/index.jsx b/src/tabviews/custom/components/table/base-table/index.jsx index b02d9ae..5b5f0f3 100644 --- a/src/tabviews/custom/components/table/base-table/index.jsx +++ b/src/tabviews/custom/components/table/base-table/index.jsx @@ -67,8 +67,6 @@ if (setting.selected !== 'always' && setting.selected !== 'init' && setting.selected !== 'sign') { setting.selected = 'false' - } else { - setting.orisel = true } _config.style = _config.style || {} @@ -85,7 +83,7 @@ }, () => { if (_config.setting.onload === 'true') { setTimeout(() => { - this.loadmaindata() + this.loadData() this.getStatFieldsValue() }, _config.setting.delay || 0) } @@ -94,10 +92,8 @@ /** * @description 涓昏〃鏁版嵁鍔犺浇 - * @param { Boolean } reset 琛ㄦ牸鏄惁閲嶇疆 - * @param { String } repage 琛ㄦ牸鏄惁閲嶇疆椤电爜 */ - async loadmaindata (reset, repage, id) { + async loadData (reset, repage, id) { const { setting, config, search, orderBy, BID, pageIndex, pageSize, BData } = this.state if (setting.supModule && !BID) { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇� @@ -110,9 +106,6 @@ MKEmitter.emit('resetSelectLine', config.uuid, '', '') // 骞挎挱鏁版嵁鍒囨崲 reset && MKEmitter.emit('resetTable', config.uuid, 'true') // 鍒楄〃閲嶇疆 - // if (setting.$hasSyncModule) { - // MKEmitter.emit('syncBalconyData', config.uuid, [], false) - // } this.requestId = '' return @@ -147,38 +140,12 @@ if (result.status) { if (result.$requestId && this.requestId !== result.$requestId) return - 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 (repage === 'false' && result.data.length === 0 && pageIndex > 1) { + this.reloadIndex() + return } - if ((setting.selected !== 'false' || (setting.orisel && id)) && result.data && result.data.length > 0) { - setTimeout(() => { - MKEmitter.emit('mkCheckTopLine', config.uuid, id, setting.selected) - }, 200) - if (setting.selected === 'init') { - this.setState({setting: {...setting, selected: 'false'}}) - } - } else { - MKEmitter.emit('resetSelectLine', config.uuid, '', '') // 骞挎挱鏁版嵁鍒囨崲 - // if (setting.$hasSyncModule) { - // MKEmitter.emit('syncBalconyData', config.uuid, [], false) - // } - } - - reset && MKEmitter.emit('resetTable', config.uuid, repage) // 鍒楄〃閲嶇疆 + reset && MKEmitter.emit('resetTable', config.uuid, repage || '') // 鍒楄〃閲嶇疆 let start = 1 if (setting.laypage) { @@ -214,12 +181,24 @@ total = data[data.length - 1].mk_total || 0 } + if (data.length && (id || setting.selected !== 'false')) { + setTimeout(() => { + MKEmitter.emit('mkCheckTopLine', config.uuid, id, setting.selected) + }, 200) + } else { + MKEmitter.emit('resetSelectLine', config.uuid, '', '') // 骞挎挱鏁版嵁鍒囨崲 + } + this.setState({ data: data, selectedData: [], total: total, loading: false }) + + if (setting.selected === 'init') { + this.setState({setting: {...setting, selected: 'false'}}) + } if (config.autoMatic) { if (result.data && result.data.length > 0) { @@ -249,11 +228,6 @@ async loadLinedata (id, position) { const { setting, config, search, orderBy, BID, pageIndex, pageSize, BData } = this.state - if (config.forbidLine) { - this.reloadtable() - return - } - let searches = fromJS(search).toJS() if (config.setting.useMSearch) { // 涓昏〃鎼滅储鏉′欢 let mainSearch = window.GLOB.SearchBox.get(config.$searchId) || [] @@ -275,7 +249,7 @@ let result = await Api.genericInterface(param) if (result.status) { if (position === 'line_grid' && (!result.data || !result.data[0])) { - this.loadmaindata(true, 'false') + this.reloadIndex() return } @@ -463,7 +437,7 @@ pageIndex: 1, search: searches }, () => { - this.loadmaindata(true, 'true') + this.loadData(true, 'true') this.getStatFieldsValue() }) @@ -481,7 +455,7 @@ this.setState({ pageIndex: pagination.pageIndex }, () => { - this.loadmaindata() + this.loadData() }) } else { if (sorter.order) { @@ -497,25 +471,8 @@ pageSize: pagination.pageSize, orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : '' }, () => { - this.loadmaindata() + this.loadData() }) - } - } - - /** - * @description 琛ㄦ牸鍒锋柊 - */ - reloadtable = (btn, id) => { - if (!btn || btn.resetPageIndex !== 'false') { - this.setState({ - pageIndex: 1 - }, () => { - this.loadmaindata(true, 'true', id) - this.getStatFieldsValue() - }) - } else { - this.loadmaindata(true, 'false', id) - this.getStatFieldsValue() } } @@ -550,7 +507,10 @@ if (config.uuid !== menuId) return if (!id) { - this.reloadtable() + this.reloadIndex() + } else if (config.forbidLine) { + this.loadData(true, 'false', id) + this.getStatFieldsValue() } else { this.loadLinedata(id) } @@ -567,7 +527,7 @@ BData: data }, () => { if (!setting.checkBid) { - this.loadmaindata(true, 'true') + this.loadData(true, 'true') this.getStatFieldsValue() } }) @@ -576,25 +536,32 @@ /** * @description 鎸夐挳鎵ц瀹屾垚鍚庨〉闈㈠埛鏂� - * @param {*} menuId // 鑿滃崟Id - * @param {*} position // 鍒锋柊浣嶇疆 - * @param {*} btn // 鎵ц鐨勬寜閽� */ refreshByButtonResult = (menuId, position, btn, id, lines) => { const { config, BID } = this.state if (config.uuid !== menuId) return + let _id = config.wrap.selected === 'always' ? (id || '') : '' if (position === 'line' || position === 'line_grid') { - if (lines && lines.length === 1 && !config.forbidLine) { - this.loadLinedata(lines[0].$$uuid, position) + if (lines && lines.length === 1) { + if (config.forbidLine) { + this.loadData(true, 'false', lines[0].$$uuid) + this.getStatFieldsValue() + } else { + this.loadLinedata(lines[0].$$uuid, position) + } } else { - this.reloadtable(btn, id) + this.loadData(true, 'false', _id) + this.getStatFieldsValue() } } else if (['mainline', 'maingrid', 'popclose'].includes(position) && config.setting.supModule) { MKEmitter.emit('reloadData', config.setting.supModule, position === 'maingrid' ? '' : BID) + } else if (btn.resetPageIndex !== 'false') { + this.reloadIndex() } else { - this.reloadtable(btn, id) + this.loadData(true, 'false', _id) + this.getStatFieldsValue() } } @@ -602,8 +569,17 @@ const { config } = this.state if (config.$searchId !== searchId) return - - this.reloadtable() + + this.reloadIndex() + } + + reloadIndex = () => { + this.setState({ + pageIndex: 1 + }, () => { + this.loadData(true, 'true') + this.getStatFieldsValue() + }) } autoExec = (times) => { diff --git a/src/tabviews/custom/components/table/edit-table/index.jsx b/src/tabviews/custom/components/table/edit-table/index.jsx index 30e10ab..c3cdecd 100644 --- a/src/tabviews/custom/components/table/edit-table/index.jsx +++ b/src/tabviews/custom/components/table/edit-table/index.jsx @@ -225,7 +225,7 @@ }, () => { if (_config.setting.onload === 'true') { setTimeout(() => { - this.loadmaindata() + this.loadData() }, _config.setting.delay || 0) } }) @@ -421,10 +421,8 @@ /** * @description 涓昏〃鏁版嵁鍔犺浇 - * @param { Boolean } reset 琛ㄦ牸鏄惁閲嶇疆 - * @param { String } repage 琛ㄦ牸鏄惁閲嶇疆椤电爜 */ - async loadmaindata (reset, repage) { + async loadData (reset, repage) { const { setting, config, search, orderBy, BID, pageIndex, pageSize, BData } = this.state if (setting.supModule && !BID) { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇� @@ -530,11 +528,6 @@ */ async loadLinedata (id, position) { const { setting, config, search, orderBy, BID, pageIndex, pageSize, BData } = this.state - - if (config.forbidLine) { - this.reloadtable() - return - } let searches = fromJS(search).toJS() if (config.setting.useMSearch) { // 涓昏〃鎼滅储鏉′欢 @@ -557,7 +550,7 @@ let result = await Api.genericInterface(param) if (result.status) { if (position === 'line_grid' && (!result.data || !result.data[0])) { - this.loadmaindata(true, 'false') + this.reloadIndex() return } @@ -652,7 +645,7 @@ pageIndex: 1, search: searches }, () => { - this.loadmaindata(true, 'true') + this.loadData(true, 'true') }) } @@ -673,23 +666,19 @@ pageSize: pagination.pageSize, orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : '' }, () => { - this.loadmaindata() + this.loadData() }) } /** * @description 琛ㄦ牸鍒锋柊 */ - reloadtable = (btn) => { - if (!btn || btn.resetPageIndex !== 'false') { - this.setState({ - pageIndex: 1 - }, () => { - this.loadmaindata(true, 'true') - }) - } else { - this.loadmaindata(true, 'false') - } + reloadIndex = () => { + this.setState({ + pageIndex: 1 + }, () => { + this.loadData(true, 'true') + }) } /** @@ -723,7 +712,9 @@ if (config.uuid !== menuId) return if (!id) { - this.reloadtable() + this.reloadIndex() + } else if (config.forbidLine) { + this.loadData(true, 'false') } else { this.loadLinedata(id) } @@ -745,7 +736,7 @@ }, () => { if (!setting.checkBid) { setTimeout(() => { - this.loadmaindata(true, 'true') + this.loadData(true, 'true') }, setting.delay || 0) } }) @@ -764,15 +755,21 @@ if (config.uuid !== menuId) return if (position === 'line' || position === 'line_grid') { - if (lines && lines.length === 1 && !config.forbidLine) { - this.loadLinedata(lines[0].$$uuid, position) + if (lines && lines.length === 1) { + if (config.forbidLine) { + this.loadData(true, 'false') + } else { + this.loadLinedata(lines[0].$$uuid, position) + } } else { - this.reloadtable(btn) + this.loadData(true, 'false') } } else if (['mainline', 'maingrid', 'popclose'].includes(position) && config.setting.supModule) { MKEmitter.emit('reloadData', config.setting.supModule, position === 'maingrid' ? '' : BID) + } else if (btn.resetPageIndex !== 'false') { + this.reloadIndex() } else { - this.reloadtable(btn) + this.loadData(true, 'false') } } @@ -805,7 +802,7 @@ if (config.$searchId !== searchId) return - this.reloadtable() + this.reloadIndex() } shouldComponentUpdate (nextProps, nextState) { diff --git a/src/tabviews/custom/components/table/normal-table/index.jsx b/src/tabviews/custom/components/table/normal-table/index.jsx index 12f76e9..ae15927 100644 --- a/src/tabviews/custom/components/table/normal-table/index.jsx +++ b/src/tabviews/custom/components/table/normal-table/index.jsx @@ -79,8 +79,6 @@ if (setting.selected !== 'always' && setting.selected !== 'init' && setting.selected !== 'sign') { setting.selected = 'false' - } else { - setting.orisel = true } if (_config.setting.sync === 'true') { @@ -200,7 +198,7 @@ this.setState({ pageIndex: 1 }, () => { - this.loadmaindata(true, 'true', '', 'timer') + this.loadData(true, 'true', '', 'timer') }) }) } @@ -237,7 +235,7 @@ Api.getLCacheConfig(config.uuid, config.$time, BID).then(res => { if (!res.valid && config.setting.onload === 'true') { setTimeout(() => { - this.loadmaindata(false, 'true', '', 'init') + this.loadData(false, 'true', '', 'init') }, config.setting.delay || 0) } @@ -299,13 +297,13 @@ if (config.setting.onload === 'true') { setTimeout(() => { - this.loadmaindata(false, 'true', '', 'init') + this.loadData(false, 'true', '', 'init') }, config.setting.delay || 0) } } } else if (config.setting.onload === 'true') { setTimeout(() => { - this.loadmaindata() + this.loadData() }, config.setting.delay || 0) } } @@ -511,10 +509,8 @@ /** * @description 涓昏〃鏁版嵁鍔犺浇 - * @param { Boolean } reset 琛ㄦ牸鏄惁閲嶇疆 - * @param { String } repage 琛ㄦ牸鏄惁閲嶇疆椤电爜 */ - async loadmaindata (reset, repage, id, type) { + async loadData (reset, repage, id, type) { const { setting, config, search, orderBy, BID, pageIndex, pageSize, BData } = this.state if (setting.supModule && !BID && setting.supKey !== 'false') { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇� @@ -575,35 +571,9 @@ Api.writeCacheConfig(config.uuid, result.data || [], BID) } - 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(() => { - MKEmitter.emit('mkCheckTopLine', config.uuid, id, setting.selected) - }, 200) - if (setting.selected === 'init') { - this.setState({setting: {...setting, selected: 'false'}}) - } - } else { - MKEmitter.emit('resetSelectLine', config.uuid, '', '') // 骞挎挱鏁版嵁鍒囨崲 - if (setting.$hasSyncModule) { - MKEmitter.emit('syncBalconyData', config.uuid, [], false) - } + if (repage === 'false' && result.data.length === 0 && pageIndex > 1) { + this.reloadIndex() + return } reset && MKEmitter.emit('resetTable', config.uuid, repage) // 鍒楄〃閲嶇疆 @@ -649,6 +619,17 @@ allSearch.push(...searches) } + if (data.length && (id || setting.selected !== 'false')) { + setTimeout(() => { + MKEmitter.emit('mkCheckTopLine', config.uuid, id, setting.selected) + }, 200) + } else { + MKEmitter.emit('resetSelectLine', config.uuid, '', '') // 骞挎挱鏁版嵁鍒囨崲 + if (setting.$hasSyncModule) { + MKEmitter.emit('syncBalconyData', config.uuid, [], false) + } + } + this.setState({ data: data, selectedData: [], @@ -656,6 +637,10 @@ total: total, loading: false }) + + if (setting.selected === 'init') { + this.setState({setting: {...setting, selected: 'false'}}) + } if (config.$hasTopModule) { window.GLOB.CacheData.set(config.uuid + 'tb', data[0] || { $$empty: true, $$uuid: '' }) @@ -686,11 +671,6 @@ async loadLinedata (id, position) { const { setting, config, search, orderBy, BID, pageIndex, pageSize, BData } = this.state - if (config.forbidLine) { - this.reloadtable() - return - } - let searches = fromJS(search).toJS() if (config.setting.useMSearch) { // 涓昏〃鎼滅储鏉′欢 let mainSearch = window.GLOB.SearchBox.get(config.$searchId) || [] @@ -712,7 +692,7 @@ let result = await Api.genericInterface(param) if (result.status) { if (position === 'line_grid' && (!result.data || !result.data[0])) { - this.loadmaindata(true, 'false') + this.reloadIndex() return } @@ -836,7 +816,7 @@ pageIndex: 1, search: searches }, () => { - this.loadmaindata(true, 'true') + this.loadData(true, 'true') }) } @@ -857,23 +837,19 @@ pageSize: pagination.pageSize, orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : '' }, () => { - this.loadmaindata() + this.loadData() }) } /** * @description 琛ㄦ牸鍒锋柊 */ - reloadtable = (btn, id) => { - if (!btn || btn.resetPageIndex !== 'false') { - this.setState({ - pageIndex: 1 - }, () => { - this.loadmaindata(true, 'true', id) - }) - } else { - this.loadmaindata(true, 'false', id) - } + reloadIndex = () => { + this.setState({ + pageIndex: 1 + }, () => { + this.loadData(true, 'true') + }) } /** @@ -907,7 +883,9 @@ if (config.uuid !== menuId) return if (!id) { - this.reloadtable() + this.reloadIndex() + } else if (config.forbidLine) { + this.loadData(true, 'false', id) } else { this.loadLinedata(id) } @@ -932,7 +910,7 @@ if (bid !== this.state.BID || bid !== '') { this.setState({ BID: bid, BData: _data, pageIndex: 1 }, () => { - this.loadmaindata(true, 'true') + this.loadData(true, 'true') }) } } else { @@ -948,7 +926,7 @@ BData: data }, () => { if (!setting.checkBid) { - this.loadmaindata(true, 'true') + this.loadData(true, 'true') } }) } @@ -957,15 +935,13 @@ /** * @description 鎸夐挳鎵ц瀹屾垚鍚庨〉闈㈠埛鏂� - * @param {*} menuId // 鑿滃崟Id - * @param {*} position // 鍒锋柊浣嶇疆 - * @param {*} btn // 鎵ц鐨勬寜閽� */ refreshByButtonResult = (menuId, position, btn, id, lines) => { const { config, BID } = this.state if (config.uuid !== menuId) return + let _id = config.wrap.selected === 'always' ? (id || '') : '' if (config.supNodes) { if (['mainline', 'maingrid', 'popclose'].includes(position)) { let supNode = this.supModules[this.supModules.length - 1] @@ -980,26 +956,38 @@ }) } else { if (position === 'line' || position === 'line_grid') { - if (lines && lines.length === 1 && !config.forbidLine) { - this.loadLinedata(lines[0].$$uuid, position) + if (lines && lines.length === 1) { + if (config.forbidLine) { + this.loadData(true, 'false', lines[0].$$uuid) + } else { + this.loadLinedata(lines[0].$$uuid, position) + } } else { - this.reloadtable(btn, id) + this.loadData(true, 'false', _id) } + } else if (btn.resetPageIndex !== 'false') { + this.reloadIndex() } else { - this.reloadtable(btn, id) + this.loadData(true, 'false', _id) } } } else { if (position === 'line' || position === 'line_grid') { - if (lines && lines.length === 1 && !config.forbidLine) { - this.loadLinedata(lines[0].$$uuid, position) + if (lines && lines.length === 1) { + if (config.forbidLine) { + this.loadData(true, 'false', lines[0].$$uuid) + } else { + this.loadLinedata(lines[0].$$uuid, position) + } } else { - this.reloadtable(btn, id) + this.loadData(true, 'false', _id) } } else if (['mainline', 'maingrid', 'popclose'].includes(position) && config.setting.supModule) { MKEmitter.emit('reloadData', config.setting.supModule, position === 'maingrid' ? '' : BID) + } else if (btn.resetPageIndex !== 'false') { + this.reloadIndex() } else { - this.reloadtable(btn, id) + this.loadData(true, 'false', _id) } } } @@ -1033,7 +1021,7 @@ if (config.$searchId !== searchId) return - this.reloadtable() + this.reloadIndex() } render() { -- Gitblit v1.8.0