| | |
| | | import {Component} from 'react' |
| | | import { Component } from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { notification, Modal } from 'antd' |
| | | |
| | | import Api from '@/api' |
| | | import UtilsDM from '@/utils/utils-datamanage.js' |
| | |
| | | } |
| | | |
| | | loading = false |
| | | loadTimer = null |
| | | |
| | | state = { |
| | | BID: '' |
| | |
| | | } |
| | | |
| | | if (config.setting.onload !== 'false') { |
| | | setTimeout(() => { |
| | | this.loadData() |
| | | }, config.setting.delay) |
| | | this.loadData() |
| | | } else { |
| | | MKEmitter.addListener('initFinish', this.initFinish) |
| | | } |
| | | |
| | | if (config.setting.useMSearch) { |
| | | MKEmitter.addListener('searchRefresh', this.searchRefresh) |
| | | } |
| | | |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | |
| | | this.timer && this.timer.stop() |
| | | MKEmitter.removeListener('initFinish', this.initFinish) |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('searchRefresh', this.searchRefresh) |
| | | MKEmitter.removeListener('resetSelectLine', this.resetParentParam) |
| | | } |
| | | |
| | | searchRefresh = (searchId) => { |
| | | const { config } = this.props |
| | | |
| | | if (config.$searchId !== searchId) return |
| | | |
| | | this.loadData() |
| | | } |
| | | |
| | | initFinish = (MenuID) => { |
| | |
| | | if (config.MenuID !== MenuID) return |
| | | |
| | | if (config.setting.onload === 'false') { |
| | | setTimeout(() => { |
| | | this.loadData() |
| | | }, config.setting.delay) |
| | | this.loadData() |
| | | } |
| | | } |
| | | |
| | |
| | | this.loadData() |
| | | } |
| | | |
| | | async loadData () { |
| | | loadData = () => { |
| | | const { config } = this.props |
| | | |
| | | this.loadTimer && clearTimeout(this.loadTimer) |
| | | |
| | | this.loadTimer = setTimeout(() => { |
| | | this.execLoadData() |
| | | }, config.setting.delay) |
| | | } |
| | | |
| | | async execLoadData () { |
| | | const { config } = this.props |
| | | const { BID } = this.state |
| | | |
| | | if (config.setting.supModule && !BID) { |
| | | MKEmitter.emit('mkPublicData', config.uuid, { $$empty: true, $$uuid: '' }) |
| | | MKEmitter.emit('resetSelectLine', config.uuid, '', { $$empty: true, $$uuid: '' }) |
| | | setTimeout(() => { |
| | | MKEmitter.emit('mkPublicData', config.uuid, { $$empty: true, $$uuid: '' }) |
| | | MKEmitter.emit('resetSelectLine', config.uuid, '', { $$empty: true, $$uuid: '' }) |
| | | }, 20) |
| | | this.loading = false |
| | | return |
| | | } |
| | | |
| | | if (this.loading) return |
| | | |
| | | let searches = [] |
| | | if (config.setting.useMSearch) { |
| | | searches = window.GLOB.SearchBox.get(config.$searchId) || [] |
| | | |
| | | if (window.GLOB.SearchBox.has(config.$searchId + 'required') && searches.filter(item => item.required && item.value === '').length > 0) { |
| | | return |
| | | } |
| | | } |
| | | |
| | | this.loading = true |
| | | |
| | | let param = UtilsDM.getQueryDataParams(config.setting, config.columns.map(col => col.field).join(','), [], config.setting.order, 1, 1, BID) |
| | | let param = UtilsDM.getQueryDataParams(config.setting, searches, config.setting.order, 1, 1, BID) |
| | | |
| | | let result = await Api.genericInterface(param) |
| | | if (result.status) { |
| | |
| | | MKEmitter.emit('interFinish', config.MenuID, config.uuid) |
| | | } |
| | | |
| | | if (result.message) { |
| | | if (result.ErrCode === 'Y') { |
| | | Modal.success({ |
| | | title: result.message |
| | | }) |
| | | } else if (result.ErrCode === 'S') { |
| | | notification.success({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 2 |
| | | }) |
| | | } |
| | | } |
| | | UtilsDM.querySuccess(result) |
| | | } else { |
| | | this.loading = false |
| | | this.timer && this.timer.stop() |
| | | |
| | | if (!result.message) return |
| | | if (result.ErrCode === 'N') { |
| | | Modal.error({ |
| | | title: result.message, |
| | | }) |
| | | } else if (result.ErrCode !== '-2') { |
| | | notification.error({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 10 |
| | | }) |
| | | } |
| | | |
| | | if (config.setting.loadlevel === 'init') { |
| | | MKEmitter.emit('interFinish', config.MenuID, config.uuid) |
| | | } |
| | | |
| | | UtilsDM.queryFail(result) |
| | | } |
| | | } |
| | | |