Browse Source

feat:多仿真功能接口联调

linchengzhe 1 year ago
parent
commit
9d460eb49b

+ 4 - 2
src/api/index.js

@@ -7,7 +7,8 @@ import modelLibrary from './modelLibrary.js' // 模型库
 import algorithmsLibrary from './algorithmsLibrary.js' // 算法库
 import algorithmsLibrary from './algorithmsLibrary.js' // 算法库
 import mainPage from './mainPage.js' // 首页
 import mainPage from './mainPage.js' // 首页
 import systemManagement from "./systemManagement.js"; //系统管理
 import systemManagement from "./systemManagement.js"; //系统管理
-import userInfo from "./userInfo.js";
+import userInfo from "./userInfo.js"; 
+import multimode  from "./multimode.js"; // 多模式仿真
 
 
 const api = {
 const api = {
     common,
     common,
@@ -17,7 +18,8 @@ const api = {
     algorithmsLibrary,
     algorithmsLibrary,
     mainPage,
     mainPage,
     systemManagement,
     systemManagement,
-    userInfo
+    userInfo,
+    multimode
 }
 }
 
 
 export default api;
 export default api;

+ 16 - 0
src/api/multimode.js

@@ -0,0 +1,16 @@
+const basePart = '/simulation/resource/server';
+
+
+
+export default{
+  queryMulationList: basePart+'/simulationProject/selectMultiSimulationProject', // 获取仿真任务列表
+  deleteMulationById:basePart + '/simulationProject/deleteMultiSimulationProject', // 删除仿真任务
+  updateMulationStatus:basePart + '/simulationProject/updateMultiSimulationProjectStatus', // 更新任务状态
+  queryMulationDetailById: basePart + '/simulationProject/getMultiSimulationProjectDetail', // 获取仿真任务详情 
+  queryMulationSceneList :basePart + '/simulationProject/selectMultiSimulationSceneList', // 任务场景列表
+  viewMulationSceneResult: basePart +'/simulationProject/viewMultiSimulationProjectResult', // 查看场景评价结果
+  createMulationTask:basePart + '/simulationProject/addMultiSimulationProject', // 创建仿真任务
+  addMulationSceneList:basePart + '/simulationProject/addMultiSimulationScene', // 添加仿真场景列表数据
+  deleteMulationScene :basePart + '/simulationProject/deleteMultiSimulationScene', // 删除多模式场景
+  saveMulationTask : basePart + '/simulationProject/submitMultiSimulationProjectDetail', // 提交多模式任务
+}

+ 21 - 0
src/views/multimodeSimulation/evaluationResults.vue

@@ -164,5 +164,26 @@ export default {
       },
       },
     }
     }
   },
   },
+  methods:{
+    getMulationSceneResult(id){
+      this.$axios({
+        method: 'post',
+        url: this.$api.multimode.viewMulationSceneResult,
+        data: {
+          sceneId: id,
+        },
+      }).then((res) => {
+        if (res.code == 200) {
+         
+        } else {
+          this.$message.error(res.message || '查询信息失败')
+        }
+      })
+    }
+  },
+  mounted(){
+    console.log('t',this.$route.query.id)
+    this.$route.query.id && this.getMulationSceneResult(this.$route.query.id)
+  }
 }
 }
 </script>
 </script>

+ 164 - 45
src/views/multimodeSimulation/simulationEdit.vue

@@ -69,7 +69,7 @@
     </p>
     </p>
     <div style="display: flex; justify-content: end; margin: 20px 50px">
     <div style="display: flex; justify-content: end; margin: 20px 50px">
       <el-button
       <el-button
-        v-if="isEdit"
+        v-if="configBtnShow"
         class="addBtn"
         class="addBtn"
         icon="el-icon-circle-plus-outline"
         icon="el-icon-circle-plus-outline"
         @click="addConfig"
         @click="addConfig"
@@ -77,7 +77,7 @@
         >添加</el-button
         >添加</el-button
       >
       >
       <el-button
       <el-button
