@tagplus/components 1.2.6 → 1.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tp.common.js +1 -1
- package/dist/tp.common.js.map +1 -1
- package/dist/tp.css +3 -3
- package/dist/tp.umd.js +1 -1
- package/dist/tp.umd.js.map +1 -1
- package/dist/tp.umd.min.js +1 -1
- package/dist/tp.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Money/Money.vue +2 -19
- package/src/components/Multisuggest/Multisuggest.vue +4 -5
- package/src/components/Percent/Percent.vue +3 -19
- package/src/mixins/floatFormatter.js +34 -0
- package/src/utils/currency.js +18 -1
package/package.json
CHANGED
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
|
|
31
31
|
<script>
|
|
32
32
|
import Locale from 'tp-ui/mixins/locale'
|
|
33
|
-
import
|
|
33
|
+
import floatFormatterMixin from 'tp-ui/mixins/floatFormatter'
|
|
34
34
|
|
|
35
35
|
export default {
|
|
36
36
|
name: 'TpMoney',
|
|
37
37
|
|
|
38
|
-
mixins: [Locale],
|
|
38
|
+
mixins: [Locale, floatFormatterMixin],
|
|
39
39
|
props: {
|
|
40
40
|
id: {
|
|
41
41
|
type: String,
|
|
@@ -61,12 +61,6 @@ export default {
|
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
63
|
|
|
64
|
-
data () {
|
|
65
|
-
return {
|
|
66
|
-
formattedValue: this.value
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
|
|
70
64
|
computed: {
|
|
71
65
|
_id () {
|
|
72
66
|
return this.id || this.$options.name
|
|
@@ -75,17 +69,6 @@ export default {
|
|
|
75
69
|
prepend () {
|
|
76
70
|
return this.t('tp.money.currency')
|
|
77
71
|
}
|
|
78
|
-
},
|
|
79
|
-
|
|
80
|
-
methods: {
|
|
81
|
-
input (evt) {
|
|
82
|
-
this.formattedValue = formatMoney(evt, true)
|
|
83
|
-
this.$emit('input', formatMoney(evt, false))
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
handleChange (evt) {
|
|
87
|
-
this.$emit('change', formatMoney(evt, false))
|
|
88
|
-
}
|
|
89
72
|
}
|
|
90
73
|
}
|
|
91
74
|
</script>
|
|
@@ -475,12 +475,11 @@ export default {
|
|
|
475
475
|
|
|
476
476
|
if (Array.isArray(this.value)) {
|
|
477
477
|
this.value.forEach((item, key) => {
|
|
478
|
-
|
|
479
|
-
this.
|
|
480
|
-
|
|
481
|
-
this.selectedLabelsArray.push(item)
|
|
478
|
+
this.suggestionsList.forEach(suggestion => {
|
|
479
|
+
if (suggestion[this.valueKey] === item) {
|
|
480
|
+
this.selectedLabelsArray.push(suggestion)
|
|
482
481
|
}
|
|
483
|
-
}
|
|
482
|
+
})
|
|
484
483
|
})
|
|
485
484
|
} else if (process.env.DEBUG === 'true') {
|
|
486
485
|
console.log(`'${this.$options.name}' recebeu valor em formato inválido.`)
|
|
@@ -26,11 +26,12 @@
|
|
|
26
26
|
|
|
27
27
|
<script>
|
|
28
28
|
import Locale from 'tp-ui/mixins/locale'
|
|
29
|
-
import
|
|
29
|
+
import floatFormatterMixin from 'tp-ui/mixins/floatFormatter'
|
|
30
30
|
|
|
31
31
|
export default {
|
|
32
32
|
name: 'TpPercent',
|
|
33
|
-
|
|
33
|
+
|
|
34
|
+
mixins: [Locale, floatFormatterMixin],
|
|
34
35
|
props: {
|
|
35
36
|
id: {
|
|
36
37
|
type: String,
|
|
@@ -63,27 +64,10 @@ export default {
|
|
|
63
64
|
}
|
|
64
65
|
},
|
|
65
66
|
|
|
66
|
-
data () {
|
|
67
|
-
return {
|
|
68
|
-
formattedValue: this.value
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
|
|
72
67
|
computed: {
|
|
73
68
|
_id () {
|
|
74
69
|
return this.id || this.$options.name
|
|
75
70
|
}
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
methods: {
|
|
79
|
-
input (evt) {
|
|
80
|
-
this.formattedValue = formatMoney(evt, true)
|
|
81
|
-
this.$emit('input', formatMoney(evt, false))
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
handleChange (evt) {
|
|
85
|
-
this.$emit('change', formatMoney(evt, false))
|
|
86
|
-
}
|
|
87
71
|
}
|
|
88
72
|
}
|
|
89
73
|
</script>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { formatMoney } from 'tp-ui/utils/currency'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Eventos para componentes tp-money e tp-percent mostratem o número formatado com a precisão correta e devolver float sem arredondar
|
|
5
|
+
*/
|
|
6
|
+
export default {
|
|
7
|
+
data () {
|
|
8
|
+
return {
|
|
9
|
+
formattedValue: this.value
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
|
|
13
|
+
watch: {
|
|
14
|
+
value: {
|
|
15
|
+
immediate: true,
|
|
16
|
+
handler (newValue, oldValue) {
|
|
17
|
+
this.formattedValue = formatMoney(newValue, true)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
methods: {
|
|
23
|
+
input (evt) {
|
|
24
|
+
this.formattedValue = formatMoney(evt, true)
|
|
25
|
+
const moneyFormatado = formatMoney(evt, false)
|
|
26
|
+
this.$emit('input', moneyFormatado)
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
handleChange (evt) {
|
|
30
|
+
this.$emit('change', formatMoney(evt, false))
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
}
|
package/src/utils/currency.js
CHANGED
|
@@ -25,7 +25,10 @@ function unformat (input, precision = defaults.precision) {
|
|
|
25
25
|
|
|
26
26
|
function formatMoney (input, toString = false, precision = defaults.precision) {
|
|
27
27
|
const negative = ('' + input).indexOf('-') >= 0 ? -1 : 1
|
|
28
|
-
|
|
28
|
+
if (toString) {
|
|
29
|
+
input = completeZeros(('' + input), precision)
|
|
30
|
+
}
|
|
31
|
+
const numbers = onlyNumbers(input, precision)
|
|
29
32
|
const currency = numbersToCurrency(numbers, precision)
|
|
30
33
|
if (toString) {
|
|
31
34
|
return negative === -1 ? '-' + currency : '' + currency
|
|
@@ -34,6 +37,19 @@ function formatMoney (input, toString = false, precision = defaults.precision) {
|
|
|
34
37
|
}
|
|
35
38
|
}
|
|
36
39
|
|
|
40
|
+
function completeZeros (input, precision = defaults.precision) {
|
|
41
|
+
const i = input.indexOf('.')
|
|
42
|
+
const qntDecimais = i ? input.length - i - 1 : 0
|
|
43
|
+
|
|
44
|
+
// correção para decimal quebrado
|
|
45
|
+
if (i === -1) {
|
|
46
|
+
input = input + '.' + '0'.repeat(precision)
|
|
47
|
+
} else if (i && qntDecimais < precision) {
|
|
48
|
+
input = input + '0'.repeat(precision - qntDecimais)
|
|
49
|
+
}
|
|
50
|
+
return input
|
|
51
|
+
}
|
|
52
|
+
|
|
37
53
|
function onlyNumbers (input) {
|
|
38
54
|
return toStr(input).replace(/\D+/g, '') || '0'
|
|
39
55
|
}
|
|
@@ -90,5 +106,6 @@ export {
|
|
|
90
106
|
format,
|
|
91
107
|
unformat,
|
|
92
108
|
setCursor,
|
|
109
|
+
completeZeros,
|
|
93
110
|
event
|
|
94
111
|
}
|