From 41fc80adb208e8bbf0bd0a65d9c3051b78fd4501 Mon Sep 17 00:00:00 2001
From: wangtengyu <wangtengyu>
Date: Fri, 09 Nov 2018 12:15:09 +0800
Subject: [PATCH] “重新提交”

---
 src/pages/access/components/checkbox/checkbox.sass |    0 
 src/pages/tabs/home/home.ts                        |    4 
 src/pages/access/components/checkbox/checkbox.html |    4 
 src/pages/access/components/select/select.ts       |   46 +++++++++
 src/assets/json/data.json                          |    1 
 src/app/app.module.ts                              |    1 
 src/pages/access/components/components.module.ts   |   24 ++++
 src/pages/access/components/select/select.html     |    8 +
 src/pages/access/components/input/input.html       |   20 +--
 /dev/null                                          |   25 -----
 src/pages/tabs/home/home.module.ts                 |    3 
 src/pages/access/components/select/select.scss     |    0 
 src/pages/access/components/input/input.ts         |   45 ++++++--
 src/pages/tabs/home/home.html                      |   70 +------------
 src/pages/access/components/checkbox/checkbox.ts   |   31 ++++++
 src/pages/tabs/tabs.module.ts                      |    3 
 src/kl/core/services/httpclient.ts                 |    9 +
 17 files changed, 176 insertions(+), 118 deletions(-)

diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 20f4187..b5f0ede 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -9,6 +9,7 @@
 import { SplashScreen } from '@ionic-native/splash-screen';
 import { KlCoreModule } from 'kl/core';
 
