astraSupport‌.tsx 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. import { useAjax } from '@/Hook/useAjax';
  2. import { getCorpWechatAllApi } from '@/services/adqV3/global';
  3. import { getCorpUserDayListApi, GetCorpUserDayListProps } from '@/services/adqV3/monitorEWList';
  4. import { Button, Card, DatePicker, Input, InputNumber, Select, Table } from 'antd';
  5. import React, { useEffect, useState } from 'react';
  6. import moment from 'moment';
  7. import { CorpUserDayListTableConfig } from './tableConfig';
  8. import GroupUserEdit from '../tencenTasset/corpWechat/csgroup/components/group/groupUserEdit';
  9. import { POOLTYPE } from '../tencenTasset/corpWechat/csgroup/const';
  10. /**
  11. * 客服号加粉数据
  12. * @returns
  13. */
  14. const AstraSupport: React.FC<{ localCorpCsgroupList: { label: string, value: string, type: 0 | 1 }[] }> = ({ localCorpCsgroupList }) => {
  15. /*******************************************/
  16. const [corpWechatList, setCorpWechatList] = useState<{ label: string, value: string }[]>([]);
  17. const [queryParamsNew, setQueryParamsNew] = useState<GetCorpUserDayListProps>({ pageNum: 1, pageSize: 20 });
  18. const [queryParams, setQueryParams] = useState<GetCorpUserDayListProps>({ pageNum: 1, pageSize: 20 });
  19. const [upDateAddFans, setUpDateAddFans] = useState<{ visible?: boolean, idList: number[] }>({ visible: false, idList: [] })
  20. const getCorpWechatAll = useAjax((params) => getCorpWechatAllApi(params))
  21. const getCorpUserDayList = useAjax((params) => getCorpUserDayListApi(params))
  22. /*******************************************/
  23. useEffect(() => {
  24. getCorpWechatAll.run({}).then((res) => {
  25. if (res && res.length > 0) {
  26. setCorpWechatList(res.map((item: { corpName: string; localCorpId: string; }) => ({ label: item.corpName, value: item.localCorpId })));
  27. }
  28. })
  29. }, [])
  30. useEffect(() => {
  31. getCorpUserDayList.run(queryParamsNew)
  32. }, [queryParamsNew])
  33. const updateLimitAddFansOfDay = (data: any) => {
  34. setUpDateAddFans({ visible: true, idList: [data.signId] })
  35. }
  36. return <Card
  37. title={<div style={{ display: 'flex', gap: 8 }}>
  38. <DatePicker
  39. value={queryParams?.day ? moment(queryParams.day) : undefined}
  40. onChange={(_, dateString) => {
  41. setQueryParams({ ...queryParams, day: dateString, pageNum: 1 })
  42. }}
  43. />
  44. <Select
  45. showSearch
  46. placeholder="请选择企业"
  47. filterOption={(input, option) =>
  48. ((option?.label ?? '') as any).toLowerCase().includes(input.toLowerCase())
  49. }
  50. style={{ minWidth: 140 }}
  51. allowClear
  52. mode='multiple'
  53. maxTagCount={1}
  54. value={queryParams?.corpIdList}
  55. loading={getCorpWechatAll.loading}
  56. onChange={(e) => {
  57. setQueryParams({ ...queryParams, corpIdList: e, pageNum: 1 })
  58. }}
  59. options={corpWechatList}
  60. />
  61. <Select
  62. showSearch
  63. placeholder="请选择本地客服组"
  64. filterOption={(input, option) =>
  65. ((option?.label ?? '') as any).toLowerCase().includes(input.toLowerCase())
  66. }
  67. style={{ width: 200 }}
  68. allowClear
  69. value={queryParams?.localCsgroupId}
  70. onChange={(e) => {
  71. setQueryParams({ ...queryParams, localCsgroupId: e, pageNum: 1 })
  72. }}
  73. options={localCorpCsgroupList?.filter(item => item.type === 1)}
  74. />
  75. <Select
  76. showSearch
  77. placeholder="归属客服池"
  78. filterOption={(input, option) =>
  79. ((option?.label ?? '') as any).toLowerCase().includes(input.toLowerCase())
  80. }
  81. disabled={!queryParams?.localCsgroupId}
  82. allowClear
  83. value={queryParams?.poolType}
  84. onChange={(e) => {
  85. setQueryParams({ ...queryParams, poolType: e, pageNum: 1 })
  86. }}
  87. options={Object.keys(POOLTYPE).map((key) => ({ label: POOLTYPE[key as keyof typeof POOLTYPE], value: key }))}
  88. />
  89. <Input value={queryParams?.corpUserName} style={{ width: 140 }} placeholder='客服号名称' onChange={(e) => setQueryParams({ ...queryParams, corpUserName: e.target.value, pageNum: 1 })} allowClear />
  90. <InputNumber value={queryParams?.addFansMin} placeholder='新增粉丝数最小值' style={{ width: 150 }} onChange={(e) => setQueryParams({ ...queryParams, addFansMin: e, pageNum: 1 })} />
  91. <InputNumber value={queryParams?.addFansMax} placeholder='新增粉丝数最大值' style={{ width: 150 }} onChange={(e) => setQueryParams({ ...queryParams, addFansMax: e, pageNum: 1 })} />
  92. <Button type='primary' onClick={() => {
  93. setQueryParamsNew({ ...queryParams })
  94. }}>搜索</Button>
  95. </div>}
  96. headStyle={{ padding: '0 16px' }}
  97. bodyStyle={{ padding: 16 }}
  98. >
  99. <Table
  100. dataSource={getCorpUserDayList?.data?.records}
  101. columns={CorpUserDayListTableConfig(updateLimitAddFansOfDay)}
  102. size='small'
  103. bordered
  104. rowKey={'id'}
  105. loading={getCorpUserDayList.loading}
  106. scroll={{ x: 1200 }}
  107. pagination={{
  108. total: getCorpUserDayList.data?.total,
  109. defaultPageSize: 20,
  110. current: queryParamsNew.pageNum,
  111. pageSize: queryParamsNew.pageSize,
  112. }}
  113. onChange={(pagination, _, sorter: any) => {
  114. const { current, pageSize } = pagination
  115. const newQueryForm = JSON.parse(JSON.stringify(queryParams))
  116. const newQueryFormNew = JSON.parse(JSON.stringify(queryParamsNew))
  117. if (sorter && sorter?.order) {
  118. newQueryForm['sortAsc'] = sorter?.order === 'ascend' ? true : false
  119. newQueryForm['sortFiled'] = sorter?.field
  120. newQueryFormNew['sortAsc'] = sorter?.order === 'ascend' ? true : false
  121. newQueryFormNew['sortFiled'] = sorter?.field
  122. } else {
  123. delete newQueryForm['sortAsc']
  124. delete newQueryForm['sortFiled']
  125. delete newQueryFormNew['sortAsc']
  126. delete newQueryFormNew['sortFiled']
  127. }
  128. newQueryForm.pageNum = current || newQueryForm.pageNum
  129. newQueryForm.pageSize = pageSize || newQueryForm.pageSize
  130. newQueryFormNew.pageNum = current || newQueryFormNew.pageNum
  131. newQueryFormNew.pageSize = pageSize || newQueryFormNew.pageSize
  132. setQueryParamsNew({ ...newQueryFormNew })
  133. setQueryParams({ ...newQueryForm })
  134. }}
  135. />
  136. {/* 修改单日限制加粉 */}
  137. {upDateAddFans?.visible && <GroupUserEdit
  138. {...upDateAddFans}
  139. isUpdatePoolType={false}
  140. onChange={() => {
  141. setUpDateAddFans({ visible: false, idList: [] })
  142. getCorpUserDayList.refresh()
  143. }}
  144. onClose={() => {
  145. setUpDateAddFans({ visible: false, idList: [] })
  146. }}
  147. />}
  148. </Card>
  149. };
  150. export default React.memo(AstraSupport);