Forráskód Böngészése

首页首页统计图表优化,接口请求放宽到60s

wangzhiqiang 2 hónapja
szülő
commit
99e20cb5e8

+ 10 - 6
src/api/dashboard.js

@@ -1,11 +1,12 @@
 import request from '@/utils/system/request'
 
 // 查询广告平台收益
-export function getIndexProfit(data) {
+export function getIndexProfit(params) {
     return request({
         url: '/agent-service/index/profit',
-        method: 'post',
-        data
+        method: 'get',
+        params,
+        timeout: 60 * 1000
     })
 }
 
@@ -14,7 +15,8 @@ export function getIndexHourReport(data) {
     return request({
         url: '/agent-service/index/hourReport',
         method: 'post',
-        data
+        data,
+        timeout: 60 * 1000
     })
 }
 
@@ -23,7 +25,8 @@ export function getIndexUserStatistic(data) {
     return request({
         url: '/agent-service/index/userStatistic',
         method: 'post',
-        data
+        data,
+        timeout: 60 * 1000
     })
 }
 
@@ -32,7 +35,8 @@ export function getTopCount(params) {
     return request({
         url: '/agent-service/index/getTopCount',
         method: 'get',
-        params
+        params,
+        timeout: 60 * 1000
     })
 }
 

+ 16 - 5
src/views/main/dashboard/components/charts/index.vue

@@ -1,9 +1,9 @@
 <template>
   <div>
     <lineChartModel :tableData="tableData" :lineListData="seriesData" :totalProfit="totalProfit"
-      :legendData="legendData" title="收益" />
+      :legendData="legendData" title="收益" :appList="issuedAppList" @update="getIndexProfitData" />
     <lineChartModel :tableData="tableData" :lineListData="seriesEcpmData" :totalProfit="totalProfit"
-      :legendData="legendData" :type="'ecpm'" title="ECPM趋势" />
+      :legendData="legendData" :type="'ecpm'" title="ECPM趋势"  />
 
     <userDataChart />
   </div>
@@ -12,6 +12,7 @@
 <script setup>
 import { ref, onBeforeMount } from 'vue'
 import { getIndexProfit, getIndexHourReport } from '@/api/dashboard.js'
+import { issuedApps } from "@/api/formworkErection.js";
 import lineChartModel from './lineChartModel.vue'
 import userDataChart from './userDataChart.vue'
 import { roundPrice } from '@/utils'
@@ -35,8 +36,8 @@ const totalProfit = ref({}) //表格数据汇总
 const seriesData = ref([])
 const seriesEcpmData = ref([])
 const legendData = ref([]) //名称
-const getIndexProfitData = async () => {
-  const res = await getIndexProfit()
+const getIndexProfitData = async (appId) => {
+  const res = await getIndexProfit({appId})
 
   // 清空现有数据(保留响应式引用)
   tableData.value.splice(0)
@@ -128,8 +129,18 @@ const fillHourRevenueMap = (map) => {
   return fullMap
 }
 
+//应用列表
+const issuedAppList = ref([])
+const getIssuedAppList = async ()=>{
+  let res = await issuedApps({})
+  issuedAppList.value = res.data
+  console.log('res.data',res.data)
+  const firstApp =  issuedAppList.value[0].appId
+  await getIndexProfitData(firstApp)
+}
+
 onBeforeMount(async () => {
-  await getIndexProfitData()
+  await getIssuedAppList()
 })
 
 </script>

+ 54 - 29
src/views/main/dashboard/components/charts/lineChartModel.vue

@@ -2,34 +2,40 @@
     <div class="layout-container-main" id="jcsb">
         <div class="item" id="box1">
             <div class="layout-container-main-top">
-                <div class="top-left">
-                    <div class="line"></div>
-                    <span>{{ title }}</span>
-                </div>
-                <div class="main" v-if="totalProfit">
-                    <el-row v-if="type === 'earn'">
-                        <el-col :span="8">
-                            <el-statistic class="statistic" title="今日收益" :value="totalProfit.today" :precision="2" />
-                        </el-col>
-                        <el-col :span="8">
-                            <el-statistic title="昨日收益" :value="totalProfit.yesterday" :precision="2" />
-                        </el-col>
-                        <el-col :span="8">
-                            <el-statistic title="本月收益" :value="totalProfit.month" :precision="2" />
-                        </el-col>
-                    </el-row>
-                   <!--  <el-row v-else>
-                        <el-col :span="8">
-                            <el-statistic title="今日ECPM" :value="totalProfit.ecpmToday" :precision="2" />
-                        </el-col>
-                        <el-col :span="8">
-                            <el-statistic title="昨日ECPM" :value="totalProfit.ecpmYesterday" :precision="2" />
-                        </el-col>
-                        <el-col :span="8">
-                            <el-statistic title="本月ECPM" :value="totalProfit.ecpmMonth" :precision="2" />
-                        </el-col>
-                    </el-row> -->
+                <div class="left_title">
+                    <div class="top-left">
+                        <div class="line"></div>
+                        <span>{{ title }}</span>
+                    </div>
+                    <div class="main" v-if="totalProfit">
+                        <el-row v-if="type === 'earn'">
+                            <el-col :span="8">
+                                <el-statistic class="statistic" title="今日收益" :value="totalProfit.today" :precision="2" />
+                            </el-col>
+                            <el-col :span="8">
+                                <el-statistic title="昨日收益" :value="totalProfit.yesterday" :precision="2" />
+                            </el-col>
+                            <el-col :span="8">
+                                <el-statistic title="本月收益" :value="totalProfit.month" :precision="2" />
+                            </el-col>
+                        </el-row>
+                    <!--  <el-row v-else>
+                            <el-col :span="8">
+                                <el-statistic title="今日ECPM" :value="totalProfit.ecpmToday" :precision="2" />
+                            </el-col>
+                            <el-col :span="8">
+                                <el-statistic title="昨日ECPM" :value="totalProfit.ecpmYesterday" :precision="2" />
+                            </el-col>
+                            <el-col :span="8">
+                                <el-statistic title="本月ECPM" :value="totalProfit.ecpmMonth" :precision="2" />
+                            </el-col>
+                        </el-row> -->
+                    </div>
                 </div>
+
+                <el-select v-if="appList.length > 0" v-model="appId" @change="getChangeAppId">
+                    <el-option v-for="item in appList" :key="item.appId" :value="item.appId" :label="item.appName" />
+                </el-select>
             </div>
             <div class="main-echart" ref="chartRef">
                 <el-table class="table" :data="tableData" border height="100%" :fit="true" :scroll-x="false"
@@ -51,6 +57,8 @@
 import { ref, watch } from 'vue'
 import Chart from '@/components/charts/index.vue'
 
+const emit = defineEmits(['update'])
+
 const props = defineProps({
     // 表格数据
     tableData: {
@@ -80,6 +88,11 @@ const props = defineProps({
     title: {
         type: String,
         default: ''
+    },
+    // 应用数据
+    appList: {
+        type: Array,
+        default: []
     }
 });
 
@@ -174,11 +187,19 @@ const options = ref({
     series: []
 });
 
+const appId = ref('')
+const getChangeAppId = (appId) => {
+    emit('update',appId)
+}
+
+watch(() => props.appList, (newVal) => {
+    // 默认显示第一个应用
+    appId.value = props.appList[0].appId
+})
 
 // 监听 props.lineListData 变化,动态更新 series
 watch(() => props.lineListData, (newVal) => {
     if (Object.keys(newVal).length === 0) return; // 空数据不更新
-
     // 更新 ECharts 配置
     options.value.legend = {
         data: props.legendData,
@@ -216,7 +237,11 @@ watch(() => props.lineListData, (newVal) => {
         .layout-container-main-top {
             height: 6vh;
             display: flex;
-            // justify-content: space-between;
+            justify-content: space-between;
+
+            .left_title {
+                display: flex;
+            }
 
             .top-left {
                 display: flex;

+ 0 - 3
src/views/main/dashboard/components/charts/userDataChart.vue

@@ -76,7 +76,6 @@ const options = ref({
 
 const getIndexUserStatisticData = async () => {
     let res = await getIndexUserStatistic()
-    console.log('user', res)
     res = res.data
     tableData.value = [
         { name: '注册数', today: res.today, yesterday: res.yesterday, month: res.month },
@@ -132,8 +131,6 @@ function formatData(apiData) {
         )
     }
 
-    console.log('result :===>>', result);
-
     return result
 }