Ver Fonte

doing #19407 优化报表页

chengc há 2 semanas atrás
pai
commit
b13b85780c

+ 40 - 25
lib/features/report/expense_apply_detail_report_page.dart

@@ -74,7 +74,7 @@ class _ExpenseApplyDetailReportPageState
     }
   }
 
-  Future<void> _loadDetails({bool append = false}) async {
+  Future<void> _loadDetails() async {
     if (_detailLoading) return;
     setState(() => _detailLoading = true);
     try {
@@ -82,7 +82,7 @@ class _ExpenseApplyDetailReportPageState
       final result = await api.getExpenseApplyReportDetail(
         startDate: _startCtrl.text.isNotEmpty ? _startCtrl.text : null,
         endDate: _endCtrl.text.isNotEmpty ? _endCtrl.text : null,
-        page: append ? _detailPage : 1,
+        page: _detailPage,
       );
       if (!mounted) return;
       final list =
@@ -91,13 +91,7 @@ class _ExpenseApplyDetailReportPageState
               .toList() ??
           [];
       setState(() {
-        if (append) {
-          _details.addAll(list);
-          _detailPage++;
-        } else {
-          _details = list;
-          _detailPage = 2;
-        }
+        _details = list;
         _detailTotal = result['total'] as int? ?? 0;
         _detailLoading = false;
       });
@@ -606,6 +600,8 @@ class _ExpenseApplyDetailReportPageState
 
   // ── 明细列表 ──
   Widget _buildDetailList() {
+    final l10n = AppLocalizations.of(context);
+    final colors = Theme.of(context).extension<AppColorsExtension>()!;
     if (_detailLoading && _details.isEmpty) {
       return const Padding(
         padding: EdgeInsets.only(top: 32),
@@ -617,9 +613,32 @@ class _ExpenseApplyDetailReportPageState
         ),
       );
     }
-    if (_details.isEmpty) return const SizedBox.shrink();
-    final l10n = AppLocalizations.of(context);
-    final colors = Theme.of(context).extension<AppColorsExtension>()!;
+    if (_details.isEmpty) {
+      return Padding(
+        padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
+        child: Container(
+          width: double.infinity,
+          decoration: BoxDecoration(
+            color: colors.bgCard,
+            borderRadius: BorderRadius.circular(8),
+          ),
+          child: Padding(
+            padding: const EdgeInsets.symmetric(vertical: 48),
+            child: Column(
+              mainAxisSize: MainAxisSize.min,
+              children: [
+                Icon(Icons.inbox_outlined, size: 48, color: colors.textPlaceholder),
+                const SizedBox(height: 12),
+                Text(
+                  l10n.get('noDetailData'),
+                  style: TextStyle(fontSize: 14, color: colors.textSecondary),
+                ),
+              ],
+            ),
+          ),
+        ),
+      );
+    }
     final headerStyle = TextStyle(
       fontSize: 12,
       fontWeight: FontWeight.w600,
@@ -653,11 +672,6 @@ class _ExpenseApplyDetailReportPageState
                       color: colors.textPrimary,
                     ),
                   ),
-                  const Spacer(),
-                  Text(
-                    '${_details.length} ${l10n.get('items')}',
-                    style: TextStyle(fontSize: 12, color: colors.textSecondary),
-                  ),
                 ],
               ),
             ),
@@ -782,23 +796,23 @@ class _ExpenseApplyDetailReportPageState
                   mainAxisAlignment: MainAxisAlignment.center,
                   children: [
                     GestureDetector(
-                      onTap: _detailPage > 2
+                      onTap: _detailPage > 1
                           ? () {
-                              _detailPage -= 2;
-                              _loadDetails(append: false);
+                              _detailPage--;
+                              _loadDetails();
                             }
                           : null,
                       child: Icon(
                         Icons.chevron_left,
                         size: 20,
-                        color: _detailPage > 2
+                        color: _detailPage > 1
                             ? colors.textPrimary
                             : colors.textPlaceholder,
                       ),
                     ),
                     const SizedBox(width: 16),
                     Text(
-                      _detailPage > 1 ? '${_detailPage - 1}' : '1',
+                      '$_detailPage',
                       style: TextStyle(fontSize: 13, color: colors.textPrimary),
                     ),
                     const SizedBox(width: 4),
@@ -811,15 +825,16 @@ class _ExpenseApplyDetailReportPageState
                     ),
                     const SizedBox(width: 16),
                     GestureDetector(
-                      onTap: (_detailPage - 1) * 20 < _detailTotal
+                      onTap: _detailPage * 20 < _detailTotal
                           ? () {
-                              _loadDetails(append: true);
+                              _detailPage++;
+                              _loadDetails();
                             }
                           : null,
                       child: Icon(
                         Icons.chevron_right,
                         size: 20,
-                        color: (_detailPage - 1) * 20 < _detailTotal
+                        color: _detailPage * 20 < _detailTotal
                             ? colors.textPrimary
                             : colors.textPlaceholder,
                       ),

+ 40 - 25
lib/features/report/expense_detail_report_page.dart

@@ -75,7 +75,7 @@ class _ExpenseDetailReportPageState
     }
   }
 
