diff --git a/lib/const/api.dart b/lib/const/api.dart index b539df0..eca5e5e 100644 --- a/lib/const/api.dart +++ b/lib/const/api.dart @@ -14,6 +14,7 @@ class API { static _Auth auth = _Auth(); static _User user = _User(); static _Manage manage = _Manage(); + static _Upload upload = _Upload(); } class _Auth { @@ -41,8 +42,10 @@ class _User { String get sendTelUpdateCode => '/user/personalData/sendTelUpdateCode'; ///个人资料:根据新手机号发送修改验证码 - String get updateTel =>'/user/personalData/updateTel'; - + String get updateTel => '/user/personalData/updateTel'; + + ///个人资料:修改管家用户头像 + String get updateAvatar => '/user/personalData/updateHeadPortrait'; } class _Manage { @@ -87,4 +90,44 @@ class _Manage { ///报事报修:处理完成 String get handleResult => '/user/repair/handleResult'; + ///借还管理:查询全部物品 + String get borrowList => '/user/borrow/articleList'; + + ///借还管理:根据物品主键id查询所有的物品明细信息 + String get borrowDetailList => '/user/borrow/articleDetailList'; + + ///借还管理:根据物品明细id 查询物品信息 + String get borrowItemDetail => '/user/borrow/findById'; + + ///借还管理:查询所有的借还信息(包含条件搜索) + String get borrowStatusList => '/user/borrow/list'; + + ///借还管理:提醒归还(管理员发送) + String get remindUserReturn => '/user/borrow/remind'; + + ///借还管理:检查信息 + String get borrowCheckInfo => '/user/borrow/checkItems'; + + ///借还管理:提交检查结果 + String get borrowCheck => '/user/borrow/submitCheck'; + + ///借还管理:修改物品明细信息 + String get borrowEdit => '/user/borrow/updateArticleDetail'; + + ///物品出户:查询所有的物品出户信息(包含搜索条件) + String get goodsOutList => '/user/articleOut/list'; + + ///物品出户:根据物品出户主键id查询出户详情 + String get goodsOutDetail => '/user/articleOut/findById'; + + ///物品出户:放行 + String get goodsOutRelease => '/user/articleOut/release'; + + ///物品出户:不放行 + String get goodsOutNotRelease => '/user/articleOut/noRelease'; +} + +class _Upload { + ///上传个人资料头像照片 + String get avatar => '/user/upload/butlerAppHeadSculpture'; } diff --git a/lib/main.dart b/lib/main.dart index 2ef29b6..1455fc8 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -15,7 +15,6 @@ import 'package:aku_community_manager/provider/anouncement_provider.dart'; import 'package:aku_community_manager/provider/app_provider.dart'; import 'package:aku_community_manager/provider/fix_provider.dart'; import 'package:aku_community_manager/provider/manage_provider.dart'; -import 'package:aku_community_manager/provider/outdoor_provider.dart'; import 'package:aku_community_manager/provider/user_provider.dart'; import 'package:aku_community_manager/ui/splash/splash_page.dart'; @@ -58,7 +57,7 @@ class MyApp extends StatelessWidget { ChangeNotifierProvider(create: (context) => FixProvider()), ChangeNotifierProvider(create: (context) => GreenManageProvider()), ChangeNotifierProvider(create: (context) => InspectionManageProvider()), - ChangeNotifierProvider(create: (context) => OutdoorProvider()), + ChangeNotifierProvider(create: (context) => GreenManageProvider()), ChangeNotifierProvider(create: (context) => InspectionManageProvider()), ChangeNotifierProvider(create: (context) => AnouncementProvider()), diff --git a/lib/mock_models/borrow/borrow_data.dart b/lib/mock_models/borrow/borrow_data.dart index 6e00d8e..9b9e45f 100644 --- a/lib/mock_models/borrow/borrow_data.dart +++ b/lib/mock_models/borrow/borrow_data.dart @@ -2,6 +2,8 @@ import 'package:aku_community_manager/const/resource.dart'; import 'package:aku_community_manager/mock_models/borrow/borrow_model.dart'; +//TODO CLEAN BOTTOM CODES. +@Deprecated("borrow_data need to be cleaned.") class BorrowData { static List get checkModels => models.where((e) { return e.borrowGoods.status == BORROW_STATUS.WAIT_CHECK; diff --git a/lib/mock_models/borrow/borrow_model.dart b/lib/mock_models/borrow/borrow_model.dart index 105bd66..909286c 100644 --- a/lib/mock_models/borrow/borrow_model.dart +++ b/lib/mock_models/borrow/borrow_model.dart @@ -24,6 +24,8 @@ enum GOODS_STATUS { LOST, } +//TODO CLEAN BOTTOM CODES. +@Deprecated(" borrow_model need to be cleaned.") class BorrowModel { String borrowPerson; String phone; diff --git a/lib/mock_models/outdoor_models/outdoor_model.dart b/lib/mock_models/outdoor_models/outdoor_model.dart deleted file mode 100644 index 3b864ea..0000000 --- a/lib/mock_models/outdoor_models/outdoor_model.dart +++ /dev/null @@ -1,184 +0,0 @@ -// Flutter imports: -import 'package:flutter/material.dart'; - -// Project imports: -import 'package:aku_community_manager/const/resource.dart'; - -enum OUTDOORSTATUS { - ///待出户 - NOT_OUT, - - ///已出户 - OUT_DONE, - - ///已驳回 - REJECTED, - - ///已作废 - CANCELLATION, -} - -class ItemsOutdoorModel { - ///出户状态 - OUTDOORSTATUS status; - - ///卡片上方时间,即开始时间 - DateTime datetime; - - ///小区名字 - String communityname; - - ///想起地址 - String adress; - - ///出户人 - String name; - - ///身份 - String identify; - - ///物品 - ItemDetails items; - - ///预计出户时间 - String outtime; - - ///实际出户/驳回时间 - String finalOutTime; - - ///出户地点 - String outPlace; - - ///驳回理由 - String rejectReason; - ItemsOutdoorModel({ - @required this.status, - @required this.datetime, - @required this.communityname, - @required this.adress, - @required this.name, - @required this.identify, - @required this.items, - @required this.outtime, - this.finalOutTime, - this.outPlace, - this.rejectReason, - }); - - static List initList() { - return [ - ItemsOutdoorModel( - status: OUTDOORSTATUS.NOT_OUT, - datetime: DateTime(2020, 10, 23, 09, 28, 56), - communityname: '深圳华悦茂峰', - adress: '1幢1单元702室', - name: '马云', - identify: '业主', - items: ItemDetails( - itemname: '家具', - weight: 40, - way: '搬家公司', - imagepath: [ - R.ASSETS_OUTDOOR_ITME1_PNG, - R.ASSETS_OUTDOOR_ITEM2_PNG, - R.ASSETS_OUTDOOR_ITEM3_PNG - ], - ), - outtime: '2020-10-24 12:00', - finalOutTime: '', - outPlace: '', - rejectReason: '', - ), - ItemsOutdoorModel( - status: OUTDOORSTATUS.OUT_DONE, - datetime: DateTime(2020, 10, 23, 09, 28, 56), - communityname: '深圳华悦茂峰', - adress: '1幢1单元702室', - name: '马云', - identify: '业主', - items: ItemDetails( - itemname: '家具', - weight: 60, - way: '搬家公司', - imagepath: [ - R.ASSETS_OUTDOOR_ITME1_PNG, - R.ASSETS_OUTDOOR_ITEM2_PNG, - R.ASSETS_OUTDOOR_ITEM3_PNG - ], - ), - outtime: '2020-10-24 12:00', - finalOutTime: '2020-10-23 11:23:56', - outPlace: '东大门', - rejectReason: ''), - ItemsOutdoorModel( - status: OUTDOORSTATUS.REJECTED, - datetime: DateTime(2020, 10, 23, 09, 28, 56), - communityname: '深圳华悦茂峰', - adress: '1幢1单元702室', - name: '马云', - identify: '业主', - items: ItemDetails( - itemname: '家具', - weight: 80, - way: '搬家公司', - imagepath: [ - R.ASSETS_OUTDOOR_ITME1_PNG, - R.ASSETS_OUTDOOR_ITEM2_PNG, - R.ASSETS_OUTDOOR_ITEM3_PNG - ], - ), - outtime: '2020-10-24 12:00', - finalOutTime: '2020-10-24 12:22:34', - outPlace: '', - rejectReason: '申报物品与实际物品不符', - ), - ItemsOutdoorModel( - status: OUTDOORSTATUS.CANCELLATION, - datetime: DateTime(2020, 10, 23, 09, 28, 56), - communityname: '深圳华悦茂峰', - adress: '1幢1单元702室', - name: '马云', - identify: '业主', - items: ItemDetails( - itemname: '家具', - weight: 120, - way: '搬家公司', - imagepath: [ - R.ASSETS_OUTDOOR_ITME1_PNG, - R.ASSETS_OUTDOOR_ITEM2_PNG, - R.ASSETS_OUTDOOR_ITEM3_PNG - ], - ), - outtime: '2020-10-24 12:00', - finalOutTime: '', - outPlace: '', - rejectReason: '', - ), - ]; - } - - static Map outdoorStatusMap = { - OUTDOORSTATUS.NOT_OUT: '待出户', - OUTDOORSTATUS.OUT_DONE: '已出户', - OUTDOORSTATUS.REJECTED: '已驳回', - OUTDOORSTATUS.CANCELLATION: '已作废', - }; - static Map outdoorStatusStringMap = { - '待出户': OUTDOORSTATUS.NOT_OUT, - '已出户': OUTDOORSTATUS.OUT_DONE, - '已驳回': OUTDOORSTATUS.REJECTED, - '已作废': OUTDOORSTATUS.CANCELLATION, - }; -} - -class ItemDetails { - String itemname; - double weight; - String way; - List imagepath; - ItemDetails( - {@required this.itemname, - @required this.weight, - this.way, - this.imagepath}); -} diff --git a/lib/models/manager/borrow/borrow_check_item_model.dart b/lib/models/manager/borrow/borrow_check_item_model.dart new file mode 100644 index 0000000..12fc6d1 --- /dev/null +++ b/lib/models/manager/borrow/borrow_check_item_model.dart @@ -0,0 +1,47 @@ +import 'package:aku_community_manager/models/common/img_model.dart'; + +class BorrowCheckItemModel { + int id; + int articleDetailId; + String articleName; + String code; + int status; + List imgUrls; + ImgModel get firstImg => imgUrls.isEmpty ? null : imgUrls.first; + + BorrowCheckItemModel( + {this.id, + this.articleDetailId, + this.articleName, + this.code, + this.status, + this.imgUrls}); + + BorrowCheckItemModel.fromJson(Map json) { + id = json['id']; + articleDetailId = json['articleDetailId']; + articleName = json['articleName']; + code = json['code']; + status = json['status']; + if (json['imgUrls'] != null) { + imgUrls = new List(); + json['imgUrls'].forEach((v) { + imgUrls.add(new ImgModel.fromJson(v)); + }); + } else + imgUrls = []; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['articleDetailId'] = this.articleDetailId; + data['articleName'] = this.articleName; + data['code'] = this.code; + data['status'] = this.status; + if (this.imgUrls != null) { + data['imgUrls'] = this.imgUrls.map((v) => v.toJson()).toList(); + } + return data; + } +} diff --git a/lib/models/manager/borrow/borrow_detail_item_model.dart b/lib/models/manager/borrow/borrow_detail_item_model.dart new file mode 100644 index 0000000..9ebee2e --- /dev/null +++ b/lib/models/manager/borrow/borrow_detail_item_model.dart @@ -0,0 +1,39 @@ +import 'package:aku_community_manager/models/common/img_model.dart'; + +class BorrowDetailItemModel { + int id; + String name; + String code; + int borrowStatus; + List imgUrls; + ImgModel get firstImg => imgUrls.isEmpty ? null : imgUrls.first; + bool get borrowed => borrowStatus == 2; + BorrowDetailItemModel( + {this.id, this.name, this.code, this.borrowStatus, this.imgUrls}); + + BorrowDetailItemModel.fromJson(Map json) { + id = json['id']; + name = json['name']; + code = json['code']; + borrowStatus = json['borrowStatus']; + if (json['imgUrls'] != null) { + imgUrls = new List(); + json['imgUrls'].forEach((v) { + imgUrls.add(new ImgModel.fromJson(v)); + }); + } else + imgUrls = []; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['name'] = this.name; + data['code'] = this.code; + data['borrowStatus'] = this.borrowStatus; + if (this.imgUrls != null) { + data['imgUrls'] = this.imgUrls.map((v) => v.toJson()).toList(); + } + return data; + } +} diff --git a/lib/models/manager/borrow/borrow_item_detail_model.dart b/lib/models/manager/borrow/borrow_item_detail_model.dart new file mode 100644 index 0000000..0c5db33 --- /dev/null +++ b/lib/models/manager/borrow/borrow_item_detail_model.dart @@ -0,0 +1,60 @@ +import 'package:aku_community_manager/models/common/img_model.dart'; + +class BorrowItemDetailModel { + int id; + String name; + String code; + int borrowStatus; + int status; + List imgUrls; + ImgModel get firstImg => imgUrls.isEmpty ? null : imgUrls.first; + bool get borrowed => borrowStatus == 2; + String get statusValue { + switch (status) { + case 1: + return '正常'; + case 2: + return '破损'; + case 3: + return '丢失'; + default: + return '未知'; + } + } + + BorrowItemDetailModel( + {this.id, + this.name, + this.code, + this.borrowStatus, + this.status, + this.imgUrls}); + + BorrowItemDetailModel.fromJson(Map json) { + id = json['id']; + name = json['name']; + code = json['code']; + borrowStatus = json['borrowStatus']; + status = json['status']; + if (json['imgUrls'] != null) { + imgUrls = new List(); + json['imgUrls'].forEach((v) { + imgUrls.add(new ImgModel.fromJson(v)); + }); + } else + imgUrls = []; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['name'] = this.name; + data['code'] = this.code; + data['borrowStatus'] = this.borrowStatus; + data['status'] = this.status; + if (this.imgUrls != null) { + data['imgUrls'] = this.imgUrls.map((v) => v.toJson()).toList(); + } + return data; + } +} diff --git a/lib/models/manager/borrow/borrow_item_model.dart b/lib/models/manager/borrow/borrow_item_model.dart new file mode 100644 index 0000000..6bbff25 --- /dev/null +++ b/lib/models/manager/borrow/borrow_item_model.dart @@ -0,0 +1,48 @@ +import 'package:aku_community_manager/models/common/img_model.dart'; + +class BorrowItemModel { + int id; + String name; + int borrowNum; + int remainingNum; + int quantity; + List imgUrls; + + ImgModel get firstImg => imgUrls.isEmpty ? null : imgUrls.first; + + BorrowItemModel( + {this.id, + this.name, + this.borrowNum, + this.remainingNum, + this.quantity, + this.imgUrls}); + + BorrowItemModel.fromJson(Map json) { + id = json['id']; + name = json['name']; + borrowNum = json['borrowNum']; + remainingNum = json['remainingNum']; + quantity = json['quantity']; + if (json['imgUrls'] != null) { + imgUrls = new List(); + json['imgUrls'].forEach((v) { + imgUrls.add(new ImgModel.fromJson(v)); + }); + } else + imgUrls = []; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['name'] = this.name; + data['borrowNum'] = this.borrowNum; + data['remainingNum'] = this.remainingNum; + data['quantity'] = this.quantity; + if (this.imgUrls != null) { + data['imgUrls'] = this.imgUrls.map((v) => v.toJson()).toList(); + } + return data; + } +} diff --git a/lib/models/manager/borrow/borrow_status_item_model.dart b/lib/models/manager/borrow/borrow_status_item_model.dart new file mode 100644 index 0000000..78ae7a7 --- /dev/null +++ b/lib/models/manager/borrow/borrow_status_item_model.dart @@ -0,0 +1,119 @@ +import 'package:aku_community_manager/models/common/img_model.dart'; +import 'package:aku_community_manager/style/app_style.dart'; +import 'package:common_utils/common_utils.dart'; +import 'package:flutter/material.dart'; + +class BorrowStatusItemModel { + int id; + int articleDetailId; + String articleName; + + ///借取状态(1.出借中,2.已还,3.待检查) + int borrowStatus; + + ///物品状态(1.正常,2.损坏,3.丢失) + int status; + int borrowTime; + String beginDate; + String endDate; + String borrowName; + String borrowTel; + String createDate; + List imgUrls; + ImgModel get firstImg => imgUrls.isEmpty ? null : imgUrls.first; + DateTime get create => DateUtil.getDateTime(createDate); + DateTime get begin => DateUtil.getDateTime(beginDate); + DateTime get end => DateUtil.getDateTime(endDate); + + ///借取状态(1.出借中,2.已还,3.待检查) + String get borrowStatusValue { + switch (borrowStatus) { + case 1: + return '出借中'; + case 2: + return '已还'; + case 3: + return '待检查'; + default: + return '未知'; + } + } + + ///物品状态(1.正常,2.损坏,3.丢失) + String get statusValue { + switch (status) { + case 1: + return '正常'; + case 2: + return '损坏'; + case 3: + return '丢失'; + default: + return '未知'; + } + } + + ///物品状态(1.正常,2.损坏,3.丢失) + Color get statusColor { + switch (status) { + case 1: + return AppStyle.primaryTextColor; + default: + return AppStyle.failColor; + } + } + + BorrowStatusItemModel( + {this.id, + this.articleDetailId, + this.articleName, + this.borrowStatus, + this.status, + this.borrowTime, + this.beginDate, + this.endDate, + this.borrowName, + this.borrowTel, + this.createDate, + this.imgUrls}); + + BorrowStatusItemModel.fromJson(Map json) { + id = json['id']; + articleDetailId = json['articleDetailId']; + articleName = json['articleName']; + borrowStatus = json['borrowStatus']; + status = json['status']; + borrowTime = json['borrowTime']; + beginDate = json['beginDate']; + endDate = json['endDate']; + borrowName = json['borrowName']; + borrowTel = json['borrowTel']; + createDate = json['createDate']; + if (json['imgUrls'] != null) { + imgUrls = new List(); + json['imgUrls'].forEach((v) { + imgUrls.add(new ImgModel.fromJson(v)); + }); + } else + imgUrls = []; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['articleDetailId'] = this.articleDetailId; + data['articleName'] = this.articleName; + data['borrowStatus'] = this.borrowStatus; + data['status'] = this.status; + data['borrowTime'] = this.borrowTime; + data['beginDate'] = this.beginDate; + data['endDate'] = this.endDate; + data['borrowName'] = this.borrowName; + data['borrowTel'] = this.borrowTel; + data['createDate'] = this.createDate; + if (this.imgUrls != null) { + data['imgUrls'] = this.imgUrls.map((v) => v.toJson()).toList(); + } + return data; + } +} diff --git a/lib/models/manager/goods_out/goods_out_detail_model.dart b/lib/models/manager/goods_out/goods_out_detail_model.dart new file mode 100644 index 0000000..27a22d9 --- /dev/null +++ b/lib/models/manager/goods_out/goods_out_detail_model.dart @@ -0,0 +1,181 @@ +import 'package:aku_community_manager/models/common/img_model.dart'; +import 'package:common_utils/common_utils.dart'; +import 'package:flutter/material.dart'; + +// * id 物品出户主键id +// * status 状态(1.待出门,2.已出门,3.驳回申请) +// * roomName 详细地址(房产名称) +// * applicantName 出户人(申请人) +// * identity 身份(1业主,2亲属,3租客) +// * applicantTel 联系方式(申请人电话) +// * expectedTime 预计出户时间 +// * articleOutName 出户物品 +// * weight 物品重量(1. <50kg , 2. 50kg-100kg , 3. >100kg) +// * approach 搬运方式(1.自己搬运,2.搬家公司) +// * imgUrls 物品照片 +// * reviewDate 审核时间【status=2:出门时间,status=3:驳回时间】 +// * export 出口(1.东门,2.南门,3.西门,4.北门)【status=2时显示】 +// * remarks 备注(不放行理由,驳回申请时使用)【status=3时显示】 +class GoodsOutDetailModel { + int id; + + ///status 状态(1.待出门,2.已出门,3.驳回申请) + int status; + String roomName; + String applicantName; + + ///identity 身份(1业主,2亲属,3租客) + int identity; + String applicantTel; + String expectedTime; + String articleOutName; + int weight; + + ///approach 搬运方式(1.自己搬运,2.搬家公司) + int approach; + List imgUrls; + String reviewDate; + int export; + String remarks; + + String get exportValue { + switch (export) { + case 1: + return '东门'; + case 2: + return '南门'; + case 3: + return '西门'; + case 4: + return '北门'; + default: + return '未知'; + } + } + + DateTime get review => DateUtil.getDateTime(reviewDate); + DateTime get expected => DateUtil.getDateTime(expectedTime); + + ///approach 搬运方式(1.自己搬运,2.搬家公司) + String get approachValue { + switch (approach) { + case 1: + return '自己搬运'; + case 2: + return '搬家公司'; + + default: + return '未知'; + } + } + + ///status 状态(1.待出门,2.已出门,3.驳回申请) + String get statusValue { + switch (status) { + case 1: + return '待出门'; + case 2: + return '已出门'; + case 3: + return '驳回申请'; + default: + return ' 未知'; + } + } + + Color get statusColor { + switch (status) { + case 2: + return Color(0xFF999999); + default: + return Color(0xFFFF4501); + } + } + + ///identity 身份(1业主,2亲属,3租客) + String get identityValue { + switch (identity) { + case 1: + return '业主'; + case 2: + return '亲属'; + case 3: + return '租客'; + default: + return '未知'; + } + } + + String get weightValue { + switch (weight) { + case 1: + return '<50kg'; + case 2: + return '50kg-100kg'; + case 3: + return '>100kg'; + default: + return '未知'; + } + } + + GoodsOutDetailModel( + {this.id, + this.status, + this.roomName, + this.applicantName, + this.identity, + this.applicantTel, + this.expectedTime, + this.articleOutName, + this.weight, + this.approach, + this.imgUrls, + this.reviewDate, + this.export, + this.remarks}); + + GoodsOutDetailModel.fromJson(Map json) { + id = json['id']; + status = json['status']; + roomName = json['roomName']; + applicantName = json['applicantName']; + identity = json['identity']; + applicantTel = json['applicantTel']; + expectedTime = json['expectedTime']; + articleOutName = json['articleOutName']; + weight = json['weight']; + approach = json['approach']; + if (json['imgUrls'] != null) { + imgUrls = new List(); + json['imgUrls'].forEach((v) { + imgUrls.add(new ImgModel.fromJson(v)); + }); + } else + imgUrls = []; + reviewDate = json['reviewDate']; + export = json['export']; + remarks = json['remarks']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['status'] = this.status; + data['roomName'] = this.roomName; + data['applicantName'] = this.applicantName; + data['identity'] = this.identity; + data['applicantTel'] = this.applicantTel; + data['expectedTime'] = this.expectedTime; + data['articleOutName'] = this.articleOutName; + data['weight'] = this.weight; + data['approach'] = this.approach; + if (this.imgUrls != null) { + data['imgUrls'] = this.imgUrls.map((v) => v.toJson()).toList(); + } + data['reviewDate'] = this.reviewDate; + data['export'] = this.export; + data['remarks'] = this.remarks; + return data; + } +} diff --git a/lib/models/manager/goods_out/goods_out_item_model.dart b/lib/models/manager/goods_out/goods_out_item_model.dart new file mode 100644 index 0000000..d5ef1e3 --- /dev/null +++ b/lib/models/manager/goods_out/goods_out_item_model.dart @@ -0,0 +1,93 @@ +import 'package:common_utils/common_utils.dart'; +import 'package:flutter/material.dart'; + +/// * id 物品出户主键id +/// * status 状态(1.待出门,2.已出门,3.驳回申请) +/// * roomName 详细地址(房产名称) +/// * applicantName 出户人(申请人) +/// * identity 身份(1业主,2亲属,3租客) +/// * articleOutName 出户物品 +/// * expectedTime 预计出户时间 +class GoodsOutItemModel { + int id; + + ///状态(1.待出门,2.已出门,3.驳回申请) + int status; + String roomName; + String applicantName; + + /// 身份(1业主,2亲属,3租客) + int identity; + String articleOutName; + String expectedTime; + + DateTime get expected => DateUtil.getDateTime(expectedTime); + + ///状态(1.待出门,2.已出门,3.驳回申请) + String get statusValue { + switch (status) { + case 1: + return '待出门'; + case 2: + return '已出门'; + case 3: + return '驳回申请'; + default: + return '未知'; + } + } + + Color get statusColor { + switch (status) { + case 2: + return Color(0xFF999999); + default: + return Color(0xFFFF4501); + } + } + + /// 身份(1业主,2亲属,3租客) + String get identityValue { + switch (identity) { + case 1: + return '业主'; + case 2: + return '亲属'; + case 3: + return '租客'; + default: + return '未知'; + } + } + + GoodsOutItemModel( + {this.id, + this.status, + this.roomName, + this.applicantName, + this.identity, + this.articleOutName, + this.expectedTime}); + + GoodsOutItemModel.fromJson(Map json) { + id = json['id']; + status = json['status']; + roomName = json['roomName']; + applicantName = json['applicantName']; + identity = json['identity']; + articleOutName = json['articleOutName']; + expectedTime = json['expectedTime']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['status'] = this.status; + data['roomName'] = this.roomName; + data['applicantName'] = this.applicantName; + data['identity'] = this.identity; + data['articleOutName'] = this.articleOutName; + data['expectedTime'] = this.expectedTime; + return data; + } +} diff --git a/lib/provider/outdoor_provider.dart b/lib/provider/outdoor_provider.dart index 5e5d5cf..e69de29 100644 --- a/lib/provider/outdoor_provider.dart +++ b/lib/provider/outdoor_provider.dart @@ -1,32 +0,0 @@ -// Flutter imports: -import 'package:flutter/material.dart'; - -// Project imports: -import 'package:aku_community_manager/mock_models/outdoor_models/outdoor_model.dart'; - -class OutdoorProvider extends ChangeNotifier { - List _itemOutdoorModel = ItemsOutdoorModel.initList(); - List get itemOutdoorModels => _itemOutdoorModel; - addOutdoormodel(ItemsOutdoorModel model) { - _itemOutdoorModel.insert(0, model); - notifyListeners(); - } - - List getOutdoorModels(int index) { - return [ - _itemOutdoorModel - .where((element) => element.status == OUTDOORSTATUS.NOT_OUT) - .toList(), - _itemOutdoorModel - .where((element) => element.status == OUTDOORSTATUS.OUT_DONE) - .toList(), - _itemOutdoorModel - .where((element) => element.status == OUTDOORSTATUS.REJECTED) - .toList(), - _itemOutdoorModel - .where((element) => element.status == OUTDOORSTATUS.CANCELLATION) - .toList(), - _itemOutdoorModel, - ][index]; - } -} diff --git a/lib/provider/user_provider.dart b/lib/provider/user_provider.dart index 4c5261c..3b7399a 100644 --- a/lib/provider/user_provider.dart +++ b/lib/provider/user_provider.dart @@ -2,6 +2,8 @@ import 'dart:io'; // Flutter imports: +import 'package:aku_community_manager/utils/network/base_file_model.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/material.dart'; // Project imports: @@ -87,20 +89,34 @@ class UserProvider extends ChangeNotifier { _isSigned = true; notifyListeners(); } -///修改昵称 + + ///修改昵称 setNickName(String name) { _infoModel.nickName = name; notifyListeners(); } - setAvatar(File file) { - _userInfoModel.avatar = file; - notifyListeners(); + ///修改头像 + setAvatar(File file) async { + Function cancel = BotToast.showLoading(); + BaseFileModel fileModel = await NetUtil().upload(API.upload.avatar, file); + if (fileModel.status == true) { + await NetUtil().post( + API.user.updateAvatar, + params: { + 'fileUrls': [fileModel.url], + }, + showMessage: true, + ); + _profileModel = await updateProfile(); + cancel(); + notifyListeners(); + } } ///修改手机 - setTel(String tel){ - _profileModel.tel=tel; + setTel(String tel) { + _profileModel.tel = tel; notifyListeners(); } } diff --git a/lib/ui/settings/user_info_page.dart b/lib/ui/settings/user_info_page.dart index 948baee..f821789 100644 --- a/lib/ui/settings/user_info_page.dart +++ b/lib/ui/settings/user_info_page.dart @@ -1,4 +1,6 @@ // Flutter imports: +import 'dart:io'; + import 'package:aku_community_manager/tools/aku_divider.dart'; import 'package:aku_community_manager/ui/settings/nick_name_change_page.dart'; import 'package:aku_community_manager/ui/settings/tel_change_page.dart'; @@ -35,10 +37,9 @@ class _UserInfoPageState extends State { padding: EdgeInsets.symmetric(vertical: 24.w), children: [ AkuTile( - onTap: () { - akuPickImage().then((file) { - if (file != null) userProvider.setAvatar(file); - }); + onTap: () async { + File file = await akuPickImage(); + if (file != null) await userProvider.setAvatar(file); }, title: Text('头像'), height: 168.w, @@ -53,11 +54,9 @@ class _UserInfoPageState extends State { suffix: Text(userProvider.infoModel.nickName), ), AkuTile( - onTap: () async{ + onTap: () async { await TelChangePage().to(); - setState(() { - - }); + setState(() {}); }, title: Text('手机'), suffix: Text(TextUtil.hideNumber(userProvider.profileModel.tel)), diff --git a/lib/ui/splash/splash_page.dart b/lib/ui/splash/splash_page.dart index b51b649..6ab86f2 100644 --- a/lib/ui/splash/splash_page.dart +++ b/lib/ui/splash/splash_page.dart @@ -50,6 +50,8 @@ class _SplashPageState extends State { @override Widget build(BuildContext context) { + ScreenUtil.init(context, + designSize: Size(750, 1334), allowFontScaling: true); return Scaffold( body: Center( child: Image.asset(R.ASSETS_PLACEHOLDER_WEBP), diff --git a/lib/ui/sub_pages/borrow_manager/all_borrow_goods.dart b/lib/ui/sub_pages/borrow_manager/all_borrow_goods.dart index d188d91..33ad832 100644 --- a/lib/ui/sub_pages/borrow_manager/all_borrow_goods.dart +++ b/lib/ui/sub_pages/borrow_manager/all_borrow_goods.dart @@ -1,20 +1,17 @@ // Flutter imports: +import 'package:aku_community_manager/const/api.dart'; +import 'package:aku_community_manager/models/manager/borrow/borrow_item_model.dart'; +import 'package:aku_community_manager/ui/widgets/common/bee_list_view.dart'; import 'package:flutter/material.dart'; // Package imports: -import 'package:aku_ui/common_widgets/aku_material_button.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:get/get.dart'; -import 'package:provider/provider.dart'; // Project imports: import 'package:aku_community_manager/const/resource.dart'; -import 'package:aku_community_manager/mock_models/borrow/borrow_data.dart'; -import 'package:aku_community_manager/mock_models/borrow/borrow_model.dart'; -import 'package:aku_community_manager/mock_models/users/user_info_model.dart'; -import 'package:aku_community_manager/provider/user_provider.dart'; import 'package:aku_community_manager/style/app_style.dart'; import 'package:aku_community_manager/tools/widget_tool.dart'; -import 'package:aku_community_manager/ui/sub_pages/borrow_manager/add_borrow_object_page.dart'; import 'package:aku_community_manager/ui/sub_pages/borrow_manager/borrow_items_page.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; @@ -26,43 +23,51 @@ class AllBorrowGoods extends StatefulWidget { } class _AllBorrowGoodsState extends State { + EasyRefreshController _refreshController = EasyRefreshController(); @override Widget build(BuildContext context) { - final userProvider = Provider.of(context); return AkuScaffold( title: '全部物品', actions: [ - userProvider.userInfoModel.role == USER_ROLE.MANAGER - ? AkuMaterialButton( - minWidth: 120.w, - onPressed: () { - Get.to(AddBorrowObjectPage()); - }, - child: Text( - '新增', - style: TextStyle( - fontSize: 28.w, - color: AppStyle.primaryTextColor, - ), - ), - ) - : SizedBox(), + // userProvider.userInfoModel.role == USER_ROLE.MANAGER + // ? AkuMaterialButton( + // minWidth: 120.w, + // onPressed: () { + // Get.to(AddBorrowObjectPage()); + // }, + // child: Text( + // '新增', + // style: TextStyle( + // fontSize: 28.w, + // color: AppStyle.primaryTextColor, + // ), + // ), + // ) + // : SizedBox(), ], - body: ListView.builder( - padding: EdgeInsets.symmetric( - horizontal: 32.w, - ), - itemBuilder: (context, index) { - return _buildCard(BorrowData.borrowObjects[index]); + body: BeeListView( + path: API.manage.borrowList, + controller: _refreshController, + convert: (model) => + model.tableList.map((e) => BorrowItemModel.fromJson(e)).toList(), + builder: (items) { + return ListView.builder( + padding: EdgeInsets.symmetric( + horizontal: 32.w, + ), + itemBuilder: (context, index) { + return _buildCard(items[index]); + }, + itemCount: items.length, + ); }, - itemCount: BorrowData.borrowObjects.length, ), ); } - _buildCard(BorrowObject object) { + _buildCard(BorrowItemModel object) { return GestureDetector( - onTap: () => Get.to(BorrowItemPage(object: object)), + onTap: () => Get.to(BorrowItemPage(id: object.id)), child: Container( padding: EdgeInsets.all(24.w), margin: EdgeInsets.only(top: 16.w), @@ -70,19 +75,12 @@ class _AllBorrowGoodsState extends State { children: [ ClipRRect( borderRadius: BorderRadius.circular(4.w), - child: (object.assetPath is String) - ? Image.asset( - object.assetPath, - width: 184.w, - height: 184.w, - fit: BoxFit.cover, - ) - : Image.file( - object.assetPath, - width: 184.w, - height: 184.w, - fit: BoxFit.cover, - ), + child: FadeInImage.assetNetwork( + placeholder: R.ASSETS_PLACEHOLDER_WEBP, + image: API.image(object.firstImg?.url ?? ''), + height: 184.w, + width: 184.w, + ), ), AkuBox.w(24), Expanded( @@ -91,10 +89,10 @@ class _AllBorrowGoodsState extends State { _buildRow(R.ASSETS_MANAGE_ARTICLE_PNG, '物品名称', object.name), AkuBox.h(12), _buildRow(R.ASSETS_MANAGE_BORROW_PNG, '借出数量', - object.borrowNumber.toString()), + object.borrowNum.toString()), AkuBox.h(12), _buildRow(R.ASSETS_MANAGE_REMAINING_PNG, '剩余数量', - object.items.length.toString()), + object.remainingNum.toString()), ], )), ], diff --git a/lib/ui/sub_pages/borrow_manager/borrow_item_detail_page.dart b/lib/ui/sub_pages/borrow_manager/borrow_item_detail_page.dart index 12f40fd..9b5767a 100644 --- a/lib/ui/sub_pages/borrow_manager/borrow_item_detail_page.dart +++ b/lib/ui/sub_pages/borrow_manager/borrow_item_detail_page.dart @@ -1,8 +1,14 @@ // Flutter imports: +import 'package:aku_community_manager/const/api.dart'; +import 'package:aku_community_manager/models/manager/borrow/borrow_item_detail_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: import 'package:aku_ui/common_widgets/aku_material_button.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:provider/provider.dart'; // Project imports: @@ -14,8 +20,8 @@ import 'package:aku_community_manager/tools/widget_tool.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; class BorrowItemDetailPage extends StatefulWidget { - final SingleBorrowGoods item; - BorrowItemDetailPage({Key key, this.item}) : super(key: key); + final int id; + BorrowItemDetailPage({Key key, this.id}) : super(key: key); @override _BorrowItemDetailPageState createState() => _BorrowItemDetailPageState(); @@ -24,10 +30,11 @@ class BorrowItemDetailPage extends StatefulWidget { class _BorrowItemDetailPageState extends State { bool _isEditing = false; TextEditingController _textEditingController; + BorrowItemDetailModel _detailModel; @override void initState() { super.initState(); - _textEditingController = TextEditingController(text: widget.item.name); + _textEditingController = TextEditingController(text: ''); } @override @@ -45,7 +52,21 @@ class _BorrowItemDetailPageState extends State { userProvider.userInfoModel.role == USER_ROLE.MANAGER ? AkuMaterialButton( minWidth: 120.w, - onPressed: () { + onPressed: () async { + if (_isEditing && _detailModel != null) { + Function cancel = BotToast.showLoading(); + await NetUtil().post( + API.manage.borrowEdit, + params: { + 'id': _detailModel.id, + 'name': _textEditingController.text, + 'fileUrls': _detailModel.imgUrls, + }, + showMessage: true, + ); + await Future.delayed(Duration(milliseconds: 1000)); + cancel(); + } setState(() { _isEditing = !_isEditing; }); @@ -60,77 +81,86 @@ class _BorrowItemDetailPageState extends State { ) : SizedBox(), ], - body: ListView( - padding: EdgeInsets.symmetric(vertical: 16.w), - children: [ - Container( - color: Colors.white, - padding: EdgeInsets.symmetric(horizontal: 32.w), - child: Column( - children: [ - _buildRow( - '物品名称', - TextField( - style: TextStyle( - color: AppStyle.primaryTextColor, - fontSize: 28.sp, - fontWeight: FontWeight.bold, - ), - controller: _textEditingController, - enabled: _isEditing, - onChanged: (text) { - widget.item.name = text; - }, - decoration: InputDecoration( - border: InputBorder.none, - ), - )), - Divider(height: 1.w), - _buildRow( - '物品单号', - Text( - widget.item.code, - style: TextStyle( - color: _isEditing - ? AppStyle.minorTextColor - : AppStyle.primaryTextColor, - fontSize: 28.sp, - fontWeight: FontWeight.bold, - ), - )), - _buildRow( - '出借状态', - Text( - '未出借', - style: TextStyle( - color: _isEditing - ? AppStyle.minorTextColor - : AppStyle.primaryTextColor, - fontSize: 28.sp, - fontWeight: FontWeight.bold, - ), - )), - _buildRow( - '物品图片', - (widget.item.assetpath is String) - ? Image.asset( - widget.item.assetpath, - height: 184.w, - width: 184.w, - fit: BoxFit.cover, - ) - : Image.file( - widget.item.assetpath, - height: 184.w, - width: 184.w, - fit: BoxFit.cover, + body: EasyRefresh( + firstRefresh: true, + header: MaterialHeader(), + onRefresh: () async { + BaseModel model = await NetUtil().get( + API.manage.borrowItemDetail, + params: {'articleDetailId': widget.id}, + ); + _detailModel = BorrowItemDetailModel.fromJson(model.data); + _textEditingController.text = _detailModel.name; + setState(() {}); + }, + child: _detailModel == null + ? SizedBox() + : ListView( + padding: EdgeInsets.symmetric(vertical: 16.w), + children: [ + Container( + color: Colors.white, + padding: EdgeInsets.symmetric(horizontal: 32.w), + child: Column( + children: [ + _buildRow( + '物品名称', + TextField( + style: TextStyle( + color: AppStyle.primaryTextColor, + fontSize: 28.sp, + fontWeight: FontWeight.bold, + ), + controller: _textEditingController, + enabled: _isEditing, + onChanged: (text) { + //TODO edit + // widget.item.name = text; + }, + decoration: InputDecoration( + border: InputBorder.none, + ), + )), + Divider(height: 1.w), + _buildRow( + '物品单号', + Text( + _detailModel.code, + style: TextStyle( + color: _isEditing + ? AppStyle.minorTextColor + : AppStyle.primaryTextColor, + fontSize: 28.sp, + fontWeight: FontWeight.bold, + ), + )), + _buildRow( + '出借状态', + Text( + '未出借', + style: TextStyle( + color: _isEditing + ? AppStyle.minorTextColor + : AppStyle.primaryTextColor, + fontSize: 28.sp, + fontWeight: FontWeight.bold, + ), + )), + _buildRow( + '物品图片', + FadeInImage.assetNetwork( + placeholder: R.ASSETS_PLACEHOLDER_WEBP, + image: API.image(_detailModel.firstImg?.url ?? ''), + height: 184.w, + width: 184.w, + ), ), - ), - AkuBox.h(28), - ], - ), - ), - ], + AkuBox.h(28), + ], + ), + ), + ], + ), ), ); } diff --git a/lib/ui/sub_pages/borrow_manager/borrow_items_page.dart b/lib/ui/sub_pages/borrow_manager/borrow_items_page.dart index 17569d4..720cdda 100644 --- a/lib/ui/sub_pages/borrow_manager/borrow_items_page.dart +++ b/lib/ui/sub_pages/borrow_manager/borrow_items_page.dart @@ -1,68 +1,80 @@ // Flutter imports: +import 'package:aku_community_manager/const/api.dart'; +import 'package:aku_community_manager/models/manager/borrow/borrow_detail_item_model.dart'; +import 'package:aku_community_manager/ui/sub_pages/borrow_manager/borrow_item_detail_page.dart'; +import 'package:aku_community_manager/ui/widgets/common/bee_list_view.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; // Package imports: import 'package:aku_ui/common_widgets/aku_material_button.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:get/get.dart'; import 'package:provider/provider.dart'; // Project imports: -import 'package:aku_community_manager/mock_models/borrow/borrow_model.dart'; import 'package:aku_community_manager/mock_models/users/user_info_model.dart'; import 'package:aku_community_manager/provider/user_provider.dart'; import 'package:aku_community_manager/style/app_style.dart'; import 'package:aku_community_manager/tools/widget_tool.dart'; -import 'package:aku_community_manager/ui/sub_pages/borrow_manager/add_borrow_item_page.dart'; -import 'package:aku_community_manager/ui/sub_pages/borrow_manager/borrow_item_detail_page.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; class BorrowItemPage extends StatefulWidget { - final BorrowObject object; - BorrowItemPage({Key key, @required this.object}) : super(key: key); + final int id; + BorrowItemPage({Key key, @required this.id}) : super(key: key); @override _BorrowItemPageState createState() => _BorrowItemPageState(); } class _BorrowItemPageState extends State { + EasyRefreshController _refreshController = EasyRefreshController(); @override Widget build(BuildContext context) { - final userProvider = Provider.of(context); return AkuScaffold( title: '物品查看', actions: [ - userProvider.userInfoModel.role == USER_ROLE.MANAGER - ? AkuMaterialButton( - minWidth: 120.w, - onPressed: () { - Get.to(AddBorrowItemPage(object: widget.object)); - }, - child: Text( - '新增', - style: TextStyle( - fontSize: 28.w, - color: AppStyle.primaryTextColor, - ), - ), - ) - : SizedBox(), + // userProvider.userInfoModel.role == USER_ROLE.MANAGER + // ? AkuMaterialButton( + // minWidth: 120.w, + // onPressed: () { + // // Get.to(AddBorrowItemPage(object: widget.object)); + // }, + // child: Text( + // '新增', + // style: TextStyle( + // fontSize: 28.w, + // color: AppStyle.primaryTextColor, + // ), + // ), + // ) + // : SizedBox(), ], - body: ListView.builder( - padding: EdgeInsets.symmetric(horizontal: 32.w), - itemBuilder: (context, index) { - return _buildCard(widget.object.items[index]); + body: BeeListView( + path: API.manage.borrowDetailList, + controller: _refreshController, + extraParams: {'articleId': widget.id}, + convert: (model) => model.tableList + .map((e) => BorrowDetailItemModel.fromJson(e)) + .toList(), + builder: (items) { + return ListView.builder( + padding: EdgeInsets.symmetric(horizontal: 32.w), + itemBuilder: (context, index) { + return _buildCard(items[index]); + }, + itemCount: items.length, + ); }, - itemCount: widget.object.items.length, ), ); } - _buildCard(SingleBorrowGoods item) { + _buildCard(BorrowDetailItemModel item) { final userProvider = Provider.of(context); return GestureDetector( onTap: () { - Get.to(BorrowItemDetailPage(item: item)); + Get.to(BorrowItemDetailPage(id: item.id)); }, child: Container( margin: EdgeInsets.only(top: 16.w), @@ -81,54 +93,54 @@ class _BorrowItemPageState extends State { ), ), Spacer(), - userProvider.userInfoModel.role == USER_ROLE.MANAGER - ? AkuMaterialButton( - padding: EdgeInsets.symmetric(horizontal: 24.w), - onPressed: () { - showCupertinoDialog( - context: context, - builder: (context) { - return CupertinoAlertDialog( - title: Text('删除物品'), - content: Text('确定要删除${item.name}该物品吗?'), - actions: [ - CupertinoDialogAction( - child: Text('取消'), - onPressed: () { - Get.back(); - }, - ), - CupertinoDialogAction( - child: Text('删除'), - onPressed: () { - widget.object.items.remove(item); - setState(() {}); - Get.back(); - }, - ), - ], - ); - }, - ); - }, - child: Row( - children: [ - Icon( - Icons.delete, - color: AppStyle.minorTextColor, - size: 40.w, - ), - Text( - '删除', - style: TextStyle( - color: AppStyle.minorTextColor, - fontSize: 28.sp, - ), - ), - ], - ), - ) - : SizedBox(), + // userProvider.userInfoModel.role == USER_ROLE.MANAGER + // ? AkuMaterialButton( + // padding: EdgeInsets.symmetric(horizontal: 24.w), + // onPressed: () { + // showCupertinoDialog( + // context: context, + // builder: (context) { + // return CupertinoAlertDialog( + // title: Text('删除物品'), + // content: Text('确定要删除${item.name}该物品吗?'), + // actions: [ + // CupertinoDialogAction( + // child: Text('取消'), + // onPressed: () { + // Get.back(); + // }, + // ), + // CupertinoDialogAction( + // child: Text('删除'), + // onPressed: () { + // //TODO delete + // setState(() {}); + // Get.back(); + // }, + // ), + // ], + // ); + // }, + // ); + // }, + // child: Row( + // children: [ + // Icon( + // Icons.delete, + // color: AppStyle.minorTextColor, + // size: 40.w, + // ), + // Text( + // '删除', + // style: TextStyle( + // color: AppStyle.minorTextColor, + // fontSize: 28.sp, + // ), + // ), + // ], + // ), + // ) + // : SizedBox(), ], ), Divider( @@ -141,19 +153,12 @@ class _BorrowItemPageState extends State { AkuBox.w(24), ClipRRect( borderRadius: BorderRadius.circular(4.w), - child: (item.assetpath is String) - ? Image.asset( - item.assetpath, - height: 184.w, - width: 184.w, - fit: BoxFit.cover, - ) - : Image.file( - item.assetpath, - height: 184.w, - width: 184.w, - fit: BoxFit.cover, - ), + child: FadeInImage.assetNetwork( + placeholder: R.ASSETS_PLACEHOLDER_WEBP, + image: API.image(item.firstImg?.url ?? ''), + height: 184.w, + width: 184.w, + ), ), AkuBox.w(24), Expanded( @@ -164,7 +169,7 @@ class _BorrowItemPageState extends State { _buildRow( R.ASSETS_MANAGE_BORROW_PNG, '出借状态', - '未借出', + item.borrowed ? '已出借' : '未借出', color: AppStyle.secondaryColor, ), ], diff --git a/lib/ui/sub_pages/borrow_manager/borrow_manager_card.dart b/lib/ui/sub_pages/borrow_manager/borrow_manager_card.dart index 5bdcf95..06694c3 100644 --- a/lib/ui/sub_pages/borrow_manager/borrow_manager_card.dart +++ b/lib/ui/sub_pages/borrow_manager/borrow_manager_card.dart @@ -1,4 +1,8 @@ // Flutter imports: +import 'package:aku_community_manager/const/api.dart'; +import 'package:aku_community_manager/models/manager/borrow/borrow_status_item_model.dart'; +import 'package:aku_community_manager/ui/sub_pages/borrow_manager/borrow_manager_check_page.dart'; +import 'package:aku_community_manager/utils/network/net_util.dart'; import 'package:flutter/material.dart'; // Package imports: @@ -9,17 +13,14 @@ import 'package:get/get.dart'; import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; -// Project imports: -import 'package:aku_community_manager/mock_models/borrow/borrow_model.dart'; import 'package:aku_community_manager/mock_models/users/user_info_model.dart'; import 'package:aku_community_manager/provider/user_provider.dart'; import 'package:aku_community_manager/style/app_style.dart'; import 'package:aku_community_manager/tools/widget_tool.dart'; -import 'package:aku_community_manager/ui/sub_pages/borrow_manager/borrow_manager_check_page.dart'; import 'package:aku_community_manager/ui/widgets/inner/aku_chip_box.dart'; class BorrowManagerCard extends StatefulWidget { - final BorrowModel model; + final BorrowStatusItemModel model; BorrowManagerCard({Key key, this.model}) : super(key: key); @override @@ -46,12 +47,12 @@ class _BorrowManagerCardState extends State { AkuChipBox(title: '借还管理'), AkuBox.w(24), Text( - DateUtil.formatDate(widget.model.date), + DateUtil.formatDate(widget.model.create), style: TextStyle(), ), Spacer(), Text( - widget.model.borrowGoods.borrowValue, + widget.model.borrowStatusValue, style: TextStyle( color: AppStyle.failColor, fontWeight: FontWeight.bold, @@ -62,7 +63,7 @@ class _BorrowManagerCardState extends State { ), AkuBox.h(24), Text( - widget.model.title, + widget.model.articleName, style: TextStyle( color: AppStyle.primaryTextColor, fontSize: 32.sp, @@ -73,40 +74,27 @@ class _BorrowManagerCardState extends State { Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - (widget.model.borrowGoods.assetpath is String) - ? Image.asset( - widget.model.borrowGoods.assetpath, - height: 184.w, - width: 183.w, - fit: BoxFit.cover, - ) - : Image.file( - widget.model.borrowGoods.assetpath, - height: 184.w, - width: 183.w, - fit: BoxFit.cover, - ), + FadeInImage.assetNetwork( + placeholder: R.ASSETS_PLACEHOLDER_WEBP, + image: API.image(widget.model.firstImg?.url ?? ''), + height: 184.w, + width: 184.w, + ), AkuBox.w(24), Expanded( child: Column( children: [ _buildRow(R.ASSETS_MESSAGE_IC_PEOPLE_PNG, '借用人员', - widget.model.borrowPerson), + widget.model.borrowName), _buildRow(R.ASSETS_MESSAGE_IC_PHONE_PNG, '联系电话', - widget.model.phone), + widget.model.borrowTel), _buildRow(R.ASSETS_MANAGE_IC_TIME_PNG, '借用时常', - '${widget.model.borrowTime}天'), + '${(widget.model.borrowTime / 24).toStringAsFixed(0)}天'), _buildRow( R.ASSETS_MANAGE_INFO_PNG, '物品状态', - widget.model.goodsStatus == GOODS_STATUS.BROKEN - ? '损坏' - : widget.model.goodsStatus == GOODS_STATUS.LOST - ? '丢失' - : '正常', - color: widget.model.goodsStatus == GOODS_STATUS.NORMAL - ? AppStyle.primaryTextColor - : AppStyle.failColor, + widget.model.statusValue, + color: widget.model.statusColor, ), ], ), @@ -120,9 +108,10 @@ class _BorrowManagerCardState extends State { } List _buildCard() { - if (role != USER_ROLE.MANAGER) + final userProvider = Provider.of(context); + if (!userProvider.infoModel.canOperation) return []; - else if (widget.model.borrowGoods.status == BORROW_STATUS.DONE) { + else if (widget.model.borrowStatus == 2) { return []; } else return [ @@ -142,7 +131,7 @@ class _BorrowManagerCardState extends State { ), ), onPressed: () { - launch('tel:${widget.model.phone}'); + launch('tel:${widget.model.borrowTel}'); }, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(4.w), @@ -150,14 +139,27 @@ class _BorrowManagerCardState extends State { ), ), AkuBox.w(24), - widget.model.borrowGoods.status == BORROW_STATUS.BORROWING + widget.model.borrowStatus == 1 ? AkuMaterialButton( minWidth: 160.w, height: 64.w, color: AppStyle.primaryColor, radius: 4.w, - onPressed: () { - BotToast.showText(text: '已提醒用户'); + onPressed: () async { + //TODO unknown param `butlerMessage` + Function cancel = BotToast.showLoading(); + await NetUtil().post( + API.manage.remindUserReturn, + params: { + 'borrowId': widget.model.id, + 'butlerMessage': { + 'title': '', + 'content': '', + }, + }, + showMessage: true, + ); + cancel(); }, child: Text( '提醒归还', @@ -169,14 +171,14 @@ class _BorrowManagerCardState extends State { ), ) : SizedBox(), - widget.model.borrowGoods.status == BORROW_STATUS.WAIT_CHECK + widget.model.borrowStatus == 3 ? AkuMaterialButton( minWidth: 160.w, height: 64.w, color: AppStyle.primaryColor, radius: 4.w, - onPressed: () { - Get.to(BorrowManagerCheckPage(model: widget.model)); + onPressed: () async { + await Get.to(BorrowManagerCheckPage(id: widget.model.id)); }, child: Text( '检查信息', diff --git a/lib/ui/sub_pages/borrow_manager/borrow_manager_check_page.dart b/lib/ui/sub_pages/borrow_manager/borrow_manager_check_page.dart index 2b71b3d..da96e8c 100644 --- a/lib/ui/sub_pages/borrow_manager/borrow_manager_check_page.dart +++ b/lib/ui/sub_pages/borrow_manager/borrow_manager_check_page.dart @@ -1,5 +1,11 @@ // Flutter imports: +import 'package:aku_community_manager/const/api.dart'; +import 'package:aku_community_manager/models/manager/borrow/borrow_check_item_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'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; // Package imports: import 'package:get/get.dart'; @@ -12,105 +18,126 @@ import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; import 'package:aku_community_manager/ui/widgets/inner/aku_bottom_button.dart'; class BorrowManagerCheckPage extends StatefulWidget { - final BorrowModel model; - BorrowManagerCheckPage({Key key, @required this.model}) : super(key: key); + final int id; + BorrowManagerCheckPage({Key key, @required this.id}) : super(key: key); @override _BorrowManagerCheckPageState createState() => _BorrowManagerCheckPageState(); } class _BorrowManagerCheckPageState extends State { - GOODS_STATUS borrowStatus = GOODS_STATUS.NORMAL; + int borrowStatus = 1; + BorrowCheckItemModel _model; @override Widget build(BuildContext context) { return AkuScaffold( title: '检查物品', bottom: AkuBottomButton( title: '确认归还', - onTap: () { - widget.model.goodsStatus = borrowStatus; - widget.model.borrowGoods.status = BORROW_STATUS.DONE; - Get.back(); + onTap: () async { + Function cancel = BotToast.showLoading(); + await NetUtil().post( + API.manage.borrowCheck, + params: { + 'articleBorrowId': widget.id, + 'articleStatus': borrowStatus, + }, + showMessage: true, + ); + cancel(); + Get.back(result: true); }, ), - body: ListView( - padding: EdgeInsets.symmetric(vertical: 16.w), - children: [ - Container( - color: Colors.white, - padding: EdgeInsets.symmetric(horizontal: 32.w), - child: Column( - children: [ - _buildRow( - '物品名称', - Text( - widget.model.borrowGoods.name, - style: TextStyle( - color: AppStyle.primaryTextColor, - fontSize: 28.sp, - fontWeight: FontWeight.bold, - ), - ), - ), - Divider(height: 1.w), - _buildRow( - '物品单号', - Text( - widget.model.borrowGoods.code, - style: TextStyle( - color: AppStyle.primaryTextColor, - fontSize: 28.sp, - fontWeight: FontWeight.bold, + body: EasyRefresh( + firstRefresh: true, + onRefresh: () async { + BaseModel model = await NetUtil().get( + API.manage.borrowCheckInfo, + params: {'articleBorrowId': widget.id}, + showMessage: true, + ); + if (model.data == null) { + // Get.back(); + return; + } + _model = BorrowCheckItemModel.fromJson(model.data); + setState(() {}); + }, + header: MaterialHeader(), + child: _model == null + ? SizedBox() + : ListView( + padding: EdgeInsets.symmetric(vertical: 16.w), + children: [ + Container( + color: Colors.white, + padding: EdgeInsets.symmetric(horizontal: 32.w), + child: Column( + children: [ + _buildRow( + '物品名称', + Text( + _model.articleName, + style: TextStyle( + color: AppStyle.primaryTextColor, + fontSize: 28.sp, + fontWeight: FontWeight.bold, + ), + ), + ), + Divider(height: 1.w), + _buildRow( + '物品单号', + Text( + _model.code, + style: TextStyle( + color: AppStyle.primaryTextColor, + fontSize: 28.sp, + fontWeight: FontWeight.bold, + ), + ), + ), + Divider(height: 1.w), + _buildRow( + '归还数量', + Text( + '1', + style: TextStyle( + color: AppStyle.primaryTextColor, + fontSize: 28.sp, + fontWeight: FontWeight.bold, + ), + )), + Divider(height: 1.w), + _buildRow( + '物品情况', + Row( + children: [ + _buildCard(1), + AkuBox.w(24), + _buildCard(2), + AkuBox.w(24), + _buildCard(3), + ], + ), + ), + Divider(height: 1.w), + AkuBox.h(16), + _buildRow( + '物品图片', + FadeInImage.assetNetwork( + placeholder: R.ASSETS_PLACEHOLDER_WEBP, + image: API.image(_model.firstImg?.url ?? ''), + height: 184.w, + width: 184.w, + ), + ), + AkuBox.h(28), + ], ), ), - ), - Divider(height: 1.w), - _buildRow( - '归还数量', - Text( - '1', - style: TextStyle( - color: AppStyle.primaryTextColor, - fontSize: 28.sp, - fontWeight: FontWeight.bold, - ), - )), - Divider(height: 1.w), - _buildRow( - '物品情况', - Row( - children: [ - _buildCard(GOODS_STATUS.NORMAL), - AkuBox.w(24), - _buildCard(GOODS_STATUS.BROKEN), - AkuBox.w(24), - _buildCard(GOODS_STATUS.LOST), - ], - ), - ), - Divider(height: 1.w), - AkuBox.h(16), - _buildRow( - '物品图片', - (widget.model.borrowGoods.assetpath is String) - ? Image.asset( - widget.model.borrowGoods.assetpath, - height: 184.w, - width: 184.w, - fit: BoxFit.cover, - ) - : Image.file( - widget.model.borrowGoods.assetpath, - height: 184.w, - width: 184.w, - fit: BoxFit.cover, - ), - ), - AkuBox.h(28), - ], - ), - ), - ], + ], + ), ), ); } @@ -137,7 +164,7 @@ class _BorrowManagerCheckPageState extends State { ); } - _buildCard(GOODS_STATUS status) { + _buildCard(int status) { return GestureDetector( onTap: () { borrowStatus = status; @@ -148,9 +175,9 @@ class _BorrowManagerCheckPageState extends State { width: 112.w, child: Text( { - GOODS_STATUS.NORMAL: '完好', - GOODS_STATUS.BROKEN: '损坏', - GOODS_STATUS.LOST: '丢失', + 1: '完好', + 2: '损坏', + 3: '丢失', }[status], style: TextStyle( color: borrowStatus == status diff --git a/lib/ui/sub_pages/borrow_manager/borrow_manager_page.dart b/lib/ui/sub_pages/borrow_manager/borrow_manager_page.dart index 56be063..1c0d9a9 100644 --- a/lib/ui/sub_pages/borrow_manager/borrow_manager_page.dart +++ b/lib/ui/sub_pages/borrow_manager/borrow_manager_page.dart @@ -1,4 +1,5 @@ // Flutter imports: +import 'package:aku_community_manager/ui/sub_pages/borrow_manager/borrow_manager_view.dart'; import 'package:flutter/material.dart'; // Package imports: @@ -30,12 +31,13 @@ class _BorrowManagerPageState extends State Provider.of(context, listen: false).userInfoModel.role; TabController _tabController; List get _tabs { - switch (role) { - case USER_ROLE.MANAGER: - return ['全部', '出借中', '待检查', '已归还']; - default: - return ['全部', '出借中', '已归还']; - } + final userProvider = Provider.of(context, listen: false); + return [ + '全部', + '出借中', + ...userProvider.infoModel.canOperation ? ['待检查'] : [], + '已归还' + ]; } @override @@ -77,32 +79,14 @@ class _BorrowManagerPageState extends State } List _getChildren() { - switch (role) { - case USER_ROLE.MANAGER: - return [ - getView(BorrowData.models), - getView(BorrowData.borrowModels), - getView(BorrowData.checkModels), - getView(BorrowData.doneModels), - ]; - break; - default: - return [ - getView(BorrowData.models), - getView(BorrowData.borrowModels), - getView(BorrowData.doneModels), - ]; - } + final userProvider = Provider.of(context); + return [ + BorrowManagerView(), + BorrowManagerView(status: 1), + ...userProvider.infoModel.canOperation + ? [BorrowManagerView(status: 3)] + : [], + BorrowManagerView(status: 2), + ]; } } - -Widget getView(List models) { - return ListView.builder( - itemBuilder: (context, index) { - return BorrowManagerCard( - model: models[index], - ); - }, - itemCount: models.length, - ); -} diff --git a/lib/ui/sub_pages/borrow_manager/borrow_manager_view.dart b/lib/ui/sub_pages/borrow_manager/borrow_manager_view.dart new file mode 100644 index 0000000..c420636 --- /dev/null +++ b/lib/ui/sub_pages/borrow_manager/borrow_manager_view.dart @@ -0,0 +1,42 @@ +import 'package:aku_community_manager/const/api.dart'; +import 'package:aku_community_manager/models/manager/borrow/borrow_status_item_model.dart'; +import 'package:aku_community_manager/ui/sub_pages/borrow_manager/borrow_manager_card.dart'; +import 'package:aku_community_manager/ui/widgets/common/bee_list_view.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; + +class BorrowManagerView extends StatefulWidget { + final int status; + BorrowManagerView({Key key, this.status}) : super(key: key); + + @override + _BorrowManagerViewState createState() => _BorrowManagerViewState(); +} + +class _BorrowManagerViewState extends State + with AutomaticKeepAliveClientMixin { + EasyRefreshController _refreshController = EasyRefreshController(); + @override + Widget build(BuildContext context) { + super.build(context); + return BeeListView( + path: API.manage.borrowStatusList, + extraParams: {'borrowStatus': widget.status}, + controller: _refreshController, + convert: (model) => model.tableList + .map((e) => BorrowStatusItemModel.fromJson(e)) + .toList(), + builder: (items) { + return ListView.builder( + itemBuilder: (context, index) { + return BorrowManagerCard(model: items[index]); + }, + itemCount: items.length, + ); + }, + ); + } + + @override + bool get wantKeepAlive => true; +} diff --git a/lib/ui/sub_pages/items_outdoor/items_outdoor_card.dart b/lib/ui/sub_pages/items_outdoor/items_outdoor_card.dart index f9cb2cc..c52935b 100644 --- a/lib/ui/sub_pages/items_outdoor/items_outdoor_card.dart +++ b/lib/ui/sub_pages/items_outdoor/items_outdoor_card.dart @@ -1,44 +1,27 @@ // Flutter imports: +import 'package:aku_community_manager/models/manager/goods_out/goods_out_item_model.dart'; +import 'package:aku_community_manager/ui/sub_pages/items_outdoor/items_outdoor_details_page.dart'; import 'package:flutter/material.dart'; // Package imports: import 'package:aku_ui/common_widgets/aku_common_widgets.dart'; -import 'package:common_utils/common_utils.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:get/get.dart'; // Project imports: import 'package:aku_community_manager/const/resource.dart'; -import 'package:aku_community_manager/mock_models/outdoor_models/outdoor_model.dart'; import 'package:aku_community_manager/style/app_style.dart'; import 'package:aku_community_manager/tools/widget_tool.dart'; -import 'package:aku_community_manager/ui/sub_pages/items_outdoor/items_outdoor_details_page.dart'; +import 'package:get/get.dart'; class ItemsOutdoorCard extends StatefulWidget { - final ItemsOutdoorModel cardModel; - final bool isdetail; - ItemsOutdoorCard({ - Key key, - @required this.cardModel, - this.isdetail = false, - }) : super(key: key); + final GoodsOutItemModel model; + ItemsOutdoorCard({Key key, @required this.model}) : super(key: key); @override _ItemsOutdoorCardState createState() => _ItemsOutdoorCardState(); } class _ItemsOutdoorCardState extends State { - ItemsOutdoorModel _cardModel; - String _datetime; - - @override - void initState() { - super.initState(); - _cardModel = widget.cardModel; - _datetime = - DateUtil.formatDate(_cardModel.datetime, format: "yyyy/MM/dd HH:mm:ss"); - } - @override Widget build(BuildContext context) { TextStyle _textStyle = @@ -47,250 +30,196 @@ class _ItemsOutdoorCardState extends State { color: Color(0xFFFFFFFF), margin: EdgeInsets.only(top: 16.w), padding: EdgeInsets.only(left: 24.w, right: 24.w), - child: Column(children: [ - widget.isdetail - ? Container( - alignment: Alignment.centerLeft, - height: 90.w, - width: double.infinity, - child: Row( - children: [ - Text( - '出户信息', - style: TextStyle( - color: AppStyle.primaryTextColor, - fontSize: 36.sp, - fontWeight: FontWeight.bold), - ), - Spacer(), - Text( - ItemsOutdoorModel.outdoorStatusMap[_cardModel.status], - style: TextStyle( - color: _cardModel.status == OUTDOORSTATUS.CANCELLATION - ? Color(0xFF999999) - : Color(0xFFFF4501), - fontSize: 24.sp, - fontWeight: FontWeight.bold), - ), - ], - ), - ) - : Container( - alignment: Alignment.centerLeft, - height: 88.w, - width: double.infinity, - child: Row( - children: [ - Container( - alignment: Alignment.center, - width: 112.w, - height: 40.w, - decoration: BoxDecoration( - border: - Border.all(color: Color(0xFF3F8FFE), width: 2.w), - ), - child: Text( - '物品出户', - style: TextStyle( - color: Color(0xFF3F8FFE), - fontSize: 20.sp, - fontWeight: FontWeight.bold), - ), - ), - AkuBox.w(16), - Text( - _datetime, - style: TextStyle( - color: AppStyle.minorTextColor, - fontSize: 22.sp, - ), - ), - Spacer(), - Text( - ItemsOutdoorModel.outdoorStatusMap[_cardModel.status], - style: TextStyle( - color: _cardModel.status == OUTDOORSTATUS.CANCELLATION - ? Color(0xFF999999) - : Color(0xFFFF4501), - fontSize: 24.sp, - fontWeight: FontWeight.bold), - ), - ], - ), - ), - Row( - children: [ - Image.asset( - R.ASSETS_OUTDOOR_IC_HOME_PNG, - width: 40.w, - height: 40.w, - ), - AkuBox.w(4), - Text( - '小区名称', - style: _textStyle, - ), - Spacer(), - Text( - _cardModel.communityname, - style: AppStyle().primaryStyle, - ), - ], - ), - AkuBox.h(12), - Row( - children: [ - Image.asset( - R.ASSETS_OUTDOOR_IC_ADDRESS_PNG, - width: 40.w, - height: 40.w, - ), - AkuBox.w(4), - Text('详细地址', style: _textStyle), - Spacer(), - Text( - _cardModel.adress, - style: AppStyle().primaryStyle, - ), - ], - ), - AkuBox.h(12), - Row( - children: [ - Image.asset( - R.ASSETS_OUTDOOR_IC_GOOUT_PNG, - width: 40.w, - height: 40.w, - ), - AkuBox.w(4), - Text( - '出户人', - style: _textStyle, - ), - Spacer(), - Text( - _cardModel.name, - style: AppStyle().primaryStyle, - ), - ], - ), - AkuBox.h(12), - Row( - children: [ - Image.asset( - R.ASSETS_OUTDOOR_IC_PEOPLE_PNG, - width: 40.w, - height: 40.w, - ), - AkuBox.w(4), - Text( - '身份', - style: _textStyle, - ), - Spacer(), - Text( - _cardModel.identify, - style: AppStyle().primaryStyle, - ), - ], - ), - AkuBox.h(12), - Row( - children: [ - Image.asset( - R.ASSETS_OUTDOOR_IC_CHUHU_PNG, - width: 40.w, - height: 40.w, - ), - Text( - '出户物品', - style: _textStyle, - ), - Spacer(), - Text( - _cardModel.items.itemname, - style: AppStyle().primaryStyle, - ), - ], - ), - AkuBox.h(12), - Row( - children: [ - Image.asset( - R.ASSETS_OUTDOOR_IC_TIME_PNG, - width: 40.w, - height: 40.w, - ), - AkuBox.w(4), - Text( - '出户时间', - style: _textStyle, - ), - Spacer(), - Text( - _cardModel.outtime, - style: AppStyle().primaryStyle, - ), - ], - ), - AkuBox.h(24), - Divider( - height: 1.w, - ), - widget.isdetail - ? AkuButton( - onPressed: () {}, - child: Container( + child: Column( + children: [ + Container( + alignment: Alignment.centerLeft, + height: 88.w, + width: double.infinity, + child: Row( + children: [ + Container( alignment: Alignment.center, - height: 96.w, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Image.asset( - R.ASSETS_OUTDOOR_IC_PHONEBLUE_PNG, - width: 38.w, - height: 39.w, - ), - AkuBox.w(16), - Text('联系业主', - style: TextStyle( - color: Color(0xFF3F8FFE), - fontSize: 28.sp, - fontWeight: FontWeight.bold)), - ], + width: 112.w, + height: 40.w, + decoration: BoxDecoration( + border: Border.all(color: Color(0xFF3F8FFE), width: 2.w), + ), + child: Text( + '物品出户', + style: TextStyle( + color: Color(0xFF3F8FFE), + fontSize: 20.sp, + fontWeight: FontWeight.bold), ), ), - ) - : Container( - height: 112.w, - alignment: Alignment.centerRight, - child: AkuButton( - onPressed: () { - Get.to(ItemsOutdoorDetailsPage( - cardMedel: _cardModel, - )); - }, - child: Container( - alignment: Alignment.center, - width: 160.w, - height: 64.w, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(8.w), - gradient: LinearGradient( - begin: Alignment.topLeft, - end: Alignment.bottomRight, - colors: [ - AppStyle.primaryColor, - AppStyle.minorColor - ])), - child: Text( - '查看详情', - style: AppStyle().primaryStyle, - ), + AkuBox.w(16), + //TODO 创建时间 + // Text( + // widget.model.create, + // style: TextStyle( + // color: AppStyle.minorTextColor, + // fontSize: 22.sp, + // ), + // ), + Spacer(), + Text( + widget.model.statusValue, + style: TextStyle( + color: widget.model.statusColor, + fontSize: 24.sp, + fontWeight: FontWeight.bold, ), ), + ], + ), + ), + Row( + children: [ + Image.asset( + R.ASSETS_OUTDOOR_IC_HOME_PNG, + width: 40.w, + height: 40.w, + ), + AkuBox.w(4), + Text( + '小区名称', + style: _textStyle, + ), + Spacer(), + //TODO 小区名称 + Text( + 'XXXXXX', + style: AppStyle().primaryStyle, + ), + ], + ), + AkuBox.h(12), + Row( + children: [ + Image.asset( + R.ASSETS_OUTDOOR_IC_ADDRESS_PNG, + width: 40.w, + height: 40.w, + ), + AkuBox.w(4), + Text('详细地址', style: _textStyle), + Spacer(), + Text( + widget.model.roomName, + style: AppStyle().primaryStyle, + ), + ], + ), + AkuBox.h(12), + Row( + children: [ + Image.asset( + R.ASSETS_OUTDOOR_IC_GOOUT_PNG, + width: 40.w, + height: 40.w, + ), + AkuBox.w(4), + Text( + '出户人', + style: _textStyle, + ), + Spacer(), + Text( + widget.model.applicantName, + style: AppStyle().primaryStyle, + ), + ], + ), + AkuBox.h(12), + Row( + children: [ + Image.asset( + R.ASSETS_OUTDOOR_IC_PEOPLE_PNG, + width: 40.w, + height: 40.w, + ), + AkuBox.w(4), + Text( + '身份', + style: _textStyle, + ), + Spacer(), + Text( + widget.model.identityValue, + style: AppStyle().primaryStyle, + ), + ], + ), + AkuBox.h(12), + Row( + children: [ + Image.asset( + R.ASSETS_OUTDOOR_IC_CHUHU_PNG, + width: 40.w, + height: 40.w, + ), + Text( + '出户物品', + style: _textStyle, + ), + Spacer(), + Text( + widget.model.articleOutName, + style: AppStyle().primaryStyle, + ), + ], + ), + AkuBox.h(12), + Row( + children: [ + Image.asset( + R.ASSETS_OUTDOOR_IC_TIME_PNG, + width: 40.w, + height: 40.w, + ), + AkuBox.w(4), + Text( + '出户时间', + style: _textStyle, + ), + Spacer(), + Text( + widget.model.expectedTime, + style: AppStyle().primaryStyle, + ), + ], + ), + AkuBox.h(24), + Divider( + height: 1.w, + ), + Container( + height: 112.w, + alignment: Alignment.centerRight, + child: AkuButton( + onPressed: () { + Get.to(ItemsOutdoorDetailsPage(id: widget.model.id)); + }, + child: Container( + alignment: Alignment.center, + width: 160.w, + height: 64.w, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(8.w), + gradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [AppStyle.primaryColor, AppStyle.minorColor])), + child: Text( + '查看详情', + style: AppStyle().primaryStyle, + ), ), - ]), + ), + ), + ], + ), ); } } diff --git a/lib/ui/sub_pages/items_outdoor/items_outdoor_details_page.dart b/lib/ui/sub_pages/items_outdoor/items_outdoor_details_page.dart index f5eccdd..d19fb40 100644 --- a/lib/ui/sub_pages/items_outdoor/items_outdoor_details_page.dart +++ b/lib/ui/sub_pages/items_outdoor/items_outdoor_details_page.dart @@ -1,29 +1,33 @@ // Flutter imports: +import 'package:aku_community_manager/const/api.dart'; +import 'package:aku_community_manager/models/manager/goods_out/goods_out_detail_model.dart'; +import 'package:aku_community_manager/utils/network/base_model.dart'; +import 'package:aku_community_manager/utils/network/net_util.dart'; +import 'package:common_utils/common_utils.dart'; import 'package:flutter/material.dart'; +import 'package:aku_community_manager/tools/extensions/list_extension_tool.dart'; // Package imports: import 'package:aku_ui/aku_ui.dart'; import 'package:aku_ui/common_widgets/aku_material_button.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:provider/provider.dart'; // Project imports: import 'package:aku_community_manager/const/resource.dart'; -import 'package:aku_community_manager/mock_models/outdoor_models/outdoor_model.dart'; -import 'package:aku_community_manager/mock_models/users/user_info_model.dart'; import 'package:aku_community_manager/provider/user_provider.dart'; import 'package:aku_community_manager/style/app_style.dart'; import 'package:aku_community_manager/tools/widget_tool.dart'; -import 'package:aku_community_manager/ui/sub_pages/items_outdoor/items_outdoor_card.dart'; import 'package:aku_community_manager/ui/sub_pages/items_outdoor/outdoor_notpass_page.dart'; import 'package:aku_community_manager/ui/sub_pages/items_outdoor/outdoor_pass_page.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; +import 'package:url_launcher/url_launcher.dart'; class ItemsOutdoorDetailsPage extends StatefulWidget { - final ItemsOutdoorModel cardMedel; - ItemsOutdoorDetailsPage({Key key, @required this.cardMedel}) - : super(key: key); + final int id; + ItemsOutdoorDetailsPage({Key key, @required this.id}) : super(key: key); @override _ItemsOutdoorDetailsPageState createState() => @@ -31,137 +35,248 @@ class ItemsOutdoorDetailsPage extends StatefulWidget { } class _ItemsOutdoorDetailsPageState extends State { + GoodsOutDetailModel _model; + + _buildTile(String path, String title, String subTitle) { + return Row( + children: [ + Image.asset( + path, + width: 40.w, + height: 40.w, + ), + AkuBox.w(4), + Text( + title ?? '', + style: TextStyle(color: AppStyle.minorTextColor, fontSize: 28.sp), + ), + Spacer(), + Text( + subTitle ?? '', + style: AppStyle().primaryStyle, + ), + ], + ); + } + @override Widget build(BuildContext context) { - UserProvider _userprovider = - Provider.of(context, listen: false); - USER_ROLE userRole = _userprovider.userInfoModel.role; return AkuScaffold( title: '出户详情', - body: ListView( - children: [ - ItemsOutdoorCard( - cardModel: widget.cardMedel, - isdetail: true, - ), - Container( - color: Color(0xFFFFFFFF), - margin: EdgeInsets.only(top: 16.w), - padding: EdgeInsets.only( - top: 24.w, left: 32.w, right: 32.w, bottom: 40.w), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - '物品信息', - style: AppStyle().barTitleStyle, - ), - AkuBox.h(16), - Row( - children: [ - Image.asset( - R.ASSETS_OUTDOOR_IC_CHUHU_PNG, - width: 40.w, - height: 40.w, - ), - AkuBox.w(4), - Text( - '出户物品', - style: AppStyle().secondaryTextStyle, - ), - Spacer(), - Text( - widget.cardMedel.items.itemname, - style: AppStyle().primaryStyle, - ), - ], - ), - AkuBox.h(16), - Row( - children: [ - Image.asset( - R.ASSETS_OUTDOOR_IC_WEIGHT_PNG, - width: 40.w, - height: 40.w, - ), - AkuBox.w(4), - Text( - '物品重量', - style: AppStyle().secondaryTextStyle, - ), - Spacer(), - Text( - widget.cardMedel.items.weight < 50.0 - ? '<50kg' - : '${widget.cardMedel.items.weight}kg', - style: AppStyle().primaryStyle, - ), - ], - ), - AkuBox.h(16), - Row( - children: [ - Image.asset( - R.ASSETS_OUTDOOR_IC_TRANSPORT_PNG, - width: 40.w, - height: 40.w, - ), - AkuBox.w(4), - Text( - '搬运方式', - style: AppStyle().secondaryTextStyle, + body: EasyRefresh( + firstRefresh: true, + onRefresh: () async { + BaseModel model = await NetUtil().get( + API.manage.goodsOutDetail, + params: {'articleOutId': widget.id}, + ); + _model = GoodsOutDetailModel.fromJson(model.data); + setState(() {}); + }, + header: MaterialHeader(), + child: _model == null + ? SizedBox() + : ListView( + padding: EdgeInsets.symmetric(vertical: 16.w), + children: [ + Container( + padding: + EdgeInsets.symmetric(horizontal: 32.w, vertical: 24.w), + color: Colors.white, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Text( + '出户信息', + style: AppStyle().barTitleStyle, + ), + Spacer(), + Text( + _model.statusValue, + style: TextStyle( + color: _model.statusColor, + fontSize: 24.sp, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + AkuBox.h(16), + ...[ + _buildTile( + R.ASSETS_OUTDOOR_IC_HOME_PNG, '小区名称', 'XXXX'), + _buildTile( + R.ASSETS_OUTDOOR_IC_ADDRESS_PNG, + '详细地址', + _model.roomName, + ), + _buildTile(R.ASSETS_OUTDOOR_IC_HOME_PNG, '出户人', + _model.applicantName), + _buildTile(R.ASSETS_OUTDOOR_IC_HOME_PNG, '身份', + _model.identityValue), + _buildTile(R.ASSETS_OUTDOOR_IC_HOME_PNG, '联系方式', + _model.applicantTel), + _buildTile( + R.ASSETS_OUTDOOR_IC_HOME_PNG, + '出户时间', + DateUtil.formatDate( + _model.expected, + format: 'yyyy-MM-dd HH:mm', + ), + ), + ].sepWidget(separate: AkuBox.h(12)), + ], ), - Spacer(), - Text( - widget.cardMedel.items.way, - style: AppStyle().primaryStyle, - ) - ], - ), - AkuBox.h(16), - Row( - children: [ - Image.asset( - R.ASSETS_OUTDOOR_IC_IMAGE_PNG, - width: 40.w, - height: 40.w, + ), + Divider(height: 1.w), + MaterialButton( + onPressed: () { + launch('tel:${_model.applicantTel}'); + }, + elevation: 0, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Image.asset( + R.ASSETS_OUTDOOR_IC_PHONEBLUE_PNG, + width: 30.w, + height: 30.w, + ), + AkuBox.w(16), + Text( + '联系业主', + style: TextStyle( + color: Color(0xFF3F8FFE), + fontSize: 28.sp, + ), + ), + ], ), - AkuBox.w(4), - Text( - '图片信息', - style: AppStyle().secondaryTextStyle, + color: Colors.white, + height: 96.w, + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + ), + Container( + color: Color(0xFFFFFFFF), + margin: EdgeInsets.only(top: 16.w), + padding: EdgeInsets.only( + top: 24.w, left: 32.w, right: 32.w, bottom: 40.w), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + '物品信息', + style: AppStyle().barTitleStyle, + ), + AkuBox.h(16), + Row( + children: [ + Image.asset( + R.ASSETS_OUTDOOR_IC_CHUHU_PNG, + width: 40.w, + height: 40.w, + ), + AkuBox.w(4), + Text( + '出户物品', + style: AppStyle().secondaryTextStyle, + ), + Spacer(), + Text( + _model.articleOutName ?? '', + style: AppStyle().primaryStyle, + ), + ], + ), + AkuBox.h(16), + Row( + children: [ + Image.asset( + R.ASSETS_OUTDOOR_IC_WEIGHT_PNG, + width: 40.w, + height: 40.w, + ), + AkuBox.w(4), + Text( + '物品重量', + style: AppStyle().secondaryTextStyle, + ), + Spacer(), + Text( + _model.weightValue, + style: AppStyle().primaryStyle, + ), + ], + ), + AkuBox.h(16), + Row( + children: [ + Image.asset( + R.ASSETS_OUTDOOR_IC_TRANSPORT_PNG, + width: 40.w, + height: 40.w, + ), + AkuBox.w(4), + Text( + '搬运方式', + style: AppStyle().secondaryTextStyle, + ), + Spacer(), + Text( + _model.approachValue, + style: AppStyle().primaryStyle, + ) + ], + ), + AkuBox.h(16), + Row( + children: [ + Image.asset( + R.ASSETS_OUTDOOR_IC_IMAGE_PNG, + width: 40.w, + height: 40.w, + ), + AkuBox.w(4), + Text( + '图片信息', + style: AppStyle().secondaryTextStyle, + ), + Spacer(), + ], + ), + AkuBox.h(16), + Wrap( + spacing: 16.w, + children: _model.imgUrls + .map( + (e) => ClipRRect( + borderRadius: BorderRadius.circular(4.w), + child: FadeInImage.assetNetwork( + placeholder: R.ASSETS_PLACEHOLDER_WEBP, + image: API.image(e?.url ?? ''), + width: 218.w, + height: 218.w, + )), + ) + .toList(), + ), + ], ), - Spacer(), - ], - ), - AkuBox.h(16), - Wrap( - spacing: 16.w, - children: widget.cardMedel.items.imagepath - .map( - (e) => ClipRRect( - borderRadius: BorderRadius.circular(4.w), - child: Image.asset( - e, - width: 218.w, - height: 218.w, - )), - ) - .toList(), - ), - ], - ), - ), - ], + ), + ], + ), ), - bottom: _bottomCard(userRole), + bottom: _model == null ? SizedBox() : _bottomCard(), ); } - Widget _bottomCard(USER_ROLE userRole) { - switch (widget.cardMedel.status) { - case OUTDOORSTATUS.NOT_OUT: - return userRole == USER_ROLE.SECURITY + Widget _bottomCard() { + final userProvider = Provider.of(context); + switch (_model.status) { + case 1: + return userProvider.infoModel.canPass ? Container( height: 98.w, decoration: BoxDecoration( @@ -181,9 +296,7 @@ class _ItemsOutdoorDetailsPageState extends State { children: [ AkuButton( onPressed: () { - Get.to(OutdoorNotpassPage( - model: widget.cardMedel, - )); + Get.to(OutdoorNotpassPage(id: _model.id)); }, child: Container( width: 304.w, @@ -203,9 +316,7 @@ class _ItemsOutdoorDetailsPageState extends State { Spacer(), AkuMaterialButton( onPressed: () { - Get.to(OutdoorPassPage( - model: widget.cardMedel, - )); + Get.to(OutdoorPassPage(id: _model.id)); }, radius: 4.w, color: Color(0xFFFFC40C), @@ -221,7 +332,7 @@ class _ItemsOutdoorDetailsPageState extends State { ) : SizedBox(); break; - case OUTDOORSTATUS.OUT_DONE: + case 2: return Container( height: 226.w, color: Color(0xFFFFFFFF), @@ -247,7 +358,10 @@ class _ItemsOutdoorDetailsPageState extends State { ), Spacer(), Text( - widget.cardMedel.finalOutTime, + DateUtil.formatDate( + _model.expected, + format: 'yyyy-MM-dd HH:mm', + ), style: AppStyle().primaryStyle, ), ], @@ -267,7 +381,7 @@ class _ItemsOutdoorDetailsPageState extends State { ), Spacer(), Text( - widget.cardMedel.outPlace, + _model.exportValue, style: AppStyle().primaryStyle, ), ], @@ -276,7 +390,7 @@ class _ItemsOutdoorDetailsPageState extends State { ), ); break; - case OUTDOORSTATUS.REJECTED: + case 3: return Container( height: 226.w, color: Color(0xFFFFFFFF), @@ -302,7 +416,10 @@ class _ItemsOutdoorDetailsPageState extends State { ), Spacer(), Text( - widget.cardMedel.finalOutTime, + DateUtil.formatDate( + _model.expected, + format: 'yyyy-MM-dd HH:mm', + ), style: AppStyle().primaryStyle, ), ], @@ -321,11 +438,13 @@ class _ItemsOutdoorDetailsPageState extends State { style: AppStyle().secondaryTextStyle, ), Spacer(), - Text(widget.cardMedel.rejectReason, - style: TextStyle( - color: Color(0xFFFF4501), - fontSize: 28.sp, - fontWeight: FontWeight.bold)), + Text( + _model.remarks, + style: TextStyle( + color: Color(0xFFFF4501), + fontSize: 28.sp, + fontWeight: FontWeight.bold), + ), ], ), ], diff --git a/lib/ui/sub_pages/items_outdoor/items_outdoor_page.dart b/lib/ui/sub_pages/items_outdoor/items_outdoor_page.dart index 8574f6d..607574a 100644 --- a/lib/ui/sub_pages/items_outdoor/items_outdoor_page.dart +++ b/lib/ui/sub_pages/items_outdoor/items_outdoor_page.dart @@ -1,14 +1,12 @@ -// Flutter imports: + +import 'package:aku_community_manager/ui/sub_pages/items_outdoor/items_outdoor_view.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; // Package imports: import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:provider/provider.dart'; // Project imports: -import 'package:aku_community_manager/mock_models/outdoor_models/outdoor_model.dart'; -import 'package:aku_community_manager/provider/outdoor_provider.dart'; -import 'package:aku_community_manager/ui/sub_pages/items_outdoor/items_outdoor_card.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; import 'package:aku_community_manager/ui/widgets/inner/aku_tab_bar.dart'; @@ -23,6 +21,7 @@ class _ItemsOutdoorPageState extends State with TickerProviderStateMixin { List _tabs = ['待出户', '已出户', '已驳回', '已作废', '全部']; TabController _tabController; + EasyRefreshController _refreshController = EasyRefreshController(); @override void initState() { super.initState(); @@ -44,24 +43,15 @@ class _ItemsOutdoorPageState extends State child: AkuTabBar(controller: _tabController, tabs: _tabs), ), body: TabBarView( - controller: _tabController, - children: - _tabs.map((e) => _buildListView(_tabs.indexOf(e))).toList()), - ); - } - - Widget _buildListView(int index) { - final _outdoorModels = Provider.of(context); - List _selectModels = - _outdoorModels.getOutdoorModels(index); - return ListView( - padding: EdgeInsets.only(left: 32.w, right: 32.w), - children: _selectModels - .map((e) => ItemsOutdoorCard( - cardModel: e, - isdetail: false, - )) - .toList(), + controller: _tabController, + children: [ + ItemsOutdoorView(status: 1), + ItemsOutdoorView(status: 2), + ItemsOutdoorView(status: 3), + ItemsOutdoorView(status: 4), + ItemsOutdoorView(status: null), + ], + ), ); } } diff --git a/lib/ui/sub_pages/items_outdoor/items_outdoor_view.dart b/lib/ui/sub_pages/items_outdoor/items_outdoor_view.dart new file mode 100644 index 0000000..b3403b2 --- /dev/null +++ b/lib/ui/sub_pages/items_outdoor/items_outdoor_view.dart @@ -0,0 +1,45 @@ +import 'package:aku_community_manager/const/api.dart'; +import 'package:aku_community_manager/models/manager/goods_out/goods_out_item_model.dart'; +import 'package:aku_community_manager/ui/sub_pages/items_outdoor/items_outdoor_card.dart'; +import 'package:aku_community_manager/ui/widgets/common/bee_list_view.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class ItemsOutdoorView extends StatefulWidget { + final int status; + ItemsOutdoorView({Key key, this.status}) : super(key: key); + + @override + _ItemsOutdoorViewState createState() => _ItemsOutdoorViewState(); +} + +class _ItemsOutdoorViewState extends State + with AutomaticKeepAliveClientMixin { + EasyRefreshController _refreshController = new EasyRefreshController(); + @override + Widget build(BuildContext context) { + super.build(context); + return BeeListView( + path: API.manage.goodsOutList, + extraParams: {'articleOutStatus': widget.status}, + controller: _refreshController, + convert: (model) => + model.tableList.map((e) => GoodsOutItemModel.fromJson(e)).toList(), + builder: (items) { + return ListView.builder( + itemBuilder: (context, index) { + return ItemsOutdoorCard( + model: items[index], + ); + }, + padding: EdgeInsets.only(left: 32.w, right: 32.w), + itemCount: items.length, + ); + }, + ); + } + + @override + bool get wantKeepAlive => true; +} diff --git a/lib/ui/sub_pages/items_outdoor/outdoor_notpass_page.dart b/lib/ui/sub_pages/items_outdoor/outdoor_notpass_page.dart index 2c48bfa..3b58514 100644 --- a/lib/ui/sub_pages/items_outdoor/outdoor_notpass_page.dart +++ b/lib/ui/sub_pages/items_outdoor/outdoor_notpass_page.dart @@ -1,4 +1,7 @@ // Flutter imports: +import 'package:aku_community_manager/const/api.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: @@ -7,15 +10,14 @@ import 'package:common_utils/common_utils.dart'; import 'package:get/get.dart'; // Project imports: -import 'package:aku_community_manager/mock_models/outdoor_models/outdoor_model.dart'; import 'package:aku_community_manager/style/app_style.dart'; import 'package:aku_community_manager/tools/widget_tool.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_radio.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; class OutdoorNotpassPage extends StatefulWidget { - final ItemsOutdoorModel model; - OutdoorNotpassPage({Key key, @required this.model}) : super(key: key); + final int id; + OutdoorNotpassPage({Key key, @required this.id}) : super(key: key); @override _OutdoorNotpassPageState createState() => _OutdoorNotpassPageState(); @@ -185,13 +187,23 @@ class _OutdoorNotpassPageState extends State { ], ), bottom: AkuButton( - onPressed: () { - widget.model.finalOutTime = _currentTime; - widget.model.datetime = DateTime.now(); - _select == 3 - ? widget.model.rejectReason = _textEditingController.text - : widget.model.rejectReason = _rejectReason[_select]; - widget.model.status = OUTDOORSTATUS.REJECTED; + onPressed: () async { + Function cancel = BotToast.showLoading(); + String remark = ''; + if (_select <= 2) { + remark = _rejectReason[_select]; + } else { + remark = _textEditingController.text; + } + await NetUtil().post( + API.manage.goodsOutNotRelease, + params: { + 'id': widget.id, + 'remarks': remark, + }, + showMessage: true, + ); + cancel(); Get.back(); Get.back(); }, diff --git a/lib/ui/sub_pages/items_outdoor/outdoor_pass_page.dart b/lib/ui/sub_pages/items_outdoor/outdoor_pass_page.dart index b092adc..c6944bd 100644 --- a/lib/ui/sub_pages/items_outdoor/outdoor_pass_page.dart +++ b/lib/ui/sub_pages/items_outdoor/outdoor_pass_page.dart @@ -1,4 +1,6 @@ // Flutter imports: +import 'package:aku_community_manager/const/api.dart'; +import 'package:aku_community_manager/utils/network/net_util.dart'; import 'package:flutter/material.dart'; // Package imports: @@ -9,36 +11,25 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; // Project imports: -import 'package:aku_community_manager/mock_models/outdoor_models/outdoor_model.dart'; import 'package:aku_community_manager/style/app_style.dart'; import 'package:aku_community_manager/tools/widget_tool.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; class OutdoorPassPage extends StatefulWidget { - final ItemsOutdoorModel model; - OutdoorPassPage({Key key, @required this.model}) : super(key: key); + final int id; + + OutdoorPassPage({Key key, this.id}) : super(key: key); @override _OutdoorPassPageState createState() => _OutdoorPassPageState(); } class _OutdoorPassPageState extends State { - TextEditingController _textController; - @override - void initState() { - super.initState(); - _textController = TextEditingController(); - } - - @override - void dispose() { - _textController?.dispose(); - super.dispose(); - } - + int _doorValue; @override Widget build(BuildContext context) { - String _currentTime = DateUtil.formatDate(DateTime.now()); + String _currentTime = + DateUtil.formatDate(DateTime.now(), format: 'yyyy-MM-dd HH:mm'); return AkuScaffold( title: '放行', @@ -86,21 +77,34 @@ class _OutdoorPassPageState extends State { ), AkuBox.w(32), Expanded( - child: Container( - height: double.infinity, - width: double.infinity, - padding: EdgeInsets.only(left: 48.w), - child: TextFormField( - controller: _textController, - maxLines: 1, - style: TextStyle( - color: AppStyle.primaryTextColor, - fontSize: 32.sp, + child: PopupMenuButton( + itemBuilder: (context) { + return [ + PopupMenuItem(child: Text('东门'), value: 1), + PopupMenuItem(child: Text('南门'), value: 2), + PopupMenuItem(child: Text('西门'), value: 3), + PopupMenuItem(child: Text('北门'), value: 4), + ]; + }, + onSelected: (value) { + _doorValue = value; + setState(() {}); + }, + child: Container( + padding: EdgeInsets.only(left: 48.w), + child: Text( + _doorValue == null + ? '请输入当前入口' + : { + 1: '东门', + 2: '南门', + 3: '西门', + 4: '北门', + }[_doorValue], + style: _doorValue == null + ? AppStyle().secondaryTextStyle + : AppStyle().primaryStyle, ), - decoration: InputDecoration( - hintText: '请输入当前入口', - hintStyle: AppStyle().secondaryTextStyle, - border: InputBorder.none), ), ), ), @@ -110,15 +114,21 @@ class _OutdoorPassPageState extends State { ], ), bottom: AkuButton( - onPressed: _textController.text == null + onPressed: _doorValue == null ? () { BotToast.showText(text: '出口不能为空!'); } - : () { - widget.model.finalOutTime = _currentTime; - widget.model.outPlace = _textController.text; - widget.model.datetime = DateTime.now(); - widget.model.status = OUTDOORSTATUS.OUT_DONE; + : () async { + Function cancel = BotToast.showLoading(); + NetUtil().post( + API.manage.goodsOutRelease, + params: { + 'id': widget.id, + 'export': _doorValue, + }, + showMessage: true, + ); + cancel(); Get.back(); Get.back(); }, diff --git a/lib/ui/tool_pages/warning/warning_page.dart b/lib/ui/tool_pages/warning/warning_page.dart index b6f818a..2c254c5 100644 --- a/lib/ui/tool_pages/warning/warning_page.dart +++ b/lib/ui/tool_pages/warning/warning_page.dart @@ -54,6 +54,7 @@ class _WarningPageState extends State { showScaleControl: false, onMapCreated: (controller) async { _amapController = controller; + _amapController.showMyLocation(MyLocationOption()); _getLocation(); }, ), diff --git a/lib/ui/widgets/app_widgets/aku_avatar.dart b/lib/ui/widgets/app_widgets/aku_avatar.dart index 22cc34c..6a9ba94 100644 --- a/lib/ui/widgets/app_widgets/aku_avatar.dart +++ b/lib/ui/widgets/app_widgets/aku_avatar.dart @@ -27,6 +27,7 @@ class AkuAvatar extends StatelessWidget { image: API.image(userProvider.profileModel.firstImg?.url ?? ''), height: size ?? 72.w, width: size ?? 72.w, + fit: BoxFit.cover, ), ) : CircleAvatar( diff --git a/lib/utils/network/net_util.dart b/lib/utils/network/net_util.dart index c718263..a34f8dd 100644 --- a/lib/utils/network/net_util.dart +++ b/lib/utils/network/net_util.dart @@ -3,6 +3,7 @@ import 'dart:io'; // Package imports: import 'package:aku_community_manager/provider/user_provider.dart'; +import 'package:aku_community_manager/ui/home/home_page.dart'; import 'package:aku_community_manager/ui/login/login_page.dart'; import 'package:bot_toast/bot_toast.dart'; import 'package:dio/dio.dart'; @@ -37,7 +38,6 @@ class NetUtil { onRequest: (RequestOptions options) async => options, onResponse: (Response response) async { LoggerData.addData(response); - print(response.headers); return response; }, onError: (DioError error) async { @@ -148,6 +148,7 @@ class NetUtil { } _parseErr(DioError err) { + final userProvider = Provider.of(Get.context, listen: false); LoggerData.addData(err); _makeToast(String message) { BotToast.showText(text: '$message\_${err?.response?.statusCode ?? ''}'); diff --git a/pubspec.lock b/pubspec.lock index 3b500c3..c5d6955 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -192,6 +192,20 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "0.3.5" + device_info: + dependency: transitive + description: + name: device_info + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.0" + device_info_platform_interface: + dependency: transitive + description: + name: device_info_platform_interface + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.1" dio: dependency: "direct main" description: @@ -464,6 +478,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.9.3" + package_info: + dependency: transitive + description: + name: package_info + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.4.3+4" path: dependency: transitive description: @@ -554,7 +575,7 @@ packages: name: power_logger url: "https://pub.flutter-io.cn" source: hosted - version: "0.1.0" + version: "0.1.1" pretty_json: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 9152a80..92a1dfb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -51,7 +51,7 @@ dependencies: dio: - power_logger: ^0.1.0 + power_logger: ^0.1.1 logger: ^0.9.4 aku_ui: git: