record_registration.dart 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. import 'dart:convert';
  2. import 'dart:io';
  3. import 'dart:typed_data';
  4. import 'package:eitc_erm_app/select_patient.dart';
  5. import 'package:eitc_erm_app/utils/Component.dart';
  6. import 'package:eitc_erm_app/utils/Constants.dart';
  7. import 'package:eitc_erm_app/widget/loading.dart';
  8. import 'package:flutter/material.dart';
  9. import 'package:flutter/services.dart';
  10. import 'package:http/http.dart' as http;
  11. import 'bean/appointment_list.dart';
  12. void main() {
  13. WidgetsFlutterBinding.ensureInitialized();
  14. runApp(RecordRegistration());
  15. }
  16. class RecordRegistration extends StatefulWidget {
  17. @override
  18. State<StatefulWidget> createState() => RecordRegistrationState();
  19. }
  20. class RecordRegistrationState extends State<RecordRegistration> {
  21. ValueNotifier<dynamic> result = ValueNotifier(null);
  22. late Future<AppointmentList?> _future;
  23. String appointmentStatusStr =
  24. 'appointmentStatusArray[0]=1&appointmentStatusArray[1]=3&appointmentStatusArray[2]=4&appointmentStatusArray[3]=5&appointmentStatusArray[4]=6&appointmentStatusArray[5]=8';
  25. @override
  26. void initState() {
  27. super.initState();
  28. print("Global.selectPatient " + Global.selectPatient.toString());
  29. if (Global.selectPatient == -1) {
  30. Component.toast("请先添加或选择患者!", 2);
  31. Navigator.of(context).pop();
  32. return;
  33. }
  34. _future = fetchData();
  35. }
  36. Future<AppointmentList?> fetchData() async {
  37. print(Global.token);
  38. final response = await http.get(
  39. Uri.parse(
  40. '${Global.BaseUrl}patient-appointment/list?appointmentPersonId=${Global.appointmentPersonId}&${appointmentStatusStr}'),
  41. headers: {
  42. HttpHeaders.contentTypeHeader: "application/json; charset=utf-8",
  43. 'token': '${Global.token}',
  44. });
  45. print(
  46. '${Global.BaseUrl}patient-appointment/list?appointmentPersonId=${Global.appointmentPersonId}&${appointmentStatusStr}');
  47. if (response.statusCode == 200) {
  48. final jsonString = utf8.decode(response.bodyBytes);
  49. final jsonResponse = jsonDecode(jsonString);
  50. print(jsonResponse);
  51. AppointmentList mAppointmentList =
  52. new AppointmentList.fromJson(jsonResponse);
  53. if (mAppointmentList.code == Global.responseSuccessCode) {
  54. } else {
  55. Component.toast(mAppointmentList.msg.toString(), 0);
  56. return null;
  57. }
  58. return mAppointmentList;
  59. } else {
  60. Component.toast("出错了,请稍后再试!", 0);
  61. return null;
  62. }
  63. }
  64. @override
  65. Widget build(BuildContext context) {
  66. return MaterialApp(
  67. home: Scaffold(
  68. appBar: new AppBar(
  69. title: new Text('预约挂号记录',
  70. style: TextStyle(
  71. color: Colors.white,
  72. )),
  73. centerTitle: true,
  74. elevation: 0.5,
  75. backgroundColor: Global.StatusBarColor,
  76. leading: new IconButton(
  77. tooltip: '返回上一页',
  78. icon: const Icon(
  79. Icons.arrow_back_ios,
  80. color: Colors.white,
  81. ),
  82. onPressed: () {
  83. Navigator.of(context).pop();
  84. //_nextPage(-1);
  85. },
  86. ),
  87. ),
  88. body: Center(
  89. child: Column(children: <Widget>[
  90. Container(
  91. decoration: BoxDecoration(
  92. color: Global.StatusBarColor,
  93. ),
  94. child: Padding(
  95. padding: const EdgeInsets.all(20),
  96. child: Row(
  97. crossAxisAlignment: CrossAxisAlignment.center,
  98. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  99. children: [
  100. Column(
  101. crossAxisAlignment: CrossAxisAlignment.start,
  102. mainAxisSize: MainAxisSize.max,
  103. children: <Widget>[
  104. Row(
  105. mainAxisAlignment:
  106. MainAxisAlignment.spaceEvenly,
  107. children: [
  108. Text(
  109. Global.patient.data == null
  110. ? ""
  111. : Global
  112. .patient
  113. .data![Global.selectPatient]
  114. .patientName
  115. .toString(),
  116. style: const TextStyle(
  117. fontSize: 20, color: Colors.white),
  118. ),
  119. SizedBox(
  120. width: 20,
  121. ),
  122. Text(
  123. Global.patient.data == null
  124. ? ""
  125. : Global
  126. .patient
  127. .data![Global.selectPatient]
  128. .userRelationship
  129. .toString(),
  130. style: const TextStyle(
  131. backgroundColor: Colors.cyan,
  132. fontSize: 14,
  133. color: Colors.white),
  134. ),
  135. ]),
  136. Text(
  137. Global.patient.data == null
  138. ? ""
  139. : Global.patient.data![Global.selectPatient]
  140. .identificationCard
  141. .toString()
  142. .replaceRange(
  143. 6,
  144. Global
  145. .patient
  146. .data![Global.selectPatient]
  147. .identificationCard
  148. .toString()
  149. .length -
  150. 2,
  151. '******'),
  152. style: const TextStyle(
  153. fontSize: 15, color: Colors.black38),
  154. ),
  155. ]),
  156. GestureDetector(
  157. child: Column(children: <Widget>[
  158. Icon(
  159. Icons.cached_outlined,
  160. color: Colors.yellowAccent,
  161. ),
  162. Text(
  163. '切换就诊人',
  164. style: const TextStyle(
  165. fontSize: 14, color: Colors.yellowAccent),
  166. ),
  167. ]),
  168. onTap: () async {
  169. await Navigator.push(
  170. context,
  171. MaterialPageRoute(
  172. builder: (context) =>
  173. SelectPatient("fromRecordRegistration")),
  174. );
  175. setState(() {
  176. _future = fetchData();
  177. });
  178. }),
  179. ]),
  180. ),
  181. ),
  182. DefaultTabController(
  183. initialIndex: 0,
  184. length: 4,
  185. child: TabBar(
  186. tabs: <Widget>[
  187. Tab(
  188. text: "全部",
  189. ),
  190. Tab(
  191. text: "已预约",
  192. ),
  193. Tab(
  194. text: "治疗完成",
  195. ),
  196. Tab(
  197. text: "已取消",
  198. ),
  199. ],
  200. enableFeedback: true,
  201. onTap: (index) {
  202. switch (index) {
  203. case 0:
  204. appointmentStatusStr =
  205. 'appointmentStatusArray[0]=1&appointmentStatusArray[1]=3&appointmentStatusArray[2]=4&appointmentStatusArray[3]=5&appointmentStatusArray[4]=6&appointmentStatusArray[5]=8';
  206. break;
  207. case 1:
  208. appointmentStatusStr =
  209. 'appointmentStatusArray[0]=0&appointmentStatusArray[1]=1';
  210. break;
  211. case 2:
  212. appointmentStatusStr =
  213. 'appointmentStatusArray[0]=0&appointmentStatusArray[1]=5';
  214. break;
  215. case 3:
  216. appointmentStatusStr =
  217. 'appointmentStatusArray[0]=0&appointmentStatusArray[1]=8';
  218. break;
  219. }
  220. setState(() {
  221. _future = fetchData();
  222. });
  223. },
  224. ),
  225. ),
  226. Expanded(
  227. child: FutureBuilder<AppointmentList?>(
  228. future: _future,
  229. builder: (context, snapshot) {
  230. if (snapshot.hasData) {
  231. AppointmentList? data = snapshot.data;
  232. return ListView.builder(
  233. itemCount: data?.data?.length,
  234. itemBuilder: (context, index) {
  235. return ListTile(
  236. title: Container(
  237. width: double.infinity,
  238. child: Column(
  239. mainAxisAlignment: MainAxisAlignment.center,
  240. mainAxisSize: MainAxisSize.max,
  241. children: [
  242. Padding(
  243. padding: EdgeInsets.all(10),
  244. child: Row(
  245. mainAxisAlignment:
  246. MainAxisAlignment.spaceBetween,
  247. children: [
  248. Row(children: [
  249. Text(
  250. data!.data![index].department == null ? "" : data!.data![index].department
  251. .toString(),
  252. style:
  253. const TextStyle(fontSize: 18),
  254. ),
  255. SizedBox(
  256. width: 5,
  257. ),
  258. Text(
  259. data!.data![index].attendingDoctor
  260. .toString(),
  261. style: const TextStyle(
  262. fontSize: 15,
  263. color: Colors.green),
  264. ),
  265. ]),
  266. GetAppointmentStatus(data!
  267. .data![index].appointmentStatus),
  268. ]),
  269. ),
  270. Padding(
  271. padding: EdgeInsets.all(10),
  272. child: Row(
  273. mainAxisAlignment:
  274. MainAxisAlignment.spaceBetween,
  275. children: [
  276. Text(
  277. '就诊科室',
  278. style: TextStyle(
  279. fontSize: 15,
  280. color: Colors.grey),
  281. ),
  282. Text(
  283. data!.data![index].department == null ? "" : data!.data![index].department
  284. .toString(),
  285. style: TextStyle(fontSize: 15),
  286. ),
  287. ]),
  288. ),
  289. Padding(
  290. padding: EdgeInsets.all(10),
  291. child: Row(
  292. mainAxisAlignment:
  293. MainAxisAlignment.spaceBetween,
  294. children: [
  295. Text(
  296. '就诊人',
  297. style: TextStyle(
  298. fontSize: 15,
  299. color: Colors.grey),
  300. ),
  301. Text(
  302. data!.data![index].patientName
  303. .toString(),
  304. style: TextStyle(fontSize: 15),
  305. ),
  306. ]),
  307. ),
  308. Padding(
  309. padding: EdgeInsets.all(10),
  310. child: Row(
  311. mainAxisAlignment:
  312. MainAxisAlignment.spaceBetween,
  313. children: [
  314. Text(
  315. '就诊时间',
  316. style: TextStyle(
  317. fontSize: 15,
  318. color: Colors.grey),
  319. ),
  320. Text(
  321. data!.data![index]
  322. .appointmentStartTime
  323. .toString(),
  324. style: TextStyle(fontSize: 15),
  325. ),
  326. ]),
  327. ),
  328. ]),
  329. ),
  330. subtitle: Padding(
  331. padding: const EdgeInsets.fromLTRB(10, 0, 10, 10),
  332. child: Container(
  333. width: double.infinity,
  334. height: 1.0,
  335. padding: const EdgeInsets.all(50),
  336. decoration: BoxDecoration(
  337. gradient: LinearGradient(
  338. colors: [Colors.black, Colors.white],
  339. begin: Alignment.center,
  340. end: Alignment.centerRight,
  341. tileMode: TileMode.mirror,
  342. ),
  343. ),
  344. child: Image(
  345. image: AssetImage('assets/images/line.png'),
  346. fit: BoxFit.fitWidth),
  347. ),
  348. ),
  349. onTap: () {
  350. // Navigator.push(
  351. // context,
  352. // MaterialPageRoute(builder: (context) => NfcDetail()),
  353. // );
  354. },
  355. );
  356. },
  357. );
  358. } else if (snapshot.hasError) {
  359. return Text('Error: ${snapshot.error}');
  360. }
  361. return ColorLoader();
  362. },
  363. ),
  364. ),
  365. ]),
  366. ),
  367. ),
  368. );
  369. }
  370. }
  371. class GetAppointmentStatus extends StatelessWidget {
  372. int mStatus = 0;
  373. GetAppointmentStatus(status) {
  374. mStatus = status;
  375. }
  376. @override
  377. Widget build(BuildContext context) {
  378. // 1预约,2已确定,3已到店,4治疗中,5治疗完成,6已结账,7已离开,8已失约
  379. switch (mStatus) {
  380. case 1:
  381. return Text(
  382. '已预约',
  383. style: const TextStyle(fontSize: 15, color: Colors.blue),
  384. );
  385. break;
  386. case 2:
  387. return Text(
  388. '已确定',
  389. style: const TextStyle(fontSize: 15, color: Colors.blue),
  390. );
  391. break;
  392. case 3:
  393. return Text(
  394. '已到店',
  395. style: const TextStyle(fontSize: 15, color: Colors.blue),
  396. );
  397. break;
  398. case 4:
  399. return Text(
  400. '治疗中',
  401. style: const TextStyle(fontSize: 15, color: Colors.blue),
  402. );
  403. break;
  404. case 5:
  405. return Text(
  406. '治疗完成',
  407. style: const TextStyle(fontSize: 15, color: Colors.blue),
  408. );
  409. break;
  410. case 6:
  411. return Text(
  412. '已结账',
  413. style: const TextStyle(fontSize: 15, color: Colors.blue),
  414. );
  415. break;
  416. case 7:
  417. return Text(
  418. '已离开',
  419. style: const TextStyle(fontSize: 15, color: Colors.blue),
  420. );
  421. break;
  422. case 8:
  423. return Text(
  424. '已失约',
  425. style: const TextStyle(fontSize: 15, color: Colors.blue),
  426. );
  427. break;
  428. }
  429. return Text(
  430. '未知',
  431. style: const TextStyle(fontSize: 15, color: Colors.blue),
  432. );
  433. ;
  434. }
  435. }
  436. class _IdCardInputFormatter extends TextInputFormatter {
  437. @override
  438. TextEditingValue formatEditUpdate(
  439. TextEditingValue oldValue, TextEditingValue newValue) {
  440. // 只保留前6位和后2位,中间用星号(*)替换
  441. String newText =
  442. newValue.text.replaceRange(6, newValue.text.length - 2, '******');
  443. return new TextEditingValue(
  444. text: newText,
  445. selection: new TextSelection.collapsed(offset: newText.length),
  446. );
  447. }
  448. }