提交 a7b67c5c authored 作者: wangjiahao's avatar wangjiahao

feat: 修改文字组件样式

上级 8aaf2aa0
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
export default { export default {
data() { data() {
return { return {
excludes: ['Picture', 'Group', 'user-view'], // 这些组件不显示内容 excludes: ['Picture', 'Group', 'view'], // 这些组件不显示内容
textAlignOptions: [ textAlignOptions: [
{ {
label: this.$t('panel.text_align_left'), label: this.$t('panel.text_align_left'),
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<template> <template>
<div class="attr-list"> <div class="attr-list">
<el-form label-width="80px" size="mini"> <el-form label-width="80px" size="mini">
<el-form-item v-for="(key, index) in styleKeys.filter(item => item != 'rotate')" :key="index" :label="map[key]+':'"> <el-form-item v-for="(key, index) in styleKeys.filter(item => styleFilter.includes(item))" :key="index" :label="map[key]+':'">
<el-color-picker v-if="key == 'borderColor'" v-model="curComponent.style[key]" /> <el-color-picker v-if="key == 'borderColor'" v-model="curComponent.style[key]" />
<el-color-picker v-else-if="key == 'color'" v-model="curComponent.style[key]" /> <el-color-picker v-else-if="key == 'color'" v-model="curComponent.style[key]" />
<el-color-picker v-else-if="key == 'backgroundColor'" v-model="curComponent.style[key]" /> <el-color-picker v-else-if="key == 'backgroundColor'" v-model="curComponent.style[key]" />
...@@ -34,18 +34,39 @@ ...@@ -34,18 +34,39 @@
</el-select> </el-select>
<el-input v-else v-model="curComponent.style[key]" type="number" /> <el-input v-else v-model="curComponent.style[key]" type="number" />
</el-form-item> </el-form-item>
<el-form-item v-if="curComponent && !excludes.includes(curComponent.component)" :label="$t('panel.content')+':'"> <el-form-item :label="$t('panel.content_style')+':'">
<el-input v-model="curComponent.propValue" type="textarea" /> <div v-if="curComponent.type==='v-text'" style="width: 100%;max-height: 400px;overflow: auto">
<VText
style="border: 1px solid #dcdfe6;border-radius:4px;background-color: #f7f8fa;"
:prop-value="curComponent.propValue"
:element="curComponent"
:edit-mode="'edit'"
:style="getComponentStyleDefault(curComponent.style)"
/>
</div>
<rect-shape
v-if="curComponent.type==='rect-shape'"
style="width: 200px!important;height: 100px!important;"
:prop-value="curComponent.propValue"
:element="curComponent"
:style="getComponentStyleDefault(curComponent.style)"
/>
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
</template> </template>
<script> <script>
import VText from '@/components/canvas/custom-component/VText'
import RectShape from '@/components/canvas/custom-component/RectShape'
import { getStyle } from '@/components/canvas/utils/style'
export default { export default {
components: { VText, RectShape },
data() { data() {
return { return {
excludes: ['Picture', 'Group', 'user-view'], // 这些组件不显示内容 excludes: ['Picture', 'Group', 'view'], // 这些组件不显示内容
textAlignOptions: [ textAlignOptions: [
{ {
label: this.$t('panel.text_align_left'), label: this.$t('panel.text_align_left'),
...@@ -113,6 +134,35 @@ export default { ...@@ -113,6 +134,35 @@ export default {
}, },
curComponent() { curComponent() {
return this.$store.state.curComponent return this.$store.state.curComponent
},
styleFilter() {
const filter = [
'fontSize',
'fontWeight',
'lineHeight',
'letterSpacing',
'textAlign',
'color',
'borderColor',
'borderWidth',
'backgroundColor',
'borderStyle',
'verticalAlign'
]
if (this.$store.state.curComponent.type === 'v-text') {
filter.push('width', 'height')
}
return filter
}
},
methods: {
getComponentStyleDefault(style) {
if (this.$store.state.curComponent.type === 'v-text') {
return getStyle(style, ['top', 'left', 'rotate'])
} else {
return getStyle(style, ['top', 'left', 'rotate', 'height', 'width'])
}
// return style
} }
} }
} }
......
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
<ul @mouseup="handleMouseUp"> <ul @mouseup="handleMouseUp">
<template v-if="curComponent"> <template v-if="curComponent">
<template v-if="!curComponent.isLock"> <template v-if="!curComponent.isLock">
<li @click="edit"> {{ $t('panel.edit') }}</li> <li v-if="editFilter.includes(curComponent.type)" @click="edit"> {{ $t('panel.edit') }}</li>
<!-- <li @click="copy"> {{ $t('panel.copy') }}</li>--> <!-- <li @click="copy"> {{ $t('panel.copy') }}</li>-->
<li @click="paste"> {{ $t('panel.paste') }}</li> <li @click="paste"> {{ $t('panel.paste') }}</li>
<li @click="cut"> {{ $t('panel.cut') }}</li> <li @click="cut"> {{ $t('panel.cut') }}</li>
<li @click="deleteComponent"> {{ $t('panel.delete') }}</li> <li @click="deleteComponent"> {{ $t('panel.delete') }}</li>
<!-- <li @click="lock"> {{ $t('panel.lock') }}</li>--> <!-- <li @click="lock"> {{ $t('panel.lock') }}</li>-->
<li @click="topComponent"> {{ $t('panel.topComponent') }}</li> <li @click="topComponent"> {{ $t('panel.topComponent') }}</li>
<li @click="bottomComponent"> {{ $t('panel.bottomComponent') }}</li> <li @click="bottomComponent"> {{ $t('panel.bottomComponent') }}</li>
<li @click="upComponent"> {{ $t('panel.upComponent') }}</li> <li @click="upComponent"> {{ $t('panel.upComponent') }}</li>
...@@ -28,7 +28,13 @@ import bus from '@/utils/bus' ...@@ -28,7 +28,13 @@ import bus from '@/utils/bus'
export default { export default {
data() { data() {
return { return {
copyData: null copyData: null,
editFilter: [
'view',
'v-text',
'rect-shape',
'custom'
]
} }
}, },
computed: mapState([ computed: mapState([
...@@ -44,7 +50,7 @@ export default { ...@@ -44,7 +50,7 @@ export default {
// 编辑时临时保存 当前修改的画布 // 编辑时临时保存 当前修改的画布
this.$store.dispatch('panel/setComponentDataTemp', JSON.stringify(this.componentData)) this.$store.dispatch('panel/setComponentDataTemp', JSON.stringify(this.componentData))
this.$store.dispatch('panel/setCanvasStyleDataTemp', JSON.stringify(this.canvasStyleData)) this.$store.dispatch('panel/setCanvasStyleDataTemp', JSON.stringify(this.canvasStyleData))
if (this.curComponent.component === 'user-view') { if (this.curComponent.type === 'view') {
this.$store.dispatch('chart/setViewId', null) this.$store.dispatch('chart/setViewId', null)
this.$store.dispatch('chart/setViewId', this.curComponent.propValue.viewId) this.$store.dispatch('chart/setViewId', this.curComponent.propValue.viewId)
bus.$emit('PanelSwitchComponent', { name: 'ChartEdit', param: { 'id': this.curComponent.propValue.viewId }}) bus.$emit('PanelSwitchComponent', { name: 'ChartEdit', param: { 'id': this.curComponent.propValue.viewId }})
...@@ -52,7 +58,12 @@ export default { ...@@ -52,7 +58,12 @@ export default {
if (this.curComponent.type === 'custom') { if (this.curComponent.type === 'custom') {
bus.$emit('component-dialog-edit') bus.$emit('component-dialog-edit')
} }
// 编辑组件
//编辑样式组件
if (this.curComponent.type === 'v-text' || this.curComponent.type === 'rect-shape') {
bus.$emit('component-dialog-style')
}
}, },
lock() { lock() {
this.$store.commit('lock') this.$store.commit('lock')
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
:class="{'gap_class':canvasStyleData.panel.gap==='yes'}" :class="{'gap_class':canvasStyleData.panel.gap==='yes'}"
:snap="true" :snap="true"
:snap-tolerance="1" :snap-tolerance="1"
:change-style="customStyleHistory"
@refLineParams="getRefLineParams" @refLineParams="getRefLineParams"
> >
<component <component
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<span>自适应画布区域 </span> <span>自适应画布区域 </span>
</div> </div>
<div class="canvas-config" style="margin-right: 40px"> <div class="canvas-config" style="margin-right: 55px">
<span> {{ $t('panel.canvas_size') }} </span> <span> {{ $t('panel.canvas_size') }} </span>
<input v-model="canvasStyleData.width" :disabled="canvasStyleData.selfAdaption"> <input v-model="canvasStyleData.width" :disabled="canvasStyleData.selfAdaption">
<span>*</span> <span>*</span>
...@@ -27,13 +27,13 @@ ...@@ -27,13 +27,13 @@
<el-button :class="styleButtonActive?'button-show':'button-closed'" class="el-icon-magic-stick" size="mini" circle @click="showPanel" /> <el-button :class="styleButtonActive?'button-show':'button-closed'" class="el-icon-magic-stick" size="mini" circle @click="showPanel" />
</el-tooltip> </el-tooltip>
<el-tooltip v-if="!aidedButtonActive" :content="$t('panel.open_aided_design') "> <!-- <el-tooltip v-if="!aidedButtonActive" :content="$t('panel.open_aided_design') ">-->
<el-button class="el-icon-help button-closed" size="mini" circle @click="changeAidedDesign" /> <!-- <el-button class="el-icon-help button-closed" size="mini" circle @click="changeAidedDesign" />-->
</el-tooltip> <!-- </el-tooltip>-->
<el-tooltip v-if="aidedButtonActive" :content="$t('panel.close_aided_design') "> <!-- <el-tooltip v-if="aidedButtonActive" :content="$t('panel.close_aided_design') ">-->
<el-button class="el-icon-help button-show" size="mini" circle @click="changeAidedDesign" /> <!-- <el-button class="el-icon-help button-show" size="mini" circle @click="changeAidedDesign" />-->
</el-tooltip> <!-- </el-tooltip>-->
<el-tooltip :content="$t('panel.undo') "> <el-tooltip :content="$t('panel.undo') ">
<el-button class="el-icon-refresh-right" size="mini" circle @click="undo" /> <el-button class="el-icon-refresh-right" size="mini" circle @click="undo" />
......
<template> <template>
<div class="rect-shape"> <div class="rect-shape">
<v-text :propValue="element.propValue" :element="element" /> <v-text :prop-value="element.propValue" :element="element" />
</div> </div>
</template> </template>
<script> <script>
export default { export default {
props: { props: {
element: { element: {
type: Object, type: Object
}, }
}, }
} }
</script> </script>
...@@ -20,4 +20,4 @@ export default { ...@@ -20,4 +20,4 @@ export default {
height: 100%; height: 100%;
overflow: auto; overflow: auto;
} }
</style> </style>
\ No newline at end of file
...@@ -47,18 +47,18 @@ const list = [ ...@@ -47,18 +47,18 @@ const list = [
id: '10001', id: '10001',
component: 'v-text', component: 'v-text',
label: '文字', label: '文字',
propValue: '双击编辑文字', propValue: '双击输入文字',
icon: 'wenben', icon: 'wenben',
type: 'v-text', type: 'v-text',
style: { style: {
width: 200, width: 300,
height: 22, height: 100,
fontSize: 14, fontSize: 18,
fontWeight: 500, fontWeight: 500,
lineHeight: '', lineHeight: '',
letterSpacing: 0, letterSpacing: 0,
textAlign: '', textAlign: '',
color: '' color: '#000000'
} }
}, },
{ {
...@@ -119,22 +119,15 @@ const list = [ ...@@ -119,22 +119,15 @@ const list = [
style: { style: {
width: 200, width: 200,
height: 200, height: 200,
fontSize: 14,
fontWeight: 500,
lineHeight: '',
letterSpacing: 0,
textAlign: 'center',
color: '',
borderColor: '#000', borderColor: '#000',
borderWidth: 1, borderWidth: 1,
backgroundColor: '', backgroundColor: '',
borderStyle: 'solid', borderStyle: 'solid'
verticalAlign: 'middle'
} }
}, },
{ {
id: '10005', id: '10005',
component: 'user-view', component: 'view',
label: '用户视图', label: '用户视图',
propValue: '', propValue: '',
icon: 'juxing', icon: 'juxing',
......
...@@ -996,7 +996,8 @@ export default { ...@@ -996,7 +996,8 @@ export default {
other_module: 'Other', other_module: 'Other',
content: 'Content', content: 'Content',
default_panel_name: 'Default Dashboard Name', default_panel_name: 'Default Dashboard Name',
source_panel_name: 'Source Dashboard Name' source_panel_name: 'Source Dashboard Name',
content_style: 'Content Style',
}, },
plugin: { plugin: {
local_install: 'Local installation', local_install: 'Local installation',
......
...@@ -996,7 +996,8 @@ export default { ...@@ -996,7 +996,8 @@ export default {
other_module: '其他', other_module: '其他',
content: '内容', content: '内容',
default_panel_name: '默认仪表板名称', default_panel_name: '默认仪表板名称',
source_panel_name: '原仪表板名称' source_panel_name: '原仪表板名称',
content_style: '内容样式'
}, },
plugin: { plugin: {
local_install: '本地安裝', local_install: '本地安裝',
......
...@@ -996,7 +996,8 @@ export default { ...@@ -996,7 +996,8 @@ export default {
other_module: '其他', other_module: '其他',
content: '内容', content: '内容',
default_panel_name: '默认仪表板名称', default_panel_name: '默认仪表板名称',
source_panel_name: '原仪表板名称' source_panel_name: '原仪表板名称',
content_style: '内容样式'
}, },
plugin: { plugin: {
local_install: '本地安装', local_install: '本地安装',
......
...@@ -103,6 +103,24 @@ div:focus { ...@@ -103,6 +103,24 @@ div:focus {
} }
} }
.de-style-dialog {
min-width: 500px !important;
width: 300px !important;
.el-dialog__header{
// background-color: #f4f4f5;
padding: 10px 20px !important;
.el-dialog__headerbtn {
top: 15px !important;
}
}
.el-dialog__body{
padding: 1px 15px !important;
}
}
.preview-dialog { .preview-dialog {
padding: 0px!important; padding: 0px!important;
.el-dialog--center{ .el-dialog--center{
......
...@@ -104,10 +104,10 @@ ...@@ -104,10 +104,10 @@
<Editor v-if="!previewVisible" :out-style="outStyle" /> <Editor v-if="!previewVisible" :out-style="outStyle" />
</div> </div>
</de-main-container> </de-main-container>
<de-aside-container v-if="aidedButtonActive" :class="aidedButtonActive ? 'show' : 'hidden'" class="style-aside"> <!-- <de-aside-container v-if="aidedButtonActive" :class="aidedButtonActive ? 'show' : 'hidden'" class="style-aside">-->
<AttrListExtend v-if="curComponent" /> <!-- <AttrListExtend v-if="curComponent" />-->
<p v-else class="placeholder">{{ $t('panel.select_component') }}</p> <!-- <p v-else class="placeholder">{{ $t('panel.select_component') }}</p>-->
</de-aside-container> <!-- </de-aside-container>-->
</de-container> </de-container>
...@@ -135,6 +135,21 @@ ...@@ -135,6 +135,21 @@
</div> </div>
</el-dialog> </el-dialog>
<!--文字组件对话框-->
<el-dialog
v-if="styleDialogVisible"
:title="$t('panel.style')"
:visible.sync="styleDialogVisible"
custom-class="de-style-dialog"
>
<AttrListExtend v-if="curComponent" />
<div style="text-align: center">
<span slot="footer">
<el-button size="mini" @click="closeStyleDialog">{{ $t('commons.confirm') }}</el-button>
</span>
</div>
</el-dialog>
<fullscreen style="height: 100%;background: #f7f8fa;overflow-y: auto" :fullscreen.sync="previewVisible"> <fullscreen style="height: 100%;background: #f7f8fa;overflow-y: auto" :fullscreen.sync="previewVisible">
<Preview v-if="previewVisible" :show-type="canvasStyleData.selfAdaption?'full':'width'" /> <Preview v-if="previewVisible" :show-type="canvasStyleData.selfAdaption?'full':'width'" />
</fullscreen> </fullscreen>
...@@ -222,7 +237,8 @@ export default { ...@@ -222,7 +237,8 @@ export default {
width: null, width: null,
height: null height: null
}, },
beforeDialogValue: [] beforeDialogValue: [],
styleDialogVisible: false
} }
}, },
...@@ -234,7 +250,8 @@ export default { ...@@ -234,7 +250,8 @@ export default {
'curComponent', 'curComponent',
'isClickComponent', 'isClickComponent',
'canvasStyleData', 'canvasStyleData',
'curComponentIndex' 'curComponentIndex',
'componentData'
]) ])
}, },
...@@ -266,7 +283,10 @@ export default { ...@@ -266,7 +283,10 @@ export default {
}) })
bus.$on('component-dialog-edit', () => { bus.$on('component-dialog-edit', () => {
this.eidtDialog() this.editDialog()
})
bus.$on('component-dialog-style', () => {
this.styleDialogVisible = true
}) })
bus.$on('previewFullScreenClose', () => { bus.$on('previewFullScreenClose', () => {
...@@ -400,7 +420,7 @@ export default { ...@@ -400,7 +420,7 @@ export default {
this.currentFilterCom.id = newComponentId this.currentFilterCom.id = newComponentId
if (this.currentWidget.filterDialog) { if (this.currentWidget.filterDialog) {
this.show = false this.show = false
this.openFilterDiolog() this.openFilterDialog()
return return
} }
component = deepCopy(this.currentFilterCom) component = deepCopy(this.currentFilterCom)
...@@ -413,6 +433,14 @@ export default { ...@@ -413,6 +433,14 @@ export default {
this.$store.commit('addComponent', { component }) this.$store.commit('addComponent', { component })
this.$store.commit('recordSnapshot') this.$store.commit('recordSnapshot')
this.clearCurrentInfo() this.clearCurrentInfo()
debugger
// 文字组件
if (component.type === 'v-text' || component.type === 'rect-shape') {
this.$store.commit('setCurComponent', { component: component, index: this.componentData.length })
this.styleDialogVisible = true
this.show = false
}
}, },
clearCurrentInfo() { clearCurrentInfo() {
this.currentWidget = null this.currentWidget = null
...@@ -440,7 +468,7 @@ export default { ...@@ -440,7 +468,7 @@ export default {
this.$store.commit('hideContextMenu') this.$store.commit('hideContextMenu')
} }
}, },
openFilterDiolog() { openFilterDialog() {
this.beforeDialogValue = [] this.beforeDialogValue = []
this.filterVisible = true this.filterVisible = true
}, },
...@@ -463,11 +491,11 @@ export default { ...@@ -463,11 +491,11 @@ export default {
this.currentFilterCom = component this.currentFilterCom = component
this.$forceUpdate() this.$forceUpdate()
}, },
eidtDialog() { editDialog() {
const serviceName = this.curComponent.serviceName const serviceName = this.curComponent.serviceName
this.currentWidget = ApplicationContext.getService(serviceName) this.currentWidget = ApplicationContext.getService(serviceName)
this.currentFilterCom = this.curComponent this.currentFilterCom = this.curComponent
this.openFilterDiolog() this.openFilterDialog()
}, },
closeLeftPanel() { closeLeftPanel() {
this.show = false this.show = false
...@@ -494,6 +522,9 @@ export default { ...@@ -494,6 +522,9 @@ export default {
// console.log(canvasHeight + '--' + canvasWidth) // console.log(canvasHeight + '--' + canvasWidth)
}) })
} }
},
closeStyleDialog() {
this.styleDialogVisible = false
} }
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论