| | |
| | | import PropTypes from 'prop-types' |
| | | import {connect} from 'react-redux' |
| | | import { is, fromJS } from 'immutable' |
| | | import { notification, Spin, Tabs, Icon, Switch, Row, Col } from 'antd' |
| | | import { notification, Spin, Tabs, Switch, Row, Col } from 'antd' |
| | | |
| | | import Api from '@/api' |
| | | import zhCN from '@/locales/zh-CN/main.js' |
| | |
| | | import { updateCommonTable } from '@/utils/utils-update.js' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import asyncSpinComponent from '@/utils/asyncSpinComponent' |
| | | import MkIcon from '@/components/mk-icon' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import NotFount from '@/components/404' |
| | | import './index.scss' |
| | |
| | | const CardComponent = asyncSpinComponent(() => import('@/tabviews/zshare/cardcomponent')) |
| | | const ChartComponent = asyncSpinComponent(() => import('@/tabviews/zshare/chartcomponent')) |
| | | const PagemsgComponent = asyncComponent(() => import('@/tabviews/zshare/pageMessage')) |
| | | const AutoMatic = asyncComponent(() => import('@/tabviews/zshare/automatic')) |
| | | |
| | | const { TabPane } = Tabs |
| | | |
| | |
| | | statFValue: [], // 合计值 |
| | | absFields: [], // 绝对值字段 |
| | | loadCustomApi: true, // 加载外部资源 |
| | | hasReqFields: false |
| | | hasReqFields: false, |
| | | autoMatic: null |
| | | } |
| | | |
| | | /** |
| | | * @description 获取页面配置信息 |
| | | */ |
| | | async loadconfig () { |
| | | const { permAction, permMenus, param, MenuName } = this.props |
| | | const { permAction, permMenus, param, MenuName, MenuID } = this.props |
| | | |
| | | let _param = { |
| | | func: 'sPC_Get_LongParam', |
| | | MenuID: this.props.MenuID |
| | | MenuID: MenuID |
| | | } |
| | | let result = await Api.getCacheConfig(_param) |
| | | |
| | |
| | | |
| | | try { // 配置信息解析 |
| | | config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) |
| | | config.MenuID = this.props.MenuID |
| | | config.MenuID = MenuID |
| | | config.MenuName = MenuName |
| | | config.setting.MenuName = MenuName |
| | | config.setting.$name = MenuName |
| | |
| | | if (this.props.menuType !== 'HS') { |
| | | config.action = config.action.filter(item => permAction[item.uuid]) |
| | | config.tabgroups.forEach(group => { |
| | | group.sublist = group.sublist.filter(tab => permAction[tab.linkTab]) |
| | | group.sublist = group.sublist.filter(tab => { |
| | | if (tab.supMenu === 'mainTable') { |
| | | tab.supMenu = MenuID |
| | | } |
| | | return permAction[tab.linkTab] |
| | | }) |
| | | }) |
| | | } else { |
| | | config.tabgroups.forEach(group => { |
| | | group.sublist = group.sublist.map(tab => { |
| | | if (tab.supMenu === 'mainTable') { |
| | | tab.supMenu = MenuID |
| | | } |
| | | return tab |
| | | }) |
| | | }) |
| | | } |
| | | // 去除空行标签 |
| | |
| | | config.setting.selected = 'false' |
| | | } |
| | | |
| | | let autoMatic = null |
| | | if (config.autoMatic && config.autoMatic.enable === 'true') { |
| | | _actions.forEach(item => { |
| | | if (item.uuid === config.autoMatic.action && (['pop', 'prompt', 'exec'].includes(item.OpenType) || (item.OpenType === 'funcbutton' && item.funcType === 'print'))) { |
| | | autoMatic = config.autoMatic |
| | | autoMatic.OpenType = item.execMode || item.OpenType |
| | | config.setting.selected = 'false' |
| | | item.autoMatic = true |
| | | } |
| | | }) |
| | | } |
| | | |
| | | this.setState({ |
| | | pageSize: config.setting.pageSize || 10, |
| | | loadingview: false, |
| | | absFields, |
| | | autoMatic, |
| | | chartId, |
| | | config, |
| | | statFields, |
| | |
| | | } |
| | | |
| | | loadData = () => { |
| | | const { setting, search, BIDs, loadCustomApi, hasReqFields } = this.state |
| | | const { MenuID } = this.props |
| | | const { setting, search, loadCustomApi, hasReqFields, ContainerId } = this.state |
| | | |
| | | this.setState({ |
| | | selectedData: [], |
| | | BIDs: { |
| | | ...BIDs, |
| | | mainTable: '', |
| | | mainTabledata: '' |
| | | } |
| | | selectedData: [] |
| | | }) |
| | | MKEmitter.emit('changeTableLine', ContainerId, MenuID, '', '') |
| | | |
| | | if (hasReqFields) { |
| | | let requireFields = search.filter(item => item.required && item.value === '') |
| | |
| | | * @description 主表数据加载 |
| | | */ |
| | | async loadmaindata () { |
| | | const { setting, arr_field, search, orderBy, BID, pageIndex, pageSize, absFields } = this.state |
| | | const { setting, arr_field, search, orderBy, BID, pageIndex, pageSize, absFields, autoMatic } = this.state |
| | | |
| | | this.setState({ |
| | | loading: true |
| | |
| | | loading: false, |
| | | pickup: false |
| | | }) |
| | | |
| | | if (autoMatic) { |
| | | if (result.data && result.data.length > 0) { |
| | | MKEmitter.emit('autoGetData', this.props.MenuID) |
| | | } else { |
| | | MKEmitter.emit('autoMaticOver', this.props.MenuID) |
| | | } |
| | | } |
| | | } else { |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | if (autoMatic) { |
| | | MKEmitter.emit('autoMaticError', this.props.MenuID) |
| | | } |
| | | notification.error({ |
| | | top: 92, |
| | | message: result.message, |
| | |
| | | this.loadData() |
| | | }) |
| | | } else { |
| | | MKEmitter.emit('resetTable', this.props.MenuID + 'mainTable') // 列表重置 |
| | | MKEmitter.emit('resetTable', this.props.MenuID) // 列表重置 |
| | | this.setState({ |
| | | pageIndex: 1, |
| | | search: searches |
| | |
| | | * @description 表格条件改变时重置数据(分页或排序) |
| | | */ |
| | | refreshbytable = (pagination, filters, sorter) => { |
| | | if (!sorter) { |
| | | this.setState({ |
| | | pageIndex: pagination.pageIndex |
| | | }, () => { |
| | | this.loadData() |
| | | }) |
| | | return |
| | | } |
| | | |
| | | if (sorter.order) { |
| | | let _chg = { |
| | | ascend: 'asc', |
| | |
| | | */ |
| | | reloadtable = (btn) => { |
| | | if (!btn || btn.resetPageIndex !== 'false') { |
| | | MKEmitter.emit('resetTable', this.props.MenuID + 'mainTable') // 列表重置 |
| | | MKEmitter.emit('resetTable', this.props.MenuID) // 列表重置 |
| | | this.setState({ |
| | | pageIndex: 1 |
| | | }, () => { |
| | | this.loadData() |
| | | }) |
| | | } else { |
| | | MKEmitter.emit('resetTable', this.props.MenuID + 'mainTable', 'false') // 列表重置 |
| | | MKEmitter.emit('resetTable', this.props.MenuID, 'false') // 列表重置 |
| | | this.loadData() |
| | | } |
| | | } |
| | |
| | | */ |
| | | changeSelectedData = (selectedData) => { |
| | | this.setState({selectedData}) |
| | | } |
| | | |
| | | /** |
| | | * @description 表格Id变化 |
| | | */ |
| | | handleTableId = (type, id, data) => { |
| | | const { BIDs } = this.state |
| | | |
| | | this.setState({ |
| | | BIDs: { |
| | | ...BIDs, |
| | | [type]: id, |
| | | [type + 'data']: data |
| | | } |
| | | }) |
| | | } |
| | | |
| | | /** |
| | |
| | | this.setShortcut() |
| | | } |
| | | |
| | | changeTableLine = (ContainerId, tableId, id, data) => { |
| | | if (this.state.ContainerId !== ContainerId) return |
| | | |
| | | this.setState({ |
| | | BIDs: {...this.state.BIDs, [tableId]: id, [tableId + 'data']: data} |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 按钮执行完成后页面刷新 |
| | | * @param {*} menuId // 菜单Id |
| | | * @param {*} position // 刷新位置 |
| | | * @param {*} btn // 执行的按钮 |
| | | */ |
| | | refreshByButtonResult = (menuId, position, btn) => { |
| | | refreshByButtonResult = (menuId, position, btn, id, lines) => { |
| | | const { MenuID } = this.props |
| | | |
| | | if (MenuID !== menuId) return |
| | | |
| | | this.reloadtable(btn) |
| | | if (position === 'line' && lines && lines.length === 1) { |
| | | this.loadmainLinedata(lines[0].$$uuid) |
| | | } else { |
| | | this.reloadtable(btn) |
| | | } |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | | MKEmitter.addListener('reloadMenuView', this.reloadMenuView) |
| | | MKEmitter.addListener('changeTableLine', this.changeTableLine) |
| | | MKEmitter.addListener('resetActiveMenu', this.resetActiveMenu) |
| | | MKEmitter.addListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) |
| | |
| | | document.onkeydown = () => {} |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('reloadMenuView', this.reloadMenuView) |
| | | MKEmitter.removeListener('changeTableLine', this.changeTableLine) |
| | | MKEmitter.removeListener('resetActiveMenu', this.resetActiveMenu) |
| | | MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) |
| | | } |
| | | |
| | | render() { |
| | | const { menuType } = this.props |
| | | const { BID, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, pickup, config, chartId, search, selectedData, shortcuts } = this.state |
| | | const { menuType, MenuID } = this.props |
| | | const { BID, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, pickup, config, chartId, search, selectedData, shortcuts, autoMatic } = this.state |
| | | |
| | | return ( |
| | | <div className="commontable" id={this.state.ContainerId}> |
| | |
| | | {/* 视图组 */} |
| | | {!config.expand ? <Tabs activeKey={chartId} onChange={this.changeChart}> |
| | | {config.charts.map(item => ( |
| | | <TabPane tab={<Icon type={item.icon} />} key={item.uuid}></TabPane> |
| | | <TabPane tab={<MkIcon type={item.icon} />} key={item.uuid}></TabPane> |
| | | ))} |
| | | </Tabs> : null} |
| | | {config.charts.map(item => { |
| | |
| | | actions={actions} |
| | | columns={columns} |
| | | dict={this.state.dict} |
| | | MenuID={this.props.MenuID} |
| | | MenuID={MenuID} |
| | | selectedData={selectedData} |
| | | ContainerId={this.state.ContainerId} |
| | | /> |
| | |
| | | <Switch title="收起" className="main-pickup" checkedChildren="开" unCheckedChildren="关" checked={pickup} onChange={this.pickupChange} /> : null |
| | | } |
| | | <MainTable |
| | | tableId="mainTable" |
| | | MenuID={MenuID} |
| | | tableId={MenuID} |
| | | pickup={pickup} |
| | | setting={setting} |
| | | columns={columns} |
| | |
| | | dict={this.state.dict} |
| | | data={this.state.data} |
| | | total={this.state.total} |
| | | MenuID={this.props.MenuID} |
| | | loading={this.state.loading} |
| | | statFValue={this.state.statFValue} |
| | | ContainerId={this.state.ContainerId} |
| | | refreshdata={this.refreshbytable} |
| | | handleTableId={this.handleTableId} |
| | | chgSelectData={this.changeSelectedData} |
| | | /> |
| | | </div> |
| | |
| | | <CardComponent |
| | | BID={BID} |
| | | plot={item} |
| | | MenuID={MenuID} |
| | | config={config} |
| | | tableId={MenuID} |
| | | columns={columns} |
| | | tableId="mainTable" |
| | | data={this.state.data} |
| | | MenuID={this.props.MenuID} |
| | | loading={this.state.loading} |
| | | ContainerId={this.state.ContainerId} |
| | | handleTableId={this.handleTableId} |
| | | /> |
| | | </Col> |
| | | ) |
| | |
| | | return ( |
| | | <TabPane tab={ |
| | | <span id={_tab.uuid}> |
| | | {_tab.icon ? <Icon type={_tab.icon} /> : null} |
| | | {_tab.icon ? <MkIcon type={_tab.icon} /> : null} |
| | | {_tab.label} |
| | | </span> |
| | | } key={_tab.uuid}> |
| | | <SubTable |
| | | Tab={_tab} |
| | | SupMenuID={MenuID} |
| | | MenuID={_tab.linkTab} |
| | | mainSearch={_tab.searchPass === 'true' ? search : null} |
| | | SupMenuID={this.props.MenuID} |
| | | ContainerId={this.state.ContainerId} |
| | | BID={this.state.BIDs[_tab.supMenu] || ''} |
| | | BData={this.state.BIDs[_tab.supMenu + 'data'] || ''} |
| | | handleTableId={this.handleTableId} |
| | | /> |
| | | </TabPane> |
| | | ) |
| | | })} |
| | | </Tabs>)) |
| | | } |
| | | {menuType !== 'HS' && autoMatic ? <AutoMatic autoMatic={autoMatic} config={config} /> : null} |
| | | {menuType !== 'HS' && window.GLOB.systemType !== 'production' ? <PagemsgComponent menu={{MenuName: this.props.MenuName, MenuNo: this.props.MenuNo}} config={config} dict={this.state.dict} /> : null} |
| | | {menuType !== 'HS' && shortcuts ? <SettingComponent config={config} dict={this.state.dict} shortcuts={shortcuts} permAction={this.props.permAction}/> : null} |
| | | {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} |