repair_job_device_list.dart 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. import 'package:deus_app/common/style/TitleBar.dart';
  2. import 'package:deus_app/common/style/gsy_style.dart';
  3. import 'package:deus_app/common/utils/DioUtil.dart';
  4. import 'package:deus_app/common/utils/ToastUtils.dart';
  5. import 'package:deus_app/generated/json/repair_query_device_response_entity_helper.dart';
  6. import 'package:deus_app/main.dart';
  7. import 'package:deus_app/model/repair_query_device_response_entity.dart';
  8. import 'package:flutter/material.dart';
  9. class RepairJobDeviceList extends StatefulWidget {
  10. @override
  11. State createState() {
  12. return new _RepairJobDeviceList();
  13. }
  14. }
  15. class _RepairJobDeviceList extends State<RepairJobDeviceList> {
  16. RepairQueryDeviceResponseEntity data = RepairQueryDeviceResponseEntity();
  17. List<RepairQueryDeviceResponseDataList> mList = [];
  18. @override
  19. void initState() {
  20. super.initState();
  21. patrolItemModel();
  22. }
  23. @override
  24. Widget build(BuildContext context) {
  25. return Scaffold(
  26. appBar: TitleBar().backAppbar("添加巡检项目"),
  27. backgroundColor: const Color(0xfff2f2f2),
  28. body: Container(
  29. child: ListView.builder(
  30. itemCount: mList.length,
  31. itemBuilder: (context, index) {
  32. return Container(
  33. margin: EdgeInsets.only(top: 12, left: 10, right: 10),
  34. padding: EdgeInsets.only(top: 12, bottom: 10),
  35. color: Colors.white,
  36. child: ListTile(
  37. title: Column(
  38. children: [
  39. Row(
  40. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  41. children: [
  42. Container(
  43. child: Text(
  44. mList[index].showName,
  45. style: const TextStyle(
  46. color: Colors.black,
  47. fontSize: GSYConstant.middleTextWhiteSize,
  48. fontWeight: FontWeight.bold,
  49. ),
  50. ),
  51. ),
  52. Container(
  53. padding: EdgeInsets.only(
  54. top: 3, bottom: 3, left: 5, right: 5),
  55. child: Text(
  56. mList[index].status == 0
  57. ? '在线'
  58. : mList[index].status == 1
  59. ? '离线'
  60. : mList[index].status == 2
  61. ? '未激活'
  62. : '未知',
  63. textAlign: TextAlign.right,
  64. style: TextStyle(
  65. color: mList[index].status == 0
  66. ? Colors.blue
  67. : mList[index].status == 1
  68. ? Colors.orange
  69. : mList[index].status == 2
  70. ? Colors.red
  71. : Colors.black,
  72. fontSize: GSYConstant.minTextSize,
  73. ),
  74. ),
  75. decoration: BoxDecoration(
  76. border: new Border.all(
  77. color: mList[index].status == 0
  78. ? Colors.blue
  79. : mList[index].status == 1
  80. ? Colors.orange
  81. : mList[index].status == 2
  82. ? Colors.red
  83. : Colors.black, //边框颜色
  84. width: 1.0, //边框粗细
  85. ),
  86. borderRadius: const BorderRadius.all(
  87. const Radius.circular(3.0)), //边框的弧度
  88. ),
  89. )
  90. ]),
  91. SizedBox(
  92. height: 5,
  93. ),
  94. ],
  95. ),
  96. onTap: () {
  97. eventBus.fire(mList[index]);
  98. Navigator.pop(context);
  99. },
  100. ));
  101. },
  102. ),
  103. ));
  104. }
  105. patrolItemModel() async {
  106. var result = await DioUtil().request('repair-bill/query-device',
  107. method: DioMethod.post, data: {'query': {}});
  108. if (0 == result['code']) {
  109. setState(() {
  110. data = repairQueryDeviceResponseEntityFromJson(
  111. RepairQueryDeviceResponseEntity(), result);
  112. mList.clear();
  113. mList.addAll(data.data.xList);
  114. });
  115. } else {
  116. showToast(result['msg']);
  117. }
  118. }
  119. }