import 'package:deus_app/common/style/TitleBar.dart'; import 'package:deus_app/common/style/gsy_style.dart'; import 'package:deus_app/common/utils/ConstantString.dart'; import 'package:deus_app/model/drop_menu_item.dart'; import 'package:deus_app/model/maint_job_detail_response.dart'; import 'package:deus_app/model/patrol_response_entity.dart'; import 'package:flutter/material.dart'; import '../../common/utils/DioUtil.dart'; /** * 巡检任务详情页面 */ class MaintJobDetail extends StatefulWidget { var id ; MaintJobDetail({super.key, @required this.id}); static var routeName = '/MaintJobDetail'; @override State createState() { print(id); return new _MaintJobDetail(id); } } PatrolJobDeviceData p = PatrolJobDeviceData('设备名称1', '展示名称1', 'deviceKey1', '2023-05-28', '曹刚', 0); PatrolJobDeviceData a = PatrolJobDeviceData('设备名称2', '展示名称2', 'deviceKey2', '2023-05-29', '曹刚', 1); List device_list = [a, a, a, a, a, a, a, p]; PatrolJobDetailData patrolJobDetailData = PatrolJobDetailData( '巡检任务', 'XJRW10001', '巡检计划', 'XJJH10001', 1, '2023-05-29 00:00:00', '2023-05-29 23:59:59', '曹刚', '2023-05-29 14:00:35', 2, '备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注'); PatrolJobItemData patrolJobItemData = PatrolJobItemData('巡检项目1', '结果1', 0); PatrolJobItemData patrolJobItemData2 = PatrolJobItemData('巡检项目2', '结果2', 1); List item_list = [patrolJobItemData, patrolJobItemData2]; PatrolJobImageData imageData = PatrolJobImageData(1, 'https://fqgz.flowbb.cn:7070/deus-test/image/59a75f5b80d7458c88f6b48608ee16eb.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=minioadmin%2F20230530%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230530T054753Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=cdc7f9501492ef218ce42d4f31c41ed01208802a88c9e9f7df5316251569664c'); List image_list = [ imageData, imageData, imageData, imageData, imageData, imageData, imageData, imageData, imageData, imageData, imageData, imageData, imageData, imageData, ]; DropMenuItem boy = DropMenuItem('男', 1); DropMenuItem girl = DropMenuItem('女', 2); List sexMenuItems = [boy, girl]; List sexSelects = ['男', '女', '奥特曼']; DropMenuItem sexSelect = DropMenuItem('男', 1); MaintJobDetailData maintJobDetail = MaintJobDetailData(); List maintEquipmentVOList = []; class _MaintJobDetail extends State { var id; _MaintJobDetail(this.id); _load() async { var result = await DioUtil().request('maintJob/detail', method: DioMethod.post, params: {'id':id}); MaintJobDetailResponse maintJobDetailResponse = MaintJobDetailResponse.fromJson(result); maintJobDetail = maintJobDetailResponse.data!; } @override void initState() { // TODO: implement initState super.initState(); Future.delayed( Duration.zero, () => setState(() { _load(); })); } @override Widget build(BuildContext context) { return Scaffold( appBar: TitleBar().backAppbar(context, "维保任务详情"), backgroundColor: const Color(0xfff2f2f2), body: Column( children: [ Expanded( // flex: 7, child: ListView( children: _Ws(), ), ), Container( height: 50, // flex: 7, child: Row( children: [ Expanded( child: SizedBox( height: 50, child: TextButton( onPressed: () {}, child: Text(ConstantString.close_job), style: ButtonStyle( backgroundColor: MaterialStateProperty.all( Color(0xFF4875EC)), shape: MaterialStateProperty.all( BeveledRectangleBorder( borderRadius: BorderRadius.circular(0))), foregroundColor: MaterialStateProperty.all(Colors.white), // padding: MaterialStateProperty.all(EdgeInsets.zero) ), ), ), ), Expanded( child: SizedBox( height: 50, child: TextButton( onPressed: () {}, child: Text(ConstantString.login_maint), style: ButtonStyle( backgroundColor: MaterialStateProperty.all(Colors.blue), foregroundColor: MaterialStateProperty.all(Colors.white), shape: MaterialStateProperty.all(BeveledRectangleBorder( borderRadius: BorderRadius.circular(0))), // padding: MaterialStateProperty.all(EdgeInsets.zero) ), ), )), ], ), ) ], )); } List _Ws() { List ws = []; ws.add(_maintJobDetail(maintJobDetail)); ws.add(_device()); ws.add(_item()); ws.add(_remark()); ws.add(_url()); return ws; } Widget _maintJobDetail(MaintJobDetailData maintJobDetail) { return Column( children: [ Row( children: [ Container( margin: EdgeInsets.only(top: 10, left: 12), // padding: EdgeInsets.fromLTRB(12, 0, 0, 0), alignment: Alignment.bottomLeft, child: Text( maintJobDetail.jobName==null?'暂无':maintJobDetail.jobName!, style: TextStyle( fontSize: GSYConstant.middleTextWhiteSize, fontWeight: FontWeight.bold), ), ), Container( margin: EdgeInsets.only(top: 10, left: 10), padding: EdgeInsets.fromLTRB(3, 2, 3, 2), alignment: Alignment.centerLeft, child: Text( maintJobDetail.status == 2 ? '已关闭' : maintJobDetail.status == 3 ? '执行中' : maintJobDetail.status == 5 ? '已完成' : maintJobDetail.status == 1 ? '待执行' : maintJobDetail.status == 4 ? '已逾期' : '未知', style: TextStyle( fontSize: GSYConstant.minTextSize, color: maintJobDetail.status == 0 || maintJobDetail.status == 4 ? Colors.red : maintJobDetail.status == 3 ? Colors.orange : maintJobDetail.status == 2 ? Colors.green : Colors.black, //边框颜色 ), ), decoration: BoxDecoration( border: new Border.all( color: maintJobDetail.status == 0 || maintJobDetail.status == 4 ? Colors.red : maintJobDetail.status == 3 ? Colors.orange : maintJobDetail.status == 2 ? Colors.green : Colors.black, //边框颜色 width: 1.0, //边框粗细 ), borderRadius: const BorderRadius.all( const Radius.circular(3.0)), //边框的弧度 ), ) ], ), Container( margin: EdgeInsets.only(top: 10, left: 12, bottom: 12), alignment: Alignment.centerLeft, child: Text( '任务编号: ' + (maintJobDetail.jobNum==null?'暂无':maintJobDetail.jobNum!), style: TextStyle( fontSize: GSYConstant.smallTextSize, ), ), ), // Divider( // height: 0.8, // indent: 5.0, // endIndent: 5.0, // color: Colors.grey, // ), Container( decoration: BoxDecoration(color: Colors.white), child: Column( children: [ Container( padding: EdgeInsets.fromLTRB(12, 20, 12, 0), alignment: Alignment.centerLeft, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ new Text( '维保产品数:', style: GSYConstant.smallTextLight, ), Container( child: Text( maintJobDetail.prodCount==null?'暂无':maintJobDetail.prodCount.toString(), style: GSYConstant.smallTextLight, textAlign: TextAlign.right, ), ), ], ), ), Container( padding: EdgeInsets.fromLTRB(12, 15, 12, 0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ new Text( '任务开始时间:', style: GSYConstant.smallTextLight, ), Container( child: Text( maintJobDetail.startTime==null?'暂无':maintJobDetail.startTime!, style: GSYConstant.smallTextLight, textAlign: TextAlign.right, ), ), ], ), ), Container( padding: EdgeInsets.fromLTRB(12, 15, 12, 0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ new Text( '任务结束时间:', style: GSYConstant.smallTextLight, ), Container( child: Text( maintJobDetail.endTime==null?'暂无':maintJobDetail.endTime!, style: GSYConstant.smallTextLight, textAlign: TextAlign.right, ), ), ])), Container( padding: EdgeInsets.fromLTRB(12, 15, 12, 0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ new Text( '维保计划名称:', style: GSYConstant.smallTextLight, ), Container( child: Text( maintJobDetail.planName==null?'暂无':maintJobDetail.planName!, style: GSYConstant.smallTextLight, textAlign: TextAlign.right, ), ), ])), Container( padding: EdgeInsets.fromLTRB(12, 15, 12, 0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ new Text( '维保计划编号:', style: GSYConstant.smallTextLight, ), Container( child: Text( maintJobDetail.planNum==null?'暂无':maintJobDetail.planNum!, style: GSYConstant.smallTextLight, textAlign: TextAlign.right, ), ), ])), Container( padding: EdgeInsets.fromLTRB(12, 15, 12, 0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ new Text( '周期类型:', style: GSYConstant.smallTextLight, ), Container( child: Text( maintJobDetail.cycleType == 1?'日计划':maintJobDetail.cycleType == 2?'周计划':maintJobDetail.cycleType == 3?'月计划':'暂无', style: GSYConstant.smallTextLight, textAlign: TextAlign.right, ), ), ])), Container( padding: EdgeInsets.fromLTRB(12, 15, 12, 0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ new Text( '维保完成时间:', style: GSYConstant.smallTextLight, ), Container( child: Text( maintJobDetail.finishTime==null?'暂无':maintJobDetail.finishTime!, style: GSYConstant.smallTextLight, textAlign: TextAlign.right, ), ), ])), Container( padding: EdgeInsets.fromLTRB(12, 15, 12, 15), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ new Text( '维保人员:', style: GSYConstant.smallTextLight, ), Container( child: Text( maintJobDetail.maintStaffName==null?'暂无':maintJobDetail.maintStaffName!, style: GSYConstant.smallTextLight, textAlign: TextAlign.right, ), ), ])), ], ), ), ], ); } Widget _device() { return ExpansionTile( title: Container( child: Text( '维保设备', style: GSYConstant.normalTextActionWhiteBold, )), children: device_list.map((e) => _buildDevice(e)).toList(), initiallyExpanded: true); } Widget _buildDevice(PatrolJobDeviceData device) { return FractionallySizedBox( widthFactor: 1, child: Container( margin: device.id == device_list[device_list.length - 1].id ? EdgeInsets.only(bottom: 0) : EdgeInsets.only(bottom: 5), decoration: BoxDecoration(color: Colors.white), padding: const EdgeInsets.fromLTRB(12, 12, 12, 12), child: Column( children: [ Container( // padding: const EdgeInsets.fromLTRB(30.0, 0.0, 0.0, 0.0), alignment: Alignment.centerLeft, child: Text(device.showName, style: GSYConstant.smallTextBold), ), Container( margin: const EdgeInsets.only(top: 10), // padding: const EdgeInsets.fromLTRB(30.0, 0.0, 0.0, 0.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ new Text( '设备名称:', style: GSYConstant.smallTextLight, ), Container( child: Text( device.name, style: GSYConstant.smallTextLight, textAlign: TextAlign.right, ), ), ]), ), Container( margin: const EdgeInsets.only(top: 10), // padding: const EdgeInsets.fromLTRB(30.0, 0.0, 0.0, 0.0), // alignment: Alignment.centerLeft, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ new Text( 'deviceKey:', style: GSYConstant.smallTextLight, ), Container( child: Text( device.deviceKey, style: GSYConstant.smallTextLight, textAlign: TextAlign.right, ), ), ]), ), Container( margin: const EdgeInsets.only(top: 10), // padding: const EdgeInsets.fromLTRB(30.0, 0.0, 0.0, 10.0), // alignment: Alignment.centerLeft, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ new Text( '维保完成时间:', style: GSYConstant.smallTextLight, ), Container( child: Text( device.itemCompleteTime, style: GSYConstant.smallTextLight, textAlign: TextAlign.right, ), ), ]), ), // Divider( // height: 0.8, // indent: 10.0, // endIndent: 10.0, // color: Colors.grey, // ), ], ), )); } Widget _item() { return ExpansionTile( title: Container( child: Text( '维保项目', style: GSYConstant.normalTextActionWhiteBold, )), children: item_list.map((e) => _buildItem(e)).toList(), initiallyExpanded: true); } Widget _buildItem(PatrolJobItemData item) { return FractionallySizedBox( widthFactor: 1, child: Container( margin: item.id == item_list[item_list.length - 1].id ? EdgeInsets.only(bottom: 0) : EdgeInsets.only(bottom: 5), padding: const EdgeInsets.fromLTRB(12, 15, 15, 0), decoration: BoxDecoration(color: Colors.white), child: Column( children: [ Container( alignment: Alignment.centerLeft, child: Text(item.name, style: TextStyle( fontSize: GSYConstant.middleTextWhiteSize, fontWeight: FontWeight.bold)), ), // Divider( // height: 0.8, // indent: 10.0, // endIndent: 10.0, // color: Colors.grey, // ), ], ), )); } Widget _remark() { return ExpansionTile( title: Container( child: Text( '任务结果备注', style: GSYConstant.normalTextActionWhiteBold, )), children: [_buildRemark(patrolJobDetailData)], initiallyExpanded: true); } Widget _buildRemark(PatrolJobDetailData patrolJobDetailData) { return FractionallySizedBox( widthFactor: 1, child: Container( decoration: BoxDecoration(color: Colors.white), child: Column( children: [ Container( margin: const EdgeInsets.fromLTRB(12, 15.0, 12, 15.0), alignment: Alignment.centerLeft, child: Text(patrolJobDetailData.remark, style: TextStyle(fontSize: 14)), ) ], ), )); } Widget _url() { return ExpansionTile( title: Container( child: Text( '维保图片', style: GSYConstant.normalTextActionWhiteBold, )), children: [ Wrap(children: image_list.map((e) => _buildImage(e)).toList()), ], initiallyExpanded: true); } Widget _buildImage(PatrolJobImageData imageData) { return Container( width: MediaQuery.of(context).size.width / 2, margin: EdgeInsets.only(bottom: 5), padding: EdgeInsets.only(left: 12, right: 12), alignment: Alignment.center, decoration: BoxDecoration(color: Colors.white), child: Image.network(imageData.url)); } }