| | |
| | | lineMarks: PropTypes.any, // 行标记 |
| | | fields: PropTypes.array, // 组件字段集 |
| | | BID: PropTypes.any, // 主表ID |
| | | data: PropTypes.any, // 表格数据 |
| | | total: PropTypes.any, // 总数 |
| | | loading: PropTypes.bool, // 表格加载中 |
| | | refreshdata: PropTypes.func, // 表格中排序列、页码的变化时刷新 |
| | |
| | | this.setState({data: data || []}) |
| | | |
| | | if (this.state.editable && !this.state.pickup) { |
| | | this.setState({editable: false}) |
| | | setTimeout(() => { |
| | | this.pickupChange() |
| | | }, 200) |
| | |
| | | |
| | | this.setState({edData: _edData, data: _data}) |
| | | } |
| | | this.setState({editable: false}) |
| | | } |
| | | |
| | | improveActionForm = (deForms) => { |
| | |
| | | } |
| | | |
| | | pickupChange = () => { |
| | | const { submit, MenuID } = this.props |
| | | const { submit, MenuID, setting } = this.props |
| | | const { data } = this.state |
| | | |
| | | let pickup = !this.state.pickup |
| | |
| | | return |
| | | } |
| | | |
| | | if (!pickup && !is(fromJS(data), fromJS(this.state.edData))) { |
| | | if (!pickup && this.state.edData.filter(item => !item.$origin).length > 0) { |
| | | const _this = this |
| | | confirm({ |
| | | title: '数据已修改,确定放弃保存吗?', |
| | |
| | | } else { |
| | | pickup && MKEmitter.emit('resetSelectLine', MenuID, '', '') |
| | | pickup && this.props.chgSelectData([]) |
| | | let keys = this.state.selectedRowKeys |
| | | this.setState({ |
| | | data: [], |
| | | edData: [], |
| | | selectedRowKeys: [], |
| | | pickup, |
| | | loading: false, |
| | | editable: 'false' |
| | | editable: false |
| | | }, () => { |
| | | this.setState({ |
| | | data: data, |
| | | edData: pickup ? fromJS(data).toJS() : [] |
| | | }) |
| | | if (pickup && setting.tableType === 'checkbox' && keys.length > 0) { |
| | | this.setState({ |
| | | data: data, |
| | | edData: fromJS(data).toJS().filter(item => keys.includes(item.$$uuid)) |
| | | }) |
| | | } else { |
| | | this.setState({ |
| | | data: data, |
| | | edData: pickup ? fromJS(data).toJS() : [] |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | } |
| | | this.props.changeLock(pickup) |
| | | } |
| | |
| | | let height = setting.height || false |
| | | |
| | | return ( |
| | | <div className={`edit-custom-table ${pickup ? 'editable' : ''} ${setting.tableHeader || ''} ${setting.operType || ''} ${height ? 'fixed-height' : ''} ${setting.mode || ''}`} id={tableId}> |
| | | <Switch title="编辑" className="main-pickup" checkedChildren="开" unCheckedChildren="关" disabled={loading || this.props.loading} checked={pickup} onChange={this.pickupChange} /> |
| | | {pickup ? <Button style={submit.style} onClick={() => setTimeout(() => {this.checkData()}, 10)} loading={loading} className="submit-table" type="link">提交</Button> : null} |
| | | <Table |
| | | rowKey="$$uuid" |
| | | components={components} |
| | | style={setting.style} |
| | | size={setting.size || 'middle'} |
| | | bordered={setting.bordered !== 'false'} |
| | | rowSelection={rowSelection} |
| | | columns={_columns} |
| | | dataSource={_data} |
| | | loading={this.props.loading} |
| | | scroll={{ x: '100%', y: height }} |
| | | onRow={(record, index) => { |
| | | return { |
| | | lineMarks, |
| | | data: record, |
| | | onClick: () => {this.changeRow(record.$$uuid)}, |
| | | } |
| | | }} |
| | | onChange={this.changeTable} |
| | | pagination={_pagination} |
| | | /> |
| | | {_footer ? <div className={'normal-table-footer ' + (_pagination ? 'pagination' : '')}>{_footer}</div> : null} |
| | | {pickup && setting.addable === 'true' ? <Button className="mk-add-line" onClick={() => this.addLine()} disabled={this.props.loading} type="link"><PlusOutlined /></Button> : null} |
| | | </div> |
| | | <> |
| | | <div className="edit-custom-table-btn-wrap" style={submit.wrapStyle}> |
| | | {pickup ? <Button style={submit.style} onClick={() => setTimeout(() => {this.checkData()}, 10)} loading={loading} className="submit-table" type="link">提交</Button> : null} |
| | | <Switch title="编辑" className="main-pickup" checkedChildren="开" unCheckedChildren="关" disabled={loading || this.props.loading} checked={pickup} onChange={this.pickupChange} /> |
| | | </div> |
| | | <div className={`edit-custom-table ${pickup ? 'editable' : ''} ${setting.tableHeader || ''} ${setting.operType || ''} ${height ? 'fixed-height' : ''} ${setting.mode || ''}`} id={tableId}> |
| | | <Table |
| | | rowKey="$$uuid" |
| | | components={components} |
| | | style={setting.style} |
| | | size={setting.size || 'middle'} |
| | | bordered={setting.bordered !== 'false'} |
| | | rowSelection={rowSelection} |
| | | columns={_columns} |
| | | dataSource={_data} |
| | | loading={this.props.loading} |
| | | scroll={{ x: '100%', y: height }} |
| | | onRow={(record, index) => { |
| | | return { |
| | | lineMarks, |
| | | data: record, |
| | | onClick: () => {this.changeRow(record.$$uuid)}, |
| | | } |
| | | }} |
| | | onChange={this.changeTable} |
| | | pagination={_pagination} |
| | | /> |
| | | {_footer ? <div className={'normal-table-footer ' + (_pagination ? 'pagination' : '')}>{_footer}</div> : null} |
| | | {pickup && setting.addable === 'true' ? <Button className="mk-add-line" onClick={() => this.addLine()} disabled={this.props.loading} type="link"><PlusOutlined /></Button> : null} |
| | | {pickup && _data.length > 10 ? <Button style={submit.style} onClick={() => setTimeout(() => {this.checkData()}, 10)} loading={loading} className="submit-footer-table" type="link">提交</Button> : null} |
| | | </div> |
| | | </> |
| | | ) |
| | | } |
| | | } |