+ :disabled="(menuList[menuIndex].material!='' && menuList[menuIndex].material!=null) || isEdit == false" @change="changeAttribute">
+ :disabled="(menuList[menuIndex].attribute!='' && menuList[menuIndex].attribute!=null)|| isEdit == true" @change="changeMaterial">
@@ -254,9 +321,9 @@ function getDeviceInfo(e:any){ // 获取设备信息
-
@@ -291,12 +358,12 @@ function getDeviceInfo(e:any){ // 获取设备信息
-
+
diff --git a/business-css/frontend/src/views/component/scenario/index.vue b/business-css/frontend/src/views/component/scenario/index.vue
index 85f3766..d4d4cf8 100644
--- a/business-css/frontend/src/views/component/scenario/index.vue
+++ b/business-css/frontend/src/views/component/scenario/index.vue
@@ -8,14 +8,14 @@ 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';
+const webUrl = import.meta.env.VITE_APP_BASE_HTTP; // 基础路径
const algorithmTypeData: any = ref([]); // 算法类型数据
const stepsActive = ref(0); // 步骤导航栏当前激活的步骤索引
const props = defineProps({ // 接收父组件传递的项目信息
@@ -25,7 +25,6 @@ const props = defineProps({ // 接收父组件传递的项目信息
default: {}
}
});
-
// 搜索框
const queryParams = ref({
current: 1,
@@ -72,7 +71,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 = {
@@ -142,25 +142,37 @@ function confirmClick(formEl: any) {
//新建角色-取消按钮
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;
+}
+function editClick1(row: any) {
+
+ info.value = JSON.parse(JSON.stringify(row));
+ dialogEditVisible.value = true;
}
//删除事故情景
@@ -226,38 +238,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 +289,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,15 +320,39 @@ 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: "修改成功",
+ });
+ }
+ })
-
+
+}
@@ -358,25 +399,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="editClick1(scope.row)" style="cursor: pointer; ">
-
-
-
+
@@ -387,38 +427,43 @@ function confirmationAnalysis(row: any) {