OrganizationForm.tsx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * <<
  3. * Davinci
  4. * ==
  5. * Copyright (C) 2016 - 2017 EDP
  6. * ==
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. * >>
  19. */
  20. import React from 'react'
  21. import { Form, Row, Col, Input, Button } from 'antd'
  22. import { FormComponentProps } from 'antd/lib/form/Form'
  23. const FormItem = Form.Item
  24. const TextArea = Input.TextArea
  25. const styles = require('../Organization.less')
  26. const utilStyles = require('assets/less/util.less')
  27. interface IProjectsFormProps {
  28. form: any
  29. modalLoading: boolean
  30. onModalOk: () => any
  31. onCheckUniqueName: (pathname: any, data: any, resolve: () => any, reject: (error: string) => any) => any
  32. }
  33. export class OrganizationForm extends React.PureComponent<IProjectsFormProps & FormComponentProps, {}> {
  34. public render () {
  35. const { getFieldDecorator } = this.props.form
  36. const { modalLoading } = this.props
  37. const commonFormItemStyle = {
  38. labelCol: { span: 3 },
  39. wrapperCol: { span: 24}
  40. }
  41. const modalButtons = [(
  42. <Button
  43. key="submit"
  44. type="primary"
  45. loading={modalLoading}
  46. disabled={modalLoading}
  47. onClick={this.props.onModalOk}
  48. >
  49. 保 存
  50. </Button>
  51. )]
  52. return (
  53. <div className={styles.formWrapper}>
  54. <div className={styles.header}>
  55. <div className={styles.title}>
  56. 创建组织
  57. </div>
  58. <div className={styles.desc}>
  59. {/* 用户创建组织,邀请成员加入,创建团队 */}
  60. </div>
  61. </div>
  62. <div className={styles.body}>
  63. <Form>
  64. <Row gutter={8}>
  65. <Col span={24}>
  66. <FormItem label="名称" {...commonFormItemStyle}>
  67. {getFieldDecorator('name', {
  68. rules: [{
  69. required: true,
  70. message: 'Name 不能为空'
  71. }, {
  72. validator: this.props.onCheckUniqueName
  73. }],
  74. validateFirst: true
  75. })(
  76. <Input placeholder="Name" />
  77. )}
  78. </FormItem>
  79. </Col>
  80. <Col span={24}>
  81. <FormItem label="描述" {...commonFormItemStyle}>
  82. {getFieldDecorator('description', {
  83. initialValue: ''
  84. })(
  85. <TextArea
  86. placeholder="Description"
  87. autosize={{minRows: 2, maxRows: 6}}
  88. />
  89. )}
  90. </FormItem>
  91. </Col>
  92. </Row>
  93. </Form>
  94. </div>
  95. <div className={styles.footer}>
  96. {modalButtons}
  97. </div>
  98. </div>
  99. )
  100. }
  101. }
  102. export default Form.create<IProjectsFormProps & FormComponentProps>()((OrganizationForm))