Bläddra i källkod

改单添加线路Id

daxu0403 7 år sedan
förälder
incheckning
ffb48d114b

+ 64 - 33
lib/pages/order_detail/order_detail.dart

@@ -4,6 +4,7 @@ import '../../util/api.dart';
 import '../../util/models.dart';
 import '../../util/util.dart';
 import '../../showAlert.dart';
+import '../../showLineModal.dart';
 class OrderDetailsPage extends StatefulWidget {
   final String orderNo;
 
@@ -18,7 +19,6 @@ class OrderDetailsPage extends StatefulWidget {
 class _OrderDetailsPageState extends State < OrderDetailsPage > {
 
   OrderDetailData orderDetailObj;
-
   @override
   void initState() {
     super.initState();
@@ -110,6 +110,8 @@ class _ItemInfoWidgetState extends State < ItemInfoWidget > {
   int afterGoodsNumber=0;//数量
   double afterCollectingFee=0.0;//代收
   bool submitStatus = true;
+  String lineId = '-1';
+   List<CompanyOfLineList>  lineList = [];
   @override
   void initState() {
     super.initState();
@@ -118,7 +120,14 @@ class _ItemInfoWidgetState extends State < ItemInfoWidget > {
        afterGoodsNumber =widget.obj.goodsQuantity;
        afterCollectingFee =widget.obj.goodsAgencyFund/100;
     });
-   
+    getLineOfCompanyId(widget.obj.sendCompanyId.toString()).then((resp){
+     if(isNotError(context, resp)){
+        CompanyOfLine obj = CompanyOfLine.fromJson(resp.data);
+        setState(() {
+            lineList = obj.data;
+        });
+      }
+    });
   }
 
   @override
@@ -220,37 +229,61 @@ class _ItemInfoWidgetState extends State < ItemInfoWidget > {
   }
 
   Widget submitBtn(String orderNo) {
-  return GestureDetector(
-    child: Container(
-      margin: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(50), ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(40)),
-      height: ScreenUtil.getInstance().setHeight(88),
-      decoration: BoxDecoration(
-        borderRadius: BorderRadius.all(Radius.circular(4)),
-        color: Color.fromRGBO(37, 102, 242, 1),
-      ),
-      child: Center(
-       child:Row(
-          mainAxisAlignment: MainAxisAlignment.center,
-          children: <Widget>[
-              Offstage(
-                offstage: submitStatus,
-                child: SizedBox(
-                  width: ScreenUtil.getInstance().setWidth(45),
-                  height: ScreenUtil.getInstance().setHeight(45),
-                  child: Image.asset('lib/images/loading.gif'),
+    return GestureDetector(
+      child: Container(
+        margin: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(50), ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(40)),
+        height: ScreenUtil.getInstance().setHeight(88),
+        decoration: BoxDecoration(
+          borderRadius: BorderRadius.all(Radius.circular(4)),
+          color: Color.fromRGBO(37, 102, 242, 1),
+        ),
+        child: Center(
+        child:Row(
+            mainAxisAlignment: MainAxisAlignment.center,
+            children: <Widget>[
+                Offstage(
+                  offstage: submitStatus,
+                  child: SizedBox(
+                    width: ScreenUtil.getInstance().setWidth(45),
+                    height: ScreenUtil.getInstance().setHeight(45),
+                    child: Image.asset('lib/images/loading.gif'),
+                  ),
                 ),
-              ),
-              Text('提交', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(36), color: Colors.white)),
-          ],
-        )
+                Text('提交', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(36), color: Colors.white)),
+            ],
+          )
+        ),
       ),
-    ),
-    onTap: () {
-      if(!submitStatus) return;
-      setState(() {
+      onTap: () {
+        if(!submitStatus) return;
+         if(lineList.length==1){
+            lineId = lineList[0].lineId.toString();
+          }else if(lineList.length>1){
+            showLineModal(lineList,orderNo);
+            return;
+        }
+          submitOrder(orderNo);
+      },
+    );
+  }
+   showLineModal(List<CompanyOfLineList> list,String orderNo){
+    showDialog < Null > (
+      context: context, //BuildContext对象
+      barrierDismissible: false,
+      builder: (BuildContext context) {
+        return ShowLineModal( 
+          lineList: list, childCallback: (val) {
+              lineId = val;
+             submitOrder(orderNo);
+          },
+        );
+      });
+  }
+  submitOrder(String orderNo){
+     setState(() {
         submitStatus = false;
       });
-      updataOrder(orderNo,afterTransportFee,afterCollectingFee,afterGoodsNumber).then((resp){
+      updataOrder(lineId,orderNo,afterTransportFee,afterCollectingFee,afterGoodsNumber).then((resp){
         if(isNotError(context, resp)){
           showDialog < Null > (
           context: context, //BuildContext对象
@@ -270,10 +303,8 @@ class _ItemInfoWidgetState extends State < ItemInfoWidget > {
           });
         }
       });
-    },
-  );
-}
-  
+  }
+ 
 }
 
 Widget titleWidget(String iconUrl, String str) {

+ 64 - 31
lib/pages/order_management_page/order_detail_page.dart

@@ -4,6 +4,7 @@ import '../../util/api.dart';
 import '../../util/models.dart';
 import '../../util/util.dart';
 import '../../showAlert.dart';
+import '../../showLineModal.dart';
 class OrderDetailPage extends StatefulWidget {
   final String orderNo;
 
@@ -110,6 +111,8 @@ class _ItemInfoWidgetState extends State < ItemInfoWidget > {
   int afterGoodsNumber=0;//数量
   double afterCollectingFee=0.0;//代收
   bool submitStatus = true;
+   String lineId = '-1';
+   List<CompanyOfLineList>  lineList = [];
   @override
   void initState() {
     super.initState();
@@ -118,7 +121,14 @@ class _ItemInfoWidgetState extends State < ItemInfoWidget > {
        afterGoodsNumber =widget.obj.goodsQuantity;
        afterCollectingFee =widget.obj.goodsAgencyFund/100;
     });
-   
+     getLineOfCompanyId(widget.obj.sendCompanyId.toString()).then((resp){
+     if(isNotError(context, resp)){
+        CompanyOfLine obj = CompanyOfLine.fromJson(resp.data);
+        setState(() {
+            lineList = obj.data;
+        });
+      }
+    });
   }
 
   @override
@@ -221,37 +231,61 @@ class _ItemInfoWidgetState extends State < ItemInfoWidget > {
   }
 
   Widget submitBtn(String orderNo) {
-  return GestureDetector(
-    child: Container(
-      margin: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(50), ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(40)),
-      height: ScreenUtil.getInstance().setHeight(88),
-      decoration: BoxDecoration(
-        borderRadius: BorderRadius.all(Radius.circular(4)),
-        color: Color.fromRGBO(37, 102, 242, 1),
-      ),
-      child: Center(
-       child:Row(
-          mainAxisAlignment: MainAxisAlignment.center,
-          children: <Widget>[
-              Offstage(
-                offstage: submitStatus,
-                child: SizedBox(
-                  width: ScreenUtil.getInstance().setWidth(45),
-                  height: ScreenUtil.getInstance().setHeight(45),
-                  child: Image.asset('lib/images/loading.gif'),
+    return GestureDetector(
+      child: Container(
+        margin: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(50), ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(40)),
+        height: ScreenUtil.getInstance().setHeight(88),
+        decoration: BoxDecoration(
+          borderRadius: BorderRadius.all(Radius.circular(4)),
+          color: Color.fromRGBO(37, 102, 242, 1),
+        ),
+        child: Center(
+        child:Row(
+            mainAxisAlignment: MainAxisAlignment.center,
+            children: <Widget>[
+                Offstage(
+                  offstage: submitStatus,
+                  child: SizedBox(
+                    width: ScreenUtil.getInstance().setWidth(45),
+                    height: ScreenUtil.getInstance().setHeight(45),
+                    child: Image.asset('lib/images/loading.gif'),
+                  ),
                 ),
-              ),
-              Text('提交', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(36), color: Colors.white)),
-          ],
-        )
+                Text('提交', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(36), color: Colors.white)),
+            ],
+          )
+        ),
       ),
-    ),
-    onTap: () {
-      if(!submitStatus) return;
-      setState(() {
+      onTap: () {
+        if(!submitStatus) return;
+          if(lineList.length==1){
+              lineId = lineList[0].lineId.toString();
+            }else if(lineList.length>1){
+              showLineModal(lineList,orderNo);
+              return;
+          }
+            submitOrder(orderNo);
+      },
+    );
+  }
+  showLineModal(List<CompanyOfLineList> list,String orderNo){
+    showDialog < Null > (
+      context: context, //BuildContext对象
+      barrierDismissible: false,
+      builder: (BuildContext context) {
+        return ShowLineModal( 
+          lineList: list, childCallback: (val) {
+              lineId = val;
+             submitOrder(orderNo);
+          },
+        );
+      });
+  }
+  submitOrder(String orderNo){
+     setState(() {
         submitStatus = false;
       });
-      updataOrder(orderNo,afterTransportFee,afterCollectingFee,afterGoodsNumber).then((resp){
+      updataOrder(lineId,orderNo,afterTransportFee,afterCollectingFee,afterGoodsNumber).then((resp){
         if(isNotError(context, resp)){
           showDialog < Null > (
           context: context, //BuildContext对象
@@ -271,9 +305,8 @@ class _ItemInfoWidgetState extends State < ItemInfoWidget > {
           });
         }
       });
-    },
-  );
-}
+  }
+ 
   
 }
 

+ 1 - 1
lib/util/api.dart

@@ -170,7 +170,7 @@ Future fromStatusGetOrderList(int orderStatus, int page, String orderNo) {
 }
 
 //改单接口
-Future updataOrder(String orderNo, double afterTransportFee, double afterCollectingFee, int afterGoodsNumber) {
+Future updataOrder(String lineId,String orderNo, double afterTransportFee, double afterCollectingFee, int afterGoodsNumber) {
   var response = Http().post('app/order/update_order', data: {
     'orderNo': orderNo,
     'afterTransportFee': afterTransportFee * 100,