From 79edfec1f6e6789d3f6cc57db3cb0cfdffd64c32 Mon Sep 17 00:00:00 2001
From: chen.lin <1442464845@qq.com>
Date: 星期二, 24 二月 2026 15:50:32 +0800
Subject: [PATCH] 库位拣料出库数量调整
---
rsf-admin/src/utils/common.js | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 50 insertions(+), 0 deletions(-)
diff --git a/rsf-admin/src/utils/common.js b/rsf-admin/src/utils/common.js
index 2083ca8..3874cd3 100644
--- a/rsf-admin/src/utils/common.js
+++ b/rsf-admin/src/utils/common.js
@@ -1,4 +1,36 @@
+/** 搴撳瓨/鏁伴噺鏄剧ず锛氫繚鐣欐渶澶�6浣嶅皬鏁帮紝鍘绘帀鏈熬澶氫綑鐨�0锛堜笉寮哄埗琛ラ浂锛� */
+export const formatQuantity = (value) => {
+ if (value == null || value === '') return '0';
+ const n = Number(value);
+ if (Number.isNaN(n)) return '0';
+ if (n < 0) return '0';
+ return n % 1 === 0 ? String(n) : n.toFixed(6).replace(/\.?0+$/, '');
+};
+
+/** 鏍¢獙鏈�澶� N 浣嶅皬鏁帮紝鐢ㄤ簬鏁伴噺绫诲瓧娈碉紱瓒呰繃鏃惰繑鍥為敊璇俊鎭苟闃绘鎻愪氦 */
+export const maxDecimalPlaces = (maxDecimals, message) => {
+ const factor = Math.pow(10, maxDecimals);
+ const msg = message || `鏈�澶�${maxDecimals}浣嶅皬鏁癭;
+ return (value) => {
+ if (value == null || value === '') return undefined;
+ const n = Number(value);
+ if (Number.isNaN(n)) return undefined;
+ const rounded = Math.round(n * factor) / factor;
+ if (Math.abs(n - rounded) > 1e-10) return msg;
+ return undefined;
+ };
+};
+
+/** 鍒ゆ柇鏁板�兼槸鍚﹁秴杩� 6 浣嶅皬鏁帮紙鐢ㄤ簬鎻愪氦鍓嶆牎楠岋級 */
+export const hasMoreThan6Decimals = (value) => {
+ if (value == null || value === '') return false;
+ const n = Number(value);
+ if (Number.isNaN(n)) return false;
+ const rounded = Math.round(n * 1e6) / 1e6;
+ return Math.abs(n - rounded) > 1e-10;
+};
+
export const extractNavMenus = (data) => {
if (!data) {
return;
@@ -50,3 +82,21 @@
});
return result;
};
+
+export const haveChildren = (item) => {
+ if (Array.isArray(item)) {
+ return item.map((k) => haveChildren(k));
+ }
+
+ if (item && typeof item === 'object') {
+ if (item.id !== undefined) {
+ item.id = item.id.toString();
+ }
+
+ if (item.children && Array.isArray(item.children)) {
+ item.children = haveChildren(item.children);
+ }
+ }
+
+ return item;
+};
--
Gitblit v1.9.1