Quellcode durchsuchen

发件添加线路id

daxu0403 vor 7 Jahren
Ursprung
Commit
c1948e5c5a
4 geänderte Dateien mit 577 neuen und 402 gelöschten Zeilen
  1. 48 16
      lib/pages/send_express_page.dart
  2. 175 0
      lib/showLineModal.dart
  3. 10 0
      lib/util/api.dart
  4. 344 386
      lib/util/models.dart

+ 48 - 16
lib/pages/send_express_page.dart

@@ -11,6 +11,7 @@ import '../util/models.dart';
 import '../showAlert.dart';
 import '../send_Dialog.dart';
 import '../util/session.dart';
+import '../showLineModal.dart';
 class SendExpressPage extends StatefulWidget {
   final Widget child;
 
@@ -36,6 +37,7 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
   double tipPosY = 0;
 
   bool tipStatus = true;
+  bool lineModalStatus = false;
   bool submitStatus = true;
 
   List < LikePhoneList > likePhoneList = [];
@@ -58,6 +60,7 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
   List < dynamic > goodsCateGoryList = [];
   List < dynamic > goodsPackageList = [];
   //请求字段-------------------------
+  String lineId = '-1';//收件公司匹配的线路id
   String sendCompanyId = '0'; //寄件公司Id
   String sendCompanyName = ''; //寄件公司名称 不能为空
   String sendCompanyPhone = ''; //寄件公司电话 不能为空
@@ -90,6 +93,7 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
   double goodsFreight = 0.0; //商品运费 不能为空
   String memo = ''; //备注
 
+  List<CompanyOfLineList>  lineList = [];
 
   String sendPCA = ' '; //Text组件内容必须有空格,否则报null
   String getPCA = ' ';
@@ -719,9 +723,6 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
         print('goodsFreight---${goodsFreight}');
         print('memo---${memo}');
 
-        // if (!isChinaPhoneLegal(sendCompanyPhone)) {
-
-        // }
         if (sendCompanyPhone == '') {
           errStr = '请填写发件电话';
         }
@@ -765,11 +766,25 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
           showError(errStr);
           return;
         }
-        setState(() {
-          submitStatus = false;
-        });
-        getKey('stationId').then((value) {
+        
+        if(lineList.length==1){
+            lineId = lineList[0].lineId.toString();
+        }else if(lineList.length>1){
+          showLineModal(lineList);
+          return;
+       }
+         submitOrder();
+      },
+    );
+  }
+
+  submitOrder(){
+     setState(() {
+      submitStatus = false;
+    });
+    getKey('stationId').then((value) {
           createOrder(
+            lineId,
             value,
             sendCompanyId, //寄件公司Id
             sendCompanyName, //寄件公司名称 不能为空
@@ -831,10 +846,7 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
             }
           });
         });
-      },
-    );
   }
-
   showError(String str) {
     showDialog < Null > (
       context: context, //BuildContext对象
@@ -845,6 +857,19 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
         );
       });
   }
