修改data-visualization\utils
This commit is contained in:
parent
5e24f9f74c
commit
353d0da345
@ -1,6 +1,7 @@
|
|||||||
import eventBus from '@/data-visualization/utils/eventBus'
|
import eventBus from '@/data-visualization/utils/eventBus'
|
||||||
import { dvMainStoreWithOut } from '@/data-visualization/store/modules/data-visualization/dvMain'
|
import { dvMainStoreWithOut } from '@/data-visualization/store/modules/data-visualization/dvMain'
|
||||||
import { snapshotStoreWithOut } from '@/data-visualization/store/modules/data-visualization/snapshot'
|
import { snapshotStoreWithOut } from '@/data-visualization/store/modules/data-visualization/snapshot'
|
||||||
|
import { copyStoreWithOut } from '@/data-visualization/store/modules/data-visualization/copy'
|
||||||
import { composeStoreWithOut } from '@/data-visualization/store/modules/data-visualization/compose'
|
import { composeStoreWithOut } from '@/data-visualization/store/modules/data-visualization/compose'
|
||||||
import { lockStoreWithOut } from '@/data-visualization/store/modules/data-visualization/lock'
|
import { lockStoreWithOut } from '@/data-visualization/store/modules/data-visualization/lock'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
@ -11,8 +12,9 @@ import { groupStyleRevert } from '@/data-visualization/utils/style'
|
|||||||
const dvMainStore = dvMainStoreWithOut()
|
const dvMainStore = dvMainStoreWithOut()
|
||||||
const composeStore = composeStoreWithOut()
|
const composeStore = composeStoreWithOut()
|
||||||
const snapshotStore = snapshotStoreWithOut()
|
const snapshotStore = snapshotStoreWithOut()
|
||||||
|
const copyStore = copyStoreWithOut()
|
||||||
const lockStore = lockStoreWithOut()
|
const lockStore = lockStoreWithOut()
|
||||||
const { curComponent, isInEditor, editMode } = storeToRefs(dvMainStore)
|
const { curComponent, editMode } = storeToRefs(dvMainStore)
|
||||||
const { areaData } = storeToRefs(composeStore)
|
const { areaData } = storeToRefs(composeStore)
|
||||||
|
|
||||||
const ctrlKey = 17,
|
const ctrlKey = 17,
|
||||||
@ -86,7 +88,10 @@ const checkDialog = () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
document.querySelectorAll('.ed-popper').forEach(element => {
|
document.querySelectorAll('.ed-popper').forEach(element => {
|
||||||
if (window.getComputedStyle(element).getPropertyValue('display') != 'none') {
|
if (
|
||||||
|
!element.classList?.contains('template-popper-tips') &&
|
||||||
|
window.getComputedStyle(element).getPropertyValue('display') != 'none'
|
||||||
|
) {
|
||||||
haveDialog = true
|
haveDialog = true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -172,10 +177,11 @@ function releaseKeyCheck(keyType) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function copy() {
|
function copy() {
|
||||||
|
copyStore.copy()
|
||||||
}
|
}
|
||||||
|
|
||||||
function paste() {
|
function paste() {
|
||||||
|
copyStore.paste(false)
|
||||||
snapshotStore.recordSnapshotCache('key-paste')
|
snapshotStore.recordSnapshotCache('key-paste')
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,6 +224,7 @@ function groupAreaAdaptor(leftOffset = 0, topOffset = 0) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function cut() {
|
function cut() {
|
||||||
|
copyStore.cut()
|
||||||
}
|
}
|
||||||
|
|
||||||
function redo() {
|
function redo() {
|
||||||
|
22
frontend/src/data-visualization/utils/RemoteJs.ts
Normal file
22
frontend/src/data-visualization/utils/RemoteJs.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
export const loadScript = (url: string, jsId?: string) => {
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
const scriptId = jsId || 'de-fit2cloud-script-id'
|
||||||
|
let dom = document.getElementById(scriptId)
|
||||||
|
if (dom) {
|
||||||
|
dom.parentElement?.removeChild(dom)
|
||||||
|
dom = null
|
||||||
|
}
|
||||||
|
const script = document.createElement('script')
|
||||||
|
|
||||||
|
script.id = scriptId
|
||||||
|
script.onload = function () {
|
||||||
|
return resolve(null)
|
||||||
|
}
|
||||||
|
script.onerror = function () {
|
||||||
|
return reject(new Error('Load script from '.concat(url, ' failed')))
|
||||||
|
}
|
||||||
|
script.src = url
|
||||||
|
const head = document.head || document.getElementsByTagName('head')[0]
|
||||||
|
;(document.body || head).appendChild(script)
|
||||||
|
})
|
||||||
|
}
|
@ -6,6 +6,7 @@ import {
|
|||||||
} from '@/data-visualization/chart/components/editor/util/chart'
|
} from '@/data-visualization/chart/components/editor/util/chart'
|
||||||
|
|
||||||
import { dvMainStoreWithOut } from '@/data-visualization/store/modules/data-visualization/dvMain'
|
import { dvMainStoreWithOut } from '@/data-visualization/store/modules/data-visualization/dvMain'
|
||||||
|
import { useEmitt } from '@/data-visualization/hooks/web/useEmitt'
|
||||||
import { defaultTo, merge } from 'lodash-es'
|
import { defaultTo, merge } from 'lodash-es'
|
||||||
const dvMainStore = dvMainStoreWithOut()
|
const dvMainStore = dvMainStoreWithOut()
|
||||||
|
|
||||||
@ -157,6 +158,9 @@ export const customStyleTrans = {
|
|||||||
axisLabel: ['fontSize'],
|
axisLabel: ['fontSize'],
|
||||||
splitLine: {
|
splitLine: {
|
||||||
lineStyle: ['width']
|
lineStyle: ['width']
|
||||||
|
},
|
||||||
|
axisLine: {
|
||||||
|
lineStyle: ['width']
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
yAxis: {
|
yAxis: {
|
||||||
@ -164,6 +168,9 @@ export const customStyleTrans = {
|
|||||||
axisLabel: ['fontSize'],
|
axisLabel: ['fontSize'],
|
||||||
splitLine: {
|
splitLine: {
|
||||||
lineStyle: ['width']
|
lineStyle: ['width']
|
||||||
|
},
|
||||||
|
axisLine: {
|
||||||
|
lineStyle: ['width']
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
yAxisExt: {
|
yAxisExt: {
|
||||||
@ -171,6 +178,9 @@ export const customStyleTrans = {
|
|||||||
axisLabel: ['fontSize'],
|
axisLabel: ['fontSize'],
|
||||||
splitLine: {
|
splitLine: {
|
||||||
lineStyle: ['width']
|
lineStyle: ['width']
|
||||||
|
},
|
||||||
|
axisLine: {
|
||||||
|
lineStyle: ['width']
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
misc: {
|
misc: {
|
||||||
@ -283,7 +293,14 @@ export const THEME_ATTR_TRANS_MAIN = {
|
|||||||
color: 'color',
|
color: 'color',
|
||||||
proportionSeriesFormatter: ['color']
|
proportionSeriesFormatter: ['color']
|
||||||
},
|
},
|
||||||
tooltip: ['color']
|
tooltip: ['color'],
|
||||||
|
misc: {
|
||||||
|
bullet: {
|
||||||
|
bar: {
|
||||||
|
target: ['fill']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const THEME_ATTR_TRANS_MAIN_SYMBOL = {
|
export const THEME_ATTR_TRANS_MAIN_SYMBOL = {
|
||||||
@ -450,7 +467,32 @@ export function adaptTitleFontFamily(fontFamily, viewInfo) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function adaptTitleFontFamilyAll(fontFamily) {
|
export function adaptTitleFontFamilyAll(fontFamily) {
|
||||||
|
const componentData = dvMainStore.componentData
|
||||||
|
componentData.forEach(item => {
|
||||||
|
if (item.component === 'UserView') {
|
||||||
|
const viewDetails = dvMainStore.canvasViewInfo[item.id]
|
||||||
|
adaptTitleFontFamily(fontFamily, viewDetails)
|
||||||
|
useEmitt().emitter.emit('renderChart-' + item.id, viewDetails)
|
||||||
|
} else if (item.component === 'Group') {
|
||||||
|
item.propValue.forEach(groupItem => {
|
||||||
|
if (groupItem.component === 'UserView') {
|
||||||
|
const viewDetails = dvMainStore.canvasViewInfo[groupItem.id]
|
||||||
|
adaptTitleFontFamily(fontFamily, viewDetails)
|
||||||
|
useEmitt().emitter.emit('renderChart-' + groupItem.id, viewDetails)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else if (item.component === 'DeTabs') {
|
||||||
|
item.propValue.forEach(tabItem => {
|
||||||
|
tabItem.componentData.forEach(tabComponent => {
|
||||||
|
if (tabComponent.component === 'UserView') {
|
||||||
|
const viewDetails = dvMainStore.canvasViewInfo[tabComponent.id]
|
||||||
|
adaptTitleFontFamily(fontFamily, viewDetails)
|
||||||
|
useEmitt().emitter.emit('renderChart-' + tabComponent.id, viewDetails)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function adaptCurThemeCommonStyle(component) {
|
export function adaptCurThemeCommonStyle(component) {
|
||||||
@ -460,9 +502,16 @@ export function adaptCurThemeCommonStyle(component) {
|
|||||||
// 背景融合-Begin 如果是大屏['CanvasBoard', 'CanvasIcon', 'Picture']组件不需要设置背景
|
// 背景融合-Begin 如果是大屏['CanvasBoard', 'CanvasIcon', 'Picture']组件不需要设置背景
|
||||||
if (
|
if (
|
||||||
dvMainStore.dvInfo.type === 'dataV' &&
|
dvMainStore.dvInfo.type === 'dataV' &&
|
||||||
['CanvasBoard', 'CanvasIcon', 'Picture', 'Group', 'SvgTriangle', 'SvgStar'].includes(
|
[
|
||||||
component.component
|
'CanvasBoard',
|
||||||
)
|
'CanvasIcon',
|
||||||
|
'Picture',
|
||||||
|
'Group',
|
||||||
|
'SvgTriangle',
|
||||||
|
'SvgStar',
|
||||||
|
'RectShape',
|
||||||
|
'CircleShape'
|
||||||
|
].includes(component.component)
|
||||||
) {
|
) {
|
||||||
component.commonBackground['backgroundColorSelect'] = false
|
component.commonBackground['backgroundColorSelect'] = false
|
||||||
component.commonBackground['innerPadding'] = 0
|
component.commonBackground['innerPadding'] = 0
|
||||||
@ -485,7 +534,7 @@ export function adaptCurThemeCommonStyle(component) {
|
|||||||
// 图表-Begin
|
// 图表-Begin
|
||||||
const curViewInfo = dvMainStore.canvasViewInfo[component.id]
|
const curViewInfo = dvMainStore.canvasViewInfo[component.id]
|
||||||
adaptCurTheme(curViewInfo.customStyle, curViewInfo.customAttr)
|
adaptCurTheme(curViewInfo.customStyle, curViewInfo.customAttr)
|
||||||
|
useEmitt().emitter.emit('renderChart-' + component.id, curViewInfo)
|
||||||
// 图表-Begin
|
// 图表-Begin
|
||||||
} else if (component.component === 'Group') {
|
} else if (component.component === 'Group') {
|
||||||
component.propValue.forEach(groupItem => {
|
component.propValue.forEach(groupItem => {
|
||||||
|
@ -2,7 +2,7 @@ import { deepCopy } from './utils'
|
|||||||
import { divide, multiply } from 'mathjs'
|
import { divide, multiply } from 'mathjs'
|
||||||
import { dvMainStoreWithOut } from '@/data-visualization/store/modules/data-visualization/dvMain'
|
import { dvMainStoreWithOut } from '@/data-visualization/store/modules/data-visualization/dvMain'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
import { groupSizeStyleAdaptor } from '@/data-visualization/utils/style'
|
import { groupItemStyleAdaptor, groupSizeStyleAdaptor } from '@/data-visualization/utils/style'
|
||||||
import { nextTick } from 'vue'
|
import { nextTick } from 'vue'
|
||||||
|
|
||||||
const dvMainStore = dvMainStoreWithOut()
|
const dvMainStore = dvMainStoreWithOut()
|
||||||
@ -53,7 +53,17 @@ function changeComponentsSizeWithScaleCircle(componentDataCopy, scale) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (['Group'].includes(component.component)) {
|
if (['Group'].includes(component.component)) {
|
||||||
changeComponentsSizeWithScaleCircle(component.propValue, scale)
|
groupSizeStyleAdaptor(component)
|
||||||
|
const parentStyle = component.style
|
||||||
|
component.propValue.forEach(componentInner => {
|
||||||
|
if (['DeTabs'].includes(componentInner.component)) {
|
||||||
|
componentInner.propValue.forEach(tabItem => {
|
||||||
|
changeComponentsSizeWithScaleCircle(tabItem.componentData, scale)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
groupItemStyleAdaptor(componentInner, parentStyle)
|
||||||
|
}
|
||||||
|
})
|
||||||
} else if (['DeTabs'].includes(component.component)) {
|
} else if (['DeTabs'].includes(component.component)) {
|
||||||
component.propValue.forEach(tabItem => {
|
component.propValue.forEach(tabItem => {
|
||||||
changeComponentsSizeWithScaleCircle(tabItem.componentData, scale)
|
changeComponentsSizeWithScaleCircle(tabItem.componentData, scale)
|
||||||
|
@ -51,32 +51,32 @@ export const componentsMap = {
|
|||||||
CanvasBoardAttr: CanvasBoardAttr,
|
CanvasBoardAttr: CanvasBoardAttr,
|
||||||
CanvasIcon: CanvasIcon,
|
CanvasIcon: CanvasIcon,
|
||||||
CanvasIconAttr: CanvasIconAttr,
|
CanvasIconAttr: CanvasIconAttr,
|
||||||
// DeTabs: DeTabs,
|
DeTabs: DeTabs,
|
||||||
// DeTabsAttr: DeTabsAttr,
|
DeTabsAttr: DeTabsAttr,
|
||||||
// DeGraphical: DeGraphical,
|
DeGraphical: DeGraphical,
|
||||||
// DeGraphicalAttr: DeGraphicalAttr,
|
DeGraphicalAttr: DeGraphicalAttr,
|
||||||
// CircleShape: CircleShape,
|
CircleShape: CircleShape,
|
||||||
// CircleShapeAttr: CircleShapeAttr,
|
CircleShapeAttr: CircleShapeAttr,
|
||||||
// RectShape: RectShape,
|
RectShape: RectShape,
|
||||||
// RectShapeAttr: RectShapeAttr,
|
RectShapeAttr: RectShapeAttr,
|
||||||
// SvgTriangle: SvgTriangle,
|
SvgTriangle: SvgTriangle,
|
||||||
// SvgTriangleAttr: SvgTriangleAttr,
|
SvgTriangleAttr: SvgTriangleAttr,
|
||||||
// DeTimeClock: DeTimeClock,
|
DeTimeClock: DeTimeClock,
|
||||||
// DeTimeClockAttr: DeTimeClockAttr,
|
DeTimeClockAttr: DeTimeClockAttr,
|
||||||
// GroupArea: GroupArea,
|
GroupArea: GroupArea,
|
||||||
// GroupAreaAttr: GroupAreaAttr,
|
GroupAreaAttr: GroupAreaAttr,
|
||||||
// DeFrame: DeFrame,
|
DeFrame: DeFrame,
|
||||||
// DeFrameAttr: DeFrameAttr,
|
DeFrameAttr: DeFrameAttr,
|
||||||
// DeVideo: DeVideo,
|
DeVideo: DeVideo,
|
||||||
// DeVideoAttr: DeVideoAttr,
|
DeVideoAttr: DeVideoAttr,
|
||||||
// DeStreamMedia: DeStreamMedia,
|
DeStreamMedia: DeStreamMedia,
|
||||||
// DeStreamMediaAttr: DeStreamMediaAttr,
|
DeStreamMediaAttr: DeStreamMediaAttr,
|
||||||
// ScrollText: ScrollText,
|
ScrollText: ScrollText,
|
||||||
// ScrollTextAttr: ScrollTextAttr,
|
ScrollTextAttr: ScrollTextAttr,
|
||||||
// PopArea: PopArea,
|
PopArea: PopArea,
|
||||||
// PopAreaAttr: PopAreaAttr,
|
PopAreaAttr: PopAreaAttr,
|
||||||
// PictureGroup: PictureGroup,
|
PictureGroup: PictureGroup,
|
||||||
// PictureGroupAttr: PictureGroupAttr
|
PictureGroupAttr: PictureGroupAttr
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function findComponent(key) {
|
export default function findComponent(key) {
|
||||||
|
@ -3,11 +3,20 @@ export default function decomposeComponent(
|
|||||||
component,
|
component,
|
||||||
editorRect,
|
editorRect,
|
||||||
parentStyle,
|
parentStyle,
|
||||||
canvasId = 'canvas-main'
|
canvasId = 'canvas-main',
|
||||||
|
parentGroupStyle?
|
||||||
) {
|
) {
|
||||||
// 计算出元素新的 top left 坐标
|
// 计算出元素新的 top left 坐标
|
||||||
component.style.left = component.style.left + parentStyle.left
|
component.style.left = component.style.left + parentStyle.left
|
||||||
component.style.top = component.style.top + parentStyle.top
|
component.style.top = component.style.top + parentStyle.top
|
||||||
component.groupStyle = {}
|
if (parentGroupStyle && component.groupStyle) {
|
||||||
|
const originLeftScale = component.groupStyle['left'] / component.groupStyle['width']
|
||||||
|
const originTopScale = component.groupStyle['top'] / component.groupStyle['height']
|
||||||
|
component.groupStyle['width'] = component.groupStyle['width'] * parentGroupStyle['width']
|
||||||
|
component.groupStyle['height'] = component.groupStyle['height'] * parentGroupStyle['height']
|
||||||
|
component.groupStyle['left'] =
|
||||||
|
parentStyle.left + component.groupStyle['width'] * originLeftScale
|
||||||
|
component.groupStyle['top'] = parentStyle.top + component.groupStyle['height'] * originTopScale
|
||||||
|
}
|
||||||
component.canvasId = canvasId
|
component.canvasId = canvasId
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
import html2canvas from 'html2canvas'
|
import html2canvas from 'html2canvas'
|
||||||
import JsPDF from 'jspdf'
|
import JsPDF from 'jspdf'
|
||||||
import { dvMainStoreWithOut } from '@/data-visualization/store/modules/data-visualization/dvMain'
|
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
|
||||||
import { useEmbedded } from '@/data-visualization/store/modules/embedded'
|
import { useEmbedded } from '@/store/modules/embedded'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
import { findResourceAsBase64 } from '@/api/data-visualization/staticResource'
|
import { findResourceAsBase64 } from '@/api/staticResource'
|
||||||
|
import FileSaver from 'file-saver'
|
||||||
|
import { deepCopy } from '@/utils/utils'
|
||||||
import { toPng } from 'html-to-image'
|
import { toPng } from 'html-to-image'
|
||||||
const embeddedStore = useEmbedded()
|
const embeddedStore = useEmbedded()
|
||||||
const dvMainStore = dvMainStoreWithOut()
|
const dvMainStore = dvMainStoreWithOut()
|
||||||
const { canvasStyleData, componentData, canvasViewInfo, canvasViewDataInfo, dvInfo } =
|
const { canvasStyleData, componentData, canvasViewInfo, canvasViewDataInfo, dvInfo } =
|
||||||
storeToRefs(dvMainStore)
|
storeToRefs(dvMainStore)
|
||||||
const basePath = import.meta.env.VITE_API_BASE_URL
|
const basePath = import.meta.env.VITE_API_BASEPATH
|
||||||
|
|
||||||
export function formatterUrl(url: string) {
|
export function formatterUrl(url: string) {
|
||||||
return url.replace('//de2api', '/de2api')
|
return url.replace('//de2api', '/de2api')
|
||||||
@ -35,7 +37,39 @@ export function imgUrlTrans(url) {
|
|||||||
|
|
||||||
export function download2AppTemplate(downloadType, canvasDom, name, attachParams, callBack?) {
|
export function download2AppTemplate(downloadType, canvasDom, name, attachParams, callBack?) {
|
||||||
try {
|
try {
|
||||||
|
findStaticSource(function (staticResource) {
|
||||||
|
html2canvas(canvasDom).then(canvas => {
|
||||||
|
const canvasViewDataTemplate = deepCopy(canvasViewInfo.value)
|
||||||
|
Object.keys(canvasViewDataTemplate).forEach(viewId => {
|
||||||
|
canvasViewDataTemplate[viewId].data = canvasViewDataInfo.value[viewId]
|
||||||
|
})
|
||||||
|
const snapshot = canvas.toDataURL('image/jpeg', 0.1) // 0.1是图片质量
|
||||||
|
if (snapshot !== '') {
|
||||||
|
const templateInfo = {
|
||||||
|
name: name,
|
||||||
|
templateType: 'self',
|
||||||
|
snapshot: snapshot,
|
||||||
|
dvType: dvInfo.value.type,
|
||||||
|
nodeType: downloadType,
|
||||||
|
version: 3,
|
||||||
|
canvasStyleData: JSON.stringify(canvasStyleData.value),
|
||||||
|
componentData: JSON.stringify(componentData.value),
|
||||||
|
dynamicData: JSON.stringify(canvasViewDataTemplate),
|
||||||
|
staticResource: JSON.stringify(staticResource || {}),
|
||||||
|
appData: attachParams ? JSON.stringify(attachParams) : null
|
||||||
|
}
|
||||||
|
const blob = new Blob([JSON.stringify(templateInfo)], { type: '' })
|
||||||
|
if (downloadType === 'template') {
|
||||||
|
FileSaver.saveAs(blob, name + '-TEMPLATE.DET2')
|
||||||
|
} else if (downloadType === 'app') {
|
||||||
|
FileSaver.saveAs(blob, name + '-APP.DET2APP')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (callBack) {
|
||||||
|
callBack()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (callBack) {
|
if (callBack) {
|
||||||
callBack()
|
callBack()
|
||||||
@ -140,7 +174,8 @@ function findStaticSourceInner(componentDataInfo, staticResource) {
|
|||||||
) {
|
) {
|
||||||
staticResource.push(item.propValue['url'])
|
staticResource.push(item.propValue['url'])
|
||||||
} else if (
|
} else if (
|
||||||
item.component === 'picture-group' &&
|
item.component === 'UserView' &&
|
||||||
|
item.innerType === 'picture-group' &&
|
||||||
item.propValue['urlList'] &&
|
item.propValue['urlList'] &&
|
||||||
item.propValue['urlList'].length > 0
|
item.propValue['urlList'].length > 0
|
||||||
) {
|
) {
|
||||||
|
@ -267,11 +267,14 @@ function dataVTabSizeStyleAdaptor(tabComponent) {
|
|||||||
tabComponent.propValue.forEach(tabItem => {
|
tabComponent.propValue.forEach(tabItem => {
|
||||||
tabItem.componentData.forEach(tabComponent => {
|
tabItem.componentData.forEach(tabComponent => {
|
||||||
groupItemStyleAdaptor(tabComponent, parentStyleAdaptor)
|
groupItemStyleAdaptor(tabComponent, parentStyleAdaptor)
|
||||||
|
if (['Group'].includes(tabComponent.component)) {
|
||||||
|
groupSizeStyleAdaptor(tabComponent)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function groupItemStyleAdaptor(component, parentStyle) {
|
export function groupItemStyleAdaptor(component, parentStyle) {
|
||||||
// 分组还原逻辑
|
// 分组还原逻辑
|
||||||
// 当发上分组缩放是,要将内部组件按照比例转换
|
// 当发上分组缩放是,要将内部组件按照比例转换
|
||||||
const styleScale = component.groupStyle
|
const styleScale = component.groupStyle
|
||||||
|
@ -75,23 +75,6 @@ const getSecondEnd = timestamp => {
|
|||||||
return [+new Date(timestamp), +new Date(timestamp) + 999]
|
return [+new Date(timestamp), +new Date(timestamp) + 999]
|
||||||
}
|
}
|
||||||
|
|
||||||
const getYearBegin = timestamp => {
|
|
||||||
const time = new Date(timestamp)
|
|
||||||
return +new Date(time.getFullYear(), 0, 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
const getMonthBegin = timestamp => {
|
|
||||||
const time = new Date(timestamp)
|
|
||||||
const date = new Date(time.getFullYear(), time.getMonth(), 1)
|
|
||||||
date.setDate(1)
|
|
||||||
date.setMonth(date.getMonth() + 1)
|
|
||||||
return +new Date(time.getFullYear(), time.getMonth(), 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
const getDayBegin = timestamp => {
|
|
||||||
return +new Date(timestamp)
|
|
||||||
}
|
|
||||||
|
|
||||||
const getUtcTime = timestamp => {
|
const getUtcTime = timestamp => {
|
||||||
if (timestamp) {
|
if (timestamp) {
|
||||||
const time = new Date(timestamp)
|
const time = new Date(timestamp)
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
export function deepCopy(target: any) {
|
import { useCache } from '@/data-visualization/hooks/web/useCache'
|
||||||
|
import { loadScript } from '@/data-visualization/utils/RemoteJs'
|
||||||
|
import { ElMessage } from 'element-plus-secondary'
|
||||||
|
|
||||||
|
const { wsCache } = useCache()
|
||||||
|
export function deepCopy(target) {
|
||||||
if (target === null || target === undefined) {
|
if (target === null || target === undefined) {
|
||||||
return target
|
return target
|
||||||
} else if (typeof target == 'object') {
|
} else if (typeof target == 'object') {
|
||||||
const result: any = Array.isArray(target) ? [] : {}
|
const result = Array.isArray(target) ? [] : {}
|
||||||
for (const key in target) {
|
for (const key in target) {
|
||||||
if (target[key] === null || target[key] === undefined) {
|
if (target[key] === null || target[key] === undefined) {
|
||||||
result[key] = target[key]
|
result[key] = target[key]
|
||||||
@ -20,26 +25,26 @@ export function deepCopy(target: any) {
|
|||||||
return target
|
return target
|
||||||
}
|
}
|
||||||
|
|
||||||
export function swap(arr: any, i: any, j: any) {
|
export function swap(arr, i, j) {
|
||||||
const temp = arr[i]
|
const temp = arr[i]
|
||||||
arr[i] = arr[j]
|
arr[i] = arr[j]
|
||||||
arr[j] = temp
|
arr[j] = temp
|
||||||
}
|
}
|
||||||
|
|
||||||
export function _$(selector: any) {
|
export function _$(selector) {
|
||||||
return document.querySelector(selector)
|
return document.querySelector(selector)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function $(selector: any) {
|
export function $(selector) {
|
||||||
return document.querySelector(selector)
|
return document.querySelector(selector)
|
||||||
}
|
}
|
||||||
|
|
||||||
const components = ['VText', 'RectShape', 'CircleShape']
|
const components = ['VText', 'RectShape', 'CircleShape']
|
||||||
export function isPreventDrop(component: any) {
|
export function isPreventDrop(component) {
|
||||||
return !components.includes(component) && !component.startsWith('SVG')
|
return !components.includes(component) && !component.startsWith('SVG')
|
||||||
}
|
}
|
||||||
|
|
||||||
export function checkAddHttp(url: any) {
|
export function checkAddHttp(url) {
|
||||||
if (!url) {
|
if (!url) {
|
||||||
return url
|
return url
|
||||||
} else if (/^(http(s)?:\/\/)/.test(url.toLowerCase())) {
|
} else if (/^(http(s)?:\/\/)/.test(url.toLowerCase())) {
|
||||||
@ -101,6 +106,8 @@ export const checkPlatform = () => {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
export const cleanPlatformFlag = () => {
|
export const cleanPlatformFlag = () => {
|
||||||
|
const platformKey = 'out_auth_platform'
|
||||||
|
wsCache.delete(platformKey)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
export const isInIframe = () => {
|
export const isInIframe = () => {
|
||||||
@ -135,6 +142,33 @@ export function isISOMobile() {
|
|||||||
|
|
||||||
export const isDingTalk = window.navigator.userAgent.toLowerCase().includes('dingtalk')
|
export const isDingTalk = window.navigator.userAgent.toLowerCase().includes('dingtalk')
|
||||||
|
|
||||||
|
export const setTitle = (title?: string) => {
|
||||||
|
if (!isDingTalk) {
|
||||||
|
document.title = title || 'DataEase'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const jsUrl = 'https://g.alicdn.com/dingding/dingtalk-jsapi/3.0.25/dingtalk.open.js'
|
||||||
|
const jsId = 'fit2cloud-dataease-v2-platform-client-dingtalk'
|
||||||
|
if (window['dd'] && window['dd'].biz?.navigation?.setTitle) {
|
||||||
|
window['dd'].biz.navigation.setTitle({
|
||||||
|
title: title
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const awaitMethod = loadScript(jsUrl, jsId)
|
||||||
|
awaitMethod
|
||||||
|
.then(() => {
|
||||||
|
window['dd'].ready(() => {
|
||||||
|
window['dd'].biz.navigation.setTitle({
|
||||||
|
title: title
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
document.title = title || 'DataEase'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export function isTablet() {
|
export function isTablet() {
|
||||||
const userAgent = navigator.userAgent
|
const userAgent = navigator.userAgent
|
||||||
const tabletRegex = /iPad|Silk|Galaxy Tab|PlayBook|BlackBerry|(tablet|ipad|playbook)/i
|
const tabletRegex = /iPad|Silk|Galaxy Tab|PlayBook|BlackBerry|(tablet|ipad|playbook)/i
|
||||||
@ -199,8 +233,76 @@ export const getBrowserLocale = () => {
|
|||||||
}
|
}
|
||||||
return language
|
return language
|
||||||
}
|
}
|
||||||
|
export const getLocale = () => {
|
||||||
|
return wsCache.get('user.language') || getBrowserLocale() || 'zh-CN'
|
||||||
export const nameTrim = (target: {}, msg = '名称字段长度1-64个字符') => {
|
}
|
||||||
|
|
||||||
|
export const isFreeFolder = (node, flag) => {
|
||||||
|
const oid = wsCache.get('user.oid')
|
||||||
|
if (!oid) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
const freeRootId = (Number(oid) + flag).toString()
|
||||||
|
let cNode = node
|
||||||
|
while (cNode) {
|
||||||
|
const data = cNode.data
|
||||||
|
const id = data['id']
|
||||||
|
if (id === freeRootId) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
cNode = cNode['parent']
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
export const filterFreeFolder = (list, flagText) => {
|
||||||
|
const flagArray = ['dashboard', 'dataV', 'dataset', 'datasource']
|
||||||
|
const index = flagArray.findIndex(item => item === flagText)
|
||||||
|
const oid = wsCache.get('user.oid')
|
||||||
|
if (!oid || index < 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const freeRootId = (Number(oid) + index + 1).toString()
|
||||||
|
let len = list.length
|
||||||
|
while (len--) {
|
||||||
|
const node = list[len]
|
||||||
|
if (node['id'] === freeRootId) {
|
||||||
|
list.splice(len, 1)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (node['id'] === '0') {
|
||||||
|
const children = node['children']
|
||||||
|
let innerLen = children?.length
|
||||||
|
while (innerLen--) {
|
||||||
|
const kid = children[innerLen]
|
||||||
|
if (kid['id'] === freeRootId) {
|
||||||
|
children.splice(innerLen, 1)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export const nameTrim = (target: {}, msg = '名称字段长度1-64个字符') => {
|
||||||
|
if (target.name) {
|
||||||
|
target.name = target.name.trim()
|
||||||
|
if (target.name.length < 1 || target.name.length > 64) {
|
||||||
|
ElMessage.warning(msg)
|
||||||
|
throw new Error(msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getActiveCategories = contents => {
|
||||||
|
const result = ['最近使用']
|
||||||
|
if (contents) {
|
||||||
|
contents.forEach(item => {
|
||||||
|
if (item.showFlag) {
|
||||||
|
item.categories.forEach(category => {
|
||||||
|
result.push(category.name)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return new Set(result)
|
||||||
}
|
}
|
||||||
|
@ -10,25 +10,25 @@ export function viewFieldTimeTrans(viewDataInfo, params) {
|
|||||||
: []
|
: []
|
||||||
|
|
||||||
const idNameMap = fields.reduce((pre, next) => {
|
const idNameMap = fields.reduce((pre, next) => {
|
||||||
pre[next['id']] = next['dataeaseName']
|
pre[next['id']] = next['gisbiName']
|
||||||
return pre
|
return pre
|
||||||
}, {})
|
}, {})
|
||||||
|
|
||||||
const nameTypeMap = fields.reduce((pre, next) => {
|
const nameTypeMap = fields.reduce((pre, next) => {
|
||||||
pre[next['dataeaseName']] = next['deType']
|
pre[next['gisbiName']] = next['deType']
|
||||||
return pre
|
return pre
|
||||||
}, {})
|
}, {})
|
||||||
|
|
||||||
const nameDateStyleMap = fields.reduce((pre, next) => {
|
const nameDateStyleMap = fields.reduce((pre, next) => {
|
||||||
pre[next['dataeaseName']] = next['dateStyle']
|
pre[next['gisbiName']] = next['dateStyle']
|
||||||
return pre
|
return pre
|
||||||
}, {})
|
}, {})
|
||||||
|
|
||||||
params.dimensionList.forEach(dimension => {
|
params.dimensionList.forEach(dimension => {
|
||||||
const dataeaseName = idNameMap[dimension.id]
|
const gisbiName = idNameMap[dimension.id]
|
||||||
// deType === 1 表示是时间类型
|
// deType === 1 表示是时间类型
|
||||||
if (nameTypeMap[dataeaseName] === 1) {
|
if (nameTypeMap[gisbiName] === 1) {
|
||||||
dimension['timeValue'] = getRange(dimension.value, nameDateStyleMap[dataeaseName])
|
dimension['timeValue'] = getRange(dimension.value, nameDateStyleMap[gisbiName])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user