fix(surveyor/so): perbaikkan back di surveyor, luas denah decimal dan revisi di so

This commit is contained in:
majid
2025-03-05 14:31:55 +07:00
parent 976dab7566
commit 23afbc7ece
6 changed files with 34 additions and 21 deletions

View File

@@ -27,19 +27,27 @@
function formatNumber(input) {
// Ambil posisi kursor saat ini
const cursorPosition = input.selectionStart;
const cursorPosition = input.selectionStart;
// Ambil nilai input tanpa "m²" dan karakter non-angka
let value = input.value.replace(/[^\d]/g, '');
let value = input.value.replace(/[^0-9,]/g, '');
// Update nilai input dengan format angka dan "m²"
input.value = value ? value + '' : '';
// Atur posisi kursor di depan "m²"
input.setSelectionRange(cursorPosition, cursorPosition);
if ((value.match(/,/g) || []).length > 1) {
value = value.replace(/,/g, (match, offset) => (offset === value.indexOf(',') ? ',' : ''));
}
if (value.includes(',')) {
const [beforeComma, afterComma] = value.split(',');
value = `${beforeComma},${afterComma.substring(0, 2)}`;
}
input.value = value ? value + ' m²' : 'm²';
input.setSelectionRange(cursorPosition, cursorPosition);
}
function formatCurrency(value, isDiskon = false) {