| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674 |
- import 'package:flutter/material.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:flutter_picker/flutter_picker.dart';
- import '../../util/api.dart';
- import '../../util/models.dart';
- import '../../util/util.dart';
- import '../../showAlert.dart';
- import '../../showLineModal.dart';
- import '../../util/session.dart';
- import '../../util/bluetooth_utils.dart';
- class OrderDetailPage extends StatefulWidget {
- final String orderNo;
- final String status;
- OrderDetailPage({
- Key key,
- @required this.orderNo,
- @required this.status
- }): super(key: key);
- _OrderDetailPageState createState() => _OrderDetailPageState();
- }
- class _OrderDetailPageState extends State < OrderDetailPage > {
- OrderDetailData orderDetailObj;
- @override
- void initState() {
- super.initState();
- getOrderDetail(widget.orderNo).then((resp) {
- if (isNotError(context, resp) && this.mounted) {
- OrderDetailObj tempObj = OrderDetailObj.fromJson(resp.data);
- setState(() {
- orderDetailObj = tempObj.data;
- });
- }
- });
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- title: Text(
- "订单详情",
- style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(36)),
- ),
- centerTitle: true,
- backgroundColor: Color.fromRGBO(64, 98, 254, 1),
- ),
- body: Container(
- padding: EdgeInsets.fromLTRB(
- 0,
- ScreenUtil.getInstance().setHeight(20),
- 0,
- ScreenUtil.getInstance().setHeight(20)),
- color: Color.fromRGBO(246, 246, 254, 1),
- child: orderDetailObj == null ?
- Center(
- child: _getMoreWidget(),
- ) :
- ListView(
- children: < Widget > [
- _sendInfo(),
- _getInfo(),
- ItemInfoWidget(obj: orderDetailObj, status: widget.status),
- ],
- )),
- //resizeToAvoidBottomPadding: false //键盘弹出,页面不跟随向上滑动,防止出现溢出错误
- );
- }
- Widget _sendInfo() {
- return Container(
- color: Colors.white,
- margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
- child: Column(
- children: < Widget > [
- titleWidget('lib/images/icon_send.png', '发件信息'),
- underLine(),
- contentWiget(
- '电话',
- orderDetailObj.senderPhone != null ?
- orderDetailObj.senderPhone :
- orderDetailObj.sendCompanyPhone),
- contentWiget('企业编码', orderDetailObj.sendCompanyCode),
- contentWiget('企业名称', orderDetailObj.sendCompanyName),
- contentWiget(
- '城市/区域',
- '${orderDetailObj.sendCompanyProvinceName}' +
- ' ' +
- '${orderDetailObj.sendCompanyCityName}' +
- ' ' +
- '${orderDetailObj.sendCompanyAreaName}'),
- lastContentWiget('详细地址', orderDetailObj.sendCompanyAddress)
- ],
- ));
- }
- Widget _getInfo() {
- return Container(
- color: Colors.white,
- margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
- child: Column(
- children: < Widget > [
- titleWidget('lib/images/icon_shoujian.png', '收件信息'),
- underLine(),
- contentWiget('企业名称', orderDetailObj.receiptCompanyName),
- contentWiget('电话', orderDetailObj.receiptCompanyPhone),
- contentWiget(
- '城市/区域',
- '${orderDetailObj.receiptCompanyProvinceName}' +
- ' ' +
- '${orderDetailObj.receiptCompanyCityName}' +
- ' ' +
- '${orderDetailObj.receiptCompanyAreaName}'),
- lastContentWiget('详细地址', orderDetailObj.sendCompanyAddress)
- ],
- ));
- }
- }
- class ItemInfoWidget extends StatefulWidget {
- final OrderDetailData obj;
- final String status;
- ItemInfoWidget({
- Key key,
- @required this.obj,
- @required this.status
- }): super(key: key);
- _ItemInfoWidgetState createState() => _ItemInfoWidgetState();
- }
- class _ItemInfoWidgetState extends State < ItemInfoWidget > {
- double afterTransportFee = 0.0; //运费
- int afterGoodsNumber = 0; //数量
- double afterCollectingFee = 0.0; //代收
- bool submitStatus = true;
- String lineId = '-1';
- List < CompanyOfLineList > lineList = [];
- String showTextPaymentMehod = '现付';
- int goodsPaymentMethod = 1;
- BluetoothUtils bluetooth = BluetoothUtils();
- @override
- void initState() {
- super.initState();
- setState(() {
- afterTransportFee = widget.obj.goodsFreight / 100;
- afterGoodsNumber = widget.obj.goodsQuantity;
- afterCollectingFee = widget.obj.goodsAgencyFund / 100;
- lineId = widget.obj.lineId.toString();
- });
- if (widget.obj.receiptCompanyId != null) {
- getLineOfCompanyId(widget.obj.receiptCompanyId.toString()).then((resp) {
- if (isNotError(context, resp) && this.mounted) {
- CompanyOfLine obj = CompanyOfLine.fromJson(resp.data);
- setState(() {
- lineList = obj.data;
- });
- }
- });
- }
- showTextPaymentMehod = widget.obj.goodsPaymentMethod == 1 ? '现付' : '到付';
- goodsPaymentMethod = widget.obj.goodsPaymentMethod;
- }
- @override
- Widget build(BuildContext context) {
- return Container(
- child: Container(
- color: Colors.white,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: < Widget > [
- titleWidget('lib/images/icon_huowu.png', "货物信息"),
- underLine(),
- contentWiget("货物名称", widget.obj.goods),
- _inputWidget("数量", widget.obj.goodsQuantity),
- _inputWidget("运费", widget.obj.goodsFreight / 100),
- _inputWidget("代收", widget.obj.goodsAgencyFund / 100),
- _packageType('付款方式'),
- contentWiget(
- "保价", (widget.obj.goodsPriceProtection / 100).toString()),
- contentWiget("重量", widget.obj.goodsWeight.toStringAsFixed(1)),
- contentWiget("包装类型", (widget.obj.goodsPackingName)),
- contentWiget("货物类型", (widget.obj.goodsCategoryName)),
- _descWidget(widget.obj.memo),
- submitBtn(widget.obj.orderNo)
- ],
- ),
- ));
- }
- Widget _inputWidget(String key, num value) {
- 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 > [
- Text(
- key,
- style: TextStyle(
- fontSize: ScreenUtil.getInstance().setSp(30),
- color: Color.fromRGBO(74, 74, 74, 1)),
- ),
- Container(
- width: ScreenUtil.getInstance().setWidth(300),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.end,
- children: < Widget > [
- Expanded(
- //padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(20)),
- //child: Text(value,style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
- child: Center(
- child: TextField(
- keyboardType: TextInputType.number,
- textAlign: TextAlign.end,
- style: TextStyle(
- fontSize:
- ScreenUtil.getInstance().setSp(30),
- color: Colors.black),
- decoration: InputDecoration(
- border: InputBorder.none,
- hintText: value.toString(),
- hintStyle: TextStyle(
- fontSize:
- ScreenUtil.getInstance().setSp(30),
- color: Colors.black),
- contentPadding: EdgeInsets.fromLTRB(
- ScreenUtil.getInstance().setWidth(20),
- 0,
- 0,
- 0),
- ),
- onChanged: (value) {
- if (key == '数量') {
- afterGoodsNumber = int.parse(value);
- } else if (key == '运费') {
- afterTransportFee = double.parse(value);
- String temp =
- afterTransportFee.toStringAsFixed(1);
- afterTransportFee = double.parse(temp);
- } else if (key == '代收') {
- afterCollectingFee = double.parse(value);
- String temp =
- afterCollectingFee.toStringAsFixed(1);
- afterCollectingFee = double.parse(temp);
- }
- },
- ),
- )),
- Icon(
- Icons.keyboard_arrow_right,
- color: Color.fromRGBO(199, 199, 204, 1),
- )
- ],
- ))
- ],
- ),
- )),
- Expanded(flex: 0, child: underLine())
- ],
- ));
- }
- Widget _descWidget(String str) {
- return Container(
- padding: EdgeInsets.all(ScreenUtil.getInstance().setWidth(30)),
- child: Text(
- str,
- maxLines: 100,
- style: TextStyle(
- fontSize: ScreenUtil.getInstance().setSp(30),
- color: Color.fromRGBO(74, 74, 74, 1)),
- ),
- );
- }
- 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'),
- ),
- ),
- Text('提交',
- style: TextStyle(
- fontSize: ScreenUtil.getInstance().setSp(36),
- color: Colors.white)),
- ],
- )),
- ),
- onTap: () {
- if (!submitStatus) return;
- if (afterCollectingFee > 0) {
- if (widget.obj.sendCompanyBankCard == null ||
- widget.obj.sendCompanyBankCard == '') {
- showDialog < Null > (
- context: context,
- barrierDismissible: false,
- builder: (BuildContext context) {
- return MyAlertDialog(text: '银行信息不全', childCallback: (val) {});
- });
- return;
- }
- }
- if (lineList.length > 1 && widget.status == '寄件') {
- showLineModal(lineList, orderNo);
- return;
- }
- submitOrder(orderNo);
- },
- );
- }
- Widget _packageType(String key) {
- 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(
- 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: Text(
- showTextPaymentMehod,
- 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) {
- List < dynamic > data = ['现付', '到付'];
- new Picker(
- adapter: PickerDataAdapter < String > (pickerdata: data),
- 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(() {
- showTextPaymentMehod = data[value[0]];
- });
- if (showTextPaymentMehod == '现付') {
- goodsPaymentMethod = 1;
- } else {
- goodsPaymentMethod = 2;
- }
- }).showModal(this.context);
- }
- 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(lineId, orderNo, afterTransportFee, afterCollectingFee,
- afterGoodsNumber, goodsPaymentMethod)
- .then((resp) {
- if (isNotError(context, resp) && this.mounted) {
- showDialog < Null > (
- context: context, //BuildContext对象
- barrierDismissible: false,
- builder: (BuildContext context) {
- //打印
- OrderDetailObj parentObj = OrderDetailObj.fromJson(resp.data);
- if (parentObj.success) {
- OrderDetailData data = parentObj.data;
- getKey('printType').then((printType) {
- getKey('stationName').then((stationName) {
- getKey('nickName').then((nickName) {
- getKey('companyName').then((companyName) {
- getKey('companyCustomerPhone')
- .then((companyCustomerPhone) {
- double goodsYs = data.goodsPaymentMethod == 2 ?
- (data.goodsFreight / 100) +
- (data.goodsAgencyFund / 100) :
- data.goodsAgencyFund / 100;
- String nowDate = fromatDate(
- DateTime.now().millisecondsSinceEpoch); //打印时间
- String createTime = fromatDate(data.createTime);
- double goodsAgencyFunds = data.goodsAgencyFund / 100;
- double goodsDFreight = data.goodsPaymentMethod == 2 ?
- data.goodsFreight / 100 :
- 0;
- double goodsXFreight = data.goodsPaymentMethod == 1 ?
- 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",
- "[companyCustomerPhone]": "$companyCustomerPhone",
- "[companyName]": "$companyName"
- };
- bluetooth
- .printOrder(pum, int.parse(printType))
- .then((value) {
- if (value == null) {
- showDialog < Null > (
- context: context,
- barrierDismissible: false,
- builder: (BuildContext context) {
- return MyAlertDialog(
- text: '未连接打印机',
- childCallback: (val) {});
- });
- }
- });
- });
- });
- });
- });
- });
- return MyAlertDialog(
- //调用对话框
- text: '订单修改成功!',
- childCallback: (val) {
- if (val) {
- Navigator.pop(context, true);
- }
- },
- );
- } else {
- showDialog < Null > (
- context: context,
- barrierDismissible: false,
- builder: (BuildContext context) {
- return MyAlertDialog(
- text: parentObj.msg, childCallback: (val) {
- Navigator.pop(context, true);
- });
- });
- }
- });
- } else {
- setState(() {
- submitStatus = true;
- });
- }
- });
- }
- }
- Widget titleWidget(String iconUrl, String str) {
- return Container(
- height: ScreenUtil.getInstance().setHeight(90),
- padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
- child: Center(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.start,
- children: < Widget > [
- Padding(
- padding: EdgeInsets.only(
- right: ScreenUtil.getInstance().setHeight(20)),
- child: Image.asset(
- iconUrl,
- width: ScreenUtil.getInstance().setWidth(40),
- height: ScreenUtil.getInstance().setHeight(40),
- )),
- Text(
- str,
- style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(32)),
- )
- ],
- ),
- ),
- );
- }
- Widget underLine() {
- return Container(
- color: Color.fromRGBO(223, 223, 223, 1),
- height: ScreenUtil.getInstance().setHeight(1),
- );
- }
- Widget contentWiget(String key, String value) {
- return Padding(
- padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
- child: Column(
- children: < Widget > [
- Padding(
- padding:
- EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(30)),
- child: SizedBox(
- height: ScreenUtil.getInstance().setHeight(89),
- child: Center(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: < Widget > [
- Text(
- key,
- style: TextStyle(
- fontSize: ScreenUtil.getInstance().setSp(30),
- color: Color.fromRGBO(74, 74, 74, 1)),
- ),
- Text(
- value,
- style: TextStyle(
- fontSize: ScreenUtil.getInstance().setSp(30),
- color: Color.fromRGBO(136, 136, 136, 1)),
- ),
- ],
- ),
- ))),
- Expanded(flex: 0, child: underLine())
- ],
- ));
- }
- Widget lastContentWiget(String key, String value) {
- return Padding(
- padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
- child: Padding(
- padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(30)),
- child: SizedBox(
- height: ScreenUtil.getInstance().setHeight(89),
- child: Center(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: < Widget > [
- Text(
- key,
- style: TextStyle(
- fontSize: ScreenUtil.getInstance().setSp(30),
- color: Color.fromRGBO(74, 74, 74, 1)),
- ),
- Text(
- value,
- style: TextStyle(
- fontSize: ScreenUtil.getInstance().setSp(30),
- color: Color.fromRGBO(136, 136, 136, 1)),
- ),
- ],
- ),
- ))),
- );
- }
- Widget _getMoreWidget() {
- return Center(
- child: Padding(
- padding: EdgeInsets.all(10.0),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment: CrossAxisAlignment.center,
- children: < Widget > [
- Text(
- '加载中...',
- style: TextStyle(fontSize: 16.0),
- ),
- Container(
- width: ScreenUtil.getInstance().setWidth(50),
- height: ScreenUtil.getInstance().setHeight(50),
- child: CircularProgressIndicator())
- ],
- ),
- ),
- );
- }
|