bonus-ui/src/views/home/components/ProvincialChart.vue

232 lines
4.3 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="viewport">
<div class="screen" :style="screenStyle">
<div class="app-container">
<div style="height: 90px"></div>
<div class="top">
<div class="top-1">
<Top1 />
</div>
<div class="top-2">
<Top2 />
</div>
<div class="top-3">
<Top3 />
</div>
</div>
<div class="center">
<div class="center-1">
<Center1 />
</div>
<div class="center-2">
<Center2 />
</div>
</div>
<div class="bottom">
<div class="bottom-1">
<div class="bottom-1-1">
<Bottom11 />
</div>
<div class="bottom-1-2">
<Bottom12 />
</div>
</div>
<div class="bottom-2">
<Bottom2 />
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import Top1 from './provincial/Top1'
import Top2 from './provincial/Top2'
import Top3 from './provincial/Top3'
import Center1 from './provincial/Center1'
import Center2 from './provincial/Center2'
import Bottom11 from './provincial/Bottom1-1'
import Bottom12 from './provincial/Bottom1-2'
import Bottom2 from './provincial/Bottom2'
export default {
name: 'provincialChart',
components: {
Top1,
Top2,
Top3,
Center1,
Center2,
Bottom11,
Bottom12,
Bottom2,
},
data() {
return {
scale: 1,
offsetX: 0,
offsetY: 0,
}
},
computed: {
screenStyle() {
return {
width: '1920px',
height: '1080px',
transform: `translate(${this.offsetX}px, ${this.offsetY}px) scale(${this.scale})`,
transformOrigin: '0 0',
}
},
},
mounted() {
this.calcScale()
window.addEventListener('resize', this.calcScale)
},
beforeDestroy() {
window.removeEventListener('resize', this.calcScale)
},
methods: {
calcScale() {
const baseW = 1920
const baseH = 1080
const vw = document.documentElement.clientWidth
const vh = document.documentElement.clientHeight
const scale = Math.min(vw / baseW, vh / baseH)
const realW = baseW * scale
const realH = baseH * scale
// ✅ 横向:仍然居中
this.offsetX = (vw - realW) / 2 / scale
// ✅ 纵向:贴顶(不再居中)
this.offsetY = 0
this.scale = scale
},
},
}
</script>
<style lang="scss" scoped>
/* 外层视口:锁满屏 */
.viewport {
position: fixed;
inset: 0;
overflow: hidden;
background: #e1ebf7; /* 大屏底色 */
}
/* 被缩放的 1920×1080 画布 */
.screen {
position: absolute;
top: 0;
left: 0;
}
.app-container {
width: 1920px;
height: 1080px;
background: #e1ebf7;
}
.top {
margin-bottom: 16px;
display: flex;
align-items: center;
justify-content: space-between;
.top-1,
.top-2,
.top-3 {
padding: 24px;
background: rgba(255, 255, 255, 0.91);
border-radius: 5px;
}
.top-1,
.top-3 {
width: 480px;
height: 518px;
}
.top-2 {
flex: 1;
margin: 0 15px;
height: 518px;
background-image: url('~@/assets/images/map-img.png');
background-size: 100% 100%;
}
}
.center {
margin-bottom: 16px;
display: flex;
align-items: center;
justify-content: space-between;
.center-1,
.center-2 {
width: 928px;
height: 390px;
padding: 24px;
background: rgba(255, 255, 255, 0.91);
border-radius: 5px;
}
.center-1 {
margin-right: 7.5px;
}
.center-2 {
margin-left: 7.5px;
}
}
.bottom {
display: flex;
align-items: center;
justify-content: space-between;
.bottom-1 {
width: 928px;
height: 350px;
display: flex;
align-items: center;
justify-content: space-between;
.bottom-1-1,
.bottom-1-2 {
padding: 24px;
width: 50%;
height: 350px;
background: rgba(255, 255, 255, 0.91);
border-radius: 5px;
}
.bottom-1-1 {
margin-right: 7.5px;
}
.bottom-1-2 {
margin-left: 7.5px;
}
}
.bottom-2 {
width: 928px;
height: 350px;
padding: 24px;
background: rgba(255, 255, 255, 0.91);
border-radius: 5px;
}
.bottom-1 {
margin-right: 7.5px;
}
.bottom-2 {
margin-left: 7.5px;
}
}
</style>