diff --git a/lib/constants/app_enums.dart b/lib/constants/app_enums.dart index 7120cda..9f4f290 100644 --- a/lib/constants/app_enums.dart +++ b/lib/constants/app_enums.dart @@ -387,6 +387,9 @@ enum UploadFileType { /// 重点工程安全管理协议 - 类型: '168', 路径: 'key_project_safety_management_agreement' keyProjectSafetyManagementAgreement('168', 'key_project_safety_management_agreement'), + /// 存重点工程安全管理协议图片 - 类型: '168', 路径: 'key_homework_safety_management_agreement' + keyHomeworkSafetyManagementAgreement('168', 'key_homework_safety_management_agreement'), + /// 重点工程发起情况图片 - 类型: '169', 路径: 'key_project_initiation_image' keyProjectInitiationImage('169', 'key_project_initiation_image'), diff --git a/lib/pages/home/keyTasks/keyTasksDetail/key_tasks_confirm_detail_page.dart b/lib/pages/home/keyTasks/keyTasksDetail/key_tasks_confirm_detail_page.dart index 21bbedd..c86a432 100644 --- a/lib/pages/home/keyTasks/keyTasksDetail/key_tasks_confirm_detail_page.dart +++ b/lib/pages/home/keyTasks/keyTasksDetail/key_tasks_confirm_detail_page.dart @@ -9,8 +9,10 @@ import 'package:path_provider/path_provider.dart'; import 'package:qhd_prevention/constants/app_enums.dart'; import 'package:qhd_prevention/customWidget/BaiDuMap/map_preview_widget.dart'; import 'package:qhd_prevention/customWidget/BaiDuMap/map_webview_page.dart'; +import 'package:qhd_prevention/customWidget/DocumentPicker.dart'; import 'package:qhd_prevention/customWidget/ItemWidgetFactory.dart'; import 'package:qhd_prevention/customWidget/center_multi_picker.dart'; +import 'package:qhd_prevention/customWidget/custom_alert_dialog.dart'; import 'package:qhd_prevention/customWidget/custom_button.dart'; import 'package:qhd_prevention/customWidget/dotted_border_box.dart'; @@ -157,7 +159,45 @@ class _KeyTasksConfirmDetailPageState extends State { _buildInfoItem('监理单位工程负责人电话', pd['supervisionUnitUserPhone'] ?? ''), Divider(height: 1), - _buildInfoItem('安全管理协议',''), + // _buildInfoItem('安全管理协议',''), + ItemListWidget.OneRowButtonTitleText( + horizontalnum: 10, + label: '安全管理协议', + buttonText: '新增', + text: '', + onTap: () async { + final List picked = await DocumentPicker.showPickerModal( + context, + maxAssets: 1, + maxSizeInBytes: 20 * 1024 * 1024, + allowedExtensions: ['pdf', 'doc', 'docx','png', 'jpg', 'jpeg'], + //, 'png', 'jpg', 'jpeg' + allowMultipleFiles: false, + showPhotoSelect: false, + ); + + if (picked.isNotEmpty && picked.first.path != null) { + LoadingDialogHelper.show(); + List imagePaths=[]; + imagePaths.add(picked.first.path!); + final raw = await FileApi.uploadFiles(imagePaths, UploadFileType.keyHomeworkSafetyManagementAgreement, pd['keyProjectId'], + ); + if (raw['success']) { + LoadingDialogHelper.hide(); + setState(() { + fileList.add(raw['data']['fileList'][0]); + // choosefile = picked.first; + // specialHandlingReview['disposalFile'] = raw['data']['filePath']; + ToastUtil.showNormal(context, "上传成功",); + }); + } else { + ToastUtil.showNormal(context, "上传失败"); + LoadingDialogHelper.hide(); + } + } + } + ), + // 文件列表 ListView.builder( shrinkWrap: true, @@ -165,23 +205,63 @@ class _KeyTasksConfirmDetailPageState extends State { itemCount: fileList.length, itemBuilder: (context, index) { final file = fileList[index]; - final fileName = _subText(file,index); - final fileUrl = file['filePath'] ?? ''; + final fileName = _subText(file, index); + final fileUrl = file['filePath'] ?? ''; + return Row( + children: [ + Expanded( // 👈 关键:让 OneRowButtonTitleText 占满剩余空间 + child: ItemListWidget.OneRowButtonTitleText( + horizontalnum: 10, + label: fileName, + buttonText: '查看', + text: '', + onTap: () { + if (fileUrl.isEmpty) { + ToastUtil.showNormal(context, '文件不存在'); + return; + } + _downloadAndLoad(ApiService.baseImgPath + fileUrl); + }, + ), + ), + CustomButton( + text: '删除', + height: 30, + padding: const EdgeInsets.symmetric(vertical: 2, horizontal: 10), + textStyle: TextStyle( + color: Colors.white, + fontSize: 12, + fontWeight: FontWeight.w600, + ), + backgroundColor: Colors.red, + onPressed: () async { + if (fileUrl.isEmpty) { + ToastUtil.showNormal(context, '文件不存在'); + return; + } + final confirmed = await CustomAlertDialog.showConfirm( + context, + title: '提示', + content: '确定删除此文件吗?', + cancelText: '取消', + confirmText: '确定', + ); + if (!confirmed) return; + // 删除逻辑 + List ids=[]; + ids.add(fileList[index]['id']??''); + final fileData = await FileApi.deleteImages(ids); + if (fileData['success']) { + setState(() { + fileList.removeAt(index); + }); + } - return ItemListWidget.OneRowButtonTitleText( - horizontalnum: 10, - label: fileName, - buttonText: '查看', - text: '', - onTap: () { - if (fileUrl.isEmpty) { - ToastUtil.showNormal(context, '文件不存在'); - return; - } - // 打开文件预览 - _downloadAndLoad(ApiService.baseImgPath +fileUrl); - // pushPage(ReadFilePage(fileUrl: ApiService.baseImgPath + fileUrl), context); - }, + + }, + ), + SizedBox(width: 10,), + ], ); }, ), @@ -718,9 +798,12 @@ class _KeyTasksConfirmDetailPageState extends State { String _subText(final item,index) { + if (item == null) { + return '协议${index + 1}'; + } final fileName = item['fileName'] ?? '协议${index + 1}'; - if (fileName.length > 23) { - return '${fileName.substring(0, 23)}...'; + if (fileName.length > 21) { + return '${fileName.substring(0, 21)}...'; } return fileName; }