对接接口:根据问卷id查询问卷详情

hmxc
张萌 4 years ago
parent bba0d4e52c
commit e208d398df

@ -157,6 +157,9 @@ class _Manager {
///applist
String get questionnaireList => '/user/questionnaire/list';
///id
String get questionnairefindById => '/user/questionnaire/findById';
}
class _Community {

@ -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';

@ -14,3 +14,27 @@ extension WidgetListExt on List<Widget> {
});
}
}
extension OddListExt<T> on List<T> {
List<T> oddList() {
List<T> _newList = [];
this.forEach((element) {
if (this.indexOf(element).isEven) {
_newList.add(element);
}
});
return _newList;
}
}
extension EvenListExt<T> on List<T> {
List<T> evenList() {
List<T> _newList = [];
this.forEach((element) {
if (this.indexOf(element).isOdd) {
_newList.add(element);
}
});
return _newList;
}
}

@ -0,0 +1,142 @@
class QuestionnaireDetialModel {
int id;
String title;
String description;
String beginDate;
String endDate;
List<QuestionnaireTopicVoList> questionnaireTopicVoList;
List<VoResourcesImgList> voResourcesImgList;
QuestionnaireDetialModel(
{this.id,
this.title,
this.description,
this.beginDate,
this.endDate,
this.questionnaireTopicVoList,
this.voResourcesImgList});
QuestionnaireDetialModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
title = json['title'];
description = json['description'];
beginDate = json['beginDate'];
endDate = json['endDate'];
if (json['questionnaireTopicVoList'] != null) {
questionnaireTopicVoList = new List<QuestionnaireTopicVoList>();
json['questionnaireTopicVoList'].forEach((v) {
questionnaireTopicVoList.add(new QuestionnaireTopicVoList.fromJson(v));
});
}
if (json['voResourcesImgList'] != null) {
voResourcesImgList = new List<VoResourcesImgList>();
json['voResourcesImgList'].forEach((v) {
voResourcesImgList.add(new VoResourcesImgList.fromJson(v));
});
}else voResourcesImgList=[];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
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> questionnaireChoiceVoList;
QuestionnaireTopicVoList(
{this.id, this.type, this.topic, this.questionnaireChoiceVoList});
QuestionnaireTopicVoList.fromJson(Map<String, dynamic> json) {
id = json['id'];
type = json['type'];
topic = json['topic'];
if (json['questionnaireChoiceVoList'] != null) {
questionnaireChoiceVoList = new List<QuestionnaireChoiceVoList>();
json['questionnaireChoiceVoList'].forEach((v) {
questionnaireChoiceVoList
.add(new QuestionnaireChoiceVoList.fromJson(v));
});
}else questionnaireChoiceVoList=[];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
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<String, dynamic> json) {
id = json['id'];
options = json['options'];
answer = json['answer'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
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<String, dynamic> json) {
url = json['url'];
size = json['size'];
longs = json['longs'];
paragraph = json['paragraph'];
sort = json['sort'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['url'] = this.url;
data['size'] = this.size;
data['longs'] = this.longs;
data['paragraph'] = this.paragraph;
data['sort'] = this.sort;
return data;
}
}

@ -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<QuestionnaireDetialModel> questionnairefindById(int id) async {
BaseModel baseModel = await NetUtil().get(
API.manager.questionnairefindById,
params: {
'questionnaireId': id,
},
showMessage: false,
);
return QuestionnaireDetialModel.fromJson(baseModel.data);
}
}

@ -100,7 +100,7 @@ class _BeeListViewState<T> extends State<BeeListView> {
params: _params,
);
_models = widget.convert(_model);
widget.controller.resetLoadState();
// widget.controller.resetLoadState(); TODO:
setState(() {});
},
firstRefresh: true,

@ -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<QuestionnaireDetailPage> {
return Container();
}
Widget _singleCheck(String title, List<QuestionnaireChoiceVoList> 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: <Widget>[
...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<QuestionnaireDetailPage> {
onRefresh: () async {
_model = await ManagerFunc.questionnairefindById(widget.id);
_onload = false;
setState(() {});
},
child: _onload
? _emptyWidget()
@ -53,13 +91,24 @@ class _QuestionnaireDetailPageState extends State<QuestionnaireDetailPage> {
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)
],
),
),

Loading…
Cancel
Save