order_detail_page.dart 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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. myUpdataOrder(4);
  162. } else {
  163. return;
  164. }
  165. },
  166. );
  167. });
  168. print("拒收");
  169. },
  170. ),
  171. GestureDetector(
  172. child: Offstage(
  173. offstage: false,
  174. child: Container(
  175. width: ScreenUtil.getInstance().setWidth(94),
  176. height: ScreenUtil.getInstance().setHeight(48),
  177. decoration: BoxDecoration(
  178. color: Color.fromRGBO(239, 243, 249, 1),
  179. borderRadius: BorderRadius.all(Radius.circular(4.0))
  180. ),
  181. child: Center(
  182. child: Text('签收', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  183. ),
  184. ),
  185. ),
  186. onTap: () {
  187. showDialog < Null > (
  188. context: context, //BuildContext对象
  189. barrierDismissible: false,
  190. builder: (BuildContext context) {
  191. return new LoadingDialog( //调用对话框
  192. text: '是否确认签收', childCallback: (val) {
  193. if (val) {
  194. myUpdataOrder(3);
  195. } else {
  196. return;
  197. }
  198. },
  199. );
  200. });
  201. print("签收");
  202. },
  203. ),
  204. GestureDetector(
  205. child: Offstage(
  206. offstage: false,
  207. child: Container(
  208. width: ScreenUtil.getInstance().setWidth(94),
  209. height: ScreenUtil.getInstance().setHeight(48),
  210. decoration: BoxDecoration(
  211. color: Color.fromRGBO(239, 243, 249, 1),
  212. borderRadius: BorderRadius.all(Radius.circular(4.0))
  213. ),
  214. child: Center(
  215. child: Text('改单', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  216. ),
  217. ),
  218. ),
  219. onTap: () {
  220. showDialog < Null > (
  221. context: context, //BuildContext对象
  222. barrierDismissible: false,
  223. builder: (BuildContext context) {
  224. return new LoadingDialog( //调用对话框
  225. text: '是否确认改单', childCallback: (val) {
  226. if (val) {
  227. print(val);
  228. Navigator.push(context, MaterialPageRoute(builder: (context) {
  229. return OrderDetailPage(orderNo: '123456', );
  230. }));
  231. } else {
  232. return;
  233. }
  234. },
  235. );
  236. });
  237. print("改单");
  238. },
  239. ),
  240. GestureDetector(
  241. child: Offstage(
  242. offstage: false,
  243. child: Container(
  244. width: ScreenUtil.getInstance().setWidth(94),
  245. height: ScreenUtil.getInstance().setHeight(48),
  246. decoration: BoxDecoration(
  247. color: Color.fromRGBO(239, 243, 249, 1),
  248. borderRadius: BorderRadius.all(Radius.circular(4.0))
  249. ),
  250. child: Center(
  251. child: Text('打印', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1))),
  252. ),
  253. ),
  254. ),
  255. onTap: () {
  256. showDialog < Null > (
  257. context: context, //BuildContext对象
  258. barrierDismissible: false,
  259. builder: (BuildContext context) {
  260. return new LoadingDialog( //调用对话框
  261. text: '是否确认打印', childCallback: (val) {
  262. if (val) {
  263. //widget.callback(widget.index);
  264. } else {
  265. return;
  266. }
  267. },
  268. );
  269. });
  270. print("打印");
  271. },
  272. ),
  273. ],
  274. )
  275. ],
  276. ),
  277. )
  278. ),
  279. onTap: () {
  280. },
  281. );
  282. }
  283. Widget _getMoreWidget() {
  284. return Center(
  285. child: Padding(
  286. padding: EdgeInsets.all(10.0),
  287. child: Row(
  288. mainAxisAlignment: MainAxisAlignment.center,
  289. crossAxisAlignment: CrossAxisAlignment.center,
  290. children: < Widget > [
  291. Text(
  292. '加载中...',
  293. style: TextStyle(fontSize: 16.0),
  294. ),
  295. Container(
  296. width: ScreenUtil.getInstance().setWidth(50),
  297. height: ScreenUtil.getInstance().setHeight(50),
  298. child: CircularProgressIndicator()
  299. )
  300. ],
  301. ),
  302. ),
  303. );
  304. }
  305. myUpdataOrder(int myOrderStatus) {
  306. updataOrderStatus(data.orderNo, myOrderStatus).then((resp) {
  307. if (isNotError(context, resp)) {
  308. }
  309. });
  310. }
  311. }