record_registration.dart 18 KB

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