Ver Fonte

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

lailin há 4 anos atrás
pai
commit
c8e37adfe7

BIN
taskservice/.gradle/5.2.1/fileChanges/last-build.bin


BIN
taskservice/.gradle/5.2.1/fileHashes/fileHashes.lock


+ 0 - 0
taskservice/.gradle/5.2.1/gc.properties


BIN
taskservice/.gradle/buildOutputCleanup/buildOutputCleanup.lock


+ 2 - 0
taskservice/.gradle/buildOutputCleanup/cache.properties

@@ -0,0 +1,2 @@
+#Wed Aug 26 21:56:11 CST 2020
+gradle.version=5.2.1

+ 0 - 0
taskservice/.gradle/vcs-1/gc.properties


+ 23 - 20
taskservice/lib/Model/JXMemberModel.dart

@@ -1,32 +1,35 @@
-
 /*
 用户信息模型
 * */
 class JXMemberModel {
   /*姓名*/
-  String name;
+  String name = '';
+
   /*电话*/
-  String tel;
+  String tel  = '';
+
   /*生日信息*/
-  String birth;
+  String birth  = '';
+
   /*地址*/
-  String prov;
-  String city;
-  String area;
-  String addr;
+  String prov = '';
+  String city = '';
+  String area = '';
+  String addr = '';
+
   /*其他*/
-  String remark;
+  String remark = '';
 
-  Map<String, String> toMap(){
+  Map<String, dynamic> toMap() {
     return {
-      'name': name,
-      'tel': tel,
-      'birth': birth,
-      'prov': prov,
-      'city': city,
-      'area': area,
-      'addr': addr,
-      'remark': remark,
-    };
+      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);
   }
-}
+}

+ 12 - 2
taskservice/lib/Model/JXServiceModel.dart

@@ -1,4 +1,3 @@
-
 /*
 服务信息模型
 * */
@@ -19,4 +18,15 @@ class JXServiceModel {
 
   /*备注*/
   String remark;
-}
+
+  Map<String, dynamic> toMap() {
+    return {
+      _id: _id,
+      kind: kind,
+      'cycle': '$cycle',
+      cycleUnit: cycleUnit,
+      'remindDay': remindDay,
+      remark: remark,
+    };
+  }
+}

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

@@ -1,32 +1,49 @@
 
-import 'package:database/sql.dart';
-import 'package:database_adapter_sqlite/database_adapter_sqlite.dart';
+import 'package:path/path.dart';
+import 'package:sqflite/sqflite.dart' as Sqlite;
+import 'package:sqflite/sqflite.dart';
 import 'package:taskservice/Model/JXMemberModel.dart';
 import 'package:taskservice/Model/JXServiceModel.dart';
 
 class MyDataBase {
-  SqlClient _database;
-  SqlClientTableHelper _memberHelper;
-  SqlClientTableHelper _serviceHelper;
   static MyDataBase _instance;
+  Database _database;
+  String tableMembers = 'members';
+  String tableServices = 'services';
+
+  static Future<MyDataBase> get database async {
+    if(_instance == null){
+      _instance = MyDataBase();
+      await _instance.init();
+    }
+    return _instance;
+  }
 
-  MyDataBase() {
-    _database = SQLite(path: 'path/to/database.db',).database().sqlClient;
-    _memberHelper = _database.table('members');
-    _serviceHelper = _database.table('services');
+ 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)",);
   }
 
-  static MyDataBase getInstance(){
-    if(_instance == null) _instance = MyDataBase();
-    return _instance;
+  Future<List<JXMemberModel>> queryAllMembers() async {
+    List<Map<String , dynamic>> datas =  await _database.query("$tableMembers");
+    return datas.map((e) =>
+      JXMemberModel()
+    ).toList();
+
   }
 
   Future<void> saveMember(JXMemberModel jxMemberModel) async {
-    _memberHelper.insert(jxMemberModel.toMap());
+    await _database.insert(
+      tableMembers,
+      jxMemberModel.toMap(),
+      conflictAlgorithm: ConflictAlgorithm.replace,
+    );
   }
 
-  Future<void> saveService(JXMemberModel jxMemberModel, JXServiceModel jxServiceModel) {
-  }
 
+  Future<void> saveService(JXMemberModel jxMemberModel, JXServiceModel jxServiceModel) {
 
+  }
 }

