repair_detail.dart 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. import 'package:deus_app/common/dialog/CloseTaskDialog.dart';
  2. import 'package:deus_app/common/dialog/ViewDialog.dart';
  3. import 'package:deus_app/common/event/RefreshRepairDetail.dart';
  4. import 'package:deus_app/common/event/RefreshRepairPage.dart';
  5. import 'package:deus_app/common/style/TitleBar.dart';
  6. import 'package:deus_app/common/style/gsy_style.dart';
  7. import 'package:deus_app/common/utils/ConstantString.dart';
  8. import 'package:deus_app/common/utils/DioUtil.dart';
  9. import 'package:deus_app/common/utils/ToastUtils.dart';
  10. import 'package:deus_app/generated/json/repair_detail_response_entity_helper.dart';
  11. import 'package:deus_app/main.dart';
  12. import 'package:deus_app/model/repair_detail_response_entity.dart';
  13. import 'package:deus_app/page/repair/repair_job_edit.dart';
  14. import 'package:flutter/material.dart';
  15. class RepairDetail extends StatefulWidget {
  16. var id;
  17. RepairDetail({super.key, required this.id});
  18. @override
  19. State createState() {
  20. return _RepairDetail(id);
  21. }
  22. }
  23. class _RepairDetail extends State<RepairDetail> {
  24. var id;
  25. bool type = false;
  26. RepairDetailResponseData responseData = RepairDetailResponseData();
  27. List<String> repairImgUrls = [];
  28. List<String> repairResUrls = [];
  29. String buttonText='';
  30. var _event;
  31. bool isClose=false;
  32. _RepairDetail(this.id);
  33. @override
  34. void initState() {
  35. super.initState();
  36. _load();
  37. _event = eventBus.on<RefreshRepairDetail>().listen((event) {
  38. setState(() {
  39. _load();
  40. });
  41. });
  42. }
  43. @override
  44. Widget build(BuildContext context) {
  45. return Scaffold(
  46. resizeToAvoidBottomInset: false,
  47. appBar: TitleBar().backAppbar("报修详情"),
  48. backgroundColor: const Color(0xfff2f2f2),
  49. body: Stack(
  50. children: [
  51. Container(
  52. margin: EdgeInsets.only(bottom: type ? 60 : 0),
  53. child: ListView(
  54. children: _Ws(),
  55. ),
  56. ),
  57. Visibility(
  58. visible: type,
  59. child: Positioned(
  60. left: 0,
  61. right: 0,
  62. bottom: 0,
  63. // flex: 7,
  64. child: Row(
  65. children: [
  66. Visibility(
  67. visible: isClose,
  68. child: Expanded(
  69. child: SizedBox(
  70. height: 50,
  71. child: TextButton(
  72. onPressed: () {
  73. CloseTaskDialog.showAlertDialog(context, () {
  74. closeJob();
  75. }, '确认关闭申请?');
  76. },
  77. style: ButtonStyle(
  78. backgroundColor: MaterialStateProperty.all<Color>(
  79. Colors.blue),
  80. shape: MaterialStateProperty.all(
  81. BeveledRectangleBorder(
  82. borderRadius: BorderRadius.circular(0))),
  83. foregroundColor: MaterialStateProperty.all<Color>(
  84. Colors.white),
  85. // padding: MaterialStateProperty.all(EdgeInsets.zero)
  86. ),
  87. child: const Text(ConstantString.close_job),
  88. ),
  89. ),
  90. ),
  91. ),
  92. Expanded(
  93. child: SizedBox(
  94. height: 50,
  95. child: TextButton(
  96. onPressed: () {
  97. if (type) {
  98. if('维修接单'==buttonText){
  99. CloseTaskDialog.showAlertDialog(context, () {
  100. receive();
  101. }, '确认维修接单么?');
  102. }else if('开始维修'==buttonText){
  103. CloseTaskDialog.showAlertDialog(context, () {
  104. start();
  105. }, '确认后不支持更换维修人员');
  106. }else{
  107. Navigator.push(
  108. context,
  109. MaterialPageRoute(
  110. builder: (context) =>
  111. RepairJobEdit(responseData: responseData)));
  112. }
  113. }
  114. },
  115. style: ButtonStyle(
  116. backgroundColor:
  117. MaterialStateProperty.all<Color>(Color(0xFF4875EC)),
  118. foregroundColor:
  119. MaterialStateProperty.all<Color>(Colors.white),
  120. shape: MaterialStateProperty.all(
  121. BeveledRectangleBorder(
  122. borderRadius: BorderRadius.circular(0))),
  123. // padding: MaterialStateProperty.all(EdgeInsets.zero)
  124. ),
  125. child: Text(buttonText),
  126. ),
  127. )),
  128. ],
  129. ),
  130. ))
  131. ],
  132. ),
  133. );
  134. }
  135. List<Widget> _Ws() {
  136. List<Widget> ws = [];
  137. ws.add(_patrolJobDetail(responseData));
  138. ws.add(_basicInformation());
  139. ws.add(_notes());
  140. ws.add(_img());
  141. return ws;
  142. }
  143. Widget _notes() {
  144. return Column(children: [
  145. Container(
  146. height: 50,
  147. padding: EdgeInsets.only(left: 12),
  148. alignment: Alignment.centerLeft,
  149. child: const Text(
  150. '维修结果备注:',
  151. style: TextStyle(
  152. color: Colors.black,
  153. fontSize: GSYConstant.TextSize15,
  154. ),
  155. ),
  156. ),
  157. Container(
  158. color: Colors.white,
  159. padding: EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 10),
  160. alignment: Alignment.centerLeft,
  161. child: Text(
  162. responseData.repResRemarks == null
  163. ? '无'
  164. : responseData.repResRemarks!,
  165. style: const TextStyle(
  166. color: Colors.black,
  167. fontSize: GSYConstant.TextSize15,
  168. ),
  169. ),
  170. ),
  171. ]);
  172. }
  173. Widget _img() {
  174. return Column(children: [
  175. Container(
  176. height: 50,
  177. padding: EdgeInsets.only(left: 12),
  178. alignment: Alignment.centerLeft,
  179. child: const Text(
  180. '维修图片:',
  181. style: TextStyle(
  182. color: Colors.black,
  183. fontSize: GSYConstant.TextSize15,
  184. ),
  185. ),
  186. ),
  187. Container(
  188. width: double.infinity,
  189. margin: EdgeInsets.only(bottom: 5),
  190. padding: repairResUrls.isNotEmpty?EdgeInsets.only(right: 12, top: 10):EdgeInsets.only(right: 0, top: 0),
  191. color: Colors.white,
  192. child: Wrap(
  193. children: repairResUrls.map((e) => _buildImage(e,1)).toList()),
  194. alignment: Alignment.centerLeft,
  195. )
  196. ]);
  197. }
  198. Widget _basicInformation() {
  199. return Column(children: [
  200. Container(
  201. height: 50,
  202. padding: EdgeInsets.only(left: 12),
  203. alignment: Alignment.centerLeft,
  204. child: const Text(
  205. '基本信息:',
  206. style: TextStyle(
  207. color: Colors.black,
  208. fontSize: GSYConstant.TextSize15,
  209. ),
  210. ),
  211. ),
  212. Container(
  213. color: Colors.white,
  214. padding: EdgeInsets.only(left: 12, right: 12, top: 15, bottom: 15),
  215. child: Column(
  216. crossAxisAlignment: CrossAxisAlignment.start,
  217. children: [
  218. Row(
  219. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  220. children: [
  221. const Text(
  222. '紧急程度:',
  223. style: GSYConstant.smallTextLight,
  224. ),
  225. Text(
  226. responseData.urg == 1 ? "一般" : "紧急",
  227. style: GSYConstant.smallTextLight,
  228. textAlign: TextAlign.right,
  229. ),
  230. ],
  231. ),
  232. const SizedBox(
  233. height: 12,
  234. ),
  235. Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
  236. const Text(
  237. '报修设备:',
  238. style: GSYConstant.smallTextLight,
  239. ),
  240. Text(
  241. responseData.device == null
  242. ? ''
  243. : responseData.device!.showName!,
  244. style: GSYConstant.smallTextLight,
  245. textAlign: TextAlign.right,
  246. ),
  247. ]),
  248. const SizedBox(
  249. height: 12,
  250. ),
  251. Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
  252. const Text(
  253. '报修说明:',
  254. style: GSYConstant.smallTextLight,
  255. ),
  256. Text(
  257. responseData.instructions == null
  258. ? '无'
  259. : responseData.instructions!,
  260. style: GSYConstant.smallTextLight,
  261. textAlign: TextAlign.right,
  262. ),
  263. ]),
  264. const SizedBox(
  265. height: 12,
  266. ),
  267. const Text(
  268. '图片说明:',
  269. style: GSYConstant.smallTextLight,
  270. textAlign: TextAlign.left,
  271. ),
  272. const SizedBox(
  273. height: 10,
  274. ),
  275. Container(
  276. width: double.infinity,
  277. // margin: EdgeInsets.only(bottom: 5),
  278. // padding: fileUrls.isNotEmpty?EdgeInsets.only(right: 12, top: 10):EdgeInsets.only(right: 0, top: 0),
  279. color: Colors.white,
  280. child: Wrap(
  281. children: repairImgUrls.map((e) => _buildImage(e,0)).toList()),
  282. alignment: Alignment.centerLeft,
  283. )
  284. ],
  285. ),
  286. )
  287. ]);
  288. }
  289. Widget _buildImage(String imageData,int i) {
  290. return InkWell(
  291. child: Container(
  292. margin: EdgeInsets.only(left: 12, bottom: 10),
  293. width: MediaQuery.of(context).size.width / 4,
  294. height: MediaQuery.of(context).size.width / 4,
  295. child: Image.network(
  296. imageData,
  297. fit: BoxFit.fill,
  298. )),
  299. onTap: () {
  300. Navigator.push(
  301. context,
  302. MaterialPageRoute(
  303. builder: (context) =>
  304. ViewDialog(img: imageData,imgs: i==0?repairImgUrls:repairResUrls,width: MediaQuery.of(context).size.width,)));
  305. },
  306. );
  307. }
  308. Widget _patrolJobDetail(RepairDetailResponseData patrolJobDetailData) {
  309. return Column(
  310. children: [
  311. Row(
  312. children: [
  313. Container(
  314. margin: EdgeInsets.only(top: 10, left: 12),
  315. // padding: EdgeInsets.fromLTRB(12, 0, 0, 0),
  316. alignment: Alignment.bottomLeft,
  317. child: Text(
  318. patrolJobDetailData.theme == null
  319. ? '暂无'
  320. : patrolJobDetailData.theme!,
  321. style: TextStyle(
  322. fontSize: GSYConstant.middleTextWhiteSize,
  323. fontWeight: FontWeight.bold),
  324. ),
  325. ),
  326. Container(
  327. margin: const EdgeInsets.only(top: 10, left: 10),
  328. padding: const EdgeInsets.fromLTRB(3, 2, 3, 2),
  329. alignment: Alignment.centerLeft,
  330. decoration: BoxDecoration(
  331. border: Border.all(
  332. color: patrolJobDetailData.status == 1 ||
  333. patrolJobDetailData.status == 2
  334. ? Colors.red
  335. : patrolJobDetailData.status == 3
  336. ? Colors.orange
  337. : patrolJobDetailData.status == 4 ||
  338. patrolJobDetailData.status == 5
  339. ? Colors.blue
  340. : Colors.black, //边框颜色
  341. width: 1.0, //边框粗细
  342. ),
  343. borderRadius:
  344. const BorderRadius.all(const Radius.circular(3.0)), //边框的弧度
  345. ),
  346. child: Text(
  347. patrolJobDetailData.status == 1
  348. ? '待接单'
  349. : patrolJobDetailData.status == 2
  350. ? '待执行'
  351. : patrolJobDetailData.status == 3
  352. ? '维修中'
  353. : patrolJobDetailData.status == 4
  354. ? '已关闭'
  355. : patrolJobDetailData.status == 5
  356. ? '已完成'
  357. : '未知',
  358. style: TextStyle(
  359. fontSize: GSYConstant.minTextSize,
  360. color: patrolJobDetailData.status == 1 ||
  361. patrolJobDetailData.status == 2
  362. ? Colors.red
  363. : patrolJobDetailData.status == 3
  364. ? Colors.orange
  365. : patrolJobDetailData.status == 4 ||
  366. patrolJobDetailData.status == 5
  367. ? Colors.blue
  368. : Colors.black, //边框颜色
  369. ),
  370. ),
  371. )
  372. ],
  373. ),
  374. Container(
  375. margin: const EdgeInsets.only(top: 10, left: 12, bottom: 12),
  376. alignment: Alignment.centerLeft,
  377. child: Text(
  378. '报修单号: ' + patrolJobDetailData.repNum,
  379. style: TextStyle(
  380. fontSize: GSYConstant.smallTextSize,
  381. ),
  382. ),
  383. ),
  384. // Divider(
  385. // height: 0.8,
  386. // indent: 5.0,
  387. // endIndent: 5.0,
  388. // color: Colors.grey,
  389. // ),
  390. Container(
  391. decoration: BoxDecoration(color: Colors.white),
  392. child: Column(
  393. children: [
  394. Container(
  395. padding: EdgeInsets.fromLTRB(12, 15, 12, 0),
  396. alignment: Alignment.centerLeft,
  397. child: Row(
  398. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  399. children: [
  400. new Text(
  401. '申请人:',
  402. style: GSYConstant.smallTextLight,
  403. ),
  404. Container(
  405. child: Text(
  406. patrolJobDetailData.applicant,
  407. style: GSYConstant.smallTextLight,
  408. textAlign: TextAlign.right,
  409. ),
  410. ),
  411. ],
  412. ),
  413. ),
  414. Container(
  415. padding: EdgeInsets.fromLTRB(12, 12, 12, 0),
  416. child: Row(
  417. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  418. children: [
  419. new Text(
  420. '申请时间:',
  421. style: GSYConstant.smallTextLight,
  422. ),
  423. Container(
  424. child: Text(
  425. patrolJobDetailData.applicationTime,
  426. style: GSYConstant.smallTextLight,
  427. textAlign: TextAlign.right,
  428. ),
  429. ),
  430. ],
  431. ),
  432. ),
  433. Container(
  434. padding: EdgeInsets.fromLTRB(12, 12, 12, 0),
  435. child: Row(
  436. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  437. children: [
  438. new Text(
  439. '维修人员:',
  440. style: GSYConstant.smallTextLight,
  441. ),
  442. Container(
  443. child: Text(
  444. patrolJobDetailData.maintainer,
  445. style: GSYConstant.smallTextLight,
  446. textAlign: TextAlign.right,
  447. ),
  448. ),
  449. ])),
  450. Container(
  451. padding: EdgeInsets.fromLTRB(12, 12, 12, 0),
  452. child: Row(
  453. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  454. children: [
  455. new Text(
  456. '接单时间:',
  457. style: GSYConstant.smallTextLight,
  458. ),
  459. Container(
  460. child: Text(
  461. patrolJobDetailData.orderRecTime,
  462. style: GSYConstant.smallTextLight,
  463. textAlign: TextAlign.right,
  464. ),
  465. ),
  466. ])),
  467. Container(
  468. padding: EdgeInsets.fromLTRB(12, 12, 12, 15),
  469. child: Row(
  470. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  471. children: [
  472. const Text(
  473. '完成时间:',
  474. style: GSYConstant.smallTextLight,
  475. ),
  476. Text(
  477. patrolJobDetailData.completeTime,
  478. style: GSYConstant.smallTextLight,
  479. textAlign: TextAlign.right,
  480. ),
  481. ])),
  482. ],
  483. ),
  484. ),
  485. ],
  486. );
  487. }
  488. _load() async {
  489. var result = await DioUtil().request('repair-bill/app-detail',
  490. method: DioMethod.post, data: {'id': id});
  491. RepairDetailResponseEntity patrolJobResponse =
  492. repairDetailResponseEntityFromJson(
  493. RepairDetailResponseEntity(), result);
  494. if (patrolJobResponse.code == 0) {
  495. setState(() {
  496. responseData = patrolJobResponse.data;
  497. repairImgUrls.clear();
  498. repairImgUrls.addAll(responseData.repairImgUrls);
  499. repairResUrls.clear();
  500. repairResUrls.addAll(responseData.repairResUrls);
  501. if (responseData.status == 1 || responseData.status == 2|| responseData.status == 3) {
  502. type = true;
  503. if(responseData.status == 1){
  504. isClose=true;
  505. buttonText='维修接单';
  506. }else if(responseData.status==2){
  507. isClose=false;
  508. buttonText='开始维修';
  509. }else if(responseData.status==3){
  510. buttonText='登记维修';
  511. }
  512. }else{
  513. type = false;
  514. }
  515. });
  516. } else {
  517. showToast(patrolJobResponse.msg);
  518. }
  519. }
  520. @override
  521. void dispose() {
  522. super.dispose();
  523. _event.cancel();
  524. }
  525. closeJob() async {
  526. var result = await DioUtil().request('repair-bill/close',
  527. method: DioMethod.get, params: {'id': id});
  528. if (0 == result['code']) {
  529. setState(() {
  530. eventBus.fire(RefreshRepairPage());
  531. Navigator.pop(context);
  532. });
  533. } else {
  534. showToast(result['msg']);
  535. }
  536. }
  537. receive() async {
  538. var result = await DioUtil().request('repair-bill/receive',
  539. method: DioMethod.post, data: {'id': id});
  540. if (0 == result['code']) {
  541. setState(() {
  542. _load();
  543. });
  544. } else {
  545. showToast(result['msg']);
  546. }
  547. }
  548. start() async {
  549. var result = await DioUtil().request('repair-bill/start',
  550. method: DioMethod.post, data: {'id': id});
  551. if (0 == result['code']) {
  552. setState(() {
  553. _load();
  554. });
  555. } else {
  556. showToast(result['msg']);
  557. }
  558. }
  559. }