order_management_page.dart 32 KB

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