+ 35 - 3
taskservice/lib/src/acclist/page_acclist.dart

@@ -1,9 +1,41 @@
-
+import 'package:flutter/material.dart';
 import 'package:flutter/widgets.dart';
+import 'package:taskservice/Model/JXMemberModel.dart';
+import 'package:taskservice/database/DataBase.dart';
+import 'package:taskservice/src/custom_widgets.dart';
+
+class AccountListPage extends StatefulWidget {
+  @override
+  _AccountListPageState createState() => _AccountListPageState();
+}
+
+class _AccountListPageState extends State<AccountListPage> {
+  List<JXMemberModel> members = [];
+  @override
+  Future<void> initState() async {
+    super.initState();
+    var db = await MyDataBase.database;
+    members.addAll(await db.queryAllMembers());
+    setState(() {});
+  }
 
-class AccountListPage extends StatelessWidget {
   @override
   Widget build(BuildContext context) {
-    return Container();
+    return MyScaffold(title: '会员列表', body: Column(children: <Widget>[
+            SearchBar(hint: '快速筛选', onTextChanged: (value) {},),
+            Expanded(child: ListView.builder(itemBuilder: (context, index) {
+              if(index < members.length - 1) {
+                JXMemberModel member = members[index];
+                return Container(child: Column(children: <Widget>[
+                  Row(children: <Widget>[
+                    Text(member.name),
+                    Text(member.tel),
+                  ],)
+                ],),);
+              }
+                return null;
+            }),)
+          ],
+        ));
   }
 }

+ 56 - 44
taskservice/lib/src/crtacc/page_crtacc.dart

@@ -5,6 +5,7 @@ import 'package:taskservice/Common/JXColors.dart';
 import 'package:taskservice/Model/JXMemberModel.dart';
 import 'package:taskservice/Model/JXServiceModel.dart';
 import 'package:taskservice/database/DataBase.dart';
+import 'package:taskservice/src/custom_widgets.dart';
 
 class CreateAccPage extends StatefulWidget {
   @override
@@ -14,6 +15,11 @@ class CreateAccPage extends StatefulWidget {
 class _CreateAccPageState extends State<CreateAccPage> {
   List<JXServiceModel> services;
   JXMemberModel member;
+  TextEditingController nameController = TextEditingController();
+  TextEditingController phoneController = TextEditingController();
+  TextEditingController birthController = TextEditingController();
+  TextEditingController addrConotroller = TextEditingController();
+  TextEditingController remarkConotroller = TextEditingController();
   @override
   void initState() {
     super.initState();
@@ -49,52 +55,58 @@ class _CreateAccPageState extends State<CreateAccPage> {
         ..cycleUnit = '个月'
         ..remark = '备注111111',
     ];
+
+    member = JXMemberModel();
+    nameController.addListener(onInfoChanged);
+    phoneController.addListener(onInfoChanged);
+    birthController.addListener(onInfoChanged);
+    addrConotroller.addListener(onInfoChanged);
+    remarkConotroller.addListener(onInfoChanged);
+  }
+
+  void onInfoChanged() {
+    member.name = nameController.value.text;
+    member.tel = phoneController.value.text;
+    member.birth = birthController.value.text;
+    member.addr = addrConotroller.value.text;
+    member.remark = remarkConotroller.value.text;
   }
 
   @override
   Widget build(BuildContext context) {
-
-    return SafeArea(
-        child: Scaffold(
-      appBar: AppBar(
-        centerTitle: true,
-        title: Text('新建会员'),
-        backgroundColor: JXColors.k1F2529,
-      ),
-      body: Column(
-        children: <Widget>[
-          Expanded(
-            child: CustomScrollView(
-              slivers: <Widget>[
-                buildEditPart(),
-                buildItemsPart(),
-                SliverToBoxAdapter(
-                  child: Container(
-                    decoration: BoxDecoration(
-                        borderRadius: BorderRadius.circular(12),
-                        border: Border.all(
-                          width: 1,
-                        )),
-                    margin: EdgeInsets.symmetric(vertical: 12, horizontal: 80),
-                    child: InkWell(
-                      onTap: () => null,
-                      child: Container(
-                        padding: EdgeInsets.all(8),
-                        child: Text(
-                          '添加服务',
-                          textAlign: TextAlign.center,
-                          style: TextStyle(fontSize: 18),
-                        ),
+    return MyScaffold(title: '新建会员', body: Column(
+      children: <Widget>[
+        Expanded(
+          child: CustomScrollView(
+            slivers: <Widget>[
+              buildEditPart(),
+              buildItemsPart(),
+              SliverToBoxAdapter(
+                child: Container(
+                  decoration: BoxDecoration(
+                      borderRadius: BorderRadius.circular(12),
+                      border: Border.all(
+                        width: 1,
+                      )),
+                  margin: EdgeInsets.symmetric(vertical: 12, horizontal: 80),
+                  child: InkWell(
+                    onTap: () => null,
+                    child: Container(
+                      padding: EdgeInsets.all(8),
+                      child: Text(
+                        '添加服务',
+                        textAlign: TextAlign.center,
+                        style: TextStyle(fontSize: 18),
                       ),
                     ),
                   ),
                 ),
-              ],
-            ),
+              ),
+            ],
           ),
-          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),)),
-        ],
-      ),
+        ),
+        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),)),
+      ],
     ));
   }
 
@@ -151,7 +163,7 @@ class _CreateAccPageState extends State<CreateAccPage> {
             Expanded(
                 child: Padding(
               padding: const EdgeInsets.symmetric(horizontal: 20),
-              child: TextField(),
+              child: TextField(controller: nameController,),
             )),
           ],
         ),
@@ -168,7 +180,7 @@ class _CreateAccPageState extends State<CreateAccPage> {
             Expanded(
                 child: Padding(
               padding: const EdgeInsets.symmetric(horizontal: 20),
-              child: TextField(),
+              child: TextField(controller: phoneController,),
             )),
           ],
         ),
@@ -185,7 +197,7 @@ class _CreateAccPageState extends State<CreateAccPage> {
             Expanded(
                 child: Padding(
               padding: const EdgeInsets.symmetric(horizontal: 20),
-              child: TextField(),
+              child: TextField(controller: birthController,),
             )),
           ],
         ),
@@ -240,7 +252,7 @@ class _CreateAccPageState extends State<CreateAccPage> {
                       border: Border.all(color: JXColors.kE6E6E6, width: 2),
                       borderRadius: BorderRadius.circular(12)),
                   height: 150,
-                  child: TextField(decoration: null)),
+                  child: TextField(decoration: null, controller: addrConotroller,)),
             )),
           ],
         ),
