order_management_page.dart 31 KB

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