riku
2024-09-11 89ab2ec7f8790c5cc184de98682af032c69c2afc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<template>
  <el-table
    :data="showTableData"
    v-loading="loading"
    table-layout="fixed"
    :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">
    </el-table-column>
    <el-table-column prop="scene.location" :show-overflow-tooltip="true" label="地址">
    </el-table-column>
    <el-table-column prop="proNum" :show-overflow-tooltip="true" label="问题" width="41">
    </el-table-column>
    <el-table-column prop="changeNum" :show-overflow-tooltip="true" label="整改" width="41">
    </el-table-column>
    <el-table-column :show-overflow-tooltip="true" label="整改率" width="54">
      <template #default="{ row }">
        {{ calPer(row.proNum, row.changeNum) }}
      </template>
    </el-table-column>
    <el-table-column prop="updateTime" :show-overflow-tooltip="true" label="时间">
      <template #default="{ row }">
        {{ $fm.formatH(row.updateTime) }}
      </template>
    </el-table-column>
  </el-table>
  <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: {
    type: Array
  },
  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) => {
    const time = value.subtask.executionendtime
      ? value.subtask.executionendtime
      : value.subtask.executionstarttime
    value.updateTime = time
    return value
  })
 
  return l.sort((a, b) => {
    if (!a.updateTime) {
      return 1
    } else if (!b.updateTime) {
      return -1
    } else {
      return dayjs(b.updateTime) - dayjs(a.updateTime)
    }
  })
  // return l
})
 
const showTableData = computed(() => {
  if (showMore.value) {
    return tableData.value
  } else {
    return tableData.value.slice(0, showCount)
  }
})
 
/**
 * 计算整改率
 * @param {Number} p 问题数
 * @param {Number} c 整改数
 */
function calPer(p, c) {
  if (p == 0) {
    return '/'
  } else {
    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()
  mapUtil.setCenter(lnglat)
  mapUtil.setZoomSmall()
 
  mapStore.focusMarker = row
}
</script>
<style scoped>
.btn-more {
  text-align: center;
}
</style>