ShowStatisticResult.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <el-dialog v-model="showResultDialogVisible" :title="title" width="700">
  3. <el-card style="width: 100%; margin-bottom: 10px">
  4. <div class="evaluate-data">
  5. <template v-for="(item, index) in ResultData" :key="index">
  6. <span>{{ item.name }}: {{ item.value }}</span
  7. ><br />
  8. </template>
  9. </div>
  10. </el-card>
  11. </el-dialog>
  12. </template>
  13. <script setup lang="ts">
  14. import { ref } from 'vue'
  15. const props = defineProps({
  16. api: {
  17. type: Function,
  18. required: false,
  19. default: () => {}
  20. },
  21. title: {
  22. type: String,
  23. required: false,
  24. default: '统计结果'
  25. }
  26. })
  27. const title = ref(props.title)
  28. const showResultDialogVisible = ref(false)
  29. const ResultData = ref([])
  30. const get_statistics_result = async (id: number | string, api: Function = undefined, title__: string = undefined) => {
  31. let res: any = {}
  32. if (!api) {
  33. res = await props.api(id)
  34. } else {
  35. res = await api(id)
  36. }
  37. if (title__) {
  38. title.value = title__
  39. }
  40. ResultData.value = res.data
  41. showResultDialogVisible.value = true
  42. }
  43. defineExpose({
  44. get_statistics_result: get_statistics_result
  45. })
  46. </script>
  47. <style lang="scss" scoped>
  48. .evaluate-data {
  49. span {
  50. margin-bottom: 20px;
  51. font-size: 20px;
  52. line-height: 2;
  53. }
  54. }
  55. </style>