|
|
|
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/get_seller_info_model.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/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';
|
|
...
|
...
|
@@ -22,20 +26,197 @@ class PersonnelDetailPage extends StatefulWidget { |
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
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 == '绑定微信') {
|
|
|
|
DialogUtil.openAlertDialogImage(
|
|
|
|
context, '请员工使用微信扫一扫添加店员', dcAdduserCode, 660);
|
|
|
|
} else if (element == '查看密码') {}
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
@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('店员详情'),
|
|
|
|
appBar: SystemAppBar(
|
|
|
|
'店员详情',
|
|
|
|
onTap: () {
|
|
|
|
Navigator.pop(context);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
body: SingleChildScrollView(
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
margin: EdgeInsets.all(ScreenUtil().setWidth(40)),
|
|
|
|
// decoration: BoxDecoration(
|
|
|
|
// border: Border.all(color: Color.fromRGBO(235, 234, 239, 1)),
|
|
|
|
// borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10)),
|
|
|
|
// ),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
...
|
...
|
@@ -54,37 +235,75 @@ class _PersonnelDetailPageState extends State<PersonnelDetailPage> { |
|
|
|
width: ScreenUtil().setWidth(38 * 2),
|
|
|
|
height: ScreenUtil().setWidth(38 * 2),
|
|
|
|
),
|
|
|
|
VEmptyView(30),
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
widget.model.userName != null &&
|
|
|
|
widget.model.userName != 'null'
|
|
|
|
? widget.model.userName
|
|
|
|
: '暂未设置名称',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: ScreenUtil().setWidth(34),
|
|
|
|
color: MyColours.color_333333),
|
|
|
|
),
|
|
|
|
HEmptyView(20),
|
|
|
|
Image.asset(
|
|
|
|
Utils.getImgPath('yd_bianji'),
|
|
|
|
width: ScreenUtil().setWidth(20),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
VEmptyView(30),
|
|
|
|
Text(
|
|
|
|
widget.model.phone != null &&
|
|
|
|
widget.model.userName != 'null'
|
|
|
|
? widget.model.phone
|
|
|
|
: '',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: ScreenUtil().setWidth(28),
|
|
|
|
color: MyColours.color_199095),
|
|
|
|
),
|
|
|
|
VEmptyView(30),
|
|
|
|
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: [
|
|
...
|
...
|
@@ -111,66 +330,10 @@ class _PersonnelDetailPageState extends State<PersonnelDetailPage> { |
|
|
|
// color: Color.fromRGBO(235, 234, 239, 1),
|
|
|
|
// ),
|
|
|
|
VEmptyView(60),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
vertical: ScreenUtil().setWidth(20)),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
|
|
children: [
|
|
|
|
RoundButton(
|
|
|
|
text: '移除店员',
|
|
|
|
fontSize: 30,
|
|
|
|
isBold: false,
|
|
|
|
height: ScreenUtil().setWidth(80),
|
|
|
|
// width: double.infinity,
|
|
|
|
width: (ScreenUtil.screenWidthDp -
|
|
|
|
ScreenUtil().setWidth(140)) /
|
|
|
|
2,
|
|
|
|
radius: ScreenUtil().setWidth(10),
|
|
|
|
),
|
|
|
|
RoundButton(
|
|
|
|
text: '查看初始密码',
|
|
|
|
fontSize: 30,
|
|
|
|
isBold: false,
|
|
|
|
height: ScreenUtil().setWidth(80),
|
|
|
|
// width: double.infinity,
|
|
|
|
width: (ScreenUtil.screenWidthDp -
|
|
|
|
ScreenUtil().setWidth(140)) /
|
|
|
|
2,
|
|
|
|
radius: ScreenUtil().setWidth(10),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.only(bottom: ScreenUtil().setWidth(60)),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
|
|
children: [
|
|
|
|
RoundButton(
|
|
|
|
text: '设为接单人',
|
|
|
|
fontSize: 30,
|
|
|
|
isBold: false,
|
|
|
|
height: ScreenUtil().setWidth(80),
|
|
|
|
// width: double.infinity,
|
|
|
|
width: (ScreenUtil.screenWidthDp -
|
|
|
|
ScreenUtil().setWidth(140)) /
|
|
|
|
2,
|
|
|
|
radius: ScreenUtil().setWidth(10),
|
|
|
|
),
|
|
|
|
RoundButton(
|
|
|
|
text: '绑定微信',
|
|
|
|
fontSize: 30,
|
|
|
|
isBold: false,
|
|
|
|
height: ScreenUtil().setWidth(80),
|
|
|
|
// width: double.infinity,
|
|
|
|
width: (ScreenUtil.screenWidthDp -
|
|
|
|
ScreenUtil().setWidth(140)) /
|
|
|
|
2,
|
|
|
|
radius: ScreenUtil().setWidth(10),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Wrap(
|
|
|
|
spacing: ScreenUtil().setWidth(20), //主轴上子控件的间距
|
|
|
|
runSpacing: ScreenUtil().setWidth(20), //交叉轴上子控件之间的间距
|
|
|
|
children: _listWidget(btnList), //要显示的子控件集合
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
...
|
...
|
|