index.tsx 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. import { useAjax } from "@/Hook/useAjax"
  2. import { PlayerListProps, getPlayerListApi, getUserInfotApi, getUserUpdateApi, interdictionGamerApi } from "@/services/gameData/player"
  3. import React, { useEffect, useState } from "react"
  4. import columns12 from "./tableConfig"
  5. import TableData from "../../components/TableData"
  6. import QueryForm from "@/components/QueryForm"
  7. import moment from "moment"
  8. import { getPresetsRanking } from "@/components/QueryForm/const"
  9. import { message } from "antd"
  10. import ExportH5Modal from "./exportH5Modal"
  11. import Look from "./look"
  12. let ajax: any = null, ajax1: any = null
  13. const List: React.FC = () => {
  14. /************************/
  15. const [queryForm, setQueryForm] = useState<PlayerListProps>({ pageNum: 1, pageSize: 50, sourceSystem: 'ZX_ONE' })
  16. const [lookShow, setLookShow] = useState<boolean>(false) // 新增标签控制弹窗
  17. const [exportData, setExportData] = useState<any>({})
  18. const [exportShow, setExportShow] = useState<boolean>(false)
  19. const getPlayerList = useAjax((params) => getPlayerListApi(params))
  20. ajax = getPlayerList
  21. const getUserInfo = useAjax((params) => getUserInfotApi(params))
  22. ajax1 = getUserInfo
  23. const interdictionGamer = useAjax((params) => interdictionGamerApi(params))
  24. const getUserUpdate = useAjax((params) => getUserUpdateApi(params))
  25. /************************/
  26. useEffect(() => {
  27. getPlayerList.run(queryForm)
  28. }, [queryForm])
  29. // 查看详情
  30. const lookHandle = (data: any) => {
  31. setLookShow(true)
  32. getUserInfo.run(data)
  33. }
  34. //编辑玩家按钮
  35. const exportH5 = (data: any) => {
  36. setExportData({
  37. username: data?.username,
  38. mobile: data?.mobile,
  39. userId: data.id
  40. })
  41. setExportShow(true)
  42. }
  43. // 封禁
  44. const interdictionHandle = (userId: number, status: number) => {
  45. interdictionGamer.run({ userId, status }).then(res => {
  46. if (res) {
  47. message.success(status === 1 ? '封禁成功!' : '解封成功!');
  48. ajax.refresh();
  49. } else {
  50. message.error(res.msg)
  51. }
  52. })
  53. }
  54. // 编辑确定发送
  55. const editUser = (params: any) => {
  56. Object.keys(params).forEach(key => {
  57. if (!params[key]) {
  58. delete params[key]
  59. }
  60. })
  61. getUserUpdate.run(params).then(res => {
  62. if (res.data) {
  63. message.success('编辑成功!')
  64. ajax.refresh()//重新获取用户列表
  65. ajax1.refresh()//重新获取详情列表
  66. } else {
  67. message.error(res.msg)
  68. }
  69. })
  70. }
  71. return <div>
  72. <TableData
  73. leftChild={<QueryForm
  74. initialValues={{ sourceSystem: 'ZX_ONE' }}
  75. onChange={(data: any) => {
  76. const { gameUserId, username, gameClassify, regStartDay, regEndDay, rechargeDay, regPayIntervalTime, userStatus, agentId, roleCount, ...par } = data
  77. let newQueryForm = JSON.parse(JSON.stringify(queryForm))
  78. newQueryForm.pageNum = 1
  79. newQueryForm.userId = gameUserId
  80. newQueryForm.userName = username
  81. newQueryForm.gameCategoryId = gameClassify
  82. newQueryForm.status = userStatus
  83. newQueryForm.channelId = agentId
  84. if (regStartDay && regEndDay) {
  85. newQueryForm.beginDate = regStartDay
  86. newQueryForm.endDate = regEndDay
  87. } else {
  88. delete newQueryForm.beginDate
  89. delete newQueryForm.endDate
  90. }
  91. if (rechargeDay && rechargeDay?.length === 2) {
  92. newQueryForm['rechargeBeginDate'] = moment(rechargeDay[0]).format('YYYY-MM-DD')
  93. newQueryForm['rechargeEndDate'] = moment(rechargeDay[1]).format('YYYY-MM-DD')
  94. } else {
  95. delete newQueryForm['rechargeBeginDate']
  96. delete newQueryForm['rechargeEndDate']
  97. }
  98. if (regPayIntervalTime?.length > 0 && (regPayIntervalTime[0] || regPayIntervalTime[1])) {
  99. newQueryForm.regPayIntervalTimeMin = regPayIntervalTime[0]
  100. newQueryForm.regPayIntervalTimeMax = regPayIntervalTime[1]
  101. } else {
  102. delete newQueryForm.regPayIntervalTimeMin
  103. delete newQueryForm.regPayIntervalTimeMax
  104. }
  105. if (roleCount?.length > 0 && (roleCount[0] || roleCount[1])) {
  106. newQueryForm.roleCountMin = roleCount[0]
  107. newQueryForm.roleCountMax = roleCount[1]
  108. } else {
  109. delete newQueryForm.roleCountMin
  110. delete newQueryForm.roleCountMax
  111. }
  112. setQueryForm({ ...newQueryForm, ...par })
  113. }}
  114. isSource
  115. isGameUserId
  116. isUserName
  117. isNickname
  118. isMobile
  119. isRegIp
  120. isIsAuth
  121. isIsBindMobile
  122. isCpId
  123. isGameId
  124. isBGGameClassify
  125. isRegDay={{ ranges: getPresetsRanking() }}
  126. rechargeDay={{ ranges: getPresetsRanking() }}
  127. isIsRecharge
  128. isUserStatus
  129. isAgentId
  130. isAccountId
  131. isSysUserId
  132. isCreateRole
  133. isPayIntervalTime={{ tips: '充值距注册时间区间(分钟)' }}
  134. isRoleCount={{ tips: '每个账号角色数量区间' }}
  135. />}
  136. scroll={{ x: 1000, y: 600 }}
  137. ajax={getPlayerList}
  138. fixed={{ left: 1, right: 2 }}
  139. dataSource={getPlayerList?.data?.records}
  140. page={getPlayerList?.data?.current || 1}
  141. pageSize={getPlayerList?.data?.size || 20}
  142. total={getPlayerList?.data?.total || 0}
  143. title='玩家列表'
  144. onChange={(props: any) => {
  145. console.log('props--->', props)
  146. let { pagination, sortData } = props
  147. let { current, pageSize } = pagination
  148. let newQueryForm = JSON.parse(JSON.stringify(queryForm))
  149. if (sortData && sortData?.order) {
  150. newQueryForm['sortType'] = sortData?.order === 'ascend' ? 'asc' : 'desc'
  151. newQueryForm['sortFiled'] = sortData?.field
  152. } else {
  153. delete newQueryForm['sortType']
  154. delete newQueryForm['sortFiled']
  155. }
  156. newQueryForm.pageNum = current
  157. newQueryForm.pageSize = pageSize
  158. setQueryForm({ ...newQueryForm })
  159. }}
  160. config={columns12(lookHandle, exportH5, interdictionHandle)}
  161. configName={'玩家列表'}
  162. />
  163. {exportShow && <ExportH5Modal initialValues={exportData} visible={exportShow} onClose={() => { setExportShow(false); setExportData({}) }} onChange={() => { setExportShow(false); setExportData({}); ajax.refresh() }} />}
  164. {/* 查看详情 */}
  165. {lookShow && <Look visible={lookShow} onClose={() => { setLookShow(false) }} onChange={(params: any) => { editUser(params) }} userInfo={getUserInfo?.data || null} />}
  166. </div>
  167. }
  168. export default List