|
@@ -23,16 +23,38 @@
|
|
<el-radio-button label="2">未关闭告警</el-radio-button>
|
|
<el-radio-button label="2">未关闭告警</el-radio-button>
|
|
</el-radio-group>
|
|
</el-radio-group>
|
|
</div>
|
|
</div>
|
|
- <Chart height="300px" ref="chart1"></Chart>
|
|
|
|
|
|
+ <Chart height="250px" ref="chart1"></Chart>
|
|
</div>
|
|
</div>
|
|
<div class="chart-item" style="flex: 1.5">
|
|
<div class="chart-item" style="flex: 1.5">
|
|
- <div class="chart-title">告警趋势</div>
|
|
|
|
- <Chart height="300px" ref="chart2"></Chart>
|
|
|
|
|
|
+ <div class="chart-title flex-row">
|
|
|
|
+ 告警趋势
|
|
|
|
+ <el-radio-group v-model="intervalType" size="small" @change="onIntervalTypeChange">
|
|
|
|
+ <el-radio-button label="1">小时</el-radio-button>
|
|
|
|
+ <el-radio-button label="2">天</el-radio-button>
|
|
|
|
+ <el-radio-button label="3">月</el-radio-button>
|
|
|
|
+ </el-radio-group>
|
|
|
|
+ </div>
|
|
|
|
+ <Chart height="250px" ref="chart2"></Chart>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="chart-wrapper">
|
|
<div class="chart-wrapper">
|
|
<div class="chart-item" style="flex: 1">
|
|
<div class="chart-item" style="flex: 1">
|
|
- <div class="chart-title">处理状态</div>
|
|
|
|
|
|
+ <div class="chart-title flex-row">
|
|
|
|
+ 处理状态
|
|
|
|
+ <el-date-picker
|
|
|
|
+ v-model="statusDateRange"
|
|
|
|
+ type="daterange"
|
|
|
|
+ range-separator="至"
|
|
|
|
+ start-placeholder="开始日期"
|
|
|
|
+ end-placeholder="结束日期"
|
|
|
|
+ :disabled-date="disabledDate"
|
|
|
|
+ format="YYYY-MM-DD"
|
|
|
|
+ value-format="YYYY-MM-DD"
|
|
|
|
+ size="small"
|
|
|
|
+ @change="onStatusDateChange"
|
|
|
|
+ style="max-width: 200px"
|
|
|
|
+ />
|
|
|
|
+ </div>
|
|
<Chart height="300px" ref="chart3"></Chart>
|
|
<Chart height="300px" ref="chart3"></Chart>
|
|
</div>
|
|
</div>
|
|
<div class="chart-item" style="flex: 1.5">
|
|
<div class="chart-item" style="flex: 1.5">
|
|
@@ -49,8 +71,9 @@ import { toRefs, reactive, onMounted, ref, watch, nextTick, onActivated, getCurr
|
|
import api from '/@/api/alarm'
|
|
import api from '/@/api/alarm'
|
|
import AlarmList from '/@/views/iot/alarm/list/index.vue'
|
|
import AlarmList from '/@/views/iot/alarm/list/index.vue'
|
|
import Chart from '/@/components/chart/index.vue'
|
|
import Chart from '/@/components/chart/index.vue'
|
|
-import { getLineOption, getPie2Option, getPie3Option, getPie4Option, getPieOption } from '/@/components/chart/options'
|
|
|
|
|
|
+import { getBarOption, getBarRowOption, getLineOption, getPie2Option, getPie3Option, getPie4Option, getPieOption } from '/@/components/chart/options'
|
|
import dayjs from 'dayjs'
|
|
import dayjs from 'dayjs'
|
|
|
|
+import { useThemeChangeFunc } from '/@/hooks/useCommon'
|
|
|
|
|
|
const chart1 = ref()
|
|
const chart1 = ref()
|
|
const chart2 = ref()
|
|
const chart2 = ref()
|
|
@@ -59,6 +82,18 @@ const chart4 = ref()
|
|
|
|
|
|
// 查询类型:不传为 全部告警 1已关闭告警 2未关闭告警
|
|
// 查询类型:不传为 全部告警 1已关闭告警 2未关闭告警
|
|
const searchType = ref('')
|
|
const searchType = ref('')
|
|
|
|
+// 统计间隔:1小时 2天 3月
|
|
|
|
+const intervalType = ref('1')
|
|
|
|
+// 处理状态时间范围
|
|
|
|
+const statusDateRange = ref([
|
|
|
|
+ dayjs().startOf('month').format('YYYY-MM-DD'),
|
|
|
|
+ dayjs().format('YYYY-MM-DD')
|
|
|
|
+])
|
|
|
|
+
|
|
|
|
+// 禁用未来日期
|
|
|
|
+const disabledDate = (time: Date) => {
|
|
|
|
+ return time.getTime() > Date.now()
|
|
|
|
+}
|
|
|
|
|
|
const { proxy } = getCurrentInstance() as any
|
|
const { proxy } = getCurrentInstance() as any
|
|
const { alarm_type } = proxy.useDict('alarm_type')
|
|
const { alarm_type } = proxy.useDict('alarm_type')
|
|
@@ -72,6 +107,7 @@ watch(
|
|
list.forEach((item: any) => {
|
|
list.forEach((item: any) => {
|
|
alarmTypeMap[item.value] = item.label
|
|
alarmTypeMap[item.value] = item.label
|
|
})
|
|
})
|
|
|
|
+ getOverviewData()
|
|
},
|
|
},
|
|
{
|
|
{
|
|
immediate: true,
|
|
immediate: true,
|
|
@@ -101,78 +137,62 @@ const homeOne = reactive([
|
|
},
|
|
},
|
|
])
|
|
])
|
|
|
|
|
|
|
|
+const onIntervalTypeChange = () => {
|
|
|
|
+ // 告警趋势 intervalType 统计间隔:1小时 2天 3月
|
|
|
|
+ api.dashboard.getAnalyzeTrend({ intervalType: intervalType.value }).then((res: any) => {
|
|
|
|
+ const resData = Object.values(res || []) as any[]
|
|
|
|
+ const legend = Object.keys(res || []).map((item) => alarmTypeMap[item])
|
|
|
|
+ // console.log(resData)
|
|
|
|
+ chart2.value?.draw(
|
|
|
|
+ getLineOption({
|
|
|
|
+ legend,
|
|
|
|
+ datas: resData.map((arr: any) => arr.map((item: any) => item.alarmCount)),
|
|
|
|
+ xAxis: resData?.[0]?.map((item: any) => item.alarmDate),
|
|
|
|
+ })
|
|
|
|
+ )
|
|
|
|
+ })
|
|
|
|
+}
|
|
|
|
+
|
|
const onSearchTypeChange = () => {
|
|
const onSearchTypeChange = () => {
|
|
// 告警级别分布
|
|
// 告警级别分布
|
|
api.dashboard
|
|
api.dashboard
|
|
.getAlarmLevel({
|
|
.getAlarmLevel({
|
|
searchType: searchType.value,
|
|
searchType: searchType.value,
|
|
- startDate: dayjs().startOf('year').format('YYYY-MM-DD'),
|
|
|
|
- endDate: dayjs().endOf('year').format('YYYY-MM-DD'),
|
|
|
|
|
|
+ startDate: dayjs().subtract(20, 'year').format('YYYY-MM-DD'),
|
|
|
|
+ endDate: dayjs().format('YYYY-MM-DD'),
|
|
})
|
|
})
|
|
.then((res: any) => {
|
|
.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: '提醒',
|
|
|
|
- },
|
|
|
|
- ]
|
|
|
|
|
|
+ const resData = res || []
|
|
|
|
+ const total = resData.reduce((a: any, b: any) => a + b.alarmCount, 0)
|
|
chart1.value?.draw(
|
|
chart1.value?.draw(
|
|
getPieOption({
|
|
getPieOption({
|
|
- data: resData.map((item: any) => ({ name: item.levelName, value: item.alarmCount })),
|
|
|
|
|
|
+ radius: ['45%', '60%'],
|
|
|
|
+ center: ['35%', '50%'],
|
|
|
|
+ legend: {
|
|
|
|
+ orient: 'vertical',
|
|
|
|
+ top: 'center',
|
|
|
|
+ right: '10%',
|
|
|
|
+ },
|
|
|
|
+ total,
|
|
|
|
+ data: resData.map((item: any) => ({
|
|
|
|
+ name: item.levelName + ' ' + item.alarmCount + ' (' + ((item.alarmCount / total) * 100).toFixed(2) + '%)',
|
|
|
|
+ value: item.alarmCount,
|
|
|
|
+ })),
|
|
})
|
|
})
|
|
)
|
|
)
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
-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
|
|
|
|
- })
|
|
|
|
- onSearchTypeChange()
|
|
|
|
- // 告警趋势 intervalType 统计间隔:1小时 2天 3月
|
|
|
|
- api.dashboard.getAnalyzeTrend({ intervalType: 2 }).then((res: any) => {
|
|
|
|
- const resData = Object.values(res || []) as any[]
|
|
|
|
- const legend = Object.keys(res || [])
|
|
|
|
- // console.log(resData)
|
|
|
|
|
|
+const onStatusDateChange = () => {
|
|
|
|
+ getAlarmStatusData()
|
|
|
|
+}
|
|
|
|
|
|
- chart2.value?.draw(
|
|
|
|
- getLineOption({
|
|
|
|
- legend,
|
|
|
|
- datas: resData.map((arr: any) => arr.map((item: any) => item.alarmCount)),
|
|
|
|
- xAxis: resData?.[0]?.map((item: any) => item.alarmDate),
|
|
|
|
- })
|
|
|
|
- )
|
|
|
|
- })
|
|
|
|
|
|
+const getAlarmStatusData = () => {
|
|
// 处理状态
|
|
// 处理状态
|
|
api.dashboard
|
|
api.dashboard
|
|
.getAlarmStatus({
|
|
.getAlarmStatus({
|
|
- startDate: dayjs().startOf('month').format('YYYY-MM-DD'),
|
|
|
|
- endDate: dayjs().endOf('month').format('YYYY-MM-DD'),
|
|
|
|
|
|
+ startDate: statusDateRange.value[0],
|
|
|
|
+ endDate: statusDateRange.value[1],
|
|
})
|
|
})
|
|
.then((res: any) => {
|
|
.then((res: any) => {
|
|
const statusMap = {
|
|
const statusMap = {
|
|
@@ -181,42 +201,40 @@ const getOverviewData = () => {
|
|
2: '已忽略',
|
|
2: '已忽略',
|
|
}
|
|
}
|
|
|
|
|
|
- const resData = res || [
|
|
|
|
- {
|
|
|
|
- alarmCount: 4,
|
|
|
|
- status: '1',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- alarmCount: 2544,
|
|
|
|
- status: '0',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- alarmCount: 0,
|
|
|
|
- status: '2',
|
|
|
|
- },
|
|
|
|
- ]
|
|
|
|
- console.log(resData)
|
|
|
|
|
|
+ const resData = res || []
|
|
|
|
+ const total = resData.reduce((a: any, b: any) => a + b.alarmCount, 0)
|
|
chart3.value?.draw(
|
|
chart3.value?.draw(
|
|
- getPieOption({
|
|
|
|
|
|
+ getPie3Option({
|
|
|
|
+ total,
|
|
data: resData.map((item: any) => ({ name: statusMap[item.status as keyof typeof statusMap], value: item.alarmCount })),
|
|
data: resData.map((item: any) => ({ name: statusMap[item.status as keyof typeof statusMap], value: item.alarmCount })),
|
|
})
|
|
})
|
|
)
|
|
)
|
|
})
|
|
})
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+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
|
|
|
|
+ })
|
|
|
|
+ onSearchTypeChange()
|
|
|
|
+ onIntervalTypeChange()
|
|
|
|
+ // 获取处理状态数据
|
|
|
|
+ getAlarmStatusData()
|
|
api.dashboard.getDeviceAlarmTop10().then((res: any) => {
|
|
api.dashboard.getDeviceAlarmTop10().then((res: any) => {
|
|
const list = res || []
|
|
const list = res || []
|
|
- const chartData = getLineOption({
|
|
|
|
- datas: [list.map((item: any) => item.alarmCount)],
|
|
|
|
|
|
+ const chartData = getBarRowOption({
|
|
|
|
+ data: [list.map((item: any) => item.alarmCount)],
|
|
xAxis: list.map((item: any) => item.deviceName),
|
|
xAxis: list.map((item: any) => item.deviceName),
|
|
- legend: ['告警设备top10'],
|
|
|
|
})
|
|
})
|
|
chart4.value.draw(chartData)
|
|
chart4.value.draw(chartData)
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
-// 页面加载时
|
|
|
|
-onMounted(() => {
|
|
|
|
- getOverviewData()
|
|
|
|
-})
|
|
|
|
|
|
+useThemeChangeFunc(getOverviewData)
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|
|
<style scoped lang="scss">
|