123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470 |
- import 'package:flutter/material.dart';
- import 'package:get_it/get_it.dart';
- import 'package:ustest/Services/ConsultationService.dart';
- import 'package:ustest/Services/UserService.dart';
- import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
- import 'package:autocomplete_textfield/autocomplete_textfield.dart';
- import 'ConsultationList.dart';
- class CustomPicker extends CommonPickerModel {
- String digits(int value, int length) {
- return '$value'.padLeft(length, "0");
- }
- CustomPicker({DateTime? currentTime, LocaleType? locale})
- : super(locale: locale) {
- this.currentTime = currentTime ?? DateTime.now();
- this.setLeftIndex(this.currentTime.hour);
- this.setMiddleIndex(this.currentTime.minute);
- this.setRightIndex(this.currentTime.second);
- }
- @override
- String? leftStringAtIndex(int index) {
- if (index >= 0 && index < 24) {
- return this.digits(index, 2);
- } else {
- return null;
- }
- }
- @override
- String? middleStringAtIndex(int index) {
- if (index >= 0 && index < 60) {
- return this.digits(index, 2);
- } else {
- return null;
- }
- }
- @override
- String? rightStringAtIndex(int index) {
- if (index >= 0 && index < 60) {
- return this.digits(index, 2);
- } else {
- return null;
- }
- }
- @override
- String leftDivider() {
- return "|";
- }
- @override
- String rightDivider() {
- return "|";
- }
- @override
- List<int> layoutProportions() {
- return [1, 2, 1];
- }
- @override
- DateTime finalTime() {
- return currentTime.isUtc
- ? DateTime.utc(
- currentTime.year,
- currentTime.month,
- currentTime.day,
- this.currentLeftIndex(),
- this.currentMiddleIndex(),
- this.currentRightIndex())
- : DateTime(
- currentTime.year,
- currentTime.month,
- currentTime.day,
- this.currentLeftIndex(),
- this.currentMiddleIndex(),
- this.currentRightIndex());
- }
- }
- Consultation consultationModel=new Consultation(consultationStatus: 0, id: '', patientName: '', applyUserCode: '', expertUserCode: '');
- class ApprovalConsultationScreen extends StatelessWidget {
- final Consultation model;
- ApprovalConsultationScreen({required this.model})
- {
- consultationModel = model;
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- backgroundColor: Colors.grey[200],
- body: const Center(
- child: SizedBox(
- width: 400,
- child: Card(
- child: ApprovalConsultationForm(),
- ),
- ),
- ),
- );
- }
- }
- class ApprovalConsultationForm extends StatefulWidget {
- const ApprovalConsultationForm();
- @override
- _ApprovalConsultationFormState createState() => _ApprovalConsultationFormState();
- }
- class _ApprovalConsultationFormState extends State<ApprovalConsultationForm> {
- final patientCodeController = TextEditingController();
- List<Expert> selectedUsers = <Expert>[];
- DateTime time = DateTime.now();
- GlobalKey<AutoCompleteTextFieldState<Expert>> exportKey =
- GlobalKey<AutoCompleteTextFieldState<Expert>>();
- double _formProgress = 0;
- _ApprovalConsultationFormState() {
- }
- @override
- Widget build(BuildContext context) {
- return Form(
- child: FutureBuilder<AppConsultationDataModel>(
- future: lodaDataAsync(),
- builder: (context, snapshot) {
- if (snapshot.hasError) {
- return const Center(
- child: Text('An error has occurred!'),
- );
- } else if (snapshot.hasData) {
- return Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- LinearProgressIndicator(value: _formProgress),
- Text('Approval', style: Theme.of(context).textTheme.headline4),
- Padding(
- padding: const EdgeInsets.all(24.0),
- child: Row(
- children: [
- Expanded(
- child: Text(time.toString()),
- ),
- TextButton(
- onPressed: () {
- DatePicker.showDatePicker(context,
- showTitleActions: true,
- minTime: DateTime(2022, 3, 5),
- maxTime: DateTime(2024, 6, 7),
- theme: DatePickerTheme(
- headerColor: Colors.orange,
- backgroundColor: Colors.blue,
- itemStyle: TextStyle(
- color: Colors.white,
- fontWeight: FontWeight.bold,
- fontSize: 18),
- doneStyle: TextStyle(
- color: Colors.white,
- fontSize: 16)), onChanged: (date) {
- print('change $date in time zone ' +
- date.timeZoneOffset.inHours.toString());
- }, onConfirm: (date) {
- print('confirm $date');
- setState(() {
- this.time = date;
- });
- },
- currentTime: DateTime.now(),
- locale: LocaleType.en);
- },
- child: Text(
- 'date',
- style: TextStyle(color: Colors.blue),
- )),
- TextButton(
- onPressed: () {
- DatePicker.showTimePicker(context,
- showTitleActions: true, onChanged: (date) {
- print('change $date in time zone ' +
- date.timeZoneOffset.inHours.toString());
- }, onConfirm: (date) {
- print('confirm $date');
- setState(() {
- this.time = date;
- });
- }, currentTime: DateTime.now());
- },
- child: Text(
- 'time',
- style: TextStyle(color: Colors.blue),
- )),
- ],
- ),
- ),
- Padding(
- padding: const EdgeInsets.all(24.0),
- child: DropdownButtonFormField<Expert>(
-
- decoration: InputDecoration(
- hintText: "Select some users",
- suffixIcon: Icon(Icons.search)),
- onChanged: (item) {
- setState(() => setSelectUsers(item) );
- },
- key: exportKey,
- items: snapshot.data!.users
- .map((e) => DropdownMenuItem<Expert>(
- child: Text(e.userName),
- value: e,
- ))
- .toList(),
- )),
- Padding(
- padding: EdgeInsets.all(8.0),
- child: Row(
- children: [
-
- Text(getSelectUsers()),
- ],
- ),
- ),
- Padding(
- padding: const EdgeInsets.all(8.0),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- TextButton(
- style: ButtonStyle(
- foregroundColor:
- MaterialStateProperty.resolveWith(
- (Set<MaterialState> states) {
- return states.contains(MaterialState.disabled)
- ? null
- : Colors.white;
- }),
- backgroundColor:
- MaterialStateProperty.resolveWith(
- (Set<MaterialState> states) {
- return states.contains(MaterialState.disabled)
- ? null
- : Colors.blue;
- }),
- ),
- onPressed: onSubmit,
- child: const Text('Submit'),
- ),
- Padding(
- padding: const EdgeInsets.all(8.0),
- child: TextButton(
- style: ButtonStyle(
- foregroundColor:
- MaterialStateProperty.resolveWith(
- (Set<MaterialState> states) {
- return states.contains(MaterialState.disabled)
- ? null
- : Colors.white;
- }),
- backgroundColor:
- MaterialStateProperty.resolveWith(
- (Set<MaterialState> states) {
- return states.contains(MaterialState.disabled)
- ? null
- : Colors.blue;
- }),
- ),
- onPressed: () => {Navigator.of(context).pop()},
- child: const Text('Cancel'),
- ),
- ),
- ],
- )),
- ],
- );
- } else {
- return const Center(
- child: CircularProgressIndicator(),
- );
- }
- }),
- );
- }
- void setSelectUsers(Expert? user)
- {
- if(!this.selectedUsers.contains(user))
- {
- this.selectedUsers.add(user!);
- }
- }
- String getSelectUsers()
- {
- var str = "";
- this.selectedUsers.forEach((element) {
- str+=element.userName+" ";
- });
-
- return str;
- }
- void onSubmit() async {
- try {
- var userCodes =<String>[];
- selectedUsers.forEach((element) {
- userCodes.add(element.code);
- });
- ApprovalConsultationRequest _model = new ApprovalConsultationRequest(
- consultationModel.id,consultationModel.expertUserCode,this.time,userCodes,"");
- print(_model.toString());
- var service = GetIt.instance.get<ConsultationService>();
- var result = await service.ApprovalConsultationAsync(
- _model);
- if (result) {
- Navigator.of(context).pushNamed('/');
- }
- } catch (e) {
- print('signInAsync ex: $e');
- }
- }
- Future<AppConsultationDataModel> lodaDataAsync() async {
- try {
- var service = GetIt.instance.get<ConsultationService>();
- var model = await service.LoadDataAsync();
- return model;
- } catch (ex) {
- print('lodaDataAsync ex' + ex.toString());
- return Future.error(ex);
- }
- }
- }
- class ExportInfo {
- final String id;
- final String name;
- ExportInfo({required this.id, required this.name});
- factory ExportInfo.fromJson(Map<String, dynamic> json) {
- var item = ExportInfo(
- id: json['id'] as String,
- name: json['name'] as String,
- );
- return item;
- }
- Map<String, dynamic> toMap() {
- return {
- 'id': id,
- 'name': name,
- };
- }
- @override
- String toString() {
- return 'ExportInfo{id: $id}, {name: $name}';
- }
- }
- enum NotificationTypeEnum {
- Daiding,
- /// <summary>
- /// ChatMsgNotification|1| 聊天通知
- /// </summary>
- ChatMsgNotification,
- /// <summary>
- /// UpgradeVersionNotification|2| 版本更新通知
- /// </summary>
- UpgradeVersionNotification,
- /// <summary>
- /// LogoffNotification|3| 登出通知
- /// </summary>
- LogoffNotification,
- /// <summary>
- /// DisconnectNotification| 4|与服务器断开连接通知
- /// </summary>
- DisconnectNotification,
- /// <summary>
- /// ConnectionNotification| 5| 与服务器已连接通知
- /// </summary>
- ConnectionNotification,
- /// <summary>
- ///FinishNotifyRecordsMessage| 6 | 检查记录完成消息类型
- /// </summary>
- FinishNotifyRecordsMessage,
- /// <summary>
- ///InvitedEnterRoomNotification| 7 | 邀请用户加入房间通知
- /// </summary>
- InvitedEnterRoomNotification,
- /// <summary>
- ///CancelInvitedEnterRoomNotification| 8 |取消邀请用户通知
- /// </summary>
- CancelInvitedEnterRoomNotification,
- placeholder9,
- placeholder10,
- placeholder11,
- placeholder12,
- placeholder13,
- placeholder14,
- placeholder15,
- placeholder16,
- placeholder17,
- placeholder18,
- placeholder19,
- placeholder20,
- placeholder21,
- placeholder22,
- placeholder23,
- placeholder24,
- /// <summary>
- /// InviteLiveConsultationNotification| 25 | 开始会诊的通知
- /// </summary>
- InviteLiveConsultationNotification,
- /// <summary>
- /// AcceptLiveConsultationNotification| 26 | 接受会诊的通知
- /// </summary>
- AcceptLiveConsultationNotification,
- /// <summary>
- /// RejectLiveConsultationNotification| 27 | 拒绝会诊的通知
- /// </summary>
- RejectLiveConsultationNotification,
- }
- class ConnectionNotification {
- NotificationTypeEnum notificationType;
- ConnectionNotification({
- this.notificationType = NotificationTypeEnum.Daiding,
- });
- factory ConnectionNotification.fromJson(Map<String, dynamic> map) {
- return ConnectionNotification(
- notificationType: NotificationTypeEnum.values
- .firstWhere((e) => e.index == map['NotificationType']),
- );
- }
- }
- class DisconnectNotification {
- NotificationTypeEnum notificationType;
- DisconnectNotification({
- this.notificationType = NotificationTypeEnum.Daiding,
- });
- factory DisconnectNotification.fromJson(Map<String, dynamic> map) {
- return DisconnectNotification(
- notificationType: NotificationTypeEnum.values
- .firstWhere((e) => e.index == map['NotificationType']),
- );
- }
- }
- class FinishNotifyRecordsMessage {}
|