Parcourir la source

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

lailin il y a 4 ans
Parent
commit
9deb0e6353

+ 10 - 9
taskservice/lib/Model/JXMemberModel.dart

@@ -4,6 +4,7 @@
 import 'JXServiceModel.dart';
 
 class JXMemberModel {
+  int id = -1;
   /*姓名*/
   String name = '';
 
@@ -27,14 +28,14 @@ class JXMemberModel {
 
   Map<String, dynamic> toMap() {
     return {
-      name: name,
-      tel: tel,
-      birth: birth,
-      prov: prov,
-      city: city,
-      area: area,
-      addr: addr,
-      remark: remark,
-    }.map((key, value) => key.isNotEmpty?MapEntry(key, value):null);
+      'name': name,
+      'tel': tel,
+      'birth': birth,
+      'prov': prov,
+      'city': city,
+      'area': area,
+      'addr': addr,
+      'remark': remark,
+    };
   }
 }

+ 4 - 4
taskservice/lib/Model/JXServiceModel.dart

@@ -21,12 +21,12 @@ class JXServiceModel {
 
   Map<String, dynamic> toMap() {
     return {
-      _id: _id,
-      kind: kind,
+      '_id': _id,
+      'kind': kind,
       'cycle': '$cycle',
-      cycleUnit: cycleUnit,
+      'cycleUnit': cycleUnit,
       'remindDay': remindDay,
-      remark: remark,
+      'remark': remark,
     };
   }
 }

+ 5 - 6
taskservice/lib/database/DataBase.dart

@@ -21,15 +21,14 @@ class MyDataBase {
 
  Future init() async {
     _database = await Sqlite.openDatabase(join((await Sqlite.getDatabasesPath()), 'data.db'));
-    List<Map<String, dynamic>> result = await _database.rawQuery("CREATE TABLE IF NOT EXISTS $tableMembers(id INTEGER PRIMARY KEY, name TEXT, age INTEGER)");
-    result.toString();
-   // _database.execute("CREATE TABLE $tableMembers(id INTEGER PRIMARY KEY, name TEXT, age INTEGER)",);
+    List<Map<String, dynamic>> result = await _database.rawQuery("CREATE TABLE IF NOT EXISTS $tableMembers(id INTEGER PRIMARY KEY, "
+        "name TEXT, tel TEXT, birth TEXT, prov TEXT, city TEXT, area TEXT, addr TEXT, remark TEXT)");
   }
 
   Future<List<JXMemberModel>> queryAllMembers() async {
-    List<Map<String , dynamic>> datas =  await _database.query("$tableMembers");
-    return datas.map((e) =>
-      JXMemberModel()
+    List<Map<String , dynamic>> data =  await _database.query("$tableMembers");
+    return data.map((e) =>
+       JXMemberModel()..id = e['id']..name = e['name']..tel = e['tel']
     ).toList();
 
   }

+ 19 - 11
taskservice/lib/src/acclist/page_acclist.dart

@@ -1,5 +1,6 @@
 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/database/DataBase.dart';
 import 'package:taskservice/src/custom_widgets.dart';
@@ -12,30 +13,37 @@ class AccountListPage extends StatefulWidget {
 class _AccountListPageState extends State<AccountListPage> {
   List<JXMemberModel> members = [];
   @override
-  Future<void> initState() async {
+   initState()  {
     super.initState();
-    var db = await MyDataBase.database;
-    members.addAll(await db.queryAllMembers());
-    setState(() {});
+     MyDataBase.database.then((db) async {
+       members.addAll(await db.queryAllMembers());
+       setState(() {});
+    });
   }
 
   @override
   Widget build(BuildContext context) {
     return MyScaffold(title: '会员列表', body: Column(children: <Widget>[
             SearchBar(hint: '快速筛选', onTextChanged: (value) {},),
-            Expanded(child: ListView.builder(itemBuilder: (context, index) {
-              if(index < members.length - 1) {
+            buildItems()
+          ],
+        ));
+  }
+
+  Expanded buildItems() {
+    return Expanded(child: Container(color: JXColors.kF0F0F0,
+            child: ListView.builder(physics:BouncingScrollPhysics(), itemBuilder: (context, index) {
+              if(index <= members.length - 1) {
                 JXMemberModel member = members[index];
-                return Container(child: Column(children: <Widget>[
-                  Row(children: <Widget>[
+                return Container(decoration:BoxDecoration(color: JXColors.kFFFFFF, borderRadius: BorderRadius.circular(8)),margin: EdgeInsets.only(left: 12, right: 12, bottom: 12),padding: EdgeInsets.all(12), child: Column(children: <Widget>[
+                  Row(mainAxisAlignment:MainAxisAlignment.spaceBetween,children: <Widget>[
                     Text(member.name),
                     Text(member.tel),
                   ],)
                 ],),);
               }
                 return null;
-            }),)
-          ],
-        ));
+            }),
+          ),);
   }
 }

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

@@ -77,7 +77,7 @@ class _CreateAccPageState extends State<CreateAccPage> {
     return MyScaffold(title: '新建会员', body: Column(
       children: <Widget>[
         Expanded(
-          child: CustomScrollView(
+          child: CustomScrollView(physics:BouncingScrollPhysics(),
             slivers: <Widget>[
               buildEditPart(),
               buildItemsPart(),
@@ -303,5 +303,6 @@ class _CreateAccPageState extends State<CreateAccPage> {
 
   Future<void> onClickSave() async {
     (await MyDataBase.database).saveMember(member);
+    Navigator.of(context).pop();
   }
 }