order_management_page.dart 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872
  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. };
  357. return InkWell(
  358. child: Card(
  359. color: Colors.white,
  360. child: Container(
  361. padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(20)),
  362. child: Column(
  363. children: < Widget > [
  364. Padding(
  365. padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(30)),
  366. child: Row(
  367. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  368. children: < Widget > [
  369. Text('订单号:${obj.orderNo}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(102, 102, 102, 1)), ),
  370. Text('${statusMap[obj.orderStatus]}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(126, 211, 33, 1)), ),
  371. ],
  372. )
  373. ),
  374. Padding(
  375. padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  376. child: Row(
  377. children: < Widget > [
  378. Text('${obj.sendCompanyName} --> ${obj.receiptCompanyName}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30)), ),
  379. ],
  380. )
  381. ),
  382. Padding(
  383. padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(15)),
  384. child: Row(
  385. children: < Widget > [
  386. SizedBox(
  387. width: ScreenUtil.getInstance().setWidth(355),
  388. child: Text('货物名称:${obj.goods}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(155, 155, 155, 1)), ),
  389. ),
  390. Text('代收款:${obj.goodsAgencyFund/100}元', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(155, 155, 155, 1)), ),
  391. ],
  392. ),
  393. ),
  394. Padding(
  395. padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(30)),
  396. child: Row(
  397. children: < Widget > [
  398. SizedBox(
  399. width: ScreenUtil.getInstance().setWidth(355),
  400. child: Text('货物件数:${obj.goodsQuantity}件', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(155, 155, 155, 1)), ),
  401. ),
  402. Text('运费:${obj.goodsFreight/100}元', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(155, 155, 155, 1)), ),
  403. ],
  404. ),
  405. ),
  406. Padding(
  407. padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  408. child: Container(
  409. height: ScreenUtil.getInstance().setHeight(1),
  410. color: Color.fromRGBO(223, 223, 223, 1),
  411. ),
  412. ),
  413. orderStatus == 1 ? _status1Fun(obj, index) : orderStatus == 2 ? _status2Fun(obj, index) : _status3Fun(obj, index)
  414. ],
  415. ),
  416. )
  417. ),
  418. onTap: () {
  419. Navigator.push(
  420. context,
  421. MaterialPageRoute(
  422. builder: (BuildContext context) {
  423. return OrderDetailsPage(orderNo: obj.orderNo);
  424. })
  425. );
  426. },
  427. );
  428. }
  429. Widget _status1Fun(FromStatusGetOrderList obj, int index) {
  430. return Row(
  431. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  432. children: < Widget > [
  433. InkWell(
  434. child: Container(
  435. width: ScreenUtil.getInstance().setWidth(94),
  436. height: ScreenUtil.getInstance().setHeight(48),
  437. decoration: BoxDecoration(
  438. color: Color.fromRGBO(239, 243, 249, 1),
  439. borderRadius: BorderRadius.all(Radius.circular(4.0))
  440. ),
  441. child: Center(
  442. child: Text('作废', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  443. ),
  444. ),
  445. onTap: () {
  446. showDialog < Null > (
  447. context: context, //BuildContext对象
  448. barrierDismissible: false,
  449. builder: (BuildContext context) {
  450. return new LoadingDialog( //调用对话框
  451. text: '是否确认作废', childCallback: (val) {
  452. if (val) {
  453. myUpdataOrder(obj.orderNo, 5, index);
  454. } else {
  455. return;
  456. }
  457. },
  458. );
  459. });
  460. print("作废");
  461. },
  462. ),
  463. InkWell(
  464. child: Container(
  465. width: ScreenUtil.getInstance().setWidth(94),
  466. height: ScreenUtil.getInstance().setHeight(48),
  467. decoration: BoxDecoration(
  468. color: Color.fromRGBO(239, 243, 249, 1),
  469. borderRadius: BorderRadius.all(Radius.circular(4.0))
  470. ),
  471. child: Center(
  472. child: Text('寄件', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  473. ),
  474. ),
  475. onTap: () {
  476. showDialog < Null > (
  477. context: context, //BuildContext对象
  478. barrierDismissible: false,
  479. builder: (BuildContext context) {
  480. return new LoadingDialog( //调用对话框
  481. text: '是否确认寄件', childCallback: (val) {
  482. if (val) {
  483. Navigator.push(
  484. context,
  485. MaterialPageRoute(
  486. builder: (BuildContext context) {
  487. return OrderDetailPage(orderNo: obj.orderNo);
  488. })
  489. ).then((resp) {
  490. if (resp == true) {
  491. deleteOrder(index);
  492. }
  493. });
  494. } else {
  495. return;
  496. }
  497. },
  498. );
  499. });
  500. print("寄件");
  501. },
  502. ),
  503. ],
  504. );
  505. }
  506. Widget _status2Fun(FromStatusGetOrderList obj, int index) {
  507. return Row(
  508. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  509. children: < Widget > [
  510. InkWell(
  511. child: Container(
  512. width: ScreenUtil.getInstance().setWidth(94),
  513. height: ScreenUtil.getInstance().setHeight(48),
  514. decoration: BoxDecoration(
  515. color: Color.fromRGBO(239, 243, 249, 1),
  516. borderRadius: BorderRadius.all(Radius.circular(4.0))
  517. ),
  518. child: Center(
  519. child: Text('作废', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  520. ),
  521. ),
  522. onTap: () {
  523. showDialog < Null > (
  524. context: context, //BuildContext对象
  525. barrierDismissible: false,
  526. builder: (BuildContext context) {
  527. return new LoadingDialog( //调用对话框
  528. text: '是否确认作废', childCallback: (val) {
  529. if (val) {
  530. myUpdataOrder(obj.orderNo, 5, index);
  531. } else {
  532. return;
  533. }
  534. },
  535. );
  536. });
  537. print("作废");
  538. },
  539. ),
  540. InkWell(
  541. child: Container(
  542. width: ScreenUtil.getInstance().setWidth(94),
  543. height: ScreenUtil.getInstance().setHeight(48),
  544. decoration: BoxDecoration(
  545. color: Color.fromRGBO(239, 243, 249, 1),
  546. borderRadius: BorderRadius.all(Radius.circular(4.0))
  547. ),
  548. child: Center(
  549. child: Text('拒收', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  550. ),
  551. ),
  552. onTap: () {
  553. showDialog < Null > (
  554. context: context, //BuildContext对象
  555. barrierDismissible: false,
  556. builder: (BuildContext context) {
  557. return new LoadingDialog( //调用对话框
  558. text: '是否确认拒收', childCallback: (val) {
  559. if (val) {
  560. myUpdataOrder(obj.orderNo, 4, index);
  561. } else {
  562. return;
  563. }
  564. },
  565. );
  566. });
  567. print("拒收");
  568. },
  569. ),
  570. InkWell(
  571. child: Container(
  572. width: ScreenUtil.getInstance().setWidth(94),
  573. height: ScreenUtil.getInstance().setHeight(48),
  574. decoration: BoxDecoration(
  575. color: Color.fromRGBO(239, 243, 249, 1),
  576. borderRadius: BorderRadius.all(Radius.circular(4.0))
  577. ),
  578. child: Center(
  579. child: Text('签收', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  580. ),
  581. ),
  582. onTap: () {
  583. showDialog < Null > (
  584. context: context, //BuildContext对象
  585. barrierDismissible: false,
  586. builder: (BuildContext context) {
  587. return new LoadingDialog( //调用对话框
  588. text: '是否确认签收', childCallback: (val) {
  589. if (val) {
  590. myUpdataOrder(obj.orderNo, 3, index);
  591. } else {
  592. return;
  593. }
  594. },
  595. );
  596. });
  597. print("签收");
  598. },
  599. ),
  600. InkWell(
  601. child: Container(
  602. width: ScreenUtil.getInstance().setWidth(94),
  603. height: ScreenUtil.getInstance().setHeight(48),
  604. decoration: BoxDecoration(
  605. color: Color.fromRGBO(239, 243, 249, 1),
  606. borderRadius: BorderRadius.all(Radius.circular(4.0))
  607. ),
  608. child: Center(
  609. child: Text('改单', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  610. ),
  611. ),
  612. onTap: () {
  613. showDialog < Null > (
  614. context: context, //BuildContext对象
  615. barrierDismissible: false,
  616. builder: (BuildContext context) {
  617. return new LoadingDialog( //调用对话框
  618. text: '是否确认改单', childCallback: (val) {
  619. if (val) {
  620. Navigator.push(
  621. context,
  622. MaterialPageRoute(
  623. builder: (BuildContext context) {
  624. return OrderDetailPage(orderNo: obj.orderNo);
  625. })
  626. ).then((resp) {
  627. if (resp == true) {
  628. switchOrderFromStatus(orderStatus, page);
  629. }
  630. });
  631. } else {
  632. return;
  633. }
  634. },
  635. );
  636. });
  637. print("改单");
  638. },
  639. ),
  640. InkWell(
  641. child: Container(
  642. width: ScreenUtil.getInstance().setWidth(94),
  643. height: ScreenUtil.getInstance().setHeight(48),
  644. decoration: BoxDecoration(
  645. color: Color.fromRGBO(239, 243, 249, 1),
  646. borderRadius: BorderRadius.all(Radius.circular(4.0))
  647. ),
  648. child: Center(
  649. child: Text('打印', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  650. ),
  651. ),
  652. onTap: () {
  653. showDialog < Null > (
  654. context: context, //BuildContext对象
  655. barrierDismissible: false,
  656. builder: (BuildContext context) {
  657. return new LoadingDialog( //调用对话框
  658. text: '是否确认打印', childCallback: (val) {
  659. if (val) {
  660. getOrderDetail(obj.orderNo).then((resp){
  661. if(isNotError(context, resp) && this.mounted){
  662. OrderDetailData data = OrderDetailObj.fromJson(resp.data).data;
  663. getKey('printType').then((printType){
  664. getKey('stationName').then((stationName){
  665. getKey('nickName').then((nickName){
  666. double goodsYs = (obj.goodsFreight/100)+(obj.goodsAgencyFund/100);
  667. String nowDate = fromatDate( DateTime.now().millisecondsSinceEpoch);//打印时间
  668. double goodsAgencyFunds = double.parse(resp.goodsAgencyFunds/100);
  669. double goodsDFreight = 0;
  670. double goodsXFreight = 0;
  671. // Map<String, String> pum = {
  672. // "[logisticsNo]": "${data.orderNo ?? ''}",
  673. // "[createTime]": "",
  674. // "[sendStationName]": "$stationName",
  675. // "[dealerCode]": "${data.sendCompanyCode ?? ''}",
  676. // "[dealerName]": "${data.sendCompanyName}",
  677. // "[dealerTel]": "${data.sendCompanyPhone ?? ''}",
  678. // "[repairName]": "${data.receiptCompanyName ?? ''}",
  679. // "[repairTel]": "${data.receiptCompanyPhone ?? ''}",
  680. // "[endStationName]": "",
  681. // "[goodsLineCode]": "${data.goodsLineCode ?? ''}",
  682. // "[goodsLine]": "${data.goodsLine ?? ''}",
  683. // "[repairAddress]": "${data.receiptCompanyAddress ?? ''}",
  684. // "[goodsQuantity]": "${data.goodsQuantity ?? ''}",
  685. // "[goodsInsurance]": "${data.goodsInsurance ?? ''}",
  686. // "[goodsFlatCost]": "${data.goodsFlatCost ?? ''}",
  687. // // 到付 现付 金额
  688. // "[goodsDFreight]": "$goodsDFreight",
  689. // "[goodsXFreight]": "$goodsXFreight",
  690. // "[goodsAgencyFund]": "$goodsAgencyFunds",
  691. // "[goodsYs]": "$goodsYs",
  692. // "[dealerBankAccount]": "${data.sendCompanyBankCard ?? ''}",
  693. // "[goodsRemark]": "${data.goodsRemark ?? ''}",
  694. // "[realName]": "${nickName?? ''}",
  695. // "[currentTime]": "$nowDate",
  696. // "[currentGoodNumber]": "1/1",
  697. // };
  698. // bluetooth.printOrder(pum, int.parse(printType);
  699. });
  700. });
  701. });
  702. }
  703. });
  704. } else {
  705. return;
  706. }
  707. },
  708. );
  709. });
  710. print("打印");
  711. },
  712. ),
  713. ],
  714. );
  715. }
  716. Widget _status3Fun(FromStatusGetOrderList obj, int index) {
  717. return Row(
  718. mainAxisAlignment: MainAxisAlignment.end,
  719. children: < Widget > [
  720. InkWell(
  721. child: Container(
  722. width: ScreenUtil.getInstance().setWidth(94),
  723. height: ScreenUtil.getInstance().setHeight(48),
  724. decoration: BoxDecoration(
  725. color: Color.fromRGBO(239, 243, 249, 1),
  726. borderRadius: BorderRadius.all(Radius.circular(4.0))
  727. ),
  728. child: Center(
  729. child: Text('打印', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  730. ),
  731. ),
  732. onTap: () {
  733. showDialog < Null > (
  734. context: context, //BuildContext对象
  735. barrierDismissible: false,
  736. builder: (BuildContext context) {
  737. return new LoadingDialog( //调用对话框
  738. text: '是否确认打印', childCallback: (val) {
  739. if (val) {
  740. //widget.callback(widget.index);
  741. } else {
  742. return;
  743. }
  744. },
  745. );
  746. });
  747. print("打印");
  748. },
  749. ),
  750. ],
  751. );
  752. }
  753. Widget _getMoreWidget() {
  754. return Center(
  755. child: Padding(
  756. padding: EdgeInsets.all(10.0),
  757. child: Row(
  758. mainAxisAlignment: MainAxisAlignment.center,
  759. crossAxisAlignment: CrossAxisAlignment.center,
  760. children: < Widget > [
  761. Text(
  762. '加载中...',
  763. style: TextStyle(fontSize: 16.0),
  764. ),
  765. Container(
  766. width: ScreenUtil.getInstance().setWidth(50),
  767. height: ScreenUtil.getInstance().setHeight(50),
  768. child: CircularProgressIndicator()
  769. )
  770. ],
  771. ),
  772. ),
  773. );
  774. }
  775. Widget _noMoreWidegt() {
  776. return Center(
  777. child: Padding(
  778. padding: EdgeInsets.all(10.0),
  779. child: Text(
  780. '没有更多数据了...',
  781. style: TextStyle(fontSize: 16.0),
  782. ),
  783. ),
  784. );
  785. }
  786. switchOrderFromStatus(int orderStatus, int page) {
  787. setState(() {
  788. orderList = null;
  789. });
  790. page = 1;
  791. fromStatusGetOrderList(orderStatus, page, _orderNo).then((resp) {
  792. if (isNotError(context, resp) && this.mounted) {
  793. FromStatusGetOrderObj tempObj = FromStatusGetOrderObj.fromJson(resp.data);
  794. setState(() {
  795. orderList = tempObj.data.items;
  796. hasNextPage = tempObj.data.hasNextPage;
  797. });
  798. }
  799. });
  800. }
  801. getMoreOrder(int orderStatus, int page) {
  802. if (!hasNextPage) {
  803. return;
  804. }
  805. loadMoreStatus = false;
  806. fromStatusGetOrderList(orderStatus, page, _orderNo).then((resp) {
  807. if (isNotError(context, resp) && this.mounted) {
  808. FromStatusGetOrderObj tempObj = FromStatusGetOrderObj.fromJson(resp.data);
  809. setState(() {
  810. orderList.addAll(tempObj.data.items);
  811. hasNextPage = tempObj.data.hasNextPage;
  812. });
  813. loadMoreStatus = true;
  814. } else {
  815. loadMoreStatus = true;
  816. }
  817. });
  818. }
  819. deleteOrder(int index) {
  820. setState(() {
  821. orderList.removeAt(index);
  822. });
  823. if (orderList.length < 4) {
  824. if (hasNextPage) {
  825. setState(() {
  826. page = ++page;
  827. });
  828. getMoreOrder(orderStatus, page);
  829. }
  830. }
  831. }
  832. myUpdataOrder(String myOrderNo, int myOrderStatus, int index) {
  833. updataOrderStatus(myOrderNo, myOrderStatus).then((resp) {
  834. if (isNotError(context, resp) && this.mounted) {
  835. deleteOrder(index);
  836. }
  837. });
  838. }
  839. Future refreshOrder() async {
  840. page = 1;
  841. await fromStatusGetOrderList(orderStatus, page, _orderNo).then((resp) {
  842. if (isNotError(context, resp) && this.mounted) {
  843. FromStatusGetOrderObj tempObj = FromStatusGetOrderObj.fromJson(resp.data);
  844. setState(() {
  845. orderList = tempObj.data.items;
  846. hasNextPage = tempObj.data.hasNextPage;
  847. });
  848. }
  849. });
  850. }
  851. }