-        v-if="isEdit"
+        v-if="configBtnShow"
         class="addBtn"
         class="addBtn"
         icon="el-icon-circle-plus-outline"
         icon="el-icon-circle-plus-outline"
         @click="copyConfig"
         @click="copyConfig"
@@ -86,6 +86,7 @@
       >
       >
     </div>
     </div>
     <tableList
     <tableList
+      v-if="tableShow"
       ref="table"
       ref="table"
       style="margin: 0 30px 30px"
       style="margin: 0 30px 30px"
       :columns="columns"
       :columns="columns"
@@ -95,12 +96,23 @@
     >
     >
       <el-table-column label="操作" slot="cgInfos" align="center" width="180">
       <el-table-column label="操作" slot="cgInfos" align="center" width="180">
         <template v-slot="scope">
         <template v-slot="scope">
-          <span v-if="!isEdit" @click="toEvaluate" class="elIcon"> 评价结果 </span>
-          <span v-if="isEdit" @click="navigatorEdit" class="elIcon"> 编辑 </span>
-          <span v-if="isEdit" @click="" class="elIcon"> 删除 </span>
+          <span v-if="!isEdit" @click="toEvaluate(scope.row)" class="elIcon">
+            评价结果
+          </span>
+          <span v-if="isEdit" @click="navigatorEdit" class="elIcon">
+            编辑
+          </span>
+          <span v-if="isEdit" @click="deleteScene(scope.row.id)" class="elIcon">
+            删除
+          </span>
         </template>
         </template>
       </el-table-column>
       </el-table-column>
     </tableList>
     </tableList>
+    <div style="display: flex; justify-content: center; margin-top: 30px">
+      <el-button type="primary" @click="createTask">保存</el-button>
+      <el-button type="primary" @click="saveTask">提交</el-button>
+      <el-button @click="cancelHandle">取消</el-button>
+    </div>
   </div>
   </div>
 </template>
 </template>
 
 
