This commit is contained in:
2022-12-12 09:33:39 +08:00
parent 5a0d86e2e9
commit 80c457a21b
4 changed files with 100 additions and 44 deletions

View File

@@ -11236,10 +11236,28 @@ const _sfc_main$1v = defineComponent({
onNumberBlur(event);
}
if (props.qfw) {
var formatMoney = function(s) {
var noNegative = true;
s = parseFloat((s + "").replace(/[^\d\.-]/g, "")).toFixed(2) + "";
if (parseFloat(s) < 0) {
s = Math.abs(s).toFixed(2) + "";
noNegative = false;
}
var l = s.split(".")[0].split("").reverse(), r = s.split(".")[1];
var t = "";
for (let i = 0; i < l.length; i++) {
if (i % 3 == 2 && i != l.length - 1) {
t += l[i] + ",";
} else {
t += l[i] + "";
}
}
return (noNegative ? "" : "-") + t.split("").reverse().join("") + "." + r;
};
try {
let reg = /\B(?=(\d{3})+$)/g;
console.log("\u6DFB\u52A0\uFF0C", new String(props.modelValue).replace(reg, "$&,"));
currentValue.value = new String(props.modelValue).replace(reg, "$&,");
let reg = /\d{1,3}(?=(\d{3})+$)/g;
console.log("\u6DFB\u52A0\uFF0C", formatMoney(props.modelValue));
currentValue.value = formatMoney(props.modelValue);
} catch {
currentValue.value = "\u8F93\u5165\u9519\u8BEF";
}