YSHomeListDetailGather.dart 74 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter/services.dart';
  4. import 'package:flutter_tzh/base/YSBase.dart';
  5. import 'package:flutter_tzh/home/view/YSInputView.dart';
  6. import 'package:flutter_tzh/home/view/YSMapView.dart';
  7. import 'package:flutter_tzh/tool/YSFileView.dart';
  8. import 'package:flutter_tzh/tool/YSNetWork.dart';
  9. import 'package:flutter_tzh/tool/YSTools.dart';
  10. //TODO:YSHomeListDetailGather
  11. class YSHomeListDetailGather extends StatefulWidget {
  12. final int gatherId;
  13. const YSHomeListDetailGather({Key? key, required this.gatherId}) : super(key: key);
  14. @override
  15. YSHomeListDetailGatherState createState() => YSHomeListDetailGatherState();
  16. }
  17. class YSHomeListDetailGatherState extends State<YSHomeListDetailGather> {
  18. bool _isHiden = false;
  19. final Map _contentMap = {'title':'采样描述'};
  20. final List _inputArray = [];
  21. final List _fileArray = [];
  22. String _value = '';
  23. @override
  24. void initState() {
  25. Future.delayed(const Duration(seconds: 0)).then((value) {
  26. _getSamplingFieldIndex();
  27. });
  28. super.initState();
  29. }
  30. @override
  31. Widget build(BuildContext context) {
  32. return YSBase(
  33. ysTitle: '采样',
  34. ysChild: GestureDetector(
  35. // onVerticalDragEnd: (value){
  36. // if(value.primaryVelocity!>0){
  37. // _isHiden = true;
  38. // }else if(value.primaryVelocity!<0){
  39. // _isHiden = false;
  40. // }
  41. // setState(() {});
  42. // },
  43. child: SingleChildScrollView(
  44. padding: EdgeInsets.only(left: hsp(20),right: hsp(20),top: hsp(20)),
  45. child: Column(
  46. children: [
  47. ClipRRect(
  48. borderRadius: const BorderRadius.all(Radius.circular(24)),
  49. child: Container(
  50. height: _isHiden?ysHeight(context)-ysTOP(context)-44-hsp(110):hsp(150),
  51. decoration: const BoxDecoration(
  52. color: Color(0xFF3E434E)
  53. ),
  54. child: const YSMapView(location: {'latitude': 57.24, 'longitude': 127.38},),
  55. ),
  56. ),
  57. GestureDetector(
  58. onTap: (){
  59. _isHiden = !_isHiden;
  60. setState(() {});
  61. },
  62. child: Container(
  63. padding: EdgeInsets.only(top: hsp(10),bottom: hsp(10)),
  64. child: Image.asset('images/tzh_${_isHiden?'up':'down1'}.png',height: hsp(15),width: hsp(15),),
  65. ),
  66. ),
  67. _isHiden?Container(
  68. height: hsp(50),
  69. decoration: const BoxDecoration(
  70. image: DecorationImage(image: AssetImage('images/tzh_hiden.png') )
  71. ),
  72. alignment: Alignment.center,
  73. padding: EdgeInsets.only(top: hsp(15)),
  74. child: Text('采样说明',style: TextStyle(fontSize: zsp(14),color: const Color(0xFFDBE1EA)),),
  75. ):SizedBox(
  76. height: ysHeight(context)-ysTOP(context)-44-hsp(205),
  77. child: Column(
  78. children: [
  79. SizedBox(
  80. height: ysHeight(context)-ysTOP(context)-44-hsp(277),
  81. child: SingleChildScrollView(
  82. child: Column(
  83. children: [
  84. Container(
  85. width: ysWidth(context)-hsp(40),
  86. decoration: const BoxDecoration(
  87. color: Color(0xFF3E434E),
  88. borderRadius: BorderRadius.all(Radius.circular(24))
  89. ),
  90. child: Column(
  91. children: [
  92. Container(
  93. height: hsp(50),
  94. alignment: Alignment.centerLeft,
  95. padding: EdgeInsets.only(left: hsp(15),right: hsp(15)),
  96. decoration: BoxDecoration(
  97. border: Border(bottom: BorderSide(color: const Color(0x99535966),width: hsp(1)))
  98. ),
  99. child: Text('采样描述',style: TextStyle(fontSize: zsp(14),color: const Color(0xFFDBE1EA)),),
  100. ),
  101. Container(
  102. width: ysWidth(context)-hsp(40),
  103. padding: EdgeInsets.all(hsp(15)),
  104. constraints: BoxConstraints(minHeight: hsp(100)),
  105. child: YSInputView2(item: _contentMap),
  106. )
  107. ],
  108. ),
  109. ),
  110. Container(
  111. margin: EdgeInsets.only(top: hsp(15),bottom: hsp(15)),
  112. padding: EdgeInsets.all(hsp(15)),
  113. decoration: const BoxDecoration(
  114. color: Color(0xFF3E434E),
  115. borderRadius: BorderRadius.all(Radius.circular(24))
  116. ),
  117. child: Column(
  118. crossAxisAlignment: CrossAxisAlignment.start,
  119. children: [
  120. Container(
  121. decoration: BoxDecoration(
  122. color: const Color(0xFF1A1C1F),
  123. borderRadius: const BorderRadius.all(Radius.circular(3)),
  124. border: Border.all(color: const Color(0xFF3E434E),width: hsp(1))
  125. ),
  126. padding: EdgeInsets.only(left: hsp(12),right: hsp(12),top: hsp(5),bottom: hsp(5)),
  127. margin: EdgeInsets.only(bottom: hsp(10)),
  128. child: Column(
  129. crossAxisAlignment: CrossAxisAlignment.start,
  130. children: [
  131. Text('有机土壤碳',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),),
  132. SizedBox(
  133. height: hsp(20),
  134. child: CupertinoTextField(
  135. placeholder: '请描述内容',
  136. style: TextStyle(fontSize: zsp(16),color: Colors.white),
  137. padding: const EdgeInsets.all(0),
  138. placeholderStyle: TextStyle(fontSize: zsp(16),color: Colors.white),
  139. decoration: const BoxDecoration(
  140. color: Colors.transparent
  141. ),
  142. suffix: Text('kg',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),),
  143. maxLines: 100,
  144. onChanged: (value){
  145. _value = value;
  146. },
  147. )
  148. )
  149. ],
  150. ),
  151. ),
  152. ListView.separated(
  153. itemBuilder: (context,index){
  154. Map item = _inputArray[index];
  155. return Container(
  156. decoration: BoxDecoration(
  157. color: const Color(0xFF1A1C1F),
  158. borderRadius: const BorderRadius.all(Radius.circular(3)),
  159. border: Border.all(color: const Color(0xFF3E434E),width: hsp(1))
  160. ),
  161. padding: EdgeInsets.only(left: hsp(12),right: hsp(12),top: hsp(5),bottom: hsp(5)),
  162. child: Column(
  163. crossAxisAlignment: CrossAxisAlignment.start,
  164. children: [
  165. Text('${item['title']}',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),),
  166. SizedBox(
  167. height: hsp(20),
  168. child: CupertinoTextField(
  169. placeholder: '请输入${item['title']}',
  170. style: TextStyle(fontSize: zsp(16),color: Colors.white),
  171. padding: const EdgeInsets.all(0),
  172. placeholderStyle: TextStyle(fontSize: zsp(16),color: Colors.white),
  173. decoration: const BoxDecoration(
  174. color: Colors.transparent
  175. ),
  176. suffix: Text('${item['unit']}',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),),
  177. inputFormatters: [FilteringTextInputFormatter.allow(RegExp("[0-9.]"))],
  178. keyboardType: const TextInputType.numberWithOptions(),
  179. maxLines: 100,
  180. onChanged: (value){
  181. if(value.isEmpty){
  182. item.remove('value');
  183. }else{
  184. item['value'] = value;
  185. }
  186. },
  187. )
  188. )
  189. ],
  190. ),
  191. );
  192. },
  193. separatorBuilder: (context,index){
  194. return Container(height: hsp(10),);
  195. },
  196. itemCount: _inputArray.length,
  197. shrinkWrap: true,
  198. physics: const NeverScrollableScrollPhysics(),
  199. padding: const EdgeInsets.all(0),
  200. ),
  201. Container(
  202. alignment: Alignment.centerLeft,
  203. height: hsp(30),
  204. child: Text('附件',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),),
  205. ),
  206. YSUploadFileView2(fileArray: _fileArray),
  207. Container(
  208. alignment: Alignment.centerLeft,
  209. height: hsp(30),
  210. child: Text('建议尺寸900*400,最多4张,单个图片不超过20M。',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),),
  211. )
  212. ],
  213. ),
  214. ),
  215. ],
  216. ),
  217. ),
  218. ),
  219. GestureDetector(
  220. behavior: HitTestBehavior.opaque,
  221. onTap: () async{
  222. FocusScope.of(context).unfocus();
  223. // LogUtil.d(_fileArray);
  224. if(_contentMap['value']==null){
  225. ysFlutterToast('请填写采样描述');
  226. return;
  227. }
  228. if(_value.isEmpty){
  229. ysFlutterToast('请填写有机土壤碳信息');
  230. return;
  231. }
  232. // for (var element in _inputArray) {
  233. // if(element['value']==null){
  234. // ysFlutterToast('请完善${element['title']}');
  235. // return;
  236. // }
  237. // }
  238. List images = [];
  239. List video = [];
  240. for (var element in _fileArray) {
  241. if('${element['url']}'.contains('.mp4')==true){
  242. video.add(element['url']);
  243. }else{
  244. images.add(element['url']);
  245. }
  246. }
  247. Map request = {};
  248. request['id'] = widget.gatherId;
  249. request['describes'] = _contentMap['value'];
  250. request['recordList'] = _inputArray;
  251. request['imageList'] = images;
  252. if(video.isNotEmpty)request['video'] = video.first;
  253. request['value'] = _value;
  254. LogUtil.d(request);
  255. YSNetWork.ysRequestHttp(context, type: RequestType.post, api: '/samplingRecord/add', parameter: request, successSetter: (dict){
  256. ysFlutterToast('采样点数据更新成功');
  257. Navigator.of(context).pop('');
  258. },isLoading: true);
  259. },
  260. child: Image.asset('images/tzh_done.png',height: hsp(72),),
  261. )
  262. ],
  263. ),
  264. )
  265. ],
  266. ),
  267. ),
  268. ),
  269. );
  270. }
  271. _getSamplingFieldIndex() async{
  272. YSNetWork.ysRequestHttp(context, type: RequestType.get, api: '/samplingField/index', parameter: {}, successSetter: (dict){
  273. _inputArray.clear();
  274. _inputArray.addAll(dict['data']??[]);
  275. setState(() {});
  276. });
  277. }
  278. }
  279. //TODO:YSHomeListDetailGather2
  280. class YSHomeListDetailGather2 extends StatefulWidget {
  281. final int gatherId;
  282. const YSHomeListDetailGather2({Key? key, required this.gatherId}) : super(key: key);
  283. @override
  284. YSHomeListDetailGather2State createState() => YSHomeListDetailGather2State();
  285. }
  286. class YSHomeListDetailGather2State extends State<YSHomeListDetailGather2> {
  287. bool _isHiden = false;
  288. final Map _contentMap = {'title':'采样描述'};
  289. final List _inputArray = [];
  290. final List _fileArray = [];
  291. String _value = '';
  292. @override
  293. void initState() {
  294. Future.delayed(const Duration(seconds: 0)).then((value) {
  295. _getSamplingFieldData();
  296. });
  297. super.initState();
  298. }
  299. @override
  300. Widget build(BuildContext context) {
  301. return YSBase(
  302. ysTitle: '采样',
  303. ysChild: GestureDetector(
  304. // onVerticalDragEnd: (value){
  305. // if(value.primaryVelocity!>0){
  306. // _isHiden = true;
  307. // }else if(value.primaryVelocity!<0){
  308. // _isHiden = false;
  309. // }
  310. // setState(() {});
  311. // },
  312. child: SingleChildScrollView(
  313. padding: EdgeInsets.only(left: hsp(20),right: hsp(20),top: hsp(20)),
  314. child: Column(
  315. children: [
  316. ClipRRect(
  317. borderRadius: const BorderRadius.all(Radius.circular(24)),
  318. child: Container(
  319. height: _isHiden?ysHeight(context)-ysTOP(context)-44-hsp(110):hsp(150),
  320. decoration: const BoxDecoration(
  321. color: Color(0xFF3E434E)
  322. ),
  323. child: const YSMapView(location: {'latitude': 57.24, 'longitude': 127.38},),
  324. ),
  325. ),
  326. GestureDetector(
  327. onTap: (){
  328. _isHiden = !_isHiden;
  329. setState(() {});
  330. },
  331. child: Container(
  332. padding: EdgeInsets.only(top: hsp(10),bottom: hsp(10)),
  333. child: Image.asset('images/tzh_${_isHiden?'up':'down1'}.png',height: hsp(15),width: hsp(15),),
  334. ),
  335. ),
  336. _isHiden?Container(
  337. height: hsp(50),
  338. decoration: const BoxDecoration(
  339. image: DecorationImage(image: AssetImage('images/tzh_hiden.png') )
  340. ),
  341. alignment: Alignment.center,
  342. padding: EdgeInsets.only(top: hsp(15)),
  343. child: Text('采样说明',style: TextStyle(fontSize: zsp(14),color: const Color(0xFFDBE1EA)),),
  344. ):SizedBox(
  345. height: ysHeight(context)-ysTOP(context)-44-hsp(205),
  346. child: SingleChildScrollView(
  347. child: Column(
  348. children: [
  349. Container(
  350. width: ysWidth(context)-hsp(40),
  351. decoration: const BoxDecoration(
  352. color: Color(0xFF3E434E),
  353. ),
  354. child: Column(
  355. children: [
  356. Container(
  357. height: hsp(50),
  358. alignment: Alignment.centerLeft,
  359. padding: EdgeInsets.only(left: hsp(15),right: hsp(15)),
  360. decoration: BoxDecoration(
  361. border: Border(bottom: BorderSide(color: const Color(0x99535966),width: hsp(1)))
  362. ),
  363. child: Text('采样描述',style: TextStyle(fontSize: zsp(14),color: const Color(0xFFDBE1EA)),),
  364. ),
  365. Container(
  366. width: ysWidth(context)-hsp(40),
  367. padding: EdgeInsets.all(hsp(15)),
  368. constraints: BoxConstraints(minHeight: hsp(100)),
  369. child: Text('${_contentMap['value']??''}',style: TextStyle(fontSize: zsp(14),color: ysValueColor),),
  370. )
  371. ],
  372. ),
  373. ),
  374. Container(
  375. margin: EdgeInsets.only(top: hsp(15),bottom: hsp(15)),
  376. padding: EdgeInsets.all(hsp(15)),
  377. decoration: const BoxDecoration(
  378. color: Color(0xFF3E434E),
  379. borderRadius: BorderRadius.all(Radius.circular(24))
  380. ),
  381. child: Column(
  382. crossAxisAlignment: CrossAxisAlignment.start,
  383. children: [
  384. Container(
  385. decoration: BoxDecoration(
  386. color: const Color(0xFF1A1C1F),
  387. borderRadius: const BorderRadius.all(Radius.circular(3)),
  388. border: Border.all(color: const Color(0xFF3E434E),width: hsp(1))
  389. ),
  390. padding: EdgeInsets.only(left: hsp(12),right: hsp(12),top: hsp(5),bottom: hsp(5)),
  391. margin: EdgeInsets.only(bottom: hsp(10)),
  392. child: Column(
  393. crossAxisAlignment: CrossAxisAlignment.start,
  394. children: [
  395. Text('有机土壤碳',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),),
  396. SizedBox(
  397. height: hsp(20),
  398. child: Row(
  399. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  400. children: [
  401. Text(_value,style: TextStyle(fontSize: zsp(16),color: Colors.white),),
  402. Text('kg',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),)
  403. ],
  404. )
  405. )
  406. ],
  407. ),
  408. ),
  409. ListView.separated(
  410. itemBuilder: (context,index){
  411. Map item = _inputArray[index];
  412. return Container(
  413. decoration: BoxDecoration(
  414. color: const Color(0xFF1A1C1F),
  415. borderRadius: const BorderRadius.all(Radius.circular(3)),
  416. border: Border.all(color: const Color(0xFF3E434E),width: hsp(1))
  417. ),
  418. padding: EdgeInsets.only(left: hsp(12),right: hsp(12),top: hsp(5),bottom: hsp(5)),
  419. child: Column(
  420. crossAxisAlignment: CrossAxisAlignment.start,
  421. children: [
  422. Text('${item['title']}',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),),
  423. SizedBox(
  424. height: hsp(20),
  425. child: Row(
  426. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  427. children: [
  428. Text('${item['total']??''}',style: TextStyle(fontSize: zsp(16),color: Colors.white),),
  429. Text('${item['unit']}',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),)
  430. ],
  431. )
  432. ),
  433. ],
  434. ),
  435. );
  436. },
  437. separatorBuilder: (context,index){
  438. return Container(height: hsp(10),);
  439. },
  440. itemCount: _inputArray.length,
  441. shrinkWrap: true,
  442. physics: const NeverScrollableScrollPhysics(),
  443. padding: const EdgeInsets.all(0),
  444. ),
  445. Container(
  446. alignment: Alignment.centerLeft,
  447. height: hsp(30),
  448. child: Text('附件',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),),
  449. ),
  450. YSFileView(fileArray: _fileArray),
  451. ],
  452. ),
  453. ),
  454. ],
  455. ),
  456. ),
  457. )
  458. ],
  459. ),
  460. ),
  461. ),
  462. );
  463. }
  464. _getSamplingFieldData() async{
  465. YSNetWork.ysRequestHttp(context, type: RequestType.get, api: '/samplingField/data', parameter: {'pointId':widget.gatherId}, successSetter: (dict){
  466. Map data = dict['data']??{};
  467. _value = '${data['value']}';
  468. _contentMap['value'] = '${data['describes']}';
  469. _fileArray.add({'url':data['video'],'type':2});
  470. List imageList = data['imageList']??[];
  471. for (var element in imageList) {
  472. _fileArray.add({'url':element,'type':1});
  473. }
  474. _inputArray.addAll(data['getDataVoList']??[]);
  475. setState(() {});
  476. });
  477. }
  478. }
  479. //TODO:YSHomeListDetailGather3
  480. class YSHomeListDetailGather3 extends StatefulWidget {
  481. final int gatherId;
  482. const YSHomeListDetailGather3({Key? key, required this.gatherId}) : super(key: key);
  483. @override
  484. YSHomeListDetailGather3State createState() => YSHomeListDetailGather3State();
  485. }
  486. class YSHomeListDetailGather3State extends State<YSHomeListDetailGather3> {
  487. bool _isHiden = true;
  488. final Map _contentMap = {'title':'采样描述'};
  489. final List _inputArray = [];
  490. final List _fileArray = [];
  491. String _value = '';
  492. Map _location = {};
  493. @override
  494. void initState() {
  495. Future.delayed(const Duration(seconds: 0)).then((value) {
  496. _getSamplingFieldData();
  497. });
  498. super.initState();
  499. }
  500. @override
  501. Widget build(BuildContext context) {
  502. return YSBase(
  503. ysTitle: '采样',
  504. ysChild: SingleChildScrollView(
  505. padding: EdgeInsets.only(left: hsp(20),right: hsp(20),top: hsp(20)),
  506. child: Stack(
  507. children: [
  508. ClipRRect(
  509. borderRadius: const BorderRadius.all(Radius.circular(24)),
  510. child: Container(
  511. height: ysHeight(context)-ysTOP(context)-44-hsp(110),
  512. decoration: const BoxDecoration(
  513. color: Color(0xFF3E434E)
  514. ),
  515. child: _location.isEmpty?Container():YSMapView(location: _location,),
  516. ),
  517. ),
  518. Container(
  519. margin: EdgeInsets.only(top: _isHiden?ysHeight(context)-ysTOP(context)-44-hsp(95):hsp(150),),
  520. child: Column(
  521. children: [
  522. GestureDetector(
  523. onTap: (){
  524. _isHiden = !_isHiden;
  525. setState(() {});
  526. },
  527. behavior: HitTestBehavior.opaque,
  528. child: Container(
  529. padding: EdgeInsets.only(bottom: hsp(10)),
  530. width: ysWidth(context),
  531. child: Image.asset('images/tzh_${_isHiden?'up':'down1'}.png',height: hsp(15),width: hsp(15),),
  532. ),
  533. ),
  534. if (_isHiden) Container(
  535. height: hsp(50),
  536. decoration: const BoxDecoration(
  537. image: DecorationImage(image: AssetImage('images/tzh_hiden.png') )
  538. ),
  539. alignment: Alignment.center,
  540. padding: EdgeInsets.only(top: hsp(15)),
  541. child: Text('采样说明',style: TextStyle(fontSize: zsp(14),color: const Color(0xFFDBE1EA)),),
  542. ) else ClipRRect(
  543. borderRadius: const BorderRadius.all(Radius.circular(24)),
  544. child: Container(
  545. color: ysBgColor,
  546. height: ysHeight(context)-ysTOP(context)-44-hsp(215),
  547. child: SingleChildScrollView(
  548. child: Column(
  549. children: [
  550. Container(
  551. width: ysWidth(context)-hsp(40),
  552. decoration: const BoxDecoration(
  553. color: Color(0xFF3E434E),
  554. ),
  555. child: Column(
  556. children: [
  557. Container(
  558. height: hsp(50),
  559. alignment: Alignment.centerLeft,
  560. padding: EdgeInsets.only(left: hsp(15),right: hsp(15)),
  561. decoration: BoxDecoration(
  562. border: Border(bottom: BorderSide(color: const Color(0x99535966),width: hsp(1)))
  563. ),
  564. child: Text('采样描述',style: TextStyle(fontSize: zsp(14),color: const Color(0xFFDBE1EA)),),
  565. ),
  566. Container(
  567. width: ysWidth(context)-hsp(40),
  568. padding: EdgeInsets.all(hsp(15)),
  569. constraints: BoxConstraints(minHeight: hsp(100)),
  570. child: Text('${_contentMap['value']??''}',style: TextStyle(fontSize: zsp(14),color: ysValueColor),),
  571. )
  572. ],
  573. ),
  574. ),
  575. Container(
  576. margin: EdgeInsets.only(top: hsp(15),bottom: hsp(15)),
  577. padding: EdgeInsets.all(hsp(15)),
  578. decoration: const BoxDecoration(
  579. color: Color(0xFF3E434E),
  580. borderRadius: BorderRadius.all(Radius.circular(24))
  581. ),
  582. child: Column(
  583. crossAxisAlignment: CrossAxisAlignment.start,
  584. children: [
  585. Container(
  586. decoration: BoxDecoration(
  587. color: const Color(0xFF1A1C1F),
  588. borderRadius: const BorderRadius.all(Radius.circular(3)),
  589. border: Border.all(color: const Color(0xFF3E434E),width: hsp(1))
  590. ),
  591. padding: EdgeInsets.only(left: hsp(12),right: hsp(12),top: hsp(5),bottom: hsp(5)),
  592. margin: EdgeInsets.only(bottom: hsp(10)),
  593. child: Column(
  594. crossAxisAlignment: CrossAxisAlignment.start,
  595. children: [
  596. Text('有机土壤碳',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),),
  597. SizedBox(
  598. height: hsp(20),
  599. child: Row(
  600. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  601. children: [
  602. Text(_value,style: TextStyle(fontSize: zsp(16),color: Colors.white),),
  603. Text('kg',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),)
  604. ],
  605. )
  606. )
  607. ],
  608. ),
  609. ),
  610. ListView.separated(
  611. itemBuilder: (context,index){
  612. Map item = _inputArray[index];
  613. return Container(
  614. decoration: BoxDecoration(
  615. color: const Color(0xFF1A1C1F),
  616. borderRadius: const BorderRadius.all(Radius.circular(3)),
  617. border: Border.all(color: const Color(0xFF3E434E),width: hsp(1))
  618. ),
  619. padding: EdgeInsets.only(left: hsp(12),right: hsp(12),top: hsp(5),bottom: hsp(5)),
  620. child: Column(
  621. crossAxisAlignment: CrossAxisAlignment.start,
  622. children: [
  623. Text('${item['title']}',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),),
  624. SizedBox(
  625. height: hsp(20),
  626. child: Row(
  627. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  628. children: [
  629. Text('${item['total']??''}',style: TextStyle(fontSize: zsp(16),color: Colors.white),),
  630. Text('${item['unit']}',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),)
  631. ],
  632. )
  633. ),
  634. ],
  635. ),
  636. );
  637. },
  638. separatorBuilder: (context,index){
  639. return Container(height: hsp(10),);
  640. },
  641. itemCount: _inputArray.length,
  642. shrinkWrap: true,
  643. physics: const NeverScrollableScrollPhysics(),
  644. padding: const EdgeInsets.all(0),
  645. ),
  646. Container(
  647. alignment: Alignment.centerLeft,
  648. height: hsp(30),
  649. child: Text('附件',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),),
  650. ),
  651. YSFileView(fileArray: _fileArray),
  652. ],
  653. ),
  654. ),
  655. ],
  656. ),
  657. ),
  658. ),
  659. )
  660. ],
  661. ),
  662. )
  663. ],
  664. ),
  665. ),
  666. );
  667. }
  668. _getSamplingFieldData() async{
  669. YSNetWork.ysRequestHttp(context, type: RequestType.get, api: '/samplingField/data', parameter: {'pointId':widget.gatherId}, successSetter: (dict){
  670. Map data = dict['data']??{};
  671. _value = '${data['value']}';
  672. _contentMap['value'] = '${data['describes']}';
  673. if(data['video']!=null)_fileArray.add({'url':data['video'],'type':2});
  674. List imageList = data['imageList']??[];
  675. for (var element in imageList) {
  676. _fileArray.add({'url':element,'type':1});
  677. }
  678. _inputArray.addAll(data['getDataVoList']??[]);
  679. if(data['location']!=null){
  680. _location = data['location'];
  681. _location['name'] = data['name'];
  682. _location['coordinates'] = data['geo'];
  683. }
  684. setState(() {});
  685. });
  686. }
  687. }
  688. //TODO:YSHomeListDetailGather4
  689. class YSHomeListDetailGather4 extends StatefulWidget {
  690. final int gatherId;
  691. const YSHomeListDetailGather4({Key? key, required this.gatherId}) : super(key: key);
  692. @override
  693. YSHomeListDetailGather4State createState() => YSHomeListDetailGather4State();
  694. }
  695. class YSHomeListDetailGather4State extends State<YSHomeListDetailGather4> {
  696. bool _isHiden = false;
  697. final Map _contentMap = {'title':'采样描述'};
  698. final List _inputArray = [];
  699. final List _fileArray = [];
  700. Container _widget = Container();
  701. Map _location = {};
  702. final TextEditingController _valueController = TextEditingController();
  703. @override
  704. void initState() {
  705. Future.delayed(const Duration(seconds: 0)).then((value) {
  706. _getSamplingFieldIndex();
  707. });
  708. super.initState();
  709. }
  710. @override
  711. void dispose() {
  712. _valueController.dispose();
  713. for (var element in _inputArray) {
  714. TextEditingController controller = element['controller'];
  715. controller.dispose();
  716. }
  717. super.dispose();
  718. }
  719. @override
  720. Widget build(BuildContext context) {
  721. // LogUtil.d(_inputArray);
  722. return YSBase(
  723. ysTitle: '采样',
  724. ysChild: SingleChildScrollView(
  725. padding: EdgeInsets.only(left: hsp(20),right: hsp(20),top: hsp(20)),
  726. child: Stack(
  727. children: [
  728. ClipRRect(
  729. borderRadius: const BorderRadius.all(Radius.circular(24)),
  730. child: Container(
  731. height: ysHeight(context)-ysTOP(context)-44-hsp(110),
  732. decoration: const BoxDecoration(
  733. color: Color(0xFF3E434E)
  734. ),
  735. child: _location.isEmpty?Container():YSMapView(location: _location,),
  736. ),
  737. ),
  738. Container(
  739. margin: EdgeInsets.only(top: hsp(140)+(_isHiden?ysHeight(context)-ysTOP(context)-44-hsp(235):hsp(10))),
  740. child: Column(
  741. children: [
  742. GestureDetector(
  743. onTap: (){
  744. _isHiden = !_isHiden;
  745. setState(() {});
  746. },
  747. behavior: HitTestBehavior.opaque,
  748. child: Container(
  749. padding: EdgeInsets.only(bottom: hsp(10)),
  750. width: ysWidth(context),
  751. child: Image.asset('images/tzh_${_isHiden?'up':'down1'}.png',height: hsp(15),width: hsp(15),),
  752. ),
  753. ),
  754. if (_isHiden) Container(
  755. height: hsp(50),
  756. decoration: const BoxDecoration(
  757. image: DecorationImage(image: AssetImage('images/tzh_hiden.png') )
  758. ),
  759. alignment: Alignment.center,
  760. padding: EdgeInsets.only(top: hsp(15)),
  761. child: Text('采样说明',style: TextStyle(fontSize: zsp(14),color: const Color(0xFFDBE1EA)),),
  762. ) else ClipRRect(
  763. borderRadius: const BorderRadius.all(Radius.circular(24)),
  764. child: SizedBox(
  765. height: ysHeight(context)-ysTOP(context)-44-hsp(205),
  766. child: Column(
  767. children: [
  768. if (_widget.child==null) Container(height: ysHeight(context)-ysTOP(context)-44-hsp(277),) else _widget,
  769. GestureDetector(
  770. behavior: HitTestBehavior.opaque,
  771. onTap: () async{
  772. FocusScope.of(context).unfocus();
  773. LogUtil.d(_inputArray);
  774. if(_contentMap['value']==null){
  775. ysFlutterToast('请填写采样描述');
  776. return;
  777. }
  778. // if(_valueController.text.isEmpty){
  779. // ysFlutterToast('请填写有机土壤碳信息');
  780. // return;
  781. // }
  782. // for (var element in _inputArray) {
  783. // if(element['value']==null){
  784. // ysFlutterToast('请完善${element['title']}');
  785. // return;
  786. // }
  787. // }
  788. List images = [];
  789. List video = [];
  790. for (var element in _fileArray) {
  791. if('${element['url']}'.contains('.mp4')==true){
  792. video.add(element['url']);
  793. }else{
  794. images.add(element['url']);
  795. }
  796. }
  797. List inputArray = [];
  798. for (Map element in _inputArray) {
  799. Map input = {};
  800. element.forEach((key, value) {
  801. if(key!='controller'){
  802. input[key] = value;
  803. }
  804. });
  805. inputArray.add(input);
  806. }
  807. Map request = {};
  808. request['id'] = widget.gatherId;
  809. request['describes'] = _contentMap['value'];
  810. request['recordList'] = inputArray;
  811. if(images.isNotEmpty)request['imageList'] = images;
  812. if(video.isNotEmpty)request['video'] = video.first;
  813. if(_valueController.text.isNotEmpty)request['value'] = _valueController.text;
  814. LogUtil.d(request);
  815. // return;
  816. YSNetWork.ysRequestHttp(context, type: RequestType.post, api: '/samplingRecord/add', parameter: request, successSetter: (dict){
  817. ysFlutterToast('新增采样成功');
  818. Navigator.of(context).pop('');
  819. },isLoading: true);
  820. },
  821. child: Image.asset('images/tzh_done.png',height: hsp(72),),
  822. )
  823. ],
  824. ),
  825. ),
  826. )
  827. ],
  828. ),
  829. )
  830. ],
  831. ),
  832. ),
  833. );
  834. }
  835. _getSamplingFieldIndex() async{
  836. YSNetWork.ysRequestHttp(context, type: RequestType.get, api: '/samplingField/index', parameter: {}, successSetter: (dict){
  837. _inputArray.clear();
  838. _inputArray.addAll(dict['data']??[]);
  839. _getSamplingFieldData();
  840. });
  841. }
  842. _getSamplingFieldData() async{
  843. YSNetWork.ysRequestHttp(context, type: RequestType.get, api: '/samplingField/data', parameter: {'pointId':widget.gatherId}, successSetter: (dict){
  844. Map data = dict['data']??{};
  845. if(data['value']!=null)_valueController.text = '${data['value']}';
  846. if(data['describes']!=null)_contentMap['value'] = '${data['describes']}';
  847. if(data['video']!=null)_fileArray.add({'url':data['video'],'type':2});
  848. List imageList = data['imageList']??[];
  849. for (var element in imageList) {
  850. _fileArray.add({'url':element,'type':1});
  851. }
  852. List getDataVoList = data['getDataVoList']??[];
  853. if(getDataVoList.isNotEmpty){
  854. _inputArray.clear();
  855. _inputArray.addAll(getDataVoList);
  856. }
  857. if(data['location']!=null){
  858. _location = data['location'];
  859. _location['name'] = data['name'];
  860. _location['coordinates'] = data['geo'];
  861. }
  862. for (var element in _inputArray) {
  863. element['controller'] =TextEditingController(text: '${element['total']??''}');
  864. }
  865. _widget = Container(
  866. color: ysBgColor,
  867. height: ysHeight(context)-ysTOP(context)-44-hsp(277),
  868. child: SingleChildScrollView(
  869. child: Column(
  870. children: [
  871. Container(
  872. width: ysWidth(context)-hsp(40),
  873. decoration: const BoxDecoration(
  874. color: Color(0xFF3E434E),
  875. borderRadius: BorderRadius.all(Radius.circular(24))
  876. ),
  877. child: Column(
  878. children: [
  879. Container(
  880. height: hsp(50),
  881. alignment: Alignment.centerLeft,
  882. padding: EdgeInsets.only(left: hsp(15),right: hsp(15)),
  883. decoration: BoxDecoration(
  884. border: Border(bottom: BorderSide(color: const Color(0x99535966),width: hsp(1)))
  885. ),
  886. child: Text('采样描述',style: TextStyle(fontSize: zsp(14),color: const Color(0xFFDBE1EA)),),
  887. ),
  888. Container(
  889. width: ysWidth(context)-hsp(40),
  890. padding: EdgeInsets.all(hsp(15)),
  891. constraints: BoxConstraints(minHeight: hsp(100)),
  892. child: YSInputView2(item: _contentMap),
  893. )
  894. ],
  895. ),
  896. ),
  897. Container(
  898. margin: EdgeInsets.only(top: hsp(15),bottom: hsp(15)),
  899. padding: EdgeInsets.all(hsp(15)),
  900. decoration: const BoxDecoration(
  901. color: Color(0xFF3E434E),
  902. borderRadius: BorderRadius.all(Radius.circular(24))
  903. ),
  904. child: Column(
  905. crossAxisAlignment: CrossAxisAlignment.start,
  906. children: [
  907. Container(
  908. decoration: BoxDecoration(
  909. color: const Color(0xFF1A1C1F),
  910. borderRadius: const BorderRadius.all(Radius.circular(3)),
  911. border: Border.all(color: const Color(0xFF3E434E),width: hsp(1))
  912. ),
  913. padding: EdgeInsets.only(left: hsp(12),right: hsp(12),top: hsp(5),bottom: hsp(5)),
  914. margin: EdgeInsets.only(bottom: hsp(10)),
  915. child: Column(
  916. crossAxisAlignment: CrossAxisAlignment.start,
  917. children: [
  918. Text('有机土壤碳',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),),
  919. SizedBox(
  920. height: hsp(20),
  921. child: CupertinoTextField(
  922. placeholder: '请描述内容',
  923. style: TextStyle(fontSize: zsp(16),color: Colors.white),
  924. padding: const EdgeInsets.all(0),
  925. placeholderStyle: TextStyle(fontSize: zsp(16),color: Colors.white),
  926. decoration: const BoxDecoration(
  927. color: Colors.transparent
  928. ),
  929. suffix: Text('kg',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),),
  930. maxLines: 100,
  931. controller: _valueController,
  932. inputFormatters: [NumberFormat()],
  933. keyboardType: const TextInputType.numberWithOptions(),
  934. )
  935. )
  936. ],
  937. ),
  938. ),
  939. ListView.separated(
  940. itemBuilder: (context,index){
  941. Map item = _inputArray[index];
  942. return Container(
  943. decoration: BoxDecoration(
  944. color: const Color(0xFF1A1C1F),
  945. borderRadius: const BorderRadius.all(Radius.circular(3)),
  946. border: Border.all(color: const Color(0xFF3E434E),width: hsp(1))
  947. ),
  948. padding: EdgeInsets.only(left: hsp(12),right: hsp(12),top: hsp(5),bottom: hsp(5)),
  949. child: Column(
  950. crossAxisAlignment: CrossAxisAlignment.start,
  951. children: [
  952. Text('${item['title']}',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),),
  953. SizedBox(
  954. height: hsp(20),
  955. child: CupertinoTextField(
  956. placeholder: '请输入${item['title']}',
  957. style: TextStyle(fontSize: zsp(16),color: Colors.white),
  958. padding: const EdgeInsets.all(0),
  959. placeholderStyle: TextStyle(fontSize: zsp(16),color: Colors.white),
  960. decoration: const BoxDecoration(
  961. color: Colors.transparent
  962. ),
  963. suffix: Text('${item['unit']}',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),),
  964. inputFormatters: [NumberFormat()],
  965. keyboardType: const TextInputType.numberWithOptions(),
  966. maxLines: 100,
  967. onChanged: (value){
  968. if(value.isEmpty){
  969. item.remove('value');
  970. }else{
  971. item['value'] = value;
  972. }
  973. },
  974. controller: item['controller'],
  975. )
  976. )
  977. ],
  978. ),
  979. );
  980. },
  981. separatorBuilder: (context,index){
  982. return Container(height: hsp(10),);
  983. },
  984. itemCount: _inputArray.length,
  985. shrinkWrap: true,
  986. physics: const NeverScrollableScrollPhysics(),
  987. padding: const EdgeInsets.all(0),
  988. ),
  989. Container(
  990. alignment: Alignment.centerLeft,
  991. height: hsp(30),
  992. child: Text('附件',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),),
  993. ),
  994. YSUploadFileView2(fileArray: _fileArray),
  995. Container(
  996. alignment: Alignment.centerLeft,
  997. height: hsp(30),
  998. child: Text('建议尺寸900*400,最多4张,单个图片不超过20M。',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),),
  999. )
  1000. ],
  1001. ),
  1002. ),
  1003. ],
  1004. ),
  1005. ),
  1006. );
  1007. setState(() {});
  1008. });
  1009. }
  1010. }
  1011. //TODO:YSHomeListDetailGather5
  1012. class YSHomeListDetailGather5 extends StatefulWidget {
  1013. final int gatherId;
  1014. const YSHomeListDetailGather5({Key? key, required this.gatherId}) : super(key: key);
  1015. @override
  1016. YSHomeListDetailGather5State createState() => YSHomeListDetailGather5State();
  1017. }
  1018. class YSHomeListDetailGather5State extends State<YSHomeListDetailGather5> {
  1019. bool _isEdit = false;
  1020. Map _location = {};
  1021. Map _data = {};
  1022. _getSamplingFieldData() async{
  1023. YSNetWork.ysRequestHttp(context, type: RequestType.get, api: '/samplingField/data', parameter: {'pointId':widget.gatherId}, successSetter: (dict){
  1024. _data = dict['data']??{};
  1025. if(_data['location']!=null){
  1026. _location = _data['location'];
  1027. _location['name'] = _data['name'];
  1028. _location['coordinates'] = _data['geo'];
  1029. }
  1030. setState(() {});
  1031. });
  1032. }
  1033. @override
  1034. void initState() {
  1035. networkDelay((){
  1036. _getSamplingFieldData();
  1037. });
  1038. super.initState();
  1039. }
  1040. @override
  1041. Widget build(BuildContext context) {
  1042. return YSBase(
  1043. ysTitle: '采样',
  1044. ysRightWidget: GestureDetector(
  1045. onTap: (){
  1046. _isEdit = !_isEdit;
  1047. setState(() {});
  1048. },
  1049. child: Text(_isEdit?'详情':'编辑',style: TextStyle(fontSize: zsp(16),color: Colors.white),),
  1050. ),
  1051. ysChild: SingleChildScrollView(
  1052. padding: EdgeInsets.only(left: hsp(20),right: hsp(20),top: hsp(20)),
  1053. child: Stack(
  1054. children: [
  1055. ClipRRect(
  1056. borderRadius: const BorderRadius.all(Radius.circular(24)),
  1057. child: Container(
  1058. height: ysHeight(context)-ysTOP(context)-44-hsp(110),
  1059. decoration: const BoxDecoration(
  1060. color: Color(0xFF3E434E)
  1061. ),
  1062. child: _location.isEmpty?Container():YSMapView(location: _location,),
  1063. ),
  1064. ),
  1065. _data.isEmpty?Container():(
  1066. _isEdit?YSHomeListDetailGatherEditView(
  1067. gatherId: widget.gatherId,data: _data,
  1068. ):YSHomeListDetailGatherDetailView(
  1069. data: _data,
  1070. )
  1071. )
  1072. ],
  1073. ),
  1074. ),
  1075. );
  1076. }
  1077. }
  1078. //TODO:YSHomeListDetailGatherEditView
  1079. class YSHomeListDetailGatherEditView extends StatefulWidget {
  1080. final int gatherId;
  1081. final Map data;
  1082. const YSHomeListDetailGatherEditView({Key? key, required this.gatherId, required this.data}) : super(key: key);
  1083. @override
  1084. YSHomeListDetailGatherEditViewState createState() => YSHomeListDetailGatherEditViewState();
  1085. }
  1086. class YSHomeListDetailGatherEditViewState extends State<YSHomeListDetailGatherEditView> {
  1087. bool _isHiden = false;
  1088. final Map _contentMap = {'title':'采样描述'};
  1089. final List _inputArray = [];
  1090. final List _fileArray = [];
  1091. Container _widget = Container();
  1092. final TextEditingController _valueController = TextEditingController();
  1093. @override
  1094. void initState() {
  1095. Future.delayed(const Duration(seconds: 0)).then((value) {
  1096. _getSamplingFieldIndex();
  1097. });
  1098. super.initState();
  1099. }
  1100. @override
  1101. void dispose() {
  1102. _valueController.dispose();
  1103. for (var element in _inputArray) {
  1104. TextEditingController controller = element['controller'];
  1105. controller.dispose();
  1106. }
  1107. super.dispose();
  1108. }
  1109. @override
  1110. Widget build(BuildContext context) {
  1111. return Container(
  1112. margin: EdgeInsets.only(top: hsp(140)+(_isHiden?ysHeight(context)-ysTOP(context)-44-hsp(235):hsp(10))),
  1113. child: Column(
  1114. children: [
  1115. GestureDetector(
  1116. onTap: (){
  1117. _isHiden = !_isHiden;
  1118. setState(() {});
  1119. },
  1120. behavior: HitTestBehavior.opaque,
  1121. child: Container(
  1122. padding: EdgeInsets.only(bottom: hsp(10)),
  1123. width: ysWidth(context),
  1124. child: Image.asset('images/tzh_${_isHiden?'up':'down1'}.png',height: hsp(15),width: hsp(15),),
  1125. ),
  1126. ),
  1127. if (_isHiden) Container(
  1128. height: hsp(50),
  1129. decoration: const BoxDecoration(
  1130. image: DecorationImage(image: AssetImage('images/tzh_hiden.png') )
  1131. ),
  1132. alignment: Alignment.center,
  1133. padding: EdgeInsets.only(top: hsp(15)),
  1134. child: Text('采样说明',style: TextStyle(fontSize: zsp(14),color: const Color(0xFFDBE1EA)),),
  1135. ) else ClipRRect(
  1136. borderRadius: const BorderRadius.all(Radius.circular(24)),
  1137. child: SizedBox(
  1138. height: ysHeight(context)-ysTOP(context)-44-hsp(205),
  1139. child: Column(
  1140. children: [
  1141. if (_widget.child==null) Container(height: ysHeight(context)-ysTOP(context)-44-hsp(277),) else _widget,
  1142. GestureDetector(
  1143. behavior: HitTestBehavior.opaque,
  1144. onTap: () async{
  1145. FocusScope.of(context).unfocus();
  1146. LogUtil.d(_inputArray);
  1147. // if(_contentMap['value']==null){
  1148. // ysFlutterToast('请填写采样描述');
  1149. // return;
  1150. // }
  1151. // if(_valueController.text.isEmpty){
  1152. // ysFlutterToast('请填写有机土壤碳信息');
  1153. // return;
  1154. // }
  1155. // for (var element in _inputArray) {
  1156. // if(element['value']==null){
  1157. // ysFlutterToast('请完善${element['title']}');
  1158. // return;
  1159. // }
  1160. // }
  1161. List images = [];
  1162. List video = [];
  1163. for (var element in _fileArray) {
  1164. if('${element['url']}'.contains('.mp4')==true){
  1165. video.add(element['url']);
  1166. }else{
  1167. images.add(element['url']);
  1168. }
  1169. }
  1170. List inputArray = [];
  1171. for (Map element in _inputArray) {
  1172. Map input = {};
  1173. element.forEach((key, value) {
  1174. if(key!='controller'){
  1175. input[key] = value;
  1176. }
  1177. });
  1178. if(element['value']==null){
  1179. input['value'] = '0';
  1180. }
  1181. inputArray.add(input);
  1182. }
  1183. Map request = {};
  1184. request['id'] = widget.gatherId;
  1185. // request['describes'] = _contentMap['value'];
  1186. request['recordList'] = inputArray;
  1187. if(images.isNotEmpty)request['imageList'] = images;
  1188. if(video.isNotEmpty)request['video'] = video.first;
  1189. if(_valueController.text.isNotEmpty)request['value'] = _valueController.text;
  1190. // LogUtil.d(request);
  1191. // return;
  1192. YSNetWork.ysRequestHttp(context, type: RequestType.post, api: '/samplingRecord/add', parameter: request, successSetter: (dict){
  1193. ysFlutterToast('新增采样成功');
  1194. Navigator.of(context).pop('');
  1195. },isLoading: true);
  1196. },
  1197. child: Image.asset('images/tzh_done.png',height: hsp(72),),
  1198. )
  1199. ],
  1200. ),
  1201. ),
  1202. )
  1203. ],
  1204. ),
  1205. );
  1206. }
  1207. _getSamplingFieldIndex() async{
  1208. YSNetWork.ysRequestHttp(context, type: RequestType.get, api: '/samplingField/index', parameter: {}, successSetter: (dict){
  1209. _inputArray.clear();
  1210. _inputArray.addAll(dict['data']??[]);
  1211. _getSamplingFieldData();
  1212. });
  1213. }
  1214. _getSamplingFieldData() async{
  1215. Map data = widget.data;
  1216. if(data['value']!=null)_valueController.text = '${data['value']}';
  1217. if(data['content']!=null)_contentMap['value'] = '${data['content']}';
  1218. _fileArray.clear();
  1219. if(data['video']!=null)_fileArray.add({'url':data['video'],'type':2});
  1220. List imageList = data['imageList']??[];
  1221. for (var element in imageList) {
  1222. _fileArray.add({'url':element,'type':1});
  1223. }
  1224. List getDataVoList = data['getDataVoList']??[];
  1225. if(getDataVoList.isNotEmpty){
  1226. _inputArray.clear();
  1227. _inputArray.addAll(getDataVoList);
  1228. }
  1229. for (var element in _inputArray) {
  1230. element['controller'] =TextEditingController(text: '${element['total']??''}');
  1231. }
  1232. _widget = Container(
  1233. color: ysBgColor,
  1234. height: ysHeight(context)-ysTOP(context)-44-hsp(277),
  1235. child: SingleChildScrollView(
  1236. child: Column(
  1237. children: [
  1238. Container(
  1239. width: ysWidth(context)-hsp(40),
  1240. decoration: const BoxDecoration(
  1241. color: Color(0xFF3E434E),
  1242. borderRadius: BorderRadius.all(Radius.circular(24))
  1243. ),
  1244. child: Column(
  1245. children: [
  1246. Container(
  1247. height: hsp(50),
  1248. alignment: Alignment.centerLeft,
  1249. padding: EdgeInsets.only(left: hsp(15),right: hsp(15)),
  1250. decoration: BoxDecoration(
  1251. border: Border(bottom: BorderSide(color: const Color(0x99535966),width: hsp(1)))
  1252. ),
  1253. child: Text('采样内容',style: TextStyle(fontSize: zsp(14),color: const Color(0xFFDBE1EA)),),
  1254. ),
  1255. Container(
  1256. width: ysWidth(context)-hsp(40),
  1257. padding: EdgeInsets.all(hsp(15)),
  1258. constraints: BoxConstraints(minHeight: hsp(100)),
  1259. // child: Text(_contentMap['value'],style: TextStyle(fontSize: zsp(14),color: ysValueColor),),
  1260. child: YSInputView2(item: _contentMap,isEnable: false,),
  1261. )
  1262. ],
  1263. ),
  1264. ),
  1265. Container(
  1266. margin: EdgeInsets.only(top: hsp(15),bottom: hsp(15)),
  1267. padding: EdgeInsets.all(hsp(15)),
  1268. decoration: const BoxDecoration(
  1269. color: Color(0xFF3E434E),
  1270. borderRadius: BorderRadius.all(Radius.circular(24))
  1271. ),
  1272. child: Column(
  1273. crossAxisAlignment: CrossAxisAlignment.start,
  1274. children: [
  1275. Container(
  1276. decoration: BoxDecoration(
  1277. color: const Color(0xFF1A1C1F),
  1278. borderRadius: const BorderRadius.all(Radius.circular(3)),
  1279. border: Border.all(color: const Color(0xFF3E434E),width: hsp(1))
  1280. ),
  1281. padding: EdgeInsets.only(left: hsp(12),right: hsp(12),top: hsp(5),bottom: hsp(5)),
  1282. margin: EdgeInsets.only(bottom: hsp(10)),
  1283. child: Column(
  1284. crossAxisAlignment: CrossAxisAlignment.start,
  1285. children: [
  1286. Text('有机土壤碳',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),),
  1287. SizedBox(
  1288. height: hsp(20),
  1289. child: CupertinoTextField(
  1290. placeholder: '请描述内容',
  1291. style: TextStyle(fontSize: zsp(16),color: Colors.white),
  1292. padding: const EdgeInsets.all(0),
  1293. placeholderStyle: TextStyle(fontSize: zsp(16),color: Colors.white),
  1294. decoration: const BoxDecoration(
  1295. color: Colors.transparent
  1296. ),
  1297. suffix: Text('kg',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),),
  1298. maxLines: 100,
  1299. controller: _valueController,
  1300. inputFormatters: [NumberFormat()],
  1301. keyboardType: const TextInputType.numberWithOptions(),
  1302. )
  1303. )
  1304. ],
  1305. ),
  1306. ),
  1307. ListView.separated(
  1308. itemBuilder: (context,index){
  1309. Map item = _inputArray[index];
  1310. return Container(
  1311. decoration: BoxDecoration(
  1312. color: const Color(0xFF1A1C1F),
  1313. borderRadius: const BorderRadius.all(Radius.circular(3)),
  1314. border: Border.all(color: const Color(0xFF3E434E),width: hsp(1))
  1315. ),
  1316. padding: EdgeInsets.only(left: hsp(12),right: hsp(12),top: hsp(5),bottom: hsp(5)),
  1317. child: Column(
  1318. crossAxisAlignment: CrossAxisAlignment.start,
  1319. children: [
  1320. Text('${item['title']}',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),),
  1321. SizedBox(
  1322. height: hsp(20),
  1323. child: CupertinoTextField(
  1324. placeholder: '请输入${item['title']}',
  1325. style: TextStyle(fontSize: zsp(16),color: Colors.white),
  1326. padding: const EdgeInsets.all(0),
  1327. placeholderStyle: TextStyle(fontSize: zsp(16),color: Colors.white),
  1328. decoration: const BoxDecoration(
  1329. color: Colors.transparent
  1330. ),
  1331. suffix: Text('${item['unit']}',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),),
  1332. inputFormatters: [NumberFormat()],
  1333. keyboardType: const TextInputType.numberWithOptions(),
  1334. maxLines: 100,
  1335. onChanged: (value){
  1336. if(value.isEmpty){
  1337. item.remove('value');
  1338. }else{
  1339. item['value'] = value;
  1340. }
  1341. },
  1342. controller: item['controller'],
  1343. )
  1344. )
  1345. ],
  1346. ),
  1347. );
  1348. },
  1349. separatorBuilder: (context,index){
  1350. return Container(height: hsp(10),);
  1351. },
  1352. itemCount: _inputArray.length,
  1353. shrinkWrap: true,
  1354. physics: const NeverScrollableScrollPhysics(),
  1355. padding: const EdgeInsets.all(0),
  1356. ),
  1357. Container(
  1358. alignment: Alignment.centerLeft,
  1359. height: hsp(30),
  1360. child: Text('附件',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),),
  1361. ),
  1362. YSUploadFileView2(fileArray: _fileArray),
  1363. Container(
  1364. alignment: Alignment.centerLeft,
  1365. height: hsp(30),
  1366. child: Text('建议尺寸900*400,最多4张,单个图片不超过20M。',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),),
  1367. )
  1368. ],
  1369. ),
  1370. ),
  1371. ],
  1372. ),
  1373. ),
  1374. );
  1375. setState(() {});
  1376. }
  1377. }
  1378. ////TODO:YSHomeListDetailGatherDetailView
  1379. class YSHomeListDetailGatherDetailView extends StatefulWidget {
  1380. final Map data;
  1381. const YSHomeListDetailGatherDetailView({Key? key, required this.data}) : super(key: key);
  1382. @override
  1383. YSHomeListDetailGatherDetailViewState createState() => YSHomeListDetailGatherDetailViewState();
  1384. }
  1385. class YSHomeListDetailGatherDetailViewState extends State<YSHomeListDetailGatherDetailView> {
  1386. bool _isHiden = true;
  1387. final Map _contentMap = {'title':'采样描述'};
  1388. final List _inputArray = [];
  1389. final List _fileArray = [];
  1390. String _value = '';
  1391. Map _location = {};
  1392. @override
  1393. void initState() {
  1394. Future.delayed(const Duration(seconds: 0)).then((value) {
  1395. _getSamplingFieldData();
  1396. });
  1397. super.initState();
  1398. }
  1399. @override
  1400. Widget build(BuildContext context) {
  1401. return Container(
  1402. margin: EdgeInsets.only(top: _isHiden?ysHeight(context)-ysTOP(context)-44-hsp(95):hsp(150),),
  1403. child: Column(
  1404. children: [
  1405. GestureDetector(
  1406. onTap: (){
  1407. _isHiden = !_isHiden;
  1408. setState(() {});
  1409. },
  1410. behavior: HitTestBehavior.opaque,
  1411. child: Container(
  1412. padding: EdgeInsets.only(bottom: hsp(10)),
  1413. width: ysWidth(context),
  1414. child: Image.asset('images/tzh_${_isHiden?'up':'down1'}.png',height: hsp(15),width: hsp(15),),
  1415. ),
  1416. ),
  1417. if (_isHiden) Container(
  1418. // margin: EdgeInsets.only(top: ysHeight(context)-ysTOP(context)-44-hsp(250)),
  1419. height: hsp(50),
  1420. decoration: const BoxDecoration(
  1421. image: DecorationImage(image: AssetImage('images/tzh_hiden.png') )
  1422. ),
  1423. alignment: Alignment.center,
  1424. padding: EdgeInsets.only(top: hsp(15)),
  1425. child: Text('采样说明',style: TextStyle(fontSize: zsp(14),color: const Color(0xFFDBE1EA)),),
  1426. ) else ClipRRect(
  1427. borderRadius: const BorderRadius.all(Radius.circular(24)),
  1428. child: Container(
  1429. color: ysBgColor,
  1430. height: ysHeight(context)-ysTOP(context)-44-hsp(215),
  1431. child: SingleChildScrollView(
  1432. child: Column(
  1433. children: [
  1434. Container(
  1435. width: ysWidth(context)-hsp(40),
  1436. decoration: const BoxDecoration(
  1437. color: Color(0xFF3E434E),
  1438. ),
  1439. child: Column(
  1440. children: [
  1441. Container(
  1442. height: hsp(50),
  1443. alignment: Alignment.centerLeft,
  1444. padding: EdgeInsets.only(left: hsp(15),right: hsp(15)),
  1445. decoration: BoxDecoration(
  1446. border: Border(bottom: BorderSide(color: const Color(0x99535966),width: hsp(1)))
  1447. ),
  1448. child: Text('采样描述',style: TextStyle(fontSize: zsp(14),color: const Color(0xFFDBE1EA)),),
  1449. ),
  1450. Container(
  1451. width: ysWidth(context)-hsp(40),
  1452. padding: EdgeInsets.all(hsp(15)),
  1453. constraints: BoxConstraints(minHeight: hsp(100)),
  1454. child: Text('${_contentMap['value']??''}',style: TextStyle(fontSize: zsp(14),color: ysValueColor),),
  1455. )
  1456. ],
  1457. ),
  1458. ),
  1459. Container(
  1460. margin: EdgeInsets.only(top: hsp(15),bottom: hsp(15)),
  1461. padding: EdgeInsets.all(hsp(15)),
  1462. decoration: const BoxDecoration(
  1463. color: Color(0xFF3E434E),
  1464. borderRadius: BorderRadius.all(Radius.circular(24))
  1465. ),
  1466. child: Column(
  1467. crossAxisAlignment: CrossAxisAlignment.start,
  1468. children: [
  1469. Container(
  1470. decoration: BoxDecoration(
  1471. color: const Color(0xFF1A1C1F),
  1472. borderRadius: const BorderRadius.all(Radius.circular(3)),
  1473. border: Border.all(color: const Color(0xFF3E434E),width: hsp(1))
  1474. ),
  1475. padding: EdgeInsets.only(left: hsp(12),right: hsp(12),top: hsp(5),bottom: hsp(5)),
  1476. margin: EdgeInsets.only(bottom: hsp(10)),
  1477. child: Column(
  1478. crossAxisAlignment: CrossAxisAlignment.start,
  1479. children: [
  1480. Text('有机土壤碳',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),),
  1481. SizedBox(
  1482. height: hsp(20),
  1483. child: Row(
  1484. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  1485. children: [
  1486. Text(_value,style: TextStyle(fontSize: zsp(16),color: Colors.white),),
  1487. Text('kg',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),)
  1488. ],
  1489. )
  1490. )
  1491. ],
  1492. ),
  1493. ),
  1494. ListView.separated(
  1495. itemBuilder: (context,index){
  1496. Map item = _inputArray[index];
  1497. return Container(
  1498. decoration: BoxDecoration(
  1499. color: const Color(0xFF1A1C1F),
  1500. borderRadius: const BorderRadius.all(Radius.circular(3)),
  1501. border: Border.all(color: const Color(0xFF3E434E),width: hsp(1))
  1502. ),
  1503. padding: EdgeInsets.only(left: hsp(12),right: hsp(12),top: hsp(5),bottom: hsp(5)),
  1504. child: Column(
  1505. crossAxisAlignment: CrossAxisAlignment.start,
  1506. children: [
  1507. Text('${item['title']}',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),),
  1508. SizedBox(
  1509. height: hsp(20),
  1510. child: Row(
  1511. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  1512. children: [
  1513. Text('${item['total']??''}',style: TextStyle(fontSize: zsp(16),color: Colors.white),),
  1514. Text('${item['unit']}',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),)
  1515. ],
  1516. )
  1517. ),
  1518. ],
  1519. ),
  1520. );
  1521. },
  1522. separatorBuilder: (context,index){
  1523. return Container(height: hsp(10),);
  1524. },
  1525. itemCount: _inputArray.length,
  1526. shrinkWrap: true,
  1527. physics: const NeverScrollableScrollPhysics(),
  1528. padding: const EdgeInsets.all(0),
  1529. ),
  1530. Container(
  1531. alignment: Alignment.centerLeft,
  1532. height: hsp(30),
  1533. child: Text('附件',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),),
  1534. ),
  1535. YSFileView(fileArray: _fileArray),
  1536. ],
  1537. ),
  1538. ),
  1539. ],
  1540. ),
  1541. ),
  1542. ),
  1543. )
  1544. ],
  1545. ),
  1546. );
  1547. }
  1548. _getSamplingFieldData() async{
  1549. Map data = widget.data;
  1550. _value = '${data['value']??''}';
  1551. _contentMap['value'] = '${data['content']}';
  1552. _fileArray.clear();
  1553. if(data['video']!=null)_fileArray.add({'url':data['video'],'type':2});
  1554. List imageList = data['imageList']??[];
  1555. for (var element in imageList) {
  1556. _fileArray.add({'url':element,'type':1});
  1557. }
  1558. _inputArray.addAll(data['getDataVoList']??[]);
  1559. if(data['location']!=null){
  1560. _location = data['location'];
  1561. _location['name'] = data['name'];
  1562. }
  1563. setState(() {});
  1564. }
  1565. }