simulationEvaluate.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. <template>
  2. <router-view v-if="$route.path.includes('evaluationResults')"></router-view>
  3. <div
  4. v-else
  5. style="
  6. width: 100%;
  7. display: flex;
  8. flex-direction: column;
  9. padding: 20px 50px;
  10. "
  11. >
  12. <p
  13. style="
  14. font-size: 18px;
  15. font-weight: bold;
  16. border-bottom: 1px solid #ccc;
  17. padding-bottom: 15px;
  18. "
  19. >
  20. 基础信息
  21. </p>
  22. <search-layout :needBox="true">
  23. <template slot="searchItem1">
  24. <span class="label">项目名称</span>
  25. <el-input
  26. v-model="baseInfo.projectName"
  27. size="small"
  28. clearable
  29. placeholder="请输入"
  30. maxlength="60"
  31. :disabled="!isEdit"
  32. >
  33. </el-input>
  34. </template>
  35. <template slot="searchItem3">
  36. <span class="label">最大仿真时间(s)</span>
  37. <el-input
  38. v-model="baseInfo.projectMaxSeconds"
  39. size="small"
  40. clearable
  41. placeholder="请输入"
  42. maxlength="60"
  43. :disabled="!isEdit"
  44. >
  45. </el-input>
  46. <span style="color: red" class="label">(最小是5,最大4500)</span>
  47. </template>
  48. <template slot="searchItem8">
  49. <span class="label">项目描述</span>
  50. <el-input
  51. v-model="baseInfo.projectDescription"
  52. size="small"
  53. clearable
  54. placeholder="请输入"
  55. maxlength="60"
  56. :disabled="!isEdit"
  57. >
  58. </el-input>
  59. </template>
  60. </search-layout>
  61. <p
  62. style="
  63. font-size: 18px;
  64. font-weight: bold;
  65. border-bottom: 1px solid #ccc;
  66. padding-bottom: 15px;
  67. margin-top: 30px;
  68. "
  69. >
  70. 场景详情
  71. </p>
  72. <div style="display: flex; justify-content: end; margin: 20px 50px">
  73. <el-button
  74. v-if="configBtnShow"
  75. class="addBtn"
  76. icon="el-icon-circle-plus-outline"
  77. @click="addConfig"
  78. type="primary"
  79. >添加</el-button
  80. >
  81. <el-button
  82. v-if="configBtnShow"
  83. class="addBtn"
  84. icon="el-icon-circle-plus-outline"
  85. @click="copyConfig"
  86. type="primary"
  87. >复制配置</el-button
  88. >
  89. </div>
  90. <tableList
  91. v-if="tableShow"
  92. ref="table"
  93. style="margin: 0 30px 30px"
  94. :columns="columns"
  95. :getDataWay="getDataWay"
  96. :pagination="pagination"
  97. selection
  98. index
  99. :needSelectedCallBack="true"
  100. :selectedCallBack="selectedCallBackB"
  101. :selectedAllCallBack="selectedAllCallBackB"
  102. >
  103. <el-table-column label="操作" slot="cgInfos" align="center" width="180">
  104. <template v-slot="scope">
  105. <span
  106. v-if="!isEdit && ![2, 4, 6, null].includes(scope.row.taskStatus)"
  107. @click="toEvaluate(scope.row)"
  108. class="elIcon"
  109. >
  110. 评价结果
  111. </span>
  112. <span v-else>-</span>
  113. </template>
  114. </el-table-column>
  115. </tableList>
  116. <!-- <div style="display: flex; justify-content: center; margin-top: 30px">
  117. <el-button type="primary" @click="createTask">保存</el-button>
  118. <el-button type="primary" @click="saveTask">提交</el-button>
  119. <el-button @click="cancelHandle">取消</el-button>
  120. </div> -->
  121. </div>
  122. </template>
  123. <script>
  124. import searchLayout from '@/components/grid/searchLayout'
  125. import tableList from '@/components/grid/TableList'
  126. export default {
  127. name: 'simulationEvaluate',
  128. components: { searchLayout, tableList },
  129. data() {
  130. return {
  131. isEdit: true, // 模式, 默认编辑模式 false 预览
  132. isUpdate: false, // 更新模式
  133. tableShow: false, // 是否显示表格,新增默认不显示
  134. configBtnShow: false,
  135. projectId: '', // 仿真任务id
  136. baseInfo: {
  137. projectName: '', // 项目名称
  138. projectMaxSeconds: '', // 最大仿真时间
  139. projectDescription: '', // 项目描述
  140. },
  141. selectSceneIds: [], // 选中ids
  142. columns: [
  143. {
  144. label: '地图文件',
  145. prop: 'mapName',
  146. },
  147. {
  148. label: '车辆数量',
  149. prop: 'carNums',
  150. },
  151. {
  152. label: '运行开始时间',
  153. prop: 'startTimeStr',
  154. },
  155. {
  156. label: '运行结束时间',
  157. prop: 'endTimeStr',
  158. },
  159. {
  160. label: '运行状态',
  161. prop: 'taskStatus',
  162. formatter(row) {
  163. switch (Number(row.taskStatus)) {
  164. case 2:
  165. return '手动终止'
  166. case 3:
  167. return '完成'
  168. case 4:
  169. return '自动终止'
  170. case 5:
  171. return '待分析'
  172. case 6:
  173. return 'terminated'
  174. default:
  175. return '-'
  176. }
  177. },
  178. },
  179. {
  180. label: '运行结果',
  181. prop: 'taskStatus',
  182. formatter(row) {
  183. if ([3, 5, '3', '5'].includes(row.taskStatus)) {
  184. return '成功'
  185. } else {
  186. return '-'
  187. }
  188. },
  189. },
  190. {
  191. label: '操作',
  192. prop: 'cgInfos',
  193. template: true,
  194. },
  195. ],
  196. pagination: {
  197. //分页使用
  198. currentPage: 1,
  199. pageSize: 10,
  200. position: 'right',
  201. pageSizes: [10, 30, 50, 100, 200],
  202. layout: 'sizes, total, prev, pager, next, jumper',
  203. },
  204. getDataWay: {
  205. //加载表格数据
  206. dataType: 'url',
  207. type: 'post',
  208. data: this.$api.multimode.queryMulationSceneList,
  209. param: {
  210. projectId: this.$route.query.id || '',
  211. },
  212. },
  213. }
  214. },
  215. mounted() {
  216. this.isEdit = ['edit', 'add'].includes(this.$route.query.mode)
  217. ? true
  218. : false
  219. this.isUpdate = ['edit', 'preview'].includes(this.$route.query.mode)
  220. ? true
  221. : false
  222. this.configBtnShow = this.$route.query.mode == 'edit' ? true : false
  223. if (['edit', 'preview'].includes(this.$route.query.mode)) {
  224. this.tableShow = true
  225. }
  226. if (this.$route.query.id) {
  227. this.projectId = this.$route.query.id
  228. this.getTaskDetailById(this.$route.query.id)
  229. }
  230. },
  231. methods: {
  232. // 获取任务详情信息
  233. getTaskDetailById(id) {
  234. this.$axios({
  235. method: 'post',
  236. url: this.$api.multimode.queryMulationDetailById,
  237. data: {
  238. projectId: id,
  239. },
  240. }).then((res) => {
  241. if (res.code == 200) {
  242. this.baseInfo = {
  243. projectName: res.info.projectName, // 项目名称
  244. projectMaxSeconds: res.info.projectMaxSeconds, // 最大仿真时间
  245. projectDescription: res.info.projectDescription, // 项目描述
  246. }
  247. } else {
  248. this.$message.error(res.message || '查询信息失败')
  249. }
  250. })
  251. },
  252. deleteScene(id) {
  253. this.$axios({
  254. method: 'post',
  255. url: this.$api.multimode.deleteMulationScene,
  256. data: {
  257. sceneId: id,
  258. },
  259. }).then((res) => {
  260. if (res.code == 200) {
  261. this.refreshList({ projectId: this.projectId })
  262. this.$message.success('删除成功')
  263. } else {
  264. this.$message.error(res.message || '删除失败')
  265. }
  266. })
  267. },
  268. // 提交
  269. saveTask() {
  270. this.$axios({
  271. method: 'post',
  272. url: this.$api.multimode.saveMulationTask,
  273. data: {
  274. projectId: this.projectId,
  275. projectName: this.baseInfo.projectName,
  276. projectMaxSeconds: this.baseInfo.projectMaxSeconds,
  277. projectDescription: this.baseInfo.projectDescription,
  278. },
  279. }).then((res) => {
  280. if (res.code == 200) {
  281. this.$message.success('提交成功')
  282. this.$router.push({
  283. path: '/multimodeSimulation',
  284. })
  285. } else {
  286. this.$message.error(res.message || '提交失败')
  287. }
  288. })
  289. },
  290. // 刷新场景列表
  291. refreshList(param) {
  292. param
  293. ? this.$refs['table'].loadData(param)
  294. : this.$refs['table'].loadData()
  295. },
  296. // 复制场景列表
  297. copyConfig() {
  298. if (this.selectSceneIds.length <= 0) {
  299. this.$message.warning('请选择要复制的列表')
  300. return
  301. } else {
  302. this.$axios({
  303. method: 'post',
  304. url: this.$api.multimode.copyMulationScene,
  305. data: {
  306. sceneIdList: this.selectSceneIds,
  307. },
  308. }).then((res) => {
  309. if (res.code == 200) {
  310. this.$message.success('复制成功')
  311. this.refreshList({ projectId: this.projectId })
  312. } else {
  313. this.$message.error(res.message || '复制失败')
  314. }
  315. })
  316. }
  317. },
  318. // 新增场景列表
  319. addConfig() {
  320. this.$axios({
  321. method: 'post',
  322. url: this.$api.multimode.addMulationSceneList,
  323. data: {
  324. projectId: this.projectId,
  325. },
  326. }).then((res) => {
  327. if (res.code == 200) {
  328. this.isEdit = true
  329. this.$message.success('添加成功')
  330. this.selectSceneIds = []
  331. this.refreshList({ projectId: this.projectId })
  332. } else {
  333. this.$message.error(res.message || '添加失败')
  334. }
  335. })
  336. },
  337. // 单列表选中
  338. selectedCallBackB(row, type) {
  339. // 选中
  340. if (type == 1) {
  341. const arr = this.selectSceneIds
  342. arr.push(row.id)
  343. this.selectSceneIds = arr
  344. } else {
  345. // 取消选中
  346. this.selectSceneIds = this.selectSceneIds.filter(
  347. (item) => item !== row.id
  348. )
  349. }
  350. },
  351. // 全选
  352. selectedAllCallBackB(row) {
  353. const arr = []
  354. row.forEach((item) => {
  355. arr.push(item.id)
  356. })
  357. this.selectSceneIds = arr
  358. },
  359. // 创建仿真任务
  360. createTask() {
  361. // 编辑,更新
  362. if (this.isUpdate) {
  363. this.$axios({
  364. method: 'post',
  365. url: this.$api.multimode.updateMulationSceneList,
  366. data: {
  367. projectId: this.projectId,
  368. projectName: this.baseInfo.projectName,
  369. projectMaxSeconds: this.baseInfo.projectMaxSeconds,
  370. projectDescription: this.baseInfo.projectDescription,
  371. },
  372. }).then((res) => {
  373. if (res.code == 200) {
  374. this.$message.success('仿真任务更新成功')
  375. } else {
  376. this.$message.error(res.message || '任务更新失败')
  377. }
  378. })
  379. } else {
  380. // 创建
  381. if (
  382. this.baseInfo.projectName &&
  383. this.baseInfo.projectMaxSeconds &&
  384. this.baseInfo.projectDescription
  385. ) {
  386. this.$axios({
  387. method: 'post',
  388. url: this.$api.multimode.createMulationTask,
  389. data: {
  390. projectName: this.baseInfo.projectName,
  391. projectMaxSeconds: this.baseInfo.projectMaxSeconds,
  392. projectDescription: this.baseInfo.projectDescription,
  393. },
  394. }).then((res) => {
  395. if (res.code == 200) {
  396. this.$message.success('仿真任务创建成功')
  397. this.getDataWay.param.projectId = res.info.projectId
  398. this.projectId = res.info.projectId
  399. this.isEdit = false
  400. this.configBtnShow = true
  401. this.tableShow = true
  402. this.isUpdate = true
  403. } else {
  404. this.$message.error(res.message || '查询信息失败')
  405. }
  406. })
  407. } else {
  408. this.$message.warning('请填写完整信息后再保存')
  409. }
  410. }
  411. },
  412. cancelHandle() {
  413. this.$router.back()
  414. },
  415. // 跳转场景评价
  416. toEvaluate(row) {
  417. this.$router.push({
  418. path: '/multimodeSimulation/simulationEvaluate/evaluationResults',
  419. query: { id: row.id },
  420. })
  421. },
  422. navigatorEdit(id) {
  423. this.$router.push({
  424. name: 'multimodeSimulationEdit',
  425. query: {
  426. sceneId: id,
  427. projectId: this.projectId,
  428. },
  429. })
  430. },
  431. },
  432. }
  433. </script>