|
|
|
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);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
//获取员工信息列表
|
|
|
|
_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);
|
|
|
|
}
|
|
|
|
|
|
|
|
@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 = [];
|
|
|
|
if (personnelProvider.dataMap != null) {
|
|
|
|
if (title == '管理员') {
|
|
|
|
data = personnelProvider.dataMap.admin.listdata;
|
|
|
|
} else if (title == '店长') {
|
|
|
|
data = personnelProvider.dataMap.shopowner.listdata;
|
|
|
|
} else if (title == '客户经理') {
|
|
|
|
data = personnelProvider.dataMap.manager.listdata;
|
|
|
|
} else if (title == '收银员') {
|
|
|
|
data = personnelProvider.dataMap.cashier.listdata;
|
|
|
|
} else if (title == '服务员') {
|
|
|
|
data = personnelProvider.dataMap.waiter.listdata;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Column(
|
|
|
|
children: [
|
|
|
|
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),
|
|
|
|
),
|
|
|
|
InkWell(
|
|
|
|
onTap: () {},
|
|
|
|
child: Text(
|
|
|
|
'添加',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: ScreenUtil().setWidth(30),
|
|
|
|
color: MyColours.color_199095),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
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.userName != null &&
|
|
|
|
model.userName != 'null'
|
|
|
|
? model.userName
|
|
|
|
: '暂未设置名称',
|
|
|
|
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,
|
|
|
|
)
|
|
|
|
]),
|
|
|
|
Provider.of<UserModel>(context, listen: false)
|
|
|
|
.user
|
|
|
|
.account ==
|
|
|
|
model.account
|
|
|
|
? 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),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
})));
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|