| | |
| | | * 1、 initdata 为打印时使用的数据集 |
| | | */ |
| | | UNSAFE_componentWillMount () { |
| | | const { data, initdata, BID, BData } = this.props |
| | | const { BID, BData } = this.props |
| | | let _config = fromJS(this.props.config).toJS() |
| | | let _cols = new Map() |
| | | let _data = null |
| | | let _sync = _config.setting.sync === 'true' |
| | | let setting = {..._config.setting, ..._config.wrap, style: {}} |
| | | setting.tableId = Utils.getuuid() |
| | | |
| | | if (_config.setting.sync === 'true' && data) { |
| | | _data = data[_config.dataName] || [] |
| | | _sync = false |
| | | } else if (_config.setting.sync === 'true' && initdata) { |
| | | _data = initdata || [] |
| | | _sync = false |
| | | } |
| | | |
| | | if (_data) { |
| | | _data = _data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[_config.setting.primaryKey] || '' |
| | | item.$$BID = BID || '' |
| | | item.$$BData = BData || '' |
| | | item.$Index = index + 1 + '' |
| | | return item |
| | | }) |
| | | if (setting.height) { |
| | | setting.operType = 'btnMode' |
| | | } |
| | | |
| | | _config.columns.forEach(item => { |
| | |
| | | }) |
| | | |
| | | let _columns = [] |
| | | // let signAdd = false |
| | | let signAdd = false |
| | | _config.cols.forEach(column => { |
| | | if (column.Hide === 'true') return |
| | | if (column.type === 'index') { |
| | |
| | | column.type = 'text' |
| | | } |
| | | |
| | | // if (setting.addable === 'true' && column.type !== 'action' && !signAdd) { |
| | | // column.addable = true |
| | | // signAdd = true |
| | | // } |
| | | if (setting.addable === 'true' && setting.operType === 'buoyMode' && column.type !== 'action' && !signAdd) { |
| | | column.addable = true |
| | | signAdd = true |
| | | } |
| | | |
| | | if (column.marks && column.marks.length === 0) { |
| | | column.marks = '' |
| | |
| | | _columns.push(column) |
| | | }) |
| | | |
| | | // if (setting.delable !== 'false') { |
| | | // if (_columns[_columns.length - 1] && _columns[_columns.length - 1].type !== 'action') { |
| | | // _columns[_columns.length - 1].delable = true |
| | | // } else if (_columns[_columns.length - 2] && _columns[_columns.length - 2].type !== 'action') { |
| | | // _columns[_columns.length - 2].delable = true |
| | | // } |
| | | // } |
| | | if (setting.delable !== 'false' && setting.operType === 'buoyMode') { |
| | | if (_columns[_columns.length - 1] && _columns[_columns.length - 1].type !== 'action') { |
| | | _columns[_columns.length - 1].delable = true |
| | | } else if (_columns[_columns.length - 2] && _columns[_columns.length - 2].type !== 'action') { |
| | | _columns[_columns.length - 2].delable = true |
| | | } |
| | | } |
| | | |
| | | if (setting.color) { |
| | | setting.style.color = setting.color |
| | |
| | | BID: BID || '', |
| | | BData: BData || '', |
| | | title: _config.wrap.title, |
| | | sync: _sync, |
| | | data: _data, |
| | | config: _config, |
| | | setting: setting, |
| | | searchlist: _config.search, |
| | |
| | | arr_field: _config.columns.map(col => col.field).join(','), |
| | | search: Utils.initMainSearch(_config.search) // 搜索条件初始化(含有时间格式,需要转化) |
| | | }, () => { |
| | | if (_config.setting.sync !== 'true' && _config.setting.onload === 'true') { |
| | | if (_config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | | this.loadmaindata() |
| | | this.getStatFieldsValue() |
| | | }, _config.setting.delay || 0) |
| | | } else if (_config.setting.onload === 'true') { |
| | | this.getStatFieldsValue() |
| | | } |
| | | }) |
| | | } |
| | |
| | | item.$$BID = BID || '' |
| | | item.$$BData = BData || '' |
| | | item.$Index = start + index + '' |
| | | item.$type = 'upt' |
| | | item.$origin = true |
| | | return item |
| | | }), |
| | | total: result.total, |
| | |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps(nextProps) { |
| | | const { sync, config, BID, BData } = this.state |
| | | const { config } = this.state |
| | | |
| | | if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) { |
| | | let _data = [] |
| | | if (nextProps.data && nextProps.data[config.dataName]) { |
| | | _data = nextProps.data[config.dataName] || [] |
| | | _data = _data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[config.setting.primaryKey] || '' |
| | | item.$$BID = BID || '' |
| | | item.$$BData = BData || '' |
| | | item.$Index = index + 1 + '' |
| | | return item |
| | | }) |
| | | } |
| | | |
| | | this.setState({sync: false, data: _data}) |
| | | } else if (config.setting.syncRefresh && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | if (config.setting.syncRefresh && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({pageIndex: 1}, () => { |
| | | this.reloadtable() |
| | | }) |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { BID, setting, searchlist, actions, config, columns, BData } = this.state |
| | | const { BID, setting, searchlist, actions, config, columns, BData, data } = this.state |
| | | |
| | | return ( |
| | | <div className="custom-edit-table" style={config.style}> |
| | |
| | | <div className={'main-table-box ' + (!actions || actions.length === 0 ? 'no-action' : '')}> |
| | | <MainTable |
| | | BID={BID} |
| | | data={data} |
| | | setting={setting} |
| | | columns={columns} |
| | | MenuID={config.uuid} |
| | | data={this.state.data} |
| | | submit={config.submit} |
| | | fields={config.columns} |
| | | total={this.state.total} |