order_management_page.dart 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import 'order_management_page/order_detail_page.dart';
  4. import '../showDialog.dart';
  5. import '../util/models.dart';
  6. import '../util/api.dart';
  7. import '../util/util.dart';
  8. class OrderManagementPage extends StatefulWidget {
  9. final Widget child;
  10. OrderManagementPage({
  11. Key key,
  12. this.child
  13. }): super(key: key);
  14. _OrderManagementPageState createState() => _OrderManagementPageState();
  15. }
  16. class _OrderManagementPageState extends State < OrderManagementPage > with AutomaticKeepAliveClientMixin {
  17. @override
  18. Widget build(BuildContext context) {
  19. return Container(
  20. child: Scaffold(
  21. appBar: AppBar(
  22. title: Text('订单管理', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(36)), ),
  23. centerTitle: true,
  24. backgroundColor: Color.fromRGBO(64, 98, 254, 1),
  25. ),
  26. body: Container(
  27. decoration: BoxDecoration(
  28. color: Color.fromRGBO(246, 246, 254, 1)
  29. ),
  30. child: QueryWidget()
  31. ),
  32. resizeToAvoidBottomPadding: false //键盘弹出,页面不跟随向上滑动,防止出现溢出错误
  33. )
  34. );
  35. }
  36. @override
  37. bool get wantKeepAlive => true;
  38. }
  39. class QueryWidget extends StatefulWidget { //搜索栏
  40. final Widget child;
  41. QueryWidget({
  42. Key key,
  43. this.child
  44. }): super(key: key);
  45. _QueryWidgetState createState() => _QueryWidgetState();
  46. }
  47. class _QueryWidgetState extends State < QueryWidget > {
  48. //单号的输入框控制器
  49. TextEditingController _orderController = TextEditingController();
  50. ScrollController _scrollController =ScrollController();
  51. GlobalKey _globalKey = GlobalKey(); //搜索栏key
  52. List < bool > statusList = [true, false, false];
  53. double inputPostX = 0;
  54. double inputPostY = 0;
  55. double inputWidth = 0;
  56. double inputHeight = 0;
  57. bool showStatus = true; //提示层显示状态
  58. String _orderNo = "";
  59. int orderStatus = 1; //0:代收单,1:待取件,2:运途中:已完成
  60. int page = 1;
  61. bool hasNextPage = true;
  62. List<FromStatusGetOrderList> orderList=[];
  63. @override
  64. void initState() {
  65. super.initState();
  66. switchOrderFromStatus(orderStatus, page);
  67. _scrollController.addListener((){
  68. if (_scrollController.position.pixels == _scrollController.position.maxScrollExtent) {
  69. print("滑到底部了");
  70. }
  71. });
  72. }
  73. @override
  74. Widget build(BuildContext context) {
  75. return Stack(
  76. children: < Widget > [
  77. Container(
  78. child: Column(
  79. children: < Widget > [
  80. Container(
  81. color: Colors.white,
  82. height: ScreenUtil.getInstance().setHeight(222),
  83. padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(20), ScreenUtil.getInstance().setWidth(20), ScreenUtil.getInstance().setWidth(20), 0),
  84. child: Column(
  85. children: < Widget > [
  86. Container(
  87. key: _globalKey,
  88. height: ScreenUtil.getInstance().setHeight(100),
  89. decoration: BoxDecoration(
  90. border: Border.all(color: Color.fromRGBO(204, 204, 204, 1), width: 1),
  91. borderRadius: BorderRadius.all(Radius.circular(5))
  92. ),
  93. child: Row(
  94. children: < Widget > [
  95. Expanded(
  96. child: TextField(
  97. controller: _orderController,
  98. keyboardType: TextInputType.number,
  99. autocorrect: true,
  100. decoration: InputDecoration(
  101. border: InputBorder.none,
  102. hintText: "输入运单号后6位查询物流",
  103. hintStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(26), color: Color.fromRGBO(155, 155, 155, 1)),
  104. contentPadding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(30), 0, ScreenUtil.getInstance().setWidth(30), 0)
  105. ),
  106. onTap: () {
  107. RenderObject inputObj = _globalKey.currentContext.findRenderObject();
  108. setState(() {
  109. inputWidth = inputObj.paintBounds.size.width;
  110. inputHeight = inputObj.paintBounds.size.height;
  111. inputPostX = inputObj.getTransformTo(null).getTranslation().x;
  112. inputPostY = ScreenUtil.getInstance().setWidth(20) + inputHeight;
  113. });
  114. },
  115. onChanged: ((value) {
  116. print(value);
  117. setState(() {
  118. _orderNo = value;
  119. });
  120. if (_orderNo.length >= 6) {
  121. setState(() {
  122. showStatus = false;
  123. });
  124. } else {
  125. setState(() {
  126. showStatus = true;
  127. });
  128. }
  129. }),
  130. onEditingComplete: () {
  131. FocusScope.of(context).requestFocus(FocusNode());
  132. setState(() {
  133. showStatus = true;
  134. });
  135. },
  136. ),
  137. ),
  138. IconButton(
  139. icon: Image.asset('lib/images/icon_saoyisao.png',
  140. width: ScreenUtil.getInstance().setWidth(38),
  141. height: ScreenUtil.getInstance().setHeight(36),
  142. ),
  143. onPressed: () {},
  144. ),
  145. GestureDetector(
  146. child: Container(
  147. width: ScreenUtil.getInstance().setWidth(120),
  148. decoration: BoxDecoration(
  149. 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)), )
  150. ),
  151. child: Center(
  152. child: Text("查询", style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(26), color: Color.fromRGBO(64, 98, 254, 1)), ),
  153. ),
  154. ),
  155. onTap: () {
  156. print("查询");
  157. }
  158. ),
  159. ],
  160. ),
  161. ),
  162. Container(
  163. height: ScreenUtil.getInstance().setHeight(100),
  164. child: Container(
  165. padding: EdgeInsets.only(top: ScreenUtil.getInstance().setHeight(25)),
  166. child: Row(
  167. mainAxisAlignment: MainAxisAlignment.spaceAround,
  168. children: < Widget > [
  169. GestureDetector(
  170. child: Container(
  171. height: ScreenUtil.getInstance().setHeight(80),
  172. decoration: BoxDecoration(
  173. border: statusList[0] ? Border(bottom: BorderSide.merge(BorderSide(color: Colors.black, width: 1), BorderSide(color: Colors.black, width: 0)), ) : Border()
  174. ),
  175. child: Center(
  176. child: Text("待取件", style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: statusList[0] ? Colors.black : Color.fromRGBO(155, 155, 155, 1)), ),
  177. )
  178. ),
  179. onTap: () {
  180. if (statusList[0]) {
  181. return;
  182. } else {
  183. setState(() {
  184. statusList = [true, false, false];
  185. });
  186. }
  187. },
  188. ),
  189. GestureDetector(
  190. child: Container(
  191. height: ScreenUtil.getInstance().setHeight(80),
  192. decoration: BoxDecoration(
  193. border: statusList[1] ? Border(bottom: BorderSide.merge(BorderSide(color: Colors.black, width: 1), BorderSide(color: Colors.black, width: 0)), ) : Border()
  194. ),
  195. child: Center(
  196. child: Text("运途中", style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: statusList[1] ? Colors.black : Color.fromRGBO(155, 155, 155, 1)), ),
  197. )
  198. ),
  199. onTap: () {
  200. if (statusList[1]) {
  201. return;
  202. } else {
  203. setState(() {
  204. statusList = [false, true, false];
  205. });
  206. }
  207. },
  208. ),
  209. GestureDetector(
  210. child: Container(
  211. height: ScreenUtil.getInstance().setHeight(80),
  212. decoration: BoxDecoration(
  213. border: statusList[2] ? Border(bottom: BorderSide.merge(BorderSide(color: Colors.black, width: 1), BorderSide(color: Colors.black, width: 0)), ) : Border()
  214. ),
  215. child: Center(
  216. child: Text("已完成", style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: statusList[2] ? Colors.black : Color.fromRGBO(155, 155, 155, 1)), ),
  217. )
  218. ),
  219. onTap: () {
  220. if (statusList[2]) {
  221. return;
  222. } else {
  223. setState(() {
  224. statusList = [false, false, true];
  225. });
  226. }
  227. },
  228. ),
  229. ],
  230. )
  231. )
  232. ),
  233. ],
  234. )
  235. ),
  236. Expanded(
  237. child: Container(
  238. padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(20), ScreenUtil.getInstance().setWidth(20), ScreenUtil.getInstance().setWidth(20), 0),
  239. child:
  240. // ListView(
  241. // controller: _scrollController,
  242. // children: < Widget > [
  243. // _cardWiget(),
  244. // _cardWiget(),
  245. // _cardWiget(),
  246. // ],
  247. // ),
  248. ListView.builder(
  249. controller:_scrollController,
  250. itemCount: orderList.length,
  251. itemBuilder: (BuildContext context,int index){
  252. if(index<orderList.length){
  253. return _cardWiget(orderList[index]);
  254. }
  255. if (hasNextPage) {
  256. return _getMoreWidget();
  257. } else {
  258. return _noMoreWidegt();
  259. }
  260. },
  261. )
  262. ),
  263. )
  264. ],
  265. )
  266. ),
  267. Positioned(
  268. left: inputPostX,
  269. top: inputPostY,
  270. child: Offstage(
  271. offstage: showStatus,
  272. child:
  273. Container(
  274. width: inputWidth,
  275. height: ScreenUtil.getInstance().setHeight(320),
  276. margin: EdgeInsets.only(top: ScreenUtil.getInstance().setHeight(1)),
  277. decoration: BoxDecoration(
  278. color: Color.fromRGBO(244, 248, 251, 1),
  279. border: Border.all(color: Color.fromRGBO(204, 204, 204, 1), width: 1),
  280. borderRadius: BorderRadius.all(Radius.circular(5))
  281. ),
  282. child: ListView(
  283. children: < Widget > [
  284. InkWell(
  285. child: Padding(
  286. padding: EdgeInsets.all(10),
  287. child: Text("11012312312312312313123131"),
  288. ),
  289. onTap: () {
  290. setState(() {
  291. _orderController.text = ('11122223333333');
  292. showStatus = true;
  293. FocusScope.of(context).requestFocus(FocusNode());
  294. });
  295. },
  296. )
  297. ],
  298. ),
  299. ),
  300. )
  301. )
  302. ],
  303. );
  304. }
  305. Widget _cardWiget(FromStatusGetOrderList obj) {
  306. Map<int,String> statusMap={
  307. 1:'待取货',
  308. 2:'运途中',
  309. 3:'已签收',
  310. 4:'拒收'
  311. };
  312. return GestureDetector(
  313. child: Card(
  314. color: Colors.white,
  315. child: Container(
  316. padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(20)),
  317. child: Column(
  318. children: < Widget > [
  319. Padding(
  320. padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(30)),
  321. child: Row(
  322. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  323. children: < Widget > [
  324. Text('订单号:${obj.orderNo}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(102, 102, 102, 1)), ),
  325. Text('${statusMap[obj.orderStatus]}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(126, 211, 33, 1)), ),
  326. ],
  327. )
  328. ),
  329. Padding(
  330. padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  331. child: Row(
  332. children: < Widget > [
  333. Text('${obj.sendCompanyName} --> ${obj.receiptCompanyName}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30)), ),
  334. ],
  335. )
  336. ),
  337. Padding(
  338. padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(15)),
  339. child: Row(
  340. children: < Widget > [
  341. SizedBox(
  342. width: ScreenUtil.getInstance().setWidth(355),
  343. child: Text('货物名称:${obj.goods}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(155, 155, 155, 1)), ),
  344. ),
  345. Text('代收款:${obj.goodsAgencyFund/100}元', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(155, 155, 155, 1)), ),
  346. ],
  347. ),
  348. ),
  349. Padding(
  350. padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(30)),
  351. child: Row(
  352. children: < Widget > [
  353. SizedBox(
  354. width: ScreenUtil.getInstance().setWidth(355),
  355. child: Text('货物件数:${obj.goodsQuantity}件', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(155, 155, 155, 1)), ),
  356. ),
  357. Text('运费:${obj.goodsFreight/100}元', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(155, 155, 155, 1)), ),
  358. ],
  359. ),
  360. ),
  361. Padding(
  362. padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  363. child: Container(
  364. height: ScreenUtil.getInstance().setHeight(1),
  365. color: Color.fromRGBO(223, 223, 223, 1),
  366. ),
  367. ),
  368. Row(
  369. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  370. children: < Widget > [
  371. GestureDetector(
  372. child: Offstage(
  373. offstage: false,
  374. child: Container(
  375. width: ScreenUtil.getInstance().setWidth(94),
  376. height: ScreenUtil.getInstance().setHeight(48),
  377. decoration: BoxDecoration(
  378. color: Color.fromRGBO(239, 243, 249, 1),
  379. borderRadius: BorderRadius.all(Radius.circular(4.0))
  380. ),
  381. child: Center(
  382. child: Text('作废', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  383. ),
  384. ),
  385. ),
  386. onTap: () {
  387. showDialog < Null > (
  388. context: context, //BuildContext对象
  389. barrierDismissible: false,
  390. builder: (BuildContext context) {
  391. return new LoadingDialog( //调用对话框
  392. text:'是否确认作废',childCallback: (val){
  393. if(val){
  394. //widget.callback(widget.index);
  395. }else{
  396. return;
  397. }
  398. },
  399. );
  400. });
  401. print("作废");
  402. },
  403. ),
  404. GestureDetector(
  405. child: Offstage(
  406. offstage: false,
  407. child: Container(
  408. width: ScreenUtil.getInstance().setWidth(94),
  409. height: ScreenUtil.getInstance().setHeight(48),
  410. decoration: BoxDecoration(
  411. color: Color.fromRGBO(239, 243, 249, 1),
  412. borderRadius: BorderRadius.all(Radius.circular(4.0))
  413. ),
  414. child: Center(
  415. child: Text('寄件', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  416. ),
  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. //widget.callback(widget.index);
  428. }else{
  429. return;
  430. }
  431. },
  432. );
  433. });
  434. print("寄件");
  435. },
  436. ),
  437. GestureDetector(
  438. child: Offstage(
  439. offstage: false,
  440. child: Container(
  441. width: ScreenUtil.getInstance().setWidth(94),
  442. height: ScreenUtil.getInstance().setHeight(48),
  443. decoration: BoxDecoration(
  444. color: Color.fromRGBO(239, 243, 249, 1),
  445. borderRadius: BorderRadius.all(Radius.circular(4.0))
  446. ),
  447. child: Center(
  448. child: Text('拒收', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  449. ),
  450. ),
  451. ),
  452. onTap: () {
  453. showDialog < Null > (
  454. context: context, //BuildContext对象
  455. barrierDismissible: false,
  456. builder: (BuildContext context) {
  457. return new LoadingDialog( //调用对话框
  458. text:'是否确认拒收',childCallback: (val){
  459. if(val){
  460. //widget.callback(widget.index);
  461. }else{
  462. return;
  463. }
  464. },
  465. );
  466. });
  467. print("拒收");
  468. },
  469. ),
  470. GestureDetector(
  471. child: Offstage(
  472. offstage: false,
  473. child: Container(
  474. width: ScreenUtil.getInstance().setWidth(94),
  475. height: ScreenUtil.getInstance().setHeight(48),
  476. decoration: BoxDecoration(
  477. color: Color.fromRGBO(239, 243, 249, 1),
  478. borderRadius: BorderRadius.all(Radius.circular(4.0))
  479. ),
  480. child: Center(
  481. child: Text('签收', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  482. ),
  483. ),
  484. ),
  485. onTap: () {
  486. showDialog < Null > (
  487. context: context, //BuildContext对象
  488. barrierDismissible: false,
  489. builder: (BuildContext context) {
  490. return new LoadingDialog( //调用对话框
  491. text:'是否确认签收',childCallback: (val){
  492. if(val){
  493. //widget.callback(widget.index);
  494. }else{
  495. return;
  496. }
  497. },
  498. );
  499. });
  500. print("签收");
  501. },
  502. ),
  503. GestureDetector(
  504. child: Offstage(
  505. offstage: false,
  506. child: Container(
  507. width: ScreenUtil.getInstance().setWidth(94),
  508. height: ScreenUtil.getInstance().setHeight(48),
  509. decoration: BoxDecoration(
  510. color: Color.fromRGBO(239, 243, 249, 1),
  511. borderRadius: BorderRadius.all(Radius.circular(4.0))
  512. ),
  513. child: Center(
  514. child: Text('改单', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  515. ),
  516. ),
  517. ),
  518. onTap: () {
  519. showDialog < Null > (
  520. context: context, //BuildContext对象
  521. barrierDismissible: false,
  522. builder: (BuildContext context) {
  523. return new LoadingDialog( //调用对话框
  524. text:'是否确认改单',childCallback: (val){
  525. if(val){
  526. print(val);
  527. Navigator.push(context, MaterialPageRoute(builder: (context) {
  528. return OrderDetailPage(orderId: 123456, );
  529. }));
  530. }else{
  531. return;
  532. }
  533. },
  534. );
  535. });
  536. print("改单");
  537. },
  538. ),
  539. GestureDetector(
  540. child: Offstage(
  541. offstage: false,
  542. child: Container(
  543. width: ScreenUtil.getInstance().setWidth(94),
  544. height: ScreenUtil.getInstance().setHeight(48),
  545. decoration: BoxDecoration(
  546. color: Color.fromRGBO(239, 243, 249, 1),
  547. borderRadius: BorderRadius.all(Radius.circular(4.0))
  548. ),
  549. child: Center(
  550. child: Text('打印', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  551. ),
  552. ),
  553. ),
  554. onTap: () {
  555. showDialog < Null > (
  556. context: context, //BuildContext对象
  557. barrierDismissible: false,
  558. builder: (BuildContext context) {
  559. return new LoadingDialog( //调用对话框
  560. text:'是否确认打印',childCallback: (val){
  561. if(val){
  562. //widget.callback(widget.index);
  563. }else{
  564. return;
  565. }
  566. },
  567. );
  568. });
  569. print("打印");
  570. },
  571. ),
  572. ],
  573. )
  574. ],
  575. ),
  576. )
  577. ),
  578. onTap: () {
  579. },
  580. );
  581. }
  582. switchOrderFromStatus(int orderStatus,int page){
  583. fromStatusGetOrderList(orderStatus,page).then((resp){
  584. print(resp);
  585. if(isNotError(context, resp)){
  586. FromStatusGetOrderObj tempObj = FromStatusGetOrderObj.fromJson(resp.data);
  587. setState(() {
  588. orderList =tempObj.data.items;
  589. });
  590. }
  591. });
  592. }
  593. Widget _getMoreWidget() {
  594. return Center(
  595. child: Padding(
  596. padding: EdgeInsets.all(10.0),
  597. child: Row(
  598. mainAxisAlignment: MainAxisAlignment.center,
  599. crossAxisAlignment: CrossAxisAlignment.center,
  600. children: < Widget > [
  601. Text(
  602. '加载中...',
  603. style: TextStyle(fontSize: 16.0),
  604. ),
  605. Container(
  606. width: ScreenUtil.getInstance().setWidth(50),
  607. height: ScreenUtil.getInstance().setHeight(50),
  608. child: CircularProgressIndicator()
  609. )
  610. ],
  611. ),
  612. ),
  613. );
  614. }
  615. Widget _noMoreWidegt() {
  616. return Center(
  617. child: Padding(
  618. padding: EdgeInsets.all(10.0),
  619. child: Text(
  620. '没有更多数据了...',
  621. style: TextStyle(fontSize: 16.0),
  622. ),
  623. ),
  624. );
  625. }
  626. }