This commit is contained in:
@@ -118,6 +118,35 @@ export default {
|
|||||||
default:
|
default:
|
||||||
return Boolean(string);
|
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
|
//new functions above here
|
||||||
|
|||||||
@@ -83,7 +83,6 @@
|
|||||||
<v-text-field
|
<v-text-field
|
||||||
v-model="_self[item.dataKey]"
|
v-model="_self[item.dataKey]"
|
||||||
:readonly="readOnly"
|
:readonly="readOnly"
|
||||||
:prefix="ltFormat().currencySymbol"
|
|
||||||
:label="lt(item.fld)"
|
:label="lt(item.fld)"
|
||||||
:ref="item.fld"
|
:ref="item.fld"
|
||||||
:error-messages="form().serverErrors(parentVM, item.fld)"
|
:error-messages="form().serverErrors(parentVM, item.fld)"
|
||||||
@@ -224,9 +223,16 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
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;
|
return ret;
|
||||||
},
|
},
|
||||||
SetValueForField: function(dataKey, newValue) {
|
SetValueForField: function(dataKey, newValue) {
|
||||||
|
|||||||
Reference in New Issue
Block a user