order_detail_page.dart 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  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/api.dart';
  6. import '../../util/models.dart';
  7. import '../../util/util.dart';
  8. class OrderDetail extends StatefulWidget {
  9. final String orderId;
  10. OrderDetail({
  11. Key key,
  12. @required this.orderId
  13. }): super(key: key);
  14. _OrderDetailState createState() => _OrderDetailState();
  15. }
  16. class _OrderDetailState extends State < OrderDetail > {
  17. OrderDetailData data;
  18. @override
  19. void initState() {
  20. super.initState();
  21. getOrderDetail(widget.orderId).then((resp) {
  22. if (isNotError(context, resp)) {
  23. OrderDetailObj orderDetailObj = OrderDetailObj.fromJson(resp.data);
  24. setState(() {
  25. data = orderDetailObj.data;
  26. });
  27. }
  28. });
  29. }
  30. @override
  31. Widget build(BuildContext context) {
  32. return Container(
  33. child: Scaffold(
  34. appBar: AppBar(
  35. title: Text('订单详情'),
  36. centerTitle: true,
  37. backgroundColor: Color.fromRGBO(64, 98, 254, 1),
  38. ),
  39. body: Container(
  40. child: data==null?_getMoreWidget():_cardWiget()
  41. ),
  42. )
  43. );
  44. }
  45. Widget _cardWiget() {
  46. return GestureDetector(
  47. child: Card(
  48. color: Colors.white,
  49. child: Container(
  50. padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(20)),
  51. child: Column(
  52. children: < Widget > [
  53. Padding(
  54. padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(30)),
  55. child: Row(
  56. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  57. children: < Widget > [
  58. Text('订单号:${data.orderNo}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(102, 102, 102, 1)), ),
  59. Text("运输中", style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(126, 211, 33, 1)), ),
  60. ],
  61. )
  62. ),
  63. Padding(
  64. padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  65. child: Row(
  66. children: < Widget > [
  67. Text('${data.sendCompanyName} --> ${data.receiptCompanyName}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30)), ),
  68. ],
  69. )
  70. ),
  71. Padding(
  72. padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(15)),
  73. child: Row(
  74. children: < Widget > [
  75. SizedBox(
  76. width: ScreenUtil.getInstance().setWidth(355),
  77. child: Text('货物名称:${data.goods}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(155, 155, 155, 1)), ),
  78. ),
  79. Text('代收款:${data.goodsAgencyFund/100}元', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(155, 155, 155, 1)), ),
  80. ],
  81. ),
  82. ),
  83. Padding(
  84. padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(30)),
  85. child: Row(
  86. children: < Widget > [
  87. SizedBox(
  88. width: ScreenUtil.getInstance().setWidth(355),
  89. child: Text('货物件数:${data.goodsQuantity}件', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(155, 155, 155, 1)), ),
  90. ),
  91. Text('运费:${data.goodsFreight/100}元', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(155, 155, 155, 1)), ),
  92. ],
  93. ),
  94. ),
  95. Padding(
  96. padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  97. child: Container(
  98. height: ScreenUtil.getInstance().setHeight(1),
  99. color: Color.fromRGBO(223, 223, 223, 1),
  100. ),
  101. ),
  102. Row(
  103. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  104. children: < Widget > [
  105. GestureDetector(
  106. child: Offstage(
  107. offstage: false,
  108. child: Container(
  109. width: ScreenUtil.getInstance().setWidth(94),
  110. height: ScreenUtil.getInstance().setHeight(48),
  111. decoration: BoxDecoration(
  112. color: Color.fromRGBO(239, 243, 249, 1),
  113. borderRadius: BorderRadius.all(Radius.circular(4.0))
  114. ),
  115. child: Center(
  116. child: Text('作废', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  117. ),
  118. ),
  119. ),
  120. onTap: () {
  121. showDialog < Null > (
  122. context: context, //BuildContext对象
  123. barrierDismissible: false,
  124. builder: (BuildContext context) {
  125. return new LoadingDialog( //调用对话框
  126. text: '是否确认作废', childCallback: (val) {
  127. if (val) {
  128. myUpdataOrder(5);
  129. } else {
  130. return;
  131. }
  132. },
  133. );
  134. });
  135. print("作废");
  136. },
  137. ),
  138. GestureDetector(
  139. child: Offstage(
  140. offstage: false,
  141. child: Container(
  142. width: ScreenUtil.getInstance().setWidth(94),
  143. height: ScreenUtil.getInstance().setHeight(48),
  144. decoration: BoxDecoration(
  145. color: Color.fromRGBO(239, 243, 249, 1),
  146. borderRadius: BorderRadius.all(Radius.circular(4.0))
  147. ),
  148. child: Center(
  149. child: Text('改单', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  150. ),
  151. ),
  152. ),
  153. onTap: () {
  154. showDialog < Null > (
  155. context: context, //BuildContext对象
  156. barrierDismissible: false,
  157. builder: (BuildContext context) {
  158. return new LoadingDialog( //调用对话框
  159. text: '是否确认改单', childCallback: (val) {
  160. if (val) {
  161. print(val);
  162. Navigator.push(context, MaterialPageRoute(builder: (context) {
  163. return OrderDetailPage(orderNo: '${data.orderNo}', );
  164. })).then((resp){
  165. if(resp==true){
  166. getOrderDetail(widget.orderId).then((resp) {
  167. if (isNotError(context, resp)) {
  168. OrderDetailObj orderDetailObj = OrderDetailObj.fromJson(resp.data);
  169. setState(() {
  170. data = orderDetailObj.data;
  171. });
  172. }
  173. });
  174. }
  175. });
  176. } else {
  177. return;
  178. }
  179. },
  180. );
  181. });
  182. print("改单");
  183. },
  184. ),
  185. GestureDetector(
  186. child: Offstage(
  187. offstage: false,
  188. child: Container(
  189. width: ScreenUtil.getInstance().setWidth(94),
  190. height: ScreenUtil.getInstance().setHeight(48),
  191. decoration: BoxDecoration(
  192. color: Color.fromRGBO(239, 243, 249, 1),
  193. borderRadius: BorderRadius.all(Radius.circular(4.0))
  194. ),
  195. child: Center(
  196. child: Text('打印', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  197. ),
  198. ),
  199. ),
  200. onTap: () {
  201. showDialog < Null > (
  202. context: context, //BuildContext对象
  203. barrierDismissible: false,
  204. builder: (BuildContext context) {
  205. return new LoadingDialog( //调用对话框
  206. text: '是否确认打印', childCallback: (val) {
  207. if (val) {
  208. //widget.callback(widget.index);
  209. } else {
  210. return;
  211. }
  212. },
  213. );
  214. });
  215. print("打印");
  216. },
  217. ),
  218. ],
  219. )
  220. ],
  221. ),
  222. )
  223. ),
  224. onTap: () {
  225. },
  226. );
  227. }
  228. Widget _getMoreWidget() {
  229. return Center(
  230. child: Padding(
  231. padding: EdgeInsets.all(10.0),
  232. child: Row(
  233. mainAxisAlignment: MainAxisAlignment.center,
  234. crossAxisAlignment: CrossAxisAlignment.center,
  235. children: < Widget > [
  236. Text(
  237. '加载中...',
  238. style: TextStyle(fontSize: 16.0),
  239. ),
  240. Container(
  241. width: ScreenUtil.getInstance().setWidth(50),
  242. height: ScreenUtil.getInstance().setHeight(50),
  243. child: CircularProgressIndicator()
  244. )
  245. ],
  246. ),
  247. ),
  248. );
  249. }
  250. myUpdataOrder(int myOrderStatus) {
  251. updataOrderStatus(data.orderNo, myOrderStatus).then((resp) {
  252. if (isNotError(context, resp)) {
  253. }
  254. });
  255. }
  256. }