653 lines
29 KiB
Dart
653 lines
29 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/widgets.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:starwork_flutter/api/model/team/response/depart_list_reponse.dart';
|
|
import 'package:starwork_flutter/api/model/team/response/role_list_response.dart';
|
|
import 'package:starwork_flutter/common/constant/app_colors.dart';
|
|
import 'package:starwork_flutter/common/constant/app_view_parameter_keys.dart';
|
|
import 'package:starwork_flutter/common/widgets/custom_cell_list_widget.dart';
|
|
import 'package:starwork_flutter/common/widgets/custom_cell_widget.dart';
|
|
import 'package:starwork_flutter/common/widgets/custome_app_bar_wdiget.dart';
|
|
import 'package:starwork_flutter/extension/function_extension.dart';
|
|
import 'package:starwork_flutter/routes/app_routes.dart';
|
|
import 'edit_person_controller.dart';
|
|
|
|
class EditPersonView extends GetView<EditPersonController> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
// 即使不使用,只是引用一下 controller 就能触发初始化
|
|
final _ = controller; // 添加这一行
|
|
return Scaffold(
|
|
appBar: CustomAppBarWidget(
|
|
title: '编辑人员'.tr,
|
|
backgroundColor: AppColors.scaffoldBackgroundColor,
|
|
),
|
|
backgroundColor: AppColors.scaffoldBackgroundColor,
|
|
body: SafeArea(
|
|
child: SingleChildScrollView(
|
|
child: Padding(
|
|
padding: EdgeInsets.only(
|
|
left: 10.w,
|
|
right: 10.w,
|
|
bottom: 10.h,
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
'基本信息'.tr,
|
|
style: TextStyle(
|
|
fontSize: 12.sp,
|
|
color: Colors.black54,
|
|
fontWeight: FontWeight.w400,
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 6.h,
|
|
),
|
|
CustomCellListWidget(
|
|
children: [
|
|
CustomCellWidget(
|
|
onTap: () async {
|
|
final result = await Get.toNamed(AppRoutes.teamSelectOrganization);
|
|
if (result != null && result is DepartItem) {
|
|
controller.selectedDepartItem.value = result;
|
|
controller.selectedDepartItem.refresh();
|
|
}
|
|
},
|
|
leftText: '组织'.tr,
|
|
leftIcon: Icon(
|
|
Icons.circle,
|
|
size: 4.w,
|
|
color: Colors.red,
|
|
),
|
|
rightWidget: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Obx(
|
|
() => Text(
|
|
controller.selectedDepartItem.value.departName ?? '请选择',
|
|
style: TextStyle(
|
|
fontSize: 14.sp,
|
|
color: Colors.black54,
|
|
fontWeight: FontWeight.w400,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
width: 4.w,
|
|
),
|
|
Icon(
|
|
Icons.arrow_forward_ios_rounded,
|
|
size: 16.sp,
|
|
color: Colors.grey[300],
|
|
)
|
|
],
|
|
),
|
|
),
|
|
CustomCellWidget(
|
|
onTap: () {},
|
|
leftText: '姓名'.tr,
|
|
leftIcon: Icon(
|
|
Icons.circle,
|
|
size: 4.w,
|
|
color: Colors.red,
|
|
),
|
|
rightWidget: Expanded(
|
|
flex: 3,
|
|
child: TextField(
|
|
controller: controller.nameInputController,
|
|
keyboardType: TextInputType.text,
|
|
textInputAction: TextInputAction.next,
|
|
textAlign: TextAlign.end,
|
|
style: TextStyle(
|
|
fontSize: 14.sp,
|
|
),
|
|
decoration: InputDecoration(
|
|
isCollapsed: true,
|
|
hintText: '请输入姓名'.tr,
|
|
hintStyle: TextStyle(
|
|
fontSize: 14.sp,
|
|
color: Colors.black54,
|
|
fontWeight: FontWeight.w400,
|
|
),
|
|
// 设置无边框
|
|
border: InputBorder.none,
|
|
contentPadding: EdgeInsets.zero,
|
|
// 获取焦点时的边框
|
|
focusedBorder: InputBorder.none,
|
|
enabledBorder: InputBorder.none,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
CustomCellWidget(
|
|
onTap: () {},
|
|
leftText: '手机号'.tr,
|
|
rightWidget: controller.phoneInputController.text.isNotEmpty
|
|
? Row(
|
|
children: [
|
|
Text(
|
|
controller.getDisplayPhone(),
|
|
style: TextStyle(
|
|
fontSize: 14.sp,
|
|
color: Colors.black54,
|
|
fontWeight: FontWeight.w400,
|
|
),
|
|
),
|
|
SizedBox(
|
|
width: 10.w,
|
|
),
|
|
GestureDetector(
|
|
onTap: () {
|
|
controller.isPhoneVisible.value = !controller.isPhoneVisible.value;
|
|
},
|
|
child: Icon(
|
|
controller.isPhoneVisible.value ? Icons.visibility : Icons.visibility_off,
|
|
size: 16.sp,
|
|
color: Colors.grey,
|
|
),
|
|
),
|
|
],
|
|
)
|
|
: Expanded(
|
|
flex: 3,
|
|
child: TextField(
|
|
controller: controller.phoneInputController,
|
|
keyboardType: TextInputType.number,
|
|
textInputAction: TextInputAction.next,
|
|
textAlign: TextAlign.end,
|
|
style: TextStyle(
|
|
fontSize: 14.sp,
|
|
),
|
|
decoration: InputDecoration(
|
|
isCollapsed: true,
|
|
hintText: '请输入手机号'.tr,
|
|
hintStyle: TextStyle(
|
|
fontSize: 14.sp,
|
|
color: Colors.black54,
|
|
fontWeight: FontWeight.w400,
|
|
),
|
|
// 设置无边框
|
|
border: InputBorder.none,
|
|
contentPadding: EdgeInsets.zero,
|
|
// 获取焦点时的边框
|
|
focusedBorder: InputBorder.none,
|
|
enabledBorder: InputBorder.none,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
CustomCellWidget(
|
|
onTap: () {
|
|
Get.toNamed(AppRoutes.teamEditPersonInfo);
|
|
},
|
|
leftText: '用户账号'.tr,
|
|
rightWidget: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Obx(
|
|
() => Text(
|
|
controller.userState.value == 1
|
|
? '已开通'
|
|
: controller.userState.value == 2
|
|
? '未开通'
|
|
: '已停用',
|
|
style: TextStyle(
|
|
fontSize: 14.sp,
|
|
color: Colors.black54,
|
|
fontWeight: FontWeight.w400,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
width: 4.w,
|
|
),
|
|
Icon(
|
|
Icons.arrow_forward_ios_rounded,
|
|
size: 16.sp,
|
|
color: Colors.grey[300],
|
|
)
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
SizedBox(
|
|
height: 10.h,
|
|
),
|
|
Text(
|
|
'凭证信息'.tr,
|
|
style: TextStyle(
|
|
fontSize: 12.sp,
|
|
color: Colors.black54,
|
|
fontWeight: FontWeight.w400,
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 10.h,
|
|
),
|
|
SizedBox(
|
|
height: 68.w,
|
|
child: ListView(
|
|
scrollDirection: Axis.horizontal,
|
|
children: [
|
|
_buildHorizontalItem(title: '人脸', count: 0),
|
|
SizedBox(width: 5.w), // 添加间距
|
|
_buildHorizontalItem(title: '指纹', count: 0),
|
|
SizedBox(width: 5.w), // 添加间距
|
|
_buildHorizontalItem(title: '卡片', count: 0),
|
|
SizedBox(width: 5.w), // 添加间距
|
|
_buildHorizontalItem(title: '密码', count: 0),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 10.h,
|
|
),
|
|
Text(
|
|
'扩展信息'.tr,
|
|
style: TextStyle(
|
|
fontSize: 12.sp,
|
|
color: Colors.black54,
|
|
fontWeight: FontWeight.w400,
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 10.h,
|
|
),
|
|
CustomCellListWidget(
|
|
children: [
|
|
CustomCellWidget(
|
|
onTap: () {},
|
|
leftText: '工号'.tr,
|
|
rightWidget: Expanded(
|
|
flex: 3,
|
|
child: TextField(
|
|
controller: controller.jobNoInputController,
|
|
keyboardType: TextInputType.text,
|
|
textInputAction: TextInputAction.next,
|
|
textAlign: TextAlign.end,
|
|
style: TextStyle(
|
|
fontSize: 14.sp,
|
|
),
|
|
decoration: InputDecoration(
|
|
isCollapsed: true,
|
|
hintText: '选填'.tr,
|
|
hintStyle: TextStyle(
|
|
fontSize: 14.sp,
|
|
color: Colors.black54,
|
|
fontWeight: FontWeight.w400,
|
|
),
|
|
// 设置无边框
|
|
border: InputBorder.none,
|
|
contentPadding: EdgeInsets.zero,
|
|
// 获取焦点时的边框
|
|
focusedBorder: InputBorder.none,
|
|
enabledBorder: InputBorder.none,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
CustomCellWidget(
|
|
onTap: () {},
|
|
leftText: '性别'.tr,
|
|
rightWidget: Obx(
|
|
() => Row(
|
|
children: [
|
|
Radio<String>(
|
|
value: 'male',
|
|
activeColor: Colors.blue,
|
|
groupValue: controller.selectedGender.value,
|
|
visualDensity: VisualDensity.compact,
|
|
onChanged: (value) {
|
|
controller.selectedGender.value = value!;
|
|
},
|
|
),
|
|
Text('男'),
|
|
Radio<String>(
|
|
value: 'female',
|
|
activeColor: Colors.blue,
|
|
groupValue: controller.selectedGender.value,
|
|
visualDensity: VisualDensity.compact,
|
|
onChanged: (value) {
|
|
controller.selectedGender.value = value!;
|
|
},
|
|
),
|
|
Text('女'),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
CustomCellWidget(
|
|
onTap: () async {
|
|
var result = await Get.toNamed(AppRoutes.teamAddPersonEditValidity, arguments: {
|
|
AppViewParameterKeys.isLongTerm: controller.isLongTerm.value,
|
|
AppViewParameterKeys.startDate: controller.startDate.value,
|
|
AppViewParameterKeys.endDate: controller.endDate.value,
|
|
});
|
|
if (result != null) {
|
|
controller.isLongTerm.value = result[AppViewParameterKeys.isLongTerm];
|
|
if (controller.isLongTerm.isFalse) {
|
|
controller.startDate.value = result[AppViewParameterKeys.startDate];
|
|
controller.endDate.value = result[AppViewParameterKeys.endDate];
|
|
}
|
|
}
|
|
},
|
|
leftText: '有效期'.tr,
|
|
rightWidget: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Obx(
|
|
() => Text(
|
|
controller.isLongTerm.value
|
|
? '长期'.tr
|
|
: '${controller.formatTimestamp(controller.startDate.value)} - '
|
|
'${controller.formatTimestamp(controller.endDate.value)}',
|
|
style: TextStyle(
|
|
fontSize: 14.sp,
|
|
color: Colors.black54,
|
|
fontWeight: FontWeight.w400,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
width: 4.w,
|
|
),
|
|
Icon(
|
|
Icons.arrow_forward_ios_rounded,
|
|
size: 16.sp,
|
|
color: Colors.grey[300],
|
|
)
|
|
],
|
|
),
|
|
),
|
|
CustomCellWidget(
|
|
onTap: () {},
|
|
leftText: '职务'.tr,
|
|
rightWidget: Expanded(
|
|
flex: 3,
|
|
child: TextField(
|
|
controller: controller.positionInputController,
|
|
keyboardType: TextInputType.text,
|
|
textInputAction: TextInputAction.next,
|
|
textAlign: TextAlign.end,
|
|
style: TextStyle(
|
|
fontSize: 14.sp,
|
|
),
|
|
decoration: InputDecoration(
|
|
isCollapsed: true,
|
|
hintText: '选填'.tr,
|
|
hintStyle: TextStyle(
|
|
fontSize: 14.sp,
|
|
color: Colors.black54,
|
|
fontWeight: FontWeight.w400,
|
|
),
|
|
// 设置无边框
|
|
border: InputBorder.none,
|
|
contentPadding: EdgeInsets.zero,
|
|
// 获取焦点时的边框
|
|
focusedBorder: InputBorder.none,
|
|
enabledBorder: InputBorder.none,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
CustomCellWidget(
|
|
onTap: () {},
|
|
leftText: '备注'.tr,
|
|
rightWidget: Expanded(
|
|
flex: 3,
|
|
child: TextField(
|
|
controller: controller.remarkInputController,
|
|
keyboardType: TextInputType.text,
|
|
textInputAction: TextInputAction.next,
|
|
textAlign: TextAlign.end,
|
|
style: TextStyle(
|
|
fontSize: 14.sp,
|
|
),
|
|
decoration: InputDecoration(
|
|
isCollapsed: true,
|
|
hintText: '选填'.tr,
|
|
hintStyle: TextStyle(
|
|
fontSize: 14.sp,
|
|
color: Colors.black54,
|
|
fontWeight: FontWeight.w400,
|
|
),
|
|
// 设置无边框
|
|
border: InputBorder.none,
|
|
contentPadding: EdgeInsets.zero,
|
|
// 获取焦点时的边框
|
|
focusedBorder: InputBorder.none,
|
|
enabledBorder: InputBorder.none,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
CustomCellWidget(
|
|
onTap: () {},
|
|
leftText: '身份证号码'.tr,
|
|
rightWidget: Expanded(
|
|
flex: 3,
|
|
child: TextField(
|
|
controller: controller.idCardInputController,
|
|
keyboardType: TextInputType.text,
|
|
textInputAction: TextInputAction.next,
|
|
textAlign: TextAlign.end,
|
|
style: TextStyle(
|
|
fontSize: 14.sp,
|
|
),
|
|
decoration: InputDecoration(
|
|
isCollapsed: true,
|
|
hintText: '选填'.tr,
|
|
hintStyle: TextStyle(
|
|
fontSize: 14.sp,
|
|
color: Colors.black54,
|
|
fontWeight: FontWeight.w400,
|
|
),
|
|
// 设置无边框
|
|
border: InputBorder.none,
|
|
contentPadding: EdgeInsets.zero,
|
|
// 获取焦点时的边框
|
|
focusedBorder: InputBorder.none,
|
|
enabledBorder: InputBorder.none,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
CustomCellWidget(
|
|
onTap: () async {},
|
|
leftText: '关联用户'.tr,
|
|
rightWidget: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Text(
|
|
'关联用户',
|
|
style: TextStyle(
|
|
fontSize: 14.sp,
|
|
color: Colors.black54,
|
|
fontWeight: FontWeight.w400,
|
|
),
|
|
),
|
|
SizedBox(
|
|
width: 4.w,
|
|
),
|
|
Icon(
|
|
Icons.arrow_forward_ios_rounded,
|
|
size: 16.sp,
|
|
color: Colors.grey[300],
|
|
)
|
|
],
|
|
),
|
|
),
|
|
CustomCellWidget(
|
|
onTap: () async {},
|
|
leftText: '人员ID'.tr,
|
|
rightWidget: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Obx(
|
|
() => Text(
|
|
controller.selectedPersonItem.value?.personNo ?? '',
|
|
style: TextStyle(
|
|
fontSize: 14.sp,
|
|
color: Colors.black54,
|
|
fontWeight: FontWeight.w400,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
)
|
|
],
|
|
),
|
|
],
|
|
),
|
|
SizedBox(
|
|
height: 10.h,
|
|
),
|
|
Column(
|
|
children: [
|
|
SizedBox(
|
|
width: double.infinity,
|
|
child: Row(
|
|
children: [
|
|
Obx(
|
|
() => Visibility(
|
|
visible: controller.selectedPersonItem.value!.phone!.isEmpty,
|
|
child: Expanded(
|
|
child: ElevatedButton(
|
|
onPressed: () {}.debounce(),
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: Colors.grey[100],
|
|
padding: EdgeInsets.symmetric(vertical: 12.h),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(8.r),
|
|
),
|
|
),
|
|
child: Text(
|
|
'开通用户账号'.tr,
|
|
style: TextStyle(
|
|
fontSize: 16.sp,
|
|
color: Colors.blue,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
width: 10.w,
|
|
),
|
|
Expanded(
|
|
child: ElevatedButton(
|
|
onPressed: () {}.debounce(),
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: Colors.grey[100],
|
|
padding: EdgeInsets.symmetric(vertical: 12.h),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(8.r),
|
|
),
|
|
),
|
|
child: Text(
|
|
'删除'.tr,
|
|
style: TextStyle(
|
|
fontSize: 16.sp,
|
|
color: Colors.blue,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
width: 10.w,
|
|
),
|
|
Expanded(
|
|
child: ElevatedButton(
|
|
onPressed: () {
|
|
controller.requestEditPersonInfo();
|
|
}.debounce(),
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: Colors.blue,
|
|
padding: EdgeInsets.symmetric(vertical: 12.h),
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8.r)),
|
|
),
|
|
child: Text(
|
|
'保存'.tr,
|
|
style: TextStyle(
|
|
fontSize: 16.sp,
|
|
color: Colors.white,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
_buildHorizontalItem({
|
|
required String title,
|
|
required int count,
|
|
}) {
|
|
return Container(
|
|
width: 88.w,
|
|
height: 44.w,
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(8.r),
|
|
),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Text(
|
|
count.toString(),
|
|
style: TextStyle(
|
|
fontSize: 22.sp,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 2.h,
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Text(
|
|
title,
|
|
style: TextStyle(
|
|
fontSize: 12.sp,
|
|
color: Colors.black54,
|
|
fontWeight: FontWeight.w400,
|
|
),
|
|
),
|
|
Icon(
|
|
Icons.arrow_forward_ios_rounded,
|
|
size: 12.sp,
|
|
color: Colors.black54,
|
|
)
|
|
],
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|