From 39d0686b91af3e0ed5d1d4945f961975b53f4e19 Mon Sep 17 00:00:00 2001 From: machuanyu <840649825@qq.com> Date: Tue, 5 Mar 2024 17:36:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=80=BB=E4=BD=93=E6=B0=B4=E5=B9=B3=EF=BC=8C?= =?UTF-8?q?=E9=87=8D=E7=82=B9=E5=85=B3=E6=B3=A8=E5=88=97=E8=A1=A8=E5=9B=BA?= =?UTF-8?q?=E5=AE=9A=E7=AC=AC=E4=B8=80=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/pages/report_detail/index.dart | 427 ++++++++++-------- .../report_detail/widgets/card_table.dart | 11 +- .../widgets/report_card_dialog.dart | 2 +- marking_app/lib/pages/reports/index.dart | 4 +- 4 files changed, 258 insertions(+), 186 deletions(-) diff --git a/marking_app/lib/pages/report_detail/index.dart b/marking_app/lib/pages/report_detail/index.dart index 03e351e..a4506b4 100644 --- a/marking_app/lib/pages/report_detail/index.dart +++ b/marking_app/lib/pages/report_detail/index.dart @@ -49,6 +49,7 @@ class _ReportDetailState extends ConsumerState with CommonMixin { List classList = []; //班级 ComboData currentSubject = ComboData('', ''); ComboData currentClass = ComboData('', ''); + // List questionClassList = []; //小题得分班级 ComboData questionCurrentClass = ComboData('', ''); bool isClass = false; @@ -82,12 +83,12 @@ class _ReportDetailState extends ConsumerState with CommonMixin { setState(() { classList = List.from(res.data!); - questionCurrentClass =ComboData(0, '全部',isCheck: true); - classList.insert(0,questionCurrentClass); + questionCurrentClass = ComboData(0, '全部', isCheck: true); + classList.insert(0, questionCurrentClass); // classList[1].isCheck = true; currentClass = classList[1]; - /* questionClassList = List.from(res.data!); + /* questionClassList = List.from(res.data!); questionCurrentClass =ComboData(0, '全部',isCheck: true); questionClassList.insert(0,questionCurrentClass);*/ @@ -105,7 +106,7 @@ class _ReportDetailState extends ConsumerState with CommonMixin { await clientReport.getReportDetail(widget.examId, widget.showGrade && isGrade ? -1 : currentClass.value); // print('*************result=${result.message}'); - if(result.code == 200){ + if (result.code == 200) { setState(() { currentPage = 1; questionCurrentPage = 1; @@ -117,12 +118,11 @@ class _ReportDetailState extends ConsumerState with CommonMixin { getQuestionTable(); getKnowPointTable(); getCard(); - }else{ + } else { Navigator.pop(context); EasyLoading.dismiss(); ToastUtils.showError(result.message.toString()); } - } //小题得分 @@ -132,21 +132,21 @@ class _ReportDetailState extends ConsumerState with CommonMixin { "%%%%%%%%%%%%%%%%%%%widget.examId=${widget.examId}&questionCurrentClass.value=${questionCurrentClass.value}¤tSubject.value=${currentSubject.value}"); ReportCardParams params = ReportCardParams( examId: widget.examId, - classId: isGrade?questionCurrentClass.value:currentClass.value, + classId: isGrade ? questionCurrentClass.value : currentClass.value, // classId: 494760774623317, subject: currentSubject.value, page: questionCurrentPage, limit: pageSize); BaseStructureResultReport res = await clientReport.getQuestion(params); - print('res.data!.total=${res.code== 200 ?res.data!.bodyExcelData.sheets[0].bodyData.length:''}'); - if(res.code != 200 || res.data == null){ + print( + 'res.data!.total=${res.code == 200 ? res.data!.bodyExcelData.sheets[0].bodyData.length : ''}'); + if (res.code != 200 || res.data == null) { setState(() { smallQuestionRes = null; questionTotalPage = 0; }); - - }else{ + } else { setState(() { smallQuestionRes = res; questionTotalPage = (res.data!.total / pageSize).ceil(); @@ -156,19 +156,22 @@ class _ReportDetailState extends ConsumerState with CommonMixin { EasyLoading.dismiss(); } + //知识点 void getKnowPointTable() async { RestClientReport clientReport = await getClientReport(); BaseStructureResultReport res = - await clientReport.getKnowPoint( - //494760774623317 - widget.examId,isGrade ? questionCurrentClass.value:currentClass.value,currentSubject.value - ); + await clientReport.getKnowPoint( + //494760774623317 + widget.examId, + isGrade ? questionCurrentClass.value : currentClass.value, + currentSubject.value); setState(() { knowPointRes = res; }); EasyLoading.dismiss(); } + void getCard() async { RestClientReport clientReport = await getClientReport(); @@ -229,31 +232,31 @@ class _ReportDetailState extends ConsumerState with CommonMixin { ); } - void refreshData(item, type,index) { + void refreshData(item, type, index) { setState(() { - if(type == 'classList'){ + if (type == 'classList') { currentClass = item; currentPage = 1; - }else if(type == 'questionClassList'){ + } else if (type == 'questionClassList') { questionCurrentClass = item; questionCurrentPage = 1; - }else if(type == 'subjectList'){ + } else if (type == 'subjectList') { currentSubject = item; questionCurrentPage = 1; } }); - if(type == 'classList'){ + if (type == 'classList') { getBaseInfo(); } - if(type == 'questionClassList' || type == 'subjectList' || !isGrade){ + if (type == 'questionClassList' || type == 'subjectList' || !isGrade) { getQuestionTable(); getKnowPointTable(); } } - void showSubjectDialog( - BuildContext context, List list, String type,ComboData currentSelect) { + void showSubjectDialog(BuildContext context, List list, + String type, ComboData currentSelect) { showModalBottomSheet( context: context, shape: RoundedRectangleBorder( @@ -274,29 +277,28 @@ class _ReportDetailState extends ConsumerState with CommonMixin { element.isCheck = false; }); // item!.isCheck = true; - if(item!.value == currentSelect.value){ + if (item!.value == currentSelect.value) { item!.isCheck = true; - } }); EasyLoading.show(status: 'loading...'); - refreshData(item, type,index); + refreshData(item, type, index); Navigator.pop(context); }, - child: type == 'classList' && index ==0?Container(): - Padding( - padding: EdgeInsets.symmetric(vertical: 10.r), - child: Center( - child: Text( - item!.text, - style: TextStyle( - fontSize: 14.r, - color: - item.value == currentSelect.value - // item.isCheck - ? Color(0xFF5F81FD) - : Color(0xFF2E2E2E)), - ))), + child: type == 'classList' && index == 0 + ? Container() + : Padding( + padding: EdgeInsets.symmetric(vertical: 10.r), + child: Center( + child: Text( + item!.text, + style: TextStyle( + fontSize: 14.r, + color: item.value == currentSelect.value + // item.isCheck + ? Color(0xFF5F81FD) + : Color(0xFF2E2E2E)), + ))), ); }, itemCount: list.length, @@ -451,7 +453,8 @@ class _ReportDetailState extends ConsumerState with CommonMixin { ), InkWell( onTap: () { - showSubjectDialog(context, classList, 'classList',currentClass); + showSubjectDialog(context, classList, + 'classList', currentClass); }, child: Container( padding: EdgeInsets.symmetric( @@ -476,62 +479,116 @@ class _ReportDetailState extends ConsumerState with CommonMixin { ), ), LabTitle('基本信息', 'assets/images/basic_info.png'), - BasicTable(baseInfo,!widget.showGrade || !isGrade), + BasicTable(baseInfo, !widget.showGrade || !isGrade), LabTitle('总体水平', 'assets/images/overall_level.png'), - OverallLevelTable(overallLevelRes!.data!.module1CJZL.sheets[0]), + overallLevelRes!.data!.module1CJZL != null && overallLevelRes! + .data!.module1CJZL.sheets[0].bodyData.length > 0 + ? + Container( + height: overallLevelRes! + .data!.module1CJZL.sheets[0].bodyData.length>5? 300.r : overallLevelRes! + .data!.module1CJZL.sheets[0].bodyData.length * 50.r + 40.r, + padding: EdgeInsets.symmetric(horizontal: 14.r), + child: CardList( + headList: overallLevelRes! + .data!.module1CJZL.sheets[0].headData, + bodyList: overallLevelRes! + .data!.module1CJZL.sheets[0].bodyData, + isScore: true, + fixedRows: 1, + fixedCols: 1, + ), + ):NoData(), + + // OverallLevelTable(overallLevelRes!.data!.module1CJZL.sheets[0]), LabTitle('重点关注学生', 'assets/images/reports_focus.png'), - overallLevelRes! - .data!.module2ZDGZ.topExcelData != null? - OverallLevelTable(overallLevelRes! - .data!.module2ZDGZ.topExcelData?.sheets[0]):NoData(), + overallLevelRes!.data!.module2ZDGZ.topExcelData != null + ? + /*OverallLevelTable(overallLevelRes! + .data!.module2ZDGZ.topExcelData?.sheets[0])*/ + Container( + height: 300.r, + padding: EdgeInsets.symmetric(horizontal: 14.r), + child: CardList( + headList: overallLevelRes! + .data!.module2ZDGZ.topExcelData!.sheets[0].headData, + bodyList: overallLevelRes! + .data!.module2ZDGZ.topExcelData!.sheets[0].bodyData, + isScore: true, + isHtml:true, + fixedRows: 1, + fixedCols: 1, + ), + ) + : NoData(), SizedBox( height: 20.r, ), - if(overallLevelRes! - .data!.module2ZDGZ.topExcelData != null) - OverallLevelTable(overallLevelRes! - .data!.module2ZDGZ.bottomExcelData?.sheets[0]), + if (overallLevelRes!.data!.module2ZDGZ.topExcelData != + null) + /* OverallLevelTable(overallLevelRes! + .data!.module2ZDGZ.bottomExcelData?.sheets[0]),*/ + Container( + height: 300.r, + padding: EdgeInsets.symmetric(horizontal: 14.r), + child: CardList( + headList: overallLevelRes! + .data!.module2ZDGZ.bottomExcelData!.sheets[0].headData, + bodyList: overallLevelRes! + .data!.module2ZDGZ.bottomExcelData!.sheets[0].bodyData, + isScore: true, + isHtml:true, + fixedRows: 1, + fixedCols: 1, + ), + ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ LabTitle('小题得分', 'assets/images/reports_score.png'), - Expanded(child: Text(''),), - if(isGrade) - Container( - padding: EdgeInsets.symmetric( - vertical: 2.r, horizontal: 10.r), - margin: EdgeInsets.only(right: 14.r), - decoration: BoxDecoration( - color: Color(0xFF6787FD), - borderRadius: - BorderRadius.all(Radius.circular(15.r)), - ), - child: InkWell( - onTap: () { - showSubjectDialog(context, classList, 'questionClassList',questionCurrentClass); - }, - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Text( - questionCurrentClass.text, - style: TextStyle( - fontSize: 14.sp, - color: Colors.white, - fontWeight: FontWeight.w500), - ), - Padding( - padding: EdgeInsets.only(left: 8.r), - child: Image.asset( - 'assets/images/right_icon.png', - width: 6.r, - height: 10.r, + Expanded( + child: Text(''), + ), + if (isGrade) + Container( + padding: EdgeInsets.symmetric( + vertical: 2.r, horizontal: 10.r), + margin: EdgeInsets.only(right: 14.r), + decoration: BoxDecoration( + color: Color(0xFF6787FD), + borderRadius: + BorderRadius.all(Radius.circular(15.r)), + ), + child: InkWell( + onTap: () { + showSubjectDialog( + context, + classList, + 'questionClassList', + questionCurrentClass); + }, + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + questionCurrentClass.text, + style: TextStyle( + fontSize: 14.sp, + color: Colors.white, + fontWeight: FontWeight.w500), ), - ) - ], + Padding( + padding: EdgeInsets.only(left: 8.r), + child: Image.asset( + 'assets/images/right_icon.png', + width: 6.r, + height: 10.r, + ), + ) + ], + ), ), ), - ), Container( padding: EdgeInsets.symmetric( vertical: 2.r, horizontal: 10.r), @@ -543,7 +600,8 @@ class _ReportDetailState extends ConsumerState with CommonMixin { ), child: InkWell( onTap: () { - showSubjectDialog(context, subjectList, 'subjectList',currentSubject); + showSubjectDialog(context, subjectList, + 'subjectList', currentSubject); }, child: Row( crossAxisAlignment: CrossAxisAlignment.center, @@ -577,10 +635,11 @@ class _ReportDetailState extends ConsumerState with CommonMixin { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - (smallQuestionRes !=null && smallQuestionRes!.data!.bodyExcelData + (smallQuestionRes != null && + smallQuestionRes!.data!.bodyExcelData .sheets[0].headData.length > 0 && - smallQuestionRes!.data!.bodyExcelData + smallQuestionRes!.data!.bodyExcelData .sheets[0].bodyData.length > 0) ? SizedBox( @@ -593,12 +652,13 @@ class _ReportDetailState extends ConsumerState with CommonMixin { 9 ? 300.r : smallQuestionRes! - .data! - .bodyExcelData - .sheets[0] - .bodyData - .length * - 50.r + 40.r, + .data! + .bodyExcelData + .sheets[0] + .bodyData + .length * + 50.r + + 40.r, // width: MediaQuery.of(context).size.width, child: CardList( headList: smallQuestionRes!.data! @@ -611,88 +671,97 @@ class _ReportDetailState extends ConsumerState with CommonMixin { ), ) : NoData(), - if(smallQuestionRes !=null && smallQuestionRes!.data!.bodyExcelData - .sheets[0].bodyData.length > - 0) - Padding( - padding: EdgeInsets.only(right: 14.r,top: 6.r), - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - InkWell( - onTap: () { - setState(() { - if (questionCurrentPage > 1 && questionIsRefresh) { - questionIsRefresh = false; - questionCurrentPage = questionCurrentPage - 1; - getQuestionTable(); - EasyLoading.show(status: 'loading...'); - } - }); - }, - child: Container( - padding: EdgeInsets.symmetric( - vertical: 2.r, horizontal: 5.r), - decoration: BoxDecoration( - border: Border.all( - color: questionCurrentPage == 1 - ? Color(0xFFB3B9B9) - : Color(0xFF6787FD), - width: 1.r), - borderRadius: BorderRadius.all( - Radius.circular(2.r)), - ), - child: Text( - '上一页', - style: TextStyle( - color: questionCurrentPage == 1 - ? Color(0xFFB3B9B9) - : Color(0xFF6787FD)), - ), - ) - ), - SizedBox( - width: 15.r, - ), - InkWell( - onTap: () { - setState(() { - if (questionCurrentPage < totalPage && - questionIsRefresh) { - questionIsRefresh = false; - questionCurrentPage = questionCurrentPage + 1; - getQuestionTable(); - EasyLoading.show(status: 'loading...'); - } - }); - }, - child: Container( - padding: EdgeInsets.symmetric( - vertical: 2.r, horizontal: 5.r), - decoration: BoxDecoration( - border: Border.all( - color: questionTotalPage - questionCurrentPage > 0 - ? Color(0xFF6787FD) - : Color(0xFFB3B9B9), - width: 1.r), - borderRadius: BorderRadius.all( - Radius.circular(2.r)), - ), - child: Text( - '下一页', - style: TextStyle( - color: questionTotalPage - questionCurrentPage > 0 - ? Color(0xFF6787FD) - : Color(0xFFB3B9B9)), - ), - ) - ) - ], + if (smallQuestionRes != null && + smallQuestionRes!.data!.bodyExcelData + .sheets[0].bodyData.length > + 0) + Padding( + padding: + EdgeInsets.only(right: 14.r, top: 6.r), + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + InkWell( + onTap: () { + setState(() { + if (questionCurrentPage > 1 && + questionIsRefresh) { + questionIsRefresh = false; + questionCurrentPage = + questionCurrentPage - 1; + getQuestionTable(); + EasyLoading.show( + status: 'loading...'); + } + }); + }, + child: Container( + padding: EdgeInsets.symmetric( + vertical: 2.r, horizontal: 5.r), + decoration: BoxDecoration( + border: Border.all( + color: + questionCurrentPage == 1 + ? Color(0xFFB3B9B9) + : Color(0xFF6787FD), + width: 1.r), + borderRadius: BorderRadius.all( + Radius.circular(2.r)), + ), + child: Text( + '上一页', + style: TextStyle( + color: + questionCurrentPage == 1 + ? Color(0xFFB3B9B9) + : Color(0xFF6787FD)), + ), + )), + SizedBox( + width: 15.r, + ), + InkWell( + onTap: () { + setState(() { + if (questionCurrentPage < + totalPage && + questionIsRefresh) { + questionIsRefresh = false; + questionCurrentPage = + questionCurrentPage + 1; + getQuestionTable(); + EasyLoading.show( + status: 'loading...'); + } + }); + }, + child: Container( + padding: EdgeInsets.symmetric( + vertical: 2.r, horizontal: 5.r), + decoration: BoxDecoration( + border: Border.all( + color: questionTotalPage - + questionCurrentPage > + 0 + ? Color(0xFF6787FD) + : Color(0xFFB3B9B9), + width: 1.r), + borderRadius: BorderRadius.all( + Radius.circular(2.r)), + ), + child: Text( + '下一页', + style: TextStyle( + color: questionTotalPage - + questionCurrentPage > + 0 + ? Color(0xFF6787FD) + : Color(0xFFB3B9B9)), + ), + )) + ], + ), ), - ), - - - Padding( padding: EdgeInsets.symmetric( vertical: 10.r, horizontal: 10.r), @@ -704,13 +773,11 @@ class _ReportDetailState extends ConsumerState with CommonMixin { fontWeight: FontWeight.w500), ), ), - knowPointRes!.data!.knowPointList.length > - 0 + knowPointRes!.data!.knowPointList.length > 0 ? SizedBox( height: 300.r, child: KnowPointTable( - knowPointRes! - .data!.knowPointList), + knowPointRes!.data!.knowPointList), ) : NoData(), /* knowPointRes!.data!.knowPointList.length > @@ -737,7 +804,7 @@ class _ReportDetailState extends ConsumerState with CommonMixin { ), if (cardBodyList.length > 0) Padding( - padding: EdgeInsets.only(right: 14.r,top: 6.r), + padding: EdgeInsets.only(right: 14.r, top: 6.r), child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ diff --git a/marking_app/lib/pages/report_detail/widgets/card_table.dart b/marking_app/lib/pages/report_detail/widgets/card_table.dart index d362e61..d860f95 100644 --- a/marking_app/lib/pages/report_detail/widgets/card_table.dart +++ b/marking_app/lib/pages/report_detail/widgets/card_table.dart @@ -1,6 +1,7 @@ import 'package:data_table_2/data_table_2.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:flutter_widget_from_html_core/flutter_widget_from_html_core.dart'; class CardList extends StatefulWidget { final List headList; @@ -9,6 +10,7 @@ class CardList extends StatefulWidget { final bool? isScore; final int? fixedRows; final int? fixedCols; + final bool? isHtml; const CardList({ Key? key, @@ -16,6 +18,7 @@ class CardList extends StatefulWidget { required this.bodyList, this.showCardDetail, this.isScore = false, + this.isHtml = false, this.fixedCols, this.fixedRows, }) : super(key: key); @@ -74,7 +77,9 @@ class _CardListState extends State { : Center( child: Padding( padding: EdgeInsets.symmetric(horizontal: 5.r), - child: Text(item.toString(), + child: + widget.isHtml == true?HtmlWidget(item.toString(),textStyle: TextStyle(fontSize: 12.sp,color: Color(0xFF262626)),): + Text(item.toString(), style: TextStyle(fontSize: 12.sp, color: Color(0xFF262626))), ), @@ -114,7 +119,7 @@ class _CardListState extends State { headingRowDecoration: BoxDecoration(color: Color(0xFFF0F3FF)), fixedColumnsColor: Color(0xFFF0F3FF), fixedCornerColor: Colors.grey[400], - minWidth: 70.r * widget.headList.length + 10.r, + minWidth: widget.headList.length > 5?70.r * widget.headList.length + 10.r:MediaQuery.of(context).size.width, fixedTopRows: widget.fixedRows!, fixedLeftColumns: widget.fixedCols!, sortColumnIndex: _sortColumnIndex, @@ -128,7 +133,7 @@ class _CardListState extends State { style: TextStyle(fontSize: 12.sp, color: Color(0xFF505767))), ), // size: ColumnSize.S, - fixedWidth: index == 0 && widget.isScore == false?50.r:70.r, + fixedWidth: index == 0 && widget.isScore == false?50.r:widget.headList.length > 5 ?70.r:(MediaQuery.of(context).size.width - 28.r)/widget.headList.length, ); }), rows: List.generate(widget.bodyList.length, diff --git a/marking_app/lib/pages/report_detail/widgets/report_card_dialog.dart b/marking_app/lib/pages/report_detail/widgets/report_card_dialog.dart index 519aed7..a142e72 100644 --- a/marking_app/lib/pages/report_detail/widgets/report_card_dialog.dart +++ b/marking_app/lib/pages/report_detail/widgets/report_card_dialog.dart @@ -68,7 +68,7 @@ class _ReportCardDialogState extends ConsumerState if(res.data!=null){ examOrigin = res.data!.examOriginPapers[0]; examOriginList = res.data!.examOriginPapers; - print('examOrigin!.width=${examOrigin!.width}'); + // print('examOrigin!.width=${examOrigin!.width}'); }else{ examOriginList = []; examOrigin = null; diff --git a/marking_app/lib/pages/reports/index.dart b/marking_app/lib/pages/reports/index.dart index 382a845..9baebd1 100644 --- a/marking_app/lib/pages/reports/index.dart +++ b/marking_app/lib/pages/reports/index.dart @@ -213,7 +213,7 @@ class _TheReportState extends ConsumerState @override Widget build(BuildContext context) { super.build(context); //调用super.build(返回值始终返回null,应将其忽略) - + final userState = ref.watch(userProvider); return AnnotatedRegion( value: const SystemUiOverlayStyle( systemNavigationBarColor: Color(0xFF000000), @@ -274,7 +274,7 @@ class _TheReportState extends ConsumerState height: 22.w, ), Text( - '远轩高级中学', + userState.schoolName, style: TextStyle( fontSize: 14.sp, color: Color.fromRGBO(62, 86, 173, 1)),