Browse Source

feat : 显示绑定信息

dev
徐振升 19 hours ago
parent
commit
06da8c6600
  1. 13
      README.md
  2. 1
      lib/data/repositories/problem_repository.dart
  3. 12
      lib/modules/problem/controllers/problem_form_controller.dart
  4. 96
      lib/modules/problem/views/problem_form_page.dart

13
README.md

@ -24,3 +24,16 @@ Image Picker (图片选择)
Geolocator (位置信息) Geolocator (位置信息)
HTTP/Dio (网络请求) HTTP/Dio (网络请求)
# !/bin/bash
echo "开始清理..."
flutter clean
echo "获取依赖..."
flutter pub get
echo "构建APK..."
flutter build apk --release --target-platform android-arm64
echo "构建完成!APK位置:build/app/outputs/flutter-apk/app-release.apk"

1
lib/data/repositories/problem_repository.dart

@ -54,6 +54,7 @@ class ProblemRepository extends GetxService {
await sqliteProvider.deleteProblem(problemId); await sqliteProvider.deleteProblem(problemId);
} }
// TODO id,
// ProblemRepository中添加 // ProblemRepository中添加
Future<List<ServerProblem>> fetchProblemsFromServer({ Future<List<ServerProblem>> fetchProblemsFromServer({
DateTime? startTime, DateTime? startTime,

12
lib/modules/problem/controllers/problem_form_controller.dart

@ -1,3 +1,5 @@
import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:image_picker/image_picker.dart'; import 'package:image_picker/image_picker.dart';
@ -14,6 +16,7 @@ import 'package:uuid/uuid.dart';
class ProblemFormController extends GetxController { class ProblemFormController extends GetxController {
final Problem? problem; final Problem? problem;
late Map<String, dynamic> bindInfo;
final bool isReadOnly; final bool isReadOnly;
final ProblemRepository problemRepository; final ProblemRepository problemRepository;
@ -29,6 +32,9 @@ class ProblemFormController extends GetxController {
this.isReadOnly = false, this.isReadOnly = false,
}) { }) {
if (problem != null) { if (problem != null) {
if (problem!.bindData != null) {
bindInfo = jsonDecode(problem!.bindData!);
}
descriptionController.text = problem!.description; descriptionController.text = problem!.description;
locationController.text = problem!.location; locationController.text = problem!.location;
final imagePaths = problem!.imageUrls final imagePaths = problem!.imageUrls
@ -42,6 +48,12 @@ class ProblemFormController extends GetxController {
} }
} }
// @override
// void onInit() {
// super.onInit();
// }
// pickImage // pickImage
Future<void> pickImage(ImageSource source) async { Future<void> pickImage(ImageSource source) async {
try { try {

96
lib/modules/problem/views/problem_form_page.dart

@ -47,6 +47,47 @@ class ProblemFormPage extends GetView<ProblemFormController> {
child: SingleChildScrollView( child: SingleChildScrollView(
child: Column( child: Column(
children: [ children: [
if (controller.problem?.bindData != null)
Container(
color: Colors.white,
padding: const EdgeInsets.symmetric(
horizontal: 16.0,
vertical: 8.0,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
_buildSection(
'项目名称',
controller.bindInfo['projectName'],
),
_buildDivider(),
_buildSection(
'企业名称',
controller.bindInfo['companyName'],
),
_buildDivider(),
_buildSection(
'要素名称',
controller.bindInfo['censorElementName'],
),
_buildDivider(),
_buildSection(
'评估内容',
controller.bindInfo['pgContent'],
),
_buildDivider(),
_buildSection(
'建议项',
controller.bindInfo['suggestion'],
),
_buildDivider(),
_buildSection('问题类型', ''),
_buildDivider(),
_buildSection('工艺设备名称', ''),
],
),
),
_buildInputCard( _buildInputCard(
title: '问题描述', title: '问题描述',
textController: controller.descriptionController, textController: controller.descriptionController,
@ -69,6 +110,61 @@ class ProblemFormPage extends GetView<ProblemFormController> {
); );
} }
// The main widget to build a section with a title and content.
Widget _buildSection(String title, dynamic content) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 12.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 16.0,
color: Colors.black87,
),
),
const SizedBox(height: 8.0),
// This is where the content is dynamically rendered
..._buildContent(content),
],
),
);
}
// A helper method to handle different types of content
List<Widget> _buildContent(dynamic content) {
if (content is String) {
// If the content is a single string, return a single Text widget.
return [
Text(
content.isEmpty ? "" : content,
style: const TextStyle(fontSize: 15.0, color: Colors.black54),
),
];
} else if (content is List) {
// If the content is a list (like suggestions), map it to Text widgets.
return content.map<Widget>((item) {
// Safely access the 'desc' key from each item in the list
final String desc = (item as Map)['desc'] as String;
return Padding(
padding: const EdgeInsets.only(bottom: 4.0),
child: Text(
desc,
style: const TextStyle(fontSize: 15.0, color: Colors.black54),
),
);
}).toList();
}
// Return an empty list if content is of an unsupported type.
return [];
}
Widget _buildDivider() {
return Divider(height: 1, color: Colors.grey[300]);
}
/// ///
Widget _buildInputCard({ Widget _buildInputCard({
required String title, required String title,

Loading…
Cancel
Save