diff --git a/lib/const/api.dart b/lib/const/api.dart index 490bf3e..497d6cf 100644 --- a/lib/const/api.dart +++ b/lib/const/api.dart @@ -218,6 +218,12 @@ class _Manage { ///管家app绿化管理:确认完成 String get greenManageComplete => '/user/green/complete'; + + ///管家app卫生管理:查询所有的卫生管理 + String get hygienceList => '/user/hygiene/list'; + + ///管家app卫生管理:确认完成 + String get hygienceComplete => '/user/hygiene/complete'; } class _Upload { diff --git a/lib/models/manager/hygience_manage/heygience_list_model.dart b/lib/models/manager/hygience_manage/heygience_list_model.dart new file mode 100644 index 0000000..9f8c906 --- /dev/null +++ b/lib/models/manager/hygience_manage/heygience_list_model.dart @@ -0,0 +1,54 @@ +import 'package:common_utils/common_utils.dart'; + +class HygienceListModel { + int id; + String hygieneAreaName; + String content; + String directorName; + int status; + String completeDate; + String endDate; + String createDate; + + HygienceListModel( + {this.id, + this.hygieneAreaName, + this.content, + this.directorName, + this.status, + this.completeDate, + this.endDate, + this.createDate}); + + HygienceListModel.fromJson(Map json) { + id = json['id']; + hygieneAreaName = json['hygieneAreaName']; + content = json['content']; + directorName = json['directorName']; + status = json['status']; + completeDate = json['completeDate']; + endDate = json['endDate']; + createDate = json['createDate']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['hygieneAreaName'] = this.hygieneAreaName; + data['content'] = this.content; + data['directorName'] = this.directorName; + data['status'] = this.status; + data['completeDate'] = this.completeDate; + data['endDate'] = this.endDate; + data['createDate'] = this.createDate; + return data; + } + String get createDateString => + DateUtil.formatDateStr(this.createDate, format: 'yy-MM-dd HH:mm'); + + String get endDateString => + DateUtil.formatDateStr(this.endDate, format: 'yy-MM-dd HH:mm'); + + String get completeDateString => + DateUtil.formatDateStr(this.completeDate, format: 'yy-MM-dd HH:mm'); +} diff --git a/lib/ui/manage_pages/hygience_manage/hygience_manage_card.dart b/lib/ui/manage_pages/hygience_manage/hygience_manage_card.dart index d7264a9..5358a77 100644 --- a/lib/ui/manage_pages/hygience_manage/hygience_manage_card.dart +++ b/lib/ui/manage_pages/hygience_manage/hygience_manage_card.dart @@ -1,4 +1,9 @@ // Flutter imports: +import 'package:aku_community_manager/const/api.dart'; +import 'package:aku_community_manager/models/manager/hygience_manage/heygience_list_model.dart'; +import 'package:aku_community_manager/utils/network/base_model.dart'; +import 'package:aku_community_manager/utils/network/net_util.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/material.dart'; // Package imports: @@ -14,7 +19,10 @@ import 'package:aku_community_manager/ui/manage_pages/hygience_manage/hygience_m class HyginecManageCard extends StatefulWidget { final int index; - HyginecManageCard({Key key, this.index}) : super(key: key); + final HygienceListModel model; + final VoidCallback callRefresh; + HyginecManageCard({Key key, this.index, this.model, this.callRefresh}) + : super(key: key); @override _HyginecManageCardState createState() => _HyginecManageCardState(); @@ -40,7 +48,7 @@ class _HyginecManageCardState extends State { child: Row( children: [ Text( - 'cardModel.title', + widget.model.hygieneAreaName, style: TextStyle( color: AppStyle.primaryTextColor, fontSize: 32.w, @@ -75,7 +83,7 @@ class _HyginecManageCardState extends State { )), Spacer(), Text( - 'cardModel.task', + widget.model.content, style: AppStyle().primaryStyle, ), ], @@ -95,7 +103,7 @@ class _HyginecManageCardState extends State { )), Spacer(), Text( - 'cardModel.name', + widget.model.directorName, style: AppStyle().primaryStyle, ), ], @@ -113,7 +121,7 @@ class _HyginecManageCardState extends State { color: AppStyle.primaryTextColor, fontSize: 28.sp)), Spacer(), Text( - '${'cardModel.timestart'}至${'cardModel.timeend'}', + '${widget.model.createDateString}至${widget.model.endDateString}', style: AppStyle().primaryStyle, ), ], @@ -147,7 +155,16 @@ class _HyginecManageCardState extends State { .color(kTextPrimaryColor) .bold .make(), - onPressed: () {}, + onPressed: () async { + BaseModel baseModel = await NetUtil() + .post(API.manage.hygienceComplete, params: { + "id": widget.model.id, + }); + if (baseModel.status) { + widget.callRefresh(); + } + BotToast.showText(text: baseModel.message); + }, ) ], ) diff --git a/lib/ui/manage_pages/hygience_manage/hygience_manage_page.dart b/lib/ui/manage_pages/hygience_manage/hygience_manage_page.dart index d9e9261..803de46 100644 --- a/lib/ui/manage_pages/hygience_manage/hygience_manage_page.dart +++ b/lib/ui/manage_pages/hygience_manage/hygience_manage_page.dart @@ -36,7 +36,7 @@ class _HygienceManagePageState extends State @override Widget build(BuildContext context) { return AkuScaffold( - title: '绿化管理', + title: '卫生管理', appBarBottom: PreferredSize( preferredSize: Size.fromHeight(88.w), child: AkuTabBar(controller: _tabController, tabs: _tabs)), diff --git a/lib/ui/manage_pages/hygience_manage/hygience_manage_view.dart b/lib/ui/manage_pages/hygience_manage/hygience_manage_view.dart index 397f1c1..19948a4 100644 --- a/lib/ui/manage_pages/hygience_manage/hygience_manage_view.dart +++ b/lib/ui/manage_pages/hygience_manage/hygience_manage_view.dart @@ -1,8 +1,14 @@ // Flutter imports: +import 'package:aku_community_manager/const/api.dart'; +import 'package:aku_community_manager/models/manager/hygience_manage/heygience_list_model.dart'; +import 'package:aku_community_manager/ui/widgets/common/bee_list_view.dart'; import 'package:flutter/material.dart'; // Project imports: import 'package:aku_community_manager/ui/manage_pages/hygience_manage/hygience_manage_card.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:velocity_x/velocity_x.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; class HygienceManageView extends StatefulWidget { final int index; @@ -13,14 +19,48 @@ class HygienceManageView extends StatefulWidget { } class _HygienceManageViewState extends State { + EasyRefreshController _refreshController; + @override + void initState() { + super.initState(); + _refreshController = EasyRefreshController(); + } + + @override + void dispose() { + _refreshController.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { - return ListView( - children: [ - HyginecManageCard( - index: widget.index, - ) - ], - ); + return BeeListView( + path: API.manage.hygienceList, + controller: _refreshController, + extraParams: { + "hygieneStatus":widget.index+1, + }, + convert: (models) { + return models.tableList + .map((e) => HygienceListModel.fromJson(e)) + .toList(); + }, + builder: (items) { + return ListView.separated( + padding: EdgeInsets.all(24.w), + itemBuilder: (context, index) { + return HyginecManageCard( + index: widget.index, + model: items[index], + callRefresh: () { + _refreshController.callRefresh(); + }, + ); + }, + separatorBuilder: (_, __) { + return 24.w.heightBox; + }, + itemCount: items.length); + }); } }