Commit 4852e9bb authored by 张牧越's avatar 张牧越

AI预警联调

parent 62a270e3
...@@ -111,6 +111,15 @@ export function getWarningList(params) { ...@@ -111,6 +111,15 @@ export function getWarningList(params) {
}) })
} }
export function getStatis(params) {
return request({
url: '/pweb/s/aiwarning/statis',
method: 'get',
params
})
}
export function getMonthWarningStatis() { export function getMonthWarningStatis() {
return request({ return request({
url: '/pweb/s/aiwarning/month/statis', url: '/pweb/s/aiwarning/month/statis',
......
...@@ -104,7 +104,12 @@ ...@@ -104,7 +104,12 @@
</div> </div>
</template> </template>
<script> <script>
import { getAIdata, getWarningList, getMonthWarningStatis } from "@/api/index"; import {
getAIdata,
getWarningList,
getMonthWarningStatis,
getStatis,
} from "@/api/index";
export default { export default {
name: "EarlyWarning", name: "EarlyWarning",
data() { data() {
...@@ -113,12 +118,10 @@ export default { ...@@ -113,12 +118,10 @@ export default {
classOption: { classOption: {
singleHeight: 152, singleHeight: 152,
}, },
pieChartData: [
{ value: 30, name: "已处理" },
{ value: 10, name: "未处理" },
],
screenDetail: {}, screenDetail: {},
date: "", date: "",
todayPieChartData: {},
historyChartData: {},
}; };
}, },
methods: { methods: {
...@@ -211,18 +214,24 @@ export default { ...@@ -211,18 +214,24 @@ export default {
this.$echarts.getInstanceByDom(entry.target).resize(); this.$echarts.getInstanceByDom(entry.target).resize();
} }
}); });
resizeOb.observe(document.getElementById("today-chart"));
resizeOb.observe(document.getElementById("history-chart"));
resizeOb.observe(document.getElementById("warning-chart")); resizeOb.observe(document.getElementById("warning-chart"));
}); });
}, },
renderTodayChart() { renderTodayChart() {
const chartData = [
{ value: this.todayPieChartData.yclCount, name: "已处理" },
{ value: this.todayPieChartData.wclCount, name: "未处理" },
];
const chart = this.$echarts.init(this.$refs.todayChart); const chart = this.$echarts.init(this.$refs.todayChart);
let total = 0;
chartData.map((item) => {
total += item.value;
});
const option = { const option = {
title: { title: {
x: "27%", //X坐标 x: "27%", //X坐标
y: "37%", y: "37%",
text: "5", text: total,
subtext: "今日整改", subtext: "今日整改",
textAlign: "center", textAlign: "center",
textStyle: { textStyle: {
...@@ -264,7 +273,7 @@ export default { ...@@ -264,7 +273,7 @@ export default {
}, },
}, },
formatter: (name) => { formatter: (name) => {
let data = this.pieChartData; let data = chartData;
let target; let target;
for (let i = 0, l = data.length; i < l; i++) { for (let i = 0, l = data.length; i < l; i++) {
if (data[i].name == name) { if (data[i].name == name) {
...@@ -290,19 +299,36 @@ export default { ...@@ -290,19 +299,36 @@ export default {
position: "center", position: "center",
}, },
data: this.pieChartData, data: chartData,
}, },
], ],
}; };
chart.setOption(option); chart.setOption(option);
this.$nextTick(() => {
// 解决echarts图表放大溢出父容器
const resizeOb = new ResizeObserver((entries) => {
for (const entry of entries) {
this.$echarts.getInstanceByDom(entry.target).resize();
}
});
resizeOb.observe(document.getElementById("today-chart"));
});
}, },
renderHistoryChart() { renderHistoryChart() {
const chartData = [
{ value: this.historyChartData.yclCount, name: "已处理" },
{ value: this.historyChartData.wclCount, name: "未处理" },
];
let total = 0;
chartData.map((item) => {
total += item.value;
});
const chart = this.$echarts.init(this.$refs.historyChart); const chart = this.$echarts.init(this.$refs.historyChart);
const option = { const option = {
title: { title: {
x: "27%", //X坐标 x: "27%", //X坐标
y: "37%", y: "37%",
text: "10", text: total,
subtext: "历史整改", subtext: "历史整改",
textAlign: "center", textAlign: "center",
textStyle: { textStyle: {
...@@ -344,7 +370,7 @@ export default { ...@@ -344,7 +370,7 @@ export default {
}, },
}, },
formatter: (name) => { formatter: (name) => {
let data = this.pieChartData; let data = chartData;
let target; let target;
for (let i = 0, l = data.length; i < l; i++) { for (let i = 0, l = data.length; i < l; i++) {
if (data[i].name == name) { if (data[i].name == name) {
...@@ -370,11 +396,20 @@ export default { ...@@ -370,11 +396,20 @@ export default {
position: "center", position: "center",
}, },
data: this.pieChartData, data: chartData,
}, },
], ],
}; };
chart.setOption(option); chart.setOption(option);
this.$nextTick(() => {
// 解决echarts图表放大溢出父容器
const resizeOb = new ResizeObserver((entries) => {
for (const entry of entries) {
this.$echarts.getInstanceByDom(entry.target).resize();
}
});
resizeOb.observe(document.getElementById("history-chart"));
});
}, },
getAIdata() { getAIdata() {
getAIdata().then((res) => { getAIdata().then((res) => {
...@@ -400,6 +435,18 @@ export default { ...@@ -400,6 +435,18 @@ export default {
}, 60000); }, 60000);
} }
}); });
// 今日统计
getStatis({
start_log_time: `${this.date} 00:00:00`,
end_log_time: `${this.date} 23:59:59`,
}).then((res) => {
this.todayPieChartData = res.data;
this.renderTodayChart();
});
getStatis().then((res) => {
this.historyChartData = res.data;
this.renderHistoryChart();
});
getMonthWarningStatis().then((res) => { getMonthWarningStatis().then((res) => {
if (res.status == 200) { if (res.status == 200) {
this.warningChartData = res.data; this.warningChartData = res.data;
...@@ -412,8 +459,6 @@ export default { ...@@ -412,8 +459,6 @@ export default {
mounted() { mounted() {
this.getTime(); this.getTime();
this.getAIdata(); this.getAIdata();
this.renderTodayChart();
this.renderHistoryChart();
}, },
}; };
</script> </script>
......
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
> >
<span class="name">经理 / 王一</span> <span class="name">经理 / 王一</span>
</div> </div>
<div class="recent-open">最近开机:2023-03-12</div> <div class="recent-open">最近使用:2023-03-12</div>
<div class="cap-operation"> <div class="cap-operation">
<div <div
:class="['cap-button', windowData.online ? 'active' : 'disabled']" :class="['cap-button', windowData.online ? 'active' : 'disabled']"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment