Ver código fonte

发件的货物匹配;多线路添加精确匹配

daxu0403 7 anos atrás
pai
commit
e58f606e63
3 arquivos alterados com 726 adições e 446 exclusões
  1. 186 84
      lib/pages/send_express_page.dart
  2. 30 1
      lib/util/api.dart
  3. 510 361
      lib/util/models.dart

+ 186 - 84
lib/pages/send_express_page.dart

@@ -34,17 +34,23 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
   GlobalKey _sendCompanyCodeKey = GlobalKey();
   GlobalKey _sendCompanyNameKey = GlobalKey();
   GlobalKey _getCompanyNameKey = GlobalKey();
+  GlobalKey _goodsKey = GlobalKey();
 
   double tipWidth = 0;
   double tipHeight = 0;
   double tipPosX = 0;
   double tipPosY = 0;
 
-  bool tipStatus = true;
+  bool tipStatus = true;//是否展示公司信息匹配列表,true为不展示
+  bool goodsTipStatus = true;//是否展示货物匹配列表,true为不展示
   bool lineModalStatus = false;
   bool submitStatus = true;
+  bool checkedLine = false;//当收件方有多条线路时,此状态表示是否已经选择过线路了
+
+  String stationId;//司机端站点id
 
   List < LikePhoneList > likePhoneList = [];
+  List <GoodsPriceList> goodsPriceList = [];
   var timer;
   bool sendPhoneOrGetPhoneTab = true; //区分电话提示层点击时填入发件信息或手机信息的标记
 
@@ -126,12 +132,15 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
   BluetoothUtils bluetooth = BluetoothUtils();
   
   bool checkedCompanyInfo = false;//选择公司信息向sendCompanyPhoneController填充时不去模糊匹配
