15815213711
2025-04-24 16c179b122eb8c69d31b0fab66c5e29b9c332b8d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<template>
  <div class="section">
    <div class="section-header" @click="onClick">
      <div class="section-header__decoration" v-if="type" :class="type"/>
      <slot v-else name="decoration"></slot>
 
      <div class="section-header__content">
        <span :style="{'font-size':titleFontSize,'color':titleColor}" class="section__content-title"
              :class="{'distraction':!subTitle}">{{ title }}</span>
        <span v-if="subTitle" :style="{'font-size':subTitleFontSize,'color':subTitleColor}"
              class="section-header__content-sub">{{ subTitle }}</span>
      </div>
 
      <div class="section-header__slot-right">
        <slot name="right"></slot>
      </div>
    </div>
 
    <div class="section-content" :style="{padding: _padding}">
      <slot/>
    </div>
  </div>
</template>
 
<script setup name="Section">
/**
 * Section 标题栏
 * @description 标题栏
 * @property {String} type = [line|circle|square] 标题装饰类型
 *  @value line 竖线
 *  @value circle 圆形
 *  @value square 正方形
 * @property {String} title 主标题
 * @property {String} titleFontSize 主标题字体大小
 * @property {String} titleColor 主标题字体颜色
 * @property {String} subTitle 副标题
 * @property {String} subTitleFontSize 副标题字体大小
 * @property {String} subTitleColor 副标题字体颜色
 * @property {String} padding 默认插槽 padding
 */
 
import {computed, watch} from "vue";
 
const props = defineProps({
  type: {
    type: String,
    default: 'line'
  },
  title: {
    type: String,
    required: true,
    default: ''
  },
  titleFontSize: {
    type: String,
    default: '14px'
  },
  titleColor: {
    type: String,
    default: '#333'
  },
  subTitle: {
    type: String,
    default: ''
  },
  subTitleFontSize: {
    type: String,
    default: '12px'
  },
  subTitleColor: {
    type: String,
    default: '#999'
  },
  padding: {
    type: [Boolean, String],
    default: false
  }
})
 
const _padding = computed(() => {
  if (typeof props.padding === 'string') {
    return props.padding
  }
  return props.padding ? '10px' : ''
})
 
const emits = defineEmits(['click'])
const onClick = () => {
  emits('click');
}
 
</script>
 
<style lang="less">
 
.section {
  background-color: #fff;
 
  .section-header {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 12px 10px;
    font-weight: normal;
 
    .section-header__decoration {
      margin-right: 6px;
      background-color: #2979ff;
 
      &.line {
        width: 4px;
        height: 12px;
        border-radius: 10px;
      }
 
      &.circle {
        width: 8px;
        height: 8px;
        border-radius: 50px;
      }
 
      &.square {
        width: 8px;
        height: 8px;
      }
    }
    .section__content-title{
      font-weight: bold;
    }
    .section-header__content {
 
      display: flex;
      flex-direction: column;
      flex: 1;
      color: #333;
 
      .distraction {
        flex-direction: row;
        align-items: center;
      }
 
      &-sub {
        margin-top: 2px;
      }
    }
 
    .section-header__slot-right {
      font-size: 14px;
    }
  }
 
  .section-content {
    font-size: 14px;
    padding-left: 20px;
  }
}
</style>