From e208d398df50a315fc2ce01a6d177d6f680a038f Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Sun, 7 Feb 2021 15:15:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E6=8E=A5=E5=8F=A3=EF=BC=9A?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E9=97=AE=E5=8D=B7id=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E9=97=AE=E5=8D=B7=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants/api.dart | 3 + lib/constants/application_objects.dart | 3 +- lib/extensions/widget_list_ext.dart | 24 +++ .../manager/questionnaire_detail_model.dart | 142 ++++++++++++++++++ lib/pages/manager_func.dart | 12 ++ .../things_page/widget/bee_list_view.dart | 2 +- .../questionnaire_detail_page.dart | 51 ++++++- 7 files changed, 233 insertions(+), 4 deletions(-) create mode 100644 lib/model/manager/questionnaire_detail_model.dart diff --git a/lib/constants/api.dart b/lib/constants/api.dart index e84fca38..a0c6854e 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -157,6 +157,9 @@ class _Manager { ///问卷调查:app查询所有的问卷调查list String get questionnaireList => '/user/questionnaire/list'; + + ///问卷调查:根据问卷id查询问卷详情 + String get questionnairefindById => '/user/questionnaire/findById'; } class _Community { diff --git a/lib/constants/application_objects.dart b/lib/constants/application_objects.dart index 811ca7f1..28f882e8 100644 --- a/lib/constants/application_objects.dart +++ b/lib/constants/application_objects.dart @@ -1,5 +1,5 @@ // Flutter imports: -import 'package:akuCommunity/pages/questionnaire_page/questionnaire_page.dart'; +import 'package:akuCommunity/ui/manager/questionnaire/questionnaire_page.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; @@ -15,7 +15,6 @@ import 'package:akuCommunity/pages/life_pay/life_pay_page.dart'; import 'package:akuCommunity/pages/one_alarm/widget/alarm_page.dart'; import 'package:akuCommunity/pages/open_door_page/open_door_page.dart'; import 'package:akuCommunity/pages/opening_code_page/opening_code_page.dart'; -import 'package:akuCommunity/pages/questionnaire_page/questionnaire_details_page/questionnaire_details_page.dart'; import 'package:akuCommunity/pages/things_page/fixed_submit_page.dart'; import 'package:akuCommunity/pages/visitor_access_page/visitor_access_page.dart'; import 'package:akuCommunity/ui/home/application/all_application.dart'; diff --git a/lib/extensions/widget_list_ext.dart b/lib/extensions/widget_list_ext.dart index 03daa608..cbb1e8d6 100644 --- a/lib/extensions/widget_list_ext.dart +++ b/lib/extensions/widget_list_ext.dart @@ -14,3 +14,27 @@ extension WidgetListExt on List { }); } } + +extension OddListExt on List { + List oddList() { + List _newList = []; + this.forEach((element) { + if (this.indexOf(element).isEven) { + _newList.add(element); + } + }); + return _newList; + } +} + +extension EvenListExt on List { + List evenList() { + List _newList = []; + this.forEach((element) { + if (this.indexOf(element).isOdd) { + _newList.add(element); + } + }); + return _newList; + } +} diff --git a/lib/model/manager/questionnaire_detail_model.dart b/lib/model/manager/questionnaire_detail_model.dart new file mode 100644 index 00000000..0c9c17d2 --- /dev/null +++ b/lib/model/manager/questionnaire_detail_model.dart @@ -0,0 +1,142 @@ +class QuestionnaireDetialModel { + int id; + String title; + String description; + String beginDate; + String endDate; + List questionnaireTopicVoList; + List voResourcesImgList; + + QuestionnaireDetialModel( + {this.id, + this.title, + this.description, + this.beginDate, + this.endDate, + this.questionnaireTopicVoList, + this.voResourcesImgList}); + + QuestionnaireDetialModel.fromJson(Map json) { + id = json['id']; + title = json['title']; + description = json['description']; + beginDate = json['beginDate']; + endDate = json['endDate']; + if (json['questionnaireTopicVoList'] != null) { + questionnaireTopicVoList = new List(); + json['questionnaireTopicVoList'].forEach((v) { + questionnaireTopicVoList.add(new QuestionnaireTopicVoList.fromJson(v)); + }); + } + if (json['voResourcesImgList'] != null) { + voResourcesImgList = new List(); + json['voResourcesImgList'].forEach((v) { + voResourcesImgList.add(new VoResourcesImgList.fromJson(v)); + }); + }else voResourcesImgList=[]; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['title'] = this.title; + data['description'] = this.description; + data['beginDate'] = this.beginDate; + data['endDate'] = this.endDate; + if (this.questionnaireTopicVoList != null) { + data['questionnaireTopicVoList'] = + this.questionnaireTopicVoList.map((v) => v.toJson()).toList(); + } + if (this.voResourcesImgList != null) { + data['voResourcesImgList'] = + this.voResourcesImgList.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class QuestionnaireTopicVoList { + int id; + int type; + String topic; + List questionnaireChoiceVoList; + + QuestionnaireTopicVoList( + {this.id, this.type, this.topic, this.questionnaireChoiceVoList}); + + QuestionnaireTopicVoList.fromJson(Map json) { + id = json['id']; + type = json['type']; + topic = json['topic']; + if (json['questionnaireChoiceVoList'] != null) { + questionnaireChoiceVoList = new List(); + json['questionnaireChoiceVoList'].forEach((v) { + questionnaireChoiceVoList + .add(new QuestionnaireChoiceVoList.fromJson(v)); + }); + }else questionnaireChoiceVoList=[]; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['type'] = this.type; + data['topic'] = this.topic; + if (this.questionnaireChoiceVoList != null) { + data['questionnaireChoiceVoList'] = + this.questionnaireChoiceVoList.map((v) => v.toJson()).toList(); + }else questionnaireChoiceVoList=[]; + return data; + } +} + +class QuestionnaireChoiceVoList { + int id; + String options; + String answer; + + QuestionnaireChoiceVoList({this.id, this.options, this.answer}); + + QuestionnaireChoiceVoList.fromJson(Map json) { + id = json['id']; + options = json['options']; + answer = json['answer']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['options'] = this.options; + data['answer'] = this.answer; + return data; + } +} + +class VoResourcesImgList { + String url; + String size; + int longs; + int paragraph; + int sort; + + VoResourcesImgList( + {this.url, this.size, this.longs, this.paragraph, this.sort}); + + VoResourcesImgList.fromJson(Map json) { + url = json['url']; + size = json['size']; + longs = json['longs']; + paragraph = json['paragraph']; + sort = json['sort']; + } + + Map toJson() { + final Map data = new Map(); + data['url'] = this.url; + data['size'] = this.size; + data['longs'] = this.longs; + data['paragraph'] = this.paragraph; + data['sort'] = this.sort; + return data; + } +} diff --git a/lib/pages/manager_func.dart b/lib/pages/manager_func.dart index 1e79cee7..f281175f 100644 --- a/lib/pages/manager_func.dart +++ b/lib/pages/manager_func.dart @@ -1,6 +1,7 @@ // Package imports: import 'package:akuCommunity/model/manager/article_QR_code_model.dart'; import 'package:akuCommunity/model/manager/moving_company_model.dart'; +import 'package:akuCommunity/model/manager/questionnaire_detail_model.dart'; import 'package:akuCommunity/model/manager/voting_detail_model.dart'; import 'package:dio/dio.dart'; import 'package:flustars/flustars.dart'; @@ -182,4 +183,15 @@ class ManagerFunc { }); return baseModel; } + + static Future questionnairefindById(int id) async { + BaseModel baseModel = await NetUtil().get( + API.manager.questionnairefindById, + params: { + 'questionnaireId': id, + }, + showMessage: false, + ); + return QuestionnaireDetialModel.fromJson(baseModel.data); + } } diff --git a/lib/pages/things_page/widget/bee_list_view.dart b/lib/pages/things_page/widget/bee_list_view.dart index 12a878c7..8dfed6ca 100644 --- a/lib/pages/things_page/widget/bee_list_view.dart +++ b/lib/pages/things_page/widget/bee_list_view.dart @@ -100,7 +100,7 @@ class _BeeListViewState extends State { params: _params, ); _models = widget.convert(_model); - widget.controller.resetLoadState(); + // widget.controller.resetLoadState(); TODO:待解决 setState(() {}); }, firstRefresh: true, diff --git a/lib/ui/manager/questionnaire/questionnaire_detail_page.dart b/lib/ui/manager/questionnaire/questionnaire_detail_page.dart index dd90ed6b..3ae5731f 100644 --- a/lib/ui/manager/questionnaire/questionnaire_detail_page.dart +++ b/lib/ui/manager/questionnaire/questionnaire_detail_page.dart @@ -3,6 +3,7 @@ import 'package:akuCommunity/constants/api.dart'; import 'package:akuCommunity/model/manager/questionnaire_detail_model.dart'; import 'package:akuCommunity/pages/manager_func.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; +import 'package:akuCommunity/widget/buttons/bee_single_check.dart'; import 'package:akuCommunity/widget/buttons/bottom_button.dart'; import 'package:flutter/material.dart'; import 'package:akuCommunity/utils/headers.dart'; @@ -25,6 +26,42 @@ class _QuestionnaireDetailPageState extends State { return Container(); } + Widget _singleCheck(String title, List answers) { + return Container( + width: double.infinity, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + title.text.black.size(32.sp).bold.make(), + 64.w.heightBox, + Flex( + direction: Axis.horizontal, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ...answers.oddList().map((e){ + return Row( + children: [ + BeeSingleCheck( + value: e.id, + groupValue: , + ), + ], + ); + }).toList(), + ].sepWidget(separate: 48.w.heightBox), + ).expand(flex: 1), + Column( + children: [], + ).expand(flex: 1), + ], + ) + ], + ), + ); + } + @override Widget build(BuildContext context) { return BeeScaffold( @@ -35,6 +72,7 @@ class _QuestionnaireDetailPageState extends State { onRefresh: () async { _model = await ManagerFunc.questionnairefindById(widget.id); _onload = false; + setState(() {}); }, child: _onload ? _emptyWidget() @@ -53,13 +91,24 @@ class _QuestionnaireDetailPageState extends State { image: API.image(_model.voResourcesImgList.first.url)), ), 40.w.heightBox, - _model.title.text.color(ktextPrimary).size(32.sp).bold.make(), + Container( + width: double.infinity, + alignment: Alignment.center, + child: _model.title.text + .color(ktextPrimary) + .size(32.sp) + .bold + .make()), 36.w.heightBox, _model.description.text .color(ktextPrimary) .size(28.sp) .make(), 130.w.heightBox, + _singleCheck( + 'title', + _model.questionnaireTopicVoList.first + .questionnaireChoiceVoList) ], ), ),