+
diff --git a/business-css/frontend/src/views/component/scenario/index.vue b/business-css/frontend/src/views/component/scenario/index.vue
index 85f3766..5724ac6 100644
--- a/business-css/frontend/src/views/component/scenario/index.vue
+++ b/business-css/frontend/src/views/component/scenario/index.vue
@@ -8,14 +8,17 @@ export default {
import { onMounted, ref, nextTick } from "vue";
import { ElForm, ElMessage, ElMessageBox } from "element-plus";
import { searchScenariosLsit,addScenarios,updateScenarios,deleteScenarios,deleteBatchScenarios} from "@/api/business/scenario";
-
+import { getActiveAlgorithms } from "@/api/business/scenario";
+import ConditionModel from '@/views/component/scenario/condition.vue'
import { simulationInit,simulationRun } from "@/api/business/project";
-
import Page from '@/components/Pagination/page.vue'
import { getDictItemById } from '@/api/dict';
-// import ConditionModel from '@/views/component/scenario/condition.vue'
import Createscenario from '@/views/component/scenario/createscenario.vue'
import { eventsBatchSave } from '@/api/business/event';
+import { topologyDevicesLsit } from '@/api/business/project';
+import TableModels from '@/components/antvx6/tableModel.vue';
+import EchartsModels from '@/components/antvx6/echartsModel.vue';
+const webUrl = import.meta.env.VITE_APP_BASE_HTTP; // 基础路径
const algorithmTypeData: any = ref([]); // 算法类型数据
const stepsActive = ref(0); // 步骤导航栏当前激活的步骤索引
const props = defineProps({ // 接收父组件传递的项目信息
@@ -25,7 +28,6 @@ const props = defineProps({ // 接收父组件传递的项目信息
default: {}
}
});
-
// 搜索框
const queryParams = ref({
current: 1,
@@ -72,7 +74,8 @@ const info: any = ref({
description: "",
});
const scenarioId = ref(""); // 事故情景id
-const dialogVisible = ref(false);
+const dialogVisible = ref(false); // 新增事故情景弹窗是否显示
+const dialogEditVisible = ref(false); // 修改或查看事故情景弹窗是否显示
function addClick() {
title.value = "新增事故情景";
info.value = {
@@ -85,82 +88,35 @@ function addClick() {
}
const isSwitch = ref(false); // 事故情景id
-//新建事故情景-确认按钮/修改按钮
-function confirmClick(formEl: any) {
- console.log(info.value)
- formEl.validate((valid: any) => {
- if (valid) {
-
- if (!info.value.scenarioId) {
- const params = {
- projectId: props.projectInfo.projectId,
- name: info.value.name,
- algorithmType: info.value.algorithmType,
- description: info.value.description,
- };
- if(isSwitch.value == true){
- return ;
- }
- isSwitch.value = true
- addScenarios(params).then((res:any) => {
- isSwitch.value = false;
- if(res && res.code == 0) {
- scenarioId.value = res.scenarioId;
- gettableData();
- ElMessage({
- type: "success",
- message: "新增成功",
- });
- stepsActive.value = 1;
- } else {
- ElMessage({
- type: "error",
- message: "新增失败",
- });
- }
- }).catch(() => {
- isSwitch.value = false;
- })
- } else if (info.value.scenarioId) {
- const params = {
- scenarioId: info.value.scenarioId,
- projectId: info.value.projectId,
- name: info.value.name,
- algorithmType: info.value.algorithmType,
- description: info.value.description,
- };
- updateScenarios(params).then((res) => {
- gettableData();
- dialogVisible.value = false;
- });
- } else {
- return false;
- }
- }
- });
-}
//新建角色-取消按钮
function handleClose() {
- dialogVisible.value = false;
+ dialogEditVisible.value = false;
if (infoForm.value != null) infoForm.value.resetFields();
}
-function handleScenarioClose(){
- dialogVisible.value = false;
- gettableData();
- if (infoForm.value != null) infoForm.value.resetFields();
-
-}
//新建事故情景
const rules = ref({
name: [{ required: true, message: "请输入事故情景名称", trigger: "blur" }],
algorithmType: [{ required: true, message: "请选择算法类型", trigger: "change" }],
});
//修改事故情景
-function editClick(row: any) {
- title.value = "修改事故情景";
+function editClick(row: any,type: string) {
+ title.value =type + "事故情景";
info.value = JSON.parse(JSON.stringify(row));
- dialogVisible.value = true;
+
+ dialogEditVisible.value = true;
+}
+const isEdit = ref(false);
+function departureClick(row: any,type: string) {
+ title.value =type;
+ if(type == "初始条件设置"){
+ isEdit.value = true;
+ } else {
+ isEdit.value = false;
+ }
+ info.value = JSON.parse(JSON.stringify(row));
+ scenarioId.value = row.scenarioId;
+ isShowCondition.value = true;
}
//删除事故情景
@@ -226,38 +182,27 @@ function dateFormat(row: any) {
}
const getAlgorithmType = async () => {
try {
- let params = {
- dictId: '595502b91e7741b5033b53622d8731a3',
- size:99,
- current:1
- }
- const result:any = await getDictItemById(params);
- if (result.code == '0') {
- algorithmTypeData.value = result.data.records
- }
+ const result:any = await getActiveAlgorithms();
+ algorithmTypeData.value = result
} catch (error) {
}
}
-const conditionModel = ref()
function submitClick(){
- const tempData = conditionModel.value?.submitClick()
- let data:any = []
-
- tempData.forEach((item: any) => {
- data.push({
- triggerTime:'0',
- attrChanges:JSON.stringify(item) ,
- scenarioId: scenarioId.value
- })
- })
- eventsBatchSave(data).then((res:any) => {
- if (res.code == '0') {
- // ElMessage({
- // type: "success",
- // message: "保存成功",
- // });
- dialogVisible.value = false;
+ let data = {
+ scenarioId: info.value.scenarioId,
+ algorithm_type: info.value.algorithmType,
+ name: info.value.name,
+ description: info.value.description,
+ }
+ updateScenarios(data).then((res:any) => {
+ if (res == true) {
+ ElMessage({
+ type: "success",
+ message: "保存成功",
+ });
+ dialogEditVisible.value = false;
+ gettableData();
}
})
@@ -288,8 +233,24 @@ function confirmationAnalysis(row: any) {
let data = {
data: res.data
}
- simulationRun(row.projectId, row.scenarioId, data || {}).then((res) => {
- gettableData();
+ simulationRun(row.projectId, row.scenarioId, data || {}).then((res:any) => {
+ if(res.code == '0'){
+ ElMessage({
+ type: "success",
+ message: "模拟计算成功",
+ });
+ gettableData();
+ setTimeout(() => {
+ window.open(webUrl + '/#/viewanalysis?projectId='+ row.projectId +'&scenarioId='+ row.scenarioId, '_blank');
+ }, 1000);
+
+ }else{
+ ElMessage({
+ type: "error",
+ message: "模拟运行失败,请检查后端服务是否正常",
+ });
+ }{}
+
}).catch((error) => {
console.error('模拟运行失败:', error);
ElMessage({
@@ -303,16 +264,85 @@ function confirmationAnalysis(row: any) {
message: "模拟初始化失败",
});
}
-
-
-
});
})
}
+const isShowCondition = ref
(false); // 是否显示条件模型
+const conditionModelRef = ref() // 条件模型实例
+function handleScenarioClose(){
+ isShowCondition.value = false;
+}
+function submitConditionClick(){
+ const tempData = conditionModelRef.value?.submitClick()
+ let data:any = []
+ tempData.forEach((item: any) => {
+ data.push({
+ triggerTime:'0',
+ eventId: item.eventId ==null? '' : item.eventId,
+ attrChanges:JSON.stringify(item) ,
+ scenarioId: scenarioId.value
+ })
+ })
+ eventsBatchSave(data).then((res:any) => {
+ if (res.code == '0') {
+ isShowCondition.value = false;
+ gettableData();
+ ElMessage({
+ type: "success",
+ message: "修改成功",
+ });
+ }
+ })
+
+}
+function resultClick(row:any){
+ isAcitve.value = 0
+ scenarioId.value = row.scenarioId,
+ getMenuData()
+ isShowResult.value = true;
+}
+const isShowResult = ref(false); // 是否显示结果模型
+const deviceList:any = ref([]) // 变动设备列表
+const isAcitve:any = ref(-1) // 选中项
+const deviceId:any = ref('') // 变动设备id
+function getMenuData() {
+ topologyDevicesLsit({
+ id: props.projectInfo.projectId
+ }).then((res:any) => {
+ if (res.code == 0) {
+ deviceList.value = res.data;
+ deviceId.value = res.data[0].deviceId
+ }
+ })
+}
+// const title = ref('') // 标题
+function handleClick(item:any, index:any){
+ // formulaInfo.value.correlation = JSON.parse(JSON.stringify(item.deviceName))
+ isAcitve.value = index
+ deviceId.value = ""
+ setTimeout(() => {
+ deviceId.value = item.deviceId
+ },
+ 200);
+}
+function handleResultClose(){ // 关闭结果模型
+ isShowResult.value = false;
+}
+const isEchartsModel = ref(false) // 是否显示echarts模型
+
+function changeShowResult(isShow:boolean){ // 切换显示结果模型
+ isEchartsModel.value = isShow
+ let tempId = deviceId.value
+ deviceId.value = ''
+ setTimeout(() => {
+ deviceId.value = tempId
+ },
+ 200);
+}
@@ -358,25 +388,24 @@ function confirmationAnalysis(row: any) {
style="display: flex;display: -webkit-flex; justify-content: space-around;-webkit-justify-content: space-around; ">
+ @click="editClick(scope.row,'修改')" style="cursor: pointer; ">
+
+ @click="editClick(scope.row,'查看')" style="cursor: pointer; ">
+ @click="departureClick(scope.row,'初始条件设置')" style="cursor: pointer; ">
+ @click="departureClick(scope.row,'查看初始条件')" style="cursor: pointer; ">
+ @click="resultClick(scope.row)" style="cursor: pointer; ">
-
-
-
+
@@ -387,38 +416,71 @@ function confirmationAnalysis(row: any) {