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