order_management_page.dart 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import 'dart:async';
  4. import 'order_management_page/order_detail_page.dart';
  5. import 'order_detail/order_detail.dart';
  6. import '../util/bluetooth_utils.dart';
  7. import '../util/session.dart';
  8. import '../showDialog.dart';
  9. import '../util/models.dart';
  10. import '../util/api.dart';
  11. import '../util/util.dart';
  12. class OrderManagementPage extends StatefulWidget {
  13. final Widget child;
  14. OrderManagementPage({
  15. Key key,
  16. this.child
  17. }): super(key: key);
  18. _OrderManagementPageState createState() => _OrderManagementPageState();
  19. }
  20. class _OrderManagementPageState extends State < OrderManagementPage > with AutomaticKeepAliveClientMixin {
  21. @override
  22. Widget build(BuildContext context) {
  23. return Container(
  24. child: Scaffold(
  25. appBar: AppBar(
  26. title: Text('订单管理', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(36)), ),
  27. centerTitle: true,
  28. backgroundColor: Color.fromRGBO(64, 98, 254, 1),
  29. ),
  30. body: Container(
  31. decoration: BoxDecoration(
  32. color: Color.fromRGBO(246, 246, 254, 1)
  33. ),
  34. child: QueryWidget()
  35. ),
  36. resizeToAvoidBottomPadding: false //键盘弹出,页面不跟随向上滑动,防止出现溢出错误
  37. )
  38. );
  39. }
  40. @override
  41. bool get wantKeepAlive => true;
  42. }
  43. class QueryWidget extends StatefulWidget { //搜索栏
  44. final Widget child;
  45. QueryWidget({
  46. Key key,
  47. this.child
  48. }): super(key: key);
  49. _QueryWidgetState createState() => _QueryWidgetState();
  50. }
  51. class _QueryWidgetState extends State < QueryWidget > {
  52. //单号的输入框控制器
  53. TextEditingController _orderController = TextEditingController();
  54. ScrollController _scrollController = ScrollController();
  55. GlobalKey _globalKey = GlobalKey(); //搜索栏key
  56. List < bool > statusList = [true, false, false];
  57. double inputPostX = 0;
  58. double inputPostY = 0;
  59. double inputWidth = 0;
  60. double inputHeight = 0;
  61. bool showStatus = true; //提示层显示状态
  62. String _orderNo = "";
  63. int orderStatus = 1; //0:代收单,1:待取件,2:运途中:已完成
  64. int page = 1;
  65. bool hasNextPage = true;
  66. BluetoothUtils bluetooth = BluetoothUtils();
  67. List < FromStatusGetOrderList > orderList = [];
  68. List likeOrderNoList = [];
  69. var timer;
  70. bool loadMoreStatus = true;
  71. @override
  72. void initState() {
  73. super.initState();
  74. switchOrderFromStatus(orderStatus, page);
  75. _scrollController.addListener(() {
  76. if (_scrollController.position.pixels == _scrollController.position.maxScrollExtent) {
  77. if (loadMoreStatus) {
  78. page = ++page;
  79. getMoreOrder(orderStatus, page);
  80. }
  81. }
  82. });
  83. }
  84. @override
  85. Widget build(BuildContext context) {
  86. return Stack(
  87. children: < Widget > [
  88. Container(
  89. child: Column(
  90. children: < Widget > [
  91. Container(
  92. color: Colors.white,
  93. height: ScreenUtil.getInstance().setHeight(222),
  94. padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(20), ScreenUtil.getInstance().setWidth(20), ScreenUtil.getInstance().setWidth(20), 0),
  95. child: Column(
  96. children: < Widget > [
  97. Container(
  98. key: _globalKey,
  99. height: ScreenUtil.getInstance().setHeight(100),
  100. decoration: BoxDecoration(
  101. border: Border.all(color: Color.fromRGBO(204, 204, 204, 1), width: 1),
  102. borderRadius: BorderRadius.all(Radius.circular(5))
  103. ),
  104. child: Row(
  105. children: < Widget > [
  106. Expanded(
  107. child: TextField(
  108. controller: _orderController,
  109. keyboardType: TextInputType.number,
  110. autocorrect: true,
  111. decoration: InputDecoration(
  112. border: InputBorder.none,
  113. hintText: "输入运单号后6位查询物流",
  114. hintStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(26), color: Color.fromRGBO(155, 155, 155, 1)),
  115. contentPadding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(30), 0, ScreenUtil.getInstance().setWidth(30), 0)
  116. ),
  117. onTap: () {
  118. RenderObject inputObj = _globalKey.currentContext.findRenderObject();
  119. setState(() {
  120. inputWidth = inputObj.paintBounds.size.width;
  121. inputHeight = inputObj.paintBounds.size.height;
  122. inputPostX = inputObj.getTransformTo(null).getTranslation().x;
  123. inputPostY = ScreenUtil.getInstance().setWidth(20) + inputHeight;
  124. });
  125. },
  126. onChanged: ((value) {
  127. setState(() {
  128. _orderNo = value;
  129. });
  130. if (timer != null) {
  131. timer.cancel();
  132. }
  133. timer = Timer(Duration(milliseconds: 500), () {
  134. if (_orderNo.length >= 6) {
  135. orderNoLike(_orderNo, orderStatus).then((resp) {
  136. if (isNotError(context, resp) && this.mounted) {
  137. LikeOrderNo tempObj = LikeOrderNo.fromJson(resp.data);
  138. if (tempObj.data.length > 0) {
  139. setState(() {
  140. likeOrderNoList = tempObj.data;
  141. showStatus = false;
  142. });
  143. }
  144. }
  145. });
  146. } else {
  147. setState(() {
  148. showStatus = true;
  149. });
  150. }
  151. });
  152. }),
  153. onEditingComplete: () {
  154. FocusScope.of(context).requestFocus(FocusNode());
  155. setState(() {
  156. showStatus = true;
  157. });
  158. },
  159. ),
  160. ),
  161. IconButton(
  162. icon: Image.asset('lib/images/icon_saoyisao.png',
  163. width: ScreenUtil.getInstance().setWidth(38),
  164. height: ScreenUtil.getInstance().setHeight(36),
  165. ),
  166. onPressed: () {},
  167. ),
  168. GestureDetector(
  169. child: Container(
  170. width: ScreenUtil.getInstance().setWidth(120),
  171. decoration: BoxDecoration(
  172. 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)), )
  173. ),
  174. child: Center(
  175. child: Text("查询", style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(26), color: Color.fromRGBO(64, 98, 254, 1)), ),
  176. ),
  177. ),
  178. onTap: () {
  179. print("查询");
  180. }
  181. ),
  182. ],
  183. ),
  184. ),
  185. Container(
  186. height: ScreenUtil.getInstance().setHeight(100),
  187. child: Container(
  188. padding: EdgeInsets.only(top: ScreenUtil.getInstance().setHeight(25)),
  189. child: Row(
  190. mainAxisAlignment: MainAxisAlignment.spaceAround,
  191. children: < Widget > [
  192. GestureDetector(
  193. child: Container(
  194. height: ScreenUtil.getInstance().setHeight(80),
  195. decoration: BoxDecoration(
  196. border: statusList[0] ? Border(bottom: BorderSide.merge(BorderSide(color: Colors.black, width: 1), BorderSide(color: Colors.black, width: 0)), ) : Border()
  197. ),
  198. child: Center(
  199. child: Text("待取件", style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: statusList[0] ? Colors.black : Color.fromRGBO(155, 155, 155, 1)), ),
  200. )
  201. ),
  202. onTap: () {
  203. if (statusList[0]) {
  204. return;
  205. } else {
  206. setState(() {
  207. statusList = [true, false, false];
  208. orderStatus = 1;
  209. });
  210. switchOrderFromStatus(orderStatus, page);
  211. }
  212. },
  213. ),
  214. GestureDetector(
  215. child: Container(
  216. height: ScreenUtil.getInstance().setHeight(80),
  217. decoration: BoxDecoration(
  218. border: statusList[1] ? Border(bottom: BorderSide.merge(BorderSide(color: Colors.black, width: 1), BorderSide(color: Colors.black, width: 0)), ) : Border()
  219. ),
  220. child: Center(
  221. child: Text("运途中", style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: statusList[1] ? Colors.black : Color.fromRGBO(155, 155, 155, 1)), ),
  222. )
  223. ),
  224. onTap: () {
  225. if (statusList[1]) {
  226. return;
  227. } else {
  228. setState(() {
  229. statusList = [false, true, false];
  230. orderStatus = 2;
  231. });
  232. switchOrderFromStatus(orderStatus, page);
  233. }
  234. },
  235. ),
  236. GestureDetector(
  237. child: Container(
  238. height: ScreenUtil.getInstance().setHeight(80),
  239. decoration: BoxDecoration(
  240. border: statusList[2] ? Border(bottom: BorderSide.merge(BorderSide(color: Colors.black, width: 1), BorderSide(color: Colors.black, width: 0)), ) : Border()
  241. ),
  242. child: Center(
  243. child: Text("已完成", style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: statusList[2] ? Colors.black : Color.fromRGBO(155, 155, 155, 1)), ),
  244. )
  245. ),
  246. onTap: () {
  247. if (statusList[2]) {
  248. return;
  249. } else {
  250. setState(() {
  251. statusList = [false, false, true];
  252. orderStatus = 3;
  253. });
  254. switchOrderFromStatus(orderStatus, page);
  255. }
  256. },
  257. ),
  258. ],
  259. )
  260. )
  261. ),
  262. ],
  263. )
  264. ),
  265. Expanded(
  266. child: Container(
  267. padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(20), ScreenUtil.getInstance().setWidth(20), ScreenUtil.getInstance().setWidth(20), 0),
  268. child: orderList == null ? Center(
  269. child: _getMoreWidget()
  270. ) : orderList.length == 0 ?
  271. Center(
  272. child: Text('暂无订单'),
  273. ) :
  274. RefreshIndicator(
  275. onRefresh: refreshOrder,
  276. child: ListView.builder(
  277. physics: AlwaysScrollableScrollPhysics(),
  278. controller: _scrollController,
  279. itemCount: orderList.length + 1,
  280. itemBuilder: (BuildContext context, int index) {
  281. if (index < orderList.length) {
  282. return _cardWiget(orderList[index], index);
  283. }
  284. if (hasNextPage) {
  285. return _getMoreWidget();
  286. } else {
  287. return _noMoreWidegt();
  288. }
  289. },
  290. )
  291. )
  292. ),
  293. )
  294. ],
  295. )
  296. ),
  297. Positioned(
  298. left: inputPostX,
  299. top: inputPostY,
  300. child: Offstage(
  301. offstage: showStatus,
  302. child:
  303. Container(
  304. width: inputWidth,
  305. height: ScreenUtil.getInstance().setHeight(320),
  306. margin: EdgeInsets.only(top: ScreenUtil.getInstance().setHeight(1)),
  307. decoration: BoxDecoration(
  308. color: Color.fromRGBO(244, 248, 251, 1),
  309. border: Border.all(color: Color.fromRGBO(204, 204, 204, 1), width: 1),
  310. borderRadius: BorderRadius.all(Radius.circular(5))
  311. ),
  312. child: ListView.builder(
  313. itemCount: likeOrderNoList.length,
  314. itemBuilder: (BuildContext context, int index) {
  315. return InkWell(
  316. child: Padding(
  317. padding: EdgeInsets.all(10),
  318. child: Text(likeOrderNoList[index]),
  319. ),
  320. onTap: () {
  321. setState(() {
  322. page = 1;
  323. _orderNo = likeOrderNoList[index];
  324. });
  325. fromStatusGetOrderList(orderStatus, page, likeOrderNoList[index]).then((resp) {
  326. if (isNotError(context, resp) && this.mounted) {
  327. FromStatusGetOrderObj tempObj = FromStatusGetOrderObj.fromJson(resp.data);
  328. setState(() {
  329. orderList = tempObj.data.items;
  330. hasNextPage = tempObj.data.hasNextPage;
  331. });
  332. }
  333. });
  334. setState(() {
  335. _orderController.text = likeOrderNoList[index];
  336. showStatus = true;
  337. FocusScope.of(context).requestFocus(FocusNode());
  338. });
  339. },
  340. );
  341. },
  342. ),
  343. ),
  344. )
  345. )
  346. ],
  347. );
  348. }
  349. Widget _cardWiget(FromStatusGetOrderList obj, int index) {
  350. Map < int, String > statusMap = {
  351. 1: '待取货',
  352. 2: '运途中',
  353. 3: '已签收',
  354. 4: '已拒收',
  355. 5: '已作废',
  356. 6: '已取消'
  357. };
  358. return InkWell(
  359. child: Card(
  360. color: Colors.white,
  361. child: Container(
  362. padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(20)),
  363. child: Column(
  364. children: < Widget > [
  365. Padding(
  366. padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(30)),
  367. child: Row(
  368. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  369. children: < Widget > [
  370. Text('订单号:${obj.orderNo}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(102, 102, 102, 1)), ),
  371. Text('${statusMap[obj.orderStatus]}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(126, 211, 33, 1)), ),
  372. ],
  373. )
  374. ),
  375. Padding(
  376. padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  377. child: Row(
  378. children: < Widget > [
  379. Text('${obj.sendCompanyName} --> ${obj.receiptCompanyName}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30)), ),
  380. ],
  381. )
  382. ),
  383. Padding(
  384. padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(15)),
  385. child: Row(
  386. children: < Widget > [
  387. SizedBox(
  388. width: ScreenUtil.getInstance().setWidth(355),
  389. child: Text('货物名称:${obj.goods}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(155, 155, 155, 1)), ),
  390. ),
  391. Text('代收款:${obj.goodsAgencyFund/100}元', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(155, 155, 155, 1)), ),
  392. ],
  393. ),
  394. ),
  395. Padding(
  396. padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(30)),
  397. child: Row(
  398. children: < Widget > [
  399. SizedBox(
  400. width: ScreenUtil.getInstance().setWidth(355),
  401. child: Text('货物件数:${obj.goodsQuantity}件', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(155, 155, 155, 1)), ),
  402. ),
  403. Text('运费:${obj.goodsFreight/100}元', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(155, 155, 155, 1)), ),
  404. ],
  405. ),
  406. ),
  407. Padding(
  408. padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  409. child: Container(
  410. height: ScreenUtil.getInstance().setHeight(1),
  411. color: Color.fromRGBO(223, 223, 223, 1),
  412. ),
  413. ),
  414. orderStatus == 1 ? _status1Fun(obj, index) : orderStatus == 2 ? _status2Fun(obj, index) : _status3Fun(obj, index)
  415. ],
  416. ),
  417. )
  418. ),
  419. onTap: () {
  420. Navigator.push(
  421. context,
  422. MaterialPageRoute(
  423. builder: (BuildContext context) {
  424. return OrderDetailsPage(orderNo: obj.orderNo);
  425. })
  426. );
  427. },
  428. );
  429. }
  430. Widget _status1Fun(FromStatusGetOrderList obj, int index) {
  431. return Row(
  432. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  433. children: < Widget > [
  434. InkWell(
  435. child: Container(
  436. width: ScreenUtil.getInstance().setWidth(94),
  437. height: ScreenUtil.getInstance().setHeight(48),
  438. decoration: BoxDecoration(
  439. color: Color.fromRGBO(239, 243, 249, 1),
  440. borderRadius: BorderRadius.all(Radius.circular(4.0))
  441. ),
  442. child: Center(
  443. child: Text('作废', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  444. ),
  445. ),
  446. onTap: () {
  447. showDialog < Null > (
  448. context: context, //BuildContext对象
  449. barrierDismissible: false,
  450. builder: (BuildContext context) {
  451. return new LoadingDialog( //调用对话框
  452. text: '是否确认作废', childCallback: (val) {
  453. if (val) {
  454. myUpdataOrder(obj.orderNo, 5, index);
  455. } else {
  456. return;
  457. }
  458. },
  459. );
  460. });
  461. print("作废");
  462. },
  463. ),
  464. InkWell(
  465. child: Container(
  466. width: ScreenUtil.getInstance().setWidth(94),
  467. height: ScreenUtil.getInstance().setHeight(48),
  468. decoration: BoxDecoration(
  469. color: Color.fromRGBO(239, 243, 249, 1),
  470. borderRadius: BorderRadius.all(Radius.circular(4.0))
  471. ),
  472. child: Center(
  473. child: Text('寄件', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  474. ),
  475. ),
  476. onTap: () {
  477. showDialog < Null > (
  478. context: context, //BuildContext对象
  479. barrierDismissible: false,
  480. builder: (BuildContext context) {
  481. return new LoadingDialog( //调用对话框
  482. text: '是否确认寄件', childCallback: (val) {
  483. if (val) {
  484. Navigator.push(
  485. context,
  486. MaterialPageRoute(
  487. builder: (BuildContext context) {
  488. return OrderDetailPage(orderNo: obj.orderNo);
  489. })
  490. ).then((resp) {
  491. if (resp == true) {
  492. deleteOrder(index);
  493. }
  494. });
  495. } else {
  496. return;
  497. }
  498. },
  499. );
  500. });
  501. print("寄件");
  502. },
  503. ),
  504. ],
  505. );
  506. }
  507. Widget _status2Fun(FromStatusGetOrderList obj, int index) {
  508. return Row(
  509. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  510. children: < Widget > [
  511. InkWell(
  512. child: Container(
  513. width: ScreenUtil.getInstance().setWidth(94),
  514. height: ScreenUtil.getInstance().setHeight(48),
  515. decoration: BoxDecoration(
  516. color: Color.fromRGBO(239, 243, 249, 1),
  517. borderRadius: BorderRadius.all(Radius.circular(4.0))
  518. ),
  519. child: Center(
  520. child: Text('作废', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  521. ),
  522. ),
  523. onTap: () {
  524. showDialog < Null > (
  525. context: context, //BuildContext对象
  526. barrierDismissible: false,
  527. builder: (BuildContext context) {
  528. return new LoadingDialog( //调用对话框
  529. text: '是否确认作废', childCallback: (val) {
  530. if (val) {
  531. myUpdataOrder(obj.orderNo, 5, index);
  532. } else {
  533. return;
  534. }
  535. },
  536. );
  537. });
  538. print("作废");
  539. },
  540. ),
  541. InkWell(
  542. child: Container(
  543. width: ScreenUtil.getInstance().setWidth(94),
  544. height: ScreenUtil.getInstance().setHeight(48),
  545. decoration: BoxDecoration(
  546. color: Color.fromRGBO(239, 243, 249, 1),
  547. borderRadius: BorderRadius.all(Radius.circular(4.0))
  548. ),
  549. child: Center(
  550. child: Text('拒收', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  551. ),
  552. ),
  553. onTap: () {
  554. showDialog < Null > (
  555. context: context, //BuildContext对象
  556. barrierDismissible: false,
  557. builder: (BuildContext context) {
  558. return new LoadingDialog( //调用对话框
  559. text: '是否确认拒收', childCallback: (val) {
  560. if (val) {
  561. myUpdataOrder(obj.orderNo, 4, index);
  562. } else {
  563. return;
  564. }
  565. },
  566. );
  567. });
  568. print("拒收");
  569. },
  570. ),
  571. InkWell(
  572. child: Container(
  573. width: ScreenUtil.getInstance().setWidth(94),
  574. height: ScreenUtil.getInstance().setHeight(48),
  575. decoration: BoxDecoration(
  576. color: Color.fromRGBO(239, 243, 249, 1),
  577. borderRadius: BorderRadius.all(Radius.circular(4.0))
  578. ),
  579. child: Center(
  580. child: Text('签收', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  581. ),
  582. ),
  583. onTap: () {
  584. showDialog < Null > (
  585. context: context, //BuildContext对象
  586. barrierDismissible: false,
  587. builder: (BuildContext context) {
  588. return new LoadingDialog( //调用对话框
  589. text: '是否确认签收', childCallback: (val) {
  590. if (val) {
  591. myUpdataOrder(obj.orderNo, 3, index);
  592. } else {
  593. return;
  594. }
  595. },
  596. );
  597. });
  598. print("签收");
  599. },
  600. ),
  601. InkWell(
  602. child: Container(
  603. width: ScreenUtil.getInstance().setWidth(94),
  604. height: ScreenUtil.getInstance().setHeight(48),
  605. decoration: BoxDecoration(
  606. color: Color.fromRGBO(239, 243, 249, 1),
  607. borderRadius: BorderRadius.all(Radius.circular(4.0))
  608. ),
  609. child: Center(
  610. child: Text('改单', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  611. ),
  612. ),
  613. onTap: () {
  614. showDialog < Null > (
  615. context: context, //BuildContext对象
  616. barrierDismissible: false,
  617. builder: (BuildContext context) {
  618. return new LoadingDialog( //调用对话框
  619. text: '是否确认改单', childCallback: (val) {
  620. if (val) {
  621. Navigator.push(
  622. context,
  623. MaterialPageRoute(
  624. builder: (BuildContext context) {
  625. return OrderDetailPage(orderNo: obj.orderNo);
  626. })
  627. ).then((resp) {
  628. if (resp == true) {
  629. switchOrderFromStatus(orderStatus, page);
  630. }
  631. });
  632. } else {
  633. return;
  634. }
  635. },
  636. );
  637. });
  638. print("改单");
  639. },
  640. ),
  641. InkWell(
  642. child: Container(
  643. width: ScreenUtil.getInstance().setWidth(94),
  644. height: ScreenUtil.getInstance().setHeight(48),
  645. decoration: BoxDecoration(
  646. color: Color.fromRGBO(239, 243, 249, 1),
  647. borderRadius: BorderRadius.all(Radius.circular(4.0))
  648. ),
  649. child: Center(
  650. child: Text('打印', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  651. ),
  652. ),
  653. onTap: () {
  654. showDialog < Null > (
  655. context: context, //BuildContext对象
  656. barrierDismissible: false,
  657. builder: (BuildContext context) {
  658. return new LoadingDialog( //调用对话框
  659. text: '是否确认打印', childCallback: (val) {
  660. if (val) {
  661. getOrderDetail(obj.orderNo).then((resp){
  662. if(isNotError(context, resp) && this.mounted){
  663. OrderDetailData data = OrderDetailObj.fromJson(resp.data).data;
  664. getKey('printType').then((printType){
  665. getKey('stationName').then((stationName){
  666. getKey('nickName').then((nickName){
  667. double goodsYs = (data.goodsFreight/100)+(data.goodsAgencyFund/100);
  668. String nowDate = fromatDate( DateTime.now().millisecondsSinceEpoch);//打印时间
  669. String createTime = fromatDate(data.createTime);
  670. double goodsAgencyFunds = data.goodsAgencyFund/100;
  671. double goodsDFreight = data.goodsPaymentMethod==1?data.goodsFreight/100:0;
  672. double goodsXFreight = data.goodsPaymentMethod==2?data.goodsFreight/100:0;
  673. String receiptAddress = data.receiptCompanyAddress.length>10?data.receiptCompanyAddress.substring(0,10):data.receiptCompanyAddress;
  674. Map<String, String> pum = {
  675. "[logisticsNo]": "${data.orderNo ?? ''}",
  676. "[createTime]": "$createTime",
  677. "[sendStationName]": "$stationName",
  678. "[dealerCode]": "${data.sendCompanyCode ?? ''}",
  679. "[dealerName]": "${data.sendCompanyName}",
  680. "[dealerTel]": "${data.sendCompanyPhone ?? ''}",
  681. "[repairName]": "${data.receiptCompanyName ?? ''}",
  682. "[repairTel]": "${data.receiptCompanyPhone ?? ''}",
  683. "[endStationName]": "收件站点",
  684. "[goodsLineCode]": "${data.lineCode ?? ''}",
  685. "[goodsLine]": "${data.lineName ?? ''}",
  686. "[repairAddress]": "${receiptAddress?? ''}",
  687. "[goodsQuantity]": "${data.goodsQuantity ?? ''}",
  688. "[goodsInsurance]": "${data.goodsInsurance ?? ''}",
  689. "[goodsFlatCost]": "${data.goodsFlatCost ?? ''}",
  690. // 到付 现付 金额
  691. "[goodsDFreight]": "$goodsDFreight",
  692. "[goodsXFreight]": "$goodsXFreight",
  693. "[goodsAgencyFund]": "$goodsAgencyFunds",
  694. "[goodsYs]": "$goodsYs",
  695. "[dealerBankAccount]": "${data.sendCompanyBankCard ?? ''}",
  696. "[goodsRemark]": "${data.memo ?? ''}",
  697. "[realName]": "${nickName?? ''}",
  698. "[currentTime]": "$nowDate",
  699. "[currentGoodNumber]": "1/1",
  700. };
  701. bluetooth.printOrder(pum, int.parse(printType));
  702. });
  703. });
  704. });
  705. }
  706. });
  707. } else {
  708. return;
  709. }
  710. },
  711. );
  712. });
  713. print("打印");
  714. },
  715. ),
  716. ],
  717. );
  718. }
  719. Widget _status3Fun(FromStatusGetOrderList obj, int index) {
  720. return Row(
  721. mainAxisAlignment: MainAxisAlignment.end,
  722. children: < Widget > [
  723. InkWell(
  724. child: Container(
  725. width: ScreenUtil.getInstance().setWidth(94),
  726. height: ScreenUtil.getInstance().setHeight(48),
  727. decoration: BoxDecoration(
  728. color: Color.fromRGBO(239, 243, 249, 1),
  729. borderRadius: BorderRadius.all(Radius.circular(4.0))
  730. ),
  731. child: Center(
  732. child: Text('打印', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  733. ),
  734. ),
  735. onTap: () {
  736. showDialog < Null > (
  737. context: context, //BuildContext对象
  738. barrierDismissible: false,
  739. builder: (BuildContext context) {
  740. return new LoadingDialog( //调用对话框
  741. text: '是否确认打印', childCallback: (val) {
  742. if (val) {
  743. //widget.callback(widget.index);
  744. } else {
  745. return;
  746. }
  747. },
  748. );
  749. });
  750. print("打印");
  751. },
  752. ),
  753. ],
  754. );
  755. }
  756. Widget _getMoreWidget() {
  757. return Center(
  758. child: Padding(
  759. padding: EdgeInsets.all(10.0),
  760. child: Row(
  761. mainAxisAlignment: MainAxisAlignment.center,
  762. crossAxisAlignment: CrossAxisAlignment.center,
  763. children: < Widget > [
  764. Text(
  765. '加载中...',
  766. style: TextStyle(fontSize: 16.0),
  767. ),
  768. Container(
  769. width: ScreenUtil.getInstance().setWidth(50),
  770. height: ScreenUtil.getInstance().setHeight(50),
  771. child: CircularProgressIndicator()
  772. )
  773. ],
  774. ),
  775. ),
  776. );
  777. }
  778. Widget _noMoreWidegt() {
  779. return Center(
  780. child: Padding(
  781. padding: EdgeInsets.all(10.0),
  782. child: Text(
  783. '没有更多数据了...',
  784. style: TextStyle(fontSize: 16.0),
  785. ),
  786. ),
  787. );
  788. }
  789. switchOrderFromStatus(int orderStatus, int page) {
  790. setState(() {
  791. orderList = null;
  792. });
  793. page = 1;
  794. fromStatusGetOrderList(orderStatus, page, _orderNo).then((resp) {
  795. if (isNotError(context, resp) && this.mounted) {
  796. FromStatusGetOrderObj tempObj = FromStatusGetOrderObj.fromJson(resp.data);
  797. setState(() {
  798. orderList = tempObj.data.items;
  799. hasNextPage = tempObj.data.hasNextPage;
  800. });
  801. }
  802. });
  803. }
  804. getMoreOrder(int orderStatus, int page) {
  805. if (!hasNextPage) {
  806. return;
  807. }
  808. loadMoreStatus = false;
  809. fromStatusGetOrderList(orderStatus, page, _orderNo).then((resp) {
  810. if (isNotError(context, resp) && this.mounted) {
  811. FromStatusGetOrderObj tempObj = FromStatusGetOrderObj.fromJson(resp.data);
  812. setState(() {
  813. orderList.addAll(tempObj.data.items);
  814. hasNextPage = tempObj.data.hasNextPage;
  815. });
  816. loadMoreStatus = true;
  817. } else {
  818. loadMoreStatus = true;
  819. }
  820. });
  821. }
  822. deleteOrder(int index) {
  823. setState(() {
  824. orderList.removeAt(index);
  825. });
  826. if (orderList.length < 4) {
  827. if (hasNextPage) {
  828. setState(() {
  829. page = ++page;
  830. });
  831. getMoreOrder(orderStatus, page);
  832. }
  833. }
  834. }
  835. myUpdataOrder(String myOrderNo, int myOrderStatus, int index) {
  836. updataOrderStatus(myOrderNo, myOrderStatus).then((resp) {
  837. if (isNotError(context, resp) && this.mounted) {
  838. deleteOrder(index);
  839. }
  840. });
  841. }
  842. Future refreshOrder() async {
  843. page = 1;
  844. await fromStatusGetOrderList(orderStatus, page, _orderNo).then((resp) {
  845. if (isNotError(context, resp) && this.mounted) {
  846. FromStatusGetOrderObj tempObj = FromStatusGetOrderObj.fromJson(resp.data);
  847. setState(() {
  848. orderList = tempObj.data.items;
  849. hasNextPage = tempObj.data.hasNextPage;
  850. });
  851. }
  852. });
  853. }
  854. }