simulationMap.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. <template>
  2. <div class="multimodeSimulation">
  3. <search-layout :needBox="true">
  4. <template slot="searchItem1">
  5. <span class="label">地图名称</span>
  6. <el-input
  7. v-model="searchParams.mapName"
  8. size="small"
  9. clearable
  10. placeholder="请输入"
  11. maxlength="60"
  12. >
  13. </el-input>
  14. </template>
  15. <template slot="searchItem1">
  16. <span class="label">地图描述</span>
  17. <el-input
  18. v-model="searchParams.mapDescription"
  19. size="small"
  20. clearable
  21. placeholder="请输入"
  22. maxlength="60"
  23. >
  24. </el-input>
  25. </template>
  26. <template slot="searchBtn1">
  27. <el-button type="primary" @click="doSearch">查询</el-button>
  28. </template>
  29. </search-layout>
  30. <div></div>
  31. <div style="display: flex; justify-content: end; margin: 20px 50px">
  32. <el-button
  33. class="addBtn"
  34. icon="el-icon-arrow-left"
  35. @click="routeBack"
  36. type="primary"
  37. >返回任务</el-button
  38. >
  39. <el-button
  40. class="addBtn"
  41. icon="el-icon-circle-plus-outline"
  42. @click="addConfig"
  43. type="primary"
  44. >新增</el-button
  45. >
  46. </div>
  47. <tableList
  48. ref="table"
  49. style="margin: 0 30px 30px"
  50. :columns="mapColumns"
  51. :getDataWay="getDataWay"
  52. :pagination="pagination"
  53. index
  54. >
  55. <el-table-column label="操作" slot="cgInfos" align="center" width="180">
  56. <template v-slot="scope">
  57. <i @click="editMapDetail(scope.row)" class="elIcon el-icon-edit-outline" title="编辑"> </i>
  58. <i @click="deleteMapById(scope.row)" class="elIcon el-icon-delete" title="删除"> </i>
  59. </template>
  60. </el-table-column>
  61. </tableList>
  62. <el-dialog
  63. :title="isEdit ? '编辑地图' : '新增地图'"
  64. :visible.sync="editVisible"
  65. width="480px"
  66. :close-on-click-modal="false"
  67. :close-on-press-escape="false"
  68. @close="closeDialog"
  69. >
  70. <el-form
  71. ref="editInfo"
  72. :model="editInfo"
  73. label-width="150px"
  74. style="display: flex; flex-wrap: wrap; justify-content: space-between"
  75. >
  76. <el-form-item label="地图名称">
  77. <el-input
  78. v-model="editInfo.mapName"
  79. placeholder="请输入"
  80. :disabled="isEdit"
  81. ></el-input>
  82. </el-form-item>
  83. <el-form-item label="轨迹数量">
  84. <el-input v-model="editInfo.pathNum" placeholder="请输入"></el-input>
  85. </el-form-item>
  86. <el-form-item label="地图描述">
  87. <el-input
  88. v-model="editInfo.mapDescription"
  89. placeholder="请输入"
  90. ></el-input>
  91. </el-form-item>
  92. <el-form-item label="OpenDrive文件" v-if="!isEdit">
  93. <el-upload
  94. :multiple="false"
  95. action=""
  96. class="upload-demo"
  97. list-type="card"
  98. :file-list="openFile"
  99. :http-request="(e) => uploadHandle('opendrive', e)"
  100. :on-remove="() => fileRemove('opendrive')"
  101. >
  102. <el-button size="small" type="primary">点击上传</el-button>
  103. </el-upload>
  104. </el-form-item>
  105. <el-form-item label="Json文件" v-if="!isEdit">
  106. <el-upload
  107. :multiple="false"
  108. action=""
  109. class="upload-demo"
  110. list-type="card"
  111. :file-list="jsonFile"
  112. :http-request="(e) => uploadHandle('json', e)"
  113. :on-remove="() => fileRemove('json')"
  114. >
  115. <el-button size="small" type="primary">点击上传</el-button>
  116. </el-upload>
  117. </el-form-item>
  118. <el-form-item label="Osgb文件" v-if="!isEdit">
  119. <el-upload
  120. :multiple="false"
  121. action=""
  122. class="upload-demo"
  123. list-type="card"
  124. :file-list="osgbFile"
  125. :http-request="(e) => uploadHandle('osgb', e)"
  126. :on-remove="() => fileRemove('osgb')"
  127. >
  128. <el-button size="small" type="primary">点击上传</el-button>
  129. </el-upload>
  130. </el-form-item>
  131. </el-form>
  132. <div style="width: 100%; display: flex; justify-content: center">
  133. <el-button @click="closeDialog">取消</el-button>
  134. <el-button @click="addMulationMap" type="primary">确认</el-button>
  135. </div>
  136. </el-dialog>
  137. </div>
  138. </template>
  139. <script>
  140. import searchLayout from '@/components/grid/searchLayout'
  141. import tableList from '@/components/grid/TableList'
  142. export default {
  143. name: 'simulationMap', // 多模式仿真地图
  144. components: { searchLayout, tableList },
  145. data() {
  146. return {
  147. searchParams: {
  148. mapName: '', // 地图名称
  149. mapDescription: '', // 地图描述
  150. },
  151. selectMapId: '', // 当前编辑地图id
  152. editVisible: false, // 地图编辑
  153. isEdit: false,
  154. openFile: [], // opendrive文件
  155. jsonFile: [], // json文件
  156. osgbFile: [], // osgb文件
  157. // 地图管理表头
  158. mapColumns: [
  159. {
  160. label: '地图名称',
  161. prop: 'mapName',
  162. },
  163. {
  164. label: '轨迹数量',
  165. prop: 'pathNum',
  166. },
  167. {
  168. label: '地图描述',
  169. prop: 'mapDescription',
  170. },
  171. {
  172. label: '创建时间',
  173. prop: 'createTime',
  174. },
  175. {
  176. label: '操作',
  177. prop: 'cgInfos',
  178. template: true,
  179. },
  180. ],
  181. editInfo: {
  182. mapName: '',
  183. mapDescription: '',
  184. pathNum: '',
  185. }, // 编辑数据
  186. pagination: {
  187. //分页使用
  188. currentPage: 1,
  189. pageSize: 10,
  190. position: 'right',
  191. pageSizes: [10, 30, 50, 100, 200],
  192. layout: 'sizes, total, prev, pager, next, jumper',
  193. },
  194. getDataWay: {
  195. //加载表格数据
  196. dataType: 'url',
  197. type: 'post',
  198. data: this.$api.multimode.queryMulationMapList,
  199. param: {},
  200. },
  201. }
  202. },
  203. methods: {
  204. refreshList(param) {
  205. param
  206. ? this.$refs['table'].loadData(param)
  207. : this.$refs['table'].loadData()
  208. },
  209. doSearch() {
  210. this.refreshList({ ...this.searchParams })
  211. },
  212. doReset() {
  213. this.searchParams = {
  214. mapName: '', // 地图名称
  215. mapDescription: '', // 地图描述
  216. }
  217. this.refreshList()
  218. },
  219. uploadHandle(type, e) {
  220. switch (type) {
  221. case 'opendrive':
  222. this.openFile = [e.file]
  223. break
  224. case 'json':
  225. this.jsonFile = [e.file]
  226. break
  227. case 'osgb':
  228. this.osgbFile = [e.file]
  229. break
  230. }
  231. },
  232. // 地图编辑
  233. editMapDetail(row) {
  234. const { id } = row
  235. this.selectMapId = id
  236. this.$axios({
  237. method: 'post',
  238. url: this.$api.multimode.queryMapDetailByID,
  239. data: {
  240. mapId: id,
  241. },
  242. }).then((res) => {
  243. if (res.code == 200) {
  244. this.editInfo = {
  245. mapName: res.info.mapName,
  246. mapDescription: res.info.mapDescription,
  247. pathNum: res.info.pathNum,
  248. }
  249. this.editVisible = true
  250. this.isEdit = true
  251. } else {
  252. this.$message.error(res.message || '查询详情信息失败')
  253. }
  254. })
  255. },
  256. fileRemove(type) {
  257. switch (type) {
  258. case 'opendrive':
  259. this.openFile = []
  260. break
  261. case 'json':
  262. this.jsonFile = []
  263. break
  264. case 'osgb':
  265. this.osgbFile = []
  266. break
  267. }
  268. },
  269. // 更新地图
  270. updateMap() {
  271. this.$axios({
  272. method: 'post',
  273. url: this.$api.multimode.updateMapDetail,
  274. data: {
  275. mapId: this.selectMapId,
  276. pathNum:this.editInfo.pathNum,
  277. mapDescription:this.editInfo.mapDescription
  278. },
  279. }).then((res) => {
  280. if(res.code ==200){
  281. this.$message.success('地图更新成功')
  282. this.editVisible = false
  283. this.refreshList({ ...this.searchParams })
  284. }else{
  285. this.$message.error(res.message || '地图更新失败')
  286. }
  287. })
  288. },
  289. deleteMapById(row){
  290. const { id } = row
  291. this.$axios({
  292. method: 'post',
  293. url: this.$api.multimode.deleteMapById,
  294. data: {
  295. mapId: id,
  296. },
  297. }).then((res) => {
  298. if(res.code ==200){
  299. this.$message.success('删除成功')
  300. this.refreshList({ ...this.searchParams })
  301. }else{
  302. this.$message.error(res.message || '删除失败')
  303. }
  304. })
  305. },
  306. addMulationMap() {
  307. if (this.isEdit) {
  308. this.updateMap()
  309. return
  310. }
  311. // addMulationMap
  312. let formData = new FormData()
  313. const json = JSON.stringify(this.editInfo)
  314. const blob = new Blob([json], {
  315. type: 'application/json',
  316. })
  317. formData.append('content', blob)
  318. formData.append('fileJson', this.jsonFile[0])
  319. formData.append('fileDriver', this.openFile[0])
  320. formData.append('fileOsgb', this.osgbFile[0])
  321. this.$axios({
  322. method: 'post',
  323. url: this.$api.multimode.addMulationMap,
  324. data: formData,
  325. withCredentials: true,
  326. headers: {
  327. 'Content-type': 'multipart/form-data',
  328. },
  329. }).then((res) => {
  330. if(res.code ==200){
  331. this.$message.success('新增成功')
  332. this.editVisible = false
  333. this.refreshList({ ...this.searchParams })
  334. }else{
  335. this.$message.error(res.message || '新增失败')
  336. }
  337. })
  338. },
  339. addConfig() {
  340. this.editVisible = true
  341. this.isEdit = false
  342. },
  343. routeBack(){
  344. this.$router.back()
  345. },
  346. closeDialog() {
  347. this.editInfo = {
  348. mapName: '',
  349. mapDescription: '',
  350. pathNum: '',
  351. }
  352. this.editVisible = false
  353. },
  354. },
  355. }
  356. </script>
  357. <style lang='less' scoped>
  358. // @import './common/util.less';
  359. .naturalDrivingScenarioListPanel {
  360. .inputBox {
  361. .label {
  362. min-width: 75px;
  363. }
  364. }
  365. .btnsPanel {
  366. text-align: right;
  367. }
  368. }
  369. </style>