SocialNetworks_duan/src/views/KeyNodeDiscern/bridgeCommunication/components/DetailsModal.vue

157 lines
4.2 KiB
Vue
Raw Normal View History

2025-07-17 10:28:56 +08:00
<template>
<div v-if="store.isDetailsModalVisible" class="modal-overlay" @click="store.closeDetailsModal">
<div class="modal-content" @click.stop>
<img class="model-title" :src="titleImage" alt="" />
2025-07-17 10:28:56 +08:00
<button class="close-btn" @click="store.closeDetailsModal">×</button>
<div ref="detailsChartRef" class="details-chart-container"></div>
<img class="model-bottom-icon" src="@/assets/images/icon/dialog_bottom_icon.png" alt="" />
2025-07-17 10:28:56 +08:00
</div>
</div>
</template>
<script setup>
import { ref, watch, onUnmounted, nextTick, defineProps } from "vue"
import { useKeyNodeStore2 } from "@/store/keyNodeStore2"
import * as echarts from "echarts/core"
import { SVGRenderer } from "echarts/renderers"
import { LineChart } from "echarts/charts"
import { GridComponent, TooltipComponent } from "echarts/components"
import shixuTitle from "@/assets/images/head/event_shixu_hotmap_title.png"
import leijiTitle from "@/assets/images/head/event_leiji_hotmap_title.png"
import { computed } from "vue"
2025-07-17 10:28:56 +08:00
2025-07-23 11:22:36 +08:00
const props = defineProps({
activeChartTab: {
type: String,
default: "trend"
2025-07-23 11:22:36 +08:00
}
})
const titleImage = computed(() => {
return props.activeChartTab === "trend" ? shixuTitle : leijiTitle
})
2025-07-23 11:22:36 +08:00
echarts.use([SVGRenderer, LineChart, GridComponent, TooltipComponent])
const store = useKeyNodeStore2()
const detailsChartRef = ref(null)
let myChart = null
2025-07-17 10:28:56 +08:00
watch(
() => store.isDetailsModalVisible,
async (isVisible) => {
if (isVisible && store.detailsModalChartConfig) {
await nextTick()
if (detailsChartRef.value) {
myChart = echarts.init(detailsChartRef.value)
2025-07-22 17:40:11 +08:00
const option = {
...store.detailsModalChartConfig.option
}
if (option.yAxis) {
const yAxis = Array.isArray(option.yAxis) ? option.yAxis[0] : option.yAxis
yAxis.name = "数量"
yAxis.nameLocation = "end" // 显示在y轴最上方
2025-07-22 17:40:11 +08:00
yAxis.nameTextStyle = {
color: "#a7c5d4",
2025-07-22 17:40:11 +08:00
fontSize: 12,
padding: [0, 0, 0, -68] // 调整位置,避免与坐标轴重叠
}
if (Array.isArray(option.yAxis)) {
option.yAxis[0] = yAxis
} else {
option.yAxis = yAxis
2025-07-22 17:40:11 +08:00
}
}
// 添加以下代码将实心圆点改为空心圆点
/* if(option.series && Array.isArray(option.series)) {
option.series.forEach(series => {
if(series.itemStyle) {
series.itemStyle.color = 'transparent'; // 设置内部透明
// 确保边框颜色和宽度
if(!series.itemStyle.borderColor) series.itemStyle.borderColor = '#45B8FD';
if(!series.itemStyle.borderWidth) series.itemStyle.borderWidth = 2;
} else {
series.itemStyle = {
color: 'transparent',
borderColor: '#00baff',
borderWidth: 2
};
}
});
} */
myChart.setOption(option)
2025-07-22 17:40:11 +08:00
// myChart.setOption(store.detailsModalChartConfig.option);
}
} else if (!isVisible && myChart) {
myChart.dispose()
myChart = null
2025-07-17 10:28:56 +08:00
}
}
)
2025-07-17 10:28:56 +08:00
onUnmounted(() => {
if (myChart) {
myChart.dispose()
2025-07-17 10:28:56 +08:00
}
})
2025-07-17 10:28:56 +08:00
</script>
<style scoped lang="scss">
2025-07-17 10:28:56 +08:00
.modal-overlay {
position: fixed;
top: 0;
left: 0;
border-radius: vw(2);
2025-07-17 10:28:56 +08:00
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.7);
display: flex;
justify-content: center;
align-items: center;
z-index: 1000;
}
.modal-content {
position: relative;
background-color: #0d1b38;
padding: vh(20);
border-radius: vw(2);
2025-07-17 10:28:56 +08:00
border: 1px solid #3a95ff;
box-shadow: 0 0 vw(25) rgba(58, 149, 255, 0.5);
2025-07-17 10:28:56 +08:00
width: 50vw;
height: 45vh;
display: flex;
flex-direction: column;
}
2025-07-22 17:40:11 +08:00
.modal-content .model-title {
margin-top: vh(-28);
margin-left: vw(-21);
2025-07-22 17:40:11 +08:00
width: 30%;
height: 15%;
}
2025-07-17 10:28:56 +08:00
.close-btn {
position: absolute;
width: vw(20);
height: vh(20);
2025-07-17 10:28:56 +08:00
display: flex;
align-items: center;
justify-content: center;
top: vh(10);
right: vw(15);
2025-07-17 10:28:56 +08:00
border: none;
color: #a7c5d4;
background: none;
font-size: vw(24);
2025-07-17 10:28:56 +08:00
cursor: pointer;
}
.details-chart-container {
width: 100%;
flex-grow: 1;
}
2025-07-22 17:40:11 +08:00
.modal-content .model-bottom-icon {
position: absolute;
bottom: vh(-12);
2025-07-22 17:40:11 +08:00
left: 50%;
width: 6%;
height: 6%;
}
</style>