From acfb84c2c4f2ef1d3fed492b55fab3718493ecf3 Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Mon, 8 Feb 2021 11:41:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E6=8E=A5=E5=8F=A3=EF=BC=9Aap?= =?UTF-8?q?p=E9=97=AE=E5=8D=B7=E8=B0=83=E6=9F=A5=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants/api.dart | 3 ++ .../manager/quetionnaire_submit_model.dart | 48 +++++++++---------- lib/pages/manager_func.dart | 16 +++++++ .../questionnaire_detail_page.dart | 7 ++- 4 files changed, 48 insertions(+), 26 deletions(-) diff --git a/lib/constants/api.dart b/lib/constants/api.dart index a0c6854e..8b62559c 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -160,6 +160,9 @@ class _Manager { ///问卷调查:根据问卷id查询问卷详情 String get questionnairefindById => '/user/questionnaire/findById'; + + ///问卷调查:app问卷调查提交 + String get questionnaireSubmit => '/user/questionnaire/submit'; } class _Community { diff --git a/lib/model/manager/quetionnaire_submit_model.dart b/lib/model/manager/quetionnaire_submit_model.dart index 8219ac8c..d02a097c 100644 --- a/lib/model/manager/quetionnaire_submit_model.dart +++ b/lib/model/manager/quetionnaire_submit_model.dart @@ -1,30 +1,30 @@ -// class QuestionnaireSubmitModel { -// int id; -// List appQuestionnaireAnswerSubmits; +class QuestionnaireSubmitModel { + int id; + List appQuestionnaireAnswerSubmits; -// QuestionnaireSubmitModel({this.id, this.appQuestionnaireAnswerSubmits}); + QuestionnaireSubmitModel({this.id, this.appQuestionnaireAnswerSubmits}); -// QuestionnaireSubmitModel.fromJson(Map json) { -// id = json['id']; -// if (json['appQuestionnaireAnswerSubmits'] != null) { -// appQuestionnaireAnswerSubmits = new List(); -// json['appQuestionnaireAnswerSubmits'].forEach((v) { -// appQuestionnaireAnswerSubmits -// .add(new AppQuestionnaireAnswerSubmits.fromJson(v)); -// }); -// } -// } + QuestionnaireSubmitModel.fromJson(Map json) { + id = json['id']; + if (json['appQuestionnaireAnswerSubmits'] != null) { + appQuestionnaireAnswerSubmits = new List(); + json['appQuestionnaireAnswerSubmits'].forEach((v) { + appQuestionnaireAnswerSubmits + .add(new AppQuestionnaireAnswerSubmits.fromJson(v)); + }); + } + } -// Map toJson() { -// final Map data = new Map(); -// data['id'] = this.id; -// if (this.appQuestionnaireAnswerSubmits != null) { -// data['appQuestionnaireAnswerSubmits'] = -// this.appQuestionnaireAnswerSubmits.map((v) => v.toJson()).toList(); -// } -// return data; -// } -// } + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + if (this.appQuestionnaireAnswerSubmits != null) { + data['appQuestionnaireAnswerSubmits'] = + this.appQuestionnaireAnswerSubmits.map((v) => v.toJson()).toList(); + } + return data; + } +} class AppQuestionnaireAnswerSubmits { int topicId; diff --git a/lib/pages/manager_func.dart b/lib/pages/manager_func.dart index f281175f..01483fa9 100644 --- a/lib/pages/manager_func.dart +++ b/lib/pages/manager_func.dart @@ -1,7 +1,10 @@ // Package imports: +import 'dart:convert'; + 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/quetionnaire_submit_model.dart'; import 'package:akuCommunity/model/manager/voting_detail_model.dart'; import 'package:dio/dio.dart'; import 'package:flustars/flustars.dart'; @@ -194,4 +197,17 @@ class ManagerFunc { ); return QuestionnaireDetialModel.fromJson(baseModel.data); } + + static Future questionnaireSubmit( + int id, List model) async { + BaseModel baseModel = await NetUtil().post( + API.manager.questionnaireSubmit, + params: { + 'id': id, + 'appQuestionnaireAnswerSubmits': jsonEncode(model), + }, + showMessage: true, + ); + return baseModel; + } } diff --git a/lib/ui/manager/questionnaire/questionnaire_detail_page.dart b/lib/ui/manager/questionnaire/questionnaire_detail_page.dart index fb733295..5f57a65f 100644 --- a/lib/ui/manager/questionnaire/questionnaire_detail_page.dart +++ b/lib/ui/manager/questionnaire/questionnaire_detail_page.dart @@ -151,6 +151,7 @@ class _QuestionnaireDetailPageState extends State { answers: questionModel.questionnaireChoiceVoList); case 2: + submitModels[index].choiceAnswer.remove(-1); return QuestionnaireRadioCheck( title: questionModel.topic, selected: submitModels[index].choiceAnswer, @@ -169,7 +170,7 @@ class _QuestionnaireDetailPageState extends State { return _expandedCheck(questionModel.topic, questionModel.questionnaireChoiceVoList, submitModels, index); case 4: - return QuestionnaireTruefalse( + return QuestionnaireTruefalse( title: questionModel.topic, selected: submitModels[index].choiceAnswer.first, onPressed: (id) { @@ -246,7 +247,9 @@ class _QuestionnaireDetailPageState extends State { ), bottomNavi: BottomButton( child: '确认提交'.text.black.size(32.sp).bold.make(), - onPressed: () {}, + onPressed: () async { + await ManagerFunc.questionnaireSubmit(widget.id, _submitModels); + }, ), ); }