From bb69d7a4bdfbb90cde19b3d828f490ab10f2bb43 Mon Sep 17 00:00:00 2001
From: chen.lin <1442464845@qq.com>
Date: 星期一, 02 二月 2026 15:44:33 +0800
Subject: [PATCH] 库区增加序号

---
 rsf-admin/src/page/components/AreasSortInput.jsx |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/rsf-admin/src/page/components/AreasSortInput.jsx b/rsf-admin/src/page/components/AreasSortInput.jsx
index 9f6fb1f..9707e18 100644
--- a/rsf-admin/src/page/components/AreasSortInput.jsx
+++ b/rsf-admin/src/page/components/AreasSortInput.jsx
@@ -72,14 +72,21 @@
                     .map(id => Number(id))
                     .filter(id => !existingIds.has(id));
                 
-                // 涓烘柊澧炵殑ID鍒涘缓鎺掑簭椤癸紙榛樿鎺掑簭涓哄凡鏈夋渶澶ф帓搴忓��+1锛�
+                // 涓烘柊澧炵殑ID鍒涘缓鎺掑簭椤癸紙榛樿鎺掑簭浠庡簱鍖虹殑 sort 瀛楁鑾峰彇锛屽鏋滄病鏈夊垯浣跨敤宸叉湁鏈�澶ф帓搴忓��+1锛�
                 const maxSort = existingAreas.length > 0 
                     ? Math.max(...existingAreas.map(item => item.sort || 1), 0)
                     : 0;
-                const newItems = newIds.map((id, index) => ({
-                    id: id,
-                    sort: maxSort + index + 1,
-                }));
+                const newItems = newIds.map((id, index) => {
+                    // 浠� areas 鏁扮粍涓煡鎵惧搴斿簱鍖虹殑 sort 瀛楁
+                    const area = areas.find(a => a.id === id);
+                    const defaultSort = area && area.sort !== undefined && area.sort !== null 
+                        ? area.sort 
+                        : (maxSort + index + 1);
+                    return {
+                        id: id,
+                        sort: defaultSort,
+                    };
+                });
                 
                 // 鍚堝苟宸叉湁椤瑰拰鏂伴」
                 const converted = [...existingAreas, ...newItems];

--
Gitblit v1.9.1