123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401 |
- import 'package:flutter/material.dart';
- import 'package:get/get.dart';
- import 'package:fis_jsonrpc/rpc.dart';
- import 'index.dart';
- import 'widgets/build_record_view.dart';
- import 'widgets/filter_time.dart';
- import 'widgets/icon_tab_list.dart';
- import 'widgets/last_record.dart';
- import 'widgets/no_data_view.dart';
- import 'widgets/search_input.dart';
- import 'widgets/table/table.dart';
- import 'widgets/table/table_column.dart';
- import 'package:fis_ui/index.dart';
- import 'package:intl/intl.dart';
- import 'widgets/table_pagination.dart';
- class EcgListPage extends GetView<EcgListController> {
- final void Function(String) onEdit;
- final void Function(String, String) onExam;
- const EcgListPage({
- required this.onEdit,
- required this.onExam,
- Key? key,
- }) : super(key: key);
- // 主视图
- Widget _buildView(BuildContext context) {
- return Row(
- children: [
- Expanded(
- child: Column(
- children: [
- Container(
- margin: const EdgeInsets.all(5),
- height: 50,
- child: _buildHeader(),
- ),
- Expanded(child: _buildListView())
- ],
- ),
- ),
- Container(
- width: 300,
- decoration: BoxDecoration(
- border: Border(
- left: BorderSide(
- color: Colors.grey[300]!,
- width: 1,
- ),
- ),
- ),
- child: _buildRightContent(),
- )
- ],
- );
- }
- @override
- Widget build(BuildContext context) {
- return GetBuilder<EcgListController>(
- init: EcgListController(),
- id: "ecg_list",
- builder: (_) {
- return Scaffold(
- body: SafeArea(
- child: _buildView(context),
- ),
- );
- },
- );
- }
- Widget _buildHeader() {
- return Row(
- children: [
- Expanded(
- child: SizedBox(
- height: 50,
- child: SearchInput(
- placeholder: "请输入关键字",
- onSearch: (v) {
- controller.getDatas(pageIndex: 1, keyword: v);
- },
- ),
- ),
- ),
- const SizedBox(
- width: 10,
- ),
- IconButton(
- onPressed: () async {
- await Get.dialog(
- FilterView(
- onConfirm: (start, end) {
- controller.startTime = start;
- controller.endTime = end;
- controller.getDatas();
- },
- startTime: controller.startTime,
- endTime: controller.endTime,
- ),
- );
- },
- icon: const Icon(
- Icons.filter_alt,
- size: 24,
- color: Colors.blue,
- ),
- ),
- _tabRadio(
- title: "全部",
- value: RecordProcessStateEnum.All,
- ),
- _tabRadio(
- title: "待处理",
- value: RecordProcessStateEnum.Wait,
- ),
- _tabRadio(
- title: "已完成",
- value: RecordProcessStateEnum.Done,
- ),
- ],
- );
- }
- Widget _buildRightContent() {
- return Column(
- children: [
- const SizedBox(height: 5),
- IconTabList(
- const {
- "报告查看": FIcons.report_a4,
- },
- selectedValue: [
- "报告查看",
- ][controller.selectedTabIndex],
- onPressed: (v) {
- controller.selectedTabIndex = v;
- controller.loadReports();
- },
- ),
- _buildRecordInfoView(),
- ],
- );
- }
- Widget _buildListView() {
- return GetBuilder<EcgListController>(
- id: "table",
- builder: (_) {
- return Column(
- children: [
- Expanded(
- child: ETable<ElectrocardiogramRecord>(
- autoHeight: false,
- noDataHintText: "暂无数据",
- columns: _buildTableColumns(),
- source: controller.residentList,
- loading: controller.tableLoading,
- onRowSelected: (value, index, idxs) {},
- onRowTap: (index) async {
- controller.onRowTap(index);
- },
- cellPadding: const EdgeInsets.all(5),
- onAllRowsSelected: (value, idxs) => {},
- headerTextStyle: const TextStyle(
- fontSize: 20,
- ),
- ),
- ),
- if (controller.currectSelected != -1) ...[
- _buildButtons(),
- ],
- const TablePagination(),
- const SizedBox(
- height: 16,
- )
- ],
- );
- },
- );
- }
- List<TableColumn<ElectrocardiogramRecord>> _buildTableColumns() {
- var textStyle = const TextStyle(
- fontSize: 16,
- overflow: TextOverflow.ellipsis,
- );
- return <TableColumn<ElectrocardiogramRecord>>[
- TableColumn<ElectrocardiogramRecord>(
- headerText: "编号",
- flex: 5,
- render: (rowData, index) => Container(
- padding: const EdgeInsets.symmetric(vertical: 12),
- child: Center(
- child: Text(
- rowData.physicalExamNumber ?? '',
- style: textStyle,
- ),
- ),
- ),
- ),
- TableColumn<ElectrocardiogramRecord>(
- headerText: "姓名",
- flex: 3,
- render: (rowData, index) => Center(
- child: Text(
- rowData.patientName ?? '',
- style: textStyle,
- ),
- ),
- ),
- TableColumn<ElectrocardiogramRecord>(
- headerText: "性别",
- flex: 3,
- render: (rowData, index) => Center(
- child: Text(
- patientGenderConvertAge(rowData.patientGender),
- style: textStyle,
- ),
- ),
- ),
- TableColumn<ElectrocardiogramRecord>(
- headerText: "年龄",
- flex: 3,
- render: (rowData, index) => Center(
- child: Text(
- birthDayConvertAge(rowData.birthday),
- style: textStyle,
- ),
- ),
- ),
- TableColumn<ElectrocardiogramRecord>(
- headerText: "所属医院",
- flex: 4,
- render: (rowData, index) => Center(
- child: Text(
- rowData.organizationCode ?? "",
- style: textStyle,
- ),
- ),
- ),
- TableColumn<ElectrocardiogramRecord>(
- headerText: "状态",
- flex: 3,
- render: (rowData, index) => Center(
- child: Text(
- birthStateConvert(rowData.examState),
- style: textStyle,
- ),
- ),
- ),
- TableColumn<ElectrocardiogramRecord>(
- headerText: "检查时间",
- flex: 6,
- render: (rowData, index) => Center(
- child: Center(
- child: Text(
- DateFormat("yyy-MM-dd HH:mm:ss").format(
- rowData.createTime?.toLocal() ?? DateTime.now(),
- ),
- style: textStyle,
- ),
- ),
- ),
- ),
- ];
- }
- String birthDayConvertAge(DateTime? birthday) {
- if (birthday == null) {
- return "";
- }
- // 获取当前日期
- DateTime now = DateTime.now();
- // 计算年龄
- int age = calculateAge(birthday, now);
- return age.toString();
- }
- int calculateAge(DateTime birthDate, DateTime now) {
- // 计算年份差
- int age = now.year - birthDate.year;
- // 检查生日是否已经过了当前年份
- if (now.month < birthDate.month ||
- (now.month == birthDate.month && now.day < birthDate.day)) {
- age--;
- }
- return age;
- }
- String patientGenderConvertAge(GenderEnum patientGender) {
- switch (patientGender) {
- case GenderEnum.Male:
- return "男";
- case GenderEnum.Female:
- return "女";
- default:
- return "";
- }
- }
- Widget _buildRecordInfoView() {
- if (controller.reports.isEmpty) {
- return const NoDataView();
- }
- return Expanded(
- child: ListView(
- children: controller.reports
- .map(
- (e) => ReportRecord(
- currReport: e,
- onEditReport: (v) {
- onEdit.call(v);
- },
- ),
- )
- .toList(),
- ),
- );
- }
- Widget _buildButtons() {
- return Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- SizedBox(
- width: 120,
- child: ElevatedButton(
- onPressed: () {
- ElectrocardiogramRecord examRecord =
- controller.residentList[controller.currectSelected];
- onEdit.call(examRecord.code ?? '');
- },
- child: const Text("编辑"),
- ),
- ),
- const SizedBox(
- width: 15,
- ),
- SizedBox(
- width: 120,
- child: ElevatedButton(
- onPressed: () {
- ElectrocardiogramRecord examRecord =
- controller.residentList[controller.currectSelected];
- var physicalExamNumber = examRecord.physicalExamNumber ?? '';
- onExam.call(examRecord.code ?? '', physicalExamNumber);
- },
- child: const Text("检查"),
- ),
- ),
- ],
- );
- }
- String birthStateConvert(ExamStateEnum examState) {
- switch (examState) {
- case ExamStateEnum.Reported:
- return "已完成";
- default:
- return "待处理";
- }
- }
- Widget _tabRadio(
- {required String title, required RecordProcessStateEnum value}) {
- return InkWell(
- onTap: () {
- controller.changeTypeFilter(value);
- },
- child: FContainer(
- margin: const EdgeInsets.only(right: 15),
- child: FRow(
- children: [
- FRadio(
- value: value,
- groupValue: controller.typeFilter,
- onChanged: (v) {
- controller.changeTypeFilter(value);
- },
- ),
- FText(
- title,
- style: TextStyle(
- color: controller.typeFilter == value
- ? const Color(0xff2c77e5)
- : const Color(0xff4c4948),
- ),
- ),
- ],
- ),
- ),
- );
- }
- }
|