AnalysisComponent.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <script setup lang="ts">
  2. import type { AnalysisModel } from '@/request/model';
  3. type Props = AnalysisModel & { title?: string, exceptionType?: 'list' | 'group' };
  4. const {
  5. title = '分析', exceptionType = 'list',
  6. table, result = null, cover = [],
  7. exception, exceptionGroup,
  8. } = defineProps<Props>();
  9. </script>
  10. <template>
  11. <van-skeleton class="analysis" :row="5" :loading="result == null" v-if="result !== ''">
  12. <slot>
  13. <div class="card m-6 text-lg">
  14. <div class="card__title mb-3 text-primary text-2xl font-bold">{{ title }}</div>
  15. <slot name="content" :result="result" :cover="cover">
  16. <div class="card__content">
  17. <div
  18. class="grid grid-rows-1 gap-8"
  19. :class="cover?.length > 1 ? 'grid-cols-2' : 'grid-cols-1'"
  20. v-if="cover?.length"
  21. >
  22. <img class="m-auto w-2/4 object-contain" v-for="src in cover" :key="src" :src="src" alt="分析图像" />
  23. </div>
  24. <table class="mt-8 mb-2 w-full table-auto border border-collapse border-primary">
  25. <thead>
  26. <tr>
  27. <th
  28. class="py-4 px-2 text-primary border border-primary"
  29. v-for="(value, i) in table?.columns"
  30. :key="i"
  31. v-html="value"
  32. ></th>
  33. </tr>
  34. </thead>
  35. <tbody>
  36. <tr
  37. v-for="item in table?.data"
  38. :key="item.columns[0]"
  39. :data-exception="item.exception"
  40. :data-invalid="item.invalid"
  41. >
  42. <td
  43. class="py-4 px-2 border border-primary text-center text-grey"
  44. v-for="(value, i) in item.columns"
  45. :key="i"
  46. v-html="value"
  47. ></td>
  48. </tr>
  49. </tbody>
  50. </table>
  51. </div>
  52. </slot>
  53. </div>
  54. <slot name="exception">
  55. <div class="grid grid-rows-1 grid-cols-2 gap-8 m-6" v-if="exceptionType === 'list'">
  56. <div class="card text-lg" v-for="item in exception" :key="item.title">
  57. <div class="card__title mb-3 text-primary text-2xl font-bold">{{ item.title }}</div>
  58. <div class="card__content">
  59. <div class="flex my-6 justify-center">
  60. <img v-if="item.cover" class="flex-none w-2/4 object-scale-down" :src="item.cover" alt="分析异常图像" />
  61. <div class="flex-none ml-8">
  62. <div
  63. class="my-2 px-4 py-2 rounded-lg border border-primary-400 text-primary"
  64. v-for="value in item.tags"
  65. :key="value"
  66. >
  67. {{ value }}
  68. </div>
  69. </div>
  70. </div>
  71. <div class="my-2 text-grey" v-for="description in item.descriptions" :key="description.value">
  72. <label>{{ description.label }}</label>
  73. <span v-html="description.value"></span>
  74. </div>
  75. </div>
  76. </div>
  77. </div>
  78. <div class="grid grid-rows-1 grid-cols-1 gap-8 m-6" v-else-if="exceptionType === 'group'" >
  79. <div class="card text-lg" v-for="group in exceptionGroup" :key="group.key">
  80. <div class="card__content">
  81. <div class="flex mb-6 justify-center">
  82. <img v-if="group.key" class="flex-none w-2/4 max-h-[200px] object-scale-down" :src="group.key" alt="分析异常图像" />
  83. </div>
  84. <div class="my-3" v-for="item in group.exception" :key="item.title">
  85. <div class="card__title mb-2 text-primary text-2xl font-bold">{{ item.title }}</div>
  86. <div class="card__content">
  87. <div class="my-2 text-grey" v-for="description in item.descriptions" :key="description.value">
  88. <label>{{ description.label }}</label>
  89. <span v-html="description.value"></span>
  90. </div>
  91. </div>
  92. </div>
  93. </div>
  94. </div>
  95. </div>
  96. </slot>
  97. </slot>
  98. </van-skeleton>
  99. </template>
  100. <style scoped lang="scss">
  101. tr[data-exception='true'] td:nth-of-type(2) {
  102. color: #f87171;
  103. }
  104. tr[data-invalid='true'] td:nth-of-type(2) {
  105. color: #9ca3af;
  106. }
  107. </style>