提交 55e39cbf authored 作者: wangjiahao's avatar wangjiahao

feat:增加图片样式组件,统一样式组件设置

上级 627f91b1
<template> <template>
<el-card class="el-card-main" :style="mainStyle"> <el-card class="el-card-main" :style="mainStyle">
<div id="main-attr" style="position: relative;"> <div id="main-attr" style="position: relative;">
<div style="width: 100px;float: left;margin-top: 2px;margin-left: 2px;"> <div v-if="attrShow('textAlign')" style="width: 100px;float: left;margin-top: 2px;margin-left: 2px;">
<el-radio-group v-model="styleInfo.textAlign" size="mini" @change="styleChange"> <el-radio-group v-model="styleInfo.textAlign" size="mini" @change="styleChange">
<el-radio-button <el-radio-button
v-for="item in textAlignOptions" v-for="item in textAlignOptions"
...@@ -16,47 +16,77 @@ ...@@ -16,47 +16,77 @@
</el-radio-button> </el-radio-button>
</el-radio-group> </el-radio-group>
</div> </div>
<el-tooltip :content="$t('panel.fontSize')"> <div v-if="attrShow('borderStyle')" style="width: 80px;margin-top: 2px;margin-left: 2px;float: left">
<el-tooltip content="边框风格">
<el-select v-model="styleInfo.borderStyle" size="mini" @change="styleChange">
<el-option
v-for="item in lineStyle"
:key="item.value"
:label="item.label"
:value="item.value"
>
<span style="float: left;">
<i :class="item.icon" />
</span>
<span style="float: right; color: #8492a6; font-size: 12px">{{ item.label }}</span>
</el-option>
</el-select>
</el-tooltip>
</div>
<div v-if="attrShow('borderWidth')" style="width: 55px;float: left;margin-top: 2px;margin-left: 2px;">
<el-tooltip content="边框宽度">
<el-select v-model="styleInfo.borderWidth" size="mini" placeholder="" @change="styleChange">
<el-option
v-for="item in lineFont"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-tooltip>
</div>
<el-tooltip v-if="attrShow('fontSize')" :content="$t('panel.fontSize')">
<i style="float: left;margin-top: 3px;margin-left: 2px;" class="iconfont icon-font_size" /> <i style="float: left;margin-top: 3px;margin-left: 2px;" class="iconfont icon-font_size" />
</el-tooltip> </el-tooltip>
<div style="width: 70px;float: left;margin-top: 2px;margin-left: 2px;"> <div v-if="attrShow('fontSize')" style="width: 70px;float: left;margin-top: 2px;margin-left: 2px;">
<el-input v-model="styleInfo.fontSize" type="number" size="mini" min="12" max="128" @change="styleChange" /> <el-input v-model="styleInfo.fontSize" type="number" size="mini" min="12" max="128" @change="styleChange" />
</div> </div>
<el-tooltip :content="$t('panel.fontWeight')"> <el-tooltip v-if="attrShow('fontWeight')" :content="$t('panel.fontWeight')">
<i style="float: left;margin-top: 3px;margin-left: 2px;" class="icon iconfont icon-font-weight-bold" /> <i style="float: left;margin-top: 3px;margin-left: 2px;" class="icon iconfont icon-font-weight-bold" />
</el-tooltip> </el-tooltip>
<div style="width: 70px;float: left;margin-top: 2px;margin-left: 2px;"> <div v-if="attrShow('fontWeight')" style="width: 70px;float: left;margin-top: 2px;margin-left: 2px;">
<el-input v-model="styleInfo.fontWeight" type="number" size="mini" min="100" step="100" max="900" @change="styleChange" /> <el-input v-model="styleInfo.fontWeight" type="number" size="mini" min="100" step="100" max="900" @change="styleChange" />
</div> </div>
<el-tooltip :content="$t('panel.letterSpacing')"> <el-tooltip v-if="attrShow('letterSpacing')" :content="$t('panel.letterSpacing')">
<i style="float: left;margin-top: 3px;margin-left: 2px;" class="icon iconfont icon-letter_spacing" /> <i style="float: left;margin-top: 3px;margin-left: 2px;" class="icon iconfont icon-letter_spacing" />
</el-tooltip> </el-tooltip>
<div style="width: 70px;float: left;margin-top: 2px;margin-left: 2px;"> <div v-if="attrShow('letterSpacing')" style="width: 70px;float: left;margin-top: 2px;margin-left: 2px;">
<el-input v-model="styleInfo.letterSpacing" type="number" size="mini" min="0" max="99" @change="styleChange" /> <el-input v-model="styleInfo.letterSpacing" type="number" size="mini" min="0" max="99" @change="styleChange" />
</div> </div>
<el-tooltip :content="$t('panel.opacity')"> <el-tooltip v-if="attrShow('opacity')" :content="$t('panel.opacity')">
<i style="float: left;margin-top: 3px;margin-left: 2px;" class="icon iconfont icon-touming" /> <i style="float: left;margin-top: 3px;margin-left: 2px;" class="icon iconfont icon-touming" />
</el-tooltip> </el-tooltip>
<div style="width: 70px;float: left;margin-top: 2px;margin-left: 2px;"> <div v-if="attrShow('opacity')" style="width: 70px;float: left;margin-top: 2px;margin-left: 2px;">
<el-input v-model="innerOpacity" type="number" size="mini" min="0" max="100" step="10" @change="styleChange" /> <el-input v-model="innerOpacity" type="number" size="mini" min="0" max="100" step="10" @change="styleChange" />
</div> </div>
<el-tooltip :content="$t('panel.borderRadius')"> <el-tooltip v-if="attrShow('borderRadius')" :content="$t('panel.borderRadius')">
<i style="float: left;margin-top: 3px;margin-left: 2px;" class="icon iconfont icon-fangxing-" /> <i style="float: left;margin-top: 3px;margin-left: 2px;" class="icon iconfont icon-fangxing-" />
</el-tooltip> </el-tooltip>
<div style="width: 70px;float: left;margin-top: 2px;margin-left: 2px;"> <div v-if="attrShow('borderRadius')" style="width: 70px;float: left;margin-top: 2px;margin-left: 2px;">
<el-input v-model="styleInfo.borderRadius" type="number" size="mini" min="0" max="100" step="1" @change="styleChange" /> <el-input v-model="styleInfo.borderRadius" type="number" size="mini" min="0" max="100" step="1" @change="styleChange" />
</div> </div>
<div style="width: 20px;float: left;margin-top: 2px;margin-left: 10px;"> <div v-if="attrShow('color')" style="width: 20px;float: left;margin-top: 2px;margin-left: 10px;">
<div style="width: 16px;height: 18px"> <div style="width: 16px;height: 18px">
<el-tooltip :content="$t('panel.color')"> <el-tooltip :content="$t('panel.color')">
<i class="icon iconfont icon-zimua" @click="goColor" /> <i class="icon iconfont icon-zimua" @click="goColor" />
...@@ -65,8 +95,17 @@ ...@@ -65,8 +95,17 @@
<el-color-picker ref="colorPicker" v-model="styleInfo.color" style="margin-top: 7px;height: 0px" size="mini" @change="styleChange" /> <el-color-picker ref="colorPicker" v-model="styleInfo.color" style="margin-top: 7px;height: 0px" size="mini" @change="styleChange" />
</div> </div>
</div> </div>
<div v-if="attrShow('borderColor')" style="width: 20px;float: left;margin-top: 2px;margin-left: 10px;">
<div style="width: 16px;height: 18px">
<el-tooltip content="边框颜色">
<i class="iconfont icon-huabi" @click="goBoardColor" />
</el-tooltip>
<div :style="boardDivColor" />
<el-color-picker ref="boardColorPicker" v-model="styleInfo.borderColor" style="margin-top: 7px;height: 0px" size="mini" @change="styleChange" />
</div>
</div>
<div style="width: 20px;float: left;margin-top: 2px;margin-left: 10px;"> <div v-if="attrShow('backgroundColor')" style="width: 20px;float: left;margin-top: 2px;margin-left: 10px;">
<div style="width: 16px;height: 18px"> <div style="width: 16px;height: 18px">
<el-tooltip content="背景颜色"> <el-tooltip content="背景颜色">
<i class="iconfont icon-beijingse1" @click="goBackgroundColor" /> <i class="iconfont icon-beijingse1" @click="goBackgroundColor" />
...@@ -76,12 +115,14 @@ ...@@ -76,12 +115,14 @@
</div> </div>
</div> </div>
<div style="width: 20px;float: left;margin-top: 2px;margin-left: 2px;"> <div v-if="attrShow('hyperlinks')" style="width: 20px;float: left;margin-top: 2px;margin-left: 2px;">
<el-tooltip v-if="curComponent.hyperlinks" content="超链接"> <el-tooltip v-if="curComponent.hyperlinks" content="超链接">
<Hyperlinks :link-info="curComponent.hyperlinks" /> <Hyperlinks :link-info="curComponent.hyperlinks" />
</el-tooltip> </el-tooltip>
</div>
<el-tooltip v-if="curComponent.type === 'de-show-date'" content="日期格式"> <div v-if="attrShow('date-format')" style="width: 20px;float: left;margin-top: 2px;margin-left: 2px;">
<el-tooltip content="日期格式">
<date-format :format-info="curComponent.formatInfo" /> <date-format :format-info="curComponent.formatInfo" />
</el-tooltip> </el-tooltip>
</div> </div>
...@@ -109,8 +150,8 @@ export default { ...@@ -109,8 +150,8 @@ export default {
}, },
data() { data() {
return { return {
showMain: true,
innerOpacity: 0, innerOpacity: 0,
mainWidthOffset: 600,
textAlignOptions: [ textAlignOptions: [
{ {
icon: 'iconfont icon-juzuo', icon: 'iconfont icon-juzuo',
...@@ -128,6 +169,82 @@ export default { ...@@ -128,6 +169,82 @@ export default {
label: 'right' label: 'right'
} }
], ],
lineStyle: [{
icon: 'iconfont icon-solid_line',
value: 'solid',
label: '实线'
}, {
icon: 'iconfont icon-xuxian',
value: 'dashed',
label: '虚线'
}, {
icon: 'iconfont icon-dianxian',
value: 'dotted',
label: '点线'
}],
lineFont: [{
value: '0',
label: '0'
}, {
value: '1',
label: '1'
}, {
value: '2',
label: '2'
}, {
value: '3',
label: '3'
}, {
value: '4',
label: '4'
}, {
value: '5',
label: '5'
}],
// 矩形组件显示的属性
'picture-add': [
'borderStyle',
'borderWidth',
'borderRadius',
'opacity',
'borderColor'
],
// 过滤组件显示的属性
'custom': [
'fontSize',
'fontWeight',
'letterSpacing',
'color',
'backgroundColor'
],
// tab组件显示的属性
'de-tabs': [
'borderStyle',
'borderWidth',
'borderRadius',
'opacity',
'borderColor'
],
// 矩形组件显示的属性
'rect-shape': [
'borderStyle',
'borderWidth',
'borderRadius',
'opacity',
'borderColor'
],
// 时间组件显示的属性
'de-show-date': [
'textAlign',
'fontSize',
'fontWeight',
'opacity',
'borderRadius',
'color',
'backgroundColor',
'date-format'
],
// 文本组件显示的属性
'v-text': [ 'v-text': [
'textAlign', 'textAlign',
'fontSize', 'fontSize',
...@@ -138,24 +255,33 @@ export default { ...@@ -138,24 +255,33 @@ export default {
'color', 'color',
'backgroundColor', 'backgroundColor',
'hyperlinks' 'hyperlinks'
] } ]
}
}, },
watch: { watch: {
innerOpacity: { innerOpacity: {
handler(oldVal, newVal) { handler(oldVal, newVal) {
this.styleInfo['opacity'] = this.innerOpacity / 100 this.styleInfo['opacity'] = this.innerOpacity / 100
} }
},
curComponent: {
handler(oldVal, newVal) {
this.$nextTick(() => {
this.init()
})
// console.log('curComponent change')
}
} }
}, },
mounted() { mounted() {
if (this.styleInfo['opacity']) { this.init()
this.innerOpacity = this.styleInfo['opacity'] * 100
}
this.mainWidthOffset = document.getElementById('main-attr').offsetWidth - 50
// console.log('mainWidthOffset:' + this.mainWidthOffset)
}, },
computed: { computed: {
attrShow(attr) { boardDivColor() {
const style = {
height: '2px',
background: this.styleInfo.borderColor
}
return style return style
}, },
letterDivColor() { letterDivColor() {
...@@ -198,9 +324,23 @@ export default { ...@@ -198,9 +324,23 @@ export default {
}, },
methods: { methods: {
init() {
if (this.styleInfo['opacity']) {
this.innerOpacity = this.styleInfo['opacity'] * 100
}
this.mainWidthOffset = document.getElementById('main-attr').offsetWidth - 50
// console.log('mainWidthOffset:' + this.mainWidthOffset)
},
attrShow(attr) {
// console.log('attr:' + attr + this[this.curComponent.type].includes(attr))
return this[this.curComponent.type].includes(attr)
},
goColor() { goColor() {
this.$refs.colorPicker.handleTrigger() this.$refs.colorPicker.handleTrigger()
}, },
goBoardColor() {
this.$refs.boardColorPicker.handleTrigger()
},
goBackgroundColor() { goBackgroundColor() {
this.$refs.backgroundColorPicker.handleTrigger() this.$refs.backgroundColorPicker.handleTrigger()
}, },
......
// 公共样式 // 公共样式
export const commonStyle = { export const commonStyle = {
rotate: 0, rotate: 0,
opacity: 1 opacity: 1,
borderStyle: 'solid',
borderWidth: 0,
borderRadius: 0
} }
export const commonAttr = { export const commonAttr = {
...@@ -143,6 +146,8 @@ const list = [ ...@@ -143,6 +146,8 @@ const list = [
type: 'Picture', type: 'Picture',
propValue: require('@/components/canvas/assets/bg-kj-1.jpg'), propValue: require('@/components/canvas/assets/bg-kj-1.jpg'),
style: { style: {
borderStyle: 'solid',
borderWidth: 0,
width: 600, width: 600,
height: 300, height: 300,
borderRadius: '' borderRadius: ''
...@@ -198,7 +203,7 @@ const list = [ ...@@ -198,7 +203,7 @@ const list = [
width: 200, width: 200,
height: 200, height: 200,
borderStyle: 'solid', borderStyle: 'solid',
borderWidth: 1, borderWidth: 0,
borderColor: '#000000', borderColor: '#000000',
backgroundColor: '#ffffff', backgroundColor: '#ffffff',
borderRadius: 0 borderRadius: 0
......
...@@ -162,9 +162,9 @@ ...@@ -162,9 +162,9 @@
<input id="input" ref="files" type="file" accept="image/*" hidden @click="e => {e.target.value = '';}" @change="handleFileChange"> <input id="input" ref="files" type="file" accept="image/*" hidden @click="e => {e.target.value = '';}" @change="handleFileChange">
<!--矩形样式组件--> <!--矩形样式组件-->
<RectangleAttr v-if="curComponent&&(curComponent.type==='rect-shape'||curComponent.type==='de-tabs')" :scroll-left="scrollLeft" :scroll-top="scrollTop" /> <!-- <RectangleAttr v-if="curComponent&&(curComponent.type==='rect-shape'||curComponent.type==='de-tabs')" :scroll-left="scrollLeft" :scroll-top="scrollTop" />-->
<TextAttr v-if="curComponent && (curComponent.type==='v-text' || curComponent.type==='de-show-date')" :scroll-left="scrollLeft" :scroll-top="scrollTop" /> <TextAttr v-if="showAttr" :scroll-left="scrollLeft" :scroll-top="scrollTop" />
<FilterTextAttr v-if="curComponent&&curComponent.type==='custom'&&curComponent.options.attrs.title" :scroll-left="scrollLeft" :scroll-top="scrollTop" /> <!-- <FilterTextAttr v-if="curComponent&&curComponent.type==='custom'&&curComponent.options.attrs.title" :scroll-left="scrollLeft" :scroll-top="scrollTop" />-->
<!--复用ChartGroup组件 不做显示--> <!--复用ChartGroup组件 不做显示-->
<ChartGroup <ChartGroup
ref="chartGroup" ref="chartGroup"
...@@ -280,11 +280,33 @@ export default { ...@@ -280,11 +280,33 @@ export default {
scrollLeft: 0, scrollLeft: 0,
scrollTop: 0, scrollTop: 0,
timeMachine: null, timeMachine: null,
dropComponentInfo: null dropComponentInfo: null,
// 需要展示属性设置的组件类型
showAttrComponent: [
'custom',
'v-text',
'picture-add',
'de-tabs',
'rect-shape',
'de-show-date'
]
} }
}, },
computed: { computed: {
showAttr() {
// console.log('showAttr:' + JSON.stringify(this.curComponent))
if (this.curComponent && this.showAttrComponent.includes(this.curComponent.type)) {
// 过滤组件有标题才显示
if (this.curComponent.type === 'custom' && !this.curComponent.options.attrs.title) {
return false
} else {
return true
}
} else {
return false
}
},
customCanvasStyle() { customCanvasStyle() {
let style = {} let style = {}
...@@ -687,6 +709,7 @@ export default { ...@@ -687,6 +709,7 @@ export default {
...commonAttr, ...commonAttr,
id: generateID(), id: generateID(),
component: 'Picture', component: 'Picture',
type: 'picture-add',
label: '图片', label: '图片',
icon: '', icon: '',
propValue: fileResult, propValue: fileResult,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论