diff --git a/lib/const/api.dart b/lib/const/api.dart index 98e1200..490bf3e 100644 --- a/lib/const/api.dart +++ b/lib/const/api.dart @@ -212,6 +212,12 @@ class _Manage { ///管家app钥匙管理:查询所有的申请记录(包含条件搜索) String get keyRecordList => '/user/key/record'; + + ///管家app绿化管理:查询所有的绿化管理 + String get greenManageList => '/user/green/list'; + + ///管家app绿化管理:确认完成 + String get greenManageComplete => '/user/green/complete'; } class _Upload { diff --git a/lib/models/manager/green_manage/green_manage_list_model.dart b/lib/models/manager/green_manage/green_manage_list_model.dart new file mode 100644 index 0000000..7efbdb1 --- /dev/null +++ b/lib/models/manager/green_manage/green_manage_list_model.dart @@ -0,0 +1,82 @@ +import 'package:common_utils/common_utils.dart'; +import 'package:flutter/material.dart'; + +class GreenManageListModel { + int id; + String greenAreaName; + String content; + String directorName; + int status; + String completeDate; + String endDate; + String createDate; + + GreenManageListModel( + {this.id, + this.greenAreaName, + this.content, + this.directorName, + this.status, + this.completeDate, + this.endDate, + this.createDate}); + + GreenManageListModel.fromJson(Map json) { + id = json['id']; + greenAreaName = json['greenAreaName']; + 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['greenAreaName'] = this.greenAreaName; + 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 statusString { + switch (this.status) { + case 1: + return '待处理'; + case 2: + return '已完成'; + case 3: + return '未完成'; + default: + return '未知'; + } + } + + Color get statusColor { + switch (this.status) { + case 1: + return Color(0xFFFF8200); + case 2: + return Color(0xFF999999); + case 3: + return Color(0xFFE60E0E); + default: + Colors.black; + } + } + + 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/green_manage/green_manage_card.dart b/lib/ui/manage_pages/green_manage/green_manage_card.dart index 07f42f6..90aba86 100644 --- a/lib/ui/manage_pages/green_manage/green_manage_card.dart +++ b/lib/ui/manage_pages/green_manage/green_manage_card.dart @@ -1,4 +1,9 @@ // Flutter imports: +import 'package:aku_community_manager/const/api.dart'; +import 'package:aku_community_manager/models/manager/green_manage/green_manage_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: @@ -15,7 +20,10 @@ import 'package:aku_community_manager/ui/manage_pages/green_manage/green_manage_ class GreenManageCard extends StatefulWidget { final int index; - GreenManageCard({Key key, this.index}) : super(key: key); + final GreenManageListModel model; + final VoidCallback callRefresh; + GreenManageCard({Key key, this.index, this.model, this.callRefresh}) + : super(key: key); @override _GreenManageCardState createState() => _GreenManageCardState(); @@ -41,17 +49,17 @@ class _GreenManageCardState extends State { child: Row( children: [ Text( - 'cardModel.title', + widget.model.greenAreaName, style: TextStyle( color: AppStyle.primaryTextColor, fontSize: 32.w, fontWeight: FontWeight.bold), ), Spacer(), - GreenManageMap.statusString(widget.index + 1) + GreenManageMap.statusString(widget.model.status) .text .size(28.sp) - .color(GreenManageMap.statusColor(widget.index + 1)) + .color(GreenManageMap.statusColor(widget.model.status)) .bold .make(), ], @@ -76,7 +84,7 @@ class _GreenManageCardState extends State { )), Spacer(), Text( - 'cardModel.task', + widget.model.content, style: AppStyle().primaryStyle, ), ], @@ -96,7 +104,7 @@ class _GreenManageCardState extends State { )), Spacer(), Text( - 'cardModel.name', + widget.model.directorName, style: AppStyle().primaryStyle, ), ], @@ -114,7 +122,7 @@ class _GreenManageCardState extends State { color: AppStyle.primaryTextColor, fontSize: 28.sp)), Spacer(), Text( - '${'cardModel.timestart'}至${'cardModel.timeend'}', + '${widget.model.createDateString}至${widget.model.endDateString}', style: AppStyle().primaryStyle, ), ], @@ -128,7 +136,7 @@ class _GreenManageCardState extends State { } List _buttomButtons() { - return widget.index != 0 + return widget.model.status != 1 ? [SizedBox()] : [ 40.w.heightBox, @@ -148,7 +156,16 @@ class _GreenManageCardState extends State { .color(kTextPrimaryColor) .bold .make(), - onPressed: () {}, + onPressed: () async { + BaseModel baseModel = await NetUtil() + .post(API.manage.greenManageComplete, params: { + "id": widget.model.id, + }); + if (baseModel.status) { + widget.callRefresh(); + } + BotToast.showText(text: baseModel.message); + }, ) ], ) diff --git a/lib/ui/manage_pages/green_manage/green_manage_view.dart b/lib/ui/manage_pages/green_manage/green_manage_view.dart index 0f48590..49fbd12 100644 --- a/lib/ui/manage_pages/green_manage/green_manage_view.dart +++ b/lib/ui/manage_pages/green_manage/green_manage_view.dart @@ -1,8 +1,14 @@ // Flutter imports: +import 'package:aku_community_manager/const/api.dart'; +import 'package:aku_community_manager/models/manager/green_manage/green_manage_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/green_manage/green_manage_card.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:velocity_x/velocity_x.dart'; class GreenManageView extends StatefulWidget { final int index; @@ -13,14 +19,48 @@ class GreenManageView extends StatefulWidget { } class _GreenManageViewState 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: [ - GreenManageCard( - index: widget.index, - ) - ], - ); + return BeeListView( + path: API.manage.greenManageList, + extraParams: { + "greenStatus": widget.index + 1, + }, + controller: _refreshController, + convert: (models) { + return models.tableList + .map((e) => GreenManageListModel.fromJson(e)) + .toList(); + }, + builder: (items) { + return ListView.separated( + padding: EdgeInsets.all(24.w), + itemBuilder: (contex, index) { + return GreenManageCard( + index: widget.index, + model: items[index], + callRefresh: () { + _refreshController.callRefresh(); + }, + ); + }, + separatorBuilder: (_, __) { + return 24.w.heightBox; + }, + itemCount: items.length); + }); } } diff --git a/lib/ui/manage_pages/key_manage/key_apply_record_page.dart b/lib/ui/manage_pages/key_manage/key_apply_record_page.dart index ea7191c..b00d382 100644 --- a/lib/ui/manage_pages/key_manage/key_apply_record_page.dart +++ b/lib/ui/manage_pages/key_manage/key_apply_record_page.dart @@ -18,7 +18,7 @@ class KeyApplyRecordPage extends StatefulWidget { class _KeyApplyRecordPageState extends State with TickerProviderStateMixin { - List _tabs = [ '审核中', '已通过', '已驳回','已归还']; + List _tabs = ['全部', '审核中', '已通过', '已驳回','已归还']; TabController _tabController; @override void initState() { diff --git a/lib/ui/manage_pages/key_manage/key_apply_record_view.dart b/lib/ui/manage_pages/key_manage/key_apply_record_view.dart index 5026b1f..fc380cb 100644 --- a/lib/ui/manage_pages/key_manage/key_apply_record_view.dart +++ b/lib/ui/manage_pages/key_manage/key_apply_record_view.dart @@ -39,6 +39,9 @@ class _KeyApplyRecordViewState extends State Widget build(BuildContext context) { return BeeListView( path: API.manage.keyRecordList, + extraParams: { + "recordStatus": widget.index == 0 ? null : widget.index, + }, controller: _refreshController, convert: (models) { return models.tableList @@ -47,7 +50,7 @@ class _KeyApplyRecordViewState extends State }, builder: (items) { return ListView.separated( - padding: EdgeInsets.all(24.w), + padding: EdgeInsets.all(24.w), itemBuilder: (context, index) { return KeyApplyRecordCard( index: widget.index,