appOperationReport.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. <template>
  2. <div class="app-container">
  3. <div class="period-switch">
  4. <el-radio-group v-model="periodType" @change="handlePeriodChange">
  5. <el-radio-button label="current">本月</el-radio-button>
  6. <el-radio-button label="last">上月</el-radio-button>
  7. </el-radio-group>
  8. <span class="period-label">{{ periodLabel }}</span>
  9. <el-select v-model="monthAppVersion" placeholder="APP 版本" clearable size="small" filterable style="margin-left: 20px; width: 150px;" @change="getData">
  10. <el-option v-for="item in appVersionList" :key="item.versionId" :label="item.versionName" :value="item.versionCode" />
  11. </el-select>
  12. </div>
  13. <el-row :gutter="20" class="card-row">
  14. <el-col :span="6">
  15. <el-card shadow="hover" class="metric-card">
  16. <div class="metric-icon" style="background: #409EFF;">
  17. <i class="el-icon-user"></i>
  18. </div>
  19. <div class="metric-content">
  20. <div class="metric-value">{{ reportData.newUsers || 0 }}</div>
  21. <div class="metric-label">新增用户数</div>
  22. </div>
  23. </el-card>
  24. </el-col>
  25. <el-col :span="6">
  26. <el-card shadow="hover" class="metric-card">
  27. <div class="metric-icon" style="background: #67C23A;">
  28. <i class="el-icon-s-custom"></i>
  29. </div>
  30. <div class="metric-content">
  31. <div class="metric-value">{{ reportData.totalUsers || 0 }}</div>
  32. <div class="metric-label">累计注册用户</div>
  33. </div>
  34. </el-card>
  35. </el-col>
  36. <el-col :span="6">
  37. <el-card shadow="hover" class="metric-card">
  38. <div class="metric-icon" style="background: #E6A23C;">
  39. <i class="el-icon-s-data"></i>
  40. </div>
  41. <div class="metric-content">
  42. <div class="metric-value">{{ reportData.activeUsers || 0 }}</div>
  43. <div class="metric-label">活跃用户数</div>
  44. </div>
  45. </el-card>
  46. </el-col>
  47. <el-col :span="6">
  48. <el-card shadow="hover" class="metric-card">
  49. <div class="metric-icon" style="background: #F56C6C;">
  50. <i class="el-icon-connection"></i>
  51. </div>
  52. <div class="metric-content">
  53. <div class="metric-value">{{ reportData.retentionRate != null ? reportData.retentionRate + '%' : '-' }}</div>
  54. <div class="metric-label">留存率</div>
  55. </div>
  56. </el-card>
  57. </el-col>
  58. </el-row>
  59. <el-row :gutter="20" class="card-row">
  60. <el-col :span="6">
  61. <el-card shadow="hover" class="metric-card">
  62. <div class="metric-icon" style="background: #909399;">
  63. <i class="el-icon-time"></i>
  64. </div>
  65. <div class="metric-content">
  66. <div class="metric-value">{{ reportData.avgUseDuration != null ? reportData.avgUseDuration + ' 分钟' : '-' }}</div>
  67. <div class="metric-label">用户平均使用时长</div>
  68. </div>
  69. </el-card>
  70. </el-col>
  71. <el-col :span="6">
  72. <el-card shadow="hover" class="metric-card">
  73. <div class="metric-icon" style="background: #9C27B0;">
  74. <i class="el-icon-coin"></i>
  75. </div>
  76. <div class="metric-content">
  77. <div class="metric-value">{{ reportData.ltv != null ? '¥' + reportData.ltv : '-' }}</div>
  78. <div class="metric-label">用户生命周期价值(LTV)</div>
  79. </div>
  80. </el-card>
  81. </el-col>
  82. <el-col :span="6">
  83. <el-card shadow="hover" class="metric-card">
  84. <div class="metric-icon" style="background: #FF9800;">
  85. <i class="el-icon-money"></i>
  86. </div>
  87. <div class="metric-content">
  88. <div class="metric-value">{{ reportData.cac != null ? '¥' + reportData.cac : '-' }}</div>
  89. <div class="metric-label">用户获取成本(CAC)</div>
  90. </div>
  91. </el-card>
  92. </el-col>
  93. <el-col :span="6">
  94. <el-card shadow="hover" class="metric-card">
  95. <div class="metric-icon" style="background: #795548;">
  96. <i class="el-icon-warning-outline"></i>
  97. </div>
  98. <div class="metric-content">
  99. <div class="metric-value">{{ reportData.monthlyChurnRate != null ? reportData.monthlyChurnRate + '%' : '-' }}</div>
  100. <div class="metric-label">月流失率</div>
  101. </div>
  102. </el-card>
  103. </el-col>
  104. </el-row>
  105. <el-card shadow="hover" class="daily-report-card">
  106. <div slot="header" class="card-header">
  107. <span>日报表</span>
  108. </div>
  109. <el-form :inline="true" :model="dailyQueryParams" class="query-form">
  110. <el-form-item label="时间范围">
  111. <el-date-picker
  112. v-model="dailyTimeRange"
  113. type="daterange"
  114. range-separator="至"
  115. start-placeholder="开始日期"
  116. end-placeholder="结束日期"
  117. value-format="yyyy-MM-dd"
  118. size="small"
  119. style="width: 260px"
  120. @change="handleDailyDateChange">
  121. </el-date-picker>
  122. </el-form-item>
  123. <el-form-item label="APP 版本">
  124. <el-select v-model="dailyQueryParams.appVersion" placeholder="请选择 APP 版本" clearable size="small" filterable>
  125. <el-option v-for="item in appVersionList" :key="item.versionId" :label="item.versionName" :value="item.versionCode" />
  126. </el-select>
  127. </el-form-item>
  128. <el-form-item>
  129. <el-button type="primary" icon="el-icon-search" size="mini" @click="getDailyReport">查询</el-button>
  130. </el-form-item>
  131. </el-form>
  132. <el-table v-loading="dailyLoading" :data="dailyReportList" border style="width: 100%">
  133. <el-table-column label="日期" align="center" prop="statDate" width="120" />
  134. <el-table-column label="新增用户数" align="center" prop="newUsers" width="120" />
  135. <el-table-column label="累计注册用户" align="center" prop="totalUsers" width="130" />
  136. <el-table-column label="活跃用户数" align="center" prop="activeUsers" width="120" />
  137. <el-table-column label="次日留存率(%)" align="center" prop="nextDayRetentionRate" width="130" />
  138. <el-table-column label="平均使用时长(分钟)" align="center" prop="avgUseDuration" width="150" />
  139. <el-table-column label="LTV(元)" align="center" prop="ltv" width="100" />
  140. <el-table-column label="CAC(元)" align="center" prop="cac" width="100" />
  141. <el-table-column label="日流失率(%)" align="center" prop="dailyChurnRate" width="110" />
  142. </el-table>
  143. <pagination
  144. v-show="dailyTotal > 0"
  145. :total="dailyTotal"
  146. :page.sync="dailyQueryParams.pageNum"
  147. :limit.sync="dailyQueryParams.pageSize"
  148. @pagination="getDailyReport"
  149. />
  150. </el-card>
  151. <el-card shadow="hover" class="weekly-report-card">
  152. <div slot="header" class="card-header">
  153. <span>周报表</span>
  154. </div>
  155. <el-form :inline="true" :model="weeklyQueryParams" class="query-form">
  156. <el-form-item label="时间范围">
  157. <el-date-picker
  158. v-model="weeklyTimeRange"
  159. type="daterange"
  160. range-separator="至"
  161. start-placeholder="开始日期"
  162. end-placeholder="结束日期"
  163. value-format="yyyy-MM-dd"
  164. size="small"
  165. style="width: 260px"
  166. @change="handleWeeklyDateChange">
  167. </el-date-picker>
  168. </el-form-item>
  169. <el-form-item label="APP 版本">
  170. <el-select v-model="weeklyQueryParams.appVersion" placeholder="请选择 APP 版本" clearable size="small" filterable>
  171. <el-option v-for="item in appVersionList" :key="item.versionId" :label="item.versionName" :value="item.versionCode" />
  172. </el-select>
  173. </el-form-item>
  174. <el-form-item>
  175. <el-button type="primary" icon="el-icon-search" size="mini" @click="getWeeklyReport">查询</el-button>
  176. </el-form-item>
  177. </el-form>
  178. <el-table v-loading="weeklyLoading" :data="weeklyReportList" border style="width: 100%">
  179. <el-table-column label="周期" align="center" width="180">
  180. <template slot-scope="scope">
  181. 第{{ scope.$index + 1 + (weeklyQueryParams.pageNum - 1) * weeklyQueryParams.pageSize }}周 ({{ scope.row.weekStart }} ~ {{ scope.row.weekEnd }})
  182. </template>
  183. </el-table-column>
  184. <el-table-column label="新增用户数" align="center" prop="newUsers" width="120" />
  185. <el-table-column label="累计注册用户" align="center" prop="totalUsers" width="130" />
  186. <el-table-column label="活跃用户数" align="center" prop="activeUsers" width="120" />
  187. <el-table-column label="留存率(%)" align="center" prop="retentionRate" width="110" />
  188. <el-table-column label="平均使用时长(分钟)" align="center" prop="avgUseDuration" width="150" />
  189. <el-table-column label="LTV(元)" align="center" prop="ltv" width="100" />
  190. <el-table-column label="CAC(元)" align="center" prop="cac" width="100" />
  191. <el-table-column label="周流失率(%)" align="center" prop="weeklyChurnRate" width="110" />
  192. </el-table>
  193. <pagination
  194. v-show="weeklyTotal > 0"
  195. :total="weeklyTotal"
  196. :page.sync="weeklyQueryParams.pageNum"
  197. :limit.sync="weeklyQueryParams.pageSize"
  198. @pagination="getWeeklyReport"
  199. />
  200. </el-card>
  201. </div>
  202. </template>
  203. <script>
  204. import request from '@/utils/request'
  205. export default {
  206. name: "AppOperationReport",
  207. data() {
  208. return {
  209. periodType: "current",
  210. reportData: {},
  211. year: null,
  212. month: null,
  213. monthAppVersion: null,
  214. appVersionList: [],
  215. dailyTimeRange: null,
  216. dailyLoading: false,
  217. dailyReportList: [],
  218. dailyTotal: 0,
  219. dailyQueryParams: {
  220. pageNum: 1,
  221. pageSize: 10,
  222. startDate: null,
  223. endDate: null,
  224. appVersion: null
  225. },
  226. weeklyTimeRange: null,
  227. weeklyLoading: false,
  228. weeklyReportList: [],
  229. weeklyTotal: 0,
  230. weeklyQueryParams: {
  231. pageNum: 1,
  232. pageSize: 10,
  233. startDate: null,
  234. endDate: null,
  235. appVersion: null
  236. }
  237. };
  238. },
  239. computed: {
  240. periodLabel() {
  241. return this.year + '年' + this.month + '月';
  242. }
  243. },
  244. created() {
  245. this.initPeriod();
  246. this.getAppVersionList();
  247. this.getData();
  248. },
  249. methods: {
  250. initPeriod() {
  251. const now = new Date();
  252. if (this.periodType === 'current') {
  253. this.year = now.getFullYear();
  254. this.month = now.getMonth() + 1;
  255. } else {
  256. const lastMonth = new Date(now.getFullYear(), now.getMonth() - 1, 1);
  257. this.year = lastMonth.getFullYear();
  258. this.month = lastMonth.getMonth() + 1;
  259. }
  260. },
  261. handlePeriodChange() {
  262. this.initPeriod();
  263. this.getData();
  264. },
  265. getData() {
  266. request({
  267. url: '/his/appOperationReport/monthReport',
  268. method: 'get',
  269. params: {
  270. year: this.year,
  271. month: this.month,
  272. appVersion: this.monthAppVersion
  273. }
  274. }).then(response => {
  275. this.reportData = response.data || {};
  276. });
  277. },
  278. getAppVersionList() {
  279. request({
  280. url: '/his/appVersion/appVersions',
  281. method: 'get'
  282. }).then(response => {
  283. this.appVersionList = response.data || [];
  284. });
  285. },
  286. handleDailyDateChange() {
  287. if (this.dailyTimeRange && this.dailyTimeRange.length === 2) {
  288. this.dailyQueryParams.startDate = this.dailyTimeRange[0];
  289. this.dailyQueryParams.endDate = this.dailyTimeRange[1];
  290. } else {
  291. this.dailyQueryParams.startDate = null;
  292. this.dailyQueryParams.endDate = null;
  293. }
  294. },
  295. getDailyReport() {
  296. if (!this.dailyQueryParams.startDate || !this.dailyQueryParams.endDate) {
  297. this.$message.warning('请选择时间范围');
  298. return;
  299. }
  300. this.dailyLoading = true;
  301. request({
  302. url: '/his/appOperationReport/dailyReport',
  303. method: 'get',
  304. params: this.dailyQueryParams
  305. }).then(response => {
  306. this.dailyReportList = response.rows || [];
  307. this.dailyTotal = response.total || 0;
  308. }).finally(() => {
  309. this.dailyLoading = false;
  310. });
  311. },
  312. handleWeeklyDateChange() {
  313. if (this.weeklyTimeRange && this.weeklyTimeRange.length === 2) {
  314. this.weeklyQueryParams.startDate = this.weeklyTimeRange[0];
  315. this.weeklyQueryParams.endDate = this.weeklyTimeRange[1];
  316. } else {
  317. this.weeklyQueryParams.startDate = null;
  318. this.weeklyQueryParams.endDate = null;
  319. }
  320. },
  321. getWeeklyReport() {
  322. if (!this.weeklyQueryParams.startDate || !this.weeklyQueryParams.endDate) {
  323. this.$message.warning('请选择时间范围');
  324. return;
  325. }
  326. this.weeklyLoading = true;
  327. request({
  328. url: '/his/appOperationReport/weeklyReport',
  329. method: 'get',
  330. params: this.weeklyQueryParams
  331. }).then(response => {
  332. this.weeklyReportList = response.rows || [];
  333. this.weeklyTotal = response.total || 0;
  334. }).finally(() => {
  335. this.weeklyLoading = false;
  336. });
  337. }
  338. }
  339. };
  340. </script>
  341. <style scoped>
  342. .period-switch {
  343. margin-bottom: 20px;
  344. display: flex;
  345. align-items: center;
  346. }
  347. .period-label {
  348. margin-left: 20px;
  349. font-size: 16px;
  350. font-weight: bold;
  351. color: #303133;
  352. }
  353. .card-row {
  354. margin-bottom: 20px;
  355. }
  356. .metric-card {
  357. display: flex;
  358. align-items: center;
  359. padding: 20px;
  360. }
  361. .metric-card >>> .el-card__body {
  362. display: flex;
  363. align-items: center;
  364. width: 100%;
  365. padding: 20px;
  366. }
  367. .metric-icon {
  368. width: 60px;
  369. height: 60px;
  370. border-radius: 12px;
  371. display: flex;
  372. align-items: center;
  373. justify-content: center;
  374. flex-shrink: 0;
  375. }
  376. .metric-icon i {
  377. font-size: 28px;
  378. color: #fff;
  379. }
  380. .metric-content {
  381. margin-left: 20px;
  382. flex: 1;
  383. }
  384. .metric-value {
  385. font-size: 24px;
  386. font-weight: bold;
  387. color: #303133;
  388. line-height: 1.2;
  389. }
  390. .metric-label {
  391. font-size: 13px;
  392. color: #909399;
  393. margin-top: 6px;
  394. }
  395. .daily-report-card {
  396. margin-top: 20px;
  397. }
  398. .card-header {
  399. font-size: 16px;
  400. font-weight: bold;
  401. }
  402. .query-form {
  403. margin-bottom: 15px;
  404. }
  405. .weekly-report-card {
  406. margin-top: 20px;
  407. }
  408. </style>