| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300 |
- import 'package:deus_app/common/style/TitleBar.dart';
- import 'package:deus_app/common/style/gsy_style.dart';
- import 'package:deus_app/common/utils/ConstantString.dart';
- import 'package:deus_app/common/utils/DioUtil.dart';
- import 'package:deus_app/common/utils/ToastUtils.dart';
- import 'package:deus_app/model/equipment_info_entity.dart';
- import 'package:deus_app/widget/gsy_flex_button.dart';
- import 'package:event_bus/event_bus.dart';
- import 'package:flutter/material.dart';
- class DeviceManageUpdatePage extends StatefulWidget {
- final EquipmentInfoData data;
- const DeviceManageUpdatePage({super.key, required this.data});
- @override
- State createState() {
- return _DeviceManageUpdatePage(data);
- }
- }
- //创建EventBus对象
- final EventBus eventBus = EventBus();
- class _DeviceManageUpdatePage extends State<DeviceManageUpdatePage>{
- EquipmentInfoData data;
- _DeviceManageUpdatePage(this.data);
- TextEditingController _finenessAController= TextEditingController();
- TextEditingController _finenessBController= TextEditingController();
- TextEditingController _holeCountAController= TextEditingController();
- TextEditingController _holeCountBController= TextEditingController();
- TextEditingController _speedAController= TextEditingController();
- TextEditingController _speedBController= TextEditingController();
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: TitleBar().backAppbar(context, "修改参数"),
- backgroundColor: const Color(0xfff2f2f2),
- body: SingleChildScrollView (
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- children:<Widget> [
- Padding(
- padding: const EdgeInsets.only(top: 50.0, left: 10, right: 10),
- child: Row(children: [
- Expanded(
- flex: 1,
- child: Text(
- 'A测速度:',
- style: TextStyle(
- color: Colors.black,
- fontSize: GSYConstant.smallTextSize,
- fontWeight: FontWeight.bold,
- ),
- ),
- ),
- Expanded(
- child: Container(
- height: 40,
- child: TextField(
- decoration: InputDecoration(
- border: OutlineInputBorder(),
- ),
- controller: _speedAController,
- style: TextStyle(fontSize: 14),
- onChanged: (value) {
- setState(() {
- data.speedA=value;
- });
- },
- ),
- ),
- flex: 3,
- ),
- ]),
- ),
- Padding(
- padding: const EdgeInsets.only(top: 20.0, left: 10, right: 10),
- child: Row(children: [
- Expanded(
- flex: 1,
- child: Text(
- 'B侧速度:',
- style: TextStyle(
- color: Colors.black,
- fontSize: GSYConstant.smallTextSize,
- fontWeight: FontWeight.bold,
- ),
- ),
- ),
- Expanded(
- child: Container(
- height: 40,
- child: TextField(
- controller: _speedBController,
- decoration: InputDecoration(border: OutlineInputBorder()),
- style: TextStyle(fontSize: 14),
- onChanged: (value) {
- setState(() {
- data.speedB=value;
- });
- },
- ),
- ),
- flex: 3,
- ),
- ]),
- ),
- Padding(
- padding: const EdgeInsets.only(top: 20.0, left: 10, right: 10),
- child: Row(children: [
- Expanded(
- flex: 1,
- child: Text(
- 'A侧纤度:',
- style: TextStyle(
- color: Colors.black,
- fontSize: GSYConstant.smallTextSize,
- fontWeight: FontWeight.bold,
- ),
- ),
- ),
- Expanded(
- child: Container(
- height: 40,
- child: TextField(
- controller: _finenessAController,
- decoration: InputDecoration(border: OutlineInputBorder()),
- style: TextStyle(fontSize: 14),
- onChanged: (value) {
- setState(() {
- data.finenessA=value;
- });
- },
- ),
- ),
- flex: 3,
- ),
- ]),
- ),
- Padding(
- padding: const EdgeInsets.only(top: 20.0, left: 10, right: 10),
- child: Row(children: [
- Expanded(
- flex: 1,
- child: Text(
- 'B侧纤度:',
- style: TextStyle(
- color: Colors.black,
- fontSize: GSYConstant.smallTextSize,
- fontWeight: FontWeight.bold,
- ),
- ),
- ),
- Expanded(
- flex: 3,
- child: Container(
- height: 40,
- child: TextField(
- controller: _finenessBController,
- decoration: InputDecoration(border: OutlineInputBorder()),
- style: TextStyle(fontSize: 14),
- onChanged: (value) {
- setState(() {
- data.finenessB=value;
- });
- },
- ),
- ),
- ),
- ]),
- ),
- Padding(
- padding: const EdgeInsets.only(top: 20.0, left: 10, right: 10),
- child: Row(children: [
- Expanded(
- flex: 1,
- child: Text(
- 'A侧孔数:',
- style: TextStyle(
- color: Colors.black,
- fontSize: GSYConstant.smallTextSize,
- fontWeight: FontWeight.bold,
- ),
- ),
- ),
- Expanded(
- flex: 3,
- child: Container(
- height: 40,
- child: TextField(
- controller: _holeCountAController,
- decoration: InputDecoration(border: OutlineInputBorder()),
- style: TextStyle(fontSize: 14),
- onChanged: (value) {
- setState(() {
- data.holeCountA=value;
- });
- },
- ),
- ),
- ),
- ]),
- ),
- Padding(
- padding: const EdgeInsets.only(top: 20.0, left: 10, right: 10),
- child: Row(children: [
- Expanded(
- flex: 1,
- child: Text(
- 'B侧孔数:',
- style: TextStyle(
- color: Colors.black,
- fontSize: GSYConstant.smallTextSize,
- fontWeight: FontWeight.bold,
- ),
- ),
- ),
- Expanded(
- flex: 3,
- child: Container(
- height: 40,
- child: TextField(
- controller: _holeCountBController,
- decoration: InputDecoration(border: OutlineInputBorder()),
- style: TextStyle(fontSize: 14),
- onChanged: (value) {
- setState(() {
- data.holeCountB=value;
- });
- },
- ),
- ),
- ),
- ]),
- ),
- SizedBox(
- height: 30,
- ),
- _getButton()
- ],
- ),
- ),
- );
- }
- parameter() async {
- // LoadingDialogHelper.showLoading(context);
- var result = await DioUtil().request("equipment/parameter",
- method: DioMethod.post, data: {'id':data.id,'finenessA':data.finenessA,'finenessB':data.finenessB
- ,'holeCountA':data.holeCountA,'holeCountB':data.holeCountB,'speedA':data.speedA,'speedB':data.speedB});
- // LoadingDialogHelper.dismissLoading(context);
- if (result['code']== 0) {
- setState(() {
- //发出事件
- eventBus.fire(Object());
- Navigator.pop(context);
- });
- } else {
- showToast(result['msg']);
- }
- }
- @override
- void initState() {
- super.initState();
- _finenessAController=TextEditingController(text: data.finenessA);
- _finenessBController=TextEditingController(text: data.finenessB);
- _holeCountAController=TextEditingController(text: data.holeCountA);
- _holeCountBController=TextEditingController(text: data.holeCountB);
- _speedAController=TextEditingController(text: data.speedA);
- _speedBController=TextEditingController(text: data.speedB);
- }
- Widget _getButton() {
- return Container(
- height: 50,
- width: double.infinity,
- margin: EdgeInsets.all(10),
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(4.0),
- ),
- child: GSYFlexButton(
- text: ConstantString.updateText,
- color: Color(0xFF4875EC),
- textColor: GSYColors.textWhite,
- fontSize: 16,
- onPress: parameter,
- ),
- );
- }
- }
|