From e8df4c569a1edeceaca8a5e5e1571cb0d0073ab7 Mon Sep 17 00:00:00 2001 From: zhangmeng <494089941@qq.com> Date: Mon, 12 Apr 2021 15:26:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=EF=BC=9A=20=E5=80=9F?= =?UTF-8?q?=E8=BF=98=E7=AE=A1=E7=90=86=20=E5=88=A0=E9=99=A4=E7=89=A9?= =?UTF-8?q?=E5=93=81=20=E6=98=8E=E7=BB=86=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/const/api.dart | 4 +- .../add_borrow_object_page.dart | 36 ----- .../borrow_manager/all_borrow_goods.dart | 10 +- .../borrow_manager/borrow_items_page.dart | 138 +++++++++--------- 4 files changed, 84 insertions(+), 104 deletions(-) diff --git a/lib/const/api.dart b/lib/const/api.dart index f75477a..5d40ee5 100644 --- a/lib/const/api.dart +++ b/lib/const/api.dart @@ -176,7 +176,9 @@ class _Manage { ///借还管理:新增总类 String get insertArticle => '/user/borrow/insertArticle'; - + + ///借还管理:删除物品明细信息 + String get borrowDelete => '/user/borrow/delete'; } class _Upload { diff --git a/lib/ui/sub_pages/borrow_manager/add_borrow_object_page.dart b/lib/ui/sub_pages/borrow_manager/add_borrow_object_page.dart index d14c055..0106922 100644 --- a/lib/ui/sub_pages/borrow_manager/add_borrow_object_page.dart +++ b/lib/ui/sub_pages/borrow_manager/add_borrow_object_page.dart @@ -35,48 +35,12 @@ class AddBorrowObjectPage extends StatefulWidget { class _AddBorrowObjectPageState extends State { TextEditingController _textEditingController = TextEditingController(); - // TextEditingController _numberController = TextEditingController(); File file; - // List get objects => BorrowData.borrowObjects; @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: () { - // if (TextUtil.isEmpty(_textEditingController.text)) { - // BotToast.showText(text: '名称不能为空'); - // } else if (file == null) { - // BotToast.showText(text: '图片不能为空'); - // } else if (int.tryParse(_numberController.text) == null) { - // BotToast.showText(text: '数量错误'); - // } else { - // objects.insert( - // 0, - // BorrowObject.init( - // name: _textEditingController.text, - // allNumber: int.parse(_numberController.text), - // assetPath: file, - // ), - // ); - // Get.back(); - // } - // }, - // child: Text( - // '完成', - // style: TextStyle( - // fontSize: 28.w, - // color: AppStyle.primaryTextColor, - // ), - // ), - // ) - // : SizedBox(), - // ], body: ListView( padding: EdgeInsets.symmetric(vertical: 16.w), children: [ 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 eb2c1fa..a86eb25 100644 --- a/lib/ui/sub_pages/borrow_manager/all_borrow_goods.dart +++ b/lib/ui/sub_pages/borrow_manager/all_borrow_goods.dart @@ -1,6 +1,7 @@ // 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/provider/user_provider.dart'; import 'package:aku_community_manager/ui/sub_pages/borrow_manager/add_borrow_object_page.dart'; import 'package:aku_community_manager/ui/widgets/common/bee_list_view.dart'; import 'package:aku_ui/common_widgets/aku_material_button.dart'; @@ -16,6 +17,7 @@ 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_items_page.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; +import 'package:provider/provider.dart'; class AllBorrowGoods extends StatefulWidget { AllBorrowGoods({Key key}) : super(key: key); @@ -28,12 +30,15 @@ class _AllBorrowGoodsState extends State { EasyRefreshController _refreshController = EasyRefreshController(); @override Widget build(BuildContext context) { + final userProvider = Provider.of(context); return AkuScaffold( title: '全部物品', - actions: [ AkuMaterialButton( + actions: [ + userProvider.infoModel.canOperation + ? AkuMaterialButton( minWidth: 120.w, onPressed: () { - Get.to(()=>AddBorrowObjectPage()); + Get.to(() => AddBorrowObjectPage()); }, child: Text( '新增', @@ -43,6 +48,7 @@ class _AllBorrowGoodsState extends State { ), ), ) + : SizedBox() ], body: BeeListView( path: API.manage.borrowList, 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 720cdda..3d15b1c 100644 --- a/lib/ui/sub_pages/borrow_manager/borrow_items_page.dart +++ b/lib/ui/sub_pages/borrow_manager/borrow_items_page.dart @@ -1,19 +1,20 @@ // 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/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/bee_list_view.dart'; +import 'package:aku_community_manager/utils/network/net_util.dart'; +import 'package:aku_ui/common_widgets/aku_material_button.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/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'; @@ -31,24 +32,25 @@ 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.infoModel.canOperation + ? AkuMaterialButton( + minWidth: 120.w, + onPressed: () { + // Get.to(AddBorrowItemPage(object: widget.object)); + }, + child: Text( + '新增', + style: TextStyle( + fontSize: 28.w, + color: AppStyle.primaryTextColor, + ), + ), + ) + : SizedBox(), ], body: BeeListView( path: API.manage.borrowDetailList, @@ -93,54 +95,60 @@ 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: () { - // //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(), + userProvider.infoModel.canOperation + ? 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: () async { + await NetUtil().post( + API.manage.borrowDelete, + params: { + "ids": [item.id] + }, + showMessage: true, + ); + _refreshController.callRefresh(); + 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(