From b69b5f6329ca5f87932436b7a6c1ddfc3377e10f Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 16 五月 2024 10:56:41 +0800 Subject: [PATCH] 2024-05-16 --- src/tabviews/custom/components/card/balcony/index.jsx | 101 ++++++++++++++++++++++++-------------------------- 1 files changed, 48 insertions(+), 53 deletions(-) diff --git a/src/tabviews/custom/components/card/balcony/index.jsx b/src/tabviews/custom/components/card/balcony/index.jsx index ff3bec1..3b9b8f7 100644 --- a/src/tabviews/custom/components/card/balcony/index.jsx +++ b/src/tabviews/custom/components/card/balcony/index.jsx @@ -1,7 +1,7 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Spin, notification, Checkbox, Modal } from 'antd' +import { Spin, Checkbox } from 'antd' import Api from '@/api' import UtilsDM from '@/utils/utils-datamanage.js' @@ -55,7 +55,7 @@ _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' @@ -71,12 +71,26 @@ _data = window.GLOB.CacheData.get(_config.wrap.publicId) _data = fromJS(_data).toJS() } + } else { + _config.elements.forEach(item => { + if (item.eleType === 'button') return + if (item.datatype === 'dynamic' && item.field) { + item.field = item.field.toLowerCase() + } + }) } _data.$$BID = BID || '' _data.$$BData = BData || '' if (_config.setting.primaryKey) { _data.$$uuid = _data[_config.setting.primaryKey] || '' + } + + if (_config.wrap.datatype === 'static' && BData) { + Object.keys(BData).forEach(key => { + if (/\$/.test(key)) return + _data[key.toLowerCase()] = BData[key] + }) } if (!_config.style.position) { @@ -118,8 +132,7 @@ syncConfig, data: _data, BID: BID || '', - config: _config, - arr_field: _config.columns.map(col => col.field).join(',') + config: _config }) } @@ -144,7 +157,7 @@ if (config.wrap.datatype === 'dynamic') { if (config.timer) { 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() @@ -172,21 +185,21 @@ } initExec = () => { - const { config } = this.state + const { config, BID } = this.state 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}) @@ -194,10 +207,10 @@ } } 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}) @@ -206,7 +219,7 @@ if (config.setting.onload === 'true') { setTimeout(() => { - this.loadData() + this.loadData('init') }, config.setting.delay || 0) } } @@ -227,7 +240,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} @@ -253,7 +266,6 @@ _data.$$BID = BID || '' _data.$$BData = BData || '' - _data.$$uuid = _data[config.setting.primaryKey] || '' this.setState({data: _data}) } @@ -275,8 +287,8 @@ this.loadData() } else { - if ((position === 'mainline' || position === 'popclose') && config.wrap.supModule && BID) { // 鍒锋柊婧愮粍浠舵椂锛岄檮甯﹀埛鏂颁笂绾ц涓庡綋鍓嶇粍浠� - MKEmitter.emit('reloadData', config.wrap.supModule, BID) + if (['mainline', 'maingrid', 'popclose'].includes(position) && config.wrap.supModule) { + MKEmitter.emit('reloadData', config.wrap.supModule, position === 'maingrid' ? '' : BID) } else { this.loadData() } @@ -339,10 +351,8 @@ if (config.uuid !== menuId) return callback({ - arr_field: '', orderBy: '', search: [], - menuName: config.name }) } @@ -354,8 +364,8 @@ this.loadData() } - async loadData (hastimer) { - const { config, arr_field, BID, BData } = this.state + async loadData (type) { + const { config, BID, BData } = this.state if (config.wrap.datatype === 'public') { MKEmitter.emit('reloadData', config.wrap.publicId) @@ -363,8 +373,16 @@ } if (config.wrap.datatype === 'static') { + 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: {$$BID: BID || '', $$BData: BData, $$empty: true}, + data: _data }) return } else if (config.setting.supModule && !BID) { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇� @@ -377,22 +395,22 @@ let searches = [] - 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]) { @@ -417,37 +435,14 @@ } } - 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