ReportView.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  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="max-width: 100%; height: auto;">
  8. <!-- 推荐使用 max-width 保持图片比例 -->
  9. </div>
  10. </el-header>
  11. <el-main style="background-color:white;">
  12. <div class="topbar">
  13. <el-form style=" background-color: rgba(0,0,0,0%);" :inline="true" :model="queryLine"
  14. class="demo-form-inline">
  15. <el-form-item label="数据名称">
  16. <el-input v-model="queryLine.dataName" placeholder="请输入数据名称" clearable/>
  17. </el-form-item>
  18. <!-- <el-form-item label="数据标签">-->
  19. <!-- <el-input v-model="queryLine.teamName" placeholder="请输入数据标签" clearable/>-->
  20. <!-- </el-form-item>-->
  21. <el-form-item label="设备名称">
  22. <el-input v-model="queryLine.equipmentName" placeholder="请输入设备名称" clearable/>
  23. </el-form-item>
  24. <el-form-item label="设备类型">
  25. <el-input v-model="queryLine.equipmentTypeName" placeholder="请输入设备类型" clearable/>
  26. </el-form-item>
  27. <el-form-item label="触发器名称">
  28. <el-input v-model="queryLine.triggerName" placeholder="请输入触发器名称" clearable/>
  29. </el-form-item>
  30. <el-form-item label="触发器类型">
  31. <el-input v-model="queryLine.triggerTypeName" placeholder="请输入触发器类型" clearable/>
  32. </el-form-item>
  33. <el-form-item>
  34. <el-button type="danger" @click="onSubmit">查询</el-button>
  35. </el-form-item>
  36. <el-form-item>
  37. <el-button type="danger" @click="onSubmit">重置</el-button>
  38. </el-form-item>
  39. </el-form>
  40. <el-button type="primary" @click="updateMap">地图更新</el-button>
  41. <el-button type="primary" @click="goToUpdateStat">地图更新统计</el-button>
  42. <el-button type="primary" @click="mapDialogVisible = true">地图续扫提醒阈值</el-button>
  43. <el-button type="primary" @click="goToMapRescan">地图续扫提醒</el-button>
  44. <el-dialog
  45. v-model="updateDialogVisible"
  46. title="地图更新"
  47. width="400"
  48. :before-close="handleClose"
  49. >
  50. <el-steps style="max-width: 600px" :active="active" finish-status="success">
  51. <el-step title="数据格式检查"/>
  52. <el-step title="地图生成"/>
  53. </el-steps>
  54. <template #footer>
  55. <el-button @click="goToMapUpdate" :disabled="active !== 2">去部署</el-button>
  56. </template>
  57. </el-dialog>
  58. <el-dialog
  59. v-model="mapDialogVisible"
  60. title="地图续扫提醒"
  61. width="400"
  62. :before-close="handleClose"
  63. >
  64. <el-form :model="mapRescanForm">
  65. <el-form-item label="请输入地图续扫提醒阈值" label-width="170">
  66. <el-input v-model="mapRescanForm.name">
  67. <template #suffix>
  68. <i slot="suffix" style="color: #181818">%</i>
  69. </template>
  70. </el-input>
  71. </el-form-item>
  72. </el-form>
  73. <template #footer>
  74. <div class="dialog-footer">
  75. <el-button type="primary" @click="mapDialogVisible = false">
  76. 确认
  77. </el-button>
  78. </div>
  79. </template>
  80. </el-dialog>
  81. <div style="float: right">
  82. <el-switch
  83. style="margin-left: 10px;"
  84. v-model="value"
  85. size="large"
  86. inactive-text="算法容器"
  87. />
  88. <el-button type="primary" @click="algorithmDialogVisible = true" style="margin-left: 10px;">算法镜像导入</el-button>
  89. <el-dialog
  90. v-model="algorithmDialogVisible"
  91. title="请输入算法版本"
  92. width="300"
  93. :before-close="handleClose"
  94. >
  95. <template #footer>
  96. <div class="dialog-footer">
  97. <el-form :model="algorithmForm" label-width="auto">
  98. <el-form-item style="margin-bottom: 10px" label="sudo密码:">
  99. <el-input v-model="algorithmForm.sudoPassword"/>
  100. </el-form-item>
  101. <el-form-item style="margin-bottom: 10px" label="算法版本:">
  102. <el-input v-model="algorithmForm.tag"/>
  103. </el-form-item>
  104. </el-form>
  105. <!-- -->
  106. <!-- <el-button @click="algorithmDialogVisible = false">取消</el-button>-->
  107. <el-button type="primary" @click="algorithmImport">选择镜像文件</el-button>
  108. </div>
  109. </template>
  110. </el-dialog>
  111. <el-button style="margin-left: 10px;" type="primary" @click="algorithmImport">算法镜像选择</el-button>
  112. <!-- <el-switch-->
  113. <!-- v-model="algorithmContainerState"-->
  114. <!-- class="ml-2"-->
  115. <!-- inline-prompt-->
  116. <!-- style="margin-left: 100px;&#45;&#45;el-switch-on-color: #13ce66; &#45;&#45;el-switch-off-color: #ff4949"-->
  117. <!-- active-text="算法容器已开启"-->
  118. <!-- inactive-text="算法容器已关闭"-->
  119. <!-- />-->
  120. <!-- <el-switch-->
  121. <!-- v-model="gazeboState"-->
  122. <!-- class="ml-2"-->
  123. <!-- inline-prompt-->
  124. <!-- style="margin-left: 100px; &#45;&#45;el-switch-on-color: #13ce66; &#45;&#45;el-switch-off-color: #ff4949"-->
  125. <!-- active-text="Gazebo 已开启"-->
  126. <!-- inactive-text="Gazebo 已关闭"-->
  127. <!-- @click="gazebo"-->
  128. <!-- />-->
  129. <!-- <el-switch-->
  130. <!-- v-model="rvizState"-->
  131. <!-- class="ml-2"-->
  132. <!-- inline-prompt-->
  133. <!-- style="margin-left: 100px;&#45;&#45;el-switch-on-color: #13ce66; &#45;&#45;el-switch-off-color: #ff4949"-->
  134. <!-- active-text="Rviz 已开启"-->
  135. <!-- inactive-text="Rviz 已关闭"-->
  136. <!-- @click="rviz"-->
  137. <!-- />-->
  138. <el-button style="margin-left: 10px;" type="primary" @click="goToTestRecord">仿真测试记录</el-button>
  139. </div>
  140. </div>
  141. <el-table stripe style="background-color: rgba(255,0,0,99%);width: 100%" border :data="tableData"
  142. fixed ref="multipleTableRef" @selection-change="handleSelectionChange" :cell-style="{ textAlign: 'center'}" :header-cell-style="{ textAlign: 'center'}">
  143. <el-table-column type="selection" width="55"/>
  144. <el-table-column prop="dataName" label="数据名称"/>
  145. <el-table-column prop="dataSize" label="数据容量" :formatter="dataSizeFormatter"/>
  146. <el-table-column prop="equipmentName" label="设备名称"/>
  147. <el-table-column prop="equipmentTypeName" label="设备类型"/>
  148. <el-table-column prop="triggerName" label="触发器名称"/>
  149. <el-table-column prop="triggerTypeName" label="触发器类型"/>
  150. <el-table-column prop="callbackTime" label="上报时间"/>
  151. <el-table-column prop="dataStateName" label="数据状态"/>
  152. <el-table-column width="300" fixed="right" label="操作">
  153. <el-button size="small" type="danger" @click="goToDetail">生成world</el-button>
  154. <el-button size="small" type="danger" @click="goToDetail">仿真测试</el-button>
  155. <!-- <el-button size="small" type="danger" @click="goToDetail">算法评价</el-button>-->
  156. </el-table-column>
  157. </el-table>
  158. <p></p> <!--空行-->
  159. <el-pagination
  160. v-model:current-page="currentPage"
  161. v-model:page-size="pageSize"
  162. :page-sizes="[10]"
  163. :small="small"
  164. :disabled="disabled"
  165. :background="true"
  166. layout="total, sizes, prev, pager, next, jumper"
  167. :total="total"
  168. @size-change="handleSizeChange"
  169. @current-change="handleCurrentChange"
  170. />
  171. <!-- <el-pagination background layout="prev, pager, next" :total="1000"/>-->
  172. </el-main>
  173. <!-- <el-footer style="background-color: rgba(255,0,0,99%)">国家智能网联汽车创新中心</el-footer>-->
  174. </el-container>
  175. </div>
  176. </template>
  177. <script lang="ts" setup>
  178. import {onBeforeMount, ref} from "vue";
  179. import axios from "axios";
  180. import {reactive} from 'vue'
  181. import {ElTable} from "element-plus";
  182. import { ElMessage } from "element-plus";
  183. import {useRouter} from 'vue-router'; // 导入 Vue Router 的 useRouter 钩子
  184. const value
  185. = ref(true)
  186. const active = ref(0)
  187. const router = useRouter();
  188. const algorithmContainerState = ref(false)
  189. const gazeboState = ref(false)
  190. const rvizState = ref(false)
  191. const multipleTableRef = ref<InstanceType<typeof ElTable>>
  192. const algorithmDialogVisible = ref(false)
  193. const mapDialogVisible = ref(false)
  194. const updateDialogVisible = ref(false)
  195. const handleClose = (done: () => void) => {
  196. done()
  197. }
  198. const multipleSelection = ref<[]>([])
  199. // do not use same name with ref
  200. const algorithmForm = reactive({
  201. sudoPassword: '',
  202. tag: '',
  203. // date1: '',
  204. // date2: '',
  205. // delivery: false,
  206. // type: [],
  207. // resource: '',
  208. // desc: '',
  209. })
  210. const mapRescanForm = reactive({
  211. name: ''
  212. })
  213. const currentTag = ref('')
  214. const algorithmImport = async () => {
  215. algorithmDialogVisible.value = false
  216. try {
  217. const result = await window.electronAPI.openFileManager();
  218. console.log('用户选择的文件路径为:', result, ',版本为:', algorithmForm.tag);
  219. window.electronAPI.dockerImport(algorithmForm.sudoPassword, result, algorithmForm.tag)
  220. } catch (error) {
  221. console.error('打开文件管理器时出错:', error);
  222. }
  223. };
  224. const goToDetail = () => {
  225. router.push('/about')
  226. }
  227. const goToMapUpdate = () => {
  228. router.push('/map_update')
  229. }
  230. const goToUpdateStat = () => {
  231. router.push('/update_stat')
  232. }
  233. const goToMapRescan = () => {
  234. router.push('/map_rescan')
  235. }
  236. const goToTestRecord = () => {
  237. router.push('/test_record')
  238. }
  239. // 数据容量单位从B转成MB
  240. const dataSizeFormatter = (row, column, cellValue, index) => {
  241. // 假设 1MB = 1024 * 1024 字节
  242. if (cellValue) {
  243. const mb = (cellValue / (1024 * 1024)).toFixed(2); // 保留两位小数
  244. return `${mb}MB`;
  245. }
  246. return cellValue; // 如果cellValue为null或undefined,则返回原值或你想要的默认值
  247. }
  248. const isPropertySame= (array, propertyName) => {
  249. if (array.length <= 1) {
  250. return true; // 空数组或但个元素视为所有值相同
  251. }
  252. const firstValue = array[0][propertyName];
  253. for (let i = 1; i < array.length; i++) {
  254. if (array[i][propertyName] !== firstValue) {
  255. return false; // 发现不同的值
  256. }
  257. }
  258. return true; // 所有值都是相同的
  259. }
  260. const updateMap = () => {
  261. if (multipleSelection.value.length == 0) {
  262. ElMessage.error("请选择记录!");
  263. return;
  264. }
  265. const isEquipmentSame = isPropertySame(multipleSelection.value, "equipmentId")
  266. if (!isEquipmentSame) {
  267. ElMessage.error("所选择的记录属于多个设备,请进行检查!");
  268. return;
  269. } else {
  270. updateDialogVisible.value = true;
  271. console.log(JSON.stringify(multipleSelection.value))
  272. }
  273. }
  274. const handleSelectionChange = (rows: []) => {
  275. multipleSelection.value = rows
  276. const isEquipmentSame = isPropertySame(rows, "equipmentId")
  277. if (!isEquipmentSame) {
  278. ElMessage.error("所选择的记录属于多个设备,请进行检查!");
  279. } else {
  280. console.log(JSON.stringify(multipleSelection.value))
  281. }
  282. }
  283. const gazebo = () => {
  284. if (gazeboState.value) {
  285. if (window.electronAPI) {
  286. window.electronAPI.openGazebo(); // 关闭 gazebo
  287. } else {
  288. console.error('electronAPI is not defined');
  289. }
  290. // gazeboState.value = false
  291. } else {
  292. if (window.electronAPI) {
  293. window.electronAPI.closeGazebo();
  294. } else {
  295. console.error('electronAPI is not defined');
  296. }
  297. // gazeboState.value = true
  298. }
  299. }
  300. const rviz = () => {
  301. if (rvizState.value) {
  302. if (window.electronAPI) {
  303. window.electronAPI.openRviz();
  304. } else {
  305. console.error('electronAPI is not defined');
  306. }
  307. } else {
  308. if (window.electronAPI) {
  309. window.electronAPI.closeRviz();
  310. } else {
  311. console.error('electronAPI is not defined');
  312. }
  313. }
  314. }
  315. const queryLine = reactive({
  316. dataName: '',
  317. equipmentName: '',
  318. equipmentTypeName: '',
  319. triggerName: '',
  320. triggerTypeName: '',
  321. })
  322. const onSubmit = () => {
  323. page()
  324. }
  325. let total = ref(0)
  326. let tableData = ref([]);
  327. onBeforeMount(() => {
  328. page()
  329. })
  330. function page() {
  331. axios.get('http://36.110.106.156:11121/open/scene/list?equipmentType=YI_DAO_JI_QI_REN&page=' + currentPage.value + '&size=' + pageSize.value,
  332. {
  333. headers: {
  334. "Authorization": "4773hd92ysj54paflw2jem3onyhywxt2"
  335. }
  336. }
  337. ).then(function (response) {
  338. tableData.value = response.data.data.content
  339. total.value = response.data.data.totalElements
  340. // total.value = tableData.value.length
  341. // console.log(tableData);
  342. // console.log(response.data.data);
  343. }).catch(function (error) {
  344. console.log(error);
  345. });
  346. }
  347. const currentPage = ref(1)
  348. const pageSize = ref(10)
  349. const small = ref(false)
  350. const disabled = ref(false)
  351. const handleSizeChange = (val: number) => {
  352. pageSize.value = val
  353. page()
  354. if (tableData.value.length == 0) {
  355. page()
  356. }
  357. }
  358. const handleCurrentChange = (val: number) => {
  359. currentPage.value = val
  360. page()
  361. }
  362. const handleClick = () => {
  363. console.log('click')
  364. }
  365. </script>
  366. <style scoped>
  367. .demo-pagination-block + .demo-pagination-block {
  368. margin-top: 10px;
  369. }
  370. .demo-pagination-block .demonstration {
  371. margin-bottom: 16px;
  372. }
  373. .demo-form-inline .el-input {
  374. --el-input-width: 200px;
  375. }
  376. .demo-form-inline .el-select {
  377. --el-select-width: 400px;
  378. }
  379. .demo-image .block {
  380. padding: 30px 0;
  381. text-align: center;
  382. border-right: solid 1px var(--el-border-color);
  383. display: inline-block;
  384. width: 20%;
  385. box-sizing: border-box;
  386. vertical-align: top;
  387. }
  388. .demo-image .block:last-child {
  389. border-right: none;
  390. }
  391. .demo-image .demonstration {
  392. display: block;
  393. color: var(--el-text-color-secondary);
  394. font-size: 14px;
  395. margin-bottom: 20px;
  396. }
  397. .topbar {
  398. margin-bottom: 15px;
  399. }
  400. /* 假设 .el-pager__item 是分页按钮的类名,这可能需要你根据实际的 Element UI 版本和源码进行调整 */
  401. .el-pager__item {
  402. background-color: rgba(255, 0, 0, 50%) !important; /* 修改背景色 */
  403. color: #fff; /* 可能需要修改文本颜色以在红色背景上可见 */
  404. border-color: transparent; /* 如果需要,修改边框颜色 */
  405. }
  406. /* 修改当前选中页码的按钮样式 */
  407. .el-pager__item.is-active {
  408. background-color: rgba(255, 0, 0, 70%) !important; /* 选中时的背景色 */
  409. color: #fff; /* 选中时的文本颜色 */
  410. }
  411. </style>