123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- import 'package:flutter/material.dart';
- import 'package:vitalapp/architecture/types/index.dart';
- import 'package:vitalapp/components/button.dart';
- import 'package:vitalapp/components/no_data_view.dart';
- import 'package:vitalapp/pages/check/models/form.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_radio_and_select.dart';
- class ExamTable extends StatelessWidget {
- const ExamTable({
- super.key,
- required this.tableThList,
- required this.currentFormObject,
- this.currentValue,
- this.addTableData,
- this.editTableData,
- });
- final List<String> tableThList;
- final FormObject currentFormObject;
- final List<dynamic>? currentValue;
- final Function? addTableData;
- final ValueCallback? editTableData;
- @override
- Widget build(BuildContext context) {
- return Stack(
- children: [
- ExamCardRadioSelect(
- title: currentFormObject.label ?? '',
- clickCard: null,
- content: Container(
- alignment: Alignment.center,
- padding: const EdgeInsets.only(
- // bottom: 20,
- right: 20,
- left: 20,
- ),
- child: SingleChildScrollView(
- scrollDirection: Axis.horizontal,
- child: Column(
- children: [
- DataTable(
- columnSpacing: 80,
- headingRowColor: MaterialStateProperty.all<Color?>(
- Theme.of(context).primaryColor),
- dataRowHeight: 60,
- headingTextStyle: const TextStyle(
- fontSize: 24,
- color: Colors.white,
- ),
- dataTextStyle: TextStyle(
- fontSize: 22,
- color: Colors.black.withOpacity(0.9),
- ),
- columns: tableThList
- .map(
- (e) => DataColumn(
- numeric: false,
- label: Text(
- e,
- ),
- ),
- )
- .toList(),
- rows: currentValue!.map((c) {
- List<DataCell> cells = (c as Map)
- .entries
- .map(
- (a) => DataCell(
- Container(
- constraints: const BoxConstraints(
- maxWidth: 150,
- ),
- child: Text(
- a.value ?? '',
- overflow: TextOverflow.ellipsis,
- ),
- ),
- ),
- )
- .toList();
- cells.add(
- DataCell(
- Text(
- '编辑',
- style: TextStyle(
- fontSize: 22,
- color: Theme.of(context).primaryColor,
- ),
- ),
- onTap: () {
- editTableData!.call(
- EditTableValue(
- id: int.parse(c['id']),
- value: currentValue![int.parse(c['id']) - 1],
- ),
- );
- },
- ),
- );
- return DataRow(
- cells: cells,
- );
- }).toList(),
- ),
- if (currentValue?.isEmpty ?? true)
- Container(
- margin: EdgeInsets.symmetric(vertical: 50),
- width: 300,
- height: 300,
- child: FittedBox(
- child: VNoDataView(),
- ),
- )
- ],
- )),
- ),
- ),
- Positioned(
- right: 16,
- top: 8,
- child: SizedBox(
- width: 130,
- height: 54,
- child: VButton(
- // label: '新增',
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: const [
- Icon(Icons.add, size: 24),
- SizedBox(
- width: 8,
- ),
- Text("新增", style: TextStyle(fontSize: 20)),
- ],
- ),
- onTap: () {
- addTableData!();
- },
- ),
- ),
- ),
- ],
- );
- }
- }
|