RelRoleMember.tsx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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, Radio, Steps, Transfer } from 'antd'
  22. import { FormComponentProps } from 'antd/lib/form/Form'
  23. interface IRoleFormProps {
  24. form: any
  25. groupSource?: any[]
  26. groupTarget?: any[]
  27. onGroupChange?: (targets) => any
  28. organizationMembers?: any[]
  29. }
  30. export class RelRoleMember extends React.PureComponent<IRoleFormProps & FormComponentProps, {}> {
  31. private getTransferRowKey = (g) => g.user.id
  32. private transferRender = (item) => item.user.username
  33. private onTransferChange = (cb) => (nextTargetKeys, direction, moveKeys) => {
  34. cb(nextTargetKeys)
  35. }
  36. public render () {
  37. const {
  38. organizationMembers,
  39. groupTarget,
  40. onGroupChange
  41. } = this.props
  42. const groupTransfer =
  43. (
  44. <Transfer
  45. showSearch
  46. titles={['列表', '已选']}
  47. listStyle={{width: '210px'}}
  48. dataSource={organizationMembers}
  49. rowKey={this.getTransferRowKey}
  50. targetKeys={groupTarget}
  51. render={this.transferRender}
  52. onChange={this.onTransferChange(onGroupChange)}
  53. />
  54. )
  55. return (
  56. <Row>
  57. <Col span={24}>
  58. {groupTransfer}
  59. </Col>
  60. </Row>
  61. )
  62. }
  63. }
  64. export default Form.create<IRoleFormProps & FormComponentProps>()(RelRoleMember)