| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022 |
- import 'package:flutter/material.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'dart:async';
- import 'order_management_page/order_detail_page.dart';
- 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';
- import 'package:barcode_scan/barcode_scan.dart';
- import 'package:flutter/services.dart';
- class OrderManagementPage extends StatefulWidget {
- final Widget child;
- OrderManagementPage({
- Key key,
- this.child
- }): super(key: key);
- _OrderManagementPageState createState() => _OrderManagementPageState();
- }
- class _OrderManagementPageState extends State < OrderManagementPage > with AutomaticKeepAliveClientMixin {
- @override
- Widget build(BuildContext context) {
- return Container(
- child: Scaffold(
- appBar: AppBar(
- title: Text('订单管理', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(36)), ),
- centerTitle: true,
- backgroundColor: Color.fromRGBO(64, 98, 254, 1),
- ),
- body: Container(
- decoration: BoxDecoration(
- color: Color.fromRGBO(246, 246, 254, 1)
- ),
- child: QueryWidget()
- ),
- resizeToAvoidBottomPadding: false //键盘弹出,页面不跟随向上滑动,防止出现溢出错误
- )
- );
- }
- @override
- bool get wantKeepAlive => true;
- }
- class QueryWidget extends StatefulWidget { //搜索栏
- final Widget child;
- QueryWidget({
- Key key,
- this.child
- }): super(key: key);
- _QueryWidgetState createState() => _QueryWidgetState();
- }
- class _QueryWidgetState extends State < QueryWidget > {
- //单号的输入框控制器
- TextEditingController _orderController = TextEditingController();
- ScrollController _scrollController = ScrollController();
- GlobalKey _globalKey = GlobalKey(); //搜索栏key
- List < bool > statusList = [true, false, false];
- double inputPostX = 0;
- double inputPostY = 0;
- double inputWidth = 0;
- double inputHeight = 0;
- bool showStatus = true; //提示层显示状态
- String _orderNo = "";
- int orderStatus = 1; //0:代收单,1:待取件,2:运途中:已完成
- int page = 1;
- bool hasNextPage = true;
- BluetoothUtils bluetooth = BluetoothUtils();
- List < FromStatusGetOrderList > orderList = [];
- List likeOrderNoList = [];
- var timer;
- bool loadMoreStatus = true;
- String barcode = "";//扫描的订单号
- @override
- void initState() {
- super.initState();
- switchOrderFromStatus(orderStatus, page);
- _scrollController.addListener(() {
- if (_scrollController.position.pixels == _scrollController.position.maxScrollExtent) {
- if (loadMoreStatus) {
- page = ++page;
- getMoreOrder(orderStatus, page);
- }
- }
- });
- }
- @override
- Widget build(BuildContext context) {
- return Stack(
- children: < Widget > [
- Container(
- child: Column(
- children: < Widget > [
- Container(
- color: Colors.white,
- height: ScreenUtil.getInstance().setHeight(222),
- padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(20), ScreenUtil.getInstance().setWidth(20), ScreenUtil.getInstance().setWidth(20), 0),
- child: Column(
- children: < Widget > [
- Container(
- key: _globalKey,
- height: ScreenUtil.getInstance().setHeight(100),
- decoration: BoxDecoration(
- border: Border.all(color: Color.fromRGBO(204, 204, 204, 1), width: 1),
- borderRadius: BorderRadius.all(Radius.circular(5))
- ),
- child: Row(
- children: < Widget > [
- Expanded(
- child: TextField(
- controller: _orderController,
- keyboardType: TextInputType.number,
- autocorrect: true,
- decoration: InputDecoration(
- border: InputBorder.none,
- hintText: "输入运单号后6位查询物流",
- hintStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(26), color: Color.fromRGBO(155, 155, 155, 1)),
- contentPadding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(30), 0, ScreenUtil.getInstance().setWidth(30), 0)
- ),
- onTap: () {
- RenderObject inputObj = _globalKey.currentContext.findRenderObject();
- setState(() {
- inputWidth = inputObj.paintBounds.size.width;
- inputHeight = inputObj.paintBounds.size.height;
- inputPostX = inputObj.getTransformTo(null).getTranslation().x;
- inputPostY = ScreenUtil.getInstance().setWidth(20) + inputHeight;
- });
- },
- onChanged: ((value) {
- setState(() {
- _orderNo = value;
- });
- if (timer != null) {
- timer.cancel();
- }
- timer = Timer(Duration(milliseconds: 500), () {
- if (_orderNo.length >= 6) {
- orderNoLike(_orderNo, orderStatus).then((resp) {
- if (isNotError(context, resp) && this.mounted) {
- LikeOrderNo tempObj = LikeOrderNo.fromJson(resp.data);
- if (tempObj.data.length > 0) {
- setState(() {
- likeOrderNoList = tempObj.data;
- showStatus = false;
- });
- }
- }
- });
- } else {
- setState(() {
- showStatus = true;
- });
- }
- });
- }),
- onEditingComplete: () {
- FocusScope.of(context).requestFocus(FocusNode());
- setState(() {
- showStatus = true;
- });
- },
- ),
- ),
- IconButton(
- icon: Image.asset('lib/images/icon_saoyisao.png',
- width: ScreenUtil.getInstance().setWidth(38),
- height: ScreenUtil.getInstance().setHeight(36),
- ),
- onPressed: () {
- scan();
- },
- ),
- // GestureDetector(
- // child: Container(
- // width: ScreenUtil.getInstance().setWidth(120),
- // decoration: BoxDecoration(
- // border: Border(left: BorderSide.merge(BorderSide(color: Color.fromRGBO(204, 204, 204, 1), width: 1), BorderSide(color: Color.fromRGBO(204, 204, 204, 1), width: 0)), )
- // ),
- // child: Center(
- // child: Text("查询", style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(26), color: Color.fromRGBO(64, 98, 254, 1)), ),
- // ),
- // ),
- // onTap: () {
- // print("查询");
- // }
- // ),
- ],
- ),
- ),
- Container(
- height: ScreenUtil.getInstance().setHeight(100),
- child: Container(
- padding: EdgeInsets.only(top: ScreenUtil.getInstance().setHeight(25)),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceAround,
- children: < Widget > [
- InkWell(
- child: Container(
- height: ScreenUtil.getInstance().setHeight(80),
- decoration: BoxDecoration(
- border: statusList[0] ? Border(bottom: BorderSide.merge(BorderSide(color: Colors.black, width: 1), BorderSide(color: Colors.black, width: 0)), ) : Border()
- ),
- child: Center(
- child: Text("待取件", style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: statusList[0] ? Colors.black : Color.fromRGBO(155, 155, 155, 1)), ),
- )
- ),
- onTap: () {
- if (statusList[0]) {
- return;
- } else {
- setState(() {
- statusList = [true, false, false];
- orderStatus = 1;
- });
- switchOrderFromStatus(orderStatus, page);
- }
- },
- ),
- InkWell(
- child: Container(
- height: ScreenUtil.getInstance().setHeight(80),
- decoration: BoxDecoration(
- border: statusList[1] ? Border(bottom: BorderSide.merge(BorderSide(color: Colors.black, width: 1), BorderSide(color: Colors.black, width: 0)), ) : Border()
- ),
- child: Center(
- child: Text("运途中", style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: statusList[1] ? Colors.black : Color.fromRGBO(155, 155, 155, 1)), ),
- )
- ),
- onTap: () {
- if (statusList[1]) {
- return;
- } else {
- setState(() {
- statusList = [false, true, false];
- orderStatus = 2;
- });
- switchOrderFromStatus(orderStatus, page);
- }
- },
- ),
- InkWell(
- child: Container(
- height: ScreenUtil.getInstance().setHeight(80),
- decoration: BoxDecoration(
- border: statusList[2] ? Border(bottom: BorderSide.merge(BorderSide(color: Colors.black, width: 1), BorderSide(color: Colors.black, width: 0)), ) : Border()
- ),
- child: Center(
- child: Text("已完成", style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: statusList[2] ? Colors.black : Color.fromRGBO(155, 155, 155, 1)), ),
- )
- ),
- onTap: () {
- if (statusList[2]) {
- return;
- } else {
- setState(() {
- statusList = [false, false, true];
- orderStatus = 3;
- });
- switchOrderFromStatus(orderStatus, page);
- }
- },
- ),
- ],
- )
- )
- ),
- ],
- )
- ),
- Expanded(
- child: Container(
- padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(20), ScreenUtil.getInstance().setWidth(20), ScreenUtil.getInstance().setWidth(20), 0),
- child: orderList == null ? Center(
- child: _getMoreWidget()
- ) : orderList.length == 0 ?
- Center(
- child: Text('暂无订单'),
- ) :
- RefreshIndicator(
- onRefresh: refreshOrder,
- child: ListView.builder(
- physics: AlwaysScrollableScrollPhysics(),
- controller: _scrollController,
- itemCount: orderList.length + 1,
- itemBuilder: (BuildContext context, int index) {
- if (index < orderList.length) {
- return _cardWiget(orderList[index], index);
- }
- if (hasNextPage) {
- return _getMoreWidget();
- } else {
- return _noMoreWidegt();
- }
- },
- )
- )
- ),
- )
- ],
- )
- ),
- Positioned(
- left: inputPostX,
- top: inputPostY,
- child: Offstage(
- offstage: showStatus,
- child:
- Container(
- width: inputWidth,
- height: ScreenUtil.getInstance().setHeight(320),
- margin: EdgeInsets.only(top: ScreenUtil.getInstance().setHeight(1)),
- decoration: BoxDecoration(
- color: Colors.white,
- border: Border.all(color: Color.fromRGBO(204, 204, 204, 1), width: 1),
- borderRadius: BorderRadius.all(Radius.circular(5))
- ),
- child: ListView.builder(
- itemCount: likeOrderNoList.length,
- itemBuilder: (BuildContext context, int index) {
- return InkWell(
- child: Padding(
- padding: EdgeInsets.all(10),
- child: Text(likeOrderNoList[index],style: TextStyle(color:Color.fromRGBO(64, 98, 254, 1)),),
- ),
- onTap: () {
- setState(() {
- page = 1;
- _orderNo = likeOrderNoList[index];
- });
- fromStatusGetOrderList(orderStatus, page, likeOrderNoList[index]).then((resp) {
- if (isNotError(context, resp) && this.mounted) {
- FromStatusGetOrderObj tempObj = FromStatusGetOrderObj.fromJson(resp.data);
- setState(() {
- orderList = tempObj.data.items;
- hasNextPage = tempObj.data.hasNextPage;
- });
- }
- });
- setState(() {
- _orderController.text = likeOrderNoList[index];
- showStatus = true;
- FocusScope.of(context).requestFocus(FocusNode());
- });
- },
- );
- },
- ),
- ),
- )
- )
- ],
- );
- }
-
- Widget _cardWiget(FromStatusGetOrderList obj, int index) {
- Map < int, String > statusMap = {
- 1: '待取货',
- 2: '运途中',
- 3: '已签收',
- 4: '已拒收',
- 5: '已作废',
- 6: '已取消'
- };
- return Container(
- margin: EdgeInsets.all(4),
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.all(Radius.circular(8)),
- boxShadow: [
- BoxShadow(color: Color.fromRGBO(217, 226, 233, 0.5),offset: Offset(0, 2),blurRadius: 3.0),
- ]
- ),
- child: Container(
- padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(20)),
- child: Column(
- children: < Widget > [
- InkWell(
- child: Column(
- children: <Widget>[
- Padding(
- padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(30)),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: < Widget > [
- Text('订单号:${obj.orderNo}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(102, 102, 102, 1)), ),
- Text('${statusMap[obj.orderStatus]}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color:obj.orderStatus==5?Colors.red:Color.fromRGBO(126, 211, 33, 1)), ),
- ],
- )
- ),
- Padding(
- padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
- child: Row(
- children: < Widget > [
- Text('${obj.sendCompanyName} --> ${obj.receiptCompanyName}',
- overflow: TextOverflow.ellipsis,style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30)), ),
- ],
- )
- ),
- Padding(
- padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(15)),
- child: Row(
- children: < Widget > [
- SizedBox(
- width: ScreenUtil.getInstance().setWidth(355),
- child: Text('货物名称:${obj.goods}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(155, 155, 155, 1)), ),
- ),
- Text('代收款:${obj.goodsAgencyFund/100}元', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(155, 155, 155, 1)), ),
- ],
- ),
- ),
- Padding(
- padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(30)),
- child: Row(
- children: < Widget > [
- SizedBox(
- width: ScreenUtil.getInstance().setWidth(355),
- child: Text('货物件数:${obj.goodsQuantity}件', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(155, 155, 155, 1)), ),
- ),
- Text('运费:${obj.goodsFreight/100}元', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(155, 155, 155, 1)), ),
- ],
- ),
- ),
- Padding(
- padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
- child: Container(
- height: ScreenUtil.getInstance().setHeight(1),
- color: Color.fromRGBO(223, 223, 223, 1),
- ),
- ),
- ],
- ),
- onTap: () {
- Navigator.push(
- context,
- MaterialPageRoute(
- builder: (BuildContext context) {
- return OrderDetailsPage(orderNo: obj.orderNo);
- })
- );
- },
- ),
- orderStatus == 1 ? _status1Fun(obj, index) : orderStatus == 2 ? _status2Fun(obj, index) : _status3Fun(obj, index)
- ],
- ),
- )
- );
- }
-
- Widget _status1Fun(FromStatusGetOrderList obj, int index) {
- return Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: < Widget > [
- InkWell(
- child: Container(
- width: ScreenUtil.getInstance().setWidth(94),
- height: ScreenUtil.getInstance().setHeight(48),
- decoration: BoxDecoration(
- color: Color.fromRGBO(239, 243, 249, 1),
- borderRadius: BorderRadius.all(Radius.circular(4.0))
- ),
- child: Center(
- child: Text('作废', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
- ),
- ),
- onTap: () {
- showDialog < Null > (
- context: context, //BuildContext对象
- barrierDismissible: false,
- builder: (BuildContext context) {
- return new LoadingDialog( //调用对话框
- text: '是否确认作废', childCallback: (val) {
- if (val) {
- myUpdataOrder(obj.orderNo, 5, index);
- } else {
- return;
- }
- },
- );
- });
- print("作废");
- },
- ),
- InkWell(
- child: Container(
- width: ScreenUtil.getInstance().setWidth(94),
- height: ScreenUtil.getInstance().setHeight(48),
- decoration: BoxDecoration(
- color: Color.fromRGBO(239, 243, 249, 1),
- borderRadius: BorderRadius.all(Radius.circular(4.0))
- ),
- child: Center(
- child: Text('寄件', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
- ),
- ),
- onTap: () {
- showDialog < Null > (
- context: context, //BuildContext对象
- barrierDismissible: false,
- builder: (BuildContext context) {
- return new LoadingDialog( //调用对话框
- text: '是否确认寄件', childCallback: (val) {
- if (val) {
- Navigator.push(
- context,
- MaterialPageRoute(
- builder: (BuildContext context) {
- return OrderDetailPage(orderNo: obj.orderNo,status: '寄件',);
- })
- ).then((resp) {
- if (resp == true) {
- deleteOrder(index);
- }
- });
- } else {
- return;
- }
- },
- );
- });
- print("寄件");
- },
- ),
- ],
- );
- }
-
- Widget _status2Fun(FromStatusGetOrderList obj, int index) {
- return Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: < Widget > [
- InkWell(
- child: Container(
- width: ScreenUtil.getInstance().setWidth(94),
- height: ScreenUtil.getInstance().setHeight(48),
- decoration: BoxDecoration(
- color: Color.fromRGBO(239, 243, 249, 1),
- borderRadius: BorderRadius.all(Radius.circular(4.0))
- ),
- child: Center(
- child: Text('作废', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
- ),
- ),
- onTap: () {
- showDialog < Null > (
- context: context, //BuildContext对象
- barrierDismissible: false,
- builder: (BuildContext context) {
- return new LoadingDialog( //调用对话框
- text: '是否确认作废', childCallback: (val) {
- if (val) {
- myUpdataOrder(obj.orderNo, 5, index);
- } else {
- return;
- }
- },
- );
- });
- print("作废");
- },
- ),
- InkWell(
- child: Container(
- width: ScreenUtil.getInstance().setWidth(94),
- height: ScreenUtil.getInstance().setHeight(48),
- decoration: BoxDecoration(
- color: Color.fromRGBO(239, 243, 249, 1),
- borderRadius: BorderRadius.all(Radius.circular(4.0))
- ),
- child: Center(
- child: Text('拒收', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
- ),
- ),
- onTap: () {
- showDialog < Null > (
- context: context, //BuildContext对象
- barrierDismissible: false,
- builder: (BuildContext context) {
- return new LoadingDialog( //调用对话框
- text: '是否确认拒收', childCallback: (val) {
- if (val) {
- myUpdataOrder(obj.orderNo, 4, index);
- } else {
- return;
- }
- },
- );
- });
- print("拒收");
- },
- ),
- InkWell(
- child: Container(
- width: ScreenUtil.getInstance().setWidth(94),
- height: ScreenUtil.getInstance().setHeight(48),
- decoration: BoxDecoration(
- color: Color.fromRGBO(239, 243, 249, 1),
- borderRadius: BorderRadius.all(Radius.circular(4.0))
- ),
- child: Center(
- child: Text('签收', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
- ),
- ),
- onTap: () {
- showDialog < Null > (
- context: context, //BuildContext对象
- barrierDismissible: false,
- builder: (BuildContext context) {
- return new LoadingDialog( //调用对话框
- text: '是否确认签收', childCallback: (val) {
- if (val) {
- myUpdataOrder(obj.orderNo, 3, index);
- } else {
- return;
- }
- },
- );
- });
- print("签收");
- },
- ),
- InkWell(
- child: Container(
- width: ScreenUtil.getInstance().setWidth(94),
- height: ScreenUtil.getInstance().setHeight(48),
- decoration: BoxDecoration(
- color: Color.fromRGBO(239, 243, 249, 1),
- borderRadius: BorderRadius.all(Radius.circular(4.0))
- ),
- child: Center(
- child: Text('改单', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
- ),
- ),
- onTap: () {
- showDialog < Null > (
- context: context, //BuildContext对象
- barrierDismissible: false,
- builder: (BuildContext context) {
- return new LoadingDialog( //调用对话框
- text: '是否确认改单', childCallback: (val) {
- if (val) {
- Navigator.push(
- context,
- MaterialPageRoute(
- builder: (BuildContext context) {
- return OrderDetailPage(orderNo: obj.orderNo,status: '改单',);
- })
- ).then((resp) {
- if (resp == true) {
- switchOrderFromStatus(orderStatus, page);
- }
- });
- } else {
- return;
- }
- },
- );
- });
- print("改单");
- },
- ),
- InkWell(
- child: Container(
- width: ScreenUtil.getInstance().setWidth(94),
- height: ScreenUtil.getInstance().setHeight(48),
- decoration: BoxDecoration(
- color: Color.fromRGBO(239, 243, 249, 1),
- borderRadius: BorderRadius.all(Radius.circular(4.0))
- ),
- child: Center(
- child: Text('打印', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
- ),
- ),
- onTap: () {
- showDialog < Null > (
- context: context, //BuildContext对象
- barrierDismissible: false,
- builder: (BuildContext context) {
- return new LoadingDialog( //调用对话框
- text: '是否确认打印', childCallback: (val) {
- if (val) {
- checkBlueToothAndPrintOrder(obj);
- } else {
- return;
- }
- },
- );
- });
- print("打印");
- },
- ),
- ],
- );
- }
-
- Widget _status3Fun(FromStatusGetOrderList obj, int index) {
- return Row(
- mainAxisAlignment: MainAxisAlignment.end,
- children: < Widget > [
- InkWell(
- child: Container(
- width: ScreenUtil.getInstance().setWidth(94),
- height: ScreenUtil.getInstance().setHeight(48),
- decoration: BoxDecoration(
- color: Color.fromRGBO(239, 243, 249, 1),
- borderRadius: BorderRadius.all(Radius.circular(4.0))
- ),
- child: Center(
- child: Text('打印', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
- ),
- ),
- onTap: () {
- showDialog < Null > (
- context: context, //BuildContext对象
- barrierDismissible: false,
- builder: (BuildContext context) {
- return new LoadingDialog( //调用对话框
- text: '是否确认打印', childCallback: (val) {
- if (val) {
- checkBlueToothAndPrintOrder(obj);
- } else {
- return;
- }
- },
- );
- });
- print("打印");
- },
- ),
- ],
- );
- }
- 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()
- )
- ],
- ),
- ),
- );
- }
- Widget _noMoreWidegt() {
- return Center(
- child: Padding(
- padding: EdgeInsets.all(10.0),
- child: Text(
- '没有更多数据了...',
- style: TextStyle(fontSize: 16.0),
- ),
- ),
- );
- }
- switchOrderFromStatus(int orderStatus, int page) {
- setState(() {
- orderList = null;
- });
- page = 1;
- fromStatusGetOrderList(orderStatus, page, _orderNo).then((resp) {
- if (isNotError(context, resp) && this.mounted) {
- FromStatusGetOrderObj tempObj = FromStatusGetOrderObj.fromJson(resp.data);
- setState(() {
- orderList = tempObj.data.items;
- hasNextPage = tempObj.data.hasNextPage;
- });
- }
- });
- }
- //扫描切换
- scanSearchOrder(){
- setState(() {
- orderList = [];
- });
- page = 1;
- getOrderDetail(_orderNo).then((resp) {
- if (isNotError(context, resp) && this.mounted) {
- OrderDetailData tempObj = OrderDetailObj.fromJson(resp.data).data;
- var tempJson = {
- "goods": tempObj.goods,
- "goodsAgencyFund": tempObj.goodsAgencyFund,
- "goodsFreight": tempObj.goodsFreight,
- "goodsQuantity": tempObj.goodsQuantity,
- "orderNo": tempObj.orderNo,
- "orderStatus": tempObj.orderStatus,
- "receiptCompanyName": tempObj.receiptCompanyName,
- "sendCompanyName": tempObj.sendCompanyName
- };
- FromStatusGetOrderList obj = FromStatusGetOrderList.fromJson(tempJson);
- if(obj.orderStatus==2){
- setState(() {
- statusList = [false, true, false];
- orderStatus = 2;
- });
-
- }else if(obj.orderStatus>=3){
- setState(() {
- statusList = [false, false, true];
- orderStatus = 3;
- });
- }
-
- setState(() {
- orderList.add(obj);
- hasNextPage = false;
- });
- }
- });
- }
-
- getMoreOrder(int orderStatus, int page) {
- if (!hasNextPage) {
- return;
- }
- loadMoreStatus = false;
- fromStatusGetOrderList(orderStatus, page, _orderNo).then((resp) {
- if (isNotError(context, resp) && this.mounted) {
- FromStatusGetOrderObj tempObj = FromStatusGetOrderObj.fromJson(resp.data);
- setState(() {
- orderList.addAll(tempObj.data.items);
- hasNextPage = tempObj.data.hasNextPage;
- });
- loadMoreStatus = true;
- } else {
- loadMoreStatus = true;
- }
- });
- }
- deleteOrder(int index) {
- setState(() {
- orderList.removeAt(index);
- });
- if (orderList.length < 4) {
- if (hasNextPage) {
- setState(() {
- page = ++page;
- });
- getMoreOrder(orderStatus, page);
- }
- }
- }
-
- myUpdataOrder(String myOrderNo, int myOrderStatus, int index) {
- updataOrderStatus(myOrderNo, myOrderStatus).then((resp) {
- if (isNotError(context, resp) && this.mounted) {
- deleteOrder(index);
- }else{
- OrderReception obj = OrderReception.fromJson(resp.data);
- showDialog < Null > (
- context: context, //BuildContext对象
- barrierDismissible: false,
- builder: (BuildContext context) {
- return new LoadingDialog( //调用对话框
- text: obj.msg, childCallback: (val) {
- },
- );
- });
- }
- });
- }
- Future refreshOrder() async {
- page = 1;
- await fromStatusGetOrderList(orderStatus, page, _orderNo).then((resp) {
- if (isNotError(context, resp) && this.mounted) {
- FromStatusGetOrderObj tempObj = FromStatusGetOrderObj.fromJson(resp.data);
- setState(() {
- orderList = tempObj.data.items;
- hasNextPage = tempObj.data.hasNextPage;
- });
- }
- });
- }
- 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){
- 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){});
- }
- );
- }
- });
- });
- });
-
- });
- });
- });
- }
- });
- }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){});
- }
- );
- }
- });
-
- }
- Future scan() async {
- try {
- String barcode = await BarcodeScanner.scan();
- setState(() {
- page=1;
- _orderNo = barcode;
- _orderController.text = barcode;
- });
- scanSearchOrder();
- } on PlatformException catch (e) {
- if (e.code == BarcodeScanner.CameraAccessDenied) {
- setState(() {
- return this.barcode = 'The user did not grant the camera permission!';
- });
- } else {
- setState(() {
- return this.barcode = 'Unknown error: $e';
- });
- }
- } on FormatException{
- setState(() => this.barcode = 'null (User returned using the "back"-button before scanning anything. Result)');
- } catch (e) {
- setState(() => this.barcode = 'Unknown error: $e');
- }
- }
- }
|