Riku
2025-07-13 4b275f2093954cc58bbc23e4fc67e67d6fe81c0b
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<template>
  <el-table
    :data="sceneList"
    table-layout="fixed"
    size="small"
    :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 label="临近站点" width="65">
      <template #default="{ row }">
        <div>{{ row.closestStation.name }}</div>
        <div>{{ parseInt(row.length) + '米' }}</div>
      </template>
    </el-table-column>
    <slot></slot>
    <!-- <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, onUnmounted } 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,
  showMarks: {
    type: Boolean,
    default: true
  }
});
 
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;
    });
  }
});
 
onUnmounted(() => {
  removeLayer();
});
 
watch(showSceneList, (nV, oV) => {
  if (nV && props.showMarks) {
    drawMarks(nV);
  } else {
    removeLayer();
  }
});
 
watch(
  () => props.showMarks,
  (nV, oV) => {
    if (showSceneList.value && nV) {
      drawMarks(showSceneList.value);
    } else {
      removeLayer();
    }
  },
  { immediate: true }
);
 
function removeLayer() {
  if (layer != undefined) {
    MapUtil.removeViews(layer);
    layer = undefined;
  }
}
 
function drawMarks(sceneList) {
  removeLayer();
  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>