device_manage_page.dart 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  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/ConstantString.dart';
  4. import 'package:deus_app/common/utils/DioUtil.dart';
  5. import 'package:deus_app/common/utils/ToastUtils.dart';
  6. import 'package:deus_app/generated/json/equipment_info_entity_helper.dart';
  7. import 'package:deus_app/generated/json/equipment_list_entity_helper.dart';
  8. import 'package:deus_app/model/equipment_info_entity.dart';
  9. import 'package:deus_app/model/equipment_list_entity.dart';
  10. import 'package:deus_app/page/device/device_manage_detail_page.dart';
  11. import 'package:deus_app/widget/MyDrawer.dart';
  12. import 'package:flutter/cupertino.dart';
  13. import 'package:flutter/material.dart';
  14. class DeviceManagePage extends StatefulWidget {
  15. static var routeName = '/DeviceManagePage';
  16. const DeviceManagePage({super.key});
  17. @override
  18. State createState() {
  19. return _DeviceManage();
  20. }
  21. }
  22. class _DeviceManage extends State<DeviceManagePage> {
  23. String deviceNum = "0";
  24. String _device = '', _username = '';
  25. dynamic _satus, _isEnabled;
  26. final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
  27. List<EquipmentListDataEquipmentVOS> equipmentVOS =
  28. <EquipmentListDataEquipmentVOS>[];
  29. @override
  30. void initState() {
  31. super.initState();
  32. equipmentList();
  33. }
  34. @override
  35. Widget build(BuildContext contexts) {
  36. return Scaffold(
  37. key: _scaffoldKey,
  38. appBar: TitleBar().drawAppBar(ConstantString.deviceManageText, () {
  39. _scaffoldKey.currentState?.openEndDrawer();
  40. }),
  41. backgroundColor: const Color(0xfff2f2f2),
  42. endDrawer: MyDrawer(
  43. callback:(String device, String name,dynamic stase,dynamic isEnabled){
  44. _device=device;
  45. _username=name;
  46. _satus=stase;
  47. _isEnabled=isEnabled;
  48. equipmentList();
  49. },
  50. ),
  51. //抽屉
  52. body: Column(
  53. children: [
  54. SizedBox(
  55. height: 10,
  56. ),
  57. Row(
  58. mainAxisAlignment: MainAxisAlignment.start,
  59. children: [
  60. SizedBox(
  61. width: 15,
  62. ),
  63. Text(ConstantString.deviceNum,
  64. style: GSYConstant.smallActionLightText),
  65. Text(deviceNum, style: GSYConstant.normalTextBigWhiteBold),
  66. ],
  67. ),
  68. Expanded(
  69. child: Container(
  70. // child: SmartRefresher(
  71. // enablePullDown: true,
  72. // enablePullUp: true,
  73. // header: WaterDropHeader(),
  74. // footer: CustomFooter(
  75. // builder: (BuildContext context, LoadStatus? mode) {
  76. // Widget body;
  77. // if (mode == LoadStatus.idle) {
  78. // body = Text("上拉加载");
  79. // } else if (mode == LoadStatus.loading) {
  80. // body = CupertinoActivityIndicator();
  81. // } else if (mode == LoadStatus.failed) {
  82. // body = Text("加载失败!点击重试!");
  83. // } else if (mode == LoadStatus.canLoading) {
  84. // body = Text("松手,加载更多!");
  85. // } else {
  86. // body = Text("没有更多数据了!");
  87. // }
  88. // return Container(
  89. // height: 55.0,
  90. // child: Center(child: body),
  91. // );
  92. // },
  93. // ),
  94. // controller: _refreshController,
  95. // onRefresh: _onRefresh,
  96. // onLoading: _onLoading,
  97. child: ListView.builder(
  98. itemCount: equipmentVOS.length,
  99. itemBuilder: (context, index) {
  100. return Container(
  101. margin: EdgeInsets.only(top: 12, left: 10, right: 10),
  102. padding: EdgeInsets.only(top: 12, bottom: 10),
  103. color: Colors.white,
  104. child: ListTile(
  105. title: Column(
  106. children: [
  107. Row(
  108. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  109. children: [
  110. Container(
  111. child: Text(
  112. equipmentVOS[index].showName,
  113. style: const TextStyle(
  114. color: Colors.black,
  115. fontSize: GSYConstant.middleTextWhiteSize,
  116. fontWeight: FontWeight.bold,
  117. ),
  118. ),
  119. ),
  120. Container(
  121. padding: EdgeInsets.only(
  122. top: 3, bottom: 3, left: 5, right: 5),
  123. child: Text(
  124. equipmentVOS[index].status == 0
  125. ? '在线'
  126. : equipmentVOS[index].status == 1
  127. ? '离线'
  128. : equipmentVOS[index].status == 2
  129. ? '未激活'
  130. : '未知',
  131. textAlign: TextAlign.right,
  132. style: TextStyle(
  133. color: equipmentVOS[index].status == 0
  134. ? Colors.blue
  135. : equipmentVOS[index].status == 1
  136. ? Colors.orange
  137. : equipmentVOS[index].status == 2
  138. ? Colors.red
  139. : Colors.black,
  140. fontSize: GSYConstant.minTextSize,
  141. ),
  142. ),
  143. decoration: BoxDecoration(
  144. border: new Border.all(
  145. color: equipmentVOS[index].status == 0
  146. ? Colors.blue
  147. : equipmentVOS[index].status == 1
  148. ? Colors.orange
  149. : equipmentVOS[index].status == 2
  150. ? Colors.red
  151. : Colors.black, //边框颜色
  152. width: 1.0, //边框粗细
  153. ),
  154. borderRadius: const BorderRadius.all(
  155. const Radius.circular(3.0)), //边框的弧度
  156. ),
  157. )
  158. ]),
  159. // SizedBox(
  160. // height: 12,
  161. // ),
  162. // Row(
  163. // mainAxisAlignment: MainAxisAlignment.spaceBetween,
  164. // children: [
  165. // Container(
  166. // child: Text(
  167. // 'devicekey:',
  168. // style: TextStyle(
  169. // color: GSYColors.primaryLightValue,
  170. // fontSize: GSYConstant.middleTextWhiteSize,
  171. // ),
  172. // ),
  173. // ),
  174. // Container(
  175. // child: Text(
  176. // 'devicekey',
  177. // textAlign: TextAlign.right,
  178. // style: TextStyle(
  179. // color: GSYColors.primaryLightValue,
  180. // fontSize: GSYConstant.middleTextWhiteSize,
  181. // ),
  182. // ),
  183. // ),
  184. // ]),
  185. // SizedBox(
  186. // height: 10,
  187. // ),
  188. // Row(
  189. // mainAxisAlignment: MainAxisAlignment.spaceBetween,
  190. // children: [
  191. // Container(
  192. // child: Text(
  193. // 'IMEI:',
  194. // style: TextStyle(
  195. // color: GSYColors.primaryLightValue,
  196. // fontSize: GSYConstant.middleTextWhiteSize,
  197. // ),
  198. // ),
  199. // ),
  200. // Container(
  201. // child: Text(
  202. // 'IMEI',
  203. // textAlign: TextAlign.right,
  204. // style: TextStyle(
  205. // color: GSYColors.primaryLightValue,
  206. // fontSize: GSYConstant.middleTextWhiteSize,
  207. // ),
  208. // ),
  209. // ),
  210. // ]),
  211. SizedBox(
  212. height: 5,
  213. ),
  214. ],
  215. ),
  216. onTap: () {
  217. equipmentInfo(equipmentVOS[index].id);
  218. },
  219. ));
  220. },
  221. ),
  222. ))
  223. ],
  224. ),
  225. );
  226. }
  227. equipmentList() async {
  228. // LoadingDialogHelper.showLoading(context);
  229. var result = await DioUtil().request("equipment/equipmentList",
  230. method: DioMethod.post, data: {'index': 1, 'size': 50,'query':{'status':_satus,'name':_username,'isEnable':_isEnabled,'showName':_device}});
  231. EquipmentListEntity entity =
  232. equipmentListEntityFromJson(EquipmentListEntity(), result,);
  233. // LoadingDialogHelper.dismissLoading(context);
  234. if (entity.code == 0) {
  235. setState(() {
  236. equipmentVOS.clear();
  237. equipmentVOS.addAll(entity.data.equipmentVOS);
  238. });
  239. } else {
  240. showToast(entity.msg);
  241. }
  242. }
  243. equipmentInfo(int id) async{
  244. var result = await DioUtil().request("equipment/equipmentInfo",method: DioMethod.get,params: {'id':id});
  245. EquipmentInfoEntity entity=equipmentInfoEntityFromJson(EquipmentInfoEntity(), result);
  246. if (entity.code == 0) {
  247. setState(() {
  248. Navigator.push(
  249. context,
  250. MaterialPageRoute(
  251. builder: (context) => DeviceManageDetailPage(data:entity.data)));
  252. });
  253. } else {
  254. showToast(entity.msg);
  255. }
  256. }
  257. }