确实文件
parent
980bbe19c9
commit
698ccad423
|
@ -0,0 +1,309 @@
|
||||||
|
import 'dart:io';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:qhd_prevention/customWidget/ItemWidgetFactory.dart';
|
||||||
|
import 'package:qhd_prevention/customWidget/custom_button.dart';
|
||||||
|
import 'package:qhd_prevention/customWidget/toast_util.dart';
|
||||||
|
import 'package:qhd_prevention/pages/home/tap/item_list_widget.dart';
|
||||||
|
import 'package:qhd_prevention/pages/home/tap/tabList/special_wrok/dl_work/CutroadFormBaseWork.dart';
|
||||||
|
import 'package:qhd_prevention/tools/tools.dart';
|
||||||
|
import 'package:qhd_prevention/http/ApiService.dart';
|
||||||
|
import 'package:qhd_prevention/pages/my_appbar.dart';
|
||||||
|
import 'package:qhd_prevention/pages/home/tap/tabList/special_wrok/dh_work/qtfx_work_detail/hotwork_gas_list.dart';
|
||||||
|
import 'package:qhd_prevention/customWidget/custom_alert_dialog.dart';
|
||||||
|
import 'package:qhd_prevention/customWidget/single_image_viewer.dart';
|
||||||
|
import 'package:qhd_prevention/pages/mine/mine_sign_page.dart';
|
||||||
|
import 'package:qhd_prevention/pages/home/tap/tabList/special_wrok/dl_work/CutroadFormBaseWork.dart';
|
||||||
|
|
||||||
|
/// 作业人意见
|
||||||
|
class CutroadZyrDetail extends StatefulWidget {
|
||||||
|
const CutroadZyrDetail({
|
||||||
|
super.key,
|
||||||
|
required this.CUTROAD_ID,
|
||||||
|
required this.flow,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String CUTROAD_ID;
|
||||||
|
final String flow;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<CutroadZyrDetail> createState() => _CutroadZyrDetailState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CutroadZyrDetailState extends State<CutroadZyrDetail> {
|
||||||
|
late bool isEditable = false;
|
||||||
|
|
||||||
|
/// 详情
|
||||||
|
late Map<String, dynamic> pd = {};
|
||||||
|
|
||||||
|
/// 安全防护措施列表
|
||||||
|
late List<Map<String, dynamic>> measuresList = [];
|
||||||
|
late Map<String, dynamic> signs = {};
|
||||||
|
|
||||||
|
List<String> signImages = [];
|
||||||
|
List<String> signTimes = []; // 签字时间列表
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 签字
|
||||||
|
Future<void> _sign() async {
|
||||||
|
final path = await Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) => MineSignPage()),
|
||||||
|
);
|
||||||
|
if (path != null) {
|
||||||
|
final now = DateFormat('yyyy-MM-dd HH:mm').format(DateTime.now());
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
signImages.add(path);
|
||||||
|
signTimes.add(now);
|
||||||
|
FocusHelper.clearFocus(context);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _signListWidget() {
|
||||||
|
return Column(
|
||||||
|
children:
|
||||||
|
signImages.map((path) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
const Divider(),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
GestureDetector(
|
||||||
|
child: // 用一个 ConstrainedBox 限制最大尺寸,并改为 BoxFit.contain
|
||||||
|
ConstrainedBox(
|
||||||
|
constraints: const BoxConstraints(
|
||||||
|
maxWidth: 200,
|
||||||
|
maxHeight: 150,
|
||||||
|
),
|
||||||
|
child: Image.file(
|
||||||
|
File(path),
|
||||||
|
// 改为完整显示
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
presentOpaque(
|
||||||
|
SingleImageViewer(imageUrl: path),
|
||||||
|
context,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.only(right: 5),
|
||||||
|
child: CustomButton(
|
||||||
|
text: 'X',
|
||||||
|
height: 30,
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||||
|
backgroundColor: Colors.red,
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
signImages.remove(path);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 80),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 作废 -1 通过 1
|
||||||
|
Future<void> _submit(String status) async {
|
||||||
|
if (signImages.isEmpty) {
|
||||||
|
ToastUtil.showNormal(context, '请签字');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String reasonText = '';
|
||||||
|
|
||||||
|
if (status == '1') {
|
||||||
|
} else {
|
||||||
|
await showDialog<String>(
|
||||||
|
context: context,
|
||||||
|
builder:
|
||||||
|
(_) => CustomAlertDialog(
|
||||||
|
title: '作废原因',
|
||||||
|
mode: DialogMode.input,
|
||||||
|
hintText: '请输入作废原因',
|
||||||
|
cancelText: '取消',
|
||||||
|
confirmText: '确定',
|
||||||
|
onInputConfirm: (text) {
|
||||||
|
reasonText = text;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (reasonText.isEmpty) {
|
||||||
|
ToastUtil.showNormal(context, '请填写作废原因');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 存回 measures
|
||||||
|
final Map<String, dynamic> formData = {};
|
||||||
|
// 提交参数
|
||||||
|
formData['CUTROAD_ID'] = widget.CUTROAD_ID;
|
||||||
|
formData['SIGNTIME'] = signTimes.join(',');
|
||||||
|
formData['USER_ID'] = SessionService.instance.loginUserId;
|
||||||
|
formData['APPLY_STATUS'] = status;
|
||||||
|
formData['STEP_REASON'] = reasonText;
|
||||||
|
|
||||||
|
await showDialog<String>(
|
||||||
|
context: context,
|
||||||
|
builder:
|
||||||
|
(_) => CustomAlertDialog(
|
||||||
|
title: '提示',
|
||||||
|
content: '请确认' + (status == '1' ? "通过" : "作废") + '本作业票?',
|
||||||
|
cancelText: '取消',
|
||||||
|
confirmText: '确定',
|
||||||
|
onConfirm: () async {
|
||||||
|
LoadingDialogHelper.show();
|
||||||
|
try {
|
||||||
|
final result = await ApiService.saveSafeFunctionSure(
|
||||||
|
'cutroad',
|
||||||
|
formData,
|
||||||
|
signImages,
|
||||||
|
);
|
||||||
|
LoadingDialogHelper.hide();
|
||||||
|
if (result['result'] == 'success') {
|
||||||
|
ToastUtil.showSuccess(context, '保存成功');
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
LoadingDialogHelper.hide();
|
||||||
|
ToastUtil.showNormal(context, '操作失败:$e');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 初始化拉取数据
|
||||||
|
Future<void> _getData() async {
|
||||||
|
final data = await ApiService.getHomeworkFindById('cutroad', widget.CUTROAD_ID);
|
||||||
|
setState(() {
|
||||||
|
pd = data['pd'];
|
||||||
|
|
||||||
|
_getSigns(pd['CUTROAD_ID'] ?? '');
|
||||||
|
_getMeasures(pd['CUTROAD_ID'] ?? '');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _getMeasures(String homework_id) async {
|
||||||
|
final data = await ApiService.listSignFinishMeasures('cutroad',
|
||||||
|
homework_id.length > 0 ? homework_id : widget.CUTROAD_ID,
|
||||||
|
);
|
||||||
|
setState(() {
|
||||||
|
measuresList = List<Map<String, dynamic>>.from(
|
||||||
|
data['finishMeasuresList'] ?? <Map<String, dynamic>>[],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _getSigns(String homework_id) async {
|
||||||
|
final data = await ApiService.listSignFinished('cutroad',
|
||||||
|
homework_id.length > 0 ? homework_id : widget.CUTROAD_ID,
|
||||||
|
);
|
||||||
|
setState(() {
|
||||||
|
signs = data['signs'] ?? {};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 底部按钮
|
||||||
|
Widget _bottomButtons() {
|
||||||
|
return Row(
|
||||||
|
spacing: 10,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: CustomButton(
|
||||||
|
height: 45,
|
||||||
|
textStyle: TextStyle(fontSize: 16, color: Colors.white),
|
||||||
|
text: '作废',
|
||||||
|
backgroundColor: Colors.red,
|
||||||
|
onPressed: () {
|
||||||
|
_submit('-1');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: CustomButton(
|
||||||
|
textStyle: TextStyle(fontSize: 16, color: Colors.white),
|
||||||
|
text: '通过',
|
||||||
|
backgroundColor: Colors.green,
|
||||||
|
onPressed: () {
|
||||||
|
_submit('1');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: MyAppbar(title: '作业人意见'),
|
||||||
|
body: SafeArea(
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
padding: EdgeInsets.all(12),
|
||||||
|
child: Column(
|
||||||
|
spacing: 12,
|
||||||
|
children: [
|
||||||
|
CutroadFormBaseWork(
|
||||||
|
pd: pd,
|
||||||
|
measuresList: measuresList,
|
||||||
|
signs: signs,
|
||||||
|
baseImgPath: ApiService.baseImgPath,
|
||||||
|
isEditable: false,
|
||||||
|
onChooseLevel: () {},
|
||||||
|
onAnalyzeTap: () {},
|
||||||
|
),
|
||||||
|
ItemListWidget.itemContainer(
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
ListItemFactory.headerTitle('作业人'),
|
||||||
|
CustomButton(
|
||||||
|
text: '新增手写签字',
|
||||||
|
height: 36,
|
||||||
|
backgroundColor: Colors.green,
|
||||||
|
onPressed: () {
|
||||||
|
_sign();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
if (signImages.isNotEmpty) _signListWidget(),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
_bottomButtons(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue