123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462 |
- <template>
- <div class="home-container">
- <el-row :gutter="15" class="home-card-one mb15">
- <el-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6" v-for="(v, k) in homeOne" :key="k">
- <div class="home-card-top-part">
- <div class="top">
- <img :src="'/imgs/' + v.icoimg" class="icoimg" />
- <div class="card-right">
- <span class="font30">{{ v.allnum }}</span>
- <div class="label">{{ v.num3 }}</div>
- </div>
- </div>
- </div>
- </el-col>
- </el-row>
- <div class="chart-wrapper">
- <div class="chart-item" style="flex: 1">
- <div class="chart-title">告警级别分布</div>
- <Chart height="300px" ref="chart1"></Chart>
- </div>
- <div class="chart-item" style="flex: 1.5">
- <div class="chart-title">告警趋势</div>
- <Chart height="300px" ref="chart2"></Chart>
- </div>
- </div>
- <div class="chart-wrapper">
- <div class="chart-item" style="flex: 1">
- <div class="chart-title">处理状态</div>
- <Chart height="300px" ref="chart3"></Chart>
- </div>
- <div class="chart-item" style="flex: 1.5">
- <div class="chart-title">设备告警TOP10</div>
- <Chart height="300px" ref="chart4"></Chart>
- </div>
- </div>
- <AlarmList></AlarmList>
- </div>
- </template>
- <script lang="ts" setup>
- import { toRefs, reactive, onMounted, ref, watch, nextTick, onActivated, getCurrentInstance, onUnmounted } from 'vue'
- import 'vue-data-ui/style.css'
- import api from '/@/api/alarm'
- import AlarmList from '/@/views/iot/alarm/list/index.vue'
- import { useThemeChange } from '/@/hooks/useCommon'
- import Chart from '/@/components/chart/index.vue'
- import { getLineOption } from '/@/components/chart/options'
- import dayjs from 'dayjs'
- const chart1 = ref()
- const chart2 = ref()
- const chart3 = ref()
- const chart4 = ref()
- const { proxy } = getCurrentInstance() as any
- const { alarm_type } = proxy.useDict('alarm_type')
- const alarmTypeMap: any = {}
- // 监听告警类型是否获取成功
- watch(
- () => alarm_type.value,
- (list) => {
- if (!list.length) return
- list.forEach((item: any) => {
- alarmTypeMap[item.value] = item.label
- })
- },
- {
- immediate: true,
- }
- )
- const homeOne = reactive([
- {
- allnum: 0,
- num3: '告警总数',
- icoimg: 'dashboard-icon1.svg',
- },
- {
- allnum: 0,
- num3: '已关闭告警数',
- icoimg: 'dashboard-icon2.svg',
- },
- {
- allnum: 0,
- num3: '未关闭告警数',
- icoimg: 'dashboard-icon3.svg',
- },
- {
- allnum: 0,
- num3: '平均处理时长MTTR',
- icoimg: 'dashboard-icon4.svg',
- },
- ])
- const getOverviewData = () => {
- // 顶部统计数据
- api.dashboard.getTotalAlarmStatistics().then((res: any) => {
- homeOne[0].allnum = res.alarmTotalCount
- homeOne[1].allnum = res.closeAlarmCount
- homeOne[2].allnum = res.unCloseAlarmCount
- homeOne[3].allnum = res.averageDealTime
- })
- // 告警级别分布
- api.dashboard
- .getAlarmLevel({
- searchType: null,
- startDate: dayjs().startOf('month').format('YYYY-MM-DD'),
- endDate: dayjs().endOf('month').format('YYYY-MM-DD'),
- })
- .then((res: any) => {
- const resData = res || [
- {
- alarmCount: 2548,
- alarmLevel: '1',
- levelName: '超紧急',
- },
- {
- alarmCount: 0,
- alarmLevel: '2',
- levelName: '紧急',
- },
- {
- alarmCount: 0,
- alarmLevel: '3',
- levelName: '严重',
- },
- {
- alarmCount: 0,
- alarmLevel: '4',
- levelName: '一般',
- },
- {
- alarmCount: 0,
- alarmLevel: '5',
- levelName: '提醒',
- },
- ]
- console.log(resData)
- })
- // 告警趋势 intervalType 统计间隔:1小时 2天 3月
- api.dashboard.getAnalyzeTrend({ intervalType: 2 }).then((res: any) => {
- const resData = res || []
- console.log(resData)
- })
- // 处理状态
- api.dashboard
- .getAlarmStatus({
- startDate: dayjs().startOf('month').format('YYYY-MM-DD'),
- endDate: dayjs().endOf('month').format('YYYY-MM-DD'),
- })
- .then((res: any) => {
- const resData = res || [
- {
- alarmCount: 4,
- status: '1',
- },
- {
- alarmCount: 2544,
- status: '0',
- },
- {
- alarmCount: 0,
- status: '2',
- },
- ]
- console.log(resData)
- })
- api.dashboard.getDeviceAlarmTop10().then((res: any) => {
- const list = res || []
- const chartData = getLineOption({
- datas: [list.map((item: any) => item.alarmCount)],
- xAxis: list.map((item: any) => item.deviceName),
- legend: ['告警设备top10'],
- })
- chart4.value.draw(chartData)
- })
- }
- // 页面加载时
- onMounted(() => {
- getOverviewData()
- })
- </script>
- <style scoped lang="scss">
- $homeNavLengh: 8;
- .chart-wrapper {
- display: flex;
- justify-content: space-between;
- align-items: stretch;
- gap: 16px;
- .chart-item {
- background-color: var(--el-color-white);
- padding: 12px 15px;
- border-radius: 8px;
- margin-bottom: 16px;
- flex: 1;
- min-width: 200px;
- }
- .chart-title {
- font-size: 15px;
- font-weight: bold;
- padding-left: 5px;
- }
- }
- .home-card-top-part {
- background-color: var(--el-color-white);
- border-radius: 8px;
- padding: 20px 20px;
- .top {
- display: flex;
- justify-content: space-around;
- overflow: hidden;
- align-items: center;
- }
- .icoimg {
- width: 54px !important;
- height: 54px !important;
- margin-right: 12px;
- }
- .label {
- font-size: 14px;
- font-weight: 500;
- }
- .divider {
- border-top: 1px solid var(--el-border-color-light);
- margin: 12px 0 15px;
- }
- .card-right {
- flex: 1;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- white-space: nowrap;
- line-height: 1;
- height: 54px;
- .font30 {
- color: #4285f4;
- font-weight: bold;
- font-size: 30px;
- }
- }
- .card-bottom {
- font-size: 12px;
- display: flex;
- align-items: center;
- justify-content: space-around;
- gap: 12px;
- white-space: nowrap;
- .split {
- border-right: 1px solid var(--el-border-color-light);
- height: 20px;
- }
- .icon {
- width: 17px;
- height: 17px;
- }
- .info {
- font-size: 12px;
- font-weight: 500;
- }
- }
- }
- .home-container {
- overflow: hidden;
- .home-card-one,
- .home-card-two,
- .home-card-three {
- .icoimg {
- width: 75px;
- height: 75px;
- }
- .title_status {
- width: 7px;
- height: 7px;
- background: #c1bbbb;
- border-radius: 50px;
- margin-right: 5px;
- }
- .home-card-item,
- .home-card-top {
- width: 100%;
- border-radius: 8px;
- transition: all ease 0.3s;
- padding: 10px 20px;
- overflow: hidden;
- background: var(--el-color-white);
- color: var(--el-text-color-primary);
- // border: 1px solid var(--next-border-color-light);
- &:hover {
- // box-shadow: 0 2px 12px var(--next-color-dark-hover);
- transition: all ease 0.3s;
- }
- &-icon {
- width: 70px;
- height: 70px;
- border-radius: 100%;
- flex-shrink: 1;
- i {
- color: var(--el-text-color-placeholder);
- }
- }
- &-title {
- font-size: 15px;
- font-weight: bold;
- height: 30px;
- }
- }
- }
- .home-card-three {
- .home-card-item-title {
- display: flex;
- justify-content: space-between;
- // span:nth-child(2) {
- // color: #409eff;
- // }
- }
- }
- .home-card-one {
- @for $i from 0 through 3 {
- .home-one-animation#{$i} {
- opacity: 0;
- animation-name: error-num;
- animation-duration: 0.5s;
- animation-fill-mode: forwards;
- animation-delay: calc($i/10) + s;
- }
- }
- }
- .home-card-two,
- .home-card-three {
- .home-card-top {
- height: 250px;
- .box-card {
- padding: 15px 20px 20px 10px;
- p {
- margin-bottom: 10px;
- }
- &-item {
- margin-bottom: 10px;
- }
- }
- }
- .home-card-item,
- .home-card-top {
- width: 100%;
- overflow: hidden;
- .home-monitor {
- height: 100%;
- .flex-warp-item {
- width: 25%;
- height: 111px;
- display: flex;
- .flex-warp-item-box {
- margin: auto;
- text-align: center;
- color: var(--el-text-color-primary);
- display: flex;
- border-radius: 5px;
- background: var(--next-bg-color);
- cursor: pointer;
- transition: all 0.3s ease;
- &:hover {
- background: var(--el-color-primary-light-9);
- transition: all 0.3s ease;
- }
- }
- @for $i from 0 through $homeNavLengh {
- .home-animation#{$i} {
- opacity: 0;
- animation-name: error-num;
- animation-duration: 0.5s;
- animation-fill-mode: forwards;
- animation-delay: calc($i/10) + s;
- }
- }
- }
- }
- }
- }
- .text-info {
- color: #23c6c8;
- }
- .text-danger {
- color: #ed5565;
- }
- .git-res {
- margin-top: 20px;
- }
- .git-res .el-link {
- margin-right: 30px;
- }
- ul,
- li {
- padding: 0;
- margin: 0;
- list-style: none;
- }
- .product {
- margin-top: 50px;
- h3 {
- margin-bottom: 15px;
- }
- }
- .product li {
- margin-bottom: 20px;
- float: left;
- width: 150px;
- }
- .box-card.xx {
- margin-top: 20px;
- }
- }
- .home-card-item.chart {
- padding: 10px !important;
- }
- </style>
|