Compare commits

..

No commits in common. "ef5b1ff2299a74c569bb63764051e46a32cf0f47" and "fc40593ab355aff5552bdeec0e666f5f46e087da" have entirely different histories.

4 changed files with 268 additions and 289 deletions

View File

@ -7,6 +7,7 @@ import 'package:qhd_prevention/customWidget/toast_util.dart';
import 'package:qhd_prevention/http/ApiService.dart'; import 'package:qhd_prevention/http/ApiService.dart';
import 'package:qhd_prevention/pages/my_appbar.dart'; import 'package:qhd_prevention/pages/my_appbar.dart';
class PhotoItem { class PhotoItem {
final String id; final String id;
final String filePath; final String filePath;
@ -15,13 +16,13 @@ class PhotoItem {
PhotoItem({ PhotoItem({
required this.id, required this.id,
required this.filePath, required this.filePath,
required this.type, //1 2 required this.type,//1 2
}); });
} }
class DangerImageUpdataPage extends StatefulWidget { class DangerImageUpdataPage extends StatefulWidget {
const DangerImageUpdataPage(this.id, {super.key, required this.imgList}); const DangerImageUpdataPage(this.id, {super.key});
final List<PhotoItem> imgList;
final String id; final String id;
@ -30,39 +31,40 @@ class DangerImageUpdataPage extends StatefulWidget {
} }
class _DangerImageUpdataPageState extends State<DangerImageUpdataPage> { class _DangerImageUpdataPageState extends State<DangerImageUpdataPage> {
late List<PhotoItem> _imgList = [];
List<PhotoItem> _imgList = [];
List<String> _yinHuanImages = [];
// List<dynamic> alreadyImageList=[]; // List<dynamic> alreadyImageList=[];
@override @override
void initState() { void initState() {
// TODO: implement initState // TODO: implement initState
super.initState(); super.initState();
_imgList = widget.imgList;
_getAlreadyUpImages(); _getAlreadyUpImages();
} }
Future<void> _getAlreadyUpImages() async { Future<void> _getAlreadyUpImages() async {
try { try {
final result = await ApiService.getAlreadyUpImages(widget.id); final result = await ApiService.getAlreadyUpImages(widget.id);
if (result['result'] == 'success') { if (result['result'] == 'success') {
final List<dynamic> newList = result['imgs'] ?? []; final List<dynamic> newList = result['imgs'] ?? [];
setState(() { setState(() {
for (Map item in newList) { for(int i=0;i<newList.length;i++){
String id = item['IMGFILES_ID'] ?? ''; _imgList.add(PhotoItem(
String filePath = item['FILEPATH'] ?? ''; id: newList[i]["IMGFILES_ID"], // ID
_imgList.add( filePath: newList[i]["FILEPATH"],
PhotoItem( type: "1",
id: id, // ID )
filePath: ApiService.baseImgPath+filePath,
type: "1",
),
); );
_yinHuanImages.add(ApiService.baseImgPath +newList[i]["FILEPATH"]);
} }
// alreadyImageList.addAll(newList);
}); });
} else {
}else{
ToastUtil.showNormal(context, "加载数据失败"); ToastUtil.showNormal(context, "加载数据失败");
// _showMessage('加载数据失败'); // _showMessage('加载数据失败');
} }
@ -79,121 +81,128 @@ class _DangerImageUpdataPageState extends State<DangerImageUpdataPage> {
appBar: MyAppbar(title: "检查照片"), appBar: MyAppbar(title: "检查照片"),
body: Column( body: Column(
children: [ children: [
RepairedPhotoSection( RepairedPhotoSection(
title: "检查照片", title: "检查照片",
maxCount: 4, maxCount: 4,
mediaType: MediaType.image, mediaType: MediaType.image,
isShowAI: false, isShowAI: false,
initialMediaPaths: _imgList.map((e)=> e.filePath).toList(), initialMediaPaths: _yinHuanImages,
onMediaAdded: (value) { onMediaAdded: (value) {
setState(() { setState(() {
_imgList.add( _imgList.add(PhotoItem(
PhotoItem( id: "", // ID
id: "", // ID filePath: value,
filePath: value, type: "2",
type: "2", ));
), _yinHuanImages.add(value);
); });
});
}, },
onMediaRemoved: (path) { onMediaRemoved: (path) {
int delete = 0; int delete=0;
_onImageRemoved(_imgList[delete]); for(int i=0;i<_yinHuanImages.length;i++){
_imgList.removeAt(delete); if(_yinHuanImages[i]==path){
}, delete=i;
onAiIdentify: () {}, }
onChanged: (List<File> value) {}, }
), _onImageRemoved(_imgList[delete]);
_yinHuanImages.removeAt(delete);
_imgList.removeAt(delete);
// },
Container( onAiIdentify: () {
margin: const EdgeInsets.only(bottom: 20),
}, onChanged: (List<File> value) {
},
),
//
Container(
margin: const EdgeInsets.only(bottom: 20),
height: 50,
decoration: BoxDecoration(
color: Colors.green,
borderRadius: BorderRadius.circular(10),
boxShadow: [
BoxShadow(
color: Colors.black12,
blurRadius: 6,
offset: Offset(0, 2),
),
],
),
child:
SizedBox(
width: screenWidth - 30,
height: 50, height: 50,
decoration: BoxDecoration( child: TextButton(
color: Colors.green, onPressed: () {
borderRadius: BorderRadius.circular(10), if(_imgList.length>4){
boxShadow: [ ToastUtil.showNormal(context, "图片不能大于4张");
BoxShadow( return;
color: Colors.black12, }
blurRadius: 6, for(int i=0;i<_imgList.length;i++){
offset: Offset(0, 2), if(_imgList[i].type=="2") {
), _addImgFiles(_yinHuanImages[i], "14", widget.id);
],
),
child: SizedBox(
width: screenWidth - 30,
height: 50,
child: TextButton(
onPressed: () async {
if (_imgList.length > 4) {
ToastUtil.showNormal(context, "图片不能大于4张");
return;
} }
_submitAll(); }
}, ToastUtil.showNormal(context, "提交成功");
child: Text( Navigator.pop(context);
"提交", },
style: TextStyle( child: Text(
color: Colors.white, "提交",
fontSize: 18, style: TextStyle(
fontWeight: FontWeight.bold, color: Colors.white,
), fontSize: 18,
fontWeight: FontWeight.bold,
), ),
), ),
), ),
), ),
], ),
), ],)
); );
} }
Future<void> _submitAll() async {
int i = 0;
for (PhotoItem item in _imgList) {
if (item.type == '2') {
String imgPath = await _addImgFiles(item.filePath, "14", widget.id);
if (imgPath.isEmpty) {
//
ToastUtil.showError(context, "${i+1}张上传失败");
return;
}
}
i++;
}
ToastUtil.showNormal(context, "提交成功"); Future<String> _addImgFiles(String imagePath,String type,String id) async {
Navigator.of(context).pop();
}
Future<String> _addImgFiles(String imagePath, String type, String id) async {
try { try {
final raw = await ApiService.addImgFiles(imagePath, type, id);
if (raw['result'] == 'success') {
Map pd = raw['pd'];
final String img = pd['FILEPATH'];
return img;
} else {
return "";
}
} catch (e) {
print('上传图片失败:$e');
return "";
}
}
final raw = await ApiService.addImgFiles( imagePath, type, id);
Future<String> _onImageRemoved(PhotoItem item) async {
try {
final raw = await ApiService.onImageRemoved(item.id);
if (raw['result'] == 'success') { if (raw['result'] == 'success') {
return raw['imgPath']; return raw['imgPath'];
} else { }else{
// _showMessage('反馈提交失败'); // _showMessage('反馈提交失败');
return ""; return "";
} }
} catch (e) { } catch (e) {
// Toast // Toast
print('加载首页数据失败:$e'); print('加载首页数据失败:$e');
return ""; return "";
} }
} }
Future<String> _onImageRemoved(PhotoItem item) async {
try {
final raw = await ApiService.onImageRemoved( item.id);
if (raw['result'] == 'success') {
return raw['imgPath'];
}else{
// _showMessage('反馈提交失败');
return "";
}
} catch (e) {
// Toast
print('加载首页数据失败:$e');
return "";
}
}
} }

View File

@ -364,19 +364,17 @@ class _HighworkListPageState extends State<HighworkListPage> {
Text("所在单位负责人: ${item['LEADER_USER_NAME'] ?? ''}"), Text("所在单位负责人: ${item['LEADER_USER_NAME'] ?? ''}"),
], ],
), ),
// const SizedBox(height: 8), const SizedBox(height: 8),
// Row( Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [ children: [
// Text("作业负责人: ${item['CONFIRM_USER_NAME'] ?? ''}"), Text("作业负责人: ${item['CONFIRM_USER_NAME'] ?? ''}"),
// Text("动火点负责人: ${item['LEADER_USER_NAME'] ?? ''}"), Text("动火点负责人: ${item['LEADER_USER_NAME'] ?? ''}"),
// ], ],
// ), ),
const SizedBox(height: 8), const SizedBox(height: 8),
if (item['AUDIT_USER_NAME'] != null) if (item['AUDIT_USER_NAME'] != null)
Text("安全管理部门负责人: ${item['AUDIT_USER_NAME'] ?? ''}"), Text("安全管理部门负责人: ${item['AUDIT_USER_NAME'] ?? ''}"),
if (item['APPROVE_USER_NAME'] != null)
Text("安全管理部门负责人: ${item['APPROVE_USER_NAME'] ?? ''}"),
const SizedBox(height: 8), const SizedBox(height: 8),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,

View File

@ -182,7 +182,7 @@ class _DangerProjectPageState extends State<DangerProjectPage> {
color: option['color'], color: option['color'],
screenWidth: screenWidth, screenWidth: screenWidth,
onImageTap: () { onImageTap: () {
_getAlreadyUpImages(item); pushPage(DangerImageUpdataPage(item["RECORDITEM_ID"]), context);
}, },
); );
}).toList(), }).toList(),
@ -209,34 +209,6 @@ class _DangerProjectPageState extends State<DangerProjectPage> {
), ),
); );
} }
Future<void> _getAlreadyUpImages(Map item) async {
try {
final result = await ApiService.getAlreadyUpImages(item["RECORDITEM_ID"]);
if (result['result'] == 'success') {
final List<dynamic> newList = result['imgs'] ?? [];
List<PhotoItem> imgList = [];
for (Map item in newList) {
String id = item['IMGFILES_ID'] ?? '';
String filePath = item['FILEPATH'] ?? '';
imgList.add(
PhotoItem(
id: id, // ID
filePath: ApiService.baseImgPath+filePath,
type: "1",
),
);
}
pushPage(DangerImageUpdataPage(item["RECORDITEM_ID"], imgList: imgList), context);
} else {
ToastUtil.showNormal(context, "加载数据失败");
// _showMessage('加载数据失败');
}
} catch (e) {
// Toast
print('加载数据失败:$e');
}
}
// //
Widget _buildOptionButton({ Widget _buildOptionButton({

File diff suppressed because it is too large Load Diff