提交 34791773 authored 作者: taojinlong's avatar taojinlong

Merge branch 'v1.3' of github.com:dataease/dataease into v1.3

...@@ -85,7 +85,7 @@ export default { ...@@ -85,7 +85,7 @@ export default {
result[attr] = style[attr] + 'px' result[attr] = style[attr] + 'px'
}) })
result['rotate'] = style['rotate'] result['rotate'] = style['rotate']
result['opacity'] = style['opacity'] // result['opacity'] = style['opacity']
return result return result
// return style // return style
...@@ -93,6 +93,8 @@ export default { ...@@ -93,6 +93,8 @@ export default {
getComponentStyleDefault(style) { getComponentStyleDefault(style) {
return getStyle(style, ['top', 'left', 'width', 'height', 'rotate']) return getStyle(style, ['top', 'left', 'width', 'height', 'rotate'])
// console.log('styleInfo', JSON.stringify(styleInfo))
// return styleInfo
// return style // return style
}, },
......
...@@ -17,16 +17,22 @@ export function getStyle(style, filter = []) { ...@@ -17,16 +17,22 @@ export function getStyle(style, filter = []) {
if (!filter.includes(key)) { if (!filter.includes(key)) {
if (key !== 'rotate') { if (key !== 'rotate') {
result[key] = style[key] result[key] = style[key]
if (key) {
if (needUnit.includes(key)) { if (key === 'backgroundColor') {
result[key] += 'px' result[key] = colorRgb(style[key], style.opacity)
}
if (needUnit.includes(key)) {
result[key] += 'px'
}
} }
} else { } else {
result.transform = key + '(' + style[key] + 'deg)' result.transform = key + '(' + style[key] + 'deg)'
} }
} }
}) })
if (result.backgroundColor && (result.opacity || result.opacity === 0)) {
delete result.opacity
}
return result return result
} }
...@@ -53,3 +59,29 @@ export function getComponentRotatedStyle(style) { ...@@ -53,3 +59,29 @@ export function getComponentRotatedStyle(style) {
return style return style
} }
export function colorRgb(color, opacity) {
var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/
var sColor = color.toLowerCase()
if (sColor && reg.test(sColor)) {
if (sColor.length === 4) {
var sColorNew = '#'
for (var i = 1; i < 4; i += 1) {
sColorNew += sColor.slice(i, i + 1).concat(sColor.slice(i, i + 1))
}
sColor = sColorNew
}
// 处理六位的颜色值
var sColorChange = []
for (var i = 1; i < 7; i += 2) {
sColorChange.push(parseInt('0x' + sColor.slice(i, i + 2)))
}
if (opacity || opacity === 0) {
return 'rgba(' + sColorChange.join(',') + ',' + opacity + ')'
} else {
return 'rgba(' + sColorChange.join(',') + ')'
}
} else {
return sColor
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论