Blame view

frontend/front/src/components/datav/DvDecoration.vue 4.21 KB
8ea9c133   陈威   初始化提交
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
<template>
  <div :style="{ width: width + 'px', height: element.height + 'px' }">
    <template v-if="element.alias == 'decoration1'">
      <dv-decoration-1
        :color="element.options.config.color"
        :style="'width:' + width + 'px;height:' + height + 'px;'"
      />
    </template>
    <template v-if="element.alias == 'decoration2'">
      <dv-decoration-2
        :dur="element.options.config.dur"
        :reverse="element.options.config.reverse"
        :style="'width:' + width + 'px;height:' + height + 'px;'"
      />
    </template>
    <template v-if="element.alias == 'decoration3'">
      <dv-decoration-3
        :style="'width:' + width + 'px;height:' + height + 'px;'"
      />
    </template>
    <template v-if="element.alias == 'decoration4'">
      <dv-decoration-4
        :reverse="element.options.config.reverse"
        :style="'width:' + width + 'px;height:' + height + 'px;'"
      />
    </template>
    <template v-if="element.alias == 'decoration5'">
      <dv-decoration-5
        :dur="element.options.config.dur"
        :style="'width:' + width + 'px;height:' + height + 'px;'"
      />
    </template>
    <template v-if="element.alias == 'decoration6'">
      <dv-decoration-6
        :style="'width:' + width + 'px;height:' + height + 'px;'"
      />
    </template>
    <template v-if="element.alias == 'decoration7'">
      <dv-decoration-7
        :style="'width:' + width + 'px;height:' + height + 'px;'"
      >
        <span :style="getFontStyle(element)">
          {{ getTextContent(element) }}
        </span>
      </dv-decoration-7>
    </template>
    <template v-if="element.alias == 'decoration8'">
      <dv-decoration-8
        :reverse="element.options.config.reverse"
        :style="'width:' + width + 'px;height:' + height + 'px;'"
      />
    </template>
    <template v-if="element.alias == 'decoration9'">
      <dv-decoration-9
        :dur="element.options.config.dur"
        :style="'width:' + width + 'px;height:' + height + 'px;'"
      >
        <span :style="getFontStyle(element)">
          {{ getTextContent(element) }}
        </span>
      </dv-decoration-9>
    </template>
    <template v-if="element.alias == 'decoration10'">
      <dv-decoration-10
        :style="'width:' + width + 'px;height:' + height + 'px;'"
      />
    </template>
    <template v-if="element.alias == 'decoration11'">
      <dv-decoration-11
        :style="'width:' + width + 'px;height:' + height + 'px;'"
      >
        <span :style="getFontStyle(element)">
          {{ getTextContent(element) }}
        </span>
      </dv-decoration-11>
    </template>
    <template v-if="element.alias == 'decoration12'">
      <dv-decoration-12
        :scan-dur="element.options.config.scanDur"
        :halo-dur="element.options.config.haloDur"
        :style="'width:' + width + 'px;height:' + height + 'px;'"
      />
    </template>
  </div>
</template>
<script>
  import VueDraggableResizable from 'vue-draggable-resizable'
  import 'vue-draggable-resizable/dist/VueDraggableResizable.css'
  export default {
    name: 'DvBorderBox',
    components: {
      VueDraggableResizable,
    },
    props: {
      width: {
        type: Number,
        default: 0,
      },
      height: {
        type: Number,
        default: 0,
      },
      element: {
        type: Object,
        default: {},
      },
    },
    data() {
      return {}
    },
    mounted() {},
    methods: {
      getFontStyle(obj) {
        if (obj.options.config.isDiyStyle && obj.options.config.diyStyle) {
          return JSON.parse(obj.options.config.diyStyle)
        } else {
          return {
            fontSize: obj.options.config.text.fontSize,
            color: obj.options.config.text.color,
            fontWeight: obj.options.config.text.fontWeight,
          }
        }
      },
      getTextContent(ele) {
        const content = ele.options.config.text.content
        const formatter = ele.options.config.text.formatter
        if (content != '' && content != null && formatter) {
          return this.execReplace(formatter, content)
        }
        return content
      },
      execReplace(formatterText, replacement) {
        return formatterText.replace(new RegExp('\\{c\\}', 'g'), replacement)
      },
    },
  }
</script>
<style></style>