Explorar el Código

Merge branch '1.0.0' of ssh://gogs.soulhub.xyz:8525/JXZS/JXZS_TaskService into 1.0.0

lailin hace 4 años
padre
commit
8d97d85e3e

+ 13 - 0
taskservice/lib/Model/JXMemberModel.dart

@@ -16,4 +16,17 @@ class JXMemberModel {
   String addr;
   /*其他*/
   String remark;
+
+  Map<String, String> toMap(){
+    return {
+      'name': name,
+      'tel': tel,
+      'birth': birth,
+      'prov': prov,
+      'city': city,
+      'area': area,
+      'addr': addr,
+      'remark': remark,
+    };
+  }
 }

+ 32 - 0
taskservice/lib/database/DataBase.dart

@@ -0,0 +1,32 @@
+
+import 'package:database/sql.dart';
+import 'package:database_adapter_sqlite/database_adapter_sqlite.dart';
+import 'package:taskservice/Model/JXMemberModel.dart';
+import 'package:taskservice/Model/JXServiceModel.dart';
+
+class MyDataBase {
+  SqlClient _database;
+  SqlClientTableHelper _memberHelper;
+  SqlClientTableHelper _serviceHelper;
+  static MyDataBase _instance;
+
+  MyDataBase() {
+    _database = SQLite(path: 'path/to/database.db',).database().sqlClient;
+    _memberHelper = _database.table('members');
+    _serviceHelper = _database.table('services');
+  }
+
+  static MyDataBase getInstance(){
+    if(_instance == null) _instance = MyDataBase();
+    return _instance;
+  }
+
+  Future<void> saveMember(JXMemberModel jxMemberModel) async {
+    _memberHelper.insert(jxMemberModel.toMap());
+  }
+
+  Future<void> saveService(JXMemberModel jxMemberModel, JXServiceModel jxServiceModel) {
+  }
+
+
+}

+ 3 - 0
taskservice/lib/main.dart

@@ -1,5 +1,6 @@
 import 'package:flutter/cupertino.dart';
 import 'package:flutter/material.dart';
+import 'package:taskservice/src/acclist/page_acclist.dart';
 import 'package:taskservice/src/crtacc/page_crtacc.dart';
 import 'package:taskservice/src/home/home.dart';
 
@@ -16,6 +17,8 @@ class MyApp extends StatelessWidget {
         var name = settings.name;
         if(name == '$CreateAccPage') {
           return CupertinoPageRoute(builder: (context)=> CreateAccPage());
+        }else if(name == '$AccountListPage') {
+          return CupertinoPageRoute(builder: (context)=> AccountListPage());
         }
         return null;
       },

+ 9 - 0
taskservice/lib/src/acclist/page_acclist.dart

@@ -0,0 +1,9 @@
+
+import 'package:flutter/widgets.dart';
+
+class AccountListPage extends StatelessWidget {
+  @override
+  Widget build(BuildContext context) {
+    return Container();
+  }
+}

+ 8 - 2
taskservice/lib/src/crtacc/page_crtacc.dart

@@ -2,7 +2,9 @@ import 'package:flutter/cupertino.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter/widgets.dart';
 import 'package:taskservice/Common/JXColors.dart';
+import 'package:taskservice/Model/JXMemberModel.dart';
 import 'package:taskservice/Model/JXServiceModel.dart';
+import 'package:taskservice/database/DataBase.dart';
 
 class CreateAccPage extends StatefulWidget {
   @override
@@ -11,7 +13,7 @@ class CreateAccPage extends StatefulWidget {
 
 class _CreateAccPageState extends State<CreateAccPage> {
   List<JXServiceModel> services;
-
+  JXMemberModel member;
   @override
   void initState() {
     super.initState();
@@ -90,7 +92,7 @@ class _CreateAccPageState extends State<CreateAccPage> {
               ],
             ),
           ),
-          Container(width: MediaQuery.of(context).size.width, child: Text('保存', textAlign: TextAlign.center, style: TextStyle(fontSize: 16, color: JXColors.kFFFFFF),), padding: EdgeInsets.symmetric(vertical: 16), decoration: BoxDecoration(color: JXColors.k101E40),),
+          GestureDetector(onTap: onClickSave, child: Container(width: MediaQuery.of(context).size.width, child: Text('保存', textAlign: TextAlign.center, style: TextStyle(fontSize: 16, color: JXColors.kFFFFFF),), padding: EdgeInsets.symmetric(vertical: 16), decoration: BoxDecoration(color: JXColors.k101E40),)),
         ],
       ),
     ));
@@ -286,4 +288,8 @@ class _CreateAccPageState extends State<CreateAccPage> {
       ]),
     );
   }
+
+  void onClickSave() {
+    MyDataBase.getInstance().saveMember(member);
+  }
 }

+ 2 - 0
taskservice/lib/src/home/home.dart

@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
 import 'package:flutter/widgets.dart';
 import 'package:taskservice/Common/JXColors.dart';
 import 'package:taskservice/Model/JXMemberModel.dart';
+import 'package:taskservice/src/acclist/page_acclist.dart';
 import 'package:taskservice/src/crtacc/page_crtacc.dart';
 
 class MyHomePage extends StatefulWidget {
@@ -257,6 +258,7 @@ class _MyHomePageState extends State<MyHomePage> {
                       child: CupertinoButton(
                         onPressed: () {
                           print('会员列表');
+                          Navigator.of(context).pushNamed('$AccountListPage');
                         },
                         padding: EdgeInsets.all(0),
                         color: JXColors.k1F2529,

+ 2 - 2
taskservice/pubspec.yaml

@@ -24,8 +24,8 @@ dependencies:
   flutter:
     sdk: flutter
 
-  #数据库
-  database: ^0.3.3
+  database: any
+  database_adapter_sqlite: any
 
 
   # The following adds the Cupertino Icons font to your application.