From 4f40148798c944eaddceb3539cfe0ecc1dab5266 Mon Sep 17 00:00:00 2001
From: 罗广辉 <guanghui.luo@foxmail.com>
Date: Mon, 31 Mar 2025 18:56:30 +0800
Subject: [PATCH] feat: 巡检任务概况,事件概况,事件类型完成率接口对接
---
src/components/CommonDateTime.vue | 46 ++++++-
src/views/Home/components/HomeLeft/InspectionRaskDetails.vue | 116 +++++++++++--------
src/views/TestTemplate.vue | 3
src/api/home/index.js | 24 +++
src/views/Home/components/HomeRight/EventOverview.vue | 135 ++++++++++++++-------
5 files changed, 218 insertions(+), 106 deletions(-)
diff --git a/src/api/home/index.js b/src/api/home/index.js
index 318eb8e..45fbd5f 100644
--- a/src/api/home/index.js
+++ b/src/api/home/index.js
@@ -17,9 +17,31 @@
};
// 巡检任务柱状图数据
-export const getJobNumBar = () => {
+export const getJobNumBar = (data) => {
return request({
url: '/drone-device-core/wayline/waylineJobInfo/jobNumBar',
method: 'post',
+ data
+ });
+};
+// 事件概况
+export const getJobEventTotal = () => {
+ return request({
+ url: '/drone-device-core/jobEvent/total',
+ method: 'get',
+ });
+};
+export const getJobEventByStatus = (data) => {
+ return request({
+ url: '/drone-device-core/jobEvent/eventByStatus',
+ method: 'post',
+ data
+ });
+};
+export const getJobEventBrokerLine = (data) => {
+ return request({
+ url: '/drone-device-core/jobEvent/eventBrokerLine',
+ method: 'post',
+ data
});
};
diff --git a/src/components/CommonDateTime.vue b/src/components/CommonDateTime.vue
index efd1c5a..e33162a 100644
--- a/src/components/CommonDateTime.vue
+++ b/src/components/CommonDateTime.vue
@@ -1,33 +1,61 @@
<template>
<div class="common-date-time">
<el-date-picker
- v-model="newTime"
+ v-model="model"
type="daterange"
+ value-format="YYYY-MM-DD"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
- >
- </el-date-picker>
+ @change="change"
+ />
<div class="time-card">
<div
class="card-item"
- :class="item == checked ? 'active' : ''"
- v-for="item in timeList"
+ :class="item === checked ? 'active' : ''"
+ v-for="(item, index) in timeList"
@click="timeClick(item)"
>
- {{ item }}
+ {{ timeListStr[index] }}
</div>
</div>
</div>
</template>
<script setup>
-const newTime = ref([]);
-let timeList = ['今日', '本周', '本月', '本年'];
+import dayjs from 'dayjs';
+import { ref, defineEmits } from 'vue';
-let checked = ref('今日');
+const emit = defineEmits(['change']);
+
+const model = defineModel();
+
+let timeList = ['today', 'week', 'month', 'year'];
+let timeListStr = ['今日', '本周', '本月', '本年'];
+let checked = ref('today');
+
+const getDateRange = unit => {
+ if (unit === 'today') {
+ return [dayjs().format('YYYY-MM-DD'), dayjs().format('YYYY-MM-DD')];
+ }
+ return [dayjs().startOf(unit).format('YYYY-MM-DD'), dayjs().endOf(unit).format('YYYY-MM-DD')];
+};
+
+const dateRanges = {
+ today: getDateRange('today'),
+ week: getDateRange('week'),
+ month: getDateRange('month'),
+ year: getDateRange('year'),
+};
+
+const change = value => {
+ emit('change', value);
+};
+
let timeClick = item => {
checked.value = item;
+ model.value = dateRanges[item];
+ emit('change', model.value);
};
</script>
diff --git a/src/views/Home/components/HomeLeft/InspectionRaskDetails.vue b/src/views/Home/components/HomeLeft/InspectionRaskDetails.vue
index e061d39..a2c55fc 100644
--- a/src/views/Home/components/HomeLeft/InspectionRaskDetails.vue
+++ b/src/views/Home/components/HomeLeft/InspectionRaskDetails.vue
@@ -1,15 +1,11 @@
<!-- 巡检任务详情 -->
<template>
- <common-title
- title="巡检任务情况"
- :style="{ marginLeft: pxToRem(14) }"
- @details="detailsFun"
- >
+ <common-title title="巡检任务情况" :style="{ marginLeft: pxToRem(14) }" @details="detailsFun">
</common-title>
<div class="inspection-rask-details">
<div class="inspection-num">
<div class="total">
- <div class="value">{{total}}</div>
+ <div class="value">{{ total }}</div>
<div class="name">总任务数</div>
</div>
<div class="status">
@@ -19,7 +15,7 @@
</div>
</div>
</div>
- <CommonDateTime :style="{ top: pxToRem(19) }"></CommonDateTime>
+ <CommonDateTime :style="{ top: pxToRem(19) }" v-model="newTime" @change="dateChange" />
<div class="chart-container" ref="chartRef"></div>
</div>
</template>
@@ -30,13 +26,17 @@
import CommonTitle from '@/components/CommonTitle.vue';
import CommonDateTime from '@/components/CommonDateTime.vue';
import { getJobNumBar, getJobStatistics, getTotalJobNum } from '@/api/home';
+import dayjs from 'dayjs';
+
+const currenDate = dayjs().format('YYYY-MM-DD');
+const newTime = ref([currenDate, currenDate]);
const list = ref([
- { name: '计划执行', value: 89, color: '#FFFFFF',field:'planned_executions' },
- { name: '执行中', value: 100, color: '#FFA768',field:'running_num' },
- { name: '待执行', value: 66, color: '#FFE17E',field:'pending_executions' },
- { name: '已执行', value: 10, color: '#8EFFAC',field:'executed' },
- { name: '执行失败', value: 10, color: '#FF8E8E',field:'failed_executions' },
+ { name: '计划执行', value: 89, color: '#FFFFFF', field: 'planned_executions' },
+ { name: '执行中', value: 100, color: '#FFA768', field: 'running_num' },
+ { name: '待执行', value: 66, color: '#FFE17E', field: 'pending_executions' },
+ { name: '已执行', value: 10, color: '#8EFFAC', field: 'executed' },
+ { name: '执行失败', value: 10, color: '#FF8E8E', field: 'failed_executions' },
]);
const option = {
grid: {
@@ -121,54 +121,67 @@
},
},
},
- series: [
- {
- data: [
- 10, 15, 8, 20, 12, 18, 15, 22, 16, 19, 14, 17, 21, 13, 16, 18, 15, 20, 17, 22, 19, 16, 14,
- 18, 21, 15, 17, 20, 16, 18,
- ],
- type: 'bar',
- barWidth: '60%',
- itemStyle: {
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
- { offset: 0, color: '#1EE7E7' },
- { offset: 1, color: 'rgba(0, 112, 255, 0.1)' },
- ]),
- },
+ series: {
+ data: [
+ 10, 15, 8, 20, 12, 18, 15, 22, 16, 19, 14, 17, 21, 13, 16, 18, 15, 20, 17, 22, 19, 16, 14, 18,
+ 21, 15, 17, 20, 16, 18,
+ ],
+ type: 'bar',
+ barWidth: '60%',
+ itemStyle: {
+ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
+ { offset: 0, color: '#1EE7E7' },
+ { offset: 1, color: 'rgba(0, 112, 255, 0.1)' },
+ ]),
},
- ],
+ },
};
const detailsFun = () => {
console.log('details');
};
+const dateChange = value => {
+ newTime.value = value;
+ getData();
+};
+let chart = null;
+const getData = () => {
+ const params = {
+ date_enum: 'TODAY',
+ // start_date: newTime.value[0],
+ // end_date: newTime.value[1]
+ };
+ getJobStatistics(params).then(res => {
+ jobStatistics.value = res.data?.data || {};
+ });
+ getJobNumBar(params).then(res => {
+ option.xAxis.data = res.data?.data.map(item => item.name);
+ option.series.data = res.data?.data.map(item => item.value);
+ chart.setOption(option);
+ });
+};
+
const chartRef = ref(null);
const total = ref(0);
const jobStatistics = ref({
- "planned_executions": 0,
- "executed": 0,
- "running_num": 0,
- "failed_executions": 0,
- "pending_executions": 0
-})
+ planned_executions: 0,
+ executed: 0,
+ running_num: 0,
+ failed_executions: 0,
+ pending_executions: 0,
+});
onMounted(() => {
- getTotalJobNum().then(res => {
- total.value = res.data?.data || 0
- })
- getJobStatistics().then(res => {
- jobStatistics.value = res.data?.data || {}
- })
- getJobNumBar().then(res => {
- console.log(res.data.data);
- })
- const chart = echarts.init(chartRef.value);
- chart.setOption(option);
+ chart = echarts.init(chartRef.value);
// 监听窗口大小变化
window.addEventListener('resize', () => {
chart.resize();
});
+ getTotalJobNum().then(res => {
+ total.value = res.data?.data || 0;
+ });
+ getData();
});
</script>
@@ -179,18 +192,20 @@
width: 390px;
height: 414px;
background: linear-gradient(
- 270deg,
- rgba(31, 62, 122, 0) 0%,
- rgba(31, 62, 122, 0.35) 21%,
- #1f3e7a 100%
+ 270deg,
+ rgba(31, 62, 122, 0) 0%,
+ rgba(31, 62, 122, 0.35) 21%,
+ #1f3e7a 100%
);
border-radius: 0px 0px 0px 0px;
opacity: 0.85;
+
.inspection-num {
background: url('@/assets/images/home/homeLeft/inspection-num.png') no-repeat center / 100% 100%;
width: 360px;
height: 118px;
position: relative;
+
.total {
position: absolute;
left: 34px;
@@ -201,12 +216,14 @@
text-align: center;
font-family: Source Han Sans CN, Source Han Sans CN;
line-height: 19px;
+
.value {
font-family: YouSheBiaoTiHei, YouSheBiaoTiHei;
margin-left: 8px;
font-size: 26px;
}
}
+
.status {
position: absolute;
top: 8px;
@@ -218,12 +235,14 @@
justify-content: flex-start;
line-height: 22px;
padding: 0 10px 10px 0;
+
.name {
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 400;
font-size: 14px;
color: #ffffff;
}
+
.value {
font-family: YouSheBiaoTiHei, YouSheBiaoTiHei;
font-weight: 400;
@@ -231,6 +250,7 @@
}
}
}
+
.chart-container {
width: 100%;
height: 200px;
diff --git a/src/views/Home/components/HomeRight/EventOverview.vue b/src/views/Home/components/HomeRight/EventOverview.vue
index b642822..426573d 100644
--- a/src/views/Home/components/HomeRight/EventOverview.vue
+++ b/src/views/Home/components/HomeRight/EventOverview.vue
@@ -1,6 +1,42 @@
+<template>
+ <CommonTitle title="事件概况" />
+ <div :style="{ marginLeft: pxToRem(14) }">
+ <div class="eventOverview">
+ <div class="overviewData">
+ <div class="totalBox">
+ <div class="totalNumber">{{ total }}</div>
+ <div class="totalLabel">总事件数</div>
+ </div>
+ <div class="contentBox">
+ <div class="overviewItem" v-for="item in list" :key="item.name">
+ <div class="itemName"><img :src="item.img" alt="" />{{ item.name }}</div>
+ <div class="itemValue" :style="{ color: item.color }">{{ item.value }}</div>
+ </div>
+ </div>
+ </div>
+ <CommonDateTime class="dateTime" v-model="newTime" @change="dateChange" />
+
+ <el-select class="homeRightSelect" v-model="value" placeholder="请选择" size="large">
+ <el-option
+ v-for="item in options"
+ :key="item.value"
+ :label="item.label"
+ :value="item.value"
+ />
+ </el-select>
+ <div class="completion">
+ <img class="completion-left-img" :src="completionLeft" alt="" />
+ <div class="completion-text">事件类型完成率情况</div>
+ <div class="completion-separator"></div>
+ <img class="completion-left-img" :src="completionLeft" alt="" />
+ </div>
+
+ <div class="chart" ref="echartsRef"></div>
+ </div>
+ </div>
+</template>
<script setup>
import CommonTitle from '@/components/CommonTitle.vue';
-import { pxToRem } from '@/utils/rem';
import overviewImg1 from '@/assets/images/home/homeRight/overview1.png';
import overviewImg2 from '@/assets/images/home/homeRight/overview2.png';
import overviewImg3 from '@/assets/images/home/homeRight/overview3.png';
@@ -10,6 +46,14 @@
import completionLeft from '@/assets/images/home/homeRight/completionLeft.png';
import * as echarts from 'echarts';
import CommonDateTime from '@/components/CommonDateTime.vue';
+import {
+ getJobEventBrokerLine,
+ getJobEventByStatus,
+ getJobEventTotal,
+ getJobNumBar,
+ getJobStatistics,
+} from '@/api/home';
+import dayjs from 'dayjs';
const list = ref([
{ name: '待审核', value: 265, img: overviewImg1, color: '#FF8E8E' },
@@ -20,7 +64,7 @@
{ name: '已完结', value: 262, img: overviewImg6, color: '#8EFFAC' },
]);
const value = ref('');
-const echartsRef = ref('');
+const echartsRef = ref(null);
const options = [
{
@@ -28,6 +72,8 @@
label: 'Option1',
},
];
+const currenDate = dayjs().format('YYYY-MM-DD');
+const newTime = ref([currenDate, currenDate]);
const option = {
tooltip: {
trigger: 'axis',
@@ -53,7 +99,7 @@
fontWeight: 400,
fontSize: 10,
},
- data: ['暴露垃圾', '占道','暴露垃圾', '占道','暴露垃圾', '占道','暴露垃圾', '占道',],
+ data: ['暴露垃圾', '占道', '暴露垃圾', '占道', '暴露垃圾', '占道', '暴露垃圾', '占道'],
},
],
yAxis: [
@@ -90,7 +136,7 @@
itemStyle: {
color: '#FF8E8E', // 设置颜色
},
- data: [120, 132,120, 132,120, 132,120, 132,],
+ data: [120, 132, 120, 132, 120, 132, 120, 132],
},
{
name: '已完成',
@@ -99,7 +145,7 @@
emphasis: {
focus: 'series',
},
- data: [120, 132,120, 132,120, 132,120, 132,],
+ data: [120, 132, 120, 132, 120, 132, 120, 132],
},
{
name: '已完成1',
@@ -108,7 +154,7 @@
emphasis: {
focus: 'series',
},
- data: [120, 132,120, 132,120, 132,120, 132,],
+ data: [120, 132, 120, 132, 120, 132, 120, 132],
},
{
name: '已完成2',
@@ -117,7 +163,7 @@
emphasis: {
focus: 'series',
},
- data: [120, 132,120, 132,120, 132,120, 132,],
+ data: [120, 132, 120, 132, 120, 132, 120, 132],
},
{
name: '完成率',
@@ -138,6 +184,33 @@
},
],
};
+const total = ref(0);
+
+const getData = () => {
+ const params = {
+ date_enum: 'TODAY',
+ // start_date: newTime.value[0],
+ // end_date: newTime.value[1]
+ };
+ getJobEventByStatus(params).then(res => {
+ const resList = res?.data?.data || [];
+ resList.forEach(item => {
+ list.value.forEach(item1 => {
+ if (item1.name === item.name) {
+ item1.value = item.num;
+ }
+ });
+ });
+ });
+ // todo 未对接
+ getJobEventBrokerLine(params).then(res => {});
+};
+
+const dateChange = value => {
+ console.log(value);
+ newTime.value = value;
+ getData();
+};
onMounted(() => {
const chart = echarts.init(echartsRef.value);
@@ -145,51 +218,17 @@
window.addEventListener('resize', () => {
chart.resize();
});
+ getJobEventTotal().then(res => {
+ total.value = res?.data?.data || 0;
+ });
+ getData();
});
</script>
-
-<template>
- <CommonTitle title="事件概况" />
- <div :style="{ marginLeft: pxToRem(14) }">
- <div class="eventOverview">
- <div class="overviewData">
- <div class="totalBox">
- <div class="totalNumber">8096</div>
- <div class="totalLabel">总事件数</div>
- </div>
- <div class="contentBox">
- <div class="overviewItem" v-for="item in list" :key="item.name">
- <div class="itemName"><img :src="item.img" alt="" />{{ item.name }}</div>
- <div class="itemValue" :style="{ color: item.color }">{{ item.value }}</div>
- </div>
- </div>
- </div>
- <CommonDateTime class="dateTime" />
-
- <el-select class="homeRightSelect" v-model="value" placeholder="请选择" size="large">
- <el-option
- v-for="item in options"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- />
- </el-select>
-
- <div class="completion">
- <img class="completion-left-img" :src="completionLeft" />
- <div class="completion-text">事件类型完成率情况</div>
- <div class="completion-separator"></div>
- <img class="completion-left-img" :src="completionLeft" />
- </div>
-
- <div class="chart" ref="echartsRef"></div>
- </div>
- </div>
-</template>
<style scoped lang="scss">
.homeRightSelect {
width: 356px;
+
:deep() {
.el-select__wrapper {
background: linear-gradient(90deg, #195bad 0%, rgba(25, 91, 173, 0) 100%);
@@ -224,7 +263,7 @@
flex-direction: column;
align-items: center;
- .dateTime{
+ .dateTime {
width: 356px;
margin: 15px 0 8px 0;
}
@@ -239,6 +278,8 @@
padding-left: 11px;
.totalBox {
+ width: 77px;
+
.totalNumber {
font-family: YouSheBiaoTiHei, YouSheBiaoTiHei;
font-weight: 400;
diff --git a/src/views/TestTemplate.vue b/src/views/TestTemplate.vue
index 359a7f4..0836554 100644
--- a/src/views/TestTemplate.vue
+++ b/src/views/TestTemplate.vue
@@ -1,3 +1,5 @@
+<template></template>
+
<script setup>
import { useStore } from 'vuex';
@@ -22,6 +24,5 @@
);
</script>
-<template></template>
<style scoped lang="scss"></style>
--
Gitblit v1.9.3