This commit is contained in:
2019-12-11 20:55:26 +00:00
parent 79a84eba42
commit ba5c44bf59
2 changed files with 37 additions and 2 deletions

View File

@@ -118,6 +118,35 @@ export default {
default:
return Boolean(string);
}
}, ///////////////////////////////
// CONVERT STRING TO FLOAT
// https://stackoverflow.com/a/9409894/8939
//
stringToFloat: function(string) {
//null or empty then zero
if (!string) {
return 0;
}
//A number already then parse and return
if (window.$gz._.isNumber(string)) {
if (string === NaN) {
return 0;
}
return parseFloat(string);
}
//Not a string at all?
if (!window.$gz._.isString(string)) {
return 0;
}
var ret = parseFloat(string.replace(/[^\d.-]/g, ""));
if (ret == NaN) {
return 0;
}
return ret;
}
//new functions above here

View File

@@ -83,7 +83,6 @@
<v-text-field
v-model="_self[item.dataKey]"
:readonly="readOnly"
:prefix="ltFormat().currencySymbol"
:label="lt(item.fld)"
:ref="item.fld"
:error-messages="form().serverErrors(parentVM, item.fld)"
@@ -224,9 +223,16 @@ export default {
}
}
break;
case "number":
case "currency":
if (!window.$gz._.isNumber(ret)) {
ret = window.$gz.util.stringToFloat(ret);
break;
}
break;
}
}
//{"c1":"2019-01-27T09:26:06.1673391Z","c2":"Esse sunt re in.","c3":48824971,"c4":false,"c5":0.120971084628706}
return ret;
},
SetValueForField: function(dataKey, newValue) {