index.jsx 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. import React, { useEffect, useRef, useMemo, useState, useCallback } from 'react'
  2. import { Button, Card, Cascader, Dropdown, Input, Menu, Select, Pagination } from 'antd'
  3. import EditableForm from '@/components/EditableForm'
  4. import { useModal } from '@/components/Modal'
  5. import { connect } from 'dva'
  6. import SearchModal from '@/pages/Customer/Contact/components/CustomerModal'
  7. import ChangeCompanyInput from '../Contact/components/ChangeCompany'
  8. import PersonLabel from '../Company/components/PersonLabel'
  9. import { TagTypeEnum } from '../Company/components/PersonLabel'
  10. import { TagDataTypeEnum } from '../Company/components/PersonLabel'
  11. const { Option } = Select
  12. const Test = ({ natures, dispatch }) => {
  13. const { toggleModal, setModalProps } = useModal()
  14. const [state, setState] = useState(null)
  15. const iRef = useRef(null)
  16. const options = [
  17. {
  18. value: 'zhejiang',
  19. label: 'Zhejiang',
  20. children: [
  21. {
  22. value: 'hangzhou',
  23. label: 'Hangzhou',
  24. children: [
  25. {
  26. value: 'xihu',
  27. label: 'West Lake'
  28. }
  29. ]
  30. }
  31. ]
  32. },
  33. {
  34. value: 'jiangsu',
  35. label: 'Jiangsu',
  36. children: [
  37. {
  38. value: 'nanjing',
  39. label: 'Nanjing',
  40. children: [
  41. {
  42. value: 'zhonghuamen',
  43. label: 'Zhong Hua Men'
  44. }
  45. ]
  46. }
  47. ]
  48. }
  49. ]
  50. const record = {
  51. address: '珠海',
  52. clientName: '啊实打实大',
  53. age: 16
  54. }
  55. const columns = [
  56. {
  57. dataIndex: 'address',
  58. label: '珠海',
  59. span: 12
  60. },
  61. {
  62. dataIndex: 'clientName',
  63. label: '名字',
  64. span: 12
  65. },
  66. {
  67. dataIndex: 'age',
  68. label: '年龄',
  69. span: 24
  70. }
  71. ]
  72. const onClick = () => {
  73. setModalProps({
  74. modalRender: node => <SearchModal node={node} />,
  75. onCancel: () => toggleModal()
  76. })
  77. toggleModal()
  78. }
  79. useEffect(() => {
  80. const initNatures = () => {
  81. dispatch({
  82. type: 'customer/fetch'
  83. })
  84. }
  85. !natures.length && initNatures()
  86. }, [])
  87. // const a = useMemo(() => {
  88. // const e = null
  89. // const b = 2
  90. // const c = e ?? b
  91. // console.log('c', c)
  92. // }, [state])
  93. // const customOptions = useCallback(originNode => {
  94. // return originNode
  95. // }, [])
  96. const menu = (
  97. <Menu>
  98. <Menu.Item key="1">1st menu item</Menu.Item>
  99. <Menu.Item key="2">2nd menu item</Menu.Item>
  100. <Menu.Item key="3">3rd menu item</Menu.Item>
  101. </Menu>
  102. )
  103. // const measuredRef = useCallback(node => {
  104. // if (node) {
  105. // console.log(node.getBoundingClientRect)
  106. // }
  107. // })
  108. return (
  109. <Card bordered={false}>
  110. {/* <EditableForm dataSource={record} columns={columns} /> */}
  111. {/* <Button onClick={onClick}>click</Button> */}
  112. {/* <Cascader ref={iRef} options={options} /> */}
  113. {/* <ChangeCompanyInput /> */}
  114. <div className="zh-width-100P">
  115. <Dropdown overlay={menu} trigger={['click']}>
  116. <Input />
  117. </Dropdown>
  118. </div>
  119. <Button
  120. onClick={() => {
  121. setState('123')
  122. }}>
  123. AAA
  124. </Button>
  125. {/* <Select
  126. ref={iRef}
  127. onBlur={() => console.log(22)}
  128. // onChange={() => console.log(iRef)}
  129. options={options}
  130. style={{ width: '200px' }}
  131. /> */}
  132. <PersonLabel tagType={TagTypeEnum.PERSONTAG} tagColumn={TagDataTypeEnum.CONTACT}>
  133. <Button>2222</Button>
  134. </PersonLabel>
  135. <Pagination
  136. total={500}
  137. onChange={(page, size) => {
  138. console.log(page, size)
  139. }}
  140. />
  141. </Card>
  142. )
  143. }
  144. export default connect(({ customer }) => ({
  145. natures: customer.natures
  146. }))(Test)