| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { notification } from 'antd' |
| | | import moment from 'moment' |
| | | |
| | | import Api from '@/api' |
| | |
| | | _config.colsCtrls = null |
| | | } |
| | | |
| | | if (_config.setting.supModule && !BID) { |
| | | _config.setting.onload = 'false' |
| | | } |
| | | |
| | | this.setState({ |
| | | pageSize: setting.pageSize || 10, |
| | | BID: BID || '', |
| | |
| | | }, () => { |
| | | if (_config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | | this.loadmaindata() |
| | | this.loadData() |
| | | }, _config.setting.delay || 0) |
| | | } |
| | | }) |
| | |
| | | config.dataSource = config.dataSource.replace(/@SessionUid@/ig, `'${localStorage.getItem('SessionUid') || ''}'`) |
| | | config.dataSource = config.dataSource.replace(/@UserID@/ig, `'${sessionStorage.getItem('UserID') || ''}'`) |
| | | config.dataSource = config.dataSource.replace(/@Appkey@/ig, `'${window.GLOB.appkey || ''}'`) |
| | | config.dataSource = config.dataSource.replace(/@lang@/ig, `'${sessionStorage.getItem('lang')}'`) |
| | | |
| | | if (/\s/.test(config.dataSource)) { // 拼接别名 |
| | | config.dataSource = '(' + config.dataSource + ') tb' |
| | |
| | | |
| | | if (col.supField) { |
| | | names = [] |
| | | if (BData && BData[col.supField]) { |
| | | names = BData[col.supField].split(',') |
| | | let val = '' |
| | | if (BData) { |
| | | let field = col.supField.toLowerCase() |
| | | Object.keys(BData).forEach(key => { |
| | | if (key.toLowerCase() === field) { |
| | | val = BData[key] + '' |
| | | } |
| | | }) |
| | | } |
| | | |
| | | if (val) { |
| | | names = val.split(',') |
| | | |
| | | if (names.length > fields.length) { |
| | | names.length = fields.length |
| | |
| | | |
| | | /** |
| | | * @description 主表数据加载 |
| | | * @param { Boolean } reset 表格是否重置 |
| | | * @param { String } repage 表格是否重置页码 |
| | | */ |
| | | async loadmaindata (reset, repage) { |
| | | async loadData (reset, repage) { |
| | | const { setting, config, search, orderBy, BID, pageIndex, pageSize, BData } = this.state |
| | | |
| | | if (setting.supModule && !BID) { // BID 不存在时,不做查询 |
| | |
| | | total: 0 |
| | | }) |
| | | reset && MKEmitter.emit('resetTable', config.uuid, 'true') // 列表重置 |
| | | MKEmitter.emit('transferData' + setting.tableId, []) |
| | | |
| | | this.requestId = '' |
| | | return |
| | |
| | | */ |
| | | async loadLinedata (id, position) { |
| | | const { setting, config, search, orderBy, BID, pageIndex, pageSize, BData } = this.state |
| | | |
| | | if (config.forbidLine) { |
| | | this.reloadtable() |
| | | return |
| | | } |
| | | |
| | | let searches = fromJS(search).toJS() |
| | | if (config.setting.useMSearch) { // 主表搜索条件 |
| | |
| | | let result = await Api.genericInterface(param) |
| | | if (result.status) { |
| | | if (position === 'line_grid' && (!result.data || !result.data[0])) { |
| | | this.loadmaindata(true, 'false') |
| | | this.reloadIndex() |
| | | return |
| | | } |
| | | |
| | |
| | | * 含有初始不加载的页面,修改设置 |
| | | */ |
| | | refreshbysearch = (searches) => { |
| | | const { setting, BID } = this.state |
| | | |
| | | if (setting.supModule && !BID) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: setting.supModTip || window.GLOB.dict['sup_key_req'] || '需要上级主键值!', |
| | | duration: 5 |
| | | }) |
| | | this.setState({ |
| | | search: searches |
| | | }) |
| | | return |
| | | } |
| | | |
| | | this.setState({ |
| | | pageIndex: 1, |
| | | search: searches |
| | | }, () => { |
| | | this.loadmaindata(true, 'true') |
| | | this.loadData(true, 'true') |
| | | }) |
| | | } |
| | | |
| | |
| | | pageSize: pagination.pageSize, |
| | | orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : '' |
| | | }, () => { |
| | | this.loadmaindata() |
| | | this.loadData() |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 表格刷新 |
| | | */ |
| | | reloadtable = (btn) => { |
| | | if (!btn || btn.resetPageIndex !== 'false') { |
| | | this.setState({ |
| | | pageIndex: 1 |
| | | }, () => { |
| | | this.loadmaindata(true, 'true') |
| | | }) |
| | | } else { |
| | | this.loadmaindata(true, 'false') |
| | | } |
| | | reloadIndex = () => { |
| | | this.setState({ |
| | | pageIndex: 1 |
| | | }, () => { |
| | | this.loadData(true, 'true') |
| | | }) |
| | | } |
| | | |
| | | /** |
| | |
| | | if (config.uuid !== menuId) return |
| | | |
| | | if (!id) { |
| | | this.reloadtable() |
| | | this.reloadIndex() |
| | | } else if (config.forbidLine) { |
| | | this.loadData(true, 'false') |
| | | } else { |
| | | this.loadLinedata(id) |
| | | } |
| | |
| | | }, () => { |
| | | if (!setting.checkBid) { |
| | | setTimeout(() => { |
| | | this.loadmaindata(true, 'true') |
| | | this.loadData(true, 'true') |
| | | }, setting.delay || 0) |
| | | } |
| | | }) |
| | |
| | | |
| | | if (position === 'line' || position === 'line_grid') { |
| | | if (lines && lines.length === 1) { |
| | | this.loadLinedata(lines[0].$$uuid, position) |
| | | if (config.forbidLine) { |
| | | this.loadData(true, 'false') |
| | | } else { |
| | | this.loadLinedata(lines[0].$$uuid, position) |
| | | } |
| | | } else { |
| | | this.reloadtable(btn) |
| | | this.loadData(true, 'false') |
| | | } |
| | | } else if ((position === 'mainline' || position === 'popclose') && config.setting.supModule && BID) { // 刷新源组件时,附带刷新上级行与当前组件 |
| | | MKEmitter.emit('reloadData', config.setting.supModule, BID) |
| | | } else if (['mainline', 'maingrid', 'popclose'].includes(position) && config.setting.supModule) { |
| | | MKEmitter.emit('reloadData', config.setting.supModule, position === 'maingrid' ? '' : BID) |
| | | } else if (btn.resetPageIndex !== 'false') { |
| | | this.reloadIndex() |
| | | } else { |
| | | this.reloadtable(btn) |
| | | this.loadData(true, 'false') |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | if (config.$searchId !== searchId) return |
| | | |
| | | this.setState({pageIndex: 1}, () => { |
| | | this.reloadtable() |
| | | }) |
| | | this.reloadIndex() |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |