| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { fromJS } from 'immutable' |
| | | import { Form, Row, Col, Input, Select, Icon, Radio, notification, InputNumber, Tooltip } from 'antd' |
| | | import { Form, Row, Col, Input, Select, Radio, notification, InputNumber, Tooltip } from 'antd' |
| | | import { QuestionCircleOutlined } from '@ant-design/icons' |
| | | |
| | | import { formRule } from '@/utils/option.js' |
| | |
| | | const ColorSketch = asyncComponent(() => import('@/mob/colorsketch')) |
| | | const FieldsTable = asyncComponent(() => import('./fieldtable')) |
| | | const DataTable = asyncComponent(() => import('./datatable')) |
| | | const MkIcon = asyncComponent(() => import('@/components/mkIcon')) |
| | | |
| | | const modalTypeOptions = { |
| | | text: ['initval', 'readonly', 'required', 'hidden', 'readin', 'fieldlength', 'regular', 'interception', 'span', 'labelwidth', 'tooltip', 'extra', 'enter', 'cursor', 'scan', 'splitline', 'placeholder', 'place', 'marginTop', 'marginBottom'], |
| | |
| | | datetime: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'declareType', 'mode', 'splitline', 'marginTop', 'marginBottom', 'minDate', 'maxDate'], |
| | | textarea: ['initval', 'readonly', 'required', 'hidden', 'readin', 'fieldlength', 'span', 'labelwidth', 'maxRows', 'encryption', 'interception', 'tooltip', 'extra', 'count', 'placeholder', 'marginTop', 'marginBottom'], |
| | | color: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'marginTop', 'marginBottom'], |
| | | rate: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'splitline', 'tooltip', 'extra', 'marginTop', 'marginBottom', 'allowHalf', 'rateCount', 'character', 'place'], |
| | | hint: ['label', 'type', 'blacklist', 'message', 'span', 'labelwidth', 'splitline', 'marginTop', 'marginBottom'], |
| | | split: ['label', 'type', 'marginTop', 'marginBottom'], |
| | | brafteditor: ['required', 'hidelabel', 'hidden', 'readin', 'fieldlength', 'readonly', 'span', 'labelwidth', 'tooltip', 'extra', 'encryption', 'marginTop', 'marginBottom'], |
| | |
| | | resourceType: resourceType, |
| | | linkSubFields: linkSubFields, |
| | | formlist: formlist.map(form => { |
| | | if (dateOptions.hasOwnProperty(type) && form.key === 'initval') { |
| | | form.options = dateOptions[type] |
| | | form.type = 'select' |
| | | } else if (type === 'switch' && form.key === 'initval') { |
| | | form.initVal = !!form.initVal |
| | | form.options = [ |
| | | {value: true, text: '开'}, |
| | | {value: false, text: '关'} |
| | | ] |
| | | form.type = 'radio' |
| | | } else if (type === 'number' && form.key === 'initval') { |
| | | form.type = 'number' |
| | | form.initVal = form.initVal || 0 |
| | | form.required = true |
| | | if (form.key === 'initval') { |
| | | if (dateOptions.hasOwnProperty(type)) { |
| | | form.options = dateOptions[type] |
| | | form.type = 'select' |
| | | } else if (type === 'switch') { |
| | | form.initVal = !!form.initVal |
| | | form.options = [ |
| | | {value: true, text: '开'}, |
| | | {value: false, text: '关'} |
| | | ] |
| | | form.type = 'radio' |
| | | } |
| | | if (type === 'number') { |
| | | form.type = 'number' |
| | | form.initVal = form.initVal || 0 |
| | | form.required = true |
| | | } else if (type === 'rate') { |
| | | form.type = 'number' |
| | | form.initVal = form.initVal || 0 |
| | | form.required = false |
| | | } |
| | | } else if (form.key === 'label') { |
| | | form.required = true |
| | | if (type === 'hint') { |
| | |
| | | } else if (value === 'number') { |
| | | form.type = 'number' |
| | | form.required = true |
| | | form.initVal = 0 |
| | | } else if (value === 'rate') { |
| | | form.type = 'number' |
| | | form.required = false |
| | | form.initVal = 0 |
| | | } else { |
| | | form.type = 'text' |
| | |
| | | > |
| | | {item.options.map((option, i) => |
| | | <Select.Option key={`${i}`} value={option.value || option.field || ''}> |
| | | {item.key === 'icon' && <Icon type={option.text} />} {option.text || option.label} |
| | | {option.text || option.label} |
| | | </Select.Option> |
| | | )} |
| | | </Select> |
| | |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'icon') { |
| | | fields.push( |
| | | <Col span={12} key={index}> |
| | | <Form.Item label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | {item.label} |
| | | </Tooltip> : item.label |
| | | }> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: item.initVal || '', |
| | | rules: [{ |
| | | required: !!item.required, |
| | | message: this.props.dict['form.required.select'] + item.label + '!' |
| | | }] |
| | | })( |
| | | <MkIcon allowClear /> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } |
| | | }) |
| | | |