diff --git a/business-css/frontend/src/views/component/scenario/createscenario.vue b/business-css/frontend/src/views/component/scenario/createscenario.vue index 85bf7b6..8142c65 100644 --- a/business-css/frontend/src/views/component/scenario/createscenario.vue +++ b/business-css/frontend/src/views/component/scenario/createscenario.vue @@ -11,7 +11,7 @@ import { getDictItemById } from '@/api/dict'; import { eventsBatchSave } from '@/api/business/event'; import ConditionModels from '@/views/component/scenario/condition.vue' import { addScenarios,updateScenarios,getActiveAlgorithms } from "@/api/business/scenario"; - +import { topologyDevicesLsit } from '@/api/business/project'; const emit = defineEmits([ 'closeCreatescenario']); const props = defineProps({ // 接收父组件传递的项目信息 projectInfo: { @@ -53,12 +53,25 @@ function confirmClick(formEl: any) { if (valid) { if (!info.value.scenarioId) { - const params = { + const params:any = { projectId: props.projectInfo.projectId, name: info.value.name, algorithmType: info.value.algorithmType, description: info.value.description, + keffThreshold: info.value.keffThreshold, }; + let device_algo_config:any = {} + let isTrue:any = false + deviceData.value.forEach((item: any) => { + if(item.algorithmType !=null && item.algorithmType != ''){ + device_algo_config[item.deviceId] = item.algorithmType + isTrue = true + } + }) + if(isTrue == true){ + params.deviceAlgoConfig = JSON.stringify(device_algo_config) + } + if(isSwitch.value == true){ return ; } @@ -82,13 +95,26 @@ function confirmClick(formEl: any) { isSwitch.value = false; }) } else if (info.value.scenarioId) { - const params = { + const params:any = { scenarioId: info.value.scenarioId, projectId: info.value.projectId, name: info.value.name, algorithmType: info.value.algorithmType, description: info.value.description, + keffThreshold: info.value.keffThreshold, }; + + let device_algo_config:any = {} + let isTrue:any = false + deviceData.value.forEach((item: any) => { + if(item.algorithmType !=null && item.algorithmType != ''){ + device_algo_config[item.deviceId] = item.algorithmType + isTrue = true + } + }) + if(isTrue == true){ + params.deviceAlgoConfig = JSON.stringify(device_algo_config) + } updateScenarios(params).then((res) => { }); @@ -121,8 +147,26 @@ function submitClick(){ }) +} +const deviceData: any = ref([]); // 设备数据 +function initDeviceData(){ + deviceData.value = [] + topologyDevicesLsit({ + id: props.projectInfo.projectId + }).then((res:any) => { + if (res.code == 0) { + res.data.forEach((item: any) => { + deviceData.value.push({ + deviceId: item.deviceId, + deviceName: item.deviceName, + algorithmType: '' + }) + }) + } + }) } onMounted(() => { + initDeviceData() getAlgorithmType() }); @@ -138,7 +182,7 @@ onMounted(() => {