Unverified 提交 7f895505 authored 作者: XiaJunjie2020's avatar XiaJunjie2020 提交者: GitHub

Merge pull request #635 from dataease/pr@dev@feat_color

feat: 视图支持简单颜色修改
...@@ -840,7 +840,9 @@ export default { ...@@ -840,7 +840,9 @@ export default {
bubble_symbol: 'Shape', bubble_symbol: 'Shape',
gap_width: 'Gap Width', gap_width: 'Gap Width',
width: 'Width', width: 'Width',
height: 'Height' height: 'Height',
system_case: 'System',
custom_case: 'Custom'
}, },
dataset: { dataset: {
sheet_warn: 'There are multiple sheet pages, and the first one is extracted by default', sheet_warn: 'There are multiple sheet pages, and the first one is extracted by default',
......
...@@ -840,7 +840,9 @@ export default { ...@@ -840,7 +840,9 @@ export default {
bubble_symbol: '圖形', bubble_symbol: '圖形',
gap_width: '間隔', gap_width: '間隔',
width: '寬度', width: '寬度',
height: '高度' height: '高度',
system_case: '系統方案',
custom_case: '自定義'
}, },
dataset: { dataset: {
sheet_warn: '有多個sheet頁面,默認抽取第一個', sheet_warn: '有多個sheet頁面,默認抽取第一個',
......
...@@ -840,7 +840,9 @@ export default { ...@@ -840,7 +840,9 @@ export default {
bubble_symbol: '图形', bubble_symbol: '图形',
gap_width: '间隔', gap_width: '间隔',
width: '宽度', width: '宽度',
height: '高度' height: '高度',
system_case: '系统方案',
custom_case: '自定义'
}, },
dataset: { dataset: {
sheet_warn: '有多个 Sheet 页,默认抽取第一个', sheet_warn: '有多个 Sheet 页,默认抽取第一个',
......
...@@ -4,14 +4,46 @@ ...@@ -4,14 +4,46 @@
<el-form ref="colorForm" :model="colorForm" label-width="80px" size="mini" :disabled="param && !hasDataPermission('manage',param.privileges)"> <el-form ref="colorForm" :model="colorForm" label-width="80px" size="mini" :disabled="param && !hasDataPermission('manage',param.privileges)">
<div v-if="sourceType==='view' || sourceType==='panelEchart'"> <div v-if="sourceType==='view' || sourceType==='panelEchart'">
<el-form-item v-show="chart.type && !chart.type.includes('table') && !chart.type.includes('text')" :label="$t('chart.color_case')" class="form-item"> <el-form-item v-show="chart.type && !chart.type.includes('table') && !chart.type.includes('text')" :label="$t('chart.color_case')" class="form-item">
<el-select v-model="colorForm.value" :placeholder="$t('chart.pls_slc_color_case')" size="mini" @change="changeColorCase"> <el-popover
<el-option v-for="option in colorCases" :key="option.value" :label="option.name" :value="option.value" style="display: flex;align-items: center;"> placement="bottom"
<div style="float: left"> width="400"
<span v-for="(c,index) in option.colors" :key="index" :style="{width: '20px',height: '20px',float: 'left',backgroundColor: c}" /> trigger="click"
:disabled="param && !hasDataPermission('manage',param.privileges)"
>
<div style="padding: 6px 10px;">
<div>
<span class="color-label">{{ $t('chart.system_case') }}</span>
<el-select v-model="colorForm.value" :placeholder="$t('chart.pls_slc_color_case')" size="mini" @change="changeColorCase">
<el-option v-for="option in colorCases" :key="option.value" :label="option.name" :value="option.value" style="display: flex;align-items: center;">
<div style="float: left">
<span v-for="(c,index) in option.colors" :key="index" :style="{width: '20px',height: '20px',float: 'left',backgroundColor: c}" />
</div>
<span style="margin-left: 4px;">{{ option.name }}</span>
</el-option>
</el-select>
<el-button size="mini" type="text" style="margin-left: 2px;" @click="resetCustomColor">{{ $t('commons.reset') }}</el-button>
</div> </div>
<span style="margin-left: 4px;">{{ option.name }}</span> <div style="display: flex;align-items: center;margin-top: 10px;">
</el-option> <span class="color-label">{{ $t('chart.custom_case') }}</span>
</el-select> <span>
<el-radio-group v-model="customColor" class="color-type">
<el-radio v-for="(c,index) in colorForm.colors" :key="index" :label="c" style="padding: 2px;" @change="switchColor(index)">
<span :style="{width: '20px',height: '20px',display:'inline-block',backgroundColor: c}" />
</el-radio>
</el-radio-group>
</span>
</div>
<div style="display: flex;align-items: center;margin-top: 10px;">
<span class="color-label" />
<span>
<el-color-picker v-model="customColor" class="color-picker-style" @change="switchColorCase" />
</span>
</div>
</div>
<div slot="reference" style="cursor: pointer;margin-top: 2px;">
<span v-for="(c,index) in colorForm.colors" :key="index" :style="{width: '20px',height: '20px',display:'inline-block',backgroundColor: c}" />
</div>
</el-popover>
</el-form-item> </el-form-item>
<el-form-item v-show="(chart.type && chart.type.includes('text')) || sourceType==='panelTable'" :label="$t('chart.dimension_color')" class="form-item"> <el-form-item v-show="(chart.type && chart.type.includes('text')) || sourceType==='panelTable'" :label="$t('chart.dimension_color')" class="form-item">
...@@ -149,12 +181,16 @@ export default { ...@@ -149,12 +181,16 @@ export default {
colors: ['#00a3af', '#4da798', '#57baaa', '#62d0bd', '#6ee4d0', '#86e7d6', '#aeede1', '#bde1e6', '#e5e5e5'] colors: ['#00a3af', '#4da798', '#57baaa', '#62d0bd', '#6ee4d0', '#86e7d6', '#aeede1', '#bde1e6', '#e5e5e5']
} }
], ],
colorForm: JSON.parse(JSON.stringify(DEFAULT_COLOR_CASE)) colorForm: JSON.parse(JSON.stringify(DEFAULT_COLOR_CASE)),
customColor: null,
colorIndex: 0
} }
}, },
watch: { watch: {
'chart': { 'chart': {
handler: function() { handler: function() {
this.customColor = null
this.colorIndex = 0
this.init() this.init()
} }
} }
...@@ -172,6 +208,8 @@ export default { ...@@ -172,6 +208,8 @@ export default {
val.value = items[0].value val.value = items[0].value
val.colors = items[0].colors val.colors = items[0].colors
this.$emit('onColorChange', val) this.$emit('onColorChange', val)
this.customColor = null
this.colorIndex = 0
}, },
init() { init() {
const chart = JSON.parse(JSON.stringify(this.chart)) const chart = JSON.parse(JSON.stringify(this.chart))
...@@ -184,8 +222,26 @@ export default { ...@@ -184,8 +222,26 @@ export default {
} }
if (customAttr.color) { if (customAttr.color) {
this.colorForm = customAttr.color this.colorForm = customAttr.color
if (!this.customColor) {
this.customColor = this.colorForm.colors[0]
this.colorIndex = 0
}
} }
} }
},
switchColor(index) {
this.colorIndex = index
},
switchColorCase() {
this.colorForm.colors[this.colorIndex] = this.customColor
this.$emit('onColorChange', this.colorForm)
},
resetCustomColor() {
this.customColor = this.colorForm.colors[0]
this.colorIndex = 0
this.changeColorCase()
} }
} }
} }
...@@ -220,4 +276,22 @@ export default { ...@@ -220,4 +276,22 @@ export default {
cursor: pointer; cursor: pointer;
z-index: 1003; z-index: 1003;
} }
.color-label{
display: inline-block;
width: 60px;
}
.color-type>>>.el-radio__input{
display: none;
}
.el-radio{
margin:0 4px 0 0!important;
}
.el-radio>>>.el-radio__label{
padding-left: 0;
}
.el-radio.is-checked{
border: 1px solid #0a7be0;
}
</style> </style>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论