diff --git a/.gitignore b/.gitignore index 2113af3..8e9efbc 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,4 @@ app.*.symbols app.*.map.json resource.dart flutter_sdk +local.properties diff --git a/analysis_options.yaml b/analysis_options.yaml index f08dcc0..0bf0251 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,3 +1,2 @@ analyzer: - errors: - unused_import: error \ No newline at end of file + errors: \ No newline at end of file diff --git a/assets/manage/estate.png b/assets/manage/estate.png new file mode 100644 index 0000000..f305c2e Binary files /dev/null and b/assets/manage/estate.png differ diff --git a/lib/const/api.dart b/lib/const/api.dart index b07ad2a..3c06ca0 100644 --- a/lib/const/api.dart +++ b/lib/const/api.dart @@ -11,6 +11,7 @@ class API { static String get resource => '$host/static'; static String image(String path) => '$resource$path'; + static String file(String path) => '$resource$path'; static const int networkTimeOut = 10000; @@ -19,7 +20,7 @@ class API { static _Manage manage = _Manage(); static _Upload upload = _Upload(); static _Message message = _Message(); - static _EngineerRepair engineerReapair = _EngineerRepair(); + static _EngineerRepair engineerRepair = _EngineerRepair(); } class _Auth { @@ -353,6 +354,10 @@ class _Upload { ///家政服务 上传处理完成照片 String get uploadHandlerPhoto => '/user/upload/uploadHousekeepingServiceHandlerPhone'; + + ///上传报事报修工程维修照片 + String get uploadEngineerRepair => + '/user/upload/uploadButlerAppEngineeringRepair'; } class _Message { diff --git a/lib/const/engineer_repair.dart b/lib/const/engineer_repair.dart index 7b4bee1..803873c 100644 --- a/lib/const/engineer_repair.dart +++ b/lib/const/engineer_repair.dart @@ -2,5 +2,8 @@ part of 'api.dart'; class _EngineerRepair { ///管家app 报事报修工程维修:查询所有的报事报修工程维修信息 - String get engineerRepair => '/user/repairEngineering/list'; + String get engineerRepairList => '/user/repairEngineering/list'; + + ///管家app 报事报修工程维修:添加报事报修工程维修 + String get engineerRepairInsert => '/user/repairEngineering/insert'; } diff --git a/lib/ui/home/application/applications_page.dart b/lib/ui/home/application/applications_page.dart index 3d443af..8cba679 100644 --- a/lib/ui/home/application/applications_page.dart +++ b/lib/ui/home/application/applications_page.dart @@ -1,43 +1,43 @@ // Flutter imports: -import 'package:aku_community_manager/models/user/user_info_model.dart'; -import 'package:aku_community_manager/tools/user_tool.dart'; -import 'package:aku_community_manager/ui/manage_pages/clock_in_out/clock_in_out_page.dart'; -import 'package:aku_community_manager/ui/manage_pages/facilities/facilities_select_page.dart'; -import 'package:aku_community_manager/ui/manage_pages/house_keeping/house_keeping_page.dart'; -import 'package:aku_community_manager/ui/manage_pages/interview/interview_page.dart'; -import 'package:aku_community_manager/ui/sub_pages/decoration_manager/new_renovation/new_renovation_page.dart'; -import 'package:aku_community_manager/ui/widgets/common/aku_material_button.dart'; -import 'package:flutter/material.dart'; - -// Package imports: -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/models/user/user_info_model.dart'; import 'package:aku_community_manager/provider/app_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/user_tool.dart'; import 'package:aku_community_manager/tools/widget_tool.dart'; +import 'package:aku_community_manager/ui/manage_pages/clock_in_out/clock_in_out_page.dart'; +import 'package:aku_community_manager/ui/manage_pages/engineer_repair/engineer_repair_page.dart'; +import 'package:aku_community_manager/ui/manage_pages/facilities/facilities_select_page.dart'; import 'package:aku_community_manager/ui/manage_pages/green_manage/green_manage_page.dart'; +import 'package:aku_community_manager/ui/manage_pages/house_keeping/house_keeping_page.dart'; import 'package:aku_community_manager/ui/manage_pages/hygience_manage/hygience_manage_page.dart'; import 'package:aku_community_manager/ui/manage_pages/inspection_manage/inspection_manage_page.dart'; +import 'package:aku_community_manager/ui/manage_pages/interview/interview_page.dart'; import 'package:aku_community_manager/ui/manage_pages/key_manage/key_manage_page.dart'; import 'package:aku_community_manager/ui/manage_pages/packages_manage/packages_manage_page.dart'; import 'package:aku_community_manager/ui/manage_pages/rules_manage/rules_manage_page.dart'; import 'package:aku_community_manager/ui/sub_pages/activity_manager/activity_manager_page.dart'; import 'package:aku_community_manager/ui/sub_pages/borrow_manager/borrow_manager_page.dart'; import 'package:aku_community_manager/ui/sub_pages/business_and_fix/business_and_fix_page.dart'; +import 'package:aku_community_manager/ui/sub_pages/decoration_manager/new_renovation/new_renovation_page.dart'; import 'package:aku_community_manager/ui/sub_pages/items_outdoor/items_outdoor_page.dart'; import 'package:aku_community_manager/ui/sub_pages/visitor_manager/visitor_manager_page.dart'; import 'package:aku_community_manager/ui/tool_pages/warning/warning_page.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_back_button.dart'; +import 'package:aku_community_manager/ui/widgets/common/aku_material_button.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; +import 'package:flutter/material.dart'; +// Package imports: +import 'package:get/get.dart'; +import 'package:provider/provider.dart'; class AppApplication { String name; String assetPath; dynamic page; + AppApplication( this.name, this.assetPath, @@ -100,6 +100,10 @@ class _ApplicationPageState extends State if (UserTool.userProvider.infoModel!.houseKeepingAuthority != HKAUTH.HIDE) AppApplication( '家政服务', R.ASSETS_HOME_HOUSE_KEEPING_PNG, () => HouseKeepingPage()), + if (UserTool.userProvider.infoModel!.engineeringRepairAuthority != + ERAUTH.HIDE) + AppApplication( + '工程维修', R.ASSETS_HOME_IC_SERVICE_PNG, () => EngineerRepairPage()), ]; @override diff --git a/lib/ui/home/home_page.dart b/lib/ui/home/home_page.dart index ba3de52..164138e 100644 --- a/lib/ui/home/home_page.dart +++ b/lib/ui/home/home_page.dart @@ -1,23 +1,6 @@ // Flutter imports: import 'dart:async'; -import 'package:aku_community_manager/provider/message_provider.dart'; -import 'package:aku_community_manager/ui/widgets/common/aku_button.dart'; -import 'package:aku_community_manager/ui/widgets/common/aku_material_button.dart'; -import 'package:aku_community_manager/utils/websocket/web_socket_util.dart'; -import 'package:bot_toast/bot_toast.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; - -// Package imports: -import 'package:badges/badges.dart'; -import 'package:carousel_slider/carousel_slider.dart'; -import 'package:dio/dio.dart'; -import 'package:flutter_easyrefresh/easy_refresh.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:get/get.dart' hide Response; -import 'package:provider/provider.dart'; - // Project imports: import 'package:aku_community_manager/const/api.dart'; import 'package:aku_community_manager/const/resource.dart'; @@ -27,6 +10,7 @@ import 'package:aku_community_manager/models/manager/item_num_model.dart'; import 'package:aku_community_manager/models/todo_bussiness/todo_model.dart'; import 'package:aku_community_manager/models/todo_bussiness/todo_outdoor_model.dart'; import 'package:aku_community_manager/provider/app_provider.dart'; +import 'package:aku_community_manager/provider/message_provider.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'; @@ -47,8 +31,22 @@ import 'package:aku_community_manager/ui/sub_pages/business_and_fix/business_fix import 'package:aku_community_manager/ui/sub_pages/visitor_manager/visitor_manager_page.dart'; import 'package:aku_community_manager/ui/tool_pages/warning/warning_page.dart'; import 'package:aku_community_manager/ui/widgets/app_widgets/aku_avatar.dart'; +import 'package:aku_community_manager/ui/widgets/common/aku_button.dart'; +import 'package:aku_community_manager/ui/widgets/common/aku_material_button.dart'; import 'package:aku_community_manager/utils/network/base_list_model.dart'; import 'package:aku_community_manager/utils/network/net_util.dart'; +import 'package:aku_community_manager/utils/websocket/web_socket_util.dart'; +// Package imports: +import 'package:badges/badges.dart'; +import 'package:bot_toast/bot_toast.dart'; +import 'package:carousel_slider/carousel_slider.dart'; +import 'package:dio/dio.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart' hide Response; +import 'package:provider/provider.dart'; class HomePage extends StatefulWidget { HomePage({ diff --git a/lib/ui/manage_pages/engineer_repair/add_engineer_repair_page.dart b/lib/ui/manage_pages/engineer_repair/add_engineer_repair_page.dart new file mode 100644 index 0000000..419dc22 --- /dev/null +++ b/lib/ui/manage_pages/engineer_repair/add_engineer_repair_page.dart @@ -0,0 +1,194 @@ +import 'dart:io'; + +import 'package:aku_community_manager/const/api.dart'; +import 'package:aku_community_manager/style/app_style.dart'; +import 'package:aku_community_manager/ui/manage_pages/engineer_repair/engineer_repair_func.dart'; +import 'package:aku_community_manager/ui/widgets/app_widgets/aku_pick_image_widget.dart'; +import 'package:aku_community_manager/ui/widgets/app_widgets/aku_single_check_button.dart'; +import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; +import 'package:aku_community_manager/ui/widgets/inner/aku_bottom_button.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/services.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; +import 'package:power_logger/power_logger.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class AddEngineerRepairPage extends StatefulWidget { + const AddEngineerRepairPage({Key? key}) : super(key: key); + + @override + _AddEngineerRepairPageState createState() => _AddEngineerRepairPageState(); +} + +class _AddEngineerRepairPageState extends State { + int _serviceType = 1; + List _photos = []; + String _area = ''; + String _detail = ''; + + @override + Widget build(BuildContext context) { + return AkuScaffold( + title: '工程报修', + backgroundColor: Colors.white, + body: ListView( + padding: EdgeInsets.symmetric(vertical: 32.w, horizontal: 32.w), + children: [ + '报修区域'.text.size(28.sp).color(kTextSubColor).make(), + 55.w.heightBox, + Row( + children: [ + Image.asset( + R.ASSETS_MANAGE_ESTATE_PNG, + width: 60.w, + height: 60.w, + ), + 36.w.widthBox, + '${S.of(context)!.tempPlotName}'.text.size(28.sp).make(), + ], + ), + 24.w.heightBox, + Container( + width: 686.w, + height: 87.w, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(8.w), + border: Border.all( + width: 2.w, + color: Color(0xFFE8E8E8), + ), + ), + child: TextField( + autofocus: false, + inputFormatters: [LengthLimitingTextInputFormatter(12)], + onChanged: (value) { + setState(() { + _area = value; + }); + }, + decoration: InputDecoration( + hintText: '请填写需要维修的区域,不超过12个字', + hintStyle: TextStyle( + fontSize: 28.sp, + color: kTextSubColor, + ), + contentPadding: + EdgeInsets.symmetric(vertical: 24.w, horizontal: 24.w), + border: InputBorder.none, + isDense: true, + ), + ), + ), + 40.w.heightBox, + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + '请选择服务类型'.text.color(kTextPrimaryColor).size(32.sp).make() + ], + ), + 32.w.heightBox, + Row( + children: [ + AkuSingleCheckButton( + text: '工程维修', + value: 1, + gropValue: _serviceType, + onPressed: () {}, + ), + 80.w.widthBox, + // AkuSingleCheckButton( + // text: '异常', + // value: 1, + // gropValue: 1, + // onPressed: () { + // }, + // ), + ], + ), + 36.w.heightBox, + '请输入报修内容'.text.size(28.sp).color(kTextPrimaryColor).make(), + 36.w.heightBox, + Container( + width: 686.w, + height: 300.w, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(8.w), + border: Border.all( + width: 2.w, + color: Color(0xFFE8E8E8), + ), + ), + child: TextField( + minLines: 5, + maxLines: 10, + autofocus: false, + onChanged: (value) { + setState(() { + _detail = value; + }); + }, + decoration: InputDecoration( + hintText: '请简要描述一下你要告知我的事情,以便于我们更好地处理…', + hintStyle: TextStyle( + fontSize: 28.sp, + color: kTextSubColor, + ), + contentPadding: + EdgeInsets.symmetric(vertical: 16.w, horizontal: 24.w), + border: InputBorder.none, + isDense: true, + ), + ), + ), + ], + ).box.make(), + 36.w.heightBox, + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + '添加照片信息'.text.color(kTextPrimaryColor).size(32.sp).make() + ], + ), + 32.w.heightBox, + AkuPickImageWidget( + onChanged: (files) { + _photos = files; + setState(() {}); + }, + ) + ], + ).box.make(), + ], + ), + bottom: AkuBottomButton( + title: '确认提交', + onTap: () async { + Function cancel = BotToast.showLoading(); + List urls = []; + try { + urls = await NetUtil().uploadFiles( + _photos, + API.upload.uploadEngineerRepair, + ); + } catch (e) { + LoggerData.addData(e.toString()); + } + var result = await EngineerRepairFunc.addEngineerRepair( + _area, _serviceType, _detail, urls); + if (result) { + Get.back(); + } + cancel(); + }, + ), + ); + } +} diff --git a/lib/ui/manage_pages/engineer_repair/engineer_repair_card.dart b/lib/ui/manage_pages/engineer_repair/engineer_repair_card.dart new file mode 100644 index 0000000..74f3854 --- /dev/null +++ b/lib/ui/manage_pages/engineer_repair/engineer_repair_card.dart @@ -0,0 +1,275 @@ +import 'package:aku_community_manager/const/api.dart'; +import 'package:aku_community_manager/json_models/manager/engineer_repair/engineer_repair_list_model.dart'; +import 'package:aku_community_manager/models/user/user_info_model.dart'; +import 'package:aku_community_manager/style/app_style.dart'; +import 'package:aku_community_manager/tools/user_tool.dart'; +import 'package:aku_community_manager/ui/manage_pages/engineer_repair/engineer_repair_map.dart'; +import 'package:aku_community_manager/ui/widgets/common/aku_material_button.dart'; +import 'package:aku_community_manager/ui/widgets/inner/aku_chip_box.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class EngineerRepairCard extends StatelessWidget { + final EngineerRepairListModel model; + final VoidCallback callRefresh; + + const EngineerRepairCard( + {Key? key, required this.model, required this.callRefresh}) + : super(key: key); + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: () async { + callRefresh(); + }, + child: Container( + padding: EdgeInsets.all(24.w), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Row( + children: [ + AkuChipBox(title: '公区维修'), + 16.w.widthBox, + Expanded( + child: Text( + model.createDate, + style: TextStyle( + color: AppStyle.minorTextColor, + fontSize: 22.sp, + ), + ), + ), + Text( + '${ERMap.statusString(model.status)}', + style: TextStyle( + color: Colors.red, + ), + ), + ], + ), + 24.w.heightBox, + Text( + model.reportDetail, + overflow: TextOverflow.visible, + style: TextStyle( + color: AppStyle.primaryTextColor, + fontSize: 28.sp, + fontWeight: FontWeight.bold, + ), + ), + 16.w.heightBox, + _buildImgs(), + _getBottomCard(), + ], + ), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(8.w), + ), + ), + ); + } + + _buildImgs() { + return Container( + height: 168.w, + child: ListView.builder( + scrollDirection: Axis.horizontal, + itemBuilder: (context, index) { + var imgObj = 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), + ), + clipBehavior: Clip.antiAlias, + child: FadeInImage.assetNetwork( + placeholder: R.ASSETS_PLACEHOLDER_WEBP, + image: API.image(imgObj ?? '')), + ); + }, + itemCount: model.imgUrls.length, + ), + ); + } + + _getBottomCard() { + return Column( + children: [ + Divider(height: 48.w), + Align( + alignment: Alignment.centerRight, + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: _getButtons())), + ], + ); + } + + _getButtons() { + switch (model.status) { + case 1: + return [ + AkuMaterialButton( + height: 64.w, + onPressed: () async { + callRefresh(); + }, + radius: 4, + color: AppStyle.primaryColor, + padding: EdgeInsets.symmetric(horizontal: 24.w), + child: Text( + (UserTool.userProvider.infoModel!.engineeringRepairAuthority == + ERAUTH.SENDTOCOMPANY + ? '分派单位' + : '查看详情'), + style: TextStyle( + color: AppStyle.primaryTextColor, + fontWeight: FontWeight.bold, + fontSize: 28.sp, + height: 40 / 28, + ), + ), + ), + ]; + case 2: + return [ + AkuMaterialButton( + height: 64.w, + onPressed: () async { + callRefresh(); + }, + radius: 4, + color: AppStyle.primaryColor, + padding: EdgeInsets.symmetric(horizontal: 24.w), + child: Text( + (UserTool.userProvider.infoModel!.engineeringRepairAuthority == + ERAUTH.SENDTOPERSON + ? '指派人员' + : '查看详情'), + style: TextStyle( + color: AppStyle.primaryTextColor, + fontWeight: FontWeight.bold, + fontSize: 28.sp, + height: 40 / 28, + ), + ), + ), + ]; + case 3: + return [ + UserTool.userProvider.infoModel!.engineeringRepairAuthority == + ERAUTH.PICK + ? AkuMaterialButton( + height: 64.w, + onPressed: () async { + callRefresh(); + }, + radius: 4, + color: AppStyle.primaryColor, + padding: EdgeInsets.symmetric(horizontal: 24.w), + child: Text( + ('立即接单'), + style: TextStyle( + color: AppStyle.primaryTextColor, + fontWeight: FontWeight.bold, + fontSize: 28.sp, + height: 40 / 28, + ), + ), + ) + : SizedBox(), + 12.w.widthBox, + AkuMaterialButton( + height: 64.w, + onPressed: () async { + callRefresh(); + }, + radius: 4, + color: AppStyle.primaryColor, + padding: EdgeInsets.symmetric(horizontal: 24.w), + child: Text( + ('查看详情'), + style: TextStyle( + color: AppStyle.primaryTextColor, + fontWeight: FontWeight.bold, + fontSize: 28.sp, + height: 40 / 28, + ), + ), + ), + ]; + case 4: + return [ + AkuMaterialButton( + height: 64.w, + onPressed: () async { + callRefresh(); + }, + radius: 4, + color: AppStyle.primaryColor, + padding: EdgeInsets.symmetric(horizontal: 24.w), + child: Text( + ('汇报进度'), + style: TextStyle( + color: AppStyle.primaryTextColor, + fontWeight: FontWeight.bold, + fontSize: 28.sp, + height: 40 / 28, + ), + ), + ), + ];case 5: + case 6: + return [ + AkuMaterialButton( + height: 64.w, + onPressed: () async { + callRefresh(); + }, + radius: 4, + color: AppStyle.primaryColor, + padding: EdgeInsets.symmetric(horizontal: 24.w), + child: Text( + ('验收记录'), + style: TextStyle( + color: AppStyle.primaryTextColor, + fontWeight: FontWeight.bold, + fontSize: 28.sp, + height: 40 / 28, + ), + ), + ), + ]; + case 7: + return [ + AkuMaterialButton( + height: 64.w, + onPressed: () async { + callRefresh(); + }, + radius: 4, + color: AppStyle.primaryColor, + padding: EdgeInsets.symmetric(horizontal: 24.w), + child: Text( + ('查看详情'), + style: TextStyle( + color: AppStyle.primaryTextColor, + fontWeight: FontWeight.bold, + fontSize: 28.sp, + height: 40 / 28, + ), + ), + ), + ]; + default: + return []; + } + } +} diff --git a/lib/ui/manage_pages/engineer_repair/engineer_repair_func.dart b/lib/ui/manage_pages/engineer_repair/engineer_repair_func.dart new file mode 100644 index 0000000..d92ebdb --- /dev/null +++ b/lib/ui/manage_pages/engineer_repair/engineer_repair_func.dart @@ -0,0 +1,16 @@ +import 'package:aku_community_manager/const/api.dart'; +import 'package:aku_community_manager/utils/network/net_util.dart'; + +class EngineerRepairFunc { + static Future addEngineerRepair( + String area, int type, String reportDetail, List urls) async { + var model = + await NetUtil().post(API.engineerRepair.engineerRepairInsert, params: { + 'repairArea': area, + 'type': type, + 'reportDetail': reportDetail, + 'fileUrls': urls, + }); + return model.status ?? false; + } +} diff --git a/lib/ui/manage_pages/engineer_repair/engineer_repair_map.dart b/lib/ui/manage_pages/engineer_repair/engineer_repair_map.dart new file mode 100644 index 0000000..12f01b1 --- /dev/null +++ b/lib/ui/manage_pages/engineer_repair/engineer_repair_map.dart @@ -0,0 +1,26 @@ +class ERMap { + static statusString(int status) { + switch (status) { + case 1: + return '待派单'; + case 2: + return '待派单'; + case 3: + return '待接单'; + case 4: + return '处理中'; + case 5: + return '待验收'; + case 6: + return '验收失败'; + case 7: + return '验收成功'; + case 8: + return '已作废'; + case 9: + return '已取消'; + default: + return '未知'; + } + } +} diff --git a/lib/ui/manage_pages/engineer_repair/engineer_repair_page.dart b/lib/ui/manage_pages/engineer_repair/engineer_repair_page.dart index 6b55cff..c518798 100644 --- a/lib/ui/manage_pages/engineer_repair/engineer_repair_page.dart +++ b/lib/ui/manage_pages/engineer_repair/engineer_repair_page.dart @@ -1,10 +1,14 @@ import 'package:aku_community_manager/models/user/user_info_model.dart'; import 'package:aku_community_manager/tools/user_tool.dart'; +import 'package:aku_community_manager/ui/manage_pages/engineer_repair/add_engineer_repair_page.dart'; import 'package:aku_community_manager/ui/manage_pages/engineer_repair/engineer_repair_view.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; +import 'package:aku_community_manager/ui/widgets/inner/aku_bottom_button.dart'; import 'package:aku_community_manager/ui/widgets/inner/aku_tab_bar.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; import 'package:velocity_x/velocity_x.dart'; class EngineerRepairPage extends StatefulWidget { @@ -30,10 +34,22 @@ class _EngineerRepairPageState extends State } late TabController _tabController; + List _controllers = []; + @override void initState() { super.initState(); _tabController = TabController(length: _tabs.length, vsync: this); + _tabs.forEach((element) { + _controllers.add(EasyRefreshController()); + }); + } + + @override + void dispose() { + _tabController.dispose(); + _controllers.map((e) => e.dispose()); + super.dispose(); } @override @@ -42,12 +58,27 @@ class _EngineerRepairPageState extends State title: '工程维修', appBarBottom: PreferredSize( preferredSize: Size.fromHeight(88.w), - child: AkuTabBar(controller: _tabController, tabs: _tabs), - + child: AkuTabBar( + controller: _tabController, + tabs: _tabs, + isScrollable: true, + ), ), body: TabBarView( - controller: _tabController, - children: _tabs.mapIndexed((currentValue, index) => EngineerRepairView()).toList()), + controller: _tabController, + children: _tabs + .mapIndexed((currentValue, index) => EngineerRepairView( + index: index, + controller: _controllers[index], + )) + .toList()), + bottom: AkuBottomButton( + title: '新增', + onTap: () async { + await Get.to(() => AddEngineerRepairPage()); + _controllers[_tabController.index].callRefresh(); + }, + ), ); } } diff --git a/lib/ui/manage_pages/engineer_repair/engineer_repair_view.dart b/lib/ui/manage_pages/engineer_repair/engineer_repair_view.dart index 2d02508..760f5fd 100644 --- a/lib/ui/manage_pages/engineer_repair/engineer_repair_view.dart +++ b/lib/ui/manage_pages/engineer_repair/engineer_repair_view.dart @@ -1,15 +1,74 @@ +import 'package:aku_community_manager/const/api.dart'; +import 'package:aku_community_manager/json_models/manager/engineer_repair/engineer_repair_list_model.dart'; +import 'package:aku_community_manager/models/user/user_info_model.dart'; +import 'package:aku_community_manager/tools/user_tool.dart'; +import 'package:aku_community_manager/ui/manage_pages/engineer_repair/engineer_repair_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'; +import 'package:velocity_x/velocity_x.dart'; class EngineerRepairView extends StatefulWidget { - EngineerRepairView({Key? key}) : super(key: key); + final int index; + final EasyRefreshController controller; + EngineerRepairView({Key? key, required this.index, required this.controller}) + : super(key: key); @override _EngineerRepairViewState createState() => _EngineerRepairViewState(); } class _EngineerRepairViewState extends State { + int? get repairEngineeringStatus { + if (widget.index == 0) { + return null; + } else if (widget.index == 1) { + switch (UserTool.userProvider.infoModel!.engineeringRepairAuthority) { + case ERAUTH.SENDTOCOMPANY: + return 1; + case ERAUTH.SENDTOPERSON: + return 2; + case ERAUTH.PICK: + return 3; + case ERAUTH.HIDE: + break; + } + } else { + UserTool.userProvider.infoModel!.engineeringRepairAuthority == ERAUTH.PICK + ? widget.index + 2 + : widget.index + 1; + } + } + @override Widget build(BuildContext context) { - return ListView(); + return BeeListView( + path: API.engineerRepair.engineerRepairList, + extraParams: { + 'repairStatus': repairEngineeringStatus, + }, + controller: widget.controller, + convert: (models) { + return models.tableList! + .map((e) => EngineerRepairListModel.fromJson(e)) + .toList(); + }, + builder: (items) { + return ListView.separated( + padding: EdgeInsets.all(32.w), + itemBuilder: (context, index) { + var model = items[index]; + return EngineerRepairCard( + model: model, + callRefresh: () { + widget.controller.callRefresh(); + }); + }, + separatorBuilder: (_, __) { + return 16.w.heightBox; + }, + itemCount: items.length); + }); } }