| | |
| | | const { TextArea } = Input |
| | | |
| | | const modalTypeOptions = { |
| | | text: ['initval', 'readonly', 'required', 'hidden', 'readin', 'fieldlength', 'regular', 'interception', 'entireLine', 'tooltip', 'enter'], |
| | | number: ['initval', 'readonly', 'hidden', 'decimal', 'min', 'max', 'readin', 'entireLine', 'tooltip', 'enter'], |
| | | select: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'setAll', 'linkSubField', 'entireLine', 'tooltip', 'emptyText', 'enter'], |
| | | checkbox: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'entireLine', 'tooltip'], |
| | | radio: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'linkSubField', 'entireLine', 'tooltip', 'setAll', 'emptyText'], |
| | | checkcard: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'linkSubField', 'fieldlength', 'display', 'tooltip', 'width', 'multiple'], |
| | | multiselect: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'fieldlength', 'entireLine', 'tooltip'], |
| | | link: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'setAll', 'linkField', 'entireLine', 'tooltip', 'emptyText', 'enter'], |
| | | fileupload: ['readonly', 'required', 'readin', 'fieldlength', 'maxfile', 'fileType', 'entireLine', 'tooltip', 'suffix'], |
| | | switch: ['initval', 'openVal', 'closeVal', 'openText', 'closeText', 'readonly', 'hidden', 'readin', 'entireLine', 'tooltip'], |
| | | date: ['initval', 'readonly', 'required', 'hidden', 'readin', 'entireLine', 'tooltip'], |
| | | datemonth: ['initval', 'readonly', 'required', 'hidden', 'readin', 'entireLine', 'tooltip'], |
| | | datetime: ['initval', 'readonly', 'required', 'hidden', 'readin', 'entireLine', 'tooltip'], |
| | | textarea: ['initval', 'readonly', 'required', 'hidden', 'readin', 'fieldlength', 'maxRows', 'encryption', 'interception', 'tooltip'], |
| | | color: ['initval', 'readonly', 'required', 'hidden', 'readin', 'entireLine', 'tooltip'], |
| | | hint: ['label', 'type', 'blacklist', 'message'], |
| | | brafteditor: ['required', 'hidelabel', 'hidden', 'readin', 'fieldlength', 'readonly', 'tooltip', 'encryption'], |
| | | funcvar: [], |
| | | linkMain: ['readonly', 'required', 'hidden', 'fieldlength', 'entireLine', 'tooltip'] |
| | | text: ['initval', 'readonly', 'required', 'hidden', 'readin', 'fieldlength', 'regular', 'interception', 'span', 'labelwidth', 'tooltip', 'extra', 'enter'], |
| | | number: ['initval', 'readonly', 'hidden', 'decimal', 'min', 'max', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'enter'], |
| | | select: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'setAll', 'linkSubField', 'span', 'labelwidth', 'tooltip', 'extra', 'emptyText', 'enter'], |
| | | checkbox: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'span', 'labelwidth', 'tooltip', 'extra'], |
| | | radio: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'linkSubField', 'span', 'labelwidth', 'tooltip', 'extra', 'setAll', 'emptyText'], |
| | | checkcard: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'linkSubField', 'fieldlength', 'span', 'labelwidth', 'display', 'tooltip', 'extra', 'width', 'multiple'], |
| | | multiselect: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'fieldlength', 'span', 'labelwidth', 'tooltip', 'extra'], |
| | | link: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'setAll', 'linkField', 'span', 'labelwidth', 'tooltip', 'extra', 'emptyText', 'enter'], |
| | | fileupload: ['readonly', 'required', 'readin', 'fieldlength', 'maxfile', 'fileType', 'span', 'labelwidth', 'tooltip', 'extra', 'suffix'], |
| | | switch: ['initval', 'openVal', 'closeVal', 'openText', 'closeText', 'readonly', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra'], |
| | | date: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra'], |
| | | datemonth: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra'], |
| | | datetime: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra'], |
| | | textarea: ['initval', 'readonly', 'required', 'hidden', 'readin', 'fieldlength', 'span', 'labelwidth', 'maxRows', 'encryption', 'interception', 'tooltip', 'extra'], |
| | | color: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra'], |
| | | hint: ['label', 'type', 'blacklist', 'message', 'span', 'labelwidth'], |
| | | split: ['label', 'type'], |
| | | brafteditor: ['required', 'hidelabel', 'hidden', 'readin', 'fieldlength', 'readonly', 'span', 'labelwidth', 'tooltip', 'extra', 'encryption'], |
| | | funcvar: ['span', 'labelwidth'], |
| | | linkMain: ['readonly', 'required', 'hidden', 'fieldlength', 'span', 'labelwidth', 'tooltip', 'extra'] |
| | | } |
| | | |
| | | class MainSearch extends Component { |
| | | static propTpyes = { |
| | | dict: PropTypes.object, // 字典项 |
| | | formlist: PropTypes.any, |
| | | standardform: PropTypes.any, |
| | | card: PropTypes.object, |
| | | inputSubmit: PropTypes.any |
| | | } |
| | |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | let formlist = fromJS(this.props.formlist).toJS() |
| | | |
| | | let type = '' |
| | | let resourceType = '' |
| | | let supField = '' |
| | |
| | | |
| | | if (type === 'hint') { |
| | | _options = fromJS(modalTypeOptions[type]).toJS() |
| | | } else if (type === 'split') { |
| | | return fromJS(modalTypeOptions[type]).toJS() |
| | | } else if (['multiselect', 'select', 'link', 'radio', 'checkbox'].includes(type)) { |
| | | if (resourceType === '0') { // 自定义资源 |
| | | _options.push('options') |
| | |
| | | } |
| | | } else if (form.key === 'fieldlength') { |
| | | form.initVal = 50 |
| | | if (value === 'textarea') { |
| | | if (value === 'textarea' || value === 'brafteditor') { |
| | | form.initVal = 8000 |
| | | } else if (value === 'fileupload' || value === 'multiselect' || value === 'checkbox') { |
| | | form.initVal = 512 |
| | |
| | | }) |
| | | } |
| | | |
| | | changeVal = (val, type) => { |
| | | if (type !== 'span' || ![24, 12, 8, 6].includes(val)) return |
| | | |
| | | const { standardform } = this.props |
| | | |
| | | if (!standardform || ![24, 12, 8, 6].includes(standardform.span) || !standardform.labelwidth) return |
| | | |
| | | let labelwidth = null |
| | | |
| | | if (standardform.span === val) { |
| | | labelwidth = standardform.labelwidth |
| | | } else if (standardform.span > val) { |
| | | labelwidth = 33.3 |
| | | } else { |
| | | switch(standardform.span) { |
| | | case 12: |
| | | labelwidth = 16.2 |
| | | break; |
| | | case 8: |
| | | if (val === 12) { |
| | | labelwidth = 21.6 |
| | | } else { |
| | | labelwidth = 10.5 |
| | | } |
| | | break; |
| | | case 6: |
| | | if (val === 8) { |
| | | labelwidth = 24.3 |
| | | } else if (val === 12) { |
| | | labelwidth = 15.8 |
| | | } else { |
| | | labelwidth = 7.7 |
| | | } |
| | | break; |
| | | default: |
| | | } |
| | | } |
| | | |
| | | |
| | | if (labelwidth) { |
| | | this.props.form.setFieldsValue({labelwidth}) |
| | | } |
| | | } |
| | | |
| | | handleSubmit = (e) => { |
| | | e.preventDefault() |
| | | |
| | |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'number') { |
| | | if (item.key === 'decimal') { |
| | | if (item.max) { |
| | | fields.push( |
| | | <Col span={12} key={index}> |
| | | <Form.Item label={item.label}> |
| | | <Form.Item label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <Icon type="question-circle" /> |
| | | {item.label} |
| | | </Tooltip> : item.label |
| | | }> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: item.initVal || 0, |
| | | rules: [ |
| | |
| | | message: this.props.dict['form.required.input'] + item.label + '!' |
| | | } |
| | | ] |
| | | })(<InputNumber min={0} max={18} precision={0} />)} |
| | | })(<InputNumber onChange={(value) => this.changeVal(value, item.key)} min={item.min} max={item.max} precision={item.precision} onPressEnter={this.handleSubmit}/>)} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } else if (item.key === 'fieldlength' || item.key === 'maxfile') { |
| | | } else { |
| | | fields.push( |
| | | <Col span={12} key={index}> |
| | | <Form.Item label={item.label}> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: item.initVal, |
| | | rules: [ |
| | | { |
| | | required: !!item.required, |
| | | message: this.props.dict['form.required.input'] + item.label + '!' |
| | | } |
| | | ] |
| | | })(<InputNumber min={1} precision={0} />)} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } else if (item.key === 'maxRows') { |
| | | fields.push( |
| | | <Col span={12} key={index}> |
| | | <Form.Item label={item.label}> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: item.initVal, |
| | | rules: [ |
| | | { |
| | | required: !!item.required, |
| | | message: this.props.dict['form.required.input'] + item.label + '!' |
| | | } |
| | | ] |
| | | })(<InputNumber min={2} max={100} precision={0} />)} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } else if (item.key === 'width') { |
| | | fields.push( |
| | | <Col span={12} key={index}> |
| | | <Form.Item label={ |
| | | <Form.Item label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <Icon type="question-circle" /> |
| | | {item.label} |
| | | </Tooltip> |
| | | </Tooltip> : item.label |
| | | }> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: item.initVal, |
| | |
| | | message: this.props.dict['form.required.input'] + item.label + '!' |
| | | } |
| | | ] |
| | | })(<InputNumber min={1} max={24} precision={0} />)} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } else { |
| | | fields.push( |
| | | <Col span={12} key={index}> |
| | | <Form.Item label={item.label}> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: item.initVal, |
| | | rules: [ |
| | | { |
| | | required: !!item.required, |
| | | message: this.props.dict['form.required.input'] + item.label + '!' |
| | | } |
| | | ] |
| | | })(<InputNumber />)} |
| | | })(<InputNumber onPressEnter={this.handleSubmit}/>)} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | |
| | | } |
| | | } else if (values.type === 'linkMain') { |
| | | values.initval = '' |
| | | } else if (values.type === 'split') { |
| | | values.span = 24 |
| | | } |
| | | |
| | | ['linkField', 'valueField', 'valueText', 'orderBy'].forEach(item => { |