This commit is contained in:
Theluyuan 2022-12-12 10:04:13 +08:00
parent b12826594e
commit 23f2e2ff67
4 changed files with 20 additions and 7 deletions

View File

@ -106,7 +106,7 @@ const _sfc_main = defineComponent({
var noNegative = true; var noNegative = true;
s = parseFloat((s + "").replace(/[^\d\.-]/g, "")) + ""; s = parseFloat((s + "").replace(/[^\d\.-]/g, "")) + "";
if (parseFloat(s) < 0) { if (parseFloat(s) < 0) {
s = Math.abs(s).toFixed(2) + ""; s = Math.abs(s) + "";
noNegative = false; noNegative = false;
} }
var l = s.split(".")[0].split("").reverse(), r = s.split(".")[1]; var l = s.split(".")[0].split("").reverse(), r = s.split(".")[1];
@ -118,7 +118,11 @@ const _sfc_main = defineComponent({
t += l[i] + ""; t += l[i] + "";
} }
} }
if (r) {
return (noNegative ? "" : "-") + t.split("").reverse().join("") + "." + r; return (noNegative ? "" : "-") + t.split("").reverse().join("") + "." + r;
} else {
return (noNegative ? "" : "-") + t.split("").reverse().join("");
}
}; };
watch(() => props.type, () => { watch(() => props.type, () => {
type.value = props.type; type.value = props.type;

View File

@ -11202,7 +11202,7 @@ const _sfc_main$1v = defineComponent({
var noNegative = true; var noNegative = true;
s = parseFloat((s + "").replace(/[^\d\.-]/g, "")) + ""; s = parseFloat((s + "").replace(/[^\d\.-]/g, "")) + "";
if (parseFloat(s) < 0) { if (parseFloat(s) < 0) {
s = Math.abs(s).toFixed(2) + ""; s = Math.abs(s) + "";
noNegative = false; noNegative = false;
} }
var l = s.split(".")[0].split("").reverse(), r = s.split(".")[1]; var l = s.split(".")[0].split("").reverse(), r = s.split(".")[1];
@ -11214,7 +11214,11 @@ const _sfc_main$1v = defineComponent({
t += l[i] + ""; t += l[i] + "";
} }
} }
if (r) {
return (noNegative ? "" : "-") + t.split("").reverse().join("") + "." + r; return (noNegative ? "" : "-") + t.split("").reverse().join("") + "." + r;
} else {
return (noNegative ? "" : "-") + t.split("").reverse().join("");
}
}; };
watch(() => props.type, () => { watch(() => props.type, () => {
type4.value = props.type; type4.value = props.type;

View File

@ -67,7 +67,7 @@ const formatMoney = function (s: string) {
var noNegative = true; var noNegative = true;
s = parseFloat((s + "").replace(/[^\d\.-]/g, "")) + ""; s = parseFloat((s + "").replace(/[^\d\.-]/g, "")) + "";
if (parseFloat(s) < 0) { if (parseFloat(s) < 0) {
s = Math.abs(s).toFixed(2) + ""; s = Math.abs(s) + "";
noNegative = false; noNegative = false;
} }
@ -81,7 +81,12 @@ const formatMoney = function (s: string) {
t += l[i] + ""; // t += l[i] + ""; //
} }
} }
if(r){
return (noNegative ? "" : "-") + t.split("").reverse().join("") + "." + r; return (noNegative ? "" : "-") + t.split("").reverse().join("") + "." + r;
}else{
return (noNegative ? "" : "-") + t.split("").reverse().join("")
}
} }
watch( watch(

File diff suppressed because one or more lines are too long