| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { BackTop, notification, Spin, Tabs, Icon} from 'antd' |
| | | import { BackTop, notification, Spin, Tabs, Icon, Card, Switch} from 'antd' |
| | | import moment from 'moment' |
| | | import Api from '@/api' |
| | | import MainSearch from './mainSearch' |
| | |
| | | orderType: 'asc', |
| | | search: '', |
| | | configMap: {}, |
| | | BIDs: '' |
| | | BIDs: {}, |
| | | setsingle: false, |
| | | pickup: false, |
| | | isLinkMain: false |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | // 过滤工具栏按钮(未经过权限过滤) |
| | | let _actions = config.action.filter(item => item.position === 'toolbar') |
| | | let _tab = config.tabs.filter(tab => tab.supMenu === 'mainTable') |
| | | |
| | | this.setState({ |
| | | loadingview: false, |
| | |
| | | actions: _actions, |
| | | columns: _columns, |
| | | tabviews: config.tabs, |
| | | isLinkMain: _tab.length > 0, |
| | | arr_field: _arrField.join(','), |
| | | search: Utils.initMainSearch(config.search), // 搜索条件初始化(含有时间格式,需要转化) |
| | | loading: true |
| | | }, () => { |
| | | this.improveSearch() |
| | | console.log(this.state.tabviews) |
| | | |
| | | if (config.setting.onload !== 'false') { |
| | | this.loadmaindata() |
| | | } |
| | |
| | | |
| | | |
| | | async loadmaindata () { |
| | | const { setting } = this.state |
| | | const { setting, BIDs } = this.state |
| | | let param = '' |
| | | |
| | | if (setting.interType !== 'inner' || (setting.interType === 'inner' && setting.innerFunc)) { |
| | |
| | | return item |
| | | }), |
| | | total: result.total, |
| | | loading: false |
| | | loading: false, |
| | | BIDs: { |
| | | ...BIDs, |
| | | mainTable: '' |
| | | } |
| | | }) |
| | | } else { |
| | | this.setState({ |
| | |
| | | orderColumn: '', |
| | | orderType: 'asc', |
| | | search: '', |
| | | configMap: {} |
| | | configMap: {}, |
| | | BIDs: {}, |
| | | setsingle: false, |
| | | pickup: false, |
| | | isLinkMain: false |
| | | }, () => { |
| | | this.loadconfig() |
| | | }) |
| | |
| | | }) |
| | | } |
| | | |
| | | checkChange = () => { |
| | | const { setsingle, BIDs } = this.state |
| | | |
| | | let _BIDs = JSON.parse(JSON.stringify(BIDs)) |
| | | _BIDs.mainTable = '' |
| | | |
| | | this.setState({ |
| | | setsingle: !setsingle, |
| | | pickup: false, |
| | | BIDs: _BIDs |
| | | }) |
| | | } |
| | | |
| | | pickupChange = () => { |
| | | const { pickup } = this.state |
| | | this.setState({ |
| | | pickup: !pickup |
| | | }) |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | // 组件加载时,获取菜单数据 |
| | | this.loadconfig() |
| | |
| | | return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | /** |
| | | * @description 组件销毁,清除state更新 |
| | | */ |
| | | componentWillUnmount () { |
| | | this.setState = (state, callback) => { |
| | | return |
| | | } |
| | | } |
| | | |
| | | render() { |
| | | const { setting, searchlist, actions, columns, loadingview, viewlost, tabviews } = this.state |
| | | const { setting, searchlist, actions, columns, loadingview, viewlost, tabviews, setsingle, pickup, isLinkMain } = this.state |
| | | |
| | | return ( |
| | | <div className="commontable" id={'commontable' + this.props.MenuID}> |
| | | {loadingview && <Spin size="large" />} |
| | | {searchlist && searchlist.length > 0 ? |
| | | <MainSearch |
| | | refreshdata={this.refreshbysearch} |
| | | searchlist={searchlist} |
| | | dict={this.state.dict} |
| | | searchlist={searchlist} |
| | | refreshdata={this.refreshbysearch} |
| | | /> : null |
| | | } |
| | | {actions && setting.onload !== 'false' && |
| | | {actions && setting.onload !== 'false' ? |
| | | <MainAction |
| | | ref="mainButton" |
| | | MenuID={this.props.MenuID} |
| | | setting={setting} |
| | | refreshdata={this.refreshbyaction} |
| | | gettableselected={this.gettableselected} |
| | | actions={actions} |
| | | dict={this.state.dict} |
| | | /> |
| | | } |
| | | {columns && setting.onload !== 'false' && |
| | | <MainTable |
| | | ref="mainTable" |
| | | dict={this.state.dict} |
| | | MenuID={this.props.MenuID} |
| | | setting={setting} |
| | | columns={columns} |
| | | data={this.state.data} |
| | | total={this.state.total} |
| | | loading={this.state.loading} |
| | | refreshdata={this.refreshbytable} |
| | | buttonTrigger={this.buttonTrigger} |
| | | handleTableId={this.handleTableId} |
| | | /> |
| | | refreshdata={this.refreshbyaction} |
| | | gettableselected={this.gettableselected} |
| | | /> : null |
| | | } |
| | | {columns && setting.onload !== 'false' ? |
| | | <div className="main-table-box"> |
| | | {isLinkMain && setting.tableType === 'checkbox' ? <Switch title="单选切换" checkedChildren="多" unCheckedChildren="单" defaultChecked={setsingle} onChange={this.checkChange} /> : null} |
| | | {isLinkMain && this.state.BIDs.mainTable && (setting.tableType === 'radio' || setsingle) ? <Switch title="收起" checkedChildren="关" unCheckedChildren="开" defaultChecked={pickup} onChange={this.pickupChange} /> : null} |
| | | <MainTable |
| | | ref="mainTable" |
| | | pickup={pickup} |
| | | setting={setting} |
| | | columns={columns} |
| | | setsingle={setsingle} |
| | | dict={this.state.dict} |
| | | data={this.state.data} |
| | | total={this.state.total} |
| | | MenuID={this.props.MenuID} |
| | | loading={this.state.loading} |
| | | refreshdata={this.refreshbytable} |
| | | buttonTrigger={this.buttonTrigger} |
| | | handleTableId={this.handleTableId} |
| | | /> |
| | | </div> : null |
| | | } |
| | | {setting && setting.onload !== 'false' && setting.tabshow !== 'vertical' && tabviews && tabviews.length > 0 && |
| | | <Tabs defaultActiveKey="0" tabPosition="top"> |
| | |
| | | })} |
| | | </Tabs> |
| | | } |
| | | {setting && setting.onload !== 'false' && setting.tabshow === 'vertical' && tabviews && tabviews.length > 0 && |
| | | tabviews.map((_tab, index) => { |
| | | return !_tab.supMenu || (_tab.supMenu && this.state.BIDs[_tab.supMenu]) ? |
| | | <Card bordered={false} title={ |
| | | <span> |
| | | {_tab.icon ? <Icon type={_tab.icon} /> : null} |
| | | {_tab.label} |
| | | </span> |
| | | } key={`${index}`}> |
| | | {_tab.type === 'SubTable' ? <SubTable SupMenuID={this.props.MenuID} MenuID={_tab.linkTab} Tab={_tab} BID={this.state.BIDs[_tab.supMenu] || ''} /> : null} |
| | | </Card> : null |
| | | }) |
| | | } |
| | | <BackTop> |
| | | <div className="ant-back-top"> |
| | | <div className="ant-back-top-content"> |