patrol_job_detail.dart 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. import 'package:deus_app/common/style/TitleBar.dart';
  2. import 'package:deus_app/common/utils/ConstantString.dart';
  3. import 'package:deus_app/common/utils/ToastUtils.dart';
  4. import 'package:deus_app/model/drop_menu_item.dart';
  5. import 'package:flutter/material.dart';
  6. import 'package:deus_app/model/patrol_response_entity.dart';
  7. /**
  8. * 巡检任务详情页面
  9. */
  10. class PatrolJobDetail extends StatefulWidget {
  11. const PatrolJobDetail({super.key});
  12. static var routeName = '/PatrolJobDetail';
  13. @override
  14. State createState() {
  15. return _PatrolJobDetail();
  16. }
  17. }
  18. PatrolJobDeviceData p =
  19. PatrolJobDeviceData('设备名称1', '展示名称1', 'deviceKey1', '2023-05-28', '曹刚');
  20. PatrolJobDeviceData a =
  21. PatrolJobDeviceData('设备名称2', '展示名称2', 'deviceKey2', '2023-05-29', '曹刚');
  22. List<PatrolJobDeviceData> device_list = [p, a, a, a, a, a, a, a];
  23. PatrolJobDetailData patrolJobDetailData = PatrolJobDetailData(
  24. '巡检任务',
  25. 'XJRW10001',
  26. '巡检计划',
  27. 'XJJH10001',
  28. 1,
  29. '2023-05-29 00:00:00',
  30. '2023-05-29 23:59:59',
  31. '曹刚',
  32. '2023-05-29 14:00:35',
  33. 2,
  34. '备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注');
  35. PatrolJobItemData patrolJobItemData = PatrolJobItemData('巡检项目1', '结果1');
  36. PatrolJobItemData patrolJobItemData2 = PatrolJobItemData('巡检项目2', '结果2');
  37. List<PatrolJobItemData> item_list = [patrolJobItemData, patrolJobItemData2];
  38. PatrolJobImageData imageData = PatrolJobImageData(1,
  39. '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');
  40. List<PatrolJobImageData> image_list = [
  41. imageData,
  42. imageData,
  43. imageData,
  44. imageData,
  45. imageData,
  46. imageData,
  47. imageData,
  48. imageData,
  49. imageData,
  50. imageData,
  51. imageData,
  52. imageData,
  53. imageData,
  54. imageData,
  55. ];
  56. DropMenuItem boy = DropMenuItem('男', 1);
  57. DropMenuItem girl = DropMenuItem('女', 2);
  58. List<DropMenuItem> sexMenuItems = [boy,girl];
  59. List<String> sexSelects = ['男','女','奥特曼'];
  60. DropMenuItem sexSelect = DropMenuItem('男',1);
  61. class _PatrolJobDetail extends State<PatrolJobDetail> {
  62. @override
  63. Widget build(BuildContext context) {
  64. return Scaffold(
  65. appBar: TitleBar().backAppbar(context, "巡检任务详情"),
  66. body: Column(
  67. children: [
  68. Expanded(
  69. child: ListView(
  70. children: _Ws(),
  71. ),
  72. )
  73. ],
  74. ));
  75. }
  76. List<Widget> _Ws() {
  77. List<Widget> ws = [];
  78. // ws.add(_patrolJobDetail(patrolJobDetailData));
  79. // ws.add(_device());
  80. // ws.add(_item());
  81. // ws.add(_remark());
  82. // ws.add(_url());
  83. ws.add(dropDownButtonsColumn(sexMenuItems,'性别',sexSelect));
  84. return ws;
  85. }
  86. Widget _patrolJobDetail(PatrolJobDetailData patrolJobDetailData) {
  87. if (patrolJobDetailData.status == 2) {
  88. return Column(
  89. children: [
  90. Row(
  91. children: [
  92. Container(
  93. padding: EdgeInsets.fromLTRB(15, 20, 0, 0),
  94. alignment: Alignment.centerLeft,
  95. child: Text(
  96. '已完成',
  97. style: TextStyle(fontSize: 20, backgroundColor: Colors.red),
  98. ),
  99. ),
  100. Container(
  101. padding: EdgeInsets.fromLTRB(20, 0, 0, 0),
  102. alignment: Alignment.bottomLeft,
  103. child: Text(
  104. patrolJobDetailData.name,
  105. style: TextStyle(fontSize: 18),
  106. ),
  107. )
  108. ],
  109. ),
  110. Container(
  111. padding: EdgeInsets.fromLTRB(95, 0, 0, 20),
  112. alignment: Alignment.centerLeft,
  113. child: Text(
  114. '任务编号: ' + patrolJobDetailData.number,
  115. style: TextStyle(fontSize: 18),
  116. ),
  117. ),
  118. Divider(
  119. height: 0.8,
  120. indent: 5.0,
  121. endIndent: 5.0,
  122. color: Colors.grey,
  123. ),
  124. Container(
  125. padding: EdgeInsets.fromLTRB(65, 20, 0, 0),
  126. alignment: Alignment.centerLeft,
  127. child: Text(
  128. '巡检任务名称 ' + patrolJobDetailData.name,
  129. style: TextStyle(fontSize: 14),
  130. ),
  131. ),
  132. Container(
  133. padding: EdgeInsets.fromLTRB(65, 20, 0, 0),
  134. alignment: Alignment.centerLeft,
  135. child: Text(
  136. '巡检任务编号 ' + patrolJobDetailData.number,
  137. style: TextStyle(fontSize: 14),
  138. ),
  139. ),
  140. Container(
  141. padding: EdgeInsets.fromLTRB(65, 20, 0, 0),
  142. alignment: Alignment.centerLeft,
  143. child: Text(
  144. '巡检计划名称 ' + patrolJobDetailData.planName,
  145. style: TextStyle(fontSize: 14),
  146. ),
  147. ),
  148. Container(
  149. padding: EdgeInsets.fromLTRB(65, 20, 0, 0),
  150. alignment: Alignment.centerLeft,
  151. child: Text(
  152. '巡检计划编号 ' + patrolJobDetailData.planNumber,
  153. style: TextStyle(fontSize: 14),
  154. ),
  155. ),
  156. Container(
  157. padding: EdgeInsets.fromLTRB(92, 20, 0, 0),
  158. alignment: Alignment.centerLeft,
  159. child: Text(
  160. '周期类型 ' + (patrolJobDetailData.termType == 1 ? '日计划' : '暂无'),
  161. style: TextStyle(fontSize: 14),
  162. ),
  163. ),
  164. Container(
  165. padding: EdgeInsets.fromLTRB(65, 20, 0, 0),
  166. alignment: Alignment.centerLeft,
  167. child: Text(
  168. '任务开始时间 ' + patrolJobDetailData.startDate,
  169. style: TextStyle(fontSize: 14),
  170. ),
  171. ),
  172. Container(
  173. padding: EdgeInsets.fromLTRB(65, 20, 0, 0),
  174. alignment: Alignment.centerLeft,
  175. child: Text(
  176. '任务结束时间 ' + patrolJobDetailData.endDate,
  177. style: TextStyle(fontSize: 14),
  178. ),
  179. ),
  180. Container(
  181. padding: EdgeInsets.fromLTRB(65, 20, 0, 0),
  182. alignment: Alignment.centerLeft,
  183. child: Text(
  184. '实际完成时间 ' + patrolJobDetailData.finishTime,
  185. style: TextStyle(fontSize: 14),
  186. ),
  187. ),
  188. Container(
  189. padding: EdgeInsets.fromLTRB(92, 20, 0, 20),
  190. alignment: Alignment.centerLeft,
  191. child: Text(
  192. '巡检人员 ' + patrolJobDetailData.personnel,
  193. style: TextStyle(fontSize: 14),
  194. ),
  195. ),
  196. ],
  197. );
  198. } else {
  199. return Text('暂无数据');
  200. }
  201. }
  202. Widget _device() {
  203. return ExpansionTile(
  204. title: Container(
  205. child: Text(
  206. '巡检设备',
  207. style: TextStyle(color: Colors.blue, fontSize: 20),
  208. )),
  209. children: device_list.map((e) => _buildDevice(e)).toList(),
  210. initiallyExpanded: true);
  211. }
  212. Widget _buildDevice(PatrolJobDeviceData device) {
  213. return FractionallySizedBox(
  214. widthFactor: 1,
  215. child: Container(
  216. height: 160,
  217. margin: EdgeInsets.only(bottom: 5),
  218. decoration: BoxDecoration(color: Colors.white),
  219. child: Column(
  220. children: [
  221. Container(
  222. margin: const EdgeInsets.fromLTRB(0, 20.0, 0, 0),
  223. padding: const EdgeInsets.fromLTRB(30.0, 0.0, 0.0, 0.0),
  224. alignment: Alignment.centerLeft,
  225. child: Text(device.showName, style: TextStyle(fontSize: 14)),
  226. ),
  227. Container(
  228. margin: const EdgeInsets.fromLTRB(0, 10.0, 0, 0),
  229. padding: const EdgeInsets.fromLTRB(30.0, 0.0, 0.0, 0.0),
  230. alignment: Alignment.centerLeft,
  231. child: Text('设备名称: ' + device.name,
  232. style: TextStyle(fontSize: 14)),
  233. ),
  234. Container(
  235. margin: const EdgeInsets.fromLTRB(0, 10.0, 0, 0),
  236. padding: const EdgeInsets.fromLTRB(30.0, 0.0, 0.0, 0.0),
  237. alignment: Alignment.centerLeft,
  238. child: Text('deviceKey: ' + device.deviceKey,
  239. style: TextStyle(fontSize: 14)),
  240. ),
  241. Container(
  242. margin: const EdgeInsets.fromLTRB(0, 10.0, 0, 20),
  243. padding: const EdgeInsets.fromLTRB(30.0, 0.0, 0.0, 10.0),
  244. alignment: Alignment.centerLeft,
  245. child: Text('完成时间: ' + device.itemCompleteTime,
  246. style: TextStyle(fontSize: 14)),
  247. ),
  248. Divider(
  249. height: 0.8,
  250. indent: 10.0,
  251. endIndent: 10.0,
  252. color: Colors.grey,
  253. ),
  254. ],
  255. ),
  256. ));
  257. }
  258. Widget _item() {
  259. return ExpansionTile(
  260. title: Container(
  261. child: Text(
  262. '巡检项目',
  263. style: TextStyle(color: Colors.blue, fontSize: 20),
  264. )),
  265. children: item_list.map((e) => _buildItem(e)).toList(),
  266. initiallyExpanded: true);
  267. }
  268. Widget _buildItem(PatrolJobItemData item) {
  269. return FractionallySizedBox(
  270. widthFactor: 1,
  271. child: Container(
  272. height: 100,
  273. margin: EdgeInsets.only(bottom: 5),
  274. decoration: BoxDecoration(color: Colors.white),
  275. child: Column(
  276. children: [
  277. Container(
  278. margin: const EdgeInsets.fromLTRB(0, 15.0, 0, 0),
  279. padding: const EdgeInsets.fromLTRB(30.0, 0.0, 0.0, 0.0),
  280. alignment: Alignment.centerLeft,
  281. child: Text(item.name, style: TextStyle(fontSize: 14)),
  282. ),
  283. Container(
  284. margin: const EdgeInsets.fromLTRB(0, 10.0, 0, 20),
  285. padding: const EdgeInsets.fromLTRB(30.0, 0.0, 0.0, 0.0),
  286. alignment: Alignment.centerLeft,
  287. child: Text(item.result, style: TextStyle(fontSize: 14)),
  288. ),
  289. Divider(
  290. height: 0.8,
  291. indent: 10.0,
  292. endIndent: 10.0,
  293. color: Colors.grey,
  294. ),
  295. ],
  296. ),
  297. ));
  298. }
  299. Widget _remark() {
  300. return ExpansionTile(
  301. title: Container(
  302. child: Text(
  303. '任务结果备注',
  304. style: TextStyle(color: Colors.blue, fontSize: 20),
  305. )),
  306. children: [_buildRemark(patrolJobDetailData)],
  307. initiallyExpanded: true);
  308. }
  309. Widget _buildRemark(PatrolJobDetailData patrolJobDetailData) {
  310. return FractionallySizedBox(
  311. widthFactor: 1,
  312. child: Container(
  313. margin: EdgeInsets.only(bottom: 5),
  314. decoration: BoxDecoration(color: Colors.white),
  315. child: Column(
  316. children: [
  317. Container(
  318. margin: const EdgeInsets.fromLTRB(0, 15.0, 0, 15.0),
  319. padding: const EdgeInsets.fromLTRB(20.0, 0.0, 20.0, 0.0),
  320. alignment: Alignment.centerLeft,
  321. child: Text(patrolJobDetailData.remark,
  322. style: TextStyle(fontSize: 14)),
  323. )
  324. ],
  325. ),
  326. ));
  327. }
  328. Widget _url() {
  329. return ExpansionTile(
  330. title: Container(
  331. child: Text(
  332. '任务图片',
  333. style: TextStyle(color: Colors.blue, fontSize: 20),
  334. )),
  335. children: [
  336. Wrap(children: image_list.map((e) => _buildImage(e)).toList()),
  337. ],
  338. initiallyExpanded: true);
  339. }
  340. Widget _buildImage(PatrolJobImageData imageData) {
  341. return Container(
  342. width: 150,
  343. margin: EdgeInsets.only(bottom: 5),
  344. alignment: Alignment.centerLeft,
  345. decoration: BoxDecoration(color: Colors.white),
  346. child: Image.network(imageData.url));
  347. }
  348. Widget dropDownButtonsColumn(List<DropMenuItem> list, String hint,DropMenuItem select){
  349. return Padding(
  350. padding: const EdgeInsets.only(left: 40, right: 40 , bottom: 24,top:12),
  351. child: Container(
  352. height: 55, //gives the height of the dropdown button
  353. width: MediaQuery.of(context).size.width, //gives the width of the dropdown button
  354. decoration: BoxDecoration(
  355. borderRadius: BorderRadius.all(Radius.circular(3)),
  356. color: Color(0xFFF2F2F2)
  357. ),
  358. // padding: const EdgeInsets.symmetric(horizontal: 13), //you can include padding to control the menu items
  359. child: Theme(
  360. data: Theme.of(context).copyWith(
  361. canvasColor: Colors.white70, // background color for the dropdown items
  362. buttonTheme: ButtonTheme.of(context).copyWith(
  363. alignedDropdown: true, //If false (the default), then the dropdown's menu will be wider than its button.
  364. )
  365. ),
  366. child: DropdownButtonHideUnderline( // to hide the default underline of the dropdown button
  367. child: DropdownButton<String>(
  368. iconEnabledColor: Color(0xFF595959), // icon color of the dropdown button
  369. items: list.map(( dropMenuItem){
  370. return DropdownMenuItem<String>(
  371. value: dropMenuItem.label,
  372. child: Text(
  373. dropMenuItem.label,
  374. style: TextStyle(
  375. fontSize: 15
  376. ),
  377. ),
  378. );
  379. }).toList(),
  380. hint: Text(hint,style: TextStyle(fontSize: 15),), // setting hint
  381. onChanged: (String? value){
  382. setState(() {
  383. sexSelect.label = value!; // saving the selected value
  384. });
  385. },
  386. value: sexSelect.label, // displaying the selected value
  387. ),
  388. )
  389. ),
  390. ),
  391. );
  392. }
  393. }