Explorar o código

fix: (dashborad) search to ref and update

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

+ 4 - 4
src/views/dashboard/analysis/enterprise.vue

@@ -24,7 +24,7 @@
   </div>
 </template>
 <script lang="ts" setup>
-  import { onMounted, reactive, ref } from 'vue';
+  import { ref } from 'vue';
   import { BasicTable, useTable, BasicColumn, FormProps } from '/@/components/Table';
   // import { useI18n } from '/@/hooks/web/useI18n';
   // import GrowCard from './components/GrowCard.vue';
@@ -191,7 +191,7 @@
     ],
   };
 
-  const searchInfo = reactive({
+  const searchInfo = ref({
     liveRoomId: '',
     limit: 20,
     page: 1,
@@ -207,6 +207,7 @@
     beforeFetch: (data) => {
       console.log('beforeFetch', data);
       data.time = data.time.map((item) => formatToDate(item));
+      searchInfo.value = data;
       return data;
     },
     afterFetch: function (data) {
@@ -216,9 +217,8 @@
     searchInfo: searchInfo,
   });
 
-  onMounted(async () => {});
   async function handleExport() {
-    const data = await companyChatExportApi(searchInfo);
+    const data = await companyChatExportApi(searchInfo.value);
     const downloadBlob = new Blob([data], {
       type: 'application/msexcel',
     });

+ 5 - 4
src/views/dashboard/analysis/index.vue

@@ -46,7 +46,7 @@
   </div>
 </template>
 <script lang="ts" setup>
-  import { onMounted, reactive, ref } from 'vue';
+  import { onMounted, ref } from 'vue';
   import { BasicTable, useTable, BasicColumn, FormProps } from '/@/components/Table';
   // import { useI18n } from '/@/hooks/web/useI18n';
   // import GrowCard from './components/GrowCard.vue';
@@ -159,7 +159,7 @@
     ],
   };
 
-  const searchInfo = reactive({
+  const searchInfo = ref({
     liveRoomId: '',
     limit: 20,
     page: 1,
@@ -177,6 +177,7 @@
       console.log('beforeFetch', data);
       data.time = data.time.map((item) => formatToDate(item));
       handleStatic(data);
+      searchInfo.value = data;
       return data;
     },
     afterFetch: function (data) {
@@ -193,7 +194,7 @@
   async function handleStatic(search?: any) {
     try {
       loading.value = true;
-      const searchInfoParams = search || searchInfo;
+      const searchInfoParams = search || searchInfo.value;
       const sData = await userStaticsApi(searchInfoParams);
       const bData = await bulletChatStaticsApi(searchInfoParams);
       console.log('sData', sData);
@@ -209,7 +210,7 @@
   }
 
   async function handleExport() {
-    const data = await bulletChatExportApi(searchInfo);
+    const data = await bulletChatExportApi(searchInfo.value);
     const downloadBlob = new Blob([data], {
       type: 'application/msexcel',
     });