flutter_integrated_whb/lib/pages/mine/mine_duty_detail.dart

256 lines
8.1 KiB
Dart
Raw Normal View History

2025-07-16 08:38:10 +08:00
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
2025-09-11 15:34:21 +08:00
import 'package:qhd_prevention/pages/home/tap/item_list_widget.dart';
2025-07-16 08:38:10 +08:00
import 'package:qhd_prevention/pages/my_appbar.dart';
2025-09-11 15:34:21 +08:00
import 'package:qhd_prevention/tools/tools.dart';
2025-07-16 08:38:10 +08:00
2025-07-17 17:58:04 +08:00
///岗位详情
2025-07-16 08:38:10 +08:00
class MineDutyDetailPage extends StatefulWidget {
2025-07-17 17:58:04 +08:00
const MineDutyDetailPage(this.item, {super.key});
2025-09-11 15:34:21 +08:00
2025-07-17 17:58:04 +08:00
final item;
2025-07-16 08:38:10 +08:00
@override
State<MineDutyDetailPage> createState() => _MineDutyDetailPage();
}
class _MineDutyDetailPage extends State<MineDutyDetailPage> {
final TextEditingController _reasonController = TextEditingController();
2025-07-17 17:58:04 +08:00
2025-07-16 08:38:10 +08:00
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xFFF5F7FA),
2025-09-11 15:34:21 +08:00
appBar: MyAppbar(title: "离岗详情"),
2025-07-16 08:38:10 +08:00
body: SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
2025-09-12 21:04:05 +08:00
2025-07-16 08:38:10 +08:00
// 申请人信息
2025-09-12 21:04:05 +08:00
_buildInfoRowTwo("申请人:", widget.item["USER_NAME"]),
2025-09-11 15:34:21 +08:00
const SizedBox(height: 10),
2025-07-16 08:38:10 +08:00
// 离岗开始时间
2025-09-12 21:04:05 +08:00
_buildInfoRowTwo("离岗开始时间:", widget.item["STARTTIME"]),
2025-07-16 08:38:10 +08:00
2025-09-11 15:34:21 +08:00
const SizedBox(height: 10),
2025-07-16 08:38:10 +08:00
// 离岗结束时间
2025-09-12 21:04:05 +08:00
_buildInfoRowTwo("离岗结束时间:", widget.item["ENDTIME"]),
2025-07-16 08:38:10 +08:00
2025-09-11 15:34:21 +08:00
const SizedBox(height: 10),
2025-07-16 08:38:10 +08:00
2025-09-12 21:04:05 +08:00
_buildInfoRowTwo("离岗原因:", widget.item["DESCR"]),
2025-07-16 08:38:10 +08:00
2025-09-11 15:34:21 +08:00
const SizedBox(height: 10),
2025-07-16 08:38:10 +08:00
2025-09-12 21:04:05 +08:00
_buildInfoRowTwo("审批状态:", _getTypeReturn(widget.item)),
2025-09-11 15:34:21 +08:00
const SizedBox(height: 10),
2025-09-12 21:04:05 +08:00
2025-07-16 08:38:10 +08:00
// 申请人信息
2025-09-11 15:34:21 +08:00
if (widget.item["REVIEW_STATUS"] != '2')
2025-09-19 18:01:23 +08:00
_buildInfoRowTwo("审批人:", "${FormUtils.hasValue(widget.item, "REVIEW_USER_NAME") ? widget.item["REVIEW_USER_NAME"] : ""}${FormUtils.hasValue(widget.item, "REVIEW_USER_DEPARTMENTNAME") ? "[${widget.item["REVIEW_USER_DEPARTMENTNAME"]}]": ""}",),
2025-09-12 21:04:05 +08:00
// Container(
// padding: const EdgeInsets.symmetric(
// horizontal: 5,
// vertical: 12,
// ),
// decoration: BoxDecoration(
// color: Colors.white,
// borderRadius: BorderRadius.circular(12),
// boxShadow: [
// BoxShadow(
// color: Colors.grey.withOpacity(0.1),
// spreadRadius: 1,
// blurRadius: 6,
// offset: const Offset(0, 2),
// ),
// ],
// ),
// child: ItemListWidget.singleLineTitleText(
// label: '审批人:',
// isEditable: false,
// text:
// "${FormUtils.hasValue(widget.item, "REVIEW_USER_NAME") ? widget.item["REVIEW_USER_NAME"] : "unfind"}[${FormUtils.hasValue(widget.item, "REVIEW_USER_DEPARTMENTNAME") ? widget.item["REVIEW_USER_DEPARTMENTNAME"] : "unfind"}]",
// ),
// ),
2025-07-16 08:38:10 +08:00
2025-09-11 15:34:21 +08:00
const SizedBox(height: 10),
// 审批意见' : '取消原因
if (widget.item["REVIEW_STATUS"] == '1' ||widget.item["REVIEW_STATUS"] == '-1' )
2025-09-12 21:04:05 +08:00
_buildInfoRowTwo(widget.item["ISDELETE"] == '0' ? '审批意见:' : '取消原因:', widget.item["REVIEW_DESC"]),
// Container(
// padding: const EdgeInsets.symmetric(
// horizontal: 5,
// vertical: 12,
// ),
// decoration: BoxDecoration(
// color: Colors.white,
// borderRadius: BorderRadius.circular(12),
// boxShadow: [
// BoxShadow(
// color: Colors.grey.withOpacity(0.1),
// spreadRadius: 1,
// blurRadius: 6,
// offset: const Offset(0, 2),
// ),
// ],
// ),
// child: ItemListWidget.singleLineTitleText(
// label: widget.item["ISDELETE"] == '0' ? '审批意见:' : '取消原因:',
// isEditable: false,
// text:widget.item["REVIEW_DESC"]
//
// ),
// ),
2025-07-16 08:38:10 +08:00
const SizedBox(height: 40),
// 提交按钮
SizedBox(
width: double.infinity,
child: TextButton(
onPressed: () {
Navigator.pop(context);
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF1976D2),
padding: const EdgeInsets.symmetric(vertical: 16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
2025-09-11 15:34:21 +08:00
child: Text(
2025-07-16 08:38:10 +08:00
"返回",
style: TextStyle(fontSize: 16, color: Colors.white),
),
),
),
],
),
),
);
}
Widget _buildDateField({
required String label,
2025-07-17 17:58:04 +08:00
required String? date,
2025-07-16 08:38:10 +08:00
required VoidCallback onTap,
}) {
return GestureDetector(
onTap: onTap,
child: Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.1),
spreadRadius: 1,
blurRadius: 6,
offset: const Offset(0, 2),
),
],
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
2025-09-11 15:34:21 +08:00
Text(label, style: const TextStyle(fontSize: 16)),
2025-07-16 08:38:10 +08:00
Text(
2025-07-17 17:58:04 +08:00
// date != null ? DateFormat('yyyy-MM-dd').format(date) : "请选择日期",
2025-09-11 15:34:21 +08:00
date!,
style: TextStyle(fontSize: 16, color: Colors.black),
2025-07-16 08:38:10 +08:00
),
],
),
),
);
}
2025-09-12 21:04:05 +08:00
Widget _buildInfoRowTwo(String title, String value) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 12),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.1),
spreadRadius: 1,
blurRadius: 6,
offset: const Offset(0, 2),
),
],
),
child:ItemListWidget.singleLineTitleText(
label:title,
isEditable: false,
text:value
),
);
}
2025-07-16 08:38:10 +08:00
Widget _buildInfoRow(String title, String value) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.1),
spreadRadius: 1,
blurRadius: 6,
offset: const Offset(0, 2),
),
],
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
2025-09-11 15:34:21 +08:00
Text(title, style: const TextStyle(fontSize: 16)),
2025-07-16 08:38:10 +08:00
Text(
value,
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
),
],
),
);
}
2025-07-17 17:58:04 +08:00
String _getTypeReturn(final item) {
2025-09-11 15:34:21 +08:00
String type = item['REVIEW_STATUS'];
if ("0" == type) {
2025-07-17 17:58:04 +08:00
return "待审批";
2025-09-11 15:34:21 +08:00
} else if ("1" == type) {
2025-07-17 17:58:04 +08:00
return "审批通过";
2025-09-11 15:34:21 +08:00
} else if ("2" == type) {
2025-07-17 17:58:04 +08:00
return "无需审批";
2025-09-11 15:34:21 +08:00
} else if ("-1" == type) {
String type2 = item['ISDELETE'];
if ("1" == type2) {
if (item['CREATOR'] == item['OPERATOR']) {
2025-07-17 17:58:04 +08:00
return "申请人取消";
2025-09-11 15:34:21 +08:00
} else {
2025-07-17 17:58:04 +08:00
return "审批人取消";
}
2025-09-11 15:34:21 +08:00
} else {
2025-07-17 17:58:04 +08:00
return "审批打回";
}
2025-09-11 15:34:21 +08:00
} else {
2025-07-17 17:58:04 +08:00
return "审批错误";
}
}
2025-09-11 15:34:21 +08:00
}