|
@ -27,9 +27,9 @@ |
|
|
}" |
|
|
}" |
|
|
tree-node-filter-prop="orgName" /> |
|
|
tree-node-filter-prop="orgName" /> |
|
|
</a-form-item> |
|
|
</a-form-item> |
|
|
<a-form-item label="数据来源" name="sbtype"> |
|
|
<a-form-item label="数据来源" name="dataSources"> |
|
|
<a-cascader |
|
|
<a-cascader |
|
|
v-model:value="infoObject.sbtype" |
|
|
v-model:value="infoObject.dataSources" |
|
|
:options="deviceTypeTreeData" |
|
|
:options="deviceTypeTreeData" |
|
|
:field-names="{ |
|
|
:field-names="{ |
|
|
children: 'children', |
|
|
children: 'children', |
|
@ -45,16 +45,19 @@ |
|
|
v-model:value="infoObject.deviceNode" |
|
|
v-model:value="infoObject.deviceNode" |
|
|
style="width: 100%" |
|
|
style="width: 100%" |
|
|
placeholder="请选择设备节点" |
|
|
placeholder="请选择设备节点" |
|
|
:disabled="!infoObject.sbtype" |
|
|
:disabled="!infoObject.dataSources" |
|
|
:tree-line="true && { showLeafIcon: false }" |
|
|
:tree-line="true && { showLeafIcon: false }" |
|
|
:tree-data="jdTreeData" |
|
|
:tree-data="jdTreeData" |
|
|
:field-names="{ |
|
|
:field-names="{ |
|
|
children: 'children', |
|
|
children: 'children', |
|
|
label: infoObject.sbtype && infoObject.sbtype[1] === 1 ? 'deviceName' : 'pointName', |
|
|
label: |
|
|
|
|
|
infoObject.dataSources && infoObject.dataSources[1] === 1 |
|
|
|
|
|
? 'deviceName' |
|
|
|
|
|
: 'pointName', |
|
|
value: 'id', |
|
|
value: 'id', |
|
|
}" /> |
|
|
}" /> |
|
|
</a-form-item> |
|
|
</a-form-item> |
|
|
<a-form-item label="启用规则" name="enableRules"> |
|
|
<a-form-item label="启用规则"> |
|
|
<a-switch |
|
|
<a-switch |
|
|
:checked="infoObject.enableRules === 1 ? true : false" |
|
|
:checked="infoObject.enableRules === 1 ? true : false" |
|
|
:class="{ |
|
|
:class="{ |
|
@ -67,6 +70,7 @@ |
|
|
<a-textarea |
|
|
<a-textarea |
|
|
v-model:value="infoObject.abnormalDescription" |
|
|
v-model:value="infoObject.abnormalDescription" |
|
|
style="height: 32px" |
|
|
style="height: 32px" |
|
|
|
|
|
placeholder="请输入异常描述" |
|
|
:autoSize="{ minRows: 1, maxRows: 1 }" |
|
|
:autoSize="{ minRows: 1, maxRows: 1 }" |
|
|
show-count |
|
|
show-count |
|
|
:maxlength="30" /> |
|
|
:maxlength="30" /> |
|
@ -152,10 +156,11 @@ |
|
|
deviceNode: null, |
|
|
deviceNode: null, |
|
|
ruleType: null, |
|
|
ruleType: null, |
|
|
abnormalDescription: null, |
|
|
abnormalDescription: null, |
|
|
sbtype: null, |
|
|
dataSources: null, |
|
|
enableRules: 0, |
|
|
enableRules: 0, |
|
|
alarmList: [{ id: null, logic: null, num: null, isDelete: 0 }], |
|
|
alarmList: [{ id: null, logic: null, num: null, isDelete: 0 }], |
|
|
}); |
|
|
}); |
|
|
|
|
|
const emit = defineEmits(['editObject']); |
|
|
//删除的逻辑列表 |
|
|
//删除的逻辑列表 |
|
|
const delAlarmList = ref([]); |
|
|
const delAlarmList = ref([]); |
|
|
//对比类型 |
|
|
//对比类型 |
|
@ -271,6 +276,7 @@ |
|
|
const toggle = async (value: any, info: any) => { |
|
|
const toggle = async (value: any, info: any) => { |
|
|
// 数据来源 |
|
|
// 数据来源 |
|
|
let energyType = await dict({ params: { dicKey: 'ENERGY_TYPE' } }); |
|
|
let energyType = await dict({ params: { dicKey: 'ENERGY_TYPE' } }); |
|
|
|
|
|
if (energyType.data.data) { |
|
|
energyType.data.data.forEach((item: any) => { |
|
|
energyType.data.data.forEach((item: any) => { |
|
|
item.children = [ |
|
|
item.children = [ |
|
|
{ |
|
|
{ |
|
@ -284,6 +290,10 @@ |
|
|
]; |
|
|
]; |
|
|
}); |
|
|
}); |
|
|
deviceTypeTreeData.value = energyType.data.data; |
|
|
deviceTypeTreeData.value = energyType.data.data; |
|
|
|
|
|
} else { |
|
|
|
|
|
deviceTypeTreeData.value = []; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//能源告警 |
|
|
//能源告警 |
|
|
energyAlarm.value = info; |
|
|
energyAlarm.value = info; |
|
|
// 获取站点数据 |
|
|
// 获取站点数据 |
|
@ -294,16 +304,29 @@ |
|
|
}); |
|
|
}); |
|
|
//判断 是新增 还是修改 |
|
|
//判断 是新增 还是修改 |
|
|
if (value) { |
|
|
if (value) { |
|
|
value.ruleType = value.ruleType + ''; |
|
|
await http.post(energyAlarms.configFindById, { id: value.id }).then((res) => { |
|
|
value.comparisonType = value.comparisonType.split(','); |
|
|
if (res.msg === 'success') { |
|
|
value.sbtype = [value.dataSourcesType, value.dataSourcesWay]; |
|
|
infoObject.value = res.data; |
|
|
delete value.dataSourcesType; |
|
|
// 拼凑成 修改回显形式 |
|
|
delete value.dataSourcesWay; |
|
|
infoObject.value.dataSources = [ |
|
|
infoObject.value = value; |
|
|
infoObject.value.dataSourcesType, |
|
|
|
|
|
infoObject.value.dataSourcesWay, |
|
|
|
|
|
]; |
|
|
|
|
|
delete infoObject.value.dataSourcesType; |
|
|
|
|
|
delete infoObject.value.dataSourcesWay; |
|
|
|
|
|
infoObject.value.comparisonType = infoObject.value.comparisonType.split(','); |
|
|
|
|
|
infoObject.value.ruleType = infoObject.value.ruleType + ''; |
|
|
|
|
|
infoObject.value.alarmList = infoObject.value.hxAlarmRuleLogicList || []; |
|
|
|
|
|
delete infoObject.value.hxAlarmRuleLogicList; |
|
|
//获取设备/节点 |
|
|
//获取设备/节点 |
|
|
|
|
|
|
|
|
|
|
|
if (deviceTypeTreeData && deviceTypeTreeData.value.length > 0) { |
|
|
deviceTypeTreeData.value.forEach((item: any) => { |
|
|
deviceTypeTreeData.value.forEach((item: any) => { |
|
|
if (item.id === infoObject.value.sbtype[0]) { |
|
|
if (item.id === infoObject.value.dataSources[0]) { |
|
|
selectDeviceType(infoObject.value.sbtype, [{ ...item }]); |
|
|
selectDeviceType(infoObject.value.dataSources, [{ ...item }]); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} else { |
|
|
} else { |
|
@ -313,7 +336,7 @@ |
|
|
deviceNode: null, |
|
|
deviceNode: null, |
|
|
ruleType: null, |
|
|
ruleType: null, |
|
|
abnormalDescription: null, |
|
|
abnormalDescription: null, |
|
|
sbtype: null, |
|
|
dataSources: null, |
|
|
enableRules: 0, |
|
|
enableRules: 0, |
|
|
alarmList: [{ id: null, logic: null, num: null, isDelete: 0 }], |
|
|
alarmList: [{ id: null, logic: null, num: null, isDelete: 0 }], |
|
|
}; |
|
|
}; |
|
@ -324,8 +347,7 @@ |
|
|
//表单 判断规格 |
|
|
//表单 判断规格 |
|
|
const rules = { |
|
|
const rules = { |
|
|
site: [{ required: true, message: '请选择站点', trigger: 'change' }], |
|
|
site: [{ required: true, message: '请选择站点', trigger: 'change' }], |
|
|
sbtype: [{ required: true, message: '请选择设备类型', trigger: 'change' }], |
|
|
dataSources: [{ required: true, message: '请选择设备类型', trigger: 'change' }], |
|
|
enableRules: [{ required: true, message: '请选择启用规则', trigger: 'change' }], |
|
|
|
|
|
deviceNode: [{ required: true, message: '请选择设备名称', trigger: 'change' }], |
|
|
deviceNode: [{ required: true, message: '请选择设备名称', trigger: 'change' }], |
|
|
sbAdress: [{ required: true, message: '请选择设备点位', trigger: 'change' }], |
|
|
sbAdress: [{ required: true, message: '请选择设备点位', trigger: 'change' }], |
|
|
comparisonType: [{ required: true, message: '请选择对比类型', trigger: 'change' }], |
|
|
comparisonType: [{ required: true, message: '请选择对比类型', trigger: 'change' }], |
|
@ -344,12 +366,9 @@ |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
], |
|
|
], |
|
|
logic: [{ required: true, message: '请选择逻辑', trigger: 'blur' }], |
|
|
|
|
|
num: [{ required: true, message: '请输入数值', trigger: 'blur' }], |
|
|
|
|
|
}; |
|
|
}; |
|
|
// 确认按钮 |
|
|
// 确认按钮 |
|
|
const btnClick = () => { |
|
|
const btnClick = () => { |
|
|
console.log(infoObject.value, '数据'); |
|
|
|
|
|
infoObject.value.alarmList.forEach((item) => { |
|
|
infoObject.value.alarmList.forEach((item) => { |
|
|
if (item.logic === null || item.num === null) { |
|
|
if (item.logic === null || item.num === null) { |
|
|
return; |
|
|
return; |
|
@ -361,17 +380,16 @@ |
|
|
} |
|
|
} |
|
|
//数据是否验证通过 |
|
|
//数据是否验证通过 |
|
|
formRef.value.validate().then(() => { |
|
|
formRef.value.validate().then(() => { |
|
|
console.log(energyAlarm.value, '数据'); |
|
|
|
|
|
|
|
|
|
|
|
//处理数据 |
|
|
//处理数据 |
|
|
let data = { ...infoObject.value }; |
|
|
let data = { ...infoObject.value }; |
|
|
//关联能耗告警id |
|
|
//关联能耗告警id |
|
|
data.equipmentAlarmId = energyAlarm.value.id; |
|
|
data.equipmentAlarmId = energyAlarm.value.id; |
|
|
data.errorCode = energyAlarm.value.errorCode; |
|
|
data.errorCode = energyAlarm.value.errorCode; |
|
|
data.dataSourcesType = data.sbtype[0]; |
|
|
data.dataSourcesType = data.dataSources[0]; |
|
|
data.dataSourcesWay = data.sbtype[1]; |
|
|
data.dataSourcesWay = data.dataSources[1]; |
|
|
|
|
|
delete data.dataSources; |
|
|
data.hxAlarmRuleLogicList = [...infoObject.value.alarmList, ...delAlarmList.value]; |
|
|
data.hxAlarmRuleLogicList = [...infoObject.value.alarmList, ...delAlarmList.value]; |
|
|
data.comparisonType = data.comparisonType.toString; |
|
|
data.comparisonType = data.comparisonType.toString(); |
|
|
data.hxAlarmRuleLogicList.forEach((item) => { |
|
|
data.hxAlarmRuleLogicList.forEach((item) => { |
|
|
const num = Number(item.num); |
|
|
const num = Number(item.num); |
|
|
if (!isNaN(num)) { |
|
|
if (!isNaN(num)) { |
|
@ -382,24 +400,24 @@ |
|
|
}); |
|
|
}); |
|
|
data.ruleType = Number(data.ruleType); |
|
|
data.ruleType = Number(data.ruleType); |
|
|
delete data.alarmList; |
|
|
delete data.alarmList; |
|
|
// http |
|
|
http |
|
|
// .post(energyAlarms.configAddOrUpNewData, data) |
|
|
.post(energyAlarms.configAddOrUpNewData, data) |
|
|
// .then((res) => { |
|
|
.then((res) => { |
|
|
// if (res.msg === 'success') { |
|
|
if (res.msg === 'success') { |
|
|
// // 操作成功时的处理 |
|
|
// 操作成功时的处理 |
|
|
// if (data.id) { |
|
|
if (data.id) { |
|
|
// NsMessage.success('告警规则编辑成功'); |
|
|
NsMessage.success('告警规则编辑成功'); |
|
|
// } else { |
|
|
} else { |
|
|
// NsMessage.success('告警规则新增成功'); |
|
|
NsMessage.success('告警规则新增成功'); |
|
|
// } |
|
|
} |
|
|
// emit('editObject', null); |
|
|
emit('editObject', null); |
|
|
// handleClose(); |
|
|
handleClose(); |
|
|
// } |
|
|
} |
|
|
// }) |
|
|
}) |
|
|
// .catch((error) => { |
|
|
.catch((error) => { |
|
|
// // 错误处理 |
|
|
// 错误处理 |
|
|
// console.error('请求失败:', error); |
|
|
console.error('请求失败:', error); |
|
|
// }); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}; |
|
|
}; |
|
|
//取消按钮 |
|
|
//取消按钮 |
|
@ -413,7 +431,7 @@ |
|
|
ruleType: null, |
|
|
ruleType: null, |
|
|
deviceNode: null, |
|
|
deviceNode: null, |
|
|
abnormalDescription: null, |
|
|
abnormalDescription: null, |
|
|
sbtype: null, |
|
|
dataSources: null, |
|
|
enableRules: 0, |
|
|
enableRules: 0, |
|
|
alarmList: [{ id: null, logic: null, num: null, isDelete: 0 }], |
|
|
alarmList: [{ id: null, logic: null, num: null, isDelete: 0 }], |
|
|
}; |
|
|
}; |
|
|