appHealth.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <template>
  2. <div class="app-health">
  3. <div :class="`a-h-item ${itemClass[index]}`" v-for="(item,index) in currData" @click="handleDetails(item)">
  4. <div :class="`i-value ${ item.hlScore > 80 ? 'i-normal' : 'i-risk' } `">
  5. {{item.hlScore}}
  6. </div>
  7. <img :src="itemImg" alt="" class="h-img"/>
  8. <div class="i-label">{{item.modelName}}</div>
  9. </div>
  10. <!-- <div class="a-h-item item-jcd">-->
  11. <!-- <img src="@/assets/images/health-small.png" alt="" />-->
  12. <!-- <div class="i-label">应用健康度</div>-->
  13. <!-- </div>-->
  14. </div>
  15. </template>
  16. <script setup lang="ts">
  17. import itemImg from "@/assets/images/health-mini.png"
  18. import {hlCurr} from "@/api/index/hl"
  19. import {onMounted,onUnmounted} from "vue";
  20. import {useRouter} from "vue-router"
  21. const props = defineProps(["refreshTime"])
  22. const router = useRouter()
  23. const currData= ref([])
  24. const itemClass = ["","item-cq","item-js","item-hg","item-fb","item-yw"]
  25. const interval = ref(null)
  26. onMounted( ()=>{
  27. getHl()
  28. interval.value = setInterval(() => {
  29. getHl()
  30. }, props.refreshTime)
  31. })
  32. onUnmounted(() => {
  33. clearInterval(interval.value)
  34. })
  35. async function getHl(){
  36. const res = await hlCurr()
  37. currData.value = res.data
  38. }
  39. function handleDetails(item){
  40. const {modelId,hlScoreId} = item
  41. router.push({path: '/pxf-risk-monitor-web/hl/bm',query:{modelId,hlScoreId}})
  42. }
  43. </script>
  44. <style scoped lang="scss">
  45. </style>