wujingjing
2025-02-07 4c20089472b20319746649decbce3a11f16cb6a0
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<template>
    <div class="property-panel">
        <div class="w-[370px] bg-white p-3 rounded">
            <div class="header flex-items-center pb-1.5" style="border-bottom: 1px solid black">
                <div class="flex-items-center">
                    <span class="ywifont ywicon-guanbi cursor-pointer mr-1.5" @click="closeClick"></span>
                    <span class="text-lg font-bold">{{ propertyTitle }}</span>
                </div>
            </div>
            <div class="content rounded-lg max-h-[700px] overflow-y-auto">
                <el-collapse v-model="activeNames" @change="handleChange" class="mt-2 h-full">
                    <el-collapse-item v-for="group in propertyGroupList" :key="group.type" :title="group.title" :name="group.type" class="">
                        <el-table
                            class="collapse-table"
                            :data="group.prop_list"
                            style="width: 100%"
                            :showHeader="false"
                            border
                            cellClassName="over-ellipsis"
                        >
                            <el-table-column prop="date" label="Date" min-width="40%" show-overflow-tooltip>
                                <template #default="scope">
                                    {{ scope.row.info.title }}
                                </template>
                            </el-table-column>
                            <el-table-column prop="name" label="Name">
                                <template #default="scope">
                                    <div class="flex-items-center">
                                        <el-tooltip :disabled="disableTooltip" effect="dark" :content="scope.row.info.value" placement="top-start">
                                            <span class="over-ellipsis mr-2" @mouseover="textMouseOver($event)"> {{ scope.row.info.value }}</span>
                                        </el-tooltip>
 
                                        <!-- <span class="ywifont ywicon ywicon-tubiao-zhexiantu text-blue-400 ml-auto mr-2 cursor-pointer"></span> -->
                                    </div>
                                </template>
                            </el-table-column>
                        </el-table>
                    </el-collapse-item>
                </el-collapse>
            </div>
        </div>
    </div>
</template>
 
<script setup lang="ts" name="PropertyPanel">
import type { Feature } from 'ol';
import { ref } from 'vue';
import { useTextOverflow } from '/@/hooks/useOverflow';
import { formatDate } from '/@/utils/formatTime';
import { getMapValuesByPost } from '/@/api/map';
const props = defineProps(['propertyMap', 'propertyConfigMap']);
const emit = defineEmits(['close']);
const activeNames = ref(['1']);
const { disableTooltip, textMouseOver } = useTextOverflow();
 
const handleChange = (val) => {};
const closeClick = () => {
    emit('close');
};
0;
const propertyTitle = ref('无选中对象');
const propertyGroupList = ref<any[]>([]);
 
const getVpropValues = async (config) => {
    const { otype, oname, vprops } = config;
    const time = formatDate(new Date());
    if (!otype || !oname || !vprops) return;
    const res = await getMapValuesByPost({
        otype,
        oname,
        vprops,
        time,
    });
    const valueMap = res?.values ?? {};
    for (const group of propertyGroupList.value) {
        for (const item of group.prop_list ?? []) {
            if (item.info.hasOwnProperty('value') && item.vprop !== 'ONAME') {
                item.info.value = valueMap[item.vprop];
            }
        }
    }
};
const featureClick = (feature: Feature) => {
    const otype = feature.get('otype');
    const oname = feature.get('oname');
    console.log("🚀 ~ feature:", feature)
    if (!otype) return;
    const otypeProperty = props.propertyMap?.[otype] ?? {};
    propertyTitle.value = otypeProperty.title;
    const vpropsMap = otypeProperty.vprops ?? {};
    const config = props.propertyConfigMap?.[otype] ?? {};
    const specialList = ['ONAME', 'OTYPE'];
 
    const vpropsList: any[] = [];
    propertyGroupList.value = (config?.['sections']?.['WebGIS'] ?? []).map((group) => {
        group.prop_list = (group?.prop_list ?? [])
            ?.filter((item) => !['OTYPE'].includes(item.vprop))
            .map((item) => {
                let info = {};
                if (item.vprop === 'ONAME') {
                    info = {
                        title: 'ONAME',
                        unit: null,
                        value: oname,
                    };
                } else {
                    info = vpropsMap[item.vprop] ?? {};
                    vpropsList.push(item.vprop);
                    info = {
                        ...info,
                        value:null
                    }
                }
                return {
                    ...item,
                    info
                };
            });
        return group;
    });
    activeNames.value = [propertyGroupList.value[0]?.type];
    getVpropValues({
        otype,
        oname,
        vprops: vpropsList.join(','),
    });
};
defineExpose({
    featureClick,
});
</script>
<style scoped lang="scss">
.content {
    .el-collapse {
        --item-border-radius: 0.8rem;
        --el-collapse-border-color: black;
        border-top: unset;
        border-bottom: unset;
        .el-collapse-item {
            :deep(.el-collapse-item__header) {
                background-color: #e5e5e5;
                padding-left: 4px;
            }
            :deep(.el-collapse-item__content) {
                padding-bottom: 0;
            }
 
            &:first-child {
                :deep(.el-collapse-item__header) {
                    border-top-left-radius: var(--item-border-radius);
                    border-top-right-radius: var(--item-border-radius);
                }
            }
            &:last-child {
                :deep(.el-collapse-item__header) {
                    border: unset;
                }
                margin-bottom: unset;
            }
 
            .el-table {
                --el-table-border-color: var(--el-border-color-darker);
                :deep(tbody) {
                    .el-table__row {
                        &:hover {
                            > .el-table__cell {
                                background-color: unset !important; //修改成自己想要的颜色即可
                            }
                        }
 
                        .el-table__cell {
                            border-width: 1.5px;
                            .cell {
                                padding: 0 2px;
 
                                // 溢出显示
 
                                // text-overflow: ellipsis !important;
                                // overflow: hidden !important;
                                // white-space: nowrap !important;
                            }
                        }
                    }
                }
            }
        }
    }
}
</style>