|
|
@@ -6,10 +6,26 @@
|
|
|
<el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick" type="border-card" v-if="modelData.length">
|
|
|
<el-tab-pane :label="item.modelName" :name="item.modelName" v-for="item in modelData" :key="item.modelId"/>
|
|
|
<div class="tab-content">
|
|
|
- <div v-for="(item,index) in hostData" :key="index" class="t-c-row">
|
|
|
- <cpu-top v-if="item.data[0].alarms === undefined" :data="item.data" :title="item.title" :colors="colors" />
|
|
|
- <alarms-top v-if="item.data[0].alarms" :data="item.data" :title="item.title" :colors="colors" />
|
|
|
+ <div class="tab-bar-row">
|
|
|
+ <el-icon color="#99a9bf" size="14">
|
|
|
+ <ArrowRightBold/>
|
|
|
+ </el-icon>
|
|
|
+ <span class="row-title">按前当值排序</span>
|
|
|
+ <el-select v-model="currentTitle" size="small" style="width: 200px;" @change="changeCurrent">
|
|
|
+ <el-option v-for="item in currentData" :key="item.title" :label="item.title" :value="item.title"/>
|
|
|
+ </el-select>
|
|
|
</div>
|
|
|
+ <cpu-top :data="currentRow.data" ref="ctRef" v-if="currentRow.data" @clickRanking="getHostTrend" :currentId="currentId"/>
|
|
|
+ <div class="tab-bar-row mt30">
|
|
|
+ <el-icon color="#99a9bf" size="14">
|
|
|
+ <ArrowRightBold/>
|
|
|
+ </el-icon>
|
|
|
+ <span class="row-title">按警告次数排序</span>
|
|
|
+ <el-select v-model="alarmTitle" size="small" style="width: 200px;" @change="changeAlarm">
|
|
|
+ <el-option v-for="item in alarmData" :key="item.title" :label="item.title" :value="item.title"/>
|
|
|
+ </el-select>
|
|
|
+ </div>
|
|
|
+ <alarms-top :alarmId="alarmId" v-if="alarmRow.data" :data="alarmRow.data" ref="atRef" @clickRanking="getHostTrend"/>
|
|
|
</div>
|
|
|
</el-tabs>
|
|
|
<el-empty description="暂无数据" v-else/>
|
|
|
@@ -21,8 +37,9 @@
|
|
|
|
|
|
</template>
|
|
|
<script setup lang="ts">
|
|
|
-import {listHost, listModel} from "@/api/risk/r5"
|
|
|
-import {onMounted} from "vue";
|
|
|
+import {listHost, listHostTrend, listModel} from "@/api/risk/r5"
|
|
|
+import {nextTick, onMounted} from "vue";
|
|
|
+import {ArrowRightBold} from "@element-plus/icons-vue"
|
|
|
import cpuTop from "./components/cpuTop.vue"
|
|
|
import alarmsTop from "./components/alarmsTop.vue"
|
|
|
import hostSetting from "./components/hostSetting.vue"
|
|
|
@@ -32,6 +49,18 @@ const modelData = ref([])
|
|
|
const activeName = ref('')
|
|
|
const hostData = ref([])
|
|
|
const visible = ref(false)
|
|
|
+const currentData = ref([])
|
|
|
+const currentTitle = ref("")
|
|
|
+const currentRow = ref({})
|
|
|
+const ctRef = ref(null)
|
|
|
+const currentId = ref(0)
|
|
|
+
|
|
|
+const alarmData = ref([])
|
|
|
+const alarmTitle = ref("")
|
|
|
+const alarmRow = ref({})
|
|
|
+const atRef = ref(null)
|
|
|
+const alarmId = ref(0)
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
getModelList()
|
|
|
})
|
|
|
@@ -43,7 +72,7 @@ async function getModelList() {
|
|
|
await getHostInfo(modelData.value[0].modelId)
|
|
|
}
|
|
|
|
|
|
-function handleSet(){
|
|
|
+function handleSet() {
|
|
|
visible.value = true
|
|
|
}
|
|
|
|
|
|
@@ -54,6 +83,39 @@ function handleClick(tab) {
|
|
|
async function getHostInfo(modelId) {
|
|
|
const res = await listHost(modelId)
|
|
|
hostData.value = res.data
|
|
|
+ currentData.value = res.data.filter(p => p.data[0].alarms === undefined)
|
|
|
+ alarmData.value = res.data.filter(p => p.data[0].alarms)
|
|
|
+ if (currentData.value.length) {
|
|
|
+ changeCurrent(currentData.value[0].title)
|
|
|
+ }
|
|
|
+ if (alarmData.value.length) {
|
|
|
+ changeAlarm(alarmData.value[0].title)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function changeAlarm(title) {
|
|
|
+ alarmTitle.value = title
|
|
|
+ alarmRow.value = alarmData.value.find(p => p.title === title)
|
|
|
+ getHostTrend(alarmRow.value.data[0].id, "alarm")
|
|
|
+}
|
|
|
+
|
|
|
+function changeCurrent(title) {
|
|
|
+ currentTitle.value = title
|
|
|
+ currentRow.value = currentData.value.find(p => p.title === title)
|
|
|
+ getHostTrend(currentRow.value.data[0].id, "current")
|
|
|
+}
|
|
|
+
|
|
|
+async function getHostTrend(id, type) {
|
|
|
+ const res = await listHostTrend(id)
|
|
|
+ await nextTick(() => {
|
|
|
+ if(type === "current"){
|
|
|
+ currentId.value = id
|
|
|
+ ctRef.value.initChart(res.data)
|
|
|
+ }else{
|
|
|
+ alarmId.value = id
|
|
|
+ atRef.value.initChart(res.data)
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
</script>
|