| | |
| | | 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' |
| | |
| | | } |
| | | |
| | | if (_config.wrap.datatype === 'dynamic') { |
| | | _config.setting.onload = _config.setting.sync === 'true' ? 'false' : 'true' |
| | | _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) || [] |
| | | |
| | |
| | | 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] || '' |
| | | } |
| | |
| | | |
| | | 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' : '' |
| | | |
| | |
| | | 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('timer')}) |
| | | } |
| | |
| | | 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 (selected !== 'false') { |
| | | this.checkTopLine() |
| | | } else if (data.$$uuid) { |
| | | } else { |
| | | this.transferLine() |
| | | } |
| | | this.autoExec() |
| | |
| | | } else { |
| | | if (selected !== 'false') { |
| | | this.checkTopLine() |
| | | } else if (_data.$$uuid) { |
| | | } else { |
| | | this.transferLine() |
| | | } |
| | | this.autoExec() |
| | |
| | | |
| | | 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(() => { |
| | |
| | | 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) |
| | | } |
| | |
| | | |
| | | 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('', btn) |
| | | } |
| | |
| | | |
| | | if (id !== this.state.BID || id !== '') { |
| | | this.setState({ BID: id, BData: data }, () => { |
| | | this.loadData() |
| | | if (config.wrap.datatype !== 'public') { |
| | | this.loadData() |
| | | } |
| | | }) |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | 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({ |
| | |
| | | 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) |
| | | } |
| | | } |
| | | |