123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452 |
- import 'dart:io';
- import 'package:eitc_erm_app/select_patient.dart';
- import 'package:eitc_erm_app/utils/Component.dart';
- import 'package:eitc_erm_app/utils/Constants.dart';
- import 'package:eitc_erm_app/utils/logger.dart';
- import 'package:eitc_erm_app/widget/loading.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- import 'package:http/http.dart' as http;
- import 'bean/appointment_list.dart';
- void main() {
- WidgetsFlutterBinding.ensureInitialized();
- runApp(RecordRegistration());
- }
- class RecordRegistration extends StatefulWidget {
- @override
- State<StatefulWidget> createState() => RecordRegistrationState();
- }
- class RecordRegistrationState extends State<RecordRegistration> {
- ValueNotifier<dynamic> result = ValueNotifier(null);
- late Future<AppointmentList?> _future;
- String appointmentStatusStr =
- 'appointmentStatusArray[0]=1&appointmentStatusArray[1]=3&appointmentStatusArray[2]=4&appointmentStatusArray[3]=5&appointmentStatusArray[4]=6&appointmentStatusArray[5]=8';
- @override
- void initState() {
- super.initState();
- logd("Global.selectPatient " + Global.selectPatient.toString());
- if (Global.selectPatient == -1) {
- Component.toast("请先添加或选择患者!", 2);
- Navigator.of(context).pop();
- return;
- }
- _future = fetchData();
- }
- Future<AppointmentList?> fetchData() async {
- logd(Global.token);
- final response = await http.get(
- Uri.parse(
- '${Global.BaseUrl}patient-appointment/list?appointmentPersonId=${Global.appointmentPersonId}&${appointmentStatusStr}'),
- headers: jsonHeaders(withToken: true));
- logd(
- '${Global.BaseUrl}patient-appointment/list?appointmentPersonId=${Global.appointmentPersonId}&${appointmentStatusStr}');
- if (response.statusCode == 200) {
- final json = decodeBodyToJson(response.bodyBytes);
- logd("预约记录列表=$json");
- AppointmentList mAppointmentList = AppointmentList.fromJson(json);
- if (mAppointmentList.code == Global.responseSuccessCode) {
- } else {
- Component.toast(mAppointmentList.msg.toString(), 0);
- return null;
- }
- return mAppointmentList;
- } else {
- Component.toast("出错了,请稍后再试!", 0);
- return null;
- }
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: new AppBar(
- title: new Text('预约挂号记录',
- style: TextStyle(
- color: Colors.white,
- )),
- centerTitle: true,
- elevation: 0.5,
- backgroundColor: Global.StatusBarColor,
- leading: new IconButton(
- tooltip: '返回上一页',
- icon: const Icon(
- Icons.arrow_back_ios,
- color: Colors.white,
- ),
- onPressed: () {
- Navigator.of(context).pop();
- //_nextPage(-1);
- },
- ),
- ),
- body: Center(
- child: Column(children: <Widget>[
- Container(
- decoration: BoxDecoration(
- color: Global.StatusBarColor,
- ),
- child: Padding(
- padding: const EdgeInsets.all(20),
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.center,
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisSize: MainAxisSize.max,
- children: <Widget>[
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceEvenly,
- children: [
- Text(
- Global.patient.data == null
- ? ""
- : Global
- .patient
- .data![Global.selectPatient]
- .patientName
- .toString(),
- style: const TextStyle(
- fontSize: 20, color: Colors.white),
- ),
- const SizedBox(
- width: 20,
- ),
- Container(
- padding: const EdgeInsets.symmetric(
- horizontal: 8, vertical: 2),
- decoration: BoxDecoration(
- color: Colors.red,
- borderRadius: BorderRadius.circular(30)),
- child: Text(
- Global.patient.data == null
- ? ""
- : Global
- .patient
- .data![Global.selectPatient]
- .userRelationship
- .toString(),
- style: const TextStyle(
- color: Colors.white, fontSize: 12),
- ),
- ),
- ]),
- Text(
- Global.patient.data == null
- ? ""
- : Global.patient.data![Global.selectPatient]
- .identificationCard
- .toString()
- .replaceRange(
- 6,
- Global
- .patient
- .data![Global.selectPatient]
- .identificationCard
- .toString()
- .length -
- 2,
- '******'),
- style: const TextStyle(
- fontSize: 15, color: Colors.white),
- ),
- ]),
- GestureDetector(
- child: const Column(children: <Widget>[
- Icon(
- Icons.cached_outlined,
- color: Colors.white,
- ),
- Text(
- '切换就诊人',
- style: TextStyle(fontSize: 14, color: Colors.white),
- ),
- ]),
- onTap: () async {
- await Navigator.push(
- context,
- MaterialPageRoute(
- builder: (context) =>
- SelectPatient("fromRecordRegistration")),
- );
- setState(() {
- _future = fetchData();
- });
- }),
- ]),
- ),
- ),
- DefaultTabController(
- initialIndex: 0,
- length: 4,
- child: TabBar(
- tabs: const <Widget>[
- Tab(
- text: "全部",
- ),
- Tab(
- text: "已预约",
- ),
- Tab(
- text: "治疗完成",
- ),
- Tab(
- text: "已取消",
- ),
- ],
- enableFeedback: true,
- onTap: (index) {
- switch (index) {
- case 0:
- appointmentStatusStr =
- 'appointmentStatusArray[0]=1&appointmentStatusArray[1]=3&appointmentStatusArray[2]=4&appointmentStatusArray[3]=5&appointmentStatusArray[4]=6&appointmentStatusArray[5]=8';
- break;
- case 1:
- appointmentStatusStr =
- 'appointmentStatusArray[0]=0&appointmentStatusArray[1]=1';
- break;
- case 2:
- appointmentStatusStr =
- 'appointmentStatusArray[0]=0&appointmentStatusArray[1]=5';
- break;
- case 3:
- appointmentStatusStr =
- 'appointmentStatusArray[0]=0&appointmentStatusArray[1]=8';
- break;
- }
- setState(() {
- _future = fetchData();
- });
- },
- ),
- ),
- Expanded(
- child: FutureBuilder<AppointmentList?>(
- future: _future,
- builder: (context, snapshot) {
- if (snapshot.hasData) {
- AppointmentList? data = snapshot.data;
- return ListView.builder(
- itemCount: data?.data?.length,
- itemBuilder: (context, index) {
- return ListTile(
- title: SizedBox(
- width: double.infinity,
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- mainAxisSize: MainAxisSize.max,
- children: [
- Padding(
- padding: const EdgeInsets.all(10),
- child: Row(
- mainAxisAlignment:
- MainAxisAlignment.spaceBetween,
- children: [
- Row(children: [
- Text(
- data!.data![index].department ==
- null
- ? ""
- : data.data![index].department
- .toString(),
- style:
- const TextStyle(fontSize: 18),
- ),
- const SizedBox(
- width: 5,
- ),
- Text(
- data.data![index].attendingDoctor
- .toString(),
- style: const TextStyle(
- fontSize: 15,
- color: Colors.green),
- ),
- ]),
- GetAppointmentStatus(data
- .data![index].appointmentStatus),
- ]),
- ),
- Padding(
- padding: const EdgeInsets.all(10),
- child: Row(
- mainAxisAlignment:
- MainAxisAlignment.spaceBetween,
- children: [
- const Text(
- '就诊科室',
- style: TextStyle(
- fontSize: 15, color: Colors.grey),
- ),
- Text(
- data.data![index].department == null
- ? ""
- : data.data![index].department
- .toString(),
- style: const TextStyle(fontSize: 15),
- ),
- ]),
- ),
- Padding(
- padding: const EdgeInsets.all(10),
- child: Row(
- mainAxisAlignment:
- MainAxisAlignment.spaceBetween,
- children: [
- const Text(
- '就诊人',
- style: TextStyle(
- fontSize: 15, color: Colors.grey),
- ),
- Text(
- data.data![index].patientName
- .toString(),
- style: const TextStyle(fontSize: 15),
- ),
- ]),
- ),
- Padding(
- padding: const EdgeInsets.all(10),
- child: Row(
- mainAxisAlignment:
- MainAxisAlignment.spaceBetween,
- children: [
- const Text(
- '就诊时间',
- style: TextStyle(
- fontSize: 15, color: Colors.grey),
- ),
- Text(
- data.data![index].appointmentStartTime
- .toString(),
- style: const TextStyle(fontSize: 15),
- ),
- ]),
- ),
- ]),
- ),
- subtitle: Padding(
- padding: const EdgeInsets.fromLTRB(10, 0, 10, 10),
- child: Container(
- width: double.infinity,
- height: 1.0,
- padding: const EdgeInsets.all(50),
- decoration: const BoxDecoration(
- gradient: LinearGradient(
- colors: [Colors.black, Colors.white],
- begin: Alignment.center,
- end: Alignment.centerRight,
- tileMode: TileMode.mirror,
- ),
- ),
- child: const Image(
- image: AssetImage('assets/images/line.png'),
- fit: BoxFit.fitWidth),
- ),
- ),
- );
- },
- );
- } else if (snapshot.hasError) {
- return Text('Error: ${snapshot.error}');
- }
- return const ColorLoader();
- },
- ),
- ),
- ]),
- ),
- );
- }
- }
- class GetAppointmentStatus extends StatelessWidget {
- int mStatus = 0;
- GetAppointmentStatus(status) {
- mStatus = status;
- }
- @override
- Widget build(BuildContext context) {
- // 1预约,2已确定,3已到店,4治疗中,5治疗完成,6已结账,7已离开,8已失约
- switch (mStatus) {
- case 1:
- return Text(
- '已预约',
- style: const TextStyle(fontSize: 15, color: Colors.blue),
- );
- break;
- case 2:
- return Text(
- '已确定',
- style: const TextStyle(fontSize: 15, color: Colors.blue),
- );
- break;
- case 3:
- return Text(
- '已到店',
- style: const TextStyle(fontSize: 15, color: Colors.blue),
- );
- break;
- case 4:
- return Text(
- '治疗中',
- style: const TextStyle(fontSize: 15, color: Colors.blue),
- );
- break;
- case 5:
- return Text(
- '治疗完成',
- style: const TextStyle(fontSize: 15, color: Colors.blue),
- );
- break;
- case 6:
- return Text(
- '已结账',
- style: const TextStyle(fontSize: 15, color: Colors.blue),
- );
- break;
- case 7:
- return Text(
- '已离开',
- style: const TextStyle(fontSize: 15, color: Colors.blue),
- );
- break;
- case 8:
- return Text(
- '已失约',
- style: const TextStyle(fontSize: 15, color: Colors.blue),
- );
- break;
- }
- return Text(
- '未知',
- style: const TextStyle(fontSize: 15, color: Colors.blue),
- );
- ;
- }
- }
- class _IdCardInputFormatter extends TextInputFormatter {
- @override
- TextEditingValue formatEditUpdate(
- TextEditingValue oldValue, TextEditingValue newValue) {
- // 只保留前6位和后2位,中间用星号(*)替换
- String newText =
- newValue.text.replaceRange(6, newValue.text.length - 2, '******');
- return new TextEditingValue(
- text: newText,
- selection: new TextSelection.collapsed(offset: newText.length),
- );
- }
- }
|