Form.jsx 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. import { Row, Col, Tooltip } from 'antd'
  2. import React, { useEffect, useMemo } from 'react'
  3. import EditableForm from '@/components/EditableForm'
  4. import ChangeCompanyInput from '@/pages/Customer/Company/components/ChangeCompany'
  5. import { connect } from 'umi'
  6. import PersonLabel from '@/pages/Customer/Company/components/PersonLabel'
  7. import { Add } from '@icon-park/react'
  8. import {
  9. TagTypeEnum,
  10. TagDataTypeEnum,
  11. LabelModeType
  12. } from '@/pages/Customer/Company/components/PersonLabel/const'
  13. const ContanctForm = props => {
  14. const {
  15. client,
  16. personTagColorMap,
  17. personTags,
  18. teamTagColorMap,
  19. teamTags,
  20. dispatch,
  21. filterTag = false
  22. } = props
  23. const changeCopInputData = {
  24. customerName: client.companyName,
  25. customerId: client.companyId,
  26. targetName: client.clientName,
  27. dataId: client.id
  28. }
  29. const refreshClient = () => {
  30. dispatch({
  31. type: 'refresh/commitAction',
  32. payload: 'client'
  33. })
  34. }
  35. useEffect(() => {
  36. if (!personTags.length) {
  37. dispatch({
  38. type: 'client/fetchPersonTags',
  39. payload: { tagType: TagTypeEnum.PERSONTAG, tagColumn: TagDataTypeEnum.CLIENT }
  40. })
  41. }
  42. if (!teamTags.length) {
  43. dispatch({
  44. type: 'client/fetchTeamTags',
  45. payload: { tagType: TagTypeEnum.TEAMTAG, tagColumn: TagDataTypeEnum.CLIENT }
  46. })
  47. }
  48. }, [])
  49. const defaultCompanyValue = {
  50. districtIds: client.districtIds,
  51. address: client.address,
  52. ride: client.ride,
  53. stay: client.stay,
  54. landmarks: client.landmarks
  55. }
  56. const columns = useMemo(() => {
  57. const pColumns = [
  58. {
  59. dataIndex: 'clientName',
  60. label: '姓名',
  61. span: 24
  62. },
  63. {
  64. dataIndex: 'districtIds',
  65. label: '客户地区',
  66. editCellType: 'cascader',
  67. span: 24
  68. },
  69. {
  70. dataIndex: 'companyName',
  71. label: '单位名称',
  72. editCellType: 'custom',
  73. customCell: (
  74. <ChangeCompanyInput dataSource={changeCopInputData} defaultValue={defaultCompanyValue} />
  75. ),
  76. span: 24
  77. },
  78. {
  79. dataIndex: 'gender',
  80. label: '性别',
  81. editCellType: 'select',
  82. span: 24
  83. },
  84. {
  85. dataIndex: 'niceName',
  86. label: '昵称',
  87. span: 24
  88. },
  89. {
  90. dataIndex: 'telephone',
  91. label: '手机',
  92. span: 24
  93. },
  94. {
  95. dataIndex: 'qq',
  96. label: 'QQ',
  97. span: 24
  98. },
  99. {
  100. dataIndex: 'phone',
  101. label: '电话',
  102. span: 24
  103. },
  104. {
  105. dataIndex: 'email',
  106. label: '邮箱',
  107. span: 24
  108. },
  109. {
  110. dataIndex: 'fax',
  111. label: '传真',
  112. span: 24
  113. },
  114. {
  115. dataIndex: 'department',
  116. label: '部门',
  117. span: 24
  118. },
  119. {
  120. dataIndex: 'position',
  121. label: '职务',
  122. span: 24
  123. },
  124. {
  125. dataIndex: 'office',
  126. label: '办公室',
  127. span: 24,
  128. editCellType: 'textarea'
  129. },
  130. {
  131. dataIndex: 'address',
  132. label: '客户地址',
  133. span: 24,
  134. editCellType: 'textarea'
  135. },
  136. {
  137. dataIndex: 'ride',
  138. label: '客户乘车',
  139. span: 24,
  140. editCellType: 'textarea'
  141. },
  142. {
  143. dataIndex: 'landmarks',
  144. label: '客户地标',
  145. span: 24,
  146. editCellType: 'textarea'
  147. },
  148. {
  149. dataIndex: 'stay',
  150. label: '客户住宿',
  151. span: 24,
  152. editCellType: 'textarea'
  153. },
  154. {
  155. dataIndex: 'mark',
  156. label: '备注',
  157. span: 24,
  158. editCellType: 'textarea'
  159. },
  160. {
  161. dataIndex: 'priority',
  162. label: '优先级',
  163. span: 24,
  164. editCellType: 'select'
  165. },
  166. {
  167. dataIndex: 'sourceId',
  168. label: '来源',
  169. span: 24,
  170. editCellType: 'select'
  171. }
  172. ]
  173. if (!filterTag) {
  174. pColumns.push(
  175. {
  176. dataIndex: 'tagIds',
  177. label: '个人标签',
  178. editCellType: 'custom',
  179. customCell: (
  180. <div className="editable-cell-value-wrap text-center flex flex-wrap items-center">
  181. {client.tagIds?.map(item => (
  182. <Tooltip title={personTags.find(i => i.id === item)?.name} key={client.id + item}>
  183. <span
  184. className="inline-block w-12px h-12px rounded-1/2 mr-3px"
  185. style={{ backgroundColor: personTagColorMap[item] }}
  186. />
  187. </Tooltip>
  188. ))}
  189. <PersonLabel
  190. dataId={client.id}
  191. tagIds={client.tagIds}
  192. tagType={TagTypeEnum.PERSONTAG}
  193. tagColumn={TagDataTypeEnum.CLIENT}
  194. checkCallBack={refreshClient}
  195. modeType={LabelModeType.column}
  196. >
  197. <Add theme="filled" size="20" fill="#868e96" className="cursor-pointer" />
  198. </PersonLabel>
  199. </div>
  200. ),
  201. span: 24
  202. },
  203. {
  204. dataIndex: 'tagCooperationIds',
  205. label: '协作标签',
  206. editCellType: 'custom',
  207. customCell: (
  208. <div className="editable-cell-value-wrap text-center flex flex-wrap items-center">
  209. {client.tagCooperationIds?.map(item => (
  210. <Tooltip title={teamTags.find(i => i.id === item)?.name} key={client.id + item}>
  211. <span
  212. className="inline-block w-12px h-12px mr-3px"
  213. style={{ backgroundColor: teamTagColorMap[item] }}
  214. />
  215. </Tooltip>
  216. ))}
  217. <PersonLabel
  218. dataId={client.id}
  219. tagIds={client.tagCooperationIds}
  220. tagType={TagTypeEnum.TEAMTAG}
  221. tagColumn={TagDataTypeEnum.CLIENT}
  222. checkCallBack={refreshClient}
  223. modeType={LabelModeType.column}
  224. >
  225. <Add theme="filled" size="20" fill="#868e96" className="cursor-pointer" />
  226. </PersonLabel>
  227. </div>
  228. ),
  229. span: 24
  230. }
  231. )
  232. }
  233. return pColumns
  234. }, [client, !filterTag ? teamTags : null, !filterTag ? personTags : null])
  235. return (
  236. <div>
  237. <Row>
  238. <Col span={8}>
  239. <h2 className="text-gray-500">客户</h2>
  240. </Col>
  241. {/* className={[ 'text-right', styles.textMuted ]} */}
  242. <Col span={16} className="text-right text-gray-500">
  243. {client.staffName} 创建于{client.createTime}
  244. </Col>
  245. <Col span={22}>
  246. <h2 className="text-2xl pb-4">{client.clientName}</h2>
  247. </Col>
  248. <Col span={2} />
  249. </Row>
  250. <EditableForm
  251. dataSource={client}
  252. columns={columns}
  253. tartgetUrl="/client/update"
  254. type="client"
  255. />
  256. </div>
  257. )
  258. }
  259. export default connect(({ client }) => ({
  260. personTagColorMap: client.personTagColorMap,
  261. personTags: client.personTags,
  262. teamTagColorMap: client.teamTagColorMap,
  263. teamTags: client.teamTags
  264. }))(ContanctForm)