| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <template>
- <!-- 分离器 -->
- <div class="tank_body" :style="getTankBodyStyle">
- <i class="icon iconfont-hnyz-colour icon-hnyz-colourseparator tank " :style="getTankStyle">
- <!-- 标题 -->
- <div class="tank_title" v-if="title">{{ title }}</div>
- </i>
- </div>
- </template>
- <script setup>
- import { computed } from 'vue'
- const props = defineProps({
- iconSize: {//图标大小
- type: Number,
- default: 200,
- },
- title: {//罐名
- type: String,
- },
- iconWidth: {//图标宽度
- type: Number,
- },
- iconHeight: {//图标高度
- type: Number,
- },
- })
- //罐体样式
- const getTankBodyStyle = computed(() => ({
- width: `${props.iconWidth ?? props.iconSize}px`,
- height: `${props.iconHeight ?? props.iconSize}px`,
- fontSize: `${props.iconSize}px`,
- }))
- // 罐子样式
- const getTankStyle = computed(() => {
- const style = {
- fontSize: props.iconSize + 'px',
- display: 'inline-block'
- }
- //根据传进来的iconWidth和iconHeight来控制图标的大小
- const scaleX = props.iconWidth ? props.iconWidth / props.iconSize : 1
- const scaleY = props.iconHeight ? props.iconHeight / props.iconSize : 1
- if (scaleX !== 1 || scaleY !== 1) {
- style.transform = `scale(${scaleX}, ${scaleY})`
- }
- return style
- })
- </script>
- <style scoped lang="scss">
- //水位罐
- .tank_body {
- text-align: center;
- position: relative;
- .tank {
- position: relative;
- z-index: 10;
- //罐子名称
- .tank_title {
- position: absolute;
- top: 47%;
- left: 50%;
- transform: translate(-50%, -50%);
- font-size: 16px;
- color: #d3e600;
- font-weight: bold;
- }
- }
- }
- </style>
|