| | |
| | | MenuID: PropTypes.string, // 菜单Id |
| | | SupMenuID: PropTypes.string, // 上级菜单Id |
| | | ContainerId: PropTypes.any, // 三级菜单Container(html) ID |
| | | handleTableId: PropTypes.func, // 控制表格数据切换时,更新在主表中的id |
| | | handleMainTable: PropTypes.func, // 刷新主表 |
| | | refreshtabs:PropTypes.any |
| | | } |
| | |
| | | popData: false, // 弹框页面,所选的表格数据 |
| | | visible: false, // 弹框显示隐藏控制 |
| | | pickup: false, // 子表数据隐藏显示切换 |
| | | BID: '', |
| | | BData: '' |
| | | } |
| | | |
| | | /** |
| | | * @description 上级菜单id变化时,刷新数据 |
| | | */ |
| | | UNSAFE_componentWillReceiveProps(nextProps) { |
| | | if (this.state.config && this.props.Tab.supMenu && !is(fromJS(this.props.BID), fromJS(nextProps.BID))) { |
| | | this.setState({ |
| | | pageIndex: 1, |
| | | selectedData: [] |
| | | }, () => { |
| | | MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 列表重置 |
| | | this.loadmaindata(nextProps.BID, 'refresh') |
| | | }) |
| | | } else if (this.state.config && nextProps.refreshtabs && nextProps.refreshtabs.includes(this.props.Tab.uuid)) { |
| | | |
| | | if (this.state.config && nextProps.refreshtabs && nextProps.refreshtabs.includes(this.props.Tab.uuid)) { |
| | | this.reloadtable() |
| | | } |
| | | } |
| | |
| | | * @description 获取页面配置信息 |
| | | */ |
| | | async loadconfig () { |
| | | const { Tab, BID } = this.props |
| | | const { Tab, BID, BData } = this.props |
| | | |
| | | let config = tabConfig[this.props.MenuID] |
| | | |
| | |
| | | } |
| | | |
| | | this.setState({ |
| | | BID: BID || '', |
| | | BData: BData || '', |
| | | config: config, |
| | | setting: config.setting, |
| | | searchlist: config.search, |
| | |
| | | /** |
| | | * @description 子表数据加载 |
| | | */ |
| | | async loadmaindata (bid, type) { |
| | | const { setting } = this.state |
| | | async loadmaindata (type) { |
| | | const { setting, BID } = this.state |
| | | let param = '' |
| | | let _BID = this.props.BID |
| | | |
| | | if (type === 'refresh') { |
| | | _BID = bid |
| | | if (!bid) { // 主表ID不存在时,不查询子表 |
| | | if (!BID) { // 主表ID不存在时,不查询子表 |
| | | this.setState({ |
| | | data: [], |
| | | total: 0, |
| | |
| | | } |
| | | |
| | | if (setting.interType === 'system') { |
| | | param = this.getDefaultParam(_BID) |
| | | param = this.getDefaultParam(BID) |
| | | } else { |
| | | param = this.getCustomParam(_BID) |
| | | param = this.getCustomParam(BID) |
| | | } |
| | | |
| | | this.handleTableId() |
| | | |
| | | let result = await Api.genericInterface(param) |
| | | if (result.status) { |
| | |
| | | data: result.data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[setting.primaryKey] || '' |
| | | item.$$BID = _BID || '' |
| | | item.$$BID = BID || '' |
| | | return item |
| | | }), |
| | | total: result.total, |
| | |
| | | * 含有初始不加载的页面,修改设置 |
| | | */ |
| | | refreshbysearch = (searches) => { |
| | | MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 列表重置 |
| | | MKEmitter.emit('resetTable', this.props.Tab.uuid) // 列表重置 |
| | | this.setState({ |
| | | loading: true, |
| | | pageIndex: 1, |
| | |
| | | * @description 表格刷新 |
| | | */ |
| | | reloadtable = () => { |
| | | MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 列表重置 |
| | | MKEmitter.emit('resetTable', this.props.Tab.uuid) // 列表重置 |
| | | this.setState({ |
| | | loading: true, |
| | | pageIndex: 1, |
| | |
| | | } |
| | | |
| | | /** |
| | | * @description 表格Id变化 |
| | | */ |
| | | handleTableId = (type = this.props.Tab.uuid, id = '', data = '') => { |
| | | this.props.handleTableId(type, id, data) |
| | | } |
| | | |
| | | /** |
| | | * @description 数据展开合并切换 |
| | | */ |
| | | pickupChange = () => { |
| | |
| | | }) |
| | | } |
| | | |
| | | changeTableLine = (ContainerId, tableId, id, data) => { |
| | | const { Tab } = this.props |
| | | |
| | | if (tableId !== Tab.supMenu) return |
| | | |
| | | this.setState({BData: data, BID: id}) |
| | | |
| | | if (id !== this.state.BID) { |
| | | MKEmitter.emit('resetTable', this.props.Tab.uuid) // 列表重置 |
| | | this.setState({ |
| | | pageIndex: 1, |
| | | selectedData: [] |
| | | }, () => { |
| | | this.loadmaindata('refresh') |
| | | }) |
| | | } |
| | | } |
| | | |
| | | UNSAFE_componentWillMount() { |
| | | // 组件加载时,获取菜单数据 |
| | | this.loadconfig() |
| | | } |
| | | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('changeTableLine', this.changeTableLine) |
| | | } |
| | | |
| | | 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.state), fromJS(nextState)) |
| | | } |
| | | |
| | | /** |
| | |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | MKEmitter.removeListener('changeTableLine', this.changeTableLine) |
| | | } |
| | | |
| | | render() { |
| | | const { setting, searchlist, actions, columns, pickup, selectedData } = this.state |
| | | const { BID, BData, setting, searchlist, actions, columns, pickup, selectedData } = this.state |
| | | |
| | | return ( |
| | | <div className="verup-subtable" id={'subtable' + this.props.MenuID}> |
| | |
| | | <div className="sub-action"> |
| | | <SubAction |
| | | type="sub" |
| | | BID={BID} |
| | | BData={BData} |
| | | setting={setting} |
| | | actions={actions} |
| | | columns={columns} |
| | | Tab={this.props.Tab} |
| | | BID={this.props.BID} |
| | | BData={this.props.BData} |
| | | dict={this.state.dict} |
| | | selectedData={selectedData} |
| | | MenuID={this.props.SupMenuID} |
| | |
| | | loading={this.state.loading} |
| | | refreshdata={this.refreshbytable} |
| | | buttonTrigger={() => {}} |
| | | handleTableId={this.handleTableId} |
| | | chgSelectData={this.changeSelectedData} |
| | | /> |
| | | </div> : null |