gameIpList.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <template>
  2. <div>
  3. <div class="gva-search-box">
  4. <el-form ref="searchForm" :inline="true" :model="searchInfo">
  5. <el-form-item label="游戏id">
  6. <el-input v-model="searchInfo.game_id" placeholder="游戏id" />
  7. </el-form-item>
  8. <!-- <el-form-item label="日期" prop="create_date">
  9. <el-date-picker v-model="searchInfo.create_date" popper-class="picker-popovers" class="timefilter"
  10. type="datetime" placeholder="选择日期时间" value-format="YYYY-MM-DD">
  11. </el-date-picker>
  12. </el-form-item> -->
  13. <el-form-item label="日期" prop="date">
  14. <el-date-picker v-model="searchInfo.date" size="default" type="daterange" unlink-panels
  15. range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" :disabled-date="disabledDate"
  16. :shortcuts="shortcuts" />
  17. </el-form-item>
  18. <el-form-item>
  19. <el-button size="small" type="primary" icon="search" @click="onSubmit">查询</el-button>
  20. <el-button size="small" icon="refresh" @click="onReset">重置</el-button>
  21. <el-button class="excel-btn" size="small" type="primary" icon="download"
  22. @click="handleExcelExport">导出</el-button>
  23. </el-form-item>
  24. </el-form>
  25. </div>
  26. <div class="gva-table-box">
  27. <el-table :data="tableData" @sort-change="sortChange" @selection-change="handleSelectionChange">
  28. <el-table-column type="selection" width="55" />
  29. <el-table-column align="left" label="游戏id" min-width="150" prop="game_id" />
  30. <!-- <el-table-column align="left" label="ip" min-width="150" prop="ip" /> -->
  31. <el-table-column align="left" label="上报ip次数" min-width="150" prop="count_total" sortable="custom" />
  32. <el-table-column align="left" label="任务完成" min-width="150" prop="task_count" sortable="custom" />
  33. <el-table-column align="left" label="成功ip次数" min-width="150" prop="success_ip" sortable="custom" />
  34. <el-table-column align="left" label="ip个数" min-width="150" prop="count_distinct_ip" sortable="custom" />
  35. <el-table-column align="left" label="日期" min-width="150" prop="create_date" sortable="custom" />
  36. <el-table-column align="left" fixed="right" label="操作" width="200">
  37. <template #default="scope">
  38. <el-button icon="search" size="small" type="primary" link
  39. @click="selectIpFunc(scope.row)">查看</el-button>
  40. </template>
  41. </el-table-column>
  42. </el-table>
  43. <div class="gva-pagination">
  44. <el-pagination :current-page="page" :page-size="pageSize" :page-sizes="[10, 30, 50, 100]" :total="total"
  45. layout="total, sizes, prev, pager, next, jumper" @current-change="handleCurrentChange"
  46. @size-change="handleSizeChange" />
  47. </div>
  48. </div>
  49. <el-dialog v-model="dialogFormVisible" :before-close="closeDialog" :title="dialogTitle" width="40%">
  50. <!-- <template #footer>
  51. <div class="dialog-footer">
  52. <el-text class="mx-1" type="success">Success</el-text>
  53. <el-button size="small" @click="closeDialog">取 消</el-button> -->
  54. <!-- </div>
  55. </template> -->
  56. <el-table :data="IpTableData" height="500" border>
  57. <el-table-column align="center" label="ip" min-width="120" prop="ip" />
  58. <el-table-column align="center" label="上报次数" min-width="120" prop="count" />
  59. </el-table>
  60. </el-dialog>
  61. </div>
  62. </template>
  63. <script>
  64. export default {
  65. name: 'GameList',
  66. }
  67. </script>
  68. <script setup>
  69. import {
  70. gameIpList,
  71. getGameIp,
  72. gameIpExport
  73. } from '@/api/ipLog'
  74. import { toSQLLine } from '@/utils/stringFun'
  75. import { ref } from 'vue'
  76. import { ElMessage, ElMessageBox } from 'element-plus'
  77. import warningBar from '@/components/warningBar/warningBar.vue'
  78. import dayjs from "dayjs";
  79. const apis = ref([])
  80. const page = ref(1)
  81. const total = ref(0)
  82. const pageSize = ref(10)
  83. const tableData = ref([])
  84. const IpTableData = ref([])
  85. const searchInfo = ref({})
  86. const onReset = () => {
  87. searchInfo.value = {}
  88. getTableData()
  89. }
  90. // 搜索
  91. const onSubmit = () => {
  92. page.value = 1
  93. pageSize.value = 10
  94. searchInfo.value.game_id = Number(searchInfo.value.game_id)
  95. if (typeof searchInfo.value.date != "undefined") {
  96. searchInfo.value.date[0] = dayjs(searchInfo.value.date[0]).format(
  97. "YYYY-MM-DD"
  98. );
  99. searchInfo.value.date[1] = dayjs(searchInfo.value.date[1]).format(
  100. "YYYY-MM-DD"
  101. );
  102. }
  103. getTableData()
  104. }
  105. // 分页
  106. const handleSizeChange = (val) => {
  107. pageSize.value = val
  108. getTableData()
  109. }
  110. const handleCurrentChange = (val) => {
  111. page.value = val
  112. getTableData()
  113. }
  114. // 排序
  115. const sortChange = ({ prop, order }) => {
  116. if (prop) {
  117. if (prop === 'id') {
  118. prop = 'id'
  119. }
  120. searchInfo.value.orderKey = toSQLLine(prop)
  121. searchInfo.value.desc = order === 'descending'
  122. }
  123. getTableData()
  124. }
  125. // 查询
  126. const getTableData = async () => {
  127. const table = await gameIpList({ page: page.value, pageSize: pageSize.value, ...searchInfo.value })
  128. if (table.code === 0) {
  129. tableData.value = table.data.list
  130. total.value = table.data.total
  131. page.value = table.data.page
  132. pageSize.value = table.data.pageSize
  133. }
  134. }
  135. getTableData()
  136. // 查看IP
  137. const selectIpFunc = async (row) => {
  138. const res = await getGameIp({ game_id: row.game_id, create_date: row.create_date })
  139. IpTableData.value = res.data.list
  140. IpTableData.value.total = res.data.total
  141. openDialog('getIp')
  142. }
  143. //导出列表
  144. const handleExcelExport = async () => {
  145. var fileName = Date.parse(new Date()) + "-ip.xlsx"
  146. if (searchInfo.value.create_date == null) {
  147. let dt = new Date()
  148. var y = dt.getFullYear()
  149. var mt = (dt.getMonth() + 1).toString().padStart(2, '0')
  150. var day = dt.getDate().toString().padStart(2, '0')
  151. var timeStr = y + "-" + mt + "-" + day
  152. fileName = timeStr + "-ip.xlsx"
  153. } else {
  154. fileName = searchInfo.value.create_date + "-ip.xlsx"
  155. }
  156. gameIpExport({ page: page.value, pageSize: pageSize.value, ...searchInfo.value }, fileName)
  157. }
  158. const closeDialog = () => {
  159. dialogFormVisible.value = false
  160. }
  161. const dialogTitle = ref('')
  162. const type = ref('')
  163. const dialogFormVisible = ref(false)
  164. const openDialog = (key) => {
  165. switch (key) {
  166. case 'getIp':
  167. dialogTitle.value = 'ip个数:' + IpTableData.value.total
  168. break
  169. default:
  170. break
  171. }
  172. type.value = key
  173. dialogFormVisible.value = true
  174. }
  175. // 批量操作
  176. const handleSelectionChange = (val) => {
  177. apis.value = val
  178. }
  179. // 弹窗相关
  180. // const apiForm = ref(null)
  181. // const initForm = () => {
  182. // apiForm.value.resetFields()
  183. // form.value = {
  184. // game_name: '',
  185. // game_package_name: ''
  186. // }
  187. // }
  188. </script>
  189. <style scoped lang="scss">
  190. .button-box {
  191. padding: 10px 20px;
  192. .el-button {
  193. float: right;
  194. }
  195. }
  196. .warning {
  197. color: #dc143c;
  198. }
  199. </style>