feat: 后台管理页全量重构 + backoffice 共享模块 + 启动脚本优化
## 后台管理页重构 - admin 端: add_doctor / doctors / home / patients 四页重构 - doctor 端: consultations / dashboard / followup_edit / followups / home / patient_detail / patients / profile / report_detail / reports / settings 十一页重构 - 新增 backoffice 共享模块: backoffice_refresh_providers + backoffice_formatters + backoffice_ui ## 后端 - AdminService 增强(分页/搜索/统计) - doctor_endpoints 微调 - appsettings.Development 调整 - 新增 admin_service_tests ## 前端其他 - 今日健康卡片 taskRow 行高 5->7(每行 44->48px) - 健康仪表盘配色定 #4FACFE 纯色蓝 - admin_drawer / doctor_drawer 微调 - api_client IP 适配 ## 启动脚本 - start-dev.bat: 加后端就绪检测(轮询 openapi 端点, 最多等 30s) ## 清理 - 删除旧品牌图(agent_welcome_abstract / login_background_v1) - 删除 app_status_badge 组件 - 删除旧 HANDOFF 文档, 新增 07-17 版 ## 测试 - 新增 backoffice_formatters / backoffice_refresh / backoffice_ui 三个测试 - app_router_test 扩展
This commit is contained in:
@@ -4,22 +4,51 @@ import '../../core/app_colors.dart';
|
||||
import '../../core/navigation_provider.dart';
|
||||
import '../../providers/data_providers.dart'
|
||||
show adminServiceProvider, doctorListProvider;
|
||||
import '../../providers/backoffice_refresh_providers.dart';
|
||||
import '../../widgets/app_toast.dart';
|
||||
import '../../widgets/backoffice_ui.dart';
|
||||
|
||||
class AdminAddDoctorPage extends ConsumerStatefulWidget {
|
||||
const AdminAddDoctorPage({super.key});
|
||||
final String? id;
|
||||
final String initialPhone;
|
||||
final String initialName;
|
||||
final String initialTitle;
|
||||
final String initialDepartment;
|
||||
final String initialDirection;
|
||||
|
||||
const AdminAddDoctorPage({
|
||||
super.key,
|
||||
this.id,
|
||||
this.initialPhone = '',
|
||||
this.initialName = '',
|
||||
this.initialTitle = '',
|
||||
this.initialDepartment = '',
|
||||
this.initialDirection = '',
|
||||
});
|
||||
@override
|
||||
ConsumerState<AdminAddDoctorPage> createState() => _AdminAddDoctorPageState();
|
||||
}
|
||||
|
||||
class _AdminAddDoctorPageState extends ConsumerState<AdminAddDoctorPage> {
|
||||
final _phoneCtrl = TextEditingController();
|
||||
final _nameCtrl = TextEditingController();
|
||||
final _titleCtrl = TextEditingController();
|
||||
final _deptCtrl = TextEditingController();
|
||||
final _directionCtrl = TextEditingController();
|
||||
late final TextEditingController _phoneCtrl;
|
||||
late final TextEditingController _nameCtrl;
|
||||
late final TextEditingController _titleCtrl;
|
||||
late final TextEditingController _deptCtrl;
|
||||
late final TextEditingController _directionCtrl;
|
||||
bool _saving = false;
|
||||
|
||||
bool get _isEdit => widget.id?.isNotEmpty == true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_phoneCtrl = TextEditingController(text: widget.initialPhone);
|
||||
_nameCtrl = TextEditingController(text: widget.initialName);
|
||||
_titleCtrl = TextEditingController(text: widget.initialTitle);
|
||||
_deptCtrl = TextEditingController(text: widget.initialDepartment);
|
||||
_directionCtrl = TextEditingController(text: widget.initialDirection);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_phoneCtrl.dispose();
|
||||
@@ -41,21 +70,35 @@ class _AdminAddDoctorPageState extends ConsumerState<AdminAddDoctorPage> {
|
||||
}
|
||||
setState(() => _saving = true);
|
||||
try {
|
||||
await ref.read(adminServiceProvider).addDoctor({
|
||||
final data = {
|
||||
'phone': _phoneCtrl.text.trim(),
|
||||
'name': _nameCtrl.text.trim(),
|
||||
'title': _titleCtrl.text.trim(),
|
||||
'department': _deptCtrl.text.trim(),
|
||||
'professionalDirection': _directionCtrl.text.trim(),
|
||||
});
|
||||
};
|
||||
if (_isEdit) {
|
||||
await ref.read(adminServiceProvider).updateDoctor(widget.id!, data);
|
||||
} else {
|
||||
await ref.read(adminServiceProvider).addDoctor(data);
|
||||
}
|
||||
if (mounted) {
|
||||
ref.invalidate(doctorListProvider);
|
||||
AppToast.show(context, '添加成功', type: AppToastType.success);
|
||||
ref.read(adminDoctorsRefreshSignalProvider.notifier).trigger();
|
||||
AppToast.show(
|
||||
context,
|
||||
_isEdit ? '修改成功' : '添加成功',
|
||||
type: AppToastType.success,
|
||||
);
|
||||
popRoute(ref);
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
AppToast.show(context, '添加失败: $e', type: AppToastType.error);
|
||||
AppToast.show(
|
||||
context,
|
||||
'${_isEdit ? '修改' : '添加'}失败: $e',
|
||||
type: AppToastType.error,
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
if (mounted) setState(() => _saving = false);
|
||||
@@ -70,46 +113,51 @@ class _AdminAddDoctorPageState extends ConsumerState<AdminAddDoctorPage> {
|
||||
backgroundColor: Colors.transparent,
|
||||
elevation: 0,
|
||||
surfaceTintColor: Colors.transparent,
|
||||
title: const Text(
|
||||
'新增医生',
|
||||
style: TextStyle(color: AppColors.textPrimary),
|
||||
title: Text(
|
||||
_isEdit ? '编辑医生' : '新增医生',
|
||||
style: const TextStyle(color: AppColors.textPrimary),
|
||||
),
|
||||
iconTheme: const IconThemeData(color: AppColors.textPrimary),
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
_buildField('手机号 *', _phoneCtrl, TextInputType.phone),
|
||||
const SizedBox(height: 16),
|
||||
_buildField('姓名 *', _nameCtrl, TextInputType.name),
|
||||
const SizedBox(height: 16),
|
||||
_buildField('职称', _titleCtrl, TextInputType.text),
|
||||
const SizedBox(height: 16),
|
||||
_buildField('科室', _deptCtrl, TextInputType.text),
|
||||
const SizedBox(height: 16),
|
||||
_buildField('专业方向', _directionCtrl, TextInputType.text),
|
||||
const SizedBox(height: 32),
|
||||
SizedBox(
|
||||
height: 50,
|
||||
child: ElevatedButton(
|
||||
onPressed: _saving ? null : _save,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColors.primary,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
body: BackofficeSurface(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
_buildField('手机号 *', _phoneCtrl, TextInputType.phone),
|
||||
const SizedBox(height: 16),
|
||||
_buildField('姓名 *', _nameCtrl, TextInputType.name),
|
||||
const SizedBox(height: 16),
|
||||
_buildField('职称', _titleCtrl, TextInputType.text),
|
||||
const SizedBox(height: 16),
|
||||
_buildField('科室', _deptCtrl, TextInputType.text),
|
||||
const SizedBox(height: 16),
|
||||
_buildField('专业方向', _directionCtrl, TextInputType.text),
|
||||
const SizedBox(height: 32),
|
||||
SizedBox(
|
||||
height: 50,
|
||||
child: ElevatedButton(
|
||||
onPressed: _saving ? null : _save,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColors.primary,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
child: _saving
|
||||
? const CircularProgressIndicator(color: Colors.white)
|
||||
: Text(
|
||||
_isEdit ? '保存修改' : '保存',
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: _saving
|
||||
? const CircularProgressIndicator(color: Colors.white)
|
||||
: const Text(
|
||||
'保存',
|
||||
style: TextStyle(fontSize: 16, color: Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -3,6 +3,9 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../core/app_colors.dart';
|
||||
import '../../core/navigation_provider.dart';
|
||||
import '../../providers/data_providers.dart' show adminServiceProvider;
|
||||
import '../../providers/backoffice_refresh_providers.dart';
|
||||
import '../../widgets/backoffice_ui.dart';
|
||||
import '../../widgets/app_toast.dart';
|
||||
|
||||
class AdminDoctorsPage extends ConsumerStatefulWidget {
|
||||
const AdminDoctorsPage({super.key});
|
||||
@@ -13,6 +16,7 @@ class AdminDoctorsPage extends ConsumerStatefulWidget {
|
||||
class _AdminDoctorsPageState extends ConsumerState<AdminDoctorsPage> {
|
||||
List<Map<String, dynamic>> _doctors = [];
|
||||
bool _loading = true;
|
||||
String? _error;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -21,25 +25,40 @@ class _AdminDoctorsPageState extends ConsumerState<AdminDoctorsPage> {
|
||||
}
|
||||
|
||||
Future<void> _load() async {
|
||||
setState(() => _loading = true);
|
||||
setState(() {
|
||||
_loading = true;
|
||||
_error = null;
|
||||
});
|
||||
try {
|
||||
final res = await ref.read(adminServiceProvider).getDoctors();
|
||||
if (res['code'] == 0 && mounted) {
|
||||
setState(() {
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
if (res['code'] == 0) {
|
||||
_doctors = List<Map<String, dynamic>>.from(res['data'] ?? []);
|
||||
} else {
|
||||
_error = res['message']?.toString() ?? '医生列表加载失败';
|
||||
}
|
||||
_loading = false;
|
||||
});
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_loading = false;
|
||||
_error = '医生列表加载失败';
|
||||
});
|
||||
}
|
||||
} catch (_) {
|
||||
if (mounted) setState(() => _loading = false);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _toggleActive(String id) async {
|
||||
try {
|
||||
await ref.read(adminServiceProvider).toggleDoctorActive(id);
|
||||
_load();
|
||||
} catch (_) {}
|
||||
await _load();
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
AppToast.show(context, '状态修改失败:$e', type: AppToastType.error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _delete(String id) async {
|
||||
@@ -47,7 +66,7 @@ class _AdminDoctorsPageState extends ConsumerState<AdminDoctorsPage> {
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: const Text('确认删除'),
|
||||
content: const Text('删除后患者关联将被清除,确定吗?'),
|
||||
content: const Text('只有没有绑定患者和问诊记录的医生才能删除;有历史数据的医生请使用“停用”。'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(ctx, false),
|
||||
@@ -64,13 +83,20 @@ class _AdminDoctorsPageState extends ConsumerState<AdminDoctorsPage> {
|
||||
if (ok == true) {
|
||||
try {
|
||||
await ref.read(adminServiceProvider).deleteDoctor(id);
|
||||
_load();
|
||||
} catch (_) {}
|
||||
await _load();
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
AppToast.show(context, '删除失败:$e', type: AppToastType.error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
ref.listen(adminDoctorsRefreshSignalProvider, (previous, next) {
|
||||
if (previous != null && previous != next) _load();
|
||||
});
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.pageGrey,
|
||||
floatingActionButton: FloatingActionButton(
|
||||
@@ -79,13 +105,14 @@ class _AdminDoctorsPageState extends ConsumerState<AdminDoctorsPage> {
|
||||
child: const Icon(Icons.add, color: Colors.white),
|
||||
),
|
||||
body: _loading
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
? const BackofficeLoadingState(message: '正在加载医生')
|
||||
: _error != null
|
||||
? BackofficeErrorState(message: _error!, onRetry: _load)
|
||||
: _doctors.isEmpty
|
||||
? const Center(
|
||||
child: Text(
|
||||
'暂无医生',
|
||||
style: TextStyle(color: AppColors.textHint, fontSize: 16),
|
||||
),
|
||||
? const BackofficeEmptyState(
|
||||
icon: Icons.medical_services_outlined,
|
||||
title: '暂无医生',
|
||||
description: '点击右下角按钮添加第一位医生',
|
||||
)
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.all(16),
|
||||
@@ -93,104 +120,114 @@ class _AdminDoctorsPageState extends ConsumerState<AdminDoctorsPage> {
|
||||
itemBuilder: (_, i) {
|
||||
final d = _doctors[i];
|
||||
final active = d['isActive'] != false;
|
||||
return Card(
|
||||
return BackofficeSectionCard(
|
||||
margin: const EdgeInsets.only(bottom: 10),
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
side: const BorderSide(color: AppColors.border),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(14),
|
||||
child: Row(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
backgroundColor: active
|
||||
? AppColors.successLight
|
||||
: AppColors.background,
|
||||
child: Icon(
|
||||
Icons.local_hospital,
|
||||
size: 20,
|
||||
color: active
|
||||
? AppColors.success
|
||||
: AppColors.textHint,
|
||||
),
|
||||
padding: const EdgeInsets.all(14),
|
||||
child: Row(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
backgroundColor: active
|
||||
? AppColors.successLight
|
||||
: AppColors.background,
|
||||
child: Icon(
|
||||
Icons.local_hospital,
|
||||
size: 20,
|
||||
color: active
|
||||
? AppColors.success
|
||||
: AppColors.textHint,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
d['name'] ?? '',
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
if (!active)
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 6,
|
||||
vertical: 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.errorLight,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: const Text(
|
||||
'已停用',
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
color: AppColors.error,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'${d['title'] ?? ''} 路 ${d['department'] ?? ''}',
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: AppColors.textSecondary,
|
||||
),
|
||||
),
|
||||
if (d['professionalDirection'] != null)
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
d['professionalDirection']!,
|
||||
d['name'] ?? '',
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: AppColors.textHint,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
PopupMenuButton<String>(
|
||||
onSelected: (v) {
|
||||
if (v == 'toggle') _toggleActive(d['id']);
|
||||
if (v == 'delete') _delete(d['id']);
|
||||
},
|
||||
itemBuilder: (_) => [
|
||||
PopupMenuItem(
|
||||
value: 'toggle',
|
||||
child: Text(active ? '停用' : '启用'),
|
||||
const SizedBox(width: 8),
|
||||
if (!active)
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 6,
|
||||
vertical: 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.errorLight,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: const Text(
|
||||
'已停用',
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
color: AppColors.error,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const PopupMenuItem(
|
||||
value: 'delete',
|
||||
child: Text(
|
||||
'删除',
|
||||
style: TextStyle(color: AppColors.error),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'${d['title'] ?? ''} · ${d['department'] ?? ''}',
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: AppColors.textSecondary,
|
||||
),
|
||||
),
|
||||
if (d['professionalDirection'] != null)
|
||||
Text(
|
||||
d['professionalDirection']!,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: AppColors.textHint,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
PopupMenuButton<String>(
|
||||
onSelected: (v) {
|
||||
if (v == 'edit') {
|
||||
pushRoute(
|
||||
ref,
|
||||
'adminAddDoctor',
|
||||
params: {
|
||||
'id': d['id']?.toString() ?? '',
|
||||
'phone': d['phone']?.toString() ?? '',
|
||||
'name': d['name']?.toString() ?? '',
|
||||
'title': d['title']?.toString() ?? '',
|
||||
'department': d['department']?.toString() ?? '',
|
||||
'direction':
|
||||
d['professionalDirection']?.toString() ??
|
||||
'',
|
||||
},
|
||||
);
|
||||
}
|
||||
if (v == 'toggle') _toggleActive(d['id']);
|
||||
if (v == 'delete') _delete(d['id']);
|
||||
},
|
||||
itemBuilder: (_) => [
|
||||
const PopupMenuItem(value: 'edit', child: Text('编辑')),
|
||||
PopupMenuItem(
|
||||
value: 'toggle',
|
||||
child: Text(active ? '停用' : '启用'),
|
||||
),
|
||||
const PopupMenuItem(
|
||||
value: 'delete',
|
||||
child: Text(
|
||||
'删除',
|
||||
style: TextStyle(color: AppColors.error),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../core/app_colors.dart';
|
||||
import '../../widgets/admin_drawer.dart';
|
||||
import '../../widgets/backoffice_ui.dart';
|
||||
import 'admin_doctors_page.dart';
|
||||
import 'admin_patients_page.dart';
|
||||
|
||||
@@ -27,18 +28,20 @@ class AdminHomePage extends ConsumerWidget {
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.transparent,
|
||||
elevation: 0,
|
||||
title: const Text(
|
||||
'系统管理',
|
||||
title: Text(
|
||||
page == 'patients' ? '患者管理' : '医生管理',
|
||||
style: TextStyle(color: AppColors.textPrimary),
|
||||
),
|
||||
iconTheme: const IconThemeData(color: AppColors.textPrimary),
|
||||
),
|
||||
drawer: const AdminDrawer(),
|
||||
body: switch (page) {
|
||||
'doctors' => const AdminDoctorsPage(),
|
||||
'patients' => const AdminPatientsPage(),
|
||||
_ => const AdminDoctorsPage(),
|
||||
},
|
||||
body: BackofficeSurface(
|
||||
child: switch (page) {
|
||||
'doctors' => const AdminDoctorsPage(),
|
||||
'patients' => const AdminPatientsPage(),
|
||||
_ => const AdminDoctorsPage(),
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../core/app_colors.dart';
|
||||
import '../../providers/data_providers.dart' show adminServiceProvider;
|
||||
import '../../utils/backoffice_formatters.dart';
|
||||
import '../../widgets/backoffice_ui.dart';
|
||||
|
||||
class AdminPatientsPage extends ConsumerStatefulWidget {
|
||||
const AdminPatientsPage({super.key});
|
||||
@@ -16,6 +18,7 @@ class _AdminPatientsPageState extends ConsumerState<AdminPatientsPage> {
|
||||
int _page = 1;
|
||||
bool _loading = true;
|
||||
bool _loadingMore = false;
|
||||
String? _error;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -35,13 +38,15 @@ class _AdminPatientsPageState extends ConsumerState<AdminPatientsPage> {
|
||||
setState(() {
|
||||
_loading = true;
|
||||
_patients = [];
|
||||
_error = null;
|
||||
});
|
||||
}
|
||||
try {
|
||||
final res = await ref
|
||||
.read(adminServiceProvider)
|
||||
.getPatients(search: _searchCtrl.text.trim(), page: _page);
|
||||
if (res['code'] == 0 && mounted) {
|
||||
if (!mounted) return;
|
||||
if (res['code'] == 0) {
|
||||
final data = res['data'] as Map<String, dynamic>? ?? {};
|
||||
setState(() {
|
||||
_total = data['total'] ?? 0;
|
||||
@@ -54,12 +59,19 @@ class _AdminPatientsPageState extends ConsumerState<AdminPatientsPage> {
|
||||
_loading = false;
|
||||
_loadingMore = false;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
_loading = false;
|
||||
_loadingMore = false;
|
||||
_error = res['message']?.toString() ?? '患者列表加载失败';
|
||||
});
|
||||
}
|
||||
} catch (_) {
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_loading = false;
|
||||
_loadingMore = false;
|
||||
_error = '患者列表加载失败';
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -123,13 +135,14 @@ class _AdminPatientsPageState extends ConsumerState<AdminPatientsPage> {
|
||||
// 患者列表
|
||||
Expanded(
|
||||
child: _loading
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
? const BackofficeLoadingState(message: '正在加载患者')
|
||||
: _error != null
|
||||
? BackofficeErrorState(message: _error!, onRetry: _load)
|
||||
: _patients.isEmpty
|
||||
? const Center(
|
||||
child: Text(
|
||||
'暂无患者',
|
||||
style: TextStyle(color: AppColors.textHint, fontSize: 16),
|
||||
),
|
||||
? const BackofficeEmptyState(
|
||||
icon: Icons.people_outline,
|
||||
title: '暂无患者',
|
||||
description: '注册患者会显示在这里',
|
||||
)
|
||||
: NotificationListener<ScrollNotification>(
|
||||
onNotification: (n) {
|
||||
@@ -152,20 +165,14 @@ class _AdminPatientsPageState extends ConsumerState<AdminPatientsPage> {
|
||||
);
|
||||
}
|
||||
final p = _patients[i];
|
||||
return Card(
|
||||
return BackofficeSectionCard(
|
||||
margin: const EdgeInsets.only(bottom: 8),
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
side: const BorderSide(color: AppColors.border),
|
||||
),
|
||||
padding: EdgeInsets.zero,
|
||||
child: ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: AppColors.iconBg,
|
||||
child: Text(
|
||||
p['name']?.toString().isNotEmpty == true
|
||||
? p['name']!.toString()[0]
|
||||
: '?',
|
||||
backofficeInitial(p['name']),
|
||||
style: const TextStyle(color: AppColors.primary),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user