store_house_page.dart 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. import 'package:flutter/material.dart';
  2. import 'package:lszlgl/base/base_lifecycle_state.dart';
  3. import 'package:lszlgl/base/base_vm.dart';
  4. import 'package:lszlgl/config/colors.dart';
  5. import 'package:lszlgl/main.dart';
  6. import 'package:lszlgl/model/rsp/storehouse_rsp.dart';
  7. import 'package:lszlgl/network/my_api.dart';
  8. import 'package:lszlgl/widget/page_widget.dart';
  9. import 'package:lszlgl/widget/storehouse_item.dart';
  10. class StoreHousePage extends StatefulWidget {
  11. final String houseNum;
  12. const StoreHousePage({super.key, required this.houseNum});
  13. @override
  14. State<StoreHousePage> createState() => _StoreHousePageState();
  15. }
  16. class _StoreHousePageState extends BaseLifecycleState<StoreHousePage> {
  17. final pageState = DataStatusModel<storehouseRsp?>().notifier<DataStatusModel<storehouseRsp?>>();
  18. storehouseRsp? data;
  19. List<String> cflist=[];
  20. @override
  21. void onFirstShow(Duration timeStamp) {
  22. loadData();
  23. }
  24. @override
  25. void onDestroy() {
  26. pageState.dispose();
  27. }
  28. void loadData() async {
  29. pageState.update(pageState.value.loading());
  30. try {
  31. // String jsonStr = await Future.delayed(const Duration(seconds: 3),()async{
  32. // return rootBundle.loadString('assets/json/storehouse.json');
  33. // });
  34. // Map<String,dynamic> val = json.decode(jsonStr);
  35. // ApiRsp<List<storehouseRsp?>> res= ApiRsp<List<storehouseRsp>>.fromJson(
  36. // val,
  37. // (json) => json is List<dynamic>
  38. // ? json
  39. // .map<storehouseRsp>((i) => storehouseRsp.fromJson(i as Map<String, dynamic>))
  40. // .toList()
  41. // : List.empty(),
  42. // );
  43. var res = await MyApi.get(baseUrl: 'http://121.36.17.6:28088')
  44. .getStoreMessage(widget.houseNum, 'zhijian');
  45. if (res.data?.first.tycfbm == null) {
  46. pageState.update(pageState.value.empty());
  47. } else {
  48. data = res.data!.first;
  49. //
  50. cflist = (data?.cflx ?? '').split(RegExp(r'[()()]'));
  51. cflist.removeWhere((val) => val == '');
  52. pageState.update(pageState.value.success(data: res.data!.first));
  53. }
  54. } catch (e) {
  55. logger.e(e);
  56. pageState.update(pageState.value.error());
  57. }
  58. }
  59. @override
  60. Widget build(BuildContext context) {
  61. return myScaffold(
  62. child: Column(
  63. children: [
  64. AppBar(
  65. title: Row(
  66. mainAxisSize: MainAxisSize.min,
  67. mainAxisAlignment: MainAxisAlignment.center,
  68. children: [
  69. Image.asset(sh_titicon, width: 20, height: 20),
  70. const SizedBox(width: 6),
  71. const Text('电子货位卡')
  72. ],
  73. ),
  74. ),
  75. Expanded(
  76. child: Container(
  77. clipBehavior: Clip.hardEdge,
  78. decoration: const BoxDecoration(
  79. color: MyColor.c_background,
  80. borderRadius: BorderRadius.all(Radius.circular(10))),
  81. margin: const EdgeInsets.symmetric(horizontal: 10),
  82. child: SingleChildScrollView(
  83. child: pageState.builder((v) {
  84. if (v.status == DataStatus.error) {
  85. return PageLoadingWidget.error(onTap: loadData);
  86. }
  87. if (v.status == DataStatus.empty) {
  88. return const PageLoadingWidget.empty();
  89. }
  90. if (v.status == DataStatus.loading) {
  91. return const PageLoadingWidget.loading();
  92. }
  93. return Column(
  94. children: [
  95. Padding(
  96. padding: const EdgeInsets.fromLTRB(0, 0, 0, 12),
  97. child: Column(
  98. crossAxisAlignment: CrossAxisAlignment.stretch,
  99. children: [
  100. Container(
  101. padding: const EdgeInsets.all(12),
  102. decoration: const BoxDecoration(
  103. borderRadius: BorderRadius.all(Radius.circular(12)),
  104. image: DecorationImage(
  105. image: AssetImage(sh_TitBgIm), fit: BoxFit.fill),
  106. ),
  107. child: Text(
  108. data?.kqmc ?? '仓房',
  109. textAlign: TextAlign.center,
  110. style: const TextStyle(
  111. fontSize: 20, fontWeight: FontWeight.bold),
  112. )),
  113. const SizedBox(height: 12),
  114. Container(
  115. decoration: const BoxDecoration(
  116. color: Colors.white,
  117. borderRadius: BorderRadius.all(Radius.circular(12))),
  118. child: Stack(
  119. children: [
  120. Column(
  121. crossAxisAlignment: CrossAxisAlignment.start,
  122. children: [
  123. const StoreHouseTit(tit: '基本信息'),
  124. const SizedBox(height: 12),
  125. Padding(
  126. padding: const EdgeInsets.only(left: 12.0),
  127. child: Row(
  128. children: [
  129. const Text(
  130. '仓房编号',
  131. style: TextStyle(
  132. fontSize: 15, fontWeight: FontWeight.w600),
  133. ),
  134. const SizedBox(
  135. width: 6,
  136. ),
  137. Container(
  138. alignment: Alignment.center,
  139. padding: const EdgeInsets.symmetric(
  140. horizontal: 4),
  141. decoration: const BoxDecoration(
  142. color: MyColor.c_28A3ED,
  143. borderRadius:
  144. BorderRadius.all(Radius.circular(2))),
  145. child: Center(
  146. child: Text(
  147. data?.cfmc ?? '',
  148. style: const TextStyle(
  149. fontSize: 14,
  150. color: Colors.white,
  151. fontWeight: FontWeight.bold,
  152. fontFeatures: [FontFeature.caseSensitiveForms()]
  153. ),
  154. ),
  155. ),
  156. )
  157. ],
  158. ),
  159. ),
  160. Padding(
  161. padding: const EdgeInsets.only(left: 12.0),
  162. child: Text(data?.tycfbm ?? '',
  163. style: const TextStyle(
  164. fontWeight: FontWeight.bold, fontSize: 15)),
  165. ),
  166. const SizedBox(
  167. height: 8,
  168. ),
  169. const Divider(
  170. thickness: 0.6,
  171. color: Color(0xFFEEEEEE),
  172. indent: 12,
  173. ),
  174. if(cflist.first.isNotEmpty)
  175. Padding(
  176. padding: const EdgeInsets.fromLTRB(12,12,12,8),
  177. child: Text(cflist.first ?? '',
  178. style: const TextStyle(
  179. fontWeight: FontWeight.bold, fontSize: 15)),
  180. ),
  181. if(cflist.length>=2)
  182. Padding(
  183. padding: const EdgeInsets.fromLTRB(12,0,12,12),
  184. child: Text(cflist[1] ?? '',
  185. style: const TextStyle(
  186. fontWeight: FontWeight.bold, fontSize: 15,color: Colors.grey)),
  187. ),
  188. const Divider(
  189. thickness: 0.6,
  190. color: Color(0xFFEEEEEE),
  191. indent: 12,
  192. ),
  193. SHImageAndNameWidget(
  194. image: sh_bgyim,
  195. title: '保管员',
  196. content: data?.bgr,
  197. fontSize: 13,
  198. imageR: sh_jgtimeim,
  199. titleR: '交付使用日期',
  200. contentR: data?.jfsyrq,
  201. ),
  202. const SizedBox(
  203. height: 6,
  204. ),
  205. ],
  206. ),
  207. Positioned(
  208. top: 12,
  209. right: 12,
  210. child: Container(
  211. decoration: BoxDecoration(
  212. borderRadius:
  213. const BorderRadius.all(Radius.circular(40)),
  214. border: Border.all(
  215. color: const Color(0xFFFF0000), width: 4.0),
  216. ),
  217. width: 80,
  218. height: 80,
  219. child: Center(
  220. child: Transform.rotate(
  221. angle: 0.5,
  222. child: Text(
  223. data?.cfzt ?? '',
  224. textScaler: TextScaler.noScaling,
  225. style: const TextStyle(
  226. color: Color(0xFFFF0000),
  227. fontSize: 28,
  228. fontWeight: FontWeight.w800,),
  229. ),
  230. ),
  231. ),
  232. ),
  233. ),
  234. ],
  235. ),
  236. ),
  237. const SizedBox(height: 12),
  238. Container(
  239. decoration: const BoxDecoration(
  240. color: Colors.white,
  241. borderRadius: BorderRadius.all(Radius.circular(12))),
  242. child: Column(
  243. children: [
  244. const StoreHouseTit(tit: '仓房信息'),
  245. SHImageAndNameWidget(
  246. image: sh_cang,
  247. title: '设计仓容',
  248. content: '${data?.ajsjcr}吨',
  249. fontSize: 15,
  250. imageR: sh_nian,
  251. titleR: '设计使用年限',
  252. contentR: '${data?.sjsynx}年',
  253. ),
  254. const Divider(
  255. thickness: 0.6,
  256. color: Color(0xFFEEEEEE),
  257. indent: 12,
  258. ),
  259. SHImageAndNameWidget(
  260. image: sh_chang,
  261. title: '长*宽*高(米)',
  262. content: data?.ckg,
  263. fontSize: 15,
  264. imageR: sh_xiangao,
  265. titleR: '装粮线高(米)',
  266. contentR: data?.cnzlxg),
  267. const SizedBox(
  268. height: 6,
  269. ),
  270. ],
  271. ),
  272. ),
  273. const SizedBox(height: 12),
  274. Container(
  275. decoration: const BoxDecoration(
  276. color: Colors.white,
  277. borderRadius: BorderRadius.all(Radius.circular(12))),
  278. child: Stack(
  279. children: [
  280. Column(
  281. children: [
  282. const StoreHouseTit(tit: '粮食库存'),
  283. Padding(
  284. padding: const EdgeInsets.symmetric(horizontal: 12),
  285. child: Row(
  286. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  287. children: [
  288. Container(
  289. padding:
  290. const EdgeInsets.symmetric(horizontal: 6),
  291. alignment: Alignment.center,
  292. decoration: BoxDecoration(
  293. color: const Color(0xFFEBF8FE),
  294. border: Border.all(
  295. color: const Color(0xFF60B5F4),
  296. width: 1.0),
  297. borderRadius:
  298. BorderRadius.circular(4) // 设置边框样式
  299. ),
  300. child: Text(
  301. '产地:${data?.itemList?.first?.cd}',
  302. style: const TextStyle(
  303. fontSize: 14, color: Color(0xFF60B5F4)),
  304. ),
  305. ),
  306. Container(
  307. padding:
  308. const EdgeInsets.symmetric(horizontal: 6),
  309. alignment: Alignment.center,
  310. decoration: BoxDecoration(
  311. color: const Color(0xFFFAFAEE),
  312. border: Border.all(
  313. color: const Color(0xFFE6B32A),
  314. width: 1.0),
  315. borderRadius:
  316. BorderRadius.circular(4) // 设置边框样式
  317. ),
  318. child: Text(
  319. '粮食等级:${data?.itemList?.first?.lsdjmc}',
  320. style: const TextStyle(
  321. fontSize: 14, color: Color(0xFFE6B32A)),
  322. ),
  323. ),
  324. ],
  325. ),
  326. ),
  327. SHImageAndNameWidget(
  328. image: sh_xingzhi,
  329. title: '储存性质',
  330. content: data?.itemList?.first?.lsxzmc,
  331. fontSize: 15,
  332. imageR: sh_niandu,
  333. titleR: '收获年度',
  334. contentR: '${data?.itemList?.first?.shnd}年'),
  335. const Divider(
  336. thickness: 0.6,
  337. color: Color(0xFFEEEEEE),
  338. indent: 12,
  339. ),
  340. SHImageAndNameWidget(
  341. image: sh_kucun,
  342. title: '库存',
  343. content: '${data?.itemList?.first?.jjsl}吨',
  344. fontSize: 15,
  345. imageR: sh_rucang,
  346. titleR: '入仓时间',
  347. contentR: data?.itemList?.first?.timeStr()),
  348. const Divider(
  349. thickness: 0.6,
  350. color: Color(0xFFEEEEEE),
  351. indent: 12,
  352. ),
  353. Padding(
  354. padding: const EdgeInsets.all(12),
  355. child: Row(
  356. children: [
  357. Image.asset(
  358. sh_danwei,
  359. width: 32,
  360. height: 32,
  361. ),
  362. const SizedBox(
  363. width: 6,
  364. ),
  365. Expanded(
  366. child: Column(
  367. crossAxisAlignment: CrossAxisAlignment.start,
  368. children: [
  369. const Text(
  370. '粮权归属单位',
  371. style: TextStyle(
  372. fontWeight: FontWeight.bold,
  373. fontSize: 15,
  374. color: Colors.grey),
  375. ),
  376. Text(
  377. data?.itemList?.first?.lqgsdw ?? '',
  378. style: const TextStyle(
  379. fontWeight: FontWeight.bold,
  380. fontSize: 15),
  381. )
  382. ],
  383. ),
  384. )
  385. ],
  386. ),
  387. ),
  388. const SizedBox(height: 6),
  389. ],
  390. ),
  391. Positioned(
  392. top: 12,
  393. right: 0,
  394. child: Container(
  395. padding: const EdgeInsets.symmetric(
  396. horizontal: 18, vertical: 2),
  397. decoration: const BoxDecoration(
  398. color: Color(0xFF60B5F4),
  399. borderRadius: BorderRadius.only(
  400. topLeft: Radius.circular(10),
  401. bottomLeft: Radius.circular(10)),
  402. ),
  403. child: Text(
  404. '品种:${data?.itemList?.first?.lspzmc}',
  405. style: const TextStyle(color: Colors.white),
  406. ),
  407. ),
  408. ),
  409. ],
  410. ),
  411. )
  412. ],
  413. ),
  414. ),
  415. ],
  416. );
  417. }),
  418. ),
  419. )),
  420. ],
  421. )
  422. );
  423. }
  424. }