Browse Source

add:添加设备保存时 逻辑判断

temp
zhaohy 4 months ago
parent
commit
fc4b038e2e
  1. 96
      hx-ai-intelligent/src/view/alarmManagement/alarmSettings/equipmentAlarm/editeEquipmentAlarm.vue
  2. 8
      hx-ai-intelligent/src/view/alarmManagement/alarmSettings/index.vue

96
hx-ai-intelligent/src/view/alarmManagement/alarmSettings/equipmentAlarm/editeEquipmentAlarm.vue

@ -12,6 +12,20 @@
<a-form-item name="alarmTitle" label="告警标题"> <a-form-item name="alarmTitle" label="告警标题">
<ns-input allowClear v-model:value="infoObject.alarmTitle" placeholder="请输入告警标题" /> <ns-input allowClear v-model:value="infoObject.alarmTitle" placeholder="请输入告警标题" />
</a-form-item> </a-form-item>
<a-form-item name="monitorTime" label="监测时长">
<ns-input-number
allowClear
v-model:value="infoObject.monitorTime"
placeholder="请输入监测时长" />
</a-form-item>
<a-form-item label="监测时长单位" name="monitorTimeUnit">
<a-select
v-model:value="infoObject.monitorTimeUnit"
placeholder="请选择监测时长单位"
style="width: 100%"
allowClear
:options="monitorTimeUnitData" />
</a-form-item>
<a-form-item label="告警频率" name="alarmFrequency"> <a-form-item label="告警频率" name="alarmFrequency">
<a-select <a-select
v-model:value="infoObject.alarmFrequency" v-model:value="infoObject.alarmFrequency"
@ -35,20 +49,6 @@
allowClear allowClear
:options="intervalDurationUnitData" /> :options="intervalDurationUnitData" />
</a-form-item> </a-form-item>
<a-form-item name="monitorTime" label="监测时长">
<ns-input-number
allowClear
v-model:value="infoObject.monitorTime"
placeholder="请输入监测时长" />
</a-form-item>
<a-form-item label="监测时长单位" name="monitorTimeUnit">
<a-select
v-model:value="infoObject.monitorTimeUnit"
placeholder="请选择监测时长单位"
style="width: 100%"
allowClear
:options="monitorTimeUnitData" />
</a-form-item>
<a-form-item label="优先级" name="priority"> <a-form-item label="优先级" name="priority">
<a-select <a-select
v-model:value="infoObject.priority" v-model:value="infoObject.priority"
@ -92,6 +92,9 @@
monitorTimeUnit: null, monitorTimeUnit: null,
priority: null, priority: null,
createWorkOrder: null, createWorkOrder: null,
intervalDurationUnit: null,
repetitions: null,
intervalDuration: null,
enableRules: 0, enableRules: 0,
}); });
const formRef = ref(); const formRef = ref();
@ -159,7 +162,15 @@
} else { } else {
infoObject.value = { infoObject.value = {
id: null, id: null,
accountNo: null, alarmTitle: null,
alarmFrequency: null,
monitorTime: null,
monitorTimeUnit: null,
priority: null,
createWorkOrder: null,
intervalDurationUnit: null,
repetitions: null,
intervalDuration: null,
enableRules: 0, enableRules: 0,
}; };
} }
@ -185,10 +196,9 @@
monitorTime: [ monitorTime: [
{ {
required: true, required: true,
message: '请输入正确的监测时长',
trigger: 'change', trigger: 'change',
validator: (rules: any, monitorTime: any, cbfn: any) => { validator: (rules: any, monitorTime: any, cbfn: any) => {
if (monitorTime && monitorTime > 0) { if (Number.isInteger(monitorTime) && monitorTime > 0) {
cbfn(); cbfn();
} else { } else {
cbfn('请输入正确的监测时长'); cbfn('请输入正确的监测时长');
@ -199,10 +209,9 @@
intervalDuration: [ intervalDuration: [
{ {
required: true, required: true,
message: '请输入正确的间隔时长',
trigger: 'change', trigger: 'change',
validator: (rules: any, monitorTime: any, cbfn: any) => { validator: (rules: any, intervalDuration: any, cbfn: any) => {
if (monitorTime && monitorTime > 0) { if (Number.isInteger(intervalDuration) && intervalDuration > 0) {
cbfn(); cbfn();
} else { } else {
cbfn('请输入正确的间隔时长'); cbfn('请输入正确的间隔时长');
@ -213,10 +222,9 @@
repetitions: [ repetitions: [
{ {
required: true, required: true,
message: '请输入正确的重复次数',
trigger: 'change', trigger: 'change',
validator: (rules: any, repetitions: any, cbfn: any) => { validator: (rules: any, repetitions: any, cbfn: any) => {
if (repetitions && repetitions > 0) { if (Number.isInteger(repetitions) && repetitions > 0) {
cbfn(); cbfn();
} else { } else {
cbfn('请输入正确的重复次数'); cbfn('请输入正确的重复次数');
@ -242,6 +250,50 @@
const btnClick = () => { const btnClick = () => {
// //
formRef.value.validate().then(() => { formRef.value.validate().then(() => {
// * <=
if (infoObject.value.alarmFrequency === 2) {
//
let monitorTime = 0;
switch (infoObject.value.monitorTimeUnit) {
case 1:
monitorTime = Number(infoObject.value.monitorTime) * 1;
break;
case 2:
monitorTime = Number(infoObject.value.monitorTime) * 60;
break;
case 3:
monitorTime = Number(infoObject.value.monitorTime) * 60 * 24;
break;
}
//
let intervalTime = 0;
switch (infoObject.value.intervalDurationUnit) {
case 1:
intervalTime =
Number(infoObject.value.intervalDuration) * 1 * Number(infoObject.value.repetitions);
break;
case 2:
intervalTime =
Number(infoObject.value.intervalDuration) * 60 * Number(infoObject.value.repetitions);
break;
case 3:
intervalTime =
Number(infoObject.value.intervalDuration) *
60 *
24 *
Number(infoObject.value.repetitions);
break;
}
if (intervalTime > monitorTime) {
NsMessage.error(
'间隔时长超过了告警监测周期的最大值。请设置1分钟到' +
infoObject.value.monitorTime +
['分', '小时', '天'][infoObject.value.monitorTimeUnit - 1] +
'之间的间隔时长',
);
return;
}
}
// //
let data = { ...infoObject.value }; let data = { ...infoObject.value };
data.createWorkOrder = Number(data.createWorkOrder); data.createWorkOrder = Number(data.createWorkOrder);

8
hx-ai-intelligent/src/view/alarmManagement/alarmSettings/index.vue

@ -59,14 +59,14 @@
</template> </template>
<template v-if="column.dataIndex === 'repetitions'"> <template v-if="column.dataIndex === 'repetitions'">
{{ {{
record.repetitions && record.alarmFrequency.value === 2 ? record.repetitions : '' record.repetitions && record.alarmFrequency.value === 2 ? record.repetitions : '-'
}} }}
</template> </template>
<template v-if="column.dataIndex === 'interval'"> <template v-if="column.dataIndex === 'interval'">
{{ {{
record.intervalDuration && record.alarmFrequency.value === 2 record.intervalDuration && record.alarmFrequency.value === 2
? record.intervalDuration + '' + record.intervalDurationUnit.label ? record.intervalDuration + '' + record.intervalDurationUnit.label
: '' : '-'
}} }}
</template> </template>
</template> </template>
@ -112,14 +112,14 @@
</template> </template>
<template v-if="column.dataIndex === 'repetitions'"> <template v-if="column.dataIndex === 'repetitions'">
{{ {{
record.repetitions && record.alarmFrequency.value === 2 ? record.repetitions : '' record.repetitions && record.alarmFrequency.value === 2 ? record.repetitions : '-'
}} }}
</template> </template>
<template v-if="column.dataIndex === 'interval'"> <template v-if="column.dataIndex === 'interval'">
{{ {{
record.intervalDuration && record.alarmFrequency.value === 2 record.intervalDuration && record.alarmFrequency.value === 2
? record.intervalDuration + '' + record.intervalDurationUnit.label ? record.intervalDuration + '' + record.intervalDurationUnit.label
: '' : '-'
}} }}
</template> </template>
</template> </template>

Loading…
Cancel
Save