feat: 组件背景统一到仪表板层面设置

Co-authored-by: wangjiahao <1522128093@qq.com>
This commit is contained in:
fit2cloudrd 2022-03-28 21:18:56 +08:00 committed by GitHub
parent b0fc9ac436
commit d3e8fd2da7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 181 additions and 100 deletions

View File

@ -20,19 +20,20 @@
@mouseenter="enter" @mouseenter="enter"
@mouseleave="leave" @mouseleave="leave"
> >
<edit-bar v-if="editBarShow" style="transform: translateZ(10px)" :active-model="'edit'" :element="element" @showViewDetails="showViewDetails" @amRemoveItem="amRemoveItem" @amAddItem="amAddItem" @resizeView="resizeView" @linkJumpSet="linkJumpSet" @boardSet="boardSet" />
<mobile-check-bar v-if="mobileCheckBarShow" :element="element" @amRemoveItem="amRemoveItem" />
<div v-if="resizing" style="transform: translateZ(11px);position: absolute; z-index: 3" :style="resizeShadowStyle" />
<div <div
:class="[ :class="[
{ {
['de-drag-active-inner']:enabled, ['de-drag-active-inner']:enabled,
[classNameMouseOn]: mouseOn || active [classNameMouseOn]: mouseOn || active
}, },
className className,
'main-background'
]" ]"
:style="mainSlotStyle" :style="mainSlotStyle"
> >
<edit-bar v-if="editBarShow" style="transform: translateZ(10px)" :active-model="'edit'" :element="element" @showViewDetails="showViewDetails" @amRemoveItem="amRemoveItem" @amAddItem="amAddItem" @resizeView="resizeView" @linkJumpSet="linkJumpSet" @boardSet="boardSet" />
<mobile-check-bar v-if="mobileCheckBarShow" :element="element" @amRemoveItem="amRemoveItem" />
<div v-if="resizing" style="transform: translateZ(11px);position: absolute; z-index: 3" :style="resizeShadowStyle" />
<div <div
v-for="(handlei, indexi) in actualHandles" v-for="(handlei, indexi) in actualHandles"
:key="indexi" :key="indexi"
@ -59,6 +60,7 @@ import eventBus from '@/components/canvas/utils/eventBus'
import { mapState } from 'vuex' import { mapState } from 'vuex'
import EditBar from '@/components/canvas/components/Editor/EditBar' import EditBar from '@/components/canvas/components/Editor/EditBar'
import MobileCheckBar from '@/components/canvas/components/Editor/MobileCheckBar' import MobileCheckBar from '@/components/canvas/components/Editor/MobileCheckBar'
import { hexColorToRGBA } from '@/views/chart/chart/util'
export default { export default {
replace: true, replace: true,
@ -531,13 +533,18 @@ export default {
width: this.computedMainSlotWidth, width: this.computedMainSlotWidth,
height: this.computedMainSlotHeight height: this.computedMainSlotHeight
} }
if (this.element.commonBackground && this.element.commonBackground.enable) { if (this.element.commonBackground) {
if (this.element.commonBackground.backgroundType === 'innerImage') { style['padding'] = (this.element.commonBackground.innerPadding || 0) + 'px'
style['background'] = `url(${this.element.commonBackground.innerImage}) no-repeat` style['border-radius'] = (this.element.commonBackground.borderRadius || 0) + 'px'
} else if (this.element.commonBackground.backgroundType === 'outerImage') { if (this.element.commonBackground.enable) {
style['background'] = `url(${this.element.commonBackground.outerImage}) no-repeat` if (this.element.commonBackground.backgroundType === 'innerImage') {
style['background'] = `url(${this.element.commonBackground.innerImage}) no-repeat`
} else if (this.element.commonBackground.backgroundType === 'outerImage') {
style['background'] = `url(${this.element.commonBackground.outerImage}) no-repeat`
} else if (this.element.commonBackground.backgroundType === 'color') {
style['background-color'] = hexColorToRGBA(this.element.commonBackground.color, this.element.commonBackground.alpha)
}
} }
style['background-size'] = `100% 100%`
} }
return style return style
}, },
@ -1857,4 +1864,7 @@ export default {
.de-drag-active-inner{ .de-drag-active-inner{
outline: 1px solid #70c0ff; outline: 1px solid #70c0ff;
} }
.main-background{
background-size: 100% 100% !important;
}
</style> </style>

View File

@ -49,6 +49,7 @@ import DeOutWidget from '@/components/dataease/DeOutWidget'
import EditBar from '@/components/canvas/components/Editor/EditBar' import EditBar from '@/components/canvas/components/Editor/EditBar'
import MobileCheckBar from '@/components/canvas/components/Editor/MobileCheckBar' import MobileCheckBar from '@/components/canvas/components/Editor/MobileCheckBar'
import CloseBar from '@/components/canvas/components/Editor/CloseBar' import CloseBar from '@/components/canvas/components/Editor/CloseBar'
import { hexColorToRGBA } from '@/views/chart/chart/util'
export default { export default {
components: { CloseBar, MobileCheckBar, DeOutWidget, EditBar }, components: { CloseBar, MobileCheckBar, DeOutWidget, EditBar },
@ -94,13 +95,20 @@ export default {
width: '100%', width: '100%',
height: '100%' height: '100%'
} }
if (this.config.commonBackground && this.config.commonBackground.enable) { if (this.config.commonBackground) {
if (this.config.commonBackground.backgroundType === 'innerImage') { style['padding'] = (this.config.commonBackground.innerPadding || 0) + 'px'
style['background'] = `url(${this.config.commonBackground.innerImage}) no-repeat` style['border-radius'] = (this.config.commonBackground.borderRadius || 0) + 'px'
} else if (this.config.commonBackground.backgroundType === 'outerImage') { if (this.config.commonBackground.enable) {
style['background'] = `url(${this.config.commonBackground.outerImage}) no-repeat` if (this.config.commonBackground.backgroundType === 'innerImage') {
style['background'] = `url(${this.config.commonBackground.innerImage}) no-repeat`
} else if (this.config.commonBackground.backgroundType === 'outerImage') {
style['background'] = `url(${this.config.commonBackground.outerImage}) no-repeat`
} else if (this.config.commonBackground.backgroundType === 'color') {
style['background-color'] = hexColorToRGBA(this.config.commonBackground.color, this.config.commonBackground.alpha)
}
} }
style['background-size'] = `100% 100%` style['background-size'] = `100% 100%`
style['overflow'] = 'hidden'
} }
return style return style
}, },

