|
@@ -29,9 +29,23 @@ $(function () {
|
|
|
getAllList();
|
|
|
|
|
|
$('#rpt-form input').on('change', function () {
|
|
|
- const newVal = $(this).val();
|
|
|
+ let newVal = $(this).val();
|
|
|
const index = parseInt($(this).data('index'));
|
|
|
- checkAndUpdate(index, newVal, $(this));
|
|
|
+ const type = $(this).attr('type');
|
|
|
+ if (type === 'number' && newVal) {
|
|
|
+ const val = _.toNumber(newVal);
|
|
|
+ if (countDigits(val) > 11) {
|
|
|
+ toastr.error('请输入11位整数内的数');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const reg = new RegExp("^\\d+(\\.\\d{1,"+ 6 +"})?$");
|
|
|
+ if (!reg.test(val)) {
|
|
|
+ toastr.warning('已保留6位小数');
|
|
|
+ newVal = ZhCalc.round(val, 6);
|
|
|
+ $(this).val(newVal);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ checkAndUpdate(index, newVal, $(this));
|
|
|
});
|
|
|
|
|
|
$('#rpt-form textarea').on('change', function () {
|
|
@@ -315,6 +329,13 @@ function getAllList(currPageNum = 1) {
|
|
|
$(this).addClass('bg-light');
|
|
|
});
|
|
|
}
|
|
|
+// 整数位数判断
|
|
|
+function countDigits(number) {
|
|
|
+ var numberString = Math.abs(number).toString();
|
|
|
+ var decimalIndex = numberString.indexOf('.'); // 查找小数点的索引
|
|
|
+ var integerPart = decimalIndex === -1 ? numberString : numberString.slice(0, decimalIndex); // 如果不存在小数点,则整个数字都是整数部分
|
|
|
+ return integerPart.length;
|
|
|
+}
|
|
|
|
|
|
function bytesToSize(bytes) {
|
|
|
if (parseInt(bytes) === 0) return '0 B';
|