From cad5108bd05a4f0c4b2359604d2ebc5d05808753 Mon Sep 17 00:00:00 2001 From: datang Date: Mon, 9 May 2022 11:33:55 +0800 Subject: [PATCH] =?UTF-8?q?=E9=97=AE=E5=8D=B7=E8=B0=83=E6=9F=A5=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E6=B7=BB=E5=8A=A0=EF=BC=9B=E6=8A=95=E8=AF=89=E8=A1=A8?= =?UTF-8?q?=E6=89=AC=E9=83=A8=E5=88=86=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants/new_api.dart | 17 +++++ lib/constants/saas_api.dart | 17 +++++ lib/model/manager/advice_detail_model.dart | 64 +++++++------------ lib/model/manager/questinnaire_model.dart | 12 +++- .../manager/questionnaire_detail_model.dart | 18 +++--- lib/pages/manager_func.dart | 6 +- lib/ui/manager/advice/advice_detail_page.dart | 17 ++--- lib/ui/manager/advice/advice_page.dart | 4 +- lib/ui/manager/advice/new_advice_page.dart | 5 +- .../questionnaire_detail_page.dart | 13 ++-- .../questionnaire/questionnaire_page.dart | 22 ++++--- lib/utils/application_utils.dart | 2 - 12 files changed, 117 insertions(+), 80 deletions(-) create mode 100644 lib/constants/new_api.dart diff --git a/lib/constants/new_api.dart b/lib/constants/new_api.dart new file mode 100644 index 00000000..fa79237f --- /dev/null +++ b/lib/constants/new_api.dart @@ -0,0 +1,17 @@ +class NEWAPI { + ///HOST + static const String host = 'http://127.0.0.1:8006'; + + ///接口基础地址 + static const String baseURL = '$host'; + //根分类 + static _Questionnaire questionnaire = _Questionnaire(); +} +class _Questionnaire { + ///查询所有的问卷调查 + String get list => '/app/user/questionnaire/list'; + ///根据问卷主键id查询问卷详情 + String get detail => '/app/user/questionnaire/findById'; + ///问卷调查提交 + String get submit => '/app/user/questionnaire/submit'; +} \ No newline at end of file diff --git a/lib/constants/saas_api.dart b/lib/constants/saas_api.dart index e87e8f3e..659efe11 100644 --- a/lib/constants/saas_api.dart +++ b/lib/constants/saas_api.dart @@ -40,6 +40,7 @@ class SAASAPI { static _CommunityIntroduce communityIntroduce = _CommunityIntroduce(); static _ConveniencePhone conveniencePhone = _ConveniencePhone(); static _CommitteeStaff committeeStaff = _CommitteeStaff(); + static _Advice advice = _Advice(); ///二级分类 static _ProfileApi profile = _ProfileApi(); @@ -356,4 +357,20 @@ class _ConveniencePhone { class _CommitteeStaff { ///查询业委会列表 String get list => '/app/user/industryCommittee/list'; +} +class _Advice{ + ///查询所有投诉的列表 + String get list => '/app/user/advice/list'; + ///添加建议咨询/投诉表扬 信息 + String get insert => '/app/user/advice/insert'; + ///根据咨询建议/投诉表扬主键id 查询 咨询建议/投诉表扬信息 + String get find => '/app/user/advice/findById'; + ///继续提问 + String get reQuestion => '/app/user/advice/reQuestion'; + ///完成反馈 + String get complete => '/app/user/advice/complete'; + ///评价 + String get evaluate => '/app/user/advice/evaluate'; + ///批量删除咨询建议/投诉表扬信息 + String get delete => '/app/user/advice/delete'; } \ No newline at end of file diff --git a/lib/model/manager/advice_detail_model.dart b/lib/model/manager/advice_detail_model.dart index 1ea5e6c9..6e73b5c4 100644 --- a/lib/model/manager/advice_detail_model.dart +++ b/lib/model/manager/advice_detail_model.dart @@ -3,79 +3,62 @@ import 'package:common_utils/common_utils.dart'; import 'package:aku_new_community/model/common/img_model.dart'; class AdviceDetailModel { - AppAdviceDetailVo? appAdviceDetailVo; + AppAdviceFBIDetailVo? appAdviceFBIDetailVo; + List? appAdviceFBIContentVos; - AdviceDetailModel({this.appAdviceDetailVo}); + AdviceDetailModel({this.appAdviceFBIDetailVo, this.appAdviceFBIContentVos}); AdviceDetailModel.fromJson(Map json) { - appAdviceDetailVo = json['appAdviceDetailVo'] != null - ? new AppAdviceDetailVo.fromJson(json['appAdviceDetailVo']) + appAdviceFBIDetailVo = json['appAdviceFBIDetailVo'] != null + ? new AppAdviceFBIDetailVo.fromJson(json['appAdviceFBIDetailVo']) : null; - } - - Map toJson() { - final Map data = new Map(); - if (this.appAdviceDetailVo != null) { - data['appAdviceDetailVo'] = this.appAdviceDetailVo!.toJson(); - } - return data; - } -} - -class AppAdviceDetailVo { - AppAdviceVo? appAdviceVo; - List? appAdviceContentVos; - - AppAdviceDetailVo({this.appAdviceVo, this.appAdviceContentVos}); - - AppAdviceDetailVo.fromJson(Map json) { - appAdviceVo = json['appAdviceVo'] != null - ? new AppAdviceVo.fromJson(json['appAdviceVo']) - : null; - if (json['appAdviceContentVos'] != null) { - appAdviceContentVos = []; - json['appAdviceContentVos'].forEach((v) { - appAdviceContentVos!.add(new AppAdviceContentVos.fromJson(v)); + if (json['appAdviceFBIContentVos'] != null) { + appAdviceFBIContentVos = []; + json['appAdviceFBIContentVos'].forEach((v) { + appAdviceFBIContentVos!.add(new AppAdviceFBIContentVos.fromJson(v)); }); } } Map toJson() { final Map data = new Map(); - if (this.appAdviceVo != null) { - data['appAdviceVo'] = this.appAdviceVo!.toJson(); + if (this.appAdviceFBIDetailVo != null) { + data['appAdviceFBIDetailVo'] = this.appAdviceFBIDetailVo!.toJson(); } - if (this.appAdviceContentVos != null) { - data['appAdviceContentVos'] = - this.appAdviceContentVos!.map((v) => v.toJson()).toList(); + if (this.appAdviceFBIContentVos != null) { + data['appAdviceFBIContentVos'] = + this.appAdviceFBIContentVos!.map((v) => v.toJson()).toList(); } return data; } } -class AppAdviceVo { +class AppAdviceFBIDetailVo { int? id; int? type; int? status; String? content; + int? score; String? createDate; List? imgUrls; DateTime? get date => DateUtil.getDateTime(createDate!); - AppAdviceVo( + AppAdviceFBIDetailVo( {this.id, this.type, this.status, this.content, + this.score, this.createDate, this.imgUrls}); - AppAdviceVo.fromJson(Map json) { + AppAdviceFBIDetailVo.fromJson(Map json) { id = json['id']; type = json['type']; status = json['status']; content = json['content']; + score = json['score']; createDate = json['createDate']; if (json['imgUrls'] != null) { imgUrls = []; @@ -91,6 +74,7 @@ class AppAdviceVo { data['type'] = this.type; data['status'] = this.status; data['content'] = this.content; + data['score'] = this.score; data['createDate'] = this.createDate; if (this.imgUrls != null) { data['imgUrls'] = this.imgUrls!.map((v) => v.toJson()).toList(); @@ -99,14 +83,14 @@ class AppAdviceVo { } } -class AppAdviceContentVos { +class AppAdviceFBIContentVos { int? id; int? createUserType; String? content; String? createDate; int? parentId; - AppAdviceContentVos( + AppAdviceFBIContentVos( {this.id, this.createUserType, this.content, @@ -115,7 +99,7 @@ class AppAdviceContentVos { DateTime? get date => DateUtil.getDateTime(createDate!); - AppAdviceContentVos.fromJson(Map json) { + AppAdviceFBIContentVos.fromJson(Map json) { id = json['id']; createUserType = json['createUserType']; content = json['content']; diff --git a/lib/model/manager/questinnaire_model.dart b/lib/model/manager/questinnaire_model.dart index 33e79eee..9a64ac11 100644 --- a/lib/model/manager/questinnaire_model.dart +++ b/lib/model/manager/questinnaire_model.dart @@ -10,6 +10,8 @@ class QuestionnaireModel { int? answerNum; List? imgUrls; List? headImgURls; + bool? answered; + bool? allowAnswer; QuestionnaireModel( {this.id, @@ -20,7 +22,10 @@ class QuestionnaireModel { this.status, this.answerNum, this.imgUrls, - this.headImgURls}); + this.headImgURls, + this.answered, + this.allowAnswer, + }); QuestionnaireModel.fromJson(Map json) { id = json['id']; @@ -44,6 +49,9 @@ class QuestionnaireModel { }); } else headImgURls = []; + answered = json['answered']; + allowAnswer = json['allowAnswer']; + } Map toJson() { @@ -61,6 +69,8 @@ class QuestionnaireModel { if (this.headImgURls != null) { data['headImgURls'] = this.headImgURls!.map((v) => v.toJson()).toList(); } + data['answered']=this.answered; + data['allowAnswer']=this.allowAnswer; return data; } } diff --git a/lib/model/manager/questionnaire_detail_model.dart b/lib/model/manager/questionnaire_detail_model.dart index 7556322a..6136971c 100644 --- a/lib/model/manager/questionnaire_detail_model.dart +++ b/lib/model/manager/questionnaire_detail_model.dart @@ -24,15 +24,15 @@ class QuestionnaireDetialModel { description = json['description']; beginDate = json['beginDate']; endDate = json['endDate']; - if (json['questionnaireTopicVoList'] != null) { + if (json['appQuestionnaireFBITopicVoList'] != null) { questionnaireTopicVoList = []; - json['questionnaireTopicVoList'].forEach((v) { + json['appQuestionnaireFBITopicVoList'].forEach((v) { questionnaireTopicVoList!.add(new QuestionnaireTopicVoList.fromJson(v)); }); } - if (json['voResourcesImgList'] != null) { + if (json['imgList'] != null) { voResourcesImgList = []; - json['voResourcesImgList'].forEach((v) { + json['imgList'].forEach((v) { voResourcesImgList!.add(new ImgModel.fromJson(v)); }); } else @@ -47,11 +47,11 @@ class QuestionnaireDetialModel { data['beginDate'] = this.beginDate; data['endDate'] = this.endDate; if (this.questionnaireTopicVoList != null) { - data['questionnaireTopicVoList'] = + data['appQuestionnaireFBITopicVoList'] = this.questionnaireTopicVoList!.map((v) => v.toJson()).toList(); } if (this.voResourcesImgList != null) { - data['voResourcesImgList'] = + data['imgList'] = this.voResourcesImgList!.map((v) => v.toJson()).toList(); } return data; @@ -71,9 +71,9 @@ class QuestionnaireTopicVoList { id = json['id']; type = json['type']; topic = json['topic']; - if (json['questionnaireChoiceVoList'] != null) { + if (json['appQuestionnaireFBITopicChoiceVoList'] != null) { questionnaireChoiceVoList = []; - json['questionnaireChoiceVoList'].forEach((v) { + json['appQuestionnaireFBITopicChoiceVoList'].forEach((v) { questionnaireChoiceVoList! .add(new QuestionnaireChoiceVoList.fromJson(v)); }); @@ -87,7 +87,7 @@ class QuestionnaireTopicVoList { data['type'] = this.type; data['topic'] = this.topic; if (this.questionnaireChoiceVoList != null) { - data['questionnaireChoiceVoList'] = + data['appQuestionnaireFBITopicChoiceVoList'] = this.questionnaireChoiceVoList!.map((v) => v.toJson()).toList(); } else questionnaireChoiceVoList = []; diff --git a/lib/pages/manager_func.dart b/lib/pages/manager_func.dart index cfdc7612..c311d0d4 100644 --- a/lib/pages/manager_func.dart +++ b/lib/pages/manager_func.dart @@ -1,4 +1,6 @@ import 'package:aku_new_community/constants/api.dart'; +import 'package:aku_new_community/constants/new_api.dart'; +import 'package:aku_new_community/constants/saas_api.dart'; import 'package:aku_new_community/model/manager/article_QR_code_model.dart'; import 'package:aku_new_community/model/manager/moving_company_model.dart'; import 'package:aku_new_community/model/manager/questionnaire_detail_model.dart'; @@ -229,7 +231,7 @@ class ManagerFunc { static Future questionnairefindById(int? id) async { BaseModel baseModel = await NetUtil().get( - API.manager.questionnairefindById, + NEWAPI.questionnaire.detail, params: { 'questionnaireId': id, }, @@ -241,7 +243,7 @@ class ManagerFunc { static Future questionnaireSubmit( int? id, List model) async { BaseModel baseModel = await NetUtil().post( - API.manager.questionnaireSubmit, + NEWAPI.questionnaire.submit, params: { 'id': id, 'appQuestionnaireAnswerSubmits': model, diff --git a/lib/ui/manager/advice/advice_detail_page.dart b/lib/ui/manager/advice/advice_detail_page.dart index 8634d63f..3abb7dce 100644 --- a/lib/ui/manager/advice/advice_detail_page.dart +++ b/lib/ui/manager/advice/advice_detail_page.dart @@ -91,7 +91,7 @@ class _AdviceDetailPageState extends State { ); } - _buildAdviceContent(AppAdviceContentVos item) { + _buildAdviceContent(AppAdviceFBIContentVos item) { String type = ''; switch (item.createUserType) { case 1: @@ -127,13 +127,14 @@ class _AdviceDetailPageState extends State { children: [ '您的$adviceValue'.text.black.bold.size(38.sp).make(), 30.hb, - _model.appAdviceDetailVo!.appAdviceVo!.content!.text + _model.appAdviceFBIDetailVo!.content! + .text .color(ktextSubColor) .size(28.sp) .make(), 24.hb, DateUtil.formatDate( - _model.appAdviceDetailVo!.appAdviceVo!.date, + _model.appAdviceFBIDetailVo!.date, format: 'yyyy年MM月dd日 HH:mm', ).text.size(24.sp).color(Color(0xFF999999)).make(), ...widget.model!.imgUrls!.isEmpty @@ -154,7 +155,7 @@ class _AdviceDetailPageState extends State { color: Color(0xFFD8D8D8), ) ], - ..._model.appAdviceDetailVo!.appAdviceContentVos! + ..._model.appAdviceFBIContentVos! .map((e) => _buildAdviceContent(e)) .toList(), ], @@ -186,10 +187,10 @@ class _AdviceDetailPageState extends State { header: MaterialHeader(), onRefresh: () async { Response res = await NetUtil().dio!.get( - API.manager.adviceDetail, + SAASAPI.advice.find, queryParameters: {'adviceId': widget.model!.id}, ); - _model = AdviceDetailModel.fromJson(res.data); + _model = AdviceDetailModel.fromJson(res.data['data']); _loading = false; if (mounted) setState(() {}); }, @@ -219,7 +220,7 @@ class _AdviceDetailPageState extends State { child: BottomButton( onPressed: () async { BaseModel baseModel = - await NetUtil().get(API.manager.completeFeedBack, params: { + await NetUtil().get(SAASAPI.advice.complete, params: { "adviceId": widget.model!.id, }); if (baseModel.success) { @@ -229,7 +230,7 @@ class _AdviceDetailPageState extends State { }, child: '完成沟通'.text.bold.make(), ), - ) + ), ], ); } diff --git a/lib/ui/manager/advice/advice_page.dart b/lib/ui/manager/advice/advice_page.dart index bdd5d8e6..a2cd326c 100644 --- a/lib/ui/manager/advice/advice_page.dart +++ b/lib/ui/manager/advice/advice_page.dart @@ -111,7 +111,7 @@ class _AdvicePageState extends State with TickerProviderStateMixin { controller: _tabController, children: List.generate(2, (index) { return BeeListView( - path: API.manager.advice, + path: SAASAPI.advice.list, extraParams: {'adviceType': adviceValue(index)}, controller: _refreshController, convert: (model) => model.rows @@ -168,7 +168,7 @@ class _AdvicePageState extends State with TickerProviderStateMixin { firstChild: BottomButton( onPressed: () async { await NetUtil().post( - API.manager.deleteAdvice, + SAASAPI.advice.delete, params: {'ids': _selectedItems}, showMessage: true, ); diff --git a/lib/ui/manager/advice/new_advice_page.dart b/lib/ui/manager/advice/new_advice_page.dart index 40552b8c..d94a7732 100644 --- a/lib/ui/manager/advice/new_advice_page.dart +++ b/lib/ui/manager/advice/new_advice_page.dart @@ -11,7 +11,6 @@ import 'package:provider/provider.dart'; import 'package:velocity_x/velocity_x.dart'; import 'package:aku_new_community/const/resource.dart'; -import 'package:aku_new_community/constants/api.dart'; import 'package:aku_new_community/constants/app_theme.dart'; import 'package:aku_new_community/constants/saas_api.dart'; import 'package:aku_new_community/provider/app_provider.dart'; @@ -97,9 +96,9 @@ class _NewAdvicePageState extends State { Future addAdvice(int type, List files, String content) async { VoidCallback cancel = BotToast.showLoading(); List urls = - await NetUtil().uploadFiles(files, API.upload.uploadAdvice); + await NetUtil().uploadFiles(files,SAASAPI.uploadFile.uploadImg); BaseModel baseModel = await NetUtil().post( - API.manager.addAdvice, + SAASAPI.advice.insert, params: { 'type': type, 'content': content, diff --git a/lib/ui/manager/questionnaire/questionnaire_detail_page.dart b/lib/ui/manager/questionnaire/questionnaire_detail_page.dart index 5411d410..89f7d6ba 100644 --- a/lib/ui/manager/questionnaire/questionnaire_detail_page.dart +++ b/lib/ui/manager/questionnaire/questionnaire_detail_page.dart @@ -14,6 +14,7 @@ import 'package:aku_new_community/utils/network/base_model.dart'; import 'package:aku_new_community/widget/bee_divider.dart'; import 'package:aku_new_community/widget/bee_scaffold.dart'; import 'package:aku_new_community/widget/buttons/bottom_button.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; @@ -21,9 +22,9 @@ import 'package:get/get.dart'; class QuestionnaireDetailPage extends StatefulWidget { final int? id; - final int? status; + final bool? answered; - QuestionnaireDetailPage({Key? key, this.id, this.status}) : super(key: key); + QuestionnaireDetailPage({Key? key, this.id, this.answered}) : super(key: key); @override _QuestionnaireDetailPageState createState() => @@ -258,12 +259,14 @@ class _QuestionnaireDetailPageState extends State { bottomNavi: BottomButton( child: '确认提交' .text - .color(widget.status != 2 ? ktextSubColor : ktextPrimary) + .color(widget.answered! ? ktextSubColor : ktextPrimary) .size(32.sp) .bold .make(), - onPressed: widget.status != 2 - ? () {} + onPressed: widget.answered != 2 + ? () { + BotToast.showText(text: '该问卷已填写过'); + } : () async { BaseModel baseModel = await ManagerFunc.questionnaireSubmit( widget.id, _submitModels); diff --git a/lib/ui/manager/questionnaire/questionnaire_page.dart b/lib/ui/manager/questionnaire/questionnaire_page.dart index 29d6e5e5..cad4282b 100644 --- a/lib/ui/manager/questionnaire/questionnaire_page.dart +++ b/lib/ui/manager/questionnaire/questionnaire_page.dart @@ -1,5 +1,6 @@ import 'package:aku_new_community/base/base_style.dart'; import 'package:aku_new_community/constants/api.dart'; +import 'package:aku_new_community/constants/new_api.dart'; import 'package:aku_new_community/constants/saas_api.dart'; import 'package:aku_new_community/model/common/img_model.dart'; import 'package:aku_new_community/model/manager/questinnaire_model.dart'; @@ -10,6 +11,7 @@ import 'package:aku_new_community/utils/hive_store.dart'; import 'package:aku_new_community/utils/websocket/tips_dialog.dart'; import 'package:aku_new_community/widget/bee_scaffold.dart'; import 'package:aku_new_community/widget/others/stack_avatar.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:common_utils/common_utils.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; @@ -40,12 +42,11 @@ class _QuestionnairePageState extends State { String _getButtonText(int? status) { switch (status) { case 1: + return '未开始'; case 2: - return '去投票'; + return '进行中'; case 3: return '已结束'; - case 4: - return '已投票'; default: return ''; } @@ -54,10 +55,14 @@ class _QuestionnairePageState extends State { Widget _buildCard(QuestionnaireModel model) { return GestureDetector( onTap: () { - Get.to(() => QuestionnaireDetailPage( - id: model.id, - status: model.status, - )); + if(model.status==2){ + Get.to(() => QuestionnaireDetailPage( + id: model.id, + answered: model.answered, + )); + }else{ + BotToast.showText(text: '该问卷已结束或未开始'); + } }, child: Container( decoration: BoxDecoration( @@ -142,6 +147,7 @@ class _QuestionnairePageState extends State { if (model.status == 2) { Get.to(() => QuestionnaireDetailPage( id: model.id, + answered: model.answered, )); } }, @@ -171,7 +177,7 @@ class _QuestionnairePageState extends State { return BeeScaffold( title: '问卷调查', body: BeeListView( - path: API.manager.questionnaireList, + path: NEWAPI.questionnaire.list, controller: _easyRefreshController, convert: (model) { return model.rows diff --git a/lib/utils/application_utils.dart b/lib/utils/application_utils.dart index d8d40ce5..49a56e57 100644 --- a/lib/utils/application_utils.dart +++ b/lib/utils/application_utils.dart @@ -101,8 +101,6 @@ class ApplicationUtil { title: '投诉表扬', imgPath: Assets.newIcon.icTsby.path, onTap: () { - BotToast.showText(text: '此功能暂未上线'); - return; Get.to(() => AdvicePage(type: AdviceType.COMPLAIN)); }), AppElement(