沈斌
2017-12-19 62266aa6ed5fd19fa1691089e6801e4450c4eaf1
updates
2 files added
96 ■■■■■ changed files
src/app/routes/users/installer/edit/edit.component.html 55 ●●●●● patch | view | raw | blame | history
src/app/routes/users/installer/edit/edit.component.ts 41 ●●●●● patch | view | raw | blame | history
src/app/routes/users/installer/edit/edit.component.html
New file
@@ -0,0 +1,55 @@
<div class="modal-header">
  <div class="modal-title">{{i.id > 0 ? '编辑' : '添加'}}-安装用户</div>
</div>
<form #f="ngForm" (ngSubmit)="save()" nz-form [nzType]="'horizontal'">
  <div nz-form-item nz-row class="mb-sm">
    <div nz-form-label nz-col [nzSpan]="4"><label>姓名</label></div>
    <div nz-form-control nz-col [nzSpan]="8">
      <input nz-input [(ngModel)]="i.name" name="name" maxlength="30" required />
    </div>
    <div nz-form-label nz-col [nzSpan]="4"><label>性别</label></div>
    <div nz-form-control nz-col [nzSpan]="8">
      <nz-select [(ngModel)]="i.sex" name="sex" required [nzAllowClear]="false">
        <nz-option
          *ngFor="let i of gender"
          [nzLabel]="i"
          [nzValue]="i">
        </nz-option>
      </nz-select>
    </div>
  </div>
  <div nz-form-item nz-row class="mb-sm">
    <div nz-form-label nz-col [nzSpan]="4"><label>账号</label></div>
    <div nz-form-control nz-col [nzSpan]="8">
      <input nz-input [(ngModel)]="i.mobile" name="mobile" maxlength="11" required />
    </div>
    <div nz-form-label nz-col [nzSpan]="4"><label>密码</label></div>
    <div nz-form-control nz-col [nzSpan]="8">
      <input nz-input [(ngModel)]="i.password" name="password" maxlength="50" required />
    </div>
  </div>
  <div nz-form-item nz-row class="mb-sm">
    <div nz-form-label nz-col [nzSpan]="4"><label>电子邮件</label></div>
    <div nz-form-control nz-col [nzSpan]="8">
      <input nz-input [(ngModel)]="i.email" name="email" required />
    </div>
    <div nz-form-label nz-col [nzSpan]="4"><label>微信号</label></div>
    <div nz-form-control nz-col [nzSpan]="8">
      <input nz-input [(ngModel)]="i.weixin" name="weixin" required />
    </div>
  </div>
  <div nz-form-item nz-row class="mb-sm">
    <div nz-form-label nz-col [nzSpan]="4"><label>组织</label></div>
    <div nz-form-control nz-col [nzSpan]="8">
      <input nz-input [(ngModel)]="i.organization" name="organization" maxlength="50" placeholder="50字以内" />
    </div>
    <div nz-form-label nz-col [nzSpan]="4"><label>昵称</label></div>
    <div nz-form-control nz-col [nzSpan]="8">
      <input nz-input [(ngModel)]="i.nickname" name="nickname" maxlength="20" placeholder="20字以内" />
    </div>
  </div>
  <div class="modal-footer">
    <button nz-button type="button" (click)="close()">关闭</button>
    <button nz-button [nzLoading]="http.loading" [nzType]="'primary'">保存</button>
  </div>
</form>
src/app/routes/users/installer/edit/edit.component.ts
New file
@@ -0,0 +1,41 @@
import { NzModalSubject, NzMessageService } from 'ng-zorro-antd';
import { HttpClient } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { _HttpClient } from '@delon/theme';
import { ModalHelper } from '@delon/theme';
@Component({
  selector: 'app-edit',
  templateUrl: './edit.component.html',
  styles: []
})
export class UserInstallerEditComponent implements OnInit {
  i: any;
  gender: string[] = [ '男', '女' ];
  constructor(
    private modalHelper: ModalHelper,
    private subject: NzModalSubject,
    public msgSrv: NzMessageService,
    public http: _HttpClient) { }
  ngOnInit() {
    if (this.i.id > 0) {
      this.http.get('./assets/pois.json').subscribe(res => this.i = res.data[0]);
    }
  }
  save() {
    this.http.get('./assets/pois.json').subscribe(() => {
      this.msgSrv.success('保存成功,只是模拟,实际未变更');
      this.subject.next('true');
      this.close();
    });
  }
  close() {
    this.subject.destroy();
  }
}