device_manage_update_page.dart 9.9 KB

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