修改大屏
parent
a42d078825
commit
778755616e
|
|
@ -1,9 +1,26 @@
|
||||||
<template>
|
<template>
|
||||||
<section :style="{ ...styles.box, ...boxStyle }" class="v-screen-box">
|
<div>
|
||||||
<div :style="{ ...styles.wrapper, ...wrapperStyle }" class="screen-wrapper" ref="screenWrapper">
|
<transition name="slide">
|
||||||
<slot></slot>
|
<div
|
||||||
</div>
|
v-if="isScroll"
|
||||||
</section>
|
v-show="showTop"
|
||||||
|
class="fixed topTool border border-[#396684] bg-[#1c2c34cc] top-0 z-99999 flex text-white py-4px px-10px"
|
||||||
|
>
|
||||||
|
<div class="px-10px cursor-pointer" @click="handleScrollLeft">左</div>
|
||||||
|
<div class="px-10px cursor-pointer" @click="handleScrollCenter">中</div>
|
||||||
|
<div class="px-10px cursor-pointer" @click="handleScrollRight">右</div>
|
||||||
|
</div>
|
||||||
|
</transition>
|
||||||
|
<section ref="screenRef" :style="{ ...styles.box, ...boxStyle }" class="v-screen-box">
|
||||||
|
<div
|
||||||
|
:style="{ ...styles.wrapper, ...wrapperStyle }"
|
||||||
|
class="screen-wrapper"
|
||||||
|
ref="screenWrapper"
|
||||||
|
>
|
||||||
|
<slot></slot>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {
|
import {
|
||||||
|
|
@ -15,6 +32,7 @@
|
||||||
PropType,
|
PropType,
|
||||||
reactive,
|
reactive,
|
||||||
ref,
|
ref,
|
||||||
|
toRef,
|
||||||
} from 'vue'
|
} from 'vue'
|
||||||
/**
|
/**
|
||||||
* 防抖函数
|
* 防抖函数
|
||||||
|
|
@ -41,6 +59,8 @@
|
||||||
width?: string | number
|
width?: string | number
|
||||||
height?: string | number
|
height?: string | number
|
||||||
observer: null | MutationObserver
|
observer: null | MutationObserver
|
||||||
|
showTop: boolean
|
||||||
|
isScroll: boolean
|
||||||
}
|
}
|
||||||
type IAutoScale =
|
type IAutoScale =
|
||||||
| boolean
|
| boolean
|
||||||
|
|
@ -87,8 +107,11 @@
|
||||||
originalWidth: 0,
|
originalWidth: 0,
|
||||||
originalHeight: 0,
|
originalHeight: 0,
|
||||||
observer: null,
|
observer: null,
|
||||||
|
showTop: false,
|
||||||
|
isScroll: false,
|
||||||
})
|
})
|
||||||
const styles: Record<string, CSSProperties> = {
|
const screenRef = ref<HTMLElement>()
|
||||||
|
const styles: Record<string, CSSProperties> = reactive({
|
||||||
box: {
|
box: {
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
backgroundSize: `100% 100%`,
|
backgroundSize: `100% 100%`,
|
||||||
|
|
@ -104,8 +127,9 @@
|
||||||
overflow: `hidden`,
|
overflow: `hidden`,
|
||||||
zIndex: 100,
|
zIndex: 100,
|
||||||
transformOrigin: `left top`,
|
transformOrigin: `left top`,
|
||||||
|
display: 'inline-block',
|
||||||
},
|
},
|
||||||
}
|
})
|
||||||
const screenWrapper = ref<HTMLElement>()
|
const screenWrapper = ref<HTMLElement>()
|
||||||
/**
|
/**
|
||||||
* 初始化大屏容器宽高
|
* 初始化大屏容器宽高
|
||||||
|
|
@ -175,7 +199,16 @@
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// 按照宽高最小比例进行缩放
|
// 按照宽高最小比例进行缩放
|
||||||
const scale = Math.min(widthScale, heightScale)
|
let scale = Math.min(widthScale, heightScale)
|
||||||
|
if (currentWidth < 3000) {
|
||||||
|
scale = heightScale
|
||||||
|
state.isScroll = true
|
||||||
|
styles.box.overflow = 'auto'
|
||||||
|
} else {
|
||||||
|
state.isScroll = false
|
||||||
|
styles.box.overflow = 'hidden'
|
||||||
|
}
|
||||||
|
|
||||||
autoScale(scale)
|
autoScale(scale)
|
||||||
}
|
}
|
||||||
const onResize = debounce(async () => {
|
const onResize = debounce(async () => {
|
||||||
|
|
@ -193,20 +226,63 @@
|
||||||
attributeOldValue: true,
|
attributeOldValue: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
const onMouseUpdate = (e) => {
|
||||||
|
if (e.pageY <= 30) state.showTop = true
|
||||||
|
else state.showTop = false
|
||||||
|
}
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
nextTick(async () => {
|
nextTick(async () => {
|
||||||
await initSize()
|
await initSize()
|
||||||
updateSize()
|
updateSize()
|
||||||
updateScale()
|
updateScale()
|
||||||
window.addEventListener('resize', onResize)
|
window.addEventListener('resize', onResize)
|
||||||
|
window.addEventListener('mousemove', onMouseUpdate)
|
||||||
initMutationObserver()
|
initMutationObserver()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
window.removeEventListener('resize', onResize)
|
window.removeEventListener('resize', onResize)
|
||||||
|
window.removeEventListener('mousemove', onMouseUpdate)
|
||||||
state.observer?.disconnect()
|
state.observer?.disconnect()
|
||||||
})
|
})
|
||||||
return { screenWrapper, styles }
|
|
||||||
|
const handleScrollLeft = () => {
|
||||||
|
nextTick(() => {
|
||||||
|
screenRef.value?.scrollTo({ left: 0, behavior: 'smooth' })
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const handleScrollCenter = () => {
|
||||||
|
nextTick(() => {
|
||||||
|
screenRef.value?.scrollTo({
|
||||||
|
left: (screenRef.value?.scrollWidth ?? 0) / 2 - document.body.clientWidth / 2,
|
||||||
|
behavior: 'smooth',
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const handleScrollRight = () => {
|
||||||
|
nextTick(() => {
|
||||||
|
screenRef.value?.scrollTo({ left: screenRef.value?.scrollWidth, behavior: 'smooth' })
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const showTop = toRef(state, 'showTop')
|
||||||
|
const isScroll = toRef(state, 'isScroll')
|
||||||
|
return {
|
||||||
|
screenWrapper,
|
||||||
|
styles,
|
||||||
|
isScroll,
|
||||||
|
showTop,
|
||||||
|
screenRef,
|
||||||
|
handleScrollLeft,
|
||||||
|
handleScrollCenter,
|
||||||
|
handleScrollRight,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
<style scoped lang="less">
|
||||||
|
.topTool {
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -154,6 +154,7 @@
|
||||||
const year = computed(() => visualizationStore.getYear)
|
const year = computed(() => visualizationStore.getYear)
|
||||||
|
|
||||||
const getContainer = () => {
|
const getContainer = () => {
|
||||||
|
if (document.body.clientWidth < 3000) return document.body
|
||||||
return document.body.querySelector(`.modelRef`)
|
return document.body.querySelector(`.modelRef`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,7 @@
|
||||||
unref,
|
unref,
|
||||||
watchEffect,
|
watchEffect,
|
||||||
watch,
|
watch,
|
||||||
|
nextTick,
|
||||||
} from 'vue'
|
} from 'vue'
|
||||||
import type { TabsProps } from 'ant-design-vue'
|
import type { TabsProps } from 'ant-design-vue'
|
||||||
import { getCates, getCropYieldQuarterStatics } from '/@/api/sys/other'
|
import { getCates, getCropYieldQuarterStatics } from '/@/api/sys/other'
|
||||||
|
|
@ -318,6 +319,7 @@
|
||||||
})
|
})
|
||||||
|
|
||||||
const getContainer = () => {
|
const getContainer = () => {
|
||||||
|
if (document.body.clientWidth < 3000) return document.body
|
||||||
return document.body.querySelector(`.cmodal`)
|
return document.body.querySelector(`.cmodal`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -329,7 +331,9 @@
|
||||||
(e) => {
|
(e) => {
|
||||||
if (e) {
|
if (e) {
|
||||||
ppName.value = props.pName ?? props.name
|
ppName.value = props.pName ?? props.name
|
||||||
getTabs()
|
nextTick(() => {
|
||||||
|
getTabs()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -152,6 +152,7 @@
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
},
|
},
|
||||||
getContainer: (): any => {
|
getContainer: (): any => {
|
||||||
|
if (document.body.clientWidth < 3000) return document.body
|
||||||
return document.body.querySelector(`.visualization—xx`)
|
return document.body.querySelector(`.visualization—xx`)
|
||||||
},
|
},
|
||||||
description: message,
|
description: message,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue