From 099486cfc138000fbedb5d13bd9b43ce837672d0 Mon Sep 17 00:00:00 2001 From: limengnan <420004014@qq.com> Date: Thu, 12 Mar 2026 16:32:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A8=A1=E6=8B=9F=E5=88=86?= =?UTF-8?q?=E6=9E=90=E6=B7=BB=E5=8A=A0Keff=E9=A2=84=E8=AD=A6=E9=98=88?= =?UTF-8?q?=E5=80=BC=EF=BC=8C=E8=AE=BE=E5=A4=87=E7=AE=97=E6=B3=95=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=98=A0=E5=B0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/scenario/createscenario.vue | 72 +++++++++++++++++-- .../src/views/component/scenario/index.vue | 72 ++++++++++++++++++- 2 files changed, 139 insertions(+), 5 deletions(-) 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: '' + }) + }) + } + }) + }