QinGang_interested/lib/pages/mine/certificate/certificate_detail_page.dart

770 lines
27 KiB
Dart
Raw Normal View History

2025-12-12 09:11:30 +08:00
import 'package:flutter/material.dart';
2026-01-14 09:55:23 +08:00
import 'package:intl/intl.dart';
import 'package:qhd_prevention/constants/app_enums.dart';
2026-02-28 14:38:07 +08:00
import 'package:qhd_prevention/customWidget/MultiDictValuesPicker.dart';
2025-12-12 09:11:30 +08:00
import 'package:qhd_prevention/customWidget/custom_alert_dialog.dart';
import 'package:qhd_prevention/customWidget/custom_button.dart';
import 'package:qhd_prevention/customWidget/item_list_widget.dart';
import 'package:qhd_prevention/customWidget/photo_picker_row.dart';
2026-01-14 09:55:23 +08:00
import 'package:qhd_prevention/customWidget/picker/CupertinoDatePicker.dart';
import 'package:qhd_prevention/customWidget/toast_util.dart';
import 'package:qhd_prevention/http/ApiService.dart';
import 'package:qhd_prevention/http/modules/basic_info_api.dart';
2025-12-12 09:11:30 +08:00
import 'package:qhd_prevention/pages/my_appbar.dart';
2026-01-14 09:55:23 +08:00
import 'package:qhd_prevention/customWidget/bottom_picker.dart';
import 'package:qhd_prevention/services/SessionService.dart';
import 'package:qhd_prevention/tools/tools.dart';
import 'dart:io';
2026-02-28 14:38:07 +08:00
import 'certificate_list_page.dart';
2026-01-14 09:55:23 +08:00
enum CertifitcateTypeMode {
// 特种设备
specialEquipment('tzsbczry', 2),
// 主要负责人
principal('zyfzr', 3),
//安全生产管理人员
safetyManager('aqscglry', 4),
// 特种作业人员
specialWorker('tezhongzuoye', 1),
// 默认
normal('nor', 0);
const CertifitcateTypeMode(this.value, this.type);
final String value;
final int type;
}
2025-12-12 09:11:30 +08:00
class CertificateDetailPage extends StatefulWidget {
2026-01-14 09:55:23 +08:00
const CertificateDetailPage({
super.key,
required this.model,
required this.id,
});
final String id;
2025-12-12 09:11:30 +08:00
final CertifitcateEditMode model;
@override
State<CertificateDetailPage> createState() => _CertificateDetailPageState();
}
class _CertificateDetailPageState extends State<CertificateDetailPage> {
2026-01-14 09:55:23 +08:00
late Map pd = {};
// 证书类型
List _cerTypes = [];
/// 特种作业数据字典
List _specialWorkList = [];
List _chooseWorkTypeList = [];
// 证书照片
List<String> _cerImgList = [];
List<String> _idCartImgIds = [];
// 已删除的证书照片
List<String> _cerImgRemoveList = [];
List<String> cerPhotos = [];
/// 特种设备数据字典
List _equipmentList = [];
List _chooseEquipmentTypeList = [];
bool _isEdit = false;
late CertifitcateTypeMode _chooseMode = CertifitcateTypeMode.normal;
@override
void initState() {
super.initState();
_isEdit =
widget.model == CertifitcateEditMode.add ||
widget.model == CertifitcateEditMode.edit;
_getKeyValues();
}
Future<void> _getData() async {
try {
final result = await CertificateApi.getCertificateDetail(widget.id);
LoadingDialogHelper.dismiss();
if (result['success'] == true) {
setState(() {
pd = result['data'];
_chooseMode = CertifitcateTypeMode.normal;
if (pd['type'] == CertifitcateTypeMode.principal.value) {
_chooseMode = CertifitcateTypeMode.principal;
}
2026-02-28 14:38:07 +08:00
if (pd['type'] == CertifitcateTypeMode.safetyManager.value) {
_chooseMode = CertifitcateTypeMode.safetyManager;
}
2026-01-14 09:55:23 +08:00
if (pd['type'] == CertifitcateTypeMode.specialEquipment.value) {
_chooseMode = CertifitcateTypeMode.specialEquipment;
for (Map item in _equipmentList) {
if (item['dictValue'] == pd['assignmentOperatingItemsCode']) {
2026-02-28 14:38:07 +08:00
_chooseEquipmentTypeList = item['children'] ?? [];
2026-01-14 09:55:23 +08:00
break;
}
}
}
if (pd['type'] == CertifitcateTypeMode.specialWorker.value) {
_chooseMode = CertifitcateTypeMode.specialWorker;
for (Map item in _specialWorkList) {
if (item['dictValue'] == pd['industryCategoryCode']) {
2026-02-28 14:38:07 +08:00
_chooseWorkTypeList = item['children'] ?? [];
2026-01-14 09:55:23 +08:00
break;
}
}
}
for (Map item in _cerTypes) {
if (item['dictValue'] == pd['type']) {
pd['typeName'] = item['dictLabel'] ?? '';
break;
}
}
_getCertificatePhotos(pd['userCertificateId']);
});
} else {
ToastUtil.showNormal(context, result['errMessage'] ?? '');
}
} catch (e) {
LoadingDialogHelper.dismiss();
}
}
// 获取证书照片
Future<void> _getCertificatePhotos(String userCertificateId) async {
var fileEnum = _getFileType();
try {
final result = await FileApi.getImagePath(userCertificateId, fileEnum);
setState(() {
List resultList = result['data'];
_cerImgList =
resultList.map((item) => item['filePath'].toString()).toList();
_idCartImgIds =
resultList.map((item) => item['id'].toString()).toList();
});
} catch (e) {
print(e);
}
}
UploadFileType _getFileType() {
switch (_chooseMode) {
case CertifitcateTypeMode.specialWorker:
return UploadFileType.specialOperationPersonnelPhoto;
case CertifitcateTypeMode.specialEquipment:
return UploadFileType.specialEquipmentOperatorPhoto;
case CertifitcateTypeMode.principal:
return UploadFileType.mainResponsiblePersonPhoto;
case CertifitcateTypeMode.safetyManager:
return UploadFileType.photosSafetyProductionManagementPersonnel;
default:
return UploadFileType.specialOperationPersonnelPhoto;
}
}
Future<void> _getKeyValues() async {
LoadingDialogHelper.show();
try {
await BasicInfoApi.getDictValues('zslx').then((res) {
_cerTypes = res['data'];
});
/// 特种作业
await BasicInfoApi.getDictValues('tzzyryhylb0000').then((res) {
_specialWorkList = res['data'];
});
/// 特种设备
await BasicInfoApi.getDictValues('tzsbczryczxmzylb0000').then((res) {
_equipmentList = res['data'];
});
if (widget.model == CertifitcateEditMode.edit ||
widget.model == CertifitcateEditMode.detail) {
_getData();
} else {
LoadingDialogHelper.dismiss();
}
} catch (e) {
print(e);
LoadingDialogHelper.dismiss();
}
}
void _uploadChooseType(Map found) {
String typeCode = found['dictValue'];
String typeName = found['dictLabel'];
setState(() {
if (typeCode == CertifitcateTypeMode.principal.value) {
// 主要负责人
_chooseMode = CertifitcateTypeMode.principal;
}
if (typeCode == CertifitcateTypeMode.specialEquipment.value) {
// 特种设备
_chooseMode = CertifitcateTypeMode.specialEquipment;
}
if (typeCode == CertifitcateTypeMode.specialWorker.value) {
// 特种作业人员
_chooseMode = CertifitcateTypeMode.specialWorker;
}
if (typeCode == CertifitcateTypeMode.safetyManager.value) {
// 安全管理人员
_chooseMode = CertifitcateTypeMode.safetyManager;
}
pd['type'] = typeCode;
pd['typeName'] = typeName;
});
}
Future<void> _submit() async {
if (!_checkSubmit()) {
return;
}
LoadingDialogHelper.show();
// 删除证照
await _checkDeleteImage();
// 先上传证书照片
if (!await _uploadCertificatePhotos()) {
return;
}
try {
if (!FormUtils.hasValue(pd, 'corpinfoId')) {
pd['corpinfoId'] = SessionService.instance.tenantId;
}
if (!FormUtils.hasValue(pd, 'userId')) {
pd['userId'] = SessionService.instance.accountId;
}
final result;
if (widget.model == CertifitcateEditMode.add) {
result = await CertificateApi.addCertificate(pd);
} else {
result = await CertificateApi.updateCertificate(pd);
}
LoadingDialogHelper.hide();
2025-12-12 09:11:30 +08:00
2026-01-14 09:55:23 +08:00
if (result['success'] == true) {
ToastUtil.showNormal(context, '保存成功');
Navigator.of(context).pop();
} else {
ToastUtil.showNormal(context, result['errMessage'] ?? '保存失败');
}
LoadingDialogHelper.dismiss();
} catch (e) {
print(e);
ToastUtil.showNormal(context, '保存失败');
LoadingDialogHelper.dismiss();
}
}
Future<bool> _checkDeleteImage() async {
late bool isSuccess = true;
if (_cerImgRemoveList.isNotEmpty) {
final delIds = _cerImgRemoveList;
try {
await FileApi.deleteImages(delIds).then((result) {
if (result['success']) {
isSuccess = true;
} else {
isSuccess = false;
}
});
} catch (e) {
LoadingDialogHelper.hide();
}
} else {
isSuccess = true;
}
return isSuccess;
}
2025-12-12 09:11:30 +08:00
2026-01-14 09:55:23 +08:00
// 上传证书照片
Future<bool> _uploadCertificatePhotos() async {
if (cerPhotos.isEmpty) {
return true;
}
var fileEnum = _getFileType();
try {
final result = await FileApi.uploadFiles(
cerPhotos,
fileEnum,
pd['userCertificateId'] ?? '',
);
if (result['success'] == true) {
if (!FormUtils.hasValue(pd, 'userCertificateId')) {
// 说明已经上传过,或者是编辑
pd['userCertificateId'] = result['data']['foreignKey'] ?? '';
}
return true;
2026-02-28 14:38:07 +08:00
} else {
2026-01-14 09:55:23 +08:00
ToastUtil.showNormal(context, result['errMessage'] ?? '保存失败');
}
} catch (e) {
LoadingDialogHelper.hide();
return false;
print(e);
}
return false;
}
2025-12-12 09:11:30 +08:00
2026-01-14 09:55:23 +08:00
bool _checkSubmit() {
if (cerPhotos.length + _cerImgList.length < 2) {
ToastUtil.showNormal(context, '请上传证书正面和反面照片');
return false;
}
if (!FormUtils.hasValue(pd, 'typeName')) {
ToastUtil.showNormal(context, '请选择证书类型');
return false;
}
if (!FormUtils.hasValue(pd, 'certificateName')) {
ToastUtil.showNormal(context, '请填写证书名称');
return false;
}
if (!FormUtils.hasValue(pd, 'certificateCode')) {
ToastUtil.showNormal(context, '请填写证书编号');
return false;
}
2026-02-28 14:38:07 +08:00
if (!(_chooseMode == CertifitcateTypeMode.specialEquipment ||
_chooseMode == CertifitcateTypeMode.specialWorker)) {
2026-01-14 09:55:23 +08:00
if (!FormUtils.hasValue(pd, 'postName')) {
2026-02-28 14:38:07 +08:00
ToastUtil.showNormal(context, '请选择岗位');
2026-01-14 09:55:23 +08:00
return false;
}
}
if (!FormUtils.hasValue(pd, 'issuingAuthority')) {
ToastUtil.showNormal(context, '请填写发证机构');
return false;
}
if (_chooseMode == CertifitcateTypeMode.specialWorker) {
if (!FormUtils.hasValue(pd, 'industryCategoryName')) {
ToastUtil.showNormal(context, '请选择行业类型');
return false;
}
if (!FormUtils.hasValue(pd, 'industryOperatingItemsName')) {
ToastUtil.showNormal(context, '请选择操作项目');
return false;
}
}
if (_chooseMode == CertifitcateTypeMode.specialEquipment) {
if (!FormUtils.hasValue(pd, 'assignmentOperatingItemsName')) {
ToastUtil.showNormal(context, '请选择操作项目');
return false;
}
if (!FormUtils.hasValue(pd, 'assignmentCategoryName')) {
ToastUtil.showNormal(context, '请选择作业类型');
return false;
}
}
if (!FormUtils.hasValue(pd, 'dateIssue')) {
ToastUtil.showNormal(context, '请选择发证日期');
return false;
}
if (!FormUtils.hasValue(pd, 'certificateDateStart')) {
ToastUtil.showNormal(context, '请选择有效期开始时间');
return false;
}
if (!FormUtils.hasValue(pd, 'certificateDateEnd')) {
ToastUtil.showNormal(context, '请选择有效期结束时间');
return false;
}
2026-02-28 14:38:07 +08:00
if (_chooseMode == CertifitcateTypeMode.specialWorker ||
_chooseMode == CertifitcateTypeMode.specialEquipment) {
if (!FormUtils.hasValue(pd, 'reviewDate')) {
ToastUtil.showNormal(context, '请选择复审时间');
return false;
}
2026-01-14 09:55:23 +08:00
}
2026-02-28 14:38:07 +08:00
2026-01-14 09:55:23 +08:00
return true;
2025-12-12 09:11:30 +08:00
}
@override
Widget build(BuildContext context) {
2026-01-14 09:55:23 +08:00
bool isShowIdImg = false;
bool isDetail =
widget.model == CertifitcateEditMode.edit ||
widget.model == CertifitcateEditMode.detail;
if (isDetail && _cerImgList.isNotEmpty) {
isShowIdImg = true;
} else {
if (widget.model == CertifitcateEditMode.add) {
isShowIdImg = true;
}
}
2025-12-12 09:11:30 +08:00
return Scaffold(
2026-01-14 09:55:23 +08:00
appBar: MyAppbar(
2026-02-28 14:38:07 +08:00
title: widget.model == CertifitcateEditMode.add ? '证书信息添加' : '查看信息',
2026-01-14 09:55:23 +08:00
isBack: true,
),
2025-12-12 09:11:30 +08:00
body: SafeArea(
child: ItemListWidget.itemContainer(
horizontal: 5,
ListView(
children: [
2026-01-14 09:55:23 +08:00
if (isShowIdImg) ...[
RepairedPhotoSection(
title: '证书照片',
isRequired: _isEdit,
maxCount: 2,
initialMediaPaths:
_cerImgList
.map((item) => ApiService.baseImgPath + item)
.toList(),
isEdit: _isEdit,
horizontalPadding: _isEdit ? 12 : 0,
inlineImageWidth: 60,
onChanged: (files) {
cerPhotos = files.map((file) => file.path).toList();
},
onMediaRemovedForIndex: (index) async {
final deleFile = _cerImgList[index];
final deleId = _idCartImgIds[index];
var fileEnum = _getFileType();
if (deleFile.contains(fileEnum.path)) {
_cerImgList.removeAt(index);
_idCartImgIds.removeAt(index);
_cerImgRemoveList.add(deleId);
}
},
onAiIdentify: () {},
),
if (_isEdit)
ItemListWidget.itemContainer(
const Text(
'温馨提示用户要上传证书正反面证书照片数量是2张才能保存',
style: TextStyle(color: Colors.red, fontSize: 10),
),
),
const Divider(),
],
2025-12-12 09:11:30 +08:00
ItemListWidget.selectableLineTitleTextRightButton(
label: '证书作业类型:',
2026-01-14 09:55:23 +08:00
isEditable: widget.model == CertifitcateEditMode.add,
text: pd['typeName'] ?? '请选择',
isRequired: widget.model == CertifitcateEditMode.add,
onTap: () async {
final found = await BottomPicker.show(
context,
items: _cerTypes,
itemBuilder:
(i) =>
Text(i['dictLabel']!, textAlign: TextAlign.center),
initialIndex: 0,
);
//FocusHelper.clearFocus(context);
if (found != null) {
_uploadChooseType(found);
}
2025-12-12 09:11:30 +08:00
},
),
const Divider(),
ItemListWidget.singleLineTitleText(
label: '证书名称:',
2026-01-14 09:55:23 +08:00
isRequired: _isEdit,
text: pd['certificateName'] ?? '',
2025-12-12 09:11:30 +08:00
hintText: '请输入证书名称',
2026-01-14 09:55:23 +08:00
isEditable: _isEdit,
2025-12-12 09:11:30 +08:00
onChanged: (value) {
2026-01-14 09:55:23 +08:00
pd['certificateName'] = value;
2025-12-12 09:11:30 +08:00
},
),
const Divider(),
ItemListWidget.singleLineTitleText(
label: '证书编号:',
2026-01-14 09:55:23 +08:00
isRequired: _isEdit,
text: pd['certificateCode'] ?? '',
2025-12-12 09:11:30 +08:00
hintText: '请输入证书编号',
2026-01-14 09:55:23 +08:00
isEditable: _isEdit,
2025-12-12 09:11:30 +08:00
onChanged: (value) {
2026-01-14 09:55:23 +08:00
pd['certificateCode'] = value;
2025-12-12 09:11:30 +08:00
},
),
const Divider(),
2026-02-28 14:38:07 +08:00
if (_chooseMode == CertifitcateTypeMode.principal ||
_chooseMode == CertifitcateTypeMode.safetyManager) ...[
ItemListWidget.selectableLineTitleTextRightButton(
2026-01-14 09:55:23 +08:00
label: '岗位名称:',
isEditable: _isEdit,
2026-02-28 14:38:07 +08:00
text: pd['postName'] ?? '请选择',
isRequired: _isEdit,
onTap: () async {
showModalBottomSheet(
context: context,
isScrollControlled: true,
barrierColor: Colors.black54,
backgroundColor: Colors.transparent,
builder:
(_) => MultiDictValuesPicker(
title: '岗位名称',
dictType:
_chooseMode == CertifitcateTypeMode.principal
? 'zyfzrgwmc0000'
: 'aqscglrygwmc0000',
allowSelectParent: false,
onSelected: (id, name, extraData) {
setState(() {
pd['postId'] = extraData?['dictValue'];
pd['postName'] = name;
});
},
),
);
2026-01-14 09:55:23 +08:00
},
),
const Divider(),
],
ItemListWidget.singleLineTitleText(
label: '发证机构:',
isRequired: _isEdit,
text: pd['issuingAuthority'] ?? '',
hintText: '请输入发证机构',
isEditable: _isEdit,
onChanged: (value) {
pd['issuingAuthority'] = value;
},
),
const Divider(),
if (_chooseMode == CertifitcateTypeMode.specialWorker) ...[
ItemListWidget.selectableLineTitleTextRightButton(
2026-03-05 16:12:47 +08:00
label: '行业类别:',
2026-01-14 09:55:23 +08:00
isEditable: _isEdit,
2026-03-05 16:12:47 +08:00
text: pd['industryCategoryName'] ?? '请选择',
2026-01-14 09:55:23 +08:00
isRequired: _isEdit,
onTap: () async {
final found = await BottomPicker.show(
context,
2026-03-05 16:12:47 +08:00
items: _specialWorkList,
2026-01-14 09:55:23 +08:00
itemBuilder:
(i) => Text(
2026-02-28 14:38:07 +08:00
i['dictLabel']!,
textAlign: TextAlign.center,
),
2026-01-14 09:55:23 +08:00
initialIndex: 0,
);
//FocusHelper.clearFocus(context);
if (found != null) {
2026-03-05 16:12:47 +08:00
setState(() {
pd['industryCategoryName'] = found['dictLabel'];
pd['industryCategoryCode'] = found['dictValue'];
_chooseWorkTypeList = found['children'] ?? [];
pd['industryOperatingItemsName'] = '';
pd['industryOperatingItemsCode'] = '';
});
2026-01-14 09:55:23 +08:00
}
},
),
const Divider(),
ItemListWidget.selectableLineTitleTextRightButton(
2026-03-05 16:12:47 +08:00
label: '操作项目:',
2026-01-14 09:55:23 +08:00
isEditable: _isEdit,
2026-03-05 16:12:47 +08:00
text: pd['industryOperatingItemsName'] ?? '请选择',
2026-01-14 09:55:23 +08:00
isRequired: _isEdit,
onTap: () async {
2026-03-05 16:12:47 +08:00
if (_chooseWorkTypeList.isEmpty) {
ToastUtil.showNormal(context, '暂无操作项目');
return;
}
2026-01-14 09:55:23 +08:00
final found = await BottomPicker.show(
context,
2026-03-05 16:12:47 +08:00
items: _chooseWorkTypeList,
2026-01-14 09:55:23 +08:00
itemBuilder:
(i) => Text(
2026-03-05 16:12:47 +08:00
i['dictLabel']!,
textAlign: TextAlign.center,
),
2026-01-14 09:55:23 +08:00
initialIndex: 0,
);
//FocusHelper.clearFocus(context);
if (found != null) {
2026-03-05 16:12:47 +08:00
pd['industryOperatingItemsName'] = found['dictLabel'];
pd['industryOperatingItemsCode'] = found['dictValue'];
2026-01-14 09:55:23 +08:00
}
},
),
const Divider(),
2026-02-28 14:38:07 +08:00
2026-03-05 16:12:47 +08:00
2026-01-14 09:55:23 +08:00
],
2026-03-05 16:12:47 +08:00
if (_chooseMode == CertifitcateTypeMode.specialEquipment ) ...[
2026-01-14 09:55:23 +08:00
ItemListWidget.selectableLineTitleTextRightButton(
label: '操作项目:',
isEditable: _isEdit,
text: pd['assignmentOperatingItemsName'] ?? '请选择',
isRequired: _isEdit,
onTap: () async {
final found = await BottomPicker.show(
context,
items: _equipmentList,
itemBuilder:
(i) => Text(
i['dictLabel']!,
textAlign: TextAlign.center,
),
initialIndex: 0,
);
//FocusHelper.clearFocus(context);
if (found != null) {
setState(() {
pd['assignmentOperatingItemsName'] = found['dictLabel'];
pd['assignmentOperatingItemsCode'] = found['dictValue'];
2026-02-28 14:38:07 +08:00
_chooseEquipmentTypeList = found['children'] ?? [];
2026-01-14 09:55:23 +08:00
pd['assignmentCategoryName'] = '';
pd['assignmentCategoryCode'] = '';
});
}
},
),
const Divider(),
ItemListWidget.selectableLineTitleTextRightButton(
2026-02-28 14:38:07 +08:00
label: '作业类别:',
2026-01-14 09:55:23 +08:00
isEditable: _isEdit,
text: pd['assignmentCategoryName'] ?? '请选择',
isRequired: _isEdit,
onTap: () async {
2026-02-28 14:38:07 +08:00
if (_chooseEquipmentTypeList.isEmpty) {
ToastUtil.showNormal(context, '暂无行业类型');
return;
}
2026-01-14 09:55:23 +08:00
final found = await BottomPicker.show(
context,
items: _chooseEquipmentTypeList,
itemBuilder:
(i) => Text(
i['dictLabel']!,
textAlign: TextAlign.center,
),
initialIndex: 0,
);
//FocusHelper.clearFocus(context);
if (found != null) {
pd['assignmentCategoryName'] = found['dictLabel'];
pd['assignmentCategoryCode'] = found['dictValue'];
}
},
),
const Divider(),
],
2025-12-12 09:11:30 +08:00
ItemListWidget.selectableLineTitleTextRightButton(
2026-01-14 09:55:23 +08:00
label: '发证日期:',
isEditable: _isEdit,
text: pd['dateIssue'] ?? '请选择',
isRequired: _isEdit,
onTap: () async {
DateTime? picked = await BottomDateTimePicker.showDate(
mode: BottomPickerMode.date,
context,
);
if (picked != null) {
setState(() {
pd['dateIssue'] = DateFormat('yyyy-MM-dd').format(picked);
});
//FocusHelper.clearFocus(context);
}
2025-12-12 09:11:30 +08:00
},
),
const Divider(),
ItemListWidget.selectableLineTitleTextRightButton(
2026-01-14 09:55:23 +08:00
label: '有效期开始时间:',
isEditable: _isEdit,
text: pd['certificateDateStart'] ?? '请选择',
isRequired: _isEdit,
onTap: () async {
DateTime? picked = await BottomDateTimePicker.showDate(
mode: BottomPickerMode.date,
context,
);
if (picked != null) {
setState(() {
pd['certificateDateStart'] = DateFormat(
'yyyy-MM-dd',
).format(picked);
2026-02-28 14:38:07 +08:00
// 如果已经选择结束时间,且结束时间小于开始时间,则结束时间清空
if (FormUtils.hasValue(pd, 'certificateDateEnd') &&
isAfterStr(
pd['certificateDateStart'],
pd['certificateDateEnd'],
)) {
pd['certificateDateEnd'] = '';
}
2026-01-14 09:55:23 +08:00
});
//FocusHelper.clearFocus(context);
}
2025-12-12 09:11:30 +08:00
},
),
const Divider(),
ItemListWidget.selectableLineTitleTextRightButton(
2026-01-14 09:55:23 +08:00
label: '有效期结束时间:',
isEditable: _isEdit,
text: pd['certificateDateEnd'] ?? '请选择',
isRequired: _isEdit,
2026-02-28 14:38:07 +08:00
2026-01-14 09:55:23 +08:00
onTap: () async {
DateTime? picked = await BottomDateTimePicker.showDate(
mode: BottomPickerMode.date,
context,
2026-02-28 14:38:07 +08:00
minTimeStr: pd['certificateDateStart'],
2026-01-14 09:55:23 +08:00
);
if (picked != null) {
setState(() {
pd['certificateDateEnd'] = DateFormat(
'yyyy-MM-dd',
).format(picked);
});
//FocusHelper.clearFocus(context);
}
2025-12-12 09:11:30 +08:00
},
),
const Divider(),
2026-01-14 09:55:23 +08:00
if (_chooseMode == CertifitcateTypeMode.specialWorker ||
_chooseMode == CertifitcateTypeMode.specialEquipment) ...[
ItemListWidget.selectableLineTitleTextRightButton(
label: '复审时间:',
isEditable: _isEdit,
text: pd['reviewDate'] ?? '请选择',
isRequired: _isEdit,
onTap: () async {
DateTime? picked = await BottomDateTimePicker.showDate(
mode: BottomPickerMode.date,
context,
);
if (picked != null) {
setState(() {
pd['reviewDate'] = DateFormat(
'yyyy-MM-dd',
).format(picked);
});
//FocusHelper.clearFocus(context);
}
},
),
const Divider(),
],
2025-12-12 09:11:30 +08:00
2026-01-14 09:55:23 +08:00
const SizedBox(height: 20),
if (_isEdit)
CustomButton(
text: '保存',
backgroundColor: Colors.blue,
onPressed: () {
_submit();
},
),
2025-12-12 09:11:30 +08:00
],
),
),
),
);
}
}