Kaynağa Gözat

Update 优化页面样式

Yue 1 gün önce
ebeveyn
işleme
3ce98aa526

+ 10 - 5
UI/CF.APP/chicken_farm/lib/apis/breeding/_submit.dart

@@ -33,7 +33,8 @@ class BreedSubmitApi {
         };
       }).toList();
       ResultModel result = ResultModel.offline();
-      if (!AppConfig.isOffline) {
+      if (!AppConfig.isOffline &&
+          await _breedingDataService.queryCount(TableConfig.chicken) == 0) {
         result = await ApiService().post(
           bindChickenUrl,
           data: list,
@@ -65,7 +66,8 @@ class BreedSubmitApi {
         };
       }).toList();
       ResultModel result = ResultModel.offline();
-      if (!AppConfig.isOffline) {
+      if (!AppConfig.isOffline &&
+          await _breedingDataService.queryCount(TableConfig.chicken) == 0) {
         result = await ApiService().post(
           cageChangeUrl,
           data: list,
@@ -94,7 +96,8 @@ class BreedSubmitApi {
         'is_export': 0,
       };
       ResultModel result = ResultModel.offline();
-      if (!AppConfig.isOffline) {
+      if (!AppConfig.isOffline &&
+          await _breedingDataService.queryCount(TableConfig.chicken) == 0) {
         result = await ApiService().post(
           weightUrl,
           data: weightData,
@@ -126,7 +129,8 @@ class BreedSubmitApi {
         },
       ];
       ResultModel result = ResultModel.offline();
-      if (!AppConfig.isOffline) {
+      if (!AppConfig.isOffline &&
+          await _breedingDataService.queryCount(TableConfig.chicken) == 0) {
         result = await ApiService().post(
           cullUrl,
           data: list,
@@ -156,7 +160,8 @@ class BreedSubmitApi {
         };
       }).toList();
       ResultModel result = ResultModel.offline();
-      if (!AppConfig.isOffline) {
+      if (!AppConfig.isOffline &&
+          await _breedingDataService.queryCount(TableConfig.chicken) == 0) {
         result = await ApiService().post(
           cullUrl,
           data: list,

+ 8 - 6
UI/CF.APP/chicken_farm/lib/core/services/breeding_data_service.dart

@@ -112,7 +112,7 @@ class BreedingDataService {
     }
   }
 
-  Future<ResultModel> exportData(String type) async {
+  Future<ResultModel> exportData(String type, {bool isAll = false}) async {
     String tableName = "";
     String templateKey = "";
     switch (type) {
@@ -163,7 +163,7 @@ class BreedingDataService {
           result.message = "$typeName导出过程出错";
         }
       } else {
-        result.message = "$typeName没有需要导出的数据";
+        result.message = isAll ? "" : "$typeName没有需要导出的数据";
       }
     } catch (e) {
       logger.e(e);
@@ -186,17 +186,19 @@ class BreedingDataService {
 
     // 遍历每种类型并执行导出操作
     for (String type in exportTypes) {
-      ResultModel result = await exportData(type);
+      ResultModel result = await exportData(type, isAll: true);
 
       if (result.success) {
-        successMsg += "${successMsg.isEmpty ? "" : ";"}${result.message}";
+        successMsg += "${successMsg.isEmpty ? "" : ";\n"}${result.message}";
       } else {
-        errMsg += "${errMsg.isEmpty ? "" : ";"}${result.message}";
+        errMsg += "${errMsg.isEmpty ? "" : ";\n"}${result.message}";
       }
     }
 
     return errMsg.isEmpty
         ? ResultModel.success(successMsg)
-        : ResultModel.fail(errMsg);
+        : ResultModel.fail(
+            successMsg.isEmpty ? errMsg : "$errMsg@@@$successMsg",
+          );
   }
 }

+ 6 - 1
UI/CF.APP/chicken_farm/lib/pages/breeding/individual_weighing_page.dart

@@ -167,7 +167,12 @@ class _IndividualWeighingPageState extends State<IndividualWeighingPage> {
                               setState(() {
                                 _weight = parsedValue;
                               });
-                              ToastUtil.success('重量读取成功');
+                              ScaffoldMessenger.of(context).showSnackBar(
+                                const SnackBar(
+                                  content: Text('重量读取成功'),
+                                  backgroundColor: Colors.green,
+                                ),
+                              );
                             }
                             _isReadingWeight = false;
                           } catch (e) {

+ 42 - 5
UI/CF.APP/chicken_farm/lib/pages/excel/export_data_page.dart

@@ -73,7 +73,7 @@ class _ExcelExportPageState extends State<ExcelExportPage> {
         if (mounted) {
           ScaffoldMessenger.of(context).showSnackBar(
             SnackBar(
-              content: Text('数据已保存到目录:${result.message}'),
+              content: Text('数据已保存到目录:\n ${result.message}'),
               backgroundColor: Colors.green,
             ),
           );
@@ -81,7 +81,23 @@ class _ExcelExportPageState extends State<ExcelExportPage> {
         // 导出成功后刷新选项
         _refreshExportOptions();
       } else {
-        ToastUtil.error('导出失败: ${result.message}');
+        if (type == "all") {
+          if (mounted) {
+            final arr = result.message.split('@@@');
+            if (arr.length > 1) {
+              ScaffoldMessenger.of(context).showSnackBar(
+                SnackBar(
+                  content: Text('部分导出成功:\n ${arr[1]}'),
+                  backgroundColor: Colors.orange,
+                ),
+              );
+            }
+            ToastUtil.errorAlert(arr[0]);
+          }
+          _refreshExportOptions();
+        } else {
+          ToastUtil.error('导出失败: ${result.message}');
+        }
       }
     } catch (e) {
       ToastUtil.error('导出失败: ${e.toString()}');
@@ -148,19 +164,40 @@ class _ExcelExportPageState extends State<ExcelExportPage> {
                           left: 12.0,
                           right: 12.0,
                         ),
+                        color: dataCount > 0
+                            ? option['type'] == "all"
+                                  ? Colors.yellowAccent
+                                  : Colors.greenAccent
+                            : null,
                         child: ListTile(
                           title: Text(
                             option['name'],
-                            style: const TextStyle(
+                            style: TextStyle(
                               fontSize: 18,
                               fontWeight: FontWeight.bold,
+                              color: dataCount > 0 ? null : Colors.grey,
                             ),
                           ),
+
                           subtitle: Column(
                             crossAxisAlignment: CrossAxisAlignment.start,
                             children: [
-                              Text(option['description']),
-                              if (dataCount > 0) Text('未导出数量: $dataCount'),
+                              Text(
+                                option['description'],
+                                style: TextStyle(
+                                  color: dataCount > 0 ? null : Colors.grey,
+                                ),
+                              ),
+                              if (dataCount > 0) const SizedBox(height: 5),
+                              if (dataCount > 0)
+                                Text(
+                                  '未导出数量: $dataCount',
+                                  style: TextStyle(
+                                    color: option['type'] == "all"
+                                        ? Colors.red
+                                        : Colors.deepOrange,
+                                  ),
+                                ),
                             ],
                           ),
                           trailing: isCurrentExporting