index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <template>
  2. <div>
  3. <!-- 统计 -->
  4. <summaryStatistics></summaryStatistics>
  5. <Search :search="moreSearch" :reset="moreReset">
  6. <template v-slot:body>
  7. <div v-if="rolesIdentify.includes('optimizer')" class="w-full m-3 text-gray-500">
  8. *列表统计的是所有小程序对应日期的数据
  9. </div>
  10. <el-form-item label="时间">
  11. <el-date-picker unlink-panels clearable @change="timeChange" format="YYYY/MM/DD" value-format="YYYY-MM-DD"
  12. v-model="query.time" type="daterange" :shortcuts="shortcuts" range-separator="To" start-placeholder="开始时间"
  13. end-placeholder="结束时间" />
  14. </el-form-item>
  15. <el-form-item label="优化师" prop="user_id" v-if="!rolesIdentify.includes('optimizer')">
  16. <el-select v-model="query.user_id" filterable remote clearable
  17. :remote-method="(query) => { remoteMethod(query, 'channelPromotionsUsers') }" placeholder="选择优化师">
  18. <el-option v-for="item in promotionsUsersList" :key="item.user_id" :label="item.name" :value="item.user_id" />
  19. </el-select>
  20. </el-form-item>
  21. <el-form-item label="小程序" prop="miniprogram_id">
  22. <el-select v-model="query.miniprogram_id" filterable remote
  23. :remote-method="(query) => { remoteMethod(query, 'channelMiniprogram') }" clearable placeholder="选择小程序">
  24. <el-option v-for="item in channelMiniprogram" :key="item.miniprogram_id" :label="item.name"
  25. :value="item.miniprogram_id" />
  26. </el-select>
  27. </el-form-item>
  28. </template>
  29. <template v-slot:extra_button>
  30. <exportExcel api="statistic/users/list" v-action="'statistic.UserStatistics.export'" sheet_name="充值统计"
  31. :title_obj="titleObj" :extro_params="{ is_all: true, ...query }">
  32. </exportExcel>
  33. </template>
  34. <template v-slot:content>
  35. <div style="margin:8px 6px;">
  36. <el-card shadow="hover" :body-style="{ padding: '20px' }">
  37. <div class="stat-wrapper">
  38. <div>所选时间段内累计充新增用户数:
  39. <span class="ml-2 mr-4 stat">{{ statisticalData.new_user_num || '暂无数据' }}</span>
  40. </div>
  41. <div>累计新用户充值人数:
  42. <span class="ml-2 mr-4 stat">{{ statisticalData.new_user_recharge_num || '暂无数据' }}</span>
  43. </div>
  44. </div>
  45. </el-card>
  46. </div>
  47. <div class="table-default">
  48. <el-table :data="tableData" class="mt-3" v-loading="loading">
  49. <el-table-column prop="date" min-width="120px" label="时间" />
  50. <el-table-column v-if="!rolesIdentify.includes('optimizer')" prop="username" label="优化师" min-width="160px" />
  51. <el-table-column prop="miniprogram_name" label="小程序名称" min-width="160px" />
  52. <el-table-column label="当日新增用户数" prop="new_user_num" min-width="160px">
  53. <template #header>
  54. <div class="flex items-center">
  55. <el-tooltip placement="top">
  56. <template #content>
  57. 当天的新增用户<br />
  58. </template>
  59. <el-icon>
  60. <InfoFilled />
  61. </el-icon>
  62. </el-tooltip>
  63. <span>当日新增用户数</span>
  64. </div>
  65. </template>
  66. <template #default="scope">
  67. <div class="wrapper">
  68. <div>{{ scope.row.new_user_num }}</div>
  69. </div>
  70. </template>
  71. </el-table-column>
  72. <el-table-column label="当日新增用户充值人数" prop="pay_count" min-width="180px">
  73. <template #header>
  74. <div class="flex items-center">
  75. <el-tooltip placement="top">
  76. <template #content>
  77. 当日新增用户充值人数<br />
  78. </template>
  79. <el-icon>
  80. <InfoFilled />
  81. </el-icon>
  82. </el-tooltip>
  83. <span>当日新增用户充值人数</span>
  84. </div>
  85. </template>
  86. <template #default="scope">
  87. <div class="wrapper">
  88. <div>{{ scope.row.new_user_recharge_num }}</div>
  89. </div>
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="当日新增用户充率" prop="recharge_rate" min-width="180px">
  93. <template #header>
  94. <div class="flex items-center">
  95. <el-tooltip placement="top">
  96. <template #content>
  97. 当日新增用户充率<br />
  98. </template>
  99. <el-icon>
  100. <InfoFilled />
  101. </el-icon>
  102. </el-tooltip>
  103. <span>当日新增用户充率</span>
  104. </div>
  105. </template>
  106. <template #default="scope">
  107. <div class="wrapper">
  108. <div>{{ scope.row.recharge_rate }}</div>
  109. </div>
  110. </template>
  111. </el-table-column>
  112. <el-table-column label="当日新增用户充总额" prop="new_user_recharge_total" min-width="180px">
  113. <template #header>
  114. <div class="flex items-center">
  115. <el-tooltip placement="top">
  116. <template #content>
  117. 当日新增用户充总额<br />
  118. </template>
  119. <el-icon>
  120. <InfoFilled />
  121. </el-icon>
  122. </el-tooltip>
  123. <span>当日新增用户充总额</span>
  124. </div>
  125. </template>
  126. <template #default="scope">
  127. <div class="wrapper">
  128. <div>{{ scope.row.new_user_recharge_total }}</div>
  129. </div>
  130. </template>
  131. </el-table-column>
  132. <el-table-column label="新增用户人均充值" prop="recharge_mean" min-width="180px">
  133. <template #header>
  134. <div class="flex items-center">
  135. <el-tooltip placement="top">
  136. <template #content>
  137. 新增用户人均充值<br />
  138. </template>
  139. <el-icon>
  140. <InfoFilled />
  141. </el-icon>
  142. </el-tooltip>
  143. <span>新增用户人均充值</span>
  144. </div>
  145. </template>
  146. <template #default="scope">
  147. <div class="wrapper">
  148. <div>{{ scope.row.recharge_mean }}</div>
  149. </div>
  150. </template>
  151. </el-table-column>
  152. </el-table>
  153. <Paginate />
  154. </div>
  155. </template>
  156. </Search>
  157. </div>
  158. </template>
  159. <script lang="ts" setup>
  160. import summaryStatistics from './summaryStatistics.vue';
  161. import { shortcuts } from '@/utils/shortcuts'
  162. import { useRouter, useRoute } from 'vue-router'
  163. import { InfoFilled } from '@element-plus/icons-vue';
  164. import { useGetList } from '@/hook/curd/useGetList';
  165. import { statisticUserList } from '@/api/dataStatistics/userStatistics'
  166. import { titleObj } from "./excelTitle";
  167. import moment from 'moment';
  168. const start_date = moment().subtract(7, 'days').format('YYYY-MM-DD');
  169. const end_date = moment().format('YYYY-MM-DD');
  170. const statisticalData = ref({})
  171. const api = '/statistic/users/list';
  172. const router = useRouter()
  173. const route = useRoute()
  174. const rolesIdentify = inject('rolesIdentify')
  175. import {
  176. channelMiniprogramUseList,
  177. channelPromotionsUsers,
  178. } from '@/api/orders/index'
  179. const channelMiniprogram = ref([])
  180. const promotionsUsersList = ref([])
  181. const { data, query, search, reset, loading } = useGetList(api);
  182. const remoteMethod = (query: string, type: string,) => {
  183. console.log(query, 'queryquery', type);
  184. switch (type) {
  185. case 'channelPromotionsUsers':
  186. initRemoteOption('channelPromotionsUsers', { name: query })
  187. break;
  188. case 'channelMiniprogram':
  189. initRemoteOption('channelMiniprogram', { name: query })
  190. break;
  191. }
  192. }
  193. const initRemoteOption = (type: string, params?: object) => {
  194. switch (type) {
  195. case 'channelPromotionsUsers':
  196. channelPromotionsUsers({ limit: 30, ...params }).then(res => {
  197. promotionsUsersList.value = res.data
  198. })
  199. break;
  200. case 'channelMiniprogram':
  201. channelMiniprogramUseList({ limit: 30, ...params }).then(res => {
  202. channelMiniprogram.value = res.data
  203. })
  204. break;
  205. }
  206. }
  207. const timeChange = (e: object) => {
  208. console.log(e, 'timeChangetimeChangetimeChange');
  209. if (query.value.time) {
  210. const timeArr = toRaw(e);
  211. query.value.start_at = timeArr[0]
  212. query.value.end_at = timeArr[1]
  213. } else {
  214. delete query.value.start_at
  215. delete query.value.end_at
  216. }
  217. }
  218. const moreSearch = () => {
  219. search();
  220. statisticUserList({ ...query.value }).then(res => {
  221. statisticalData.value = res.data
  222. })
  223. }
  224. const moreReset = () => {
  225. reset()
  226. statisticUserList({ ...query.value }).then(res => {
  227. statisticalData.value = res.data
  228. })
  229. }
  230. const tableData = computed(() => data.value?.data);
  231. onMounted(() => {
  232. initRemoteOption('channelPromotionsUsers')
  233. initRemoteOption('channelMiniprogram')
  234. query.value.time = [start_date, end_date];
  235. query.value.start_at = start_date;
  236. query.value.end_at = end_date;
  237. moreSearch();
  238. });
  239. </script>
  240. <style scoped lang="scss">
  241. .box-card {
  242. width: 300px;
  243. margin: 8px;
  244. .money-wrapper {
  245. height: 50px;
  246. width: 100%;
  247. color: #ed892c;
  248. font-size: 26px;
  249. }
  250. }
  251. .stat-wrapper {
  252. display: flex;
  253. font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  254. .stat {
  255. box-sizing: border-box;
  256. font-size: 18px;
  257. font-weight: 550;
  258. padding: 0 12px;
  259. }
  260. }
  261. .table-default {
  262. padding: 2px 4px 8px 4px;
  263. .set-warpper {
  264. height: 60px;
  265. display: flex;
  266. align-items: center;
  267. justify-content: flex-end;
  268. }
  269. .wrapper {
  270. margin: 8px;
  271. .label {
  272. margin-right: 6px;
  273. }
  274. .content {
  275. font-size: 15px;
  276. }
  277. }
  278. }
  279. </style>