feat(wms): 新增钢卷通用维度告警管理功能

1. 新增告警信息路由页面与API接口
2. 在导航栏添加告警入口与未读红点提示
3. 实现告警列表查询、处理、忽略、删除与导出功能
4. 每分钟自动刷新告警状态检查
This commit is contained in:
2026-06-08 10:05:52 +08:00
parent 47b3fb24b7
commit 857a3948d6
4 changed files with 475 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询钢卷通用维度告警(长度/厚度/宽度)列表
export function listMaterialWarning(query) {
return request({
url: '/wms/materialWarning/list',
method: 'get',
params: query
})
}
// 查询钢卷通用维度告警(长度/厚度/宽度)详细
export function getMaterialWarning(warningId) {
return request({
url: '/wms/materialWarning/' + warningId,
method: 'get'
})
}
// 新增钢卷通用维度告警(长度/厚度/宽度)
export function addMaterialWarning(data) {
return request({
url: '/wms/materialWarning',
method: 'post',
data: data
})
}
// 修改钢卷通用维度告警(长度/厚度/宽度)
export function updateMaterialWarning(data) {
return request({
url: '/wms/materialWarning',
method: 'put',
data: data
})
}
// 删除钢卷通用维度告警(长度/厚度/宽度)
export function delMaterialWarning(warningId) {
return request({
url: '/wms/materialWarning/' + warningId,
method: 'delete'
})
}

View File

@@ -11,6 +11,11 @@
<div class="right-menu-item hover-effect" @click="gotoTodo" title="代办事项">
<el-icon class="el-icon-document-checked" />
</div>
<div class="right-menu-item hover-effect" @click="gotoWarning" title="告警信息">
<el-badge :is-dot="hasWarning" class="nav-badge">
<el-icon class="el-icon-bell" />
</el-badge>
</div>
<screenfull id="screenfull" class="right-menu-item hover-effect" />
@@ -51,6 +56,7 @@ import Hamburger from '@/components/Hamburger'
import Screenfull from '@/components/Screenfull'
// import SizeSelect from '@/components/SizeSelect'
import Search from '@/components/HeaderSearch'
import { listMaterialWarning } from '@/api/wms/materialWarning'
// import RuoYiGit from '@/components/RuoYi/Git'
// import RuoYiDoc from '@/components/RuoYi/Doc'
@@ -65,6 +71,12 @@ export default {
// RuoYiGit,
// RuoYiDoc
},
data() {
return {
hasWarning: false,
warningTimer: null
}
},
computed: {
...mapGetters([
'sidebar',
@@ -99,6 +111,16 @@ export default {
gotoTodo() {
this.$router.push({ path: '/wms/todo' })
},
gotoWarning() {
this.$router.push({ path: '/wms/materialWarning' })
},
checkWarning() {
listMaterialWarning({ pageNum: 1, pageSize: 1, warningStatus: '0' }).then(response => {
this.hasWarning = response.total > 0
}).catch(() => {
this.hasWarning = false
})
},
async logout() {
this.$confirm('确定注销并退出系统吗?', '提示', {
confirmButtonText: '确定',
@@ -110,6 +132,18 @@ export default {
})
}).catch(() => {});
}
},
mounted() {
this.checkWarning()
this.warningTimer = setInterval(() => {
this.checkWarning()
}, 60000)
},
beforeDestroy() {
if (this.warningTimer) {
clearInterval(this.warningTimer)
this.warningTimer = null
}
}
}
</script>
@@ -216,6 +250,13 @@ export default {
}
}
}
.nav-badge {
::v-deep .el-badge__content.is-fixed {
top: 14px;
right: 14px;
}
}
}
}
</style>

View File

@@ -118,6 +118,12 @@ export const constantRoutes = [
component: () => import('@/views/wms/coil/info'),
name: 'CoilInfo',
meta: { title: '数字钢卷', icon: 'checkbox' }
},
{
path: 'materialWarning',
component: () => import('@/views/wms/coil/materialWarning/index'),
name: 'MaterialWarning',
meta: { title: '告警信息', icon: 'warning' }
}
],
},

View File

