DemuMesDataV/lib/components/borderBox3/src/main.vue

81 lines
1.9 KiB
Vue
Raw Normal View History

2019-08-22 14:41:07 +08:00
<template>
<div class="dv-border-box-3" :ref="ref">
<svg class="dv-border-svg-container" :width="width" :height="height">
2020-04-25 16:46:33 +08:00
<polygon :fill="backgroundColor" :points="`
23, 23 ${width - 24}, 23 ${width - 24}, ${height - 24} 23, ${height - 24}
`" />
2019-08-22 14:41:07 +08:00
<polyline class="dv-bb3-line1"
2019-12-06 21:07:16 +08:00
:stroke="mergedColor[0]"
:points="`4, 4 ${width - 22} ,4 ${width - 22}, ${height - 22} 4, ${height - 22} 4, 4`"
/>
2019-08-22 14:41:07 +08:00
<polyline class="dv-bb3-line2"
2019-12-06 21:07:16 +08:00
:stroke="mergedColor[1]"
:points="`10, 10 ${width - 16}, 10 ${width - 16}, ${height - 16} 10, ${height - 16} 10, 10`"
/>
2019-08-22 14:41:07 +08:00
<polyline class="dv-bb3-line2"
2019-12-06 21:07:16 +08:00
:stroke="mergedColor[1]"
:points="`16, 16 ${width - 10}, 16 ${width - 10}, ${height - 10} 16, ${height - 10} 16, 16`"
/>
2019-08-22 14:41:07 +08:00
<polyline class="dv-bb3-line2"
2019-12-06 21:07:16 +08:00
:stroke="mergedColor[1]"
:points="`22, 22 ${width - 4}, 22 ${width - 4}, ${height - 4} 22, ${height - 4} 22, 22`"
/>
2019-08-22 14:41:07 +08:00
</svg>
<div class="border-box-content">
<slot></slot>
</div>
</div>
</template>
<script>
import autoResize from '../../../mixin/autoResize'
2019-12-06 21:07:16 +08:00
import { deepMerge } from '@jiaminghi/charts/lib/util/index'
import { deepClone } from '@jiaminghi/c-render/lib/plugin/util'
2019-08-22 14:41:07 +08:00
export default {
name: 'DvBorderBox3',
mixins: [autoResize],
2019-12-06 21:07:16 +08:00
props: {
color: {
type: Array,
default: () => ([])
2020-04-25 16:46:33 +08:00
},
backgroundColor: {
type: String,
default: 'transparent'
2019-12-06 21:07:16 +08:00
}
},
2019-08-22 14:41:07 +08:00
data () {
return {
2019-12-06 21:07:16 +08:00
ref: 'border-box-3',
defaultColor: ['#2862b7', '#2862b7'],
mergedColor: []
2019-08-22 14:41:07 +08:00
}
2019-12-06 21:07:16 +08:00
},
watch: {
color () {
const { mergeColor } = this
mergeColor()
}
},
methods: {
mergeColor () {
const { color, defaultColor } = this
this.mergedColor = deepMerge(deepClone(defaultColor, true), color || [])
}
},
mounted () {
const { mergeColor } = this
mergeColor()
2019-08-22 14:41:07 +08:00
}
}
</script>