File was renamed from src/tabviews/managetable/secretKeyTable/index.jsx |
| | |
| | | import options from '@/store/options.js' |
| | | import { buttonConfig, tabConfig, refCodes } from './config' |
| | | |
| | | import SubTable from '@/tabviews/zshare/normalTable' |
| | | import asyncSpinComponent from '@/utils/asyncSpinComponent' |
| | | import SubAction from './actionList' |
| | | |
| | | import './index.scss' |
| | | |
| | | const SubTable = asyncSpinComponent(() => import('@/tabviews/zshare/normalTable')) |
| | | |
| | | class VerupSubTabViewTable extends Component { |
| | | static propTpyes = { |
| | |
| | | MenuID: PropTypes.string, // 菜单Id |
| | | SupMenuID: PropTypes.string, // 上级菜单Id |
| | | ContainerId: PropTypes.any, // 三级菜单Container(html) ID |
| | | handleTableId: PropTypes.func, // 控制表格数据切换时,更新在主表中的id |
| | | handleMainTable: PropTypes.func, // 刷新主表 |
| | | refreshtabs:PropTypes.any |
| | | } |
| | |
| | | columns: null, // 显示列 |
| | | setting: null, // 页面全局设置:数据源、按钮及显示列固定、主键等 |
| | | data: null, // 列表数据集 |
| | | selectedData: [], // 已选表格数据 |
| | | resetTable: false, // 表格重置,值在true与false之间切换,切换时表格重置 |
| | | loading: false, // 列表数据加载中 |
| | | visible: false, // 弹框显示隐藏控制 |
| | | pickup: false, // 子表数据隐藏显示切换 |
| | |
| | | */ |
| | | UNSAFE_componentWillReceiveProps(nextProps) { |
| | | if (this.state.config && this.props.Tab.supMenu && !is(fromJS(this.props.BID), fromJS(nextProps.BID))) { |
| | | this.refs.subTable.resetTable() |
| | | this.loadmaindata(nextProps.BID, 'refresh') |
| | | this.setState({ |
| | | pageIndex: 1, |
| | | selectedData: [], |
| | | resetTable: !this.state.resetTable, |
| | | }, () => { |
| | | this.loadmaindata(nextProps.BID, 'refresh') |
| | | }) |
| | | } else if (this.state.config && nextProps.refreshtabs && nextProps.refreshtabs.includes(this.props.Tab.uuid)) { |
| | | |
| | | this.reloadtable() |
| | |
| | | } |
| | | }) |
| | | |
| | | config.setting.tabType = 'sub' |
| | | |
| | | this.setState({ |
| | | config: config, |
| | | setting: config.setting, |
| | |
| | | * @description 子表数据加载 |
| | | */ |
| | | async loadmaindata (bid, type) { |
| | | const { setting } = this.state |
| | | let param = '' |
| | | let _BID = this.props.BID |
| | | |
| | | if (type === 'refresh') { |
| | |
| | | data: [], |
| | | loading: false |
| | | }) |
| | | |
| | | return |
| | | } |
| | | } |
| | | |
| | | if (setting.interType !== 'inner' || (setting.interType === 'inner' && setting.innerFunc)) { |
| | | param = this.getCustomParam(_BID) |
| | | } else { |
| | | param = this.getDefaultParam(_BID) |
| | | } |
| | | |
| | | this.handleTableId() |
| | | |
| | | let param = this.getCustomParam(_BID) |
| | | let result = await Api.getLocalConfig(param) |
| | | |
| | | if (result.status) { |
| | |
| | | }) |
| | | } |
| | | |
| | | this.setState({data}) |
| | | this.setState({data: data, selectedData: []}) |
| | | } |
| | | |
| | | /** |
| | | * @description 表格刷新 |
| | | */ |
| | | reloadtable = () => { |
| | | this.refs.subTable.resetTable() |
| | | this.setState({ |
| | | loading: true, |
| | | selectedData: [], |
| | | resetTable: !this.state.resetTable |
| | | }, () => { |
| | | this.loadmaindata() |
| | | }) |
| | |
| | | */ |
| | | reloadview = () => { |
| | | this.setState({ |
| | | config: null, |
| | | actions: null, |
| | | columns: null, |
| | | setting: null, |
| | | data: null, |
| | | loading: false, |
| | | config: null, actions: null, columns: null, setting: null, data: null, loading: false, selectedData: [] |
| | | }, () => { |
| | | this.loadconfig() |
| | | }) |
| | |
| | | /** |
| | | * @description 按钮操作完成后(成功或失败),页面刷新,重置页码及选择项 |
| | | */ |
| | | refreshbyaction = (btn, type) => { |
| | | if (btn.execSuccess === 'grid' && type === 'success') { |
| | | refreshbyaction = (position) => { |
| | | if (position === 'grid') { |
| | | this.reloadtable() |
| | | } else if (btn.execError === 'grid' && type === 'error') { |
| | | this.reloadtable() |
| | | } else if (btn.execSuccess === 'view' && type === 'success') { |
| | | this.reloadview() |
| | | } else if (btn.execError === 'view' && type === 'error') { |
| | | } else if (position === 'view') { |
| | | this.reloadview() |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 获取表格选择项 |
| | | * @description 表格选择项切换 |
| | | */ |
| | | gettableselected = () => { |
| | | let data = [] |
| | | this.refs.subTable.state.selectedRowKeys.forEach(item => { |
| | | data.push(this.refs.subTable.props.data[item]) |
| | | }) |
| | | return data |
| | | } |
| | | |
| | | /** |
| | | * @description 表格Id变化 |
| | | */ |
| | | handleTableId = (type = this.props.Tab.uuid, id = '', data = '') => { |
| | | this.props.handleTableId(type, id, data) |
| | | changeSelectedData = (selectedData) => { |
| | | this.setState({selectedData}) |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { // handleMainTable 函数判断时不相等 |
| | | return !is(fromJS({...this.props, handleMainTable: '', handleTableId: ''}), fromJS({...nextProps, handleMainTable: '', handleTableId: ''})) || !is(fromJS(this.state), fromJS(nextState)) |
| | | return !is(fromJS({...this.props, handleMainTable: ''}), fromJS({...nextProps, handleMainTable: ''})) || !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { setting, actions, columns, pickup, config } = this.state |
| | | const { setting, actions, columns, pickup, config, selectedData } = this.state |
| | | |
| | | return ( |
| | | <div className="subtable" id={'subtable' + this.props.MenuID}> |
| | | <div className="sub-action"> |
| | | <SubAction |
| | | ref="subButton" |
| | | type="sub" |
| | | setting={setting} |
| | | actions={actions} |
| | | Tab={this.props.Tab} |
| | | BID={this.props.BID} |
| | | datalist={this.state.data} |
| | | dict={this.state.dict} |
| | | selectedData={selectedData} |
| | | MenuID={this.props.SupMenuID} |
| | | logcolumns={[]} |
| | | refreshdata={this.refreshbyaction} |
| | | ContainerId={this.props.ContainerId} |
| | | getexceloutparam={this.getexceloutparam} |
| | | gettableselected={this.gettableselected} |
| | | /> |
| | | </div> |
| | | <div className="subtable-box"> |
| | |
| | | <Switch title="收起" className="subtable-pickup" checkedChildren="开" unCheckedChildren="关" defaultChecked={pickup} onChange={this.pickupChange} /> : null |
| | | } |
| | | <SubTable |
| | | ref="subTable" |
| | | menuType="HS" |
| | | tableId={this.props.Tab.uuid} |
| | | pickup={pickup} |
| | | config={config} |
| | | setting={setting} |
| | | columns={columns} |
| | | pagination={false} |
| | | dict={this.state.dict} |
| | | data={this.state.data} |
| | | MenuID={this.props.MenuID} |
| | | loading={this.state.loading} |
| | | refreshdata={this.refreshbytable} |
| | | buttonTrigger={() => {}} |
| | | handleTableId={this.handleTableId} |
| | | handleTableId={() => {}} |
| | | chgSelectData={this.changeSelectedData} |
| | | /> |
| | | </div> |
| | | </div> |