View File

@ -14,7 +14,7 @@
<el-dropdown-item v-if="'view'===curComponent.type" icon="el-icon-link" @click.native="linkageSetting">{{ $t('panel.linkage_setting') }}</el-dropdown-item> <el-dropdown-item v-if="'view'===curComponent.type" icon="el-icon-link" @click.native="linkageSetting">{{ $t('panel.linkage_setting') }}</el-dropdown-item>
<el-dropdown-item v-if="'de-tabs'===curComponent.type" icon="el-icon-link" @click.native="addTab">{{ $t('panel.add_tab') }}</el-dropdown-item> <el-dropdown-item v-if="'de-tabs'===curComponent.type" icon="el-icon-link" @click.native="addTab">{{ $t('panel.add_tab') }}</el-dropdown-item>
<el-dropdown-item v-if="'view'===curComponent.type" icon="el-icon-connection" @click.native="linkJumpSet">{{ $t('panel.setting_jump') }}</el-dropdown-item> <el-dropdown-item v-if="'view'===curComponent.type" icon="el-icon-connection" @click.native="linkJumpSet">{{ $t('panel.setting_jump') }}</el-dropdown-item>
<el-dropdown-item icon="el-icon-full-screen" @click.native="boardSet">{{ $t('panel.setting_background') }}</el-dropdown-item> <el-dropdown-item icon="el-icon-magic-stick" @click.native="boardSet">{{ $t('panel.component_style') }}</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
</div> </div>

View File

