|
|
|
|
|
|
|
import 'dart:async';
|
|
|
|
import 'dart:convert';
|
|
|
|
|
|
...
|
...
|
@@ -7,9 +6,11 @@ import 'package:common_utils/common_utils.dart'; |
|
|
|
import 'package:dio/dio.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:one_key/app.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/models/user.dart';
|
|
|
|
import 'package:one_key/net/dio_util.dart';
|
|
|
|
import 'package:one_key/provider/personnel_provider.dart';
|
|
|
|
import 'package:one_key/provider/store_wine_provider.dart';
|
|
...
|
...
|
@@ -57,13 +58,19 @@ class _PersonnelDetailPageState extends State<PersonnelDetailPage> { |
|
|
|
bool isall = false;
|
|
|
|
bool isbook = false;
|
|
|
|
bool isserver = false;
|
|
|
|
|
|
|
|
String? position = '';
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
position = widget.position;
|
|
|
|
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
|
|
|
_getSellerUserBySellerid();
|
|
|
|
_getAuthUserLists();
|
|
|
|
|
|
|
|
_getSellerRoleList();
|
|
|
|
EventBus().on('personnel_manage_detail_page', (arg) {
|
|
|
|
_getAuthUserLists(showLoading: false);
|
|
|
|
});
|
|
...
|
...
|
@@ -74,9 +81,9 @@ class _PersonnelDetailPageState extends State<PersonnelDetailPage> { |
|
|
|
// if (roleNameLogin == '管理员') {
|
|
|
|
// canEdit = true;
|
|
|
|
// } else if (roleNameLogin == '店长') {
|
|
|
|
// if (widget.position == '管理员') {
|
|
|
|
// if (position == '管理员') {
|
|
|
|
// canEdit = false;
|
|
|
|
// } else if (widget.position == '店长') {
|
|
|
|
// } else if (position == '店长') {
|
|
|
|
// if (accountLogin == data.account) {
|
|
|
|
// print('11111');
|
|
|
|
// //店长自己
|
|
...
|
...
|
@@ -144,6 +151,16 @@ class _PersonnelDetailPageState extends State<PersonnelDetailPage> { |
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
_getSellerRoleList({bool showLoading = true}) async {
|
|
|
|
Map<String, String?> params = {
|
|
|
|
"sellerid": Provider.of<UserModel>(context, listen: false).user!.sellerid,
|
|
|
|
"sid": Provider.of<UserModel>(context, listen: false).user!.sellerid,
|
|
|
|
};
|
|
|
|
|
|
|
|
await personnelProvider.getSellerRoleList(context, params,
|
|
|
|
showLoading: showLoading);
|
|
|
|
}
|
|
|
|
|
|
|
|
//获取员工信息列表
|
|
|
|
_getAuthUserLists({bool showLoading = true}) async {
|
|
|
|
Map<String, String?> params = {
|
|
...
|
...
|
@@ -153,19 +170,19 @@ class _PersonnelDetailPageState extends State<PersonnelDetailPage> { |
|
|
|
await personnelProvider.getAuthUserLists(context, params,
|
|
|
|
showLoading: showLoading);
|
|
|
|
if (personnelProvider.dataMap != null) {
|
|
|
|
if (widget.position == '管理员') {
|
|
|
|
if (position == '管理员') {
|
|
|
|
data = personnelProvider.dataMap!.admin!.listdata![widget.index!];
|
|
|
|
} else if (widget.position == '店长') {
|
|
|
|
} else if (position == '店长') {
|
|
|
|
data = personnelProvider.dataMap!.shopowner!.listdata![widget.index!];
|
|
|
|
} else if (widget.position == '客户经理') {
|
|
|
|
} else if (position == '客户经理') {
|
|
|
|
data = personnelProvider.dataMap!.manager!.listdata![widget.index!];
|
|
|
|
} else if (widget.position == '收银员') {
|
|
|
|
} else if (position == '收银员') {
|
|
|
|
data = personnelProvider.dataMap!.cashier!.listdata![widget.index!];
|
|
|
|
} else if (widget.position == '服务员') {
|
|
|
|
} else if (position == '服务员') {
|
|
|
|
data = personnelProvider.dataMap!.waiter!.listdata![widget.index!];
|
|
|
|
} else if (widget.position == '前台') {
|
|
|
|
} else if (position == '前台') {
|
|
|
|
data = personnelProvider.dataMap!.reception!.listdata![widget.index!];
|
|
|
|
} else if (widget.position == '迎宾') {
|
|
|
|
} else if (position == '迎宾') {
|
|
|
|
data = personnelProvider.dataMap!.welcome!.listdata![widget.index!];
|
|
|
|
}
|
|
|
|
if (data!.accountType == null || data!.accountType == '1') {
|
|
...
|
...
|
@@ -178,8 +195,9 @@ class _PersonnelDetailPageState extends State<PersonnelDetailPage> { |
|
|
|
nickName = data!.nickName != null && data!.nickName != 'null'
|
|
|
|
? data!.nickName
|
|
|
|
: '暂未设置名称';
|
|
|
|
phone =
|
|
|
|
data!.phone != null && data!.userName != 'null' ? data!.phone : '添加手机号';
|
|
|
|
phone = data!.phone != null && data!.userName != 'null'
|
|
|
|
? data!.phone
|
|
|
|
: '添加手机号';
|
|
|
|
if (data!.openid == null || data!.openid == 'null') {
|
|
|
|
// _getStoreBaseinfo();
|
|
|
|
_getWechatQrcode();
|
|
...
|
...
|
@@ -222,23 +240,40 @@ class _PersonnelDetailPageState extends State<PersonnelDetailPage> { |
|
|
|
if (success) {
|
|
|
|
//删除员工成功
|
|
|
|
EventBus().emit('personnel_manage_page');
|
|
|
|
if (Navigator.canPop(context)) {
|
|
|
|
Navigator.pop(context);
|
|
|
|
}
|
|
|
|
if (Navigator.canPop(context)) {
|
|
|
|
Navigator.pop(context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///编辑店员
|
|
|
|
_editAuthUser(String name, {bool showLoading = true}) async {
|
|
|
|
Map<String, String?> params = {'id': data!.id, 'user_name': name};
|
|
|
|
_editAuthUser(String roleId, {bool showLoading = true}) async {
|
|
|
|
Map<String, String?> params = {'id': data!.id, 'role_id': roleId};
|
|
|
|
|
|
|
|
bool success = await personnelProvider.editAuthUser(context, params,
|
|
|
|
showLoading: showLoading);
|
|
|
|
if (success) {
|
|
|
|
EventBus().emit('personnel_manage_page');
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
nickName = name;
|
|
|
|
int index = personnelProvider.roleList!
|
|
|
|
.indexWhere((element) => element.id == roleId);
|
|
|
|
position = personnelProvider.roleList![index].roleName;
|
|
|
|
//当前页面的角色展示刷新,我的页面取值从缓存,刷新缓存
|
|
|
|
});
|
|
|
|
|
|
|
|
UserModel userModel = Provider.of<UserModel>(context, listen: false);
|
|
|
|
if (data?.id == userModel.user!.openid) {
|
|
|
|
//如果修改的是本人的话,需要刷新缓存,我的页面会显示缓存的数据
|
|
|
|
if (App.sp!.containsKey('user')) {
|
|
|
|
String s = App.sp!.getString('user')!;
|
|
|
|
User _user = User.fromJson(json.decode(s));
|
|
|
|
|
|
|
|
_user.role_name_addition = position;
|
|
|
|
|
|
|
|
await UserModel().saveUserInfo(_user);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -399,12 +434,15 @@ class _PersonnelDetailPageState extends State<PersonnelDetailPage> { |
|
|
|
'uid': data!.id,
|
|
|
|
'account_type': accountType
|
|
|
|
};
|
|
|
|
bool success = await personnelProvider.setSellerUserAccountType(context, params);
|
|
|
|
if(success && accountType == '3' && data!.id == Provider.of<UserModel>(context,listen: false).user!.openid){
|
|
|
|
//把自己设置成只服不订人员,需要跳转到已预订页面
|
|
|
|
NavigatorUtil.goHomePage(context,initialIndex: 1);
|
|
|
|
|
|
|
|
}
|
|
|
|
bool success =
|
|
|
|
await personnelProvider.setSellerUserAccountType(context, params);
|
|
|
|
if (success &&
|
|
|
|
accountType == '3' &&
|
|
|
|
data!.id ==
|
|
|
|
Provider.of<UserModel>(context, listen: false).user!.openid) {
|
|
|
|
//把自己设置成只服不订人员,需要跳转到已预订页面
|
|
|
|
NavigatorUtil.goHomePage(context, initialIndex: 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
...
|
...
|
@@ -421,8 +459,8 @@ class _PersonnelDetailPageState extends State<PersonnelDetailPage> { |
|
|
|
appBar: SystemAppBar(
|
|
|
|
'员工详情',
|
|
|
|
onTap: () {
|
|
|
|
if (Navigator.canPop(context)) {
|
|
|
|
Navigator.pop(context);
|
|
|
|
if (Navigator.canPop(context)) {
|
|
|
|
Navigator.pop(context);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
|
...
|
...
|
@@ -474,7 +512,7 @@ class _PersonnelDetailPageState extends State<PersonnelDetailPage> { |
|
|
|
radius: ScreenUtil().setWidth(26 * 2),
|
|
|
|
onPressed: () {
|
|
|
|
NavigatorUtil.goPersonnalBaseInfoPage(
|
|
|
|
context, data, widget.position!);
|
|
|
|
context, data, position!);
|
|
|
|
}),
|
|
|
|
),
|
|
|
|
Column(
|
|
...
|
...
|
@@ -517,7 +555,7 @@ class _PersonnelDetailPageState extends State<PersonnelDetailPage> { |
|
|
|
textColor: MyColours.color_ffffff,
|
|
|
|
radius: ScreenUtil().setWidth(10),
|
|
|
|
onPressed: () {}),
|
|
|
|
Text('${widget.position} 工号: ${data?.account}',
|
|
|
|
Text('${position} 工号: ${data?.account}',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_515151,
|
|
|
|
fontSize: ScreenUtil().setSp(28),
|
|
...
|
...
|
@@ -563,82 +601,84 @@ class _PersonnelDetailPageState extends State<PersonnelDetailPage> { |
|
|
|
],
|
|
|
|
),
|
|
|
|
VEmptyView(56),
|
|
|
|
if(widget.position != '管理员') Container(
|
|
|
|
height: w(84),
|
|
|
|
padding:
|
|
|
|
EdgeInsets.symmetric(horizontal: w(20), vertical: w(12)),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
'预订与服务权限',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: font(16), color: MyColours.color_515151),
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
Container(
|
|
|
|
height: w(24),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
HEmptyView(32),
|
|
|
|
_itemRadioWidget(isall, '预订及服务', onTap: () {
|
|
|
|
if (Utils.getAuthority(context, '设置服务人员')) {
|
|
|
|
if (!isall) {
|
|
|
|
setState(() {
|
|
|
|
isall = true;
|
|
|
|
|
|
|
|
isbook = false;
|
|
|
|
isserver = false;
|
|
|
|
});
|
|
|
|
_setSellerUserAccountType('1');
|
|
|
|
if (position != '管理员')
|
|
|
|
Container(
|
|
|
|
height: w(84),
|
|
|
|
padding:
|
|
|
|
EdgeInsets.symmetric(horizontal: w(20), vertical: w(12)),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
'预订与服务权限',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: font(16), color: MyColours.color_515151),
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
Container(
|
|
|
|
height: w(24),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
HEmptyView(32),
|
|
|
|
_itemRadioWidget(isall, '预订及服务', onTap: () {
|
|
|
|
if (Utils.getAuthority(context, '设置服务人员')) {
|
|
|
|
if (!isall) {
|
|
|
|
setState(() {
|
|
|
|
isall = true;
|
|
|
|
|
|
|
|
isbook = false;
|
|
|
|
isserver = false;
|
|
|
|
});
|
|
|
|
_setSellerUserAccountType('1');
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Utils.showToast('您没有相关权限权限');
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Utils.showToast('您没有相关权限权限');
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
Spacer(),
|
|
|
|
_itemRadioWidget(isbook, '只订不服', onTap: () {
|
|
|
|
if (Utils.getAuthority(context, '设置服务人员')) {
|
|
|
|
if (!isbook) {
|
|
|
|
setState(() {
|
|
|
|
isbook = true;
|
|
|
|
|
|
|
|
isall = false;
|
|
|
|
isserver = false;
|
|
|
|
});
|
|
|
|
_setSellerUserAccountType('2');
|
|
|
|
}),
|
|
|
|
Spacer(),
|
|
|
|
_itemRadioWidget(isbook, '只订不服', onTap: () {
|
|
|
|
if (Utils.getAuthority(context, '设置服务人员')) {
|
|
|
|
if (!isbook) {
|
|
|
|
setState(() {
|
|
|
|
isbook = true;
|
|
|
|
|
|
|
|
isall = false;
|
|
|
|
isserver = false;
|
|
|
|
});
|
|
|
|
_setSellerUserAccountType('2');
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Utils.showToast('您没有相关权限权限');
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Utils.showToast('您没有相关权限权限');
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
Spacer(),
|
|
|
|
_itemRadioWidget(isserver, '只服不订', onTap: () {
|
|
|
|
if (Utils.getAuthority(context, '设置服务人员')) {
|
|
|
|
if (!isserver) {
|
|
|
|
setState(() {
|
|
|
|
isserver = true;
|
|
|
|
isall = false;
|
|
|
|
isbook = false;
|
|
|
|
});
|
|
|
|
_setSellerUserAccountType('3');
|
|
|
|
}),
|
|
|
|
Spacer(),
|
|
|
|
_itemRadioWidget(isserver, '只服不订', onTap: () {
|
|
|
|
if (Utils.getAuthority(context, '设置服务人员')) {
|
|
|
|
if (!isserver) {
|
|
|
|
setState(() {
|
|
|
|
isserver = true;
|
|
|
|
isall = false;
|
|
|
|
isbook = false;
|
|
|
|
});
|
|
|
|
_setSellerUserAccountType('3');
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Utils.showToast('您没有相关权限权限');
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Utils.showToast('您没有相关权限权限');
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
HEmptyView(30),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
HEmptyView(30),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
if(widget.position != '管理员') Padding(
|
|
|
|
padding: EdgeInsets.only(left: w(20), right: w(16)),
|
|
|
|
child: MyDivider(double.infinity, w(1),
|
|
|
|
color: MyColours.color_DBDBDB)),
|
|
|
|
if (position != '管理员')
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.only(left: w(20), right: w(16)),
|
|
|
|
child: MyDivider(double.infinity, w(1),
|
|
|
|
color: MyColours.color_DBDBDB)),
|
|
|
|
VEmptyView(32),
|
|
|
|
|
|
|
|
(data?.openid == null || data?.openid == 'null')
|
|
...
|
...
|
@@ -694,6 +734,32 @@ class _PersonnelDetailPageState extends State<PersonnelDetailPage> { |
|
|
|
color: MyColours.color_438E93,
|
|
|
|
fontSize: ScreenUtil().setSp(28)),
|
|
|
|
)),
|
|
|
|
if (Utils.getAuthority(context, '修改职级')) VEmptyView(48),
|
|
|
|
if (Utils.getAuthority(context, '修改职级'))
|
|
|
|
InkWell(
|
|
|
|
onTap: () async {
|
|
|
|
if (personnelProvider.roleList == null ||
|
|
|
|
personnelProvider.roleList?.length == 0) {
|
|
|
|
//没有角色数据
|
|
|
|
await _getSellerRoleList();
|
|
|
|
}
|
|
|
|
await DialogUtil.changeRoleDialog(
|
|
|
|
context, personnelProvider.roleList, position ?? '',
|
|
|
|
onTap: (map) {
|
|
|
|
print(map);
|
|
|
|
String? roleId = map['role'];
|
|
|
|
if (roleId != null) {
|
|
|
|
_editAuthUser(roleId);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
child: Text(
|
|
|
|
'修改职级',
|
|
|
|
style: TextStyle(
|
|
|
|
decoration: TextDecoration.underline,
|
|
|
|
color: MyColours.color_438E93,
|
|
|
|
fontSize: ScreenUtil().setSp(28)),
|
|
|
|
)),
|
|
|
|
VEmptyView(40),
|
|
|
|
|
|
|
|
// (userModel.user.role_name == '管理员' ||
|
|
...
|
...
|
@@ -844,7 +910,7 @@ class _PersonnelDetailPageState extends State<PersonnelDetailPage> { |
|
|
|
// ),
|
|
|
|
// HEmptyView(20),
|
|
|
|
// Text(
|
|
|
|
// widget.position,
|
|
|
|
// position,
|
|
|
|
// style: TextStyle(
|
|
|
|
// fontSize: ScreenUtil().setWidth(28),
|
|
|
|
// color: MyColours.color_199095),
|
|
...
|
...
|
@@ -868,7 +934,7 @@ class _PersonnelDetailPageState extends State<PersonnelDetailPage> { |
|
|
|
],
|
|
|
|
),
|
|
|
|
)),
|
|
|
|
if (widget.position != '管理员')
|
|
|
|
if (position != '管理员')
|
|
|
|
InkWell(
|
|
|
|
onTap: () async {
|
|
|
|
await DialogUtil.removePersonnalDialog(
|
...
|
...
|
|