riku
2025-05-30 c2e36c45578e63ad17c5e258c92d62d9ae03dadb
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
<template>
  <el-table
    :data="sceneList"
    table-layout="fixed"
    size="small"
    height="30vh"
    :show-overflow-tooltip="true"
    border
    row-class-name="t-row"
    cell-class-name="t-cell"
    header-row-class-name="t-header-row"
    header-cell-class-name="t-header-cell"
    @row-click="handleRowClick"
    @filter-change="handleFilterChange"
  >
    <el-table-column type="index" label="#" width="25" />
    <el-table-column
      prop="type"
      label="类型"
      width="56"
      column-key="type"
      :filters="sceneTypeFilter"
      :filter-method="filterHandler"
    />
    <el-table-column prop="name" label="名称" />
    <!-- <el-table-column prop="location" label="地址" /> -->
    <el-table-column
      prop="districtName"
      label="区县"
      align="center"
      width="54"
    />
    <!-- <el-table-column label="管理" width="70" align="center">
      <template #default="{ row }">
        <el-button
          type="primary"
          size="small"
          class="el-button-custom"
          @click="deleteDevice(row)"
          >删除</el-button
        >
      </template>
    </el-table-column> -->
  </el-table>
</template>
<script setup>
import { ref, computed, watch } from 'vue';
import { sceneTypes, sceneIcon } from '@/constant/scene-types';
import MapUtil from '@/utils/map/util';
import marks from '@/utils/map/marks';
 
const props = defineProps({
  sceneList: Array
});
 
let layer = undefined;
 
let showSceneTypes = ref([]);
 
const sceneTypeFilter = computed(() => {
  return sceneTypes()
    .filter((v) => {
      return !v.disabled;
    })
    .map((v) => {
      return { text: v.label, value: v.label };
    });
});
 
const showSceneList = computed(() => {
  if (showSceneTypes.value.length == 0) {
    return props.sceneList;
  } else {
    return props.sceneList.filter((v) => {
      return showSceneTypes.value.indexOf(v.type) != -1;
    });
  }
});
 
watch(showSceneList, (nV, oV) => {
  if (nV != oV) {
    drawMarks(nV);
  }
});
 
function drawMarks(sceneList) {
  if (layer != undefined) {
    MapUtil.removeViews(layer);
    layer = undefined;
  }
  if (sceneList.length != 0) {
    const icons = [];
    sceneList.forEach((s) => {
      icons.push(sceneIcon(s.typeId));
    });
    layer = marks.createLabelMarks(icons, sceneList, false);
  }
}
 
function handleRowClick(row, col, event) {
  MapUtil.setCenter([row.longitude, row.latitude], true);
}
 
function filterHandler(value, row, column) {
  const property = column['property'];
  return row[property] === value;
}
 
function handleFilterChange(newFilters) {
  // console.log(newFilters);
  showSceneTypes.value = newFilters['type'];
}
</script>