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