| | |
| | | import './index.scss' |
| | | |
| | | const columnTypeOptions = { |
| | | text: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'prefix', 'postfix', 'matchVal', 'color', 'fieldlength', 'blacklist', 'linkmenu'], |
| | | number: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'decimal', 'format', 'prefix', 'postfix', 'match', 'matchVal', 'color', 'blacklist', 'linkmenu'], |
| | | textarea: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'prefix', 'postfix', 'matchVal', 'color', 'fieldlength', 'blacklist'], |
| | | text: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'prefix', 'postfix', 'color', 'fieldlength', 'blacklist', 'linkmenu'], |
| | | number: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'decimal', 'format', 'prefix', 'postfix', 'color', 'blacklist', 'linkmenu'], |
| | | textarea: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'prefix', 'postfix', 'color', 'fieldlength', 'blacklist'], |
| | | picture: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'fieldlength', 'blacklist', 'scale', 'maxHeight'] |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | let _type = this.props.formlist.filter(form => form.key === 'type')[0].initVal |
| | | const { card } = this.props |
| | | let _menulist = this.props.formlist.filter(form => form.key === 'linkmenu')[0] || '' |
| | | |
| | | let _options = JSON.parse(JSON.stringify(columnTypeOptions[_type])) |
| | | let _options = JSON.parse(JSON.stringify(columnTypeOptions[card.type])) |
| | | |
| | | this.setState({ |
| | | menulist: _menulist.options || [], |
| | | formlist: this.props.formlist.map(item => { |
| | | item.hidden = !_options.includes(item.key) |
| | | if (item.key === 'matchVal' && (_type === 'text' || _type === 'textarea')) { |
| | | item.type = 'text' |
| | | } else if (item.key === 'matchVal' && _type === 'number') { |
| | | item.type = 'number' |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 初次添加的显示列元素,聚焦提示文字 |
| | | */ |
| | | componentDidMount () { |
| | | const { card } = this.props |
| | | |
| | |
| | | typeChange = (key, value) => { |
| | | if (key === 'type') { |
| | | let _options = JSON.parse(JSON.stringify(columnTypeOptions[value])) |
| | | let fieldlength = 50 |
| | | |
| | | if (value !== 'text') { |
| | | fieldlength = 512 |
| | | } |
| | | |
| | | this.setState({ |
| | | formlist: this.props.formlist.map(item => { |
| | | item.hidden = !_options.includes(item.key) |
| | | if (item.key === 'matchVal' && (value === 'text' || value === 'textarea')) { |
| | | item.type = 'text' |
| | | } else if (item.key === 'matchVal' && value === 'number') { |
| | | item.type = 'number' |
| | | item.initVal = '' |
| | | item.hidden = true |
| | | } else if (item.key === 'fieldlength') { |
| | | if (value === 'text') { |
| | | item.initVal = 50 |
| | | } else { |
| | | item.initVal = 512 |
| | | } |
| | | item.hidden = true |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | }, () => { |
| | | this.setState({ |
| | | formlist: this.props.formlist.map(item => { |
| | | if (item.key === 'matchVal' && value === 'number') { |
| | | item.hidden = false |
| | | } else if (item.key === 'fieldlength' && value !== 'number') { |
| | | item.hidden = false |
| | | } |
| | | return item |
| | | }) |
| | | }) |
| | | if (this.props.form.getFieldValue('fieldlength') !== undefined) { |
| | | this.props.form.setFieldsValue({fieldlength: fieldlength}) |
| | | } |
| | | }) |
| | | } else if (key === 'format' && value === 'percent') { |
| | | this.props.form.setFieldsValue({postfix: '%'}) |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | if (item.type === 'text') { // 文本搜索 |
| | | let rules = [] |
| | | if (item.key === 'field') { |
| | | if (item.key === 'field' || item.key === 'contrastField') { |
| | | rules = [{ |
| | | pattern: formRule.field.pattern, |
| | | message: formRule.field.message |
| | |
| | | message: this.props.dict['form.required.input'] + item.label + '!' |
| | | } |
| | | ] |
| | | })(<InputNumber min={item.min} max={item.max} precision={item.decimal} />)} |
| | | })(item.unlimit ? <InputNumber /> : |
| | | <InputNumber min={item.min} max={item.max} precision={item.decimal} />)} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | |
| | | if (!err) { |
| | | values.id = this.props.card.id |
| | | values.uuid = this.props.card.uuid |
| | | values.marks = this.props.card.marks || '' |
| | | |
| | | if ((values.type === 'text' || values.type === 'number') && values.linkmenu && values.linkmenu.length > 0) { |
| | | let linkThdMenu = '' |