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
<template>
<div class="upper-lower-deviation">
<span> {{ toleranceListValue }}</span>
<span v-if="toleranceListUp && toleranceListUp.includes('±')">
{{ toleranceListUp }}
</span>
<span v-else class="es-ei-box" :style="{width: tolerWidth+'px'}">
<span class="es-content">{{ toleranceListUp }}</span>
<span class="ei-content">{{ toleranceListDown }}</span>
</span>
</div>
</template>
<script>
export default {
name: 'UpLowAngle',
props: {
value: {
type: String,
default: () => ''
}
},
data() {
return {
finalvalue: [],
toleranceListValue: '',
toleranceListUp: '',
toleranceListDown: '',
tolerWidth: 40
}
},
computed: {},
watch: {
value() {
this.formateData()
}
},
created() {
this.formateData()
},
mounted() {},
methods: {
formateData() {
if (!this.value) {
this.finalvalue = []
} else {
const middleData = this.value.split(' ')
if (middleData[0]) {
const regdegree = /([-\d.]+?)°/.exec(middleData[0])
const regminute = /([-\d.]+?)′/.exec(middleData[0])
const regsecond = /([-\d.]+?)″/.exec(middleData[0])
const degree = regdegree ? regdegree[1] + '°' : ''
const minute = regminute ? regminute[1] + '′' : ''
const second = regsecond ? regsecond[1] + '″' : ''
this.toleranceListValue = degree + minute + second
}
if (middleData[1]) {
const regdegree = /([-\d.]+?)°/.exec(middleData[1])
const regminute = /([-\d.]+?)′/.exec(middleData[1])
const regsecond = /([-\d.]+?)″/.exec(middleData[1])
const degree = regdegree ? regdegree[1] + '°' : ''
const minute = regminute ? regminute[1] + '′' : ''
const second = regsecond ? regsecond[1] + '″' : ''
const toleranceListUp = degree + minute + second
if (toleranceListUp && toleranceListUp.indexOf('-') < 0) {
this.toleranceListUp = '+' + toleranceListUp
} else {
this.toleranceListUp = toleranceListUp
}
}
if (middleData[2]) {
const regdegree = /([-\d.]+?)°/.exec(middleData[2])
const regminute = /([-\d.]+?)′/.exec(middleData[2])
const regsecond = /([-\d.]+?)″/.exec(middleData[2])
const degree = regdegree ? regdegree[1] + '°' : ''
const minute = regminute ? regminute[1] + '′' : ''
const second = regsecond ? regsecond[1] + '″' : ''
this.toleranceListDown = degree + minute + second
const toleranceListDown = degree + minute + second
if (toleranceListDown && toleranceListDown.indexOf('-') < 0) {
this.toleranceListDown = '+' + toleranceListDown
} else {
this.toleranceListDown = toleranceListDown
}
}
if (this.toleranceListUp.length > this.toleranceListDown.length) {
this.tolerWidth = this.toleranceListUp.length * 7
} else {
this.tolerWidth = this.toleranceListDown.length * 7
}
if (this.toleranceListUp.indexOf('+') > -1 && this.toleranceListDown.indexOf('-') > -1 && this.toleranceListUp.slice(1) === this.toleranceListDown.slice(1)) {
this.toleranceListUp = '±' + this.toleranceListUp.slice(1)
}
}
}
}
}
</script>
<style lang="scss">
.upper-lower-deviation{
display: inline-block;
.es-ei-box{
position: relative;
font-size: 12px;
display: inline-block;
width: 40px;
height: 20px;
.ei-content{
position: relative;
left: 0;
bottom: -10px;
font-size: 12px;
float: left;
}
.es-content{
position: absolute;
left: 0;
top: -5px;
font-size: 12px
}
}
}
</style>