diff --git a/marking_app/lib/pages/homework_correction/pages/favorite_student_dialog.dart b/marking_app/lib/pages/homework_correction/pages/favorite_student_dialog.dart index d21a0de..41f5fff 100644 --- a/marking_app/lib/pages/homework_correction/pages/favorite_student_dialog.dart +++ b/marking_app/lib/pages/homework_correction/pages/favorite_student_dialog.dart @@ -10,12 +10,14 @@ class FavoriteStudentDialog extends StatefulWidget { final Items item; final List group; final Function deleteFav; + final Future Function() confirmDialog; const FavoriteStudentDialog( {Key? key, required this.item, required this.group, - required this.deleteFav}) + required this.deleteFav, + required this.confirmDialog}) : super(key: key); @override @@ -69,12 +71,11 @@ class _FavoriteStudentDialogState extends State { style: TextStyle(fontSize: 12.sp, color: Color(0xFF868686)), ), InkWell( - onTap: () { - + onTap: () async { + bool confim = await widget.confirmDialog(); + if (confim) { widget.deleteFav(currentStudent); imageList.removeAt(defaultIndex); - print('imageList.length=${imageList.length}'); - print('defaultIndex=${defaultIndex}'); setState(() { if (imageList.length > 0) { if (defaultIndex < imageList.length) { @@ -88,6 +89,7 @@ class _FavoriteStudentDialogState extends State { currentStudent.studentName = ''; } }); + } }, child: Padding( padding: EdgeInsets.symmetric(horizontal: 8.r), diff --git a/marking_app/lib/pages/homework_correction/pages/job_favorite.dart b/marking_app/lib/pages/homework_correction/pages/job_favorite.dart index 14428aa..1de3fc4 100644 --- a/marking_app/lib/pages/homework_correction/pages/job_favorite.dart +++ b/marking_app/lib/pages/homework_correction/pages/job_favorite.dart @@ -26,9 +26,9 @@ class JobFavorite extends StatefulWidget { const JobFavorite({ required this.jobId, - this.schoolId, - this.gradeId, - this.className, + this.schoolId, + this.gradeId, + this.className, required this.jobName, super.key, }); @@ -48,7 +48,7 @@ class _JobFavoriteState extends State with CommonMixin { @override void initState() { super.initState(); - /* FastData fastData = FastData.getInstance(); + /* FastData fastData = FastData.getInstance(); fastData.getUser().then((value) { if (value == null || value == '') return; Map userInfo = json.decode(value); @@ -56,7 +56,7 @@ class _JobFavoriteState extends State with CommonMixin { loginName = userInfo['loginName']; }); });*/ - if(widget.className != null){ + if (widget.className != null) { className = widget.className!; } @@ -66,8 +66,8 @@ class _JobFavoriteState extends State with CommonMixin { Future> getData() async { var _client = await getClient(); - var result = - await _client.getListOfJobFavorites(widget.jobId, widget.jobName, className == '全部'?'':className, pageSize); + var result = await _client.getListOfJobFavorites(widget.jobId, + widget.jobName, className == '全部' ? '' : className, pageSize); return result.data!.items; } @@ -82,10 +82,14 @@ class _JobFavoriteState extends State with CommonMixin { Future getInvolveClasses() async { try { RestClient _client = await getClient(); - BaseStructureResult> result = await _client.getJobReportJoinClasses(widget.jobId); + BaseStructureResult> result = + await _client.getJobReportJoinClasses(widget.jobId); if (result.success) { toUpState(setState, () { - involveClasses = [JobReportJoinClass(-1, '全部', -1, '全部', '全部', '全部', -1, -1, '-1'), ...(result.data ?? [])]; + involveClasses = [ + JobReportJoinClass(-1, '全部', -1, '全部', '全部', '全部', -1, -1, '-1'), + ...(result.data ?? []) + ]; involveClasses?.forEach((element) { if (element.className == widget.className && element.gradeId == widget.gradeId && @@ -101,26 +105,81 @@ class _JobFavoriteState extends State with CommonMixin { } } - deleteFav(Items student) async{ - RestClient _client = await getClient(); - BaseStructureResult res = await _client.getJobDeFavorites(widget.jobId,student.studentId,student.questionPage!); - if(res.success){ - _future = getData(); - setState(() { + Future confirmDialog() async { + return await showDialog( + context: context, + builder: (context) => AlertDialog( + actionsPadding: EdgeInsets.symmetric(vertical: 10.r, horizontal: 10.r), + content: Text( + '确定删除吗?', + style: TextStyle(fontSize: 14.sp, color: Color(0xFF505E6E)), + ), + actionsAlignment: MainAxisAlignment.center, + actions: [ + InkWell( + child: Container( + width: 97.r, + height: 27.r, + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(20.r)), + color: Color(0xFF6888FD), + ), + child: Center( + child: Text( + '确定', + style: TextStyle(color: Colors.white), + ))), + onTap: () { + // 执行操作 + Navigator.of(context).pop(true); + }, + ), + InkWell( + onTap: () { + Navigator.of(context).pop(false); + }, + child: Container( + width: 97.r, + height: 27.r, + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(20.r)), + color: Color(0xFFF4F4F4), + ), + child: Center( + child: Text( + '取消', + style: TextStyle(color: Color(0xFF666666)), + ))), + ), + ], + ), + ); + } - }); + getDelete(Items student) async { + RestClient _client = await getClient(); + BaseStructureResult res = await _client.getJobDeFavorites( + widget.jobId, student.studentId, student.questionPage!); + if (res.success) { + _future = getData(); + setState(() {}); } } - void showStudentDialog(BuildContext context,Items item,List groups) { + void showStudentDialog(BuildContext context, Items item, List groups) { showDialog( context: context, builder: (BuildContext context) { return AlertDialog( insetPadding: EdgeInsets.all(25.r), - content: FavoriteStudentDialog(item: item,group: groups, deleteFav: deleteFav,), + content: FavoriteStudentDialog( + item: item, + group: groups, + deleteFav: getDelete, + confirmDialog: confirmDialog), contentPadding: EdgeInsets.all(0), - shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(15.r)))); + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(15.r)))); }, ); } @@ -133,7 +192,9 @@ class _JobFavoriteState extends State with CommonMixin { appBar: AppBar( // titleSpacing: 0, elevation: 0.0, - leading: IconButton(icon: Icon(Icons.arrow_back_ios), onPressed: () => Navigator.of(context).pop()), + leading: IconButton( + icon: Icon(Icons.arrow_back_ios), + onPressed: () => Navigator.of(context).pop()), iconTheme: IconThemeData(color: Colors.black), title: quickText('收藏夹'), centerTitle: true, @@ -143,10 +204,10 @@ class _JobFavoriteState extends State with CommonMixin { context, _future, (List? datas) { - if (datas == null) + if (datas == null) return Container( child: InkWell( - onTap: (){ + onTap: () { toUpState(setState, () => _future = getData(), mounted); }, child: Center( @@ -163,10 +224,13 @@ class _JobFavoriteState extends State with CommonMixin { pageList = pageList.toSet().toList(); for (var page in pageList) { - var printList = datas.where((element) => element.questionPage == page).toList(); + var printList = datas + .where((element) => element.questionPage == page) + .toList(); groupList.add({"questionPage": page, "list": printList}); } - groupList.sort((a, b) => a['questionPage'].compareTo(b['questionPage'])); + groupList + .sort((a, b) => a['questionPage'].compareTo(b['questionPage'])); } return Container( child: Column( @@ -179,14 +243,17 @@ class _JobFavoriteState extends State with CommonMixin { children: [ Text( widget.jobName, - style: TextStyle(fontSize: 14.sp, color: Color(0xFF3C3C3C)), + style: + TextStyle(fontSize: 14.sp, color: Color(0xFF3C3C3C)), ), // 下拉框 Container( - padding: EdgeInsets.symmetric(vertical: 10.h, horizontal: 10.w), + padding: EdgeInsets.symmetric( + vertical: 10.h, horizontal: 10.w), child: Row( children: [ - $classSelection(involveClasses, classData, call: (JobReportJoinClass _classData) { + $classSelection(involveClasses, classData, + call: (JobReportJoinClass _classData) { classData = _classData; if (_classData.gradeId == -1) classData = null; className = _classData.className; @@ -207,151 +274,208 @@ class _JobFavoriteState extends State with CommonMixin { color: Color(0xFFCCCCCC), ), ), - groupList.length>0? - Expanded( - child: isPadFlag - ? Padding( - padding: EdgeInsets.only(top: 10.r, bottom: 8.r, left: 14.r, right: 14.r), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: List.generate(groupList.length, (index) { - var item = groupList[index]; - return Padding( - padding: EdgeInsets.only(bottom: 8.r), + groupList.length > 0 + ? Expanded( + child: isPadFlag + ? Padding( + padding: EdgeInsets.only( + top: 10.r, + bottom: 8.r, + left: 14.r, + right: 14.r), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only(bottom: 5.r), - child: Text( - '第${item['questionPage']}页', - style: TextStyle(fontSize: 12.sp, color: Color(0xFF2E5BFF)), - ), - ), - GridView( - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, - mainAxisSpacing: 8.r, - crossAxisSpacing: 10.r, - childAspectRatio: 556 / 112, - ), - shrinkWrap: true, - children: List.generate(item['list'].length, (i){ - Items student = item['list'][i]; - return Container( - padding: EdgeInsets.symmetric(vertical: 5.r, horizontal: 10.r), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.all(Radius.circular(6.r)), - ), - child: InkWell( - onTap: () { - showStudentDialog(context,student,groupList); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - quickText(student.studentName, color: Color(0xFF333333), size: 12.sp), - Expanded(child: Container()), - Padding( - padding: EdgeInsets.only(right: 8.r), - child: Text( - student.className, - style: TextStyle(fontSize: 12.sp, color: Color(0xFF666666)), - ), - ), - InkWell( - onTap: () async { - deleteFav(student); - }, - child: Image.asset( - 'assets/images/favorite_delete_icon.png', - width: 24.r, - height: 24.r, - ), - ), - ], - ), - ), - ); - }) - ), - ], - ), - ); - }) - - - ), - ) - : ListView.builder( - shrinkWrap: true, - itemBuilder: (context, index) { - var item = groupList[index]; - return Padding( - padding: EdgeInsets.only(top: 10.r, bottom: 8.r, left: 14.r, right: 14.r), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only(bottom: 5.r), - child: Text( - '第${item['questionPage']}页', - style: TextStyle(fontSize: 14.sp, color: Color(0xFF2E5BFF)), - ), - ), - ListView.builder( - itemBuilder: (context,i){ - Items student = item['list'][i]; - return InkWell( - onTap: (){ - showStudentDialog(context,student,groupList); - }, - child: Container( - padding: EdgeInsets.symmetric(vertical: 5.r, horizontal: 10.r), - margin: EdgeInsets.only(top: 5.r), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.all(Radius.circular(6.r)), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: + List.generate(groupList.length, (index) { + var item = groupList[index]; + return Padding( + padding: EdgeInsets.only(bottom: 8.r), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, children: [ - quickText(student.studentName, color: Color(0xFF333333), size: 14.sp), - Expanded(child: Container()), Padding( - padding: EdgeInsets.only(right: 8.r), + padding: + EdgeInsets.only(bottom: 5.r), child: Text( - student.className, - style: TextStyle(fontSize: 14.sp, color: Color(0xFF666666)), - ), - ), - InkWell( - onTap: () async { - deleteFav(student); - }, - child: Image.asset( - 'assets/images/favorite_delete_icon.png', - width: 32.r, - height: 32.r, + '第${item['questionPage']}页', + style: TextStyle( + fontSize: 12.sp, + color: Color(0xFF2E5BFF)), ), ), + GridView( + gridDelegate: + SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + mainAxisSpacing: 8.r, + crossAxisSpacing: 10.r, + childAspectRatio: 556 / 112, + ), + shrinkWrap: true, + children: List.generate( + item['list'].length, (i) { + Items student = item['list'][i]; + return Container( + padding: EdgeInsets.symmetric( + vertical: 5.r, + horizontal: 10.r), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: + BorderRadius.all( + Radius.circular( + 6.r)), + ), + child: InkWell( + onTap: () { + showStudentDialog(context, + student, groupList); + }, + child: Row( + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + quickText( + student.studentName, + color: Color( + 0xFF333333), + size: 12.sp), + Expanded( + child: Container()), + Padding( + padding: + EdgeInsets.only( + right: 8.r), + child: Text( + student.className, + style: TextStyle( + fontSize: 12.sp, + color: Color( + 0xFF666666)), + ), + ), + InkWell( + onTap: () async { + var confim = + await confirmDialog(); + if (confim) { + getDelete( + student); + } + }, + child: Image.asset( + 'assets/images/favorite_delete_icon.png', + width: 24.r, + height: 24.r, + ), + ), + ], + ), + ), + ); + })), ], ), - ), - ); - },itemCount: item['list'].length,shrinkWrap: true,), - - ], + ); + })), + ) + : ListView.builder( + shrinkWrap: true, + itemBuilder: (context, index) { + var item = groupList[index]; + return Padding( + padding: EdgeInsets.only( + top: 10.r, + bottom: 8.r, + left: 14.r, + right: 14.r), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.only(bottom: 5.r), + child: Text( + '第${item['questionPage']}页', + style: TextStyle( + fontSize: 14.sp, + color: Color(0xFF2E5BFF)), + ), + ), + ListView.builder( + itemBuilder: (context, i) { + Items student = item['list'][i]; + return InkWell( + onTap: () { + showStudentDialog( + context, student, groupList); + }, + child: Container( + padding: EdgeInsets.symmetric( + vertical: 5.r, + horizontal: 10.r), + margin: EdgeInsets.only(top: 5.r), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all( + Radius.circular(6.r)), + ), + child: Row( + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + quickText(student.studentName, + color: Color(0xFF333333), + size: 14.sp), + Expanded(child: Container()), + Padding( + padding: EdgeInsets.only( + right: 8.r), + child: Text( + student.className, + style: TextStyle( + fontSize: 14.sp, + color: Color( + 0xFF666666)), + ), + ), + InkWell( + onTap: () async { + var confim = + await confirmDialog(); + if (confim) { + getDelete(student); + } + }, + child: Image.asset( + 'assets/images/favorite_delete_icon.png', + width: 32.r, + height: 32.r, + ), + ), + ], + ), + ), + ); + }, + itemCount: item['list'].length, + shrinkWrap: true, + ), + ], + ), + ); + }, + itemCount: groupList.length, ), - ); - }, - itemCount: groupList.length, - ), - ):Padding( - padding: EdgeInsets.only(top: MediaQuery.of(context).size.height/2 - 200.r), - child: MyEmptyWidget(), - ), + ) + : Padding( + padding: EdgeInsets.only( + top: MediaQuery.of(context).size.height / 2 - 200.r), + child: MyEmptyWidget(), + ), ], )); }, @@ -362,9 +486,11 @@ class _JobFavoriteState extends State with CommonMixin { /// 下拉选择框 @swidget -Widget $classSelection(List? involveClasses, JobReportJoinClass? classData, +Widget $classSelection( + List? involveClasses, JobReportJoinClass? classData, {required Function(JobReportJoinClass) call}) { - if (involveClasses == null) return Container(child: quickText('点击重试')); // 点击重试 + if (involveClasses == null) + return Container(child: quickText('点击重试')); // 点击重试 return Container( // width: 200.r, padding: EdgeInsets.symmetric(horizontal: 10.r), @@ -383,14 +509,17 @@ Widget $classSelection(List? involveClasses, JobReportJoinCl items: involveClasses.map((e) { return DropdownMenuItem( value: e.uniqueId!, - child: quickText(e.uniqueId == '-1' ? e.graduationYear : e.graduationYear + e.className, - size: 10.sp, color: Colors.black), + child: quickText( + e.uniqueId == '-1' + ? e.graduationYear + : e.graduationYear + e.className, + size: 10.sp, + color: Colors.black), ); }).toList(), onChanged: (String? value) { if (value == null) return; call(involveClasses.firstWhere((element) => element.uniqueId == value)); - }, ), ); diff --git a/marking_app/lib/pages/homework_correction/quick_data_check.dart b/marking_app/lib/pages/homework_correction/quick_data_check.dart index da0142b..ab838df 100644 --- a/marking_app/lib/pages/homework_correction/quick_data_check.dart +++ b/marking_app/lib/pages/homework_correction/quick_data_check.dart @@ -428,13 +428,13 @@ class _QuickDataCheckPageState extends State if (jobData == null) return; if (!jobData!.sortLevel) { jobData!.studentDetails.sort((a, b) { - return b.readLevel! - .compareTo(a.readLevel!); + return a.readLevel! + .compareTo(b.readLevel!); }); } else { jobData!.studentDetails.sort((a, b) { - return a.readLevel! - .compareTo(b.readLevel!); + return b.readLevel! + .compareTo(a.readLevel!); }); } jobData!.sortLevel =