@@ -270,7 +282,7 @@ class _CreateAccPageState extends State<CreateAccPage> {
                       border: Border.all(color: JXColors.kE6E6E6, width: 2),
                       borderRadius: BorderRadius.circular(12)),
                   height: 150,
-                  child: TextField(decoration: null)),
+                  child: TextField(decoration: null, controller: remarkConotroller,)),
             )),
           ],
         ),
@@ -289,7 +301,7 @@ class _CreateAccPageState extends State<CreateAccPage> {
     );
   }
 
-  void onClickSave() {
-    MyDataBase.getInstance().saveMember(member);
+  Future<void> onClickSave() async {
+    (await MyDataBase.database).saveMember(member);
   }
 }

+ 81 - 0
taskservice/lib/src/custom_widgets.dart

@@ -0,0 +1,81 @@
+import 'package:flutter/material.dart';
+import 'package:flutter/widgets.dart';
+import 'package:taskservice/Common/JXColors.dart';
+
+class MyScaffold extends StatelessWidget {
+  final Widget body;
+  final String title;
+  MyScaffold({@required this.title, @required this.body});
+  @override
+  Widget build(BuildContext context) {
+    return SafeArea(
+        child: Scaffold(
+          appBar: AppBar(
+            centerTitle: true,
+            title: Text(title),
+            backgroundColor: JXColors.k1F2529,
+          ),
+          body: body,
+        ));
+  }
+}
+
+class SearchBar extends StatefulWidget {
+  final Function(String value) onTextChanged;
+  final String hint;
+  final FocusNode focusNode;
+  SearchBar({this.onTextChanged, this.hint, this.focusNode});
+  @override
+  _SearchBarState createState() => _SearchBarState();
+}
+
+class _SearchBarState extends State<SearchBar> {
+  @override
+  Widget build(BuildContext context) {
+    return Container(
+      color: JXColors.kF0F0F0,
+      padding: EdgeInsets.fromLTRB(12.0, 8, 12.0, 8),
+      child: Container(
+        alignment: Alignment.center,
+        decoration: BoxDecoration(
+          color: JXColors.kE6E6E6,
+          borderRadius: BorderRadius.circular(12.0),
+          border: Border.all(color: JXColors.kE6E6E6, width: 1),
+        ),
+        height: 44.0,
+        child: Row(children: <Widget>[
+          SizedBox(
+            width: 12,
+          ),
+          Icon(
+            Icons.search,
+            size: 24.0,
+          ),
+          SizedBox(
+            width: 6,
+          ),
+          Expanded(
+            child: TextField(
+              maxLines: 1,
+              focusNode: widget.focusNode,
+              obscureText: false,
+              cursorColor: JXColors.k1F2529,
+              decoration: InputDecoration(
+                border: InputBorder.none,
+                hintText: widget.hint,
+                labelStyle: TextStyle(
+                  color: JXColors.k2E3032,
+                  fontSize: 24.0,
+                ),
+              ),
+              onChanged: widget.onTextChanged,
+            ),
+          ),
+          SizedBox(
+            width: 12,
+          ),
+        ]),
+      ),
+    );
+  }
+}

