|
@@ -1,7 +1,9 @@
|
|
|
import 'dart:convert';
|
|
|
|
|
|
+import 'package:fis_common/index.dart';
|
|
|
import 'package:fis_jsonrpc/rpc.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
+import 'package:flutter/services.dart';
|
|
|
import 'package:get/get.dart';
|
|
|
import 'package:vitalapp/architecture/storage/text_storage.dart';
|
|
|
import 'package:vitalapp/architecture/utils/prompt_box.dart';
|
|
@@ -35,6 +37,8 @@ class _SelfCareAssessmentModule extends State<SelfCareAssessmentModule> {
|
|
|
///当前最新的模版键值对
|
|
|
Map<String, dynamic> templateRelation = {};
|
|
|
|
|
|
+ String templateCode = '';
|
|
|
+
|
|
|
///是否首次进入页面
|
|
|
bool isFirstEnter = true;
|
|
|
|
|
@@ -119,15 +123,25 @@ class _SelfCareAssessmentModule extends State<SelfCareAssessmentModule> {
|
|
|
try {
|
|
|
if (templateRelation[key] == null) {
|
|
|
currentTemplate = [];
|
|
|
- return;
|
|
|
+ if (!FPlatform.isWindows) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- var template =
|
|
|
- await _templateManager.readTemplate(templateRelation[key]!);
|
|
|
- String templateContent =
|
|
|
- TemplateDTO.fromJson(jsonDecode(template!)).templateContent!;
|
|
|
- List<Map<String, dynamic>> list =
|
|
|
- jsonDecode(templateContent).cast<Map<String, dynamic>>();
|
|
|
+ String? template;
|
|
|
+ if (templateRelation.containsKey(key)) {
|
|
|
+ templateCode = templateRelation[key]!;
|
|
|
+ template = await _templateManager.readTemplate(templateCode);
|
|
|
+ }
|
|
|
+ List<Map<String, dynamic>> list = [];
|
|
|
+ if (template == null) {
|
|
|
+ var json = await loadJsonFromAssets('assets/templates/${key}.json');
|
|
|
+ list = jsonDecode(json)["Content"].cast<Map<String, dynamic>>();
|
|
|
+ } else {
|
|
|
+ var templateContent =
|
|
|
+ TemplateDTO.fromJson(jsonDecode(template)).templateContent!;
|
|
|
+ list = jsonDecode(templateContent).cast<Map<String, dynamic>>();
|
|
|
+ }
|
|
|
for (var i in list) {
|
|
|
if (i["children"] != null) {
|
|
|
List<FormObject> currentChildren = [];
|
|
@@ -149,6 +163,11 @@ class _SelfCareAssessmentModule extends State<SelfCareAssessmentModule> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ Future<String> loadJsonFromAssets(String filePath) async {
|
|
|
+ String jsonString = await rootBundle.loadString(filePath);
|
|
|
+ return jsonString;
|
|
|
+ }
|
|
|
+
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
return Scaffold(
|
|
@@ -177,14 +196,16 @@ class _SelfCareAssessmentModule extends State<SelfCareAssessmentModule> {
|
|
|
}
|
|
|
final result = await widget.callBack(
|
|
|
widget.cardKey,
|
|
|
- templateRelation[widget.cardKey]!,
|
|
|
+ templateCode,
|
|
|
jsonEncode(formValue),
|
|
|
);
|
|
|
|
|
|
Get.back(result: formValue["SelfCareScore"]);
|
|
|
if (result) {
|
|
|
if (!widget.isEdit) formValue.clear();
|
|
|
- deleteDirectory();
|
|
|
+ if (!FPlatform.isWindows) {
|
|
|
+ deleteDirectory();
|
|
|
+ }
|
|
|
PromptBox.toast('提交成功');
|
|
|
setState(() {});
|
|
|
}
|