123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- import 'dart:convert';
- import 'package:dotted_border/dotted_border.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
- import 'package:lszlgl/base/base_lifecycle_state.dart';
- import 'package:lszlgl/base/base_vm.dart';
- import 'package:lszlgl/config/borders.dart';
- import 'package:lszlgl/main.dart';
- import 'package:lszlgl/model/api_rsp.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;
- final ValueNotifier<String> _title = ValueNotifier<String>('仓房信息');
- @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://101.36.160.117:28088').getStoreMessage(widget.houseNum, 'zhijian');
- if(res.data == null ){
- pageState.update(pageState.value.empty());
- }else{
- data = res.data!.first;
- _title.value = data?.kqmc ?? '仓房信息' ;
- 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: KeyboardDismissOnTap(
- dismissOnCapturedTaps: true,
- child: Column(
- children: [
- ValueListenableBuilder(
- valueListenable: _title,
- builder: (_,String title,__){
- return myAppBar(title: title);
- },
- ),
- Expanded(
- child:Container(
- color: Colors.white,
- 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(
- //crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
- Padding(padding: const EdgeInsets.fromLTRB(22, 20, 22, 4),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
- Text(data?.cfmc ?? '',style: TextStyles.titA,),
- const SizedBox(height: 12),
- Text('仓房编号:${data?.tycfbm}',style: TextStyles.titA),
- const SizedBox(height: 12),
- const Divider(thickness: 0.6,),
- const SizedBox(height: 6),
- StorehouseItem(special: true,left: data?.cflx,right: data?.cfzt),
- StorehouseItem(left: '保管员',right: data?.bgr),
- StorehouseItem(left: '交付使用日期', right: data?.jfsyrq),
- const SizedBox(height: 10),
- const Divider(thickness: 0.6,),
- ],
- ),
- ),
- const StoreHouseTit(tit: '仓房信息'),
- Padding(padding: const EdgeInsets.fromLTRB(22, 8, 22, 4),
- child:Column(
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
- StorehouseItem(left: '设计仓容',right: '${data?.ajsjcr}吨',),
- StorehouseItem(left: '设计使用年限',right: '${data?.sjsynx}年',),
- StorehouseItem(left: '装粮线高',right: '${data?.cnzlxg}米',),
- StorehouseItem(left: '长*宽*高',right: data?.ckg,),
- const SizedBox(height: 10),
- const Divider(thickness: 0.6,),
- ],
- )
- ),
- const StoreHouseTit(tit: '粮食库存'),
- Container(
- padding: const EdgeInsets.symmetric(horizontal:22,vertical: 12),
- child: DottedBorder(
- strokeWidth: 0.8,
- color: Colors.grey,
- dashPattern:const[3,4],
- padding: const EdgeInsets.all(8),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
- StorehouseItem(left: '粮食品种',right: data?.itemList?.first?.lspzmc),
- StorehouseItem(left: '粮食等级',right: data?.itemList?.first?.lsdjmc),
- StorehouseItem(left: '库存',right: '${data?.itemList?.first?.jjsl}kg'),
- StorehouseItem(left: '储存性质',right: data?.itemList?.first?.lsxzmc),
- StorehouseItem(left: '粮权归属单位',right: data?.itemList?.first?.lqgsdw),
- StorehouseItem(left: '入仓时间',right: data?.itemList?.first?.timeStr()),
- StorehouseItem(left: '产地',right: data?.itemList?.first?.cd),
- StorehouseItem(left: '收货年度',right: '${data?.itemList?.first?.shnd}年'),
- ],
- ),
- ),
- )
- ],
- );
- }
- ),
- ),
- )
- ),
- ],
- )
- ),
- );
- }
- }
|