<template>
|
<div class="app-container">
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="88px">
|
<el-form-item label="车牌号" prop="vehicleNo">
|
<el-input
|
v-model="queryParams.vehicleNo"
|
placeholder="请输入车牌号"
|
clearable
|
size="small"
|
@keyup.enter.native="handleQuery"
|
/>
|
</el-form-item>
|
<el-form-item label="告警日期" prop="alertDate">
|
<el-date-picker
|
v-model="queryParams.alertDate"
|
type="date"
|
value-format="yyyy-MM-dd"
|
placeholder="请选择告警日期"
|
clearable
|
size="small"
|
/>
|
</el-form-item>
|
<el-form-item label="告警状态" prop="status">
|
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable size="small">
|
<el-option label="未处理" value="0" />
|
<el-option label="已处理" value="1" />
|
</el-select>
|
</el-form-item>
|
<el-form-item label="归属部门" prop="deptId">
|
<el-select v-model="queryParams.deptId" placeholder="请选择部门" clearable size="small">
|
<el-option
|
v-for="dept in deptList"
|
:key="dept.deptId"
|
:label="dept.deptName"
|
:value="dept.deptId"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="告警时间">
|
<el-date-picker
|
v-model="dateRange"
|
size="small"
|
style="width: 240px"
|
value-format="yyyy-MM-dd"
|
type="daterange"
|
range-separator="-"
|
start-placeholder="开始日期"
|
end-placeholder="结束日期"
|
></el-date-picker>
|
</el-form-item>
|
<el-form-item>
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
</el-form-item>
|
</el-form>
|
|
<el-row :gutter="10" class="mb8">
|
<el-col :span="1.5">
|
<el-button
|
type="success"
|
plain
|
icon="el-icon-check"
|
size="mini"
|
:disabled="multiple"
|
@click="handleBatchProcess"
|
v-hasPermi="['system:vehicleAlert:handle']"
|
>批量处理</el-button>
|
</el-col>
|
<el-col :span="1.5">
|
<el-button
|
type="danger"
|
plain
|
icon="el-icon-delete"
|
size="mini"
|
:disabled="multiple"
|
@click="handleDelete"
|
v-hasPermi="['system:vehicleAlert:remove']"
|
>删除</el-button>
|
</el-col>
|
<el-col :span="1.5">
|
<el-button
|
type="warning"
|
plain
|
icon="el-icon-download"
|
size="mini"
|
@click="handleExport"
|
v-hasPermi="['system:vehicleAlert:export']"
|
>导出</el-button>
|
</el-col>
|
<el-col :span="1.5">
|
<el-button
|
type="info"
|
plain
|
icon="el-icon-refresh"
|
size="mini"
|
@click="refreshUnhandledCount"
|
>刷新统计</el-button>
|
</el-col>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
</el-row>
|
|
<!-- 统计卡片 -->
|
<el-row :gutter="20" class="mb8">
|
<el-col :span="6">
|
<el-card shadow="hover">
|
<div style="text-align: center;">
|
<div style="font-size: 14px; color: #909399;">未处理告警</div>
|
<div style="font-size: 28px; color: #F56C6C; font-weight: bold; margin-top: 10px;">
|
{{ unhandledCount }}
|
</div>
|
</div>
|
</el-card>
|
</el-col>
|
<el-col :span="6">
|
<el-card shadow="hover">
|
<div style="text-align: center;">
|
<div style="font-size: 14px; color: #909399;">今日告警</div>
|
<div style="font-size: 28px; color: #E6A23C; font-weight: bold; margin-top: 10px;">
|
{{ todayCount }}
|
</div>
|
</div>
|
</el-card>
|
</el-col>
|
<el-col :span="6">
|
<el-card shadow="hover">
|
<div style="text-align: center;">
|
<div style="font-size: 14px; color: #909399;">累计告警车辆</div>
|
<div style="font-size: 28px; color: #409EFF; font-weight: bold; margin-top: 10px;">
|
{{ totalVehicles }}
|
</div>
|
</div>
|
</el-card>
|
</el-col>
|
<el-col :span="6">
|
<el-card shadow="hover">
|
<div style="text-align: center;">
|
<div style="font-size: 14px; color: #909399;">累计告警次数</div>
|
<div style="font-size: 28px; color: #67C23A; font-weight: bold; margin-top: 10px;">
|
{{ total }}
|
</div>
|
</div>
|
</el-card>
|
</el-col>
|
</el-row>
|
|
<el-table v-loading="loading" :data="alertList" @selection-change="handleSelectionChange">
|
<el-table-column type="selection" width="55" align="center" />
|
<el-table-column label="告警ID" align="center" prop="alertId" width="80" />
|
<el-table-column label="车牌号" align="center" prop="vehicleNo" width="120">
|
<template slot-scope="scope">
|
<el-tag>{{ scope.row.vehicleNo }}</el-tag>
|
</template>
|
</el-table-column>
|
<el-table-column label="告警日期" align="center" prop="alertDate" width="120" />
|
<el-table-column label="告警时间" align="center" prop="alertTime" width="180">
|
<template slot-scope="scope">
|
<span>{{ parseTime(scope.row.alertTime) }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column label="运行里程(公里)" align="center" prop="mileage" width="140">
|
<template slot-scope="scope">
|
<el-tag type="danger" v-if="scope.row.mileage >= 10">
|
{{ scope.row.mileage }} km
|
</el-tag>
|
<span v-else>{{ scope.row.mileage }} km</span>
|
</template>
|
</el-table-column>
|
<el-table-column label="当日告警次数" align="center" prop="alertCount" width="120">
|
<template slot-scope="scope">
|
<el-tag type="warning" v-if="scope.row.alertCount >= 3">
|
第{{ scope.row.alertCount }}次
|
</el-tag>
|
<span v-else>第{{ scope.row.alertCount }}次</span>
|
</template>
|
</el-table-column>
|
<el-table-column label="归属部门" align="center" prop="deptName" width="150" :show-overflow-tooltip="true" />
|
<el-table-column label="告警状态" align="center" prop="status" width="100">
|
<template slot-scope="scope">
|
<el-tag v-if="scope.row.status === '0'" type="danger">未处理</el-tag>
|
<el-tag v-else type="success">已处理</el-tag>
|
</template>
|
</el-table-column>
|
<el-table-column label="通知状态" align="center" prop="notifyStatus" width="100">
|
<template slot-scope="scope">
|
<el-tag v-if="scope.row.notifyStatus === '0'" type="info">未发送</el-tag>
|
<el-tag v-else-if="scope.row.notifyStatus === '1'" type="success">已发送</el-tag>
|
<el-tag v-else type="danger">发送失败</el-tag>
|
</template>
|
</el-table-column>
|
<el-table-column label="处理人" align="center" prop="handlerName" width="100" :show-overflow-tooltip="true" />
|
<el-table-column label="处理时间" align="center" prop="handleTime" width="180">
|
<template slot-scope="scope">
|
<span v-if="scope.row.handleTime">{{ parseTime(scope.row.handleTime) }}</span>
|
<span v-else>-</span>
|
</template>
|
</el-table-column>
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="180" fixed="right">
|
<template slot-scope="scope">
|
<el-button
|
size="mini"
|
type="text"
|
icon="el-icon-view"
|
@click="handleView(scope.row)"
|
v-hasPermi="['system:vehicleAlert:query']"
|
>详情</el-button>
|
<el-button
|
v-if="scope.row.status === '0'"
|
size="mini"
|
type="text"
|
icon="el-icon-check"
|
@click="handleProcess(scope.row)"
|
v-hasPermi="['system:vehicleAlert:handle']"
|
>处理</el-button>
|
<el-button
|
size="mini"
|
type="text"
|
icon="el-icon-delete"
|
@click="handleDelete(scope.row)"
|
v-hasPermi="['system:vehicleAlert:remove']"
|
>删除</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
|
<pagination
|
v-show="total>0"
|
:total="total"
|
:page.sync="queryParams.pageNum"
|
:limit.sync="queryParams.pageSize"
|
@pagination="getList"
|
/>
|
|
<!-- 告警详情对话框 -->
|
<el-dialog title="告警详情" :visible.sync="detailOpen" width="700px" append-to-body>
|
<el-descriptions :column="2" border>
|
<el-descriptions-item label="告警ID">{{ detail.alertId }}</el-descriptions-item>
|
<el-descriptions-item label="车牌号">
|
<el-tag>{{ detail.vehicleNo }}</el-tag>
|
</el-descriptions-item>
|
<el-descriptions-item label="告警日期">{{ detail.alertDate }}</el-descriptions-item>
|
<el-descriptions-item label="告警时间">{{ parseTime(detail.alertTime) }}</el-descriptions-item>
|
<el-descriptions-item label="运行里程">
|
<span style="color: #F56C6C; font-weight: bold;">{{ detail.mileage }} 公里</span>
|
</el-descriptions-item>
|
<el-descriptions-item label="当日告警次数">第{{ detail.alertCount }}次</el-descriptions-item>
|
<el-descriptions-item label="归属部门" :span="2">{{ detail.deptName }}</el-descriptions-item>
|
<el-descriptions-item label="告警状态">
|
<el-tag v-if="detail.status === '0'" type="danger">未处理</el-tag>
|
<el-tag v-else type="success">已处理</el-tag>
|
</el-descriptions-item>
|
<el-descriptions-item label="通知状态">
|
<el-tag v-if="detail.notifyStatus === '0'" type="info">未发送</el-tag>
|
<el-tag v-else-if="detail.notifyStatus === '1'" type="success">已发送</el-tag>
|
<el-tag v-else type="danger">发送失败</el-tag>
|
</el-descriptions-item>
|
<el-descriptions-item label="通知用户" :span="2">{{ detail.notifyUsers || '-' }}</el-descriptions-item>
|
<el-descriptions-item label="通知消息" :span="2">{{ detail.notifyMessage || '-' }}</el-descriptions-item>
|
<el-descriptions-item label="处理人">{{ detail.handlerName || '-' }}</el-descriptions-item>
|
<el-descriptions-item label="处理时间">{{ parseTime(detail.handleTime) || '-' }}</el-descriptions-item>
|
<el-descriptions-item label="处理备注" :span="2">{{ detail.handleRemark || '-' }}</el-descriptions-item>
|
<el-descriptions-item label="创建时间" :span="2">{{ parseTime(detail.createTime) }}</el-descriptions-item>
|
</el-descriptions>
|
<div slot="footer" class="dialog-footer">
|
<el-button @click="detailOpen = false">关 闭</el-button>
|
</div>
|
</el-dialog>
|
|
<!-- 处理告警对话框 -->
|
<el-dialog title="处理告警" :visible.sync="processOpen" width="500px" append-to-body>
|
<el-form ref="processForm" :model="processForm" :rules="processRules" label-width="100px">
|
<el-form-item label="处理备注" prop="handleRemark">
|
<el-input
|
v-model="processForm.handleRemark"
|
type="textarea"
|
:rows="4"
|
placeholder="请输入处理备注(必填)"
|
/>
|
</el-form-item>
|
</el-form>
|
<div slot="footer" class="dialog-footer">
|
<el-button type="primary" @click="submitProcess">确 定</el-button>
|
<el-button @click="processOpen = false">取 消</el-button>
|
</div>
|
</el-dialog>
|
|
<!-- 批量处理对话框 -->
|
<el-dialog title="批量处理告警" :visible.sync="batchProcessOpen" width="500px" append-to-body>
|
<el-alert
|
:title="`已选择 ${ids.length} 条未处理告警记录`"
|
type="info"
|
:closable="false"
|
style="margin-bottom: 20px;"
|
/>
|
<el-form ref="batchProcessForm" :model="batchProcessForm" :rules="batchProcessRules" label-width="100px">
|
<el-form-item label="处理备注" prop="handleRemark">
|
<el-input
|
v-model="batchProcessForm.handleRemark"
|
type="textarea"
|
:rows="4"
|
placeholder="请输入处理备注(必填)"
|
/>
|
</el-form-item>
|
</el-form>
|
<div slot="footer" class="dialog-footer">
|
<el-button type="primary" @click="submitBatchProcess">确 定</el-button>
|
<el-button @click="batchProcessOpen = false">取 消</el-button>
|
</div>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import { listVehicleAlert, getVehicleAlert, delVehicleAlert, handleAlert, batchHandleAlert, getUnhandledCount, exportVehicleAlert } from "@/api/system/vehicleAlert";
|
import { listDept } from "@/api/system/dept";
|
|
export default {
|
name: "VehicleAlert",
|
data() {
|
return {
|
// 遮罩层
|
loading: true,
|
// 选中数组
|
ids: [],
|
// 非单个禁用
|
single: true,
|
// 非多个禁用
|
multiple: true,
|
// 显示搜索条件
|
showSearch: true,
|
// 总条数
|
total: 0,
|
// 车辆异常告警表格数据
|
alertList: [],
|
// 部门列表
|
deptList: [],
|
// 弹出层标题
|
title: "",
|
// 是否显示详情弹出层
|
detailOpen: false,
|
// 是否显示处理弹出层
|
processOpen: false,
|
// 是否显示批量处理弹出层
|
batchProcessOpen: false,
|
// 日期范围
|
dateRange: [],
|
// 详情数据
|
detail: {},
|
// 处理表单
|
processForm: {
|
alertId: null,
|
handleRemark: ''
|
},
|
// 批量处理表单
|
batchProcessForm: {
|
handleRemark: ''
|
},
|
// 统计数据
|
unhandledCount: 0,
|
todayCount: 0,
|
totalVehicles: 0,
|
// 查询参数
|
queryParams: {
|
pageNum: 1,
|
pageSize: 10,
|
vehicleNo: null,
|
alertDate: null,
|
status: null,
|
deptId: null
|
},
|
// 处理表单校验
|
processRules: {
|
handleRemark: [
|
{ required: true, message: "处理备注不能为空", trigger: "blur" }
|
]
|
},
|
// 批量处理表单校验
|
batchProcessRules: {
|
handleRemark: [
|
{ required: true, message: "处理备注不能为空", trigger: "blur" }
|
]
|
}
|
};
|
},
|
created() {
|
this.getList();
|
this.getDeptList();
|
this.refreshUnhandledCount();
|
},
|
methods: {
|
/** 查询车辆异常告警列表 */
|
getList() {
|
this.loading = true;
|
listVehicleAlert(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
|
this.alertList = response.rows;
|
this.total = response.total;
|
// 统计今日告警数量
|
const today = this.parseTime(new Date(), '{y}-{m}-{d}');
|
this.todayCount = this.alertList.filter(item => item.alertDate === today).length;
|
// 统计告警车辆数量(去重)
|
const vehicleSet = new Set(this.alertList.map(item => item.vehicleId));
|
this.totalVehicles = vehicleSet.size;
|
this.loading = false;
|
});
|
},
|
/** 查询部门列表 */
|
getDeptList() {
|
listDept().then(response => {
|
this.deptList = response.data;
|
});
|
},
|
/** 刷新未处理告警统计 */
|
refreshUnhandledCount() {
|
getUnhandledCount().then(response => {
|
this.unhandledCount = response.data;
|
});
|
},
|
/** 搜索按钮操作 */
|
handleQuery() {
|
this.queryParams.pageNum = 1;
|
this.getList();
|
},
|
/** 重置按钮操作 */
|
resetQuery() {
|
this.dateRange = [];
|
this.resetForm("queryForm");
|
this.handleQuery();
|
},
|
// 多选框选中数据
|
handleSelectionChange(selection) {
|
this.ids = selection.map(item => item.alertId);
|
this.single = selection.length !== 1;
|
this.multiple = !selection.length;
|
},
|
/** 查看详情按钮操作 */
|
handleView(row) {
|
getVehicleAlert(row.alertId).then(response => {
|
this.detail = response.data;
|
this.detailOpen = true;
|
});
|
},
|
/** 处理按钮操作 */
|
handleProcess(row) {
|
this.processForm = {
|
alertId: row.alertId,
|
handleRemark: ''
|
};
|
this.processOpen = true;
|
this.$nextTick(() => {
|
this.$refs["processForm"].clearValidate();
|
});
|
},
|
/** 提交处理 */
|
submitProcess() {
|
this.$refs["processForm"].validate(valid => {
|
if (valid) {
|
handleAlert(this.processForm.alertId, {
|
handleRemark: this.processForm.handleRemark
|
}).then(response => {
|
this.$modal.msgSuccess("处理成功");
|
this.processOpen = false;
|
this.getList();
|
this.refreshUnhandledCount();
|
});
|
}
|
});
|
},
|
/** 批量处理按钮操作 */
|
handleBatchProcess() {
|
// 筛选出未处理的记录
|
const unhandledIds = this.ids.filter(id => {
|
const alert = this.alertList.find(item => item.alertId === id);
|
return alert && alert.status === '0';
|
});
|
|
if (unhandledIds.length === 0) {
|
this.$modal.msgWarning("请选择未处理的告警记录");
|
return;
|
}
|
|
this.ids = unhandledIds;
|
this.batchProcessForm = {
|
handleRemark: ''
|
};
|
this.batchProcessOpen = true;
|
this.$nextTick(() => {
|
this.$refs["batchProcessForm"].clearValidate();
|
});
|
},
|
/** 提交批量处理 */
|
submitBatchProcess() {
|
this.$refs["batchProcessForm"].validate(valid => {
|
if (valid) {
|
batchHandleAlert(this.ids, {
|
handleRemark: this.batchProcessForm.handleRemark
|
}).then(response => {
|
this.$modal.msgSuccess("批量处理成功");
|
this.batchProcessOpen = false;
|
this.getList();
|
this.refreshUnhandledCount();
|
});
|
}
|
});
|
},
|
/** 删除按钮操作 */
|
handleDelete(row) {
|
const alertIds = row.alertId || this.ids;
|
this.$modal.confirm('是否确认删除告警记录编号为"' + alertIds + '"的数据项?').then(function() {
|
return delVehicleAlert(alertIds);
|
}).then(() => {
|
this.getList();
|
this.$modal.msgSuccess("删除成功");
|
}).catch(() => {});
|
},
|
/** 导出按钮操作 */
|
handleExport() {
|
this.download('system/vehicleAlert/export', {
|
...this.queryParams
|
}, `车辆异常告警_${new Date().getTime()}.xlsx`)
|
}
|
}
|
};
|
</script>
|
|
<style scoped>
|
.mb8 {
|
margin-bottom: 8px;
|
}
|
</style>
|