|
|
@ -12,6 +12,20 @@ |
|
|
|
<a-form-item name="alarmTitle" label="告警标题"> |
|
|
|
<ns-input allowClear v-model:value="infoObject.alarmTitle" placeholder="请输入告警标题" /> |
|
|
|
</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-select |
|
|
|
v-model:value="infoObject.alarmFrequency" |
|
|
@ -35,20 +49,6 @@ |
|
|
|
allowClear |
|
|
|
:options="intervalDurationUnitData" /> |
|
|
|
</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-select |
|
|
|
v-model:value="infoObject.priority" |
|
|
@ -92,6 +92,9 @@ |
|
|
|
monitorTimeUnit: null, |
|
|
|
priority: null, |
|
|
|
createWorkOrder: null, |
|
|
|
intervalDurationUnit: null, |
|
|
|
repetitions: null, |
|
|
|
intervalDuration: null, |
|
|
|
enableRules: 0, |
|
|
|
}); |
|
|
|
const formRef = ref(); |
|
|
@ -159,7 +162,15 @@ |
|
|
|
} else { |
|
|
|
infoObject.value = { |
|
|
|
id: null, |
|
|
|
accountNo: null, |
|
|
|
alarmTitle: null, |
|
|
|
alarmFrequency: null, |
|
|
|
monitorTime: null, |
|
|
|
monitorTimeUnit: null, |
|
|
|
priority: null, |
|
|
|
createWorkOrder: null, |
|
|
|
intervalDurationUnit: null, |
|
|
|
repetitions: null, |
|
|
|
intervalDuration: null, |
|
|
|
enableRules: 0, |
|
|
|
}; |
|
|
|
} |
|
|
@ -185,10 +196,9 @@ |
|
|
|
monitorTime: [ |
|
|
|
{ |
|
|
|
required: true, |
|
|
|
message: '请输入正确的监测时长', |
|
|
|
trigger: 'change', |
|
|
|
validator: (rules: any, monitorTime: any, cbfn: any) => { |
|
|
|
if (monitorTime && monitorTime > 0) { |
|
|
|
if (Number.isInteger(monitorTime) && monitorTime > 0) { |
|
|
|
cbfn(); |
|
|
|
} else { |
|
|
|
cbfn('请输入正确的监测时长'); |
|
|
@ -199,10 +209,9 @@ |
|
|
|
intervalDuration: [ |
|
|
|
{ |
|
|
|
required: true, |
|
|
|
message: '请输入正确的间隔时长', |
|
|
|
trigger: 'change', |
|
|
|
validator: (rules: any, monitorTime: any, cbfn: any) => { |
|
|
|
if (monitorTime && monitorTime > 0) { |
|
|
|
validator: (rules: any, intervalDuration: any, cbfn: any) => { |
|
|
|
if (Number.isInteger(intervalDuration) && intervalDuration > 0) { |
|
|
|
cbfn(); |
|
|
|
} else { |
|
|
|
cbfn('请输入正确的间隔时长'); |
|
|
@ -213,10 +222,9 @@ |
|
|
|
repetitions: [ |
|
|
|
{ |
|
|
|
required: true, |
|
|
|
message: '请输入正确的重复次数', |
|
|
|
trigger: 'change', |
|
|
|
validator: (rules: any, repetitions: any, cbfn: any) => { |
|
|
|
if (repetitions && repetitions > 0) { |
|
|
|
if (Number.isInteger(repetitions) && repetitions > 0) { |
|
|
|
cbfn(); |
|
|
|
} else { |
|
|
|
cbfn('请输入正确的重复次数'); |
|
|
@ -242,6 +250,50 @@ |
|
|
|
const btnClick = () => { |
|
|
|
//表单校验 |
|
|
|
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 }; |
|
|
|
data.createWorkOrder = Number(data.createWorkOrder); |
|
|
|