QinGang_interested/lib/pages/home/unit/unit_quit_apply_page.dart

97 lines
3.0 KiB
Dart
Raw Normal View History

2025-12-24 16:07:53 +08:00
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:qhd_prevention/customWidget/custom_button.dart';
import 'package:qhd_prevention/customWidget/item_list_widget.dart';
import 'package:qhd_prevention/customWidget/toast_util.dart';
import 'package:qhd_prevention/http/ApiService.dart';
import 'package:qhd_prevention/pages/my_appbar.dart';
import 'package:qhd_prevention/services/SessionService.dart';
import 'package:qhd_prevention/tools/tools.dart';
class UnitQuitApplyPage extends StatefulWidget {
const UnitQuitApplyPage({super.key, required this.firmInfo});
final Map firmInfo;
@override
State<UnitQuitApplyPage> createState() => _UnitQuitApplyPageState();
}
class _UnitQuitApplyPageState extends State<UnitQuitApplyPage> {
String _resignationReason = '';
@override
void initState() {
super.initState();
}
Future<void> _submit() async {
final Map data = {
'corpinfoId' : widget.firmInfo['corpinfoId'],
'id' : widget.firmInfo['userId'],
'resignationReason' : _resignationReason,
};
LoadingDialogHelper.show();
try {
final result = await BasicInfoApi.leaveApply(data);
LoadingDialogHelper.hide();
if (result['success'] == true) {
ToastUtil.showNormal(context, '申请已提交');
Navigator.pop(context);
}else{
ToastUtil.showNormal(context, result['errMessage']);
}
}catch(e){
LoadingDialogHelper.hide();
ToastUtil.showNormal(context, '申请失败');
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: MyAppbar(title: '离职申请'),
body: SafeArea(
child: ItemListWidget.itemContainer(
Column(
children: [
ItemListWidget.singleLineTitleText(
label: '离职申请单位',
text: widget.firmInfo['corpinfoName'] ?? '',
isEditable: false,
),
const Divider(),
ItemListWidget.multiLineTitleTextField(
label: '离职原因',
isEditable: true,
isRequired: false,
hintText: '请输入原因',
onChanged: (value) {
_resignationReason = value;
},
),
const Divider(),
ItemListWidget.singleLineTitleText(
label: '申请时间',
text: DateFormat('yyyy年MM月dd日').format(DateTime.now()),
isEditable: false,
),
const Divider(),
ItemListWidget.singleLineTitleText(
label: '申请人',
text: SessionService.instance.name,
isEditable: false,
),
const Divider(),
const SizedBox(height: 30,),
CustomButton(text: '提交', onPressed: () {
_submit();
},)
],
),
),
),
);
}
}