From 310ca9a353adf909524f3531e19b518f76ed1098 Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Mon, 25 Jan 2021 15:59:59 +0800 Subject: [PATCH 1/2] add fixed detail model --- lib/model/manager/fixed_detail_model.dart | 88 +++++++++++ lib/pages/manager_func.dart | 12 ++ lib/pages/things_page/fixed_submit_page.dart | 119 ++++++++------- .../things_page/widget/fixed_detail_page.dart | 142 ++++++++++++++++++ lib/widget/bee_divider.dart | 10 +- 5 files changed, 309 insertions(+), 62 deletions(-) create mode 100644 lib/model/manager/fixed_detail_model.dart create mode 100644 lib/pages/things_page/widget/fixed_detail_page.dart diff --git a/lib/model/manager/fixed_detail_model.dart b/lib/model/manager/fixed_detail_model.dart new file mode 100644 index 00000000..3f2a14f7 --- /dev/null +++ b/lib/model/manager/fixed_detail_model.dart @@ -0,0 +1,88 @@ +class FixedDetailModel { + AppReportRepairVo appReportRepairVo; + List appProcessRecordVo; + List appMaintenanceResultVo; //暂无用 待修改 + List appDispatchListVo; //暂无用 待修改 + + FixedDetailModel( + {this.appReportRepairVo, + this.appProcessRecordVo, + this.appMaintenanceResultVo, + this.appDispatchListVo}); + + FixedDetailModel.fromJson(Map json) { + appReportRepairVo = json['appReportRepairVo'] != null + ? new AppReportRepairVo.fromJson(json['appReportRepairVo']) + : null; + if (json['appProcessRecordVo'] != null) { + appProcessRecordVo = new List(); + json['appProcessRecordVo'].forEach((v) { + appProcessRecordVo.add(new AppProcessRecordVo.fromJson(v)); + }); + } + appMaintenanceResultVo = json['appMaintenanceResultVo'].cast(); + appDispatchListVo = json['appDispatchListVo'].cast(); + } + + Map toJson() { + final Map data = new Map(); + if (this.appReportRepairVo != null) { + data['appReportRepairVo'] = this.appReportRepairVo.toJson(); + } + if (this.appProcessRecordVo != null) { + data['appProcessRecordVo'] = + this.appProcessRecordVo.map((v) => v.toJson()).toList(); + } + data['appMaintenanceResultVo'] = this.appMaintenanceResultVo; + data['appDispatchListVo'] = this.appDispatchListVo; + return data; + } +} + +class AppReportRepairVo { + int id; + int type; + int status; + String reportDetail; + List imgUrls; + + AppReportRepairVo( + {this.id, this.type, this.status, this.reportDetail, this.imgUrls}); + + AppReportRepairVo.fromJson(Map json) { + id = json['id']; + type = json['type']; + status = json['status']; + reportDetail = json['reportDetail']; + imgUrls = json['imgUrls'].cast(); + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['type'] = this.type; + data['status'] = this.status; + data['reportDetail'] = this.reportDetail; + data['imgUrls'] = this.imgUrls; + return data; + } +} + +class AppProcessRecordVo { + String operationDate; + int operationType; + + AppProcessRecordVo({this.operationDate, this.operationType}); + + AppProcessRecordVo.fromJson(Map json) { + operationDate = json['operationDate']; + operationType = json['operationType']; + } + + Map toJson() { + final Map data = new Map(); + data['operationDate'] = this.operationDate; + data['operationType'] = this.operationType; + return data; + } +} diff --git a/lib/pages/manager_func.dart b/lib/pages/manager_func.dart index 08ba4b5c..9a7754b6 100644 --- a/lib/pages/manager_func.dart +++ b/lib/pages/manager_func.dart @@ -1,5 +1,6 @@ import 'package:akuCommunity/constants/api.dart'; +import 'package:akuCommunity/model/manager/fixed_detail_model.dart'; import 'package:akuCommunity/utils/network/base_model.dart'; import 'package:akuCommunity/utils/network/net_util.dart'; import 'package:flustars/flustars.dart'; @@ -44,4 +45,15 @@ class ManagerFunc { ); return baseModel; } + + static Future reportRepairFindBYLD(int id) async{ + BaseModel baseModel = await NetUtil().post( + API.manager.reportRepairFindBYLD, + params: { + 'repairId':id, + }, + showMessage: false, + ); + return FixedDetailModel.fromJson(baseModel.data); + } } diff --git a/lib/pages/things_page/fixed_submit_page.dart b/lib/pages/things_page/fixed_submit_page.dart index cac0cd42..f10d26d2 100644 --- a/lib/pages/things_page/fixed_submit_page.dart +++ b/lib/pages/things_page/fixed_submit_page.dart @@ -5,6 +5,7 @@ import 'package:akuCommunity/pages/manager_func.dart'; import 'package:akuCommunity/pages/things_page/widget/add_fixed_submit_page.dart'; import 'package:akuCommunity/pages/things_page/widget/bee_list_view.dart'; import 'package:akuCommunity/pages/things_page/widget/fixed_check_box.dart'; +import 'package:akuCommunity/pages/things_page/widget/fixed_detail_page.dart'; import 'package:akuCommunity/provider/user_provider.dart'; import 'package:akuCommunity/utils/bee_map.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; @@ -82,64 +83,70 @@ class _FixedSubmitPageState extends State { bottom: 0, duration: Duration(milliseconds: 300), curve: Curves.easeInOutCubic, - child: Container( - width: 686.w, - decoration: BoxDecoration( - color: kForeGroundColor, borderRadius: BorderRadius.circular(8.w)), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.fromLTRB(24.w, 24.w, 24.w, 0), - child: Row( - children: [ - BeeMap() - .fixTag[model.type] - .text - .color(ktextPrimary) - .bold - .size(32.sp) - .make(), - Spacer(), - BeeMap() - .fixState[model.status] - .text - .color(_getColor(model.status)) - .size(24.sp) - .make(), - ], + child: GestureDetector( + onTap: () { + FixedDetailPage(model.id).to(); + }, + child: Container( + width: 686.w, + decoration: BoxDecoration( + color: kForeGroundColor, + borderRadius: BorderRadius.circular(8.w)), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.fromLTRB(24.w, 24.w, 24.w, 0), + child: Row( + children: [ + BeeMap() + .fixTag[model.type] + .text + .color(ktextPrimary) + .bold + .size(32.sp) + .make(), + Spacer(), + BeeMap() + .fixState[model.status] + .text + .color(_getColor(model.status)) + .size(24.sp) + .make(), + ], + ), ), - ), - 24.hb, - Padding( - padding: EdgeInsets.symmetric( - horizontal: 24.w, + 24.hb, + Padding( + padding: EdgeInsets.symmetric( + horizontal: 24.w, + ), + child: Divider( + thickness: 1.w, + height: 0, + ), ), - child: Divider( - thickness: 1.w, - height: 0, + 24.hb, + Padding( + padding: EdgeInsets.symmetric( + horizontal: 24.w, + ), + child: model.reportDetail.text + .color(ktextSubColor) + .size(28.sp) + .ellipsis + .make(), ), - ), - 24.hb, - Padding( - padding: EdgeInsets.symmetric( - horizontal: 24.w, + // 16.hb, + Padding( + padding: EdgeInsets.only(left: 8.w), + child: model.imgUrls.length != 0 + ? HorizontalImageView(List.generate(model.imgUrls.length, + (index) => model.imgUrls[index].url)) + : SizedBox(), ), - child: model.reportDetail.text - .color(ktextSubColor) - .size(28.sp) - .ellipsis - .make(), - ), - // 16.hb, - Padding( - padding: EdgeInsets.only(left: 8.w), - child: model.imgUrls.length != 0 - ? HorizontalImageView(List.generate(model.imgUrls.length, - (index) => model.imgUrls[index].url)) - : SizedBox(), - ), - ], + ], + ), ), ), ); @@ -179,8 +186,8 @@ class _FixedSubmitPageState extends State { .bold .isIntrinsic .make(), - onPressed: () async{ - await ManagerFunc.reportRepairDelete(_selected); + onPressed: () async { + await ManagerFunc.reportRepairDelete(_selected); Get.back(); _selected.clear(); _easyRefreshController.callRefresh(); diff --git a/lib/pages/things_page/widget/fixed_detail_page.dart b/lib/pages/things_page/widget/fixed_detail_page.dart new file mode 100644 index 00000000..d77f1d34 --- /dev/null +++ b/lib/pages/things_page/widget/fixed_detail_page.dart @@ -0,0 +1,142 @@ +import 'package:akuCommunity/base/base_style.dart'; +import 'package:akuCommunity/model/manager/fixed_detail_model.dart'; +import 'package:akuCommunity/pages/manager_func.dart'; +import 'package:akuCommunity/utils/bee_map.dart'; +import 'package:akuCommunity/widget/bee_divider.dart'; +import 'package:akuCommunity/widget/bee_scaffold.dart'; +import 'package:akuCommunity/widget/horizontal_image_view.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:velocity_x/velocity_x.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:akuCommunity/utils/headers.dart'; + +class FixedDetailPage extends StatefulWidget { + final int id; + FixedDetailPage( + this.id, { + Key key, + }) : super(key: key); + + @override + _FixedDetailPageState createState() => _FixedDetailPageState(); +} + +class _FixedDetailPageState extends State { + EasyRefreshController _easyRefreshController; + FixedDetailModel _model; + Color _getColor(int state) { + switch (state) { + case 1: + case 2: + case 3: + return kDarkPrimaryColor; + case 4: + case 5: + case 6: + case 7: + return ktextSubColor; + default: + return kDangerColor; + } + } + + Widget _buildHead(FixedDetailModel model) { + return Container( + child: Column( + children: [ + Padding( + padding: EdgeInsets.fromLTRB(28.w, 20.w, 20.w, 24.w), + child: Row( + children: [ + '报修信息'.text.black.size(32.sp).bold.make(), + 8.widthBox, + Container( + padding: + EdgeInsets.symmetric(horizontal: 20.w, vertical: 4.w), + decoration: BoxDecoration( + border: Border.all( + color: kPrimaryColor, + width: 2.w, + ), + borderRadius: BorderRadius.circular(36.w), + color: Colors.transparent, + ), + child: BeeMap() + .fixTag[model.appReportRepairVo.type] + .text + .black + .size(20.sp) + .make(), + ), + Spacer(), + BeeMap() + .fixState[model.appReportRepairVo.status] + .text + .color(_getColor(_model.appReportRepairVo.status)) + .size(24.sp) + .bold + .make() + ], + ), + ), + BeeDivider.horizontal( + indent: 24.w, + endIndent: 20.w, + ), + 24.heightBox, + Padding( + padding: EdgeInsets.symmetric(horizontal: 28.w), + child: model.appReportRepairVo.reportDetail.text.black + .size(28.sp) + .maxLines(8) + .overflow(TextOverflow.ellipsis) + .make(), + ), + Padding( + padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 8.w), + child: HorizontalImageView(model.appReportRepairVo.imgUrls), + ) + ], + ), + ); + } + + @override + Widget build(BuildContext context) { + return BeeScaffold( + title: '报事报修', + body: Column( + children: [ + EasyRefresh( + firstRefresh: true, + controller: _easyRefreshController, + onRefresh: () async { + _model = await ManagerFunc.reportRepairFindBYLD(widget.id); + }, + child: ListView( + padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 36.w), + children: [ + _buildHead(_model), + ].sepWidget(separate: 16.heightBox), + ), + ).expand(), + Padding( + padding: EdgeInsets.only( + bottom: MediaQuery.of(context).padding.bottom + 39.w), + child: MaterialButton( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(48.w)), + color: kPrimaryColor, + padding: EdgeInsets.symmetric(horizontal: 278.w, vertical: 26.w), + elevation: 0, + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + onPressed: () {}, + child: '确认完成'.text.black.size(32.sp).bold.make(), + ), + ) + ], + ), + ); + } +} diff --git a/lib/widget/bee_divider.dart b/lib/widget/bee_divider.dart index 29aa5236..db072e2c 100644 --- a/lib/widget/bee_divider.dart +++ b/lib/widget/bee_divider.dart @@ -16,17 +16,15 @@ class BeeDivider extends StatelessWidget { this.isHorizontal}) : super(key: key); BeeDivider.horizontal({ - Key key, - }) : indent = 0, - endIndent = 0, + Key key, this.indent, this.endIndent, + }) : thickness = 1.w, color = Color(0xFFE8E8E8), isHorizontal = true, super(key: key); BeeDivider.vertical({ - Key key, - }) : indent = 0, - endIndent = 0, + Key key, this.indent, this.endIndent, + }) : thickness = 1.w, color = Color(0xFFE8E8E8), isHorizontal = false, From 5420ad4058ea40d8f0be21cfc4b681bc96607223 Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Mon, 25 Jan 2021 18:26:29 +0800 Subject: [PATCH 2/2] update fixed detail page --- lib/model/manager/fixed_detail_model.dart | 92 +++++++++++++++-- lib/pages/manager_func.dart | 13 ++- .../things_page/widget/fixed_detail_page.dart | 98 ++++++++++++------- 3 files changed, 154 insertions(+), 49 deletions(-) diff --git a/lib/model/manager/fixed_detail_model.dart b/lib/model/manager/fixed_detail_model.dart index 3f2a14f7..c3975c6e 100644 --- a/lib/model/manager/fixed_detail_model.dart +++ b/lib/model/manager/fixed_detail_model.dart @@ -1,8 +1,8 @@ class FixedDetailModel { AppReportRepairVo appReportRepairVo; List appProcessRecordVo; - List appMaintenanceResultVo; //暂无用 待修改 - List appDispatchListVo; //暂无用 待修改 + Null appMaintenanceResultVo; + List appDispatchListVo; FixedDetailModel( {this.appReportRepairVo, @@ -20,8 +20,13 @@ class FixedDetailModel { appProcessRecordVo.add(new AppProcessRecordVo.fromJson(v)); }); } - appMaintenanceResultVo = json['appMaintenanceResultVo'].cast(); - appDispatchListVo = json['appDispatchListVo'].cast(); + appMaintenanceResultVo = json['appMaintenanceResultVo']; + if (json['appDispatchListVo'] != null) { + appDispatchListVo = new List(); + json['appDispatchListVo'].forEach((v) { + appDispatchListVo.add(new AppDispatchListVo.fromJson(v)); + }); + } } Map toJson() { @@ -34,7 +39,10 @@ class FixedDetailModel { this.appProcessRecordVo.map((v) => v.toJson()).toList(); } data['appMaintenanceResultVo'] = this.appMaintenanceResultVo; - data['appDispatchListVo'] = this.appDispatchListVo; + if (this.appDispatchListVo != null) { + data['appDispatchListVo'] = + this.appDispatchListVo.map((v) => v.toJson()).toList(); + } return data; } } @@ -44,7 +52,7 @@ class AppReportRepairVo { int type; int status; String reportDetail; - List imgUrls; + List imgUrls; AppReportRepairVo( {this.id, this.type, this.status, this.reportDetail, this.imgUrls}); @@ -54,7 +62,12 @@ class AppReportRepairVo { type = json['type']; status = json['status']; reportDetail = json['reportDetail']; - imgUrls = json['imgUrls'].cast(); + if (json['imgUrls'] != null) { + imgUrls = new List(); + json['imgUrls'].forEach((v) { + imgUrls.add(new ImgUrls.fromJson(v)); + }); + } } Map toJson() { @@ -63,7 +76,37 @@ class AppReportRepairVo { data['type'] = this.type; data['status'] = this.status; data['reportDetail'] = this.reportDetail; - data['imgUrls'] = this.imgUrls; + if (this.imgUrls != null) { + data['imgUrls'] = this.imgUrls.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class ImgUrls { + String url; + String size; + int longs; + int paragraph; + int sort; + + ImgUrls({this.url, this.size, this.longs, this.paragraph, this.sort}); + + ImgUrls.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; } } @@ -86,3 +129,36 @@ class AppProcessRecordVo { return data; } } + +class AppDispatchListVo { + int code; + String orderDate; + int type; + String operatorName; + String distributorName; + + AppDispatchListVo( + {this.code, + this.orderDate, + this.type, + this.operatorName, + this.distributorName}); + + AppDispatchListVo.fromJson(Map json) { + code = json['code']; + orderDate = json['orderDate']; + type = json['type']; + operatorName = json['operatorName']; + distributorName = json['distributorName']; + } + + Map toJson() { + final Map data = new Map(); + data['code'] = this.code; + data['orderDate'] = this.orderDate; + data['type'] = this.type; + data['operatorName'] = this.operatorName; + data['distributorName'] = this.distributorName; + return data; + } +} diff --git a/lib/pages/manager_func.dart b/lib/pages/manager_func.dart index 9a7754b6..7ffd970c 100644 --- a/lib/pages/manager_func.dart +++ b/lib/pages/manager_func.dart @@ -1,8 +1,8 @@ - import 'package:akuCommunity/constants/api.dart'; import 'package:akuCommunity/model/manager/fixed_detail_model.dart'; import 'package:akuCommunity/utils/network/base_model.dart'; import 'package:akuCommunity/utils/network/net_util.dart'; +import 'package:dio/dio.dart'; import 'package:flustars/flustars.dart'; class ManagerFunc { @@ -46,14 +46,13 @@ class ManagerFunc { return baseModel; } - static Future reportRepairFindBYLD(int id) async{ - BaseModel baseModel = await NetUtil().post( + static Future reportRepairFindBYLD(int id) async { + Response response = await NetUtil().dio.get( API.manager.reportRepairFindBYLD, - params: { - 'repairId':id, + queryParameters: { + 'repairId': id, }, - showMessage: false, ); - return FixedDetailModel.fromJson(baseModel.data); + return FixedDetailModel.fromJson(response.data); } } diff --git a/lib/pages/things_page/widget/fixed_detail_page.dart b/lib/pages/things_page/widget/fixed_detail_page.dart index d77f1d34..5c78a107 100644 --- a/lib/pages/things_page/widget/fixed_detail_page.dart +++ b/lib/pages/things_page/widget/fixed_detail_page.dart @@ -4,12 +4,13 @@ import 'package:akuCommunity/pages/manager_func.dart'; import 'package:akuCommunity/utils/bee_map.dart'; import 'package:akuCommunity/widget/bee_divider.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; -import 'package:akuCommunity/widget/horizontal_image_view.dart'; +import 'package:akuCommunity/widget/views/horizontal_image_view.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:velocity_x/velocity_x.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:akuCommunity/utils/headers.dart'; +import 'package:akuCommunity/const/resource.dart'; class FixedDetailPage extends StatefulWidget { final int id; @@ -23,6 +24,7 @@ class FixedDetailPage extends StatefulWidget { } class _FixedDetailPageState extends State { + bool _onLoading = true; EasyRefreshController _easyRefreshController; FixedDetailModel _model; Color _getColor(int state) { @@ -43,14 +45,17 @@ class _FixedDetailPageState extends State { Widget _buildHead(FixedDetailModel model) { return Container( + decoration: BoxDecoration( + color: kForeGroundColor, borderRadius: BorderRadius.circular(8.w)), child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: EdgeInsets.fromLTRB(28.w, 20.w, 20.w, 24.w), child: Row( children: [ '报修信息'.text.black.size(32.sp).bold.make(), - 8.widthBox, + 8.w.widthBox, Container( padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 4.w), @@ -84,7 +89,7 @@ class _FixedDetailPageState extends State { indent: 24.w, endIndent: 20.w, ), - 24.heightBox, + 24.w.heightBox, Padding( padding: EdgeInsets.symmetric(horizontal: 28.w), child: model.appReportRepairVo.reportDetail.text.black @@ -95,47 +100,72 @@ class _FixedDetailPageState extends State { ), Padding( padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 8.w), - child: HorizontalImageView(model.appReportRepairVo.imgUrls), + child: HorizontalImageView( + model.appReportRepairVo.imgUrls.map((e) => e.url).toList()), ) ], ), ); } + Widget _buildEmpty() { + return Container(); + } + +Widget _reparCard(){ + return Container( + padding: EdgeInsets.symmetric( + horizontal: 28.w, + vertical: 24.w + ), + decoration: BoxDecoration( + color: kForeGroundColor, + borderRadius: BorderRadius.circular(8.w) + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + '维修信息'.text.black.size(32.sp).bold.make(), + 24.w.heightBox, + BeeDivider.horizontal() + ], + ), + ); +} @override Widget build(BuildContext context) { return BeeScaffold( title: '报事报修', - body: Column( - children: [ - EasyRefresh( - firstRefresh: true, - controller: _easyRefreshController, - onRefresh: () async { - _model = await ManagerFunc.reportRepairFindBYLD(widget.id); - }, - child: ListView( - padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 36.w), - children: [ - _buildHead(_model), - ].sepWidget(separate: 16.heightBox), - ), - ).expand(), - Padding( - padding: EdgeInsets.only( - bottom: MediaQuery.of(context).padding.bottom + 39.w), - child: MaterialButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(48.w)), - color: kPrimaryColor, - padding: EdgeInsets.symmetric(horizontal: 278.w, vertical: 26.w), - elevation: 0, - materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, - onPressed: () {}, - child: '确认完成'.text.black.size(32.sp).bold.make(), - ), - ) - ], + body: EasyRefresh( + firstRefresh: true, + controller: _easyRefreshController, + onRefresh: () async { + _model = await ManagerFunc.reportRepairFindBYLD(widget.id); + _onLoading = false; + }, + header: MaterialHeader(), + child: _onLoading + ? _buildEmpty() + : ListView( + padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 36.w), + children: [ + _buildHead(_model), + ].sepWidget(separate: 16.w.heightBox), + ), + ), + bottomNavi: Padding( + padding: EdgeInsets.only( + bottom: MediaQuery.of(context).padding.bottom + 39.w), + child: MaterialButton( + shape: + RoundedRectangleBorder(borderRadius: BorderRadius.circular(48.w)), + color: kPrimaryColor, + padding: EdgeInsets.symmetric(horizontal: 278.w, vertical: 26.w), + elevation: 0, + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + onPressed: () {}, + child: '确认完成'.text.black.size(32.sp).bold.make(), + ), ), ); }