order_management_page.dart 32 KB

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