| | |
| | | loading: PropTypes.bool, // 表格加载中 |
| | | refreshdata: PropTypes.func, // 表格中排序列、页码的变化时刷新 |
| | | chgSelectData: PropTypes.func, // 数据切换 |
| | | autoMatic: PropTypes.any |
| | | autoMatic: PropTypes.any, |
| | | allSearch: PropTypes.any, |
| | | colsCtrls: PropTypes.any |
| | | } |
| | | |
| | | state = { |
| | |
| | | rowspans: null, // 行合并字段信息 |
| | | pickup: false, // 收起未选择项 |
| | | orderfields: {}, // 排序id与field转换 |
| | | pageOptions: [] |
| | | pageOptions: [], |
| | | allColumns: null, |
| | | reseting: false |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { setting, fields, columns } = this.props |
| | | const { setting, columns, fields, colsCtrls } = this.props |
| | | let radio = 5 // 虚化比例 |
| | | let _format = false // 是否虚化处理 |
| | | let rowspans = [] |
| | |
| | | let cell = null |
| | | |
| | | if (item.type === 'colspan') { |
| | | cell = { title: item.label, align: item.Align } |
| | | cell = { title: item.label, align: item.Align, $key: item.uuid } |
| | | cell.children = getColumns(item.subcols) |
| | | } else { |
| | | if (item.rowspan === 'true') { |
| | |
| | | } |
| | | |
| | | cell = { |
| | | $key: item.uuid, |
| | | align: item.Align, |
| | | dataIndex: item.uuid, |
| | | title: item.label, |
| | |
| | | fields.push(item.field) |
| | | |
| | | _columns.push({ |
| | | $key: item.uuid, |
| | | align: item.Align, |
| | | dataIndex: item.field, |
| | | title: item.label, |
| | |
| | | pageOptions = pageOptions.sort((a, b) => a - b) |
| | | } |
| | | |
| | | let allColumns = null |
| | | if (colsCtrls) { |
| | | rowspans = null |
| | | allColumns = [..._columns] |
| | | _columns = this.getCurColumns(_columns, this.props.allSearch) |
| | | } |
| | | |
| | | this.setState({ |
| | | pageSize: setting.pageSize || 10, |
| | | pageOptions, |
| | | allColumns, |
| | | columns: _columns, |
| | | rowspans, |
| | | tableId, |
| | |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps(nextProps) { |
| | | const { allSearch } = this.props |
| | | const { allColumns } = this.state |
| | | |
| | | if (allSearch && !is(fromJS(allSearch), fromJS(nextProps.allSearch))) { |
| | | this.setState({ |
| | | reseting: true, |
| | | columns: this.getCurColumns(allColumns, nextProps.allSearch) |
| | | }, () => { |
| | | this.setState({reseting: false}) |
| | | }) |
| | | } |
| | | } |
| | | |
| | | componentDidMount () { |
| | |
| | | MKEmitter.removeListener('autoQueryData', this.autoQueryData) |
| | | MKEmitter.removeListener('autoSelectData', this.autoSelectData) |
| | | MKEmitter.removeListener('mkCheckTopLine', this.mkCheckTopLine) |
| | | } |
| | | |
| | | getCurColumns = (columns, allSearch) => { |
| | | const { colsCtrls } = this.props |
| | | |
| | | let values = {} |
| | | allSearch.forEach(item => { |
| | | values[item.key] = item.value |
| | | }) |
| | | let cols = null |
| | | colsCtrls.some(item => { |
| | | let originVal = item.field.map(f => values[f] || '').join('') |
| | | let contrastVal = item.contrastValue |
| | | let result = false |
| | | |
| | | if (item.match === '=') { |
| | | result = originVal === contrastVal |
| | | } else if (item.match === '!=') { |
| | | result = originVal !== contrastVal |
| | | } else { |
| | | originVal = isNaN(originVal) ? originVal : +originVal |
| | | contrastVal = isNaN(contrastVal) ? contrastVal : +contrastVal |
| | | if (item.match === '>') { |
| | | result = originVal > contrastVal |
| | | } else if (item.match === '<') { |
| | | result = originVal < contrastVal |
| | | } |
| | | } |
| | | |
| | | if (!result) return false |
| | | |
| | | cols = item.cols |
| | | |
| | | return true |
| | | }) |
| | | |
| | | if (cols) { |
| | | return columns.filter(col => cols.includes(col.$key)) |
| | | } |
| | | |
| | | return columns |
| | | } |
| | | |
| | | autoSelectData = (id, index) => { |
| | |
| | | |
| | | render() { |
| | | const { setting, statFValue, lineMarks, data } = this.props |
| | | const { selectedRowKeys, activeIndex, pickup, tableId, pageOptions, columns } = this.state |
| | | const { selectedRowKeys, activeIndex, pickup, tableId, pageOptions, columns, reseting } = this.state |
| | | |
| | | if (reseting) return null |
| | | |
| | | // 设置表格选择属性:单选、多选、不可选 |
| | | let rowSelection = null |