+  showLineModal(List<CompanyOfLineList> list){
+    showDialog < Null > (
+      context: context, //BuildContext对象
+      barrierDismissible: false,
+      builder: (BuildContext context) {
+        return ShowLineModal( 
+          lineList: list, childCallback: (val) {
+              lineId = val;
+             submitOrder();
+          },
+        );
+      });
+  }
 
   Future getCity(context) async {
     Result result = await CityPickers.showCityPicker(
@@ -866,7 +891,7 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
                   children: < Widget > [
                     Padding(
                       padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(50)),
-                      child: Text(obj.uzerPhone, style: TextStyle(
+                      child: Text(obj.uzerPhone!=null?obj.uzerPhone:obj.companyPhone, style: TextStyle(
                         fontSize: ScreenUtil.getInstance().setSp(28),
                         color: Color.fromRGBO(74, 74, 74, 1)
                       ), )
@@ -894,11 +919,11 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
             ),
             onTap: () {
               if (sendPhoneOrGetPhoneTab) {
-                sendCompanyPhone = obj.uzerPhone;
+                sendCompanyPhone = obj.uzerPhone!=null?obj.uzerPhone:obj.companyPhone;
                 sendCompanyCode = obj.companyCode;
                 sendCompanyName = obj.companyName;
                 sendCompanyId = obj.id.toString();
-                sendCompanyPhoneController.text = obj.uzerPhone;
+                sendCompanyPhoneController.text = obj.uzerPhone!=null?obj.uzerPhone:obj.companyPhone;
                 sendCompanyCodeController.text = obj.companyCode;
                 sendCompanyNameController.text = obj.companyName;
 
@@ -912,12 +937,19 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
 
                 sendCompanyAddressController.text = obj.address;
               } else {
-                receiptCompanyPhone = obj.uzerPhone;
+                receiptCompanyPhone = obj.uzerPhone!=null?obj.uzerPhone:obj.companyPhone;
                 receiptCompanyName = obj.companyName;
-                receiptCompanyPhoneController.text = obj.uzerPhone;
+                receiptCompanyPhoneController.text = obj.uzerPhone!=null?obj.uzerPhone:obj.companyPhone;
                 receiptCompanyNameController.text = obj.companyName;
                 receiptCompanyId = obj.id.toString();
-
+                getLineOfCompanyId(receiptCompanyId).then((resp){
+                  if(isNotError(context, resp)){
+                    CompanyOfLine obj = CompanyOfLine.fromJson(resp.data);
+                    setState(() {
+                        lineList = obj.data;
+                    });
+                  }
+                });
                 getPCA = obj.provinceName + ' ' + obj.cityName + ' ' + ' ' + obj.areaName;
                 receiptCompanyProvinceName = obj.provinceName;
                 receiptCompanyProvinceCode = obj.provinceCode;

+ 175 - 0
lib/showLineModal.dart

@@ -0,0 +1,175 @@
+import 'package:flutter/material.dart';
+import 'package:flutter_screenutil/flutter_screenutil.dart';
+import 'util/models.dart';
+
+// ignore: must_be_immutable
+class ShowLineModal extends Dialog {
+  List<CompanyOfLineList> lineList = [];
+  final childCallback;
+
+  ShowLineModal(
+      {Key key, @required this.lineList, @required this.childCallback})
+      : super(key: key);
+
+  String lineId = '-1';
+
+  @override
+  Widget build(BuildContext context) {
+    return new Material(
+      //创建透明层
+      type: MaterialType.transparency, //透明类型
+      child: new Center(
+        //保证控件居中效果
+        child: Container(
+          width: ScreenUtil.getInstance().setWidth(600),
+          height: ScreenUtil.getInstance().setHeight(345),
+          decoration: BoxDecoration(
+              color: Colors.white,
+              borderRadius: BorderRadius.all(Radius.circular(8))),
+          child: new Container(
+            child: new Column(
+              children: <Widget>[
+                Container(
+                    height: ScreenUtil.getInstance().setHeight(255),
+                    decoration: BoxDecoration(
+                        border: Border(
+                            bottom: BorderSide(
+                                width: 1,
+                                color: Color.fromRGBO(151, 151, 151, 0.27)))),
+                    child: LineWidget(
+                      lineList: lineList,
+                      callback: (val) {
+                        lineId = val.toString();
+                      },
+                    )),
+                Expanded(
+                    flex: 1,
+                    child: Container(
+                      child: Row(
+                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
+                        children: <Widget>[
+                          Expanded(
+                              flex: 1,
+                              child: InkWell(
+                                child: Container(
+                                    decoration: BoxDecoration(
+                                      border: Border(
+                                          right: BorderSide(
+                                              width: 1,
+                                              color: Color.fromRGBO(
+                                                  151, 151, 151, 0.27))),
+                                    ),
+                                    child: Center(
+                                      child: Text(
+                                        '取消',
+                                        style: TextStyle(
+                                            fontSize: ScreenUtil.getInstance()
+                                                .setSp(32),
+                                            color:
+                                                Color.fromRGBO(64, 98, 254, 1)),
+                                      ),
+                                    )),
+                                onTap: () {
+                                  Navigator.pop(context);
+                                },
+                              )),
+                          Expanded(
+                              flex: 1,
+                              child: InkWell(
+                                child: Container(
+                                    decoration: BoxDecoration(
+                                      border: Border(
+                                          right: BorderSide(
+                                              width: 1,
+                                              color: Color.fromRGBO(
+                                                  151, 151, 151, 0.27))),
+                                    ),
+                                    child: Center(
+                                      child: Text(
+                                        '确定',
+                                        style: TextStyle(
+                                            fontSize: ScreenUtil.getInstance()
+                                                .setSp(32),
+                                            color:
+                                                Color.fromRGBO(64, 98, 254, 1)),
+                                      ),
+                                    )),
+                                onTap: () {
+                                  Navigator.pop(context);
+                                  childCallback(lineId);
+                                },
+                              )),
+                        ],
+                      ),
+                    ))
+              ],
+            ),
+          ),
+        ),
+      ),
+    );
+  }
+}
+
+class LineWidget extends StatefulWidget {
+  final List<CompanyOfLineList> lineList;
+  final callback;
+
+  LineWidget({Key key, this.lineList, this.callback}) : super(key: key);
+
+  _LineWidgetState createState() => _LineWidgetState();
+}
+
+class _LineWidgetState extends State<LineWidget> {
+  @override
+  Widget build(BuildContext context) {
+    return Column(
+      children: <Widget>[
+        Container(
+          height: ScreenUtil.getInstance().setHeight(60),
+          child:Center(
+          child: Text('请选择线路'),
+        ),
+        ),
+        
+        Expanded(
+          flex: 1,
+          child: ListView.builder(
+            itemCount: widget.lineList.length,
+            itemBuilder: (BuildContext context, int index) {
+              return InkWell(
+                child: Container(
+                  height: ScreenUtil.getInstance().setHeight(100),
+                  padding: EdgeInsets.fromLTRB(30, 0, 30, 0),
+                  child: Row(
+                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
+                    children: <Widget>[
+                      Text(
+                        widget.lineList[index].lineName,
+                        style: TextStyle(
+                            fontSize: ScreenUtil.getInstance().setSp(35)),
+                      ),
+                       Icon(Icons.check,color: widget.lineList[index].checkedStatus?Colors.black:Colors.white,)
+                    ],
+                  ),
+                ),
+                onTap: (){
+                  setState(() {
+                    for(int i=0;i<widget.lineList.length;i++){
+                      if(i==index){
+                        widget.lineList[i].checkedStatus = true;
+                        widget.callback(widget.lineList[i].lineId);
+                      }else{
+                        widget.lineList[i].checkedStatus = false;
+                      }
+                    }
+                  });
+                },
+              );
+            },
+          ),
+        )
+      ],
+    );
+  }
+}

+ 10 - 0
lib/util/api.dart

@@ -51,6 +51,7 @@ Future updataPasswrod(oldPassword, newPassword) async {
 
 //发件(创建订单)
 Future createOrder(
+  String lineId,
   String statiodId,//司机站点id
   String sendCompanyId, //寄件公司Id
   String sendCompanyName, //寄件公司名称 不能为空
@@ -85,6 +86,7 @@ Future createOrder(
   String memo //备注
 ) async {
   var response = await Http().post('app/order/logistics_order_create', data: {
+    'lineId':lineId,
     'stationId':statiodId,
     'sendCompanyId': sendCompanyId,
     'sendCompanyName': sendCompanyName,
@@ -194,4 +196,12 @@ Future orderNoLike(String orderNo,int orderStatus) {
     'orderStatus':orderStatus
   });
   return response;
+}
+
+//根据公司id取得线路
+Future getLineOfCompanyId(String companyId){
+  var response = Http().get('app/company/line/relation/company_line_relation_list', data: {
+    'companyId': companyId,
+  });
+    return response;
 }

Datei-Diff unterdrückt, da er zu groß ist
+ 344 - 386
lib/util/models.dart