| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { Form, Row, Col, Select, Button, Input, Icon, Cascader, Tooltip } from 'antd' |
| | | import { Form, Row, Col, Select, Button, Input, Cascader, Tooltip } from 'antd' |
| | | import { QuestionCircleOutlined } from '@ant-design/icons' |
| | | |
| | | import ColorSketch from '@/mob/colorsketch' |
| | | import './index.scss' |
| | | |
| | | class UniqueForm extends Component { |
| | | static propTpyes = { |
| | | dict: PropTypes.object, // 字典项 |
| | | field: PropTypes.any, |
| | | columns: PropTypes.array, // 列名集合 |
| | | signs: PropTypes.array, // 标记类型 |
| | | markChange: PropTypes.func // 修改函数 |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { columns, signs } = this.props |
| | | const { columns, signs, field } = this.props |
| | | const { getFieldDecorator } = this.props.form |
| | | const formItemLayout = { |
| | | labelCol: { |
| | |
| | | } |
| | | } |
| | | |
| | | let initVal = [] |
| | | if (field) { |
| | | initVal = [field, 'static'] |
| | | } |
| | | |
| | | return ( |
| | | <Form {...formItemLayout} className="normal-table-mark-form"> |
| | | <Row gutter={24}> |
| | | <Col span={6}> |
| | | <Form.Item label={'对比字段'}> |
| | | {getFieldDecorator('field', { |
| | | initialValue: [], |
| | | initialValue: initVal, |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: this.props.dict['form.required.select'] + '对比字段!' |
| | | message: '请选择对比字段!' |
| | | }, |
| | | { |
| | | validator: (rule, value, callback) => { |
| | | if (value[1] === 'dynamic' && value[0] === value[2]) { |
| | | callback('对比字段不可相同!') |
| | | } else { |
| | | callback() |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | })( |
| | | <Cascader options={columns} placeholder=""/> |
| | | <Cascader className="mark-type" options={columns} placeholder=""/> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: this.props.dict['form.required.select'] + '对比方式!' |
| | | message: '请选择对比方式!' |
| | | } |
| | | ] |
| | | })( |
| | |
| | | </Col> |
| | | <Col span={6}> |
| | | <Form.Item label={<Tooltip placement="topLeft" title="对比静态值时,需要填写对比值,默认为空。"> |
| | | <Icon type="question-circle" /> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | {'对比值'} |
| | | </Tooltip> |
| | | }> |
| | |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: this.props.dict['form.required.select'] + '颜色!' |
| | | message: '请选择颜色!' |
| | | } |
| | | ] |
| | | })( |
| | |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: this.props.dict['form.required.select'] + '标记方式!' |
| | | message: '请选择标记方式!' |
| | | } |
| | | ] |
| | | })( |
| | | <Cascader options={signs} placeholder=""/> |
| | | <Cascader popupClassName="mark-type" options={signs} placeholder=""/> |
| | | )} |
| | | </Form.Item> |
| | | </Col> : null} |