|
|
@@ -6,6 +6,7 @@ import 'order_detail/order_detail.dart';
|
|
|
import '../util/bluetooth_utils.dart';
|
|
|
import '../util/session.dart';
|
|
|
import '../showDialog.dart';
|
|
|
+import '../showAlert.dart';
|
|
|
import '../util/models.dart';
|
|
|
import '../util/api.dart';
|
|
|
import '../util/util.dart';
|
|
|
@@ -673,54 +674,8 @@ class _QueryWidgetState extends State < QueryWidget > {
|
|
|
return new LoadingDialog( //调用对话框
|
|
|
text: '是否确认打印', childCallback: (val) {
|
|
|
if (val) {
|
|
|
- getOrderDetail(obj.orderNo).then((resp){
|
|
|
- if(isNotError(context, resp) && this.mounted){
|
|
|
- OrderDetailData data = OrderDetailObj.fromJson(resp.data).data;
|
|
|
- getKey('printType').then((printType){
|
|
|
- getKey('stationName').then((stationName){
|
|
|
- getKey('nickName').then((nickName){
|
|
|
- double goodsYs = (data.goodsFreight/100)+(data.goodsAgencyFund/100);
|
|
|
- String nowDate = fromatDate( DateTime.now().millisecondsSinceEpoch);//打印时间
|
|
|
- String createTime = fromatDate(data.createTime);
|
|
|
- double goodsAgencyFunds = data.goodsAgencyFund/100;
|
|
|
- double goodsDFreight = data.goodsPaymentMethod==1?data.goodsFreight/100:0;
|
|
|
- double goodsXFreight = data.goodsPaymentMethod==2?data.goodsFreight/100:0;
|
|
|
- String receiptAddress = data.receiptCompanyAddress.length>10?data.receiptCompanyAddress.substring(0,10):data.receiptCompanyAddress;
|
|
|
-
|
|
|
- Map<String, String> pum = {
|
|
|
- "[logisticsNo]": "${data.orderNo ?? ''}",
|
|
|
- "[createTime]": "$createTime",
|
|
|
- "[sendStationName]": "$stationName",
|
|
|
- "[dealerCode]": "${data.sendCompanyCode ?? ''}",
|
|
|
- "[dealerName]": "${data.sendCompanyName}",
|
|
|
- "[dealerTel]": "${data.sendCompanyPhone ?? ''}",
|
|
|
- "[repairName]": "${data.receiptCompanyName ?? ''}",
|
|
|
- "[repairTel]": "${data.receiptCompanyPhone ?? ''}",
|
|
|
- "[endStationName]": "${data.receiptStationName}",
|
|
|
- "[goodsLineCode]": "${data.lineCode ?? ''}",
|
|
|
- "[goodsLine]": "${data.lineName ?? ''}",
|
|
|
- "[repairAddress]": "${receiptAddress?? ''}",
|
|
|
- "[goodsQuantity]": "${data.goodsQuantity ?? ''}",
|
|
|
- "[goodsInsurance]": "${data.goodsInsurance ?? ''}",
|
|
|
- "[goodsFlatCost]": "${data.goodsFlatCost ?? ''}",
|
|
|
- // 到付 现付 金额
|
|
|
- "[goodsDFreight]": "$goodsDFreight",
|
|
|
- "[goodsXFreight]": "$goodsXFreight",
|
|
|
- "[goodsAgencyFund]": "$goodsAgencyFunds",
|
|
|
- "[goodsYs]": "$goodsYs",
|
|
|
- "[dealerBankAccount]": "${data.sendCompanyBankCard ?? ''}",
|
|
|
- "[goodsRemark]": "${data.memo ?? ''}",
|
|
|
- "[realName]": "${nickName?? ''}",
|
|
|
- "[currentTime]": "$nowDate",
|
|
|
- "[currentGoodNumber]": "1/1",
|
|
|
- };
|
|
|
- bluetooth.printOrder(pum, int.parse(printType));
|
|
|
- });
|
|
|
- });
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- } else {
|
|
|
+ checkBlueToothAndPrintOrder(obj);
|
|
|
+ } else {
|
|
|
return;
|
|
|
}
|
|
|
},
|
|
|
@@ -756,7 +711,7 @@ class _QueryWidgetState extends State < QueryWidget > {
|
|
|
return new LoadingDialog( //调用对话框
|
|
|
text: '是否确认打印', childCallback: (val) {
|
|
|
if (val) {
|
|
|
- //widget.callback(widget.index);
|
|
|
+ checkBlueToothAndPrintOrder(obj);
|
|
|
} else {
|
|
|
return;
|
|
|
}
|
|
|
@@ -872,4 +827,79 @@ class _QueryWidgetState extends State < QueryWidget > {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ void checkBlueToothAndPrintOrder(FromStatusGetOrderList obj){
|
|
|
+ bluetooth.isBTDevice().then((resp){
|
|
|
+ if(resp){
|
|
|
+ bluetooth.isEnableBluetooth().then((resp){
|
|
|
+ if(resp){
|
|
|
+ getOrderDetail(obj.orderNo).then((resp){
|
|
|
+ if(isNotError(context, resp) && this.mounted){
|
|
|
+ OrderDetailData data = OrderDetailObj.fromJson(resp.data).data;
|
|
|
+ getKey('printType').then((printType){
|
|
|
+ getKey('stationName').then((stationName){
|
|
|
+ getKey('nickName').then((nickName){
|
|
|
+ double goodsYs = (data.goodsFreight/100)+(data.goodsAgencyFund/100);
|
|
|
+ String nowDate = fromatDate( DateTime.now().millisecondsSinceEpoch);//打印时间
|
|
|
+ String createTime = fromatDate(data.createTime);
|
|
|
+ double goodsAgencyFunds = data.goodsAgencyFund/100;
|
|
|
+ double goodsDFreight = data.goodsPaymentMethod==1?data.goodsFreight/100:0;
|
|
|
+ double goodsXFreight = data.goodsPaymentMethod==2?data.goodsFreight/100:0;
|
|
|
+ String receiptAddress = data.receiptCompanyAddress.length>10?data.receiptCompanyAddress.substring(0,10):data.receiptCompanyAddress;
|
|
|
+
|
|
|
+ Map<String, String> pum = {
|
|
|
+ "[logisticsNo]": "${data.orderNo ?? ''}",
|
|
|
+ "[createTime]": "$createTime",
|
|
|
+ "[sendStationName]": "$stationName",
|
|
|
+ "[dealerCode]": "${data.sendCompanyCode ?? ''}",
|
|
|
+ "[dealerName]": "${data.sendCompanyName}",
|
|
|
+ "[dealerTel]": "${data.sendCompanyPhone ?? ''}",
|
|
|
+ "[repairName]": "${data.receiptCompanyName ?? ''}",
|
|
|
+ "[repairTel]": "${data.receiptCompanyPhone ?? ''}",
|
|
|
+ "[endStationName]": "${data.receiptStationName}",
|
|
|
+ "[goodsLineCode]": "${data.lineCode ?? ''}",
|
|
|
+ "[goodsLine]": "${data.lineName ?? ''}",
|
|
|
+ "[repairAddress]": "${receiptAddress?? ''}",
|
|
|
+ "[goodsQuantity]": "${data.goodsQuantity ?? ''}",
|
|
|
+ "[goodsInsurance]": "${data.goodsInsurance ?? ''}",
|
|
|
+ "[goodsFlatCost]": "${data.goodsFlatCost ?? ''}",
|
|
|
+ // 到付 现付 金额
|
|
|
+ "[goodsDFreight]": "$goodsDFreight",
|
|
|
+ "[goodsXFreight]": "$goodsXFreight",
|
|
|
+ "[goodsAgencyFund]": "$goodsAgencyFunds",
|
|
|
+ "[goodsYs]": "$goodsYs",
|
|
|
+ "[dealerBankAccount]": "${data.sendCompanyBankCard ?? ''}",
|
|
|
+ "[goodsRemark]": "${data.memo ?? ''}",
|
|
|
+ "[realName]": "${nickName?? ''}",
|
|
|
+ "[currentTime]": "$nowDate",
|
|
|
+ "[currentGoodNumber]": "1/1",
|
|
|
+ };
|
|
|
+ bluetooth.printOrder(pum, int.parse(printType));
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ showDialog <Null> (
|
|
|
+ context: context,
|
|
|
+ barrierDismissible: false,
|
|
|
+ builder: (BuildContext context) {
|
|
|
+ return MyAlertDialog(text: '请打开蓝牙并连接打印机',childCallback:(val){});
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ showDialog <Null> (
|
|
|
+ context: context,
|
|
|
+ barrierDismissible: false,
|
|
|
+ builder: (BuildContext context) {
|
|
|
+ return MyAlertDialog(text: '当前设备不支持蓝牙',childCallback:(val){});
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
}
|