Showing
10 changed files
with
575 additions
and
154 deletions
| @@ -4,6 +4,12 @@ | @@ -4,6 +4,12 @@ | ||
| 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 |
| 5 | "version": "0.2.0", | 5 | "version": "0.2.0", |
| 6 | "configurations": [ | 6 | "configurations": [ |
| 7 | + // { | ||
| 8 | + // "name": "Flutter", | ||
| 9 | + // "type": "dart", | ||
| 10 | + // "request": "launch", | ||
| 11 | + // "program": "lib/main.dart" | ||
| 12 | + // }, | ||
| 7 | { | 13 | { |
| 8 | "name": "oneKey_wdn", | 14 | "name": "oneKey_wdn", |
| 9 | "request": "launch", | 15 | "request": "launch", |
| @@ -482,7 +482,7 @@ | @@ -482,7 +482,7 @@ | ||
| 482 | CURRENT_PROJECT_VERSION = 296; | 482 | CURRENT_PROJECT_VERSION = 296; |
| 483 | DEVELOPMENT_TEAM = 8J59HM8B82; | 483 | DEVELOPMENT_TEAM = 8J59HM8B82; |
| 484 | ENABLE_BITCODE = NO; | 484 | ENABLE_BITCODE = NO; |
| 485 | - FLUTTER_BUILD_MODE = release; | 485 | + FLUTTER_BUILD_MODE = debug; |
| 486 | FRAMEWORK_SEARCH_PATHS = ( | 486 | FRAMEWORK_SEARCH_PATHS = ( |
| 487 | "$(inherited)", | 487 | "$(inherited)", |
| 488 | "$(PROJECT_DIR)/Flutter", | 488 | "$(PROJECT_DIR)/Flutter", |
| @@ -627,7 +627,7 @@ | @@ -627,7 +627,7 @@ | ||
| 627 | CURRENT_PROJECT_VERSION = 296; | 627 | CURRENT_PROJECT_VERSION = 296; |
| 628 | DEVELOPMENT_TEAM = 8J59HM8B82; | 628 | DEVELOPMENT_TEAM = 8J59HM8B82; |
| 629 | ENABLE_BITCODE = NO; | 629 | ENABLE_BITCODE = NO; |
| 630 | - FLUTTER_BUILD_MODE = release; | 630 | + FLUTTER_BUILD_MODE = debug; |
| 631 | FRAMEWORK_SEARCH_PATHS = ( | 631 | FRAMEWORK_SEARCH_PATHS = ( |
| 632 | "$(inherited)", | 632 | "$(inherited)", |
| 633 | "$(PROJECT_DIR)/Flutter", | 633 | "$(PROJECT_DIR)/Flutter", |
| @@ -86,6 +86,9 @@ class PersonnelManageSunModel extends Object { | @@ -86,6 +86,9 @@ class PersonnelManageSunModel extends Object { | ||
| 86 | @JsonKey(name: 'user_name') | 86 | @JsonKey(name: 'user_name') |
| 87 | String userName; | 87 | String userName; |
| 88 | 88 | ||
| 89 | + @JsonKey(name: 'nick_name') | ||
| 90 | + String nickName; | ||
| 91 | + | ||
| 89 | @JsonKey(name: 'is_first') | 92 | @JsonKey(name: 'is_first') |
| 90 | String isFirst; | 93 | String isFirst; |
| 91 | 94 | ||
| @@ -111,6 +114,7 @@ class PersonnelManageSunModel extends Object { | @@ -111,6 +114,7 @@ class PersonnelManageSunModel extends Object { | ||
| 111 | this.id, | 114 | this.id, |
| 112 | this.openid, | 115 | this.openid, |
| 113 | this.userName, | 116 | this.userName, |
| 117 | + this.nickName, | ||
| 114 | this.isFirst, | 118 | this.isFirst, |
| 115 | this.roleId, | 119 | this.roleId, |
| 116 | this.phone, | 120 | this.phone, |
| @@ -11,7 +11,8 @@ PersonnelManageModel _$PersonnelManageModelFromJson(Map<String, dynamic> json) { | @@ -11,7 +11,8 @@ PersonnelManageModel _$PersonnelManageModelFromJson(Map<String, dynamic> json) { | ||
| 11 | json['ret'] as int, | 11 | json['ret'] as int, |
| 12 | json['data'] == null | 12 | json['data'] == null |
| 13 | ? null | 13 | ? null |
| 14 | - : PersonnelManageModelData.fromJson(json['data'] as Map<String, dynamic>), | 14 | + : PersonnelManageModelData.fromJson( |
| 15 | + json['data'] as Map<String, dynamic>), | ||
| 15 | json['msg'] as String, | 16 | json['msg'] as String, |
| 16 | ); | 17 | ); |
| 17 | } | 18 | } |
| @@ -24,7 +25,8 @@ Map<String, dynamic> _$PersonnelManageModelToJson( | @@ -24,7 +25,8 @@ Map<String, dynamic> _$PersonnelManageModelToJson( | ||
| 24 | 'msg': instance.msg, | 25 | 'msg': instance.msg, |
| 25 | }; | 26 | }; |
| 26 | 27 | ||
| 27 | -PersonnelManageModelData _$PersonnelManageModelDataFromJson(Map<String, dynamic> json) { | 28 | +PersonnelManageModelData _$PersonnelManageModelDataFromJson( |
| 29 | + Map<String, dynamic> json) { | ||
| 28 | return PersonnelManageModelData( | 30 | return PersonnelManageModelData( |
| 29 | json['admin'] == null | 31 | json['admin'] == null |
| 30 | ? null | 32 | ? null |
| @@ -44,7 +46,9 @@ PersonnelManageModelData _$PersonnelManageModelDataFromJson(Map<String, dynamic> | @@ -44,7 +46,9 @@ PersonnelManageModelData _$PersonnelManageModelDataFromJson(Map<String, dynamic> | ||
| 44 | ); | 46 | ); |
| 45 | } | 47 | } |
| 46 | 48 | ||
| 47 | -Map<String, dynamic> _$PersonnelManageModelDataToJson(PersonnelManageModelData instance) => <String, dynamic>{ | 49 | +Map<String, dynamic> _$PersonnelManageModelDataToJson( |
| 50 | + PersonnelManageModelData instance) => | ||
| 51 | + <String, dynamic>{ | ||
| 48 | 'admin': instance.admin, | 52 | 'admin': instance.admin, |
| 49 | 'shopowner': instance.shopowner, | 53 | 'shopowner': instance.shopowner, |
| 50 | 'cashier': instance.cashier, | 54 | 'cashier': instance.cashier, |
| @@ -74,6 +78,7 @@ PersonnelManageSunModel _$PersonnelManageSunModelFromJson( | @@ -74,6 +78,7 @@ PersonnelManageSunModel _$PersonnelManageSunModelFromJson( | ||
| 74 | json['id'] as String, | 78 | json['id'] as String, |
| 75 | json['openid'] as String, | 79 | json['openid'] as String, |
| 76 | json['user_name'] as String, | 80 | json['user_name'] as String, |
| 81 | + json['nick_name'] as String, | ||
| 77 | json['is_first'] as String, | 82 | json['is_first'] as String, |
| 78 | json['role_id'] as String, | 83 | json['role_id'] as String, |
| 79 | json['phone'] as String, | 84 | json['phone'] as String, |
| @@ -90,6 +95,7 @@ Map<String, dynamic> _$PersonnelManageSunModelToJson( | @@ -90,6 +95,7 @@ Map<String, dynamic> _$PersonnelManageSunModelToJson( | ||
| 90 | 'id': instance.id, | 95 | 'id': instance.id, |
| 91 | 'openid': instance.openid, | 96 | 'openid': instance.openid, |
| 92 | 'user_name': instance.userName, | 97 | 'user_name': instance.userName, |
| 98 | + 'nick_name':instance.nickName, | ||
| 93 | 'is_first': instance.isFirst, | 99 | 'is_first': instance.isFirst, |
| 94 | 'role_id': instance.roleId, | 100 | 'role_id': instance.roleId, |
| 95 | 'phone': instance.phone, | 101 | 'phone': instance.phone, |
| @@ -154,5 +154,15 @@ class HttpUrl { | @@ -154,5 +154,15 @@ class HttpUrl { | ||
| 154 | "?service=App.Cookbook.GetCookbookById"; // 获取单个菜品信息 | 154 | "?service=App.Cookbook.GetCookbookById"; // 获取单个菜品信息 |
| 155 | static const String get_auth_user_lists = | 155 | static const String get_auth_user_lists = |
| 156 | "?service=App.Seller.GetAuthUserLists"; // 店员列表 | 156 | "?service=App.Seller.GetAuthUserLists"; // 店员列表 |
| 157 | + static const String add_seller_clerk = | ||
| 158 | + "?service=App.Seller.AddsellerClerk"; // 添加店员 | ||
| 159 | + static const String set_user_is_call = | ||
| 160 | + "?service=App.Seller.SetUserIsCall"; // 运营设置商家接单人 | ||
| 161 | + static const String delete_auth_user = | ||
| 162 | + "?service=App.Seller.DeleteAuthUser"; // 删除店员 | ||
| 163 | + static const String edit_auth_user = | ||
| 164 | + "?service=App.Seller.EditAuthUser"; // 编辑店员 | ||
| 165 | + static const String bind_phone_seller_user = | ||
| 166 | + "?service=App.Seller.BindPhoneSellerUser"; // 账号表-员工绑定手机号 | ||
| 157 | 167 | ||
| 158 | } | 168 | } |
| 1 | import 'package:cached_network_image/cached_network_image.dart'; | 1 | import 'package:cached_network_image/cached_network_image.dart'; |
| 2 | import 'package:flutter/material.dart'; | 2 | import 'package:flutter/material.dart'; |
| 3 | import 'package:flutter_screenutil/screenutil.dart'; | 3 | import 'package:flutter_screenutil/screenutil.dart'; |
| 4 | +import 'package:one_key/models/get_seller_info_model.dart'; | ||
| 4 | import 'package:one_key/models/personnel_manage_model.dart'; | 5 | import 'package:one_key/models/personnel_manage_model.dart'; |
| 6 | +import 'package:one_key/provider/personnel_provider.dart'; | ||
| 5 | import 'package:one_key/provider/user_model.dart'; | 7 | import 'package:one_key/provider/user_model.dart'; |
| 6 | import 'package:one_key/res/colors.dart'; | 8 | import 'package:one_key/res/colors.dart'; |
| 9 | +import 'package:one_key/utils/dialog_util.dart'; | ||
| 10 | +import 'package:one_key/utils/event_bus.dart'; | ||
| 7 | import 'package:one_key/utils/utils.dart'; | 11 | import 'package:one_key/utils/utils.dart'; |
| 8 | import 'package:one_key/widgets/MyDivider.dart'; | 12 | import 'package:one_key/widgets/MyDivider.dart'; |
| 9 | import 'package:one_key/widgets/h_empty_view.dart'; | 13 | import 'package:one_key/widgets/h_empty_view.dart'; |
| @@ -22,20 +26,197 @@ class PersonnelDetailPage extends StatefulWidget { | @@ -22,20 +26,197 @@ class PersonnelDetailPage extends StatefulWidget { | ||
| 22 | } | 26 | } |
| 23 | 27 | ||
| 24 | class _PersonnelDetailPageState extends State<PersonnelDetailPage> { | 28 | class _PersonnelDetailPageState extends State<PersonnelDetailPage> { |
| 29 | + String roleNameLogin; | ||
| 30 | + String accountLogin; | ||
| 31 | + bool canEdit = false; | ||
| 32 | + List<String> btnList = []; | ||
| 33 | + UserModel userModel; | ||
| 34 | + PersonnelProvider personnelProvider; | ||
| 35 | + String nickName; | ||
| 36 | + String phone; | ||
| 37 | + String dcAdduserCode; | ||
| 38 | + | ||
| 39 | + @override | ||
| 40 | + void initState() { | ||
| 41 | + super.initState(); | ||
| 42 | + nickName = widget.model.nickName != null && widget.model.nickName != 'null' | ||
| 43 | + ? widget.model.nickName | ||
| 44 | + : '暂未设置名称'; | ||
| 45 | + phone = widget.model.phone != null && widget.model.userName != 'null' | ||
| 46 | + ? widget.model.phone | ||
| 47 | + : '添加手机号'; | ||
| 48 | + WidgetsBinding.instance.addPostFrameCallback((timeStamp) { | ||
| 49 | + if (widget.model.openid == null || widget.model.openid == 'null') { | ||
| 50 | + _getStoreBaseinfo(); | ||
| 51 | + } | ||
| 52 | + setState(() { | ||
| 53 | + roleNameLogin = userModel.user.role_name; | ||
| 54 | + accountLogin = userModel.user.account; | ||
| 55 | + | ||
| 56 | + if (roleNameLogin == '管理员') { | ||
| 57 | + canEdit = true; | ||
| 58 | + } else if (roleNameLogin == '店长') { | ||
| 59 | + if (widget.position == '管理员') { | ||
| 60 | + canEdit = false; | ||
| 61 | + } else if (widget.position == '店长') { | ||
| 62 | + if (accountLogin == widget.model.account) { | ||
| 63 | + print('11111'); | ||
| 64 | + //店长自己 | ||
| 65 | + canEdit = true; | ||
| 66 | + } else { | ||
| 67 | + print('333333'); | ||
| 68 | + canEdit = false; | ||
| 69 | + } | ||
| 70 | + } else { | ||
| 71 | + canEdit = true; | ||
| 72 | + } | ||
| 73 | + } else { | ||
| 74 | + if (accountLogin == widget.model.account) { | ||
| 75 | + //自己 | ||
| 76 | + canEdit = true; | ||
| 77 | + } else { | ||
| 78 | + canEdit = false; | ||
| 79 | + } | ||
| 80 | + } | ||
| 81 | + if (canEdit) { | ||
| 82 | + btnList = [ | ||
| 83 | + '移除店员', | ||
| 84 | + ]; | ||
| 85 | + if (widget.model.openid == null || widget.model.openid == 'null') { | ||
| 86 | + btnList.add('绑定微信'); | ||
| 87 | + } | ||
| 88 | + btnList.add('查看密码'); | ||
| 89 | + if (widget.model.isOnCall == '0') { | ||
| 90 | + btnList.add('设为接单人'); | ||
| 91 | + } | ||
| 92 | + } else { | ||
| 93 | + btnList = []; | ||
| 94 | + } | ||
| 95 | + }); | ||
| 96 | + }); | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + ///获取店铺信息 | ||
| 100 | + _getStoreBaseinfo() async { | ||
| 101 | + GetSellerInfoSunModel itemModel = | ||
| 102 | + await personnelProvider.getSellerById(context); | ||
| 103 | + if (itemModel != null) { | ||
| 104 | + dcAdduserCode = itemModel.data.dcAdduserCode; | ||
| 105 | + } | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + ///设置接单人 | ||
| 109 | + _setUserIsCall({bool showLoading = true}) async { | ||
| 110 | + Map<String, String> params = { | ||
| 111 | + "sid": Provider.of<UserModel>(context, listen: false).user.sellerid, | ||
| 112 | + 'uid': widget.model.id | ||
| 113 | + }; | ||
| 114 | + | ||
| 115 | + bool success = await personnelProvider.setUserIsCall(context, params, | ||
| 116 | + showLoading: showLoading); | ||
| 117 | + if (success) { | ||
| 118 | + Utils.showToast('设置成功'); | ||
| 119 | + EventBus().emit('personnel_manage_page'); | ||
| 120 | + //刷新页面 | ||
| 121 | + setState(() { | ||
| 122 | + btnList.remove('设为接单人'); | ||
| 123 | + }); | ||
| 124 | + } | ||
| 125 | + } | ||
| 126 | + | ||
| 127 | + ///删除店员 | ||
| 128 | + _delSellerClerk({bool showLoading = true}) async { | ||
| 129 | + Map<String, String> params = {'seller_user_id': widget.model.id}; | ||
| 130 | + | ||
| 131 | + bool success = await personnelProvider.delSellerClerk(context, params, | ||
| 132 | + showLoading: showLoading); | ||
| 133 | + if (success) { | ||
| 134 | + EventBus().emit('personnel_manage_page'); | ||
| 135 | + Navigator.pop(context); | ||
| 136 | + } | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | + ///编辑店员 | ||
| 140 | + _editAuthUser(String name, {bool showLoading = true}) async { | ||
| 141 | + Map<String, String> params = {'id': widget.model.id, 'user_name': name}; | ||
| 142 | + | ||
| 143 | + bool success = await personnelProvider.editAuthUser(context, params, | ||
| 144 | + showLoading: showLoading); | ||
| 145 | + if (success) { | ||
| 146 | + EventBus().emit('personnel_manage_page'); | ||
| 147 | + setState(() { | ||
| 148 | + nickName = name; | ||
| 149 | + }); | ||
| 150 | + } | ||
| 151 | + } | ||
| 152 | + | ||
| 153 | + /// 账号表-员工绑定手机号 | ||
| 154 | + _bindPhoneSellerUser(String name, {bool showLoading = true}) async { | ||
| 155 | + Map<String, String> params = {'kid': widget.model.id, 'phone': name}; | ||
| 156 | + | ||
| 157 | + bool success = await personnelProvider.bindPhoneSellerUser(context, params, | ||
| 158 | + showLoading: showLoading); | ||
| 159 | + if (success) { | ||
| 160 | + EventBus().emit('personnel_manage_page'); | ||
| 161 | + setState(() { | ||
| 162 | + phone = name; | ||
| 163 | + }); | ||
| 164 | + } | ||
| 165 | + } | ||
| 166 | + | ||
| 167 | + List<Widget> _listWidget(List<String> titleList) { | ||
| 168 | + List<Widget> list = []; | ||
| 169 | + titleList.forEach((element) { | ||
| 170 | + list.add( | ||
| 171 | + RoundButton( | ||
| 172 | + text: element, | ||
| 173 | + fontSize: 30, | ||
| 174 | + isBold: false, | ||
| 175 | + height: ScreenUtil().setWidth(80), | ||
| 176 | + // width: double.infinity, | ||
| 177 | + width: (ScreenUtil.screenWidthDp - ScreenUtil().setWidth(140)) / 2, | ||
| 178 | + radius: ScreenUtil().setWidth(10), | ||
| 179 | + onPressed: () { | ||
| 180 | + if (element == '设为接单人') { | ||
| 181 | + DialogUtil.cupertinoAlertDialog(context, | ||
| 182 | + content: '请确认该用户关注了周到安排公众号并填写了手机号,否则无法接单', rCallback: () { | ||
| 183 | + _setUserIsCall(); | ||
| 184 | + }); | ||
| 185 | + } else if (element == '移除店员') { | ||
| 186 | + DialogUtil.cupertinoAlertDialog(context, | ||
| 187 | + title: '提示', | ||
| 188 | + content: '移除店员后,店员将无法接收门店收款通知,店员收款码也将无法收款', | ||
| 189 | + rTitle: '移除', rCallback: () { | ||
| 190 | + _delSellerClerk(); | ||
| 191 | + }); | ||
| 192 | + } else if (element == '绑定微信') { | ||
| 193 | + DialogUtil.openAlertDialogImage( | ||
| 194 | + context, '请员工使用微信扫一扫添加店员', dcAdduserCode, 660); | ||
| 195 | + } else if (element == '查看密码') {} | ||
| 196 | + }, | ||
| 197 | + ), | ||
| 198 | + ); | ||
| 199 | + }); | ||
| 200 | + return list; | ||
| 201 | + } | ||
| 202 | + | ||
| 25 | @override | 203 | @override |
| 26 | Widget build(BuildContext context) { | 204 | Widget build(BuildContext context) { |
| 205 | + userModel = Provider.of<UserModel>(context, listen: false); | ||
| 206 | + personnelProvider = Provider.of<PersonnelProvider>(context, listen: true); | ||
| 27 | return Scaffold( | 207 | return Scaffold( |
| 28 | backgroundColor: MyColours.color_ffffff, | 208 | backgroundColor: MyColours.color_ffffff, |
| 29 | - appBar: SystemAppBar('店员详情'), | 209 | + appBar: SystemAppBar( |
| 210 | + '店员详情', | ||
| 211 | + onTap: () { | ||
| 212 | + Navigator.pop(context); | ||
| 213 | + }, | ||
| 214 | + ), | ||
| 30 | body: SingleChildScrollView( | 215 | body: SingleChildScrollView( |
| 31 | child: Column( | 216 | child: Column( |
| 32 | children: [ | 217 | children: [ |
| 33 | Container( | 218 | Container( |
| 34 | margin: EdgeInsets.all(ScreenUtil().setWidth(40)), | 219 | margin: EdgeInsets.all(ScreenUtil().setWidth(40)), |
| 35 | - // decoration: BoxDecoration( | ||
| 36 | - // border: Border.all(color: Color.fromRGBO(235, 234, 239, 1)), | ||
| 37 | - // borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10)), | ||
| 38 | - // ), | ||
| 39 | child: Column( | 220 | child: Column( |
| 40 | crossAxisAlignment: CrossAxisAlignment.center, | 221 | crossAxisAlignment: CrossAxisAlignment.center, |
| 41 | children: [ | 222 | children: [ |
| @@ -54,37 +235,75 @@ class _PersonnelDetailPageState extends State<PersonnelDetailPage> { | @@ -54,37 +235,75 @@ class _PersonnelDetailPageState extends State<PersonnelDetailPage> { | ||
| 54 | width: ScreenUtil().setWidth(38 * 2), | 235 | width: ScreenUtil().setWidth(38 * 2), |
| 55 | height: ScreenUtil().setWidth(38 * 2), | 236 | height: ScreenUtil().setWidth(38 * 2), |
| 56 | ), | 237 | ), |
| 57 | - VEmptyView(30), | ||
| 58 | - Row( | ||
| 59 | - mainAxisAlignment: MainAxisAlignment.center, | ||
| 60 | - children: [ | ||
| 61 | - Text( | ||
| 62 | - widget.model.userName != null && | ||
| 63 | - widget.model.userName != 'null' | ||
| 64 | - ? widget.model.userName | ||
| 65 | - : '暂未设置名称', | ||
| 66 | - style: TextStyle( | ||
| 67 | - fontSize: ScreenUtil().setWidth(34), | ||
| 68 | - color: MyColours.color_333333), | ||
| 69 | - ), | ||
| 70 | - HEmptyView(20), | ||
| 71 | - Image.asset( | ||
| 72 | - Utils.getImgPath('yd_bianji'), | ||
| 73 | - width: ScreenUtil().setWidth(20), | ||
| 74 | - ), | ||
| 75 | - ], | ||
| 76 | - ), | ||
| 77 | - VEmptyView(30), | ||
| 78 | - Text( | ||
| 79 | - widget.model.phone != null && | ||
| 80 | - widget.model.userName != 'null' | ||
| 81 | - ? widget.model.phone | ||
| 82 | - : '', | ||
| 83 | - style: TextStyle( | ||
| 84 | - fontSize: ScreenUtil().setWidth(28), | ||
| 85 | - color: MyColours.color_199095), | ||
| 86 | - ), | ||
| 87 | - VEmptyView(30), | 238 | + VEmptyView(40), |
| 239 | + InkWell( | ||
| 240 | + onTap: () { | ||
| 241 | + if (canEdit) { | ||
| 242 | + DialogUtil.textfeildAlertDialog(context, | ||
| 243 | + title: '修改店员名称', | ||
| 244 | + text: nickName != '暂未设置名称' ? nickName : '', | ||
| 245 | + hintText: '输入店员名称', | ||
| 246 | + toast: '请输入店员名称', rCallback: (name) { | ||
| 247 | + _editAuthUser(name); | ||
| 248 | + }); | ||
| 249 | + } | ||
| 250 | + }, | ||
| 251 | + child: Row( | ||
| 252 | + mainAxisAlignment: MainAxisAlignment.center, | ||
| 253 | + children: [ | ||
| 254 | + Text( | ||
| 255 | + nickName, | ||
| 256 | + style: TextStyle( | ||
| 257 | + fontSize: ScreenUtil().setWidth(36), | ||
| 258 | + color: MyColours.color_333333), | ||
| 259 | + ), | ||
| 260 | + canEdit | ||
| 261 | + ? Padding( | ||
| 262 | + padding: EdgeInsets.only( | ||
| 263 | + left: ScreenUtil().setWidth(20)), | ||
| 264 | + child: Image.asset( | ||
| 265 | + Utils.getImgPath('yd_bianji'), | ||
| 266 | + width: ScreenUtil().setWidth(20), | ||
| 267 | + ), | ||
| 268 | + ) | ||
| 269 | + : SizedBox(), | ||
| 270 | + ], | ||
| 271 | + )), | ||
| 272 | + VEmptyView(40), | ||
| 273 | + canEdit | ||
| 274 | + ? InkWell( | ||
| 275 | + onTap: () { | ||
| 276 | + DialogUtil.textfeildAlertDialog(context, | ||
| 277 | + title: '修改手机号', | ||
| 278 | + text: phone != '添加手机号' ? phone : '', | ||
| 279 | + hintText: '输入手机号', | ||
| 280 | + keyboardType: TextInputType.number, | ||
| 281 | + toast: '请输入手机号', rCallback: (phone) { | ||
| 282 | + _bindPhoneSellerUser(phone); | ||
| 283 | + }); | ||
| 284 | + }, | ||
| 285 | + child: Padding( | ||
| 286 | + padding: EdgeInsets.only( | ||
| 287 | + bottom: ScreenUtil().setWidth(40)), | ||
| 288 | + child: Text( | ||
| 289 | + phone, | ||
| 290 | + style: TextStyle( | ||
| 291 | + fontSize: ScreenUtil().setWidth(28), | ||
| 292 | + color: MyColours.color_199095), | ||
| 293 | + ))) | ||
| 294 | + : widget.model.phone != null && | ||
| 295 | + widget.model.phone != 'null' | ||
| 296 | + ? Padding( | ||
| 297 | + padding: EdgeInsets.only( | ||
| 298 | + bottom: ScreenUtil().setWidth(40)), | ||
| 299 | + child: Text( | ||
| 300 | + widget.model.phone, | ||
| 301 | + style: TextStyle( | ||
| 302 | + fontSize: ScreenUtil().setWidth(28), | ||
| 303 | + color: MyColours.color_333333), | ||
| 304 | + )) | ||
| 305 | + : SizedBox(), | ||
| 306 | + | ||
| 88 | Row( | 307 | Row( |
| 89 | mainAxisAlignment: MainAxisAlignment.center, | 308 | mainAxisAlignment: MainAxisAlignment.center, |
| 90 | children: [ | 309 | children: [ |
| @@ -111,66 +330,10 @@ class _PersonnelDetailPageState extends State<PersonnelDetailPage> { | @@ -111,66 +330,10 @@ class _PersonnelDetailPageState extends State<PersonnelDetailPage> { | ||
| 111 | // color: Color.fromRGBO(235, 234, 239, 1), | 330 | // color: Color.fromRGBO(235, 234, 239, 1), |
| 112 | // ), | 331 | // ), |
| 113 | VEmptyView(60), | 332 | VEmptyView(60), |
| 114 | - Padding( | ||
| 115 | - padding: EdgeInsets.symmetric( | ||
| 116 | - vertical: ScreenUtil().setWidth(20)), | ||
| 117 | - child: Row( | ||
| 118 | - mainAxisAlignment: MainAxisAlignment.spaceEvenly, | ||
| 119 | - children: [ | ||
| 120 | - RoundButton( | ||
| 121 | - text: '移除店员', | ||
| 122 | - fontSize: 30, | ||
| 123 | - isBold: false, | ||
| 124 | - height: ScreenUtil().setWidth(80), | ||
| 125 | - // width: double.infinity, | ||
| 126 | - width: (ScreenUtil.screenWidthDp - | ||
| 127 | - ScreenUtil().setWidth(140)) / | ||
| 128 | - 2, | ||
| 129 | - radius: ScreenUtil().setWidth(10), | ||
| 130 | - ), | ||
| 131 | - RoundButton( | ||
| 132 | - text: '查看初始密码', | ||
| 133 | - fontSize: 30, | ||
| 134 | - isBold: false, | ||
| 135 | - height: ScreenUtil().setWidth(80), | ||
| 136 | - // width: double.infinity, | ||
| 137 | - width: (ScreenUtil.screenWidthDp - | ||
| 138 | - ScreenUtil().setWidth(140)) / | ||
| 139 | - 2, | ||
| 140 | - radius: ScreenUtil().setWidth(10), | ||
| 141 | - ), | ||
| 142 | - ], | ||
| 143 | - ), | ||
| 144 | - ), | ||
| 145 | - Padding( | ||
| 146 | - padding: EdgeInsets.only(bottom: ScreenUtil().setWidth(60)), | ||
| 147 | - child: Row( | ||
| 148 | - mainAxisAlignment: MainAxisAlignment.spaceEvenly, | ||
| 149 | - children: [ | ||
| 150 | - RoundButton( | ||
| 151 | - text: '设为接单人', | ||
| 152 | - fontSize: 30, | ||
| 153 | - isBold: false, | ||
| 154 | - height: ScreenUtil().setWidth(80), | ||
| 155 | - // width: double.infinity, | ||
| 156 | - width: (ScreenUtil.screenWidthDp - | ||
| 157 | - ScreenUtil().setWidth(140)) / | ||
| 158 | - 2, | ||
| 159 | - radius: ScreenUtil().setWidth(10), | ||
| 160 | - ), | ||
| 161 | - RoundButton( | ||
| 162 | - text: '绑定微信', | ||
| 163 | - fontSize: 30, | ||
| 164 | - isBold: false, | ||
| 165 | - height: ScreenUtil().setWidth(80), | ||
| 166 | - // width: double.infinity, | ||
| 167 | - width: (ScreenUtil.screenWidthDp - | ||
| 168 | - ScreenUtil().setWidth(140)) / | ||
| 169 | - 2, | ||
| 170 | - radius: ScreenUtil().setWidth(10), | ||
| 171 | - ), | ||
| 172 | - ], | ||
| 173 | - ), | 333 | + Wrap( |
| 334 | + spacing: ScreenUtil().setWidth(20), //主轴上子控件的间距 | ||
| 335 | + runSpacing: ScreenUtil().setWidth(20), //交叉轴上子控件之间的间距 | ||
| 336 | + children: _listWidget(btnList), //要显示的子控件集合 | ||
| 174 | ), | 337 | ), |
| 175 | ], | 338 | ], |
| 176 | ), | 339 | ), |
| @@ -33,6 +33,17 @@ class _PersonnelManagePageState extends State<PersonnelManagePage> { | @@ -33,6 +33,17 @@ class _PersonnelManagePageState extends State<PersonnelManagePage> { | ||
| 33 | WidgetsBinding.instance.addPostFrameCallback((timeStamp) { | 33 | WidgetsBinding.instance.addPostFrameCallback((timeStamp) { |
| 34 | _getAuthUserLists(showLoading: false); | 34 | _getAuthUserLists(showLoading: false); |
| 35 | }); | 35 | }); |
| 36 | + | ||
| 37 | + EventBus().on('personnel_manage_page', (arg) { | ||
| 38 | + _getAuthUserLists(showLoading: false); | ||
| 39 | + }); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + @override | ||
| 43 | + void dispose() { | ||
| 44 | + // TODO: implement dispose | ||
| 45 | + super.dispose(); | ||
| 46 | + EventBus().off('personnel_manage_page'); | ||
| 36 | } | 47 | } |
| 37 | 48 | ||
| 38 | //获取员工信息列表 | 49 | //获取员工信息列表 |
| @@ -45,6 +56,21 @@ class _PersonnelManagePageState extends State<PersonnelManagePage> { | @@ -45,6 +56,21 @@ class _PersonnelManagePageState extends State<PersonnelManagePage> { | ||
| 45 | showLoading: showLoading); | 56 | showLoading: showLoading); |
| 46 | } | 57 | } |
| 47 | 58 | ||
| 59 | + ///添加店员 | ||
| 60 | + _addSellerClerk(String roleId, {bool showLoading = true}) async { | ||
| 61 | + Map<String, String> params = { | ||
| 62 | + "sellerid": Provider.of<UserModel>(context, listen: false).user.sellerid, | ||
| 63 | + 'role_id': roleId | ||
| 64 | + }; | ||
| 65 | + | ||
| 66 | + bool success = await personnelProvider.addSellerClerk(context, params, | ||
| 67 | + showLoading: showLoading); | ||
| 68 | + if (success) { | ||
| 69 | + //刷新页面 | ||
| 70 | + _getAuthUserLists(showLoading: false); | ||
| 71 | + } | ||
| 72 | + } | ||
| 73 | + | ||
| 48 | @override | 74 | @override |
| 49 | Widget build(BuildContext context) { | 75 | Widget build(BuildContext context) { |
| 50 | personnelProvider = Provider.of<PersonnelProvider>(context, listen: true); | 76 | personnelProvider = Provider.of<PersonnelProvider>(context, listen: true); |
| @@ -69,17 +95,23 @@ class _PersonnelManagePageState extends State<PersonnelManagePage> { | @@ -69,17 +95,23 @@ class _PersonnelManagePageState extends State<PersonnelManagePage> { | ||
| 69 | itemBuilder: (BuildContext context, int index) { | 95 | itemBuilder: (BuildContext context, int index) { |
| 70 | String title = titleList[index]; | 96 | String title = titleList[index]; |
| 71 | List<PersonnelManageSunModel> data = []; | 97 | List<PersonnelManageSunModel> data = []; |
| 98 | + String roleId = ''; | ||
| 72 | if (personnelProvider.dataMap != null) { | 99 | if (personnelProvider.dataMap != null) { |
| 73 | if (title == '管理员') { | 100 | if (title == '管理员') { |
| 74 | data = personnelProvider.dataMap.admin.listdata; | 101 | data = personnelProvider.dataMap.admin.listdata; |
| 102 | + roleId = personnelProvider.dataMap.admin.roleId; | ||
| 75 | } else if (title == '店长') { | 103 | } else if (title == '店长') { |
| 76 | data = personnelProvider.dataMap.shopowner.listdata; | 104 | data = personnelProvider.dataMap.shopowner.listdata; |
| 105 | + roleId = personnelProvider.dataMap.shopowner.roleId; | ||
| 77 | } else if (title == '客户经理') { | 106 | } else if (title == '客户经理') { |
| 78 | data = personnelProvider.dataMap.manager.listdata; | 107 | data = personnelProvider.dataMap.manager.listdata; |
| 108 | + roleId = personnelProvider.dataMap.manager.roleId; | ||
| 79 | } else if (title == '收银员') { | 109 | } else if (title == '收银员') { |
| 80 | data = personnelProvider.dataMap.cashier.listdata; | 110 | data = personnelProvider.dataMap.cashier.listdata; |
| 111 | + roleId = personnelProvider.dataMap.cashier.roleId; | ||
| 81 | } else if (title == '服务员') { | 112 | } else if (title == '服务员') { |
| 82 | data = personnelProvider.dataMap.waiter.listdata; | 113 | data = personnelProvider.dataMap.waiter.listdata; |
| 114 | + roleId = personnelProvider.dataMap.waiter.roleId; | ||
| 83 | } | 115 | } |
| 84 | } | 116 | } |
| 85 | 117 | ||
| @@ -100,15 +132,32 @@ class _PersonnelManagePageState extends State<PersonnelManagePage> { | @@ -100,15 +132,32 @@ class _PersonnelManagePageState extends State<PersonnelManagePage> { | ||
| 100 | fontSize: ScreenUtil().setWidth(28), | 132 | fontSize: ScreenUtil().setWidth(28), |
| 101 | color: MyColours.color_333333), | 133 | color: MyColours.color_333333), |
| 102 | ), | 134 | ), |
| 103 | - InkWell( | ||
| 104 | - onTap: () {}, | ||
| 105 | - child: Text( | ||
| 106 | - '添加', | ||
| 107 | - style: TextStyle( | ||
| 108 | - fontSize: ScreenUtil().setWidth(30), | ||
| 109 | - color: MyColours.color_199095), | ||
| 110 | - ), | ||
| 111 | - ) | 135 | + title == '管理员' |
| 136 | + ? SizedBox() | ||
| 137 | + : Provider.of<UserModel>(context, | ||
| 138 | + listen: false) | ||
| 139 | + .user | ||
| 140 | + .role_name == | ||
| 141 | + '管理员' || | ||
| 142 | + (Provider.of<UserModel>(context, | ||
| 143 | + listen: false) | ||
| 144 | + .user | ||
| 145 | + .role_name == | ||
| 146 | + '店长' && | ||
| 147 | + title != '店长') | ||
| 148 | + ? InkWell( | ||
| 149 | + onTap: () { | ||
| 150 | + _addSellerClerk(roleId); | ||
| 151 | + }, | ||
| 152 | + child: Text( | ||
| 153 | + '添加', | ||
| 154 | + style: TextStyle( | ||
| 155 | + fontSize: | ||
| 156 | + ScreenUtil().setWidth(30), | ||
| 157 | + color: MyColours.color_199095), | ||
| 158 | + ), | ||
| 159 | + ) | ||
| 160 | + : SizedBox() | ||
| 112 | ], | 161 | ], |
| 113 | )), | 162 | )), |
| 114 | MyDivider( | 163 | MyDivider( |
| @@ -167,9 +216,9 @@ class _PersonnelManagePageState extends State<PersonnelManagePage> { | @@ -167,9 +216,9 @@ class _PersonnelManagePageState extends State<PersonnelManagePage> { | ||
| 167 | HEmptyView(40), | 216 | HEmptyView(40), |
| 168 | Expanded( | 217 | Expanded( |
| 169 | child: Text( | 218 | child: Text( |
| 170 | - model.userName != null && | ||
| 171 | - model.userName != 'null' | ||
| 172 | - ? model.userName | 219 | + model.nickName != null && |
| 220 | + model.nickName != 'null' | ||
| 221 | + ? model.nickName | ||
| 173 | : '暂未设置名称', | 222 | : '暂未设置名称', |
| 174 | style: TextStyle( | 223 | style: TextStyle( |
| 175 | fontSize: | 224 | fontSize: |
| @@ -200,10 +249,7 @@ class _PersonnelManagePageState extends State<PersonnelManagePage> { | @@ -200,10 +249,7 @@ class _PersonnelManagePageState extends State<PersonnelManagePage> { | ||
| 200 | color: MyColours.color_f3f3f3, | 249 | color: MyColours.color_f3f3f3, |
| 201 | ) | 250 | ) |
| 202 | ]), | 251 | ]), |
| 203 | - Provider.of<UserModel>(context, listen: false) | ||
| 204 | - .user | ||
| 205 | - .account == | ||
| 206 | - model.account | 252 | + model.isOnCall == '1' |
| 207 | ? Positioned( | 253 | ? Positioned( |
| 208 | child: Container( | 254 | child: Container( |
| 209 | width: ScreenUtil().setWidth(50), | 255 | width: ScreenUtil().setWidth(50), |
| @@ -160,7 +160,10 @@ class _MenuCategoryPageState extends State<MenuCategoryPage> { | @@ -160,7 +160,10 @@ class _MenuCategoryPageState extends State<MenuCategoryPage> { | ||
| 160 | onTapRight: () { | 160 | onTapRight: () { |
| 161 | // | 161 | // |
| 162 | DialogUtil.textfeildAlertDialog(context, | 162 | DialogUtil.textfeildAlertDialog(context, |
| 163 | - title: '添加分类', content: '输入分类名称', rCallback: (name) { | 163 | + title: '添加分类', |
| 164 | + hintText: '输入分类名称', | ||
| 165 | + lenghtLimit: true, | ||
| 166 | + toast: '请输入分类名称', rCallback: (name) { | ||
| 164 | _addCookbookClass(name, showLoading: true); | 167 | _addCookbookClass(name, showLoading: true); |
| 165 | }); | 168 | }); |
| 166 | }, | 169 | }, |
| 1 | import 'package:flutter/material.dart'; | 1 | import 'package:flutter/material.dart'; |
| 2 | import 'package:one_key/constant/constant.dart'; | 2 | import 'package:one_key/constant/constant.dart'; |
| 3 | +import 'package:one_key/models/get_seller_info_model.dart'; | ||
| 3 | import 'package:one_key/models/personnel_manage_model.dart'; | 4 | import 'package:one_key/models/personnel_manage_model.dart'; |
| 4 | import 'package:one_key/net/base_resp.dart'; | 5 | import 'package:one_key/net/base_resp.dart'; |
| 5 | import 'package:one_key/net/dio_util.dart'; | 6 | import 'package:one_key/net/dio_util.dart'; |
| 6 | 7 | ||
| 7 | import 'package:one_key/net/http_url.dart'; | 8 | import 'package:one_key/net/http_url.dart'; |
| 9 | +import 'package:one_key/provider/user_model.dart'; | ||
| 8 | import 'package:one_key/utils/utils.dart'; | 10 | import 'package:one_key/utils/utils.dart'; |
| 11 | +import 'package:provider/provider.dart'; | ||
| 9 | 12 | ||
| 10 | /** | 13 | /** |
| 11 | * 员工管理 | 14 | * 员工管理 |
| @@ -37,4 +40,128 @@ class PersonnelProvider extends ChangeNotifier { | @@ -37,4 +40,128 @@ class PersonnelProvider extends ChangeNotifier { | ||
| 37 | } | 40 | } |
| 38 | notifyListeners(); | 41 | notifyListeners(); |
| 39 | } | 42 | } |
| 43 | + | ||
| 44 | + /// 添加店员 | ||
| 45 | + Future<bool> addSellerClerk(BuildContext context, Map<String, String> params, | ||
| 46 | + {showLoading = false}) async { | ||
| 47 | + BaseResp<dynamic> baseResp = await DioUtil() | ||
| 48 | + .request<dynamic>(context, Method.get, HttpUrl.add_seller_clerk, | ||
| 49 | + data: params, showLoading: showLoading) | ||
| 50 | + .catchError((error) { | ||
| 51 | + print(error.toString()); | ||
| 52 | + }); | ||
| 53 | + if (baseResp != null && baseResp.code == Constant.status_success) { | ||
| 54 | + if (baseResp.data != '') { | ||
| 55 | + return true; | ||
| 56 | + } | ||
| 57 | + } else { | ||
| 58 | + Utils.showToast(baseResp.msg ?? ""); | ||
| 59 | + } | ||
| 60 | + return false; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + /// 删除店员 | ||
| 64 | + Future<bool> delSellerClerk(BuildContext context, Map<String, String> params, | ||
| 65 | + {showLoading = false}) async { | ||
| 66 | + BaseResp<dynamic> baseResp = await DioUtil() | ||
| 67 | + .request<dynamic>(context, Method.get, HttpUrl.delete_auth_user, | ||
| 68 | + data: params, showLoading: showLoading) | ||
| 69 | + .catchError((error) { | ||
| 70 | + print(error.toString()); | ||
| 71 | + }); | ||
| 72 | + if (baseResp != null && baseResp.code == Constant.status_success) { | ||
| 73 | + if (baseResp.data.length == 1 && baseResp.data[0] == 1) { | ||
| 74 | + return true; | ||
| 75 | + } | ||
| 76 | + } else { | ||
| 77 | + Utils.showToast(baseResp.msg ?? ""); | ||
| 78 | + } | ||
| 79 | + return false; | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + /// 编辑店员 | ||
| 83 | + Future<bool> editAuthUser(BuildContext context, Map<String, String> params, | ||
| 84 | + {showLoading = false}) async { | ||
| 85 | + BaseResp<dynamic> baseResp = await DioUtil() | ||
| 86 | + .request<dynamic>(context, Method.get, HttpUrl.edit_auth_user, | ||
| 87 | + data: params, showLoading: showLoading) | ||
| 88 | + .catchError((error) { | ||
| 89 | + print(error.toString()); | ||
| 90 | + }); | ||
| 91 | + if (baseResp != null && baseResp.code == Constant.status_success) { | ||
| 92 | + if (baseResp.data.length == 1 && baseResp.data[0] == 1) { | ||
| 93 | + return true; | ||
| 94 | + } | ||
| 95 | + } else { | ||
| 96 | + Utils.showToast(baseResp.msg ?? ""); | ||
| 97 | + } | ||
| 98 | + return false; | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + /// 账号表-员工绑定手机号 | ||
| 102 | + Future<bool> bindPhoneSellerUser( | ||
| 103 | + BuildContext context, Map<String, String> params, | ||
| 104 | + {showLoading = false}) async { | ||
| 105 | + BaseResp<dynamic> baseResp = await DioUtil() | ||
| 106 | + .request<dynamic>(context, Method.get, HttpUrl.bind_phone_seller_user, | ||
| 107 | + data: params, showLoading: showLoading) | ||
| 108 | + .catchError((error) { | ||
| 109 | + print(error.toString()); | ||
| 110 | + }); | ||
| 111 | + if (baseResp != null && baseResp.code == Constant.status_success) { | ||
| 112 | + if (baseResp.data == 1) { | ||
| 113 | + return true; | ||
| 114 | + } | ||
| 115 | + } else { | ||
| 116 | + Utils.showToast(baseResp.msg ?? ""); | ||
| 117 | + } | ||
| 118 | + return false; | ||
| 119 | + } | ||
| 120 | + ///根据商家ID获取商家信息 | ||
| 121 | + Future<GetSellerInfoSunModel> getSellerById(BuildContext context) async { | ||
| 122 | + UserModel userModel = Provider.of<UserModel>(context, listen: false); | ||
| 123 | + Map<String, String> params = { | ||
| 124 | + "sellerid": userModel.user.sellerid, | ||
| 125 | + }; | ||
| 126 | + BaseResp<Map<String, dynamic>> baseResp = await DioUtil() | ||
| 127 | + .request<Map<String, dynamic>>( | ||
| 128 | + context, Method.get, HttpUrl.get_seller_info, | ||
| 129 | + data: params) | ||
| 130 | + .catchError((error) { | ||
| 131 | + print(error.toString()); | ||
| 132 | + }); | ||
| 133 | + GetSellerInfoSunModel itemModel; | ||
| 134 | + if (baseResp == null) return itemModel; | ||
| 135 | + if (baseResp.code == Constant.status_success) { | ||
| 136 | + if (int.parse(baseResp.status) != Constant.status_success) { | ||
| 137 | + Utils.showToast(baseResp.msg ?? ""); | ||
| 138 | + return itemModel; | ||
| 139 | + } | ||
| 140 | + if (baseResp.responseData['data'] != null) { | ||
| 141 | + itemModel = GetSellerInfoModel.fromJson(baseResp.responseData).data; | ||
| 142 | + } else { | ||
| 143 | + Utils.showToast(baseResp.msg ?? ""); | ||
| 144 | + } | ||
| 145 | + return itemModel; | ||
| 146 | + } | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + /// 设置商家接单人 | ||
| 150 | + Future<bool> setUserIsCall(BuildContext context, Map<String, String> params, | ||
| 151 | + {showLoading = false}) async { | ||
| 152 | + BaseResp<dynamic> baseResp = await DioUtil() | ||
| 153 | + .request<dynamic>(context, Method.get, HttpUrl.set_user_is_call, | ||
| 154 | + data: params, showLoading: showLoading) | ||
| 155 | + .catchError((error) { | ||
| 156 | + print(error.toString()); | ||
| 157 | + }); | ||
| 158 | + if (baseResp != null && baseResp.code == Constant.status_success) { | ||
| 159 | + if (baseResp.data == 1) { | ||
| 160 | + return true; | ||
| 161 | + } | ||
| 162 | + } else { | ||
| 163 | + Utils.showToast(baseResp.msg ?? ""); | ||
| 164 | + } | ||
| 165 | + return false; | ||
| 166 | + } | ||
| 40 | } | 167 | } |
| 1 | import 'dart:convert'; | 1 | import 'dart:convert'; |
| 2 | import 'dart:ui'; | 2 | import 'dart:ui'; |
| 3 | 3 | ||
| 4 | +import 'package:cached_network_image/cached_network_image.dart'; | ||
| 4 | import 'package:common_utils/common_utils.dart'; | 5 | import 'package:common_utils/common_utils.dart'; |
| 5 | import 'package:flutter/cupertino.dart'; | 6 | import 'package:flutter/cupertino.dart'; |
| 6 | import 'package:flutter/material.dart'; | 7 | import 'package:flutter/material.dart'; |
| @@ -1987,7 +1988,7 @@ class DialogUtil { | @@ -1987,7 +1988,7 @@ class DialogUtil { | ||
| 1987 | } | 1988 | } |
| 1988 | 1989 | ||
| 1989 | static Future cupertinoAlertDialog(BuildContext context, | 1990 | static Future cupertinoAlertDialog(BuildContext context, |
| 1990 | - {String title = "标题", | 1991 | + {String title = "", |
| 1991 | String content = "内容", | 1992 | String content = "内容", |
| 1992 | String lTitle = "取消", | 1993 | String lTitle = "取消", |
| 1993 | String rTitle = "确定", | 1994 | String rTitle = "确定", |
| @@ -2038,12 +2039,18 @@ class DialogUtil { | @@ -2038,12 +2039,18 @@ class DialogUtil { | ||
| 2038 | //输入弹框 | 2039 | //输入弹框 |
| 2039 | static Future textfeildAlertDialog(BuildContext context, | 2040 | static Future textfeildAlertDialog(BuildContext context, |
| 2040 | {String title = "标题", | 2041 | {String title = "标题", |
| 2041 | - String content = "内容", | 2042 | + String text = "内容", |
| 2043 | + String hintText = "内容", | ||
| 2042 | String lTitle = "取消", | 2044 | String lTitle = "取消", |
| 2043 | String rTitle = "确定", | 2045 | String rTitle = "确定", |
| 2046 | + String toast = '请输入', | ||
| 2044 | VoidCallback lCallback, | 2047 | VoidCallback lCallback, |
| 2048 | + bool lenghtLimit = false, | ||
| 2049 | + TextInputType keyboardType = TextInputType.text, | ||
| 2045 | CustomCallBack rCallback}) { | 2050 | CustomCallBack rCallback}) { |
| 2046 | - String name = ''; | 2051 | + String name = text; |
| 2052 | + TextEditingController controller = TextEditingController(); | ||
| 2053 | + controller.text = text; | ||
| 2047 | showCupertinoDialog( | 2054 | showCupertinoDialog( |
| 2048 | context: context, | 2055 | context: context, |
| 2049 | builder: (context) { | 2056 | builder: (context) { |
| @@ -2058,41 +2065,45 @@ class DialogUtil { | @@ -2058,41 +2065,45 @@ class DialogUtil { | ||
| 2058 | content: Material( | 2065 | content: Material( |
| 2059 | color: Colors.transparent, | 2066 | color: Colors.transparent, |
| 2060 | child: TextField( | 2067 | child: TextField( |
| 2061 | - maxLines: 1, | ||
| 2062 | - // //光标颜色 | ||
| 2063 | - // cursorColor: | ||
| 2064 | - // widget.isSelect ? Colors.white : MyColours.color_199095, | ||
| 2065 | - //输入文本的样式 | ||
| 2066 | - inputFormatters: [ | ||
| 2067 | - LengthLimitingTextInputFormatter(10), | ||
| 2068 | - ], | ||
| 2069 | - textAlignVertical: TextAlignVertical.bottom, | ||
| 2070 | - textAlign: TextAlign.center, | ||
| 2071 | - style: TextStyle( | ||
| 2072 | - fontSize: ScreenUtil().setSp(28), | ||
| 2073 | - ), | ||
| 2074 | - decoration: InputDecoration( | ||
| 2075 | - border: OutlineInputBorder(borderSide: BorderSide.none), | ||
| 2076 | - hintText: content, | ||
| 2077 | - hintStyle: TextStyle( | ||
| 2078 | - color: MyColours.color_999999, | 2068 | + controller: controller, |
| 2069 | + maxLines: 1, | ||
| 2070 | + autofocus: true, | ||
| 2071 | + // //光标颜色 | ||
| 2072 | + // cursorColor: | ||
| 2073 | + // widget.isSelect ? Colors.white : MyColours.color_199095, | ||
| 2074 | + //输入文本的样式 | ||
| 2075 | + inputFormatters: lenghtLimit | ||
| 2076 | + ? [ | ||
| 2077 | + LengthLimitingTextInputFormatter(10), | ||
| 2078 | + ] | ||
| 2079 | + : [], | ||
| 2080 | + textAlignVertical: TextAlignVertical.bottom, | ||
| 2081 | + textAlign: TextAlign.center, | ||
| 2082 | + style: TextStyle( | ||
| 2079 | fontSize: ScreenUtil().setSp(28), | 2083 | fontSize: ScreenUtil().setSp(28), |
| 2080 | ), | 2084 | ), |
| 2081 | - enabledBorder: new UnderlineInputBorder( | ||
| 2082 | - borderSide: BorderSide.none, | ||
| 2083 | - ), | ||
| 2084 | - focusedBorder: new UnderlineInputBorder( | ||
| 2085 | - borderSide: BorderSide.none, | 2085 | + decoration: InputDecoration( |
| 2086 | + border: OutlineInputBorder(borderSide: BorderSide.none), | ||
| 2087 | + hintText: hintText, | ||
| 2088 | + hintStyle: TextStyle( | ||
| 2089 | + color: MyColours.color_999999, | ||
| 2090 | + fontSize: ScreenUtil().setSp(28), | ||
| 2091 | + ), | ||
| 2092 | + enabledBorder: new UnderlineInputBorder( | ||
| 2093 | + borderSide: BorderSide.none, | ||
| 2094 | + ), | ||
| 2095 | + focusedBorder: new UnderlineInputBorder( | ||
| 2096 | + borderSide: BorderSide.none, | ||
| 2097 | + ), | ||
| 2086 | ), | 2098 | ), |
| 2087 | - ), | ||
| 2088 | - onChanged: (value) { | ||
| 2089 | - name = value; | ||
| 2090 | - }, | ||
| 2091 | - onEditingComplete: () { | ||
| 2092 | - FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘 | ||
| 2093 | - }, | ||
| 2094 | - keyboardType: TextInputType.text, | ||
| 2095 | - )), | 2099 | + onChanged: (value) { |
| 2100 | + name = value; | ||
| 2101 | + }, | ||
| 2102 | + onEditingComplete: () { | ||
| 2103 | + FocusScope.of(context) | ||
| 2104 | + .requestFocus(FocusNode()); //点击空白处隐藏键盘 | ||
| 2105 | + }, | ||
| 2106 | + keyboardType: keyboardType)), | ||
| 2096 | actions: [ | 2107 | actions: [ |
| 2097 | CupertinoDialogAction( | 2108 | CupertinoDialogAction( |
| 2098 | child: Text(lTitle, | 2109 | child: Text(lTitle, |
| @@ -2111,7 +2122,7 @@ class DialogUtil { | @@ -2111,7 +2122,7 @@ class DialogUtil { | ||
| 2111 | color: MyColours.color_199095)), | 2122 | color: MyColours.color_199095)), |
| 2112 | onPressed: () { | 2123 | onPressed: () { |
| 2113 | if (name == '' || name.trim().length == 0) { | 2124 | if (name == '' || name.trim().length == 0) { |
| 2114 | - Utils.showToast('请输入分类名称'); | 2125 | + Utils.showToast(toast); |
| 2115 | return; | 2126 | return; |
| 2116 | } | 2127 | } |
| 2117 | Navigator.of(context).pop(); | 2128 | Navigator.of(context).pop(); |
| @@ -2123,4 +2134,49 @@ class DialogUtil { | @@ -2123,4 +2134,49 @@ class DialogUtil { | ||
| 2123 | }, | 2134 | }, |
| 2124 | ); | 2135 | ); |
| 2125 | } | 2136 | } |
| 2137 | + | ||
| 2138 | + static Future openAlertDialogImage( | ||
| 2139 | + BuildContext context, String title, String image, double height, | ||
| 2140 | + {GestureTapCallback onTap, double fontSize = 30}) async { | ||
| 2141 | + final action = await showDialog( | ||
| 2142 | + context: context, | ||
| 2143 | + barrierDismissible: true, | ||
| 2144 | + builder: (BuildContext context) { | ||
| 2145 | + return Center( | ||
| 2146 | + child: Container( | ||
| 2147 | + padding: | ||
| 2148 | + EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(72)), | ||
| 2149 | + height: ScreenUtil().setWidth(height), | ||
| 2150 | + decoration: BoxDecoration( | ||
| 2151 | + borderRadius: BorderRadius.circular(ScreenUtil().setWidth(30))), | ||
| 2152 | + child: Card( | ||
| 2153 | + shape: RoundedRectangleBorder( | ||
| 2154 | + borderRadius: BorderRadius.all( | ||
| 2155 | + Radius.circular(ScreenUtil().setWidth(30)))), //设置圆角 | ||
| 2156 | + child: Column( | ||
| 2157 | + children: [ | ||
| 2158 | + VEmptyView(60), | ||
| 2159 | + Container( | ||
| 2160 | + height: ScreenUtil().setWidth(48), | ||
| 2161 | + alignment: Alignment.center, | ||
| 2162 | + child: Text(title, | ||
| 2163 | + style: TextStyle( | ||
| 2164 | + fontSize: ScreenUtil().setSp(fontSize), | ||
| 2165 | + color: MyColours.color_353535)), | ||
| 2166 | + ), | ||
| 2167 | + VEmptyView(40), | ||
| 2168 | + MyDivider( | ||
| 2169 | + ScreenUtil().setWidth(280 * 2), ScreenUtil().setWidth(2), | ||
| 2170 | + color: MyColours.color_efefef), | ||
| 2171 | + VEmptyView(70), | ||
| 2172 | + CachedNetworkImage( | ||
| 2173 | + imageUrl: image, width: ScreenUtil().setWidth(320)) | ||
| 2174 | + ], | ||
| 2175 | + ), | ||
| 2176 | + ), | ||
| 2177 | + ), | ||
| 2178 | + ); | ||
| 2179 | + }, | ||
| 2180 | + ); | ||
| 2181 | + } | ||
| 2126 | } | 2182 | } |
-
Please register or login to post a comment