+
 @NgModule({
   declarations: [
     MyApp
diff --git a/src/assets/json/data.json b/src/assets/json/data.json
new file mode 100644
index 0000000..d99db03
--- /dev/null
+++ b/src/assets/json/data.json
@@ -0,0 +1 @@
+{"1":{"dataType":"1","id":"1","name":"name1"},"2":{"dataType":"2","id":"2","name":"name2"},"3":{"dataType":"3","id":"3","name":"name3","dataList":[{"id":"1","vel":"v1"},{"id":"2","vel":"v2"},{"id":"3","vel":"v3"},{"id":"4","vel":"v4"}]},"4":{"dataType":"4","id":"4","name":"name4"}}
\ No newline at end of file
diff --git a/src/kl/core/services/httpclient.ts b/src/kl/core/services/httpclient.ts
index 8c45197..3112527 100644
--- a/src/kl/core/services/httpclient.ts
+++ b/src/kl/core/services/httpclient.ts
@@ -4,6 +4,8 @@
 import { LoadingService } from './loading.service';
 import { ApiResult } from 'kl/model';
 
+
+
 @Injectable()
 export class HttpClient {
 
@@ -17,6 +19,13 @@
     this.getResponse(this.http.post(api, params), fun);
   }
 
+  getData(id: string, fun: Function) {
+    return this.http.get('assets/json/data.json').map((res: Response) => res.json()).subscribe(data => {
+      fun(data[id]);
+    });
+  }
+
+
   xhrPost(api, data, fun) {
     let xhr = new XMLHttpRequest();
     xhr.open('POST', api, false);
diff --git a/src/pages/access/components/checkbox/checkbox.html b/src/pages/access/components/checkbox/checkbox.html
new file mode 100644
index 0000000..6bb1cab
--- /dev/null
+++ b/src/pages/access/components/checkbox/checkbox.html
@@ -0,0 +1,4 @@
+<ion-item>
+  <ion-label>多选2</ion-label>
+  <ion-checkbox ></ion-checkbox>
+</ion-item>
diff --git a/src/pages/access/components/checkbox/checkbox.sass b/src/pages/access/components/checkbox/checkbox.sass
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/pages/access/components/checkbox/checkbox.sass
diff --git a/src/pages/access/components/checkbox/checkbox.ts b/src/pages/access/components/checkbox/checkbox.ts
new file mode 100644
index 0000000..13c17b3
--- /dev/null
+++ b/src/pages/access/components/checkbox/checkbox.ts
@@ -0,0 +1,31 @@
+import { Component, Input } from '@angular/core';
+import { HttpClient } from 'kl/core/services/httpclient';
+
+@Component({
+  selector: 'test-checkbox',
+  templateUrl: 'checkbox.html'
+})
+export class CheckboxComponent {
+
+  @Input()
+  id = '';
+  @Input()
+  data = {
+    id: '0',
+    name: 'err',
+    type: 1,
+    max: '',
+    minx: ''
+  };
+
+  constructor(private http: HttpClient) {}
+
+  getData() {
+    this.http.getData(this.id, res => this.data = res);
+  }
+
+  ngOnInit(): void {
+    this.getData();
+  }
+
+}
diff --git a/src/pages/access/components/components.module.ts b/src/pages/access/components/components.module.ts
new file mode 100644
index 0000000..d8753d6
--- /dev/null
+++ b/src/pages/access/components/components.module.ts
@@ -0,0 +1,24 @@
+import { NgModule } from '@angular/core';
+import { InputComponent } from './input/input';
+import { IonicPageModule } from 'ionic-angular';
+import { SelectComponent } from './select/select';
+import { CheckboxComponent } from './checkbox/checkbox';
+
+@NgModule({
+  declarations: [
+    InputComponent,
+    SelectComponent,
+    CheckboxComponent
+  ],
+  imports: [
+    IonicPageModule.forChild(InputComponent),
+    IonicPageModule.forChild(SelectComponent),
+    IonicPageModule.forChild(CheckboxComponent)
+  ],
+  exports: [
+    InputComponent,
+    SelectComponent,
+    CheckboxComponent
+  ]
+})
+export class ComponentsModule {}
diff --git a/src/pages/access/components/input/input.html b/src/pages/access/components/input/input.html
index 3f75aa8..b04b1c6 100644
--- a/src/pages/access/components/input/input.html
+++ b/src/pages/access/components/input/input.html
@@ -1,14 +1,6 @@
-<!-- Generated template for the InputComponent component -->
-
-<ion-header>
-
-  <ion-navbar>
-    <ion-title>input</ion-title>
-  </ion-navbar>
-
-</ion-header>
-<ion-content padding>
-  <ion-list col text-center>
-
-  </ion-list>
-</ion-content>
+<ion-row>
+  <ion-item *ngIf = 'data !== undefined'>
+      <ion-label fixed>{{data.name}}</ion-label>
+      <ion-input [type]="inputType" value=""></ion-input>
+  </ion-item>
+</ion-row>
diff --git a/src/pages/access/components/input/input.module.ts b/src/pages/access/components/input/input.module.ts
deleted file mode 100644
index 43c694c..0000000
--- a/src/pages/access/components/input/input.module.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import { NgModule } from '@angular/core';
-import { IonicPageModule } from 'ionic-angular';
-import { InputPage } from './input';
-import { AccessModule } from '../../access.module';
-
-@NgModule({
-  declarations: [
-    InputPage,
-  ],
-  imports: [
-    AccessModule,
-    IonicPageModule.forChild(InputPage),
-  ],
-})
-export class LoginPageModule { }
diff --git a/src/pages/access/components/input/input.ts b/src/pages/access/components/input/input.ts
index 0d2b9e5..66560db 100644
--- a/src/pages/access/components/input/input.ts
+++ b/src/pages/access/components/input/input.ts
@@ -1,5 +1,5 @@
-import { Component } from '@angular/core';
-import { IonicPage } from 'ionic-angular';
+import { Component, Input } from '@angular/core';
+import { HttpClient } from 'kl/core';
 
 /**
  * Generated class for the InputComponent component.
@@ -7,19 +7,40 @@
  * See https://angular.io/docs/ts/latest/api/core/index/ComponentMetadata-class.html
  * for more info on Angular Components.
  */
-
-
-@IonicPage({
-  name: 'access-input'
-})
 @Component({
-  selector: 'page-input',
-  templateUrl: 'input.html',
+  selector: 'test-input',
+  templateUrl: 'input.html'
 })
-export class InputPage {
+export class InputComponent {
 
-  text: string;
+  @Input()
+  id = '';
+  @Input()
+  data = {
+    id: '0',
+    name: 'err',
+    type: 1,
+    max: '',
+    minx: ''
+  };
 
-  constructor() {}
+  inputType = 'text';
+
+  constructor(private http: HttpClient) {}
+
+  getData() {
+    this.http.getData(this.id, res => {
+      this.data = res;
+      if (this.data.type === 1) {
+        this.inputType = 'text';
+      } else {
+        this.inputType = 'number';
+      }
+    });
+  }
+
+  ngOnInit(): void {
+    this.getData();
+  }
 
 }
diff --git a/src/pages/access/components/login/login.html b/src/pages/access/components/login/login.html
deleted file mode 100644
index db6e0c9..0000000
--- a/src/pages/access/components/login/login.html
+++ /dev/null
@@ -1,31 +0,0 @@
-<ion-header>
-
-  <ion-navbar>
-    <ion-title>login</ion-title>
-  </ion-navbar>
-
-</ion-header>
-
-
-<ion-content padding>
-    <ion-grid>
-      <ion-row>
-        <ion-col col text-center >
-            <img  src='../../../assets/img/loginuser.jpg'/>
-        </ion-col>
-      </ion-row>
-      <ion-row>
-        <ion-list col text-center>
-          <ion-item>
-            <ion-input type="text" placeholder="Username"></ion-input>
-          </ion-item>
-          <ion-item col text-center>
-            <ion-input type="password" placeholder="Password"></ion-input>
-          </ion-item>
-        </ion-list>
-      </ion-row>
-      <ion-row>
-          <button ion-button class="button-block" (click)="register()">login</button>
-      </ion-row>
-    </ion-grid>
-</ion-content>
diff --git a/src/pages/access/components/login/login.module.ts b/src/pages/access/components/login/login.module.ts
deleted file mode 100644
index 1228aad..0000000
--- a/src/pages/access/components/login/login.module.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import { NgModule } from '@angular/core';
-import { IonicPageModule } from 'ionic-angular';
-import { LoginPage } from './login';
-import { AccessModule } from '../../access.module';
-
-@NgModule({
-  declarations: [
-    LoginPage,
-  ],
-  imports: [
-    AccessModule,
-    IonicPageModule.forChild(LoginPage),
-  ],
-})
-export class LoginPageModule { }
diff --git a/src/pages/access/components/login/login.scss b/src/pages/access/components/login/login.scss
deleted file mode 100644
index 2b94c14..0000000
--- a/src/pages/access/components/login/login.scss
+++ /dev/null
@@ -1,3 +0,0 @@
-page-login {
-
-}
diff --git a/src/pages/access/components/login/login.ts b/src/pages/access/components/login/login.ts
deleted file mode 100644
index c525fe5..0000000
--- a/src/pages/access/components/login/login.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import { Component } from '@angular/core';
-import { IonicPage, NavController } from 'ionic-angular';
-
-import { LoginService } from '../../services';
-
-@IonicPage({
-  name: 'access-login'
-})
-@Component({
-  selector: 'page-login',
-  templateUrl: 'login.html',
-})
-export class LoginPage {
-
-  constructor(
-    public navCtrl: NavController,
-    private service: LoginService) {
-  }
-
-  ionViewDidLoad() {
-    this.service.login();
-  }
-
-  register() {
-    this.navCtrl.push('access-register');
-  }
-}
diff --git a/src/pages/access/components/register/register.html b/src/pages/access/components/register/register.html
deleted file mode 100644
index 89d8830..0000000
--- a/src/pages/access/components/register/register.html
+++ /dev/null
@@ -1,12 +0,0 @@
-<ion-header>
-
-  <ion-navbar>
-    <ion-title>register</ion-title>
-  </ion-navbar>
-
-</ion-header>
-
-
-<ion-content padding>
-  <button ion-button block (click)="back()">Back</button>
-</ion-content>
diff --git a/src/pages/access/components/register/register.module.ts b/src/pages/access/components/register/register.module.ts
deleted file mode 100644
index de588a6..0000000
--- a/src/pages/access/components/register/register.module.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import { NgModule } from '@angular/core';
-import { IonicPageModule } from 'ionic-angular';
-import { RegisterPage } from './register';
-import { AccessModule } from '../../access.module';
-
-@NgModule({
-  declarations: [
-    RegisterPage,
-  ],
-  imports: [
-    AccessModule,
-    IonicPageModule.forChild(RegisterPage),
-  ],
-})
-export class RegisterPageModule { }
diff --git a/src/pages/access/components/register/register.scss b/src/pages/access/components/register/register.scss
deleted file mode 100644
index 0d5201f..0000000
--- a/src/pages/access/components/register/register.scss
+++ /dev/null
@@ -1,3 +0,0 @@
-page-register {
-
-}
diff --git a/src/pages/access/components/register/register.ts b/src/pages/access/components/register/register.ts
deleted file mode 100644
index f1c48fb..0000000
--- a/src/pages/access/components/register/register.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import { Component } from '@angular/core';
-import { IonicPage, NavController, NavParams } from 'ionic-angular';
-
-import { LoginService } from '../../services';
-
-@IonicPage({
-  name: 'access-register'
-})
-@Component({
-  selector: 'page-register',
-  templateUrl: 'register.html',
-})
-export class RegisterPage {
-
-  constructor(public navCtrl: NavController, public navParams: NavParams, private service: LoginService) {
-  }
-
-  ionViewDidLoad() {
-    this.service.register();
-  }
-
-  back() {
-    this.navCtrl.pop();
-  }
-}
diff --git a/src/pages/access/components/select/select.html b/src/pages/access/components/select/select.html
new file mode 100644
index 0000000..d4984dc
--- /dev/null
+++ b/src/pages/access/components/select/select.html
@@ -0,0 +1,8 @@
+<ion-item *ngIf = 'data !== undefined'>
+    <ion-label>{{data.name}}</ion-label>
+    <ion-select *ngIf="data.dataList !== undefined" multiple="true" cancelText="取消" okText="确定">
+      <ng-container *ngFor="let item of data.dataList">
+        <ion-option  value="item.id"  >{{item.vel}}</ion-option>
+      </ng-container>
+    </ion-select>
+  </ion-item>
diff --git a/src/pages/access/components/select/select.scss b/src/pages/access/components/select/select.scss
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/pages/access/components/select/select.scss
diff --git a/src/pages/access/components/select/select.ts b/src/pages/access/components/select/select.ts
new file mode 100644
index 0000000..89dfbf3
--- /dev/null
+++ b/src/pages/access/components/select/select.ts
@@ -0,0 +1,46 @@
+import { Component, Input } from '@angular/core';
+import { HttpClient } from 'kl/core/services/httpclient';
+
+/**
+ * Generated class for the InputComponent component.
+ *
+ * See https://angular.io/docs/ts/latest/api/core/index/ComponentMetadata-class.html
+ * for more info on Angular Components.
+ */
+@Component({
+  selector: 'test-select',
+  templateUrl: 'select.html'
+})
+export class SelectComponent {
+
+  @Input()
+  id = '';
+
+  data: any = {
+    id: '0',
+    name: 'err',
+    type: 1,
+    max: '',
+    minx: '',
+    dataList: [
+      {id: '1', vel: 'err'},
+      {id: '1', vel: 'err'},
+      {id: '1', vel: 'err'}
+    ]
+  };
+
+
+  constructor(private http: HttpClient) {}
+
+  getData() {
+    this.http.getData(this.id, res => {
+      this.data = res;
+      console.log(this.data);
+    });
+  }
+
+  ngOnInit(): void {
+    this.getData();
+  }
+
+}
diff --git a/src/pages/tabs/home/home.html b/src/pages/tabs/home/home.html
index aa046a4..8d3cb70 100644
--- a/src/pages/tabs/home/home.html
+++ b/src/pages/tabs/home/home.html
@@ -1,73 +1,17 @@
 <ion-header>
 
   <ion-navbar>
-    <ion-title>login</ion-title>
+    <ion-title>home</ion-title>
   </ion-navbar>
 
 </ion-header>
 
 
 <ion-content padding>
-  <ion-grid>
-    <ion-row>
-      <ion-item>
-        <ion-input type="number" max="1" placeholder="单行文本1"></ion-input>
-      </ion-item>
-    </ion-row>
-    <ion-row>
-      <ion-item>
-        <ion-label fixed>单行文本2:</ion-label>
-        <ion-input type="text" value=""></ion-input>
-      </ion-item>
-    </ion-row>
-    <ion-row>
-      <ion-label fixed>搜索:</ion-label>
-      <ion-searchbar ></ion-searchbar>
-    </ion-row>
-    <ion-row>
-      <ion-item>
-        <ion-label>多选1</ion-label>
-        <ion-checkbox color="dark" checked="true"></ion-checkbox>
-      </ion-item>
-      <ion-item>
-        <ion-label>多选2</ion-label>
-        <ion-checkbox ></ion-checkbox>
-      </ion-item>
-    </ion-row>
-    <ion-row>
-      <ion-item>
-        <ion-label>时间</ion-label>
-        <ion-datetime displayFormat="YYYY/MM/DD" ></ion-datetime>
-      </ion-item>
-    </ion-row>
-    <ion-list>
-    <button ion-item  (click)="go()">
-      row1
-    </button>
+  <ion-list>
+     <test-input [id]='1'></test-input>
+     <test-input [id]='2'></test-input>
+     <test-select [id]='3'></test-select>
+     <test-checkbox [id]='4'></test-checkbox>
   </ion-list>
-
-
-
-    <ion-item>
-      <ion-label>下拉(多选)1</ion-label>
-      <ion-select multiple="true" cancelText="Nah" okText="Okay!">
-        <ion-option value="bacon" selected="true">Bacon</ion-option>
-        <ion-option value="olives">Black Olives</ion-option>
-        <ion-option value="xcheese" selected="true">Extra Cheese</ion-option>
-        <ion-option value="peppers">Green Peppers</ion-option>
-        <ion-option value="mushrooms">Mushrooms</ion-option>
-        <ion-option value="onions">Onions</ion-option>
-        <ion-option value="pepperoni">Pepperoni</ion-option>
-        <ion-option value="pineapple">Pineapple</ion-option>
-        <ion-option value="sausage">Sausage</ion-option>
-        <ion-option value="Spinach">Spinach</ion-option>
-      </ion-select>
-    </ion-item>
-    <ion-row>
-      <ion-item>
-        <ion-label>多行文本</ion-label>
-        <ion-textarea autoresize="100"></ion-textarea>
-      </ion-item>
-    </ion-row>
-  </ion-grid>
-</ion-content>
+</ion-content>
\ No newline at end of file
diff --git a/src/pages/tabs/home/home.module.ts b/src/pages/tabs/home/home.module.ts
index f04f121..92225ed 100644
--- a/src/pages/tabs/home/home.module.ts
+++ b/src/pages/tabs/home/home.module.ts
@@ -1,12 +1,13 @@
 import { NgModule } from '@angular/core';
 import { IonicPageModule } from 'ionic-angular';
 import { HomePage } from './home';
-
+import { ComponentsModule } from '../../access/components/components.module';
 @NgModule({
   declarations: [
     HomePage,
   ],
   imports: [
+    ComponentsModule,
     IonicPageModule.forChild(HomePage),
   ],
 })
diff --git a/src/pages/tabs/home/home.ts b/src/pages/tabs/home/home.ts
index cb2b88d..9700fc6 100644
--- a/src/pages/tabs/home/home.ts
+++ b/src/pages/tabs/home/home.ts
@@ -1,7 +1,6 @@
 import { Component } from '@angular/core';
 import { IonicPage, NavController, NavParams } from 'ionic-angular';
 
-
 @IonicPage({
   name: 'home'
 })
@@ -11,8 +10,7 @@
 })
 export class HomePage {
 
-  constructor(public navCtrl: NavController, public navParams: NavParams) {
-  }
+  constructor(public navCtrl: NavController, public navParams: NavParams) {}
 
 
   ionViewDidLoad() {
diff --git a/src/pages/tabs/tabs.module.ts b/src/pages/tabs/tabs.module.ts
index 6fa04dc..701467a 100644
--- a/src/pages/tabs/tabs.module.ts
+++ b/src/pages/tabs/tabs.module.ts
@@ -2,6 +2,8 @@
 import { IonicPageModule } from 'ionic-angular';
 import { TabsPage } from './tabs';
 
+
+
 @NgModule({
   declarations: [
     TabsPage,
@@ -9,5 +11,6 @@
   imports: [
     IonicPageModule.forChild(TabsPage),
   ],
+  exports: []
 })
 export class TabsPageModule { }

--
Gitblit v1.8.0