+  bool checkedGoodsName = false;//选择货物名称填充时不匹配
+
+  String likeWord ='';//以什么为匹配的字段用户控制高亮_tipsItem中的哪一个字段
 
   @override
   void initState() {
     super.initState();
 
-    goodsCategory().then((resp) {
+    goodsCategory().then((resp) {//获取商品类型
       if (isNotError(context, resp) && this.mounted) {
         GoodsCategory goodsCategoryObj = GoodsCategory.fromJson(resp.data);
         setState(() {
@@ -142,7 +151,7 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
       }
     });
 
-    goodsPackage().then((resp) {
+    goodsPackage().then((resp) {//获取包装类型
       if (isNotError(context, resp) && this.mounted) {
         GoodsPackage goodsPackageObj = GoodsPackage.fromJson(resp.data);
         setState(() {
@@ -152,6 +161,14 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
         });
       }
     });
+    getKey('stationId').then((resp){
+      stationId = resp;
+    });
+    getKey('defaultFreightPrice').then((resp){
+      setState(() {
+        goodsFreightController.text = (double.parse(resp)/100).toString();
+      });
+    });
 
     _scrollController.addListener(() {
       if (!tipStatus) {
@@ -159,6 +176,11 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
           tipStatus = true;
         });
       }
+      if(!goodsTipStatus){
+        setState(() {
+          goodsTipStatus = true;
+        });
+      }
       //if (_scrollController.position.pixels == _scrollController.position.maxScrollExtent) {}
     });
 
@@ -196,6 +218,7 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
                 tipPosX = sendPhoneObj.getTransformTo(null).getTranslation().x;
                 tipPosY = sendPhoneObj.getTransformTo(null).getTranslation().y - ScreenUtil.getInstance().setHeight(90);
                 tipStatus = false;
+                likeWord='phone';
               });
             } else {
               setState(() {
@@ -241,6 +264,7 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
                 tipPosX = sendPhoneObj.getTransformTo(null).getTranslation().x;
                 tipPosY = sendPhoneObj.getTransformTo(null).getTranslation().y - ScreenUtil.getInstance().setHeight(90);
                 tipStatus = false;
+                likeWord='code';
               });
             } else {
               setState(() {
@@ -286,6 +310,7 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
                 tipPosX = sendPhoneObj.getTransformTo(null).getTranslation().x;
                 tipPosY = sendPhoneObj.getTransformTo(null).getTranslation().y - ScreenUtil.getInstance().setHeight(90);
                 tipStatus = false;
+                likeWord='name';
               });
             } else {
               setState(() {
@@ -331,6 +356,7 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
                 tipPosX = getPhoneKey.getTransformTo(null).getTranslation().x;
                 tipPosY = getPhoneKey.getTransformTo(null).getTranslation().y - ScreenUtil.getInstance().setHeight(90);
                 tipStatus = false;
+                 likeWord='phone';
               });
             } else {
               setState(() {
@@ -376,6 +402,7 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
                 tipPosX = getPhoneKey.getTransformTo(null).getTranslation().x;
                 tipPosY = getPhoneKey.getTransformTo(null).getTranslation().y - ScreenUtil.getInstance().setHeight(90);
                 tipStatus = false;
+                 likeWord='name';
               });
             } else {
               setState(() {
@@ -387,6 +414,52 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
       });
     });
 
+    //货物名称监听
+    goodsController.addListener(() {
+      if(checkedGoodsName){
+        return;
+      } 
+      setState(() {
+        goods = goodsController.text;
+      });
+              
+
+      if (timer != null) {
+        timer.cancel();
+      }
+      if (goodsController.text.length < 1) {
+        setState(() {
+          goodsTipStatus = true;
+        });
+      }
+      timer = Timer(Duration(milliseconds: 250), () {
+        if (goodsController.text.length >= 1) {
+          goodsNameLike(stationId,goodsController.text,lineId).then((resp) {
+            if (isNotError(context, resp) && this.mounted) {
+              GoodsPriceObj goodsPriceObj = GoodsPriceObj.fromJson(resp.data);
+              goodsPriceList = goodsPriceObj.data;
+            }
+            if (goodsPriceList.length > 0) {
+              RenderObject goodsKey = _goodsKey.currentContext.findRenderObject();
+              setState(() {
+                tipWidth = goodsKey.paintBounds.size.width;
+                tipHeight = goodsKey.paintBounds.size.height;
+                tipPosX = goodsKey.getTransformTo(null).getTranslation().x;
+                tipPosY = goodsKey.getTransformTo(null).getTranslation().y - ScreenUtil.getInstance().setHeight(90);
+                goodsTipStatus = false;
+              });
+            } else {
+              setState(() {
+                goodsTipStatus = true;
+              });
+            }
+          });
+        }
+      });
+    });
+
+
+
     sendCompanyAddressController.addListener(() {
       setState(() {
         sendCompanyAddress = sendCompanyAddressController.text;
@@ -463,6 +536,27 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
                   )
                 ),
               )
+            ),
+            Positioned(
+              top: tipPosY,
+              left: tipPosX,
+              child: Offstage(
+                offstage: goodsTipStatus,
+                child: Container(
+                  width: tipWidth,
+                  height: ScreenUtil.getInstance().setHeight(450),
+                  padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
+                  decoration: BoxDecoration(
+                    color: Color.fromRGBO(244, 248, 251, 1),
+                  ),
+                  child: ListView.builder(
+                    itemCount: goodsPriceList.length,
+                    itemBuilder: (BuildContext context, int index) {
+                      return _goodsTipItem(goodsPriceList[index]);
+                    },
+                  )
+                ),
+              )
             )
           ],
         ),
@@ -734,83 +828,9 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
     );
   }
 
