done 设备分组报警

This commit is contained in:
lb
2023-08-28 14:56:56 +08:00
parent 9dc580ddd2
commit 4ad325c02c
4 changed files with 111 additions and 20 deletions

View File

@@ -88,7 +88,7 @@ export default {
{ prop: 'code', label: '检测分组编码', align: 'center' },
{ prop: 'remark', label: '备注', align: 'center' },
{
action: 'show-alert',
_action: 'equipment-group-show-alert',
label: '报警',
align: 'center',
subcomponent: {
@@ -103,8 +103,9 @@ export default {
click: function () {
console.log('inejctdata', _this.injectData);
_this.$emit('emitData', {
action: _this.injectData.action,
value: _this.injectData.id,
action: _this.injectData._action,
// value: _this.injectData.id,
value: _this.injectData,
});
},
},
@@ -202,6 +203,27 @@ export default {
this.getList();
},
methods: {
/** 覆盖 handleEmitFun 的默认实现 */
handleEmitFun({ action, value }) {
const {
id: equipmentGroupId,
name: equipmentGroupName,
code: equipmentGroupCode,
} = value;
switch (action) {
case 'equipment-group-show-alert':
// this.$router.push({ path: '/equipment/base/equipment-group-alarm' });
this.$router.push({
name: 'EquipmentGroupAlarm',
params: {
equipmentGroupId,
equipmentGroupCode,
equipmentGroupName,
},
});
break;
}
},
/** 查询列表 */
getList() {
this.loading = true;

View File

@@ -1,8 +1,10 @@
<template>
<div class="app-container">
<!-- 搜索工作栏 -->
<SearchBar :formConfigs="searchBarFormConfig" ref="search-bar" />
<!-- @headBtnClick="handleSearchBarBtnClick" /> -->
<SearchBar
:formConfigs="searchBarFormConfig"
ref="search-bar"
@headBtnClick="handleSearchBarBtnClick" />
<!-- 列表 -->
<base-table
@@ -31,7 +33,7 @@
<base-dialog
:dialogTitle="title"
:dialogVisible="open"
width="500px"
width="736px"
@close="cancel"
@cancel="cancel"
@confirm="submitForm">
@@ -51,6 +53,7 @@ import {
} from '@/api/base/equipmentGroupAlarm';
import basicPageMixin from '@/mixins/lb/basicPageMixin';
import moment from 'moment';
import { publicFormatter } from '@/utils/dict';
export default {
name: 'EquipmentGroupAlarm',
@@ -83,7 +86,12 @@ export default {
},
{ prop: 'code', label: '报警编码', align: 'center' },
{ prop: 'type', label: '报警类型', align: 'center' },
{ prop: 'grade', label: '报警级别', align: 'center' },
{
prop: 'grade',
label: '报警级别',
align: 'center',
filter: publicFormatter(this.DICT_TYPE.EQU_ALARM_LEVEL),
},
{ prop: 'alarmCode', label: '设备报警编码', align: 'center' },
{ prop: 'plcParamName', label: '参数列名', align: 'center' },
{ prop: 'alarmContent', label: '报警内容', align: 'center' },
@@ -94,14 +102,25 @@ export default {
label: '设备分组编码',
placeholder: '/',
param: 'equipmentGroupCode',
defaultSelect: '1',
defaultSelect: null,
disabled: true,
},
{
type: 'input',
label: '设备分组名称',
placeholder: '/',
param: 'equipmentGroupName',
defaultSelect: '2',
defaultSelect: null,
disabled: true,
},
{
type: this.$auth.hasPermi('base:equipment-group-alarm:create')
? 'button'
: '',
btnName: '新增',
name: 'add',
plain: true,
color: 'success',
},
],
rows: [
@@ -110,18 +129,18 @@ export default {
input: true,
label: '报警编码', // 自动生成
prop: 'code',
url: '',
url: '/base/equipment-group-alarm/getCode',
rules: [{ required: true, message: '不能为空', trigger: 'blur' }],
},
{
select: true,
select: true,
label: '报警类型', // 固定选项
prop: 'type',
options: [
{ label: '布尔型', value: 2 },
{ label: '布尔型', value: 2 },
{ label: '字符型', value: 1 },
],
rules: [{ required: true, message: '不能为空', trigger: 'blur' }],
rules: [{ required: true, message: '不能为空', trigger: 'blur' }],
},
],
[
@@ -161,7 +180,16 @@ export default {
equipmentGroupId: null,
},
// 表单参数
form: {},
form: {
id: undefined,
equipmentGroupId: undefined,
code: undefined,
type: undefined,
grade: undefined,
alarmCode: undefined,
alarmContent: undefined,
plcParamName: undefined,
},
// // 表单校验
// rules: {
// equipmentGroupId: [{ required: true, message: "设备分组ID关联base_equipment_group不能为空", trigger: "blur" }],
@@ -171,10 +199,38 @@ export default {
// }
};
},
created() {
// watch: {
// $route(value) {
// console.log('new route info', value)
// }
// },
// created() {
// this.getList();
// },
activated() {
// 设置顶部搜索栏信息
const { equipmentGroupName, equipmentGroupCode, equipmentGroupId } =
this.$route.params;
this.setSearchBarFormValue('equipmentGroupName', equipmentGroupName);
this.setSearchBarFormValue('equipmentGroupCode', equipmentGroupCode);
this.queryParams.equipmentGroupId = equipmentGroupId;
// if (!equipmentGroupId) this.getList(); // 拦截
this.getList();
},
deactivated() {
this.setSearchBarFormValue('equipmentGroupName', null);
this.setSearchBarFormValue('equipmentGroupCode', null);
this.queryParams.equipmentGroupId = null;
},
methods: {
/** 设置 searchBarForm 的默认值 - 用得比较少 */
setSearchBarFormValue(param, value) {
this.searchBarFormConfig.forEach((config) => {
if (config.param == param) {
config.defaultSelect = value;
}
});
},
/** 查询列表 */
getList() {
this.loading = true;
@@ -216,6 +272,8 @@ export default {
},
/** 新增按钮操作 */
handleAdd() {
if (this.queryParams.equipmentGroupId == null)
return this.$message.error('没有检测到设备分组信息');
this.reset();
this.open = true;
this.title = '添加设备分组报警明细';
@@ -238,7 +296,10 @@ export default {
}
// 修改的提交
if (this.form.id != null) {
updateEquipmentGroupAlarm(this.form).then((response) => {
updateEquipmentGroupAlarm({
...this.form,
equipmentGroupId: this.queryParams.equipmentGroupId,
}).then((response) => {
this.$modal.msgSuccess('修改成功');
this.open = false;
this.getList();
@@ -246,7 +307,10 @@ export default {
return;
}
// 添加的提交
createEquipmentGroupAlarm(this.form).then((response) => {
createEquipmentGroupAlarm({
...this.form,
equipmentGroupId: this.queryParams.equipmentGroupId,
}).then((response) => {
this.$modal.msgSuccess('新增成功');
this.open = false;
this.getList();