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/changesettings.vue b/business-css/frontend/src/components/antvx6/changesettings.vue index 1ff3255..4da9b32 100644 --- a/business-css/frontend/src/components/antvx6/changesettings.vue +++ b/business-css/frontend/src/components/antvx6/changesettings.vue @@ -56,13 +56,6 @@ if(deviceTypetype.value == ''){ deviceList.value = res.data; } }) -// topologyDevicesLsit(params).then((result:any) => { -// deviceList.value = result.records; -// }).catch((err) => { - -// }); - - } 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..a5b6d9a --- /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..6891c3e 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..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); +} @@ -589,4 +651,91 @@ function confirmationAnalysis(row: any) { align-items: center; } - \ No newline at end of file +.choiceMateria-left{ + width: 240px; + height: calc(100vh - 200px); + border-right: 1px solid rgba(240, 240, 240, 1); + box-sizing: border-box; +} +.choiceMateria-left-title{ + width: 240px; + height: 44px; + line-height: 44px; + font-family: 'Arial Negreta', 'Arial Normal', 'Arial'; + font-weight: 700; + font-style: normal; + font-size: 14px; + color: #1B1B1B; + padding-left: 16px; + border-bottom: 1px solid rgba(240, 240, 240, 1); +} +.choiceMateria-left-item{ + width: 100%; + height: 40px; + line-height: 40px; + padding-left: 16px; + font-family: 'Arial Normal', 'Arial'; + font-weight: 400; + font-style: normal; + font-size: 14px; + color: #333333; + cursor: pointer; +} +.choiceMateria-left-item:hover{ + background-color: #f5f8ff; +} +.choiceMateria-item-active{ + background-color: #f5f8ff; + color: #266fff; +} + + + + +.adddevice_navigation_left{ + width: 110px; + height: 32px; + line-height: 32px; + text-align: center; + cursor: pointer; + font-family: 'Arial Normal', 'Arial'; + font-weight: 400; + font-style: normal; + font-size: 14px; + color: #363636; + background-image: url('@/assets/x6/navleft.png'); +} +.adddevice_navigation_left:hover{ + color: #266fff ; +} +.adddevice_navigation_activeleft{ + background-image: url('@/assets/x6/navleft_active.png'); + color: #fff !important; +} +.adddevice_navigation_right{ + width: 110px; + height: 32px; + line-height: 32px; + text-align: center; + cursor: pointer; + font-family: 'Arial Normal', 'Arial'; + font-weight: 400; + font-style: normal; + font-size: 14px; + color: #363636; + background-image: url('@/assets/x6/navright.png'); +} +.adddevice_navigation_right:hover{ + color: #266fff ; +} +.adddevice_navigation_activeright{ + background-image: url('@/assets/x6/navright_active.png'); + color: #fff !important; +} + + + diff --git a/business-css/frontend/vite.config.ts b/business-css/frontend/vite.config.ts index fe7de1f..5df1cfe 100644 --- a/business-css/frontend/vite.config.ts +++ b/business-css/frontend/vite.config.ts @@ -25,7 +25,7 @@ export default ({ mode }: ConfigEnv): UserConfig => { proxy: { [env.VITE_APP_BASE_API]: { // 线上API地址 - //target: 'http://192.168.1.20:8090/', + // target: 'http://192.168.1.166:8090/', // 本地API地址 target: 'http://localhost:8090', changeOrigin: true,