123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409 |
- import 'dart:convert';
- import 'package:fis_i18n/i18n.dart';
- import 'package:fis_jsonrpc/rpc.dart';
- import 'package:fis_measure/interfaces/process/items/item_metas.dart';
- import 'package:fis_measure/interfaces/process/workspace/application.dart';
- import 'package:fis_measure/process/items/item_meta_convert.dart';
- import 'package:fis_measure/process/workspace/measure_data_controller.dart';
- import 'package:fis_measure/process/workspace/measure_handler.dart';
- import 'package:fis_measure/view/measure/measure_config/widgets/measurement_tool_selection.dart';
- import 'package:fis_theme/theme.dart';
- import 'package:fis_ui/index.dart';
- import 'package:flutter/material.dart';
- import 'package:get/get.dart';
- ///条目元数据组
- class ItemMetaGroup {
- ItemMetaGroup(
- this.itemMetaGroupTitle,
- this.itemMeta,
- this.isExpend,
- );
- /// 当前测量组的名称
- final String itemMetaGroupTitle;
- /// 当前测量组的测量数组
- final List<ItemMeta> itemMeta;
- /// 是否展开
- bool? isExpend;
- }
- /// 测量工具配置
- class MeasureConfigurationPage extends StatelessWidget {
- const MeasureConfigurationPage({Key? key}) : super(key: key);
- @override
- FWidget build(BuildContext context) {
- return const _MeasureConfigurationDialog();
- }
- }
- ///测量配置对话框
- class _MeasureConfigurationDialog extends StatefulWidget implements FWidget {
- const _MeasureConfigurationDialog({
- Key? key,
- }) : super(key: key);
- @override
- State<_MeasureConfigurationDialog> createState() =>
- _MeasureConfigurationDialogState();
- }
- class _MeasureConfigurationDialogState
- extends State<_MeasureConfigurationDialog> {
- int measureToolsTab = 0;
- /// 切换标签栏
- void changeTab(int index) {
- measureToolsTab = index;
- setState(() {});
- }
- late final application = Get.find<IApplication>();
- late final measureHandler = Get.find<MeasureHandler>();
- /// 数据
- final measureData = Get.find<MeasureDataController>();
- /// 选中的测量项
- List<String> chooseMeasureList = [];
- List<ItemMetaGroup> itemMetaListGroup = [];
- String activeName = '';
- /// 跟超声机端保持一致,配置 项目写死
- List<ItemMetaGroup> getMeasureConfigurationGroupName() {
- return [
- ItemMetaGroup('Common', [], true),
- ItemMetaGroup('ABD', [], true),
- ItemMetaGroup('CARD', [], true),
- ItemMetaGroup('GYN', [], true),
- ItemMetaGroup('OB', [], true),
- ItemMetaGroup('VAS', [], true),
- ];
- }
- /// 打开已选测量工具设置
- ///
- /// [name] 测量的名字 后期改版后应该是一个测量对象
- void openHasSelectedSettingDialog(String name) {
- // state.childItemMeta = state.allItemMeta.firstWhere(
- // (element) => element.name == name,
- // );
- // router.dialog(() => HasSelectedSettingDialog(name: name));
- }
- Future<void> getName() async {
- var measureModeSelection = MeasureModeSelection(
- application.applicationName,
- application.categoryName,
- application.isThirdPart ? ['TPPTissue'] : ['Tissue'],
- );
- measureHandler.measureModeChanged = measureModeSelection;
- measureData.getMeasureApplicationList = [];
- var measureApplicationDTO =
- await measureData.getMeasureApplication.call(measureModeSelection);
- if (measureApplicationDTO != null) {
- /// 模式版本
- measureData.measureApplicationVersion =
- measureApplicationDTO.version ?? '';
- ///模式列表
- var models = measureApplicationDTO.availableModes;
- if (models != null && models.isNotEmpty) {
- ///群组列表
- var groups = models[0].availableGroups;
- if (groups != null && groups.isNotEmpty) {
- ///项目列表
- var folders = groups[0].availableFolders;
- if (folders != null && folders.isNotEmpty) {
- measureData.getMeasureApplicationList =
- folders[0].workingItemNames ?? [];
- if (folders[0].availableItems != null) {
- measureData.itemMetaList =
- folders[0].availableItems!.map((element) {
- return ItemMetaConverter(element).output();
- }).toList();
- }
- if (measureData.getMeasureApplicationList.isNotEmpty) {
- changeItem(measureData.getMeasureApplicationList[0]);
- }
- }
- }
- }
- }
- }
- void changeItem(String? name) {
- activeName = name ?? '';
- application.switchItemByName(activeName);
- if (mounted) {
- setState(() {});
- }
- }
- void submit() async {
- var measureModeSubmitChanged = MeasureModeSubmit(
- measureData.measureApplicationVersion,
- application.applicationName,
- application.categoryName,
- UserDefinedMeasureModeDTO(
- modeName: 'Tissue',
- workingGroups: [
- UserDefinedMeasureGroupDTO(
- name: 'General',
- folders: [
- UserDefinedMeasureFolderDTO(
- name: 'General',
- workingItemNames: chooseMeasureList,
- ),
- ],
- ),
- ],
- ),
- );
- measureHandler.measureModeSubmitChanged = measureModeSubmitChanged;
- var saveUserDefinedMeasureApplication = await measureData
- .saveUserDefinedMeasureApplicationAsync
- .call(measureModeSubmitChanged);
- getName();
- setState(() {});
- }
- @override
- void initState() {
- super.initState();
- List<ItemMetaGroup> _itemMetaConfigurationList = [];
- List<String> chooseMeasure = [];
- Map<String, List<ItemMeta>> _group = {};
- getMeasureConfigurationGroupName().forEach(
- ((element) {
- List<ItemMeta> itemMetaListGroupItem = [];
- (measureData.itemMetaList).toList().forEach(
- (e) {
- // if (e.categories!.contains(element.itemMetaGroupTitle)) {
- // itemMetaListGroupItem.add(e);
- // }
- _group[element.itemMetaGroupTitle] = itemMetaListGroupItem;
- },
- );
- }),
- );
- _group.forEach(
- (key, value) {
- _itemMetaConfigurationList.add(
- ItemMetaGroup(key, value, true),
- );
- },
- );
- itemMetaListGroup = _itemMetaConfigurationList;
- chooseMeasure = measureData.getMeasureApplicationList;
- chooseMeasureList = chooseMeasure.toSet().toList();
- }
- @override
- void dispose() {
- super.dispose();
- }
- @override
- FWidget build(BuildContext context) {
- return FSimpleDialog(
- title: FText(
- i18nBook.measure.measureToolConfig.t,
- style: const TextStyle(
- color: Colors.white,
- fontSize: 18,
- ),
- ),
- isDefault: true,
- onOk: () {
- submit();
- },
- onCancel: () {
- chooseMeasureList = measureData.getMeasureApplicationList;
- Get.back();
- setState(() {});
- },
- children: [
- FContainer(
- width: 850,
- height: 500,
- child: _buildMeasureconfiguration(),
- ),
- ],
- );
- }
- FWidget _buildMeasureconfiguration() {
- return FContainer(
- padding: const EdgeInsets.symmetric(horizontal: 15),
- child: FRow(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- FContainer(
- width: 170,
- decoration: const BoxDecoration(
- border: Border(
- right: BorderSide(
- color: Color.fromRGBO(235, 235, 235, 1),
- width: 1,
- ),
- ),
- ),
- child: FColumn(
- crossAxisAlignment: CrossAxisAlignment.end,
- children: [
- const FSizedBox(
- height: 10,
- ),
- FContainer(
- width: 160,
- child: FInkWell(
- onTap: () {
- changeTab(0);
- },
- child: FContainer(
- padding: const EdgeInsets.symmetric(
- vertical: 10,
- horizontal: 5,
- ),
- child: FText(
- i18nBook.measure.measureToolSelect.t,
- style: measureToolsTab == 0
- ? TextStyle(
- color: FTheme.ins.colorScheme.primary,
- )
- : const TextStyle(),
- textAlign: TextAlign.end,
- ),
- ),
- ),
- ),
- FContainer(
- width: 160,
- child: FInkWell(
- onTap: () {
- changeTab(1);
- },
- child: FContainer(
- padding: const EdgeInsets.symmetric(
- vertical: 10,
- horizontal: 5,
- ),
- child: FText(
- i18nBook.measure.selectedMeasureTool.t,
- style: measureToolsTab == 1
- ? TextStyle(
- color: FTheme.ins.colorScheme.primary,
- )
- : const TextStyle(),
- textAlign: TextAlign.end,
- ),
- ),
- ),
- ),
- ],
- ),
- ),
- measureToolsTab == 0
- ? FExpanded(
- child: SelectModulePage(
- itemMetaListGroup: itemMetaListGroup,
- chooseMeasureList: chooseMeasureList,
- ),
- )
- : FExpanded(
- child: _HasSelectedModulePage(
- chooseMeasureList: chooseMeasureList,
- ),
- ),
- ],
- ),
- );
- }
- }
- class _HasSelectedModulePage extends StatelessWidget implements FWidget {
- final List<String> chooseMeasureList;
- /// 数据
- final measureData = Get.find<MeasureDataController>();
- _HasSelectedModulePage({
- required this.chooseMeasureList,
- });
- /// 根据语言包翻译
- ///
- /// [code] 翻译编码
- String getValues(String code) {
- final value = jsonDecode(measureData.measureLanguage)["Language"][code];
- return value ?? code;
- }
- @override
- FWidget build(BuildContext context) {
- return FListView(
- shrinkWrap: true,
- children: [
- FColumn(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- FContainer(
- padding: const EdgeInsets.only(left: 15, top: 15, bottom: 15),
- child: FWrap(
- spacing: 16.0, // 主轴(水平)方向间距
- runSpacing: 8.0, // 纵轴(垂直)方向间距
- direction: Axis.horizontal,
- crossAlignment: WrapCrossAlignment.center,
- alignment: WrapAlignment.start,
- children: List<FWidget>.generate(
- chooseMeasureList.length,
- (index) {
- return FElevatedButton(
- onPressed: () {
- // controller.openHasSelectedSettingDialog(
- // controller.state.chooseMeasureList[index],
- // );
- },
- style: ButtonStyle(
- backgroundColor: MaterialStateProperty.all(
- Colors.white,
- ),
- ),
- child: FContainer(
- width: 180,
- height: 60,
- child: FColumn(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- FText(
- chooseMeasureList[index].toString(),
- style: const TextStyle(
- color: Colors.black,
- ),
- ),
- FText(
- getValues(
- chooseMeasureList[index].toString(),
- ),
- style: const TextStyle(
- color: Colors.black,
- ),
- ),
- ],
- ),
- ),
- );
- },
- ),
- ),
- ),
- ],
- ),
- ],
- );
- }
- }
|