+ 67 - 64
taskservice/lib/src/home/home.dart

@@ -5,6 +5,7 @@ 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';
+import 'package:taskservice/src/custom_widgets.dart';
 
 class MyHomePage extends StatefulWidget {
   MyHomePage({Key key, this.title}) : super(key: key);
@@ -50,7 +51,7 @@ class _MyHomePageState extends State<MyHomePage> {
         ..addr = '广州12',
     ];
 
-    for(JXMemberModel model in _basesource) {
+    for (JXMemberModel model in _basesource) {
       _cells.add(theCellBuilder(context, model));
     }
   }
@@ -130,7 +131,7 @@ class _MyHomePageState extends State<MyHomePage> {
           ),
           SizedBox(width: 6,),
           CupertinoButton(
-            onPressed: (){
+            onPressed: () {
               /*清空输入框*/
               setState(() {
                 _searchController.clear();
@@ -227,72 +228,74 @@ class _MyHomePageState extends State<MyHomePage> {
   @override
   Widget build(BuildContext context) {
     return GestureDetector(
-        onTap: () {
-          FocusScope.of(context).requestFocus(blankNode);
-        },
-        child: Scaffold(
-          appBar: AppBar(
-            title: Text(widget.title),
-          ),
-          body: SafeArea(
+      onTap: () {
+        FocusScope.of(context).requestFocus(blankNode);
+      },
+      child: Scaffold(
+        appBar: AppBar(
+          title: Text(widget.title),
+        ),
+        body: SafeArea(
             child: Column(
               mainAxisAlignment: MainAxisAlignment.start,
               children: <Widget>[
-                theFilterBar(),
-                Expanded(
-                  child: Container(
-                    color: JXColors.kF0F0F0,
-                    child: ListView.builder(
-                      padding: EdgeInsets.only(left: 12.0, right: 12.0),
-                      itemCount: _cells.length,
-                      itemExtent: 92.0,
-                      itemBuilder: (BuildContext context, int row) {
-                        return _cells[row];
-                      },
-                    ),
+            SearchBar(hint: '快速筛选', onTextChanged: (value) {
+              filterMember();
+            }, focusNode: blankNode,),
+            Expanded(
+                child: Container(
+                  color: JXColors.kF0F0F0,
+                  child: ListView.builder(
+                    padding: EdgeInsets.only(left: 12.0, right: 12.0),
+                    itemCount: _cells.length,
+                    itemExtent: 92.0,
+                    itemBuilder: (BuildContext context, int row) {
+                      return _cells[row];
+                    },
                   ),
-                ),
-                Row(
-                  mainAxisAlignment: MainAxisAlignment.start,
-                  children: <Widget>[
-                    Expanded(
-                      child: CupertinoButton(
-                        onPressed: () {
-                          Navigator.of(context).pushNamed('$CreateAccPage');
-                        },
-                        padding: EdgeInsets.all(0),
-                        color: JXColors.kFFFFFF,
-                        borderRadius: BorderRadius.all(Radius.circular(0)),
-                        child: Text(
-                          '新建会员',
-                          style: TextStyle(
-                            fontSize: 14,
-                            color: JXColors.k101E40,
-                          ),
-                        ),
-                      ),
-                    ),
-                    Expanded(
-                      child: CupertinoButton(
-                        onPressed: () {
-                          print('会员列表');
-                          Navigator.of(context).pushNamed('$AccountListPage');
-                        },
-                        padding: EdgeInsets.all(0),
-                        color: JXColors.k1F2529,
-                        borderRadius: BorderRadius.all(Radius.circular(0)),
-                        child: Text('会员列表',
-                            style: TextStyle(
-                              fontSize: 14,
-                              color: JXColors.kFFFFFF,
-                            )),
-                      ),
-                    ),
-                  ],
-                )
-              ],
-            ),
+                )),
+        Row(
+        mainAxisAlignment: MainAxisAlignment.start,
+        children: <Widget>[
+        Expanded(
+        child: CupertinoButton(
+            onPressed: ()
+        {
+        Navigator.of(context).pushNamed('$CreateAccPage');
+        },
+        padding: EdgeInsets.all(0),
+        color: JXColors.kFFFFFF,
+        borderRadius: BorderRadius.all(Radius.circular(0)),
+        child: Text(
+          '新建会员',
+          style: TextStyle(
+            fontSize: 14,
+            color: JXColors.k101E40,
           ),
-        ));
+        ),
+      ),
+    ),
+    Expanded(
+    child: CupertinoButton(
+    onPressed: () {
+    print('会员列表');
+    Navigator.of(context).pushNamed('$AccountListPage');
+    },
+    padding: EdgeInsets.all(0),
+    color: JXColors.k1F2529,
+    borderRadius: BorderRadius.all(Radius.circular(0)),
+    child: Text('会员列表',
+    style: TextStyle(
+    fontSize: 14,
+    color: JXColors.kFFFFFF,
+    )),
+    ),
+    ),
+    ],
+    )
+    ],
+    ),
+    ),
+    ));
   }
 }

+ 2 - 4
taskservice/pubspec.yaml

@@ -23,10 +23,8 @@ environment:
 dependencies:
   flutter:
     sdk: flutter
-
-  database: any
-  database_adapter_sqlite: any
-
+  sqflite:
+  path:
 
   # The following adds the Cupertino Icons font to your application.
   # Use with the CupertinoIcons class for iOS style icons.