diff --git a/lib/app/core/utils/constants/globals.dart b/lib/app/core/utils/constants/globals.dart new file mode 100644 index 0000000..e0d4c78 --- /dev/null +++ b/lib/app/core/utils/constants/globals.dart @@ -0,0 +1,5 @@ +// globals.dart +library my_globals; + +// 普通变量 +bool isShowAddEnterprise = false; diff --git a/lib/app/features/enterprise/data/datasources/enterprise_local_data_source.dart b/lib/app/features/enterprise/data/datasources/enterprise_local_data_source.dart index f6981d0..809c347 100644 --- a/lib/app/features/enterprise/data/datasources/enterprise_local_data_source.dart +++ b/lib/app/features/enterprise/data/datasources/enterprise_local_data_source.dart @@ -74,6 +74,7 @@ class EnterpriseLocalDataSourceImpl implements EnterpriseLocalDataSource { // pendingCreate 状态的索引值,通常是 0 final int syncedIndex = SyncStatus.synced.index; + final String syncedName = SyncStatus.synced.name; // 动态构建 WHERE 子句和参数 final List whereClauses = []; @@ -129,8 +130,8 @@ class EnterpriseLocalDataSourceImpl implements EnterpriseLocalDataSource { SELECT e.*, COUNT(p.id) AS totalProblems, - COUNT(CASE WHEN p.syncStatus == $syncedIndex THEN 1 ELSE NULL END) AS uploadedProblems, - COUNT(CASE WHEN p.syncStatus != $syncedIndex THEN 1 ELSE NULL END) AS pendingProblems + COUNT(CASE WHEN p.syncStatus == '$syncedName' THEN 1 ELSE NULL END) AS uploadedProblems, + COUNT(CASE WHEN p.syncStatus != '$syncedName' THEN 1 ELSE NULL END) AS pendingProblems FROM $_tableName e LEFT JOIN diff --git a/lib/app/features/enterprise/presentation/pages/enterprise_info_page.dart b/lib/app/features/enterprise/presentation/pages/enterprise_info_page.dart index b2ce384..345b2aa 100644 --- a/lib/app/features/enterprise/presentation/pages/enterprise_info_page.dart +++ b/lib/app/features/enterprise/presentation/pages/enterprise_info_page.dart @@ -6,7 +6,6 @@ import 'package:problem_check_system/app/features/enterprise/presentation/contro import 'package:problem_check_system/app/features/enterprise/presentation/pages/widgets/enterprise_form_view.dart'; import 'package:problem_check_system/app/features/problem/presentation/pages/problem_list_page.dart'; -// 支付宝消息页面 class EnterpriseInfoPage extends GetView { const EnterpriseInfoPage({super.key}); diff --git a/lib/app/features/navigation/presentation/controllers/navigation_controller.dart b/lib/app/features/navigation/presentation/controllers/navigation_controller.dart index e0db075..0f68a3a 100644 --- a/lib/app/features/navigation/presentation/controllers/navigation_controller.dart +++ b/lib/app/features/navigation/presentation/controllers/navigation_controller.dart @@ -9,6 +9,7 @@ import 'package:problem_check_system/app/features/home/pages/home_page.dart'; import 'package:problem_check_system/app/features/my/views/my_page.dart'; import 'package:problem_check_system/app/features/problem/presentation/controllers/problem_list_controller.dart'; import 'package:problem_check_system/app/features/problem/presentation/pages/problem_list_page.dart'; +import 'package:problem_check_system/app/core/utils/constants/globals.dart'; class NavigationController extends GetxController { var selectedIndex = 0.obs; @@ -59,9 +60,11 @@ class NavigationController extends GetxController { switch (selectedIndex.value) { case 1: // 企业列表页面 enterpriseListController.search(); + isShowAddEnterprise = false; break; case 2: // 问题列表页面 problemListController.search(); + isShowAddEnterprise = true; break; default: break; diff --git a/lib/app/features/problem/presentation/pages/problem_form_page.dart b/lib/app/features/problem/presentation/pages/problem_form_page.dart index c6289dd..99805b4 100644 --- a/lib/app/features/problem/presentation/pages/problem_form_page.dart +++ b/lib/app/features/problem/presentation/pages/problem_form_page.dart @@ -6,6 +6,7 @@ import 'package:image_picker/image_picker.dart'; import 'package:problem_check_system/app/core/pages/widgets/custom_app_bar.dart'; import 'package:problem_check_system/app/features/enterprise/domain/entities/enterprise.dart'; import 'package:problem_check_system/app/features/problem/presentation/controllers/problem_form_controller.dart'; +import 'package:problem_check_system/app/core/utils/constants/globals.dart'; class ProblemFormPage extends GetView { // 构造函数,接收只读标志 @@ -510,30 +511,31 @@ class ProblemFormPage extends GetView { ), ), ), - // 右侧的按钮 - ElevatedButton( - onPressed: () { - controller.navigateToAddForm(); - }, - style: ElevatedButton.styleFrom( - backgroundColor: const Color(0xFF42A5F5), - foregroundColor: Colors.white, - padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 12.h), - tapTargetSize: MaterialTapTargetSize.shrinkWrap, - // [!!!] 移除按钮自身的阴影,因为它现在在卡片内部 - // elevation: 0, - // [!!!] 自定义形状,只保留左下角圆角,以完美贴合卡片边缘 - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(12.r), + if (isShowAddEnterprise) + // 右侧的按钮 + ElevatedButton( + onPressed: () { + controller.navigateToAddForm(); + }, + style: ElevatedButton.styleFrom( + backgroundColor: const Color(0xFF42A5F5), + foregroundColor: Colors.white, + padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 12.h), + tapTargetSize: MaterialTapTargetSize.shrinkWrap, + // [!!!] 移除按钮自身的阴影,因为它现在在卡片内部 + // elevation: 0, + // [!!!] 自定义形状,只保留左下角圆角,以完美贴合卡片边缘 + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(12.r), + ), ), ), + child: Text( + "新增企业", + style: TextStyle(fontSize: 13.sp, fontWeight: FontWeight.bold), + ), ), - child: Text( - "新增企业", - style: TextStyle(fontSize: 13.sp, fontWeight: FontWeight.bold), - ), - ), ], ); }