fix: 修复gd地图无法生成缩略图的bug 修复位置错误的bug

This commit is contained in:
huanghao1412 2024-01-16 18:51:35 +08:00
parent e93473917d
commit 3e5139a52a
25 changed files with 238 additions and 141 deletions

View File

@ -46,6 +46,12 @@ export enum MenuEnum {
GROUP = 'group',
// 解组
UN_GROUP = 'unGroup',
// 水平对齐
H_ALIGN = 'hAlign',
// 垂直对齐
V_ALIGN = 'vAlign',
// 水平平均分布
// 垂直平均分布
// 后退
BACK = 'back',
FORWORD = 'forward',

View File

@ -15,6 +15,12 @@ export const option = {
export default class Config extends PublicConfigClass implements CreateComponentType
{
constructor() {
super();
this.attr.w = 450
this.attr.h = 300
this.request.requestInterval = 15
}
public key = ComprehensivePUEConfig.key
public chartConfig = cloneDeep(ComprehensivePUEConfig)
public option = cloneDeep(option)

View File

@ -44,10 +44,6 @@ const props = defineProps({
required: true
}
})
if(!isPreview()) {
Object.assign(props.chartConfig.attr, { w: 450, h: 300 })
Object.assign(props.chartConfig.request, { requestInterval: 15, requestIntervalUnit: RequestHttpIntervalEnum.SECOND })
}
const { w, h } = toRefs(props.chartConfig.attr)
const { dataset, fit, borderRadius } = toRefs(props.chartConfig.option)

View File

@ -15,6 +15,12 @@ export const option = {
export default class Config extends PublicConfigClass implements CreateComponentType
{
constructor() {
super();
this.attr.w = 450
this.attr.h = 300
this.request.requestInterval = 15
}
public key = DeviceAlarmOverviewConfig.key
public chartConfig = cloneDeep(DeviceAlarmOverviewConfig)
public option = cloneDeep(option)

View File

@ -52,10 +52,6 @@ const props = defineProps({
required: true
}
})
if(!isPreview()) {
Object.assign(props.chartConfig.attr, { w: 450, h: 300 })
Object.assign(props.chartConfig.request, { requestInterval: 15, requestIntervalUnit: RequestHttpIntervalEnum.SECOND })
}
const { w, h } = toRefs(props.chartConfig.attr)
const { dataset, fit, borderRadius } = toRefs(props.chartConfig.option)

View File

@ -15,6 +15,12 @@ export const option = {
export default class Config extends PublicConfigClass implements CreateComponentType
{
constructor() {
super();
this.attr.w = 950
this.attr.h = 820
this.request.requestInterval = 15
}
public key = GDMapConfig.key
public chartConfig = cloneDeep(GDMapConfig)
public option = cloneDeep(option)

View File

@ -93,7 +93,9 @@
</svg>
<!-- img标签出来的图不完整 所以换background-url background-reapt object-fit: contain不支持 -->
<!-- <img v-show="showImg" @load="showImg = true" :src="gdMap.propValue" :style="{transform: `scale(${scale(w, 870)}, ${scale(h - 100,560)})`}" style="position: absolute;top: 100px;width: 870px;height: 560px;transform-origin: left top"/>-->
<div id="img" :style="{backgroundImage: `url(${gdMap.propValue})`, transform: `scale(${scale(w, 870)}, ${scale(h - 100,560)})`}" style="position: absolute;top: 100px;width: 870px;height: 560px;transform-origin: left top"></div>
<!-- <div id="img" :style="{backgroundImage: `url(${gdMap.propValue})`, transform: `scale(${scale(w, 870)}, ${scale(h - 100,560)})`}" style="position: absolute;top: 100px;width: 870px;height: 560px;transform-origin: left top"></div>-->
<!-- background-url出来的截图还是不行 会变大 用canvas可以-->
<canvas ref="canvas" width="870" height="560" :style="{transform: `scale(${scale(w, 870)}, ${scale(h - 100,560)})`}" style="position: absolute;top: 100px;width: 870px;height: 560px;transform-origin: left top"></canvas>
<div :style="{transform: `scale(${scale(w, 870)}, ${scale(h - 100,560)})`}" style="position: absolute;top: 100px;width: 870px;height: 560px;transform-origin: left top">
<div
v-for="(item, i) in point"
@ -134,6 +136,7 @@
<script setup lang="ts">
import { PropType, shallowReactive, watch, toRefs, reactive, onMounted, onUnmounted, nextTick, ref, computed } from 'vue'
import type { Ref } from 'vue'
import { CreateComponentType } from '@/packages/index.d'
import { publicInterface } from '@/api/path/business.api'
import { isPreview } from '@/utils'
@ -152,10 +155,6 @@ const props = defineProps({
required: true
}
})
if(!isPreview()) {
Object.assign(props.chartConfig.attr, { w: 950, h: 820 })
Object.assign(props.chartConfig.request, { requestInterval: 15, requestIntervalUnit: RequestHttpIntervalEnum.SECOND })
}
// Object.assign(props.chartConfig.attr, { w: 870, h: 560 })
const { w, h } = toRefs(props.chartConfig.attr)
@ -190,6 +189,7 @@ const abnormalNumber = computed(() => point.filter(_ => _.color === '#f00').leng
let safeDaysList = reactive(['0', '0', '0', '0', '0', '0'])
const canvas = ref() as Ref<HTMLCanvasElement>
const getData = () => {
safeDaysList.splice(0, safeDaysList.length, ...(moment().diff(moment(systemConfig.overview_dglt_idc_operation_date), 'days') + 1).toString().padStart(6, '0').split(''))
publicInterface('/dcim/space_page', 'get_one_no_permission', { id: props.chartConfig.customData!.mapId }).then(res => {
@ -197,6 +197,14 @@ const getData = () => {
const arr:[] = JSON.parse(res.data.canvas_data)
for (const key in gdMap) delete gdMap[key]
Object.assign(gdMap, arr.find((_:any) => _.component === 'Picture') || {})
if(canvas.value){
const ctx = canvas.value.getContext('2d');
const img = new Image();
img.onload = function() {
if(ctx) ctx.drawImage(img, 0, 0, canvas.value.width, canvas.value.height);
};
img.src = gdMap.propValue;
}
text.splice(0, text.length, ...arr.filter((_:any) => _.component === 'v-text'))
point.splice(0, point.length, ...arr.filter((_:any) => _.component === 'svg-shape'))
const activeAlarmData = {
@ -228,13 +236,11 @@ const getData = () => {
})
}
})
console.log(point)
}
})
}
const pointJump = (item:any) => {
console.log(item)
postMessageToParent({type: 'changeRouterV1', url: '/' + item.dataBind.skipPath})
}

View File

@ -15,6 +15,12 @@ export const option = {
export default class Config extends PublicConfigClass implements CreateComponentType
{
constructor() {
super();
this.attr.w = 450
this.attr.h = 300
this.request.requestInterval = 15
}
public key = MonitorRealTimeEventsConfig.key
public chartConfig = cloneDeep(MonitorRealTimeEventsConfig)
public option = cloneDeep(option)

View File

@ -52,11 +52,6 @@ const props = defineProps({
}
})
if(!isPreview()){
Object.assign(props.chartConfig.attr, { w: 450, h: 300 })
Object.assign(props.chartConfig.request, { requestInterval: 15, requestIntervalUnit: RequestHttpIntervalEnum.SECOND })
}
const { w, h } = toRefs(props.chartConfig.attr)
const { dataset, fit, borderRadius } = toRefs(props.chartConfig.option)

View File

@ -15,6 +15,12 @@ export const option = {
export default class Config extends PublicConfigClass implements CreateComponentType
{
constructor() {
super();
this.attr.w = 450
this.attr.h = 300
this.request.requestInterval = 15
}
public key = OverviewOfComputingNodesConfig.key
public chartConfig = cloneDeep(OverviewOfComputingNodesConfig)
public option = cloneDeep(option)

View File

@ -102,10 +102,6 @@ const props = defineProps({
required: true
}
})
if(!isPreview()) {
Object.assign(props.chartConfig.attr, { w: 450, h: 300 })
Object.assign(props.chartConfig.request, { requestInterval: 15, requestIntervalUnit: RequestHttpIntervalEnum.SECOND })
}
const { w, h } = toRefs(props.chartConfig.attr)
const { dataset, fit, borderRadius } = toRefs(props.chartConfig.option)

View File

@ -15,6 +15,12 @@ export const option = {
export default class Config extends PublicConfigClass implements CreateComponentType
{
constructor() {
super();
this.attr.w = 450
this.attr.h = 300
this.request.requestInterval = 15
}
public key = RealTimeAlarmStatisticsConfig.key
public chartConfig = cloneDeep(RealTimeAlarmStatisticsConfig)
public option = cloneDeep(option)

View File

@ -37,11 +37,6 @@ const props = defineProps({
}
})
if(!isPreview()) {
Object.assign(props.chartConfig.attr, {w: 450, h: 300})
Object.assign(props.chartConfig.request, { requestInterval: 15, requestIntervalUnit: RequestHttpIntervalEnum.SECOND })
}
const { w, h } = toRefs(props.chartConfig.attr)
const { dataset, fit, borderRadius } = toRefs(props.chartConfig.option)

View File

@ -15,6 +15,12 @@ export const option = {
export default class Config extends PublicConfigClass implements CreateComponentType
{
constructor() {
super();
this.attr.w = 950
this.attr.h = 300
this.request.requestInterval = 15
}
public key = RealTimeEventConfig.key
public chartConfig = cloneDeep(RealTimeEventConfig)
public option = cloneDeep(option)

View File

@ -61,11 +61,6 @@ const props = defineProps({
required: true
}
})
if(!isPreview()){
Object.assign(props.chartConfig.attr, { w: 950, h: 300 })
Object.assign(props.chartConfig.request, { requestInterval: 15, requestIntervalUnit: RequestHttpIntervalEnum.SECOND })
}
const { w, h } = toRefs(props.chartConfig.attr)
const { dataset, fit, borderRadius } = toRefs(props.chartConfig.option)

View File

@ -15,6 +15,12 @@ export const option = {
export default class Config extends PublicConfigClass implements CreateComponentType
{
constructor() {
super();
this.attr.w = 450
this.attr.h = 300
this.request.requestInterval = 15
}
public key = RealTimeTrafficConfig.key
public chartConfig = cloneDeep(RealTimeTrafficConfig)
public option = cloneDeep(option)

View File

@ -34,10 +34,6 @@ const props = defineProps({
required: true
}
})
if(!isPreview()) {
Object.assign(props.chartConfig.attr, { w: 450, h: 300 })
Object.assign(props.chartConfig.request, { requestInterval: 15, requestIntervalUnit: RequestHttpIntervalEnum.SECOND })
}
const { w, h } = toRefs(props.chartConfig.attr)
const { dataset, fit, borderRadius } = toRefs(props.chartConfig.option)

View File

@ -15,6 +15,16 @@ export const option = {
export default class Config extends PublicConfigClass implements CreateComponentType
{
constructor() {
super();
this.attr = {
...this.attr,
w: 1920,
h: 1080,
x: 0,
y: 0,
}
}
public key = Theme1Config.key
public chartConfig = cloneDeep(Theme1Config)
public option = cloneDeep(option)

View File

@ -1,10 +1,16 @@
<template>
<div :style="getStyle(borderRadius)" class="Theme1">
<div id="fullscreenButton" class="full-screen-btn" @click="toggleFullscreen">
<i class="iconfont icon-quanping full-screen" :title="showMoreMenuBts ? '全屏' : '退出全屏'"></i>
{{ showMoreMenuBts ? '全屏' : '退出全屏' }}
</div>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1920 60" style="enable-background:new 0 0 1920 60;" xml:space="preserve">
<svg
ref="svg"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
x="0px"
y="0px"
viewBox="0 0 1920 60"
style="enable-background:new 0 0 1920 60;"
xml:space="preserve"
>
<g id="顶栏">
<g>
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="960" y1="60" x2="960" y2="0">
@ -23,7 +29,9 @@
<path style="fill:url(#SVGID_2_);" d="M600,0l54.3,54.3c3.1,3.1,9.3,5.7,13.7,5.7h584c4.4,0,10.5-2.5,13.7-5.7L1320,0" />
</g>
<g>
<!-- <text transform="matrix(1 0 0 1 697.4991 43)" style="fill:#FFFFFF; font-family:'PingFang-SC-Bold'; font-size:30px;text-align: center;"></text>-->
<!-- <text transform="matrix(1 0 0 1 697.4991 43)" style="fill:#FFFFFF; font-family:'PingFang-SC-Bold'; font-size:30px;">-->
<!-- {{chartConfig?.customData?.title}}-->
<!-- </text>-->
</g>
<g>
<linearGradient id="SVGID_3_" gradientUnits="userSpaceOnUse" x1="770" y1="58" x2="1150" y2="58">
@ -90,15 +98,29 @@
</g>
</g>
</svg>
<div style="font: 30px PingFang-SC-Bold;color: #fff;width: 1920px;height: 60px;line-height: 60px;text-align: center;position: absolute;top: 0;">{{chartConfig?.customData?.title}}</div>
<div
:style="{height: `${svgHeight}px`,lineHeight: `${svgHeight}px`, fontSize: `${svgHeight / 2}px`}"
style="position: absolute;top: 0;width: 100%;"
>
<div
style="font-family: PingFang-SC-Bold;color: #fff;width: 50%;height: 100%;text-align: center;position: absolute;top: 0;left: 50%;transform: translateX(-50%)"
>
{{chartConfig?.customData?.title}}
</div>
<div id="fullscreenButton" :style="{'--height': `${svgHeight}px`}" class="full-screen-btn" @click="toggleFullscreen">
<i class="iconfont icon-quanping full-screen" :title="showMoreMenuBts ? '全屏' : '退出全屏'"></i>
{{ showMoreMenuBts ? '全屏' : '退出全屏' }}
</div>
</div>
<n-image
:object-fit="fit"
object-fit="fill"
preview-disabled
:src="background"
:fallback-src="requireErrorImg()"
:width="w"
:height="h"
lazy
:style="{height, top: `${svgHeight}px`}"
style="position: absolute;left: 0;width: 100%;"
/>
</div>
</template>
@ -110,7 +132,7 @@ import { CreateComponentType } from '@/packages/index.d'
import moment from 'moment'
import background from '@/assets/customComponents/theme1/backgrond.jpg'
import { isPreview } from '@/utils/router'
import { postMessageToParent } from "@/utils";
import { postMessageToParent, ResizeObserverELE } from "@/utils";
const props = defineProps({
chartConfig: {
@ -119,8 +141,6 @@ const props = defineProps({
}
})
if(!isPreview()) Object.assign(props.chartConfig.attr, {w: 1920, h: 1080, x: 0, y: 0})
const { w, h } = toRefs(props.chartConfig.attr)
const { dataset, fit, borderRadius } = toRefs(props.chartConfig.option)
@ -200,6 +220,20 @@ const getStyle = (radius: number) => {
}
}
let svgHeight = ref(60)
let height = ref('100%')
const observer = ResizeObserverELE((w, h) => {
svgHeight.value = h
height.value = `calc(100% - ${h}px)`
})
const svg = ref()
onMounted(() => {
if(svg.value) observer.observe(svg.value);
})
onUnmounted(() => {
observer.disconnect();
})
// //
// watch(
// () => props.chartConfig.option.dataset,
@ -242,10 +276,12 @@ const getStyle = (radius: number) => {
padding: 3px 10px;
cursor: pointer;
position: absolute;
top: 16px;
top: 50%;
right: 9.6%;
transform: translateY(-50%);
color: #4396fd;
font-size: 14px;
font-size: calc(var(--height) / 4);
height: calc(var(--height) / 3);
.full-screen {
font-size: 16px;
margin-right: 5px;

View File

@ -109,7 +109,9 @@ import {
} from '@vicons/carbon'
import {
Apps20Regular as Apps20RegularIcon
Apps20Regular as Apps20RegularIcon,
AlignSpaceEvenlyHorizontal20Filled as AlignSpaceEvenlyHorizontal20FilledIcon,
AlignSpaceEvenlyVertical20Filled as AlignSpaceEvenlyVertical20FilledIcon
} from '@vicons/fluent'
import {
@ -323,7 +325,9 @@ const carbon = {
const fluent = {
// 主题
Apps20RegularIcon
Apps20RegularIcon,
AlignSpaceEvenlyHorizontal20FilledIcon,
AlignSpaceEvenlyVertical20FilledIcon,
}
const material = {

View File

@ -863,6 +863,16 @@ export const useChartEditStore = defineStore({
loadingFinish()
}
},
// * 水平对齐
setHAlign(id: string[], isHistory = true) {
try {
const selectIds = this.idPreFormat(id) || this.getTargetChart.selectId
if (selectIds.length < 2) return
console.log(selectIds)
} catch(e) {
console.log(e)
}
},
// * 锁定
setLock(status: boolean = true, isHistory: boolean = true) {
try {

View File

@ -7,7 +7,7 @@
<!-- 位置 -->
<position-setting :chartAttr="targetData.attr" :canvasConfig="chartEditStore.getEditCanvasConfig" />
<!-- 滤镜 -->
<!-- <styles-setting :isGroup="targetData.isGroup" :chartStyles="targetData.styles"></styles-setting>-->
<styles-setting :isGroup="targetData.isGroup" :chartStyles="targetData.styles"></styles-setting>
<!-- 自定义配置项 -->
<component :is="targetData.chartConfig.conKey" :optionData="targetData.option"></component>
</div>

View File

@ -134,12 +134,12 @@ const chartsDefaultTabList = [
icon: ConstructIcon,
render: ChartSetting
},
// {
// key: TabsEnum.CHART_ANIMATION,
// title: '',
// icon: LeafIcon,
// render: ChartAnimation
// }
{
key: TabsEnum.CHART_ANIMATION,
title: '动画',
icon: LeafIcon,
render: ChartAnimation
}
]
const chartsTabList = [

View File

@ -20,6 +20,7 @@ const {
EyeOffOutlineIcon
} = icon.ionicons5
const { UpToTopIcon, DownToBottomIcon, PaintBrushIcon, Carbon3DSoftwareIcon, Carbon3DCursorIcon } = icon.carbon
const { AlignSpaceEvenlyHorizontal20FilledIcon, AlignSpaceEvenlyVertical20FilledIcon } = icon.fluent
const chartEditStore = useChartEditStore()
@ -142,6 +143,12 @@ export const defaultMultiSelectOptions: MenuOptionsItemType[] = [
key: MenuEnum.UN_GROUP,
icon: renderIcon(Carbon3DCursorIcon),
fnHandle: chartEditStore.setUnGroup
},
{
label: '水平对齐',
key: MenuEnum.H_ALIGN,
icon: renderIcon(AlignSpaceEvenlyHorizontal20FilledIcon),
fnHandle: chartEditStore.setHAlign
}
]
@ -198,7 +205,7 @@ const handleContextMenu = (
while (target instanceof SVGElement) {
target = target.parentNode
}
console.log(targetInstance)
chartEditStore.setTargetSelectChart(targetInstance && targetInstance.id)
// 隐藏旧列表

View File

@ -44,6 +44,7 @@ import { LayoutHeaderPro } from '@/layout/components/LayoutHeaderPro'
import { useContextMenu } from './hooks/useContextMenu.hook'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { useChartHistoryStore } from '@/store/modules/chartHistoryStore/chartHistoryStore'
import { watch } from 'vue'
const chartHistoryStoreStore = useChartHistoryStore()
const chartEditStore = useChartEditStore()