@ -1033,6 +1033,7 @@ export default {
}, },
methods: { methods: {
boardSet(item) { boardSet(item) {
this.$emit('boardSet', item)
this.boardSetVisible = true this.boardSetVisible = true
}, },
changeStyleWithScale, changeStyleWithScale,

View File

@ -57,16 +57,8 @@ export default {
created() { created() {
}, },
mounted() { mounted() {
this.init()
}, },
methods: { methods: {
init() {
const iframe = document.getElementById('iframe')
NProgress.start()
iframe.onload = function() {
NProgress.done()
}
}
} }
} }

View File

@ -263,6 +263,9 @@ export default {
resultCount() { resultCount() {
return this.canvasStyleData.panel.resultCount return this.canvasStyleData.panel.resultCount
}, },
innerPadding() {
return this.element.commonBackground.innerPadding || 0
},
...mapState([ ...mapState([
'canvasStyleData', 'canvasStyleData',
'nowPanelTrackInfo', 'nowPanelTrackInfo',
@ -276,7 +279,12 @@ export default {
}, },
watch: { watch: {
'innerPadding': {
handler: function(val1, val2) {
this.resizeChart()
},
deep: true
},
'cfilters': { 'cfilters': {
handler: function(val1, val2) { handler: function(val1, val2) {
if (isChange(val1, val2) && !this.isFirstLoad) { if (isChange(val1, val2) && !this.isFirstLoad) {
@ -303,9 +311,7 @@ export default {
} }
// gap // gap
if (this.preCanvasPanel && this.preCanvasPanel.gap !== newVal.panel.gap) { if (this.preCanvasPanel && this.preCanvasPanel.gap !== newVal.panel.gap) {
this.chart.isPlugin this.resizeChart()
? this.$refs[this.element.propValue.id].callPluginInner({ methodName: 'chartResize' })
: this.$refs[this.element.propValue.id].chartResize()
} }
this.preCanvasPanel = deepCopy(newVal.panel) this.preCanvasPanel = deepCopy(newVal.panel)
}, },
@ -315,15 +321,7 @@ export default {
'hw': { 'hw': {
handler(newVal, oldVla) { handler(newVal, oldVla) {
if (newVal !== oldVla && this.$refs[this.element.propValue.id]) { if (newVal !== oldVla && this.$refs[this.element.propValue.id]) {
if (this.chart.type === 'map') { this.resizeChart()
this.destroyTimeMachine()
this.changeIndex++
this.chartResize(this.changeIndex)
} else {
this.chart.isPlugin
? this.$refs[this.element.propValue.id].callPluginInner({ methodName: 'chartResize' })
: this.$refs[this.element.propValue.id].chartResize()
}
} }
}, },
deep: true deep: true
@ -369,6 +367,17 @@ export default {
} }
}, },
methods: { methods: {
resizeChart() {
if (this.chart.type === 'map') {
this.destroyTimeMachine()
this.changeIndex++
this.chartResize(this.changeIndex)
} else {
this.chart.isPlugin
? this.$refs[this.element.propValue.id].callPluginInner({ methodName: 'chartResize' })
: this.$refs[this.element.propValue.id].chartResize()
}
},
bindPluginEvent() { bindPluginEvent() {
bus.$on('plugin-chart-click', param => { bus.$on('plugin-chart-click', param => {
param.viewId && param.viewId === this.element.propValue.viewId && this.chartClick(param) param.viewId && param.viewId === this.element.propValue.viewId && this.chartClick(param)

View File

@ -16,7 +16,7 @@ export const BASE_MOBILE_STYLE = {
auxiliaryMatrix: true auxiliaryMatrix: true
} }
// 公共背景 // 组件仪表板样式
export const COMMON_BACKGROUND = { export const COMMON_BACKGROUND = {
enable: false, enable: false,
backgroundType: 'innerImage', backgroundType: 'innerImage',
@ -24,7 +24,8 @@ export const COMMON_BACKGROUND = {
innerImage: null, innerImage: null,
outerImage: null, outerImage: null,
alpha: 100, alpha: 100,
borderRadius: 5 borderRadius: 5,
innerPadding: 0
} }
// 公共样式 // 公共样式

View File

@ -1390,6 +1390,10 @@ export default {
sure_bt: 'Confirm' sure_bt: 'Confirm'
}, },
panel: { panel: {
inner_padding: 'Inner Padding',
board_radio: 'Board Radio',
background: 'Background',
component_style: 'component Style',
web_set_tips: 'Some Websites Cannot Be Displayed Because Of Cross Domain Problems ', web_set_tips: 'Some Websites Cannot Be Displayed Because Of Cross Domain Problems ',
repeat_params: 'Repeat Params Exist', repeat_params: 'Repeat Params Exist',
enable_outer_param_set: 'Enable Outer Param Set', enable_outer_param_set: 'Enable Outer Param Set',

View File

@ -1391,6 +1391,10 @@ export default {
sure_bt: '確定' sure_bt: '確定'
}, },
panel: { panel: {
inner_padding: '内边距',
board_radio: '边框半径',
background: '背景',
component_style: '组件样式',
web_set_tips: '部分网站可能存在跨域问题无法显示', web_set_tips: '部分网站可能存在跨域问题无法显示',
repeat_params: '存在名称重复的参数', repeat_params: '存在名称重复的参数',
enable_outer_param_set: '启用外部参数设置', enable_outer_param_set: '启用外部参数设置',

View File

@ -1399,6 +1399,10 @@ export default {
sure_bt: '确定' sure_bt: '确定'
}, },
panel: { panel: {
inner_padding: '内边距',
board_radio: '边框半径',
background: '背景',
component_style: '组件样式',
web_set_tips: '部分网站可能存在跨域问题无法显示', web_set_tips: '部分网站可能存在跨域问题无法显示',
repeat_params: '存在名称重复的参数', repeat_params: '存在名称重复的参数',
enable_outer_param_set: '启用外部参数设置', enable_outer_param_set: '启用外部参数设置',

View File

@ -2,71 +2,98 @@
<el-row> <el-row>
<el-row> <el-row>
<el-col :span="24"> <el-col :span="24">
<span style="font-weight:600;margin-right: 20px;font-size: 14px">{{ $t('panel.choose_background') }}</span> <span style="font-weight:600;margin-right: 20px;font-size: 14px">{{ $t('panel.component_style') }}</span>
<el-checkbox v-model="curComponent.commonBackground.enable">{{ $t('commons.enable') }}</el-checkbox>
<span style="color: #909399; font-size: 8px;margin-left: 3px">
Tips:{{ $t('panel.choose_background_tips') }}
</span>
</el-col> </el-col>
</el-row> </el-row>
<el-row class="main-content" disabled="!curComponent.commonBackground.enable"> <el-row class="main-content" disabled="!curComponent.commonBackground.enable">
<!-- <el-row style="height: 80px;margin-top:10px;margin-bottom:20px;overflow: hidden">-->
<!-- <el-col :span="3" style="padding-left: 10px">--> <el-row style="height: 50px;overflow: hidden">
<!-- <el-radio v-model="curComponent.commonBackground.backgroundType" label="color" @change="onChangeType">颜色</el-radio>--> <el-col :span="3">
<!-- </el-col>--> <span class="params-title">{{ $t('panel.inner_padding') }}</span>
<!-- <el-col :span="3">-->
<!-- <el-color-picker v-model="curComponent.commonBackground.color" class="color-picker-style" :predefine="predefineColors" />-->
<!-- </el-col>-->
<!-- <el-col :span="3" style="text-align: right;margin-top: 8px">-->
<!-- <span>不透明度</span>-->
<!-- </el-col>-->
<!-- <el-col :span="9">-->
<!-- <el-slider v-model="curComponent.commonBackground.alpha" show-input :show-input-controls="false" input-size="mini" />-->
<!-- </el-col>-->
<!-- </el-row>-->
<el-row style="height: 80px;margin-top:10px;margin-bottom:20px;overflow: hidden">
<el-col :span="3" style="padding-left: 10px">
<el-radio v-model="curComponent.commonBackground.backgroundType" label="outerImage" @change="onChangeType">{{ $t('panel.photo') }}</el-radio>
</el-col> </el-col>
<el-col style="width: 130px!important;"> <el-col :span="15">
<el-upload <el-slider v-model="curComponent.commonBackground.innerPadding" show-input :show-input-controls="false" input-size="mini" />
action=""
accept=".jpeg,.jpg,.png,.gif,.svg"
class="avatar-uploader"
list-type="picture-card"
:class="{disabled:uploadDisabled}"
:on-preview="handlePictureCardPreview"
:on-remove="handleRemove"
:http-request="upload"
:file-list="fileList"
:on-change="onChange"
>
<i class="el-icon-plus" />
</el-upload>
<el-dialog top="25vh" width="600px" :modal-append-to-body="false" :visible.sync="dialogVisible">
<img width="100%" :src="dialogImageUrl" alt="">
</el-dialog>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row style="height: 50px;overflow: hidden">
<el-col :span="3" style="padding-left: 10px"> <el-col :span="3">
<el-radio v-model="curComponent.commonBackground.backgroundType" label="innerImage" @change="onChangeType">边框</el-radio> <span class="params-title">{{ $t('panel.board_radio') }}</span>
</el-col> </el-col>
<el-col :span="21" class="main-row"> <el-col :span="15">
<el-row v-for="(value, key) in BackgroundShowMap" :key="key"> <el-slider v-model="curComponent.commonBackground.borderRadius" show-input :show-input-controls="false" input-size="mini" />
<el-col :span="24"><span>{{ key }}</span> </el-col> </el-col>
<el-col </el-row>
v-for="item in value"
:key="item.id" <el-row style="height: 50px">
:span="6" <el-col :span="3" style="padding-left: 10px;padding-top: 5px">
<el-checkbox v-model="curComponent.commonBackground.enable">{{ $t('panel.background') }}</el-checkbox>
</el-col>
<el-col :span="21">
<span style="color: #909399; font-size: 8px;margin-left: 3px;line-height: 30px">
Tips:{{ $t('panel.choose_background_tips') }}
</span>
</el-col>
</el-row>
<el-row v-if="curComponent.commonBackground.enable">
<el-row style="height: 40px;overflow: hidden">
<el-col :span="3" style="padding-left: 10px;padding-top: 5px">
<el-radio v-model="curComponent.commonBackground.backgroundType" label="color" @change="onChangeType">颜色</el-radio>
</el-col>
<el-col :span="1" style="padding-top: 5px">
<el-color-picker v-model="curComponent.commonBackground.color" size="mini" class="color-picker-style" :predefine="predefineColors" />
</el-col>
<el-col :span="3">
<span class="params-title-small">不透明度</span>
</el-col>
<el-col :span="11">
<el-slider v-model="curComponent.commonBackground.alpha" show-input :show-input-controls="false" input-size="mini" />
</el-col>
</el-row>
<el-row style="height: 80px;margin-top:10px;margin-bottom:20px;overflow: hidden">
<el-col :span="3" style="padding-left: 10px">
<el-radio v-model="curComponent.commonBackground.backgroundType" label="outerImage" @change="onChangeType">{{ $t('panel.photo') }}</el-radio>
</el-col>
<el-col style="width: 130px!important;">
<el-upload
action=""
accept=".jpeg,.jpg,.png,.gif,.svg"
class="avatar-uploader"
list-type="picture-card"
:class="{disabled:uploadDisabled}"
:on-preview="handlePictureCardPreview"
:on-remove="handleRemove"
:http-request="upload"
:file-list="fileList"
:on-change="onChange"
> >
<background-item <i class="el-icon-plus" />
:template="item" </el-upload>
/> <el-dialog top="25vh" width="600px" :modal-append-to-body="false" :visible.sync="dialogVisible">
</el-col> <img width="100%" :src="dialogImageUrl" alt="">
</el-row> </el-dialog>
</el-col> </el-col>
</el-row>
<el-row>
<el-col :span="3" style="padding-left: 10px">
<el-radio v-model="curComponent.commonBackground.backgroundType" label="innerImage" @change="onChangeType">边框</el-radio>
</el-col>
<el-col :span="21" class="main-row">
<el-row v-for="(value, key) in BackgroundShowMap" :key="key">
<el-col :span="24"><span>{{ key }}</span> </el-col>
<el-col
v-for="item in value"
:key="item.id"
:span="6"
>
<background-item
:template="item"
/>
</el-col>
</el-row>
</el-col>
</el-row>
</el-row> </el-row>
</el-row> </el-row>
<el-row class="root-class"> <el-row class="root-class">
<el-col :span="24"> <el-col :span="24">
@ -178,7 +205,7 @@ export default {
} }
.main-row{ .main-row{
height: 40vh; height: 140px;
overflow-y: auto; overflow-y: auto;
} }
@ -226,4 +253,17 @@ export default {
border:1px solid #E6E6E6; border:1px solid #E6E6E6;
} }
.params-title{
font-weight: bold;
line-height: 40px;
margin-left: 10px;
font-size: 14px;
}
.params-title-small{
font-weight: bold;
line-height: 40px;
margin-left: 10px;
font-size: 12px;
}
</style> </style>

View File

@ -393,6 +393,7 @@ export default {
}, },
data() { data() {
return { return {
asideToolType: 'none',
outerParamsSetVisible: false, outerParamsSetVisible: false,
autoMoveOffSet: 15, autoMoveOffSet: 15,
mobileEditorShow: true, mobileEditorShow: true,
@ -460,14 +461,21 @@ export default {
showAside() { showAside() {
return !this.linkageSettingStatus && !this.mobileLayoutStatus return !this.linkageSettingStatus && !this.mobileLayoutStatus
}, },
//
showPanelToolsAside() {
return !this.curComponent
},
// //
showViewToolsAside() { showViewToolsAside() {
return this.curComponent && this.curComponent.type === 'view' return this.curComponent && this.curComponent.type === 'view'
}, },
showViewToolAsideType() {
if (this.curComponent) {
if (this.curComponent.type === 'view') {
return 'view'
} else {
return 'publicSet'
}
} else {
return 'none'
}
},
showAttr() { showAttr() {
if (this.mobileLayoutStatus) { if (this.mobileLayoutStatus) {
return false return false