ApprovalConsultationScreen.dart 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. import 'package:flutter/material.dart';
  2. import 'package:get_it/get_it.dart';
  3. import 'package:ustest/Services/ConsultationService.dart';
  4. import 'package:ustest/Services/UserService.dart';
  5. import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
  6. import 'package:autocomplete_textfield/autocomplete_textfield.dart';
  7. import 'ConsultationList.dart';
  8. class CustomPicker extends CommonPickerModel {
  9. String digits(int value, int length) {
  10. return '$value'.padLeft(length, "0");
  11. }
  12. CustomPicker({DateTime? currentTime, LocaleType? locale})
  13. : super(locale: locale) {
  14. this.currentTime = currentTime ?? DateTime.now();
  15. this.setLeftIndex(this.currentTime.hour);
  16. this.setMiddleIndex(this.currentTime.minute);
  17. this.setRightIndex(this.currentTime.second);
  18. }
  19. @override
  20. String? leftStringAtIndex(int index) {
  21. if (index >= 0 && index < 24) {
  22. return this.digits(index, 2);
  23. } else {
  24. return null;
  25. }
  26. }
  27. @override
  28. String? middleStringAtIndex(int index) {
  29. if (index >= 0 && index < 60) {
  30. return this.digits(index, 2);
  31. } else {
  32. return null;
  33. }
  34. }
  35. @override
  36. String? rightStringAtIndex(int index) {
  37. if (index >= 0 && index < 60) {
  38. return this.digits(index, 2);
  39. } else {
  40. return null;
  41. }
  42. }
  43. @override
  44. String leftDivider() {
  45. return "|";
  46. }
  47. @override
  48. String rightDivider() {
  49. return "|";
  50. }
  51. @override
  52. List<int> layoutProportions() {
  53. return [1, 2, 1];
  54. }
  55. @override
  56. DateTime finalTime() {
  57. return currentTime.isUtc
  58. ? DateTime.utc(
  59. currentTime.year,
  60. currentTime.month,
  61. currentTime.day,
  62. this.currentLeftIndex(),
  63. this.currentMiddleIndex(),
  64. this.currentRightIndex())
  65. : DateTime(
  66. currentTime.year,
  67. currentTime.month,
  68. currentTime.day,
  69. this.currentLeftIndex(),
  70. this.currentMiddleIndex(),
  71. this.currentRightIndex());
  72. }
  73. }
  74. Consultation consultationModel=new Consultation(consultationStatus: 0, id: '', patientName: '', applyUserCode: '', expertUserCode: '');
  75. class ApprovalConsultationScreen extends StatelessWidget {
  76. final Consultation model;
  77. ApprovalConsultationScreen({required this.model})
  78. {
  79. consultationModel = model;
  80. }
  81. @override
  82. Widget build(BuildContext context) {
  83. return Scaffold(
  84. backgroundColor: Colors.grey[200],
  85. body: const Center(
  86. child: SizedBox(
  87. width: 400,
  88. child: Card(
  89. child: ApprovalConsultationForm(),
  90. ),
  91. ),
  92. ),
  93. );
  94. }
  95. }
  96. class ApprovalConsultationForm extends StatefulWidget {
  97. const ApprovalConsultationForm();
  98. @override
  99. _ApprovalConsultationFormState createState() => _ApprovalConsultationFormState();
  100. }
  101. class _ApprovalConsultationFormState extends State<ApprovalConsultationForm> {
  102. final patientCodeController = TextEditingController();
  103. List<Expert> selectedUsers = <Expert>[];
  104. DateTime time = DateTime.now();
  105. GlobalKey<AutoCompleteTextFieldState<Expert>> exportKey =
  106. GlobalKey<AutoCompleteTextFieldState<Expert>>();
  107. double _formProgress = 0;
  108. _ApprovalConsultationFormState() {
  109. }
  110. @override
  111. Widget build(BuildContext context) {
  112. return Form(
  113. child: FutureBuilder<AppConsultationDataModel>(
  114. future: lodaDataAsync(),
  115. builder: (context, snapshot) {
  116. if (snapshot.hasError) {
  117. return const Center(
  118. child: Text('An error has occurred!'),
  119. );
  120. } else if (snapshot.hasData) {
  121. return Column(
  122. mainAxisSize: MainAxisSize.min,
  123. children: [
  124. LinearProgressIndicator(value: _formProgress),
  125. Text('Approval', style: Theme.of(context).textTheme.headline4),
  126. Padding(
  127. padding: const EdgeInsets.all(24.0),
  128. child: Row(
  129. children: [
  130. Expanded(
  131. child: Text(time.toString()),
  132. ),
  133. TextButton(
  134. onPressed: () {
  135. DatePicker.showDatePicker(context,
  136. showTitleActions: true,
  137. minTime: DateTime(2022, 3, 5),
  138. maxTime: DateTime(2024, 6, 7),
  139. theme: DatePickerTheme(
  140. headerColor: Colors.orange,
  141. backgroundColor: Colors.blue,
  142. itemStyle: TextStyle(
  143. color: Colors.white,
  144. fontWeight: FontWeight.bold,
  145. fontSize: 18),
  146. doneStyle: TextStyle(
  147. color: Colors.white,
  148. fontSize: 16)), onChanged: (date) {
  149. print('change $date in time zone ' +
  150. date.timeZoneOffset.inHours.toString());
  151. }, onConfirm: (date) {
  152. print('confirm $date');
  153. setState(() {
  154. this.time = date;
  155. });
  156. },
  157. currentTime: DateTime.now(),
  158. locale: LocaleType.en);
  159. },
  160. child: Text(
  161. 'date',
  162. style: TextStyle(color: Colors.blue),
  163. )),
  164. TextButton(
  165. onPressed: () {
  166. DatePicker.showTimePicker(context,
  167. showTitleActions: true, onChanged: (date) {
  168. print('change $date in time zone ' +
  169. date.timeZoneOffset.inHours.toString());
  170. }, onConfirm: (date) {
  171. print('confirm $date');
  172. setState(() {
  173. this.time = date;
  174. });
  175. }, currentTime: DateTime.now());
  176. },
  177. child: Text(
  178. 'time',
  179. style: TextStyle(color: Colors.blue),
  180. )),
  181. ],
  182. ),
  183. ),
  184. Padding(
  185. padding: const EdgeInsets.all(24.0),
  186. child: DropdownButtonFormField<Expert>(
  187. decoration: InputDecoration(
  188. hintText: "Select some users",
  189. suffixIcon: Icon(Icons.search)),
  190. onChanged: (item) {
  191. setState(() => setSelectUsers(item) );
  192. },
  193. key: exportKey,
  194. items: snapshot.data!.users
  195. .map((e) => DropdownMenuItem<Expert>(
  196. child: Text(e.userName),
  197. value: e,
  198. ))
  199. .toList(),
  200. )),
  201. Padding(
  202. padding: EdgeInsets.all(8.0),
  203. child: Row(
  204. children: [
  205. Text(getSelectUsers()),
  206. ],
  207. ),
  208. ),
  209. Padding(
  210. padding: const EdgeInsets.all(8.0),
  211. child: Row(
  212. mainAxisAlignment: MainAxisAlignment.center,
  213. children: [
  214. TextButton(
  215. style: ButtonStyle(
  216. foregroundColor:
  217. MaterialStateProperty.resolveWith(
  218. (Set<MaterialState> states) {
  219. return states.contains(MaterialState.disabled)
  220. ? null
  221. : Colors.white;
  222. }),
  223. backgroundColor:
  224. MaterialStateProperty.resolveWith(
  225. (Set<MaterialState> states) {
  226. return states.contains(MaterialState.disabled)
  227. ? null
  228. : Colors.blue;
  229. }),
  230. ),
  231. onPressed: onSubmit,
  232. child: const Text('Submit'),
  233. ),
  234. Padding(
  235. padding: const EdgeInsets.all(8.0),
  236. child: TextButton(
  237. style: ButtonStyle(
  238. foregroundColor:
  239. MaterialStateProperty.resolveWith(
  240. (Set<MaterialState> states) {
  241. return states.contains(MaterialState.disabled)
  242. ? null
  243. : Colors.white;
  244. }),
  245. backgroundColor:
  246. MaterialStateProperty.resolveWith(
  247. (Set<MaterialState> states) {
  248. return states.contains(MaterialState.disabled)
  249. ? null
  250. : Colors.blue;
  251. }),
  252. ),
  253. onPressed: () => {Navigator.of(context).pop()},
  254. child: const Text('Cancel'),
  255. ),
  256. ),
  257. ],
  258. )),
  259. ],
  260. );
  261. } else {
  262. return const Center(
  263. child: CircularProgressIndicator(),
  264. );
  265. }
  266. }),
  267. );
  268. }
  269. void setSelectUsers(Expert? user)
  270. {
  271. if(!this.selectedUsers.contains(user))
  272. {
  273. this.selectedUsers.add(user!);
  274. }
  275. }
  276. String getSelectUsers()
  277. {
  278. var str = "";
  279. this.selectedUsers.forEach((element) {
  280. str+=element.userName+" ";
  281. });
  282. return str;
  283. }
  284. void onSubmit() async {
  285. try {
  286. var userCodes =<String>[];
  287. selectedUsers.forEach((element) {
  288. userCodes.add(element.code);
  289. });
  290. ApprovalConsultationRequest _model = new ApprovalConsultationRequest(
  291. consultationModel.id,consultationModel.expertUserCode,this.time,userCodes,"");
  292. print(_model.toString());
  293. var service = GetIt.instance.get<ConsultationService>();
  294. var result = await service.ApprovalConsultationAsync(
  295. _model);
  296. if (result) {
  297. Navigator.of(context).pushNamed('/');
  298. }
  299. } catch (e) {
  300. print('signInAsync ex: $e');
  301. }
  302. }
  303. Future<AppConsultationDataModel> lodaDataAsync() async {
  304. try {
  305. var service = GetIt.instance.get<ConsultationService>();
  306. var model = await service.LoadDataAsync();
  307. return model;
  308. } catch (ex) {
  309. print('lodaDataAsync ex' + ex.toString());
  310. return Future.error(ex);
  311. }
  312. }
  313. }
  314. class ExportInfo {
  315. final String id;
  316. final String name;
  317. ExportInfo({required this.id, required this.name});
  318. factory ExportInfo.fromJson(Map<String, dynamic> json) {
  319. var item = ExportInfo(
  320. id: json['id'] as String,
  321. name: json['name'] as String,
  322. );
  323. return item;
  324. }
  325. Map<String, dynamic> toMap() {
  326. return {
  327. 'id': id,
  328. 'name': name,
  329. };
  330. }
  331. @override
  332. String toString() {
  333. return 'ExportInfo{id: $id}, {name: $name}';
  334. }
  335. }
  336. enum NotificationTypeEnum {
  337. Daiding,
  338. /// <summary>
  339. /// ChatMsgNotification|1| 聊天通知
  340. /// </summary>
  341. ChatMsgNotification,
  342. /// <summary>
  343. /// UpgradeVersionNotification|2| 版本更新通知
  344. /// </summary>
  345. UpgradeVersionNotification,
  346. /// <summary>
  347. /// LogoffNotification|3| 登出通知
  348. /// </summary>
  349. LogoffNotification,
  350. /// <summary>
  351. /// DisconnectNotification| 4|与服务器断开连接通知
  352. /// </summary>
  353. DisconnectNotification,
  354. /// <summary>
  355. /// ConnectionNotification| 5| 与服务器已连接通知
  356. /// </summary>
  357. ConnectionNotification,
  358. /// <summary>
  359. ///FinishNotifyRecordsMessage| 6 | 检查记录完成消息类型
  360. /// </summary>
  361. FinishNotifyRecordsMessage,
  362. /// <summary>
  363. ///InvitedEnterRoomNotification| 7 | 邀请用户加入房间通知
  364. /// </summary>
  365. InvitedEnterRoomNotification,
  366. /// <summary>
  367. ///CancelInvitedEnterRoomNotification| 8 |取消邀请用户通知
  368. /// </summary>
  369. CancelInvitedEnterRoomNotification,
  370. placeholder9,
  371. placeholder10,
  372. placeholder11,
  373. placeholder12,
  374. placeholder13,
  375. placeholder14,
  376. placeholder15,
  377. placeholder16,
  378. placeholder17,
  379. placeholder18,
  380. placeholder19,
  381. placeholder20,
  382. placeholder21,
  383. placeholder22,
  384. placeholder23,
  385. placeholder24,
  386. /// <summary>
  387. /// InviteLiveConsultationNotification| 25 | 开始会诊的通知
  388. /// </summary>
  389. InviteLiveConsultationNotification,
  390. /// <summary>
  391. /// AcceptLiveConsultationNotification| 26 | 接受会诊的通知
  392. /// </summary>
  393. AcceptLiveConsultationNotification,
  394. /// <summary>
  395. /// RejectLiveConsultationNotification| 27 | 拒绝会诊的通知
  396. /// </summary>
  397. RejectLiveConsultationNotification,
  398. }
  399. class ConnectionNotification {
  400. NotificationTypeEnum notificationType;
  401. ConnectionNotification({
  402. this.notificationType = NotificationTypeEnum.Daiding,
  403. });
  404. factory ConnectionNotification.fromJson(Map<String, dynamic> map) {
  405. return ConnectionNotification(
  406. notificationType: NotificationTypeEnum.values
  407. .firstWhere((e) => e.index == map['NotificationType']),
  408. );
  409. }
  410. }
  411. class DisconnectNotification {
  412. NotificationTypeEnum notificationType;
  413. DisconnectNotification({
  414. this.notificationType = NotificationTypeEnum.Daiding,
  415. });
  416. factory DisconnectNotification.fromJson(Map<String, dynamic> map) {
  417. return DisconnectNotification(
  418. notificationType: NotificationTypeEnum.values
  419. .firstWhere((e) => e.index == map['NotificationType']),
  420. );
  421. }
  422. }
  423. class FinishNotifyRecordsMessage {}