222 lines
8.4 KiB
Dart
Raw Permalink Normal View History

2023-07-11 18:37:25 +08:00
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
2023-07-11 18:37:25 +08:00
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/app_settings/app_colors.dart';
import 'package:star_lock/app_settings/app_settings.dart';
import 'package:star_lock/main/lockDetail/checkingIn/checkingInSet/checkingInSet_state.dart';
2023-07-11 18:37:25 +08:00
import '../../../../appRouters.dart';
import '../../../../tools/commonItem.dart';
import '../../../../tools/showTFView.dart';
import '../../../../tools/showTipView.dart';
2023-07-11 18:37:25 +08:00
import '../../../../tools/submitBtn.dart';
import '../../../../tools/titleAppBar.dart';
import 'checkingInSet_logic.dart';
2023-07-11 18:37:25 +08:00
class CheckingInSetPage extends StatefulWidget {
2023-07-15 15:11:28 +08:00
const CheckingInSetPage({Key? key}) : super(key: key);
2023-07-11 18:37:25 +08:00
@override
State<CheckingInSetPage> createState() => _CheckingInSetPageState();
}
class _CheckingInSetPageState extends State<CheckingInSetPage> {
final CheckingInSetLogic logic = Get.put(CheckingInSetLogic());
final CheckingInSetState state = Get.find<CheckingInSetLogic>().state;
2023-07-11 18:37:25 +08:00
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar(
barTitle: '考勤设置'.tr,
haveBack: true,
backgroundColor: AppColors.mainColor),
2023-07-11 18:37:25 +08:00
body: Column(
children: <Widget>[
Obx(() => CommonItem(
2024-11-06 09:28:18 +08:00
leftTitel: '公司名称'.tr,
rightTitle: state.companyName.value ?? '',
// isHaveRightWidget: true,
// rightWidget: getTFWidget(),
isHaveLine: true,
isHaveDirection: true,
action: () {
showCupertinoAlertDialog(context);
})),
Obx(() => CommonItem(
2024-07-29 19:30:29 +08:00
leftTitel: '员工'.tr,
rightTitle: state.staffNumber.value,
isHaveLine: true,
isHaveDirection: true,
action: () {
2024-11-06 09:28:18 +08:00
Get.toNamed(Routers.checkingInStaffManagePage,
arguments: <String, Object>{
'getKeyInfosData': state.getKeyInfosData.value,
'companyId': state.companyId.value
});
})),
Obx(() => CommonItem(
2024-07-26 14:12:26 +08:00
leftTitel: '工作时间'.tr,
2024-11-06 09:28:18 +08:00
rightTitle: (state.beginTime.value.isNotEmpty)
? '${state.beginTime.value} - ${state.endTime.value}'
: '',
isHaveLine: true,
isHaveDirection: true,
action: () async {
2024-11-06 09:28:18 +08:00
var data = await Get.toNamed(Routers.checkingInSetWorkTimePage,
arguments: <String, Object>{
// "getKeyInfosData": state.getKeyInfosData.value,
'companyId': state.companyId.value,
'pushType': '2',
'checkingInSetInfo': state.checkingInSetInfo.value,
});
if (data != null) {
setState(logic.getCheckInSetInfoData);
}
})),
Obx(() => CommonItem(
2024-07-29 19:30:29 +08:00
leftTitel: '工作日设置'.tr,
2024-11-06 09:28:18 +08:00
rightTitle: state.isCustom.value == true
? state.weekDaysStr.value
: (state.weekDays.value.length == 6 ? '单休'.tr : '双休'.tr),
isHaveLine: true,
isHaveDirection: true,
action: () async {
2024-11-06 09:28:18 +08:00
var data = await Get.toNamed(Routers.checkingInSetWorkdaySet,
arguments: <String, Object>{
'getKeyInfosData': state.getKeyInfosData.value,
'companyId': state.companyId.value,
'pushType': '2',
'checkingInSetInfo': state.checkingInSetInfo.value,
});
if (data != null) {
state.isCustom.value = data['attendanceType'];
state.weekDays.value = data['weekDays'];
state.weekDaysStr.value = state.weekDays.join(',');
2024-11-06 09:28:18 +08:00
AppLog.log(
'state.weekDays.value:${state.weekDays.value} state.weekDaysStr.value:${state.weekDaysStr.value}');
setState(() {});
}
})),
CommonItem(
2024-07-29 19:30:29 +08:00
leftTitel: '节假日'.tr,
rightTitle: '',
isHaveLine: false,
isHaveDirection: true,
action: () {
2024-11-06 09:28:18 +08:00
Get.toNamed(Routers.checkingInSetHolidaysPage,
arguments: <String, String>{
'companyId': state.companyId.value
});
}),
SizedBox(
height: 30.h,
),
Visibility(
visible: state.getKeyInfosData.value.isLockOwner == 1,
child: SubmitBtn(
2024-07-26 09:21:22 +08:00
btnName: '删除公司'.tr,
borderRadius: 20.w,
fontSize: 32.sp,
isDelete: true,
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 20.w),
padding: EdgeInsets.only(top: 20.w, bottom: 20.w),
onClick: () {
2024-11-06 09:28:18 +08:00
ShowTipView().showIosTipWithContentDialog(
'是否删除?'.tr, logic.deletCompanyData);
// showDeletCompanyAlertDialog(context);
}),
),
2023-07-11 18:37:25 +08:00
],
),
);
}
void showCupertinoAlertDialog(BuildContext context) {
showDialog(
context: context,
builder: (BuildContext context) {
return ShowTFView(
2024-08-27 11:08:44 +08:00
title: '修改名字'.tr,
tipTitle: '',
controller: state.changeNameController,
inputFormatters: <TextInputFormatter>[
2024-11-06 09:28:18 +08:00
LengthLimitingTextInputFormatter(30),
],
sureClick: () {
2024-11-06 09:28:18 +08:00
if (state.changeNameController.text.isEmpty) {
logic.showToast('请输入公司名字'.tr);
return;
}
2024-11-06 09:28:18 +08:00
if (state.changeNameController.text.length < 6) {
logic.showToast('公司名字长度不能小于 6 '.tr);
return;
}
Get.back();
logic.editCheckInSetInfoData();
},
cancelClick: () {
Get.back();
2024-11-06 09:28:18 +08:00
},
);
2023-07-11 18:37:25 +08:00
});
}
// 接受者信息输入框
Widget getTFWidget() {
state.nameController.text = state.companyName.value ?? '';
return Container(
// color: Colors.red,
height: 65.h,
width: 300.w,
padding: EdgeInsets.only(top: 5.h),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Expanded(
child: TextField(
//输入框一行
maxLines: 1,
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.deny('\n'),
LengthLimitingTextInputFormatter(30),
],
2024-11-06 09:28:18 +08:00
style: TextStyle(
fontSize: 22.sp, color: AppColors.darkGrayTextColor),
controller: state.nameController,
autofocus: false,
enabled: false,
textAlign: TextAlign.end,
decoration: InputDecoration(
//输入里面输入文字内边距设置
// contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0),
// hintText: state.companyName.value ?? "",
hintStyle: TextStyle(fontSize: 22.sp),
2024-11-06 09:28:18 +08:00
focusedBorder: const OutlineInputBorder(
borderSide:
BorderSide(width: 0, color: Colors.transparent)),
disabledBorder: const OutlineInputBorder(
borderSide:
BorderSide(width: 0, color: Colors.transparent)),
enabledBorder: const OutlineInputBorder(
borderSide:
BorderSide(width: 0, color: Colors.transparent)),
border: const OutlineInputBorder(
borderSide:
BorderSide(width: 0, color: Colors.transparent)),
contentPadding: const EdgeInsets.symmetric(vertical: 0),
),
),
),
SizedBox(
width: 10.w,
),
],
),
);
}
2023-07-11 18:37:25 +08:00
}