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 createState() => _UnitQuitApplyPageState(); } class _UnitQuitApplyPageState extends State { String _resignationReason = ''; @override void initState() { super.initState(); } Future _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(); },) ], ), ), ), ); } }