device_manage_update_page.dart 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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/model/equipment_info_entity.dart';
  7. import 'package:deus_app/widget/gsy_flex_button.dart';
  8. import 'package:event_bus/event_bus.dart';
  9. import 'package:flutter/material.dart';
  10. class DeviceManageUpdatePage extends StatefulWidget {
  11. final EquipmentInfoData data;
  12. const DeviceManageUpdatePage({super.key, required this.data});
  13. @override
  14. State createState() {
  15. return _DeviceManageUpdatePage(data);
  16. }
  17. }
  18. //创建EventBus对象
  19. final EventBus eventBus = EventBus();
  20. class _DeviceManageUpdatePage extends State<DeviceManageUpdatePage>{
  21. EquipmentInfoData data;
  22. _DeviceManageUpdatePage(this.data);
  23. TextEditingController _finenessAController= TextEditingController();
  24. TextEditingController _finenessBController= TextEditingController();
  25. TextEditingController _holeCountAController= TextEditingController();
  26. TextEditingController _holeCountBController= TextEditingController();
  27. TextEditingController _speedAController= TextEditingController();
  28. TextEditingController _speedBController= TextEditingController();
  29. @override
  30. Widget build(BuildContext context) {
  31. return Scaffold(
  32. appBar: TitleBar().backAppbar(context, "修改参数"),
  33. backgroundColor: const Color(0xfff2f2f2),
  34. body: SingleChildScrollView (
  35. child: Column(
  36. crossAxisAlignment: CrossAxisAlignment.center,
  37. children:<Widget> [
  38. Padding(
  39. padding: const EdgeInsets.only(top: 50.0, left: 10, right: 10),
  40. child: Row(children: [
  41. Expanded(
  42. flex: 1,
  43. child: Text(
  44. 'A测速度:',
  45. style: TextStyle(
  46. color: Colors.black,
  47. fontSize: GSYConstant.smallTextSize,
  48. fontWeight: FontWeight.bold,
  49. ),
  50. ),
  51. ),
  52. Expanded(
  53. child: Container(
  54. height: 40,
  55. child: TextField(
  56. decoration: InputDecoration(
  57. border: OutlineInputBorder(),
  58. ),
  59. controller: _speedAController,
  60. style: TextStyle(fontSize: 14),
  61. onChanged: (value) {
  62. setState(() {
  63. data.speedA=value;
  64. });
  65. },
  66. ),
  67. ),
  68. flex: 3,
  69. ),
  70. ]),
  71. ),
  72. Padding(
  73. padding: const EdgeInsets.only(top: 20.0, left: 10, right: 10),
  74. child: Row(children: [
  75. Expanded(
  76. flex: 1,
  77. child: Text(
  78. 'B侧速度:',
  79. style: TextStyle(
  80. color: Colors.black,
  81. fontSize: GSYConstant.smallTextSize,
  82. fontWeight: FontWeight.bold,
  83. ),
  84. ),
  85. ),
  86. Expanded(
  87. child: Container(
  88. height: 40,
  89. child: TextField(
  90. controller: _speedBController,
  91. decoration: InputDecoration(border: OutlineInputBorder()),
  92. style: TextStyle(fontSize: 14),
  93. onChanged: (value) {
  94. setState(() {
  95. data.speedB=value;
  96. });
  97. },
  98. ),
  99. ),
  100. flex: 3,
  101. ),
  102. ]),
  103. ),
  104. Padding(
  105. padding: const EdgeInsets.only(top: 20.0, left: 10, right: 10),
  106. child: Row(children: [
  107. Expanded(
  108. flex: 1,
  109. child: Text(
  110. 'A侧纤度:',
  111. style: TextStyle(
  112. color: Colors.black,
  113. fontSize: GSYConstant.smallTextSize,
  114. fontWeight: FontWeight.bold,
  115. ),
  116. ),
  117. ),
  118. Expanded(
  119. child: Container(
  120. height: 40,
  121. child: TextField(
  122. controller: _finenessAController,
  123. decoration: InputDecoration(border: OutlineInputBorder()),
  124. style: TextStyle(fontSize: 14),
  125. onChanged: (value) {
  126. setState(() {
  127. data.finenessA=value;
  128. });
  129. },
  130. ),
  131. ),
  132. flex: 3,
  133. ),
  134. ]),
  135. ),
  136. Padding(
  137. padding: const EdgeInsets.only(top: 20.0, left: 10, right: 10),
  138. child: Row(children: [
  139. Expanded(
  140. flex: 1,
  141. child: Text(
  142. 'B侧纤度:',
  143. style: TextStyle(
  144. color: Colors.black,
  145. fontSize: GSYConstant.smallTextSize,
  146. fontWeight: FontWeight.bold,
  147. ),
  148. ),
  149. ),
  150. Expanded(
  151. flex: 3,
  152. child: Container(
  153. height: 40,
  154. child: TextField(
  155. controller: _finenessBController,
  156. decoration: InputDecoration(border: OutlineInputBorder()),
  157. style: TextStyle(fontSize: 14),
  158. onChanged: (value) {
  159. setState(() {
  160. data.finenessB=value;
  161. });
  162. },
  163. ),
  164. ),
  165. ),
  166. ]),
  167. ),
  168. Padding(
  169. padding: const EdgeInsets.only(top: 20.0, left: 10, right: 10),
  170. child: Row(children: [
  171. Expanded(
  172. flex: 1,
  173. child: Text(
  174. 'A侧孔数:',
  175. style: TextStyle(
  176. color: Colors.black,
  177. fontSize: GSYConstant.smallTextSize,
  178. fontWeight: FontWeight.bold,
  179. ),
  180. ),
  181. ),
  182. Expanded(
  183. flex: 3,
  184. child: Container(
  185. height: 40,
  186. child: TextField(
  187. controller: _holeCountAController,
  188. decoration: InputDecoration(border: OutlineInputBorder()),
  189. style: TextStyle(fontSize: 14),
  190. onChanged: (value) {
  191. setState(() {
  192. data.holeCountA=value;
  193. });
  194. },
  195. ),
  196. ),
  197. ),
  198. ]),
  199. ),
  200. Padding(
  201. padding: const EdgeInsets.only(top: 20.0, left: 10, right: 10),
  202. child: Row(children: [
  203. Expanded(
  204. flex: 1,
  205. child: Text(
  206. 'B侧孔数:',
  207. style: TextStyle(
  208. color: Colors.black,
  209. fontSize: GSYConstant.smallTextSize,
  210. fontWeight: FontWeight.bold,
  211. ),
  212. ),
  213. ),
  214. Expanded(
  215. flex: 3,
  216. child: Container(
  217. height: 40,
  218. child: TextField(
  219. controller: _holeCountBController,
  220. decoration: InputDecoration(border: OutlineInputBorder()),
  221. style: TextStyle(fontSize: 14),
  222. onChanged: (value) {
  223. setState(() {
  224. data.holeCountB=value;
  225. });
  226. },
  227. ),
  228. ),
  229. ),
  230. ]),
  231. ),
  232. SizedBox(
  233. height: 30,
  234. ),
  235. _getButton()
  236. ],
  237. ),
  238. ),
  239. );
  240. }
  241. parameter() async {
  242. // LoadingDialogHelper.showLoading(context);
  243. var result = await DioUtil().request("equipment/parameter",
  244. method: DioMethod.post, data: {'id':data.id,'finenessA':data.finenessA,'finenessB':data.finenessB
  245. ,'holeCountA':data.holeCountA,'holeCountB':data.holeCountB,'speedA':data.speedA,'speedB':data.speedB});
  246. // LoadingDialogHelper.dismissLoading(context);
  247. if (result['code']== 0) {
  248. setState(() {
  249. //发出事件
  250. eventBus.fire(Object());
  251. Navigator.pop(context);
  252. });
  253. } else {
  254. showToast(result['msg']);
  255. }
  256. }
  257. @override
  258. void initState() {
  259. super.initState();
  260. _finenessAController=TextEditingController(text: data.finenessA);
  261. _finenessBController=TextEditingController(text: data.finenessB);
  262. _holeCountAController=TextEditingController(text: data.holeCountA);
  263. _holeCountBController=TextEditingController(text: data.holeCountB);
  264. _speedAController=TextEditingController(text: data.speedA);
  265. _speedBController=TextEditingController(text: data.speedB);
  266. }
  267. Widget _getButton() {
  268. return Container(
  269. height: 50,
  270. width: double.infinity,
  271. margin: EdgeInsets.all(10),
  272. decoration: BoxDecoration(
  273. borderRadius: BorderRadius.circular(4.0),
  274. ),
  275. child: GSYFlexButton(
  276. text: ConstantString.updateText,
  277. color: Color(0xFF4875EC),
  278. textColor: GSYColors.textWhite,
  279. fontSize: 16,
  280. onPress: parameter,
  281. ),
  282. );
  283. }
  284. }