保誠-保戶業務員媒合平台
wayne
2022-02-17 4394e4248455637ab7836756058ac872fdf4af10
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
<template>
    <el-col :span="fieldSpan" class="pam-field"
      v-if="fieldDisplayDevice === 'ALL'
      || fieldDisplayDevice === currentDevice">
      <div class="pam-field__label">
        <div class="pam-field__title" :style="{ 'font-size': fieldLabelSize }"><i :class="fieldIcon"></i>{{ fieldLabel }}</div>
      </div>
      <p class="pam-field__content">
        <slot></slot>
      </p>
    </el-col>
</template>
 
<script lang="ts">
import { Vue, Component, Prop } from 'vue-property-decorator';
 
import UtilsService from '~/shared/services/utils.service';
 
@Component
export default class UiField extends Vue {
 
  @Prop()
  span!: number;
 
  @Prop()
  icon!: string;
 
  @Prop()
  label!: string;
 
  @Prop()
  content!: string;
 
  @Prop()
  labelSize?: number;
 
  @Prop()
  displayDevice!: 'MOBILE' | 'DESKTOP' | 'ALL';
 
  currentDevice: 'MOBILE' | 'DESKTOP' = 'MOBILE';
 
  //////////////////////////////////////////////////////////////////
 
  mounted(): void {
    this.currentDevice = UtilsService.isMobileDevice() ? 'MOBILE' : 'DESKTOP';
  }
 
  get fieldSpan(): number {
    return this.span || 24;
  }
 
  get fieldIcon(): string {
    return `pam-icon icon-${this.icon}`;
  }
 
  get fieldLabel(): string {
    return `${this.label}`;
  }
 
  get fieldDisplayDevice(): 'MOBILE' | 'DESKTOP' | 'ALL' {
    return this.displayDevice || 'ALL';
  }
 
  get fieldLabelSize(): string {
    return (this.labelSize || 16) + 'px';
  }
 
}
</script>
 
<style lang="scss" scoped>
.pam-field {
  display       : flex;
  flex-direction: column;
  .pam-field__label {
    align-items: center;
    display    : flex;
    .pam-icon {
      font-size: 12px;
    }
    .pam-field__title {
      align-items: center;
      display    : flex;
      font-weight: bold;
    }
  }
  .pam-field__content {
    display    : flex;
    // padding-top: 10px;
    white-space: pre-line;
    line-height: 1.5;
  }
}
</style>