123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439 |
- import 'package:flutter/material.dart';
- import 'package:lszlgl/base/base_lifecycle_state.dart';
- import 'package:lszlgl/base/base_vm.dart';
- import 'package:lszlgl/config/colors.dart';
- import 'package:lszlgl/main.dart';
- import 'package:lszlgl/model/rsp/storehouse_rsp.dart';
- import 'package:lszlgl/network/my_api.dart';
- import 'package:lszlgl/widget/page_widget.dart';
- import 'package:lszlgl/widget/storehouse_item.dart';
- class StoreHousePage extends StatefulWidget {
- final String houseNum;
- const StoreHousePage({super.key, required this.houseNum});
- @override
- State<StoreHousePage> createState() => _StoreHousePageState();
- }
- class _StoreHousePageState extends BaseLifecycleState<StoreHousePage> {
- final pageState = DataStatusModel<storehouseRsp?>().notifier<DataStatusModel<storehouseRsp?>>();
- storehouseRsp? data;
- List<String> cflist=[];
- @override
- void onFirstShow(Duration timeStamp) {
- loadData();
- }
- @override
- void onDestroy() {
- pageState.dispose();
- }
- void loadData() async {
- pageState.update(pageState.value.loading());
- try {
- // String jsonStr = await Future.delayed(const Duration(seconds: 3),()async{
- // return rootBundle.loadString('assets/json/storehouse.json');
- // });
- // Map<String,dynamic> val = json.decode(jsonStr);
- // ApiRsp<List<storehouseRsp?>> res= ApiRsp<List<storehouseRsp>>.fromJson(
- // val,
- // (json) => json is List<dynamic>
- // ? json
- // .map<storehouseRsp>((i) => storehouseRsp.fromJson(i as Map<String, dynamic>))
- // .toList()
- // : List.empty(),
- // );
- var res = await MyApi.get(baseUrl: 'http://121.36.17.6:28088')
- .getStoreMessage(widget.houseNum, 'zhijian');
- if (res.data?.first.tycfbm == null) {
- pageState.update(pageState.value.empty());
- } else {
- data = res.data!.first;
- //
- cflist = (data?.cflx ?? '').split(RegExp(r'[()()]'));
- cflist.removeWhere((val) => val == '');
- pageState.update(pageState.value.success(data: res.data!.first));
- }
- } catch (e) {
- logger.e(e);
- pageState.update(pageState.value.error());
- }
- }
- @override
- Widget build(BuildContext context) {
- return myScaffold(
- child: Column(
- children: [
- AppBar(
- title: Row(
- mainAxisSize: MainAxisSize.min,
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Image.asset(sh_titicon, width: 20, height: 20),
- const SizedBox(width: 6),
- const Text('电子货位卡')
- ],
- ),
- ),
- Expanded(
- child: Container(
- clipBehavior: Clip.hardEdge,
- decoration: const BoxDecoration(
- color: MyColor.c_background,
- borderRadius: BorderRadius.all(Radius.circular(10))),
- margin: const EdgeInsets.symmetric(horizontal: 10),
- child: SingleChildScrollView(
- child: pageState.builder((v) {
- if (v.status == DataStatus.error) {
- return PageLoadingWidget.error(onTap: loadData);
- }
- if (v.status == DataStatus.empty) {
- return const PageLoadingWidget.empty();
- }
- if (v.status == DataStatus.loading) {
- return const PageLoadingWidget.loading();
- }
- return Column(
- children: [
- Padding(
- padding: const EdgeInsets.fromLTRB(0, 0, 0, 12),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
- Container(
- padding: const EdgeInsets.all(12),
- decoration: const BoxDecoration(
- borderRadius: BorderRadius.all(Radius.circular(12)),
- image: DecorationImage(
- image: AssetImage(sh_TitBgIm), fit: BoxFit.fill),
- ),
- child: Text(
- data?.kqmc ?? '仓房',
- textAlign: TextAlign.center,
- style: const TextStyle(
- fontSize: 20, fontWeight: FontWeight.bold),
- )),
- const SizedBox(height: 12),
- Container(
- decoration: const BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.all(Radius.circular(12))),
- child: Stack(
- children: [
- Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- const StoreHouseTit(tit: '基本信息'),
- const SizedBox(height: 12),
- Padding(
- padding: const EdgeInsets.only(left: 12.0),
- child: Row(
- children: [
- const Text(
- '仓房编号',
- style: TextStyle(
- fontSize: 15, fontWeight: FontWeight.w600),
- ),
- const SizedBox(
- width: 6,
- ),
- Container(
- alignment: Alignment.center,
- padding: const EdgeInsets.symmetric(
- horizontal: 4),
- decoration: const BoxDecoration(
- color: MyColor.c_28A3ED,
- borderRadius:
- BorderRadius.all(Radius.circular(2))),
- child: Center(
- child: Text(
- data?.cfmc ?? '',
- style: const TextStyle(
- fontSize: 14,
- color: Colors.white,
- fontWeight: FontWeight.bold,
- fontFeatures: [FontFeature.caseSensitiveForms()]
- ),
- ),
- ),
- )
- ],
- ),
- ),
- Padding(
- padding: const EdgeInsets.only(left: 12.0),
- child: Text(data?.tycfbm ?? '',
- style: const TextStyle(
- fontWeight: FontWeight.bold, fontSize: 15)),
- ),
- const SizedBox(
- height: 8,
- ),
- const Divider(
- thickness: 0.6,
- color: Color(0xFFEEEEEE),
- indent: 12,
- ),
- if(cflist.first.isNotEmpty)
- Padding(
- padding: const EdgeInsets.fromLTRB(12,12,12,8),
- child: Text(cflist.first ?? '',
- style: const TextStyle(
- fontWeight: FontWeight.bold, fontSize: 15)),
- ),
- if(cflist.length>=2)
- Padding(
- padding: const EdgeInsets.fromLTRB(12,0,12,12),
- child: Text(cflist[1] ?? '',
- style: const TextStyle(
- fontWeight: FontWeight.bold, fontSize: 15,color: Colors.grey)),
- ),
- const Divider(
- thickness: 0.6,
- color: Color(0xFFEEEEEE),
- indent: 12,
- ),
- SHImageAndNameWidget(
- image: sh_bgyim,
- title: '保管员',
- content: data?.bgr,
- fontSize: 13,
- imageR: sh_jgtimeim,
- titleR: '交付使用日期',
- contentR: data?.jfsyrq,
- ),
- const SizedBox(
- height: 6,
- ),
- ],
- ),
- Positioned(
- top: 12,
- right: 12,
- child: Container(
- decoration: BoxDecoration(
- borderRadius:
- const BorderRadius.all(Radius.circular(40)),
- border: Border.all(
- color: const Color(0xFFFF0000), width: 4.0),
- ),
- width: 80,
- height: 80,
- child: Center(
- child: Transform.rotate(
- angle: 0.5,
- child: Text(
- data?.cfzt ?? '',
- textScaler: TextScaler.noScaling,
- style: const TextStyle(
- color: Color(0xFFFF0000),
- fontSize: 28,
- fontWeight: FontWeight.w800,),
- ),
- ),
- ),
- ),
- ),
- ],
- ),
- ),
- const SizedBox(height: 12),
- Container(
- decoration: const BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.all(Radius.circular(12))),
- child: Column(
- children: [
- const StoreHouseTit(tit: '仓房信息'),
- SHImageAndNameWidget(
- image: sh_cang,
- title: '设计仓容',
- content: '${data?.ajsjcr}吨',
- fontSize: 15,
- imageR: sh_nian,
- titleR: '设计使用年限',
- contentR: '${data?.sjsynx}年',
- ),
- const Divider(
- thickness: 0.6,
- color: Color(0xFFEEEEEE),
- indent: 12,
- ),
- SHImageAndNameWidget(
- image: sh_chang,
- title: '长*宽*高(米)',
- content: data?.ckg,
- fontSize: 15,
- imageR: sh_xiangao,
- titleR: '装粮线高(米)',
- contentR: data?.cnzlxg),
- const SizedBox(
- height: 6,
- ),
- ],
- ),
- ),
- const SizedBox(height: 12),
- Container(
- decoration: const BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.all(Radius.circular(12))),
- child: Stack(
- children: [
- Column(
- children: [
- const StoreHouseTit(tit: '粮食库存'),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 12),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Container(
- padding:
- const EdgeInsets.symmetric(horizontal: 6),
- alignment: Alignment.center,
- decoration: BoxDecoration(
- color: const Color(0xFFEBF8FE),
- border: Border.all(
- color: const Color(0xFF60B5F4),
- width: 1.0),
- borderRadius:
- BorderRadius.circular(4) // 设置边框样式
- ),
- child: Text(
- '产地:${data?.itemList?.first?.cd}',
- style: const TextStyle(
- fontSize: 14, color: Color(0xFF60B5F4)),
- ),
- ),
- Container(
- padding:
- const EdgeInsets.symmetric(horizontal: 6),
- alignment: Alignment.center,
- decoration: BoxDecoration(
- color: const Color(0xFFFAFAEE),
- border: Border.all(
- color: const Color(0xFFE6B32A),
- width: 1.0),
- borderRadius:
- BorderRadius.circular(4) // 设置边框样式
- ),
- child: Text(
- '粮食等级:${data?.itemList?.first?.lsdjmc}',
- style: const TextStyle(
- fontSize: 14, color: Color(0xFFE6B32A)),
- ),
- ),
- ],
- ),
- ),
- SHImageAndNameWidget(
- image: sh_xingzhi,
- title: '储存性质',
- content: data?.itemList?.first?.lsxzmc,
- fontSize: 15,
- imageR: sh_niandu,
- titleR: '收获年度',
- contentR: '${data?.itemList?.first?.shnd}年'),
- const Divider(
- thickness: 0.6,
- color: Color(0xFFEEEEEE),
- indent: 12,
- ),
- SHImageAndNameWidget(
- image: sh_kucun,
- title: '库存',
- content: '${data?.itemList?.first?.jjsl}吨',
- fontSize: 15,
- imageR: sh_rucang,
- titleR: '入仓时间',
- contentR: data?.itemList?.first?.timeStr()),
- const Divider(
- thickness: 0.6,
- color: Color(0xFFEEEEEE),
- indent: 12,
- ),
- Padding(
- padding: const EdgeInsets.all(12),
- child: Row(
- children: [
- Image.asset(
- sh_danwei,
- width: 32,
- height: 32,
- ),
- const SizedBox(
- width: 6,
- ),
- Expanded(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- const Text(
- '粮权归属单位',
- style: TextStyle(
- fontWeight: FontWeight.bold,
- fontSize: 15,
- color: Colors.grey),
- ),
- Text(
- data?.itemList?.first?.lqgsdw ?? '',
- style: const TextStyle(
- fontWeight: FontWeight.bold,
- fontSize: 15),
- )
- ],
- ),
- )
- ],
- ),
- ),
- const SizedBox(height: 6),
- ],
- ),
- Positioned(
- top: 12,
- right: 0,
- child: Container(
- padding: const EdgeInsets.symmetric(
- horizontal: 18, vertical: 2),
- decoration: const BoxDecoration(
- color: Color(0xFF60B5F4),
- borderRadius: BorderRadius.only(
- topLeft: Radius.circular(10),
- bottomLeft: Radius.circular(10)),
- ),
- child: Text(
- '品种:${data?.itemList?.first?.lspzmc}',
- style: const TextStyle(color: Colors.white),
- ),
- ),
- ),
- ],
- ),
- )
- ],
- ),
- ),
- ],
- );
- }),
- ),
- )),
- ],
- )
- );
- }
- }
|