order_management_page.dart 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807
  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 ? Center(
  267. child: Text('暂无订单'),
  268. ) :
  269. RefreshIndicator(
  270. onRefresh: refreshOrder,
  271. child: ListView.builder(
  272. physics: AlwaysScrollableScrollPhysics(),
  273. controller: _scrollController,
  274. itemCount: orderList.length + 1,
  275. itemBuilder: (BuildContext context, int index) {
  276. if (index < orderList.length) {
  277. return _cardWiget(orderList[index], index);
  278. }
  279. if (hasNextPage) {
  280. return _getMoreWidget();
  281. } else {
  282. return _noMoreWidegt();
  283. }
  284. },
  285. )
  286. )
  287. ),
  288. )
  289. ],
  290. )
  291. ),
  292. Positioned(
  293. left: inputPostX,
  294. top: inputPostY,
  295. child: Offstage(
  296. offstage: showStatus,
  297. child:
  298. Container(
  299. width: inputWidth,
  300. height: ScreenUtil.getInstance().setHeight(320),
  301. margin: EdgeInsets.only(top: ScreenUtil.getInstance().setHeight(1)),
  302. decoration: BoxDecoration(
  303. color: Color.fromRGBO(244, 248, 251, 1),
  304. border: Border.all(color: Color.fromRGBO(204, 204, 204, 1), width: 1),
  305. borderRadius: BorderRadius.all(Radius.circular(5))
  306. ),
  307. child: ListView.builder(
  308. itemCount: likeOrderNoList.length,
  309. itemBuilder: (BuildContext context, int index) {
  310. return InkWell(
  311. child: Padding(
  312. padding: EdgeInsets.all(10),
  313. child: Text(likeOrderNoList[index]),
  314. ),
  315. onTap: () {
  316. setState(() {
  317. page = 1;
  318. });
  319. fromStatusGetOrderList(orderStatus, page, likeOrderNoList[index]).then((resp) {
  320. if (isNotError(context, resp)) {
  321. FromStatusGetOrderObj tempObj = FromStatusGetOrderObj.fromJson(resp.data);
  322. setState(() {
  323. orderList = tempObj.data.items;
  324. hasNextPage = tempObj.data.hasNextPage;
  325. });
  326. }
  327. });
  328. setState(() {
  329. _orderController.text = likeOrderNoList[index];
  330. showStatus = true;
  331. FocusScope.of(context).requestFocus(FocusNode());
  332. });
  333. },
  334. );
  335. },
  336. ),
  337. ),
  338. )
  339. )
  340. ],
  341. );
  342. }
  343. Widget _cardWiget(FromStatusGetOrderList obj, int index) {
  344. Map < int, String > statusMap = {
  345. 1: '待取货',
  346. 2: '运途中',
  347. 3: '已签收',
  348. 4: '已拒收',
  349. 5: '已作废'
  350. };
  351. return Card(
  352. color: Colors.white,
  353. child: Container(
  354. padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(20)),
  355. child: Column(
  356. children: < Widget > [
  357. Padding(
  358. padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(30)),
  359. child: Row(
  360. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  361. children: < Widget > [
  362. Text('订单号:${obj.orderNo}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(102, 102, 102, 1)), ),
  363. Text('${statusMap[obj.orderStatus]}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(126, 211, 33, 1)), ),
  364. ],
  365. )
  366. ),
  367. Padding(
  368. padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  369. child: Row(
  370. children: < Widget > [
  371. Text('${obj.sendCompanyName} --> ${obj.receiptCompanyName}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30)), ),
  372. ],
  373. )
  374. ),
  375. Padding(
  376. padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(15)),
  377. child: Row(
  378. children: < Widget > [
  379. SizedBox(
  380. width: ScreenUtil.getInstance().setWidth(355),
  381. child: Text('货物名称:${obj.goods}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(155, 155, 155, 1)), ),
  382. ),
  383. Text('代收款:${obj.goodsAgencyFund/100}元', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(155, 155, 155, 1)), ),
  384. ],
  385. ),
  386. ),
  387. Padding(
  388. padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(30)),
  389. child: Row(
  390. children: < Widget > [
  391. SizedBox(
  392. width: ScreenUtil.getInstance().setWidth(355),
  393. child: Text('货物件数:${obj.goodsQuantity}件', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(155, 155, 155, 1)), ),
  394. ),
  395. Text('运费:${obj.goodsFreight/100}元', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(155, 155, 155, 1)), ),
  396. ],
  397. ),
  398. ),
  399. Padding(
  400. padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  401. child: Container(
  402. height: ScreenUtil.getInstance().setHeight(1),
  403. color: Color.fromRGBO(223, 223, 223, 1),
  404. ),
  405. ),
  406. orderStatus == 1 ? _status1Fun(obj, index) : orderStatus == 2 ? _status2Fun(obj, index) : _status3Fun(obj, index)
  407. ],
  408. ),
  409. )
  410. );
  411. }
  412. Widget _status1Fun(FromStatusGetOrderList obj, int index) {
  413. return Row(
  414. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  415. children: < Widget > [
  416. InkWell(
  417. child: Container(
  418. width: ScreenUtil.getInstance().setWidth(94),
  419. height: ScreenUtil.getInstance().setHeight(48),
  420. decoration: BoxDecoration(
  421. color: Color.fromRGBO(239, 243, 249, 1),
  422. borderRadius: BorderRadius.all(Radius.circular(4.0))
  423. ),
  424. child: Center(
  425. child: Text('作废', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  426. ),
  427. ),
  428. onTap: () {
  429. showDialog < Null > (
  430. context: context, //BuildContext对象
  431. barrierDismissible: false,
  432. builder: (BuildContext context) {
  433. return new LoadingDialog( //调用对话框
  434. text: '是否确认作废', childCallback: (val) {
  435. if (val) {
  436. myUpdataOrder(obj.orderNo, 5, index);
  437. } else {
  438. return;
  439. }
  440. },
  441. );
  442. });
  443. print("作废");
  444. },
  445. ),
  446. InkWell(
  447. child: Container(
  448. width: ScreenUtil.getInstance().setWidth(94),
  449. height: ScreenUtil.getInstance().setHeight(48),
  450. decoration: BoxDecoration(
  451. color: Color.fromRGBO(239, 243, 249, 1),
  452. borderRadius: BorderRadius.all(Radius.circular(4.0))
  453. ),
  454. child: Center(
  455. child: Text('寄件', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  456. ),
  457. ),
  458. onTap: () {
  459. showDialog < Null > (
  460. context: context, //BuildContext对象
  461. barrierDismissible: false,
  462. builder: (BuildContext context) {
  463. return new LoadingDialog( //调用对话框
  464. text: '是否确认寄件', childCallback: (val) {
  465. if (val) {
  466. Navigator.push(
  467. context,
  468. MaterialPageRoute(
  469. builder: (BuildContext context) {
  470. return OrderDetailPage(orderNo: obj.orderNo);
  471. })
  472. ).then((resp) {
  473. if (resp == true) {
  474. deleteOrder(index);
  475. }
  476. });
  477. } else {
  478. return;
  479. }
  480. },
  481. );
  482. });
  483. print("寄件");
  484. },
  485. ),
  486. ],
  487. );
  488. }
  489. Widget _status2Fun(FromStatusGetOrderList obj, int index) {
  490. return Row(
  491. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  492. children: < Widget > [
  493. InkWell(
  494. child: Container(
  495. width: ScreenUtil.getInstance().setWidth(94),
  496. height: ScreenUtil.getInstance().setHeight(48),
  497. decoration: BoxDecoration(
  498. color: Color.fromRGBO(239, 243, 249, 1),
  499. borderRadius: BorderRadius.all(Radius.circular(4.0))
  500. ),
  501. child: Center(
  502. child: Text('作废', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  503. ),
  504. ),
  505. onTap: () {
  506. showDialog < Null > (
  507. context: context, //BuildContext对象
  508. barrierDismissible: false,
  509. builder: (BuildContext context) {
  510. return new LoadingDialog( //调用对话框
  511. text: '是否确认作废', childCallback: (val) {
  512. if (val) {
  513. myUpdataOrder(obj.orderNo, 5, index);
  514. } else {
  515. return;
  516. }
  517. },
  518. );
  519. });
  520. print("作废");
  521. },
  522. ),
  523. InkWell(
  524. child: Container(
  525. width: ScreenUtil.getInstance().setWidth(94),
  526. height: ScreenUtil.getInstance().setHeight(48),
  527. decoration: BoxDecoration(
  528. color: Color.fromRGBO(239, 243, 249, 1),
  529. borderRadius: BorderRadius.all(Radius.circular(4.0))
  530. ),
  531. child: Center(
  532. child: Text('拒收', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  533. ),
  534. ),
  535. onTap: () {
  536. showDialog < Null > (
  537. context: context, //BuildContext对象
  538. barrierDismissible: false,
  539. builder: (BuildContext context) {
  540. return new LoadingDialog( //调用对话框
  541. text: '是否确认拒收', childCallback: (val) {
  542. if (val) {
  543. myUpdataOrder(obj.orderNo, 4, index);
  544. } else {
  545. return;
  546. }
  547. },
  548. );
  549. });
  550. print("拒收");
  551. },
  552. ),
  553. InkWell(
  554. child: Container(
  555. width: ScreenUtil.getInstance().setWidth(94),
  556. height: ScreenUtil.getInstance().setHeight(48),
  557. decoration: BoxDecoration(
  558. color: Color.fromRGBO(239, 243, 249, 1),
  559. borderRadius: BorderRadius.all(Radius.circular(4.0))
  560. ),
  561. child: Center(
  562. child: Text('签收', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  563. ),
  564. ),
  565. onTap: () {
  566. showDialog < Null > (
  567. context: context, //BuildContext对象
  568. barrierDismissible: false,
  569. builder: (BuildContext context) {
  570. return new LoadingDialog( //调用对话框
  571. text: '是否确认签收', childCallback: (val) {
  572. if (val) {
  573. myUpdataOrder(obj.orderNo, 3, index);
  574. } else {
  575. return;
  576. }
  577. },
  578. );
  579. });
  580. print("签收");
  581. },
  582. ),
  583. InkWell(
  584. child: Container(
  585. width: ScreenUtil.getInstance().setWidth(94),
  586. height: ScreenUtil.getInstance().setHeight(48),
  587. decoration: BoxDecoration(
  588. color: Color.fromRGBO(239, 243, 249, 1),
  589. borderRadius: BorderRadius.all(Radius.circular(4.0))
  590. ),
  591. child: Center(
  592. child: Text('改单', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  593. ),
  594. ),
  595. onTap: () {
  596. showDialog < Null > (
  597. context: context, //BuildContext对象
  598. barrierDismissible: false,
  599. builder: (BuildContext context) {
  600. return new LoadingDialog( //调用对话框
  601. text: '是否确认改单', childCallback: (val) {
  602. if (val) {
  603. Navigator.push(
  604. context,
  605. MaterialPageRoute(
  606. builder: (BuildContext context) {
  607. return OrderDetailPage(orderNo: obj.orderNo);
  608. })
  609. );
  610. } else {
  611. return;
  612. }
  613. },
  614. );
  615. });
  616. print("改单");
  617. },
  618. ),
  619. InkWell(
  620. child: Container(
  621. width: ScreenUtil.getInstance().setWidth(94),
  622. height: ScreenUtil.getInstance().setHeight(48),
  623. decoration: BoxDecoration(
  624. color: Color.fromRGBO(239, 243, 249, 1),
  625. borderRadius: BorderRadius.all(Radius.circular(4.0))
  626. ),
  627. child: Center(
  628. child: Text('打印', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  629. ),
  630. ),
  631. onTap: () {
  632. showDialog < Null > (
  633. context: context, //BuildContext对象
  634. barrierDismissible: false,
  635. builder: (BuildContext context) {
  636. return new LoadingDialog( //调用对话框
  637. text: '是否确认打印', childCallback: (val) {
  638. if (val) {
  639. //widget.callback(widget.index);
  640. } else {
  641. return;
  642. }
  643. },
  644. );
  645. });
  646. print("打印");
  647. },
  648. ),
  649. ],
  650. );
  651. }
  652. Widget _status3Fun(FromStatusGetOrderList obj, int index) {
  653. return Row(
  654. mainAxisAlignment: MainAxisAlignment.end,
  655. children: < Widget > [
  656. InkWell(
  657. child: Container(
  658. width: ScreenUtil.getInstance().setWidth(94),
  659. height: ScreenUtil.getInstance().setHeight(48),
  660. decoration: BoxDecoration(
  661. color: Color.fromRGBO(239, 243, 249, 1),
  662. borderRadius: BorderRadius.all(Radius.circular(4.0))
  663. ),
  664. child: Center(
  665. child: Text('打印', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  666. ),
  667. ),
  668. onTap: () {
  669. showDialog < Null > (
  670. context: context, //BuildContext对象
  671. barrierDismissible: false,
  672. builder: (BuildContext context) {
  673. return new LoadingDialog( //调用对话框
  674. text: '是否确认打印', childCallback: (val) {
  675. if (val) {
  676. //widget.callback(widget.index);
  677. } else {
  678. return;
  679. }
  680. },
  681. );
  682. });
  683. print("打印");
  684. },
  685. ),
  686. ],
  687. );
  688. }
  689. Widget _getMoreWidget() {
  690. return Center(
  691. child: Padding(
  692. padding: EdgeInsets.all(10.0),
  693. child: Row(
  694. mainAxisAlignment: MainAxisAlignment.center,
  695. crossAxisAlignment: CrossAxisAlignment.center,
  696. children: < Widget > [
  697. Text(
  698. '加载中...',
  699. style: TextStyle(fontSize: 16.0),
  700. ),
  701. Container(
  702. width: ScreenUtil.getInstance().setWidth(50),
  703. height: ScreenUtil.getInstance().setHeight(50),
  704. child: CircularProgressIndicator()
  705. )
  706. ],
  707. ),
  708. ),
  709. );
  710. }
  711. Widget _noMoreWidegt() {
  712. return Center(
  713. child: Padding(
  714. padding: EdgeInsets.all(10.0),
  715. child: Text(
  716. '没有更多数据了...',
  717. style: TextStyle(fontSize: 16.0),
  718. ),
  719. ),
  720. );
  721. }
  722. switchOrderFromStatus(int orderStatus, int page) {
  723. setState(() {
  724. orderList = null;
  725. });
  726. page = 1;
  727. fromStatusGetOrderList(orderStatus, page).then((resp) {
  728. if (isNotError(context, resp)) {
  729. FromStatusGetOrderObj tempObj = FromStatusGetOrderObj.fromJson(resp.data);
  730. setState(() {
  731. orderList = tempObj.data.items;
  732. hasNextPage = tempObj.data.hasNextPage;
  733. });
  734. }
  735. });
  736. }
  737. getMoreOrder(int orderStatus, int page) {
  738. if (!hasNextPage) {
  739. return;
  740. }
  741. loadMoreStatus = false;
  742. fromStatusGetOrderList(orderStatus, page).then((resp) {
  743. if (isNotError(context, resp)) {
  744. FromStatusGetOrderObj tempObj = FromStatusGetOrderObj.fromJson(resp.data);
  745. setState(() {
  746. orderList.addAll(tempObj.data.items);
  747. hasNextPage = tempObj.data.hasNextPage;
  748. });
  749. loadMoreStatus = true;
  750. } else {
  751. loadMoreStatus = true;
  752. }
  753. });
  754. }
  755. deleteOrder(int index) {
  756. setState(() {
  757. orderList.removeAt(index);
  758. });
  759. if (orderList.length < 4) {
  760. if (hasNextPage) {
  761. setState(() {
  762. page = ++page;
  763. });
  764. getMoreOrder(orderStatus, page);
  765. }
  766. }
  767. }
  768. myUpdataOrder(String myOrderNo, int myOrderStatus, int index) {
  769. updataOrderStatus(myOrderNo, myOrderStatus).then((resp) {
  770. if (isNotError(context, resp)) {
  771. deleteOrder(index);
  772. }
  773. });
  774. }
  775. Future refreshOrder() async {
  776. page = 1;
  777. await fromStatusGetOrderList(orderStatus, page).then((resp) {
  778. if (isNotError(context, resp)) {
  779. FromStatusGetOrderObj tempObj = FromStatusGetOrderObj.fromJson(resp.data);
  780. setState(() {
  781. orderList = tempObj.data.items;
  782. hasNextPage = tempObj.data.hasNextPage;
  783. });
  784. }
  785. });
  786. }
  787. }