Commit 94771e66afa80418ea40262e9ea4f934a1b3f022

Authored by wdn127929
1 parent 5c965131

c ccc

... ... @@ -32,10 +32,13 @@ class GetSellerUserBySelleridSunModel extends Object {
@JsonKey(name: 'id')
String id;
@JsonKey(name: 'role_name')
String roleName;
GetSellerUserBySelleridSunModel(
this.nickName,
this.id,
this.roleName
);
factory GetSellerUserBySelleridSunModel.fromJson(
... ...
... ... @@ -33,6 +33,7 @@ GetSellerUserBySelleridSunModel _$GetSellerUserBySelleridSunModelFromJson(
return GetSellerUserBySelleridSunModel(
json['nick_name'] as String,
json['id'] as String,
json['role_name'] as String,
);
}
... ... @@ -41,4 +42,5 @@ Map<String, dynamic> _$GetSellerUserBySelleridSunModelToJson(
<String, dynamic>{
'nick_name': instance.nickName,
'id': instance.id,
'role_name': instance.roleName
};
... ...
... ... @@ -63,6 +63,7 @@ class Admin extends Object {
@JsonKey(name: 'role_id')
String roleId;
int hasWechatNum; //已绑定微信数量
Admin(
this.listdata,
... ... @@ -109,6 +110,7 @@ class PersonnelManageSunModel extends Object {
@JsonKey(name: 'headimgurl')
String headimgurl;
PersonnelManageSunModel(
this.id,
... ... @@ -137,6 +139,7 @@ class Shopowner extends Object {
@JsonKey(name: 'role_id')
String roleId;
int hasWechatNum; //已绑定微信数量
Shopowner(
this.listdata,
... ... @@ -156,6 +159,7 @@ class Cashier extends Object {
@JsonKey(name: 'role_id')
String roleId;
int hasWechatNum; //已绑定微信数量
Cashier(
this.listdata,
... ... @@ -175,6 +179,7 @@ class Waiter extends Object {
@JsonKey(name: 'role_id')
String roleId;
int hasWechatNum; //已绑定微信数量
Waiter(
this.listdata,
... ... @@ -195,6 +200,8 @@ class Manager extends Object {
@JsonKey(name: 'role_id')
String roleId;
int hasWechatNum; //已绑定微信数量
Manager(
this.listdata,
this.roleId,
... ...
import 'dart:io';
import 'dart:ui';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/models/check_seller_acc_model.dart';
import 'package:one_key/models/personnel_manage_model.dart';
import 'package:one_key/models/upload_img_model.dart';
import 'package:one_key/models/user.dart';
import 'package:one_key/pages/online_check/photo_view_wiget.dart';
import 'package:one_key/pages/online_check/progress.dart';
import 'package:one_key/provider/base_info_provider.dart';
import 'package:one_key/provider/personnel_provider.dart';
import 'package:one_key/provider/upload_img_provider.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/event_bus.dart';
import 'package:one_key/utils/upload_image_util.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/round_button.dart';
import 'package:one_key/widgets/system_app_bar.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:image_picker/image_picker.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:provider/provider.dart';
import '../../../app.dart';
class BaseInfoPersonnalPage extends StatefulWidget {
final PersonnelManageSunModel sunModel;
final String position;
BaseInfoPersonnalPage({Key key, this.sunModel, this.position})
: super(key: key);
@override
_BaseInfoPersonnalPageState createState() => _BaseInfoPersonnalPageState();
}
class _BaseInfoPersonnalPageState extends State<BaseInfoPersonnalPage> {
ScrollController _scrollController;
TextEditingController _nameController = TextEditingController();
TextEditingController _phoneController = TextEditingController();
// TextEditingController _positionController = TextEditingController();
// TextEditingController _wechatController = TextEditingController();
FocusNode _nameFocusNode = FocusNode();
FocusNode _phoneFocusNode = FocusNode();
// FocusNode _positionFocusNode = FocusNode();
// FocusNode _wechatFocusNode = FocusNode();
final picker = ImagePicker();
PersonnelProvider personnelProvider;
// UploadImageProvider _uploadImageProvider;
BaseIndoProvider _baseIndoProvider;
String nameStr = '未填写';
String phoneStr = '';
bool isSelect = true;
@override
void initState() {
super.initState();
_scrollController = ScrollController();
_getCustomerActivityBaseinfo();
_nameFocusNode.addListener(() {
if (_nameFocusNode.hasFocus) {
print('得到焦点');
} else {
print('失去焦点');
}
setState(() {});
});
_phoneFocusNode.addListener(() {
if (_phoneFocusNode.hasFocus) {
print('得到焦点');
} else {
print('失去焦点');
}
});
// _positionFocusNode.addListener(() {
// if (_positionFocusNode.hasFocus) {
// print('得到焦点');
// } else {
// print('失去焦点');
// }
// setState(() {});
// });
// _wechatFocusNode.addListener(() {
// if (_wechatFocusNode.hasFocus) {
// print('得到焦点');
// } else {
// print('失去焦点');
// }
// setState(() {});
// });
WidgetsBinding.instance.addPostFrameCallback((_) {
// _getQiniuInfo();
});
}
_getCustomerActivityBaseinfo() async {
// Map<String, String> params;
// params = {
// 'sellerid': Provider.of<UserModel>(context, listen: false).user.sellerid,
// "uid": Provider.of<UserModel>(context, listen: false).user.openid,
// };
// bool success =
// await _baseIndoProvider.getCustomerActivityBaseinfo(context, params);
// if (success) {
_nameController.text = widget.sunModel.nickName;
nameStr = widget.sunModel.nickName;
// _uploadImageProvider.touxiang.qiniuUrl =
// _baseIndoProvider.baseInfoSunModel.photo;
// _uploadImageProvider.erweima.qiniuUrl =
// _baseIndoProvider.baseInfoSunModel.qrcode;
_phoneController.text = widget.sunModel.phone;
phoneStr = widget.sunModel.phone ?? '';
// _wechatController.text = _baseIndoProvider.baseInfoSunModel.wechat;
// if (_baseIndoProvider.baseInfoSunModel.wechat != null &&
// _baseIndoProvider.baseInfoSunModel.wechat != '' &&
// phoneStr != '' &&
// _baseIndoProvider.baseInfoSunModel.wechat == phoneStr) {
// isSelect = true;
// } else {
// isSelect = false;
// }
// _positionController.text = widget.position;
// _uploadImageProvider.imgSizeErweima = 64;
// setState(() {});
// _uploadImageProvider.notifyListeners();
// }
}
///获取七牛云token
///
// _getQiniuInfo() async {
// await _uploadImageProvider.getQiniuInfo(context, {});
// }
//客户经理添加/修改基本信息
// _setCustomerActivityBaseinfo() async {
// FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
// String nameTemp = _nameController.text.trim();
// String phoneTemp = _phoneController.text.trim();
// Map<String, String> params = {
// "name": nameTemp,
// 'phone': phoneTemp,
// "photo": _uploadImageProvider.touxiang.qiniuUrl.trim().length == 0 ||
// _uploadImageProvider.touxiang.qiniuUrl ==
// 'http://nosqn.colorcun.com/yd_person.png'
// ? App.sp.getString("headImg")
// : _uploadImageProvider.touxiang.qiniuUrl,
// "position": _positionController.text.trim().length == 0
// ? '经理'
// : _positionController.text,
// };
// params['sellerid'] =
// Provider.of<UserModel>(context, listen: false).user.sellerid;
// params["uid"] = Provider.of<UserModel>(context, listen: false).user.openid;
// if (isSelect) {
// params['wechat'] = phoneTemp;
// } else {
// // if (_wechatController.text.trim().length > 0) {
// params['wechat'] = _wechatController.text;
// // }
// }
// if (_uploadImageProvider.erweima.qiniuUrl != null &&
// _uploadImageProvider.erweima.qiniuUrl != '') {
// params['qrcode'] = _uploadImageProvider.erweima.qiniuUrl;
// }
// if (_baseIndoProvider.baseInfoSunModel != null) {
// params['id'] = _baseIndoProvider.baseInfoSunModel.id;
// }
// bool isSuccess =
// await _baseIndoProvider.setCustomerActivityBaseinfo(context, params);
// // _baseIndoProvider.baseInfoSunModel = null;
// if (isSuccess) {
// _uploadImageProvider.touxiang.file = null;
// _uploadImageProvider.erweima.file = null;
// nameStr = nameTemp;
// phoneStr = phoneTemp;
// //成功之后跳回前一个页面
// // bus.emit('refresh_coupon_list');
// Utils.showToast('保存成功');
// EventBus().emit('changeStatusColor');
// Navigator.pop(context, true);
// }
// }
///输入框
Widget _text(String image, String text) {
return Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
child: Image.asset(
Utils.getImgPath(image),
width: ScreenUtil().setWidth(34 * 2),
)),
HEmptyView(24),
Expanded(
child: Text(
text,
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
),
)),
],
));
}
///输入框
Widget _textfield(String image, String hintText,
TextEditingController editingController, FocusNode focusNode) {
return Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
child: Image.asset(
Utils.getImgPath(image),
width: ScreenUtil().setWidth(34 * 2),
)),
HEmptyView(24),
Expanded(
child: TextField(
controller: editingController,
// textAlign: TextAlign.right,
// textAlignVertical: TextAlignVertical.bottom,
maxLines: 1,
// //光标颜色
// cursorColor:
// widget.isSelect ? Colors.white : MyColours.color_199095,
//输入文本的样式
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
),
focusNode: focusNode,
decoration: InputDecoration(
// suffixText: '修改',
// suffixStyle: TextStyle(
// fontSize: ScreenUtil().setSp(24),
// color: MyColours.color_BFC4D4),
// suffixIcon: Container(
// margin: EdgeInsets.only(left: ScreenUtil().setWidth(16)),
// child: Image.asset(
// Utils.getImgPath('arrow_right_new'),
// width: ScreenUtil().setWidth(20),
// height: ScreenUtil().setWidth(40),
// )),
// suffixIconConstraints:
// BoxConstraints(maxWidth: ScreenUtil().setWidth(56)),
border: OutlineInputBorder(borderSide: BorderSide.none),
hintText: hintText,
hintStyle: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(32),
),
enabledBorder: new UnderlineInputBorder(
borderSide: BorderSide.none,
),
focusedBorder: new UnderlineInputBorder(
borderSide: BorderSide.none,
),
),
onChanged: (value) {
print('vvvvvv');
if (hintText == '您希望顾客看到的名字') {
setState(() {
nameStr = value;
});
} else if (hintText == '顾客联系您的手机号') {
setState(() {
phoneStr = value;
});
}
},
onEditingComplete: () {
FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
},
keyboardType: TextInputType.text,
),
),
focusNode.hasFocus
? SizedBox()
: InkWell(
onTap: () {
FocusScope.of(context).requestFocus(focusNode); // 获取焦点
setState(() {});
},
child: Row(
children: [
Text(
'修改',
style: TextStyle(
fontSize: ScreenUtil().setSp(24),
color: MyColours.color_BFC4D4),
),
Container(
margin:
EdgeInsets.only(left: ScreenUtil().setWidth(16)),
child: Image.asset(
Utils.getImgPath('base_arrow_r'),
width: ScreenUtil().setWidth(20),
height: ScreenUtil().setWidth(40),
)),
],
))
],
),
);
}
//查看大图
_showPhotoView(BuildContext context, int index, List imgs,
{isShow = false, List dashName}) async {
// if (imgs.length == 1 &&
// imgs[0] ==
// 'http://nosqn.colorcun.com/custom/lite-online/image/def-banner.png') {
// imgs[0] = 'http://nosqn.colorcun.com/app/seller-hj-empty.png';
// }
Utils.setBarStatus(false, color: Colors.black);
dynamic result = await showGeneralDialog(
context: context,
barrierDismissible: false,
// barrierColor: Colors.red,
barrierLabel:
MaterialLocalizations.of(context).modalBarrierDismissLabel,
transitionDuration: const Duration(milliseconds: 150),
pageBuilder: (BuildContext context, Animation animation,
Animation secondaryAnimation) {
Widget child = Stack(
children: <Widget>[
PhotoPreview(
initialIndex: index,
photoList: imgs,
isShow: isShow,
dashName: dashName,
needMask: false,
)
],
);
return child;
});
Utils.setBarStatus(true, color: Colors.white);
}
///#相机拍照,单图选择
// Future _getFromPictureOrCamera(
// String title, UploadImgModel imgModel, imageSource) async {
// final pickedFile = await picker.getImage(source: imageSource);
// setState(() {
// if (pickedFile != null) {
// imgModel.file = File(pickedFile.path);
// imgModel.process = 0.01;
// } else {
// print('No image selected.');
// }
// });
// if (pickedFile != null) {
// if (title == '头像') {
// _uploadImageProvider.imgSizeTouxiang = 76;
// _uploadImageProvider.touxiang.qiniuUrl = null;
// } else {
// _uploadImageProvider.imgSizeErweima = 76;
// _uploadImageProvider.erweima.qiniuUrl = null;
// }
// UploadImageUtil().startUploadOnly(context, File(pickedFile.path),
// title == '头像' ? 0 : 1, true, _uploadImageProvider);
// }
// }
///图片 头像和二维码
Widget _imageWidget(String title, double imgSize, double radius) {
return InkWell(
onTap: () {
// double process;
// String qiniuUrl;
List<String> tempList = [];
// if (title == '头像') {
// process = _uploadImageProvider.touxiang.process;
// qiniuUrl = _uploadImageProvider.touxiang.qiniuUrl;
// } else {
// process = _uploadImageProvider.erweima.process;
// qiniuUrl = _uploadImageProvider.erweima.qiniuUrl;
// }
if (widget.sunModel.headimgurl != null &&
widget.sunModel.headimgurl != '') {
tempList.add(widget.sunModel.headimgurl);
///没有上传完成的不可以点击
_showPhotoView(context, 0, tempList);
// } else {
// Utils.getPickPermission(context, () {
// _getFromPictureOrCamera(title, model, ImageSource.gallery);
// }, Platform.isAndroid ? Permission.storage : Permission.photos);
}
},
child: Stack(clipBehavior: Clip.none, children: [
Container(
width: ScreenUtil().setWidth(93 * 2),
height: ScreenUtil().setWidth(93 * 2),
margin: EdgeInsets.only(
right: ScreenUtil().setWidth(24),
),
child: ClipRRect(
borderRadius:
BorderRadius.circular(ScreenUtil().setWidth(93)),
child: Image.asset(
Utils.getImgPath('base_tx_bg'),
fit: BoxFit.cover,
width: ScreenUtil().setWidth(93 * 2),
height: ScreenUtil().setWidth(93 * 2),
))),
Positioned(
top: ScreenUtil().setWidth(9),
left: ScreenUtil().setWidth(17),
child: Container(
width: ScreenUtil().setWidth(imgSize * 2),
height: ScreenUtil().setWidth(imgSize * 2),
// margin: EdgeInsets.only(
// right: ScreenUtil().setWidth(24),
// ),
child: ClipRRect(
borderRadius:
BorderRadius.circular(ScreenUtil().setWidth(radius)),
child: widget.sunModel.headimgurl != null &&
widget.sunModel.headimgurl != '' &&
widget.sunModel.headimgurl !=
'http://nosqn.colorcun.com/yd_person.png'
? Image.network(
widget.sunModel.headimgurl,
fit: BoxFit.cover,
width: ScreenUtil().setWidth(imgSize * 2),
height: ScreenUtil().setWidth(imgSize * 2),
)
: Image.asset(
Utils.getImgPath(
title == '头像' ? 'base_tx_mr' : 'erweima'),
fit: BoxFit.cover,
width: ScreenUtil().setWidth(imgSize * 2),
height: ScreenUtil().setWidth(imgSize * 2),
)))),
// Positioned(
// right: ScreenUtil().setWidth(42),
// top: ScreenUtil().setWidth(9),
// child: (model.file != null) &&
// model.process != 1 &&
// model.process != 0.01
// ? Container(
// width: ScreenUtil().setWidth(imgSize * 2),
// height: ScreenUtil().setWidth(imgSize * 2),
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(radius),
// color: Color.fromRGBO(0, 0, 0, 0.6)),
// child: Center(
// child: Text('上传中',
// style: TextStyle(color: MyColours.color_999999)),
// ),
// )
// : Container()),
// Positioned(
// right: ScreenUtil().setWidth(14),
// top: ScreenUtil().setWidth(56),
// child: InkWell(
// onTap: () {
// Utils.getPickPermission(context, () {
// _getFromPictureOrCamera(
// title, model, ImageSource.gallery);
// },
// Platform.isAndroid
// ? Permission.storage
// : Permission.photos);
// },
// child: Image.asset(
// Utils.getImgPath('base_tx'),
// width: ScreenUtil().setWidth(28 * 2),
// )))
]));
}
///编辑店员
Future<bool> _editAuthUser(String name, {bool showLoading = true}) async {
Map<String, String> params = {'id': widget.sunModel.id, 'user_name': name};
bool success = await personnelProvider.editAuthUser(context, params,
showLoading: showLoading);
if (success) {
return true;
} else {
return false;
}
}
/// 账号表-员工绑定手机号
Future<bool> _bindPhoneSellerUser(String phone,
{bool showLoading = true}) async {
Map<String, String> params = {'kid': widget.sunModel.id, 'phone': phone};
bool success = await personnelProvider.bindPhoneSellerUser(context, params,
showLoading: showLoading);
if (success) {
return true;
} else {
return false;
}
}
@override
Widget build(BuildContext context) {
// _uploadImageProvider =
// Provider.of<UploadImageProvider>(context, listen: true);
_baseIndoProvider = Provider.of<BaseIndoProvider>(context, listen: true);
personnelProvider = Provider.of<PersonnelProvider>(context, listen: true);
return Scaffold(
backgroundColor: MyColours.color_fefefe,
appBar: SystemAppBar(
'个人信息',
onTap: () {
EventBus().emit('changeStatusColor');
Navigator.of(context).pop();
},
),
body: WillPopScope(
onWillPop: () {
EventBus().emit('changeStatusColor');
Navigator.of(context).pop();
},
child: InkWell(
onTap: () {
FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
},
child: Container(
color: MyColours.color_ffffff,
child: Column(
// crossAxisAlignment: CrossAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: SingleChildScrollView(
controller: _scrollController,
physics: BouncingScrollPhysics(),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
VEmptyView(66),
_imageWidget('头像', 76, 76),
VEmptyView(26),
Text(nameStr,
style: TextStyle(
fontSize: ScreenUtil().setWidth(50),
color: nameStr == '未填写' ||
nameStr == ''
? MyColours.color_BFC4D4
: MyColours.color_27262B)),
VEmptyView(8),
Text(phoneStr == null ? '' : phoneStr,
style: TextStyle(
fontSize: ScreenUtil().setWidth(30),
color: MyColours.color_BFC4D4)),
VEmptyView(80),
Padding(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(48),
),
child: _textfield(
'base_name',
'您希望顾客看到的名字',
_nameController,
_nameFocusNode)),
VEmptyView(26),
Padding(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
),
child: _textfield(
'base_phone',
'顾客联系您的手机号',
_phoneController,
_phoneFocusNode)),
VEmptyView(26),
Padding(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
),
child: _text(
'base_position', widget.position),
),
// VEmptyView(26),
// _imageWidget('微信二维码', _uploadImageProvider.erweima,
// _uploadImageProvider.imgSizeErweima, 0),
// InkWell(
// onTap: () {
// setState(() {
// isSelect = !isSelect;
// });
// },
// child: Container(
// padding: EdgeInsets.only(
// left: ScreenUtil().setWidth(40),
// right: ScreenUtil().setWidth(40),
// bottom:
// ScreenUtil().setWidth(26)),
// child: Row(
// crossAxisAlignment:
// CrossAxisAlignment.center,
// children: [
// Image.asset(
// Utils.getImgPath(isSelect
// ? 'base_radio_sel'
// : 'base_radio_un'),
// // width: ScreenUtil().setWidth(16),
// height:
// ScreenUtil().setWidth(34),
// ),
// HEmptyView(24),
// Text('微信同电话号',
// style: TextStyle(
// color: isSelect
// ? MyColours.color_438E93
// : MyColours
// .color_BFC4D4,
// fontSize:
// ScreenUtil().setSp(30),
// )),
// ],
// ),
// )),
// isSelect
// ? SizedBox()
// : Padding(
// padding: EdgeInsets.symmetric(
// horizontal:
// ScreenUtil().setWidth(40),
// ),
// child: _textfield(
// 'base_wechat',
// '微信号方便顾客加您微信',
// _wechatController,
// _wechatFocusNode)),
VEmptyView(30),
],
)),
),
VEmptyView(20),
Padding(
padding: EdgeInsets.fromLTRB(
ScreenUtil().setWidth(40),
0,
ScreenUtil().setWidth(40),
ScreenUtil().setWidth(56)),
child: RoundButton(
onPressed: () {
if (_phoneController.text.trim().length ==
0 ||
_nameController.text.trim().length == 0) {
Utils.showToast('请至少填写您的姓名和电话');
return;
} //接口
// _setCustomerActivityBaseinfo();
String nameTemp = _nameController.text.trim();
String phoneTemp =
_phoneController.text.trim();
Future.wait<bool>([
_editAuthUser(nameTemp),
_bindPhoneSellerUser(phoneTemp)
]).then((results) {
print(results[0]);
if (results[0] && results[1]) {
//成功
EventBus().emit('personnel_manage_page');
EventBus()
.emit('personnel_manage_detail_page');
Navigator.pop(context);
} else {
if (!results[0]) {
Utils.showToast('修改姓名失败');
} else {
Utils.showToast('修改电话失败');
}
}
}).catchError((e) {
print(e);
});
},
text: '保存',
fontSize: 34,
isBold: false,
height: ScreenUtil().setWidth(100),
width: ScreenUtil().setWidth(154 * 2),
gradientStart: _phoneController.text
.trim()
.length ==
0 ||
_nameController.text.trim().length == 0
? MyColours.color_BFC4D4
: MyColours.color_438E93,
gradientEnd: _phoneController.text
.trim()
.length ==
0 ||
_nameController.text.trim().length == 0
? MyColours.color_BFC4D4
: MyColours.color_438E93,
radius: ScreenUtil().setWidth(24),
))
])))));
}
}
... ...
... ... @@ -5,6 +5,7 @@ import 'package:common_utils/common_utils.dart';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/models/get_seller_info_model.dart';
import 'package:one_key/models/personnel_manage_model.dart';
import 'package:one_key/net/dio_util.dart';
... ... @@ -23,9 +24,9 @@ import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
class PersonnelDetailPage extends StatefulWidget {
final PersonnelManageSunModel model;
final int index;
final String position;
PersonnelDetailPage({Key key, this.model, this.position}) : super(key: key);
PersonnelDetailPage({Key key, this.index, this.position}) : super(key: key);
@override
_PersonnelDetailPageState createState() => _PersonnelDetailPageState();
... ... @@ -34,75 +35,79 @@ class PersonnelDetailPage extends StatefulWidget {
class _PersonnelDetailPageState extends State<PersonnelDetailPage> {
String roleNameLogin;
String accountLogin;
bool canEdit = false;
// bool canEdit = false;
List<String> btnList = [];
UserModel userModel;
PersonnelProvider personnelProvider;
String nickName;
String phone;
String nickName = '';
String phone = '';
String dcAdduserCode;
String manageShow = '全店未分配客户资源';
PersonnelManageSunModel data;
@override
void initState() {
super.initState();
nickName = widget.model.nickName != null && widget.model.nickName != 'null'
? widget.model.nickName
: '暂未设置名称';
phone = widget.model.phone != null && widget.model.userName != 'null'
? widget.model.phone
: '添加手机号';
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
if (widget.model.openid == null || widget.model.openid == 'null') {
// _getStoreBaseinfo();
_getWechatQrcode();
}
_getSellerUserBySellerid();
_getAuthUserLists();
EventBus().on('personnel_manage_detail_page', (arg) {
_getAuthUserLists(showLoading: false);
});
setState(() {
roleNameLogin = userModel.user.role_name;
accountLogin = userModel.user.account;
if (roleNameLogin == '管理员') {
canEdit = true;
} else if (roleNameLogin == '店长') {
if (widget.position == '管理员') {
canEdit = false;
} else if (widget.position == '店长') {
if (accountLogin == widget.model.account) {
print('11111');
//店长自己
canEdit = true;
} else {
print('333333');
canEdit = false;
}
} else {
canEdit = true;
}
} else {
if (accountLogin == widget.model.account) {
//自己
canEdit = true;
} else {
canEdit = false;
}
}
if (canEdit) {
btnList = [
'移除店员',
];
if (widget.model.openid == null || widget.model.openid == 'null') {
btnList.add('绑定微信');
}
btnList.add('查看密码');
if (widget.model.isOnCall == '0') {
btnList.add('设为接单人');
}
} else {
btnList = [];
}
// if (roleNameLogin == '管理员') {
// canEdit = true;
// } else if (roleNameLogin == '店长') {
// if (widget.position == '管理员') {
// canEdit = false;
// } else if (widget.position == '店长') {
// if (accountLogin == data.account) {
// print('11111');
// //店长自己
// canEdit = true;
// } else {
// print('333333');
// canEdit = false;
// }
// } else {
// canEdit = true;
// }
// } else {
// if (accountLogin == data.account) {
// //自己
// canEdit = true;
// } else {
// canEdit = false;
// }
// }
// if (canEdit) {
// btnList = [
// '移除店员',
// ];
// if (data.openid == null || data.openid == 'null') {
// btnList.add('绑定微信');
// }
// btnList.add('查看密码');
// if (data.isOnCall == '0') {
// btnList.add('设为接单人');
// }
// } else {
// btnList = [];
// }
});
});
}
void dispose() {
// TODO: implement dispose
super.dispose();
EventBus().off('personnel_manage_detail_page');
}
///获取店铺信息
// _getStoreBaseinfo() async {
// GetSellerInfoSunModel itemModel =
... ... @@ -112,11 +117,54 @@ class _PersonnelDetailPageState extends State<PersonnelDetailPage> {
// }
// }
///商家编辑页面 ----- 获取经理数据
_getSellerUserBySellerid() async {
await personnelProvider.getSellerUserBySellerid(context);
// for (int i = 0; i < personnelProvider.sellerManageList.length; i++) {
// if (manageShow == personnelProvider.sellerManageList[i].title) {
// personnelProvider.manageSelIndex = i;
// }
// }
}
//获取员工信息列表
_getAuthUserLists({bool showLoading = true}) async {
Map<String, String> params = {
"sellerid": Provider.of<UserModel>(context, listen: false).user.sellerid,
};
await personnelProvider.getAuthUserLists(context, params,
showLoading: showLoading);
if (personnelProvider.dataMap != null) {
if (widget.position == '管理员') {
data = personnelProvider.dataMap.admin.listdata[widget.index];
} else if (widget.position == '店长') {
data = personnelProvider.dataMap.shopowner.listdata[widget.index];
} else if (widget.position == '客户经理') {
data = personnelProvider.dataMap.manager.listdata[widget.index];
} else if (widget.position == '收银员') {
data = personnelProvider.dataMap.cashier.listdata[widget.index];
} else if (widget.position == '服务员') {
data = personnelProvider.dataMap.waiter.listdata[widget.index];
}
nickName = data.nickName != null && data.nickName != 'null'
? data.nickName
: '暂未设置名称';
phone =
data.phone != null && data.userName != 'null' ? data.phone : '添加手机号';
if (data.openid == null || data.openid == 'null') {
// _getStoreBaseinfo();
_getWechatQrcode();
}
}
}
///设置接单人
_setUserIsCall({bool showLoading = true}) async {
Map<String, String> params = {
"sid": Provider.of<UserModel>(context, listen: false).user.sellerid,
'uid': widget.model.id
'uid': data.id
};
bool success = await personnelProvider.setUserIsCall(context, params,
... ... @@ -132,20 +180,17 @@ class _PersonnelDetailPageState extends State<PersonnelDetailPage> {
}
///删除店员
_delSellerClerk({bool showLoading = true}) async {
Map<String, String> params = {'seller_user_id': widget.model.id};
Future<bool> _delSellerClerk({bool showLoading = true}) async {
Map<String, String> params = {'seller_user_id': data.id};
bool success = await personnelProvider.delSellerClerk(context, params,
showLoading: showLoading);
if (success) {
EventBus().emit('personnel_manage_page');
Navigator.pop(context);
}
return success;
}
///编辑店员
_editAuthUser(String name, {bool showLoading = true}) async {
Map<String, String> params = {'id': widget.model.id, 'user_name': name};
Map<String, String> params = {'id': data.id, 'user_name': name};
bool success = await personnelProvider.editAuthUser(context, params,
showLoading: showLoading);
... ... @@ -159,7 +204,7 @@ class _PersonnelDetailPageState extends State<PersonnelDetailPage> {
/// 账号表-员工绑定手机号
_bindPhoneSellerUser(String name, {bool showLoading = true}) async {
Map<String, String> params = {'kid': widget.model.id, 'phone': name};
Map<String, String> params = {'kid': data.id, 'phone': name};
bool success = await personnelProvider.bindPhoneSellerUser(context, params,
showLoading: showLoading);
... ... @@ -205,7 +250,7 @@ class _PersonnelDetailPageState extends State<PersonnelDetailPage> {
}
} else if (element == '查看密码') {
NavigatorUtil.goPersonnelPasswordPage(context,
account: widget.model.account, idstr: widget.model.id);
account: data.account, idstr: data.id);
}
},
),
... ... @@ -220,7 +265,7 @@ class _PersonnelDetailPageState extends State<PersonnelDetailPage> {
String id = Provider.of<UserModel>(context, listen: false).user.openid;
// https: //xt.colorcun.com/WechatApi/WechatApi/CreateDcSubQrcode/sellerid/商家ID/uid/当前账号ID
Response response = await DioUtil.getInstance().getDio().get(
"https://xt.colorcun.com/WechatApi/WechatApi/CreateDcSubQrcode?sellerid=$sid&uid=${widget.model.id}");
"https://xt.colorcun.com/WechatApi/WechatApi/CreateDcSubQrcode?sellerid=$sid&uid=${data.id}");
// Response response = await DioUtil.getInstance().getDio().get(
// "https://xt.colorcun.com/WechatApi/WechatApi/CreateDcSubQrcode?sellerid=$sid&uid=$uid");
// Response response = await DioUtil.getInstance().getDio().get(
... ... @@ -252,140 +297,372 @@ class _PersonnelDetailPageState extends State<PersonnelDetailPage> {
return Scaffold(
backgroundColor: MyColours.color_ffffff,
appBar: SystemAppBar(
'店员详情',
'员工详情',
onTap: () {
Navigator.pop(context);
},
),
body: SingleChildScrollView(
child: Column(
children: [
Container(
margin: EdgeInsets.all(ScreenUtil().setWidth(40)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
body: Column(children: [
Expanded(
child: SingleChildScrollView(
child: Column(
children: [
Stack(
children: [
VEmptyView(40),
widget.model.headimgurl != null &&
widget.model.headimgurl != 'null'
? CachedNetworkImage(
imageUrl: widget.model.headimgurl,
fit: BoxFit.cover,
width: ScreenUtil().setWidth(38 * 2),
height: ScreenUtil().setWidth(38 * 2),
)
: Image.asset(
Utils.getImgPath('touxiang'),
fit: BoxFit.cover,
width: ScreenUtil().setWidth(38 * 2),
height: ScreenUtil().setWidth(38 * 2),
),
VEmptyView(40),
InkWell(
onTap: () {
if (canEdit) {
DialogUtil.textfeildAlertDialog(context,
title: '修改店员名称',
text: nickName != '暂未设置名称' ? nickName : '',
hintText: '输入店员名称',
toast: '请输入店员名称', rCallback: (name) {
_editAuthUser(name);
});
}
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
nickName,
style: TextStyle(
fontSize: ScreenUtil().setWidth(36),
color: MyColours.color_333333),
),
canEdit
? Padding(
padding: EdgeInsets.only(
left: ScreenUtil().setWidth(20)),
child: Image.asset(
Utils.getImgPath('yd_bianji'),
width: ScreenUtil().setWidth(20),
),
)
: SizedBox(),
Container(
padding: EdgeInsets.all(ScreenUtil().setWidth(16 * 2)),
margin: EdgeInsets.only(
top: ScreenUtil().setWidth(57 * 2),
left: ScreenUtil().setWidth(40),
right: ScreenUtil().setWidth(40)),
// height: ScreenUtil().setWidth(154 * 2),
decoration: BoxDecoration(
color: MyColours.color_ffffff,
boxShadow: [
// BoxShadow(
// color: Color.fromRGBO(0, 0, 0, 0.4),
// offset: Offset(0, ScreenUtil().setWidth(8)),
// spreadRadius: ScreenUtil().setWidth(2),
// blurRadius: ScreenUtil().setWidth(34))
BoxShadow(
color: Color.fromRGBO(0, 0, 0, 0.1),
offset: Offset(0, ScreenUtil().setWidth(8)),
blurRadius: ScreenUtil().setWidth(20),
spreadRadius: ScreenUtil().setWidth(1))
],
)),
VEmptyView(40),
canEdit
? InkWell(
onTap: () {
DialogUtil.textfeildAlertDialog(context,
title: '修改手机号',
text: phone != '添加手机号' ? phone : '',
hintText: '输入手机号',
keyboardType: TextInputType.number,
toast: '请输入手机号', rCallback: (phone) {
_bindPhoneSellerUser(phone);
});
},
child: Padding(
padding: EdgeInsets.only(
bottom: ScreenUtil().setWidth(40)),
child: Text(
phone,
style: TextStyle(
fontSize: ScreenUtil().setWidth(28),
color: MyColours.color_199095),
)))
: widget.model.phone != null &&
widget.model.phone != 'null'
? Padding(
padding: EdgeInsets.only(
bottom: ScreenUtil().setWidth(40)),
child: Text(
widget.model.phone,
borderRadius:
BorderRadius.circular(ScreenUtil().setWidth(18))),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Align(
alignment: Alignment.centerRight,
child: RoundButton(
text: '编辑资料',
gradientStart: MyColours.color_ffffff,
gradientEnd: MyColours.color_ffffff,
borderColor: MyColours.color_438E93,
width: ScreenUtil().setWidth(62 * 2),
height: ScreenUtil().setWidth(21 * 2),
fontSize: 24,
isBold: false,
textColor: MyColours.color_438E93,
radius: ScreenUtil().setWidth(26 * 2),
onPressed: () {
NavigatorUtil.goPersonnalBaseInfoPage(
context, data, widget.position);
}),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
VEmptyView(38),
Text(
'姓名: ${nickName == '暂未设置名称' ? '' : nickName}',
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_515151),
),
VEmptyView(26),
Text(
'电话: ${phone == '添加手机号' ? '' : phone}',
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_515151),
),
VEmptyView(6),
],
),
VEmptyView(14),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
data == null ||
data?.openid == null ||
data?.openid == 'null'
? SizedBox()
: RoundButton(
text: '已绑定微信',
gradientStart: MyColours.color_438E93,
gradientEnd: MyColours.color_438E93,
borderColor: MyColours.color_438E93,
width: ScreenUtil().setWidth(58 * 2),
height: ScreenUtil().setWidth(18 * 2),
fontSize: 20,
isBold: false,
textColor: MyColours.color_ffffff,
radius: ScreenUtil().setWidth(10),
onPressed: () {}),
Text('${widget.position} 工号: ${data?.account}',
style: TextStyle(
fontSize: ScreenUtil().setWidth(28),
color: MyColours.color_333333),
))
: SizedBox(),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
Provider.of<UserModel>(context, listen: false)
.user
.sellername,
style: TextStyle(
fontSize: ScreenUtil().setWidth(30),
color: MyColours.color_333333),
),
HEmptyView(20),
Text(
widget.position,
style: TextStyle(
fontSize: ScreenUtil().setWidth(28),
color: MyColours.color_199095),
),
],
),
// MyDivider(
// double.infinity,
// ScreenUtil().setWidth(10),
// color: Color.fromRGBO(235, 234, 239, 1),
// ),
VEmptyView(60),
Wrap(
spacing: ScreenUtil().setWidth(20), //主轴上子控件的间距
runSpacing: ScreenUtil().setWidth(20), //交叉轴上子控件之间的间距
children: _listWidget(btnList), //要显示的子控件集合
color: MyColours.color_515151,
fontSize: ScreenUtil().setSp(28),
)),
],
)
],
),
),
Positioned(
top: ScreenUtil().setWidth(13 * 2),
left: ScreenUtil().setWidth(35 * 2),
child:
data?.headimgurl != null && data?.headimgurl != 'null'
? ClipRRect(
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(80)),
child: CachedNetworkImage(
imageUrl: data?.headimgurl,
fit: BoxFit.cover,
width: ScreenUtil().setWidth(80 * 2),
height: ScreenUtil().setWidth(80 * 2),
))
: Stack(alignment: Alignment.center, children: [
Container(
width: ScreenUtil().setWidth(80 * 2),
height: ScreenUtil().setWidth(80 * 2),
decoration: BoxDecoration(
color: MyColours.color_f3f3f3,
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(80)))),
Align(
alignment: Alignment.center,
child: Image.asset(
Utils.getImgPath('personnal_no_image'),
fit: BoxFit.cover,
width: ScreenUtil().setWidth(50 * 2),
height: ScreenUtil().setWidth(50 * 2)),
),
]),
)
],
),
)
],
),
),
VEmptyView(114),
data?.openid == null || data?.openid == 'null'
? RoundButton(
text: '绑定微信',
gradientStart: MyColours.color_438E93,
gradientEnd: MyColours.color_438E93,
borderColor: MyColours.color_438E93,
width: ScreenUtil().setWidth(80 * 2),
height: ScreenUtil().setWidth(30 * 2),
fontSize: 32,
isBold: true,
textColor: MyColours.color_ffffff,
radius: ScreenUtil().setWidth(12),
onPressed: () {
if (dcAdduserCode != '' && dcAdduserCode != null) {
DialogUtil.openAlertDialogImage(
context, '请员工使用微信扫一扫添加店员', dcAdduserCode, 660);
} else {
_getWechatQrcode(need: true);
}
})
: SizedBox(),
data?.openid == null || data?.openid == 'null'
? VEmptyView(48)
: SizedBox(),
InkWell(
onTap: () {
NavigatorUtil.goPersonnelPasswordEditPage(context,
idstr: data.id);
},
child: Text(
'重置密码',
style: TextStyle(
decoration: TextDecoration.underline,
color: MyColours.color_438E93,
fontSize: ScreenUtil().setSp(28)),
)),
// Container(
// margin: EdgeInsets.all(ScreenUtil().setWidth(40)),
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.center,
// children: [
// VEmptyView(40),
// data.headimgurl != null &&
// data.headimgurl != 'null'
// ? ClipRRect(
// borderRadius: BorderRadius.circular(
// ScreenUtil().setWidth(80)),
// child: CachedNetworkImage(
// imageUrl: data.headimgurl,
// fit: BoxFit.cover,
// width: ScreenUtil().setWidth(80 * 2),
// height: ScreenUtil().setWidth(80 * 2),
// ))
// : Stack(alignment: Alignment.center, children: [
// Container(
// width: ScreenUtil().setWidth(80 * 2),
// height: ScreenUtil().setWidth(80 * 2),
// decoration: BoxDecoration(
// color: MyColours.color_f3f3f3,
// borderRadius: BorderRadius.circular(
// ScreenUtil().setWidth(80)))),
// Align(
// alignment: Alignment.center,
// child: Image.asset(
// Utils.getImgPath('personnal_no_image'),
// fit: BoxFit.cover,
// width: ScreenUtil().setWidth(50 * 2),
// height: ScreenUtil().setWidth(50 * 2)),
// ),
// ]),
// VEmptyView(40),
// InkWell(
// onTap: () {
// if (canEdit) {
// DialogUtil.textfeildAlertDialog(context,
// title: '修改店员名称',
// text: nickName != '暂未设置名称' ? nickName : '',
// hintText: '输入店员名称',
// toast: '请输入店员名称', rCallback: (name) {
// _editAuthUser(name);
// });
// }
// },
// child: Row(
// mainAxisAlignment: MainAxisAlignment.center,
// children: [
// Text(
// nickName,
// style: TextStyle(
// fontSize: ScreenUtil().setWidth(36),
// color: MyColours.color_333333),
// ),
// canEdit
// ? Padding(
// padding: EdgeInsets.only(
// left: ScreenUtil().setWidth(20)),
// child: Image.asset(
// Utils.getImgPath('yd_bianji'),
// width: ScreenUtil().setWidth(20),
// ),
// )
// : SizedBox(),
// ],
// )),
// VEmptyView(40),
// canEdit
// ? InkWell(
// onTap: () {
// DialogUtil.textfeildAlertDialog(context,
// title: '修改手机号',
// text: phone != '添加手机号' ? phone : '',
// hintText: '输入手机号',
// keyboardType: TextInputType.number,
// toast: '请输入手机号', rCallback: (phone) {
// _bindPhoneSellerUser(phone);
// });
// },
// child: Padding(
// padding: EdgeInsets.only(
// bottom: ScreenUtil().setWidth(40)),
// child: Text(
// phone,
// style: TextStyle(
// fontSize: ScreenUtil().setWidth(28),
// color: MyColours.color_199095),
// )))
// : data.phone != null &&
// data.phone != 'null'
// ? Padding(
// padding: EdgeInsets.only(
// bottom: ScreenUtil().setWidth(40)),
// child: Text(
// data.phone,
// style: TextStyle(
// fontSize: ScreenUtil().setWidth(28),
// color: MyColours.color_333333),
// ))
// : SizedBox(),
// Row(
// mainAxisAlignment: MainAxisAlignment.center,
// children: [
// Text(
// Provider.of<UserModel>(context, listen: false)
// .user
// .sellername,
// style: TextStyle(
// fontSize: ScreenUtil().setWidth(30),
// color: MyColours.color_333333),
// ),
// HEmptyView(20),
// Text(
// widget.position,
// style: TextStyle(
// fontSize: ScreenUtil().setWidth(28),
// color: MyColours.color_199095),
// ),
// ],
// ),
// // MyDivider(
// // double.infinity,
// // ScreenUtil().setWidth(10),
// // color: Color.fromRGBO(235, 234, 239, 1),
// // ),
// VEmptyView(60),
// Wrap(
// spacing: ScreenUtil().setWidth(20), //主轴上子控件的间距
// runSpacing: ScreenUtil().setWidth(20), //交叉轴上子控件之间的间距
// children: _listWidget(btnList), //要显示的子控件集合
// ),
// ],
// ),
// )
],
),
)),
InkWell(
onTap: () async {
await DialogUtil.removePersonnalDialog(
context, personnelProvider.sellerManageList, onTap: (map) {
print(map);
String uid = map['bjtype'];
if (uid == '') {
//选择了 全店未分配客户资源
} else {
//选择了某个经理
}
Future.wait<bool>([
// 2秒后返回结果
Future.delayed(new Duration(seconds: 2), () {
return true;
}),
// 4秒后返回结果
_delSellerClerk()
]).then((results) {
print(results[0]);
if (results[1]) {
//删除员工成功
EventBus().emit('personnel_manage_page');
Navigator.pop(context);
}
}).catchError((e) {
print(e);
});
// DialogUtil.cupertinoAlertDialog(context,
// title: '提示',
// content: '移除店员后,店员将无法接收门店收款通知,店员收款码也将无法收款',
// rTitle: '移除', rCallback: () {
// _delSellerClerk();
// });
});
},
child: Padding(
padding: EdgeInsets.symmetric(
vertical: ScreenUtil().setWidth(34 * 2)),
child: Text(
'移除员工',
style: TextStyle(
decoration: TextDecoration.underline,
color: MyColours.color_438E93,
fontSize: ScreenUtil().setSp(28)),
))),
]),
);
}
}
... ...
// import 'dart:convert';
// import 'package:cached_network_image/cached_network_image.dart';
// import 'package:common_utils/common_utils.dart';
// import 'package:dio/dio.dart';
// import 'package:flutter/material.dart';
// import 'package:flutter_screenutil/screenutil.dart';
// import 'package:one_key/models/get_seller_info_model.dart';
// import 'package:one_key/models/personnel_manage_model.dart';
// import 'package:one_key/net/dio_util.dart';
// import 'package:one_key/provider/personnel_provider.dart';
// import 'package:one_key/provider/user_model.dart';
// import 'package:one_key/res/colors.dart';
// import 'package:one_key/route/navigator_util.dart';
// import 'package:one_key/utils/dialog_util.dart';
// import 'package:one_key/utils/event_bus.dart';
// import 'package:one_key/utils/utils.dart';
// import 'package:one_key/widgets/MyDivider.dart';
// import 'package:one_key/widgets/h_empty_view.dart';
// import 'package:one_key/widgets/round_button.dart';
// import 'package:one_key/widgets/system_app_bar.dart';
// import 'package:one_key/widgets/v_empty_view.dart';
// import 'package:provider/provider.dart';
// class PersonnelDetailPage extends StatefulWidget {
// final PersonnelManageSunModel model;
// final String position;
// PersonnelDetailPage({Key key, this.model, this.position}) : super(key: key);
// @override
// _PersonnelDetailPageState createState() => _PersonnelDetailPageState();
// }
// class _PersonnelDetailPageState extends State<PersonnelDetailPage> {
// String roleNameLogin;
// String accountLogin;
// bool canEdit = false;
// List<String> btnList = [];
// UserModel userModel;
// PersonnelProvider personnelProvider;
// String nickName;
// String phone;
// String dcAdduserCode;
// @override
// void initState() {
// super.initState();
// nickName = widget.model.nickName != null && widget.model.nickName != 'null'
// ? widget.model.nickName
// : '暂未设置名称';
// phone = widget.model.phone != null && widget.model.userName != 'null'
// ? widget.model.phone
// : '添加手机号';
// WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
// if (widget.model.openid == null || widget.model.openid == 'null') {
// // _getStoreBaseinfo();
// _getWechatQrcode();
// }
// setState(() {
// roleNameLogin = userModel.user.role_name;
// accountLogin = userModel.user.account;
// if (roleNameLogin == '管理员') {
// canEdit = true;
// } else if (roleNameLogin == '店长') {
// if (widget.position == '管理员') {
// canEdit = false;
// } else if (widget.position == '店长') {
// if (accountLogin == widget.model.account) {
// print('11111');
// //店长自己
// canEdit = true;
// } else {
// print('333333');
// canEdit = false;
// }
// } else {
// canEdit = true;
// }
// } else {
// if (accountLogin == widget.model.account) {
// //自己
// canEdit = true;
// } else {
// canEdit = false;
// }
// }
// if (canEdit) {
// btnList = [
// '移除店员',
// ];
// if (widget.model.openid == null || widget.model.openid == 'null') {
// btnList.add('绑定微信');
// }
// btnList.add('查看密码');
// if (widget.model.isOnCall == '0') {
// btnList.add('设为接单人');
// }
// } else {
// btnList = [];
// }
// });
// });
// }
// ///获取店铺信息
// // _getStoreBaseinfo() async {
// // GetSellerInfoSunModel itemModel =
// // await personnelProvider.getSellerById(context);
// // if (itemModel != null) {
// // dcAdduserCode = itemModel.data.dcAdduserCode;
// // }
// // }
// ///设置接单人
// _setUserIsCall({bool showLoading = true}) async {
// Map<String, String> params = {
// "sid": Provider.of<UserModel>(context, listen: false).user.sellerid,
// 'uid': widget.model.id
// };
// bool success = await personnelProvider.setUserIsCall(context, params,
// showLoading: showLoading);
// if (success) {
// Utils.showToast('设置成功');
// EventBus().emit('personnel_manage_page');
// //刷新页面
// setState(() {
// btnList.remove('设为接单人');
// });
// }
// }
// ///删除店员
// _delSellerClerk({bool showLoading = true}) async {
// Map<String, String> params = {'seller_user_id': widget.model.id};
// bool success = await personnelProvider.delSellerClerk(context, params,
// showLoading: showLoading);
// if (success) {
// EventBus().emit('personnel_manage_page');
// Navigator.pop(context);
// }
// }
// ///编辑店员
// _editAuthUser(String name, {bool showLoading = true}) async {
// Map<String, String> params = {'id': widget.model.id, 'user_name': name};
// bool success = await personnelProvider.editAuthUser(context, params,
// showLoading: showLoading);
// if (success) {
// EventBus().emit('personnel_manage_page');
// setState(() {
// nickName = name;
// });
// }
// }
// /// 账号表-员工绑定手机号
// _bindPhoneSellerUser(String name, {bool showLoading = true}) async {
// Map<String, String> params = {'kid': widget.model.id, 'phone': name};
// bool success = await personnelProvider.bindPhoneSellerUser(context, params,
// showLoading: showLoading);
// if (success) {
// EventBus().emit('personnel_manage_page');
// setState(() {
// phone = name;
// });
// }
// }
// List<Widget> _listWidget(List<String> titleList) {
// List<Widget> list = [];
// titleList.forEach((element) {
// list.add(
// RoundButton(
// text: element,
// fontSize: 30,
// isBold: false,
// height: ScreenUtil().setWidth(80),
// // width: double.infinity,
// width: (ScreenUtil.screenWidthDp - ScreenUtil().setWidth(140)) / 2,
// radius: ScreenUtil().setWidth(10),
// onPressed: () {
// if (element == '设为接单人') {
// DialogUtil.cupertinoAlertDialog(context,
// content: '请确认该用户关注了周到安排公众号并填写了手机号,否则无法接单', rCallback: () {
// _setUserIsCall();
// });
// } else if (element == '移除店员') {
// DialogUtil.cupertinoAlertDialog(context,
// title: '提示',
// content: '移除店员后,店员将无法接收门店收款通知,店员收款码也将无法收款',
// rTitle: '移除', rCallback: () {
// _delSellerClerk();
// });
// } else if (element == '绑定微信') {
// if (dcAdduserCode != '' && dcAdduserCode != null) {
// DialogUtil.openAlertDialogImage(
// context, '请员工使用微信扫一扫添加店员', dcAdduserCode, 660);
// } else {
// _getWechatQrcode(need: true);
// }
// } else if (element == '查看密码') {
// NavigatorUtil.goPersonnelPasswordPage(context,
// account: widget.model.account, idstr: widget.model.id);
// }
// },
// ),
// );
// });
// return list;
// }
// ///获取二维码
// _getWechatQrcode({bool need = false}) async {
// String sid = Provider.of<UserModel>(context, listen: false).user.sellerid;
// String id = Provider.of<UserModel>(context, listen: false).user.openid;
// // https: //xt.colorcun.com/WechatApi/WechatApi/CreateDcSubQrcode/sellerid/商家ID/uid/当前账号ID
// Response response = await DioUtil.getInstance().getDio().get(
// "https://xt.colorcun.com/WechatApi/WechatApi/CreateDcSubQrcode?sellerid=$sid&uid=${widget.model.id}");
// // Response response = await DioUtil.getInstance().getDio().get(
// // "https://xt.colorcun.com/WechatApi/WechatApi/CreateDcSubQrcode?sellerid=$sid&uid=$uid");
// // Response response = await DioUtil.getInstance().getDio().get(
// // "https://api.weixin.qq.com/sns/oauth2/access_token?appid=wx85aa3cdd0f791e65&secret=87c9a23c2e6032b2da75af6b0efc5424&code=$code&grant_type=authorization_code");
// LogUtil.v("access_token:${response.toString()}");
// Map<String, dynamic> responseData = json.decode(response.toString());
// print(responseData);
// dcAdduserCode = responseData["data"];
// if (need) {
// if (dcAdduserCode == null || dcAdduserCode == '') {
// Utils.showToast('二维码获取失败');
// } else {
// DialogUtil.openAlertDialogImage(
// context, '请员工使用微信扫一扫添加店员', dcAdduserCode, 660);
// }
// }
// print(dcAdduserCode);
// // if (responseData["data"] != null) {
// // // Utils.showToast(responseData["errmsg"] ?? "登录失败,请稍后重试");
// // // Loading.hideLoading(context);
// // } else {}
// }
// @override
// Widget build(BuildContext context) {
// userModel = Provider.of<UserModel>(context, listen: false);
// personnelProvider = Provider.of<PersonnelProvider>(context, listen: true);
// return Scaffold(
// backgroundColor: MyColours.color_ffffff,
// appBar: SystemAppBar(
// '店员详情',
// onTap: () {
// Navigator.pop(context);
// },
// ),
// body: SingleChildScrollView(
// child: Column(
// children: [
// Container(
// margin: EdgeInsets.all(ScreenUtil().setWidth(40)),
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.center,
// children: [
// VEmptyView(40),
// widget.model.headimgurl != null &&
// widget.model.headimgurl != 'null'
// ? CachedNetworkImage(
// imageUrl: widget.model.headimgurl,
// fit: BoxFit.cover,
// width: ScreenUtil().setWidth(38 * 2),
// height: ScreenUtil().setWidth(38 * 2),
// )
// : Image.asset(
// Utils.getImgPath('touxiang'),
// fit: BoxFit.cover,
// width: ScreenUtil().setWidth(38 * 2),
// height: ScreenUtil().setWidth(38 * 2),
// ),
// VEmptyView(40),
// InkWell(
// onTap: () {
// if (canEdit) {
// DialogUtil.textfeildAlertDialog(context,
// title: '修改店员名称',
// text: nickName != '暂未设置名称' ? nickName : '',
// hintText: '输入店员名称',
// toast: '请输入店员名称', rCallback: (name) {
// _editAuthUser(name);
// });
// }
// },
// child: Row(
// mainAxisAlignment: MainAxisAlignment.center,
// children: [
// Text(
// nickName,
// style: TextStyle(
// fontSize: ScreenUtil().setWidth(36),
// color: MyColours.color_333333),
// ),
// canEdit
// ? Padding(
// padding: EdgeInsets.only(
// left: ScreenUtil().setWidth(20)),
// child: Image.asset(
// Utils.getImgPath('yd_bianji'),
// width: ScreenUtil().setWidth(20),
// ),
// )
// : SizedBox(),
// ],
// )),
// VEmptyView(40),
// canEdit
// ? InkWell(
// onTap: () {
// DialogUtil.textfeildAlertDialog(context,
// title: '修改手机号',
// text: phone != '添加手机号' ? phone : '',
// hintText: '输入手机号',
// keyboardType: TextInputType.number,
// toast: '请输入手机号', rCallback: (phone) {
// _bindPhoneSellerUser(phone);
// });
// },
// child: Padding(
// padding: EdgeInsets.only(
// bottom: ScreenUtil().setWidth(40)),
// child: Text(
// phone,
// style: TextStyle(
// fontSize: ScreenUtil().setWidth(28),
// color: MyColours.color_199095),
// )))
// : widget.model.phone != null &&
// widget.model.phone != 'null'
// ? Padding(
// padding: EdgeInsets.only(
// bottom: ScreenUtil().setWidth(40)),
// child: Text(
// widget.model.phone,
// style: TextStyle(
// fontSize: ScreenUtil().setWidth(28),
// color: MyColours.color_333333),
// ))
// : SizedBox(),
// Row(
// mainAxisAlignment: MainAxisAlignment.center,
// children: [
// Text(
// Provider.of<UserModel>(context, listen: false)
// .user
// .sellername,
// style: TextStyle(
// fontSize: ScreenUtil().setWidth(30),
// color: MyColours.color_333333),
// ),
// HEmptyView(20),
// Text(
// widget.position,
// style: TextStyle(
// fontSize: ScreenUtil().setWidth(28),
// color: MyColours.color_199095),
// ),
// ],
// ),
// // MyDivider(
// // double.infinity,
// // ScreenUtil().setWidth(10),
// // color: Color.fromRGBO(235, 234, 239, 1),
// // ),
// VEmptyView(60),
// Wrap(
// spacing: ScreenUtil().setWidth(20), //主轴上子控件的间距
// runSpacing: ScreenUtil().setWidth(20), //交叉轴上子控件之间的间距
// children: _listWidget(btnList), //要显示的子控件集合
// ),
// ],
// ),
// )
// ],
// ),
// ),
// );
// }
// }
... ...
import 'dart:ffi';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/screenutil.dart';
... ... @@ -10,7 +12,9 @@ import 'package:one_key/utils/event_bus.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/MyDivider.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/round_button.dart';
import 'package:one_key/widgets/system_app_bar.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
class PersonnelManagePage extends StatefulWidget {
... ... @@ -77,7 +81,7 @@ class _PersonnelManagePageState extends State<PersonnelManagePage> {
return Scaffold(
backgroundColor: MyColours.color_ffffff,
appBar: SystemAppBar(
'员工与职级管理',
'员工管理',
onTap: () {
EventBus().emit('changeStatusColor');
Navigator.of(context).pop();
... ... @@ -95,27 +99,68 @@ class _PersonnelManagePageState extends State<PersonnelManagePage> {
itemBuilder: (BuildContext context, int index) {
String title = titleList[index];
List<PersonnelManageSunModel> data = [];
String hasWechatNum = '';
String roleId = '';
bool canAdd = false; //是否可新增员工
if (Provider.of<UserModel>(context, listen: false)
.user
.role_name ==
'管理员') {
if (title != '管理员') {
canAdd = true;
}
} else if (Provider.of<UserModel>(context, listen: false)
.user
.role_name ==
'店长') {
if (title != '管理员' && title != '店长') {
canAdd = true;
}
} else if (Provider.of<UserModel>(context, listen: false)
.user
.role_name ==
'客户经理') {
if (title != '管理员' && title != '店长' && title != '客户经理') {
canAdd = true;
}
}
if (personnelProvider.dataMap != null) {
if (title == '管理员') {
data = personnelProvider.dataMap.admin.listdata;
roleId = personnelProvider.dataMap.admin.roleId;
hasWechatNum = personnelProvider
.dataMap.admin.hasWechatNum
.toString();
} else if (title == '店长') {
data = personnelProvider.dataMap.shopowner.listdata;
roleId = personnelProvider.dataMap.shopowner.roleId;
hasWechatNum = personnelProvider
.dataMap.shopowner.hasWechatNum
.toString();
} else if (title == '客户经理') {
data = personnelProvider.dataMap.manager.listdata;
roleId = personnelProvider.dataMap.manager.roleId;
hasWechatNum = personnelProvider
.dataMap.manager.hasWechatNum
.toString();
} else if (title == '收银员') {
data = personnelProvider.dataMap.cashier.listdata;
roleId = personnelProvider.dataMap.cashier.roleId;
hasWechatNum = personnelProvider
.dataMap.cashier.hasWechatNum
.toString();
} else if (title == '服务员') {
data = personnelProvider.dataMap.waiter.listdata;
roleId = personnelProvider.dataMap.waiter.roleId;
hasWechatNum = personnelProvider
.dataMap.waiter.hasWechatNum
.toString();
}
}
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
InkWell(
onTap: () {
... ... @@ -133,139 +178,314 @@ class _PersonnelManagePageState extends State<PersonnelManagePage> {
_addSellerClerk(roleId);
}
},
child: Padding(
child: Container(
color: MyColours.color_f3f3f3,
height: ScreenUtil().setWidth(60),
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
vertical: ScreenUtil().setWidth(40)),
horizontal: ScreenUtil().setWidth(36),
),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
title == '管理员'
? '${title}'
: '${title} (${data.length}人)',
style: TextStyle(
fontSize: ScreenUtil().setWidth(28),
color: MyColours.color_333333),
),
title == '管理员'
? SizedBox()
: Provider.of<UserModel>(context,
listen: false)
.user
.role_name ==
'管理员' ||
(Provider.of<UserModel>(context,
listen: false)
.user
.role_name ==
'店长' &&
title != '店长')
? InkWell(
onTap: () {
_addSellerClerk(roleId);
},
child: Text(
'添加',
// Text(
// title == '管理员'
// ? '${title}'
// : '${title} (${data.length}/${data.length}人)',
// style: TextStyle(
// fontSize: ScreenUtil().setWidth(36),
// color: MyColours.color_515151),
// ),
RichText(
text: TextSpan(
// style: TextStyle(
// fontSize: ScreenUtil().setSp(36),
// color: MyColours.color_515151),
children: [
// const TextSpan(text: '('),
TextSpan(
text: '${title}',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize:
ScreenUtil().setSp(36),
color: MyColours.color_515151)),
title == '管理员'
? TextSpan(text: '')
: TextSpan(
text:
' ${hasWechatNum}/${data.length}',
style: TextStyle(
fontSize: ScreenUtil()
.setWidth(30),
color:
MyColours.color_199095),
),
)
: SizedBox()
fontSize:
ScreenUtil().setSp(28),
color: MyColours
.color_999999)),
])),
],
))),
MyDivider(
double.infinity,
ScreenUtil().setWidth(2),
color: MyColours.color_f3f3f3,
),
// MyDivider(
// double.infinity,
// ScreenUtil().setWidth(2),
// color: MyColours.color_f3f3f3,
// ),
ListView.builder(
padding: EdgeInsets.only(
top: ScreenUtil().setWidth(42),
left: ScreenUtil().setWidth(48),
right: ScreenUtil().setWidth(48),
bottom: ScreenUtil().setWidth(20),
),
physics: NeverScrollableScrollPhysics(),
itemCount: data.length,
shrinkWrap: true,
controller: _scrollController,
itemBuilder: (BuildContext context, int index) {
PersonnelManageSunModel model = data[index];
bool isWechat =
model.openid == null || model.openid == 'null'
? false
: true;
bool canIn = false; //是否可进入员工详情
if (Provider.of<UserModel>(context, listen: false)
.user
.role_name ==
'管理员') {
canIn = true;
} else if (Provider.of<UserModel>(context,
listen: false)
.user
.role_name ==
'店长') {
if (title == '管理员') {
canIn = false;
} else if (title == '店长') {
canIn = false;
if (Provider.of<UserModel>(context,
listen: false)
.user
.account ==
model.account) {
canIn = true;
}
} else {
canIn = true;
}
} else if (Provider.of<UserModel>(context,
listen: false)
.user
.role_name ==
'客户经理') {
if (title == '管理员') {
canIn = false;
} else if (title == '店长') {
canIn = false;
} else if (title == '客户经理') {
canIn = false;
if (Provider.of<UserModel>(context,
listen: false)
.user
.account ==
model.account) {
canIn = true;
}
} else {
canIn = true;
}
} else {
canIn = false;
if (Provider.of<UserModel>(context, listen: false)
.user
.account ==
model.account) {
canIn = true;
}
}
return InkWell(
onTap: () {
NavigatorUtil.goPersonnelDetailPage(context,
model: model, position: title);
if (canIn) {
NavigatorUtil.goPersonnelDetailPage(context,
index: index, position: title);
}
},
child: Stack(children: [
Column(children: [
Padding(
padding: EdgeInsets.symmetric(
vertical: ScreenUtil().setWidth(20),
horizontal:
ScreenUtil().setWidth(40)),
padding: EdgeInsets.only(
bottom: ScreenUtil().setWidth(44),
),
child: Row(
children: [
ClipRRect(
borderRadius:
BorderRadius.circular(
ScreenUtil()
.setWidth(38)),
child: model.headimgurl !=
null &&
model.headimgurl !=
'null'
? CachedNetworkImage(
imageUrl:
model.headimgurl,
fit: BoxFit.cover,
width: ScreenUtil()
.setWidth(38 * 2),
height: ScreenUtil()
.setWidth(38 * 2),
model.headimgurl != null &&
model.headimgurl != 'null'
? ClipRRect(
borderRadius:
BorderRadius.circular(
ScreenUtil()
.setWidth(42)),
child: CachedNetworkImage(
imageUrl:
model.headimgurl,
fit: BoxFit.cover,
width: ScreenUtil()
.setWidth(42 * 2),
height: ScreenUtil()
.setWidth(42 * 2),
))
: Stack(
alignment: Alignment.center,
children: [
Container(
width: ScreenUtil()
.setWidth(
42 * 2),
height: ScreenUtil()
.setWidth(
42 * 2),
decoration: BoxDecoration(
color: MyColours
.color_f3f3f3,
borderRadius: BorderRadius.circular(
ScreenUtil()
.setWidth(
42)))),
Align(
alignment:
Alignment.center,
child: Image.asset(
Utils.getImgPath(
'personnal_no_image'),
fit: BoxFit.cover,
width: ScreenUtil()
.setWidth(
20 * 2),
height: ScreenUtil()
.setWidth(
20 * 2)),
),
]),
HEmptyView(32),
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment
.center,
children: [
Text(
model.nickName !=
null &&
model.nickName !=
'null'
? model.nickName
: '暂未设置名称',
style: TextStyle(
fontSize:
ScreenUtil()
.setWidth(
32),
color: isWechat
? MyColours
.color_438E93
: MyColours
.color_999999),
),
HEmptyView(8),
Text(
model.phone ?? '',
style: TextStyle(
fontSize:
ScreenUtil()
.setWidth(
32),
color: isWechat
? MyColours
.color_438E93
: MyColours
.color_999999),
)
: Image.asset(
Utils.getImgPath(
'touxiang'),
fit: BoxFit.cover,
]),
VEmptyView(16),
Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: [
RoundButton(
text:
'工号:${model.account}',
gradientStart: isWechat
? MyColours
.color_438E93
: MyColours
.color_BFC4D4,
gradientEnd: isWechat
? MyColours
.color_438E93
: MyColours
.color_BFC4D4,
borderColor: isWechat
? MyColours
.color_438E93
: MyColours
.color_BFC4D4,
width: ScreenUtil()
.setWidth(38 * 2),
.setWidth(62 * 2),
height: ScreenUtil()
.setWidth(38 * 2),
)),
HEmptyView(40),
Expanded(
child: Text(
model.nickName != null &&
model.nickName != 'null'
? model.nickName
: '暂未设置名称',
style: TextStyle(
fontSize:
ScreenUtil().setWidth(28),
color:
MyColours.color_333333),
)),
Spacer(),
Text(
'工号:${model.account}',
style: TextStyle(
fontSize:
ScreenUtil().setWidth(28),
color:
MyColours.color_999999),
.setWidth(18 * 2),
fontSize: 20,
isBold: false,
textColor: MyColours
.color_ffffff,
radius: ScreenUtil()
.setWidth(8),
onPressed: () {}),
HEmptyView(8),
isWechat
? RoundButton(
text: '已绑定微信',
gradientStart:
MyColours
.color_438E93,
gradientEnd: MyColours
.color_438E93,
borderColor: MyColours
.color_438E93,
width: ScreenUtil()
.setWidth(
58 * 2),
height: ScreenUtil()
.setWidth(
18 * 2),
fontSize: 20,
isBold: false,
textColor: MyColours
.color_ffffff,
radius: ScreenUtil()
.setWidth(8),
onPressed: () {})
: SizedBox(),
],
)
],
),
HEmptyView(20),
Image.asset(
"assets/arr_right_gray.png",
width: ScreenUtil().setWidth(14),
height: ScreenUtil().setWidth(22),
)
Spacer(),
canIn
? Image.asset(
"assets/arr_right_gray.png",
width: ScreenUtil()
.setWidth(14),
height: ScreenUtil()
.setWidth(22),
)
: SizedBox()
],
)),
MyDivider(
double.infinity,
ScreenUtil().setWidth(2),
color: MyColours.color_f3f3f3,
)
]),
model.isOnCall == '1'
? Positioned(
... ... @@ -275,13 +495,9 @@ class _PersonnelManagePageState extends State<PersonnelManagePage> {
alignment: Alignment.center,
decoration: BoxDecoration(
color: MyColours.color_d93535,
borderRadius: BorderRadius.only(
topRight: Radius.circular(
ScreenUtil()
.setWidth(16)),
bottomRight: Radius.circular(
ScreenUtil()
.setWidth(16)))),
borderRadius: BorderRadius.all(
Radius.circular(ScreenUtil()
.setWidth(16)))),
child: Text(
'Call',
style: TextStyle(
... ... @@ -293,11 +509,40 @@ class _PersonnelManagePageState extends State<PersonnelManagePage> {
: SizedBox()
]));
}),
MyDivider(
double.infinity,
ScreenUtil().setWidth(20),
color: Color.fromRGBO(235, 234, 239, 1),
),
canAdd
? InkWell(
onTap: () {
_addSellerClerk(roleId);
},
child: Container(
width: ScreenUtil().setWidth(74 * 2),
height: ScreenUtil().setWidth(44),
margin: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(36),
),
decoration: BoxDecoration(
color: MyColours.color_ffffff,
border: Border.all(
width: ScreenUtil().setWidth(2),
color: MyColours.color_438E93),
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(12))),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(Utils.getImgPath('add_area'),
width: ScreenUtil().setWidth(20)),
HEmptyView(6),
Text('添加一名',
style: TextStyle(
color: MyColours.color_438E93,
fontSize: ScreenUtil().setSp(24),
)),
],
)))
: SizedBox(),
canAdd ? VEmptyView(62) : SizedBox()
],
);
})));
... ...
// import 'package:cached_network_image/cached_network_image.dart';
// import 'package:flutter/material.dart';
// import 'package:flutter_screenutil/screenutil.dart';
// import 'package:one_key/models/personnel_manage_model.dart';
// import 'package:one_key/provider/personnel_provider.dart';
// import 'package:one_key/provider/user_model.dart';
// import 'package:one_key/res/colors.dart';
// import 'package:one_key/route/navigator_util.dart';
// import 'package:one_key/utils/event_bus.dart';
// import 'package:one_key/utils/utils.dart';
// import 'package:one_key/widgets/MyDivider.dart';
// import 'package:one_key/widgets/h_empty_view.dart';
// import 'package:one_key/widgets/system_app_bar.dart';
// import 'package:provider/provider.dart';
// class PersonnelManagePage extends StatefulWidget {
// PersonnelManagePage({Key key}) : super(key: key);
// @override
// _PersonnelManagePageState createState() => _PersonnelManagePageState();
// }
// class _PersonnelManagePageState extends State<PersonnelManagePage> {
// PersonnelProvider personnelProvider;
// ScrollController _scrollController = ScrollController();
// List<String> titleList = [];
// @override
// void initState() {
// // TODO: implement initState
// super.initState();
// titleList = ['管理员', '店长', '客户经理', '收银员', '服务员'];
// WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
// _getAuthUserLists(showLoading: false);
// });
// EventBus().on('personnel_manage_page', (arg) {
// _getAuthUserLists(showLoading: false);
// });
// }
// @override
// void dispose() {
// // TODO: implement dispose
// super.dispose();
// EventBus().off('personnel_manage_page');
// }
// //获取员工信息列表
// _getAuthUserLists({bool showLoading = true}) async {
// Map<String, String> params = {
// "sellerid": Provider.of<UserModel>(context, listen: false).user.sellerid,
// };
// await personnelProvider.getAuthUserLists(context, params,
// showLoading: showLoading);
// }
// ///添加店员
// _addSellerClerk(String roleId, {bool showLoading = true}) async {
// Map<String, String> params = {
// "sellerid": Provider.of<UserModel>(context, listen: false).user.sellerid,
// 'role_id': roleId
// };
// bool success = await personnelProvider.addSellerClerk(context, params,
// showLoading: showLoading);
// if (success) {
// //刷新页面
// _getAuthUserLists(showLoading: false);
// }
// }
// @override
// Widget build(BuildContext context) {
// personnelProvider = Provider.of<PersonnelProvider>(context, listen: true);
// return Scaffold(
// backgroundColor: MyColours.color_ffffff,
// appBar: SystemAppBar(
// '员工与职级管理',
// onTap: () {
// EventBus().emit('changeStatusColor');
// Navigator.of(context).pop();
// },
// ),
// body: WillPopScope(
// onWillPop: () {
// EventBus().emit('changeStatusColor');
// Navigator.of(context).pop();
// },
// child: ListView.builder(
// itemCount: titleList.length,
// shrinkWrap: true,
// controller: _scrollController,
// itemBuilder: (BuildContext context, int index) {
// String title = titleList[index];
// List<PersonnelManageSunModel> data = [];
// String roleId = '';
// if (personnelProvider.dataMap != null) {
// if (title == '管理员') {
// data = personnelProvider.dataMap.admin.listdata;
// roleId = personnelProvider.dataMap.admin.roleId;
// } else if (title == '店长') {
// data = personnelProvider.dataMap.shopowner.listdata;
// roleId = personnelProvider.dataMap.shopowner.roleId;
// } else if (title == '客户经理') {
// data = personnelProvider.dataMap.manager.listdata;
// roleId = personnelProvider.dataMap.manager.roleId;
// } else if (title == '收银员') {
// data = personnelProvider.dataMap.cashier.listdata;
// roleId = personnelProvider.dataMap.cashier.roleId;
// } else if (title == '服务员') {
// data = personnelProvider.dataMap.waiter.listdata;
// roleId = personnelProvider.dataMap.waiter.roleId;
// }
// }
// return Column(
// children: [
// InkWell(
// onTap: () {
// if ((Provider.of<UserModel>(context, listen: false)
// .user
// .role_name ==
// '管理员' ||
// (Provider.of<UserModel>(context,
// listen: false)
// .user
// .role_name ==
// '店长' &&
// title != '店长')) &&
// title != '管理员') {
// _addSellerClerk(roleId);
// }
// },
// child: Padding(
// padding: EdgeInsets.symmetric(
// horizontal: ScreenUtil().setWidth(40),
// vertical: ScreenUtil().setWidth(40)),
// child: Row(
// mainAxisAlignment:
// MainAxisAlignment.spaceBetween,
// children: [
// Text(
// title == '管理员'
// ? '${title}'
// : '${title} (${data.length}人)',
// style: TextStyle(
// fontSize: ScreenUtil().setWidth(28),
// color: MyColours.color_333333),
// ),
// title == '管理员'
// ? SizedBox()
// : Provider.of<UserModel>(context,
// listen: false)
// .user
// .role_name ==
// '管理员' ||
// (Provider.of<UserModel>(context,
// listen: false)
// .user
// .role_name ==
// '店长' &&
// title != '店长')
// ? InkWell(
// onTap: () {
// _addSellerClerk(roleId);
// },
// child: Text(
// '添加',
// style: TextStyle(
// fontSize: ScreenUtil()
// .setWidth(30),
// color:
// MyColours.color_199095),
// ),
// )
// : SizedBox()
// ],
// ))),
// MyDivider(
// double.infinity,
// ScreenUtil().setWidth(2),
// color: MyColours.color_f3f3f3,
// ),
// ListView.builder(
// physics: NeverScrollableScrollPhysics(),
// itemCount: data.length,
// shrinkWrap: true,
// controller: _scrollController,
// itemBuilder: (BuildContext context, int index) {
// PersonnelManageSunModel model = data[index];
// return InkWell(
// onTap: () {
// NavigatorUtil.goPersonnelDetailPage(context,
// model: model, position: title);
// },
// child: Stack(children: [
// Column(children: [
// Padding(
// padding: EdgeInsets.symmetric(
// vertical: ScreenUtil().setWidth(20),
// horizontal:
// ScreenUtil().setWidth(40)),
// child: Row(
// children: [
// ClipRRect(
// borderRadius:
// BorderRadius.circular(
// ScreenUtil()
// .setWidth(38)),
// child: model.headimgurl !=
// null &&
// model.headimgurl !=
// 'null'
// ? CachedNetworkImage(
// imageUrl:
// model.headimgurl,
// fit: BoxFit.cover,
// width: ScreenUtil()
// .setWidth(38 * 2),
// height: ScreenUtil()
// .setWidth(38 * 2),
// )
// : Image.asset(
// Utils.getImgPath(
// 'touxiang'),
// fit: BoxFit.cover,
// width: ScreenUtil()
// .setWidth(38 * 2),
// height: ScreenUtil()
// .setWidth(38 * 2),
// )),
// HEmptyView(40),
// Expanded(
// child: Text(
// model.nickName != null &&
// model.nickName != 'null'
// ? model.nickName
// : '暂未设置名称',
// style: TextStyle(
// fontSize:
// ScreenUtil().setWidth(28),
// color:
// MyColours.color_333333),
// )),
// Spacer(),
// Text(
// '工号:${model.account}',
// style: TextStyle(
// fontSize:
// ScreenUtil().setWidth(28),
// color:
// MyColours.color_999999),
// ),
// HEmptyView(20),
// Image.asset(
// "assets/arr_right_gray.png",
// width: ScreenUtil().setWidth(14),
// height: ScreenUtil().setWidth(22),
// )
// ],
// )),
// MyDivider(
// double.infinity,
// ScreenUtil().setWidth(2),
// color: MyColours.color_f3f3f3,
// )
// ]),
// model.isOnCall == '1'
// ? Positioned(
// child: Container(
// width: ScreenUtil().setWidth(50),
// height: ScreenUtil().setWidth(28),
// alignment: Alignment.center,
// decoration: BoxDecoration(
// color: MyColours.color_d93535,
// borderRadius: BorderRadius.only(
// topRight: Radius.circular(
// ScreenUtil()
// .setWidth(16)),
// bottomRight: Radius.circular(
// ScreenUtil()
// .setWidth(16)))),
// child: Text(
// 'Call',
// style: TextStyle(
// color: MyColours.color_ffffff,
// fontSize:
// ScreenUtil().setSp(18)),
// ),
// ))
// : SizedBox()
// ]));
// }),
// MyDivider(
// double.infinity,
// ScreenUtil().setWidth(20),
// color: Color.fromRGBO(235, 234, 239, 1),
// ),
// ],
// );
// })));
// }
// }
... ...
import 'package:flutter/material.dart';
import 'package:one_key/constant/constant.dart';
import 'package:one_key/constant/error.dart';
import 'package:one_key/models/filter_btn_model.dart';
import 'package:one_key/models/get_seller_info_model.dart';
import 'package:one_key/models/get_seller_user_by_sellerid_model.dart';
import 'package:one_key/models/personnel_manage_model.dart';
import 'package:one_key/net/base_resp.dart';
import 'package:one_key/net/dio_util.dart';
... ... @@ -16,6 +19,48 @@ import 'package:provider/provider.dart';
class PersonnelProvider extends ChangeNotifier {
PersonnelManageModelData dataMap;
String password = '';
List<FilterBtnModel> sellerManageList = []; //经理数据 ---- 商家编辑页面
int manageSelIndex; //当前选中
///商家详情编辑页面 ------ 获取经理数据
Future<List<FilterBtnModel>> getSellerUserBySellerid(BuildContext context,
{isShowLoading = true}) async {
Map<String, String> params = {
'sellerid': Provider.of<UserModel>(context, listen: false).user.sellerid
};
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(
context, Method.get, HttpUrl.get_seller_user_by_sellerid,
data: params, showLoading: false)
.catchError((error) {
print(error.toString());
if (error is MyError) {}
});
if (baseResp.code == Constant.status_success) {
List<GetSellerUserBySelleridSunModel> sunmodel =
GetSellerUserBySelleridModel.fromJson(baseResp.responseData).data;
sellerManageList = [];
if (sunmodel != null && sunmodel.length > 0) {
for (GetSellerUserBySelleridSunModel item in sunmodel) {
if (item.nickName != null) {
FilterBtnModel model = FilterBtnModel();
model.id = item.id;
model.title = item.nickName + '(${item.roleName})';
sellerManageList.add(model);
}
}
}
} else {
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
}
FilterBtnModel model = FilterBtnModel();
model.id = '';
model.title = '全店未分配客户资源';
sellerManageList.insert(0, model);
return sellerManageList;
}
/// 获取店员列表
getAuthUserLists(BuildContext context, Map<String, String> params,
... ... @@ -36,6 +81,36 @@ class PersonnelProvider extends ChangeNotifier {
});
baseResp.responseData['data'] = tempData;
dataMap = PersonnelManageModel.fromJson(baseResp.responseData).data;
dataMap.admin.hasWechatNum = 0;
for (PersonnelManageSunModel item in dataMap.admin.listdata) {
if (item.openid != null && item.openid != 'null' && item.openid != '') {
dataMap.admin.hasWechatNum++;
}
}
dataMap.cashier.hasWechatNum = 0;
for (PersonnelManageSunModel item in dataMap.cashier.listdata) {
if (item.openid != null && item.openid != 'null' && item.openid != '') {
dataMap.cashier.hasWechatNum++;
}
}
dataMap.manager.hasWechatNum = 0;
for (PersonnelManageSunModel item in dataMap.manager.listdata) {
if (item.openid != null && item.openid != 'null' && item.openid != '') {
dataMap.manager.hasWechatNum++;
}
}
dataMap.shopowner.hasWechatNum = 0;
for (PersonnelManageSunModel item in dataMap.shopowner.listdata) {
if (item.openid != null && item.openid != 'null' && item.openid != '') {
dataMap.shopowner.hasWechatNum++;
}
}
dataMap.waiter.hasWechatNum = 0;
for (PersonnelManageSunModel item in dataMap.waiter.listdata) {
if (item.openid != null && item.openid != 'null' && item.openid != '') {
dataMap.waiter.hasWechatNum++;
}
}
} else {
Utils.showToast(baseResp.msg ?? "");
}
... ...
... ... @@ -65,9 +65,9 @@ class NavigatorUtil {
// "${Routes.home}?initialIndex=$initialIndex&needRefresh=$needRefresh&mine=$mine&dateTime=&solt=$solt",
// clearStack: true);
// } else {
_navigateTo(context,
"${Routes.home}?initialIndex=$initialIndex&needRefresh=$needRefresh&mine=$mine&dateTime=$dateTime&solt=$solt",
clearStack: true);
_navigateTo(context,
"${Routes.home}?initialIndex=$initialIndex&needRefresh=$needRefresh&mine=$mine&dateTime=$dateTime&solt=$solt",
clearStack: true);
// }
}
... ... @@ -299,6 +299,18 @@ class NavigatorUtil {
}
}
/// 员工管理---个人资料页面
static Future<dynamic> goPersonnalBaseInfoPage(
BuildContext context,
PersonnelManageSunModel sunModel,
String position, {
replace = false,
}) {
return _navigateTo(context,
"${Routes.base_info_personnal_page}?sunModel=${FluroConvertUtils.object2string(sunModel)}&position=${Uri.encodeComponent(position)}",
replace: replace);
}
/// 绑定手机号吗页面
static Future<dynamic> goBindingPhonePage(BuildContext context,
{replace = false, bool wechat = true}) {
... ... @@ -520,9 +532,9 @@ class NavigatorUtil {
/// 员工管理页面
static Future<dynamic> goPersonnelDetailPage(BuildContext context,
{replace = false, PersonnelManageSunModel model, String position}) {
{replace = false, int index, String position}) {
return _navigateTo(context,
"${Routes.personnel_detail_page}?model=${FluroConvertUtils.object2string(model)}&position=${Uri.encodeComponent(position)}",
"${Routes.personnel_detail_page}?index=$index&position=${Uri.encodeComponent(position)}",
replace: replace);
}
... ...
... ... @@ -74,8 +74,10 @@ import 'package:one_key/pages/my/customer_type/store_customer/make_marking_page.
import 'package:one_key/pages/my/customer_type/store_customer/marketing_records_detail_page.dart';
import 'package:one_key/pages/my/customer_type/store_customer/marketing_records_page.dart';
import 'package:one_key/pages/my/customer_type/store_customer/store_customer_page.dart';
import 'package:one_key/pages/my/personnel_type/base_info_personnal_page.dart';
import 'package:one_key/pages/my/personnel_type/personnel_detail_page.dart';
import 'package:one_key/pages/my/personnel_type/personnel_manage_page.dart';
import 'package:one_key/pages/my/personnel_type/personnel_manage_page_old.dart';
import 'package:one_key/pages/my/personnel_type/personnel_password_edit_page.dart';
import 'package:one_key/pages/my/personnel_type/personnel_password_show_page.dart';
import 'package:one_key/pages/my/base_info.dart';
... ... @@ -521,6 +523,22 @@ var baseInfoPageHandler = new Handler(
)));
});
///员工管理----个人资料页面
var baseInfoPersonnalPageHandle = new Handler(
handlerFunc: (BuildContext context, Map<String, List<Object>> params) {
// CouponSunModel couponSunModel = CouponSunModel.fromJson(json.decode(
// FluroConvertUtils.fluroCnParamsDecode(params["couponSunModel"].first)));
String position = params["position"].first;
PersonnelManageSunModel sunModel = PersonnelManageSunModel.fromJson(json
.decode(FluroConvertUtils.fluroCnParamsDecode(params["sunModel"].first)));
return ChangeNotifierProvider<BaseIndoProvider>(
create: (_) => BaseIndoProvider(),
child: ChangeNotifierProvider<PersonnelProvider>(
create: (_) => PersonnelProvider(),
child:
BaseInfoPersonnalPage(sunModel: sunModel, position: position)));
});
///绑定手机号码页面
var bindingPhonePageHandler = new Handler(
handlerFunc: (BuildContext context, Map<String, List<Object>> params) {
... ... @@ -870,13 +888,12 @@ var personnelManagePageHandle = new Handler(
///店员详情页面
var personnelDetailPageHandle = new Handler(
handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) {
PersonnelManageSunModel data = PersonnelManageSunModel.fromJson(json
.decode(FluroConvertUtils.fluroCnParamsDecode(params["model"].first)));
int index = int.parse(params["index"].first);
String position = params["position"].first;
return ChangeNotifierProvider<PersonnelProvider>(
create: (_) => PersonnelProvider(),
child: PersonnelDetailPage(model: data, position: position));
child: PersonnelDetailPage(index: index, position: position));
});
///密码展示页面
... ...
... ... @@ -106,12 +106,11 @@ class Routes {
"/my_show_customer_list_page"; //仅展示的客户列表----我的
static String table_manager_page = "/table_manager_page"; //客情再次预订跳转的桌位预订页面
static String account_login_page = "/account_login_page"; //账号登录页面
static String my_table_manager_home_page = "/my_table_manager_home_page"; //我的---桌位管理
static String my_area_manage_page = "/my_area_manage_page"; //我的---区域管理
static String my_table_manager_home_page =
"/my_table_manager_home_page"; //我的---桌位管理
static String my_area_manage_page = "/my_area_manage_page"; //我的---区域管理
static String base_info_personnal_page =
"/base_info_personnal_page"; //员工管理---个人资料
static void configureRoutes(FluroRouter router) {
router.notFoundHandler = new Handler(
... ... @@ -220,10 +219,11 @@ class Routes {
router.define(my_show_customer_list_page,
handler: myShowCustomerListPageHandle);
router.define(table_manager_page, handler: tableManagerPageHandle);
router.define(account_login_page, handler: accountLoginPageHandle);
router.define(my_table_manager_home_page, handler: myTableManagerHomePageHandle);
router.define(my_area_manage_page, handler: myAreaManagePageHandle);
router.define(account_login_page, handler: accountLoginPageHandle);
router.define(my_table_manager_home_page,
handler: myTableManagerHomePageHandle);
router.define(my_area_manage_page, handler: myAreaManagePageHandle);
router.define(base_info_personnal_page, handler: baseInfoPersonnalPageHandle);
}
}
... ...
... ... @@ -9,6 +9,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_picker/flutter_picker.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/constant/constant.dart';
import 'package:one_key/models/filter_btn_model.dart';
import 'package:one_key/models/remark.dart';
import 'package:one_key/models/table_list.dart';
import 'package:one_key/pages/message/message_dialog_item.dart';
... ... @@ -49,6 +50,233 @@ typedef ClickCallback = void Function(String value);
// };
class DialogUtil {
static Future removePersonnalDialog(
BuildContext context, List<FilterBtnModel> managerList,
{CustomCallBackMap onTap}) async {
int currentIndex = 0;
// int currentIndex =
// managerList.indexWhere((element) => element == '包间') ?? 0;
String manager = managerList[currentIndex].title;
bool mulCreate = false;
// StateSetter globalState;
// //输入框焦点
// focusNode.addListener(() {
// if (!focusNode.hasFocus) {
// // print('失去焦点');
// } else {
// // print('得到焦点');
// globalState(() {
// showPnumMin = true;
// showPnumMax = true;
// showArea = true;
// });
// }
// });
final action = await showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return
// Scaffold(
// resizeToAvoidBottomInset: false,
// backgroundColor: Colors.transparent,
// body:
Center(child: StatefulBuilder(builder: (context, state) {
// globalState = state;
return Material(
color: Colors.transparent,
child: Stack(
clipBehavior: Clip.none,
children: [
Container(
margin:
EdgeInsets.only(bottom: ScreenUtil().setWidth(150)),
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(50)),
height: ScreenUtil().setWidth(238 * 2),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(16))),
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(
ScreenUtil().setWidth(16)))), //设置圆角
child: Column(
children: [
VEmptyView(64),
Container(
height: ScreenUtil().setWidth(48),
alignment: Alignment.center,
child: Text('移除员工',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: ScreenUtil().setSp(32),
color: Color.fromRGBO(0, 0, 0, 0.9))),
),
VEmptyView(40),
Text('移除员工并把该员工的客户',
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: Color.fromRGBO(0, 0, 0, 0.6))),
VEmptyView(36),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
HEmptyView(70),
Text('转移到',
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_515151)),
HEmptyView(32),
InkWell(
onTap: () {
List<String> list = [];
for (FilterBtnModel item
in managerList) {
list.add(item.title);
}
DialogUtil.showSelectCusmanDialog(
context, list, (value) async {
if (value != null) {
currentIndex = value.first;
manager = list[value.first];
state(() {});
// detailModel
// .notifyListeners();
// setState(() {
// selectPnum = value.first;
// pnum = pnumlist[value.first];
// });
// bool sucess =
// await detailModel.upReserveInfo(
// context, widget.rid,
// actualPum:
// detailModel.selectNum);
// if (sucess) {
// EventBus().emit(
// "refresh_tablemanager"); //刷新桌位
// await _getReserveDetail(
// showCicle: false);
// }
}
},
selecteds: currentIndex == null
? []
: [currentIndex])
.then((value) {});
},
child: Container(
padding: EdgeInsets.symmetric(
vertical: ScreenUtil().setWidth(16),
horizontal:
ScreenUtil().setWidth(24)),
width: ScreenUtil().setWidth(182 * 2),
height: ScreenUtil().setWidth(40 * 2),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(20)),
border: Border.all(
color: MyColours.color_438E93,
width:
ScreenUtil().setWidth(2))),
child: Row(
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
Expanded(
child: Text(
manager,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize:
ScreenUtil().setSp(28),
color:
MyColours.color_438E93),
)),
HEmptyView(14),
Image.asset(
Utils.getImgPath(
'c_arrow_down'),
width:
ScreenUtil().setWidth(40)),
],
),
)),
HEmptyView(70),
],
),
VEmptyView(40),
MyDivider(
double.infinity, ScreenUtil().setWidth(2),
color: MyColours.color_f3f3f3),
Row(
// mainAxisAlignment:
// MainAxisAlignment.spaceBetween,
children: [
RoundButton(
text: '取消',
width: (ScreenUtil.screenWidthDp -
ScreenUtil().setWidth(62) * 2) /
2,
height: ScreenUtil().setWidth(112),
// radius: ScreenUtil().setWidth(10),
gradientStart: Colors.transparent,
gradientEnd: Colors.transparent,
textColor: MyColours.color_000000,
isBold: false,
fontSize: 34,
onPressed: () {
Navigator.pop(context);
}),
MyDivider(ScreenUtil().setWidth(2),
ScreenUtil().setWidth(112),
color: MyColours.color_f3f3f3),
RoundButton(
text: '确定移除',
width: (ScreenUtil.screenWidthDp -
ScreenUtil().setWidth(62) * 2) /
2,
height: ScreenUtil().setWidth(112),
// radius: ScreenUtil().setWidth(10),
gradientStart: Colors.transparent,
gradientEnd: Colors.transparent,
textColor: MyColours.color_438E93,
fontSize: 34,
onPressed: () {
if (mulCreate) {
Utils.showToast('请输入数量!');
return;
}
// 当前选中区域
// areas[currentAreaIndex]
//最低人数
// pnumMin
//最高人数
// pnumMax
onTap({
'bjtype':
managerList[currentIndex].id,
});
Navigator.pop(context);
}),
])
],
),
)),
],
));
}));
});
}
///添加图片UI弹出
static openImageModalBottomSheet(context,
{VoidCallback lCallback, VoidCallback rCallback}) async {
... ... @@ -2974,7 +3202,9 @@ class DialogUtil {
isScrollControlled: true,
builder: (BuildContext dialogContext) {
Widget widget = Container(
color:messageModel.messages.length > 3 ? MyColours.color_24A4A8: MyColours.color_ffffff,
color: messageModel.messages.length > 3
? MyColours.color_24A4A8
: MyColours.color_ffffff,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
... ...
... ... @@ -29,7 +29,7 @@ class RoundButton extends StatelessWidget {
this.borderColor = Colors.transparent,
this.isBold = true,
this.padding = EdgeInsets.zero,
this.space = 6})
this.space = 6, int imageWidth})
: super(key: key);
final String image;
... ...