MapUpdateView.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <div class="common-layout">
  3. <el-container>
  4. <el-header
  5. style="height: 250px; background-color: rgba(255,0,0,50%); display: flex; flex-direction: column; justify-content: center; align-items: center;">
  6. <div class="demo-image" style="text-align: center;"> <!-- 注意这里添加了 text-align: center; 但对于块级元素这不是必需的 -->
  7. <img src="../assets/pji-logo.jpg" alt="" style="width:506.5px;height: 146px">
  8. <!-- 推荐使用 max-width 保持图片比例 -->
  9. </div>
  10. </el-header>
  11. <el-main style="background-color:white;">
  12. <el-breadcrumb separator="/" style="margin-bottom: 10px;">
  13. <el-breadcrumb-item :to="{ path: '/' }">主页</el-breadcrumb-item>
  14. <el-breadcrumb-item>地图更新</el-breadcrumb-item>
  15. </el-breadcrumb>
  16. <div class="topbar">
  17. <el-button type="primary" @click="dialogVisible = true" style="float: right; margin-bottom: 20px;">将地图更新至机器人端</el-button>
  18. <el-dialog
  19. v-model="dialogVisible"
  20. title="提示"
  21. width="300"
  22. :before-close="handleClose"
  23. >
  24. <span>请确认是否进行地图更新</span>
  25. <template #footer>
  26. <div class="dialog-footer">
  27. <el-button @click="dialogVisible = false">取消</el-button>
  28. <el-button type="primary" @click="dialogVisible = false">
  29. 确认
  30. </el-button>
  31. </div>
  32. </template>
  33. </el-dialog>
  34. </div>
  35. <el-table stripe style="background-color: rgba(255,0,0,99%);width: 100%" border :data="tableData"
  36. fixed ref="multipleTableRef" :cell-style="{ textAlign: 'center'}" :header-cell-style="{ textAlign: 'center'}">
  37. <el-table-column type="selection" width="55"/>
  38. <el-table-column prop="mapId" label="地图id"/>
  39. <el-table-column prop="beforePgm" label="更新前pgm"/>
  40. <el-table-column prop="afterPgm" label="更新后pgm"/>
  41. <el-table-column prop="mapUpdateRate" label="地图更新率" :formatter="mapUpdateRateFormatter"/>
  42. </el-table>
  43. <!-- <p></p> &lt;!&ndash;空行&ndash;&gt;-->
  44. <!-- <el-pagination-->
  45. <!-- v-model:current-page="currentPage"-->
  46. <!-- v-model:page-size="pageSize"-->
  47. <!-- :page-sizes="[10]"-->
  48. <!-- :small="small"-->
  49. <!-- :disabled="disabled"-->
  50. <!-- :background="true"-->
  51. <!-- layout="total, sizes, prev, pager, next, jumper"-->
  52. <!-- :total="total"-->
  53. <!-- @size-change="handleSizeChange"-->
  54. <!-- @current-change="handleCurrentChange"-->
  55. <!-- />-->
  56. <!-- &lt;!&ndash; <el-pagination background layout="prev, pager, next" :total="1000"/>&ndash;&gt;-->
  57. </el-main>
  58. <!-- <el-footer style="background-color: rgba(255,0,0,99%)">国家智能网联汽车创新中心</el-footer>-->
  59. </el-container>
  60. </div>
  61. </template>
  62. <script lang="ts" setup>
  63. import {onBeforeMount, ref} from "vue";
  64. import axios from "axios";
  65. import {ElTable} from "element-plus";
  66. const multipleTableRef = ref<InstanceType<typeof ElTable>>
  67. const dialogVisible = ref(false)
  68. const handleClose = (done: () => void) => {
  69. done()
  70. }
  71. const mapUpdateRateFormatter = (row, column, cellValue, index) => {
  72. // 假设 1MB = 1024 * 1024 字节
  73. if (cellValue) {
  74. const percentValue = (cellValue * 100).toFixed(1); // 保留两位小数
  75. return `${percentValue}%`;
  76. }
  77. return cellValue; // 如果cellValue为null或undefined,则返回原值或你想要的默认值
  78. }
  79. let total = ref(0)
  80. let tableData = ref([{
  81. 'mapId': 1,
  82. 'beforePgm': 'url1',
  83. 'afterPgm': 'url1_1',
  84. 'mapUpdateRate': 0.201
  85. },
  86. {
  87. 'mapId': 2,
  88. 'beforePgm': 'url2',
  89. 'afterPgm': 'url2_1',
  90. 'mapUpdateRate': 0.21
  91. }
  92. ]);
  93. onBeforeMount(() => {
  94. page()
  95. })
  96. function page() {
  97. axios.get('http://1.202.169.139:8081/open/scene/list?equipmentType=YI_DAO_JI_QI_REN&page=' + currentPage.value + '&size=' + pageSize.value,
  98. {
  99. headers: {
  100. "Authorization": "4773hd92ysj54paflw2jem3onyhywxt2"
  101. }
  102. }
  103. ).then(function (response) {
  104. tableData.value = response.data.data.content
  105. total.value = response.data.data.totalElements
  106. // total.value = tableData.value.length
  107. // console.log(tableData);
  108. // console.log(response.data.data);
  109. }).catch(function (error) {
  110. console.log(error);
  111. });
  112. }
  113. const currentPage = ref(1)
  114. const pageSize = ref(10)
  115. const small = ref(false)
  116. const disabled = ref(false)
  117. const handleSizeChange = (val: number) => {
  118. pageSize.value = val
  119. page()
  120. if (tableData.value.length == 0) {
  121. page()
  122. }
  123. }
  124. const handleCurrentChange = (val: number) => {
  125. currentPage.value = val
  126. page()
  127. }
  128. const handleClick = () => {
  129. console.log('click')
  130. }
  131. </script>
  132. <style scoped>
  133. .demo-pagination-block + .demo-pagination-block {
  134. margin-top: 10px;
  135. }
  136. .demo-pagination-block .demonstration {
  137. margin-bottom: 16px;
  138. }
  139. .demo-form-inline .el-input {
  140. --el-input-width: 200px;
  141. }
  142. .demo-form-inline .el-select {
  143. --el-select-width: 400px;
  144. }
  145. .demo-image .block {
  146. padding: 30px 0;
  147. text-align: center;
  148. border-right: solid 1px var(--el-border-color);
  149. display: inline-block;
  150. width: 20%;
  151. box-sizing: border-box;
  152. vertical-align: top;
  153. }
  154. .demo-image .block:last-child {
  155. border-right: none;
  156. }
  157. .demo-image .demonstration {
  158. display: block;
  159. color: var(--el-text-color-secondary);
  160. font-size: 14px;
  161. margin-bottom: 20px;
  162. }
  163. .topbar {
  164. margin-bottom: 15px;
  165. }
  166. /* 假设 .el-pager__item 是分页按钮的类名,这可能需要你根据实际的 Element UI 版本和源码进行调整 */
  167. .el-pager__item {
  168. background-color: rgba(255, 0, 0, 50%) !important; /* 修改背景色 */
  169. color: #fff; /* 可能需要修改文本颜色以在红色背景上可见 */
  170. border-color: transparent; /* 如果需要,修改边框颜色 */
  171. }
  172. /* 修改当前选中页码的按钮样式 */
  173. .el-pager__item.is-active {
  174. background-color: rgba(255, 0, 0, 70%) !important; /* 选中时的背景色 */
  175. color: #fff; /* 选中时的文本颜色 */
  176. }
  177. </style>