-  // Widget _contentWiget(String key, String type, [bool keyboardType = false]) { //false是数字键盘
-  //   return Padding(
-  //     padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
-  //     child: Column(
-  //       children: < Widget > [
-  //         SizedBox(
-  //           height: ScreenUtil.getInstance().setHeight(89),
-  //           child: Center(
-  //             child: Row(
-  //               mainAxisAlignment: MainAxisAlignment.spaceBetween,
-  //               children: < Widget > [
-  //                 Expanded(
-  //                   flex: 0,
-  //                   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 > [
-  //                       SizedBox(
-  //                         width: ScreenUtil.getInstance().setWidth(500),
-  //                         child:Padding(
-  //                           padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(30)),
-  //                           child:TextField(
-  //                           controller: (key == '企业名称') ? (type == 'send' ? sendCompanyNameController : receiptCompanyNameController) : (key == '企业编码' ? sendCompanyCodeController : null),
-  //                           keyboardType: keyboardType ? TextInputType.text : TextInputType.number,
-  //                           textAlign: TextAlign.end,
-  //                           decoration: InputDecoration(
-  //                             border: InputBorder.none
-  //                           ),
-  //                           onChanged: (value) {
-  //                             if (key == '货物名称') {
-  //                               goods = value;
-  //                             } else if (key == '数量') {
-  //                               goodsQuantity = int.parse(value);
-  //                             } else if (key == '运费') {
-  //                               goodsFreight = double.parse(value);
-  //                               String temp = goodsFreight.toStringAsFixed(1);
-  //                               goodsFreight = double.parse(temp);
-  //                             } else if (key == '代收') {
-  //                               goodsAgencyFund = double.parse(value);
-  //                               String temp = goodsAgencyFund.toStringAsFixed(1);
-  //                               goodsAgencyFund = double.parse(temp);
-  //                             } else if (key == '保价') {
-  //                               goodsPriceProtection = double.parse(value);
-  //                               String temp = goodsPriceProtection.toStringAsFixed(1);
-  //                               goodsPriceProtection = double.parse(temp);
-  //                             } else if (key == '重量') {
-  //                               goodsWeight = double.parse(value);
-  //                               String temp = goodsWeight.toStringAsFixed(1);
-  //                               goodsWeight = double.parse(temp);
-  //                             }
-  //                           },
-  //                         ),
-  //                         )
-                           
-  //                       ),
-
-  //                       // Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
-  //                     ],
-  //                   )
-  //                 )
-  //               ],
-  //             ),
-  //           )
-  //         ),
-  //         Expanded(
-  //           flex: 0,
-  //           child: _underLine()
-  //         )
-  //       ],
-  //     )
-  //   );
-  // }
-
   Widget _itemContentWiget(String key,TextEditingController controller, [bool keyboardType = false]) { //false是数字键盘
     return Padding(
+      key: key=='货物名称'?_goodsKey:null,
       padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
       child: Column(
         children: < Widget > [
@@ -1232,7 +1252,7 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
           return;
         }
         
-        if(lineList.length>1){
+        if(lineList.length>1 && !checkedLine){
           showLineModal(lineList);
           return;
        }
@@ -1453,7 +1473,27 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
         return ShowLineModal( 
           lineList: list, childCallback: (val) {
               lineId = val;
-             submitOrder();
+              goodsNameAccurate(stationId,goodsController.text,lineId).then((resp){
+                if(isNotError(context, resp) && this.mounted){
+                  if(resp.data['data']['goods']!=null){
+                    GoodsPriceList tempObj = GoodsPriceObjAccurate.fromJson(resp.data).data;
+                      setState(() {
+                        goods=tempObj.goods;
+                        goodsController.text = tempObj.goods;
+                        goodsFreight = tempObj.price/100;
+                        goodsFreightController.text = (tempObj.price/100).toString();
+                      });
+                  }
+                  checkedLine = true;
+                  // showDialog <Null> (
+                  //   context: context,
+                  //   barrierDismissible: false,
+                  //   builder: (BuildContext context) {
+                  //     return MyAlertDialog(text: '线路已变更,请确认运费是否正确',childCallback:(val){});
+                  //   }
+                  // );
+                }
+              });
           },
         );
       });
@@ -1481,16 +1521,16 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
                       padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(50)),
                       child: Text(obj.uzerPhone!=null?obj.uzerPhone:obj.companyPhone, style: TextStyle(
                         fontSize: ScreenUtil.getInstance().setSp(28),
-                        color: Color.fromRGBO(74, 74, 74, 1)
+                        color: likeWord=='phone'?Color.fromRGBO(74, 74, 74, 1):Color.fromRGBO(155, 155, 155, 1)
                       ), )
                     ),
                     SizedBox(
                       width: ScreenUtil.getInstance().setWidth(185),
-                      child: Text(obj.areaCode,
+                      child: Text(obj.companyCode,
                         textAlign: TextAlign.left,
                         style: TextStyle(
                           fontSize: ScreenUtil.getInstance().setSp(28),
-                          color: Color.fromRGBO(155, 155, 155, 1)
+                          color: likeWord=='code'?Color.fromRGBO(74, 74, 74, 1):Color.fromRGBO(155, 155, 155, 1)
                         ), ),
                     ),
                     Text(obj.companyName,
@@ -1498,7 +1538,7 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
                       overflow: TextOverflow.ellipsis,
                       style: TextStyle(
                         fontSize: ScreenUtil.getInstance().setSp(28),
-                        color: Color.fromRGBO(155, 155, 155, 1)
+                        color: likeWord=='name'?Color.fromRGBO(74, 74, 74, 1):Color.fromRGBO(155, 155, 155, 1)
                       ),
                     )
                   ],
