/* * << * 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 from 'react' import { Form, Row, Col, Input, Radio, Tabs, Tree, Checkbox } from 'antd' import { FormComponentProps } from 'antd/lib/form/Form' const TreeNode = Tree.TreeNode const FormItem = Form.Item const TextArea = Input.TextArea const RadioGroup = Radio.Group const TabPane = Tabs.TabPane const utilStyles = require('assets/less/util.less') const styles = require('../Viz.less') import { IExludeRoles} from './PortalList' interface IProtalListProps { projectId: number type: string params?: any exludeRoles?: IExludeRoles[] onChangePermission: (scope: object, e: any) => any onCheckUniqueName?: (pathname: string, data: any, resolve: () => any, reject: (error: string) => any) => any } export class PortalForm extends React.PureComponent { private checkNameUnique = (rule, value = '', callback) => { const { onCheckUniqueName, type, form, projectId } = this.props const { id } = form.getFieldsValue() const data = { projectId, id: type === 'add' ? '' : id, name: value } if (!value) { callback() } onCheckUniqueName('dashboardPortal', data, () => { callback() }, (err) => { callback(err) }) } public render () { const { type, exludeRoles } = this.props const { getFieldDecorator } = this.props.form const authControl = exludeRoles && exludeRoles.length ? exludeRoles.map((role) => (
{role.name}
)) : [] const commonFormItemStyle = { labelCol: { span: 6 }, wrapperCol: { span: 16 } } return (
{type !== 'add' && ( {getFieldDecorator('id', {})( )} )} {getFieldDecorator('avatar', {})( )} {getFieldDecorator('name', { rules: [{ required: true, message: '名称 不能为空' }, { validator: this.checkNameUnique }] })( )} {getFieldDecorator('description', { initialValue: '' })(