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(() => {
- @@ -148,6 +192,26 @@ onMounted(() => { + + +
+
+
{{item.deviceName}}
+ + + +
+
+ + +
+ + + + + + + diff --git a/business-css/frontend/src/views/component/scenario/index.vue b/business-css/frontend/src/views/component/scenario/index.vue index 5789bef..0ed61a2 100644 --- a/business-css/frontend/src/views/component/scenario/index.vue +++ b/business-css/frontend/src/views/component/scenario/index.vue @@ -86,7 +86,12 @@ function addClick() { description: "", }; stepsActive.value = 0; + deviceData.value.forEach((item: any) => { + item.algorithmType = '' + }) dialogVisible.value = true; + + } const isSwitch = ref(false); // 事故情景id @@ -105,6 +110,23 @@ const rules = ref({ function editClick(row: any,type: string) { title.value =type + "事故情景"; info.value = JSON.parse(JSON.stringify(row)); + if(info.value.deviceAlgoConfig !=null && info.value.deviceAlgoConfig != ''){ + let device_algo_config = JSON.parse(info.value.deviceAlgoConfig) + for(let key in device_algo_config){ + for(let i = 0;i { } function submitClick(){ - let data = { + let data:any = { scenarioId: info.value.scenarioId, algorithm_type: info.value.algorithmType, name: info.value.name, 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){ + data.deviceAlgoConfig = JSON.stringify(device_algo_config) + } + + + updateScenarios(data).then((res:any) => { if (res == true) { ElMessage({ @@ -213,6 +250,7 @@ function submitClick(){ onMounted(() => { getAlgorithmType() gettableData(); + initDeviceData() }); function closeCreatescenario(){ dialogVisible.value = false; @@ -347,6 +385,24 @@ function changeShowResult(isShow:any){ // 切换显示结果模型 }, 200); } + +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: '' + }) + }) + } + }) + }