From 24842b40de5cd60700bf69dfd38a0332f5431e36 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 23 五月 2025 10:55:07 +0800 Subject: [PATCH] Merge branch 'master' into positec --- src/tabviews/custom/components/card/prop-card/index.jsx | 210 ++++++++++++++++++++++++++++++---------------------- 1 files changed, 121 insertions(+), 89 deletions(-) diff --git a/src/tabviews/custom/components/card/prop-card/index.jsx b/src/tabviews/custom/components/card/prop-card/index.jsx index 3ea4c17..2c4e2d2 100644 --- a/src/tabviews/custom/components/card/prop-card/index.jsx +++ b/src/tabviews/custom/components/card/prop-card/index.jsx @@ -1,7 +1,7 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Spin, notification, Col, Row, Modal } from 'antd' +import { Spin, Col, Row } from 'antd' import Api from '@/api' import UtilsDM from '@/utils/utils-datamanage.js' @@ -47,15 +47,19 @@ if (BData) { BID = BData.$BID || '' } - - if (_config.wrap.datatype === 'dynamic') { - _config.setting.onload = _config.setting.sync === 'true' ? 'false' : 'true' + if (_config.wrap.datatype === 'dynamic') { + _config.setting.onload = _config.setting.sync === 'true' ? 'false' : _config.setting.onload || 'true' + + if (_config.setting.supModule && !BID) { + _config.setting.onload = 'false' + } + if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { _data = window.GLOB.SyncData.get(_config.dataName) || [] if (_config.$cache) { - Api.writeCacheConfig(_config.uuid, fromJS(_data).toJS()) + Api.writeCacheConfig(_config.uuid, fromJS(_data).toJS(), BID) } _config.setting.sync = 'false' @@ -66,16 +70,32 @@ window.GLOB.SyncData.delete(_config.dataName) } - } else if (_config.wrap.datatype === 'public' && window.GLOB.CacheData.get(_config.wrap.publicId)) { + } else if (_config.wrap.datatype === 'public' && window.GLOB.CacheData.has(_config.wrap.publicId)) { _data = window.GLOB.CacheData.get(_config.wrap.publicId) _data = fromJS(_data).toJS() this.loaded = true } else if (_config.wrap.datatype === 'static') { this.loaded = true + _config.subcards.forEach(card => { + card.elements.forEach(ele => { + if (ele.eleType === 'button') return + if (ele.datatype === 'dynamic' && ele.field) { + ele.field = ele.field.toLowerCase() + } + }) + }) } _data.$$BID = BID || '' _data.$$BData = BData || '' + + if (_config.wrap.datatype === 'static' && BData) { + Object.keys(BData).forEach(key => { + if (/\$/.test(key)) return + _data[key.toLowerCase()] = BData[key] + }) + } + if (_config.setting.primaryKey) { _data.$$uuid = _data[_config.setting.primaryKey] || '' } @@ -103,7 +123,7 @@ let selected = _config.wrap.selected || 'false' - _config.wrap.selStyle = _config.wrap.selStyle || 'active' + _config.wrap.selStyle = _config.wrap.selStyle || 'none' _config.wrap.priKeyType = _config.wrap.priKeyType || 'static' _config.wrap.scale = _config.wrap.scale === 'true' ? 'scale' : '' @@ -118,8 +138,7 @@ data: _data, BID: BID || '', BData: BData || '', - config: _config, - arr_field: _config.columns.map(col => col.field).join(',') + config: _config }) } @@ -132,21 +151,19 @@ MKEmitter.addListener('queryModuleParam', this.queryModuleParam) MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) - if (config.setting.useMSearch) { - MKEmitter.addListener('searchRefresh', this.searchRefresh) - } - if (config.setting.sync === 'true') { MKEmitter.addListener('transferSyncData', this.transferSyncData) } if (config.wrap.datatype === 'public') { MKEmitter.addListener('mkPublicData', this.mkPublicData) + } else if (config.setting.useMSearch) { + MKEmitter.addListener('searchRefresh', this.searchRefresh) } - if (config.timer && config.wrap.datatype === 'dynamic') { + if (config.timer && config.wrap.datatype !== 'public') { this.timer = new TimerTask() - this.timer.init(config.uuid, config.timer, config.timerRepeats, () => {this.loadData(true)}) + this.timer.init(config.uuid, config.timer, config.timerRepeats, () => {this.loadData('timer')}) } this.initExec() @@ -173,33 +190,52 @@ } initExec = () => { - const { config, selected, data } = this.state + const { config, selected, data, BID } = this.state if (config.wrap.datatype === 'dynamic') { if (config.$cache) { if (config.$time) { if (!this.loaded) { - Api.getLCacheConfig(config.uuid, config.$time).then(res => { - if (!res && config.setting.onload === 'true') { + Api.getLCacheConfig(config.uuid, config.$time, BID).then(res => { + if (!res.valid && config.setting.onload === 'true') { setTimeout(() => { - this.loadData() + this.loadData('init') }, config.setting.delay || 0) } - - if (!res || this.loaded) return + + if (!res.data || this.loaded) return - let _data = res[0] || {$$empty: true} + let _data = res.data[0] || {$$empty: true} _data.$$uuid = _data[config.setting.primaryKey] || '' - this.setState({data: _data}) + this.setState({data: _data}, () => { + if (selected !== 'false') { + this.checkTopLine() + } else if (config.wrap.empty === 'hidden') { + MKEmitter.emit('resetSelectLine', config.uuid, _data.$$uuid || '', _data) + } + }) }) + } else { + if (config.wrap.goback === 'true' && data.$$empty) { + this.timer && this.timer.stop() + + MKEmitter.emit('closeTabView', config.$pageId) + } else { + if (selected !== 'false') { + this.checkTopLine() + } else { + this.transferLine() + } + this.autoExec() + } } } else { if (!this.loaded) { - Api.getLCacheConfig(config.uuid, 0).then(res => { - if (!res || this.loaded) return + Api.getLCacheConfig(config.uuid, 0, BID).then(res => { + if (!res.data || this.loaded) return - let _data = res[0] || {$$empty: true} + let _data = res.data[0] || {$$empty: true} _data.$$uuid = _data[config.setting.primaryKey] || '' this.setState({data: _data}) @@ -208,7 +244,7 @@ if (config.setting.onload === 'true') { setTimeout(() => { - this.loadData() + this.loadData('init') }, config.setting.delay || 0) } else if (this.loaded) { if (config.wrap.goback === 'true' && data.$$empty) { @@ -252,7 +288,7 @@ } else { if (selected !== 'false') { this.checkTopLine() - } else if (data.$$uuid) { + } else { this.transferLine() } this.autoExec() @@ -260,18 +296,16 @@ } } else { if (selected !== 'false') { - setTimeout(() => { - this.checkTopLine() - }, 200) + this.checkTopLine() } if (config.$cache && config.$time && config.wrap.autoExec) { - Api.getLCacheConfig(config.uuid, config.$time).then(res => { - if (!res) { - this.autoExec() - } else { - Api.writeCacheConfig(config.uuid, []) - } + Api.getLCacheConfig(config.uuid, config.$time, BID).then(res => { + if (res.valid) return + + this.autoExec() + + Api.writeCacheConfig(config.uuid, [], BID) }) } else { this.autoExec() @@ -289,7 +323,7 @@ let _data = window.GLOB.SyncData.get(config.dataName) || [] if (config.$cache) { - Api.writeCacheConfig(config.uuid, fromJS(_data).toJS()) + Api.writeCacheConfig(config.uuid, fromJS(_data).toJS(), BID) } _data = _data[0] || {$$empty: true} @@ -308,7 +342,7 @@ } else { if (selected !== 'false') { this.checkTopLine() - } else if (_data.$$uuid) { + } else { this.transferLine() } this.autoExec() @@ -338,7 +372,6 @@ _data.$$BID = BID || '' _data.$$BData = BData || '' - _data.$$uuid = _data[config.setting.primaryKey] || '' this.loaded = true @@ -362,14 +395,22 @@ autoExec = (times) => { const { config, data } = this.state - if (!config.wrap.autoExec) return + if (!config.wrap.autoExec || (config.wrap.emptyExec === 'false' && data.$$empty)) return let btn = document.getElementById('button' + config.wrap.autoExec) - clearTimeout(this.autoTimer) + this.autoTimer && clearTimeout(this.autoTimer) - if (btn) { - MKEmitter.emit('triggerBtnId', config.wrap.autoExec, data.$$empty ? [] : [data]) + if (config.setting.supModule && config.wrap.datatype === 'static' && !data.$$BID) { + + } else if (btn) { + if (config.wrap.execDelay) { + setTimeout(() => { + MKEmitter.emit('triggerBtnId', config.wrap.autoExec, data.$$empty ? [] : [data]) + }, config.wrap.execDelay) + } else { + MKEmitter.emit('triggerBtnId', config.wrap.autoExec, data.$$empty ? [] : [data]) + } } else if (!times || times < 20) { times = times ? times + 1 : 1 this.autoTimer = setTimeout(() => { @@ -399,7 +440,12 @@ transferLine = () => { const { config, data } = this.state - if (config.wrap.cardType) return + if (config.wrap.cardType) { + if (config.wrap.empty === 'hidden') { + MKEmitter.emit('resetSelectLine', config.uuid, data.$$uuid || '', data) + } + return + } MKEmitter.emit('resetSelectLine', config.uuid, data.$$uuid || '', data) } @@ -415,10 +461,10 @@ if (config.uuid !== menuId) return - if ((position === 'mainline' || position === 'popclose') && config.setting.supModule && BID) { // 鍒锋柊婧愮粍浠舵椂锛岄檮甯﹀埛鏂颁笂绾ц涓庡綋鍓嶇粍浠� - MKEmitter.emit('reloadData', config.setting.supModule, BID) + if (['mainline', 'maingrid', 'popclose'].includes(position) && config.setting.supModule) { + MKEmitter.emit('reloadData', config.setting.supModule, position === 'maingrid' ? '' : BID) } else { - this.loadData(false, btn) + this.loadData('', btn) } } @@ -442,7 +488,9 @@ if (id !== this.state.BID || id !== '') { this.setState({ BID: id, BData: data }, () => { - this.loadData() + if (config.wrap.datatype !== 'public') { + this.loadData() + } }) } } @@ -461,10 +509,8 @@ } callback({ - arr_field: '', orderBy: '', - search: searches, - menuName: config.name + search: searches }) } @@ -476,8 +522,8 @@ this.loadData() } - async loadData (hastimer, btn) { - const { config, arr_field, BID, BData, selected } = this.state + async loadData (type, btn) { + const { config, BID, BData, selected } = this.state if (config.wrap.datatype === 'public') { MKEmitter.emit('reloadData', config.wrap.publicId) @@ -485,13 +531,21 @@ } if (config.wrap.datatype === 'static') { - this.setState({ - data: {$$BID: BID || '', $$BData: BData, $$empty: true}, - }) - - if (!btn) { - this.autoExec() + let _data = {$$BID: BID || '', $$BData: BData, $$empty: true, $$time: new Date().getTime()} + if (BData) { + Object.keys(BData).forEach(key => { + if (/\$/.test(key)) return + _data[key.toLowerCase()] = BData[key] + }) } + + this.setState({ + data: _data, + }, () => { + if (!btn) { + this.autoExec() + } + }) return } else if (config.setting.supModule && !BID) { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇� this.setState({ @@ -510,22 +564,22 @@ return } - if (!hastimer) { + if (type !== 'timer') { this.setState({ loading: true }) } let _orderBy = config.setting.order || '' - let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, 1, 1, BID) + let param = UtilsDM.getQueryDataParams(config.setting, searches, _orderBy, 1, 1, BID) let result = await Api.genericInterface(param) if (result.status) { let _data = {} this.loaded = true - if (config.$cache && config.setting.onload !== 'false') { - Api.writeCacheConfig(config.uuid, result.data || []) + if (config.$cache && type === 'init') { + Api.writeCacheConfig(config.uuid, result.data || [], BID) } if (!result.data || !result.data[0]) { @@ -564,37 +618,15 @@ this.timer && this.timer.stop() } } - if (result.message) { - if (result.ErrCode === 'Y') { - Modal.success({ - title: result.message - }) - } else if (result.ErrCode === 'S') { - notification.success({ - top: 92, - message: result.message, - duration: 2 - }) - } - } + + UtilsDM.querySuccess(result) } else { this.setState({ loading: false }) this.timer && this.timer.stop() - if (!result.message) return - if (result.ErrCode === 'N') { - Modal.error({ - title: result.message, - }) - } else if (result.ErrCode !== '-2') { - notification.error({ - top: 92, - message: result.message, - duration: 10 - }) - } + UtilsDM.queryFail(result) } } -- Gitblit v1.8.0