From 505798927f75c84693cc51becf16aa525503fc92 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期四, 11 七月 2024 17:23:38 +0800
Subject: [PATCH] 2024.7.11

---
 src/views/inspection/problem/component/ProblemTable.vue |   42 +++++++++++++++++++++++++++++++++++++-----
 1 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/src/views/inspection/problem/component/ProblemTable.vue b/src/views/inspection/problem/component/ProblemTable.vue
index 50c65e2..7c8753c 100644
--- a/src/views/inspection/problem/component/ProblemTable.vue
+++ b/src/views/inspection/problem/component/ProblemTable.vue
@@ -6,6 +6,7 @@
     :row-class-name="tableRowClassName"
     :height="tableHeight"
     size="small"
+    @row-click="handleRowClick"
   >
     <el-table-column type="index" label="" width="30"> </el-table-column>
     <el-table-column prop="scene.name" :show-overflow-tooltip="true" label="鍚嶇О" width="150">
@@ -27,13 +28,22 @@
       </template>
     </el-table-column>
   </el-table>
-  <div class="btn-more font-small">
-    <el-link type="primary" @click="showMore = !showMore">鏌ョ湅鏇村</el-link>
+  <div v-if="showMoreBtn" class="btn-more font-small">
+    <el-link type="primary" @click="showMore = !showMore">
+      {{ showMore ? '鏀惰捣鏇村' : '鏌ョ湅鏇村' }}
+    </el-link>
   </div>
 </template>
 <script setup>
 import { computed, ref } from 'vue'
 import dayjs from 'dayjs'
+import { useMapStore } from '@/stores/map.js'
+
+import marks from '@/utils/map/marks.js'
+import mapUtil from '@/utils/map/util.js'
+import scene_1 from '@/assets/icon/scene_1.png'
+
+const mapStore = useMapStore()
 
 const props = defineProps({
   data: {
@@ -42,7 +52,12 @@
   loading: Boolean
 })
 
+const showCount = 3
+
 const showMore = ref(false)
+const showMoreBtn = computed(() => {
+  return props.data.length > showCount
+})
 
 const tableData = computed(() => {
   const l = props.data.map((value) => {
@@ -54,7 +69,13 @@
   })
 
   return l.sort((a, b) => {
-    return dayjs(b.updateTime) - dayjs(a.updateTime)
+    if (!a.updateTime) {
+      return 1
+    } else if (!b.updateTime) {
+      return -1
+    } else {
+      return dayjs(b.updateTime) - dayjs(a.updateTime)
+    }
   })
   // return l
 })
@@ -63,7 +84,7 @@
   if (showMore.value) {
     return tableData.value
   } else {
-    return tableData.value.slice(0, 3)
+    return tableData.value.slice(0, showCount)
   }
 })
 
@@ -76,9 +97,20 @@
   if (p == 0) {
     return '/'
   } else {
-    return Math.round((c / p) * 100) / 100 + '%'
+    return Math.round((c / p) * 100) + '%'
   }
 }
+
+function handleRowClick(row, col, event) {
+  const title = row.scene.name
+  const lnglat = [row.scene.longitude, row.scene.latitude]
+  const img = scene_1
+  mapUtil.clearViews()
+  marks.drawMarker(title, lnglat, img)
+  mapUtil.setFitView()
+
+  mapStore.focusMarker = row
+}
 </script>
 <style scoped>
 .btn-more {

--
Gitblit v1.9.3