| | |
| | | |
| | | state = { |
| | | visible: false, |
| | | formlist: null |
| | | formlist: null, |
| | | } |
| | | |
| | | column = null |
| | | |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | if (nextProps.column && !is(fromJS(this.props.column), fromJS(nextProps.column))) { |
| | |
| | | } |
| | | } |
| | | |
| | | editColumn = (column) => { |
| | | let formlist = getColumnForm(column, this.props.fields, this.props.columns) |
| | | let _options = fromJS(columnTypeOptions[column.type]).toJS() |
| | | getOptions = () => { |
| | | let _options = fromJS(columnTypeOptions[this.column.type]).toJS() |
| | | |
| | | if (column.editable === 'true') { |
| | | if (column.type === 'text') { |
| | | _options.push('required', 'enter', 'footEnter') |
| | | } else if (column.type === 'number') { |
| | | if (this.column.editable === 'true') { |
| | | if (this.column.type === 'text') { |
| | | _options.push('editType', 'required', 'enter', 'footEnter') |
| | | } else if (this.column.type === 'number') { |
| | | _options.push('max', 'min', 'enter', 'footEnter') |
| | | } |
| | | } |
| | | |
| | | return _options |
| | | } |
| | | |
| | | editColumn = (column) => { |
| | | let formlist = getColumnForm(column, this.props.fields, this.props.columns) |
| | | |
| | | this.column = fromJS(column).toJS() |
| | | |
| | | let _options = this.getOptions() |
| | | |
| | | this.setState({ |
| | | visible: true, |
| | | editable: column.editable || 'false', |
| | | type: column.type, |
| | | formlist: formlist.map(item => { |
| | | item.hidden = !_options.includes(item.key) |
| | | |
| | |
| | | } |
| | | |
| | | typeChange = (key, value, option) => { |
| | | const { editable, type } = this.state |
| | | if (key === 'type') { |
| | | let _options = fromJS(columnTypeOptions[value]).toJS() |
| | | this.column[key] = value |
| | | |
| | | if (editable === 'true') { |
| | | if (value === 'text') { |
| | | _options.push('required', 'enter', 'footEnter') |
| | | } else if (value === 'number') { |
| | | _options.push('max', 'min', 'enter', 'footEnter') |
| | | } |
| | | } |
| | | if (key === 'type') { |
| | | let _options = this.getOptions() |
| | | |
| | | this.setState({ |
| | | type: value, |
| | | formlist: this.state.formlist.map(item => { |
| | | if (item.key === 'editable') { |
| | | item.initVal = editable |
| | | item.initVal = this.column.editable || 'false' |
| | | } |
| | | item.hidden = !_options.includes(item.key) |
| | | |
| | |
| | | values.type = 'text' |
| | | } |
| | | |
| | | if (values.type !== this.state.type) { |
| | | let _options = fromJS(columnTypeOptions[values.type]).toJS() |
| | | let _type = this.column.type |
| | | this.column.type = values.type |
| | | |
| | | if (editable === 'true') { |
| | | if (values.type === 'text') { |
| | | _options.push('required', 'enter', 'footEnter') |
| | | } else if (values.type === 'number') { |
| | | _options.push('max', 'min', 'enter', 'footEnter') |
| | | } |
| | | } |
| | | if (values.type !== _type) { |
| | | let _options = this.getOptions() |
| | | |
| | | this.setState({ |
| | | type: values.type, |
| | | formlist: this.state.formlist.map(item => { |
| | | if (item.key === 'editable') { |
| | | item.initVal = editable |
| | | item.initVal = this.column.editable || 'false' |
| | | } |
| | | item.hidden = !_options.includes(item.key) |
| | | |
| | |
| | | } else if (key === 'format' && value === 'percent') { |
| | | this.props.form.setFieldsValue({postfix: '%'}) |
| | | } else if (key === 'editable') { |
| | | let _options = fromJS(columnTypeOptions[type]).toJS() |
| | | |
| | | if (value === 'true') { |
| | | if (type === 'text') { |
| | | _options.push('required', 'enter', 'footEnter') |
| | | } else if (type === 'number') { |
| | | _options.push('max', 'min', 'enter', 'footEnter') |
| | | } |
| | | } |
| | | let _options = this.getOptions() |
| | | |
| | | this.setState({ |
| | | editable: value, |
| | | formlist: this.state.formlist.map(item => { |
| | | item.hidden = !_options.includes(item.key) |
| | | |