@@ -114,23 +126,26 @@ export default {
   data() {
   data() {
     return {
     return {
       isEdit: true, // 模式, 默认编辑模式 false 预览
       isEdit: true, // 模式, 默认编辑模式 false 预览
+      tableShow: false, // 是否显示表格,新增默认不显示
+      configBtnShow: false,
+      projectId: '', // 仿真任务id
       baseInfo: {
       baseInfo: {
         projectName: '', // 项目名称
         projectName: '', // 项目名称
-        projectMaxSeconds: 0, // 最大仿真时间
+        projectMaxSeconds: '', // 最大仿真时间
         projectDescription: '', // 项目描述
         projectDescription: '', // 项目描述
       },
       },
       columns: [
       columns: [
         {
         {
           label: '地图文件',
           label: '地图文件',
-          prop: 'id',
+          prop: 'mapName',
         },
         },
         {
         {
           label: '车辆数量',
           label: '车辆数量',
-          prop: 'projectName',
+          prop: 'carNums',
         },
         },
         {
         {
           label: '创建时间',
           label: '创建时间',
-          prop: 'sceneNums',
+          prop: 'createTime',
         },
         },
         {
         {
           label: '操作',
           label: '操作',
@@ -148,56 +163,160 @@ export default {
       },
       },
       getDataWay: {
       getDataWay: {
         //加载表格数据
         //加载表格数据
-        dataType: 'data',
+        dataType: 'url',
         type: 'post',
         type: 'post',
-        // firstRequest: false,
-        data: [
-          {
-            id: 'd1245825a1aa5a6',
-            projectKey: '20240130-1',
-            projectName: '1007',
-            projectStatus: 0,
-            projectStatusValue: '未开始',
-            createTime: '2024-01-30 16:15:43',
-            sceneNums: 1,
-          },
-          {
-            id: 'd4582d2a6',
-            projectKey: '20240130-1',
-            projectName: '1007',
-            projectStatus: 1,
-            projectStatusValue: '已结束',
-            createTime: '2024-01-30 16:15:43',
-            sceneNums: 1,
-          },
-        ],
+        data: this.$api.multimode.queryMulationSceneList,
         param: {
         param: {
-          share: '0',
+          projectId: this.$route.query.id || '',
         },
         },
       },
       },
     }
     }
   },
   },
   mounted() {
   mounted() {
-    console.log('加桌', this.$route.query.mode)
-    this.isEdit = this.$route.query.mode == 'edit' ? true : false
+    this.isEdit = ['edit', 'add'].includes(this.$route.query.mode)
+      ? true
+      : false
+    this.configBtnShow = this.$route.query.mode == 'edit' ? true : false
+    if (['edit', 'preview'].includes(this.$route.query.mode)) {
+      this.tableShow = true
+    }
+    if (this.$route.query.id) {
+      this.projectId = this.$route.query.id
+      this.getTaskDetailById(this.$route.query.id)
+    }
   },
   },
   methods: {
   methods: {
+    // 获取任务详情信息
+    getTaskDetailById(id) {
+      this.$axios({
+        method: 'post',
+        url: this.$api.multimode.queryMulationDetailById,
+        data: {
+          projectId: id,
+        },
+      }).then((res) => {
+        if (res.code == 200) {
+          this.baseInfo = {
+            projectName: res.info.projectName, // 项目名称
+            projectMaxSeconds: res.info.projectMaxSeconds, // 最大仿真时间
+            projectDescription: res.info.projectDescription, // 项目描述
+          }
+        } else {
+          this.$message.error(res.message || '查询信息失败')
+        }
+      })
+    },
+    deleteScene(id) {
+      this.$axios({
+        method: 'post',
+        url: this.$api.multimode.deleteMulationScene,
+        data: {
+          sceneId: id,
+        },
+      }).then((res) => {
+        if (res.code == 200) {
+          this.refreshList({ projectId: this.projectId })
+          this.$message.success('删除成功')
+        } else {
+          this.$message.error(res.message || '删除失败')
+        }
+      })
+    },
+    // 提交
+    saveTask() {
+      this.$axios({
+        method: 'post',
+        url: this.$api.multimode.saveMulationTask,
+        data: {
+          projectId: this.projectId,
+          projectName: this.baseInfo.projectName,
+          projectMaxSeconds: this.baseInfo.projectMaxSeconds,
+          projectDescription: this.baseInfo.projectDescription,
+        },
+      }).then((res) => {
+        if (res.code == 200) {
+          this.$message.success('提交成功')
+          this.$router.push({
+            path:'/multimodeSimulation'
+          })
+        } else {
+          this.$message.error(res.message || '提交失败')
+        }
+      })
+    },
+    // 刷新场景列表
+    refreshList(param) {
+      param
+        ? this.$refs['table'].loadData(param)
+        : this.$refs['table'].loadData()
+    },
     copyConfig() {},
     copyConfig() {},
-    addConfig() {},
-    toEvaluate(){
+    // 新增场景列表
+    addConfig() {
+      this.$axios({
+        method: 'post',
+        url: this.$api.multimode.addMulationSceneList,
+        data: {
+          projectId: this.projectId,
+        },
+      }).then((res) => {
+        if (res.code == 200) {
+          this.$message.success('添加成功')
+          this.refreshList({ projectId: this.projectId })
+        } else {
+          this.$message.error(res.message || '添加失败')
+        }
+      })
+    },
+    // 创建仿真任务
+    createTask() {
+      if (
+        this.baseInfo.projectName &&
+        this.baseInfo.projectMaxSeconds &&
+        this.baseInfo.projectDescription
+      ) {
+        this.$axios({
+          method: 'post',
+          url: this.$api.multimode.createMulationTask,
+          data: {
+            projectName: this.baseInfo.projectName,
+            projectMaxSeconds: this.baseInfo.projectMaxSeconds,
+            projectDescription: this.baseInfo.projectDescription,
+          },
+        }).then((res) => {
+          if (res.code == 200) {
+            this.$message.success('仿真任务创建成功')
+            this.getDataWay.param.projectId = res.info.projectId
+            this.projectId = res.info.projectId
+            this.isEdit = false
+            this.configBtnShow = true
+            this.tableShow = true
+          } else {
+            this.$message.error(res.message || '查询信息失败')
+          }
+        })
+      } else {
+        this.$message.warning('请填写完整信息后再保存')
+      }
+    },
+    cancelHandle() {
+      this.$router.back()
+    },
+    // 跳转场景评价
+    toEvaluate(row) {
       this.$router.push({
       this.$router.push({
         path: '/evaluationResults',
         path: '/evaluationResults',
+        query: { id: row.id },
+      })
+    },
+    navigatorEdit() {
+      this.$router.push({
+        name: 'multimodeSimulationEdit',
+        query: {
+          sceneId: 'b1e8fb96cf8a41d9a0364d29a9289628',
+        },
       })
       })
     },
     },
-	navigatorEdit(){
-		this.$router.push({
-			name: 'multimodeSimulationEdit',
-			query: {
-				sceneId: 'b1e8fb96cf8a41d9a0364d29a9289628'
-			}
-			
-		})
-	}
   },
   },
 }
 }
 </script>
 </script>

+ 95 - 40
src/views/multimodeSimulation/simulationHome.vue

@@ -9,7 +9,6 @@
           clearable
           clearable
           placeholder="请输入"
           placeholder="请输入"
           maxlength="60"
           maxlength="60"
-          @keyup.enter.native="doSearch"
         >
         >
         </el-input>
         </el-input>
       </template>
       </template>
@@ -21,11 +20,10 @@
           clearable
           clearable
           placeholder="请输入"
           placeholder="请输入"
           maxlength="60"
           maxlength="60"
-          @keyup.enter.native="doSearch"
         >
         >
         </el-input>
         </el-input>
       </template>
       </template>
-      <template slot="searchItem1">
+      <template slot="searchItem4">
         <span class="label">项目进度</span>
         <span class="label">项目进度</span>
         <el-select
         <el-select
           v-model="searchParams.projectStatus"
           v-model="searchParams.projectStatus"
@@ -33,9 +31,18 @@
           clearable
           clearable
           placeholder="请输入"
           placeholder="请输入"
           maxlength="60"
           maxlength="60"
-          @keyup.enter.native="doSearch"
         >
         >
-          <el-optopn></el-optopn>
+          <el-option
+            v-for="(item, idx) in [
+              { label: '未开始', value: '0' },
+              { label: '运行中', value: '1' },
+              { label: '已终止', value: '2' },
+              { label: '已完成', value: '3' },
+            ]"
+            :label="item.label"
+            :value="item.value"
+            :key="idx"
+          ></el-option>
         </el-select>
         </el-select>
       </template>
       </template>
       <template slot="searchBtn1">
       <template slot="searchBtn1">
@@ -67,16 +74,38 @@
         <template v-slot="scope">
         <template v-slot="scope">
           <!-- <span v-if="scope.row.projectStatus==1" @click="" class="elIcon"> 查看 </span> -->
           <!-- <span v-if="scope.row.projectStatus==1" @click="" class="elIcon"> 查看 </span> -->
           <span
           <span
-            v-if="scope.row.projectStatus == '1'"
-            @click="jumpDetailPage('preview')"
+            v-if="scope.row.projectStatus == '3'"
+            @click="jumpDetailPage('preview',scope.row.id)"
             class="elIcon"
             class="elIcon"
           >
           >
             查看
             查看
           </span>
           </span>
-          <span v-else @click="jumpDetailPage('edit')" class="elIcon">
+          <span
+            v-if="scope.row.projectStatus == '0'"
+            @click="jumpDetailPage('edit',scope.row.id)"
+            class="elIcon"
+          >
             编辑
             编辑
           </span>
           </span>
-          <span @click="" class="elIcon"> 删除 </span>
+          <span v-if="scope.row.projectStatus == '3'" class="elIcon">
+             下载
+          </span>
+          <span @click="deleteById(scope.row)" class="elIcon"> 删除 </span>
+          <span
+            v-if="scope.row.projectStatus == '2'"
+            @click="updateTask(scope.row)"
+            class="elIcon"
+          >
+            终止
+          </span>
+
+          <span
+            v-if="scope.row.projectStatus == '0'"
+            @click="updateTask(scope.row)"
+            class="elIcon"
+          >
+            运行
+          </span>
         </template>
         </template>
       </el-table-column>
       </el-table-column>
     </tableList>
     </tableList>
@@ -87,7 +116,7 @@ import searchLayout from '@/components/grid/searchLayout'
 import tableList from '@/components/grid/TableList'
 import tableList from '@/components/grid/TableList'
 import { mapState } from 'vuex'
 import { mapState } from 'vuex'
 export default {
 export default {
-  name: 'simulationHome', // 多模式仿真 
+  name: 'simulationHome', // 多模式仿真
   components: { searchLayout, tableList },
   components: { searchLayout, tableList },
   data() {
   data() {
     return {
     return {
@@ -134,48 +163,74 @@ export default {
       },
       },
       getDataWay: {
       getDataWay: {
         //加载表格数据
         //加载表格数据
-        dataType: 'data',
+        dataType: 'url',
         type: 'post',
         type: 'post',
-        // firstRequest: false,
-        data: [
-          {
-            id: 'd1245825a1aa5a6',
-            projectKey: '20240130-1',
-            projectName: '1007',
-            projectStatus: 0,
-            projectStatusValue: '未开始',
-            createTime: '2024-01-30 16:15:43',
-            sceneNums: 1,
-          },
-          {
-            id: 'd4582d2a6',
-            projectKey: '20240130-1',
-            projectName: '1007',
-            projectStatus: 1,
-            projectStatusValue: '已结束',
-            createTime: '2024-01-30 16:15:43',
-            sceneNums: 1,
-          },
-        ],
-        param: {
-          share: '0',
-        },
+        data: this.$api.multimode.queryMulationList,
+        param: {},
       },
       },
     }
     }
   },
   },
   methods: {
   methods: {
-    doSearch() {},
-    doReset() {},
+    refreshList(param) {
+      param
+        ? this.$refs['table'].loadData(param)
+        : this.$refs['table'].loadData()
+    },
+    doSearch() {
+      this.refreshList({ ...this.searchParams })
+    },
+    doReset() {
+      this.searchParams = {
+        projectId: '', // 项目id
+        projectName: '', // 项目名称
+        projectStatus: '', // 项目进度
+      }
+      this.refreshList()
+    },
+    // 仿真任务状态更新
+    updateTask(row) {
+      const { id, projectStatus } = row
+      this.$axios({
+        method: 'post',
+        url: this.$api.multimode.updateMulationStatus,
+        data: {
+          projectId: id,
+          projectStatus: projectStatus == 0 || 2 ? 1 : 2,
+        },
+      }).then((res) => {
+        if (res.code == 200) {
+          this.$message.success('状态更新成功')
+          this.doSearch()
+        } else {
+          this.$message.error(res.message || '更新失败')
+        }
+      })
+    },
+    // 删除仿真列表
+    deleteById(row) {
+      this.$axios({
+        method: 'post',
+        url: this.$api.multimode.deleteMulationById,
+        data: { projectId: row.id },
+      }).then((res) => {
+        if (res.code == 200) {
+          this.$message.success('删除成功')
+          this.doSearch()
+        } else {
+          this.$message.error(res.message || '删除失败')
+        }
+      })
+    },
     addConfig() {
     addConfig() {
       this.$router.push({
       this.$router.push({
         path: '/simulationEdit',
         path: '/simulationEdit',
-        query: {mode:'edit'},
+        query: { mode: 'add' },
       })
       })
     },
     },
-    jumpDetailPage(mode) {
+    jumpDetailPage(mode,id) {
       this.$router.push({
       this.$router.push({
         path: '/simulationEdit',
         path: '/simulationEdit',
-        query: {mode},
+        query: { mode,id },
       })
       })
     },
     },
   },
   },