mirror of
https://github.com/dataease/dataease.git
synced 2026-05-21 12:45:37 +08:00
feat:增加仪表盘设计组件及设计
This commit is contained in:
60
frontend/src/components/vue-drag-resize-rotate/dom.js
Normal file
60
frontend/src/components/vue-drag-resize-rotate/dom.js
Normal file
@@ -0,0 +1,60 @@
|
||||
import { isFunction } from './fns'
|
||||
|
||||
// 将选择器与父元素匹配
|
||||
export function matchesSelectorToParentElements (el, selector, baseNode) {
|
||||
let node = el
|
||||
|
||||
const matchesSelectorFunc = [
|
||||
'matches',
|
||||
'webkitMatchesSelector',
|
||||
'mozMatchesSelector',
|
||||
'msMatchesSelector',
|
||||
'oMatchesSelector'
|
||||
].find(func => isFunction(node[func]))
|
||||
|
||||
if (!isFunction(node[matchesSelectorFunc])) return false
|
||||
|
||||
do {
|
||||
if (node[matchesSelectorFunc](selector)) return true
|
||||
if (node === baseNode) return false
|
||||
node = node.parentNode
|
||||
} while (node)
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
export function getComputedSize ($el) {
|
||||
const style = window.getComputedStyle($el)
|
||||
|
||||
return [
|
||||
parseFloat(style.getPropertyValue('width'), 10),
|
||||
parseFloat(style.getPropertyValue('height'), 10)
|
||||
]
|
||||
}
|
||||
// 添加事件
|
||||
export function addEvent (el, event, handler) {
|
||||
if (!el) {
|
||||
return
|
||||
}
|
||||
if (el.attachEvent) {
|
||||
el.attachEvent('on' + event, handler)
|
||||
} else if (el.addEventListener) {
|
||||
el.addEventListener(event, handler, true)
|
||||
} else {
|
||||
el['on' + event] = handler
|
||||
}
|
||||
}
|
||||
|
||||
// 删除事件
|
||||
export function removeEvent (el, event, handler) {
|
||||
if (!el) {
|
||||
return
|
||||
}
|
||||
if (el.detachEvent) {
|
||||
el.detachEvent('on' + event, handler)
|
||||
} else if (el.removeEventListener) {
|
||||
el.removeEventListener(event, handler, true)
|
||||
} else {
|
||||
el['on' + event] = null
|
||||
}
|
||||
}
|
||||
40
frontend/src/components/vue-drag-resize-rotate/fns.js
Normal file
40
frontend/src/components/vue-drag-resize-rotate/fns.js
Normal file
@@ -0,0 +1,40 @@
|
||||
export function isFunction (func) {
|
||||
return (typeof func === 'function' || Object.prototype.toString.call(func) === '[object Function]')
|
||||
}
|
||||
|
||||
// 对其栅格
|
||||
export function snapToGrid (grid, pendingX, pendingY, scale = 1) {
|
||||
const x = Math.round((pendingX / scale) / grid[0]) * grid[0]
|
||||
const y = Math.round((pendingY / scale) / grid[1]) * grid[1]
|
||||
return [x, y]
|
||||
}
|
||||
|
||||
// 获取rect模型
|
||||
export function getSize (el) {
|
||||
const rect = el.getBoundingClientRect()
|
||||
|
||||
return [
|
||||
parseInt(rect.width),
|
||||
parseInt(rect.height)
|
||||
]
|
||||
}
|
||||
|
||||
export function computeWidth (parentWidth, left, right) {
|
||||
return parentWidth - left - right
|
||||
}
|
||||
|
||||
export function computeHeight (parentHeight, top, bottom) {
|
||||
return parentHeight - top - bottom
|
||||
}
|
||||
|
||||
export function restrictToBounds (value, min, max) {
|
||||
if (min !== null && value < min) {
|
||||
return min
|
||||
}
|
||||
|
||||
if (max !== null && max < value) {
|
||||
return max
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
1506
frontend/src/components/vue-drag-resize-rotate/index.vue
Normal file
1506
frontend/src/components/vue-drag-resize-rotate/index.vue
Normal file
File diff suppressed because it is too large
Load Diff
60
frontend/src/components/vue-drag-resize/dom.js
Normal file
60
frontend/src/components/vue-drag-resize/dom.js
Normal file
@@ -0,0 +1,60 @@
|
||||
import { isFunction } from './fns'
|
||||
|
||||
// 将选择器与父元素匹配
|
||||
export function matchesSelectorToParentElements (el, selector, baseNode) {
|
||||
let node = el
|
||||
|
||||
const matchesSelectorFunc = [
|
||||
'matches',
|
||||
'webkitMatchesSelector',
|
||||
'mozMatchesSelector',
|
||||
'msMatchesSelector',
|
||||
'oMatchesSelector'
|
||||
].find(func => isFunction(node[func]))
|
||||
|
||||
if (!isFunction(node[matchesSelectorFunc])) return false
|
||||
|
||||
do {
|
||||
if (node[matchesSelectorFunc](selector)) return true
|
||||
if (node === baseNode) return false
|
||||
node = node.parentNode
|
||||
} while (node)
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
export function getComputedSize ($el) {
|
||||
const style = window.getComputedStyle($el)
|
||||
|
||||
return [
|
||||
parseFloat(style.getPropertyValue('width'), 10),
|
||||
parseFloat(style.getPropertyValue('height'), 10)
|
||||
]
|
||||
}
|
||||
// 添加事件
|
||||
export function addEvent (el, event, handler) {
|
||||
if (!el) {
|
||||
return
|
||||
}
|
||||
if (el.attachEvent) {
|
||||
el.attachEvent('on' + event, handler)
|
||||
} else if (el.addEventListener) {
|
||||
el.addEventListener(event, handler, true)
|
||||
} else {
|
||||
el['on' + event] = handler
|
||||
}
|
||||
}
|
||||
|
||||
// 删除事件
|
||||
export function removeEvent (el, event, handler) {
|
||||
if (!el) {
|
||||
return
|
||||
}
|
||||
if (el.detachEvent) {
|
||||
el.detachEvent('on' + event, handler)
|
||||
} else if (el.removeEventListener) {
|
||||
el.removeEventListener(event, handler, true)
|
||||
} else {
|
||||
el['on' + event] = null
|
||||
}
|
||||
}
|
||||
40
frontend/src/components/vue-drag-resize/fns.js
Normal file
40
frontend/src/components/vue-drag-resize/fns.js
Normal file
@@ -0,0 +1,40 @@
|
||||
export function isFunction (func) {
|
||||
return (typeof func === 'function' || Object.prototype.toString.call(func) === '[object Function]')
|
||||
}
|
||||
|
||||
// 对其栅格
|
||||
export function snapToGrid (grid, pendingX, pendingY, scale = 1) {
|
||||
const x = Math.round((pendingX / scale) / grid[0]) * grid[0]
|
||||
const y = Math.round((pendingY / scale) / grid[1]) * grid[1]
|
||||
return [x, y]
|
||||
}
|
||||
|
||||
// 获取rect模型
|
||||
export function getSize (el) {
|
||||
const rect = el.getBoundingClientRect()
|
||||
|
||||
return [
|
||||
parseInt(rect.width),
|
||||
parseInt(rect.height)
|
||||
]
|
||||
}
|
||||
|
||||
export function computeWidth (parentWidth, left, right) {
|
||||
return parentWidth - left - right
|
||||
}
|
||||
|
||||
export function computeHeight (parentHeight, top, bottom) {
|
||||
return parentHeight - top - bottom
|
||||
}
|
||||
|
||||
export function restrictToBounds (value, min, max) {
|
||||
if (min !== null && value < min) {
|
||||
return min
|
||||
}
|
||||
|
||||
if (max !== null && max < value) {
|
||||
return max
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
1277
frontend/src/components/vue-drag-resize/index.vue
Normal file
1277
frontend/src/components/vue-drag-resize/index.vue
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user