device_manage_detail_page.dart 10 KB

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