simulationEdit.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  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. selection
  96. index
  97. :needSelectedCallBack="true"
  98. :selectedCallBack="selectedCallBackB"
  99. :selectedAllCallBack="selectedAllCallBackB"
  100. >
  101. <el-table-column label="操作" slot="cgInfos" align="center" width="180">
  102. <template v-slot="scope">
  103. <span v-if="!isEdit && ![2,4,6,null].includes(scope.row.taskStatus)" @click="toEvaluate(scope.row)" class="elIcon">
  104. 评价结果
  105. </span>
  106. <span v-else>-</span>
  107. <span
  108. v-if="isEdit"
  109. @click="navigatorEdit(scope.row.id)"
  110. class="elIcon"
  111. >
  112. 编辑
  113. </span>
  114. <span v-if="isEdit" @click="deleteScene(scope.row.id)" class="elIcon">
  115. 删除
  116. </span>
  117. </template>
  118. </el-table-column>
  119. </tableList>
  120. <div style="display: flex; justify-content: center; margin-top: 30px">
  121. <el-button type="primary" @click="createTask">保存</el-button>
  122. <el-button type="primary" @click="saveTask">提交</el-button>
  123. <el-button @click="cancelHandle">取消</el-button>
  124. </div>
  125. </div>
  126. </template>
  127. <script>
  128. import searchLayout from '@/components/grid/searchLayout'
  129. import tableList from '@/components/grid/TableList'
  130. export default {
  131. name: 'simulationEdit',
  132. components: { searchLayout, tableList },
  133. data() {
  134. return {
  135. isEdit: true, // 模式, 默认编辑模式 false 预览
  136. tableShow: false, // 是否显示表格,新增默认不显示
  137. configBtnShow: false,
  138. projectId: '', // 仿真任务id
  139. baseInfo: {
  140. projectName: '', // 项目名称
  141. projectMaxSeconds: '', // 最大仿真时间
  142. projectDescription: '', // 项目描述
  143. },
  144. selectSceneIds: [], // 选中ids
  145. columns: [
  146. {
  147. label: '地图文件',
  148. prop: 'mapName',
  149. },
  150. {
  151. label: '车辆数量',
  152. prop: 'carNums',
  153. },
  154. {
  155. label: '创建时间',
  156. prop: 'createTime',
  157. },
  158. {
  159. label: '操作',
  160. prop: 'cgInfos',
  161. template: true,
  162. },
  163. ],
  164. pagination: {
  165. //分页使用
  166. currentPage: 1,
  167. pageSize: 10,
  168. position: 'right',
  169. pageSizes: [10, 30, 50, 100, 200],
  170. layout: 'sizes, total, prev, pager, next, jumper',
  171. },
  172. getDataWay: {
  173. //加载表格数据
  174. dataType: 'url',
  175. type: 'post',
  176. data: this.$api.multimode.queryMulationSceneList,
  177. param: {
  178. projectId: this.$route.query.id || '',
  179. },
  180. },
  181. }
  182. },
  183. mounted() {
  184. this.isEdit = ['edit', 'add'].includes(this.$route.query.mode)
  185. ? true
  186. : false
  187. this.configBtnShow = this.$route.query.mode == 'edit' ? true : false
  188. if (['edit', 'preview'].includes(this.$route.query.mode)) {
  189. this.tableShow = true
  190. }
  191. if (this.$route.query.id) {
  192. this.projectId = this.$route.query.id
  193. this.getTaskDetailById(this.$route.query.id)
  194. }
  195. },
  196. methods: {
  197. // 获取任务详情信息
  198. getTaskDetailById(id) {
  199. this.$axios({
  200. method: 'post',
  201. url: this.$api.multimode.queryMulationDetailById,
  202. data: {
  203. projectId: id,
  204. },
  205. }).then((res) => {
  206. if (res.code == 200) {
  207. this.baseInfo = {
  208. projectName: res.info.projectName, // 项目名称
  209. projectMaxSeconds: res.info.projectMaxSeconds, // 最大仿真时间
  210. projectDescription: res.info.projectDescription, // 项目描述
  211. }
  212. } else {
  213. this.$message.error(res.message || '查询信息失败')
  214. }
  215. })
  216. },
  217. deleteScene(id) {
  218. this.$axios({
  219. method: 'post',
  220. url: this.$api.multimode.deleteMulationScene,
  221. data: {
  222. sceneId: id,
  223. },
  224. }).then((res) => {
  225. if (res.code == 200) {
  226. this.refreshList({ projectId: this.projectId })
  227. this.$message.success('删除成功')
  228. } else {
  229. this.$message.error(res.message || '删除失败')
  230. }
  231. })
  232. },
  233. // 提交
  234. saveTask() {
  235. this.$axios({
  236. method: 'post',
  237. url: this.$api.multimode.saveMulationTask,
  238. data: {
  239. projectId: this.projectId,
  240. projectName: this.baseInfo.projectName,
  241. projectMaxSeconds: this.baseInfo.projectMaxSeconds,
  242. projectDescription: this.baseInfo.projectDescription,
  243. },
  244. }).then((res) => {
  245. if (res.code == 200) {
  246. this.$message.success('提交成功')
  247. this.$router.push({
  248. path: '/multimodeSimulation',
  249. })
  250. } else {
  251. this.$message.error(res.message || '提交失败')
  252. }
  253. })
  254. },
  255. // 刷新场景列表
  256. refreshList(param) {
  257. param
  258. ? this.$refs['table'].loadData(param)
  259. : this.$refs['table'].loadData()
  260. },
  261. // 复制场景列表
  262. copyConfig() {
  263. if (this.selectSceneIds.length <= 0) {
  264. this.$message.warning('请选择要复制的列表')
  265. return
  266. } else {
  267. this.$axios({
  268. method: 'post',
  269. url: this.$api.multimode.copyMulationScene,
  270. data: {
  271. sceneIdList: this.selectSceneIds,
  272. },
  273. }).then((res) => {
  274. if (res.code == 200) {
  275. this.$message.success('复制成功')
  276. this.refreshList({ projectId: this.projectId })
  277. } else {
  278. this.$message.error(res.message || '复制失败')
  279. }
  280. })
  281. }
  282. },
  283. // 新增场景列表
  284. addConfig() {
  285. this.$axios({
  286. method: 'post',
  287. url: this.$api.multimode.addMulationSceneList,
  288. data: {
  289. projectId: this.projectId,
  290. },
  291. }).then((res) => {
  292. if (res.code == 200) {
  293. this.isEdit = true
  294. this.$message.success('添加成功')
  295. this.selectSceneIds = []
  296. this.refreshList({ projectId: this.projectId })
  297. } else {
  298. this.$message.error(res.message || '添加失败')
  299. }
  300. })
  301. },
  302. // 单列表选中
  303. selectedCallBackB(row, type) {
  304. // 选中
  305. if (type == 1) {
  306. const arr = this.selectSceneIds
  307. arr.push(row.id)
  308. this.selectSceneIds = arr
  309. } else {
  310. // 取消选中
  311. this.selectSceneIds = this.selectSceneIds.filter(
  312. (item) => item !== row.id
  313. )
  314. }
  315. },
  316. // 全选
  317. selectedAllCallBackB(row) {
  318. const arr = []
  319. row.forEach((item) => {
  320. arr.push(item.id)
  321. })
  322. this.selectSceneIds = arr
  323. },
  324. // 创建仿真任务
  325. createTask() {
  326. if (
  327. this.baseInfo.projectName &&
  328. this.baseInfo.projectMaxSeconds &&
  329. this.baseInfo.projectDescription
  330. ) {
  331. this.$axios({
  332. method: 'post',
  333. url: this.$api.multimode.createMulationTask,
  334. data: {
  335. projectName: this.baseInfo.projectName,
  336. projectMaxSeconds: this.baseInfo.projectMaxSeconds,
  337. projectDescription: this.baseInfo.projectDescription,
  338. },
  339. }).then((res) => {
  340. if (res.code == 200) {
  341. this.$message.success('仿真任务创建成功')
  342. this.getDataWay.param.projectId = res.info.projectId
  343. this.projectId = res.info.projectId
  344. this.isEdit = false
  345. this.configBtnShow = true
  346. this.tableShow = true
  347. } else {
  348. this.$message.error(res.message || '查询信息失败')
  349. }
  350. })
  351. } else {
  352. this.$message.warning('请填写完整信息后再保存')
  353. }
  354. },
  355. cancelHandle() {
  356. this.$router.back()
  357. },
  358. // 跳转场景评价
  359. toEvaluate(row) {
  360. this.$router.push({
  361. path: '/evaluationResults',
  362. query: { id: row.id },
  363. })
  364. },
  365. navigatorEdit(id) {
  366. this.$router.push({
  367. name: 'multimodeSimulationEdit',
  368. query: {
  369. sceneId: id,
  370. },
  371. })
  372. },
  373. },
  374. }
  375. </script>