import 'package:deus_app/common/style/TitleBar.dart'; import 'package:deus_app/common/utils/ConstantString.dart'; import 'package:deus_app/common/utils/ToastUtils.dart'; import 'package:deus_app/model/drop_menu_item.dart'; import 'package:flutter/material.dart'; import 'package:deus_app/model/patrol_response_entity.dart'; /** * 巡检任务详情页面 */ class PatrolJobDetail extends StatefulWidget { const PatrolJobDetail({super.key}); static var routeName = '/PatrolJobDetail'; @override State createState() { return _PatrolJobDetail(); } } PatrolJobDeviceData p = PatrolJobDeviceData('设备名称1', '展示名称1', 'deviceKey1', '2023-05-28', '曹刚'); PatrolJobDeviceData a = PatrolJobDeviceData('设备名称2', '展示名称2', 'deviceKey2', '2023-05-29', '曹刚'); List device_list = [p, a, a, a, a, a, a, a]; 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'); PatrolJobItemData patrolJobItemData2 = PatrolJobItemData('巡检项目2', '结果2'); 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); class _PatrolJobDetail extends State { @override Widget build(BuildContext context) { return Scaffold( appBar: TitleBar().backAppbar(context, "巡检任务详情"), body: Column( children: [ Expanded( child: ListView( children: _Ws(), ), ) ], )); } List _Ws() { List ws = []; // ws.add(_patrolJobDetail(patrolJobDetailData)); // ws.add(_device()); // ws.add(_item()); // ws.add(_remark()); // ws.add(_url()); ws.add(dropDownButtonsColumn(sexMenuItems,'性别',sexSelect)); return ws; } Widget _patrolJobDetail(PatrolJobDetailData patrolJobDetailData) { if (patrolJobDetailData.status == 2) { return Column( children: [ Row( children: [ Container( padding: EdgeInsets.fromLTRB(15, 20, 0, 0), alignment: Alignment.centerLeft, child: Text( '已完成', style: TextStyle(fontSize: 20, backgroundColor: Colors.red), ), ), Container( padding: EdgeInsets.fromLTRB(20, 0, 0, 0), alignment: Alignment.bottomLeft, child: Text( patrolJobDetailData.name, style: TextStyle(fontSize: 18), ), ) ], ), Container( padding: EdgeInsets.fromLTRB(95, 0, 0, 20), alignment: Alignment.centerLeft, child: Text( '任务编号: ' + patrolJobDetailData.number, style: TextStyle(fontSize: 18), ), ), Divider( height: 0.8, indent: 5.0, endIndent: 5.0, color: Colors.grey, ), Container( padding: EdgeInsets.fromLTRB(65, 20, 0, 0), alignment: Alignment.centerLeft, child: Text( '巡检任务名称 ' + patrolJobDetailData.name, style: TextStyle(fontSize: 14), ), ), Container( padding: EdgeInsets.fromLTRB(65, 20, 0, 0), alignment: Alignment.centerLeft, child: Text( '巡检任务编号 ' + patrolJobDetailData.number, style: TextStyle(fontSize: 14), ), ), Container( padding: EdgeInsets.fromLTRB(65, 20, 0, 0), alignment: Alignment.centerLeft, child: Text( '巡检计划名称 ' + patrolJobDetailData.planName, style: TextStyle(fontSize: 14), ), ), Container( padding: EdgeInsets.fromLTRB(65, 20, 0, 0), alignment: Alignment.centerLeft, child: Text( '巡检计划编号 ' + patrolJobDetailData.planNumber, style: TextStyle(fontSize: 14), ), ), Container( padding: EdgeInsets.fromLTRB(92, 20, 0, 0), alignment: Alignment.centerLeft, child: Text( '周期类型 ' + (patrolJobDetailData.termType == 1 ? '日计划' : '暂无'), style: TextStyle(fontSize: 14), ), ), Container( padding: EdgeInsets.fromLTRB(65, 20, 0, 0), alignment: Alignment.centerLeft, child: Text( '任务开始时间 ' + patrolJobDetailData.startDate, style: TextStyle(fontSize: 14), ), ), Container( padding: EdgeInsets.fromLTRB(65, 20, 0, 0), alignment: Alignment.centerLeft, child: Text( '任务结束时间 ' + patrolJobDetailData.endDate, style: TextStyle(fontSize: 14), ), ), Container( padding: EdgeInsets.fromLTRB(65, 20, 0, 0), alignment: Alignment.centerLeft, child: Text( '实际完成时间 ' + patrolJobDetailData.finishTime, style: TextStyle(fontSize: 14), ), ), Container( padding: EdgeInsets.fromLTRB(92, 20, 0, 20), alignment: Alignment.centerLeft, child: Text( '巡检人员 ' + patrolJobDetailData.personnel, style: TextStyle(fontSize: 14), ), ), ], ); } else { return Text('暂无数据'); } } Widget _device() { return ExpansionTile( title: Container( child: Text( '巡检设备', style: TextStyle(color: Colors.blue, fontSize: 20), )), children: device_list.map((e) => _buildDevice(e)).toList(), initiallyExpanded: true); } Widget _buildDevice(PatrolJobDeviceData device) { return FractionallySizedBox( widthFactor: 1, child: Container( height: 160, margin: EdgeInsets.only(bottom: 5), decoration: BoxDecoration(color: Colors.white), child: Column( children: [ Container( margin: const EdgeInsets.fromLTRB(0, 20.0, 0, 0), padding: const EdgeInsets.fromLTRB(30.0, 0.0, 0.0, 0.0), alignment: Alignment.centerLeft, child: Text(device.showName, style: TextStyle(fontSize: 14)), ), Container( margin: const EdgeInsets.fromLTRB(0, 10.0, 0, 0), padding: const EdgeInsets.fromLTRB(30.0, 0.0, 0.0, 0.0), alignment: Alignment.centerLeft, child: Text('设备名称: ' + device.name, style: TextStyle(fontSize: 14)), ), Container( margin: const EdgeInsets.fromLTRB(0, 10.0, 0, 0), padding: const EdgeInsets.fromLTRB(30.0, 0.0, 0.0, 0.0), alignment: Alignment.centerLeft, child: Text('deviceKey: ' + device.deviceKey, style: TextStyle(fontSize: 14)), ), Container( margin: const EdgeInsets.fromLTRB(0, 10.0, 0, 20), padding: const EdgeInsets.fromLTRB(30.0, 0.0, 0.0, 10.0), alignment: Alignment.centerLeft, child: Text('完成时间: ' + device.itemCompleteTime, style: TextStyle(fontSize: 14)), ), Divider( height: 0.8, indent: 10.0, endIndent: 10.0, color: Colors.grey, ), ], ), )); } Widget _item() { return ExpansionTile( title: Container( child: Text( '巡检项目', style: TextStyle(color: Colors.blue, fontSize: 20), )), children: item_list.map((e) => _buildItem(e)).toList(), initiallyExpanded: true); } Widget _buildItem(PatrolJobItemData item) { return FractionallySizedBox( widthFactor: 1, child: Container( height: 100, margin: EdgeInsets.only(bottom: 5), decoration: BoxDecoration(color: Colors.white), child: Column( children: [ Container( margin: const EdgeInsets.fromLTRB(0, 15.0, 0, 0), padding: const EdgeInsets.fromLTRB(30.0, 0.0, 0.0, 0.0), alignment: Alignment.centerLeft, child: Text(item.name, style: TextStyle(fontSize: 14)), ), Container( margin: const EdgeInsets.fromLTRB(0, 10.0, 0, 20), padding: const EdgeInsets.fromLTRB(30.0, 0.0, 0.0, 0.0), alignment: Alignment.centerLeft, child: Text(item.result, style: TextStyle(fontSize: 14)), ), Divider( height: 0.8, indent: 10.0, endIndent: 10.0, color: Colors.grey, ), ], ), )); } Widget _remark() { return ExpansionTile( title: Container( child: Text( '任务结果备注', style: TextStyle(color: Colors.blue, fontSize: 20), )), children: [_buildRemark(patrolJobDetailData)], initiallyExpanded: true); } Widget _buildRemark(PatrolJobDetailData patrolJobDetailData) { return FractionallySizedBox( widthFactor: 1, child: Container( margin: EdgeInsets.only(bottom: 5), decoration: BoxDecoration(color: Colors.white), child: Column( children: [ Container( margin: const EdgeInsets.fromLTRB(0, 15.0, 0, 15.0), padding: const EdgeInsets.fromLTRB(20.0, 0.0, 20.0, 0.0), alignment: Alignment.centerLeft, child: Text(patrolJobDetailData.remark, style: TextStyle(fontSize: 14)), ) ], ), )); } Widget _url() { return ExpansionTile( title: Container( child: Text( '任务图片', style: TextStyle(color: Colors.blue, fontSize: 20), )), children: [ Wrap(children: image_list.map((e) => _buildImage(e)).toList()), ], initiallyExpanded: true); } Widget _buildImage(PatrolJobImageData imageData) { return Container( width: 150, margin: EdgeInsets.only(bottom: 5), alignment: Alignment.centerLeft, decoration: BoxDecoration(color: Colors.white), child: Image.network(imageData.url)); } Widget dropDownButtonsColumn(List list, String hint,DropMenuItem select){ return Padding( padding: const EdgeInsets.only(left: 40, right: 40 , bottom: 24,top:12), child: Container( height: 55, //gives the height of the dropdown button width: MediaQuery.of(context).size.width, //gives the width of the dropdown button decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(3)), color: Color(0xFFF2F2F2) ), // padding: const EdgeInsets.symmetric(horizontal: 13), //you can include padding to control the menu items child: Theme( data: Theme.of(context).copyWith( canvasColor: Colors.white70, // background color for the dropdown items buttonTheme: ButtonTheme.of(context).copyWith( alignedDropdown: true, //If false (the default), then the dropdown's menu will be wider than its button. ) ), child: DropdownButtonHideUnderline( // to hide the default underline of the dropdown button child: DropdownButton( iconEnabledColor: Color(0xFF595959), // icon color of the dropdown button items: list.map(( dropMenuItem){ return DropdownMenuItem( value: dropMenuItem.label, child: Text( dropMenuItem.label, style: TextStyle( fontSize: 15 ), ), ); }).toList(), hint: Text(hint,style: TextStyle(fontSize: 15),), // setting hint onChanged: (String? value){ setState(() { sexSelect.label = value!; // saving the selected value }); }, value: sexSelect.label, // displaying the selected value ), ) ), ), ); } }