index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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="8" :xs="24">
  7. <a-form-item label="系统" field="os">
  8. <a-select v-model="searchForm.os" :options="osOptions" placeholder="请选择系统" />
  9. </a-form-item>
  10. </a-col> -->
  11. <a-col :sm="8" :xs="24">
  12. <a-form-item label="游戏" field="game_id">
  13. <game-select v-model="searchForm.game_id" multiple />
  14. </a-form-item>
  15. </a-col>
  16. <a-col :sm="8" :xs="24">
  17. <a-form-item label="注册月份" field="reg_date">
  18. <a-range-picker class="w-full" v-model="searchForm.reg_date" :show-time="false" mode="date" />
  19. </a-form-item>
  20. </a-col>
  21. <a-col :sm="8" :xs="24">
  22. <a-form-item label="渠道ID" field="agent_id">
  23. <a-input v-model="searchForm.agent_id" placeholder="请输入渠道ID" />
  24. </a-form-item>
  25. </a-col>
  26. <a-col :sm="8" :xs="24">
  27. <a-form-item label="渠道名称" field="agent_name">
  28. <a-input v-model="searchForm.agent_name" placeholder="请输入渠道名称" />
  29. </a-form-item>
  30. </a-col>
  31. <a-col :sm="8" :xs="24">
  32. <a-form-item label="负责人" field="auth_id">
  33. <auth-select v-model="searchForm.auth_id" multiple />
  34. </a-form-item>
  35. </a-col>
  36. <a-col :sm="8" :xs="24">
  37. <a-form-item label="媒体类型" field="media_id">
  38. <media-select v-model="searchForm.media_id" placeholder="请选择媒体类型" />
  39. </a-form-item>
  40. </a-col>
  41. </template>
  42. <!-- Table 自定义渲染 -->
  43. </sa-table>
  44. </div>
  45. </template>
  46. <script setup>
  47. import { onMounted, ref, reactive } from 'vue'
  48. import api from '../../api/gameLog/analyse'
  49. import dayjs from 'dayjs'
  50. import GameSelect from '@/components/game-select/index.vue'
  51. import MediaSelect from '@/components/media-select/index.vue'
  52. import AuthSelect from '@/components/auth-select/index.vue'
  53. // 引用定义
  54. const crudRef = ref()
  55. const osOptions = ref([
  56. {
  57. label: 'IOS',
  58. value: '1',
  59. },
  60. {
  61. label: 'Android',
  62. value: '2',
  63. },
  64. {
  65. label: '小程序',
  66. value: '3',
  67. },
  68. ])
  69. // 搜索表单
  70. const searchForm = ref({
  71. game_id: '',
  72. media_id: '',
  73. auth_id: '',
  74. agent_id: '',
  75. agent_name: '',
  76. reg_date: [],
  77. })
  78. // SaTable 基础配置
  79. const options = reactive({
  80. api: api.getDataOverviewByMonth,
  81. pk: 'mdate',
  82. showSort: false,
  83. showSummary: true,
  84. operationColumn: false,
  85. summary: [
  86. {
  87. action: 'totalRow',
  88. dataIndex: 'mdate',
  89. },
  90. {
  91. action: 'totalRow',
  92. dataIndex: 'login_total',
  93. },
  94. {
  95. action: 'totalRow',
  96. dataIndex: 'pay_total',
  97. },
  98. {
  99. action: 'totalRow',
  100. dataIndex: 'pay_num',
  101. },
  102. {
  103. action: 'totalRow',
  104. dataIndex: 'pay_rate',
  105. },
  106. {
  107. action: 'totalRow',
  108. dataIndex: 'arpu',
  109. },
  110. {
  111. action: 'totalRow',
  112. dataIndex: 'reg_total',
  113. },
  114. {
  115. action: 'totalRow',
  116. dataIndex: 'reg_login_total',
  117. },
  118. {
  119. action: 'totalRow',
  120. dataIndex: 'act_rate',
  121. },
  122. {
  123. action: 'totalRow',
  124. dataIndex: 'reg_pay_total',
  125. },
  126. {
  127. action: 'totalRow',
  128. dataIndex: 'reg_pay_num',
  129. },
  130. {
  131. action: 'totalRow',
  132. dataIndex: 'reg_pay_rate',
  133. },
  134. {
  135. action: 'totalRow',
  136. dataIndex: 'reg_arpu',
  137. },
  138. {
  139. action: 'totalRow',
  140. dataIndex: 'old_login_total',
  141. },
  142. {
  143. action: 'totalRow',
  144. dataIndex: 'old_pay_total',
  145. },
  146. {
  147. action: 'totalRow',
  148. dataIndex: 'old_pay_num',
  149. },
  150. {
  151. action: 'totalRow',
  152. dataIndex: 'old_pay_rate',
  153. },
  154. {
  155. action: 'totalRow',
  156. dataIndex: 'old_arpu',
  157. },
  158. ],
  159. })
  160. // SaTable 列配置
  161. const columns = reactive([
  162. { title: '日期', dataIndex: 'mdate', width: 120, fixed: 'left' },
  163. {
  164. title: '总用户',
  165. children: [
  166. {
  167. title: 'DAU',
  168. dataIndex: 'login_total',
  169. width: 90,
  170. },
  171. {
  172. title: '付费金额',
  173. dataIndex: 'pay_total',
  174. width: 90,
  175. },
  176. {
  177. title: '付费人数',
  178. dataIndex: 'pay_num',
  179. width: 90,
  180. },
  181. {
  182. title: '付费率',
  183. dataIndex: 'pay_rate',
  184. width: 90,
  185. },
  186. {
  187. title: 'ARPU',
  188. dataIndex: 'arpu',
  189. width: 90,
  190. },
  191. ],
  192. },
  193. {
  194. title: '新用户',
  195. children: [
  196. {
  197. title: '注册数',
  198. dataIndex: 'reg_total',
  199. width: 90,
  200. },
  201. {
  202. title: '登录',
  203. dataIndex: 'reg_login_total',
  204. width: 90,
  205. },
  206. {
  207. title: '次留率',
  208. dataIndex: 'act_rate',
  209. width: 90,
  210. },
  211. {
  212. title: '付费金额',
  213. dataIndex: 'reg_pay_total',
  214. width: 90,
  215. },
  216. {
  217. title: '付费人数',
  218. dataIndex: 'reg_pay_num',
  219. width: 90,
  220. },
  221. {
  222. title: '付费率',
  223. dataIndex: 'reg_pay_rate',
  224. width: 90,
  225. },
  226. {
  227. title: 'ARPU',
  228. dataIndex: 'reg_arpu',
  229. width: 90,
  230. },
  231. ],
  232. },
  233. {
  234. title: '老用户',
  235. children: [
  236. {
  237. title: '登录',
  238. dataIndex: 'old_login_total',
  239. width: 90,
  240. },
  241. {
  242. title: '付费金额',
  243. dataIndex: 'old_pay_total',
  244. width: 90,
  245. },
  246. {
  247. title: '付费人数',
  248. dataIndex: 'old_pay_num',
  249. width: 90,
  250. },
  251. {
  252. title: '付费率',
  253. dataIndex: 'old_pay_rate',
  254. width: 90,
  255. },
  256. {
  257. title: 'ARPU',
  258. dataIndex: 'old_arpu',
  259. width: 90,
  260. },
  261. ],
  262. },
  263. ])
  264. // 页面数据初始化
  265. const initPage = async () => {
  266. searchForm.value.reg_date[0] = dayjs().subtract(8, 'days').format('YYYY-MM-DD')
  267. searchForm.value.reg_date[1] = dayjs().subtract(1, 'days').format('YYYY-MM-DD')
  268. }
  269. // SaTable 数据请求
  270. const refresh = async () => {
  271. crudRef.value?.refresh()
  272. }
  273. // 页面加载完成执行
  274. onMounted(async () => {
  275. initPage()
  276. refresh()
  277. })
  278. </script>