ReminderList.jsx 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. import React, { useState } from 'react'
  2. import consts from '@/consts'
  3. import { connect } from 'umi'
  4. import ProTable from '@ant-design/pro-table'
  5. import { useModal } from '@/components/Modal'
  6. import { queryReminderList } from '@/services/dashboard'
  7. // import styles from '@/pages/Customer/Company/components/ConnectCompany/index.less'
  8. import CustomModal from '@/components/Modal/src/components/CustomModal'
  9. import ContactDetail from '@/pages/Customer/Client/components/ClientDetail'
  10. import CompanyDetail from '@/pages/Customer/Company/components/CompanyDetail'
  11. import Detail from '@/pages/Customer/Business/components/BusinessDetail'
  12. const ReminderList = props => {
  13. // const dispatch = useDispatch()
  14. const { dataType, reminderCyclical } = props
  15. const { toggleDrawer, setDrawerProps } = useModal()
  16. const [state] = useState({
  17. orderIds: []
  18. })
  19. // const [state, setState] = useState({
  20. // params: { dataType, reminderCyclical }
  21. // })
  22. // 展示客户
  23. const showDrawer = id => {
  24. setDrawerProps({
  25. zIndex: 1001,
  26. closable: true,
  27. onClose: () => toggleDrawer(),
  28. bodyStyle: {
  29. height: '100vh'
  30. // overflowY: 'hidden'
  31. },
  32. children: <ContactDetail dataId={id} orderIds={state.orderIds} />
  33. })
  34. toggleDrawer()
  35. }
  36. // 展示单位
  37. const showDrawerComapny = id => {
  38. setDrawerProps({
  39. zIndex: 1001,
  40. closable: true,
  41. onClose: () => toggleDrawer(),
  42. bodyStyle: {
  43. height: '100vh'
  44. // overflowY: 'hidden'
  45. },
  46. children: <CompanyDetail dataId={id} orderIds={state.orderIds} />
  47. })
  48. toggleDrawer()
  49. }
  50. // 展示商机详情
  51. const showDrawerBusiness = (id, isCompany = false) => {
  52. setDrawerProps({
  53. zIndex: 1001,
  54. closable: true,
  55. onClose: () => toggleDrawer(),
  56. bodyStyle: {
  57. height: '100vh',
  58. overflowY: 'hidden'
  59. },
  60. children: isCompany ? (
  61. <CompanyDetail dataId={id} />
  62. ) : (
  63. <Detail dataId={id} orderIds={state.orderIds} />
  64. )
  65. })
  66. toggleDrawer()
  67. }
  68. const clientColumns = [
  69. {
  70. title: '客户名称',
  71. dataIndex: 'clientName',
  72. ellipsis: true,
  73. width: '10%',
  74. render: (clientName, record) => (
  75. <span
  76. onClick={() => showDrawer(record.id)}
  77. className="text-primary cursor-pointer hover:text-[#967bbd]">
  78. {clientName}
  79. </span>
  80. )
  81. },
  82. {
  83. title: '单位名称',
  84. dataIndex: 'companyName',
  85. width: '15%',
  86. ellipsis: true,
  87. render: (companyName, record) => (
  88. <span
  89. onClick={() => showDrawerComapny(record.companyId)}
  90. className="text-primary cursor-pointer hover:text-[#967bbd]">
  91. {companyName}
  92. </span>
  93. )
  94. },
  95. {
  96. title: '地区',
  97. dataIndex: 'districtName',
  98. ellipsis: true,
  99. width: '15%',
  100. renderText: text => text?.replaceAll(' / ', ' , ')
  101. },
  102. {
  103. title: '手机',
  104. dataIndex: 'telephone',
  105. ellipsis: true,
  106. width: '10%'
  107. },
  108. {
  109. title: '服务日期',
  110. dataIndex: 'serviceDate',
  111. ellipsis: true,
  112. width: '8%'
  113. },
  114. {
  115. title: '服务内容',
  116. dataIndex: 'serviceContent',
  117. width: '26%',
  118. ellipsis: true
  119. },
  120. {
  121. title: '备忘时间',
  122. dataIndex: 'memoDate',
  123. width: '10%',
  124. ellipsis: true
  125. },
  126. {
  127. title: '备忘内容',
  128. dataIndex: 'memoContent',
  129. width: '27%',
  130. ellipsis: true
  131. }
  132. ]
  133. const customerColumns = [
  134. {
  135. title: '单位名称',
  136. dataIndex: 'companyName',
  137. width: '15%',
  138. ellipsis: true,
  139. render: (companyName, record) => (
  140. <span
  141. onClick={() => showDrawerComapny(record.id)}
  142. className="text-primary cursor-pointer hover:text-[#967bbd]">
  143. {companyName}
  144. </span>
  145. )
  146. },
  147. {
  148. title: '地区',
  149. dataIndex: 'districtName',
  150. width: '15%',
  151. ellipsis: true,
  152. renderText: text => text?.replaceAll(' / ', ' , ')
  153. },
  154. {
  155. title: '电话',
  156. dataIndex: 'phone',
  157. width: '10%',
  158. ellipsis: true
  159. },
  160. {
  161. title: '服务日期',
  162. dataIndex: 'serviceDate',
  163. width: '8%',
  164. ellipsis: true
  165. },
  166. {
  167. title: '服务内容',
  168. dataIndex: 'serviceContent',
  169. width: '24%',
  170. ellipsis: true
  171. },
  172. {
  173. title: '备忘时间',
  174. dataIndex: 'memoDate',
  175. width: '10%',
  176. ellipsis: true
  177. },
  178. {
  179. title: '备忘内容',
  180. dataIndex: 'memoContent',
  181. width: '22%',
  182. ellipsis: true
  183. }
  184. ]
  185. const businessColumns = [
  186. {
  187. title: '商机名称',
  188. dataIndex: 'name',
  189. width: '15%',
  190. ellipsis: true,
  191. render: (text, record) => (
  192. <span
  193. onClick={() => showDrawerBusiness(record.id)}
  194. className="text-primary cursor-pointer hover:text-[#967bbd]">
  195. {text}
  196. </span>
  197. )
  198. },
  199. {
  200. title: '单位名称',
  201. dataIndex: 'customerName',
  202. width: '15%',
  203. ellipsis: true
  204. },
  205. {
  206. title: '服务日期',
  207. dataIndex: 'serviceDate',
  208. width: '8%',
  209. ellipsis: true
  210. },
  211. {
  212. title: '服务内容',
  213. dataIndex: 'serviceContent',
  214. width: '27%',
  215. ellipsis: true
  216. },
  217. {
  218. title: '备忘时间',
  219. dataIndex: 'memoDate',
  220. width: '10%',
  221. ellipsis: true
  222. },
  223. {
  224. title: '备忘内容',
  225. dataIndex: 'memoContent',
  226. width: '25%',
  227. ellipsis: true
  228. }
  229. ]
  230. const dataMap = {
  231. 0: {
  232. key: 'client',
  233. columns: clientColumns
  234. },
  235. 1: {
  236. key: 'customer',
  237. columns: customerColumns
  238. },
  239. 2: {
  240. key: 'business',
  241. columns: businessColumns
  242. }
  243. }
  244. const titleMap = {
  245. 0: { title: '客户' },
  246. 1: { title: '单位' },
  247. 2: { title: '商机' }
  248. }
  249. // const closeModal = () => {
  250. // dispatch({
  251. // type: 'single/changeModal'
  252. // })
  253. // }
  254. return (
  255. <CustomModal title={titleMap[dataType].title}>
  256. <div className="mx-4">
  257. <ProTable
  258. size="small"
  259. rowKey={record => record.id}
  260. columns={dataMap[dataType].columns}
  261. params={{ dataType, reminderCyclical }}
  262. scroll={{ y: 400 }}
  263. request={async params => {
  264. const { code = -1, data } = await queryReminderList({ ...params })
  265. return {
  266. data: data[dataMap[dataType].key],
  267. success: code === consts.RET_CODE.SUCCESS,
  268. total: data.total
  269. }
  270. }}
  271. scroll={{ y: 400 }}
  272. pagination={{ defaultPageSize: 10 }}
  273. search={false}
  274. toolBarRender={false}
  275. />
  276. </div>
  277. {/* <div className={styles.modalFooter}>
  278. <div className="text-right">
  279. <Button type="button" onClick={closeModal}>
  280. 关闭
  281. </Button>
  282. </div>
  283. </div> */}
  284. </CustomModal>
  285. )
  286. }
  287. export default connect(({ single }) => ({
  288. visible: single.drawer.visible
  289. }))(ReminderList)