diff --git a/business-css/frontend/.env.development b/business-css/frontend/.env.development index 8af9418..470ff49 100644 --- a/business-css/frontend/.env.development +++ b/business-css/frontend/.env.development @@ -6,3 +6,4 @@ NODE_ENV='development' VITE_APP_TITLE = '临界事故情景分析模拟系统' VITE_APP_PORT = 3000 VITE_APP_BASE_API = '/dev-api' +VITE_APP_BASE_HTTP = 'http://localhost:3000' diff --git a/business-css/frontend/.env.production b/business-css/frontend/.env.production index 728f41a..7a2d7c7 100644 --- a/business-css/frontend/.env.production +++ b/business-css/frontend/.env.production @@ -4,3 +4,4 @@ NODE_ENV='production' VITE_APP_TITLE = 'NewFrameWork2023-WEB' VITE_APP_PORT = 3000 VITE_APP_BASE_API = '/prod-api' +VITE_APP_BASE_HTTP = 'http://localhost:3000' \ No newline at end of file diff --git a/business-css/frontend/src/api/business/event/index.ts b/business-css/frontend/src/api/business/event/index.ts index f662ee2..9909ede 100644 --- a/business-css/frontend/src/api/business/event/index.ts +++ b/business-css/frontend/src/api/business/event/index.ts @@ -1,13 +1,13 @@ import request from '@/utils/request'; // //获取所有项目列表 -// export function searchScenariosLsit(queryParams:any){ -// return request({ -// url: '/events/by-project' , -// method: 'get', -// params:queryParams -// }); -// } +export function searchEventsByScenarioId(queryParams:any){ + return request({ + url: '/events/by-scenario' , + method: 'get', + params:queryParams + }); +} diff --git a/business-css/frontend/src/components/antvx6/echartsModel.vue b/business-css/frontend/src/components/antvx6/echartsModel.vue new file mode 100644 index 0000000..09e625e --- /dev/null +++ b/business-css/frontend/src/components/antvx6/echartsModel.vue @@ -0,0 +1,218 @@ + + + + diff --git a/business-css/frontend/src/components/antvx6/tableModel.vue b/business-css/frontend/src/components/antvx6/tableModel.vue index 36e4bb2..72adcfc 100644 --- a/business-css/frontend/src/components/antvx6/tableModel.vue +++ b/business-css/frontend/src/components/antvx6/tableModel.vue @@ -6,7 +6,8 @@ export default { @@ -545,9 +671,10 @@ function dialogTableModel(){ // 关闭变动设置弹窗
-
+
{{ projectInfo.name }}
-
-
- -
-
-
- -
-
-
样式
-
-
- -
- + + + + +
@@ -877,4 +994,40 @@ function dialogTableModel(){ // 关闭变动设置弹窗 border-bottom:1px solid rgba(238, 238, 238, 1); padding-left: 15px; } + + + + \ No newline at end of file diff --git a/business-css/frontend/src/views/component/scenario/condition.vue b/business-css/frontend/src/views/component/scenario/condition.vue index 601507d..4c77fc5 100644 --- a/business-css/frontend/src/views/component/scenario/condition.vue +++ b/business-css/frontend/src/views/component/scenario/condition.vue @@ -11,6 +11,7 @@ import Page from '@/components/Pagination/page.vue' import { getDictItemById } from '@/api/dict'; import { topologyDevicesLsit } from '@/api/business/project'; +import { searchEventsByScenarioId } from '@/api/business/event'; const conditionData:any = ref([{ // 套件数据 @@ -30,12 +31,18 @@ const props = defineProps({ // 接收父组件传递的项目信息 type: String, default: '' }, + isEdit: { + required: true, + type: Boolean, + default: false + }, }); +const isEdit = ref(props.isEdit) function submitClick() { + debugger return menuList.value } function initDeviceData(){ - console.log(props.projectInfo) topologyDevicesLsit({ id: props.projectInfo.projectId }).then((res:any) => { @@ -44,9 +51,34 @@ function initDeviceData(){ } }) } +function initConditionData(){ + searchEventsByScenarioId({ + scenarioId: props.scenarioId + }).then((res:any) => { + if(res.length > 0){ + menuList.value = [] + } + for(let i = 0; i < res.length; i++){ + if(res[i].attrChanges != null && res[i].attrChanges != ''){ + let attrChanges = JSON.parse(res[i].attrChanges) + menuList.value.push({ + ...attrChanges, + eventId: res[i].eventId, + }) + + getTimelineList() + } + } + if(res.length > 0){ + getDeviceInfo(menuList.value[0].device) + } + + }) +} onMounted(() => { DicInit() -initDeviceData() + initDeviceData() + initConditionData() }); const deviceData:any = ref([]) // 始发设备数据 const attributeData:any = ref([]) // 设备属性数据 @@ -94,6 +126,7 @@ function addAttr(){ // 添加自定义属性 function menuClick(index:any){ // 点击菜单切换 menuIndex.value = index; segmentationIndex.value = 0; + getTimelineList() } function addMenu(){ //添加导菜单 menuList.value.push({ @@ -124,6 +157,9 @@ function DicInit() { getDictItemById(params).then((result: any) => { attributeData.value = result.data.records; }).catch((err: any) => { + if(menuList.value[menuIndex.value].target.entityType == 'device'){ + getDeviceInfo(menuList.value[menuIndex.value].device) + } }); let paramss = { dictId: '9d87f873bc80e79c6d399131cbe01016', @@ -132,6 +168,9 @@ function DicInit() { } getDictItemById(paramss).then((result: any) => { materialData.value = result.data.records; + if(menuList.value[menuIndex.value].target.entityType == 'device'){ + getDeviceInfo(menuList.value[menuIndex.value].device) + } }).catch((err: any) => { }); } @@ -173,6 +212,25 @@ function changeMaterial(e:any){ // 设备属性改变时,清空变化物料 getDeviceInfo(e) } +// 查询字典项 +// async function DicInit() { +// let params = { +// dictId: 'dc7419e5f8a655966e6bb90b0cb5c0c2', +// size:99, +// current:1 +// } + +// const attributeResult = await getDictItemById(params) +// attributeData.value = attributeResult.data.records; +// let paramss = { +// dictId: '9d87f873bc80e79c6d399131cbe01016', +// size:99, +// current:1 +// } +// const materialResult = await getDictItemById(paramss) +// materialData.value = materialResult.data.records; +// initConditionData() +// } const devicename = ref('') // 选中始发设备 @@ -181,13 +239,21 @@ const timelineList:any = ref([]) // 时间线数据 function getTimelineList(){ timelineList.value = [] - menuList.value.forEach((item:any) => { + // menuList.value.forEach((item:any) => { + // item.segments.forEach((segment:any) => { + // segment.timeline.forEach((timeline:any) => { + // console.log(timeline) + // timelineList.value.push(timeline) + // }) + // }) + // }) + let item = menuList.value[menuIndex.value] item.segments.forEach((segment:any) => { segment.timeline.forEach((timeline:any) => { + console.log(timeline) timelineList.value.push(timeline) }) }) - }) } function getDeviceInfo(e:any){ // 获取设备信息 devicename.value = "" @@ -227,25 +293,26 @@ function getDeviceInfo(e:any){ // 获取设备信息 :class="{'condition-item-active': index == menuIndex}" @click="menuClick(index)"> {{ item.label }}
- + - +
+ :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){ // 获取设备信息
{{ item.segmentId }} - +
-
+
+ 新增分段
@@ -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) {
- + +