Explorar o código

feat: (dashborad) 对接

gemercheung %!s(int64=2) %!d(string=hai) anos
pai
achega
af83004783

+ 3 - 3
src/views/dashboard/analysis/components/VisitAnalysis.vue

@@ -19,7 +19,7 @@
   watch(
   watch(
     () => props.bulletChatAmounts,
     () => props.bulletChatAmounts,
     (data) => {
     (data) => {
-      console.log('viewStatics-data', data);
+      // console.log('viewStatics-data', data);
       bulletChatAmountsData.value = data.reduce<number[]>(
       bulletChatAmountsData.value = data.reduce<number[]>(
         (prev: number[], current) => prev.concat(Number(current.amount)),
         (prev: number[], current) => prev.concat(Number(current.amount)),
         [],
         [],
@@ -28,7 +28,7 @@
       maxSize.value = Math.floor(Math.max(...bulletChatAmountsData.value) / 1000) * 1000 + 500;
       maxSize.value = Math.floor(Math.max(...bulletChatAmountsData.value) / 1000) * 1000 + 500;
 
 
       yixStringData.value = data.reduce<string[]>(
       yixStringData.value = data.reduce<string[]>(
-        (prev: string[], current) => prev.concat(`${dateUtil(current.date).format('DD')}日`),
+        (prev: string[], current) => prev.concat(current.date),
         [],
         [],
       );
       );
 
 
@@ -43,7 +43,7 @@
   watch(
   watch(
     () => props.userAmount,
     () => props.userAmount,
     (data) => {
     (data) => {
-      console.log('viewStatics-data', data);
+      // console.log('viewStatics-data', data);
       userAmountData.value = data.reduce<number[]>(
       userAmountData.value = data.reduce<number[]>(
         (prev: number[], current) => prev.concat(Number(current.amount)),
         (prev: number[], current) => prev.concat(Number(current.amount)),
         [],
         [],

+ 5 - 4
src/views/dashboard/analysis/components/VisitAnalysisBar.vue

@@ -3,7 +3,7 @@
 </template>
 </template>
 <script lang="ts">
 <script lang="ts">
   import { basicProps } from './props';
   import { basicProps } from './props';
-  import { dateUtil } from '/@/utils/dateUtil';
+  // import { dateUtil } from '/@/utils/dateUtil';
 </script>
 </script>
 <script lang="ts" setup>
 <script lang="ts" setup>
   import { onMounted, ref, Ref, watch } from 'vue';
   import { onMounted, ref, Ref, watch } from 'vue';
@@ -26,12 +26,13 @@
         (prev: number[], current) => prev.concat(Number(current.amount)),
         (prev: number[], current) => prev.concat(Number(current.amount)),
         [],
         [],
       );
       );
-      maxSize.value = Math.floor(Math.max(...viewStaticsData.value) / 1000) * 1000 + 500;
+
       yixStringData.value = data.reduce<string[]>(
       yixStringData.value = data.reduce<string[]>(
-        (prev: string[], current) => prev.concat(`${dateUtil(current.date).format('DD')}日`),
+        (prev: string[], current) => prev.concat(current.date),
         [],
         [],
       );
       );
-
+      console.log('yixStringData', yixStringData.value);
+      maxSize.value = Math.floor(Math.max(...viewStaticsData.value) / 1000) * 1000 + 500;
       // viewStaticsData.value = data;
       // viewStaticsData.value = data;
     },
     },
     {
     {

+ 35 - 32
src/views/dashboard/analysis/index.vue

@@ -54,7 +54,7 @@
   import VisitAnalysis from './components/VisitAnalysis.vue';
   import VisitAnalysis from './components/VisitAnalysis.vue';
   import VisitAnalysisBar from './components/VisitAnalysisBar.vue';
   import VisitAnalysisBar from './components/VisitAnalysisBar.vue';
   import {
   import {
-    // bulletChatApi,
+    bulletChatApi,
     userStaticsApi,
     userStaticsApi,
     bulletChatStaticsApi,
     bulletChatStaticsApi,
     bulletChatExportApi,
     bulletChatExportApi,
@@ -69,32 +69,12 @@
   const loading = ref(true);
   const loading = ref(true);
   // UserStaticsModel
   // UserStaticsModel
 
 
-  const viewStaticsData = ref<StaticItemType[]>([
-    // { date: '2022-08-21', amount: 1111 },
-    // { date: '2022-08-22', amount: 9000 },
-    // { date: '2022-08-23', amount: 1311 },
-    // { date: '2022-08-24', amount: 1311 },
-  ]);
+  const viewStaticsData = ref<StaticItemType[]>([]);
 
 
-  const shareStaticsData = ref<StaticItemType[]>([
-    // { date: '2022-08-21', amount: 100 },
-    // { date: '2022-08-22', amount: 101 },
-    // { date: '2022-08-23', amount: 1921 },
-    // { date: '2022-08-24', amount: 1311 },
-  ]);
+  const shareStaticsData = ref<StaticItemType[]>([]);
 
 
-  const bulletChatAmountsData = ref<StaticItemType[]>([
-    // { date: '2022-08-21', amount: 1020 },
-    // { date: '2022-08-22', amount: 15201 },
-    // { date: '2022-08-23', amount: 192221 },
-    // { date: '2022-08-24', amount: 1711 },
-  ]);
-  const userAmountData = ref<StaticItemType[]>([
-    // { date: '2022-08-21', amount: 222 },
-    // { date: '2022-08-22', amount: 1212 },
-    // { date: '2022-08-23', amount: 3289 },
-    // { date: '2022-08-24', amount: 20 },
-  ]);
+  const bulletChatAmountsData = ref<StaticItemType[]>([]);
+  const userAmountData = ref<StaticItemType[]>([]);
   // const { t } = useI18n();
   // const { t } = useI18n();
 
 
   const columns: BasicColumn[] = [
   const columns: BasicColumn[] = [
@@ -136,6 +116,7 @@
         field: 'liveRoomId',
         field: 'liveRoomId',
         label: '全部房间',
         label: '全部房间',
         component: 'ApiSelect',
         component: 'ApiSelect',
+        required: true,
         colProps: {
         colProps: {
           xl: 5,
           xl: 5,
           xxl: 5,
           xxl: 5,
@@ -165,6 +146,7 @@
         },
         },
         componentProps: {
         componentProps: {
           format: 'YYYY-MM-DD',
           format: 'YYYY-MM-DD',
+          showTime: false,
           disabledDate(current) {
           disabledDate(current) {
             // console.log('current', current, date);
             // console.log('current', current, date);
             return current && current > dateUtil().endOf('day');
             return current && current > dateUtil().endOf('day');
@@ -189,21 +171,42 @@
     columns: columns,
     columns: columns,
     useSearchForm: true,
     useSearchForm: true,
     formConfig: searchForm,
     formConfig: searchForm,
-    api: bulletChatStaticsApi,
+    immediate: false,
+    api: bulletChatApi,
+    beforeFetch: (data) => {
+      console.log('beforeFetch', data);
+      data.time = data.time.map((item) => formatToDate(item));
+      return data;
+    },
     afterFetch: function (data) {
     afterFetch: function (data) {
-      console.log('afterFetch', data);
+      console.log('afterFetch', arguments);
+      handleStatic();
       return data;
       return data;
     },
     },
     searchInfo: searchInfo,
     searchInfo: searchInfo,
   });
   });
 
 
-  onMounted(async () => {
-    const data = await userStaticsApi(searchInfo);
-    viewStaticsData.value = data.viewStatics || [];
-    viewStaticsData.value = data.shareStatics || [];
-    loading.value = false;
+  onMounted(() => {
+    handleStatic();
   });
   });
 
 
+  async function handleStatic() {
+    try {
+      loading.value = true;
+      const sData = await userStaticsApi(searchInfo);
+      const bData = await bulletChatStaticsApi(searchInfo);
+      console.log('sData', sData);
+      console.log('bData', sData);
+      viewStaticsData.value = sData.viewStatics;
+      shareStaticsData.value = sData.shareStatics;
+      userAmountData.value = bData.userAmount;
+      bulletChatAmountsData.value = bData.bulletChatAmounts;
+      loading.value = false;
+    } catch (error) {
+      loading.value = false;
+    }
+  }
+
   async function handleExport() {
   async function handleExport() {
     const data = await bulletChatExportApi(searchInfo);
     const data = await bulletChatExportApi(searchInfo);
     const downloadBlob = new Blob([data], {
     const downloadBlob = new Blob([data], {