|
|
@ -40,9 +40,9 @@ |
|
|
|
@change="selectDeviceType" |
|
|
|
placeholder="请选择数据来源" /> |
|
|
|
</a-form-item> |
|
|
|
<a-form-item label="设备/节点" name="jdDevice"> |
|
|
|
<a-form-item label="设备/节点" name="deviceNode"> |
|
|
|
<a-tree-select |
|
|
|
v-model:value="infoObject.jdDevice" |
|
|
|
v-model:value="infoObject.deviceNode" |
|
|
|
style="width: 100%" |
|
|
|
placeholder="请选择设备节点" |
|
|
|
:disabled="!infoObject.sbtype" |
|
|
@ -52,8 +52,7 @@ |
|
|
|
children: 'children', |
|
|
|
label: infoObject.sbtype && infoObject.sbtype[1] === 1 ? 'deviceName' : 'pointName', |
|
|
|
value: 'id', |
|
|
|
}" |
|
|
|
@select="selectJdDeviceChange" /> |
|
|
|
}" /> |
|
|
|
</a-form-item> |
|
|
|
<a-form-item label="启用规则" name="enableRules"> |
|
|
|
<a-switch |
|
|
@ -72,16 +71,16 @@ |
|
|
|
show-count |
|
|
|
:maxlength="30" /> |
|
|
|
</a-form-item> |
|
|
|
<a-form-item label="规则类型" name="resource"> |
|
|
|
<a-radio-group v-model:value="infoObject.resource"> |
|
|
|
<a-form-item label="规则类型" name="ruleType"> |
|
|
|
<a-radio-group v-model:value="infoObject.ruleType"> |
|
|
|
<a-radio value="1">且 (and) </a-radio> |
|
|
|
<a-radio value="2">或 (or) </a-radio> |
|
|
|
</a-radio-group> |
|
|
|
</a-form-item> |
|
|
|
<a-form-item label="对比类型" name="qzType"> |
|
|
|
<a-form-item label="对比类型" name="comparisonType"> |
|
|
|
<a-cascader |
|
|
|
v-model:value="infoObject.sbtype" |
|
|
|
:options="deviceTypeTreeData" |
|
|
|
v-model:value="infoObject.comparisonType" |
|
|
|
:options="comparisonTypeData" |
|
|
|
:showSearch="false" |
|
|
|
placeholder="请选择对比类型" /> |
|
|
|
</a-form-item> |
|
|
@ -91,8 +90,7 @@ |
|
|
|
<a-select |
|
|
|
v-model:value="infoObject.alarmList[index - 1].logic" |
|
|
|
style="width: 70px; margin-left: 12px" |
|
|
|
:options="ljOptions" |
|
|
|
@change="handleQzChange" /> |
|
|
|
:options="ljOptions" /> |
|
|
|
<span style="line-height: 32px; margin-left: 32px">{{ `数值${index}:` }}</span> |
|
|
|
<a-input |
|
|
|
style="width: 65px; margin-left: 6px" |
|
|
@ -133,6 +131,7 @@ |
|
|
|
import type { SelectProps } from 'ant-design-vue'; |
|
|
|
import type { ShowSearchType } from 'ant-design-vue/es/cascader'; |
|
|
|
import { device, group } from '/@/api/deviceManage'; |
|
|
|
import { energyAlarms } from '/@/api/alarmSettings/energyAlarm'; |
|
|
|
import { http } from '/nerv-lib/util'; |
|
|
|
import { dict } from '/@/api'; |
|
|
|
import { async } from '@antv/x6/lib/registry/marker/async'; |
|
|
@ -150,8 +149,8 @@ |
|
|
|
const infoObject = ref({ |
|
|
|
id: null, |
|
|
|
site: null, |
|
|
|
jdDevice: null, |
|
|
|
resource: null, |
|
|
|
deviceNode: null, |
|
|
|
ruleType: null, |
|
|
|
abnormalDescription: null, |
|
|
|
sbtype: null, |
|
|
|
enableRules: 0, |
|
|
@ -159,6 +158,53 @@ |
|
|
|
}); |
|
|
|
//删除的逻辑列表 |
|
|
|
const delAlarmList = ref([]); |
|
|
|
//对比类型 |
|
|
|
const comparisonTypeData = ref([ |
|
|
|
{ |
|
|
|
value: '1', |
|
|
|
label: '数值', |
|
|
|
children: [ |
|
|
|
{ |
|
|
|
value: '1', |
|
|
|
label: '输入数值', |
|
|
|
}, |
|
|
|
{ |
|
|
|
value: '2', |
|
|
|
label: '同比', |
|
|
|
}, |
|
|
|
{ |
|
|
|
value: '3', |
|
|
|
label: '环比', |
|
|
|
}, |
|
|
|
{ |
|
|
|
value: '4', |
|
|
|
label: '对比基准', |
|
|
|
}, |
|
|
|
], |
|
|
|
}, |
|
|
|
{ |
|
|
|
value: '2', |
|
|
|
label: '比例', |
|
|
|
children: [ |
|
|
|
{ |
|
|
|
value: '1', |
|
|
|
label: '输入比例', |
|
|
|
}, |
|
|
|
{ |
|
|
|
value: '2', |
|
|
|
label: '同比', |
|
|
|
}, |
|
|
|
{ |
|
|
|
value: '3', |
|
|
|
label: '环比', |
|
|
|
}, |
|
|
|
{ |
|
|
|
value: '4', |
|
|
|
label: '对比基准', |
|
|
|
}, |
|
|
|
], |
|
|
|
}, |
|
|
|
]); |
|
|
|
const formRef = ref(); |
|
|
|
//站点数 |
|
|
|
const siteDataTree = ref([]); |
|
|
@ -169,6 +215,9 @@ |
|
|
|
//选择设备时 获取的数据 |
|
|
|
// 选择 数据来源 查询 设备节点 |
|
|
|
const selectDeviceType = async (value: any, selectedOptions: any) => { |
|
|
|
if (!infoObject.value.id) { |
|
|
|
infoObject.value.deviceNode = null; |
|
|
|
} |
|
|
|
if (value[value.length - 1] === 1) { |
|
|
|
//选择设备 |
|
|
|
await http |
|
|
@ -196,28 +245,12 @@ |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
// 选中节点 |
|
|
|
const selectJdDeviceChange = (value: any, node: any) => { |
|
|
|
console.log(value, 'value'); |
|
|
|
console.log(node, 'node'); |
|
|
|
}; |
|
|
|
//设备点位 |
|
|
|
const dwOptions = ref<SelectProps['options']>([ |
|
|
|
{ value: '电压 (U)', label: '电压 (U)', code: '1' }, |
|
|
|
{ value: '电流 (I)', label: '电流 (I)', code: '2' }, |
|
|
|
{ value: '电流 (I)', label: 'a相电流 (Ia)', code: '3' }, |
|
|
|
]); |
|
|
|
//搜索设备类型 |
|
|
|
const filterDeviceType: ShowSearchType['filter'] = (inputValue: any, path: any) => { |
|
|
|
return path.some( |
|
|
|
(option: any) => option.cnValue.toLowerCase().indexOf(inputValue.toLowerCase()) > -1, |
|
|
|
); |
|
|
|
}; |
|
|
|
//取值类型 |
|
|
|
const qzOptions = ref<SelectProps['options']>([ |
|
|
|
{ value: '实时值', label: '实时值', code: '1' }, |
|
|
|
{ value: '平均值', label: '平均值', code: '2' }, |
|
|
|
]); |
|
|
|
//逻辑 |
|
|
|
const ljOptions = ref<SelectProps['options']>([ |
|
|
|
{ value: 0, label: '≥' }, |
|
|
@ -226,19 +259,6 @@ |
|
|
|
{ value: 3, label: '<' }, |
|
|
|
{ value: 4, label: '=' }, |
|
|
|
]); |
|
|
|
//设备点位方法 |
|
|
|
const filterOption = (input: string, option: any) => { |
|
|
|
console.log('搜索', option.value); |
|
|
|
return option.value.toLowerCase().indexOf(input.toLowerCase()) >= 0; |
|
|
|
}; |
|
|
|
const handleQzChange = (value: string) => { |
|
|
|
//获得code |
|
|
|
qzOptions.value.forEach((item) => { |
|
|
|
if (item.value === value) { |
|
|
|
console.log('符合', item.code); |
|
|
|
} |
|
|
|
}); |
|
|
|
}; |
|
|
|
//开关 |
|
|
|
const clickSwitch = () => { |
|
|
|
if (infoObject.value.enableRules === 1) { |
|
|
@ -247,7 +267,6 @@ |
|
|
|
infoObject.value.enableRules = 1; |
|
|
|
} |
|
|
|
}; |
|
|
|
const emit = defineEmits(['editObject']); |
|
|
|
//父调子 页面显示方法 |
|
|
|
const toggle = async (value: any, info: any) => { |
|
|
|
// 数据来源 |
|
|
@ -275,13 +294,24 @@ |
|
|
|
}); |
|
|
|
//判断 是新增 还是修改 |
|
|
|
if (value) { |
|
|
|
value.ruleType = value.ruleType + ''; |
|
|
|
value.comparisonType = value.comparisonType.split(','); |
|
|
|
value.sbtype = [value.dataSourcesType, value.dataSourcesWay]; |
|
|
|
delete value.dataSourcesType; |
|
|
|
delete value.dataSourcesWay; |
|
|
|
infoObject.value = value; |
|
|
|
//获取设备/节点 |
|
|
|
deviceTypeTreeData.value.forEach((item: any) => { |
|
|
|
if (item.id === infoObject.value.sbtype[0]) { |
|
|
|
selectDeviceType(infoObject.value.sbtype, [{ ...item }]); |
|
|
|
} |
|
|
|
}); |
|
|
|
} else { |
|
|
|
infoObject.value = { |
|
|
|
id: null, |
|
|
|
site: null, |
|
|
|
jdDevice: null, |
|
|
|
resource: null, |
|
|
|
deviceNode: null, |
|
|
|
ruleType: null, |
|
|
|
abnormalDescription: null, |
|
|
|
sbtype: null, |
|
|
|
enableRules: 0, |
|
|
@ -296,10 +326,10 @@ |
|
|
|
site: [{ required: true, message: '请选择站点', trigger: 'change' }], |
|
|
|
sbtype: [{ required: true, message: '请选择设备类型', trigger: 'change' }], |
|
|
|
enableRules: [{ required: true, message: '请选择启用规则', trigger: 'change' }], |
|
|
|
jdDevice: [{ required: true, message: '请选择设备名称', trigger: 'change' }], |
|
|
|
deviceNode: [{ required: true, message: '请选择设备名称', trigger: 'change' }], |
|
|
|
sbAdress: [{ required: true, message: '请选择设备点位', trigger: 'change' }], |
|
|
|
qzType: [{ required: true, message: '请选择取值类型', trigger: 'change' }], |
|
|
|
resource: [{ required: true, message: '请选择规则类型', trigger: 'change' }], |
|
|
|
comparisonType: [{ required: true, message: '请选择对比类型', trigger: 'change' }], |
|
|
|
ruleType: [{ required: true, message: '请选择规则类型', trigger: 'change' }], |
|
|
|
abnormalDescription: [ |
|
|
|
{ |
|
|
|
required: true, |
|
|
@ -320,19 +350,28 @@ |
|
|
|
// 确认按钮 |
|
|
|
const btnClick = () => { |
|
|
|
console.log(infoObject.value, '数据'); |
|
|
|
|
|
|
|
infoObject.value.alarmList.forEach((item) => { |
|
|
|
if (item.logic === null || item.num === null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
}); |
|
|
|
if (infoObject.value.alarmList.length < 2) { |
|
|
|
NsMessage.error('请选择逻辑和数值'); |
|
|
|
return; |
|
|
|
} |
|
|
|
//数据是否验证通过 |
|
|
|
formRef.value.validate().then(() => { |
|
|
|
console.log(energyAlarm.value, '数据'); |
|
|
|
|
|
|
|
//处理数据 |
|
|
|
let data = { ...infoObject.value }; |
|
|
|
//关联能耗告警id |
|
|
|
data.equipmentAlarmId = energyAlarm.value.id; |
|
|
|
data.errorCode = energyAlarm.value.errorCode; |
|
|
|
data.dataSourcesType = data.sbtype[0]; |
|
|
|
data.dataSourcesWay = data.sbtype[1]; |
|
|
|
data.hxAlarmRuleLogicList = [...infoObject.value.alarmList, ...delAlarmList.value]; |
|
|
|
data.comparisonType = data.comparisonType.toString; |
|
|
|
data.hxAlarmRuleLogicList.forEach((item) => { |
|
|
|
const num = Number(item.num); |
|
|
|
if (!isNaN(num)) { |
|
|
@ -343,19 +382,25 @@ |
|
|
|
}); |
|
|
|
data.ruleType = Number(data.ruleType); |
|
|
|
delete data.alarmList; |
|
|
|
}); |
|
|
|
//调用接口 |
|
|
|
// http |
|
|
|
// .post(props.api, data) |
|
|
|
// .then(() => { |
|
|
|
// isLoading.value = false; |
|
|
|
// NsMessage.success('操作成功', 1, () => { |
|
|
|
// navigateBack(); |
|
|
|
// }); |
|
|
|
// .post(energyAlarms.configAddOrUpNewData, data) |
|
|
|
// .then((res) => { |
|
|
|
// if (res.msg === 'success') { |
|
|
|
// // 操作成功时的处理 |
|
|
|
// if (data.id) { |
|
|
|
// NsMessage.success('告警规则编辑成功'); |
|
|
|
// } else { |
|
|
|
// NsMessage.success('告警规则新增成功'); |
|
|
|
// } |
|
|
|
// emit('editObject', null); |
|
|
|
// handleClose(); |
|
|
|
// } |
|
|
|
// }) |
|
|
|
// .catch(() => { |
|
|
|
// isLoading.value = false; |
|
|
|
// .catch((error) => { |
|
|
|
// // 错误处理 |
|
|
|
// console.error('请求失败:', error); |
|
|
|
// }); |
|
|
|
}); |
|
|
|
}; |
|
|
|
//取消按钮 |
|
|
|
const handleClose = () => { |
|
|
@ -365,8 +410,8 @@ |
|
|
|
infoObject.value = { |
|
|
|
id: null, |
|
|
|
site: null, |
|
|
|
resource: null, |
|
|
|
jdDevice: null, |
|
|
|
ruleType: null, |
|
|
|
deviceNode: null, |
|
|
|
abnormalDescription: null, |
|
|
|
sbtype: null, |
|
|
|
enableRules: 0, |
|
|
@ -384,7 +429,7 @@ |
|
|
|
} |
|
|
|
}; |
|
|
|
// 删除 逻辑列表、 |
|
|
|
const deleteAlarmList = (index: num) => { |
|
|
|
const deleteAlarmList = (index: number) => { |
|
|
|
if (index < infoObject.value.alarmList.length && index >= 0) { |
|
|
|
const alarmItemToDelete = infoObject.value.alarmList[index]; |
|
|
|
if (alarmItemToDelete?.id) { |
|
|
@ -398,7 +443,6 @@ |
|
|
|
defineExpose({ |
|
|
|
toggle, |
|
|
|
handleClose, |
|
|
|
dwOptions, |
|
|
|
formRef, |
|
|
|
}); |
|
|
|
</script> |
|
|
|