fix: 颜色选择器 添加透明度的选择 以及topo图 背景默认透明

This commit is contained in:
zhangyu
2021-11-19 14:25:27 +08:00
parent 6a00be20f0
commit 415d6fadf6
4 changed files with 20 additions and 5 deletions

View File

@@ -808,7 +808,7 @@ export default {
// data = JSON.parse(localStorage.getItem('topoData')) // data = JSON.parse(localStorage.getItem('topoData'))
if (!res.data.topo || !data.pens) { if (!res.data.topo || !data.pens) {
data = { data = {
bkColor: '#FFFFFF', bkColor: '#FFFFFF00',
gridSize: 10, gridSize: 10,
gridColor: '#ededed', gridColor: '#ededed',
lineWidth: 1, lineWidth: 1,
@@ -887,6 +887,9 @@ export default {
if (!data.bkImage) { if (!data.bkImage) {
data.bkImage = undefined data.bkImage = undefined
} }
if (data.bkColor === '#FFFFFF') {
data.bkColor = '#FFFFFF00'
}
resolve(data) resolve(data)
}, 100) }, 100)
} }

View File

@@ -21,7 +21,7 @@
<el-row v-if="!single" class="color-tab"> <el-row v-if="!single" class="color-tab">
<div v-for="item in valueArr" :key="item.key" :class="[keyName==item.name?'color-active':'']" @click="colorTabChange(item)">{{item.name}}</div> <div v-for="item in valueArr" :key="item.key" :class="[keyName==item.name?'color-active':'']" @click="colorTabChange(item)">{{item.name}}</div>
</el-row> </el-row>
<sketch v-model="colors" :disableAlpha="true" @input="updateValue" :presetColors="presetColors"/> <sketch v-model="colors" :disableAlpha="disableAlpha" @input="updateValue" :presetColors="presetColors"/>
</div> </div>
</span> </span>
</template> </template>
@@ -67,6 +67,10 @@ export default {
'#7C2EA3', '#8F3BB8', '#B877D9' '#7C2EA3', '#8F3BB8', '#B877D9'
] ]
} }
},
disableAlpha: {
type: Boolean,
default: false
} }
}, },
watch: {}, watch: {},
@@ -89,7 +93,12 @@ export default {
methods: { methods: {
updateValue (color) { updateValue (color) {
this.colors = color.hex this.colors = color.hex
if (!this.disableAlpha) {
this.colors = color.hex8
this.$emit('colorChange', color.hex8, this.keyName)
} else {
this.$emit('colorChange', color.hex, this.keyName) this.$emit('colorChange', color.hex, this.keyName)
}
}, },
changeColor () { changeColor () {
this.showColorPicker = !this.showColorPicker this.showColorPicker = !this.showColorPicker

View File

@@ -1709,7 +1709,7 @@ export default {
return '' return ''
} }
; ;
if (color.length <= 7) { if (color.indexOf('#') === 0) {
return color return color
} }
const rgb = color.split(',') const rgb = color.split(',')

View File

@@ -805,7 +805,7 @@ export default {
// data = JSON.parse(localStorage.getItem('topoData')) // data = JSON.parse(localStorage.getItem('topoData'))
if (!res.data.topo || !data.pens) { if (!res.data.topo || !data.pens) {
data = { data = {
bkColor: '#FFFFFF', bkColor: '#FFFFFF00',
gridSize: 10, gridSize: 10,
gridColor: '#ededed', gridColor: '#ededed',
lineWidth: 1, lineWidth: 1,
@@ -886,6 +886,9 @@ export default {
if (!data.bkImage) { if (!data.bkImage) {
data.bkImage = undefined data.bkImage = undefined
} }
if (data.bkColor === '#FFFFFF') {
data.bkColor = '#FFFFFF00'
}
Promise.all(promiseArr).then(res => { Promise.all(promiseArr).then(res => {
res.forEach((response, index) => { res.forEach((response, index) => {
const item = data.pens[index] const item = data.pens[index]