From a9b02f6862522b54d0824152017bf2acfec2af7b Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 21 三月 2024 10:29:50 +0800 Subject: [PATCH] 2024-03-21 --- src/tabviews/custom/components/card/data-card/index.jsx | 65 +++++++++++++++++++++++++++----- 1 files changed, 54 insertions(+), 11 deletions(-) diff --git a/src/tabviews/custom/components/card/data-card/index.jsx b/src/tabviews/custom/components/card/data-card/index.jsx index 9cc9fcd..9bc199c 100644 --- a/src/tabviews/custom/components/card/data-card/index.jsx +++ b/src/tabviews/custom/components/card/data-card/index.jsx @@ -38,7 +38,7 @@ loading: false, card: null, data: [], - total: null, + total: 0, precards: [], nextcards: [], selected: 'false', @@ -134,7 +134,13 @@ _config.wrap.scale = _config.wrap.scale === 'true' ? 'scale' : '' _config.wrap.layout = (_config.wrap.layout || 'grid') + '-layout float-' + (_config.wrap.cardFloat || 'left') - _config.wrap.wrapClass = `${_config.wrap.selStyle} ${_config.wrap.cardType || ''} ${_config.wrap.scale}` + _config.wrap.wrapClass = `${_config.wrap.selStyle} ${_config.wrap.cardType || ''} ${_config.wrap.scale} ${config.wrap.hover === 'true' ? 'mk-hover' : ''}` + + if (_config.wrap.shifting === 'true') { + _config.wrap.shifting = 'shifting' + } else { + _config.wrap.shifting = '' + } let pageOptions = ['10', '25', '50', '100', '500', '1000'] @@ -147,6 +153,10 @@ if (!pageOptions.includes(size)) { pageOptions.push(size) pageOptions = pageOptions.sort((a, b) => a - b) + } + + if (_config.wrap.maxPageSize) { + pageOptions = pageOptions.filter(item => item <= _config.wrap.maxPageSize) } } @@ -230,6 +240,8 @@ } this.initExec() + + this.autoExec() } shouldComponentUpdate (nextProps, nextState) { @@ -324,6 +336,25 @@ } } + autoExec = (times) => { + const { config } = this.state + + if (!config.wrap.autoExec) return + + let btn = document.getElementById('button' + config.wrap.autoExec) + + this.autoTimer && clearTimeout(this.autoTimer) + + if (btn) { + MKEmitter.emit('triggerBtnId', config.wrap.autoExec, []) + } else if (!times || times < 20) { + times = times ? times + 1 : 1 + this.autoTimer = setTimeout(() => { + this.autoExec(times) + }, 1000) + } + } + transferSyncData = (syncId) => { const { config } = this.state @@ -398,9 +429,9 @@ }, i * 10) }) } else { - if (position === 'line') { + if (position === 'line' || position === 'line_grid') { if (lines && lines.length === 1) { - this.loadLinedata(lines[0].$$uuid) + this.loadLinedata(lines[0].$$uuid, position) } else { this.loadData(id) } @@ -417,9 +448,9 @@ } else { let supModule = config.setting.supModule - if (position === 'line') { + if (position === 'line' || position === 'line_grid') { if (lines && lines.length === 1) { - this.loadLinedata(lines[0].$$uuid) + this.loadLinedata(lines[0].$$uuid, position) } else { this.loadData(id) } @@ -674,7 +705,9 @@ if (!config.setting.supModule || config.setting.supModule !== MenuID) return if (id !== this.state.BID || id !== '') { this.setState({ BID: id, BData: data, pageIndex: 1 }, () => { - this.loadData() + if (!config.checkBid) { + this.loadData() + } }) } } @@ -710,6 +743,7 @@ if (config.setting.supModule && !BID && config.wrap.supKey !== 'false') { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇� this.loaded = true + this.requestId = '' this.setState({ activeKey: '', @@ -756,8 +790,12 @@ let _orderBy = orderBy || config.setting.order || '' let param = UtilsDM.getQueryDataParams(config.setting, searches, _orderBy, pageIndex, pageSize, BID) - let result = await Api.genericInterface(param) + this.requestId = config.uuid + new Date().getTime() + + let result = await Api.genericInterface(param, '', '', this.requestId) if (result.status) { + if (result.$requestId && this.requestId !== result.$requestId) return + let start = 1 if (config.setting.laypage) { start = pageSize * (pageIndex - 1) + 1 @@ -870,7 +908,7 @@ /** * @description 鑾峰彇鍗曡鏁版嵁 */ - async loadLinedata (id) { + async loadLinedata (id, position) { const { config, pageIndex, pageSize, search, BID, BData, orderBy } = this.state if (config.forbidLine) { @@ -902,6 +940,11 @@ let result = await Api.genericInterface(param) if (result.status) { + if (position === 'line_grid' && (!result.data || !result.data[0])) { + this.loadData() + return + } + let data = fromJS(this.state.data).toJS() let selectedData = fromJS(this.state.selectedData).toJS() let selectKeys = fromJS(this.state.selectKeys).toJS() @@ -1173,7 +1216,7 @@ } return ( - <div className="custom-data-card-box" id={'anchor' + config.uuid} style={config.style}> + <div className={'custom-data-card-box ' + config.wrap.shifting} id={'anchor' + config.uuid} style={config.style}> {loading ? <div className="loading-mask"> {data.length ? <div className="ant-spin-blur"></div> : null} @@ -1208,7 +1251,7 @@ let className = 'mk-card ' if (config.wrap.parity === 'true') { if (index % 2 === 1) { - className += 'mk-parity-bg ' + className += 'mk-even-line ' } } if (item.$disabled) { -- Gitblit v1.8.0