RatioPanels.jsx 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. import React, { useState } from 'react'
  2. import ProTable from '@ant-design/pro-table'
  3. import CustomModal from '@/components/Modal/src/components/CustomModal'
  4. import { queryRatioPanelsList, queryServiceRatioPanelsList } from '@/services/dashboard'
  5. import consts from '@/consts'
  6. import { servicelogEnum } from '@/pages/Customer/Company/components/CompanyDetail/LowerList'
  7. // import ClientDetail from '@/pages/Customer/Client/components/ClientDetail'
  8. import { Badge } from 'antd'
  9. import { cardTypeMap } from '../consts'
  10. // import { useModal } from '@/components/Modal'
  11. const dataTypeEunm = {
  12. 0: {
  13. key: 'client',
  14. title: '新增联系人'
  15. },
  16. 1: {
  17. key: 'customer',
  18. title: '新增客户'
  19. },
  20. 2: {
  21. key: 'business',
  22. title: '新增商机'
  23. },
  24. 3: {
  25. key: 'service',
  26. title: '新增服务记录'
  27. }
  28. }
  29. const renderBadge = (count, active = false) => {
  30. return active ? (
  31. <Badge
  32. count={count}
  33. style={{
  34. marginTop: -2,
  35. marginLeft: 4,
  36. color: '#531dab',
  37. backgroundColor: '#f9f0ff'
  38. }}
  39. />
  40. ) : null
  41. }
  42. /** 服务环比数据Tab切换表格 */
  43. const ServiceRatioPanels = ({ staffIds, cyclical, dataPermission }) => {
  44. const activeKeyMap = {
  45. 0: { key: 'clientName', title: '联系人' },
  46. 1: { key: 'customerName', title: '客户' },
  47. 2: { key: 'businessName', title: '商机' }
  48. }
  49. const [state, setState] = useState({
  50. activeKey: '0',
  51. total: 0
  52. })
  53. const columns = [
  54. {
  55. dataIndex: activeKeyMap[state.activeKey].key,
  56. title: `${activeKeyMap[state.activeKey].title}名称`,
  57. width: '20%'
  58. },
  59. {
  60. dataIndex: 'status',
  61. title: '服务类型',
  62. width: '15%',
  63. render: type => servicelogEnum[type]
  64. },
  65. {
  66. dataIndex: 'date',
  67. title: '服务日期',
  68. width: '15%',
  69. valueType: 'date'
  70. },
  71. {
  72. dataIndex: 'mark',
  73. width: '45%',
  74. title: '服务内容'
  75. }
  76. ]
  77. return (
  78. <ProTable
  79. size="small"
  80. params={{ dataType: state.activeKey, cyclical, dataPermission, staffIds }}
  81. rowKey={record => record.id}
  82. scroll={{ y: 400 }}
  83. border={true}
  84. columns={columns}
  85. search={false}
  86. toolbar={{
  87. settings: false,
  88. menu: {
  89. type: 'tab',
  90. activeKey: state.activeKey,
  91. items: [
  92. {
  93. key: '0',
  94. label: (
  95. <span>
  96. 联系人
  97. {renderBadge(state.total, state.activeKey === '0')}
  98. </span>
  99. )
  100. },
  101. {
  102. key: '1',
  103. label: (
  104. <span>
  105. 客户
  106. {renderBadge(state.total, state.activeKey === '1')}
  107. </span>
  108. )
  109. },
  110. {
  111. key: '2',
  112. label: (
  113. <span>
  114. 商机
  115. {renderBadge(state.total, state.activeKey === '2')}
  116. </span>
  117. )
  118. }
  119. ],
  120. onChange: key => {
  121. setState({ ...state, activeKey: key })
  122. // redoHeight()
  123. }
  124. }
  125. }}
  126. pagination={{ defaultPageSize: 10, showQuickJumper: true }}
  127. request={async params => {
  128. const { code = -1, data } = await queryServiceRatioPanelsList(params)
  129. setState({ ...state, total: data.total || 0 })
  130. return {
  131. data: data.log,
  132. success: code === consts.RET_CODE.SUCCESS,
  133. total: data.total
  134. }
  135. }}
  136. />
  137. )
  138. }
  139. const RatioPanels = ({ dataType, staffIds, retioCyclical, dataPermission }) => {
  140. // const { toggleDrawer, setDrawerProps } = useModal()
  141. // const [state, setState] = useState({
  142. // orderIds: []
  143. // })
  144. // const showDrawer = id => {
  145. // setDrawerProps({
  146. // zIndex: '1200',
  147. // closable: true,
  148. // onClose: () => toggleDrawer(),
  149. // bodyStyle: {
  150. // height: '100vh',
  151. // overflowY: 'hidden'
  152. // },
  153. // children: <ClientDetail dataId={id} orderIds={state.orderIds} />
  154. // })
  155. // toggleDrawer()
  156. // }
  157. const columnsMap = {
  158. 0: [
  159. {
  160. dataIndex: 'clientName',
  161. title: '联系人名称',
  162. width: '13%',
  163. render: (clientName, record) => (
  164. <span
  165. onClick={() => showDrawer(record.id)}
  166. className="text-primary cursor-pointer hover:text-[#967bbd]">
  167. {clientName}
  168. </span>
  169. )
  170. },
  171. {
  172. dataIndex: 'companyName',
  173. title: '客户名称',
  174. width: '20%'
  175. },
  176. {
  177. dataIndex: 'districtName',
  178. title: '地区',
  179. width: '15%'
  180. },
  181. {
  182. dataIndex: 'phone',
  183. title: '手机',
  184. width: '5%'
  185. },
  186. {
  187. dataIndex: 'email',
  188. title: '邮箱',
  189. width: '7%'
  190. },
  191. {
  192. dataIndex: 'qq',
  193. title: 'QQ',
  194. width: '5%'
  195. },
  196. {
  197. dataIndex: 'createTime',
  198. title: '创建时间',
  199. width: '7%'
  200. }
  201. ],
  202. 1: [
  203. {
  204. dataIndex: 'companyName',
  205. title: '客户名称',
  206. width: '20%'
  207. },
  208. {
  209. dataIndex: 'districtName',
  210. title: '地区',
  211. width: '15%'
  212. },
  213. {
  214. dataIndex: 'nature',
  215. title: '客户性质',
  216. ellipsis: true,
  217. width: '15%'
  218. },
  219. {
  220. dataIndex: 'phone',
  221. title: '客户电话',
  222. width: '5%'
  223. },
  224. {
  225. dataIndex: 'createTime',
  226. title: '创建时间',
  227. width: '10%'
  228. }
  229. ],
  230. 2: [
  231. {
  232. dataIndex: 'name',
  233. title: '商机名称',
  234. width: '15%'
  235. },
  236. {
  237. dataIndex: 'customerName',
  238. title: '客户名称',
  239. width: '20%'
  240. },
  241. {
  242. dataIndex: 'businessStatusName',
  243. title: '商机状态',
  244. width: '5%'
  245. },
  246. {
  247. dataIndex: 'price',
  248. title: '商机金额',
  249. width: '5%'
  250. },
  251. {
  252. dataIndex: 'createTime',
  253. title: '创建时间',
  254. width: '7%'
  255. }
  256. ]
  257. }
  258. return (
  259. <CustomModal title={`卡片详情(${dataTypeEunm[dataType].title})`}>
  260. <div className="pb-4">
  261. {dataType === cardTypeMap.SERVICE ? (
  262. <ServiceRatioPanels
  263. cyclical={retioCyclical}
  264. dataPermission={dataPermission}
  265. staffIds={staffIds}
  266. />
  267. ) : (
  268. <div className="mx-4">
  269. <ProTable
  270. size="small"
  271. border={true}
  272. pagination={{ defaultPageSize: 10 }}
  273. rowKey={record => record.id}
  274. scroll={{ y: 400 }}
  275. columns={columnsMap[dataType]}
  276. params={{ dataType, dataPermission, cyclical: retioCyclical, staffIds }}
  277. request={async params => {
  278. const { code = -1, data } = await queryRatioPanelsList(params)
  279. return {
  280. data: data[dataTypeEunm[dataType].key],
  281. success: code === consts.RET_CODE.SUCCESS,
  282. total: data.total
  283. }
  284. }}
  285. search={false}
  286. toolBarRender={false}
  287. />
  288. </div>
  289. )}
  290. </div>
  291. {/* <div className={styles.modalFooter}>
  292. <div className="text-right">
  293. <Button type="button" onClick={closeModal}>
  294. 关闭
  295. </Button>
  296. </div>
  297. </div> */}
  298. </CustomModal>
  299. )
  300. }
  301. export default RatioPanels