| | |
| | | window.GLOB.CacheVoucher = new Map() // 缓存凭证信息 |
| | | window.GLOB.UserCacheMap = new Map() // 缓存用户自定义设置 |
| | | window.GLOB.CacheData = new Map() // 存储选中数据 |
| | | window.GLOB.SearchBox = new Map() // 存储搜索条件 |
| | | window.GLOB.SyncData = new Map() // 存储同步查询数据 |
| | | |
| | | render(Route) |
| | | }) |
| | |
| | | viewlost: false, // 页面丢失:1、未获取到配置-页面丢失;2、页面未启用 |
| | | lostmsg: '', // 页面丢失时的提示信息 |
| | | config: null, // 页面配置信息,包括组件等 |
| | | mainSearch: null, // 主搜索 |
| | | userConfig: null, // 用户自定义设置 |
| | | data: null, // 列表数据集 |
| | | loading: false, // 列表数据加载中 |
| | | visible: false, // 标签页控制 |
| | | shortcuts: null, // 快捷键 |
| | |
| | | } |
| | | |
| | | // 获取主搜索条件 |
| | | let mainSearch = [] |
| | | config.components.forEach(component => { |
| | | if (component.type === 'tabs') return |
| | | |
| | | component.search = component.search.map(item => { |
| | | item.oriInitval = item.initval |
| | | if (['text', 'select', 'link'].includes(item.type) && param.$searchkey === item.field) { |
| | | item.initval = param.$searchval |
| | | if (param.$searchkey) { |
| | | component.search = component.search.map(item => { |
| | | if (['text', 'select', 'link'].includes(item.type) && param.$searchkey === item.field) { |
| | | item.initval = param.$searchval |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | | component.$searches = Utils.initMainSearch(component.search) |
| | | } |
| | | |
| | | if (component.$searches.length) { |
| | | component.$main = true |
| | | |
| | | window.GLOB.SearchBox.set(MenuID, component.$searches) |
| | | |
| | | if (component.$s_req) { |
| | | window.GLOB.SearchBox.set(MenuID + 'required', true) |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | | mainSearch = Utils.initMainSearch(component.search) |
| | | } |
| | | }) |
| | | |
| | | let BID = param.$BID || '' |
| | |
| | | BID: BID, |
| | | shortcuts: shortcuts.length > 0 ? shortcuts : null, |
| | | config, |
| | | autoMatic, |
| | | mainSearch |
| | | autoMatic |
| | | }, () => { |
| | | setTimeout(() => { // 延时加载状态 |
| | | this.setState({ |
| | |
| | | filterComponent = (components, roleId, permAction, skip, urlparam, pageId, MenuName) => { |
| | | return components.filter(item => { |
| | | item.$pageId = pageId |
| | | item.$searchId = pageId |
| | | |
| | | item.$menuname = (MenuName || '') + '-' + (item.name || '主表') |
| | | |
| | |
| | | } |
| | | |
| | | // 搜索条件初始化 |
| | | if (item.search && item.search.length > 0) { |
| | | item.search = Utils.initSearchVal(item.search) |
| | | } |
| | | Utils.initSearchVal(item) |
| | | |
| | | item.$searches = Utils.initMainSearch(item.search) |
| | | |
| | | if (item.setting.supModule) { |
| | | let pid = item.setting.supModule.pop() |
| | |
| | | } |
| | | |
| | | component.setting.useMSearch = component.setting.useMSearch === 'true' |
| | | if (component.setting.useMSearch) { |
| | | if (!window.GLOB.SearchBox.has(component.$searchId)) { |
| | | component.setting.useMSearch = false |
| | | } else if (window.GLOB.SearchBox.has(component.$searchId + 'required')) { |
| | | component.$s_req = true |
| | | } |
| | | } |
| | | |
| | | if (component.setting.interType !== 'system') { // 不使用系统函数时 |
| | | component.setting.sync = 'false' |
| | |
| | | } |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | component.setting.dataresource = component.setting.dataresource.replace(/\$@/ig, '/*').replace(/@datam@/ig, '\'Y\'') |
| | | component.setting.dataresource = component.setting.dataresource.replace(/@\$/ig, '*/') |
| | | _customScript = _customScript.replace(/\$@/ig, '/*').replace(/@datam@/ig, '\'Y\'') |
| | | _customScript = _customScript.replace(/@\$/ig, '*/') |
| | | component.setting.dataresource = component.setting.dataresource.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') |
| | | _customScript = _customScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') |
| | | } else { |
| | | component.setting.dataresource = component.setting.dataresource.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | | _customScript = _customScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | |
| | | } else { |
| | | window.GLOB.CacheData.delete(item.uuid) |
| | | } |
| | | if (item.type !== 'tabs' && item.$main) { |
| | | window.GLOB.SearchBox.delete(item.$searchId) |
| | | } |
| | | }) |
| | | } |
| | | |
| | |
| | | config: null, // 页面配置信息,包括组件等 |
| | | loading: false, // 列表数据加载中 |
| | | shortcuts: null, |
| | | data: '' |
| | | }, () => { |
| | | this.loadconfig() |
| | | }) |
| | | } |
| | | |
| | | resetSearch = (search) => { |
| | | this.setState({mainSearch: null}, () => { |
| | | this.setState({mainSearch: search}) |
| | | }) |
| | | } |
| | | |
| | | getComponents = () => { |
| | | const { config, data, mainSearch } = this.state |
| | | const { config } = this.state |
| | | |
| | | if (!config || !config.components) return |
| | | |
| | |
| | | if (item.type === 'tabs') { |
| | | return ( |
| | | <Col span={item.width} key={item.uuid}> |
| | | <AntvTabs config={item} mainSearch={mainSearch} /> |
| | | <AntvTabs config={item}/> |
| | | </Col> |
| | | ) |
| | | } else { |
| | | return ( |
| | | <Col span={item.width} key={item.uuid}> |
| | | <MkBaseTable config={item} data={data}/> |
| | | <MkBaseTable config={item}/> |
| | | </Col> |
| | | ) |
| | | } |
| | |
| | | statFields: [], // 合计字段 |
| | | statFValue: [], // 合计值 |
| | | absFields: [], // 绝对值字段 |
| | | hasReqFields: false, |
| | | autoMatic: null, |
| | | visible: false |
| | | } |
| | |
| | | chartId = config.charts[0] ? config.charts[0].uuid : '' |
| | | } |
| | | |
| | | config.search = Utils.initSearchVal(config.search) |
| | | Utils.initSearchVal(config) |
| | | |
| | | // 字段透视及必填标志 |
| | | let hasReqFields = false |
| | | config.search = config.search.map(item => { |
| | | if (['text', 'select', 'link'].includes(item.type) && param && param.$searchkey === item.field) { |
| | | item.initval = param.$searchval |
| | | } |
| | | |
| | | if (item.required) { |
| | | hasReqFields = true |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | |
| | | } |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | config.setting.dataresource = config.setting.dataresource.replace(/\$@/ig, '/*') |
| | | config.setting.dataresource = config.setting.dataresource.replace(/@\$/ig, '*/') |
| | | config.setting.customScript = config.setting.customScript.replace(/\$@/ig, '/*') |
| | | config.setting.customScript = config.setting.customScript.replace(/@\$/ig, '*/') |
| | | config.setting.dataresource = config.setting.dataresource.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/') |
| | | config.setting.customScript = config.setting.customScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/') |
| | | } else { |
| | | config.setting.dataresource = config.setting.dataresource.replace(/@\$|\$@/ig, '') |
| | | config.setting.customScript = config.setting.customScript.replace(/@\$|\$@/ig, '') |
| | |
| | | columns: _columns, |
| | | arr_field: _arrField.join(','), |
| | | BID: param && param.$BID ? param.$BID : '', |
| | | search: Utils.initMainSearch(config.search), |
| | | hasReqFields |
| | | search: Utils.initMainSearch(config.search) |
| | | }, () => { |
| | | if (config.setting.onload !== 'false') { // 初始化可加载 |
| | | this.loadData() |
| | |
| | | |
| | | loadData = (id) => { |
| | | const { MenuID } = this.props |
| | | const { setting, search, hasReqFields, ContainerId } = this.state |
| | | const { setting, search, config, ContainerId } = this.state |
| | | |
| | | this.setState({ |
| | | selectedData: [] |
| | | }) |
| | | MKEmitter.emit('changeTableLine', ContainerId, MenuID, '', '') |
| | | |
| | | if (hasReqFields) { |
| | | if (config.$s_req) { |
| | | let requireFields = search.filter(item => item.required && item.value === '') |
| | | |
| | | if (requireFields.length > 0) { |
| | |
| | | import { Spin, notification, Modal } from 'antd' |
| | | |
| | | import Api from '@/api' |
| | | import Utils from '@/utils/utils.js' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import UtilsDM from '@/utils/utils-datamanage.js' |
| | | import MKEmitter from '@/utils/events.js' |
| | |
| | | class NormalCalendar extends Component { |
| | | static propTpyes = { |
| | | config: PropTypes.object, // 组件配置信息 |
| | | mainSearch: PropTypes.any, // 外层搜索条件 |
| | | } |
| | | |
| | | state = { |
| | |
| | | BData: BData, |
| | | config: _config, |
| | | arr_field: _config.columns.map(col => col.field).join(','), |
| | | search: Utils.initMainSearch(_config.search) // 搜索条件初始化(含有时间格式,需要转化) |
| | | search: _config.$searches |
| | | }, () => { |
| | | if (_config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | | MKEmitter.addListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) |
| | | |
| | | if (config.setting.useMSearch) { |
| | | MKEmitter.addListener('searchRefresh', this.searchRefresh) |
| | | } |
| | | |
| | | if (config.$cache && !this.loaded) { |
| | | Api.getLCacheConfig(config.uuid).then(res => { |
| | |
| | | return |
| | | } |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('searchRefresh', this.searchRefresh) |
| | | MKEmitter.removeListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) |
| | | } |
| | | |
| | | /** |
| | | * @description 图表数据更新,刷新内容 |
| | | */ |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | searchRefresh = (searchId) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | if (config.$searchId !== searchId) return |
| | | |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | async loadData () { |
| | | const { mainSearch } = this.props |
| | | const { config, arr_field, BID, search, year } = this.state |
| | | |
| | | if (config.setting.supModule && !BID) { // BID 不存在时,不做查询 |
| | |
| | | } |
| | | |
| | | let searches = fromJS(search).toJS() |
| | | if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | let keys = searches.map(item => item.key.toLowerCase()) |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | let mainSearch = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | let keys = config.$s_keys || [] |
| | | mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key.toLowerCase())) { |
| | | searches.push(item) |
| | | } |
| | | if (keys.includes(item.key.toLowerCase())) return |
| | | |
| | | searches.push(item) |
| | | }) |
| | | } |
| | | |
| | | let requireFields = searches.filter(item => item.required && item.value === '') |
| | | if (requireFields.length > 0) { |
| | | if (config.$s_req && searches.filter(item => item.required && item.value === '').length > 0) { |
| | | return |
| | | } |
| | | |
| | |
| | | |
| | | class BalconyComponent extends Component { |
| | | static propTpyes = { |
| | | data: PropTypes.array, |
| | | config: PropTypes.object, |
| | | config: PropTypes.object |
| | | } |
| | | |
| | | state = { |
| | |
| | | config: null, |
| | | syncConfig: null, |
| | | loading: false, |
| | | sync: false, |
| | | data: {}, |
| | | BData: null, |
| | | syncData: [], |
| | |
| | | loaded = false |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { data, initdata } = this.props |
| | | let _config = fromJS(this.props.config).toJS() |
| | | const { config } = this.props |
| | | |
| | | let _data = { $$empty: true } |
| | | let _sync = false |
| | | |
| | | let _config = fromJS(config).toJS() |
| | | let BID = '' |
| | | let BData = '' |
| | | |
| | |
| | | BID = BData.$BID || '' |
| | | } |
| | | |
| | | let _data = { $$empty: true } |
| | | if (_config.wrap.datatype === 'dynamic') { |
| | | _sync = _config.setting.sync === 'true' |
| | | if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { |
| | | _data = window.GLOB.SyncData.get(_config.dataName) || [] |
| | | |
| | | if (_sync && data) { |
| | | _data = data[_config.dataName] || {$$empty: true} |
| | | if (_data && Array.isArray(_data)) { |
| | | _data = _data[0] || {$$empty: true} |
| | | if (_config.$cache) { |
| | | Api.writeCacheConfig(_config.uuid, fromJS(_data).toJS()) |
| | | } |
| | | _sync = false |
| | | |
| | | _config.setting.sync = 'false' |
| | | |
| | | _data = _data[0] || {$$empty: true} |
| | | |
| | | this.loaded = true |
| | | } else if (_sync && initdata) { |
| | | _data = initdata |
| | | if (Array.isArray(_data)) { |
| | | _data = _data[0] || {$$empty: true} |
| | | } |
| | | _sync = false |
| | | this.loaded = true |
| | | |
| | | window.GLOB.SyncData.delete(_config.dataName) |
| | | } |
| | | } else if (_config.wrap.datatype === 'public' && window.GLOB.CacheData.get(_config.wrap.publicId)) { |
| | | _data = window.GLOB.CacheData.get(_config.wrap.publicId) |
| | |
| | | this.setState({ |
| | | show, |
| | | syncConfig, |
| | | sync: _sync, |
| | | data: _data, |
| | | BID: BID || '', |
| | | config: _config, |
| | | arr_field: _config.columns.map(col => col.field).join(','), |
| | | }, () => { |
| | | if (_config.wrap.datatype === 'dynamic' && _config.setting && _config.setting.sync !== 'true') { |
| | | if (_config.wrap.datatype === 'dynamic' && config.setting.sync !== 'true') { |
| | | setTimeout(() => { |
| | | this.loadData() |
| | | }, _config.setting.delay || 0) |
| | |
| | | const { config } = this.state |
| | | |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | | MKEmitter.addListener('refreshLineData', this.refreshLineData) |
| | | MKEmitter.addListener('syncBalconyData', this.syncBalconyData) |
| | | MKEmitter.addListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.addListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.addListener('refreshLineData', this.refreshLineData) |
| | | MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) |
| | | |
| | | if (config.setting.sync === 'true') { |
| | | MKEmitter.addListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | |
| | | if (config.wrap.datatype === 'public') { |
| | | MKEmitter.addListener('mkPublicData', this.mkPublicData) |
| | |
| | | Api.getLCacheConfig(config.uuid).then(res => { |
| | | if (!res || this.loaded) return |
| | | |
| | | let _data = res[0] |
| | | let _data = res[0] || {$$empty: true} |
| | | _data.$$uuid = _data[config.setting.primaryKey] || '' |
| | | |
| | | this.setState({data: _data}) |
| | |
| | | } |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('mkPublicData', this.mkPublicData) |
| | | MKEmitter.removeListener('refreshLineData', this.refreshLineData) |
| | | MKEmitter.removeListener('syncBalconyData', this.syncBalconyData) |
| | | MKEmitter.removeListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.removeListener('refreshLineData', this.refreshLineData) |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) |
| | | |
| | | this.timer && this.timer.stop() |
| | | } |
| | | |
| | | /** |
| | | * @description 图表数据更新,刷新内容 |
| | | */ |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | const { sync, config, BID, BData } = this.state |
| | | transferSyncData = (syncId) => { |
| | | const { config } = this.state |
| | | |
| | | if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) { |
| | | let _data = {$$empty: true} |
| | | if (nextProps.data && nextProps.data[config.dataName]) { |
| | | _data = nextProps.data[config.dataName] |
| | | if (_data && Array.isArray(_data)) { |
| | | _data = _data[0] || {$$empty: true} |
| | | } |
| | | } |
| | | if (config.$syncId !== syncId) return |
| | | |
| | | _data.$$BID = BID || '' |
| | | _data.$$BData = BData || '' |
| | | _data.$$uuid = _data[config.setting.primaryKey] || '' |
| | | const { BID, BData } = this.state |
| | | |
| | | this.loaded = true |
| | | let _data = window.GLOB.SyncData.get(config.dataName) || [] |
| | | |
| | | this.setState({sync: false, data: _data}) |
| | | if (config.$cache) { |
| | | Api.writeCacheConfig(config.uuid, fromJS(_data).toJS()) |
| | | } |
| | | |
| | | _data = _data[0] || {$$empty: true} |
| | | |
| | | _data.$$BID = BID || '' |
| | | _data.$$BData = BData || '' |
| | | _data.$$uuid = _data[config.setting.primaryKey] || '' |
| | | |
| | | this.loaded = true |
| | | |
| | | this.setState({data: _data}) |
| | | |
| | | window.GLOB.SyncData.delete(config.dataName) |
| | | |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | |
| | | mkPublicData = (publicId, data) => { |
| | |
| | | |
| | | this.loaded = true |
| | | if (config.$cache && config.setting.onload !== 'false') { |
| | | Api.writeCacheConfig(config.uuid, result.data || '') |
| | | Api.writeCacheConfig(config.uuid, result.data || []) |
| | | } |
| | | |
| | | if (!result.data || !result.data[0]) { |
| | |
| | | import { DownOutlined } from '@ant-design/icons' |
| | | |
| | | import Api from '@/api' |
| | | import Utils from '@/utils/utils.js' |
| | | import UtilsDM from '@/utils/utils-datamanage.js' |
| | | import preImg from '@/assets/img/prev.png' |
| | | import nextImg from '@/assets/img/next.png' |
| | |
| | | |
| | | class DataCard extends Component { |
| | | static propTpyes = { |
| | | data: PropTypes.array, // 统一查询数据 |
| | | config: PropTypes.object, // 组件配置信息 |
| | | mainSearch: PropTypes.any, // 外层搜索条件 |
| | | config: PropTypes.object |
| | | } |
| | | |
| | | state = { |
| | |
| | | selectKeys: [], // 多选时选中卡片 |
| | | selectedData: [], // 选中数据,用于工具栏按钮 |
| | | loading: false, // 数据加载状态 |
| | | sync: false, // 是否统一请求数据 |
| | | card: null, // 卡片设置 |
| | | data: null, // 数据 |
| | | total: null, |
| | |
| | | loaded = false |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { data, initdata } = this.props |
| | | let _config = fromJS(this.props.config).toJS() |
| | | const { config } = this.props |
| | | |
| | | let _config = fromJS(config).toJS() |
| | | let BID = '' |
| | | let BData = '' |
| | | |
| | |
| | | }) |
| | | |
| | | _config.subcards = null |
| | | |
| | | let _data = null |
| | | let _sync = _config.setting.sync === 'true' |
| | | |
| | | if (_sync && data) { |
| | | _data = data[_config.dataName] || [] |
| | | _sync = false |
| | | } else if (_sync && initdata) { |
| | | _data = initdata || [] |
| | | _sync = false |
| | | } |
| | | |
| | | let selected = 'false' |
| | | if (_config.wrap.selected === 'always' || _config.wrap.selected === 'init' || _config.wrap.selected === 'sign') { |
| | | selected = _config.wrap.selected |
| | | } else { |
| | | _config.wrap.selected = 'false' |
| | | } |
| | | |
| | | if (_data) { |
| | | _data = _data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[_config.setting.primaryKey] || '' |
| | | item.$$BID = BID || '' |
| | | item.$$BData = BData || '' |
| | | item.$Index = index + 1 + '' |
| | | |
| | | if (_config.wrap.controlField) { |
| | | if (_config.wrap.controlVal.includes(item[_config.wrap.controlField] + '')) { |
| | | item.$disabled = true |
| | | } |
| | | } |
| | | return item |
| | | }) |
| | | |
| | | if (selected !== 'false') { |
| | | setTimeout(() => { |
| | | this.checkTopLine() |
| | | }, 200) |
| | | if (selected === 'init') { |
| | | selected = 'false' |
| | | } |
| | | } |
| | | } |
| | | |
| | | let supComs = null |
| | |
| | | _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}` |
| | | |
| | | this.loaded = _data !== null |
| | | |
| | | let pageOptions = ['10', '25', '50', '100', '500', '1000'] |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | let _data = null |
| | | 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()) |
| | | } |
| | | |
| | | _config.setting.sync = 'false' |
| | | |
| | | _data = _data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[_config.setting.primaryKey] || '' |
| | | item.$$BID = BID || '' |
| | | item.$$BData = BData || '' |
| | | item.$Index = index + 1 + '' |
| | | |
| | | if (_config.wrap.controlField) { |
| | | if (_config.wrap.controlVal.includes(item[_config.wrap.controlField] + '')) { |
| | | item.$disabled = true |
| | | } |
| | | } |
| | | return item |
| | | }) |
| | | |
| | | this.loaded = true |
| | | |
| | | window.GLOB.SyncData.delete(_config.dataName) |
| | | } |
| | | |
| | | this.setState({ |
| | | pageSize: _config.setting.pageSize || 10, |
| | | pageOptions, |
| | |
| | | selected, |
| | | precards, |
| | | nextcards, |
| | | sync: _sync, |
| | | data: _data, |
| | | BID: BID || '', |
| | | BData: BData || '', |
| | | config: _config, |
| | | card: _card, |
| | | search: Utils.initMainSearch(_config.search), |
| | | search: _config.$searches, |
| | | arr_field: _config.columns.map(col => col.field).join(','), |
| | | }, () => { |
| | | if (_config.setting.sync !== 'true' && _config.setting.onload === 'true') { |
| | | if (config.setting.sync !== 'true' && _config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | | this.loadData() |
| | | }, _config.setting.delay || 0) |
| | | } |
| | | |
| | | this.loaded && this.prevCheck() |
| | | }) |
| | | } |
| | | |
| | |
| | | |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | | MKEmitter.addListener('mkCheckAll', this.mkCheckAll) |
| | | MKEmitter.addListener('refreshLineData', this.refreshLineData) |
| | | MKEmitter.addListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.addListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.addListener('refreshLineData', this.refreshLineData) |
| | | 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.timer) { |
| | | this.timer = new TimerTask() |
| | |
| | | return !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | const { sync, config, BID, BData, selected } = this.state |
| | | |
| | | if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) { |
| | | let _data = [] |
| | | if (nextProps.data && nextProps.data[config.dataName]) { |
| | | _data = nextProps.data[config.dataName] || [] |
| | | _data = _data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[config.setting.primaryKey] || '' |
| | | item.$$BID = BID || '' |
| | | item.$$BData = BData || '' |
| | | item.$Index = index + 1 + '' |
| | | |
| | | if (config.wrap.controlField) { |
| | | if (config.wrap.controlVal.includes(item[config.wrap.controlField] + '')) { |
| | | item.$disabled = true |
| | | } |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | | if (selected !== 'false') { |
| | | setTimeout(() => { |
| | | this.checkTopLine() |
| | | }, 200) |
| | | if (selected === 'init') { |
| | | this.setState({selected: 'false'}) |
| | | } |
| | | } |
| | | } |
| | | |
| | | this.loaded = true |
| | | |
| | | this.setState({sync: false, data: _data}) |
| | | } else if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({pageIndex: 1}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | } |
| | | |
| | | componentWillUnmount () { |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('mkCheckAll', this.mkCheckAll) |
| | | MKEmitter.removeListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.removeListener('searchRefresh', this.searchRefresh) |
| | | MKEmitter.removeListener('refreshLineData', this.refreshLineData) |
| | | MKEmitter.removeListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) |
| | | |
| | | this.timer && this.timer.stop() |
| | | } |
| | | |
| | | transferSyncData = (syncId) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.$syncId !== syncId) return |
| | | |
| | | const { BID, BData } = this.state |
| | | |
| | | let _data = window.GLOB.SyncData.get(config.dataName) || [] |
| | | |
| | | if (config.$cache) { |
| | | Api.writeCacheConfig(config.uuid, fromJS(_data).toJS()) |
| | | } |
| | | |
| | | _data = _data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[config.setting.primaryKey] || '' |
| | | item.$$BID = BID || '' |
| | | item.$$BData = BData || '' |
| | | item.$Index = index + 1 + '' |
| | | |
| | | if (config.wrap.controlField) { |
| | | if (config.wrap.controlVal.includes(item[config.wrap.controlField] + '')) { |
| | | item.$disabled = true |
| | | } |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | | this.prevCheck() |
| | | |
| | | this.loaded = true |
| | | |
| | | this.setState({data: _data}) |
| | | |
| | | window.GLOB.SyncData.delete(config.dataName) |
| | | |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | |
| | | searchRefresh = (searchId) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.$searchId !== searchId) return |
| | | |
| | | this.setState({pageIndex: 1}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | |
| | | /** |
| | |
| | | this.setState({ |
| | | data: _data |
| | | }) |
| | | } |
| | | |
| | | prevCheck = (id) => { |
| | | const { selected } = this.state |
| | | |
| | | if (selected === 'false' && !id) return |
| | | |
| | | setTimeout(() => { |
| | | this.checkTopLine(id) |
| | | }, 200) |
| | | |
| | | if (selected === 'init') { |
| | | this.setState({selected: 'false'}) |
| | | } |
| | | } |
| | | |
| | | checkTopLine = (id) => { |
| | |
| | | * @description 导出Excel时,获取页面搜索排序等参数 |
| | | */ |
| | | queryModuleParam = (menuId, callback) => { |
| | | const { mainSearch } = this.props |
| | | const { arr_field, config, search, orderBy } = this.state |
| | | |
| | | if (config.uuid !== menuId) return |
| | | |
| | | let searches = search ? fromJS(search).toJS() : [] |
| | | if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | let keys = searches.map(item => item.key.toLowerCase()) |
| | | let searches = fromJS(search).toJS() |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | let mainSearch = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | let keys = config.$s_keys || [] |
| | | mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key.toLowerCase())) { |
| | | searches.push(item) |
| | | } |
| | | if (keys.includes(item.key.toLowerCase())) return |
| | | |
| | | searches.push(item) |
| | | }) |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | async loadData (id, type) { |
| | | const { mainSearch } = this.props |
| | | const { config, arr_field, pageIndex, pageSize, search, BID, BData, selected, orderBy } = this.state |
| | | |
| | | if (config.setting.supModule && !BID && config.wrap.supKey !== 'false') { // BID 不存在时,不做查询 |
| | |
| | | }) |
| | | |
| | | if (selected !== 'false' || (id && config.wrap.selected !== 'false')) { |
| | | setTimeout(() => { |
| | | this.checkTopLine(id) |
| | | }, 200) |
| | | if (selected === 'init') { |
| | | this.setState({selected: 'false'}) |
| | | } |
| | | this.prevCheck(id) |
| | | } else { |
| | | MKEmitter.emit('resetSelectLine', config.uuid, '', '') |
| | | if (config.setting.$hasSyncModule) { |
| | |
| | | } |
| | | |
| | | let searches = fromJS(search).toJS() |
| | | if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | let keys = searches.map(item => item.key.toLowerCase()) |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | let mainSearch = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | let keys = config.$s_keys || [] |
| | | mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key.toLowerCase())) { |
| | | searches.push(item) |
| | | } |
| | | if (keys.includes(item.key.toLowerCase())) return |
| | | |
| | | searches.push(item) |
| | | }) |
| | | } |
| | | |
| | | let requireFields = searches.filter(item => item.required && item.value === '') |
| | | if (requireFields.length > 0) { |
| | | if (config.$s_req && searches.filter(item => item.required && item.value === '').length > 0) { |
| | | return |
| | | } |
| | | |
| | |
| | | |
| | | this.loaded = true |
| | | if (config.$cache && pageIndex === 1 && config.setting.onload !== 'false') { |
| | | Api.writeCacheConfig(config.uuid, result.data || '') |
| | | Api.writeCacheConfig(config.uuid, result.data || []) |
| | | } |
| | | |
| | | if (selected !== 'false' || (id && config.wrap.selected !== 'false')) { |
| | | setTimeout(() => { |
| | | this.checkTopLine(id) |
| | | }, 200) |
| | | if (selected === 'init') { |
| | | this.setState({selected: 'false'}) |
| | | } |
| | | this.prevCheck(id) |
| | | } else { |
| | | MKEmitter.emit('resetSelectLine', config.uuid, '', '') |
| | | if (config.setting.$hasSyncModule) { |
| | |
| | | * @description 获取单行数据 |
| | | */ |
| | | async loadLinedata (id) { |
| | | const { mainSearch } = this.props |
| | | const { config, arr_field, pageIndex, pageSize, search, BID, BData, orderBy } = this.state |
| | | |
| | | let searches = fromJS(search).toJS() |
| | | if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | let keys = searches.map(item => item.key.toLowerCase()) |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | let mainSearch = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | let keys = config.$s_keys || [] |
| | | mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key.toLowerCase())) { |
| | | searches.push(item) |
| | | } |
| | | if (keys.includes(item.key.toLowerCase())) return |
| | | |
| | | searches.push(item) |
| | | }) |
| | | } |
| | | |
| | |
| | | import { DownOutlined, UpOutlined, PlusSquareOutlined, MinusSquareOutlined } from '@ant-design/icons' |
| | | |
| | | import Api from '@/api' |
| | | import Utils from '@/utils/utils.js' |
| | | import UtilsDM from '@/utils/utils-datamanage.js' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import TimerTask from '@/utils/timer-task.js' |
| | |
| | | class DoubleDataCard extends Component { |
| | | static propTpyes = { |
| | | config: PropTypes.object, // 组件配置信息 |
| | | mainSearch: PropTypes.any, // 外层搜索条件 |
| | | } |
| | | |
| | | state = { |
| | |
| | | subconfig: subconfig, |
| | | wrapStyle: wrapStyle, |
| | | card: _card, |
| | | search: Utils.initMainSearch(_config.search), |
| | | search: _config.$searches, |
| | | arr_field: _config.columns.map(col => col.field).join(','), |
| | | }, () => { |
| | | if (_config.setting.onload === 'true') { |
| | |
| | | const { config } = this.state |
| | | |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | | MKEmitter.addListener('refreshLineData', this.refreshLineData) |
| | | MKEmitter.addListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.addListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.addListener('refreshLineData', this.refreshLineData) |
| | | MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) |
| | | |
| | | if (config.setting.useMSearch) { |
| | | MKEmitter.addListener('searchRefresh', this.searchRefresh) |
| | | } |
| | | |
| | | if (config.timer) { |
| | | this.timer = new TimerTask() |
| | | this.timer.init(config.uuid, config.timer, config.timerRepeats, () => { |
| | |
| | | return !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | const { config } = this.state |
| | | |
| | | if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({pageIndex: 1}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | } |
| | | |
| | | componentWillUnmount () { |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('searchRefresh', this.searchRefresh) |
| | | MKEmitter.removeListener('refreshLineData', this.refreshLineData) |
| | | MKEmitter.removeListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.removeListener('refreshLineData', this.refreshLineData) |
| | | MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) |
| | | |
| | | this.timer && this.timer.stop() |
| | | } |
| | | |
| | | searchRefresh = (searchId) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.$searchId !== searchId) return |
| | | |
| | | this.setState({pageIndex: 1}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | |
| | | /** |
| | |
| | | * @description 导出Excel时,获取页面搜索排序等参数 |
| | | */ |
| | | queryModuleParam = (menuId, callback) => { |
| | | const { mainSearch } = this.props |
| | | const { arr_field, config, search, orderBy } = this.state |
| | | |
| | | if (config.uuid !== menuId) return |
| | | |
| | | let searches = search ? fromJS(search).toJS() : [] |
| | | if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | let keys = searches.map(item => item.key.toLowerCase()) |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | let mainSearch = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | let keys = config.$s_keys || [] |
| | | mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key.toLowerCase())) { |
| | | searches.push(item) |
| | | } |
| | | if (keys.includes(item.key.toLowerCase())) return |
| | | |
| | | searches.push(item) |
| | | }) |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | async loadData (id, type) { |
| | | const { mainSearch } = this.props |
| | | const { config, arr_field, pageIndex, pageSize, search, BID, BData, selected, card, orderBy } = this.state |
| | | |
| | | if (config.setting.supModule && !BID && config.wrap.supKey !== 'false') { // BID 不存在时,不做查询 |
| | |
| | | } |
| | | |
| | | let searches = fromJS(search).toJS() |
| | | if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | let keys = searches.map(item => item.key.toLowerCase()) |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | let mainSearch = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | let keys = config.$s_keys || [] |
| | | mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key.toLowerCase())) { |
| | | searches.push(item) |
| | | } |
| | | if (keys.includes(item.key.toLowerCase())) return |
| | | |
| | | searches.push(item) |
| | | }) |
| | | } |
| | | |
| | | let requireFields = searches.filter(item => item.required && item.value === '') |
| | | if (requireFields.length > 0) { |
| | | if (config.$s_req && searches.filter(item => item.required && item.value === '').length > 0) { |
| | | return |
| | | } |
| | | |
| | |
| | | |
| | | this.loaded = true |
| | | if (config.$cache && pageIndex === 1 && config.setting.onload !== 'false') { |
| | | Api.writeCacheConfig(config.uuid, result.data || '') |
| | | Api.writeCacheConfig(config.uuid, result.data || []) |
| | | } |
| | | |
| | | if (selected !== 'false' || (id && config.wrap.selected !== 'false')) { |
| | |
| | | * @description 获取单行数据 |
| | | */ |
| | | async loadLinedata (id) { |
| | | const { mainSearch } = this.props |
| | | const { config, arr_field, pageIndex, pageSize, search, BID, BData, orderBy } = this.state |
| | | |
| | | let searches = fromJS(search).toJS() |
| | | if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | let keys = searches.map(item => item.key.toLowerCase()) |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | let mainSearch = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | let keys = config.$s_keys || [] |
| | | mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key.toLowerCase())) { |
| | | searches.push(item) |
| | | } |
| | | if (keys.includes(item.key.toLowerCase())) return |
| | | |
| | | searches.push(item) |
| | | }) |
| | | } |
| | | |
| | |
| | | |
| | | class PropCard extends Component { |
| | | static propTpyes = { |
| | | data: PropTypes.array, // 统一查询数据 |
| | | config: PropTypes.object, // 组件配置信息 |
| | | mainSearch: PropTypes.any, // 外层搜索条件 |
| | | config: PropTypes.object |
| | | } |
| | | |
| | | state = { |
| | |
| | | config: null, // 图表配置信息 |
| | | loading: false, // 数据加载状态 |
| | | activeKey: '', // 选中数据 |
| | | sync: false, // 是否统一请求数据 |
| | | data: {}, // 数据 |
| | | BData: '', |
| | | selected: 'false', |
| | |
| | | autoTimer = null |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { data, initdata } = this.props |
| | | let _config = fromJS(this.props.config).toJS() |
| | | const { config } = this.props |
| | | |
| | | let _config = fromJS(config).toJS() |
| | | let _data = { $$empty: true } |
| | | let _sync = false |
| | | |
| | |
| | | } |
| | | |
| | | if (_config.wrap.datatype === 'dynamic') { |
| | | _sync = _config.setting.sync === 'true' |
| | | if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { |
| | | _data = window.GLOB.SyncData.get(_config.dataName) || [] |
| | | |
| | | if (_sync && data) { |
| | | _data = data[_config.dataName] || {$$empty: true} |
| | | if (Array.isArray(_data)) { |
| | | _data = _data[0] || {$$empty: true} |
| | | if (_config.$cache) { |
| | | Api.writeCacheConfig(_config.uuid, fromJS(_data).toJS()) |
| | | } |
| | | _sync = false |
| | | |
| | | _config.setting.sync = 'false' |
| | | |
| | | _data = _data[0] || {$$empty: true} |
| | | |
| | | this.loaded = true |
| | | } else if (_sync && initdata) { |
| | | _data = initdata |
| | | if (Array.isArray(_data)) { |
| | | _data = _data[0] || {$$empty: true} |
| | | } |
| | | _sync = false |
| | | this.loaded = true |
| | | |
| | | window.GLOB.SyncData.delete(_config.dataName) |
| | | } |
| | | } else if (_config.wrap.datatype === 'public' && window.GLOB.CacheData.get(_config.wrap.publicId)) { |
| | | _data = window.GLOB.CacheData.get(_config.wrap.publicId) |
| | |
| | | |
| | | this.setState({ |
| | | selected, |
| | | sync: _sync, |
| | | data: _data, |
| | | BID: BID || '', |
| | | BData: BData || '', |
| | | config: _config, |
| | | arr_field: _config.columns.map(col => col.field).join(','), |
| | | }, () => { |
| | | if (_config.wrap.datatype === 'dynamic' && _config.setting.sync !== 'true' && _config.setting.onload === 'true') { |
| | | if (_config.wrap.datatype === 'dynamic' && config.setting.sync !== 'true' && _config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | | this.loadData() |
| | | }, _config.setting.delay || 0) |
| | |
| | | const { config } = this.state |
| | | |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | | MKEmitter.addListener('refreshLineData', this.refreshLineData) |
| | | MKEmitter.addListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.addListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.addListener('refreshLineData', this.refreshLineData) |
| | | 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) |
| | |
| | | Api.getLCacheConfig(config.uuid).then(res => { |
| | | if (!res || this.loaded) return |
| | | |
| | | let _data = res[0] |
| | | let _data = res[0] || {$$empty: true} |
| | | _data.$$uuid = _data[config.setting.primaryKey] || '' |
| | | |
| | | this.setState({data: _data}) |
| | |
| | | } |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('mkPublicData', this.mkPublicData) |
| | | MKEmitter.removeListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.removeListener('searchRefresh', this.searchRefresh) |
| | | MKEmitter.removeListener('refreshLineData', this.refreshLineData) |
| | | MKEmitter.removeListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) |
| | | |
| | | this.timer && this.timer.stop() |
| | | } |
| | | |
| | | /** |
| | | * @description 数据更新,刷新内容 |
| | | */ |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | const { sync, config, BID, BData, selected } = this.state |
| | | transferSyncData = (syncId) => { |
| | | const { config } = this.state |
| | | |
| | | if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) { |
| | | let _data = { $$empty: true } |
| | | if (nextProps.data && nextProps.data[config.dataName]) { |
| | | _data = nextProps.data[config.dataName] |
| | | if (Array.isArray(_data)) { |
| | | _data = _data[0] || {$$empty: true} |
| | | } |
| | | } |
| | | if (config.$syncId !== syncId) return |
| | | |
| | | _data.$$BID = BID || '' |
| | | _data.$$BData = BData || '' |
| | | _data.$$uuid = _data[config.setting.primaryKey] || '' |
| | | const { BID, BData, selected } = this.state |
| | | |
| | | this.loaded = true |
| | | let _data = window.GLOB.SyncData.get(config.dataName) || [] |
| | | |
| | | this.setState({sync: false, data: _data}, () => { |
| | | if (config.wrap.goback === 'true' && _data.$$empty) { |
| | | this.timer && this.timer.stop() |
| | | |
| | | MKEmitter.emit('closeTabView', config.$pageId) |
| | | } else { |
| | | if (selected !== 'false') { |
| | | this.checkTopLine() |
| | | } else if (_data.$$uuid) { |
| | | this.transferLine() |
| | | } |
| | | this.autoExec() |
| | | } |
| | | }) |
| | | } else if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | if (config.$cache) { |
| | | Api.writeCacheConfig(config.uuid, fromJS(_data).toJS()) |
| | | } |
| | | |
| | | _data = _data[0] || {$$empty: true} |
| | | |
| | | _data.$$BID = BID || '' |
| | | _data.$$BData = BData || '' |
| | | _data.$$uuid = _data[config.setting.primaryKey] || '' |
| | | |
| | | this.loaded = true |
| | | |
| | | this.setState({data: _data}, () => { |
| | | if (config.wrap.goback === 'true' && _data.$$empty) { |
| | | this.timer && this.timer.stop() |
| | | |
| | | MKEmitter.emit('closeTabView', config.$pageId) |
| | | } else { |
| | | if (selected !== 'false') { |
| | | this.checkTopLine() |
| | | } else if (_data.$$uuid) { |
| | | this.transferLine() |
| | | } |
| | | this.autoExec() |
| | | } |
| | | }) |
| | | |
| | | window.GLOB.SyncData.delete(config.dataName) |
| | | |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | |
| | | searchRefresh = (searchId) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.$searchId !== searchId) return |
| | | |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | |
| | | mkPublicData = (publicId, data) => { |
| | |
| | | * @description 导出Excel时,获取页面搜索排序等参数 |
| | | */ |
| | | queryModuleParam = (menuId, callback) => { |
| | | const { mainSearch } = this.props |
| | | const { config } = this.state |
| | | |
| | | if (config.uuid !== menuId) return |
| | | |
| | | let searches = config.setting.useMSearch && mainSearch ? mainSearch : [] |
| | | let searches = [] |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | searches = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | } |
| | | |
| | | callback({ |
| | | arr_field: '', |
| | |
| | | } |
| | | |
| | | async loadData (hastimer, btn) { |
| | | const { mainSearch } = this.props |
| | | const { config, arr_field, BID, BData, selected } = this.state |
| | | |
| | | if (config.wrap.datatype === 'public') { |
| | |
| | | return |
| | | } |
| | | |
| | | let searches = config.setting.useMSearch && mainSearch ? mainSearch : [] |
| | | let searches = [] |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | searches = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | } |
| | | |
| | | let requireFields = searches.filter(item => item.required && item.value === '') |
| | | if (requireFields.length > 0) { |
| | | if (config.$s_req && searches.filter(item => item.required && item.value === '').length > 0) { |
| | | return |
| | | } |
| | | |
| | |
| | | |
| | | this.loaded = true |
| | | if (config.$cache && config.setting.onload !== 'false') { |
| | | Api.writeCacheConfig(config.uuid, result.data || '') |
| | | Api.writeCacheConfig(config.uuid, result.data || []) |
| | | } |
| | | |
| | | if (!result.data || !result.data[0]) { |
| | |
| | | import { DownOutlined } from '@ant-design/icons' |
| | | |
| | | import Api from '@/api' |
| | | import Utils from '@/utils/utils.js' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import UtilsDM from '@/utils/utils-datamanage.js' |
| | | import MKEmitter from '@/utils/events.js' |
| | |
| | | |
| | | class TableCard extends Component { |
| | | static propTpyes = { |
| | | data: PropTypes.array, // 统一查询数据 |
| | | config: PropTypes.object, // 组件配置信息 |
| | | mainSearch: PropTypes.any, // 外层搜索条件 |
| | | config: PropTypes.object |
| | | } |
| | | |
| | | state = { |
| | |
| | | search: null, // 搜索条件 |
| | | pageIndex: 1, // 页码 |
| | | total: 0, // 总数 |
| | | sync: false, // 是否统一请求数据 |
| | | data: null, // 数据 |
| | | BData: '' |
| | | } |
| | |
| | | * 1、 initdata 为打印时使用的数据集 |
| | | */ |
| | | UNSAFE_componentWillMount () { |
| | | const { data, initdata } = this.props |
| | | let _config = fromJS(this.props.config).toJS() |
| | | const { config } = this.props |
| | | |
| | | let _data = null |
| | | let _sync = _config.setting.sync === 'true' |
| | | |
| | | let _config = fromJS(config).toJS() |
| | | let BID = '' |
| | | let BData = '' |
| | | |
| | |
| | | } |
| | | if (BData) { |
| | | BID = BData.$BID || '' |
| | | } |
| | | |
| | | if (_config.setting.sync === 'true' && data) { |
| | | _data = data[_config.dataName] || [] |
| | | _sync = false |
| | | } else if (_config.setting.sync === 'true' && initdata) { |
| | | _data = initdata || [] |
| | | _sync = false |
| | | } |
| | | |
| | | if (_data) { |
| | | _data = _data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[_config.setting.primaryKey] || '' |
| | | item.$$BID = BID || '' |
| | | item.$$BData = BData || '' |
| | | item.$Index = index + 1 + '' |
| | | return item |
| | | }) |
| | | } |
| | | |
| | | let showHeader = false |
| | |
| | | _config.wrap.contentHeight = showHeader ? 'calc(100% - 45px)' : '100%' |
| | | } |
| | | |
| | | this.loaded = _data !== null |
| | | let _data = null |
| | | 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()) |
| | | } |
| | | |
| | | _config.setting.sync = 'false' |
| | | |
| | | _data = _data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[_config.setting.primaryKey] || '' |
| | | item.$$BID = BID || '' |
| | | item.$$BData = BData || '' |
| | | item.$Index = index + 1 + '' |
| | | return item |
| | | }) |
| | | |
| | | this.loaded = true |
| | | |
| | | window.GLOB.SyncData.delete(_config.dataName) |
| | | } |
| | | |
| | | this.setState({ |
| | | sync: _sync, |
| | | BID: BID || '', |
| | | BData: BData || '', |
| | | data: _data, |
| | | config: _config, |
| | | search: Utils.initMainSearch(_config.search), |
| | | search: _config.$searches, |
| | | arr_field: _config.columns.map(col => col.field).join(','), |
| | | }, () => { |
| | | if (_config.setting.sync !== 'true' && _config.setting.onload === 'true') { |
| | | if (config.setting.sync !== 'true' && _config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | | this.loadData() |
| | | }, _config.setting.delay || 0) |
| | |
| | | const { config } = this.state |
| | | |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | | MKEmitter.addListener('refreshLineData', this.refreshLineData) |
| | | MKEmitter.addListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.addListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.addListener('refreshLineData', this.refreshLineData) |
| | | 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.timer) { |
| | | this.timer = new TimerTask() |
| | |
| | | return |
| | | } |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.removeListener('searchRefresh', this.searchRefresh) |
| | | MKEmitter.removeListener('refreshLineData', this.refreshLineData) |
| | | MKEmitter.removeListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) |
| | | |
| | | this.timer && this.timer.stop() |
| | | } |
| | | |
| | | /** |
| | | * @description 图表数据更新,刷新内容 |
| | | */ |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | const { sync, config, BID, BData } = this.state |
| | | transferSyncData = (syncId) => { |
| | | const { config } = this.state |
| | | |
| | | if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) { |
| | | let _data = [] |
| | | if (nextProps.data && nextProps.data[config.dataName]) { |
| | | _data = nextProps.data[config.dataName] || [] |
| | | } |
| | | if (config.$syncId !== syncId) return |
| | | |
| | | _data = _data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[config.setting.primaryKey] || '' |
| | | item.$$BID = BID || '' |
| | | item.$$BData = BData || '' |
| | | item.$Index = index + 1 + '' |
| | | return item |
| | | }) |
| | | const { BID, BData } = this.state |
| | | |
| | | this.loaded = true |
| | | let _data = window.GLOB.SyncData.get(config.dataName) || [] |
| | | |
| | | this.setState({sync: false, data: _data}) |
| | | } else if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | if (config.$cache) { |
| | | Api.writeCacheConfig(config.uuid, fromJS(_data).toJS()) |
| | | } |
| | | |
| | | _data = _data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[config.setting.primaryKey] || '' |
| | | item.$$BID = BID || '' |
| | | item.$$BData = BData || '' |
| | | item.$Index = index + 1 + '' |
| | | |
| | | return item |
| | | }) |
| | | |
| | | this.loaded = true |
| | | |
| | | this.setState({data: _data}) |
| | | |
| | | window.GLOB.SyncData.delete(config.dataName) |
| | | |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | |
| | | searchRefresh = (searchId) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.$searchId !== searchId) return |
| | | |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | |
| | | /** |
| | |
| | | * @description 导出Excel时,获取页面搜索排序等参数 |
| | | */ |
| | | queryModuleParam = (menuId, callback) => { |
| | | const { mainSearch } = this.props |
| | | const { arr_field, config, search } = this.state |
| | | |
| | | if (config.uuid !== menuId) return |
| | | |
| | | let searches = search ? fromJS(search).toJS() : [] |
| | | if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | let keys = searches.map(item => item.key.toLowerCase()) |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | let mainSearch = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | let keys = config.$s_keys || [] |
| | | mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key.toLowerCase())) { |
| | | searches.push(item) |
| | | } |
| | | if (keys.includes(item.key.toLowerCase())) return |
| | | |
| | | searches.push(item) |
| | | }) |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | async loadData (type) { |
| | | const { mainSearch } = this.props |
| | | const { config, arr_field, pageIndex, search, BID, BData } = this.state |
| | | |
| | | if (config.setting.supModule && !BID) { // BID 不存在时,不做查询 |
| | |
| | | } |
| | | |
| | | let searches = search ? fromJS(search).toJS() : [] |
| | | if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | let keys = searches.map(item => item.key) |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | let mainSearch = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | let keys = config.$s_keys || [] |
| | | mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key)) { |
| | | searches.push(item) |
| | | } |
| | | if (keys.includes(item.key.toLowerCase())) return |
| | | |
| | | searches.push(item) |
| | | }) |
| | | } |
| | | |
| | | let requireFields = searches.filter(item => item.required && item.value === '') |
| | | if (requireFields.length > 0) { |
| | | if (config.$s_req && searches.filter(item => item.required && item.value === '').length > 0) { |
| | | return |
| | | } |
| | | |
| | |
| | | |
| | | this.loaded = true |
| | | if (config.$cache && pageIndex === 1 && config.setting.onload !== 'false') { |
| | | Api.writeCacheConfig(config.uuid, result.data || '') |
| | | Api.writeCacheConfig(config.uuid, result.data || []) |
| | | } |
| | | |
| | | let data = [] |
| | |
| | | |
| | | class DataCard extends Component { |
| | | static propTpyes = { |
| | | data: PropTypes.array, // 统一查询数据 |
| | | config: PropTypes.object, // 组件配置信息 |
| | | mainSearch: PropTypes.any, // 外层搜索条件 |
| | | config: PropTypes.object |
| | | } |
| | | |
| | | state = { |
| | | BID: '', // 上级ID |
| | | config: null, // 图表配置信息 |
| | | loading: false, // 数据加载状态 |
| | | sync: false, // 是否统一请求数据 |
| | | card: null, // 卡片设置 |
| | | data: null, // 数据 |
| | | BData: null, |
| | |
| | | loaded = false |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { data, initdata } = this.props |
| | | let _config = fromJS(this.props.config).toJS() |
| | | const { config } = this.props |
| | | |
| | | let _config = fromJS(config).toJS() |
| | | let _card = _config.subcards[0] |
| | | |
| | | let _data = null |
| | | let _sync = _config.setting.sync === 'true' |
| | | |
| | | let BID = '' |
| | | let BData = '' |
| | | |
| | |
| | | BID = BData.$BID || '' |
| | | } |
| | | |
| | | if (_config.setting.sync === 'true' && data) { |
| | | _data = data[_config.dataName] || [] |
| | | _sync = false |
| | | } else if (_config.setting.sync === 'true' && initdata) { |
| | | _data = initdata || [] |
| | | _sync = false |
| | | } |
| | | let _data = null |
| | | if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { |
| | | _data = window.GLOB.SyncData.get(_config.dataName) || [] |
| | | |
| | | if (_data) { |
| | | this.loaded = true |
| | | if (_config.$cache) { |
| | | Api.writeCacheConfig(_config.uuid, fromJS(_data).toJS()) |
| | | } |
| | | |
| | | _config.setting.sync = 'false' |
| | | |
| | | _data = _data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[_config.setting.primaryKey] || '' |
| | | item.$$BID = BID || '' |
| | | item.$$BData = BData || '' |
| | | item.$Index = index + 1 |
| | | item.$Index = index + 1 + '' |
| | | return item |
| | | }) |
| | | |
| | | this.loaded = true |
| | | |
| | | window.GLOB.SyncData.delete(_config.dataName) |
| | | } |
| | | |
| | | if (_card.setting.click) { |
| | |
| | | _config.wrap.speed = (_config.wrap.speed || 3) * 1000 |
| | | |
| | | this.setState({ |
| | | sync: _sync, |
| | | data: _data, |
| | | BID: BID || '', |
| | | BData: BData || '', |
| | |
| | | card: _card, |
| | | arr_field: _config.columns.map(col => col.field).join(','), |
| | | }, () => { |
| | | if (_config.setting.sync !== 'true' && _config.setting.onload === 'true') { |
| | | if (config.setting.sync !== 'true' && _config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | | this.loadData() |
| | | }, _config.setting.delay || 0) |
| | |
| | | MKEmitter.addListener('resetSelectLine', this.resetParentParam) |
| | | 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.timer) { |
| | | this.timer = new TimerTask() |
| | |
| | | return !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | const { sync, config, BID, BData } = this.state |
| | | |
| | | if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) { |
| | | let _data = [] |
| | | if (nextProps.data && nextProps.data[config.dataName]) { |
| | | _data = nextProps.data[config.dataName] || [] |
| | | } |
| | | |
| | | _data = _data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[config.setting.primaryKey] || '' |
| | | item.$$BID = BID || '' |
| | | item.$$BData = BData || '' |
| | | item.$Index = index + 1 |
| | | return item |
| | | }) |
| | | |
| | | this.loaded = true |
| | | |
| | | this.setState({sync: false, data: _data}, () => { |
| | | this.openModal() |
| | | }) |
| | | } else if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | } |
| | | |
| | | componentWillUnmount () { |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | MKEmitter.removeListener('searchRefresh', this.searchRefresh) |
| | | MKEmitter.removeListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) |
| | | |
| | | this.timer && this.timer.stop() |
| | | } |
| | | |
| | | transferSyncData = (syncId) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.$syncId !== syncId) return |
| | | |
| | | const { BID, BData } = this.state |
| | | |
| | | let _data = window.GLOB.SyncData.get(config.dataName) || [] |
| | | |
| | | if (config.$cache) { |
| | | Api.writeCacheConfig(config.uuid, fromJS(_data).toJS()) |
| | | } |
| | | |
| | | _data = _data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[config.setting.primaryKey] || '' |
| | | item.$$BID = BID || '' |
| | | item.$$BData = BData || '' |
| | | item.$Index = index + 1 + '' |
| | | |
| | | return item |
| | | }) |
| | | |
| | | this.loaded = true |
| | | |
| | | this.setState({data: _data}, () => { |
| | | this.openModal() |
| | | }) |
| | | |
| | | window.GLOB.SyncData.delete(config.dataName) |
| | | |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | |
| | | searchRefresh = (searchId) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.$searchId !== searchId) return |
| | | |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | |
| | | openModal = (ErrCode) => { |
| | |
| | | * @description 导出Excel时,获取页面搜索排序等参数 |
| | | */ |
| | | queryModuleParam = (menuId, callback) => { |
| | | const { mainSearch } = this.props |
| | | const { arr_field, config } = this.state |
| | | |
| | | if (config.uuid !== menuId) return |
| | | |
| | | let searches = config.setting.useMSearch && mainSearch ? fromJS(mainSearch).toJS() : [] |
| | | let searches = [] |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | searches = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | } |
| | | |
| | | callback({ |
| | | arr_field: arr_field, |
| | |
| | | } |
| | | |
| | | async loadData (type) { |
| | | const { mainSearch } = this.props |
| | | const { config, arr_field, BID, BData } = this.state |
| | | |
| | | if (config.setting.supModule && !BID) { // BID 不存在时,不做查询 |
| | |
| | | return |
| | | } |
| | | |
| | | let searches = config.setting.useMSearch && mainSearch ? fromJS(mainSearch).toJS() : [] |
| | | let requireFields = searches.filter(item => item.required && item.value === '') |
| | | if (requireFields.length > 0) { |
| | | let searches = [] |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | searches = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | } |
| | | |
| | | if (config.$s_req && searches.filter(item => item.required && item.value === '').length > 0) { |
| | | return |
| | | } |
| | | |
| | |
| | | if (result.status) { |
| | | this.loaded = true |
| | | if (config.$cache && config.setting.onload !== 'false') { |
| | | Api.writeCacheConfig(config.uuid, result.data || '') |
| | | Api.writeCacheConfig(config.uuid, result.data || []) |
| | | } |
| | | |
| | | let data = result.data.map((item, index) => { |
| | |
| | | |
| | | class PropCard extends Component { |
| | | static propTpyes = { |
| | | data: PropTypes.array, // 统一查询数据 |
| | | config: PropTypes.object, // 组件配置信息 |
| | | mainSearch: PropTypes.any, // 外层搜索条件 |
| | | config: PropTypes.object |
| | | } |
| | | |
| | | state = { |
| | | BID: '', // 上级ID |
| | | config: null, // 图表配置信息 |
| | | loading: false, // 数据加载状态 |
| | | sync: false, // 是否统一请求数据 |
| | | data: {$$empty: true}, |
| | | BData: null, |
| | | visible: false |
| | |
| | | loaded = false |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { data, initdata } = this.props |
| | | let _config = fromJS(this.props.config).toJS() |
| | | const { config } = this.props |
| | | |
| | | let _config = fromJS(config).toJS() |
| | | let _data = {$$empty: true} |
| | | let _sync = false |
| | | |
| | | let BID = '' |
| | | let BData = '' |
| | |
| | | } |
| | | |
| | | if (_config.wrap.datatype === 'dynamic') { |
| | | _sync = _config.setting.sync === 'true' |
| | | if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { |
| | | _data = window.GLOB.SyncData.get(_config.dataName) || [] |
| | | |
| | | if (_sync && data) { |
| | | _data = data[_config.dataName] || {$$empty: true} |
| | | if (Array.isArray(_data)) { |
| | | _data = _data[0] || {$$empty: true} |
| | | if (_config.$cache) { |
| | | Api.writeCacheConfig(_config.uuid, fromJS(_data).toJS()) |
| | | } |
| | | _sync = false |
| | | |
| | | _config.setting.sync = 'false' |
| | | |
| | | _data = _data[0] || {$$empty: true} |
| | | |
| | | this.loaded = true |
| | | } else if (_sync && initdata) { |
| | | _data = initdata |
| | | if (Array.isArray(_data)) { |
| | | _data = _data[0] || {$$empty: true} |
| | | } |
| | | _sync = false |
| | | this.loaded = true |
| | | |
| | | window.GLOB.SyncData.delete(_config.dataName) |
| | | } |
| | | } else if (_config.wrap.datatype === 'static') { |
| | | this.loaded = true |
| | |
| | | _config.wrap.speed = (_config.wrap.speed || 3) * 1000 |
| | | |
| | | this.setState({ |
| | | sync: _sync, |
| | | data: _data, |
| | | BID: BID || '', |
| | | BData: BData || '', |
| | | config: _config, |
| | | arr_field: _config.columns.map(col => col.field).join(','), |
| | | }, () => { |
| | | if (_config.wrap.datatype === 'dynamic' && _config.setting && _config.setting.sync !== 'true' && _config.setting.onload === 'true') { |
| | | if (_config.wrap.datatype === 'dynamic' && config.setting.sync !== 'true' && _config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | | this.loadData() |
| | | }, _config.setting.delay || 0) |
| | |
| | | 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.timer && config.wrap.datatype === 'dynamic') { |
| | | this.timer = new TimerTask() |
| | | this.timer.init(config.uuid, config.timer, config.timerRepeats, () => { |
| | |
| | | Api.getLCacheConfig(config.uuid).then(res => { |
| | | if (!res || this.loaded) return |
| | | |
| | | let _data = res[0] |
| | | let _data = res[0] || {$$empty: true} |
| | | _data.$$uuid = _data[config.setting.primaryKey] || '' |
| | | |
| | | this.setState({data: _data}) |
| | |
| | | return |
| | | } |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('searchRefresh', this.searchRefresh) |
| | | MKEmitter.removeListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) |
| | | |
| | | this.timer && this.timer.stop() |
| | | } |
| | | |
| | | /** |
| | | * @description 图表数据更新,刷新内容 |
| | | */ |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | const { sync, config, BID, BData } = this.state |
| | | transferSyncData = (syncId) => { |
| | | const { config } = this.state |
| | | |
| | | if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) { |
| | | let _data = {$$empty: true} |
| | | if (nextProps.data && nextProps.data[config.dataName]) { |
| | | _data = nextProps.data[config.dataName] |
| | | if (Array.isArray(_data)) { |
| | | _data = _data[0] || {$$empty: true} |
| | | } |
| | | } |
| | | if (config.$syncId !== syncId) return |
| | | |
| | | _data.$$uuid = _data[config.setting.primaryKey] || '' |
| | | _data.$$BID = BID || '' |
| | | _data.$$BData = BData || '' |
| | | const { BID, BData } = this.state |
| | | |
| | | this.loaded = true |
| | | let _data = window.GLOB.SyncData.get(config.dataName) || [] |
| | | |
| | | this.setState({sync: false, data: _data}, () => { |
| | | if (config.wrap.display === 'modal') { |
| | | this.openModal() |
| | | } |
| | | }) |
| | | } else if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | if (config.$cache) { |
| | | Api.writeCacheConfig(config.uuid, fromJS(_data).toJS()) |
| | | } |
| | | |
| | | _data = _data[0] || {$$empty: true} |
| | | |
| | | _data.$$BID = BID || '' |
| | | _data.$$BData = BData || '' |
| | | _data.$$uuid = _data[config.setting.primaryKey] || '' |
| | | |
| | | this.loaded = true |
| | | |
| | | this.setState({data: _data}, () => { |
| | | if (config.wrap.display === 'modal') { |
| | | this.openModal() |
| | | } |
| | | }) |
| | | |
| | | window.GLOB.SyncData.delete(config.dataName) |
| | | |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | |
| | | searchRefresh = (searchId) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.$searchId !== searchId) return |
| | | |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | |
| | | openModal = (ErrCode) => { |
| | |
| | | * @description 导出Excel时,获取页面搜索排序等参数 |
| | | */ |
| | | queryModuleParam = (menuId, callback) => { |
| | | const { mainSearch } = this.props |
| | | const { config } = this.state |
| | | |
| | | if (config.uuid !== menuId) return |
| | | |
| | | let searches = config.setting.useMSearch && mainSearch ? mainSearch : [] |
| | | let searches = [] |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | searches = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | } |
| | | |
| | | callback({ |
| | | arr_field: '', |
| | |
| | | } |
| | | |
| | | async loadData (type) { |
| | | const { mainSearch } = this.props |
| | | const { config, arr_field, BID, BData } = this.state |
| | | |
| | | if (config.wrap.datatype === 'static') { |
| | |
| | | return |
| | | } |
| | | |
| | | let searches = config.setting.useMSearch && mainSearch ? mainSearch : [] |
| | | let searches = [] |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | searches = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | } |
| | | |
| | | let requireFields = searches.filter(item => item.required && item.value === '') |
| | | if (requireFields.length > 0) { |
| | | if (config.$s_req && searches.filter(item => item.required && item.value === '').length > 0) { |
| | | return |
| | | } |
| | | |
| | |
| | | |
| | | this.loaded = true |
| | | if (config.$cache && config.setting.onload !== 'false') { |
| | | Api.writeCacheConfig(config.uuid, result.data || '') |
| | | Api.writeCacheConfig(config.uuid, result.data || []) |
| | | } |
| | | |
| | | if (!result.data || !result.data[0]) { |
| | |
| | | |
| | | class antvG6Chart extends Component { |
| | | static propTpyes = { |
| | | data: PropTypes.array, // 统一查询数据 |
| | | config: PropTypes.object, // 组件配置信息 |
| | | mainSearch: PropTypes.any, // 外层搜索条件 |
| | | config: PropTypes.object |
| | | } |
| | | |
| | | state = { |
| | |
| | | BID: '', |
| | | BData: '', |
| | | plot: null, |
| | | sync: false, |
| | | arr_field : '', |
| | | chartId: Utils.getuuid(), |
| | | empty: true |
| | |
| | | data = [] |
| | | mkgraph = null |
| | | selectedId = '' |
| | | loaded = false |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { config, data, initdata } = this.props |
| | | const { config } = this.props |
| | | |
| | | let _config = fromJS(config).toJS() |
| | | |
| | | let _sync = _config.setting.sync === 'true' |
| | | |
| | | let BID = '' |
| | | let BData = '' |
| | | |
| | |
| | | BID = BData.$BID || '' |
| | | } |
| | | |
| | | if (_sync && data) { |
| | | this.data = data[config.dataName] || [] |
| | | _sync = false |
| | | } else if (_sync && initdata) { |
| | | this.data = initdata || [] |
| | | _sync = false |
| | | if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { |
| | | this.data = window.GLOB.SyncData.get(_config.dataName) || [] |
| | | |
| | | if (_config.$cache) { |
| | | Api.writeCacheConfig(_config.uuid, fromJS(this.data).toJS()) |
| | | } |
| | | |
| | | _config.setting.sync = 'false' |
| | | |
| | | this.loaded = true |
| | | |
| | | window.GLOB.SyncData.delete(_config.dataName) |
| | | } |
| | | |
| | | _config.plot.height = Utils.getHeight(_config.plot.height) |
| | |
| | | BID: BID || '', |
| | | BData: BData || '', |
| | | arr_field: _config.columns.map(col => col.field).join(','), |
| | | plot: _config.plot, |
| | | sync: _sync |
| | | plot: _config.plot |
| | | }, () => { |
| | | if (config.setting.sync !== 'true' && config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 图表数据更新,刷新内容 |
| | | */ |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | const { sync, config } = this.state |
| | | |
| | | if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) { |
| | | let _data = [] |
| | | |
| | | if (nextProps.data && nextProps.data[config.dataName]) { |
| | | _data = nextProps.data[config.dataName] |
| | | } |
| | | |
| | | if (!is(fromJS(this.data), fromJS(_data))) { |
| | | this.data = _data |
| | | this.handleData() |
| | | } |
| | | |
| | | this.setState({sync: false}) |
| | | } else if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | componentDidMount () { |
| | | const { config, sync } = this.state |
| | | const { config } = this.state |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | | MKEmitter.addListener('resetSelectLine', this.resetParentParam) |
| | | |
| | | if (config.$cache && (config.setting.sync !== 'true' || sync)) { |
| | | if (config.setting.useMSearch) { |
| | | MKEmitter.addListener('searchRefresh', this.searchRefresh) |
| | | } |
| | | |
| | | if (config.setting.sync === 'true') { |
| | | MKEmitter.addListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | |
| | | if (config.$cache && !this.loaded) { |
| | | Api.getLCacheConfig(config.uuid).then(res => { |
| | | if (!res || this.data.length > 0) return |
| | | if (!res || this.loaded) return |
| | | |
| | | if (!is(fromJS(this.data), fromJS(res))) { |
| | | this.data = res |
| | |
| | | return |
| | | } |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('searchRefresh', this.searchRefresh) |
| | | MKEmitter.removeListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | |
| | | transferSyncData = (syncId) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.$syncId !== syncId) return |
| | | |
| | | let _data = window.GLOB.SyncData.get(config.dataName) || [] |
| | | |
| | | if (config.$cache) { |
| | | Api.writeCacheConfig(config.uuid, fromJS(_data).toJS()) |
| | | } |
| | | |
| | | if (!is(fromJS(this.data), fromJS(_data))) { |
| | | this.data = _data |
| | | this.handleData() |
| | | } |
| | | |
| | | this.loaded = true |
| | | |
| | | window.GLOB.SyncData.delete(config.dataName) |
| | | |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | |
| | | searchRefresh = (searchId) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.$searchId !== searchId) return |
| | | |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | |
| | | reloadData = (menuId) => { |
| | |
| | | } |
| | | |
| | | async loadData () { |
| | | const { mainSearch } = this.props |
| | | const { config, arr_field, BID } = this.state |
| | | |
| | | if (config.setting.supModule && !BID) { // BID 不存在时,不做查询 |
| | |
| | | this.data = [] |
| | | this.handleData() |
| | | } |
| | | this.loaded = true |
| | | return |
| | | } |
| | | |
| | | let searches = config.setting.useMSearch && mainSearch ? mainSearch : [] |
| | | let searches = [] |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | searches = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | } |
| | | |
| | | let requireFields = searches.filter(item => item.required && item.value === '') |
| | | if (requireFields.length > 0) { |
| | | if (config.$s_req && searches.filter(item => item.required && item.value === '').length > 0) { |
| | | return |
| | | } |
| | | |
| | |
| | | let result = await Api.genericInterface(param) |
| | | if (result.status) { |
| | | if (config.$cache && config.setting.onload !== 'false') { |
| | | Api.writeCacheConfig(config.uuid, result.data || '') |
| | | Api.writeCacheConfig(config.uuid, result.data || []) |
| | | } |
| | | |
| | | this.loaded = true |
| | | |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | |
| | | |
| | | class LineChart extends Component { |
| | | static propTpyes = { |
| | | data: PropTypes.array, // 统一查询数据 |
| | | config: PropTypes.object, // 组件配置信息 |
| | | mainSearch: PropTypes.any, // 外层搜索条件 |
| | | } |
| | | |
| | | state = { |
| | |
| | | loading: false, // 数据加载状态 |
| | | chartId: Utils.getuuid(), // 图表Id |
| | | transfield: {}, // 字段名称翻译 |
| | | sync: false, // 是否统一请求数据 |
| | | plot: null, // 图表设置 |
| | | search: null, // 搜索条件 |
| | | vFields: [], // 数值字段 |
| | |
| | | } |
| | | |
| | | data = [] |
| | | loaded = false |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { config, data, initdata } = this.props |
| | | let _config = fromJS(config).toJS() |
| | | let _sync = config.setting.sync === 'true' |
| | | const { config } = this.props |
| | | |
| | | let _config = fromJS(config).toJS() |
| | | let BID = '' |
| | | let BData = '' |
| | | |
| | |
| | | } |
| | | if (BData) { |
| | | BID = BData.$BID || '' |
| | | } |
| | | |
| | | if (_sync && data) { |
| | | this.data = data[config.dataName] || [] |
| | | _sync = false |
| | | } else if (_sync && initdata) { |
| | | this.data = initdata || [] |
| | | _sync = false |
| | | } |
| | | |
| | | let vFields = [] |
| | |
| | | }) |
| | | } |
| | | |
| | | if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { |
| | | this.data = window.GLOB.SyncData.get(_config.dataName) || [] |
| | | |
| | | if (_config.$cache) { |
| | | Api.writeCacheConfig(_config.uuid, fromJS(this.data).toJS()) |
| | | } |
| | | |
| | | _config.setting.sync = 'false' |
| | | |
| | | this.loaded = true |
| | | |
| | | window.GLOB.SyncData.delete(_config.dataName) |
| | | } |
| | | |
| | | this.setState({ |
| | | config: _config, |
| | | BID: BID || '', |
| | |
| | | vstFields: vstFields, |
| | | arr_field: _config.columns.map(col => col.field).join(','), |
| | | plot: _config.plot, |
| | | sync: _sync, |
| | | search: Utils.initMainSearch(config.search), |
| | | search: _config.$searches, |
| | | transfield |
| | | }, () => { |
| | | if (config.setting.sync !== 'true' && config.setting.onload === 'true') { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 图表数据更新,刷新内容 |
| | | */ |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | const { sync, config } = this.state |
| | | |
| | | if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) { |
| | | let _data = [] |
| | | if (nextProps.data && nextProps.data[config.dataName]) { |
| | | _data = nextProps.data[config.dataName] || [] |
| | | } |
| | | |
| | | if (!is(fromJS(this.data), fromJS(_data))) { |
| | | this.data = _data |
| | | this.handleData() |
| | | } |
| | | |
| | | this.setState({sync: false}) |
| | | } else if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | componentDidMount () { |
| | | const { config, sync } = this.state |
| | | const { config } = this.state |
| | | |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | | MKEmitter.addListener('resetSelectLine', this.resetParentParam) |
| | | 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.timer) { |
| | | this.timer = new TimerTask() |
| | | this.timer.init(config.uuid, config.timer, config.timerRepeats, () => { |
| | |
| | | }) |
| | | } |
| | | |
| | | if (config.$cache && (config.setting.sync !== 'true' || sync)) { |
| | | if (config.$cache && !this.loaded) { |
| | | Api.getLCacheConfig(config.uuid).then(res => { |
| | | if (!res || this.data.length > 0) return |
| | | if (!res || this.loaded) return |
| | | |
| | | if (!is(fromJS(this.data), fromJS(res))) { |
| | | this.data = res |
| | | this.handleData() |
| | | } |
| | | this.data = res |
| | | this.handleData() |
| | | }) |
| | | } |
| | | } |
| | |
| | | return |
| | | } |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('searchRefresh', this.searchRefresh) |
| | | MKEmitter.removeListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) |
| | | |
| | | this.timer && this.timer.stop() |
| | | } |
| | | |
| | | transferSyncData = (syncId) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.$syncId !== syncId) return |
| | | |
| | | let _data = window.GLOB.SyncData.get(config.dataName) || [] |
| | | |
| | | if (config.$cache) { |
| | | Api.writeCacheConfig(config.uuid, fromJS(_data).toJS()) |
| | | } |
| | | |
| | | if (!is(fromJS(this.data), fromJS(_data))) { |
| | | this.data = _data |
| | | this.handleData() |
| | | } |
| | | |
| | | this.loaded = true |
| | | |
| | | window.GLOB.SyncData.delete(config.dataName) |
| | | |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | |
| | | searchRefresh = (searchId) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.$searchId !== searchId) return |
| | | |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | |
| | | /** |
| | |
| | | * @description 导出Excel时,获取页面搜索排序等参数 |
| | | */ |
| | | queryModuleParam = (menuId, callback) => { |
| | | const { mainSearch } = this.props |
| | | const { arr_field, config, search } = this.state |
| | | |
| | | if (config.uuid !== menuId) return |
| | | |
| | | let searches = search ? fromJS(search).toJS() : [] |
| | | if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | let keys = searches.map(item => item.key.toLowerCase()) |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | let mainSearch = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | let keys = config.$s_keys || [] |
| | | mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key.toLowerCase())) { |
| | | searches.push(item) |
| | | } |
| | | if (keys.includes(item.key.toLowerCase())) return |
| | | |
| | | searches.push(item) |
| | | }) |
| | | } |
| | | |
| | |
| | | * @description 数据加载 |
| | | */ |
| | | async loadData (hastimer) { |
| | | const { mainSearch } = this.props |
| | | const { config, arr_field, BID, search } = this.state |
| | | |
| | | if (config.setting.supModule && !BID) { // BID 不存在时,不做查询 |
| | |
| | | this.data = [] |
| | | this.handleData() |
| | | } |
| | | this.loaded = true |
| | | return |
| | | } |
| | | |
| | | let searches = search ? fromJS(search).toJS() : [] |
| | | if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | let keys = searches.map(item => item.key) |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | let mainSearch = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | let keys = config.$s_keys || [] |
| | | mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key)) { |
| | | searches.push(item) |
| | | } |
| | | if (keys.includes(item.key.toLowerCase())) return |
| | | |
| | | searches.push(item) |
| | | }) |
| | | } |
| | | |
| | | let requireFields = searches.filter(item => item.required && item.value === '') |
| | | if (requireFields.length > 0) { |
| | | if (config.$s_req && searches.filter(item => item.required && item.value === '').length > 0) { |
| | | return |
| | | } |
| | | |
| | |
| | | let result = await Api.genericInterface(param) |
| | | if (result.status) { |
| | | if (config.$cache && config.setting.onload !== 'false') { |
| | | Api.writeCacheConfig(config.uuid, result.data || '') |
| | | Api.writeCacheConfig(config.uuid, result.data || []) |
| | | } |
| | | |
| | | this.loaded = true |
| | | |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | |
| | | |
| | | class DashboardChart extends Component { |
| | | static propTpyes = { |
| | | data: PropTypes.array, // 统一查询数据 |
| | | config: PropTypes.object, // 组件配置信息 |
| | | mainSearch: PropTypes.any, // 外层搜索条件 |
| | | config: PropTypes.object |
| | | } |
| | | |
| | | state = { |
| | |
| | | config: null, // 图表配置信息 |
| | | loading: false, // 数据加载状态 |
| | | chartId: Utils.getuuid(), // 图表Id |
| | | sync: false, // 是否统一请求数据 |
| | | plot: null, // 图表设置 |
| | | chart: null |
| | | } |
| | | |
| | | data = {} |
| | | loaded = false |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { config, data, initdata } = this.props |
| | | const { config } = this.props |
| | | |
| | | let _config = fromJS(config).toJS() |
| | | |
| | | let _sync = _config.setting.sync === 'true' |
| | | |
| | | let BID = '' |
| | | let BData = '' |
| | | |
| | |
| | | BID = BData.$BID || '' |
| | | } |
| | | |
| | | if (_sync && data) { |
| | | this.data = data[config.dataName] || [] |
| | | _sync = false |
| | | } else if (_sync && initdata) { |
| | | this.data = initdata || [] |
| | | _sync = false |
| | | if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { |
| | | this.data = window.GLOB.SyncData.get(_config.dataName) || [] |
| | | |
| | | if (_config.$cache) { |
| | | Api.writeCacheConfig(_config.uuid, fromJS(this.data).toJS()) |
| | | } |
| | | |
| | | _config.setting.sync = 'false' |
| | | |
| | | this.loaded = true |
| | | |
| | | window.GLOB.SyncData.delete(_config.dataName) |
| | | } |
| | | |
| | | if (_config.subtype !== 'ratioboard') { |
| | |
| | | config: _config, |
| | | BID: BID || '', |
| | | arr_field: _config.columns.map(col => col.field).join(','), |
| | | plot: _config.plot, |
| | | sync: _sync |
| | | plot: _config.plot |
| | | }, () => { |
| | | if (config.setting.sync !== 'true' && config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | |
| | | } |
| | | }) |
| | | |
| | | if (config.setting.sync === 'true' && !_sync) { |
| | | if (config.setting.sync === 'true' && this.loaded) { |
| | | this.handleData() |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 图表数据更新,刷新内容 |
| | | */ |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | const { sync, config } = this.state |
| | | |
| | | if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) { |
| | | let _data = null |
| | | |
| | | if (nextProps.data && nextProps.data[config.dataName]) { |
| | | _data = nextProps.data[config.dataName] |
| | | if (config.subtype !== 'ratioboard') { |
| | | if (Array.isArray(_data)) { |
| | | _data = _data[0] || {} |
| | | } |
| | | _data.value = _data[config.plot.valueField] || 0 |
| | | } |
| | | } |
| | | |
| | | if (_data && !is(fromJS(this.data), fromJS(_data))) { |
| | | this.data = _data |
| | | this.handleData() |
| | | } |
| | | |
| | | this.setState({sync: false}) |
| | | } else if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | componentDidMount () { |
| | | const { config, sync } = this.state |
| | | const { config } = this.state |
| | | |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | | MKEmitter.addListener('resetSelectLine', this.resetParentParam) |
| | | |
| | | if (config.setting.useMSearch) { |
| | | MKEmitter.addListener('searchRefresh', this.searchRefresh) |
| | | } |
| | | |
| | | if (config.setting.sync === 'true') { |
| | | MKEmitter.addListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | |
| | | if (config.timer) { |
| | | this.timer = new TimerTask() |
| | | this.timer.init(config.uuid, config.timer, config.timerRepeats, () => { |
| | |
| | | }) |
| | | } |
| | | |
| | | if (config.$cache && (config.setting.sync !== 'true' || sync)) { |
| | | if (config.$cache && !this.loaded) { |
| | | Api.getLCacheConfig(config.uuid).then(res => { |
| | | if (!res) return |
| | | if (!res || this.loaded) return |
| | | |
| | | let _data = null |
| | | if (config.subtype === 'ratioboard') { |
| | | _data = res |
| | | } else { |
| | | _data = res[0] |
| | | _data = res[0] || {} |
| | | _data.value = _data[config.plot.valueField] || 0 |
| | | } |
| | | |
| | |
| | | return |
| | | } |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('searchRefresh', this.searchRefresh) |
| | | MKEmitter.removeListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | |
| | | this.timer && this.timer.stop() |
| | | } |
| | | |
| | | transferSyncData = (syncId) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.$syncId !== syncId) return |
| | | |
| | | let _data = window.GLOB.SyncData.get(config.dataName) || [] |
| | | |
| | | if (config.$cache) { |
| | | Api.writeCacheConfig(config.uuid, fromJS(_data).toJS()) |
| | | } |
| | | |
| | | if (config.subtype !== 'ratioboard') { |
| | | if (Array.isArray(_data)) { |
| | | _data = _data[0] || {} |
| | | } |
| | | _data.value = _data[config.plot.valueField] || 0 |
| | | } |
| | | |
| | | if (!is(fromJS(this.data), fromJS(_data))) { |
| | | this.data = _data |
| | | this.handleData() |
| | | } |
| | | |
| | | this.loaded = true |
| | | |
| | | window.GLOB.SyncData.delete(config.dataName) |
| | | |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | |
| | | searchRefresh = (searchId) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.$searchId !== searchId) return |
| | | |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | |
| | | reloadData = (menuId) => { |
| | |
| | | } |
| | | |
| | | async loadData (hastimer) { |
| | | const { mainSearch } = this.props |
| | | const { config, arr_field, BID } = this.state |
| | | |
| | | if (config.setting.supModule && !BID) { // BID 不存在时,不做查询 |
| | |
| | | this.data = _data |
| | | this.handleData() |
| | | } |
| | | |
| | | this.loaded = true |
| | | return |
| | | } |
| | | |
| | | let searches = config.setting.useMSearch && mainSearch ? mainSearch : [] |
| | | let searches = [] |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | searches = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | } |
| | | |
| | | let requireFields = searches.filter(item => item.required && item.value === '') |
| | | if (requireFields.length > 0) { |
| | | if (config.$s_req && searches.filter(item => item.required && item.value === '').length > 0) { |
| | | return |
| | | } |
| | | |
| | |
| | | let result = await Api.genericInterface(param) |
| | | if (result.status) { |
| | | if (config.$cache && config.setting.onload !== 'false') { |
| | | Api.writeCacheConfig(config.uuid, result.data || '') |
| | | Api.writeCacheConfig(config.uuid, result.data || []) |
| | | } |
| | | |
| | | this.loaded = true |
| | | |
| | | let _data = null |
| | | if (config.subtype === 'ratioboard') { |
| | | _data = result.data || [] |
| | |
| | | |
| | | class PieChart extends Component { |
| | | static propTpyes = { |
| | | data: PropTypes.array, // 统一查询数据 |
| | | config: PropTypes.object, // 组件配置信息 |
| | | mainSearch: PropTypes.any, // 外层搜索条件 |
| | | config: PropTypes.object |
| | | } |
| | | |
| | | state = { |
| | |
| | | loading: false, // 数据加载状态 |
| | | chartId: Utils.getuuid(), // 图表Id |
| | | title: '', // 组件标题 |
| | | sync: false, // 是否统一请求数据 |
| | | plot: null, // 图表设置 |
| | | search: null, // 搜索条件 |
| | | chart: null |
| | | } |
| | | |
| | | data = [] |
| | | loaded = false |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { config, data, initdata } = this.props |
| | | const { config } = this.props |
| | | |
| | | let _config = fromJS(config).toJS() |
| | | |
| | | let _sync = config.setting.sync === 'true' |
| | | |
| | | let BID = '' |
| | | let BData = '' |
| | | |
| | |
| | | } |
| | | if (BData) { |
| | | BID = BData.$BID || '' |
| | | } |
| | | |
| | | if (_sync && data) { |
| | | this.data = data[config.dataName] || [] |
| | | _sync = false |
| | | } else if (_sync && initdata) { |
| | | this.data = initdata || [] |
| | | _sync = false |
| | | } |
| | | |
| | | _config.plot.height = Utils.getHeight(_config.plot.height) |
| | |
| | | |
| | | _config.plot.$decimal = decimal |
| | | |
| | | if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { |
| | | this.data = window.GLOB.SyncData.get(_config.dataName) || [] |
| | | |
| | | if (_config.$cache) { |
| | | Api.writeCacheConfig(_config.uuid, fromJS(this.data).toJS()) |
| | | } |
| | | |
| | | _config.setting.sync = 'false' |
| | | |
| | | this.loaded = true |
| | | |
| | | window.GLOB.SyncData.delete(_config.dataName) |
| | | } |
| | | |
| | | this.setState({ |
| | | config: _config, |
| | | BID: BID || '', |
| | | arr_field: _config.columns.map(col => col.field).join(','), |
| | | plot: _config.plot, |
| | | sync: _sync, |
| | | title: config.plot.title, |
| | | search: Utils.initMainSearch(config.search) |
| | | search: _config.$searches |
| | | }, () => { |
| | | if (config.setting.sync !== 'true' && config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 图表数据更新,刷新内容 |
| | | */ |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | const { sync, config } = this.state |
| | | |
| | | if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) { |
| | | let _data = [] |
| | | if (nextProps.data && nextProps.data[config.dataName]) { |
| | | _data = nextProps.data[config.dataName] || [] |
| | | } |
| | | |
| | | if (!is(fromJS(this.data), fromJS(_data))) { |
| | | this.data = _data |
| | | this.handleData() |
| | | } |
| | | |
| | | this.setState({sync: false}) |
| | | } else if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | componentDidMount () { |
| | | const { config, sync } = this.state |
| | | const { config } = this.state |
| | | |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | | MKEmitter.addListener('resetSelectLine', this.resetParentParam) |
| | | |
| | | if (config.setting.useMSearch) { |
| | | MKEmitter.addListener('searchRefresh', this.searchRefresh) |
| | | } |
| | | |
| | | if (config.setting.sync === 'true') { |
| | | MKEmitter.addListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | |
| | | if (config.timer) { |
| | | this.timer = new TimerTask() |
| | | this.timer.init(config.uuid, config.timer, config.timerRepeats, () => { |
| | |
| | | }) |
| | | } |
| | | |
| | | if (config.$cache && (config.setting.sync !== 'true' || sync)) { |
| | | if (config.$cache && !this.loaded) { |
| | | Api.getLCacheConfig(config.uuid).then(res => { |
| | | if (!res || this.data.length > 0) return |
| | | |
| | | if (!res || this.loaded) return |
| | | |
| | | if (!is(fromJS(this.data), fromJS(res))) { |
| | | this.data = res |
| | | this.handleData() |
| | |
| | | return |
| | | } |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('searchRefresh', this.searchRefresh) |
| | | MKEmitter.removeListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | |
| | | this.timer && this.timer.stop() |
| | | } |
| | | |
| | | transferSyncData = (syncId) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.$syncId !== syncId) return |
| | | |
| | | let _data = window.GLOB.SyncData.get(config.dataName) || [] |
| | | |
| | | if (config.$cache) { |
| | | Api.writeCacheConfig(config.uuid, fromJS(_data).toJS()) |
| | | } |
| | | |
| | | if (!is(fromJS(this.data), fromJS(_data))) { |
| | | this.data = _data |
| | | this.handleData() |
| | | } |
| | | |
| | | this.loaded = true |
| | | |
| | | window.GLOB.SyncData.delete(config.dataName) |
| | | |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | |
| | | searchRefresh = (searchId) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.$searchId !== searchId) return |
| | | |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | |
| | | reloadData = (menuId) => { |
| | |
| | | } |
| | | |
| | | async loadData (hastimer) { |
| | | const { mainSearch } = this.props |
| | | const { config, arr_field, search, BID } = this.state |
| | | |
| | | if (config.setting.supModule && !BID) { // BID 不存在时,不做查询 |
| | |
| | | this.data = [] |
| | | this.handleData() |
| | | } |
| | | this.loaded = true |
| | | return |
| | | } |
| | | |
| | | let searches = fromJS(search).toJS() |
| | | if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | let keys = searches.map(item => item.key) |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | let mainSearch = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | let keys = config.$s_keys || [] |
| | | mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key)) { |
| | | searches.push(item) |
| | | } |
| | | if (keys.includes(item.key.toLowerCase())) return |
| | | |
| | | searches.push(item) |
| | | }) |
| | | } |
| | | |
| | | let requireFields = searches.filter(item => item.required && item.value === '') |
| | | if (requireFields.length > 0) { |
| | | if (config.$s_req && searches.filter(item => item.required && item.value === '').length > 0) { |
| | | return |
| | | } |
| | | |
| | |
| | | let result = await Api.genericInterface(param) |
| | | if (result.status) { |
| | | if (config.$cache && config.setting.onload !== 'false') { |
| | | Api.writeCacheConfig(config.uuid, result.data || '') |
| | | Api.writeCacheConfig(config.uuid, result.data || []) |
| | | } |
| | | this.loaded = true |
| | | |
| | | this.setState({ |
| | | loading: false |
| | |
| | | |
| | | class ScatterChart extends Component { |
| | | static propTpyes = { |
| | | data: PropTypes.array, // 统一查询数据 |
| | | config: PropTypes.object, // 组件配置信息 |
| | | mainSearch: PropTypes.any, // 外层搜索条件 |
| | | config: PropTypes.object |
| | | } |
| | | |
| | | state = { |
| | |
| | | empty: true, // 图表数据为空 |
| | | loading: false, // 数据加载状态 |
| | | chartId: Utils.getuuid(), // 图表Id |
| | | sync: false, // 是否统一请求数据 |
| | | plot: null, // 图表设置 |
| | | search: null, // 搜索条件 |
| | | chart: null |
| | | } |
| | | |
| | | data = [] |
| | | loaded = false |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { config, data, initdata } = this.props |
| | | let _config = fromJS(config).toJS() |
| | | let _sync = config.setting.sync === 'true' |
| | | const { config } = this.props |
| | | |
| | | let _config = fromJS(config).toJS() |
| | | let BID = '' |
| | | let BData = '' |
| | | |
| | |
| | | BID = BData.$BID || '' |
| | | } |
| | | |
| | | if (_sync && data) { |
| | | this.data = data[config.dataName] || [] |
| | | _sync = false |
| | | } else if (_sync && initdata) { |
| | | this.data = initdata || [] |
| | | _sync = false |
| | | } |
| | | |
| | | _config.plot.height = Utils.getHeight(_config.plot.height) |
| | | _config.style.height = 'auto' |
| | | _config.style.minHeight = _config.plot.height + 30 |
| | |
| | | _config.style.minHeight = _config.style.minHeight + 45 |
| | | } |
| | | |
| | | if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { |
| | | this.data = window.GLOB.SyncData.get(_config.dataName) || [] |
| | | |
| | | if (_config.$cache) { |
| | | Api.writeCacheConfig(_config.uuid, fromJS(this.data).toJS()) |
| | | } |
| | | |
| | | _config.setting.sync = 'false' |
| | | |
| | | this.loaded = true |
| | | |
| | | window.GLOB.SyncData.delete(_config.dataName) |
| | | } |
| | | |
| | | this.setState({ |
| | | config: _config, |
| | | BID: BID || '', |
| | | empty: this.data.length === 0, |
| | | arr_field: _config.columns.map(col => col.field).join(','), |
| | | plot: _config.plot, |
| | | sync: _sync, |
| | | search: Utils.initMainSearch(config.search), |
| | | search: _config.$searches |
| | | }, () => { |
| | | if (config.setting.sync !== 'true' && config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 图表数据更新,刷新内容 |
| | | */ |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | const { sync, config } = this.state |
| | | |
| | | if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) { |
| | | let _data = [] |
| | | if (nextProps.data && nextProps.data[config.dataName]) { |
| | | _data = nextProps.data[config.dataName] || [] |
| | | } |
| | | |
| | | if (!is(fromJS(this.data), fromJS(_data))) { |
| | | this.data = _data |
| | | this.handleData() |
| | | } |
| | | |
| | | this.setState({sync: false, empty: _data.length === 0}) |
| | | } else if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | componentDidMount () { |
| | | const { config, sync } = this.state |
| | | const { config } = this.state |
| | | |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | | MKEmitter.addListener('resetSelectLine', this.resetParentParam) |
| | | 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.timer) { |
| | | this.timer = new TimerTask() |
| | | this.timer.init(config.uuid, config.timer, config.timerRepeats, () => { |
| | |
| | | }) |
| | | } |
| | | |
| | | if (config.$cache && (config.setting.sync !== 'true' || sync)) { |
| | | if (config.$cache && !this.loaded) { |
| | | Api.getLCacheConfig(config.uuid).then(res => { |
| | | if (!res || this.data.length > 0) return |
| | | if (!res || this.loaded) return |
| | | |
| | | if (!is(fromJS(this.data), fromJS(res))) { |
| | | this.data = res |
| | | this.handleData() |
| | | } |
| | | |
| | | this.setState({empty: false}) |
| | | this.setState({empty: res.length > 0}) |
| | | }) |
| | | } |
| | | } |
| | |
| | | return |
| | | } |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('searchRefresh', this.searchRefresh) |
| | | MKEmitter.removeListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) |
| | | |
| | | this.timer && this.timer.stop() |
| | | } |
| | | |
| | | transferSyncData = (syncId) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.$syncId !== syncId) return |
| | | |
| | | let _data = window.GLOB.SyncData.get(config.dataName) || [] |
| | | |
| | | if (config.$cache) { |
| | | Api.writeCacheConfig(config.uuid, fromJS(_data).toJS()) |
| | | } |
| | | |
| | | if (!is(fromJS(this.data), fromJS(_data))) { |
| | | this.data = _data |
| | | this.handleData() |
| | | } |
| | | |
| | | this.setState({empty: _data.length === 0}) |
| | | |
| | | this.loaded = true |
| | | |
| | | window.GLOB.SyncData.delete(config.dataName) |
| | | |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | |
| | | searchRefresh = (searchId) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.$searchId !== searchId) return |
| | | |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | |
| | | /** |
| | |
| | | * @description 导出Excel时,获取页面搜索排序等参数 |
| | | */ |
| | | queryModuleParam = (menuId, callback) => { |
| | | const { mainSearch } = this.props |
| | | const { arr_field, config, search } = this.state |
| | | |
| | | if (config.uuid !== menuId) return |
| | | |
| | | let searches = search ? fromJS(search).toJS() : [] |
| | | if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | let keys = searches.map(item => item.key.toLowerCase()) |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | let mainSearch = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | let keys = config.$s_keys || [] |
| | | mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key.toLowerCase())) { |
| | | searches.push(item) |
| | | } |
| | | if (keys.includes(item.key.toLowerCase())) return |
| | | |
| | | searches.push(item) |
| | | }) |
| | | } |
| | | |
| | |
| | | * @description 数据加载 |
| | | */ |
| | | async loadData (hastimer) { |
| | | const { mainSearch } = this.props |
| | | const { config, arr_field, BID, search } = this.state |
| | | |
| | | if (config.setting.supModule && !BID) { // BID 不存在时,不做查询 |
| | |
| | | this.data = [] |
| | | this.handleData() |
| | | } |
| | | |
| | | this.loaded = true |
| | | return |
| | | } |
| | | |
| | | let searches = search ? fromJS(search).toJS() : [] |
| | | if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | let keys = searches.map(item => item.key) |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | let mainSearch = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | let keys = config.$s_keys || [] |
| | | mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key)) { |
| | | searches.push(item) |
| | | } |
| | | if (keys.includes(item.key.toLowerCase())) return |
| | | |
| | | searches.push(item) |
| | | }) |
| | | } |
| | | |
| | | let requireFields = searches.filter(item => item.required && item.value === '') |
| | | if (requireFields.length > 0) { |
| | | if (config.$s_req && searches.filter(item => item.required && item.value === '').length > 0) { |
| | | return |
| | | } |
| | | |
| | |
| | | let result = await Api.genericInterface(param) |
| | | if (result.status) { |
| | | if (config.$cache && config.setting.onload !== 'false') { |
| | | Api.writeCacheConfig(config.uuid, result.data || '') |
| | | Api.writeCacheConfig(config.uuid, result.data || []) |
| | | } |
| | | this.loaded = true |
| | | |
| | | this.setState({ |
| | | empty: !result.data || result.data.length === 0, |
| | |
| | | |
| | | class CustomChart extends Component { |
| | | static propTpyes = { |
| | | data: PropTypes.array, // 统一查询数据 |
| | | config: PropTypes.object, // 组件配置信息 |
| | | mainSearch: PropTypes.any, // 外层搜索条件 |
| | | config: PropTypes.object |
| | | } |
| | | |
| | | state = { |
| | |
| | | config: null, // 图表配置信息 |
| | | empty: true, // 图表数据为空 |
| | | loading: false, // 数据加载状态 |
| | | sync: false, // 是否统一请求数据 |
| | | plot: null, // 图表设置 |
| | | search: null, // 搜索条件 |
| | | } |
| | | |
| | | data = [] |
| | | loaded = false |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { config, data, initdata } = this.props |
| | | let _config = fromJS(config).toJS() |
| | | let _sync = config.setting.sync === 'true' |
| | | const { config } = this.props |
| | | |
| | | let _config = fromJS(config).toJS() |
| | | let BID = '' |
| | | let BData = '' |
| | | |
| | |
| | | BID = BData.$BID || '' |
| | | } |
| | | |
| | | if (_sync && data) { |
| | | this.data = data[config.dataName] || [] |
| | | _sync = false |
| | | } else if (_sync && initdata) { |
| | | this.data = initdata || [] |
| | | _sync = false |
| | | } |
| | | |
| | | _config.plot.height = Utils.getHeight(_config.plot.height) |
| | | _config.style.height = 'auto' |
| | | |
| | | if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { |
| | | this.data = window.GLOB.SyncData.get(_config.dataName) || [] |
| | | |
| | | if (_config.$cache) { |
| | | Api.writeCacheConfig(_config.uuid, fromJS(this.data).toJS()) |
| | | } |
| | | |
| | | _config.setting.sync = 'false' |
| | | |
| | | this.loaded = true |
| | | |
| | | window.GLOB.SyncData.delete(_config.dataName) |
| | | } |
| | | |
| | | this.setState({ |
| | | config: _config, |
| | |
| | | BID: BID || '', |
| | | arr_field: _config.columns.map(col => col.field).join(','), |
| | | plot: _config.plot, |
| | | sync: _sync, |
| | | search: Utils.initMainSearch(config.search) |
| | | search: _config.$searches |
| | | }, () => { |
| | | if (config.setting.sync !== 'true' && config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 图表数据更新,刷新内容 |
| | | */ |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | const { sync, config } = this.state |
| | | |
| | | if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) { |
| | | let _data = [] |
| | | if (nextProps.data && nextProps.data[config.dataName]) { |
| | | _data = nextProps.data[config.dataName] || [] |
| | | } |
| | | |
| | | if (!is(fromJS(this.data), fromJS(_data))) { |
| | | this.data = _data |
| | | this.handleData() |
| | | } |
| | | |
| | | this.setState({sync: false, empty: _data.length === 0}) |
| | | } else if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | componentDidMount () { |
| | | const { config, sync } = this.state |
| | | const { config } = this.state |
| | | |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | | MKEmitter.addListener('resetSelectLine', this.resetParentParam) |
| | | 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.timer) { |
| | | this.timer = new TimerTask() |
| | | this.timer.init(config.uuid, config.timer, config.timerRepeats, () => { |
| | |
| | | }) |
| | | } |
| | | |
| | | if (config.$cache && (config.setting.sync !== 'true' || sync)) { |
| | | if (config.$cache && !this.loaded) { |
| | | Api.getLCacheConfig(config.uuid).then(res => { |
| | | if (!res || this.data.length > 0) return |
| | | if (!res || this.loaded) return |
| | | |
| | | if (!is(fromJS(this.data), fromJS(res))) { |
| | | this.data = res |
| | | this.handleData() |
| | | } |
| | | this.setState({empty: false}) |
| | | this.setState({empty: res.length > 0}) |
| | | }) |
| | | } |
| | | } |
| | |
| | | return |
| | | } |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('searchRefresh', this.searchRefresh) |
| | | MKEmitter.removeListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) |
| | | |
| | | this.timer && this.timer.stop() |
| | | } |
| | | |
| | | transferSyncData = (syncId) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.$syncId !== syncId) return |
| | | |
| | | let _data = window.GLOB.SyncData.get(config.dataName) || [] |
| | | |
| | | if (config.$cache) { |
| | | Api.writeCacheConfig(config.uuid, fromJS(_data).toJS()) |
| | | } |
| | | |
| | | if (!is(fromJS(this.data), fromJS(_data))) { |
| | | this.data = _data |
| | | this.handleData() |
| | | } |
| | | |
| | | this.setState({empty: _data.length === 0}) |
| | | |
| | | this.loaded = true |
| | | |
| | | window.GLOB.SyncData.delete(config.dataName) |
| | | |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | |
| | | searchRefresh = (searchId) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.$searchId !== searchId) return |
| | | |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | |
| | | /** |
| | |
| | | * @description 导出Excel时,获取页面搜索排序等参数 |
| | | */ |
| | | queryModuleParam = (menuId, callback) => { |
| | | const { mainSearch } = this.props |
| | | const { arr_field, config, search } = this.state |
| | | |
| | | if (config.uuid !== menuId) return |
| | | |
| | | let searches = search ? fromJS(search).toJS() : [] |
| | | if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | let keys = searches.map(item => item.key.toLowerCase()) |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | let mainSearch = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | let keys = config.$s_keys || [] |
| | | mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key.toLowerCase())) { |
| | | searches.push(item) |
| | | } |
| | | if (keys.includes(item.key.toLowerCase())) return |
| | | |
| | | searches.push(item) |
| | | }) |
| | | } |
| | | |
| | |
| | | * @description 数据加载 |
| | | */ |
| | | async loadData (hastimer) { |
| | | const { mainSearch } = this.props |
| | | const { config, arr_field, BID, search } = this.state |
| | | |
| | | if (config.setting.supModule && !BID) { // BID 不存在时,不做查询 |
| | |
| | | this.data = [] |
| | | this.handleData() |
| | | } |
| | | |
| | | this.loaded = true |
| | | return |
| | | } |
| | | |
| | | let searches = search ? fromJS(search).toJS() : [] |
| | | if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | let keys = searches.map(item => item.key) |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | let mainSearch = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | let keys = config.$s_keys || [] |
| | | mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key)) { |
| | | searches.push(item) |
| | | } |
| | | if (keys.includes(item.key.toLowerCase())) return |
| | | |
| | | searches.push(item) |
| | | }) |
| | | } |
| | | |
| | | let requireFields = searches.filter(item => item.required && item.value === '') |
| | | if (requireFields.length > 0) { |
| | | if (config.$s_req && searches.filter(item => item.required && item.value === '').length > 0) { |
| | | return |
| | | } |
| | | |
| | |
| | | let result = await Api.genericInterface(param) |
| | | if (result.status) { |
| | | if (config.$cache && config.setting.onload !== 'false') { |
| | | Api.writeCacheConfig(config.uuid, result.data || '') |
| | | Api.writeCacheConfig(config.uuid, result.data || []) |
| | | } |
| | | this.loaded = true |
| | | |
| | | this.setState({ |
| | | loading: false, |
| | |
| | | |
| | | class SandBoxComponent extends Component { |
| | | static propTpyes = { |
| | | data: PropTypes.array, // 统一查询数据 |
| | | config: PropTypes.object, // 组件配置信息 |
| | | mainSearch: PropTypes.any, // 外层搜索条件 |
| | | config: PropTypes.object |
| | | } |
| | | |
| | | state = { |
| | | BID: '', // 上级ID |
| | | config: null, // 图表配置信息 |
| | | loading: false, // 数据加载状态 |
| | | sync: false, // 是否统一请求数据 |
| | | data: [], // 数据 |
| | | html: '', |
| | | result: {} |
| | |
| | | loaded = false |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { data, initdata } = this.props |
| | | let _config = fromJS(this.props.config).toJS() |
| | | const { config } = this.props |
| | | |
| | | let _config = fromJS(config).toJS() |
| | | let _data = [] |
| | | let _sync = false |
| | | |
| | | let BID = '' |
| | | let BData = '' |
| | | |
| | |
| | | } |
| | | |
| | | if (_config.wrap.datatype !== 'static') { |
| | | _sync = _config.setting.sync === 'true' |
| | | |
| | | if (_sync && data) { |
| | | _data = data[_config.dataName] || [] |
| | | _sync = 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()) |
| | | } |
| | | |
| | | _config.setting.sync = 'false' |
| | | |
| | | this.loaded = true |
| | | } else if (_sync && initdata) { |
| | | _data = initdata || {} |
| | | _sync = false |
| | | this.loaded = true |
| | | |
| | | window.GLOB.SyncData.delete(_config.dataName) |
| | | } |
| | | } else { |
| | | _data = {} |
| | | this.loaded = true |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | this.setState({ |
| | | sync: _sync, |
| | | data: _data, |
| | | BID: BID || '', |
| | | config: _config, |
| | | arr_field: _config.columns.map(col => col.field).join(','), |
| | | }, () => { |
| | | if (_config.wrap.datatype !== 'static' && _config.setting && _config.setting.sync !== 'true' && _config.setting.onload === 'true') { |
| | | if (_config.wrap.datatype !== 'static' && config.setting.sync !== 'true' && _config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | | this.loadData() |
| | | }, _config.setting.delay || 0) |
| | |
| | | const { config } = this.state |
| | | |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | | |
| | | if (config.setting.useMSearch) { |
| | | MKEmitter.addListener('searchRefresh', this.searchRefresh) |
| | | } |
| | | |
| | | if (config.setting.sync === 'true') { |
| | | MKEmitter.addListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | |
| | | if (config.$cache && !this.loaded) { |
| | | Api.getLCacheConfig(config.uuid).then(res => { |
| | |
| | | return |
| | | } |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('searchRefresh', this.searchRefresh) |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | |
| | | /** |
| | | * @description 图表数据更新,刷新内容 |
| | | */ |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | const { sync, config } = this.state |
| | | transferSyncData = (syncId) => { |
| | | const { config } = this.state |
| | | |
| | | if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) { |
| | | let _data = [] |
| | | if (nextProps.data && nextProps.data[config.dataName]) { |
| | | _data = nextProps.data[config.dataName] |
| | | } |
| | | if (config.$syncId !== syncId) return |
| | | |
| | | this.loaded = true |
| | | let _data = window.GLOB.SyncData.get(config.dataName) || [] |
| | | |
| | | if (!is(fromJS(this.state.data), fromJS(_data))) { |
| | | setTimeout(() => { |
| | | this.renderView() |
| | | }, 10) |
| | | } |
| | | |
| | | this.setState({sync: false, data: _data}) |
| | | } else if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | if (config.$cache) { |
| | | Api.writeCacheConfig(config.uuid, fromJS(_data).toJS()) |
| | | } |
| | | |
| | | if (!is(fromJS(this.state.data), fromJS(_data))) { |
| | | setTimeout(() => { |
| | | this.renderView() |
| | | }, 10) |
| | | } |
| | | |
| | | this.setState({data: _data}) |
| | | |
| | | this.loaded = true |
| | | |
| | | window.GLOB.SyncData.delete(config.dataName) |
| | | |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | |
| | | searchRefresh = (searchId) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.$searchId !== searchId) return |
| | | |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | |
| | | reloadData = (menuId) => { |
| | |
| | | } |
| | | |
| | | async loadData () { |
| | | const { mainSearch } = this.props |
| | | const { config, arr_field, BID } = this.state |
| | | |
| | | if (config.wrap.datatype === 'static') { |
| | |
| | | return |
| | | } |
| | | |
| | | let searches = config.setting.useMSearch && mainSearch ? mainSearch : [] |
| | | let searches = [] |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | searches = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | } |
| | | |
| | | let requireFields = searches.filter(item => item.required && item.value === '') |
| | | if (requireFields.length > 0) { |
| | | if (config.$s_req && searches.filter(item => item.required && item.value === '').length > 0) { |
| | | return |
| | | } |
| | | |
| | |
| | | |
| | | this.loaded = true |
| | | if (config.$cache && config.setting.onload !== 'false') { |
| | | Api.writeCacheConfig(config.uuid, result.data || '') |
| | | Api.writeCacheConfig(config.uuid, result.data || []) |
| | | } |
| | | |
| | | if (!is(fromJS(this.state.data), fromJS(_data))) { |
| | |
| | | |
| | | class BraftEditorContent extends Component { |
| | | static propTpyes = { |
| | | data: PropTypes.array, // 统一查询数据 |
| | | config: PropTypes.object, // 组件配置信息 |
| | | mainSearch: PropTypes.any, // 外层搜索条件 |
| | | config: PropTypes.object |
| | | } |
| | | |
| | | state = { |
| | | BID: '', // 上级ID |
| | | config: null, // 图表配置信息 |
| | | loading: false, // 数据加载状态 |
| | | sync: false, // 是否统一请求数据 |
| | | data: {} // 数据 |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { data, initdata } = this.props |
| | | let _config = fromJS(this.props.config).toJS() |
| | | const { config } = this.props |
| | | |
| | | let _config = fromJS(config).toJS() |
| | | let _data = { $$empty: true } |
| | | let _sync = false |
| | | |
| | | let BID = '' |
| | | let BData = '' |
| | |
| | | BID = BData.$BID || '' |
| | | } |
| | | |
| | | if (_config.setting && _config.wrap.datatype === 'dynamic') { |
| | | _sync = _config.setting.sync === 'true' |
| | | if (_config.wrap.datatype === 'dynamic') { |
| | | if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { |
| | | _data = window.GLOB.SyncData.get(_config.dataName) || [] |
| | | _data = _data[0] || {$$empty: true} |
| | | |
| | | if (_sync && data) { |
| | | _data = data[_config.dataName] || {$$empty: true} |
| | | if (_data && Array.isArray(_data)) { |
| | | _data = _data[0] || {$$empty: true} |
| | | } |
| | | _sync = false |
| | | } else if (_sync && initdata) { |
| | | _data = initdata |
| | | if (_data && Array.isArray(_data)) { |
| | | _data = _data[0] || {$$empty: true} |
| | | } |
| | | _sync = false |
| | | _config.setting.sync = 'false' |
| | | |
| | | window.GLOB.SyncData.delete(_config.dataName) |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | this.setState({ |
| | | sync: _sync, |
| | | data: _data, |
| | | BID: BID || '', |
| | | config: _config, |
| | | arr_field: _config.columns.map(col => col.field).join(','), |
| | | }, () => { |
| | | if (_config.wrap.datatype === 'dynamic' && _config.setting && _config.setting.sync !== 'true' && _config.setting.onload === 'true') { |
| | | if (_config.wrap.datatype === 'dynamic' && config.setting.sync !== 'true' && _config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | | this.loadData() |
| | | }, _config.setting.delay || 0) |
| | |
| | | |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | | MKEmitter.addListener('resetSelectLine', this.resetParentParam) |
| | | |
| | | 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) |
| | |
| | | } |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('mkPublicData', this.mkPublicData) |
| | | MKEmitter.removeListener('searchRefresh', this.searchRefresh) |
| | | MKEmitter.removeListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | |
| | | /** |
| | | * @description 图表数据更新,刷新内容 |
| | | */ |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | const { sync, config } = this.state |
| | | transferSyncData = (syncId) => { |
| | | const { config } = this.state |
| | | |
| | | if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) { |
| | | let _data = {$$empty: true} |
| | | if (nextProps.data && nextProps.data[config.dataName]) { |
| | | _data = nextProps.data[config.dataName] |
| | | if (_data && Array.isArray(_data)) { |
| | | _data = _data[0] || {$$empty: true} |
| | | } |
| | | } |
| | | if (config.$syncId !== syncId) return |
| | | |
| | | this.setState({sync: false, data: _data}) |
| | | } else if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | let _data = window.GLOB.SyncData.get(config.dataName) || [] |
| | | _data = _data[0] || {$$empty: true} |
| | | |
| | | this.setState({data: _data}) |
| | | |
| | | window.GLOB.SyncData.delete(config.dataName) |
| | | |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | |
| | | searchRefresh = (searchId) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.$searchId !== searchId) return |
| | | |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | |
| | | mkPublicData = (publicId, data) => { |
| | |
| | | } |
| | | |
| | | async loadData () { |
| | | const { mainSearch } = this.props |
| | | const { config, arr_field, BID } = this.state |
| | | |
| | | if (config.wrap.datatype === 'public') { |
| | |
| | | return |
| | | } |
| | | |
| | | let searches = config.setting.useMSearch && mainSearch ? mainSearch : [] |
| | | let searches = [] |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | searches = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | } |
| | | |
| | | let requireFields = searches.filter(item => item.required && item.value === '') |
| | | if (requireFields.length > 0) { |
| | | if (config.$s_req && searches.filter(item => item.required && item.value === '').length > 0) { |
| | | return |
| | | } |
| | | |
| | |
| | | |
| | | let result = await Api.genericInterface(param) |
| | | if (result.status) { |
| | | let _data = result.data && result.data[0] ? result.data[0] : {$$empty: true} |
| | | let _data = result.data || [] |
| | | _data = _data[0] || {$$empty: true} |
| | | |
| | | this.setState({ |
| | | data: _data, |
| | |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import asyncSpinComponent from '@/utils/asyncSpinComponent' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import zhCN from '@/locales/zh-CN/main.js' |
| | | import enUS from '@/locales/en-US/main.js' |
| | | import './index.scss' |
| | | |
| | | const MutilForm = asyncSpinComponent(() => import('@/tabviews/zshare/mutilform')) |
| | |
| | | |
| | | class SimpleForm extends Component { |
| | | static propTpyes = { |
| | | data: PropTypes.array, // 统一查询数据 |
| | | config: PropTypes.object, // 组件配置信息 |
| | | mainSearch: PropTypes.any, // 外层搜索条件 |
| | | config: PropTypes.object |
| | | } |
| | | |
| | | state = { |
| | | dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, |
| | | BID: '', |
| | | config: null, |
| | | loading: false, |
| | | sync: false, |
| | | data: null, |
| | | group: null, |
| | | BData: '', |
| | |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { data } = this.props |
| | | let config = fromJS(this.props.config).toJS() |
| | | const { config } = this.props |
| | | |
| | | let _config = fromJS(config).toJS() |
| | | let _data = null |
| | | let _sync = false |
| | | |
| | | let BID = '' |
| | | let BData = '' |
| | | |
| | | if (config.setting.supModule) { |
| | | BData = window.GLOB.CacheData.get(config.setting.supModule) |
| | | if (_config.setting.supModule) { |
| | | BData = window.GLOB.CacheData.get(_config.setting.supModule) |
| | | } else { |
| | | BData = window.GLOB.CacheData.get(config.$pageId) |
| | | BData = window.GLOB.CacheData.get(_config.$pageId) |
| | | } |
| | | if (BData) { |
| | | BID = BData.$BID || '' |
| | | } |
| | | |
| | | if (config.wrap.datatype !== 'static') { |
| | | _sync = config.setting.sync === 'true' |
| | | if (_config.wrap.datatype !== 'static') { |
| | | if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { |
| | | _data = window.GLOB.SyncData.get(_config.dataName) || [] |
| | | _data = _data[0] || {$$empty: true} |
| | | _data.$$uuid = _data[_config.setting.primaryKey] || '' |
| | | |
| | | if (_sync && data) { |
| | | _data = data[config.dataName] || {$$empty: true} |
| | | if (Array.isArray(_data)) { |
| | | _data = _data[0] || {$$empty: true} |
| | | } |
| | | _sync = false |
| | | _data.$$uuid = _data[config.setting.primaryKey] || '' |
| | | _config.setting.sync = 'false' |
| | | |
| | | window.GLOB.SyncData.delete(_config.dataName) |
| | | } |
| | | } else { |
| | | _data = {$$empty: true} |
| | | } |
| | | |
| | | let _group = config.subcards[0] |
| | | let _group = _config.subcards[0] |
| | | |
| | | if (_group.subButton.enable === 'false' && (!_group.closeButton || _group.closeButton.enable !== 'true')) { |
| | | _group.subButton.style.display = 'none' |
| | |
| | | } |
| | | |
| | | this.setState({ |
| | | sync: _sync, |
| | | data: _data, |
| | | group: _group, |
| | | BID: BID || '', |
| | | BData: BData || '', |
| | | config: config, |
| | | arr_field: config.columns.map(col => col.field).join(','), |
| | | config: _config, |
| | | arr_field: _config.columns.map(col => col.field).join(','), |
| | | }, () => { |
| | | if (config.wrap.datatype !== 'static' && config.setting.sync !== 'true' && config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | |
| | | } |
| | | |
| | | componentDidMount () { |
| | | const { config } = this.state |
| | | |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | | MKEmitter.addListener('mkFormSubmit', this.mkFormSubmit) |
| | | MKEmitter.addListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) |
| | | |
| | | if (config.setting.useMSearch) { |
| | | MKEmitter.addListener('searchRefresh', this.searchRefresh) |
| | | } |
| | | |
| | | if (config.setting.sync === 'true') { |
| | | MKEmitter.addListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | } |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('mkFormSubmit', this.mkFormSubmit) |
| | | MKEmitter.removeListener('searchRefresh', this.searchRefresh) |
| | | MKEmitter.removeListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) |
| | | } |
| | | |
| | | /** |
| | | * @description 图表数据更新,刷新内容 |
| | | */ |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | const { sync, config } = this.state |
| | | transferSyncData = (syncId) => { |
| | | const { config } = this.state |
| | | |
| | | if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) { |
| | | let _data = {$$empty: true} |
| | | if (nextProps.data && nextProps.data[config.dataName]) { |
| | | _data = nextProps.data[config.dataName] |
| | | if (Array.isArray(_data)) { |
| | | _data = _data[0] || {$$empty: true} |
| | | } |
| | | } |
| | | if (config.$syncId !== syncId) return |
| | | |
| | | _data.$$uuid = _data[config.setting.primaryKey] || '' |
| | | let _data = window.GLOB.SyncData.get(config.dataName) || [] |
| | | _data = _data[0] || {$$empty: true} |
| | | _data.$$uuid = _data[config.setting.primaryKey] || '' |
| | | |
| | | this.setState({sync: false, data: _data}) |
| | | } else if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | this.setState({data: _data}) |
| | | |
| | | window.GLOB.SyncData.delete(config.dataName) |
| | | |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | |
| | | searchRefresh = (searchId) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.$searchId !== searchId) return |
| | | |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | |
| | | reloadData = (menuId, id) => { |
| | |
| | | } |
| | | |
| | | async loadData () { |
| | | const { mainSearch } = this.props |
| | | const { config, arr_field, BID } = this.state |
| | | |
| | | if (config.wrap.datatype === 'static') { |
| | |
| | | return |
| | | } |
| | | |
| | | let searches = config.setting.useMSearch && mainSearch ? mainSearch : [] |
| | | let searches = [] |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | searches = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | } |
| | | |
| | | let requireFields = searches.filter(item => item.required && item.value === '') |
| | | if (requireFields.length > 0) { |
| | | if (config.$s_req && searches.filter(item => item.required && item.value === '').length > 0) { |
| | | return |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { config, loading, BID, BData, data, group, dict } = this.state |
| | | const { config, loading, BID, BData, data, group } = this.state |
| | | |
| | | if (config.wrap.empty === 'hidden' && (!data || data.$$empty)) return null |
| | | if (config.idCtrl && (!data || data.$$empty)) return null |
| | |
| | | {data ? <MutilForm |
| | | BID={BID} |
| | | BData={BData} |
| | | dict={dict} |
| | | data={data} |
| | | action={group} |
| | | unload={config.setting.supModule && !BID} |
| | |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import asyncSpinComponent from '@/utils/asyncSpinComponent' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import zhCN from '@/locales/zh-CN/main.js' |
| | | import enUS from '@/locales/en-US/main.js' |
| | | import './index.scss' |
| | | |
| | | const MutilForm = asyncSpinComponent(() => import('@/tabviews/zshare/mutilform')) |
| | |
| | | |
| | | class StepForm extends Component { |
| | | static propTpyes = { |
| | | data: PropTypes.array, // 统一查询数据 |
| | | config: PropTypes.object, // 组件配置信息 |
| | | mainSearch: PropTypes.any, // 外层搜索条件 |
| | | config: PropTypes.object |
| | | } |
| | | |
| | | state = { |
| | | dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, |
| | | BID: '', |
| | | config: null, |
| | | loading: false, |
| | | sync: false, |
| | | data: null, |
| | | group: null, |
| | | BData: '', |
| | |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { data } = this.props |
| | | let config = fromJS(this.props.config).toJS() |
| | | const { config } = this.props |
| | | |
| | | let _config = fromJS(config).toJS() |
| | | let _data = null |
| | | let _sync = false |
| | | |
| | | let BID = '' |
| | | let BData = '' |
| | | |
| | | if (config.setting.supModule) { |
| | | BData = window.GLOB.CacheData.get(config.setting.supModule) |
| | | if (_config.setting.supModule) { |
| | | BData = window.GLOB.CacheData.get(_config.setting.supModule) |
| | | } else { |
| | | BData = window.GLOB.CacheData.get(config.$pageId) |
| | | BData = window.GLOB.CacheData.get(_config.$pageId) |
| | | } |
| | | if (BData) { |
| | | BID = BData.$BID || '' |
| | | } |
| | | |
| | | if (config.wrap.datatype !== 'static') { |
| | | _sync = config.setting.sync === 'true' |
| | | if (_config.wrap.datatype !== 'static') { |
| | | if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { |
| | | _data = window.GLOB.SyncData.get(_config.dataName) || [] |
| | | _data = _data[0] || {$$empty: true} |
| | | _data.$$uuid = _data[_config.setting.primaryKey] || '' |
| | | |
| | | if (_sync && data) { |
| | | _data = data[config.dataName] || {$$empty: true} |
| | | if (Array.isArray(_data)) { |
| | | _data = _data[0] || {$$empty: true} |
| | | } |
| | | _sync = false |
| | | _data.$$uuid = _data[config.setting.primaryKey] || '' |
| | | _config.setting.sync = 'false' |
| | | |
| | | window.GLOB.SyncData.delete(_config.dataName) |
| | | } |
| | | } else { |
| | | _data = {$$empty: true} |
| | | } |
| | | |
| | | if (!config.wrap.groupLabel) { |
| | | if (config.subcards.length > 1) { |
| | | config.wrap.groupLabel = 'show' |
| | | if (!_config.wrap.groupLabel) { |
| | | if (_config.subcards.length > 1) { |
| | | _config.wrap.groupLabel = 'show' |
| | | } else { |
| | | config.wrap.groupLabel = 'hidden' |
| | | _config.wrap.groupLabel = 'hidden' |
| | | } |
| | | } |
| | | |
| | | config.subcards = config.subcards.map((group, i) => { |
| | | _config.subcards = _config.subcards.map((group, i) => { |
| | | group.sort = i + 1 |
| | | if (i === 0 && group.prevButton.actionType !== 'close') { |
| | | group.prevButton.enable = 'false' |
| | | } |
| | | if (i + 1 === config.subcards.length && group.nextButton.actionType !== 'close') { |
| | | if (i + 1 === _config.subcards.length && group.nextButton.actionType !== 'close') { |
| | | group.nextButton.enable = 'false' |
| | | } |
| | | |
| | |
| | | return group |
| | | }) |
| | | |
| | | let _group = config.subcards[0] |
| | | let _group = _config.subcards[0] |
| | | |
| | | if (_data && config.wrap.statusControl && _data[config.wrap.statusControl] !== undefined) { |
| | | let _status = _data[config.wrap.statusControl] + '' |
| | | if (_data && _config.wrap.statusControl && _data[_config.wrap.statusControl] !== undefined) { |
| | | let _status = _data[_config.wrap.statusControl] + '' |
| | | |
| | | let _groups = config.subcards.filter(item => item.setting.status === _status)[0] |
| | | let _groups = _config.subcards.filter(item => item.setting.status === _status)[0] |
| | | _group = _groups || _group |
| | | } |
| | | |
| | | config.titleStyle = {} |
| | | config.sortStyle = {} |
| | | _config.titleStyle = {} |
| | | _config.sortStyle = {} |
| | | |
| | | if (config.style.fontSize) { |
| | | let size = parseInt(config.style.fontSize) |
| | | config.titleStyle = {fontSize: size} |
| | | if (_config.style.fontSize) { |
| | | let size = parseInt(_config.style.fontSize) |
| | | _config.titleStyle = {fontSize: size} |
| | | let s = size * 1.5 + 'px' |
| | | config.sortStyle = {width: s, height: s, lineHeight: s, borderRadius: s} |
| | | _config.sortStyle = {width: s, height: s, lineHeight: s, borderRadius: s} |
| | | } |
| | | |
| | | this.setState({ |
| | | sync: _sync, |
| | | data: _data, |
| | | group: _group, |
| | | step: _group.sort - 1, |
| | | BID: BID || '', |
| | | BData: BData || '', |
| | | config: config, |
| | | arr_field: config.columns.map(col => col.field).join(','), |
| | | config: _config, |
| | | arr_field: _config.columns.map(col => col.field).join(','), |
| | | }, () => { |
| | | if (config.wrap.datatype !== 'static' && config.setting && config.setting.sync !== 'true' && config.setting.onload === 'true') { |
| | | if (_config.wrap.datatype !== 'static' && config.setting.sync !== 'true' && _config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | | this.loadData() |
| | | }, config.setting.delay || 0) |
| | | }, _config.setting.delay || 0) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | componentDidMount () { |
| | | const { config } = this.state |
| | | |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | | MKEmitter.addListener('mkFormSubmit', this.mkFormSubmit) |
| | | MKEmitter.addListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) |
| | | |
| | | if (config.setting.useMSearch) { |
| | | MKEmitter.addListener('searchRefresh', this.searchRefresh) |
| | | } |
| | | |
| | | if (config.setting.sync === 'true') { |
| | | MKEmitter.addListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | } |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('mkFormSubmit', this.mkFormSubmit) |
| | | MKEmitter.removeListener('searchRefresh', this.searchRefresh) |
| | | MKEmitter.removeListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) |
| | | } |
| | | |
| | | /** |
| | | * @description 图表数据更新,刷新内容 |
| | | */ |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | const { sync, config, group } = this.state |
| | | transferSyncData = (syncId) => { |
| | | const { config, group } = this.state |
| | | |
| | | if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) { |
| | | let _data = {$$empty: true} |
| | | let _group = group |
| | | if (nextProps.data && nextProps.data[config.dataName]) { |
| | | _data = nextProps.data[config.dataName] |
| | | if (Array.isArray(_data)) { |
| | | _data = _data[0] || {$$empty: true} |
| | | } |
| | | } |
| | | if (config.$syncId !== syncId) return |
| | | |
| | | _data.$$uuid = _data[config.setting.primaryKey] || '' |
| | | let _data = window.GLOB.SyncData.get(config.dataName) || [] |
| | | _data = _data[0] || {$$empty: true} |
| | | _data.$$uuid = _data[config.setting.primaryKey] || '' |
| | | |
| | | if (config.wrap.statusControl && _data[config.wrap.statusControl] !== undefined) { |
| | | let _status = _data[config.wrap.statusControl] + '' |
| | | let _groups = config.subcards.filter(item => item.setting.status === _status)[0] |
| | | _group = _groups || _group |
| | | } |
| | | let _group = group |
| | | |
| | | this.setState({sync: false, data: _data, group: _group, step: _group.sort - 1,}) |
| | | } else if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | if (config.wrap.statusControl && _data[config.wrap.statusControl] !== undefined) { |
| | | let _status = _data[config.wrap.statusControl] + '' |
| | | let _groups = config.subcards.filter(item => item.setting.status === _status)[0] |
| | | _group = _groups || _group |
| | | } |
| | | |
| | | this.setState({data: _data, group: _group, step: _group.sort - 1}) |
| | | |
| | | window.GLOB.SyncData.delete(config.dataName) |
| | | |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | |
| | | searchRefresh = (searchId) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.$searchId !== searchId) return |
| | | |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | |
| | | reloadData = (menuId, id) => { |
| | |
| | | } |
| | | |
| | | async loadData (type) { |
| | | const { mainSearch } = this.props |
| | | const { config, arr_field, BID } = this.state |
| | | |
| | | if (config.wrap.datatype === 'static') { |
| | |
| | | return |
| | | } |
| | | |
| | | let searches = config.setting.useMSearch && mainSearch ? mainSearch : [] |
| | | let searches = [] |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | searches = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | } |
| | | |
| | | let requireFields = searches.filter(item => item.required && item.value === '') |
| | | if (requireFields.length > 0) { |
| | | if (config.$s_req && searches.filter(item => item.required && item.value === '').length > 0) { |
| | | return |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { config, loading, BID, BData, data, group, dict, step } = this.state |
| | | const { config, loading, BID, BData, data, group, step } = this.state |
| | | |
| | | if (config.wrap.empty === 'hidden' && (!data || data.$$empty)) return null |
| | | if (config.idCtrl && (!data || data.$$empty)) return null |
| | |
| | | {group && data ? <MutilForm |
| | | BID={BID} |
| | | BData={BData} |
| | | dict={dict} |
| | | data={data} |
| | | action={group} |
| | | unload={config.setting.supModule && !BID} |
| | |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import asyncSpinComponent from '@/utils/asyncSpinComponent' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import zhCN from '@/locales/zh-CN/main.js' |
| | | import enUS from '@/locales/en-US/main.js' |
| | | import './index.scss' |
| | | |
| | | const MutilForm = asyncSpinComponent(() => import('@/tabviews/zshare/mutilform')) |
| | |
| | | |
| | | class TabForm extends Component { |
| | | static propTpyes = { |
| | | data: PropTypes.array, // 统一查询数据 |
| | | config: PropTypes.object, // 组件配置信息 |
| | | mainSearch: PropTypes.any, // 外层搜索条件 |
| | | config: PropTypes.object |
| | | } |
| | | |
| | | state = { |
| | | dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, |
| | | BID: '', // 上级ID |
| | | config: null, // 图表配置信息 |
| | | loading: false, // 数据加载状态 |
| | | sync: false, // 是否统一请求数据 |
| | | data: null, |
| | | BData: '', |
| | | group: null, |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { data } = this.props |
| | | let config = fromJS(this.props.config).toJS() |
| | | const { config } = this.props |
| | | |
| | | let _config = fromJS(config).toJS() |
| | | let _data = null |
| | | let _sync = false |
| | | |
| | | let BID = '' |
| | | let BData = '' |
| | | |
| | | if (config.setting.supModule) { |
| | | BData = window.GLOB.CacheData.get(config.setting.supModule) |
| | | if (_config.setting.supModule) { |
| | | BData = window.GLOB.CacheData.get(_config.setting.supModule) |
| | | } else { |
| | | BData = window.GLOB.CacheData.get(config.$pageId) |
| | | BData = window.GLOB.CacheData.get(_config.$pageId) |
| | | } |
| | | if (BData) { |
| | | BID = BData.$BID || '' |
| | | } |
| | | |
| | | if (config.wrap.datatype !== 'static') { |
| | | _sync = config.setting.sync === 'true' |
| | | if (_config.wrap.datatype !== 'static') { |
| | | if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { |
| | | _data = window.GLOB.SyncData.get(_config.dataName) || [] |
| | | _data = _data[0] || {$$empty: true} |
| | | _data.$$uuid = _data[_config.setting.primaryKey] || '' |
| | | |
| | | if (_sync && data) { |
| | | _data = data[config.dataName] || {$$empty: true} |
| | | if (Array.isArray(_data)) { |
| | | _data = _data[0] || {$$empty: true} |
| | | } |
| | | _sync = false |
| | | _data.$$uuid = _data[config.setting.primaryKey] || '' |
| | | _config.setting.sync = 'false' |
| | | |
| | | window.GLOB.SyncData.delete(_config.dataName) |
| | | } |
| | | } else { |
| | | _data = {$$empty: true} |
| | | } |
| | | |
| | | if (!config.wrap.groupLabel) { |
| | | if (config.subcards.length > 1) { |
| | | config.wrap.groupLabel = 'show' |
| | | if (!_config.wrap.groupLabel) { |
| | | if (_config.subcards.length > 1) { |
| | | _config.wrap.groupLabel = 'show' |
| | | } else { |
| | | config.wrap.groupLabel = 'hidden' |
| | | _config.wrap.groupLabel = 'hidden' |
| | | } |
| | | } |
| | | |
| | | config.subcards = config.subcards.map(group => { |
| | | _config.subcards = _config.subcards.map(group => { |
| | | if (group.subButton.enable === 'false') { |
| | | group.subButton.style.display = 'none' |
| | | group.$button = 'no-button' |
| | |
| | | return group |
| | | }) |
| | | |
| | | config.titleStyle = {} |
| | | _config.titleStyle = {} |
| | | |
| | | if (config.style.fontSize) { |
| | | config.titleStyle = {fontSize: parseInt(config.style.fontSize)} |
| | | if (_config.style.fontSize) { |
| | | _config.titleStyle = {fontSize: parseInt(_config.style.fontSize)} |
| | | } |
| | | |
| | | this.setState({ |
| | | sync: _sync, |
| | | data: _data, |
| | | group: config.subcards[0], |
| | | group: _config.subcards[0], |
| | | BID: BID || '', |
| | | BData: BData || '', |
| | | config: config, |
| | | arr_field: config.columns.map(col => col.field).join(','), |
| | | config: _config, |
| | | arr_field: _config.columns.map(col => col.field).join(','), |
| | | }, () => { |
| | | if (config.wrap.datatype !== 'static' && config.setting && config.setting.sync !== 'true' && config.setting.onload === 'true') { |
| | | if (_config.wrap.datatype !== 'static' && config.setting.sync !== 'true' && _config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | | this.loadData() |
| | | }, config.setting.delay || 0) |
| | | }, _config.setting.delay || 0) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | componentDidMount () { |
| | | const { config } = this.state |
| | | |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | | MKEmitter.addListener('mkFormSubmit', this.mkFormSubmit) |
| | | MKEmitter.addListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) |
| | | |
| | | if (config.setting.useMSearch) { |
| | | MKEmitter.addListener('searchRefresh', this.searchRefresh) |
| | | } |
| | | |
| | | if (config.setting.sync === 'true') { |
| | | MKEmitter.addListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | } |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('mkFormSubmit', this.mkFormSubmit) |
| | | MKEmitter.removeListener('searchRefresh', this.searchRefresh) |
| | | MKEmitter.removeListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) |
| | | } |
| | | |
| | | /** |
| | | * @description 图表数据更新,刷新内容 |
| | | */ |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | const { sync, config, group } = this.state |
| | | transferSyncData = (syncId) => { |
| | | const { config, group } = this.state |
| | | |
| | | if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) { |
| | | let _data = {$$empty: true} |
| | | let _group = group |
| | | if (nextProps.data && nextProps.data[config.dataName]) { |
| | | _data = nextProps.data[config.dataName] |
| | | if (Array.isArray(_data)) { |
| | | _data = _data[0] || {$$empty: true} |
| | | } |
| | | } |
| | | if (config.$syncId !== syncId) return |
| | | |
| | | _data.$$uuid = _data[config.setting.primaryKey] || '' |
| | | let _data = window.GLOB.SyncData.get(config.dataName) || [] |
| | | _data = _data[0] || {$$empty: true} |
| | | _data.$$uuid = _data[config.setting.primaryKey] || '' |
| | | |
| | | this.setState({sync: false, data: _data, group: null}, () => { |
| | | this.setState({group: _group}) |
| | | }) |
| | | } else if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | let _group = group |
| | | |
| | | this.setState({data: _data, group: null}, () => { |
| | | this.setState({group: _group}) |
| | | }) |
| | | |
| | | window.GLOB.SyncData.delete(config.dataName) |
| | | |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | |
| | | searchRefresh = (searchId) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.$searchId !== searchId) return |
| | | |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | |
| | | reloadData = (menuId, id) => { |
| | |
| | | } |
| | | |
| | | async loadData () { |
| | | const { mainSearch } = this.props |
| | | const { config, arr_field, BID } = this.state |
| | | |
| | | if (config.wrap.datatype === 'static') { |
| | |
| | | return |
| | | } |
| | | |
| | | let searches = config.setting.useMSearch && mainSearch ? mainSearch : [] |
| | | let searches = [] |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | searches = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | } |
| | | |
| | | let requireFields = searches.filter(item => item.required && item.value === '') |
| | | if (requireFields.length > 0) { |
| | | if (config.$s_req && searches.filter(item => item.required && item.value === '').length > 0) { |
| | | return |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { config, loading, BID, BData, data, group, dict } = this.state |
| | | const { config, loading, BID, BData, data, group } = this.state |
| | | |
| | | if (config.wrap.empty === 'hidden' && (!data || data.$$empty)) return null |
| | | if (config.idCtrl && (!data || data.$$empty)) return null |
| | |
| | | {group && data ? <MutilForm |
| | | BID={BID} |
| | | BData={BData} |
| | | dict={dict} |
| | | data={data} |
| | | action={group} |
| | | unload={config.setting.supModule && !BID} |
| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Col, notification, Row } from 'antd' |
| | | |
| | | import Api from '@/api' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import { |
| | | getStructuredParams, |
| | | getStructDefaultParam |
| | | } from '@/utils/utils-datamanage.js' |
| | | import Utils from '@/utils/utils.js' |
| | | import './index.scss' |
| | | |
| | | // 通用组件 |
| | | const AntvBarAndLine = asyncComponent(() => import('@/tabviews/custom/components/chart/antv-bar-line')) |
| | | const AntvPie = asyncComponent(() => import('@/tabviews/custom/components/chart/antv-pie')) |
| | | const AntvDashboard = asyncComponent(() => import('@/tabviews/custom/components/chart/antv-dashboard')) |
| | | const AntvScatter = asyncComponent(() => import('@/tabviews/custom/components/chart/antv-scatter')) |
| | | const DataCard = asyncComponent(() => import('@/tabviews/custom/components/card/data-card')) |
| | | const TableCard = asyncComponent(() => import('@/tabviews/custom/components/card/table-card')) |
| | | const NormalTable = asyncComponent(() => import('@/tabviews/custom/components/table/normal-table')) |
| | | const DoubleDataCard = asyncComponent(() => import('@/tabviews/custom/components/card/double-data-card')) |
| | | const EditTable = asyncComponent(() => import('@/tabviews/custom/components/table/edit-table')) |
| | | const PropCard = asyncComponent(() => import('@/tabviews/custom/components/card/prop-card')) |
| | | const BraftEditor = asyncComponent(() => import('@/tabviews/custom/components/editor/braft-editor')) |
| | | const SandBox = asyncComponent(() => import('@/tabviews/custom/components/code/sand-box')) |
| | | const SimpleForm = asyncComponent(() => import('@/tabviews/custom/components/form/simple-form')) |
| | | const NormalForm = asyncComponent(() => import('@/tabviews/custom/components/form/step-form')) |
| | | const TabForm = asyncComponent(() => import('@/tabviews/custom/components/form/tab-form')) |
| | | const NormalTree = asyncComponent(() => import('@/tabviews/custom/components/tree/antd-tree')) |
| | | const CarouselDataCard = asyncComponent(() => import('@/tabviews/custom/components/carousel/data-card')) |
| | | const CarouselPropCard = asyncComponent(() => import('@/tabviews/custom/components/carousel/prop-card')) |
| | | const Balcony = asyncComponent(() => import('@/tabviews/custom/components/card/balcony')) |
| | | const TimeLine = asyncComponent(() => import('@/tabviews/custom/components/timeline/normal-timeline')) |
| | | const CustomChart = asyncComponent(() => import('@/tabviews/custom/components/chart/custom-chart')) |
| | | const AntvG6 = asyncComponent(() => import('@/tabviews/custom/components/chart/antv-G6')) |
| | | const AntvX6 = asyncComponent(() => import('@/tabviews/custom/components/chart/antv-X6')) |
| | | const Calendar = asyncComponent(() => import('@/tabviews/custom/components/calendar')) |
| | | const TabTransfer = asyncComponent(() => import('@/tabviews/custom/components/share/tabtransfer')) |
| | | |
| | | class TabTransfer extends Component { |
| | | class NormalGroup extends Component { |
| | | static propTpyes = { |
| | | config: PropTypes.object, // 组件配置信息 |
| | | mainSearch: PropTypes.any, // 全局搜索条件 |
| | | } |
| | | |
| | | state = { |
| | | mainSearch: [], |
| | | // printing: false, |
| | | data: null |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { config, mainSearch } = this.props |
| | | |
| | | // 获取主搜索条件 |
| | | let _mainSearch = mainSearch ? fromJS(mainSearch).toJS() : [] |
| | | let params = [] |
| | | config.components.forEach(item => { |
| | | if (item.type === 'tabs') return |
| | | |
| | | if (!item.setting || item.setting.interType !== 'system') return |
| | | if (!item.format) return |
| | | |
| | | if ((!item.pageable || (item.pageable && !item.setting.laypage)) && item.setting.onload === 'true' && item.setting.sync === 'true') { |
| | | let searchlist = [] |
| | | if (item.search && item.search.length > 0) { |
| | | searchlist = Utils.initMainSearch(item.search) |
| | | } |
| | | if (item.setting.useMSearch) { |
| | | let keys = searchlist.map(item => item.key) |
| | | _mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key)) { |
| | | searchlist.push(item) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | if (searchlist.filter(cell => cell.required && cell.value === '').length > 0) { |
| | | item.setting.sync = 'false' |
| | | item.setting.onload = 'false' |
| | | } else { |
| | | params.push(getStructDefaultParam(item, searchlist, params.length === 0)) |
| | | } |
| | | } else { |
| | | item.setting.sync = 'false' |
| | | } |
| | | }) |
| | | |
| | | this.setState({mainSearch: _mainSearch}) |
| | | |
| | | if (params.length > 0) { |
| | | this.loadmaindata(params) |
| | | } |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps(nextProps) { |
| | | if (nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({mainSearch: null}, () => { |
| | | this.setState({mainSearch: fromJS(nextProps.mainSearch).toJS()}) |
| | | }) |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 主表数据加载 |
| | | */ |
| | | loadmaindata = (params) => { |
| | | const { config } = this.props |
| | | let BID = '' |
| | | let BData = window.GLOB.CacheData.get(config.$pageId) |
| | | |
| | | if (BData) { |
| | | BID = BData.$BID || '' |
| | | } |
| | | |
| | | let param = getStructuredParams(params, config, BID) |
| | | |
| | | Api.genericInterface(param).then(result => { |
| | | if (result.status) { |
| | | delete result.status |
| | | delete result.message |
| | | delete result.ErrMesg |
| | | delete result.ErrCode |
| | | |
| | | if (config.$cache) { |
| | | params.forEach((item) => { |
| | | let _data = result[item.name] || '' |
| | | if (_data && !Array.isArray(_data)) { |
| | | _data = [_data] |
| | | } |
| | | Api.writeCacheConfig(item.uuid, _data) |
| | | }) |
| | | } |
| | | |
| | | this.setState({ |
| | | data: result |
| | | }) |
| | | } else { |
| | | this.setState({ |
| | | data: '' |
| | | }) |
| | | notification.error({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 10 |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | getComponents = () => { |
| | | const { config } = this.props |
| | | const { mainSearch, data } = this.state |
| | | |
| | | return config.components.map(item => { |
| | | let style = null |
| | | |
| | | if (item.style && item.style.clear === 'left') { |
| | | style = {clear: 'left'} |
| | | } else if (item.style && item.style.clear === 'right') { |
| | | style = {float: 'right'} |
| | | } |
| | | |
| | | if (item.type === 'card' && item.subtype === 'datacard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <DataCard config={item} data={data} mainSearch={mainSearch}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'card' && item.subtype === 'propcard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <PropCard config={item} data={data} mainSearch={mainSearch}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'table' && item.subtype === 'normaltable') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <NormalTable config={item} data={data} mainSearch={mainSearch}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'card' && item.subtype === 'dualdatacard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <DoubleDataCard config={item} mainSearch={mainSearch}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'bar' || item.type === 'line') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvBarAndLine data={data} config={item} mainSearch={mainSearch}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'pie') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvPie data={data} config={item} mainSearch={mainSearch}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'dashboard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvDashboard config={item} data={data} mainSearch={mainSearch}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'form' && item.subtype === 'simpleform') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <SimpleForm config={item} data={data} mainSearch={mainSearch}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'form' && item.subtype === 'stepform') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <NormalForm config={item} data={data} mainSearch={mainSearch}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'form' && item.subtype === 'tabform') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <TabForm config={item} data={data} mainSearch={mainSearch}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'scatter') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvScatter config={item} data={data} mainSearch={mainSearch}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'carousel' && item.subtype === 'datacard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <CarouselDataCard config={item} data={data} mainSearch={mainSearch}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'carousel' && item.subtype === 'propcard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <CarouselPropCard config={item} data={data} mainSearch={mainSearch}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'card' && item.subtype === 'tablecard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <TableCard config={item} data={data} mainSearch={mainSearch}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'table' && item.subtype === 'editable') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <EditTable config={item} data={data} mainSearch={mainSearch}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'tree') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <NormalTree config={item} data={data} mainSearch={mainSearch}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'calendar') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <Calendar config={item} mainSearch={mainSearch}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'editor') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <BraftEditor config={item} data={data} mainSearch={mainSearch}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'code') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <SandBox config={item} data={data} mainSearch={mainSearch}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'balcony') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <Balcony config={item} data={data}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'timeline') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <TimeLine config={item} data={data} mainSearch={mainSearch}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'chart') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <CustomChart config={item} data={data} mainSearch={mainSearch}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'antvG6') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvG6 config={item} data={data} mainSearch={mainSearch}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'antvX6') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvX6 config={item}/> |
| | | </Col> |
| | | ) |
| | | } else { |
| | | return null |
| | | } |
| | | }) |
| | | } |
| | | state = {} |
| | | |
| | | render() { |
| | | const { config } = this.props |
| | | |
| | | if (!config.components || config.components.length === 0) return (<div style={config.style}></div>) |
| | | if (config.components.length === 0) return (<div style={config.style}></div>) |
| | | |
| | | return ( |
| | | <div className={'normal-group-wrap ' + (config.setting.layout || '')} id={'anchor' + config.uuid} style={config.style}> |
| | | {config.setting && config.setting.title ? <div className="group-header" style={config.headerStyle}> |
| | | <span className="title">{config.setting.title}</span> |
| | | </div> : null} |
| | | <Row className="component-wrap">{this.getComponents()}</Row> |
| | | <TabTransfer config={config}/> |
| | | {/* <Row className="component-wrap">{this.getComponents()}</Row> */} |
| | | </div> |
| | | ) |
| | | } |
| | | } |
| | | |
| | | export default TabTransfer |
| | | export default NormalGroup |
| | |
| | | |
| | | class NormalIframe extends Component { |
| | | static propTpyes = { |
| | | data: PropTypes.array, // 统一查询数据 |
| | | config: PropTypes.object, // 组件配置信息 |
| | | mainSearch: PropTypes.any, // 外层搜索条件 |
| | | config: PropTypes.object |
| | | } |
| | | |
| | | state = { |
| | |
| | | config: null, // 图表配置信息 |
| | | loading: false, // 数据加载状态 |
| | | activeKey: '', // 选中数据 |
| | | sync: false, // 是否统一请求数据 |
| | | data: {}, // 数据 |
| | | linkUrl: '' |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { data } = this.props |
| | | let _config = fromJS(this.props.config).toJS() |
| | | const { config } = this.props |
| | | |
| | | let _config = fromJS(config).toJS() |
| | | let _data = { $$empty: true } |
| | | let _sync = false |
| | | |
| | | let BID = '' |
| | | let BData = '' |
| | | let linkUrl = '' |
| | |
| | | } |
| | | |
| | | if (_config.wrap.datatype === 'dynamic') { |
| | | _sync = _config.setting.sync === 'true' |
| | | if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { |
| | | _data = window.GLOB.SyncData.get(_config.dataName) || [] |
| | | _data = _data[0] || {$$empty: true} |
| | | |
| | | linkUrl = _data[_config.wrap.linkField] || '' |
| | | |
| | | if (_sync && data) { |
| | | _data = data[_config.dataName] || {$$empty: true} |
| | | if (Array.isArray(_data)) { |
| | | _data = _data[0] || {$$empty: true} |
| | | } |
| | | _sync = false |
| | | _config.setting.sync = 'false' |
| | | |
| | | window.GLOB.SyncData.delete(_config.dataName) |
| | | } |
| | | |
| | | linkUrl = _data[_config.wrap.linkField] || '' |
| | | } else { |
| | | if (_config.wrap.linkType !== 'input') { |
| | | linkUrl = _config.wrap.linkUrl || '' |
| | |
| | | |
| | | this.setState({ |
| | | linkUrl: linkUrl, |
| | | sync: _sync, |
| | | data: _data, |
| | | BID: BID || '', |
| | | config: _config, |
| | | arr_field: _config.columns.map(col => col.field).join(','), |
| | | }, () => { |
| | | if (_config.wrap.datatype === 'dynamic' && _config.setting.sync !== 'true' && _config.setting.onload === 'true') { |
| | | if (_config.wrap.datatype === 'dynamic' && config.setting.sync !== 'true' && _config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | | this.loadData() |
| | | }, _config.setting.delay || 0) |
| | |
| | | |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | | MKEmitter.addListener('resetSelectLine', this.resetParentParam) |
| | | |
| | | if (config.setting.useMSearch) { |
| | | MKEmitter.addListener('searchRefresh', this.searchRefresh) |
| | | } |
| | | |
| | | if (config.setting.sync === 'true') { |
| | | MKEmitter.addListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | |
| | | if (config.wrap.linkType === 'input' && config.wrap.focus !== 'false') { |
| | | setTimeout(() => { |
| | |
| | | } |
| | | |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('searchRefresh', this.searchRefresh) |
| | | MKEmitter.removeListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | |
| | | /** |
| | | * @description 数据更新,刷新内容 |
| | | */ |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | const { sync, config } = this.state |
| | | transferSyncData = (syncId) => { |
| | | const { config } = this.state |
| | | |
| | | if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) { |
| | | let _data = { $$empty: true } |
| | | if (nextProps.data && nextProps.data[config.dataName]) { |
| | | _data = nextProps.data[config.dataName] |
| | | if (Array.isArray(_data)) { |
| | | _data = _data[0] || {$$empty: true} |
| | | } |
| | | } |
| | | if (config.$syncId !== syncId) return |
| | | |
| | | let linkUrl = _data[config.wrap.linkField] || '' |
| | | let _data = window.GLOB.SyncData.get(config.dataName) || [] |
| | | _data = _data[0] || {$$empty: true} |
| | | |
| | | let linkUrl = _data[config.wrap.linkField] || '' |
| | | |
| | | this.setState({sync: false, data: _data, linkUrl}) |
| | | } else if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | this.setState({data: _data, linkUrl}) |
| | | |
| | | window.GLOB.SyncData.delete(config.dataName) |
| | | |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | |
| | | searchRefresh = (searchId) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.$searchId !== searchId) return |
| | | |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | |
| | | resetParentParam = (MenuID, id, data) => { |
| | |
| | | } |
| | | |
| | | async loadData () { |
| | | const { mainSearch } = this.props |
| | | const { config, arr_field, BID } = this.state |
| | | |
| | | if (config.wrap.datatype === 'static') { |
| | |
| | | return |
| | | } |
| | | |
| | | let searches = config.setting.useMSearch && mainSearch ? mainSearch : [] |
| | | let searches = [] |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | searches = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | } |
| | | |
| | | let requireFields = searches.filter(item => item.required && item.value === '') |
| | | if (requireFields.length > 0) { |
| | | if (config.$s_req && searches.filter(item => item.required && item.value === '').length > 0) { |
| | | return |
| | | } |
| | | |
| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Row, Col, Empty, notification } from 'antd' |
| | | import { fromJS } from 'immutable' |
| | | import { Row, Col, Empty, notification, Modal } from 'antd' |
| | | |
| | | import Api from '@/api' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | |
| | | getStructuredParams, |
| | | getStructDefaultParam |
| | | } from '@/utils/utils-datamanage.js' |
| | | import Utils from '@/utils/utils.js' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import './index.scss' |
| | | |
| | | // 通用组件 |
| | |
| | | class TabTransfer extends Component { |
| | | static propTpyes = { |
| | | config: PropTypes.object, // 组件配置信息 |
| | | mainSearch: PropTypes.any, // 全局搜索条件 |
| | | } |
| | | |
| | | state = { |
| | | mainSearch: [], |
| | | self: false, |
| | | data: null |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { config, mainSearch } = this.props |
| | | let _config = fromJS(this.props.config).toJS() |
| | | |
| | | // 获取主搜索条件 |
| | | let _mainSearch = [] |
| | | let self = false |
| | | config.components.forEach(component => { |
| | | if (component.type === 'search') { |
| | | self = true |
| | | _mainSearch = Utils.initMainSearch(component.search) |
| | | if (_config.type !== 'group') { |
| | | let params = [] |
| | | |
| | | _config.components = this.formatSetting(_config.components, params) |
| | | |
| | | if (params.length > 0) { |
| | | this.loadmaindata(params) |
| | | } |
| | | }) |
| | | |
| | | if (!self) { |
| | | _mainSearch = fromJS(mainSearch).toJS() |
| | | } else { |
| | | let delay = 110 |
| | | _config.components.forEach(item => { |
| | | if (!item.setting || item.setting.interType !== 'system') return |
| | | if (!item.format) return |
| | | |
| | | item.setting.delay = delay |
| | | delay += 20 |
| | | }) |
| | | } |
| | | |
| | | let params = [] |
| | | let delay = 20 |
| | | config.components.forEach(item => { |
| | | if (item.type === 'tabs' || item.type === 'group') return |
| | | this.setState({ |
| | | config: _config |
| | | }) |
| | | } |
| | | |
| | | if (!item.setting || item.setting.interType !== 'system') return |
| | | if (!item.format) return |
| | | formatSetting = (components, params) => { |
| | | let delay = 110 |
| | | return components.map(item => { |
| | | if (item.type === 'tabs') return item |
| | | if (item.type === 'group') { |
| | | item.components = this.formatSetting(item.components, params) |
| | | return item |
| | | } |
| | | |
| | | if ((!item.pageable || (item.pageable && !item.setting.laypage)) && item.setting.onload === 'true' && item.setting.sync === 'true') { |
| | | let searchlist = [] |
| | | if (item.search && item.search.length > 0) { |
| | | searchlist = Utils.initMainSearch(item.search) |
| | | } |
| | | if (!item.setting || item.setting.interType !== 'system') return item |
| | | if (!item.format) return item |
| | | |
| | | if (item.setting.sync === 'true') { |
| | | let searchlist = item.$searches || [] |
| | | |
| | | if (item.setting.useMSearch) { |
| | | let keys = searchlist.map(item => item.key) |
| | | _mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key)) { |
| | | searchlist.push(item) |
| | | } |
| | | let mainSearch = window.GLOB.SearchBox.get(item.$searchId) |
| | | let keys = item.$s_keys || [] |
| | | mainSearch.forEach(item => { |
| | | if (keys.includes(item.key.toLowerCase())) return |
| | | |
| | | searchlist.push(item) |
| | | }) |
| | | } |
| | | |
| | | if (searchlist.filter(cell => cell.required && cell.value === '').length > 0) { |
| | | if (item.$s_req && searchlist.filter(item => item.required && item.value === '').length > 0) { |
| | | item.setting.sync = 'false' |
| | | item.setting.onload = 'false' |
| | | } else { |
| | | params.push(getStructDefaultParam(item, searchlist, params.length === 0)) |
| | | } |
| | | } else { |
| | | item.setting.sync = 'false' |
| | | item.setting.delay = delay |
| | | delay += 20 |
| | | } |
| | | |
| | | item.setting.delay = delay |
| | | delay += 20 |
| | | |
| | | return item |
| | | }) |
| | | |
| | | this.setState({mainSearch: _mainSearch, self}) |
| | | |
| | | if (params.length > 0) { |
| | | this.loadmaindata(params) |
| | | } |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps(nextProps) { |
| | | const { self } = this.state |
| | | |
| | | if (!self && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({mainSearch: null}, () => { |
| | | this.setState({mainSearch: fromJS(nextProps.mainSearch).toJS()}) |
| | | }) |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 主表数据加载 |
| | | */ |
| | | loadmaindata = (params) => { |
| | | const { config } = this.props |
| | | const { config } = this.state |
| | | let BID = '' |
| | | let BData = window.GLOB.CacheData.get(config.$pageId) |
| | | |
| | |
| | | |
| | | Api.genericInterface(param).then(result => { |
| | | if (result.status) { |
| | | delete result.status |
| | | delete result.message |
| | | delete result.ErrMesg |
| | | delete result.ErrCode |
| | | |
| | | if (config.$cache) { |
| | | params.forEach((item) => { |
| | | let _data = result[item.name] || '' |
| | | if (_data && !Array.isArray(_data)) { |
| | | _data = [_data] |
| | | } |
| | | Api.writeCacheConfig(item.uuid, _data) |
| | | }) |
| | | 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 |
| | | }) |
| | | } |
| | | } |
| | | |
| | | this.setState({ |
| | | data: result |
| | | params.forEach((item) => { |
| | | let _data = result[item.name] || '' |
| | | if (_data && !Array.isArray(_data)) { |
| | | _data = [_data] |
| | | } |
| | | window.GLOB.SyncData.set(item.name, _data) |
| | | }) |
| | | |
| | | MKEmitter.emit('transferSyncData', config.uuid) |
| | | } else { |
| | | this.setState({ |
| | | data: '' |
| | | }) |
| | | notification.error({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 10 |
| | | }) |
| | | MKEmitter.emit('transferSyncData', config.uuid) |
| | | |
| | | 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 |
| | | }) |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | |
| | | resetSearch = (search) => { |
| | | this.setState({mainSearch: null}, () => { |
| | | this.setState({mainSearch: search}) |
| | | }) |
| | | } |
| | | |
| | | getComponents = (components) => { |
| | | const { mainSearch, data } = this.state |
| | | |
| | | return components.map(item => { |
| | | let style = null |
| | | |
| | |
| | | if (item.type === 'card' && item.subtype === 'datacard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <DataCard config={item} data={data} mainSearch={mainSearch}/> |
| | | <DataCard config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'card' && item.subtype === 'propcard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <PropCard config={item} data={data} mainSearch={mainSearch}/> |
| | | <PropCard config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'table' && item.subtype === 'normaltable') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <NormalTable config={item} data={data} mainSearch={mainSearch}/> |
| | | <NormalTable config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'card' && item.subtype === 'dualdatacard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <DoubleDataCard config={item} mainSearch={mainSearch}/> |
| | | <DoubleDataCard config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'bar' || item.type === 'line') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvBarAndLine data={data} config={item} mainSearch={mainSearch}/> |
| | | <AntvBarAndLine config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'pie') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvPie data={data} config={item} mainSearch={mainSearch}/> |
| | | <AntvPie config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'dashboard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvDashboard config={item} data={data} mainSearch={mainSearch}/> |
| | | <AntvDashboard config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'scatter') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvScatter config={item} data={data} mainSearch={mainSearch}/> |
| | | <AntvScatter config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'search') { |
| | |
| | | } |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <MainSearch config={item} BID={BID} refreshdata={this.resetSearch} /> |
| | | <MainSearch config={item} BID={BID}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'tabs') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvTabs config={item} mainSearch={mainSearch}/> |
| | | <AntvTabs config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'carousel' && item.subtype === 'datacard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <CarouselDataCard config={item} data={data} mainSearch={mainSearch}/> |
| | | <CarouselDataCard config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'carousel' && item.subtype === 'propcard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <CarouselPropCard config={item} data={data} mainSearch={mainSearch}/> |
| | | <CarouselPropCard config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'card' && item.subtype === 'tablecard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <TableCard config={item} data={data} mainSearch={mainSearch}/> |
| | | <TableCard config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'table' && item.subtype === 'basetable') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <MkBaseTable config={item} data={data} mainSearch={mainSearch}/> |
| | | <MkBaseTable config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'table' && item.subtype === 'editable') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <EditTable config={item} mainSearch={mainSearch}/> |
| | | <EditTable config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'group' && item.subtype === 'normalgroup') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <NormalGroup config={item} mainSearch={mainSearch}/> |
| | | <NormalGroup config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'form' && item.subtype === 'simpleform') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <SimpleForm config={item} data={data} mainSearch={mainSearch}/> |
| | | <SimpleForm config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'form' && item.subtype === 'stepform') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <StepForm config={item} data={data} mainSearch={mainSearch}/> |
| | | <StepForm config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'form' && item.subtype === 'tabform') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <TabForm config={item} data={data} mainSearch={mainSearch}/> |
| | | <TabForm config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'tree') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <NormalTree config={item} data={data} mainSearch={mainSearch}/> |
| | | <NormalTree config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'calendar') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <Calendar config={item} mainSearch={mainSearch}/> |
| | | <Calendar config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'editor') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <BraftEditor config={item} data={data} mainSearch={mainSearch}/> |
| | | <BraftEditor config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'code') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <SandBox config={item} data={data} mainSearch={mainSearch}/> |
| | | <SandBox config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'balcony') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <Balcony config={item} data={data}/> |
| | | <Balcony config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'timeline') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <TimeLine config={item} data={data} mainSearch={mainSearch}/> |
| | | <TimeLine config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'chart') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <CustomChart config={item} data={data} mainSearch={mainSearch}/> |
| | | <CustomChart config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'antvG6') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvG6 config={item} data={data} mainSearch={mainSearch}/> |
| | | <AntvG6 config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'antvX6') { |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { config } = this.props |
| | | const { config } = this.state |
| | | |
| | | if (!config || !config.components || config.components.length === 0) return (<Empty description={false} />) |
| | | |
| | | if (config.type === 'group') { |
| | | return ( |
| | | <Row className="component-wrap">{this.getComponents(config.components)}</Row> |
| | | ) |
| | | } |
| | | |
| | | return ( |
| | | <Row className="component-wrap" id={'anchor' + config.uuid} gutter={8}>{this.getComponents(config.components)}</Row> |
| | | ) |
| | |
| | | import { notification, Modal } from 'antd' |
| | | |
| | | import Api from '@/api' |
| | | import Utils from '@/utils/utils.js' |
| | | import UtilsDM from '@/utils/utils-datamanage.js' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import MKEmitter from '@/utils/events.js' |
| | |
| | | |
| | | class MkBaseTable extends Component { |
| | | static propTpyes = { |
| | | data: PropTypes.array, // 统一查询数据 |
| | | config: PropTypes.object, // 组件配置信息 |
| | | mainSearch: PropTypes.any, // 外层搜索条件 |
| | | } |
| | | |
| | | state = { |
| | |
| | | actions: _config.action, |
| | | columns: _config.cols, |
| | | arr_field: _config.columns.map(col => col.field).join(','), |
| | | search: Utils.initMainSearch(_config.search) // 搜索条件初始化(含有时间格式,需要转化) |
| | | search: _config.$searches |
| | | }, () => { |
| | | if (_config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | |
| | | * @param { String } repage 表格是否重置页码 |
| | | */ |
| | | async loadmaindata (reset, repage, id) { |
| | | const { mainSearch } = this.props |
| | | const { setting, config, arr_field, search, orderBy, BID, pageIndex, pageSize, BData } = this.state |
| | | |
| | | if (setting.supModule && !BID) { // BID 不存在时,不做查询 |
| | |
| | | } |
| | | |
| | | let searches = fromJS(search).toJS() |
| | | if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | let keys = searches.map(item => item.key.toLowerCase()) |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | let mainSearch = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | let keys = config.$s_keys || [] |
| | | mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key.toLowerCase())) { |
| | | searches.push(item) |
| | | } |
| | | if (keys.includes(item.key.toLowerCase())) return |
| | | |
| | | searches.push(item) |
| | | }) |
| | | } |
| | | |
| | | let requireFields = searches.filter(item => item.required && item.value === '') |
| | | if (requireFields.length > 0) { |
| | | if (config.$s_req && searches.filter(item => item.required && item.value === '').length > 0) { |
| | | return |
| | | } |
| | | |
| | |
| | | * @description 获取单行数据 |
| | | */ |
| | | async loadmainLinedata (id) { |
| | | const { mainSearch } = this.props |
| | | const { setting, config, arr_field, search, orderBy, BID, pageIndex, pageSize, BData } = this.state |
| | | |
| | | let searches = fromJS(search).toJS() |
| | | if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | let keys = searches.map(item => item.key.toLowerCase()) |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | let mainSearch = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | let keys = config.$s_keys || [] |
| | | mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key.toLowerCase())) { |
| | | searches.push(item) |
| | | } |
| | | if (keys.includes(item.key.toLowerCase())) return |
| | | |
| | | searches.push(item) |
| | | }) |
| | | } |
| | | |
| | |
| | | * @description 获取合计字段值 |
| | | */ |
| | | getStatFieldsValue = () => { |
| | | const { mainSearch } = this.props |
| | | const { setting, config, search, BID, orderBy } = this.state |
| | | |
| | | if (setting.supModule && !BID) { // BID 不存在时,不做查询 |
| | |
| | | if (config.statFields.length === 0 || setting.interType !== 'system' || !setting.dataresource) return |
| | | |
| | | let searches = fromJS(search).toJS() |
| | | if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | let keys = searches.map(item => item.key.toLowerCase()) |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | let mainSearch = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | let keys = config.$s_keys || [] |
| | | mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key.toLowerCase())) { |
| | | searches.push(item) |
| | | } |
| | | if (keys.includes(item.key.toLowerCase())) return |
| | | |
| | | searches.push(item) |
| | | }) |
| | | } |
| | | let requireFields = searches.filter(item => item.required && item.value === '') |
| | | if (requireFields.length > 0) { |
| | | |
| | | if (config.$s_req && searches.filter(item => item.required && item.value === '').length > 0) { |
| | | return |
| | | } |
| | | |
| | |
| | | * 含有初始不加载的页面,修改设置 |
| | | */ |
| | | refreshbysearch = (searches) => { |
| | | const { config} = this.state |
| | | |
| | | this.setState({ |
| | | pageIndex: 1, |
| | | search: searches |
| | |
| | | this.loadmaindata(true, 'true') |
| | | this.getStatFieldsValue() |
| | | }) |
| | | |
| | | if (config.$main) { |
| | | window.GLOB.SearchBox.set(config.$searchId, searches) |
| | | MKEmitter.emit('searchRefresh', config.$searchId) |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | * @description 导出Excel时,获取页面搜索排序等参数 |
| | | */ |
| | | queryModuleParam = (menuId, callback) => { |
| | | const { mainSearch } = this.props |
| | | const { arr_field, config, orderBy, search, setting} = this.state |
| | | |
| | | if (config.uuid !== menuId) return |
| | | |
| | | let searches = search ? fromJS(search).toJS() : [] |
| | | if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | let keys = searches.map(item => item.key.toLowerCase()) |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | let mainSearch = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | let keys = config.$s_keys || [] |
| | | mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key.toLowerCase())) { |
| | | searches.push(item) |
| | | } |
| | | if (keys.includes(item.key.toLowerCase())) return |
| | | |
| | | searches.push(item) |
| | | }) |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps(nextProps) { |
| | | searchRefresh = (searchId) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({pageIndex: 1}, () => { |
| | | this.reloadtable() |
| | | }) |
| | | } |
| | | if (config.$searchId !== searchId) return |
| | | |
| | | this.setState({pageIndex: 1}, () => { |
| | | this.reloadtable() |
| | | }) |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | } |
| | | |
| | | componentDidMount () { |
| | | const { config } = this.state |
| | | |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | | MKEmitter.addListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.addListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) |
| | | |
| | | if (config.setting.useMSearch) { |
| | | MKEmitter.addListener('searchRefresh', this.searchRefresh) |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | return |
| | | } |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('searchRefresh', this.searchRefresh) |
| | | MKEmitter.removeListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) |
| | |
| | | class EditableTable extends Component { |
| | | static propTpyes = { |
| | | config: PropTypes.object, // 组件配置信息 |
| | | mainSearch: PropTypes.any, // 外层搜索条件 |
| | | } |
| | | |
| | | state = { |
| | |
| | | actions: _config.action, |
| | | columns: _columns, |
| | | arr_field: _config.columns.map(col => col.field).join(','), |
| | | search: Utils.initMainSearch(_config.search) // 搜索条件初始化(含有时间格式,需要转化) |
| | | search: _config.$searches |
| | | }, () => { |
| | | if (_config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | |
| | | * @param { String } repage 表格是否重置页码 |
| | | */ |
| | | async loadmaindata (reset, repage) { |
| | | const { mainSearch } = this.props |
| | | const { setting, config, arr_field, search, orderBy, BID, pageIndex, pageSize, BData } = this.state |
| | | |
| | | if (setting.supModule && !BID) { // BID 不存在时,不做查询 |
| | |
| | | } |
| | | |
| | | let searches = fromJS(search).toJS() |
| | | if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | let keys = searches.map(item => item.key.toLowerCase()) |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | let mainSearch = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | let keys = config.$s_keys || [] |
| | | mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key.toLowerCase())) { |
| | | searches.push(item) |
| | | } |
| | | if (keys.includes(item.key.toLowerCase())) return |
| | | |
| | | searches.push(item) |
| | | }) |
| | | } |
| | | |
| | | let requireFields = searches.filter(item => item.required && item.value === '') |
| | | if (requireFields.length > 0) { |
| | | if (config.$s_req && searches.filter(item => item.required && item.value === '').length > 0) { |
| | | return |
| | | } |
| | | |
| | |
| | | * @description 获取单行数据 |
| | | */ |
| | | async loadmainLinedata (id) { |
| | | const { mainSearch } = this.props |
| | | const { setting, config, arr_field, search, orderBy, BID, pageIndex, pageSize, BData } = this.state |
| | | |
| | | let searches = fromJS(search).toJS() |
| | | if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | let keys = searches.map(item => item.key.toLowerCase()) |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | let mainSearch = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | let keys = config.$s_keys || [] |
| | | mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key.toLowerCase())) { |
| | | searches.push(item) |
| | | } |
| | | if (keys.includes(item.key.toLowerCase())) return |
| | | |
| | | searches.push(item) |
| | | }) |
| | | } |
| | | |
| | |
| | | * @description 导出Excel时,获取页面搜索排序等参数 |
| | | */ |
| | | queryModuleParam = (menuId, callback) => { |
| | | const { mainSearch } = this.props |
| | | const { arr_field, config, orderBy, search, setting} = this.state |
| | | |
| | | if (config.uuid !== menuId) return |
| | | |
| | | let searches = search ? fromJS(search).toJS() : [] |
| | | if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | let keys = searches.map(item => item.key.toLowerCase()) |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | let mainSearch = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | let keys = config.$s_keys || [] |
| | | mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key.toLowerCase())) { |
| | | searches.push(item) |
| | | } |
| | | if (keys.includes(item.key.toLowerCase())) return |
| | | |
| | | searches.push(item) |
| | | }) |
| | | } |
| | | |
| | |
| | | }) |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps(nextProps) { |
| | | searchRefresh = (searchId) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({pageIndex: 1}, () => { |
| | | this.reloadtable() |
| | | }) |
| | | } |
| | | if (config.$searchId !== searchId) return |
| | | |
| | | this.setState({pageIndex: 1}, () => { |
| | | this.reloadtable() |
| | | }) |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | } |
| | | |
| | | componentDidMount () { |
| | | const { config } = this.state |
| | | |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | | MKEmitter.addListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.addListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.addListener('refreshLineData', this.refreshLineData) |
| | | MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) |
| | | |
| | | if (config.setting.useMSearch) { |
| | | MKEmitter.addListener('searchRefresh', this.searchRefresh) |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | return |
| | | } |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('searchRefresh', this.searchRefresh) |
| | | MKEmitter.removeListener('refreshLineData', this.refreshLineData) |
| | | MKEmitter.removeListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.removeListener('refreshLineData', this.refreshLineData) |
| | | MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) |
| | | } |
| | | |
| | |
| | | param.func = 'sPC_TableData_InUpDe' |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | result.sql = result.sql.replace(/\$@/ig, '/*') |
| | | result.sql = result.sql.replace(/@\$/ig, '*/') |
| | | result.bottom = result.bottom.replace(/\$@/ig, '/*') |
| | | result.bottom = result.bottom.replace(/@\$/ig, '*/') |
| | | result.sql = result.sql.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') |
| | | result.bottom = result.bottom.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') |
| | | } else { |
| | | result.sql = result.sql.replace(/@\$|\$@/ig, '') |
| | | result.bottom = result.bottom.replace(/@\$|\$@/ig, '') |
| | | result.sql = result.sql.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | | result.bottom = result.bottom.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | | } |
| | | |
| | | param.excel_in_type = 'true' |
| | |
| | | import { notification, Collapse, Modal } from 'antd' |
| | | |
| | | import Api from '@/api' |
| | | import Utils from '@/utils/utils.js' |
| | | import UtilsDM from '@/utils/utils-datamanage.js' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import MKEmitter from '@/utils/events.js' |
| | |
| | | |
| | | class NormalTable extends Component { |
| | | static propTpyes = { |
| | | data: PropTypes.array, // 统一查询数据 |
| | | config: PropTypes.object, // 组件配置信息 |
| | | mainSearch: PropTypes.any, // 外层搜索条件 |
| | | config: PropTypes.object |
| | | } |
| | | |
| | | state = { |
| | |
| | | * 1、 initdata 为打印时使用的数据集 |
| | | */ |
| | | UNSAFE_componentWillMount () { |
| | | const { data, initdata } = this.props |
| | | let _config = fromJS(this.props.config).toJS() |
| | | let _data = null |
| | | let _sync = _config.setting.sync === 'true' |
| | | const { config } = this.props |
| | | |
| | | let _config = fromJS(config).toJS() |
| | | let _data = null |
| | | let BID = '' |
| | | let BData = '' |
| | | |
| | |
| | | setting.orisel = true |
| | | } |
| | | |
| | | if (_sync && data) { |
| | | _data = data[_config.dataName] || [] |
| | | _sync = false |
| | | } else if (_sync && initdata) { |
| | | _data = initdata || [] |
| | | _sync = false |
| | | } |
| | | if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { |
| | | _data = window.GLOB.SyncData.get(_config.dataName) || [] |
| | | |
| | | if (_data) { |
| | | this.loaded = true |
| | | if (_config.$cache) { |
| | | Api.writeCacheConfig(_config.uuid, fromJS(_data).toJS()) |
| | | } |
| | | |
| | | _config.setting.sync = 'false' |
| | | |
| | | _data = _data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[_config.setting.primaryKey] || '' |
| | |
| | | return item |
| | | }) |
| | | |
| | | if (setting.selected !== 'false' && _data && _data.length > 0) { |
| | | if (setting.selected !== 'false' && _data.length > 0) { |
| | | setTimeout(() => { |
| | | MKEmitter.emit('mkCheckTopLine', _config.uuid, '', setting.selected) |
| | | }, 200) |
| | |
| | | setting.selected = 'false' |
| | | } |
| | | } |
| | | } |
| | | |
| | | this.loaded = true |
| | | |
| | | window.GLOB.SyncData.delete(_config.dataName) |
| | | } |
| | | |
| | | if (_config.wrap.collapse === 'true') { |
| | | _config.wrap.title = _config.wrap.title || ' ' |
| | | } |
| | |
| | | BID: BID || '', |
| | | BData: BData || '', |
| | | title: _config.wrap.title, |
| | | sync: _sync, |
| | | data: _data, |
| | | config: _config, |
| | | setting: setting, |
| | | actions: _config.action, |
| | | columns: _config.cols, |
| | | arr_field: _config.columns.map(col => col.field).join(','), |
| | | search: Utils.initMainSearch(_config.search) // 搜索条件初始化(含有时间格式,需要转化) |
| | | search: _config.$searches |
| | | }, () => { |
| | | if (_config.setting.sync !== 'true' && _config.setting.onload === 'true') { |
| | | if (config.setting.sync !== 'true' && _config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | | this.loadmaindata() |
| | | this.getStatFieldsValue() |
| | |
| | | }) |
| | | } |
| | | |
| | | transferSyncData = (syncId) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.$syncId !== syncId) return |
| | | |
| | | const { setting, BID, BData } = this.state |
| | | |
| | | let _data = window.GLOB.SyncData.get(config.dataName) || [] |
| | | |
| | | if (config.$cache) { |
| | | Api.writeCacheConfig(config.uuid, fromJS(_data).toJS()) |
| | | } |
| | | |
| | | _data = _data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[config.setting.primaryKey] || '' |
| | | item.$$key = '' + item.key + item.$$uuid |
| | | item.$$BID = BID || '' |
| | | item.$$BData = BData || '' |
| | | item.$Index = index + 1 + '' |
| | | |
| | | if (config.absFields) { |
| | | config.absFields.forEach(f => { |
| | | if (!isNaN(item[f])) { |
| | | item[f] = Math.abs(item[f]) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | if (setting.controlField) { |
| | | if (setting.controlVal.includes(item[setting.controlField] + '')) { |
| | | item.$disabled = true |
| | | } |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | | if (setting.selected !== 'false' && _data.length > 0) { |
| | | setTimeout(() => { |
| | | MKEmitter.emit('mkCheckTopLine', config.uuid, '', setting.selected) |
| | | }, 200) |
| | | if (setting.selected === 'init') { |
| | | this.setState({setting: {...setting, selected: 'false'}}) |
| | | } |
| | | } |
| | | |
| | | this.loaded = true |
| | | |
| | | this.setState({data: _data}) |
| | | |
| | | window.GLOB.SyncData.delete(config.dataName) |
| | | |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | |
| | | /** |
| | | * @description 主表数据加载 |
| | | * @param { Boolean } reset 表格是否重置 |
| | | * @param { String } repage 表格是否重置页码 |
| | | */ |
| | | async loadmaindata (reset, repage, id, type) { |
| | | const { mainSearch } = this.props |
| | | const { setting, config, arr_field, search, orderBy, BID, pageIndex, pageSize, BData } = this.state |
| | | |
| | | if (setting.supModule && !BID && setting.supKey !== 'false') { // BID 不存在时,不做查询 |
| | |
| | | } |
| | | |
| | | let searches = fromJS(search).toJS() |
| | | if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | let keys = searches.map(item => item.key.toLowerCase()) |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | let mainSearch = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | let keys = config.$s_keys || [] |
| | | mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key.toLowerCase())) { |
| | | searches.push(item) |
| | | } |
| | | if (keys.includes(item.key.toLowerCase())) return |
| | | |
| | | searches.push(item) |
| | | }) |
| | | } |
| | | |
| | | let requireFields = searches.filter(item => item.required && item.value === '') |
| | | if (requireFields.length > 0) { |
| | | if (config.$s_req && searches.filter(item => item.required && item.value === '').length > 0) { |
| | | return |
| | | } |
| | | |
| | |
| | | * @description 获取单行数据 |
| | | */ |
| | | async loadmainLinedata (id) { |
| | | const { mainSearch } = this.props |
| | | const { setting, config, arr_field, search, orderBy, BID, pageIndex, pageSize, BData } = this.state |
| | | |
| | | let searches = fromJS(search).toJS() |
| | | if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | let keys = searches.map(item => item.key.toLowerCase()) |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | let mainSearch = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | let keys = config.$s_keys || [] |
| | | mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key.toLowerCase())) { |
| | | searches.push(item) |
| | | } |
| | | if (keys.includes(item.key.toLowerCase())) return |
| | | |
| | | searches.push(item) |
| | | }) |
| | | } |
| | | |
| | |
| | | * @description 获取合计字段值 |
| | | */ |
| | | getStatFieldsValue = () => { |
| | | const { mainSearch } = this.props |
| | | const { setting, config, search, BID, orderBy } = this.state |
| | | |
| | | if (setting.supModule && !BID && setting.supKey !== 'false') { // BID 不存在时,不做查询 |
| | |
| | | if (config.statFields.length === 0 || setting.interType !== 'system' || !setting.dataresource) return |
| | | |
| | | let searches = fromJS(search).toJS() |
| | | if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | let keys = searches.map(item => item.key.toLowerCase()) |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | let mainSearch = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | let keys = config.$s_keys || [] |
| | | mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key.toLowerCase())) { |
| | | searches.push(item) |
| | | } |
| | | if (keys.includes(item.key.toLowerCase())) return |
| | | |
| | | searches.push(item) |
| | | }) |
| | | } |
| | | let requireFields = searches.filter(item => item.required && item.value === '') |
| | | if (requireFields.length > 0) { |
| | | |
| | | if (config.$s_req && searches.filter(item => item.required && item.value === '').length > 0) { |
| | | return |
| | | } |
| | | |
| | |
| | | * @description 导出Excel时,获取页面搜索排序等参数 |
| | | */ |
| | | queryModuleParam = (menuId, callback) => { |
| | | const { mainSearch } = this.props |
| | | const { arr_field, config, orderBy, search, setting} = this.state |
| | | |
| | | if (config.uuid !== menuId) return |
| | | |
| | | let searches = search ? fromJS(search).toJS() : [] |
| | | if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | let keys = searches.map(item => item.key.toLowerCase()) |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | let mainSearch = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | let keys = config.$s_keys || [] |
| | | mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key.toLowerCase())) { |
| | | searches.push(item) |
| | | } |
| | | if (keys.includes(item.key.toLowerCase())) return |
| | | |
| | | searches.push(item) |
| | | }) |
| | | } |
| | | |
| | |
| | | }) |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps(nextProps) { |
| | | const { sync, config, setting, BID, BData } = this.state |
| | | searchRefresh = (searchId) => { |
| | | const { config } = this.state |
| | | |
| | | if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) { |
| | | let _data = [] |
| | | if (nextProps.data && nextProps.data[config.dataName]) { |
| | | _data = nextProps.data[config.dataName] || [] |
| | | _data = _data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[config.setting.primaryKey] || '' |
| | | item.$$key = '' + item.key + item.$$uuid |
| | | item.$$BID = BID || '' |
| | | item.$$BData = BData || '' |
| | | item.$Index = index + 1 + '' |
| | | |
| | | if (config.absFields) { |
| | | config.absFields.forEach(f => { |
| | | if (!isNaN(item[f])) { |
| | | item[f] = Math.abs(item[f]) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | if (setting.controlField) { |
| | | if (setting.controlVal.includes(item[setting.controlField] + '')) { |
| | | item.$disabled = true |
| | | } |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | | if (setting.selected !== 'false' && _data && _data.length > 0) { |
| | | setTimeout(() => { |
| | | MKEmitter.emit('mkCheckTopLine', config.uuid, '', setting.selected) |
| | | }, 200) |
| | | if (setting.selected === 'init') { |
| | | this.setState({setting: {...setting, selected: 'false'}}) |
| | | } |
| | | } |
| | | } |
| | | |
| | | this.loaded = true |
| | | |
| | | this.setState({sync: false, data: _data}) |
| | | } else if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({pageIndex: 1}, () => { |
| | | this.reloadtable() |
| | | }) |
| | | } |
| | | if (config.$searchId !== searchId) return |
| | | |
| | | this.setState({pageIndex: 1}, () => { |
| | | this.reloadtable() |
| | | }) |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | const { config, setting } = this.state |
| | | |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | | MKEmitter.addListener('refreshLineData', this.refreshLineData) |
| | | MKEmitter.addListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.addListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.addListener('refreshLineData', this.refreshLineData) |
| | | 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.timer) { |
| | | this.timer = new TimerTask() |
| | |
| | | return |
| | | } |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.removeListener('searchRefresh', this.searchRefresh) |
| | | MKEmitter.removeListener('refreshLineData', this.refreshLineData) |
| | | MKEmitter.removeListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) |
| | | |
| | | this.timer && this.timer.stop() |
| | |
| | | class antvTabs extends Component { |
| | | static propTpyes = { |
| | | config: PropTypes.object, // 组件配置信息 |
| | | mainSearch: PropTypes.any, // 外层搜索条件 |
| | | } |
| | | |
| | | state = { |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { mainSearch } = this.props |
| | | const { tabs } = this.state |
| | | |
| | | if (!tabs.subtabs.length) return null |
| | |
| | | <Tabs defaultActiveKey="1" tabBarStyle={{background: tabs.setting.backgroundColor || 'transparent'}} tabPosition={tabs.setting.position} type={tabs.setting.tabStyle}> |
| | | {tabs.subtabs.map(tab => ( |
| | | <TabPane tab={<span id={'tab' + tab.uuid}>{tab.icon ? <MkIcon type={tab.icon} /> : null}{tab.label}</span>} style={{backgroundColor: tab.backgroundColor || 'transparent'}} key={tab.uuid}> |
| | | <TabTransfer config={tab} mainSearch={mainSearch}/> |
| | | <TabTransfer config={tab}/> |
| | | </TabPane> |
| | | ))} |
| | | </Tabs> |
| | |
| | | |
| | | class NormalTimeline extends Component { |
| | | static propTpyes = { |
| | | data: PropTypes.array, // 统一查询数据 |
| | | config: PropTypes.object, // 组件配置信息 |
| | | mainSearch: PropTypes.any, // 外层搜索条件 |
| | | config: PropTypes.object |
| | | } |
| | | |
| | | state = { |
| | | BID: '', // 上级ID |
| | | config: null, // 图表配置信息 |
| | | loading: false, // 数据加载状态 |
| | | sync: false, // 是否统一请求数据 |
| | | data: null, // 数据 |
| | | BData: '', |
| | | card: null, |
| | |
| | | |
| | | /** |
| | | * @description 初始化处理 |
| | | * 1、 initdata 为打印时使用的数据集 |
| | | */ |
| | | UNSAFE_componentWillMount () { |
| | | const { data, initdata } = this.props |
| | | let _config = fromJS(this.props.config).toJS() |
| | | const { config } = this.props |
| | | |
| | | let _config = fromJS(config).toJS() |
| | | let _data = null |
| | | let card = null |
| | | let _sync = _config.setting.sync === 'true' |
| | | |
| | | let BID = '' |
| | | let BData = '' |
| | | |
| | |
| | | BID = BData.$BID || '' |
| | | } |
| | | |
| | | if (_config.setting.sync === 'true' && data) { |
| | | _data = data[_config.dataName] || [] |
| | | _sync = false |
| | | } else if (_config.setting.sync === 'true' && initdata) { |
| | | _data = initdata || [] |
| | | _sync = false |
| | | } |
| | | if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { |
| | | _data = window.GLOB.SyncData.get(_config.dataName) || [] |
| | | |
| | | if (_data) { |
| | | this.loaded = true |
| | | if (_config.$cache) { |
| | | Api.writeCacheConfig(_config.uuid, fromJS(_data).toJS()) |
| | | } |
| | | |
| | | _config.setting.sync = 'false' |
| | | |
| | | _data = _data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[_config.setting.primaryKey] || '' |
| | |
| | | item.$Index = index + 1 + '' |
| | | return item |
| | | }) |
| | | |
| | | this.loaded = true |
| | | |
| | | window.GLOB.SyncData.delete(_config.dataName) |
| | | } |
| | | |
| | | _config.search = [] |
| | |
| | | |
| | | this.setState({ |
| | | card, |
| | | sync: _sync, |
| | | BID: BID || '', |
| | | BData: BData || '', |
| | | data: _data, |
| | | config: _config, |
| | | arr_field: _config.columns.map(col => col.field).join(','), |
| | | }, () => { |
| | | if (_config.setting.sync !== 'true' && _config.setting.onload === 'true') { |
| | | if (config.setting.sync !== 'true' && _config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | | this.loadData() |
| | | }, _config.setting.delay || 0) |
| | |
| | | const { config } = this.state |
| | | |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | | MKEmitter.addListener('refreshLineData', this.refreshLineData) |
| | | MKEmitter.addListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.addListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.addListener('refreshLineData', this.refreshLineData) |
| | | 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.timer) { |
| | | this.timer = new TimerTask() |
| | |
| | | return |
| | | } |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('searchRefresh', this.searchRefresh) |
| | | MKEmitter.removeListener('refreshLineData', this.refreshLineData) |
| | | MKEmitter.removeListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.removeListener('refreshLineData', this.refreshLineData) |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) |
| | | |
| | | this.timer && this.timer.stop() |
| | | } |
| | | |
| | | /** |
| | | * @description 图表数据更新,刷新内容 |
| | | */ |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | const { sync, config, BID, BData } = this.state |
| | | transferSyncData = (syncId) => { |
| | | const { config } = this.state |
| | | |
| | | if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) { |
| | | let _data = [] |
| | | if (nextProps.data && nextProps.data[config.dataName]) { |
| | | _data = nextProps.data[config.dataName] || [] |
| | | } |
| | | if (config.$syncId !== syncId) return |
| | | |
| | | _data = _data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[config.setting.primaryKey] || '' |
| | | item.$$BID = BID || '' |
| | | item.$$BData = BData || '' |
| | | item.$Index = index + 1 + '' |
| | | return item |
| | | }) |
| | | const { BID, BData } = this.state |
| | | |
| | | this.loaded = true |
| | | let _data = window.GLOB.SyncData.get(config.dataName) || [] |
| | | |
| | | this.setState({sync: false, data: _data}) |
| | | } else if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | if (config.$cache) { |
| | | Api.writeCacheConfig(config.uuid, fromJS(_data).toJS()) |
| | | } |
| | | |
| | | _data = _data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[config.setting.primaryKey] || '' |
| | | item.$$BID = BID || '' |
| | | item.$$BData = BData || '' |
| | | item.$Index = index + 1 + '' |
| | | return item |
| | | }) |
| | | |
| | | this.loaded = true |
| | | |
| | | this.setState({data: _data}) |
| | | |
| | | window.GLOB.SyncData.delete(config.dataName) |
| | | |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | |
| | | searchRefresh = (searchId) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.$searchId !== searchId) return |
| | | |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | |
| | | /** |
| | |
| | | * @description 导出Excel时,获取页面搜索排序等参数 |
| | | */ |
| | | queryModuleParam = (menuId, callback) => { |
| | | const { mainSearch } = this.props |
| | | const { arr_field, config } = this.state |
| | | |
| | | if (config.uuid !== menuId) return |
| | | |
| | | let searches = [] |
| | | if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | let keys = searches.map(item => item.key.toLowerCase()) |
| | | mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key.toLowerCase())) { |
| | | searches.push(item) |
| | | } |
| | | }) |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | searches = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | } |
| | | |
| | | callback({ |
| | |
| | | } |
| | | |
| | | async loadData (hastimer) { |
| | | const { mainSearch } = this.props |
| | | const { config, arr_field, BID, BData } = this.state |
| | | |
| | | if (config.setting.supModule && !BID) { // BID 不存在时,不做查询 |
| | |
| | | } |
| | | |
| | | let searches = [] |
| | | if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | let keys = searches.map(item => item.key) |
| | | mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key)) { |
| | | searches.push(item) |
| | | } |
| | | }) |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | searches = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | } |
| | | |
| | | let requireFields = searches.filter(item => item.required && item.value === '') |
| | | if (requireFields.length > 0) { |
| | | if (config.$s_req && searches.filter(item => item.required && item.value === '').length > 0) { |
| | | return |
| | | } |
| | | |
| | |
| | | if (result.status) { |
| | | this.loaded = true |
| | | if (config.$cache && config.setting.onload !== 'false') { |
| | | Api.writeCacheConfig(config.uuid, result.data || '') |
| | | Api.writeCacheConfig(config.uuid, result.data || []) |
| | | } |
| | | |
| | | let data = result.data.map((item, index) => { |
| | |
| | | |
| | | class NormalTree extends Component { |
| | | static propTpyes = { |
| | | data: PropTypes.array, // 统一查询数据 |
| | | config: PropTypes.object, // 组件配置信息 |
| | | mainSearch: PropTypes.any, // 外层搜索条件 |
| | | config: PropTypes.object |
| | | } |
| | | |
| | | state = { |
| | | BID: '', // 主表ID |
| | | config: null, // 图表配置信息 |
| | | loading: false, // 数据加载状态 |
| | | sync: false, // 是否统一请求数据 |
| | | data: null, // 数据 |
| | | searchkey: null, // 过滤条件 |
| | | treedata: null, // 列表数据集 |
| | |
| | | loaded = false |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { config, data, initdata } = this.props |
| | | const { config } = this.props |
| | | |
| | | let _config = fromJS(config).toJS() |
| | | let _data = null |
| | | let _sync = config.setting.sync === 'true' |
| | | |
| | | let BID = '' |
| | | let BData = '' |
| | | |
| | |
| | | BID = BData.$BID || '' |
| | | } |
| | | |
| | | if (_sync && data) { |
| | | _data = data[config.dataName] || [] |
| | | _sync = false |
| | | } else if (_sync && initdata) { |
| | | _data = initdata || [] |
| | | _sync = 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()) |
| | | } |
| | | |
| | | _config.setting.sync = 'false' |
| | | |
| | | this.loaded = true |
| | | |
| | | window.GLOB.SyncData.delete(_config.dataName) |
| | | } |
| | | |
| | | _config.wrap.contentHeight = config.wrap.title || config.wrap.searchable === 'true' ? 'calc(100% - 45px)' : '100%' |
| | | |
| | | this.loaded = _data !== null |
| | | |
| | | this.setState({ |
| | | selected: _config.wrap.selected === 'true', |
| | |
| | | data: _data, |
| | | BID: BID || '', |
| | | arr_field: _config.columns.map(col => col.field).join(','), |
| | | sync: _sync |
| | | }, () => { |
| | | if (config.setting.sync !== 'true' && config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | |
| | | this.handleData() |
| | | } |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 图表数据更新,刷新内容 |
| | | */ |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | const { sync, config } = this.state |
| | | |
| | | if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) { |
| | | let _data = [] |
| | | if (nextProps.data && nextProps.data[config.dataName]) { |
| | | _data = nextProps.data[config.dataName] || [] |
| | | } |
| | | |
| | | this.loaded = true |
| | | |
| | | this.setState({sync: false, data: _data}, () => { |
| | | this.handleData() |
| | | }) |
| | | } else if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | 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.timer) { |
| | | this.timer = new TimerTask() |
| | | this.timer.init(config.uuid, config.timer, config.timerRepeats, () => { |
| | |
| | | return |
| | | } |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('searchRefresh', this.searchRefresh) |
| | | MKEmitter.removeListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) |
| | | |
| | | this.timer && this.timer.stop() |
| | | } |
| | | |
| | | transferSyncData = (syncId) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.$syncId !== syncId) return |
| | | |
| | | let _data = window.GLOB.SyncData.get(config.dataName) || [] |
| | | |
| | | if (config.$cache) { |
| | | Api.writeCacheConfig(config.uuid, fromJS(_data).toJS()) |
| | | } |
| | | |
| | | this.loaded = true |
| | | |
| | | this.setState({data: _data}, () => { |
| | | this.handleData() |
| | | }) |
| | | |
| | | window.GLOB.SyncData.delete(config.dataName) |
| | | |
| | | MKEmitter.removeListener('transferSyncData', this.transferSyncData) |
| | | } |
| | | |
| | | searchRefresh = (searchId) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.$searchId !== searchId) return |
| | | |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | |
| | | reloadData = (menuId) => { |
| | |
| | | * @description 导出Excel时,获取页面搜索排序等参数 |
| | | */ |
| | | queryModuleParam = (menuId, callback) => { |
| | | const { mainSearch } = this.props |
| | | const { arr_field, config } = this.state |
| | | |
| | | if (config.uuid !== menuId) return |
| | | |
| | | let searches = [] |
| | | if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | let keys = searches.map(item => item.key.toLowerCase()) |
| | | mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key.toLowerCase())) { |
| | | searches.push(item) |
| | | } |
| | | }) |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | searches = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | } |
| | | |
| | | callback({ |
| | |
| | | * @description 数据加载 |
| | | */ |
| | | async loadData (hastimer) { |
| | | const { mainSearch } = this.props |
| | | const { config, arr_field, BID } = this.state |
| | | |
| | | if (config.setting.supModule && !BID) { // BID 不存在时,不做查询 |
| | |
| | | return |
| | | } |
| | | |
| | | let searches = config.setting.useMSearch && mainSearch ? mainSearch : [] |
| | | let searches = [] |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | | searches = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | } |
| | | |
| | | let requireFields = searches.filter(item => item.required && item.value === '') |
| | | if (requireFields.length > 0) { |
| | | if (config.$s_req && searches.filter(item => item.required && item.value === '').length > 0) { |
| | | return |
| | | } |
| | | |
| | |
| | | if (result.status) { |
| | | this.loaded = true |
| | | if (config.$cache && config.setting.onload !== 'false') { |
| | | Api.writeCacheConfig(config.uuid, result.data || '') |
| | | Api.writeCacheConfig(config.uuid, result.data || []) |
| | | } |
| | | |
| | | this.setState({ |
| | |
| | | viewlost: false, // 页面丢失:1、未获取到配置-页面丢失;2、页面未启用 |
| | | lostmsg: '', // 页面丢失时的提示信息 |
| | | config: null, // 页面配置信息,包括组件等 |
| | | mainSearch: null, // 主搜索 |
| | | userConfig: null, // 用户自定义设置 |
| | | data: null, // 列表数据集 |
| | | loading: false, // 列表数据加载中 |
| | | visible: false, // 标签页控制 |
| | | shortcuts: null, // 快捷键 |
| | |
| | | let initInters = [] |
| | | |
| | | config.interfaces = this.formatInterSetting(config.interfaces, regs, MenuID, initInters) |
| | | config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, balMap, skip, param, MenuID, config.interfaces, popview, config.$cache, config.MenuName) |
| | | |
| | | // 获取主搜索条件 |
| | | let mainSearch = [] |
| | | config.components.forEach(component => { |
| | | if (component.type !== 'search') return |
| | | |
| | | component.search = component.search.map(item => { |
| | | item.oriInitval = item.initval |
| | | if (['text', 'select', 'link'].includes(item.type) && param.$searchkey === item.field) { |
| | | item.initval = param.$searchval |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | | mainSearch = Utils.initMainSearch(component.search) |
| | | }) |
| | | config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, balMap, skip, param, MenuID, config.interfaces, popview, config.$cache, config.MenuName, MenuID, MenuID) |
| | | |
| | | let params = [] |
| | | let BID = param.$BID || '' |
| | |
| | | inherit.cacheTime = config.cacheTime |
| | | } |
| | | |
| | | config.components = this.formatSetting(config.components, params, mainSearch, inherit, regs, balMap) |
| | | // 字段透视 |
| | | config.components.forEach(component => { |
| | | if (component.type !== 'search') return |
| | | |
| | | if (param.$searchkey) { |
| | | component.search = component.search.map(item => { |
| | | if (['text', 'select', 'link'].includes(item.type) && param.$searchkey === item.field) { |
| | | item.initval = param.$searchval |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | | component.$searches = Utils.initMainSearch(component.search) |
| | | } |
| | | |
| | | window.GLOB.SearchBox.set(MenuID, component.$searches) |
| | | |
| | | if (component.$s_req) { |
| | | window.GLOB.SearchBox.set(MenuID + 'required', true) |
| | | } |
| | | }) |
| | | |
| | | config.components = this.formatSetting(config.components, params, inherit, regs, balMap) |
| | | |
| | | if ([...balMap.keys()].length > 0) { |
| | | config.components = this.filterBalcony(config.components, balMap) |
| | |
| | | BID: BID, |
| | | loadinginter: this.stepInter !== null, |
| | | shortcuts: shortcuts.length > 0 ? shortcuts : null, |
| | | config, |
| | | mainSearch |
| | | config |
| | | }, () => { |
| | | if (config.normalcss) { |
| | | let node = document.getElementById(config.uuid) |
| | |
| | | } |
| | | } |
| | | |
| | | filterComponent = (components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, popview, cache, MenuName) => { |
| | | filterComponent = (components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, popview, cache, MenuName, searchId, syncId) => { |
| | | return components.filter(item => { |
| | | item.$pageId = pageId |
| | | item.$cache = cache |
| | | item.$searchId = searchId |
| | | item.$syncId = syncId |
| | | |
| | | if (item.style && item.style.boxShadow) { |
| | | delete item.style.hShadow |
| | |
| | | item.subtabs = item.subtabs.map(tab => { |
| | | tab.$pageId = pageId |
| | | |
| | | tab.components = this.filterComponent(tab.components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, popview, cache, MenuName) |
| | | let _searchId = searchId |
| | | |
| | | tab.components.forEach(cell => { |
| | | if (cell.type !== 'search') return |
| | | _searchId = cell.uuid |
| | | window.GLOB.SearchBox.set(cell.uuid, cell.$searches) |
| | | if (cell.$s_req) { |
| | | window.GLOB.SearchBox.set(cell.uuid + 'required', true) |
| | | } |
| | | }) |
| | | |
| | | tab.components = this.filterComponent(tab.components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, popview, cache, MenuName, _searchId, tab.uuid) |
| | | return tab |
| | | }) |
| | | |
| | |
| | | return false |
| | | } |
| | | |
| | | item.components = this.filterComponent(item.components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, popview, cache, MenuName) |
| | | item.components = this.filterComponent(item.components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, popview, cache, MenuName, searchId, syncId) |
| | | |
| | | return true |
| | | } else if (['pie', 'bar', 'line', 'dashboard', 'scatter', 'chart', 'antvG6', 'antvX6'].includes(item.type)) { |
| | |
| | | } |
| | | |
| | | // 搜索条件初始化 |
| | | if (item.search && item.search.length > 0) { |
| | | item.search = Utils.initSearchVal(item.search) |
| | | if (item.type === 'search' && item.search.length === 0) { |
| | | return false |
| | | } else if (item.search) { |
| | | Utils.initSearchVal(item) |
| | | |
| | | item.$searches = Utils.initMainSearch(item.search) |
| | | } |
| | | |
| | | if (item.wrap && item.wrap.supType === 'multi') { // 数据卡多上级组件 |
| | |
| | | } |
| | | |
| | | // 格式化默认设置 |
| | | formatSetting = (components, params, mainSearch, inherit, regs, balMap) => { |
| | | formatSetting = (components, params, inherit, regs, balMap) => { |
| | | let delay = 20 |
| | | return components.map(component => { |
| | | if (component.type === 'tabs') { |
| | | component.subtabs = component.subtabs.map(tab => { |
| | | tab.components = this.formatSetting(tab.components, null, null, inherit, regs, balMap) |
| | | tab.components = this.formatSetting(tab.components, null, inherit, regs, balMap) |
| | | tab = {...tab, ...inherit} |
| | | return tab |
| | | }) |
| | | return component |
| | | } else if (component.type === 'group') { |
| | | component.components = this.formatSetting(component.components, null, null, inherit, regs, balMap) |
| | | component.components = this.formatSetting(component.components, params, inherit, regs, balMap) |
| | | component = {...component, ...inherit} |
| | | return component |
| | | } else if (component.wrap && component.wrap.datatype === 'public') { |
| | | component.setting.useMSearch = false |
| | | component.setting.sync = 'false' |
| | | |
| | | return component |
| | | } else if (component.wrap && component.wrap.datatype === 'static') { |
| | | component.format = '' |
| | | component.setting = component.setting || {} |
| | | component.setting.useMSearch = false |
| | | component.setting.sync = 'false' |
| | | |
| | | return component |
| | | } else if (!component.setting || !component.format) { |
| | |
| | | } |
| | | |
| | | component.setting.useMSearch = component.setting.useMSearch === 'true' |
| | | if (component.setting.useMSearch) { |
| | | if (!window.GLOB.SearchBox.has(component.$searchId)) { |
| | | component.setting.useMSearch = false |
| | | } else if (window.GLOB.SearchBox.has(component.$searchId + 'required')) { |
| | | component.$s_req = true |
| | | } |
| | | } |
| | | |
| | | if (component.wrap && component.wrap.goback === 'true') { |
| | | component.setting.sync = 'false' |
| | |
| | | } |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | component.setting.dataresource = component.setting.dataresource.replace(/\$@/ig, '/*').replace(/@datam@/ig, '\'Y\'') |
| | | component.setting.dataresource = component.setting.dataresource.replace(/@\$/ig, '*/') |
| | | _customScript = _customScript.replace(/\$@/ig, '/*').replace(/@datam@/ig, '\'Y\'') |
| | | _customScript = _customScript.replace(/@\$/ig, '*/') |
| | | component.setting.dataresource = component.setting.dataresource.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') |
| | | _customScript = _customScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') |
| | | } else { |
| | | component.setting.dataresource = component.setting.dataresource.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | | _customScript = _customScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | |
| | | |
| | | component.setting.customScript = _customScript // 整理后自定义脚本 |
| | | |
| | | if (component.setting.sync === 'true') { |
| | | // pageable 是否分页,组件属性,不分页的组件才可以统一查询 |
| | | if ((!component.pageable || (component.pageable && !component.setting.laypage)) && component.setting.onload === 'true') { |
| | | |
| | | } else { |
| | | component.setting.sync = 'false' |
| | | } |
| | | } |
| | | |
| | | // dataName 系统生成的数据源名称 |
| | | if (component.setting.sync === 'true') { |
| | | component.dataName = 'mk' + component.uuid.slice(-18) |
| | | } |
| | | |
| | | // floor 组件的层级 |
| | | // pageable 是否分页,组件属性,不分页的组件才可以统一查询 |
| | | if (params && (!component.pageable || (component.pageable && !component.setting.laypage)) && component.setting.onload === 'true' && component.setting.sync === 'true') { |
| | | let searchlist = [] |
| | | if (component.search && component.search.length > 0) { |
| | | searchlist = Utils.initMainSearch(component.search) |
| | | } |
| | | if (component.setting.useMSearch) { |
| | | let keys = searchlist.map(item => item.key) |
| | | mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key)) { |
| | | |
| | | if (params) { |
| | | let searchlist = component.$searches || [] |
| | | |
| | | if (component.setting.useMSearch) { |
| | | let mainSearch = window.GLOB.SearchBox.get(component.$searchId) |
| | | let keys = component.$s_keys || [] |
| | | mainSearch.forEach(item => { |
| | | if (keys.includes(item.key.toLowerCase())) return |
| | | |
| | | searchlist.push(item) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | if (component.$s_req && searchlist.filter(item => item.required && item.value === '').length > 0) { |
| | | component.setting.sync = 'false' |
| | | component.setting.onload = 'false' |
| | | } else { |
| | | params.push(getStructDefaultParam(component, searchlist, params.length === 0)) |
| | | } |
| | | } |
| | | |
| | | if (searchlist.filter(item => item.required && item.value === '').length > 0) { |
| | | component.setting.sync = 'false' |
| | | component.setting.onload = 'false' |
| | | } else { |
| | | params.push(getStructDefaultParam(component, searchlist, params.length === 0)) |
| | | } |
| | | } else if (params) { |
| | | component.setting.sync = 'false' |
| | | } |
| | | |
| | | component.setting.delay = delay |
| | |
| | | } |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | inter.setting.dataresource = inter.setting.dataresource.replace(/\$@/ig, '/*').replace(/@datam@/ig, '\'Y\'') |
| | | inter.setting.dataresource = inter.setting.dataresource.replace(/@\$/ig, '*/') |
| | | _customScript = _customScript.replace(/\$@/ig, '/*').replace(/@datam@/ig, '\'Y\'') |
| | | _customScript = _customScript.replace(/@\$/ig, '*/') |
| | | inter.setting.dataresource = inter.setting.dataresource.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') |
| | | _customScript = _customScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') |
| | | } else { |
| | | inter.setting.dataresource = inter.setting.dataresource.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | | _customScript = _customScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | |
| | | this.setState({loading: true, loadingview: false}) |
| | | |
| | | Api.genericInterface(param).then(result => { |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | |
| | | if (result.status) { |
| | | if (result.message) { |
| | | if (result.ErrCode === 'Y') { |
| | |
| | | } |
| | | } |
| | | |
| | | delete result.status |
| | | delete result.message |
| | | delete result.ErrMesg |
| | | delete result.ErrCode |
| | | |
| | | if (config.$cache) { |
| | | params.forEach((item) => { |
| | | let _data = result[item.name] || '' |
| | | if (_data && !Array.isArray(_data)) { |
| | | _data = [_data] |
| | | } |
| | | Api.writeCacheConfig(item.uuid, _data) |
| | | }) |
| | | } |
| | | |
| | | this.setState({ |
| | | data: result, |
| | | loading: false |
| | | params.forEach((item) => { |
| | | let _data = result[item.name] || '' |
| | | if (_data && !Array.isArray(_data)) { |
| | | _data = [_data] |
| | | } |
| | | window.GLOB.SyncData.set(item.name, _data) |
| | | }) |
| | | |
| | | MKEmitter.emit('transferSyncData', config.MenuID) |
| | | } else { |
| | | this.setState({ |
| | | data: '', |
| | | loading: false |
| | | }) |
| | | |
| | | MKEmitter.emit('transferSyncData', config.MenuID) |
| | | |
| | | if (!result.message) return |
| | | if (result.ErrCode === 'N') { |
| | | Modal.error({ |
| | |
| | | }) |
| | | } else if (item.type === 'group') { |
| | | this.deleteCache(item.components) |
| | | } else if (item.type === 'search') { |
| | | window.GLOB.SearchBox.delete(item.$searchId) |
| | | } else { |
| | | window.GLOB.CacheData.delete(item.uuid) |
| | | } |
| | | if (item.dataName) { |
| | | window.GLOB.SyncData.delete(item.dataName) |
| | | } |
| | | }) |
| | | } |
| | |
| | | viewlost: false, // 页面丢失:1、未获取到配置-页面丢失;2、页面未启用 |
| | | config: null, // 页面配置信息,包括组件等 |
| | | loading: false, // 列表数据加载中 |
| | | shortcuts: null, |
| | | data: '' |
| | | shortcuts: null |
| | | }, () => { |
| | | this.loadconfig() |
| | | }) |
| | | } |
| | | |
| | | resetSearch = (search) => { |
| | | this.setState({mainSearch: null}, () => { |
| | | this.setState({mainSearch: search}) |
| | | }) |
| | | } |
| | | |
| | | getComponents = () => { |
| | | const { config, BID, data, mainSearch, loadinginter } = this.state |
| | | const { config, BID, loadinginter } = this.state |
| | | |
| | | if (!config || !config.components || loadinginter) return |
| | | |
| | |
| | | if (item.type === 'card' && item.subtype === 'datacard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <DataCard config={item} data={data} mainSearch={mainSearch}/> |
| | | <DataCard config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'card' && item.subtype === 'propcard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <PropCard config={item} data={data} mainSearch={mainSearch}/> |
| | | <PropCard config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'card' && item.subtype === 'dualdatacard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <DoubleDataCard config={item} mainSearch={mainSearch}/> |
| | | <DoubleDataCard config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'table' && item.subtype === 'normaltable') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <NormalTable config={item} data={data} mainSearch={mainSearch}/> |
| | | <NormalTable config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'bar' || item.type === 'line') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvBarAndLine config={item} data={data} mainSearch={mainSearch}/> |
| | | <AntvBarAndLine config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'pie') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvPie config={item} data={data} mainSearch={mainSearch}/> |
| | | <AntvPie config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'scatter') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvScatter config={item} data={data} mainSearch={mainSearch}/> |
| | | <AntvScatter config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'dashboard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvDashboard config={item} data={data} mainSearch={mainSearch}/> |
| | | <AntvDashboard config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'form' && item.subtype === 'simpleform') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <SimpleForm config={item} data={data} mainSearch={mainSearch}/> |
| | | <SimpleForm config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'form' && item.subtype === 'stepform') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <StepForm config={item} data={data} mainSearch={mainSearch}/> |
| | | <StepForm config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'form' && item.subtype === 'tabform') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <TabForm config={item} data={data} mainSearch={mainSearch}/> |
| | | <TabForm config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'search') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <MainSearch config={item} BID={BID} refreshdata={this.resetSearch} /> |
| | | <MainSearch config={item} BID={BID}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'tabs') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvTabs config={item} mainSearch={mainSearch} /> |
| | | <AntvTabs config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'balcony') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <Balcony config={item} data={data}/> |
| | | <Balcony config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'timeline') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <TimeLine config={item} data={data} mainSearch={mainSearch}/> |
| | | <TimeLine config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'carousel' && item.subtype === 'datacard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <CarouselDataCard config={item} data={data} mainSearch={mainSearch}/> |
| | | <CarouselDataCard config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'carousel' && item.subtype === 'propcard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <CarouselPropCard config={item} data={data} mainSearch={mainSearch}/> |
| | | <CarouselPropCard config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'card' && item.subtype === 'tablecard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <TableCard config={item} data={data} mainSearch={mainSearch}/> |
| | | <TableCard config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'table' && item.subtype === 'editable') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <EditTable config={item} mainSearch={mainSearch}/> |
| | | <EditTable config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'group' && item.subtype === 'normalgroup') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <NormalGroup config={item} mainSearch={mainSearch}/> |
| | | <NormalGroup config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'editor') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <BraftEditor config={item} data={data} mainSearch={mainSearch}/> |
| | | <BraftEditor config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'tree') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <NormalTree config={item} data={data} mainSearch={mainSearch}/> |
| | | <NormalTree config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'calendar') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <Calendar config={item} mainSearch={mainSearch}/> |
| | | <Calendar config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'code') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <SandBox config={item} data={data} mainSearch={mainSearch}/> |
| | | <SandBox config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'chart') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <CustomChart config={item} data={data} mainSearch={mainSearch}/> |
| | | <CustomChart config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'antvG6') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvG6 config={item} data={data} mainSearch={mainSearch}/> |
| | | <AntvG6 config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'antvX6') { |
| | |
| | | } else if (item.type === 'iframe') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <Iframe config={item} data={data} mainSearch={mainSearch}/> |
| | | <Iframe config={item}/> |
| | | </Col> |
| | | ) |
| | | } else { |
| | |
| | | import enUS from '@/locales/en-US/main.js' |
| | | import Utils from '@/utils/utils.js' |
| | | import { getStructuredParams, getStructDefaultParam } from '@/utils/utils-datamanage.js' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import NotFount from '@/components/404' |
| | | import './index.scss' |
| | |
| | | viewlost: false, // 页面丢失:1、未获取到配置-页面丢失;2、页面未启用 |
| | | lostmsg: '', // 页面丢失时的提示信息 |
| | | config: null, // 页面配置信息,包括组件等 |
| | | mainSearch: null, // 主搜索 |
| | | data: null, // 列表数据集 |
| | | loading: false, // 列表数据加载中 |
| | | } |
| | | |
| | |
| | | |
| | | config.$cache = config.cacheLocal === 'true' |
| | | |
| | | config.components = this.filterComponent(config.components, roleId, balMap, param, Tab, config.$cache) |
| | | config.components = this.filterComponent(config.components, roleId, balMap, param, Tab, config.$cache, Tab.uuid, Tab.uuid) |
| | | |
| | | // 获取主搜索条件 |
| | | let mainSearch = [] |
| | | config.components.forEach(component => { |
| | | if (component.type !== 'search') return |
| | | |
| | | component.search = component.search.map(item => { |
| | | item.oriInitval = item.initval |
| | | if (['text', 'select', 'link'].includes(item.type) && param.$searchkey === item.field) { |
| | | item.initval = param.$searchval |
| | | } |
| | | if (param.$searchkey) { |
| | | component.search = component.search.map(item => { |
| | | if (['text', 'select', 'link'].includes(item.type) && param.$searchkey === item.field) { |
| | | item.initval = param.$searchval |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | return item |
| | | }) |
| | | |
| | | mainSearch = Utils.initMainSearch(component.search) |
| | | component.$searches = Utils.initMainSearch(component.search) |
| | | } |
| | | |
| | | window.GLOB.SearchBox.set(Tab.uuid, component.$searches) |
| | | |
| | | if (component.$s_req) { |
| | | window.GLOB.SearchBox.set(Tab.uuid + 'required', true) |
| | | } |
| | | }) |
| | | |
| | | let params = [] |
| | |
| | | inherit.cacheTime = config.cacheTime |
| | | } |
| | | |
| | | config.components = this.formatSetting(config.components, params, mainSearch, inherit, regs, balMap) |
| | | config.components = this.formatSetting(config.components, params, inherit, regs, balMap) |
| | | |
| | | if ([...balMap.keys()].length > 0) { |
| | | config.components = this.filterBalcony(config.components, balMap) |
| | |
| | | |
| | | this.setState({ |
| | | BID: BID, |
| | | config, |
| | | mainSearch |
| | | config |
| | | }, () => { |
| | | if (params.length > 0) { |
| | | this.loadmaindata(params) |
| | |
| | | }) |
| | | } |
| | | |
| | | filterComponent = (components, roleId, balMap, urlparam, Tab, cache) => { |
| | | filterComponent = (components, roleId, balMap, urlparam, Tab, cache, searchId, syncId) => { |
| | | return components.filter(item => { |
| | | item.$pageId = Tab.uuid |
| | | item.$cache = cache |
| | | item.$searchId = searchId |
| | | item.$syncId = syncId |
| | | |
| | | if (item.style && item.style.boxShadow) { |
| | | delete item.style.hShadow |
| | |
| | | item.subtabs = item.subtabs.map(tab => { |
| | | tab.$pageId = Tab.uuid |
| | | |
| | | tab.components = this.filterComponent(tab.components, roleId, balMap, urlparam, Tab, cache) |
| | | let _searchId = searchId |
| | | |
| | | tab.components.forEach(cell => { |
| | | if (cell.type !== 'search') return |
| | | _searchId = cell.uuid |
| | | window.GLOB.SearchBox.set(cell.uuid, cell.$searches) |
| | | if (cell.$s_req) { |
| | | window.GLOB.SearchBox.set(cell.uuid + 'required', true) |
| | | } |
| | | }) |
| | | |
| | | tab.components = this.filterComponent(tab.components, roleId, balMap, urlparam, Tab, cache, _searchId, tab.uuid) |
| | | return tab |
| | | }) |
| | | |
| | |
| | | return false |
| | | } |
| | | |
| | | item.components = this.filterComponent(item.components, roleId, balMap, urlparam, Tab, cache) |
| | | item.components = this.filterComponent(item.components, roleId, balMap, urlparam, Tab, cache, searchId, syncId) |
| | | |
| | | return true |
| | | } else if (['pie', 'bar', 'line', 'dashboard', 'scatter', 'chart'].includes(item.type)) { |
| | |
| | | } |
| | | |
| | | // 搜索条件初始化 |
| | | if (item.search && item.search.length > 0) { |
| | | item.search = Utils.initSearchVal(item.search) |
| | | if (item.type === 'search' && item.search.length === 0) { |
| | | return false |
| | | } else if (item.search) { |
| | | Utils.initSearchVal(item) |
| | | |
| | | item.$searches = Utils.initMainSearch(item.search) |
| | | } |
| | | |
| | | if (item.wrap && item.wrap.supType === 'multi') { // 数据卡多上级组件 |
| | |
| | | } |
| | | |
| | | // 格式化默认设置 |
| | | formatSetting = (components, params, mainSearch, inherit, regs, balMap) => { |
| | | formatSetting = (components, params, inherit, regs, balMap) => { |
| | | let delay = 20 |
| | | return components.map(component => { |
| | | if (component.type === 'tabs') { |
| | |
| | | }) |
| | | return component |
| | | } else if (component.type === 'group') { |
| | | component.components = this.formatSetting(component.components, null, null, inherit, regs, balMap) |
| | | component.components = this.formatSetting(component.components, params, inherit, regs, balMap) |
| | | component = {...component, ...inherit} |
| | | return component |
| | | } else if (component.wrap && component.wrap.datatype === 'public') { |
| | | component.setting.useMSearch = false |
| | | component.setting.sync = 'false' |
| | | |
| | | return component |
| | | } else if (component.wrap && component.wrap.datatype === 'static') { |
| | | component.format = '' |
| | | component.setting = component.setting || {} |
| | | component.setting.useMSearch = false |
| | | component.setting.sync = 'false' |
| | | |
| | | return component |
| | | } else if (!component.setting || !component.format) { |
| | |
| | | } |
| | | |
| | | component.setting.useMSearch = component.setting.useMSearch === 'true' |
| | | if (component.setting.useMSearch) { |
| | | if (!window.GLOB.SearchBox.has(component.$searchId)) { |
| | | component.setting.useMSearch = false |
| | | } else if (window.GLOB.SearchBox.has(component.$searchId + 'required')) { |
| | | component.$s_req = true |
| | | } |
| | | } |
| | | |
| | | if (component.setting.interType !== 'system') { // 不使用系统函数时 |
| | | component.setting.sync = 'false' |
| | |
| | | } |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | component.setting.dataresource = component.setting.dataresource.replace(/\$@/ig, '/*').replace(/@datam@/ig, '\'Y\'') |
| | | component.setting.dataresource = component.setting.dataresource.replace(/@\$/ig, '*/') |
| | | _customScript = _customScript.replace(/\$@/ig, '/*').replace(/@datam@/ig, '\'Y\'') |
| | | _customScript = _customScript.replace(/@\$/ig, '*/') |
| | | component.setting.dataresource = component.setting.dataresource.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') |
| | | _customScript = _customScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') |
| | | } else { |
| | | component.setting.dataresource = component.setting.dataresource.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | | _customScript = _customScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | |
| | | |
| | | component.setting.customScript = _customScript // 整理后自定义脚本 |
| | | |
| | | if (component.setting.sync === 'true') { |
| | | // pageable 是否分页,组件属性,不分页的组件才可以统一查询 |
| | | if ((!component.pageable || (component.pageable && !component.setting.laypage)) && component.setting.onload === 'true') { |
| | | |
| | | } else { |
| | | component.setting.sync = 'false' |
| | | } |
| | | } |
| | | |
| | | // dataName 系统生成的数据源名称 |
| | | if (component.setting.sync === 'true') { |
| | | component.dataName = 'mk' + component.uuid.slice(-18) |
| | | } |
| | | |
| | | // floor 组件的层级 |
| | | // pageable 是否分页,组件属性,不分页的组件才可以统一查询 |
| | | if (params && (!component.pageable || (component.pageable && !component.setting.laypage)) && component.setting.onload === 'true' && component.setting.sync === 'true') { |
| | | let searchlist = [] |
| | | if (component.search && component.search.length > 0) { |
| | | searchlist = Utils.initMainSearch(component.search) |
| | | } |
| | | if (component.setting.useMSearch) { |
| | | let keys = searchlist.map(item => item.key) |
| | | mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key)) { |
| | | if (params) { |
| | | let searchlist = component.$searches || [] |
| | | |
| | | if (component.setting.useMSearch) { |
| | | let mainSearch = window.GLOB.SearchBox.get(component.$searchId) |
| | | let keys = component.$s_keys || [] |
| | | mainSearch.forEach(item => { |
| | | if (keys.includes(item.key.toLowerCase())) return |
| | | |
| | | searchlist.push(item) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | if (component.$s_req && searchlist.filter(item => item.required && item.value === '').length > 0) { |
| | | component.setting.sync = 'false' |
| | | component.setting.onload = 'false' |
| | | } else { |
| | | params.push(getStructDefaultParam(component, searchlist, params.length === 0)) |
| | | } |
| | | } |
| | | |
| | | if (searchlist.filter(item => item.required && item.value === '').length > 0) { |
| | | component.setting.sync = 'false' |
| | | component.setting.onload = 'false' |
| | | } else { |
| | | params.push(getStructDefaultParam(component, searchlist, params.length === 0)) |
| | | } |
| | | } else if (params) { |
| | | component.setting.sync = 'false' |
| | | } |
| | | |
| | | component.setting.delay = delay |
| | |
| | | * @description 主表数据加载 |
| | | */ |
| | | loadmaindata = (params) => { |
| | | const { Tab } = this.props |
| | | const { config } = this.state |
| | | let param = getStructuredParams(params, config, this.state.BID || '') |
| | | |
| | | this.setState({loading: true}) |
| | | |
| | | Api.genericInterface(param).then(result => { |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | |
| | | if (result.status) { |
| | | if (result.message) { |
| | | if (result.ErrCode === 'Y') { |
| | |
| | | } |
| | | } |
| | | |
| | | delete result.status |
| | | delete result.message |
| | | delete result.ErrMesg |
| | | delete result.ErrCode |
| | | |
| | | if (config.$cache) { |
| | | params.forEach((item) => { |
| | | let _data = result[item.name] || '' |
| | | if (_data && !Array.isArray(_data)) { |
| | | _data = [_data] |
| | | } |
| | | Api.writeCacheConfig(item.uuid, _data) |
| | | }) |
| | | } |
| | | |
| | | this.setState({ |
| | | data: result, |
| | | loading: false |
| | | params.forEach((item) => { |
| | | let _data = result[item.name] || '' |
| | | if (_data && !Array.isArray(_data)) { |
| | | _data = [_data] |
| | | } |
| | | window.GLOB.SyncData.set(item.name, _data) |
| | | }) |
| | | |
| | | MKEmitter.emit('transferSyncData', Tab.uuid) |
| | | } else { |
| | | this.setState({ |
| | | data: '', |
| | | loading: false |
| | | }) |
| | | MKEmitter.emit('transferSyncData', Tab.uuid) |
| | | |
| | | if (!result.message) return |
| | | if (result.ErrCode === 'N') { |
| | |
| | | }) |
| | | } else if (item.type === 'group') { |
| | | this.deleteCache(item.components) |
| | | } else if (item.type === 'search') { |
| | | window.GLOB.SearchBox.delete(item.$searchId) |
| | | } else { |
| | | window.GLOB.CacheData.delete(item.uuid) |
| | | } |
| | | |
| | | if (item.dataName) { |
| | | window.GLOB.SyncData.delete(item.dataName) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | resetSearch = (search) => { |
| | | this.setState({mainSearch: null}, () => { |
| | | this.setState({mainSearch: search}) |
| | | }) |
| | | } |
| | | |
| | | getComponents = () => { |
| | | const { config, BID, data, mainSearch } = this.state |
| | | const { config, BID } = this.state |
| | | |
| | | if (!config) return |
| | | |
| | |
| | | if (item.type === 'card' && item.subtype === 'datacard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <DataCard config={item} data={data} mainSearch={mainSearch}/> |
| | | <DataCard config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'card' && item.subtype === 'propcard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <PropCard config={item} data={data} mainSearch={mainSearch}/> |
| | | <PropCard config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'card' && item.subtype === 'dualdatacard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <DoubleDataCard config={item} mainSearch={mainSearch}/> |
| | | <DoubleDataCard config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'table' && item.subtype === 'basetable') { |
| | |
| | | } else if (item.type === 'bar' || item.type === 'line') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvBarAndLine config={item} data={data} mainSearch={mainSearch}/> |
| | | <AntvBarAndLine config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'pie') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvPie config={item} data={data} mainSearch={mainSearch}/> |
| | | <AntvPie config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'scatter') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvScatter config={item} data={data} mainSearch={mainSearch}/> |
| | | <AntvScatter config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'dashboard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvDashboard config={item} data={data} mainSearch={mainSearch}/> |
| | | <AntvDashboard config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'form' && item.subtype === 'simpleform') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <SimpleForm config={item} data={data} mainSearch={mainSearch}/> |
| | | <SimpleForm config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'form' && item.subtype === 'stepform') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <StepForm config={item} data={data} mainSearch={mainSearch}/> |
| | | <StepForm config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'form' && item.subtype === 'tabform') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <TabForm config={item} data={data} mainSearch={mainSearch}/> |
| | | <TabForm config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'search') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <MainSearch config={item} BID={BID} refreshdata={this.resetSearch} /> |
| | | <MainSearch config={item} BID={BID} /> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'tabs') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvTabs config={item} mainSearch={mainSearch} /> |
| | | <AntvTabs config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'balcony') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <Balcony config={item} data={data}/> |
| | | <Balcony config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'timeline') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <TimeLine config={item} data={data} mainSearch={mainSearch}/> |
| | | <TimeLine config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'carousel' && item.subtype === 'datacard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <CarouselDataCard config={item} data={data} mainSearch={mainSearch}/> |
| | | <CarouselDataCard config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'carousel' && item.subtype === 'propcard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <CarouselPropCard config={item} data={data} mainSearch={mainSearch}/> |
| | | <CarouselPropCard config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'card' && item.subtype === 'tablecard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <TableCard config={item} data={data} mainSearch={mainSearch}/> |
| | | <TableCard config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'table' && item.subtype === 'normaltable') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <NormalTable config={item} data={data} mainSearch={mainSearch}/> |
| | | <NormalTable config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'table' && item.subtype === 'editable') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <EditTable config={item} mainSearch={mainSearch}/> |
| | | <EditTable config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'group' && item.subtype === 'normalgroup') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <NormalGroup config={item} mainSearch={mainSearch}/> |
| | | <NormalGroup config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'editor') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <BraftEditor config={item} data={data} mainSearch={mainSearch}/> |
| | | <BraftEditor config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'tree') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <NormalTree config={item} data={data} mainSearch={mainSearch}/> |
| | | <NormalTree config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'calendar') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <Calendar config={item} mainSearch={mainSearch}/> |
| | | <Calendar config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'code') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <SandBox config={item} data={data} mainSearch={mainSearch}/> |
| | | <SandBox config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'chart') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <CustomChart config={item} data={data} mainSearch={mainSearch}/> |
| | | <CustomChart config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'module' && item.subtype === 'voucher') { |
| | |
| | | } else if (item.type === 'iframe') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <Iframe config={item} data={data} mainSearch={mainSearch}/> |
| | | <Iframe config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'antvG6') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvG6 config={item} data={data} mainSearch={mainSearch}/> |
| | | <AntvG6 config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'antvX6') { |
| | |
| | | statFields: [], // 合计字段 |
| | | statFValue: [], // 合计值 |
| | | absFields: [], // 绝对值字段 |
| | | hasReqFields: false, |
| | | BID: '', |
| | | BData: '' |
| | | } |
| | |
| | | // 权限过滤 |
| | | config.action = config.action.filter(item => item.hidden !== 'true') |
| | | |
| | | config.search = Utils.initSearchVal(config.search) |
| | | |
| | | let hasReqFields = false |
| | | config.search.forEach(field => { |
| | | if (field.required) { |
| | | hasReqFields = true |
| | | } |
| | | }) |
| | | Utils.initSearchVal(config) |
| | | |
| | | // 字段权限黑名单 |
| | | let roleId = sessionStorage.getItem('role_id') || '' // 角色ID |
| | |
| | | } |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | config.setting.dataresource = config.setting.dataresource.replace(/\$@/ig, '/*') |
| | | config.setting.dataresource = config.setting.dataresource.replace(/@\$/ig, '*/') |
| | | config.setting.customScript = config.setting.customScript.replace(/\$@/ig, '/*') |
| | | config.setting.customScript = config.setting.customScript.replace(/@\$/ig, '*/') |
| | | config.setting.dataresource = config.setting.dataresource.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/') |
| | | config.setting.customScript = config.setting.customScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/') |
| | | } else { |
| | | config.setting.dataresource = config.setting.dataresource.replace(/@\$|\$@/ig, '') |
| | | config.setting.customScript = config.setting.customScript.replace(/@\$|\$@/ig, '') |
| | |
| | | actions: _actions, |
| | | columns: _columns, |
| | | arr_field: _arrField.join(','), |
| | | search: Utils.initMainSearch(config.search), |
| | | hasReqFields |
| | | search: Utils.initMainSearch(config.search) |
| | | }, () => { |
| | | if (config.setting.onload !== 'false' && (!Tab.supMenu || this.props.BID || Tab.isTreeNode)) { // 初始化可加载 |
| | | this.loadData() |
| | |
| | | |
| | | loadData = (id) => { |
| | | const { mainSearch } = this.props |
| | | const { setting, BID, search, hasReqFields } = this.state |
| | | const { setting, BID, search, config } = this.state |
| | | |
| | | let searches = fromJS(search).toJS() |
| | | if (mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | searches = [...mainSearch, ...searches] |
| | | } |
| | | |
| | | if (hasReqFields) { |
| | | if (config.$s_req) { |
| | | let requireFields = searches.filter(item => item.required && item.value === '') |
| | | if (requireFields.length > 0) { |
| | | this.setState({ |
| | |
| | | statFields: [], // 合计字段 |
| | | statFValue: [], // 合计值 |
| | | absFields: [], // 绝对值字段 |
| | | hasReqFields: false |
| | | } |
| | | |
| | | /** |
| | |
| | | // 权限过滤 |
| | | config.action = config.action.filter(item => item.hidden !== 'true') |
| | | |
| | | config.search = Utils.initSearchVal(config.search) |
| | | |
| | | let hasReqFields = false |
| | | config.search.forEach(field => { |
| | | if (field.required) { |
| | | hasReqFields = true |
| | | } |
| | | }) |
| | | Utils.initSearchVal(config) |
| | | |
| | | // 字段权限黑名单 |
| | | let roleId = sessionStorage.getItem('role_id') || '' // 角色ID |
| | |
| | | } |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | config.setting.dataresource = config.setting.dataresource.replace(/\$@/ig, '/*') |
| | | config.setting.dataresource = config.setting.dataresource.replace(/@\$/ig, '*/') |
| | | config.setting.customScript = config.setting.customScript.replace(/\$@/ig, '/*') |
| | | config.setting.customScript = config.setting.customScript.replace(/@\$/ig, '*/') |
| | | config.setting.dataresource = config.setting.dataresource.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/') |
| | | config.setting.customScript = config.setting.customScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/') |
| | | } else { |
| | | config.setting.dataresource = config.setting.dataresource.replace(/@\$|\$@/ig, '') |
| | | config.setting.customScript = config.setting.customScript.replace(/@\$|\$@/ig, '') |
| | |
| | | columns: _columns, |
| | | arr_field: _arrField.join(','), |
| | | search: Utils.initMainSearch(config.search), // 搜索条件初始化(含有时间格式,需要转化) |
| | | hasReqFields |
| | | }, () => { |
| | | if (config.setting.onload !== 'false') { // 初始化可加载 |
| | | this.loadData() |
| | |
| | | } |
| | | |
| | | loadData = (id) => { |
| | | const { setting, search, hasReqFields } = this.state |
| | | const { setting, search, config } = this.state |
| | | |
| | | let searches = fromJS(search).toJS() |
| | | |
| | | if (hasReqFields) { |
| | | if (config.$s_req) { |
| | | let requireFields = searches.filter(item => item.required && item.value === '') |
| | | if (requireFields.length > 0) { |
| | | this.setState({ |
| | |
| | | } |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | config.setting.dataresource = config.setting.dataresource.replace(/\$@/ig, '/*') |
| | | config.setting.dataresource = config.setting.dataresource.replace(/@\$/ig, '*/') |
| | | config.setting.customScript = config.setting.customScript.replace(/\$@/ig, '/*') |
| | | config.setting.customScript = config.setting.customScript.replace(/@\$/ig, '*/') |
| | | config.setting.dataresource = config.setting.dataresource.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/') |
| | | config.setting.customScript = config.setting.customScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/') |
| | | } else { |
| | | config.setting.dataresource = config.setting.dataresource.replace(/@\$|\$@/ig, '') |
| | | config.setting.customScript = config.setting.customScript.replace(/@\$|\$@/ig, '') |
| | |
| | | |
| | | return C ? |
| | | <C {...this.props} /> : |
| | | <Button className={'mk-btn mk-' + btn.class} style={style} icon={btn.icon} disabled={true} >{btn.label}</Button> |
| | | <Button className={'mk-btn mk-' + btn.class} style={style} disabled={true} >{btn.label}</Button> |
| | | } |
| | | } |
| | | } |
| | |
| | | param.func = 'sPC_TableData_InUpDe' |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | result.sql = result.sql.replace(/\$@/ig, '/*') |
| | | result.sql = result.sql.replace(/@\$/ig, '*/') |
| | | result.bottom = result.bottom.replace(/\$@/ig, '/*') |
| | | result.bottom = result.bottom.replace(/@\$/ig, '*/') |
| | | result.sql = result.sql.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') |
| | | result.bottom = result.bottom.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') |
| | | } else { |
| | | result.sql = result.sql.replace(/@\$|\$@/ig, '') |
| | | result.bottom = result.bottom.replace(/@\$|\$@/ig, '') |
| | | result.sql = result.sql.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | | result.bottom = result.bottom.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | | } |
| | | |
| | | param.excel_in_type = 'true' |
| | |
| | | } |
| | | if (col.round) { |
| | | val = Math.round(val * col.round) / col.round |
| | | val = +val.toFixed(col.decimal) |
| | | // val = val.toFixed(col.decimal) |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | if (col.round) { |
| | | val = Math.round(val * col.round) / col.round |
| | | val = +val.toFixed(col.decimal) |
| | | // val = val.toFixed(col.decimal) |
| | | } |
| | | } |
| | | |
| | |
| | | let script = btn.verify.script |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | script = script.replace(/\$@/ig, '/*') |
| | | script = script.replace(/@\$/ig, '*/') |
| | | script = script.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') |
| | | } else { |
| | | script = script.replace(/@\$|\$@/ig, '') |
| | | script = script.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | | } |
| | | |
| | | let allSearch = Utils.getAllSearchOptions(search) |
| | |
| | | }) |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | _dataresource = _dataresource.replace(/\$@/ig, '/*') |
| | | _dataresource = _dataresource.replace(/@\$/ig, '*/') |
| | | customScript = customScript.replace(/\$@/ig, '/*') |
| | | customScript = customScript.replace(/@\$/ig, '*/') |
| | | _dataresource = _dataresource.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') |
| | | customScript = customScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') |
| | | } else { |
| | | _dataresource = _dataresource.replace(/@\$|\$@/ig, '') |
| | | customScript = customScript.replace(/@\$|\$@/ig, '') |
| | | _dataresource = _dataresource.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | | customScript = customScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | param.LText = param.LText.replace(/\$@/ig, '/*') |
| | | param.LText = param.LText.replace(/@\$/ig, '*/') |
| | | param.LText = param.LText.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') |
| | | } else { |
| | | param.LText = param.LText.replace(/@\$|\$@/ig, '') |
| | | param.LText = param.LText.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | | } |
| | | |
| | | param.exec_type = 'y' // 后台解码 |
| | |
| | | } |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | param.LText = param.LText.replace(/\$@/ig, '/*') |
| | | param.LText = param.LText.replace(/@\$/ig, '*/') |
| | | param.LText = param.LText.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') |
| | | } else { |
| | | param.LText = param.LText.replace(/@\$|\$@/ig, '') |
| | | param.LText = param.LText.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | | } |
| | | |
| | | param.exec_type = 'y' // 后台解码 |
| | |
| | | } |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | param.LText = param.LText.replace(/\$@/ig, '/*') |
| | | param.LText = param.LText.replace(/@\$/ig, '*/') |
| | | param.LText = param.LText.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') |
| | | } else { |
| | | param.LText = param.LText.replace(/@\$|\$@/ig, '') |
| | | param.LText = param.LText.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | | } |
| | | |
| | | param.exec_type = 'y' // 后台解码 |
| | |
| | | } |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | param.LText = param.LText.replace(/\$@/ig, '/*') |
| | | param.LText = param.LText.replace(/@\$/ig, '*/') |
| | | param.LText = param.LText.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') |
| | | } else { |
| | | param.LText = param.LText.replace(/@\$|\$@/ig, '') |
| | | param.LText = param.LText.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | | } |
| | | |
| | | param.exec_type = 'y' // 后台解码 |
| | |
| | | } |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | param.LText = param.LText.replace(/\$@/ig, '/*') |
| | | param.LText = param.LText.replace(/@\$/ig, '*/') |
| | | param.LText = param.LText.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') |
| | | } else { |
| | | param.LText = param.LText.replace(/@\$|\$@/ig, '') |
| | | param.LText = param.LText.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | | } |
| | | |
| | | param.exec_type = 'y' // 后台解码 |
| | |
| | | } |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | param.LText = param.LText.replace(/\$@/ig, '/*') |
| | | param.LText = param.LText.replace(/@\$/ig, '*/') |
| | | param.LText = param.LText.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') |
| | | } else { |
| | | param.LText = param.LText.replace(/@\$|\$@/ig, '') |
| | | param.LText = param.LText.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | | } |
| | | |
| | | param.exec_type = 'y' // 后台解码 |
| | |
| | | param.LText = sql |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | param.LText = param.LText.replace(/\$@/ig, '/*') |
| | | param.LText = param.LText.replace(/@\$/ig, '*/') |
| | | param.LText = param.LText.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') |
| | | } else { |
| | | param.LText = param.LText.replace(/@\$|\$@/ig, '') |
| | | param.LText = param.LText.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | | } |
| | | param.LText = param.LText.replace(/\$check@|@check\$/ig, '') |
| | | |
| | |
| | | > |
| | | <MutilForm |
| | | BID={BID} |
| | | dict={this.state.dict} |
| | | action={btnconfig} |
| | | inputSubmit={this.handleOk} |
| | | data={this.state.selines[0]} |
| | |
| | | > |
| | | <MutilForm |
| | | BID={BID} |
| | | dict={this.state.dict} |
| | | action={btnconfig} |
| | | inputSubmit={this.handleOk} |
| | | data={this.state.selines[0]} |
| | |
| | | } |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | _dataresource = _dataresource.replace(/\$@/ig, '/*').replace(/@datam@/ig, '\'Y\'') |
| | | _dataresource = _dataresource.replace(/@\$/ig, '*/') |
| | | _customScript = _customScript.replace(/\$@/ig, '/*').replace(/@datam@/ig, '\'Y\'') |
| | | _customScript = _customScript.replace(/@\$/ig, '*/') |
| | | _dataresource = _dataresource.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') |
| | | _customScript = _customScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') |
| | | } else { |
| | | _dataresource = _dataresource.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | | _customScript = _customScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | |
| | | > |
| | | <MutilForm |
| | | BID={BID} |
| | | dict={this.state.dict} |
| | | action={btnconfig} |
| | | inputSubmit={this.handleOk} |
| | | data={this.state.selines[0]} |
| | |
| | | const MkVercode = asyncComponent(() => import('./mkVercode')) |
| | | const MKEditor = asyncComponent(() => import('@/components/editor')) |
| | | |
| | | class MainSearch extends Component { |
| | | class MutilFormComponent extends Component { |
| | | static propTpyes = { |
| | | action: PropTypes.object, // 按钮信息、表单列表 |
| | | data: PropTypes.any, // 表格数据 |
| | |
| | | } |
| | | } |
| | | |
| | | export default Form.create()(MainSearch) |
| | | export default Form.create()(MutilFormComponent) |
| | |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import asyncSpinComponent from '@/utils/asyncSpinComponent' |
| | | import Utils from '@/utils/utils.js' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import MKInput from './mkInput' |
| | | import './index.scss' |
| | | |
| | |
| | | class MainSearch extends Component { |
| | | static propTpyes = { |
| | | BID: PropTypes.any, // 父级Id,用于查询下拉选择项 |
| | | config: PropTypes.object, // 组件配置信息(自定义页面) |
| | | refreshdata: PropTypes.func // 刷新数据 |
| | | config: PropTypes.object, // 组件配置信息 |
| | | } |
| | | |
| | | state = { |
| | |
| | | let advanceValues = [] |
| | | let linkFields = {} |
| | | let record = {} |
| | | let hasReqFields = false |
| | | |
| | | let forbid = false // header中不设置高级搜索 |
| | | let _setting = {showAdv: false, show: false, style: null} |
| | | |
| | |
| | | |
| | | if (fieldMap.has(item.field)) { |
| | | item.field = item.field + '@tail@' |
| | | } |
| | | |
| | | if (item.required) { |
| | | hasReqFields = true |
| | | } |
| | | |
| | | if (item.advanced && !forbid) { |
| | |
| | | |
| | | this.setState({ |
| | | setting: _setting, |
| | | hasReqFields, |
| | | hasReqFields: config.$s_req, |
| | | advanceValues, |
| | | searchlist: _list |
| | | }, () => { |
| | |
| | | this.sign = '' |
| | | }, 2000) |
| | | |
| | | this.props.refreshdata(searches) |
| | | if (this.props.refreshdata) { |
| | | this.props.refreshdata(searches) |
| | | } else { |
| | | window.GLOB.SearchBox.set(this.props.config.$searchId, searches) |
| | | MKEmitter.emit('searchRefresh', this.props.config.$searchId) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | |
| | | } |
| | | |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | param.LText = param.LText.replace(/@\$|\$@/ig, '').replace(/\$check@|@check\$/ig, '').replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id|typename)@/ig, `'${param.timestamp}'`) |
| | | param.LText = param.LText.replace(/@\$|\$@/ig, '').replace(/\$check@|@check\$/ig, '').replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id|datam|typename)@/ig, `'${param.timestamp}'`) |
| | | param.LText = param.LText.replace(/\n/g, ' ') |
| | | |
| | | // 外联数据库替换 |
| | |
| | | } |
| | | |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | param.LText = param.LText.replace(/@\$|\$@/ig, '').replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id)@/ig, `'${param.timestamp}'`) |
| | | param.LText = param.LText.replace(/@\$|\$@/ig, '').replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id|datam)@/ig, `'${param.timestamp}'`) |
| | | param.LText = param.LText.replace(/\n/g, ' ') |
| | | |
| | | param.LText = Utils.formatOptions(param.LText) |
| | |
| | | _dataresource = '' |
| | | } |
| | | |
| | | _dataresource = _dataresource.replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id|typename)@/ig, `'${timestamp}'`) |
| | | _customScript = _customScript.replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id|typename)@/ig, `'${timestamp}'`) |
| | | _dataresource = _dataresource.replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id|datam|typename)@/ig, `'${timestamp}'`) |
| | | _customScript = _customScript.replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id|datam|typename)@/ig, `'${timestamp}'`) |
| | | _dataresource = _dataresource.replace(/@\$|\$@/ig, '') |
| | | _customScript = _customScript.replace(/@\$|\$@/ig, '') |
| | | |
| | |
| | | _dataresource = '' |
| | | } |
| | | |
| | | _dataresource = _dataresource.replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id|typename)@/ig, `'${timestamp}'`) |
| | | _customScript = _customScript.replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id|typename)@/ig, `'${timestamp}'`) |
| | | _dataresource = _dataresource.replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id|datam|typename)@/ig, `'${timestamp}'`) |
| | | _customScript = _customScript.replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id|datam|typename)@/ig, `'${timestamp}'`) |
| | | _dataresource = _dataresource.replace(/@\$|\$@/ig, '') |
| | | _customScript = _customScript.replace(/@\$|\$@/ig, '') |
| | | |
| | |
| | | } |
| | | |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | param.LText = param.LText.replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id|typename)@/ig, `'${param.timestamp}'`) |
| | | param.LText = param.LText.replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id|datam|typename)@/ig, `'${param.timestamp}'`) |
| | | |
| | | console.info(`/* sql 验证 */\n${param.LText.replace(/\n\s{6,20}/ig, '\n')}`) |
| | | |
| | |
| | | * @description 初始化搜索条件初始值 |
| | | * @param {Array} searches 搜索条件 |
| | | */ |
| | | static initSearchVal (searches) { |
| | | if (!searches) return [] |
| | | static initSearchVal (config) { |
| | | if (!config.search) { |
| | | config.search = [] |
| | | return |
| | | } |
| | | |
| | | let roleId = sessionStorage.getItem('role_id') || '' |
| | | let required = false |
| | | let keys = [] |
| | | |
| | | return searches.map(item => { |
| | | config.search = config.search.map(item => { |
| | | item.hidden = item.Hide === 'true' |
| | | item.required = !item.hidden && item.required === 'true' |
| | | item.advanced = item.advanced === 'true' |
| | |
| | | } |
| | | } |
| | | |
| | | if (item.required) { |
| | | required = true |
| | | } |
| | | |
| | | if (item.type === 'text' || item.type === 'select') { |
| | | if (/,/.test(item.field)) { |
| | | item.field.split(',').forEach(field => { |
| | | keys.push(field.toLowerCase()) |
| | | }) |
| | | } else { |
| | | keys.push(item.field.toLowerCase()) |
| | | } |
| | | } else if (item.type === 'group') { |
| | | keys.push(item.field.toLowerCase()) |
| | | keys.push(item.datefield.toLowerCase()) |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | | config.$s_keys = keys |
| | | config.$s_req = required |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | sql = sql.replace(/\$@/ig, '/*') |
| | | sql = sql.replace(/@\$/ig, '*/') |
| | | sql = sql.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') |
| | | } else { |
| | | sql = sql.replace(/@\$|\$@/ig, '') |
| | | sql = sql.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | | } |
| | | |
| | | // 外联数据库替换 |
| | |
| | | |
| | | config.components = config.components.map(component => { |
| | | if (component.action) component.action = [] |
| | | if (component.search) component.search = [] |
| | | if (component.search) { |
| | | component.search = [] |
| | | component.$searches = [] |
| | | } |
| | | component.data = [] // 初始化数据为空 |
| | | |
| | | if (component.subtype === 'tablecard') { // 兼容 |
| | |
| | | } |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | component.setting.dataresource = component.setting.dataresource.replace(/\$@/ig, '/*') |
| | | component.setting.dataresource = component.setting.dataresource.replace(/@\$/ig, '*/') |
| | | _customScript = _customScript.replace(/\$@/ig, '/*') |
| | | _customScript = _customScript.replace(/@\$/ig, '*/') |
| | | component.setting.dataresource = component.setting.dataresource.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') |
| | | _customScript = _customScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') |
| | | } else { |
| | | component.setting.dataresource = component.setting.dataresource.replace(/@\$|\$@/ig, '') |
| | | _customScript = _customScript.replace(/@\$|\$@/ig, '') |
| | | component.setting.dataresource = component.setting.dataresource.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | | _customScript = _customScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | | } |
| | | |
| | | regs.forEach(cell => { |
| | |
| | | setTimeout(() => { |
| | | this.getMenuParam() |
| | | }, 50) |
| | | // Api.getAppVersion(tempId).then(() => { |
| | | // this.getMenuParam() |
| | | // }, () => { |
| | | // this.getMenuParam() |
| | | // }) |
| | | }) |
| | | } |
| | | |
| | |
| | | this.setState({loadingview: false, pages}) |
| | | } |
| | | |
| | | let setData = (item) => { |
| | | if (item.setting && item.setting.sync === 'true' && item.data) { |
| | | item.dataName = Utils.getuuid() |
| | | window.GLOB.SyncData.set(item.dataName, item.data) |
| | | } |
| | | } |
| | | |
| | | while (!over) { |
| | | let page = [] |
| | | let count = 0 |
| | |
| | | } |
| | | |
| | | if (item.wrap && item.wrap.printType === 'headerOrfooter') { // 页眉页脚 |
| | | setData(item) |
| | | page.push(item) |
| | | } else if (_pageover) { |
| | | return |
| | |
| | | } |
| | | if (count <= limit) { |
| | | _item.added = true |
| | | setData(item) |
| | | page.push(item) |
| | | } |
| | | } else if (!item.added) { |
| | | _item.added = true |
| | | setData(item) |
| | | page.push(item) |
| | | } |
| | | } else { |
| | |
| | | |
| | | } |
| | | |
| | | setData(item) |
| | | page.push(item) |
| | | } |
| | | _item.added = true |
| | | } else if (!item.added) { |
| | | _item.added = true |
| | | setData(item) |
| | | page.push(item) |
| | | } |
| | | } else if (!item.added && item.wrap && item.wrap.printHeight) { |
| | |
| | | } |
| | | if (count <= limit) { |
| | | _item.added = true |
| | | setData(item) |
| | | page.push(item) |
| | | } |
| | | } else if (!item.added) { |
| | | _item.added = true |
| | | setData(item) |
| | | page.push(item) |
| | | } |
| | | |
| | |
| | | if (item.type === 'bar' || item.type === 'line') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvBarAndLine config={item} initdata={item.data} mainSearch={[]} /> |
| | | <AntvBarAndLine config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'pie') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvPie config={item} initdata={item.data} mainSearch={[]} /> |
| | | <AntvPie config={item} /> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'scatter') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvScatter config={item} initdata={item.data} mainSearch={[]}/> |
| | | <AntvScatter config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'dashboard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvDashboard config={item} initdata={item.data} mainSearch={[]}/> |
| | | <AntvDashboard config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'card' && item.subtype === 'datacard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <DataCard config={item} initdata={item.data} mainSearch={[]} /> |
| | | <DataCard config={item} /> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'card' && item.subtype === 'propcard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <PropCard config={item} initdata={item.data} mainSearch={[]} /> |
| | | <PropCard config={item} /> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'card' && item.subtype === 'dualdatacard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <DoubleDataCard config={item} mainSearch={[]}/> |
| | | <DoubleDataCard config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'card' && item.subtype === 'tablecard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <TableCard config={item} initdata={item.data} mainSearch={[]}/> |
| | | <TableCard config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'table' && item.subtype === 'normaltable') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <NormalTable config={item} initdata={item.data} mainSearch={[]}/> |
| | | <NormalTable config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'code') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <SandBox config={item} initdata={item.data} mainSearch={[]}/> |
| | | <SandBox config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'balcony') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <Balcony config={item} initdata={item.data}/> |
| | | <Balcony config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'timeline') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <TimeLine config={item} initdata={item.data} mainSearch={[]}/> |
| | | <TimeLine config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'editor') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <BraftEditor config={item} initdata={item.data} mainSearch={[]}/> |
| | | <BraftEditor config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'antvG6') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvG6 config={item} initdata={item.data} mainSearch={[]}/> |
| | | <AntvG6 config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'antvX6') { |