@@ -0,0 +1,384 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="告警级别" prop="warningLevel">
<el-select v-model="queryParams.warningLevel" placeholder="请选择告警级别" clearable @keyup.enter.native="handleQuery">
<el-option label="警告" value="WARNING" />
<el-option label="错误" value="ERROR" />
<el-option label="严重错误" value="CRITICAL" />
</el-select>
</el-form-item>
<el-form-item label="告警状态" prop="warningStatus">
<el-select v-model="queryParams.warningStatus" placeholder="请选择告警状态" clearable
@keyup.enter.native="handleQuery">
<el-option label="未处理" value="0" />
<el-option label="已处理" value="1" />
<el-option label="已忽略" value="2" />
</el-select>
</el-form-item>
<el-form-item label="处理人" prop="handleBy">
<el-input v-model="queryParams.handleBy" placeholder="请输入处理人" clearable @keyup.enter.native="handleQuery" />
</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-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport">导出</el-button>
</el-form-item>
</el-form>
<el-table v-loading="loading" :data="materialWarningList" @selection-change="handleSelectionChange">
<!-- <el-table-column label="钢卷ID" align="center" prop="coilId" /> -->
<el-table-column label="告警类型" align="center" prop="warningType">
<template slot-scope="scope">
<span>{{ scope.row.warningType === 'LENGTH' ? '长度' : scope.row.warningType === 'THICKNESS' ? '厚度' : '宽度'
}}</span>
</template>
</el-table-column>
<el-table-column label="理论值" align="center" prop="theoreticalVal" />
<el-table-column label="实测值" align="center" prop="actualVal" />
<el-table-column label="允许偏差" align="center" prop="allowDeviation" />
<el-table-column label="实际偏差值" align="center" prop="deviationValue" />
<el-table-column label="偏差率(%)" align="center" prop="deviationRate" />
<el-table-column label="告警级别" align="center" prop="warningLevel">
<template slot-scope="scope">
<span>{{ scope.row.warningLevel === 'WARNING' ? '警告' : scope.row.warningLevel === 'ERROR' ? '错误' : '严重错误'
}}</span>
</template>
</el-table-column>
<el-table-column label="告警说明" align="center" prop="warningMsg" />
<el-table-column label="告警状态" align="center" prop="warningStatus">
<template slot-scope="scope">
<span>{{ scope.row.warningStatus == 0 ? '未处理' : scope.row.warningStatus == 1 ? '已处理' : '已忽略' }}</span>
</template>
</el-table-column>
<el-table-column label="处理人" align="center" prop="handleBy" />
<el-table-column label="处理时间" align="center" prop="handleTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.handleTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<!-- <el-table-column label="处理备注" align="center" prop="handleRemark" /> -->
<!-- <el-table-column label="备注" align="center" prop="remark" /> -->
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleHandle(scope.row)">处理</el-button>
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleIgnore(scope.row)">忽略</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</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="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="钢卷ID" prop="coilId">
<el-input v-model="form.coilId" placeholder="请输入钢卷ID" />
</el-form-item>
<el-form-item label="理论值" prop="theoreticalVal">
<el-input v-model="form.theoreticalVal" placeholder="请输入理论值" />
</el-form-item>
<el-form-item label="实测值" prop="actualVal">
<el-input v-model="form.actualVal" placeholder="请输入实测值" />
</el-form-item>
<el-form-item label="允许偏差" prop="allowDeviation">
<el-input v-model="form.allowDeviation" placeholder="请输入允许偏差" />
</el-form-item>
<el-form-item label="实际偏差值" prop="deviationValue">
<el-input v-model="form.deviationValue" placeholder="请输入实际偏差值" />
</el-form-item>
<el-form-item label="偏差率(%)" prop="deviationRate">
<el-input v-model="form.deviationRate" placeholder="请输入偏差率(%)" />
</el-form-item>
<el-form-item label="告警级别(WARNING/ERROR/CRITICAL)" prop="warningLevel">
<el-input v-model="form.warningLevel" placeholder="请输入告警级别(WARNING/ERROR/CRITICAL)" />
</el-form-item>
<el-form-item label="告警说明" prop="warningMsg">
<el-input v-model="form.warningMsg" placeholder="请输入告警说明" />
</el-form-item>
<el-form-item label="处理人" prop="handleBy">
<el-input v-model="form.handleBy" placeholder="请输入处理人" />
</el-form-item>
<el-form-item label="处理时间" prop="handleTime">
<el-date-picker clearable
v-model="form.handleTime"
type="datetime"
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="请选择处理时间">
</el-date-picker>
</el-form-item>
<el-form-item label="处理备注" prop="handleRemark">
<el-input v-model="form.handleRemark" placeholder="请输入处理备注" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog> -->
</div>
</template>
<script>
import { listMaterialWarning, getMaterialWarning, delMaterialWarning, addMaterialWarning, updateMaterialWarning } from "@/api/wms/materialWarning";
export default {
name: "MaterialWarning",
data() {
return {
// 按钮loading
buttonLoading: false,
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 钢卷告警表格数据
materialWarningList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
coilId: undefined,
warningType: undefined,
theoreticalVal: undefined,
actualVal: undefined,
allowDeviation: undefined,
deviationValue: undefined,
deviationRate: undefined,
warningLevel: undefined,
warningMsg: undefined,
warningStatus: undefined,
handleBy: undefined,
handleTime: undefined,
handleRemark: undefined,
},
// 表单参数
form: {},
// 表单校验
rules: {
warningId: [
{ required: true, message: "告警ID不能为空", trigger: "blur" }
],
coilId: [
{ required: true, message: "钢卷ID不能为空", trigger: "blur" }
],
warningType: [
{ required: true, message: "告警类型(LENGTH=长度, THICKNESS=厚度, WIDTH=宽度)不能为空", trigger: "change" }
],
theoreticalVal: [
{ required: true, message: "理论值不能为空", trigger: "blur" }
],
actualVal: [
{ required: true, message: "实测值不能为空", trigger: "blur" }
],
allowDeviation: [
{ required: true, message: "允许偏差(数值/百分比)不能为空", trigger: "blur" }
],
deviationValue: [
{ required: true, message: "实际偏差值不能为空", trigger: "blur" }
],
deviationRate: [
{ required: true, message: "偏差率(%)不能为空", trigger: "blur" }
],
warningLevel: [
{ required: true, message: "告警级别(WARNING/ERROR/CRITICAL)不能为空", trigger: "blur" }
],
warningMsg: [
{ required: true, message: "告警说明不能为空", trigger: "blur" }
],
warningStatus: [
{ required: true, message: "告警状态(0=未处理,1=已处理,2=已忽略)不能为空", trigger: "change" }
],
handleBy: [
{ required: true, message: "处理人不能为空", trigger: "blur" }
],
handleTime: [
{ required: true, message: "处理时间不能为空", trigger: "blur" }
],
handleRemark: [
{ required: true, message: "处理备注不能为空", trigger: "blur" }
],
delFlag: [
{ required: true, message: "删除标志不能为空", trigger: "blur" }
],
createTime: [
{ required: true, message: "创建时间不能为空", trigger: "blur" }
],
updateTime: [
{ required: true, message: "更新时间不能为空", trigger: "blur" }
],
remark: [
{ required: true, message: "备注不能为空", trigger: "blur" }
]
}
};
},
created() {
this.getList();
},
methods: {
/** 查询钢卷告警列表 */
getList() {
this.loading = true;
listMaterialWarning(this.queryParams).then(response => {
this.materialWarningList = response.rows;
this.total = response.total;
this.loading = false;
});
},
/** 忽略按钮操作 */
handleIgnore(row) {
this.loading = true;
updateMaterialWarning({ ...row, warningStatus: 2 }).then(response => {
this.loading = false;
this.$message({
message: "忽略成功",
type: "success"
});
this.getList();
});
},
/** 处理按钮操作 */
handleHandle(row) {
this.loading = true;
updateMaterialWarning({ ...row, warningStatus: 1 }).then(response => {
this.loading = false;
this.$message({
message: "处理成功",
type: "success"
});
this.getList();
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
warningId: undefined,
coilId: undefined,
warningType: undefined,
theoreticalVal: undefined,
actualVal: undefined,
allowDeviation: undefined,
deviationValue: undefined,
deviationRate: undefined,
warningLevel: undefined,
warningMsg: undefined,
warningStatus: undefined,
handleBy: undefined,
handleTime: undefined,
handleRemark: undefined,
delFlag: undefined,
createTime: undefined,
createBy: undefined,
updateTime: undefined,
updateBy: undefined,
remark: undefined
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.warningId)
this.single = selection.length !== 1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加钢卷告警";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.loading = true;
this.reset();
const warningId = row.warningId || this.ids
getMaterialWarning(warningId).then(response => {
this.loading = false;
this.form = response.data;
this.open = true;
this.title = "修改钢卷告警";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
this.buttonLoading = true;
if (this.form.warningId != null) {
updateMaterialWarning(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
} else {
addMaterialWarning(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const warningIds = row.warningId || this.ids;
this.$modal.confirm('是否确认删除钢卷告警编号为"' + warningIds + '"的数据项?').then(() => {
this.loading = true;
return delMaterialWarning(warningIds);
}).then(() => {
this.loading = false;
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {
}).finally(() => {
this.loading = false;
});
},
/** 导出按钮操作 */
handleExport() {
this.download('wms/materialWarning/export', {
...this.queryParams
}, `materialWarning_${new Date().getTime()}.xlsx`)
}
}
};
</script>