device_manage_detail_page.dart 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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/LoadingDialogHelper.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/model/equipment_info_entity.dart';
  8. import 'package:deus_app/page/device/device_manage_update_page.dart';
  9. import 'package:flutter/material.dart';
  10. class DeviceManageDetailPage extends StatefulWidget {
  11. final EquipmentInfoData data;
  12. const DeviceManageDetailPage({super.key, required this.data});
  13. @override
  14. State createState() {
  15. return _DeviceManageDetailPage(data);
  16. }
  17. }
  18. class _DeviceManageDetailPage extends State<DeviceManageDetailPage> {
  19. EquipmentInfoData data;
  20. _DeviceManageDetailPage(this.data);
  21. var _event;
  22. @override
  23. Widget build(BuildContext context) {
  24. // TODO: implement build
  25. return Scaffold(
  26. appBar: TitleBar().backAppbar(context, "设备详情"),
  27. backgroundColor: const Color(0xfff2f2f2),
  28. body: ListView(children: _Ws()));
  29. }
  30. List<Widget> _Ws() {
  31. List<Widget> ws = [];
  32. ws.add(_deviceDetail());
  33. ws.add(_deviceList());
  34. return ws;
  35. }
  36. Widget _deviceDetail() {
  37. return Column(children: [
  38. Container(
  39. decoration: BoxDecoration(color: Colors.white),
  40. padding: EdgeInsets.only(bottom: 15, top: 15, left: 12, right: 12),
  41. margin: EdgeInsets.only(bottom: 15),
  42. child: Column(
  43. children: [
  44. Row(
  45. children: [
  46. Container(
  47. // padding: EdgeInsets.fromLTRB(12, 0, 0, 0),
  48. alignment: Alignment.bottomLeft,
  49. child: Text(
  50. data.showName,
  51. style: TextStyle(
  52. fontSize: GSYConstant.middleTextWhiteSize,
  53. fontWeight: FontWeight.bold),
  54. ),
  55. ),
  56. Container(
  57. margin: EdgeInsets.only(left: 10),
  58. padding: EdgeInsets.fromLTRB(3, 2, 3, 2),
  59. alignment: Alignment.centerLeft,
  60. child: Text(
  61. data.status == 0
  62. ? '在线'
  63. : data.status == 1
  64. ? '离线'
  65. : data.status == 2
  66. ? '未激活'
  67. : '未知',
  68. style: TextStyle(
  69. fontSize: GSYConstant.minTextSize,
  70. color: data.status == 2
  71. ? Colors.red
  72. : data.status == 1
  73. ? Colors.orange
  74. : data.status == 0
  75. ? Colors.blue
  76. : Colors.black),
  77. ),
  78. decoration: BoxDecoration(
  79. border: new Border.all(
  80. color: data.status == 2
  81. ? Colors.red
  82. : data.status == 1
  83. ? Colors.orange
  84. : data.status == 0
  85. ? Colors.blue
  86. : Colors.black, //边框颜色
  87. width: 1.0, //边框粗细
  88. ),
  89. borderRadius: const BorderRadius.all(
  90. const Radius.circular(3.0)), //边框的弧度
  91. ),
  92. )
  93. ],
  94. ),
  95. Container(
  96. padding: EdgeInsets.only(top: 15),
  97. child: Row(
  98. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  99. children: [
  100. new Text(
  101. '产品名称:',
  102. style: GSYConstant.smallTextLight,
  103. ),
  104. Container(
  105. child: Text(
  106. data.productName,
  107. style: GSYConstant.smallTextLight,
  108. textAlign: TextAlign.right,
  109. ),
  110. ),
  111. ])),
  112. Container(
  113. padding: EdgeInsets.only(top: 15),
  114. child: Row(
  115. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  116. children: [
  117. new Text(
  118. '激活时间:',
  119. style: GSYConstant.smallTextLight,
  120. ),
  121. Container(
  122. child: Text(
  123. data.activationOn,
  124. style: GSYConstant.smallTextLight,
  125. textAlign: TextAlign.right,
  126. ),
  127. ),
  128. ])),
  129. Container(
  130. padding: EdgeInsets.only(top: 15),
  131. child: Row(
  132. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  133. children: [
  134. new Text(
  135. '最后上线时间:',
  136. style: GSYConstant.smallTextLight,
  137. ),
  138. Container(
  139. child: Text(
  140. data.lastOnlineOn,
  141. style: GSYConstant.smallTextLight,
  142. textAlign: TextAlign.right,
  143. ),
  144. ),
  145. ])),
  146. ],
  147. ),
  148. ),
  149. ]);
  150. }
  151. Widget _deviceList() {
  152. return Column(
  153. children: [
  154. Container(
  155. decoration: BoxDecoration(color: Colors.white),
  156. padding: const EdgeInsets.fromLTRB(12, 15, 12, 15),
  157. child: Column(
  158. children: [
  159. Row(
  160. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  161. children: [
  162. const Text("设备参数", style: TextStyle(
  163. fontSize: GSYConstant.middleTextWhiteSize,
  164. fontWeight: FontWeight.bold)),
  165. GestureDetector(
  166. child: const Text("修改参数",
  167. style: TextStyle(
  168. fontSize: GSYConstant.middleTextWhiteSize,
  169. color: Colors.blue),
  170. textAlign: TextAlign.right),
  171. onTap: () {
  172. Navigator.push(
  173. context,
  174. MaterialPageRoute(
  175. builder: (context) => DeviceManageUpdatePage(data:data)));
  176. },
  177. )
  178. ],
  179. ),
  180. SizedBox(
  181. height: 15,
  182. ),
  183. Container(
  184. alignment: Alignment.centerLeft,
  185. child: Text('当前设备已设置的参数如下:', style: GSYConstant.smallTextBold),
  186. ),
  187. SizedBox(
  188. height: 15,
  189. ),
  190. Row(
  191. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  192. children: [
  193. new Text('A侧速度:', style: GSYConstant.smallTextLight),
  194. new Text(data.speedA, style: GSYConstant.smallTextLight,textAlign: TextAlign.right),
  195. ],
  196. ),
  197. SizedBox(
  198. height: 15,
  199. ),
  200. Row(
  201. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  202. children: [
  203. new Text('B侧速度:', style: GSYConstant.smallTextLight),
  204. new Text(data.speedB, style: GSYConstant.smallTextLight,textAlign: TextAlign.right),
  205. ],
  206. ),
  207. SizedBox(
  208. height: 15,
  209. ),
  210. Row(
  211. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  212. children: [
  213. new Text('A侧纤度:', style: GSYConstant.smallTextLight),
  214. new Text(data.finenessA, style: GSYConstant.smallTextLight,textAlign: TextAlign.right),
  215. ],
  216. ),
  217. SizedBox(
  218. height: 15,
  219. ),
  220. Row(
  221. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  222. children: [
  223. new Text('B侧纤度:', style: GSYConstant.smallTextLight),
  224. new Text(data.finenessB, style: GSYConstant.smallTextLight,textAlign: TextAlign.right),
  225. ],
  226. ),
  227. SizedBox(
  228. height: 15,
  229. ),
  230. Row(
  231. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  232. children: [
  233. new Text('A侧孔数:', style: GSYConstant.smallTextLight),
  234. new Text(data.holeCountA, style: GSYConstant.smallTextLight,textAlign: TextAlign.right),
  235. ],
  236. ),
  237. SizedBox(
  238. height: 15,
  239. ),
  240. Row(
  241. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  242. children: [
  243. new Text('B侧孔数:', style: GSYConstant.smallTextLight),
  244. new Text(data.holeCountB, style: GSYConstant.smallTextLight,textAlign: TextAlign.right),
  245. ],
  246. )
  247. ],
  248. ))
  249. ],
  250. );
  251. }
  252. @override
  253. void initState() {
  254. super.initState();
  255. _event = eventBus.on<Object>().listen((event) {
  256. setState(() {
  257. equipmentInfo(data.id);
  258. });
  259. });
  260. }
  261. equipmentInfo(int id) async{
  262. LoadingDialogHelper.showLoading(context);
  263. var result = await DioUtil().request("equipment/equipmentInfo",method: DioMethod.get,params: {'id':id});
  264. EquipmentInfoEntity entity=equipmentInfoEntityFromJson(EquipmentInfoEntity(), result);
  265. LoadingDialogHelper.dismissLoading(context);
  266. if (entity.code == 0) {
  267. setState(() {
  268. data=entity.data;
  269. });
  270. } else {
  271. showToast(entity.msg);
  272. }
  273. }
  274. @override
  275. void dispose() {
  276. // TODO: implement dispose
  277. super.dispose();
  278. _event.cancel();
  279. }
  280. }