-  Future<void> _loadDetails({bool append = false}) async {
+  Future<void> _loadDetails() async {
     if (_detailLoading) return;
     setState(() => _detailLoading = true);
     try {
@@ -83,7 +83,7 @@ class _ExpenseDetailReportPageState
       final result = await api.getExpenseReportDetail(
         startDate: _startCtrl.text.isNotEmpty ? _startCtrl.text : null,
         endDate: _endCtrl.text.isNotEmpty ? _endCtrl.text : null,
-        page: append ? _detailPage : 1,
+        page: _detailPage,
       );
       if (!mounted) return;
       final list =
@@ -92,13 +92,7 @@ class _ExpenseDetailReportPageState
               .toList() ??
           [];
       setState(() {
-        if (append) {
-          _details.addAll(list);
-          _detailPage++;
-        } else {
-          _details = list;
-          _detailPage = 2;
-        }
+        _details = list;
         _detailTotal = result['total'] as int? ?? 0;
         _detailLoading = false;
       });
@@ -640,6 +634,8 @@ class _ExpenseDetailReportPageState
   }
 
   Widget _buildDetailList() {
+    final l10n = AppLocalizations.of(context);
+    final colors = Theme.of(context).extension<AppColorsExtension>()!;
     if (_detailLoading && _details.isEmpty) {
       return const Padding(
         padding: EdgeInsets.only(top: 32),
@@ -651,9 +647,32 @@ class _ExpenseDetailReportPageState
         ),
       );
     }
-    if (_details.isEmpty) return const SizedBox.shrink();
-    final l10n = AppLocalizations.of(context);
-    final colors = Theme.of(context).extension<AppColorsExtension>()!;
+    if (_details.isEmpty) {
+      return Padding(
+        padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
+        child: Container(
+          width: double.infinity,
+          decoration: BoxDecoration(
+            color: colors.bgCard,
+            borderRadius: BorderRadius.circular(8),
+          ),
+          child: Padding(
+            padding: const EdgeInsets.symmetric(vertical: 48),
+            child: Column(
+              mainAxisSize: MainAxisSize.min,
+              children: [
+                Icon(Icons.inbox_outlined, size: 48, color: colors.textPlaceholder),
+                const SizedBox(height: 12),
+                Text(
+                  l10n.get('noDetailData'),
+                  style: TextStyle(fontSize: 14, color: colors.textSecondary),
+                ),
+              ],
+            ),
+          ),
+        ),
+      );
+    }
     final headerStyle = TextStyle(
       fontSize: 12,
       fontWeight: FontWeight.w600,
@@ -687,11 +706,6 @@ class _ExpenseDetailReportPageState
                       color: colors.textPrimary,
                     ),
                   ),
-                  const Spacer(),
-                  Text(
-                    '${_details.length} ${l10n.get('items')}',
-                    style: TextStyle(fontSize: 12, color: colors.textSecondary),
-                  ),
                 ],
               ),
             ),
@@ -816,23 +830,23 @@ class _ExpenseDetailReportPageState
                   mainAxisAlignment: MainAxisAlignment.center,
                   children: [
                     GestureDetector(
-                      onTap: _detailPage > 2
+                      onTap: _detailPage > 1
                           ? () {
-                              _detailPage -= 2;
-                              _loadDetails(append: false);
+                              _detailPage--;
+                              _loadDetails();
                             }
                           : null,
                       child: Icon(
                         Icons.chevron_left,
                         size: 20,
-                        color: _detailPage > 2
+                        color: _detailPage > 1
                             ? colors.textPrimary
                             : colors.textPlaceholder,
                       ),
                     ),
                     const SizedBox(width: 16),
                     Text(
-                      _detailPage > 1 ? '${_detailPage - 1}' : '1',
+                      '$_detailPage',
                       style: TextStyle(fontSize: 13, color: colors.textPrimary),
                     ),
                     const SizedBox(width: 4),
@@ -845,15 +859,16 @@ class _ExpenseDetailReportPageState
                     ),
                     const SizedBox(width: 16),
                     GestureDetector(
-                      onTap: (_detailPage - 1) * 20 < _detailTotal
+                      onTap: _detailPage * 20 < _detailTotal
                           ? () {
-                              _loadDetails(append: true);
+                              _detailPage++;
+                              _loadDetails();
                             }
                           : null,
                       child: Icon(
                         Icons.chevron_right,
                         size: 20,
-                        color: (_detailPage - 1) * 20 < _detailTotal
+                        color: _detailPage * 20 < _detailTotal
                             ? colors.textPrimary
                             : colors.textPlaceholder,
                       ),