/* * << * Davinci * == * Copyright (C) 2016 - 2017 EDP * == * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * >> */ import React, { useState } from 'react' import { Form, Row, Col, Select, InputNumber } from 'antd' const FormItem = Form.Item const { Option } = Select import { FormItemProps, FormComponentProps } from 'antd/lib/form' export type PollingSetting = { polling: 'true' | 'false' frequency?: number } const FormItemStyle: Partial = { labelCol: { xl: 8, lg: 10, md: 14, sm: 8 }, wrapperCol: { xl: 14, lg: 12, md: 10, sm: 14 } } type PollingConfigProps = Partial & FormComponentProps const PollingConfig: React.FC = (props) => { const { form, polling, frequency } = props const { getFieldDecorator } = form const currentPolling = form.getFieldValue('polling') return (
{getFieldDecorator('polling', { initialValue: polling || 'false' })( )} {currentPolling === 'true' && ( {getFieldDecorator('frequency', { rules: [ { required: true, message: '时长不能为空' } ], initialValue: frequency })()} )}
) } export default Form.create()(PollingConfig)