| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Form, Row, Col, Input, Select, InputNumber, Radio, Tooltip, Icon, Modal } from 'antd' |
| | | import { Form, Row, Col, Input, Select, InputNumber, Radio, Tooltip, Icon, Modal, notification } from 'antd' |
| | | |
| | | import { getColumnForm } from './formconfig' |
| | | import { formRule } from '@/utils/option.js' |
| | | import './index.scss' |
| | | |
| | | const columnTypeOptions = { |
| | | text: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'prefix', 'postfix', 'textFormat', 'editable', 'blacklist'], |
| | | number: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'decimal', 'format', 'prefix', 'postfix', 'editable', 'sum', 'blacklist'], |
| | | textarea: ['label', 'field', 'type', 'Align', 'Hide', 'Width', 'prefix', 'postfix', 'blacklist'], |
| | | text: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'prefix', 'postfix', 'textFormat', 'editable', 'initval', 'blacklist'], |
| | | number: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'decimal', 'format', 'prefix', 'postfix', 'editable', 'initval', 'sum', 'blacklist'], |
| | | textarea: ['label', 'field', 'type', 'Align', 'Hide', 'Width', 'prefix', 'initval', 'postfix', 'blacklist'], |
| | | custom: ['label', 'type', 'Align', 'Hide', 'Width', 'blacklist'], |
| | | action: ['label', 'type', 'Align', 'Width'], |
| | | index: ['label', 'type', 'Align', 'Width'] |
| | |
| | | |
| | | if (column.editable === 'true') { |
| | | if (column.type === 'text') { |
| | | _options.push('required', 'initval', 'enter', 'footEnter') |
| | | _options.push('required', 'enter', 'footEnter') |
| | | } else if (column.type === 'number') { |
| | | _options.push('max', 'min', 'initval', 'enter', 'footEnter') |
| | | _options.push('max', 'min', 'enter', 'footEnter') |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | if (editable === 'true') { |
| | | if (value === 'text') { |
| | | _options.push('required', 'initval', 'enter', 'footEnter') |
| | | _options.push('required', 'enter', 'footEnter') |
| | | } else if (value === 'number') { |
| | | _options.push('max', 'min', 'initval', 'enter', 'footEnter') |
| | | _options.push('max', 'min', 'enter', 'footEnter') |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | if (editable === 'true') { |
| | | if (values.type === 'text') { |
| | | _options.push('required', 'initval', 'enter', 'footEnter') |
| | | _options.push('required', 'enter', 'footEnter') |
| | | } else if (values.type === 'number') { |
| | | _options.push('max', 'min', 'initval', 'enter', 'footEnter') |
| | | _options.push('max', 'min', 'enter', 'footEnter') |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | if (value === 'true') { |
| | | if (type === 'text') { |
| | | _options.push('required', 'initval', 'enter', 'footEnter') |
| | | _options.push('required', 'enter', 'footEnter') |
| | | } else if (type === 'number') { |
| | | _options.push('max', 'min', 'initval', 'enter', 'footEnter') |
| | | _options.push('max', 'min', 'enter', 'footEnter') |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | handleSubmit = () => { |
| | | const { columns, column } = this.props |
| | | // 表单提交时检查输入值是否正确 |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |
| | | if (!err) { |
| | | values.uuid = column.uuid |
| | | values.marks = column.marks || [] |
| | | |
| | | if (values.field && columns.filter(col => col.field && col.uuid !== values.uuid && col.field === values.field).length > 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '字段已添加!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | this.setState({visible: false, formlist: null}) |
| | | this.props.submitCol(values) |
| | | } |