| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Form, Row, Col, Select, Button, InputNumber, Input, Tooltip, Icon } from 'antd' |
| | | import { formRule } from '@/utils/option.js' |
| | | import './index.scss' |
| | | import { Form, Row, Col, Select, Button, InputNumber, Input, Tooltip } from 'antd' |
| | | import { QuestionCircleOutlined } from '@ant-design/icons' |
| | | |
| | | // import './index.scss' |
| | | |
| | | class UniqueForm extends Component { |
| | | class BillCodeForm extends Component { |
| | | static propTpyes = { |
| | | dict: PropTypes.object, // 字典项 |
| | | btn: PropTypes.object, // 按钮信息 |
| | | fields: PropTypes.array, // 表单 |
| | | billcodes: PropTypes.array, // 表单 |
| | | columns: PropTypes.array, // 表单 |
| | | modular: PropTypes.array, // 表单 |
| | | modularDetail: PropTypes.array, // 表单 |
| | | orderChange: PropTypes.func // 表单 |
| | | btn: PropTypes.object, |
| | | fields: PropTypes.array, |
| | | billcodes: PropTypes.array, |
| | | columns: PropTypes.array, |
| | | modular: PropTypes.array, |
| | | modularDetail: PropTypes.array, |
| | | orderChange: PropTypes.func |
| | | } |
| | | |
| | | state = { |
| | |
| | | UNSAFE_componentWillMount() { |
| | | let _modularDetail = [] |
| | | let _billFields = [] |
| | | |
| | | if (this.props.modular.length > 0) { |
| | | _modularDetail = this.props.modularDetail.filter(item => item.BID === this.props.modular[0].ID) |
| | | } |
| | | |
| | | let fieldMap = new Map() |
| | | this.props.fields.forEach(_field => { |
| | | if (_field.type === 'text' && !fieldMap.has(_field.field)) { |
| | | if (_field.type === 'text' && !fieldMap.has(_field.field.toLowerCase())) { |
| | | _billFields.push(_field) |
| | | fieldMap.set(_field.field, true) |
| | | fieldMap.set(_field.field.toLowerCase(), true) |
| | | } |
| | | }) |
| | | |
| | | if (this.props.btn.Ot !== 'notRequired') { |
| | | this.props.columns.forEach(_field => { |
| | | if (_field.type === 'text' && !fieldMap.has(_field.field)) { |
| | | if (_field.type === 'text' && !fieldMap.has(_field.field.toLowerCase())) { |
| | | _billFields.push(_field) |
| | | fieldMap.set(_field.field, true) |
| | | fieldMap.set(_field.field.toLowerCase(), true) |
| | | } |
| | | }) |
| | | } |
| | |
| | | }, () => { |
| | | this.props.form.setFieldsValue({ |
| | | field: record.field, |
| | | Type: record.Type || 4, |
| | | TypeCharOne: record.TypeCharOne, |
| | | ModularCode: record.ModularCode, |
| | | ModularDetailCode: _modularDetailCode, |
| | |
| | | values.fieldName = _funField ? _funField.label : '' |
| | | |
| | | // 一级菜单值为20190203125926873D6029A9C511041719420时TypeCharTwo=TableCode,其他用BillCode |
| | | if (values.ModularCode === '20190203125926873D6029A9C511041719420') { |
| | | if (values.ModularCode === '20190203125926873D6029A9C511041719420' || values.ModularCode === '01') { |
| | | values.TypeCharTwo = 'TableCode' |
| | | } else { |
| | | values.TypeCharTwo = 'BillCode' |
| | |
| | | |
| | | // 设置流水号位数 |
| | | let _detail = this.state.modularDetail.filter(item => item.ModularDetailCode === values.ModularDetailCode)[0] |
| | | values.Type = _detail.Type |
| | | values.Type = values.Type || _detail.Type |
| | | } else { |
| | | let _billField = billFields.filter(item => item.field === values.linkField)[0] |
| | | values.linkFieldName = _billField ? _billField.label : '' |
| | |
| | | } |
| | | |
| | | return ( |
| | | <Form {...formItemLayout} className="verify-form"> |
| | | <Form {...formItemLayout} className="verify-form mk-fix-form-height"> |
| | | <Row gutter={24}> |
| | | <Col span={7}> |
| | | <Form.Item label={this.props.dict['header.form.funcvar']}> |
| | | <Form.Item label="函数变量"> |
| | | {getFieldDecorator('field', { |
| | | initialValue: '', |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: this.props.dict['form.required.input'] + this.props.dict['header.form.funcvar'] + '!' |
| | | message: '请选择函数变量!' |
| | | } |
| | | ] |
| | | })( |
| | | <Select> |
| | | {this.state.funFields.map(option => |
| | | <Select.Option title={option.label} id={option.uuid} key={option.uuid} value={option.field}> |
| | | {option.label} |
| | | <Select.Option key={option.uuid} value={option.field}> |
| | | {`${option.label}(${option.field})`} |
| | | </Select.Option> |
| | | )} |
| | | </Select> |
| | |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={7}> |
| | | <Form.Item label={'类型'}> |
| | | <Form.Item label="类型"> |
| | | {getFieldDecorator('TypeCharOne', { |
| | | initialValue: 'Lp', |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: this.props.dict['form.required.select'] + '类型!' |
| | | message: '请选择类型!' |
| | | } |
| | | ] |
| | | })( |
| | |
| | | </Form.Item> |
| | | </Col> |
| | | {type === '1' ? <Col span={7}> |
| | | <Form.Item label={'关联字段'}> |
| | | <Form.Item label="关联字段"> |
| | | {getFieldDecorator('linkField', { |
| | | initialValue: '', |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: this.props.dict['form.required.input'] + '关联字段!' |
| | | message: '请选择关联字段!' |
| | | } |
| | | ] |
| | | })( |
| | | <Select> |
| | | <Select showSearch filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}> |
| | | {this.state.billFields.map(option => |
| | | <Select.Option title={option.label} id={option.uuid} key={option.uuid} value={option.field}> |
| | | {option.label} |
| | | <Select.Option key={option.uuid} value={option.field}> |
| | | {`${option.label}(${option.field})`} |
| | | </Select.Option> |
| | | )} |
| | | </Select> |
| | |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {type === '2' ? <Col span={7}> |
| | | <Form.Item label={'凭证类型'}> |
| | | <Form.Item label="凭证类型"> |
| | | {getFieldDecorator('ModularCode', { |
| | | initialValue: this.props.modular[0] ? this.props.modular[0].ID : '', |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: this.props.dict['form.required.input'] + '凭证类型!' |
| | | message: '请选择凭证类型!' |
| | | } |
| | | ] |
| | | })( |
| | |
| | | onChange={(value) => {this.voucherChange(value)}} |
| | | > |
| | | {this.props.modular.map(option => |
| | | <Select.Option title={option.NameNO} id={option.ID} key={option.ID} value={option.ID}> |
| | | <Select.Option key={option.ID} value={option.ID}> |
| | | {option.NameNO} |
| | | </Select.Option> |
| | | )} |
| | |
| | | </Form.Item> |
| | | </Col> : null} |
| | | <Col span={3} className="add"> |
| | | <Button onClick={this.handleConfirm} type="primary"> |
| | | 确定 |
| | | <Button onClick={this.handleConfirm} className="mk-green"> |
| | | 保存 |
| | | </Button> |
| | | </Col> |
| | | {type === '1' ? <Col span={7}> |
| | | <Form.Item label={'位数'}> |
| | | <Col span={7}> |
| | | <Form.Item label="位数"> |
| | | {getFieldDecorator('Type', { |
| | | initialValue: 4, |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: this.props.dict['form.required.input'] + '位数!' |
| | | message: '请输入位数!' |
| | | } |
| | | ] |
| | | })(<InputNumber min={1} max={10} precision={0} />)} |
| | | })(<InputNumber min={1} max={10} precision={0} onPressEnter={this.handleConfirm}/>)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | </Col> |
| | | {type === '2' ? <Col span={7}> |
| | | <Form.Item label={'凭证标识'}> |
| | | <Form.Item label="凭证标识"> |
| | | {getFieldDecorator('ModularDetailCode', { |
| | | initialValue: this.state.modularDetail[0] ? this.state.modularDetail[0].ModularDetailCode : '', |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: this.props.dict['form.required.input'] + '凭证标识!' |
| | | message: '请选择凭证标识!' |
| | | } |
| | | ] |
| | | })( |
| | |
| | | filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} |
| | | > |
| | | {this.state.modularDetail.map(option => |
| | | <Select.Option style={{whiteSpace: 'unset'}} title={option.CodeName} id={option.ModularDetailCode} key={option.ModularDetailCode} value={option.ModularDetailCode}> |
| | | <Select.Option style={{whiteSpace: 'unset'}} key={option.ModularDetailCode} value={option.ModularDetailCode}> |
| | | {option.CodeName} |
| | | </Select.Option> |
| | | )} |
| | |
| | | </Col> : null} |
| | | {TypeCharOne === 'Lp' ? <Col span={7}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title="该标识用于生成行号规则,为空时使用按钮ID"> |
| | | <Icon type="question-circle" /> |
| | | {'标识'} |
| | | <Tooltip placement="topLeft" title="该标识用于生成行号规则"> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | 标识 |
| | | </Tooltip> |
| | | }> |
| | | {getFieldDecorator('mark', { |
| | | initialValue: '', |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: '请输入标识!' |
| | | }, |
| | | { |
| | | pattern: /^[a-zA-Z0-9]*$/ig, |
| | | message: formRule.input.letternummsg |
| | | message: '请输入数字、字母以及_' |
| | | } |
| | | ] |
| | | })(<Input placeholder="" autoComplete="off" />)} |
| | | })(<Input placeholder="" autoComplete="off" onPressEnter={this.handleConfirm}/>)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | </Row> |
| | |
| | | } |
| | | } |
| | | |
| | | export default Form.create()(UniqueForm) |
| | | export default Form.create()(BillCodeForm) |