123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291 |
- import 'package:flutter/material.dart';
- import 'package:get_it/get_it.dart';
- import 'package:ustest/Services/NotificationReceivedArgs.dart';
- import 'package:ustest/Services/UserService.dart';
- import 'package:ustest/tool.dart';
- import 'Services/ConsultationService.dart';
- class ConsultationList extends StatefulWidget {
- ConsultationList({Key? key, required this.token, required this.consultations})
- : super();
- final String token;
- final List<Consultation> consultations;
- @override
- _ConsultationListState createState() => _ConsultationListState();
- }
- class _ConsultationListState extends State<ConsultationList> {
- @override
- void initState() {
- var service = GetIt.instance.get<UserService>();
- service.NotificationReceived.subscribe((args) {
- if (args == null) {
- return;
- }
- NotificationTypeEnum type = args.type;
- switch (type) {
- case NotificationTypeEnum.InviteLiveConsultationNotification:
- var code = args.jsonMessage['ConsultationCode'];
- showConfirmDialog(context, "xxx请求会诊,要接吗?", () {
- OnAcceptLiveConsultation(code);
- }, () {
- OnRejectLiveConsultation(code);
- });
- break;
- default:
- //TDOO
- }
- });
- super.initState();
- }
- @override
- void dispose() {
- var service = GetIt.instance.get<UserService>();
- service.NotificationReceived.unsubscribe((args) {});
- super.dispose();
- }
- void showConfirmDialog(BuildContext context, String content,
- Function confirmCallback, Function rejectCallback) {
- showDialog(
- context: context,
- builder: (context) {
- return new AlertDialog(
- title: new Text("提示"),
- content: new Text(content),
- actions: <Widget>[
- new TextButton(
- onPressed: () {
- confirmCallback();
- Navigator.of(context).pop();
- },
- child: new Text("接受"),
- ),
- new TextButton(
- onPressed: () {
- Navigator.of(context).pop();
- },
- child: new Text("拒絕"),
- ),
- ],
- );
- });
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- body: Container(
- height: 600,
- child: Row(
- children: [
- Container(
- height: 500,
- width: 400,
- child: ListView(
- restorationId: 'list_demo_list_view',
- padding: const EdgeInsets.symmetric(vertical: 0),
- children: [
- for (int index = 0;
- index < widget.consultations.length;
- index++)
- Row(
- children: [
- Expanded(
- child: Container(
- child: ListTile(
- leading: ExcludeSemantics(
- child: Icon(Icons.person),
- ),
- title: Text(widget.consultations[index].id +
- " - " +
- widget.consultations[index].expertUserCode),
- subtitle: Text(
- widget.consultations[index].patientName +
- getStatusDesc(widget.consultations[index]
- .consultationStatus)),
- onTap: (() =>
- onTabPatient(widget.consultations[index].id)),
- ),
- )),
- Row(
- children: [
- Offstage(
- offstage: widget.consultations[index]
- .consultationStatus !=
- 1,
- child: TextButton.icon(
- onPressed: () => onApprovalConsultation(
- context, widget.consultations[index]),
- icon: Icon(Icons.update),
- label: Text("批准")))
- ],
- ),
- Container(
- alignment: Alignment.topRight,
- child: Container(
- child: Column(
- children: [
- ClipRRect(
- borderRadius: BorderRadius.circular(2),
- child: Container(
- color: Colors.amber[50],
- child: Row(children: [
- Icon(
- Icons.star,
- color: Colors.amber[500],
- size: 12,
- ),
- Text(
- "5.0",
- style: TextStyle(
- color: Colors.amber[900],
- fontSize: 9),
- ),
- ]))),
- Container(
- child: Row(
- children: [
- TextButton(
- child: Text("Start"),
- onPressed: (() =>
- OnStartLiveConsultation(widget
- .consultations[index].id))),
- TextButton(
- child: Text("Cancel"),
- onPressed: (() =>
- OnCancelLiveConsultation(widget
- .consultations[index].id)))
- ],
- ))
- ],
- ),
- )),
- ],
- ),
- ],
- ),
- ),
- ],
- ),
- ));
- }
- void onTabPatient(String id) async {}
- void OnStartLiveConsultation(id) async {
- try {
- var service = GetIt.instance.get<ConsultationService>();
- Navigator.of(context).pushNamed('/meeting');
- } catch (ex) {
- print('OnStartLiveConsultation.to ex:$ex');
- MeetingTool.toast(ex.toString(), context);
- }
- }
- void OnCancelLiveConsultation(String id) async {
- try {
- var service = GetIt.instance.get<ConsultationService>();
- var result = await service.CancelLiveConsultationAsync(id);
- } catch (ex) {
- print('OnCancelLiveConsultation.to ex:$ex');
- MeetingTool.toast(ex.toString(), context);
- }
- }
- void OnAcceptLiveConsultation(id) async {
- try {
- var service = GetIt.instance.get<ConsultationService>();
- Navigator.of(context).pushNamed('/meeting');
- } catch (ex) {
- print('OnAcceptLiveConsultation.to ex' + ex.toString());
- }
- }
- void OnRejectLiveConsultation(id) async {
- try {
- var service = GetIt.instance.get<ConsultationService>();
- var result = await service.RejectLiveConsultationAsync(id);
- print("RejectLiveConsultationAsync");
- } catch (ex) {
- print('OnRejectLiveConsultation.to ex' + ex.toString());
- }
- }
- String getStatusDesc(status) {
- if (status == 1) {
- return "已申请";
- } else if (status == 2) {
- return "已撤回";
- } else if (status == 3) {
- return "已拒绝";
- } else if (status == 4) {
- return "待开始(即申请已同意)";
- } else if (status == 5) {
- return "进行中";
- } else if (status == 6) {
- return "待报告";
- } else if (status == 7) {
- return "已结束(即会诊报告已提交)";
- }
- return "";
- }
- void onApprovalConsultation(context, Consultation model) {
- print("onApprovalConsultation click");
- //Navigator.of(context).pushNamed('/approvalconsultation',arguments: model);
- //Navigator.push(
- //context,
- //MaterialPageRoute(
- //builder: (context) => ApprovalConsultationScreen(model: model)));
- }
- }
- class Consultation {
- final String id;
- final String patientName;
- final int consultationStatus;
- final String expertUserCode;
- final String applyUserCode;
- Consultation(
- {required this.id,
- required this.patientName,
- required this.consultationStatus,
- required this.expertUserCode,
- required this.applyUserCode});
- factory Consultation.fromJson(Map<String, dynamic> json) {
- var item = Consultation(
- id: json['ConsultationCode'] as String,
- //expertUserCode: json['ExpertUserCode'] as String,
- //applyUserCode: json['ApplyUserCode'] as String,
- //patientName: json['PatientName'] as String,
- //consultationStatus: json['ConsultationStatus'] as int);
- expertUserCode: '',
- applyUserCode: '',
- patientName: '',
- consultationStatus: json['ConsultationStatus']);
- return item;
- }
- Map<String, dynamic> toMap() {
- return {
- 'ConsultationCode': id,
- 'PatientName': patientName,
- 'ExpertUserCode': expertUserCode,
- };
- }
- @override
- String toString() {
- return 'Patient{id: $id}';
- }
- }
|