fix: 缩略图修复 分组可编辑

This commit is contained in:
huanghao1412 2024-01-30 18:36:06 +08:00
parent c10b88d35a
commit f7aff43723
10 changed files with 78 additions and 50 deletions

View File

@ -92,10 +92,11 @@
</g> </g>
</svg> </svg>
<!-- img标签出来的图不完整 所以换background-url background-reapt object-fit: contain不支持 --> <!-- 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"/> <!-- <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可以--> <!-- 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> --> <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>
<!-- 用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 :style="{transform: `scale(${scale(w, 870)}, ${scale(h - 100,560)})`}" style="position: absolute;top: 100px;width: 870px;height: 560px;transform-origin: left top">
<div <div
v-for="(item, i) in point" v-for="(item, i) in point"
@ -202,15 +203,15 @@ const getData = () => {
const arr:[] = JSON.parse(res.data.canvas_data) const arr:[] = JSON.parse(res.data.canvas_data)
for (const key in gdMap) delete gdMap[key] for (const key in gdMap) delete gdMap[key]
Object.assign(gdMap, arr.find((_:any) => _.component === 'Picture') || {}) Object.assign(gdMap, arr.find((_:any) => _.component === 'Picture') || {})
// if(canvas.value){ if(canvas.value){
// const ctx = canvas.value.getContext('2d'); const ctx = canvas.value.getContext('2d');
// ctx?.clearRect(0, 0, canvas.value.width, canvas.value.height); ctx?.clearRect(0, 0, canvas.value.width, canvas.value.height);
// const img = new Image(); const img = new Image();
// img.onload = function() { img.onload = function() {
// if(ctx) ctx.drawImage(img, 0, 0, canvas.value.width, canvas.value.height); if(ctx) ctx.drawImage(img, 0, 0, canvas.value.width, canvas.value.height);
// }; };
// img.src = gdMap.propValue; img.src = gdMap.propValue;
// } }
text.splice(0, text.length, ...arr.filter((_:any) => _.component === 'v-text')) text.splice(0, text.length, ...arr.filter((_:any) => _.component === 'v-text'))
point.splice(0, point.length, ...arr.filter((_:any) => _.component === 'svg-shape')) point.splice(0, point.length, ...arr.filter((_:any) => _.component === 'svg-shape'))
const activeAlarmData = { const activeAlarmData = {

View File

@ -2,7 +2,7 @@ import { BaseEvent, EventLife, InteractEvents, InteractEventOn, InteractActionsT
import type { GlobalThemeJsonType } from '@/settings/chartThemes/index' import type { GlobalThemeJsonType } from '@/settings/chartThemes/index'
import type { RequestConfigType } from '@/store/modules/chartEditStore/chartEditStore.d' import type { RequestConfigType } from '@/store/modules/chartEditStore/chartEditStore.d'
import { CustomComponentsList } from "@/packages/components/CustomComponents/index"; import { CustomComponentsList } from "@/packages/components/CustomComponents/index";
import { commonDataType } from '@/store/modules/chartEditStore/chartEditStore.d' import { commonDataType, CustomEventType } from '@/store/modules/chartEditStore/chartEditStore.d'
export enum ChartFrameEnum { export enum ChartFrameEnum {
// 支持 dataset 的 echarts 框架 // 支持 dataset 的 echarts 框架
@ -144,6 +144,7 @@ export interface PublicConfigType {
filter?: string filter?: string
commonData: commonDataType commonData: commonDataType
customData?: { [key: string]: any } customData?: { [key: string]: any }
customEvent: CustomEventType
status: StatusType status: StatusType
interactActions?: InteractActionsType[] interactActions?: InteractActionsType[]
events: { events: {

View File

@ -1,5 +1,5 @@
import { getUUID } from '@/utils' import { getUUID } from '@/utils'
import { RequestConfigType, commonDataType, CurrentSourceEnum, DateTypeEnum } from '@/store/modules/chartEditStore/chartEditStore.d' import { RequestConfigType, commonDataType, CustomEventType, CurrentSourceEnum, DateTypeEnum } from '@/store/modules/chartEditStore/chartEditStore.d'
import { groupTitle } from '@/settings/designSetting' import { groupTitle } from '@/settings/designSetting'
import { BaseEvent, EventLife } from '@/enums/eventEnum' import { BaseEvent, EventLife } from '@/enums/eventEnum'
import { import {
@ -96,6 +96,13 @@ const commonData: commonDataType = {
} }
} }
const customEvent: CustomEventType = {
click: {
linkHead: 'http://',
link: ''
}
}
// 单实例类 // 单实例类
export class PublicConfigClass implements PublicConfigType { export class PublicConfigClass implements PublicConfigType {
public id = getUUID() public id = getUUID()
@ -149,7 +156,9 @@ export class PublicConfigClass implements PublicConfigType {
public commonData = cloneDeep(commonData) public commonData = cloneDeep(commonData)
// 自定义数据 configData组件会用到 // 自定义数据 configData组件会用到
public customData = {} public customData = {}
// 事件 // 自定义事件
public customEvent = cloneDeep(customEvent)
// 事件 不用了
public events = { public events = {
baseEvent: { baseEvent: {
[BaseEvent.ON_CLICK]: undefined, [BaseEvent.ON_CLICK]: undefined,

View File

@ -357,6 +357,14 @@ export interface commonDataType {
singlePoint: SinglePointType singlePoint: SinglePointType
} }
// customEvent事件
export interface CustomEventType {
click: {
linkHead: 'http://' | 'https://'
link: string
}
}
// Store 类型 // Store 类型
export interface ChartEditStoreType { export interface ChartEditStoreType {
[ChartEditStoreEnum.PROJECT_INFO]: ProjectInfoType [ChartEditStoreEnum.PROJECT_INFO]: ProjectInfoType

View File

@ -31,38 +31,38 @@ import { ChartEventAdvancedHandle } from './components/ChartEventAdvancedHandle'
import { ChartEventBaseHandle } from './components/ChartEventBaseHandle' import { ChartEventBaseHandle } from './components/ChartEventBaseHandle'
import { useTargetData } from '../hooks/useTargetData.hook' import { useTargetData } from '../hooks/useTargetData.hook'
// const { targetData, chartEditStore } = useTargetData() const { targetData, chartEditStore } = useTargetData()
// const showModal = ref(false) const showModal = ref(false)
const { chartEditStore } = useTargetData() // const { chartEditStore } = useTargetData()
const targetIndex = computed(() => chartEditStore.fetchTargetIndex()) // const targetIndex = computed(() => chartEditStore.fetchTargetIndex())
const list = computed(() => chartEditStore.getComponentList) // const list = computed(() => chartEditStore.getComponentList)
let targetData:any = ref(list.value[targetIndex.value]) // let targetData:any = ref(list.value[targetIndex.value])
// const isReady = ref(false) // const isReady = ref(false)
const init = () => { // const init = () => {
if(!targetData.value.customEvent) { // if(!targetData.value.customEvent) {
targetData.value.customEvent = { // targetData.value.customEvent = {
click: { // click: {
linkHead: 'http://', // linkHead: 'http://',
link: '', // link: '',
} // }
} // }
} // }
} // }
init() // init()
watch(() => targetIndex.value, newIndex => { // watch(() => targetIndex.value, newIndex => {
// isReady.value = false // // isReady.value = false
targetData.value = list.value[newIndex] // targetData.value = list.value[newIndex]
init() // init()
setTimeout(() => { // setTimeout(() => {
// isReady.value = true // // isReady.value = true
}) // })
}) // })
watch(() => list.value.length, () => { // watch(() => list.value.length, () => {
targetData.value = list.value[targetIndex.value] // targetData.value = list.value[targetIndex.value]
init() // init()
}) // })
const linkHeadOptions = ['http://', 'https://'].map(_ => ({label: _, value: _})) const linkHeadOptions = ['http://', 'https://'].map(_ => ({label: _, value: _}))

View File

@ -8,6 +8,11 @@ export const useTargetData = () => {
const targetData: Ref<CreateComponentType | CreateComponentGroupType> = computed(() => { const targetData: Ref<CreateComponentType | CreateComponentGroupType> = computed(() => {
const list = chartEditStore.getComponentList const list = chartEditStore.getComponentList
const targetIndex = chartEditStore.fetchTargetIndex() const targetIndex = chartEditStore.fetchTargetIndex()
// 分组时 判断是不是分组里的组件
const selectId = chartEditStore.getTargetChart.selectId[0]
if(list[targetIndex].isGroup && list[targetIndex].id !== selectId) {
return list[targetIndex].groupList!.find(_ => _.id === selectId)!
}
return list[targetIndex] return list[targetIndex]
}) })
return { targetData, chartEditStore } return { targetData, chartEditStore }

View File

@ -70,6 +70,7 @@ import { TabsEnum } from './index.d'
import { useChartLayoutStore } from '@/store/modules/chartLayoutStore/chartLayoutStore' import { useChartLayoutStore } from '@/store/modules/chartLayoutStore/chartLayoutStore'
import { ChartLayoutStoreEnum } from '@/store/modules/chartLayoutStore/chartLayoutStore.d' import { ChartLayoutStoreEnum } from '@/store/modules/chartLayoutStore/chartLayoutStore.d'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { CreateComponentType, CreateComponentGroupType } from '@/packages/index.d'
const { getDetails } = toRefs(useChartLayoutStore()) const { getDetails } = toRefs(useChartLayoutStore())
const { setItem } = useChartLayoutStore() const { setItem } = useChartLayoutStore()
@ -101,10 +102,13 @@ const selectTarget = computed(() => {
const selectId = chartEditStore.getTargetChart.selectId const selectId = chartEditStore.getTargetChart.selectId
// //
if (selectId.length !== 1) return undefined if (selectId.length !== 1) return undefined
const target = chartEditStore.componentList[chartEditStore.fetchTargetIndex()] let target: CreateComponentType | CreateComponentGroupType = chartEditStore.componentList[chartEditStore.fetchTargetIndex()]
if (target?.isGroup) { if (target?.isGroup) {
// eslint-disable-next-line vue/no-side-effects-in-computed-properties if(target.id !== selectId[0]) target = target.groupList!.find(_ => _.id === selectId[0])!
tabsSelect.value = TabsEnum.CHART_SETTING else {
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
tabsSelect.value = TabsEnum.CHART_SETTING
}
} }
return target return target
}) })

View File

@ -34,7 +34,7 @@
:componentData="element" :componentData="element"
:layer-mode="layerMode" :layer-mode="layerMode"
:isGroup="true" :isGroup="true"
@mousedown="mousedownHandle($event, element, componentGroupData.id)" @mousedown="mousedownHandle($event, element)"
@mouseenter="mouseenterHandle(element)" @mouseenter="mouseenterHandle(element)"
@mouseleave="mouseleaveHandle(element)" @mouseleave="mouseleaveHandle(element)"
@contextmenu="handleContextMenu($event, componentGroupData, optionsHandle)" @contextmenu="handleContextMenu($event, componentGroupData, optionsHandle)"
@ -78,7 +78,7 @@ const { FolderIcon, FolderOpenIcon } = icon.ionicons5
const chartEditStore = useChartEditStore() const chartEditStore = useChartEditStore()
const { handleContextMenu, onClickOutSide } = useContextMenu() const { handleContextMenu, onClickOutSide } = useContextMenu()
const expend = ref(false) const expend = ref(true)
// //
const themeColor = computed(() => { const themeColor = computed(() => {

View File

@ -205,7 +205,7 @@ const handleContextMenu = (
while (target instanceof SVGElement) { while (target instanceof SVGElement) {
target = target.parentNode target = target.parentNode
} }
console.log(targetInstance)
chartEditStore.setTargetSelectChart(targetInstance && targetInstance.id) chartEditStore.setTargetSelectChart(targetInstance && targetInstance.id)
// 隐藏旧列表 // 隐藏旧列表
@ -236,6 +236,7 @@ const handleContextMenu = (
targetInstance targetInstance
) )
} }
console.log(menuOptions.value)
nextTick().then(() => { nextTick().then(() => {
chartEditStore.setMousePosition(e.clientX, e.clientY) chartEditStore.setMousePosition(e.clientX, e.clientY)
chartEditStore.setRightMenuShow(true) chartEditStore.setRightMenuShow(true)

View File

@ -4,7 +4,6 @@ const bindEvent = (item:any) => {
let {linkHead, link} = item.customEvent.click let {linkHead, link} = item.customEvent.click
obj = { obj = {
click: () => { click: () => {
console.log(1234, linkHead,link)
if(link) window.open(`${linkHead}${link}`) if(link) window.open(`${linkHead}${link}`)
} }
} }