simulationEdit.vue 12 KB

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