@tagplus/components 1.2.13 → 1.2.16
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 +1 -1
- 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/Multisuggest/Multisuggest.vue +16 -16
- package/src/mixins/floatFormatter.js +10 -4
- package/src/utils/currency.js +32 -7
package/package.json
CHANGED
|
@@ -450,7 +450,7 @@ export default {
|
|
|
450
450
|
.join(', ')
|
|
451
451
|
},
|
|
452
452
|
|
|
453
|
-
suggestionsList(_newValue, _oldValue){
|
|
453
|
+
suggestionsList (_newValue, _oldValue) {
|
|
454
454
|
this.setSelectedLabel()
|
|
455
455
|
}
|
|
456
456
|
},
|
|
@@ -503,23 +503,23 @@ export default {
|
|
|
503
503
|
},
|
|
504
504
|
|
|
505
505
|
setSelectedLabel () {
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
506
|
+
if (Array.isArray(this.value)) {
|
|
507
|
+
this.value.forEach((item, key) => {
|
|
508
|
+
this.suggestionsList.forEach(suggestion => {
|
|
509
|
+
if (suggestion[this.valueKey] === item) {
|
|
510
|
+
this.selectedLabelsArray.push(suggestion)
|
|
511
|
+
}
|
|
512
|
+
})
|
|
512
513
|
})
|
|
513
|
-
})
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
}
|
|
514
|
+
} else if (process.env.DEBUG === 'true') {
|
|
515
|
+
console.log(`'${this.$options.name}' recebeu valor em formato inválido.`)
|
|
516
|
+
}
|
|
517
517
|
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
518
|
+
this.selectedLabels = this.selectedLabelsArray
|
|
519
|
+
.map(item => {
|
|
520
|
+
return item[this.labelKey]
|
|
521
|
+
})
|
|
522
|
+
.join(', ')
|
|
523
523
|
},
|
|
524
524
|
|
|
525
525
|
// eslint-disable-next-line no-unused-vars
|
|
@@ -10,24 +10,30 @@ export default {
|
|
|
10
10
|
}
|
|
11
11
|
},
|
|
12
12
|
|
|
13
|
+
computed: {
|
|
14
|
+
locale () {
|
|
15
|
+
return this.t('locale')
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
|
|
13
19
|
watch: {
|
|
14
20
|
value: {
|
|
15
21
|
immediate: true,
|
|
16
22
|
handler (newValue, oldValue) {
|
|
17
|
-
this.formattedValue = formatMoney(newValue, true)
|
|
23
|
+
this.formattedValue = formatMoney(newValue, true, this.locale)
|
|
18
24
|
}
|
|
19
25
|
}
|
|
20
26
|
},
|
|
21
27
|
|
|
22
28
|
methods: {
|
|
23
29
|
input (evt) {
|
|
24
|
-
this.formattedValue = formatMoney(evt, true)
|
|
25
|
-
const moneyFormatado = formatMoney(evt, false)
|
|
30
|
+
this.formattedValue = formatMoney(evt, true, this.locale)
|
|
31
|
+
const moneyFormatado = formatMoney(evt, false, this.locale)
|
|
26
32
|
this.$emit('input', moneyFormatado)
|
|
27
33
|
},
|
|
28
34
|
|
|
29
35
|
handleChange (evt) {
|
|
30
|
-
this.$emit('change', formatMoney(evt, false))
|
|
36
|
+
this.$emit('change', formatMoney(evt, false, this.locale))
|
|
31
37
|
}
|
|
32
38
|
}
|
|
33
39
|
|
package/src/utils/currency.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { messages } from 'tp-ui/locale'
|
|
2
|
+
|
|
2
3
|
const defaults = messages().locale.number
|
|
3
4
|
|
|
4
5
|
function format (input, opt = defaults) {
|
|
@@ -23,27 +24,51 @@ function unformat (input, precision = defaults.precision) {
|
|
|
23
24
|
return currency * negative
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Formata dinheiro para float sem arredondar ou para string garantindo decimais completos (.00) e respeitando caracter de decimal
|
|
29
|
+
* @author gteixeira
|
|
30
|
+
* @param {Float} input Valor
|
|
31
|
+
* @param {Boolean} toString Se o retorno será float ou string
|
|
32
|
+
* @param {Object} locale Configuração de localidade para saber número de casas decimais (precision) e caracter de decimal (decimal)
|
|
33
|
+
* @returns
|
|
34
|
+
*/
|
|
35
|
+
function formatMoney (input, toString = false, locale = defaults) {
|
|
36
|
+
debugger
|
|
37
|
+
let inputString = ('' + input)
|
|
38
|
+
// Impede de digitar . ou , porque o formatador já adiciona
|
|
39
|
+
if ((inputString.slice(-1).match(/[.,]/))) {
|
|
40
|
+
inputString = inputString.substring(0, inputString.length - 1)
|
|
41
|
+
}
|
|
42
|
+
const negative = inputString.indexOf('-') >= 0 ? -1 : 1
|
|
43
|
+
const precision = locale.number.precision
|
|
44
|
+
|
|
28
45
|
if (toString) {
|
|
29
|
-
input = completeZeros(
|
|
46
|
+
input = completeZeros(inputString, locale)
|
|
30
47
|
}
|
|
31
48
|
const numbers = onlyNumbers(input, precision)
|
|
32
49
|
const currency = numbersToCurrency(numbers, precision)
|
|
33
50
|
if (toString) {
|
|
34
|
-
|
|
51
|
+
let num = negative === -1 ? '-' + currency : '' + currency
|
|
52
|
+
if (locale?.number?.decimal) {
|
|
53
|
+
const decimalChar = locale?.number?.decimal
|
|
54
|
+
num = num.replaceAll(',', decimalChar).replaceAll('.', decimalChar)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return num
|
|
35
58
|
} else {
|
|
36
59
|
return currency * negative
|
|
37
60
|
}
|
|
38
61
|
}
|
|
39
62
|
|
|
40
|
-
function completeZeros (input,
|
|
41
|
-
const
|
|
63
|
+
function completeZeros (input, locale) {
|
|
64
|
+
const precision = locale?.number?.precision || defaults.precision
|
|
65
|
+
const decimal = locale?.number?.decimal || defaults.decimal
|
|
66
|
+
const i = input.indexOf(decimal)
|
|
42
67
|
const qntDecimais = i ? input.length - i - 1 : 0
|
|
43
68
|
|
|
44
69
|
// correção para decimal quebrado
|
|
45
70
|
if (i === -1) {
|
|
46
|
-
input = input +
|
|
71
|
+
input = input + decimal + '0'.repeat(precision)
|
|
47
72
|
} else if (i && qntDecimais < precision) {
|
|
48
73
|
input = input + '0'.repeat(precision - qntDecimais)
|
|
49
74
|
}
|