daxu0403 7 лет назад
Родитель
Сommit
b51d8571b1
1 измененных файлов с 228 добавлено и 93 удалено
  1. 228 93
      lib/pages/send_express_page.dart

+ 228 - 93
lib/pages/send_express_page.dart

@@ -1,6 +1,7 @@
 import 'package:flutter/material.dart';
 import 'package:flutter_screenutil/flutter_screenutil.dart';
 import 'package:city_pickers/city_pickers.dart';
+import 'package:flutter_picker/flutter_picker.dart';
 
 class SendExpressPage extends StatefulWidget {
   final Widget child;
@@ -15,14 +16,12 @@ class SendExpressPage extends StatefulWidget {
 
 class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeepAliveClientMixin {
 
-
   ScrollController _scrollController = ScrollController();
+
+  //组件自用字段-----------------------------
   GlobalKey _sendPhoneKey = GlobalKey();
   GlobalKey _getPhoneKey = GlobalKey();
 
-  String _sendPhoneStr = '';
-  String _getPhoneStr = '';
-
   double tipWidth = 0;
   double tipHeight = 0;
   double tipPosX = 0;
@@ -30,6 +29,42 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
 
   bool tipStatus = true;
 
+  //请求字段-------------------------
+  int sendCompanyId; //寄件公司Id
+  String sendCompanyName; //寄件公司名称 不能为空
+  String sendCompanyPhone; //寄件公司电话 不能为空
+  String sendCompanyCode; //寄件公司编码 不能为空
+  String sendCompanyProvinceName; //寄件公司省名称 不能为空
+  String sendCompanyProvinceCode; //寄件公司省编码 不能为空
+  String sendCompanyCityName; //寄件公司市名称 不能为空
+  String sendCompanyCityCode; //寄件公司市编码 不能为空
+  String sendCompanyAreaName; //寄件公司区名称 不能为空
+  String sendCompanyAreaCode; //寄件公司区编码 不能为空
+  String sendCompanyAddress; //寄件公司详细地址,不能为空
+  int receiptCompanyId; //收件公司id
+  String receiptCompanyPhone; //收件公司电话 不能为空
+  String receiptCompanyName; //收件公司名称 不能为空
+  String receiptCompanyProvinceName; //收件公司省名称 不能为空
+  String receiptCompanyProvinceCode; //收件公司省编码 不能为空
+  String receiptCompanyCityName; //收件公司市名称 不能为空
+  String receiptCompanyCityCode; //收件公市编码 不能为空
+  String receiptCompanyAreaName; //收件公区名称 不能为空
+  String receiptCompanyAreaCode; //收件公司区编码 不能为空
+  String receiptCompanyAddress; //收件公司地址详情 不能为空
+  String goods; //商品名称不能为空
+  int goodsQuantity; //商品数量 不能为空
+  int goodsPackingId; //商品包装ID 
+  int goodsCategoryId; //商品包装类别ID 
+  int goodsPaymentMethod; //付款方式
+  double goodsWeight; //商品重量 
+  double goodsPriceProtection; //商品保价
+  double goodsAgencyFund; //商品代收款
+  String memo; //备注
+
+
+  String sendPCA = ' ';//Text组件内容必须有空格,否则报null
+  String getPCA = ' ';
+
   @override
   void initState() {
     super.initState();
@@ -47,39 +82,6 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
   @override
   bool get wantKeepAlive => true;
 
-  final Map < Object,
-    String > sendInfo = {
-      "icon": 'lib/images/icon_send.png',
-      "title": "发件信息",
-      "phone": "010-8788 6890",
-      "code": "345678",
-      "name": "朝阳门大阳汽贸",
-      "address": "",
-      "addressDetail": "朝阳门外大街28号"
-    };
-
-  final Map < Object,
-    String > getInfo = {
-      "icon": 'lib/images/icon_shoujian.png',
-      "title": "收件信息",
-      "name": "香河汽修厂",
-      "phone": "010-6734 3426",
-      "address": "",
-      "addressDetail": "香河县东大街29号院18栋3单元206"
-    };
-
-  Map < String,
-    String > _itemInfo = {
-      "icon": "lib/images/icon_huowu.png",
-      "title": "货物信息",
-      "itemName": "汽车轮胎",
-      "itemNo": "4",
-      "expressPrice": "15",
-      "collectionPrice": "15800",
-      "supportPrice": "5000",
-      "weight": "600",
-      "itemDesc": "轮胎请核对数量轮胎请"
-    };
   @override
   Widget build(BuildContext context) {
     return Container(
@@ -89,14 +91,6 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
           title: Text('发件', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(36)), ),
           centerTitle: true,
           backgroundColor: Color.fromRGBO(64, 98, 254, 1),
-          // leading: GestureDetector(
-          //   child: Icon(Icons.arrow_back),
-          //   onTap: (){
-          //      Navigator.pushReplacement(context, MaterialPageRoute(builder: (context){
-          //       return HomePage();
-          //     }));
-          //   },
-          // ),
         ),
         body:
         Stack(
@@ -107,9 +101,9 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
               child: ListView(
                 controller: _scrollController,
                 children: < Widget > [
-                  _sendInfo(sendInfo, context),
-                  _getInfo(getInfo),
-                  _itemInfoWidget(_itemInfo),
+                  _sendInfo(context),
+                  _getInfo(context),
+                  _itemInfoWidget(),
                   _submitBtn()
                 ],
               ),
@@ -142,57 +136,59 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
     );
   }
 
-  Widget _sendInfo(Map str, BuildContext context) {
+  Widget _sendInfo(BuildContext context) {
     return Container(
       color: Colors.white,
       margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
       child: Column(
         children: < Widget > [
-          _titleWidget(str['icon'], str['title']),
+          _titleWidget('lib/images/icon_send.png', '发件信息'),
           _underLine(),
           _inputWiget('电话', 'sendPhone'),
-          _contentWiget('企业编码', str['code'],true),
-          _contentWiget('企业名称', str['name'],true),
-          _cityWiget('城市/区域', str['address'], context),
-          _lastContentWiget('详细地址', str['addressDetail'])
+          _contentWiget('企业编码', 'send', true),
+          _contentWiget('企业名称', 'send', true),
+          _cityWiget('城市/区域', context, 'send'),
+          _lastContentWiget('详细地址', 'send')
         ],
       )
     );
   }
 
-  Widget _getInfo(Map str) {
+  Widget _getInfo(BuildContext context) {
     return Container(
       color: Colors.white,
       margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
       child: Column(
         children: < Widget > [
-          _titleWidget(str['icon'], str['title']),
+          _titleWidget('lib/images/icon_shoujian.png', '收件信息'),
           _underLine(),
-          _contentWiget('企业名称', str['name'],true),
           _inputWiget('电话', 'getPhone'),
-          _cityWiget('城市/区域', str['address'], context),
-          _lastContentWiget('详细地址', str['addressDetail'])
+          //_contentWiget('企业编码', 'get', true),
+          _contentWiget('企业名称', 'get', true),
+          _cityWiget('城市/区域', context, 'get'),
+          _lastContentWiget('详细地址', 'get')
         ],
       )
     );
   }
 
-  Widget _itemInfoWidget(Map _itemInfo) {
+  Widget _itemInfoWidget() {
     return Container(
       child: Container(
         color: Colors.white,
         child: Column(
           crossAxisAlignment: CrossAxisAlignment.start,
           children: < Widget > [
-            _titleWidget(_itemInfo['icon'], "货物信息"),
+            _titleWidget('lib/images/icon_huowu.png', "货物信息"),
             _underLine(),
-            _contentWiget("货物名称", _itemInfo["itemName"],true),
-            _contentWiget("数量", _itemInfo["itemNo"]),
-            _contentWiget("运费", _itemInfo["expressPrice"]),
-            _contentWiget("代收", _itemInfo["collectionPrice"]),
-            _contentWiget("保价", _itemInfo["supportPrice"]),
-            _contentWiget("重量", _itemInfo["weight"]),
-            _descWidget(_itemInfo['itemDesc'])
+            _contentWiget("货物名称", 'goods', true),
+            _contentWiget("数量", 'goods'),
+            _contentWiget("运费", 'goods'),
+            _contentWiget("代收", 'goods'),
+            _contentWiget("保价", 'goods'),
+            _contentWiget("重量", 'goods'),
+            _packageType(),
+            _descWidget()
           ],
         ),
       )
@@ -244,7 +240,7 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
                 children: < Widget > [
                   Expanded(
                     flex: 0,
-                    child: Text('${key}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
+                    child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
                   ),
                   Expanded(
                     child: Row(
@@ -261,7 +257,7 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
                             ),
                             onChanged: ((value) {
                               if (tab == 'sendPhone') {
-                                if(value.length>=4){
+                                if (value.length >= 4) {
                                   RenderObject sendPhoneObj = _sendPhoneKey.currentContext.findRenderObject();
                                   setState(() {
                                     tipWidth = sendPhoneObj.paintBounds.size.width;
@@ -270,18 +266,18 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
                                     tipPosY = sendPhoneObj.getTransformTo(null).getTranslation().y - ScreenUtil.getInstance().setHeight(90);
                                     tipStatus = false;
                                   });
-                                }else{
+                                } else {
                                   setState(() {
                                     tipStatus = true;
                                   });
                                 }
-                                
+
                                 // print(tipWidth);
                                 // print(tipHeight);
                                 // print(tipPosX);
                                 // print(tipPosY);
                               } else if (tab == 'getPhone') {
-                                if(value.length>=4){
+                                if (value.length >= 4) {
                                   RenderObject sendPhoneObj = _getPhoneKey.currentContext.findRenderObject();
                                   setState(() {
                                     tipWidth = sendPhoneObj.paintBounds.size.width;
@@ -290,12 +286,12 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
                                     tipPosY = sendPhoneObj.getTransformTo(null).getTranslation().y - ScreenUtil.getInstance().setHeight(90);
                                     tipStatus = false;
                                   });
-                                }else{
+                                } else {
                                   setState(() {
                                     tipStatus = true;
                                   });
                                 }
-                                
+
                                 // print(tipWidth);
                                 // print(tipHeight);
                                 // print(tipPosX);
@@ -311,7 +307,6 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
 
                           ),
                         ),
-
                         Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
                       ],
                     )
@@ -330,7 +325,7 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
   }
 
 
-  Widget _contentWiget(String key, String value,[bool keyboardType=false]) {//false是数字键盘
+  Widget _contentWiget(String key, String type, [bool keyboardType = false]) { //false是数字键盘
     return Padding(
       padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
       child: Column(
@@ -343,21 +338,57 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
                 children: < Widget > [
                   Expanded(
                     flex: 0,
-                    child: Text('${key}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
+                    child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
                   ),
                   Expanded(
                     child: Row(
                       mainAxisAlignment: MainAxisAlignment.end,
                       children: < Widget > [
-                        //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
                         SizedBox(
                           width: ScreenUtil.getInstance().setWidth(500),
                           child: TextField(
-                            keyboardType:keyboardType?TextInputType.text:TextInputType.number,
+                            keyboardType: keyboardType ? TextInputType.text : TextInputType.number,
                             textAlign: TextAlign.end,
                             decoration: InputDecoration(
                               border: InputBorder.none
                             ),
+                            onChanged: (value) {
+                              if (type == 'send') {
+                                if (key == '企业编码') {
+                                  setState(() {
+                                    sendCompanyCode = value;
+                                  });
+                                } else if (key == '企业名称') {
+                                  setState(() {
+                                    sendCompanyName = value;
+                                  });
+                                }
+                              } else if (type == 'get') {
+                                if (key == '企业编码') {
+                                  setState(() {
+                                    sendCompanyCode = value;
+                                  });
+                                } else if (key == '企业名称') {
+                                  setState(() {
+                                    receiptCompanyName = value;
+                                  });
+                                }
+                              } else {
+                                if (key == '货物名称') {
+                                  goods = value;
+                                } else if (key == '数量') {
+                                  goodsQuantity = int.parse(value);
+                                } else if (key == '运费') {
+
+                                } else if (key == '代收') {
+                                  goodsAgencyFund = double.parse(value);
+                                } else if (key == '保价') {
+                                  goodsPriceProtection = double.parse(value);
+                                } else if (key == '重量') {
+                                  goodsWeight = double.parse(value);
+                                }
+                              }
+                            },
                           ),
                         ),
 
@@ -378,7 +409,8 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
     );
   }
 
-  Widget _cityWiget(String key, String value, BuildContext context) {
+  Widget _cityWiget(String key, BuildContext context, String type) {
+
     return
     GestureDetector(
       child: Padding(
@@ -393,7 +425,7 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
                   children: < Widget > [
                     Expanded(
                       flex: 0,
-                      child: Text('${key}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
+                      child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
                     ),
                     Expanded(
                       child: Row(
@@ -402,7 +434,7 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
                           //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
                           SizedBox(
                             width: ScreenUtil.getInstance().setWidth(500),
-                            child: Text(value, textAlign: TextAlign.end, overflow: TextOverflow.ellipsis, )
+                            child: Text(type == 'send' ? sendPCA : getPCA, textAlign: TextAlign.end, overflow: TextOverflow.ellipsis, )
                           ),
                           Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
                         ],
@@ -424,16 +456,34 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
           if (resp == null) {
             return;
           }
+          print(resp.toString());
           setState(() {
-            sendInfo['address'] = resp.provinceName + ' ' + resp.cityName + ' ' + ' ' + resp.areaName;
+            if (type == 'send') {
+              sendPCA = resp.provinceName + ' ' + resp.cityName + ' ' + ' ' + resp.areaName;
+              sendCompanyProvinceName = resp.provinceName;
+              sendCompanyProvinceCode = resp.provinceId;
+              sendCompanyCityName = resp.cityName;
+              sendCompanyCityCode = resp.cityId;
+              sendCompanyAreaName = resp.areaName;
+              sendCompanyAreaCode = resp.areaId;
+            } else {
+              getPCA = resp.provinceName + ' ' + resp.cityName + ' ' + ' ' + resp.areaName;
+              receiptCompanyProvinceName = resp.provinceName;
+              receiptCompanyProvinceCode = resp.provinceId;
+              receiptCompanyCityName = resp.cityName;
+              receiptCompanyCityCode = resp.cityId;
+              receiptCompanyAreaName = resp.areaName;
+              receiptCompanyAreaCode = resp.areaId;
+            }
           });
+
           //print(value);
         });
       },
     );
   }
 
-  Widget _lastContentWiget(String key, String value) {
+  Widget _lastContentWiget(String key, String type) {
     return Padding(
       padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
       child: SizedBox(
@@ -444,7 +494,7 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
             children: < Widget > [
               Expanded(
                 flex: 0,
-                child: Text('${key}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
+                child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
               ),
               Expanded(
                 child: Row(
@@ -459,6 +509,17 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
                         decoration: InputDecoration(
                           border: InputBorder.none
                         ),
+                        onChanged: (value) {
+                          if (type == 'send') {
+                            setState(() {
+                              sendCompanyAddress = value;
+                            });
+                          } else {
+                            setState(() {
+                              receiptCompanyAddress = value;
+                            });
+                          }
+                        },
                       ),
                     ),
 
@@ -473,7 +534,7 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
     );
   }
 
-  Widget _descWidget(String str) {
+  Widget _descWidget() {
     return
     Container(
       padding: EdgeInsets.all(ScreenUtil.getInstance().setWidth(30)),
@@ -484,6 +545,11 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
           border: InputBorder.none,
           hintText: "请输入备注内容"
         ),
+        onChanged: (value) {
+          setState(() {
+            memo = value;
+          });
+        },
       ),
     );
   }
@@ -533,18 +599,18 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
                   SizedBox(
                     width: ScreenUtil.getInstance().setWidth(185),
                     child: Text('WX11042',
-                    textAlign: TextAlign.left,
-                    style: TextStyle(
-                      fontSize: ScreenUtil.getInstance().setSp(28),
-                      color: Color.fromRGBO(155,155,155,1)
-                    ),),
+                      textAlign: TextAlign.left,
+                      style: TextStyle(
+                        fontSize: ScreenUtil.getInstance().setSp(28),
+                        color: Color.fromRGBO(155, 155, 155, 1)
+                      ), ),
                   ),
                   Text('天华盛业',
                     textAlign: TextAlign.left,
                     overflow: TextOverflow.ellipsis,
                     style: TextStyle(
                       fontSize: ScreenUtil.getInstance().setSp(28),
-                       color: Color.fromRGBO(155,155,155,1)
+                      color: Color.fromRGBO(155, 155, 155, 1)
                     ),
                   )
                 ],
@@ -556,4 +622,73 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
       ),
     );
   }
+
+  Widget _packageType() {
+    return Padding(
+      padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
+      child: Column(
+        children: < Widget > [
+          InkWell(
+            child: SizedBox(
+              height: ScreenUtil.getInstance().setHeight(89),
+              child: Center(
+                child: Row(
+                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
+                  children: < Widget > [
+                    Expanded(
+                      flex: 0,
+                      child: Text('包装类型', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
+                    ),
+                    Expanded(
+                      child: Row(
+                        mainAxisAlignment: MainAxisAlignment.end,
+                        children: < Widget > [
+                          //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
+                          SizedBox(
+                            width: ScreenUtil.getInstance().setWidth(500),
+                            child: Text('纸箱', textAlign: TextAlign.end, )
+                          ),
+                          Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
+                        ],
+                      )
+                    )
+                  ],
+                ),
+              )
+            ),
+            onTap: () {
+              showPickerModal(context);
+            },
+          ),
+          Expanded(
+            flex: 0,
+            child: _underLine()
+          )
+        ],
+      )
+    );
+
+  }
+
+  showPickerModal(BuildContext context) {
+    new Picker(
+      adapter: PickerDataAdapter < String > (pickerdata: ['纸箱', '木箱']),
+      height: ScreenUtil.getInstance().setHeight(450),
+      confirmText: '确定',
+      confirmTextStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(64, 98, 254, 1)),
+      cancelText: '取消',
+      cancelTextStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(153, 153, 153, 1)),
+      headercolor: Color.fromRGBO(245, 245, 245, 1),
+      itemExtent: ScreenUtil.getInstance().setHeight(80),
+      textStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(42, 42, 42, 1)),
+      changeToFirst: true,
+      hideHeader: false,
+      onConfirm: (Picker picker, List value) {
+        // setState(() {
+        //   _siteName = stationObj.data[value[0]].name;
+        // });
+        // setKey('stationId', stationObj.data[value[0]].id.toString());
+      }
+    ).showModal(this.context); //_scaffoldKey.currentState);
+  }
 }