simulationEdit.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <template>
  2. <div
  3. style="
  4. width: 100%;
  5. display: flex;
  6. flex-direction: column;
  7. padding: 20px 50px;
  8. "
  9. >
  10. <p
  11. style="
  12. font-size: 18px;
  13. font-weight: bold;
  14. border-bottom: 1px solid #ccc;
  15. padding-bottom: 15px;
  16. "
  17. >
  18. 基础信息
  19. </p>
  20. <search-layout :needBox="true">
  21. <template slot="searchItem1">
  22. <span class="label">项目名称</span>
  23. <el-input
  24. v-model="baseInfo.projectName"
  25. size="small"
  26. clearable
  27. placeholder="请输入"
  28. maxlength="60"
  29. :disabled="!isEdit"
  30. >
  31. </el-input>
  32. </template>
  33. <template slot="searchItem3">
  34. <span class="label">最大仿真时间(s)</span>
  35. <el-input
  36. v-model="baseInfo.projectMaxSeconds"
  37. size="small"
  38. clearable
  39. placeholder="请输入"
  40. maxlength="60"
  41. :disabled="!isEdit"
  42. >
  43. </el-input>
  44. <span style="color: red" class="label">(最小是5,最大4500)</span>
  45. </template>
  46. <template slot="searchItem8">
  47. <span class="label">项目描述</span>
  48. <el-input
  49. v-model="baseInfo.projectDescription"
  50. size="small"
  51. clearable
  52. placeholder="请输入"
  53. maxlength="60"
  54. :disabled="!isEdit"
  55. >
  56. </el-input>
  57. </template>
  58. </search-layout>
  59. <p
  60. style="
  61. font-size: 18px;
  62. font-weight: bold;
  63. border-bottom: 1px solid #ccc;
  64. padding-bottom: 15px;
  65. margin-top: 30px;
  66. "
  67. >
  68. 场景详情
  69. </p>
  70. <div style="display: flex; justify-content: end; margin: 20px 50px">
  71. <el-button
  72. v-if="configBtnShow"
  73. class="addBtn"
  74. icon="el-icon-circle-plus-outline"
  75. @click="addConfig"
  76. type="primary"
  77. >添加</el-button
  78. >
  79. <el-button
  80. v-if="configBtnShow"
  81. class="addBtn"
  82. icon="el-icon-circle-plus-outline"
  83. @click="copyConfig"
  84. type="primary"
  85. >复制配置</el-button
  86. >
  87. </div>
  88. <tableList
  89. v-if="tableShow"
  90. ref="table"
  91. style="margin: 0 30px 30px"
  92. :columns="columns"
  93. :getDataWay="getDataWay"
  94. :pagination="pagination"
  95. index
  96. >
  97. <el-table-column label="操作" slot="cgInfos" align="center" width="180">
  98. <template v-slot="scope">
  99. <span v-if="!isEdit" @click="toEvaluate(scope.row)" class="elIcon">
  100. 评价结果
  101. </span>
  102. <span v-if="isEdit" @click="navigatorEdit" class="elIcon">
  103. 编辑
  104. </span>
  105. <span v-if="isEdit" @click="deleteScene(scope.row.id)" class="elIcon">
  106. 删除
  107. </span>
  108. </template>
  109. </el-table-column>
  110. </tableList>
  111. <div style="display: flex; justify-content: center; margin-top: 30px">
  112. <el-button type="primary" @click="createTask">保存</el-button>
  113. <el-button type="primary" @click="saveTask">提交</el-button>
  114. <el-button @click="cancelHandle">取消</el-button>
  115. </div>
  116. </div>
  117. </template>
  118. <script>
  119. import searchLayout from '@/components/grid/searchLayout'
  120. import tableList from '@/components/grid/TableList'
  121. export default {
  122. name: 'simulationEdit',
  123. components: { searchLayout, tableList },
  124. data() {
  125. return {
  126. isEdit: true, // 模式, 默认编辑模式 false 预览
  127. tableShow: false, // 是否显示表格,新增默认不显示
  128. configBtnShow: false,
  129. projectId: '', // 仿真任务id
  130. baseInfo: {
  131. projectName: '', // 项目名称
  132. projectMaxSeconds: '', // 最大仿真时间
  133. projectDescription: '', // 项目描述
  134. },
  135. columns: [
  136. {
  137. label: '地图文件',
  138. prop: 'mapName',
  139. },
  140. {
  141. label: '车辆数量',
  142. prop: 'carNums',
  143. },
  144. {
  145. label: '创建时间',
  146. prop: 'createTime',
  147. },
  148. {
  149. label: '操作',
  150. prop: 'cgInfos',
  151. template: true,
  152. },
  153. ],
  154. pagination: {
  155. //分页使用
  156. currentPage: 1,
  157. pageSize: 10,
  158. position: 'right',
  159. pageSizes: [10, 30, 50, 100, 200],
  160. layout: 'sizes, total, prev, pager, next, jumper',
  161. },
  162. getDataWay: {
  163. //加载表格数据
  164. dataType: 'url',
  165. type: 'post',
  166. data: this.$api.multimode.queryMulationSceneList,
  167. param: {
  168. projectId: this.$route.query.id || '',
  169. },
  170. },
  171. }
  172. },
  173. mounted() {
  174. this.isEdit = ['edit', 'add'].includes(this.$route.query.mode)
  175. ? true
  176. : false
  177. this.configBtnShow = this.$route.query.mode == 'edit' ? true : false
  178. if (['edit', 'preview'].includes(this.$route.query.mode)) {
  179. this.tableShow = true
  180. }
  181. if (this.$route.query.id) {
  182. this.projectId = this.$route.query.id
  183. this.getTaskDetailById(this.$route.query.id)
  184. }
  185. },
  186. methods: {
  187. // 获取任务详情信息
  188. getTaskDetailById(id) {
  189. this.$axios({
  190. method: 'post',
  191. url: this.$api.multimode.queryMulationDetailById,
  192. data: {
  193. projectId: id,
  194. },
  195. }).then((res) => {
  196. if (res.code == 200) {
  197. this.baseInfo = {
  198. projectName: res.info.projectName, // 项目名称
  199. projectMaxSeconds: res.info.projectMaxSeconds, // 最大仿真时间
  200. projectDescription: res.info.projectDescription, // 项目描述
  201. }
  202. } else {
  203. this.$message.error(res.message || '查询信息失败')
  204. }
  205. })
  206. },
  207. deleteScene(id) {
  208. this.$axios({
  209. method: 'post',
  210. url: this.$api.multimode.deleteMulationScene,
  211. data: {
  212. sceneId: id,
  213. },
  214. }).then((res) => {
  215. if (res.code == 200) {
  216. this.refreshList({ projectId: this.projectId })
  217. this.$message.success('删除成功')
  218. } else {
  219. this.$message.error(res.message || '删除失败')
  220. }
  221. })
  222. },
  223. // 提交
  224. saveTask() {
  225. this.$axios({
  226. method: 'post',
  227. url: this.$api.multimode.saveMulationTask,
  228. data: {
  229. projectId: this.projectId,
  230. projectName: this.baseInfo.projectName,
  231. projectMaxSeconds: this.baseInfo.projectMaxSeconds,
  232. projectDescription: this.baseInfo.projectDescription,
  233. },
  234. }).then((res) => {
  235. if (res.code == 200) {
  236. this.$message.success('提交成功')
  237. this.$router.push({
  238. path:'/multimodeSimulation'
  239. })
  240. } else {
  241. this.$message.error(res.message || '提交失败')
  242. }
  243. })
  244. },
  245. // 刷新场景列表
  246. refreshList(param) {
  247. param
  248. ? this.$refs['table'].loadData(param)
  249. : this.$refs['table'].loadData()
  250. },
  251. copyConfig() {},
  252. // 新增场景列表
  253. addConfig() {
  254. this.$axios({
  255. method: 'post',
  256. url: this.$api.multimode.addMulationSceneList,
  257. data: {
  258. projectId: this.projectId,
  259. },
  260. }).then((res) => {
  261. if (res.code == 200) {
  262. this.$message.success('添加成功')
  263. this.refreshList({ projectId: this.projectId })
  264. } else {
  265. this.$message.error(res.message || '添加失败')
  266. }
  267. })
  268. },
  269. // 创建仿真任务
  270. createTask() {
  271. if (
  272. this.baseInfo.projectName &&
  273. this.baseInfo.projectMaxSeconds &&
  274. this.baseInfo.projectDescription
  275. ) {
  276. this.$axios({
  277. method: 'post',
  278. url: this.$api.multimode.createMulationTask,
  279. data: {
  280. projectName: this.baseInfo.projectName,
  281. projectMaxSeconds: this.baseInfo.projectMaxSeconds,
  282. projectDescription: this.baseInfo.projectDescription,
  283. },
  284. }).then((res) => {
  285. if (res.code == 200) {
  286. this.$message.success('仿真任务创建成功')
  287. this.getDataWay.param.projectId = res.info.projectId
  288. this.projectId = res.info.projectId
  289. this.isEdit = false
  290. this.configBtnShow = true
  291. this.tableShow = true
  292. } else {
  293. this.$message.error(res.message || '查询信息失败')
  294. }
  295. })
  296. } else {
  297. this.$message.warning('请填写完整信息后再保存')
  298. }
  299. },
  300. cancelHandle() {
  301. this.$router.back()
  302. },
  303. // 跳转场景评价
  304. toEvaluate(row) {
  305. this.$router.push({
  306. path: '/evaluationResults',
  307. query: { id: row.id },
  308. })
  309. },
  310. navigatorEdit() {
  311. this.$router.push({
  312. name: 'multimodeSimulationEdit',
  313. query: {
  314. sceneId: 'b1e8fb96cf8a41d9a0364d29a9289628',
  315. },
  316. })
  317. },
  318. },
  319. }
  320. </script>