order_management_page.dart 32 KB

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