index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template>
  2. <div class="ma-content-block">
  3. <sa-table ref="crudRef" :options="options" :columns="columns" :searchForm="searchForm">
  4. <!-- 搜索区 tableSearch -->
  5. <template #tableSearch>
  6. <a-col :sm="12" :md="6" :lg="7" :xl="6" :xxl="4" :xs="24">
  7. <a-form-item label="游戏" field="game_id">
  8. <game-select v-model="searchForm.game_id" multiple />
  9. </a-form-item>
  10. </a-col>
  11. <a-col :sm="24" :md="17" :lg="17" :xl="12" :xxl="8" :xs="24">
  12. <a-form-item label="注册日期" field="tdate">
  13. <a-space>
  14. <a-date-picker class="w-full" v-model="searchForm.tdate" :show-time="false" mode="date" />
  15. <a-button size="mini" type="primary" @click="refreshDay('yesterday')">前一天</a-button>
  16. <a-button size="mini" type="primary" @click="refreshDay('today')">当天</a-button>
  17. <a-button size="mini" type="primary" @click="refreshDay('tomorrow')">后一天</a-button>
  18. </a-space>
  19. </a-form-item>
  20. </a-col>
  21. </template>
  22. <!-- Table 自定义渲染 -->
  23. </sa-table>
  24. </div>
  25. </template>
  26. <script setup>
  27. import { onMounted, ref, reactive } from 'vue'
  28. import api from '../../api/gameLog/analyse'
  29. import dayjs from 'dayjs'
  30. import GameSelect from '@/components/game-select/index.vue'
  31. // 引用定义
  32. const crudRef = ref()
  33. const gameList = ref([])
  34. // 搜索表单
  35. const searchForm = ref({
  36. game_id: '',
  37. media_id: '',
  38. auth_id: '',
  39. agent_id: '',
  40. agent_name: '',
  41. site_name: '',
  42. site_id: '',
  43. tdate: '',
  44. data_type: 'recovery',
  45. })
  46. // SaTable 基础配置
  47. const options = reactive({
  48. api: api.getRegHourDataList,
  49. pk: 'tdate',
  50. showSort: false,
  51. showSummary: true,
  52. singleLine: true,
  53. summary: [
  54. {
  55. action: 'totalRow',
  56. dataIndex: 'total',
  57. },
  58. {
  59. action: 'totalRow',
  60. dataIndex: 'h0',
  61. },
  62. {
  63. action: 'totalRow',
  64. dataIndex: 'h1',
  65. },
  66. {
  67. action: 'totalRow',
  68. dataIndex: 'h2',
  69. },
  70. {
  71. action: 'totalRow',
  72. dataIndex: 'h3',
  73. },
  74. {
  75. action: 'totalRow',
  76. dataIndex: 'h4',
  77. },
  78. {
  79. action: 'totalRow',
  80. dataIndex: 'h5',
  81. },
  82. {
  83. action: 'totalRow',
  84. dataIndex: 'h6',
  85. },
  86. {
  87. action: 'totalRow',
  88. dataIndex: 'h7',
  89. },
  90. {
  91. action: 'totalRow',
  92. dataIndex: 'h8',
  93. },
  94. {
  95. action: 'totalRow',
  96. dataIndex: 'h9',
  97. },
  98. {
  99. action: 'totalRow',
  100. dataIndex: 'h10',
  101. },
  102. {
  103. action: 'totalRow',
  104. dataIndex: 'h11',
  105. },
  106. {
  107. action: 'totalRow',
  108. dataIndex: 'h12',
  109. },
  110. {
  111. action: 'totalRow',
  112. dataIndex: 'h13',
  113. },
  114. {
  115. action: 'totalRow',
  116. dataIndex: 'h14',
  117. },
  118. {
  119. action: 'totalRow',
  120. dataIndex: 'h15',
  121. },
  122. {
  123. action: 'totalRow',
  124. dataIndex: 'h16',
  125. },
  126. {
  127. action: 'totalRow',
  128. dataIndex: 'h17',
  129. },
  130. {
  131. action: 'totalRow',
  132. dataIndex: 'h18',
  133. },
  134. {
  135. action: 'totalRow',
  136. dataIndex: 'h19',
  137. },
  138. {
  139. action: 'totalRow',
  140. dataIndex: 'h20',
  141. },
  142. {
  143. action: 'totalRow',
  144. dataIndex: 'h21',
  145. },
  146. {
  147. action: 'totalRow',
  148. dataIndex: 'h22',
  149. },
  150. {
  151. action: 'totalRow',
  152. dataIndex: 'h23',
  153. },
  154. {
  155. action: 'totalRow',
  156. dataIndex: 'h24',
  157. },
  158. ],
  159. operationColumn: false,
  160. })
  161. // SaTable 列配置
  162. const columns = reactive([
  163. { title: '游戏ID', dataIndex: 'game_id', width: 130, fixed: 'left' },
  164. { title: '游戏名', dataIndex: 'game_name', width: 120, fixed: 'left' },
  165. { title: '注册用户数', dataIndex: 'total', width: 140, fixed: 'left' },
  166. { title: '0', dataIndex: 'h0', width: 80 },
  167. { title: '1', dataIndex: 'h1', width: 80 },
  168. { title: '2', dataIndex: 'h2', width: 80 },
  169. { title: '3', dataIndex: 'h3', width: 80 },
  170. { title: '4', dataIndex: 'h4', width: 80 },
  171. { title: '5', dataIndex: 'h5', width: 80 },
  172. { title: '6', dataIndex: 'h6', width: 80 },
  173. { title: '7', dataIndex: 'h7', width: 80 },
  174. { title: '8', dataIndex: 'h8', width: 80 },
  175. { title: '9', dataIndex: 'h9', width: 80 },
  176. { title: '10', dataIndex: 'h10', width: 80 },
  177. { title: '11', dataIndex: 'h11', width: 80 },
  178. { title: '12', dataIndex: 'h12', width: 80 },
  179. { title: '13', dataIndex: 'h13', width: 80 },
  180. { title: '14', dataIndex: 'h14', width: 80 },
  181. { title: '15', dataIndex: 'h15', width: 80 },
  182. { title: '16', dataIndex: 'h16', width: 80 },
  183. { title: '17', dataIndex: 'h17', width: 80 },
  184. { title: '18', dataIndex: 'h18', width: 80 },
  185. { title: '19', dataIndex: 'h19', width: 80 },
  186. { title: '20', dataIndex: 'h20', width: 80 },
  187. { title: '21', dataIndex: 'h21', width: 80 },
  188. { title: '22', dataIndex: 'h22', width: 80 },
  189. { title: '23', dataIndex: 'h23', width: 80 },
  190. ])
  191. // 页面数据初始化
  192. const initPage = () => {
  193. searchForm.value.tdate = dayjs().format('YYYY-MM-DD')
  194. }
  195. // SaTable 数据请求
  196. const refresh = async () => {
  197. crudRef.value?.refresh()
  198. }
  199. const refreshDay = async (day) => {
  200. console.log(day)
  201. switch (day) {
  202. case 'yesterday':
  203. searchForm.value.tdate = dayjs(searchForm.value.tdate).subtract(1, 'day').format('YYYY-MM-DD')
  204. break
  205. case 'today':
  206. searchForm.value.tdate = dayjs().format('YYYY-MM-DD')
  207. break
  208. case 'tomorrow':
  209. searchForm.value.tdate = dayjs(searchForm.value.tdate).add(1, 'day').format('YYYY-MM-DD')
  210. break
  211. default:
  212. break
  213. }
  214. refresh()
  215. }
  216. // 页面加载完成执行
  217. onMounted(async () => {
  218. initPage()
  219. refresh()
  220. })
  221. </script>
  222. <script>
  223. export default { name: 'v1/analyse/regHour' }
  224. </script>