diff --git a/lib/const/api.dart b/lib/const/api.dart index e4129d6..8138a75 100644 --- a/lib/const/api.dart +++ b/lib/const/api.dart @@ -57,4 +57,7 @@ class _Manage { ///访客管理:管家app显示所有的访客信息 (包含条件搜索) String get visitorList => '/user/visitor/list'; + + ///报事报修:查询所有的报事报修信息(包含条件搜索) + String get repairList => '/user/repair/list'; } diff --git a/lib/models/manager/bussiness_and_fix_model.dart b/lib/models/manager/bussiness_and_fix_model.dart new file mode 100644 index 0000000..5fa6963 --- /dev/null +++ b/lib/models/manager/bussiness_and_fix_model.dart @@ -0,0 +1,75 @@ +class BussinessAndFixModel { + int id; + int dispatchId; + String reportDetail; + String repairDate; + int status; + List imgUrls; + int type; + + BussinessAndFixModel( + {this.id, + this.dispatchId, + this.reportDetail, + this.repairDate, + this.status, + this.imgUrls, + this.type}); + + BussinessAndFixModel.fromJson(Map json) { + id = json['id']; + dispatchId = json['dispatchId']; + reportDetail = json['reportDetail']; + repairDate = json['repairDate']; + status = json['status']; + if (json['imgUrls'] != null) { + imgUrls = new List(); + json['imgUrls'].forEach((v) { + imgUrls.add(new ImgUrls.fromJson(v)); + }); + } + type = json['type']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['dispatchId'] = this.dispatchId; + data['reportDetail'] = this.reportDetail; + data['repairDate'] = this.repairDate; + data['status'] = this.status; + if (this.imgUrls != null) { + data['imgUrls'] = this.imgUrls.map((v) => v.toJson()).toList(); + } + data['type'] = this.type; + return data; + } +} + +class ImgUrls { + String url; + String size; + int longs; + int paragraph; + int sort; + + ImgUrls({this.url, this.size, this.longs, this.paragraph, this.sort}); + + ImgUrls.fromJson(Map json) { + url = json['url']; + size = json['size']; + longs = json['longs']; + paragraph = json['paragraph']; + sort = json['sort']; + } + + Map toJson() { + final Map data = new Map(); + data['url'] = this.url; + data['size'] = this.size; + data['longs'] = this.longs; + data['paragraph'] = this.paragraph; + data['sort'] = this.sort; + return data; + } +} diff --git a/lib/provider/user_provider.dart b/lib/provider/user_provider.dart index 74a37a7..4c5261c 100644 --- a/lib/provider/user_provider.dart +++ b/lib/provider/user_provider.dart @@ -100,7 +100,7 @@ class UserProvider extends ChangeNotifier { ///修改手机 setTel(String tel){ - _infoModel.tel=tel; + _profileModel.tel=tel; notifyListeners(); } } diff --git a/lib/tools/aku_map.dart b/lib/tools/aku_map.dart new file mode 100644 index 0000000..398d937 --- /dev/null +++ b/lib/tools/aku_map.dart @@ -0,0 +1,60 @@ +class AkuMap { + static String fixStatus(bool canOpention, bool canPickup, int status) { + if (canOpention) { + switch (status) { + case 1: + return '待派单'; + break; + case 2: + return '已派单'; + case 3: + return '处理中'; + case 4: + case 5: + case 6: + return '已处理'; + case 7: + return '已作废'; + case 8: + return '已取消'; + default: + return ''; + } + } else if (canPickup) { + switch (status) { + case 2: + return '已派单'; + case 3: + return '处理中'; + case 4: + case 5: + case 6: + return '已处理'; + case 7: + return '已作废'; + case 8: + return '已取消'; + default: + return ''; + } + } else { + switch (status) { + case 1: + case 2: + return '未处理'; + case 3: + return '处理中'; + case 4: + case 5: + case 6: + return '已处理'; + case 7: + return '已作废'; + case 8: + return '已取消'; + default: + return ''; + } + } + } +} diff --git a/lib/ui/home/business/business_page.dart b/lib/ui/home/business/business_page.dart index 7757a07..7ee4f1f 100644 --- a/lib/ui/home/business/business_page.dart +++ b/lib/ui/home/business/business_page.dart @@ -1,10 +1,10 @@ // Flutter imports: +import 'package:aku_community_manager/models/manager/bussiness_and_fix_model.dart'; import 'package:flutter/material.dart'; // Project imports: import 'package:aku_community_manager/mock_models/all_model.dart'; import 'package:aku_community_manager/mock_models/decoration/decoration_model.dart'; -import 'package:aku_community_manager/mock_models/fix/fix_model.dart'; import 'package:aku_community_manager/style/app_style.dart'; import 'package:aku_community_manager/tools/screen_tool.dart'; import 'package:aku_community_manager/ui/sub_pages/business_and_fix/business_fix_card.dart'; @@ -72,7 +72,7 @@ class _BusinessPageState extends State final item = list[index]; if (item is DecorationModel) { return DecorationManagerCard(model: item); - } else if (item is FixModel) { + } else if (item is BussinessAndFixModel) { return BusinessFixCard(model: item); } else return SizedBox(); diff --git a/lib/ui/home/home_page.dart b/lib/ui/home/home_page.dart index 1d9ccf7..7ecb887 100644 --- a/lib/ui/home/home_page.dart +++ b/lib/ui/home/home_page.dart @@ -1,4 +1,5 @@ // Flutter imports: +import 'package:aku_community_manager/models/manager/bussiness_and_fix_model.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -14,7 +15,6 @@ import 'package:provider/provider.dart'; import 'package:aku_community_manager/const/resource.dart'; import 'package:aku_community_manager/mock_models/all_model.dart'; import 'package:aku_community_manager/mock_models/decoration/decoration_model.dart'; -import 'package:aku_community_manager/mock_models/fix/fix_model.dart'; import 'package:aku_community_manager/provider/anouncement_provider.dart'; import 'package:aku_community_manager/provider/app_provider.dart'; import 'package:aku_community_manager/provider/user_provider.dart'; @@ -504,7 +504,7 @@ class _HomePageState extends State { final item = AllModel(context).waitThings[index]; if (item is DecorationModel) { return DecorationManagerCard(model: item); - } else if (item is FixModel) { + } else if (item is BussinessAndFixModel) { return BusinessFixCard( model: item, homeDisplay: true); } else diff --git a/lib/ui/sub_pages/business_and_fix/business_and_fix_page.dart b/lib/ui/sub_pages/business_and_fix/business_and_fix_page.dart index 8998e6f..a659a05 100644 --- a/lib/ui/sub_pages/business_and_fix/business_and_fix_page.dart +++ b/lib/ui/sub_pages/business_and_fix/business_and_fix_page.dart @@ -1,16 +1,13 @@ // Flutter imports: +import 'package:aku_community_manager/ui/sub_pages/business_and_fix/bussiness_and_fix_view.dart'; import 'package:flutter/material.dart'; // Package imports: import 'package:provider/provider.dart'; // Project imports: -import 'package:aku_community_manager/mock_models/fix/fix_model.dart'; -import 'package:aku_community_manager/mock_models/users/user_info_model.dart'; -import 'package:aku_community_manager/provider/fix_provider.dart'; import 'package:aku_community_manager/provider/user_provider.dart'; import 'package:aku_community_manager/tools/screen_tool.dart'; -import 'package:aku_community_manager/ui/sub_pages/business_and_fix/business_fix_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'; @@ -27,16 +24,21 @@ class _BusinessAndFixPageState extends State List get _tabs { final userProvider = Provider.of(context, listen: false); - switch (userProvider.userInfoModel.role) { - case USER_ROLE.MANAGER: - return ['待派单', '已派单', '处理中', '已处理', '全部']; - break; - case USER_ROLE.FIXER: - return ['待接单', '处理中', '已处理', '全部']; - break; - default: - return ['待接单', '处理中', '已处理', '全部']; - break; + // switch (userProvider.userInfoModel.role) { + // case USER_ROLE.MANAGER: + // return ['待派单', '已派单', '处理中', '已处理', '全部']; + // break; + // case USER_ROLE.FIXER: + // return ['待接单', '处理中', '已处理', '全部']; + // break; + // default: + // return ['待接单', '处理中', '已处理', '全部']; + // break; + // } + if (userProvider.infoModel.canOperation) { + return ['待派单', '已派单', '处理中', '已处理', '全部']; + } else { + return ['待接单', '处理中', '已处理', '全部']; } } @@ -54,6 +56,7 @@ class _BusinessAndFixPageState extends State @override Widget build(BuildContext context) { + final userProvider = Provider.of(context, listen: false); return AkuScaffold( title: '报事报修', appBarBottom: PreferredSize( @@ -65,20 +68,28 @@ class _BusinessAndFixPageState extends State ), body: TabBarView( controller: _tabController, - children: _tabs.map((e) => _buildTabView(_tabs.indexOf(e))).toList(), + children: [ + ...userProvider.infoModel.canOperation + ? [ + BussinessAndFixView( + status: 1, + ) + ] + : [], + BussinessAndFixView( + status: 2, + ), + BussinessAndFixView( + status: 3, + ), + BussinessAndFixView( + status: 4, + ), + BussinessAndFixView( + status: null, + ), + ], ), ); } - - Widget _buildTabView(int index) { - final fixProvider = Provider.of(context, listen: false); - List models = fixProvider.getFixModel(index, context); - return ListView.builder( - padding: EdgeInsets.symmetric(horizontal: 32.w), - itemBuilder: (context, index) { - return BusinessFixCard(model: models[index]); - }, - itemCount: models.length, - ); - } } diff --git a/lib/ui/sub_pages/business_and_fix/business_fix_card.dart b/lib/ui/sub_pages/business_and_fix/business_fix_card.dart index f472753..924239f 100644 --- a/lib/ui/sub_pages/business_and_fix/business_fix_card.dart +++ b/lib/ui/sub_pages/business_and_fix/business_fix_card.dart @@ -1,26 +1,23 @@ // Flutter imports: +import 'package:aku_community_manager/models/manager/bussiness_and_fix_model.dart'; +import 'package:aku_community_manager/tools/aku_map.dart'; import 'package:flutter/material.dart'; // Package imports: import 'package:aku_ui/common_widgets/aku_material_button.dart'; import 'package:common_utils/common_utils.dart'; -import 'package:get/get.dart'; import 'package:provider/provider.dart'; // Project imports: -import 'package:aku_community_manager/mock_models/fix/fix_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/screen_tool.dart'; import 'package:aku_community_manager/tools/widget_tool.dart'; -import 'package:aku_community_manager/ui/sub_pages/business_and_fix/business_and_fix_detail_page.dart'; -import 'package:aku_community_manager/ui/sub_pages/business_and_fix/fix_more_time_page.dart'; -import 'package:aku_community_manager/ui/sub_pages/business_and_fix/fix_work_finish_page.dart'; import 'package:aku_community_manager/ui/widgets/inner/aku_chip_box.dart'; class BusinessFixCard extends StatefulWidget { - final FixModel model; + final BussinessAndFixModel model; final bool homeDisplay; BusinessFixCard({Key key, @required this.model, this.homeDisplay = false}) : super(key: key); @@ -35,36 +32,37 @@ class _BusinessFixCardState extends State { return userProvider.userInfoModel.role; } - String get dateStart => DateUtil.formatDate(widget.model.dateStart, + String get dateStart => DateUtil.formatDateStr(widget.model.repairDate, format: 'yyyy-MM-dd HH:mm:ss'); - Widget get fixTypeWidget { - if (userRole == USER_ROLE.MANAGER) { - return Text( - FixModel.managerRoleMap[widget.model.type], - style: TextStyle( - color: widget.model.type != FIX_ENUM.DONE - ? Color(0XFFFF4501) - : AppStyle.minorTextColor, - ), - ); - } else { - return Text( - FixModel.otherRoleMap[widget.model.type], - style: TextStyle( - color: widget.model.type != FIX_ENUM.DONE - ? Color(0XFFFF4501) - : AppStyle.minorTextColor, - ), - ); - } - } + // Widget get fixTypeWidget { + // if (userRole == USER_ROLE.MANAGER) { + // return Text( + // FixModel.managerRoleMap[widget.model.type], + // style: TextStyle( + // color: widget.model.status > 3 + // ? Color(0XFFFF4501) + // : AppStyle.minorTextColor, + // ), + // ); + // } else { + // return Text( + // FixModel.otherRoleMap[widget.model.type], + // style: TextStyle( + // color: widget.model.type > 3 + // ? Color(0XFFFF4501) + // : AppStyle.minorTextColor, + // ), + // ); + // } + // } @override Widget build(BuildContext context) { + final userProvider = Provider.of(context, listen: false); return GestureDetector( onTap: () { - Get.to(BusinessAndFixDetailPage(model: widget.model)); + // Get.to(BusinessAndFixDetailPage(model: widget.model)); }, child: Container( padding: EdgeInsets.all(24.w), @@ -85,12 +83,22 @@ class _BusinessFixCardState extends State { ), ), ), - fixTypeWidget, + Text( + AkuMap.fixStatus( + userProvider.infoModel.canOperation, + userProvider.infoModel.canPickUpTicket, + widget.model.status), + style: TextStyle( + color: widget.model.status <4 + ? Color(0XFFFF4501) + : AppStyle.minorTextColor, + ), + ), ], ), widget.homeDisplay ? AkuBox.h(12) : AkuBox.h(24), Text( - widget.model.title, + widget.model.reportDetail, maxLines: widget.homeDisplay ? 1 : null, overflow: !widget.homeDisplay ? TextOverflow.visible @@ -121,21 +129,20 @@ class _BusinessFixCardState extends State { child: ListView.builder( scrollDirection: Axis.horizontal, itemBuilder: (context, index) { - var imgObj = widget.model.imgs[index]; + var imgObj = widget.model.imgUrls[index].url; return Container( margin: EdgeInsets.symmetric(horizontal: 8.w), height: 168.w, width: 168.w, decoration: BoxDecoration( borderRadius: BorderRadius.circular(4.w), - image: DecorationImage( - image: (imgObj is String) - ? AssetImage(imgObj) - : FileImage(imgObj)), ), + clipBehavior: Clip.antiAlias, + child: FadeInImage.assetNetwork( + placeholder: R.ASSETS_PLACEHOLDER_WEBP, image: imgObj), ); }, - itemCount: widget.model.imgs.length, + itemCount: widget.model.imgUrls.length, ), ); } @@ -143,7 +150,7 @@ class _BusinessFixCardState extends State { _buildBottomCard() { switch (userRole) { case USER_ROLE.FIXER: - if (widget.model.type == FIX_ENUM.DONE) return SizedBox(); + if (widget.model.status > 4) return SizedBox(); return Column( children: [ Divider( @@ -152,7 +159,7 @@ class _BusinessFixCardState extends State { Row( children: [ Spacer(), - widget.model.type == FIX_ENUM.PROCESSING + widget.model.status == 3 ? MaterialButton( padding: EdgeInsets.zero, height: 64.w, @@ -172,17 +179,15 @@ class _BusinessFixCardState extends State { ), ), onPressed: () { - Get.to(FixMoreTimePage(model: widget.model)); + // Get.to(FixMoreTimePage(model: widget.model)); }, ) : SizedBox(), - widget.model.type == FIX_ENUM.PROCESSING - ? AkuBox.w(24) - : SizedBox(), - widget.model.type == FIX_ENUM.PROCESSING + widget.model.status == 3 ? AkuBox.w(24) : SizedBox(), + widget.model.status == 3 ? AkuMaterialButton( onPressed: () { - Get.to(FixWorkFinishPage(model: widget.model)); + // Get.to(FixWorkFinishPage(model: widget.model)); }, radius: 4.w, color: AppStyle.primaryColor, @@ -197,17 +202,17 @@ class _BusinessFixCardState extends State { ), ) : SizedBox(), - widget.model.type == FIX_ENUM.WAIT_PICKUP + widget.model.status == 2 ? AkuMaterialButton( onPressed: () { - final userProvider = - Provider.of(context, listen: false); - widget.model.detail.fixStatuses.add(FixStatus( - title: '${userProvider.userInfoModel.nickName}已接单', - date: DateTime.now(), - )); - widget.model.type = FIX_ENUM.PROCESSING; - Get.back(); + // final userProvider = + // Provider.of(context, listen: false); + // widget.model.detail.fixStatuses.add(FixStatus( + // title: '${userProvider.userInfoModel.nickName}已接单', + // date: DateTime.now(), + // )); + // widget.model.type = FIX_ENUM.PROCESSING; + // Get.back(); }, radius: 4.w, color: AppStyle.primaryColor, @@ -236,7 +241,7 @@ class _BusinessFixCardState extends State { child: AkuMaterialButton( height: 64.w, onPressed: () { - Get.to(BusinessAndFixDetailPage(model: widget.model)); + // Get.to(BusinessAndFixDetailPage(model: widget.model)); }, radius: 4, color: AppStyle.primaryColor, diff --git a/lib/ui/sub_pages/business_and_fix/bussiness_and_fix_view.dart b/lib/ui/sub_pages/business_and_fix/bussiness_and_fix_view.dart new file mode 100644 index 0000000..43a8f4c --- /dev/null +++ b/lib/ui/sub_pages/business_and_fix/bussiness_and_fix_view.dart @@ -0,0 +1,50 @@ +import 'package:aku_community_manager/const/api.dart'; +import 'package:aku_community_manager/models/manager/bussiness_and_fix_model.dart'; +import 'package:aku_community_manager/ui/sub_pages/business_and_fix/business_fix_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:velocity_x/velocity_x.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class BussinessAndFixView extends StatefulWidget { + final int status; + BussinessAndFixView({Key key, this.status}) : super(key: key); + + @override + _BussinessAndFixViewState createState() => _BussinessAndFixViewState(); +} + +class _BussinessAndFixViewState extends State + with AutomaticKeepAliveClientMixin { + EasyRefreshController _easyRefreshController; + + @override + Widget build(BuildContext context) { + super.build(context); + return BeeListView( + path: API.manage.repairList, + extraParams: { + 'repairStatus': widget.status, + }, + controller: _easyRefreshController, + convert: (models) { + return models.tableList + .map((e) => BussinessAndFixModel.fromJson(e)) + .toList(); + }, + builder: (items) { + return ListView.separated( + itemBuilder: (context, index) { + return BusinessFixCard(model: items[index]); + }, + separatorBuilder: (_, __) { + return 16.w.heightBox; + }, + itemCount: items.length); + }); + } + + @override + bool get wantKeepAlive => true; +} diff --git a/lib/ui/sub_pages/visitor_manager/visitor_manager_page.dart b/lib/ui/sub_pages/visitor_manager/visitor_manager_page.dart index 57b2963..547b8a9 100644 --- a/lib/ui/sub_pages/visitor_manager/visitor_manager_page.dart +++ b/lib/ui/sub_pages/visitor_manager/visitor_manager_page.dart @@ -7,7 +7,6 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; // Project imports: import 'package:aku_community_manager/style/app_style.dart'; -import 'package:aku_community_manager/ui/sub_pages/visitor_manager/visitor_manager_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'; @@ -39,19 +38,6 @@ class _VisitorManagerPageState extends State with TickerProviderStateMixin { List _tabs = ['全部', '未到访', '已到访', '已过期']; - List _cards = [ - VisitorCardsModel( - adress: '深圳华悦茂峰1幢1单元702', - name: '马泽城', - status: VisitorStatus.VISIT_DONE, - plate: '浙BA9899', - time: '2020-10-24 12:00', - ), - VisitorCardsModel( - adress: '深圳华悦茂峰2幢2单元702', name: '刘揪心', status: VisitorStatus.NOT_VISIT), - VisitorCardsModel( - adress: '深圳华悦茂峰3幢3单元602', name: '张空间', status: VisitorStatus.OUTDATE), - ]; TabController _tabController; @override