Showing
2 changed files
with
98 additions
and
0 deletions
src/api/dashboard/model/index.ts
0 → 100644
| 1 | +export interface HomeStatisticsRecordType { | |
| 2 | + deviceInfo: DeviceInfo; | |
| 3 | + alarmInfo: TotalInfo; | |
| 4 | + tenantInfo: TotalInfo; | |
| 5 | + customerInfo: TotalInfo; | |
| 6 | + productInfo: TotalInfo; | |
| 7 | + messageInfo: MessageInfo; | |
| 8 | +} | |
| 9 | + | |
| 10 | +export interface TotalInfo { | |
| 11 | + sumCount: number; | |
| 12 | + todayAdd: number; | |
| 13 | +} | |
| 14 | + | |
| 15 | +export interface DeviceInfo { | |
| 16 | + sumCount: number; | |
| 17 | + onLine: number; | |
| 18 | + offLine: number; | |
| 19 | + inActive: number; | |
| 20 | + gateWay: number; | |
| 21 | + directConnection: number; | |
| 22 | + sensor: number; | |
| 23 | + todayAdd: number; | |
| 24 | +} | |
| 25 | + | |
| 26 | +export interface MessageInfo { | |
| 27 | + messageCount: number; | |
| 28 | + dataPointsCount: number; | |
| 29 | + todayMessageAdd: number; | |
| 30 | + todayDataPointsAdd: number; | |
| 31 | +} | ... | ... |
| 1 | +<script lang="ts" setup> | |
| 2 | + import { Card, Tooltip } from 'ant-design-vue'; | |
| 3 | + import { InfoCircleOutlined } from '@ant-design/icons-vue'; | |
| 4 | + import { CountTo } from '/@/components/CountTo'; | |
| 5 | + | |
| 6 | + interface RecordType { | |
| 7 | + value: number; | |
| 8 | + label: string; | |
| 9 | + } | |
| 10 | + | |
| 11 | + withDefaults( | |
| 12 | + defineProps<{ | |
| 13 | + value?: { | |
| 14 | + images: string; | |
| 15 | + totals: RecordType[]; | |
| 16 | + tooltips: RecordType[]; | |
| 17 | + todayTotals: RecordType[]; | |
| 18 | + }; | |
| 19 | + }>(), | |
| 20 | + { | |
| 21 | + value: () => ({ | |
| 22 | + images: new URL('../../../../assets/images/product.png', import.meta.url).href, | |
| 23 | + totals: [], | |
| 24 | + tooltips: [], | |
| 25 | + todayTotals: [], | |
| 26 | + }), | |
| 27 | + } | |
| 28 | + ); | |
| 29 | +</script> | |
| 30 | + | |
| 31 | +<template> | |
| 32 | + <Card size="small" class="md:w-1/3 w-full !md:mt-0 !mt-4"> | |
| 33 | + <main class="flex flex-col"> | |
| 34 | + <div class="flex"> | |
| 35 | + <img class="w-22.5 h-22.5 mb-2.5 mr-2.5" :src="value.images" alt="" /> | |
| 36 | + <div class="flex flex-1"> | |
| 37 | + <div | |
| 38 | + class="flex-auto w-full" | |
| 39 | + v-for="(item, index) in value.totals" | |
| 40 | + :key="index" | |
| 41 | + :style="{ width: `${100 / value.totals.length}%` }" | |
| 42 | + > | |
| 43 | + <div class="font-bold text-2xl"> | |
| 44 | + <CountTo :end-val="item.value ?? 0" class="break-all" /> | |
| 45 | + </div> | |
| 46 | + <div class="text-gray-600">{{ item.label }}</div> | |
| 47 | + </div> | |
| 48 | + </div> | |
| 49 | + <Tooltip> | |
| 50 | + <template #title> | |
| 51 | + <div v-for="(item, index) in value.tooltips" :key="index" class="w-25"> | |
| 52 | + <span>{{ item.label }}</span> | |
| 53 | + <span class="ml-1">{{ item.value ?? 0 }}</span> | |
| 54 | + </div> | |
| 55 | + </template> | |
| 56 | + <InfoCircleOutlined class="text-lg svg:fill-gray-400 w-4.5 h-4.5" /> | |
| 57 | + </Tooltip> | |
| 58 | + </div> | |
| 59 | + <div class="pt-4 border-t-2 border-gray-100 flex text-gray-600 justify-between"> | |
| 60 | + <div v-for="(item, index) in value.todayTotals" :key="index"> | |
| 61 | + <span>{{ item.label }}</span> | |
| 62 | + <span class="ml-1">{{ item.value ?? 0 }}</span> | |
| 63 | + </div> | |
| 64 | + </div> | |
| 65 | + </main> | |
| 66 | + </Card> | |
| 67 | +</template> | ... | ... |