@@ -1566,6 +1606,68 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
     );
   }
 
+  Widget _goodsTipItem(GoodsPriceList obj){
+    return Container(
+      child: Column(
+        children: < Widget > [
+          InkWell(
+            child: Container(
+              height: ScreenUtil.getInstance().setHeight(89),
+              child: Center(
+                child: Row(
+                  mainAxisAlignment: MainAxisAlignment.start,
+                  children: < Widget > [
+                    SizedBox(
+                      width: ScreenUtil.getInstance().setWidth(250),
+                      child: Text(obj.goods, 
+                      textAlign: TextAlign.left,
+                      overflow: TextOverflow.ellipsis,
+                      style: TextStyle(
+                        fontSize: ScreenUtil.getInstance().setSp(28),
+                        color: Color.fromRGBO(74, 74, 74, 1)
+                      ), )
+                    ),
+                    SizedBox(
+                      width: ScreenUtil.getInstance().setWidth(250),
+                      child: Text(obj.lineName,
+                        textAlign: TextAlign.left,
+                        overflow: TextOverflow.ellipsis,
+                        style: TextStyle(
+                          fontSize: ScreenUtil.getInstance().setSp(28),
+                          color: Color.fromRGBO(155, 155, 155, 1)
+                        ), ),
+                    ),
+                    Text((obj.price/100).toString(),
+                      textAlign: TextAlign.left,
+                      overflow: TextOverflow.ellipsis,
+                      style: TextStyle(
+                        fontSize: ScreenUtil.getInstance().setSp(28),
+                        color: Color.fromRGBO(155, 155, 155, 1)
+                      ),
+                    )
+                  ],
+                ),
+              ),
+            ),
+            onTap: () {
+              checkedGoodsName = true;
+              setState(() {
+                FocusScope.of(context).requestFocus(FocusNode());
+                goodsTipStatus = true;
+                goods = obj.goods;
+                goodsController.text = obj.goods;
+                goodsFreight = (obj.price/100);
+                goodsFreightController.text = (obj.price/100).toString();
+              });
+            },
+          ),
+          _underLine()
+        ],
+      ),
+    );
+  
+  }
+ 
   Widget _packageType(String key) {
     return Padding(
       padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),

+ 30 - 1
lib/util/api.dart

@@ -12,7 +12,7 @@ Future login(phone, passwrod) async {
 
 //获取物流公司名字及客服电话
 Future getCompanyInfo() async {
-  var response = await Http().get('/app/dictionary/description_info');
+  var response = await Http().get('/app/dictionary/description_object');
   return response;
 }
 
@@ -237,6 +237,35 @@ Future orderNoLike(String orderNo,int orderStatus) {
   });
   return response;
 }
+//模糊匹配货物名称
+Future goodsNameLike(String startStationId,String goods, [String lineId='-1']){
+   var obj;
+   if(lineId!='-1'){
+     obj = {
+       'startStationId':startStationId,
+       'goods':goods,
+       'lineId':lineId
+     };
+   }else{
+     obj = {
+       'startStationId':startStationId,
+       'goods':goods,
+     };
+   }
+   var response = Http().post('/admin/goods_freight_price/freight_price_info', data: obj);
+   return response;
+}
+
+//精确匹配货物名称
+Future goodsNameAccurate(String startStationId,String goods, String lineId){
+    var obj = {
+       'startStationId':startStationId,
+       'goods':goods,
+       'lineId':lineId
+     };
+   var response = Http().post('/admin/goods_freight_price/freight_price_accurate', data: obj);
+   return response;
+}
 
 //根据公司id取得线路
 Future getLineOfCompanyId(String companyId){

Diferenças do arquivo suprimidas por serem muito extensas
+ 510 - 361
lib/util/models.dart