Browse Source

feat: 修改ShowStatisticResult组件的封装

WANGKANG 3 months ago
parent
commit
10df04f5c3
1 changed files with 10 additions and 3 deletions
  1. 10 3
      src/views/demo/components/ShowStatisticResult.vue

+ 10 - 3
src/views/demo/components/ShowStatisticResult.vue

@@ -13,10 +13,12 @@
 
 <script setup lang="ts">
 import { ref } from 'vue'
+
 const props = defineProps({
   api: {
     type: Function,
-    required: true
+    required: false,
+    default: () => {}
   },
   title: {
     type: String,
@@ -27,8 +29,13 @@ const props = defineProps({
 
 const showResultDialogVisible = ref(false)
 const ResultData = ref([])
-const get_statistics_result = async (id: number | string) => {
-  const res: any = await props.api(id)
+const get_statistics_result = async (id: number | string, api: Function = undefined) => {
+  let res: any = {}
+  if (!api) {
+    res = await props.api(id)
+  } else {
+    res = await api(id)
+  }
   ResultData.value = res.data
   showResultDialogVisible.value = true
 }