修改前端页面

Change-Id: I344849fc3dfca5725e0ef2a107e2c89a14fce8da
diff --git a/front/src/MigrationPage.js b/front/src/MigrationPage.js
index 1a9f79b..b8235e4 100644
--- a/front/src/MigrationPage.js
+++ b/front/src/MigrationPage.js
@@ -24,6 +24,7 @@
     const [selectedId, setSelectedId] = useState(null);
     const [loading, setLoading] = useState(true);
     const [error, setError] = useState(null);
+    const [grantedUploadInput, setGrantedUploadInput] = useState(0);
 
     // Helper to load migrations list
     const fetchMigrations = async () => {
@@ -32,7 +33,6 @@
             const res = await fetch(`${API_BASE_URL}/api/migrations`);
             if (!res.ok) throw new Error(`请求失败,状态码 ${res.status}`);
             const data = await res.json();
-            console.log("Fetched migrations:", data);
             const formatted = data.map(item => ({
                 migration_id: item.profileurl,
                 user_id: item.user.userid,
@@ -57,18 +57,34 @@
         fetchMigrations();
     }, []);
 
-    if (loading) return <div>加载中...</div>;
-    if (error) return <div>加载失败:{error}</div>;
-
+    // 获取当前选中的迁移申请
     const selectedMigration = migrations.find(m => m.migration_id === selectedId) || {};
 
-    // Approve selected migration and refresh
+    // 每次切换迁移申请时,重置输入框为0或当前已迁移量
+    useEffect(() => {
+        // 审核通过后,输入框应为已迁移量,否则为0
+        if (selectedMigration.approved === 1) {
+            setGrantedUploadInput(selectedMigration.granted_uploaded || 0);
+        } else {
+            setGrantedUploadInput(0);
+        }
+    }, [selectedId, migrations, selectedMigration.approved, selectedMigration.granted_uploaded]);
+
+    // 审核通过
     const handleApprove = async () => {
+        const max = selectedMigration.pending_uploaded || 0;
+        let value = Number(grantedUploadInput);
+        if (isNaN(value) || value < 0) value = 0;
+        if (value > max) value = max;
+
         try {
             const res = await fetch(`${API_BASE_URL}/api/migrations-approve`, {
                 method: "POST",
                 headers: { "Content-Type": "application/json" },
-                body: JSON.stringify({ migration_id: selectedMigration.migration_id })
+                body: JSON.stringify({
+                    migration_id: selectedMigration.migration_id,
+                    granted_uploaded: value
+                })
             });
             if (!res.ok) throw new Error(`请求失败,状态码 ${res.status}`);
             alert("已通过迁移");
@@ -77,13 +93,17 @@
             alert(`操作失败:${err.message}`);
         }
     };
-    // Reject selected migration and refresh
+
+    // 审核不通过
     const handleReject = async () => {
         try {
             const res = await fetch(`${API_BASE_URL}/api/migrations-reject`, {
                 method: "POST",
                 headers: { "Content-Type": "application/json" },
-                body: JSON.stringify({ migration_id: selectedMigration.migration_id })
+                body: JSON.stringify({
+                    migration_id: selectedMigration.migration_id,
+                    granted_uploaded: 0
+                })
             });
             if (!res.ok) throw new Error(`请求失败,状态码 ${res.status}`);
             alert("已拒绝迁移");
@@ -93,6 +113,9 @@
         }
     };
 
+    if (loading) return <div>加载中...</div>;
+    if (error) return <div>加载失败:{error}</div>;
+
     return (
         <div style={{ display: "flex", minHeight: "100vh", background: "#f7faff" }}>
             {/* 侧栏 */}
@@ -143,12 +166,32 @@
                         <FileViewer url={selectedMigration.application_url} />
                     </div>
                     <div style={{ marginBottom: 18 }}>
-                        <b>待迁移魔法值:</b>{selectedMigration.pending_magic},
-                        <b>已迁移魔法值:</b>{selectedMigration.granted_magic}
-                    </div>
-                    <div style={{ marginBottom: 18 }}>
                         <b>待迁移上传量:</b>{selectedMigration.pending_uploaded},
-                        <b>已迁移上传量:</b>{selectedMigration.granted_uploaded}
+                        <b>已迁移上传量:</b>
+                        {selectedMigration.approved === 1 ? (
+                            <span>{selectedMigration.granted_uploaded}</span>
+                        ) : (
+                            <input
+                                type="number"
+                                min={0}
+                                max={selectedMigration.pending_uploaded}
+                                value={grantedUploadInput}
+                                onChange={e => {
+                                    let val = Number(e.target.value);
+                                    if (isNaN(val) || val < 0) val = 0;
+                                    if (val > selectedMigration.pending_uploaded) val = selectedMigration.pending_uploaded;
+                                    setGrantedUploadInput(val);
+                                }}
+                                style={{
+                                    width: 100,
+                                    marginLeft: 8,
+                                    padding: "4px 8px",
+                                    borderRadius: 4,
+                                    border: "1px solid #bdbdbd"
+                                }}
+                                disabled={selectedMigration.approved === 1}
+                            />
+                        )}
                     </div>
                 </div>
                 {/* 审核按钮 */}