otherConfig.jsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import React from 'react'
  2. import { Button, Form, Row, Col, Input, InputNumber, Select, Icon, Menu, Dropdown, Divider, Upload, message } from 'antd'
  3. const FormItem = Form.Item
  4. const SelectOption = Select.Option
  5. const OptionGroup = Select.OptGroup
  6. const InputGroup = Input.Group
  7. const SubMenu = Menu.SubMenu
  8. const MenuItem = Menu.Item
  9. const MenuItemGroup = Menu.ItemGroup
  10. const UploadDragger = Upload.Dragger
  11. import { connect } from 'dva'
  12. import '../../models/dataSource'
  13. import '../../models/dataConnect'
  14. const OtherConfig = ({ dataSource, dataConnect, dispatch, mode }) => {
  15. const formItemLayout = {
  16. labelCol: { span: 4 },
  17. wrapperCol: { span: 20 },
  18. };
  19. const dataSourceLinkMenu = (
  20. <Menu
  21. className='menu-datasource-link'
  22. onClick={(e) => {
  23. const model = dataConnect.list[e.key];
  24. dispatch({ type: 'dataSource/setNewModelFields', fields: [
  25. { name: 'address', value: model.address },
  26. { name: 'port', value: model.port },
  27. { name: 'dbType', value: model.dbType },
  28. { name: 'dbName', value: model.dbName },
  29. { name: 'userName', value: model.userName },
  30. { name: 'password', value: model.password }
  31. ] });
  32. }}
  33. >
  34. {
  35. dataConnect.list.map((l, i) => {
  36. return <MenuItem key={i}>{l.name}</MenuItem>
  37. })
  38. }
  39. </Menu>
  40. );
  41. return (
  42. <Form className='form-base' size='small'>
  43. <FormItem label='数据源名称' {...formItemLayout}>
  44. <Input
  45. value={dataSource.newOne.name}
  46. onChange={(e) => { dispatch({ type: 'dataSource/setNewModelField', name: 'name', value: e.target.value }) }}>
  47. </Input>
  48. </FormItem>
  49. <FormItem label='标签' {...formItemLayout}>
  50. <Select
  51. mode="tags"
  52. placeholder='多个标签使用逗号或空格分隔'
  53. tokenSeparators={[',', ' ']}
  54. value={dataSource.newOne.tags}
  55. dropdownStyle={{display: 'none'}}
  56. onChange={(value) => {
  57. dispatch({ type: 'dataSource/setNewModelField', name: 'tags', value: value });
  58. }}
  59. >
  60. </Select>
  61. </FormItem>
  62. <FormItem className='textarea-desc' label='说明' {...formItemLayout}>
  63. <Input.TextArea
  64. autosize={{ minRows: 2, maxRows: 5 }}
  65. value={dataSource.newOne.description}
  66. onChange={(e) => {
  67. dispatch({ type: 'dataSource/setNewModelField', name: 'description', value: e.target.value });
  68. }}
  69. />
  70. </FormItem>
  71. </Form>
  72. );
  73. }
  74. function mapStateToProps({ present: {dataSource, dataConnect} }) {
  75. return { dataSource, dataConnect }
  76. }
  77. export default connect(mapStateToProps)(OtherConfig);