xufenglei
2018-01-10 0e184df30a1d07a30d412e2d5fd91bc37711455d
安装用户 管理
9 files modified
242 ■■■■ changed files
src/app/routes/systems/account/account-edit/account-edit.component.html 8 ●●●● patch | view | raw | blame | history
src/app/routes/systems/account/account-edit/account-edit.component.ts 37 ●●●●● patch | view | raw | blame | history
src/app/routes/systems/account/account.component.ts 4 ●●●● patch | view | raw | blame | history
src/app/routes/users/alarm-user/alarm-user-edit/alarm-user-edit.component.html 2 ●●● patch | view | raw | blame | history
src/app/routes/users/alarm-user/alarm-user-edit/alarm-user-edit.component.ts 31 ●●●● patch | view | raw | blame | history
src/app/routes/users/installer/edit/edit.component.html 36 ●●●●● patch | view | raw | blame | history
src/app/routes/users/installer/edit/edit.component.ts 60 ●●●●● patch | view | raw | blame | history
src/app/routes/users/installer/installer.component.html 12 ●●●●● patch | view | raw | blame | history
src/app/routes/users/installer/installer.component.ts 52 ●●●●● patch | view | raw | blame | history
src/app/routes/systems/account/account-edit/account-edit.component.html
@@ -13,10 +13,10 @@
            <div nz-form-explain *ngIf="validateForm.controls.accountName.dirty && validateForm.controls.accountName.hasError('unique')">账号不允许重复!</div>
        </div>
        <div nz-form-label nz-col [nzSpan]="4">
            <label nz-form-item-required>电话</label>
            <label>电话</label>
        </div>
        <div nz-form-control nz-col [nzSpan]="8" nzHasFeedback>
            <input nz-input maxlength="11" formControlName="mobile" required/>
            <input nz-input maxlength="11" formControlName="mobile" />
        </div>
    </div>
    <div nz-form-item nz-row class="mb-sm">
@@ -35,9 +35,9 @@
    </div>
    <div nz-form-item nz-row class="mb-sm">
        <div nz-form-label nz-col [nzSpan]="4">
            <label>组织</label>
            <label nz-form-item-required>组织</label>
        </div>
        <div nz-form-control nz-col [nzSpan]="8" >
        <div nz-form-control nz-col [nzSpan]="8" nzHasFeedback>
            <nz-select style="width: 290px;" nzAllowClear [nzPlaceHolder]="'input search text'" [nzFilter]="false" nzShowSearch 
                formControlName="organizationId" (nzSearchChange)="searchChange($event)" [nzNotFoundContent]="'无法找到'" > 
                <nz-option *ngFor="let option of searchOptions"  [nzLabel]="option['name']" [nzValue]="option['id']"> </nz-option> 
src/app/routes/systems/account/account-edit/account-edit.component.ts
@@ -24,30 +24,33 @@
  }
  ngOnInit() {
    const account = this.account;
    this.validateForm = this.formBuilder.group({
      accountName: [this.account.accountName],
      mobile: [this.account.mobile],
      email: [this.account.email],
      weixin: [this.account.weixin],
      organizationId: [this.account.organizationId],
      expireTime: [this.account.expireTime],
      id: [this.account.id]
      accountName: [account.accountName],
      mobile: [account.mobile],
      email: [account.email],
      weixin: [account.weixin],
      organizationId: [account.organizationId],
      expireTime: [account.expireTime],
      id: [account.id]
    });
    this.searchOptions = this.account.organization ? [this.account.organization] : [];
    this.searchOptions = account.organization ? [account.organization] : [];
  }
  save() {
    if (this.validateForm.valid) {
      for (const i in this.validateForm.controls) {
        this.validateForm.controls[i].disable();
    const validateForm = this.validateForm;
    const controls = validateForm.controls;
    if (validateForm.valid) {
      for (const i in controls) {
        controls[i].disable();
      }
      this.http.post(environment.SERVER_BASH_URL + '/account/account', this.validateForm.value).subscribe(() => {
      this.http.post(environment.SERVER_BASH_URL + '/account/account', validateForm.value).subscribe(() => {
        this.subject.next('true');
        this.close();
      });
    } else {
      for (const i in this.validateForm.controls) {
        this.validateForm.controls[i].markAsDirty();
      for (const i in controls) {
        controls[i].markAsDirty();
      }
    }
  }
@@ -57,14 +60,15 @@
  }
  check(accountName) {
    const controlsAccountName = this.validateForm.controls.accountName;
    if (accountName) {
      this.http.get(environment.SERVER_BASH_URL + '/account/' + accountName).subscribe((res: any) => {
        if (res.data > 0) {
          this.validateForm.controls.accountName.setErrors({unique: true});
          controlsAccountName.setErrors({unique: true});
        }
      });
    } else {
      this.validateForm.controls.accountName.setErrors({required: true});
      controlsAccountName.setErrors({required: true});
    }
  }
@@ -78,4 +82,5 @@
      }
    }
  }
}
src/app/routes/systems/account/account.component.ts
@@ -13,7 +13,7 @@
export class AccountComponent implements OnInit {
  isDeleteOptions = [
  private isDeleteOptions = [
    {value: '1', label: '是'},
    {value: '0', label: '否'}
  ];
@@ -98,7 +98,7 @@
      }
    });
  }
  checkAll(value: boolean) {
    this.data.forEach(i => {
      if (i.isDelete == '1') {
src/app/routes/users/alarm-user/alarm-user-edit/alarm-user-edit.component.html
@@ -1,7 +1,7 @@
<div class="modal-header">
    <div class="modal-title">{{alarmUser.id > 0 ? '编辑' : '添加'}} - 报警用户</div>
</div>
<form #f="ngForm" (ngSubmit)="save()" nz-form [nzType]="'horizontal'" [formGroup]="validateForm">
<form (ngSubmit)="save()" nz-form [nzType]="'horizontal'" [formGroup]="validateForm">
    <div nz-form-item nz-row class="mb-sm">
        <div nz-form-label nz-col [nzSpan]="4">
            <label>用户名</label>
src/app/routes/users/alarm-user/alarm-user-edit/alarm-user-edit.component.ts
@@ -22,30 +22,33 @@
  ) {}
  ngOnInit() {
    const alarmUser = this.alarmUser;
    this.validateForm = this.formBuilder.group({
      name: [this.alarmUser.name],
      mobile: [this.alarmUser.mobile, [Validators.pattern("^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\\d{8}$")]],
      email: [this.alarmUser.email,[Validators.email]],
      weixin: [this.alarmUser.weixin],
      organizationId: [this.alarmUser.organizationId],
      expireTime: [this.alarmUser.expireTime],
      id: [this.alarmUser.id]
      name: [alarmUser.name],
      mobile: [alarmUser.mobile, [Validators.pattern("^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\\d{8}$")]],
      email: [alarmUser.email, [Validators.email]],
      weixin: [alarmUser.weixin],
      organizationId: [alarmUser.organizationId],
      expireTime: [alarmUser.expireTime],
      id: [alarmUser.id]
    });
    this.searchOptions = this.alarmUser.organization ? [this.alarmUser.organization] : [];
    this.searchOptions = alarmUser.organization ? [alarmUser.organization] : [];
  }
  save() {
    if (this.validateForm.valid) {
      for (const i in this.validateForm.controls) {
        this.validateForm.controls[i].disable();
    const validateForm = this.validateForm;
    const controls = validateForm.controls;
    if (validateForm.valid) {
      for (const i in controls) {
        controls[i].disable();
      }
      this.http.post(environment.SERVER_BASH_URL + '/alarmUser/alarmUser', this.validateForm.value).subscribe(() => {
      this.http.post(environment.SERVER_BASH_URL + '/alarmUser/alarmUser', validateForm.value).subscribe(() => {
        this.subject.next('true');
        this.close();
      });
    } else {
      for (const i in this.validateForm.controls) {
        this.validateForm.controls[i].markAsDirty();
      for (const i in controls) {
        controls[i].markAsDirty();
      }
    }
  }
src/app/routes/users/installer/edit/edit.component.html
@@ -1,48 +1,36 @@
<div class="modal-header">
  <div class="modal-title">{{user.id > 0 ? '编辑' : '添加'}} - 安装用户</div>
</div>
<form #f="ngForm" (ngSubmit)="save()" nz-form [nzType]="'horizontal'">
<form (ngSubmit)="save()" nz-form [nzType]="'horizontal'"  [formGroup]="validateForm">
  <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)]="user.name" name="name" maxlength="30" required />
    <div nz-form-label nz-col [nzSpan]="4"><label nz-form-item-required>姓名</label></div>
    <div nz-form-control nz-col [nzSpan]="8" nzHasFeedback>
      <input nz-input formControlName="name" maxlength="30" 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)]="user.mobile" name="mobile" maxlength="11" required />
    <div nz-form-label nz-col [nzSpan]="4"><label nz-form-item-required>账号/电话</label></div>
    <div nz-form-control nz-col [nzSpan]="8" nzHasFeedback>
      <input nz-input formControlName="mobile" maxlength="11" 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)]="user.email" name="email" required />
      <input nz-input formControlName="email"/>
    </div>
    <div nz-form-label nz-col [nzSpan]="4"><label>微信号</label></div>
    <div nz-form-control nz-col [nzSpan]="8">
      <input nz-input [(ngModel)]="user.weixin" name="weixin" />
      <input nz-input formControlName="weixin" />
    </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)]="user.organizationId" name="organizationId" maxlength="20" placeholder="20字以内" />
    </div>
    <div nz-form-label nz-col [nzSpan]="4"><label>密码</label></div>
    <div nz-form-control nz-col [nzSpan]="8">
      <input nz-input [(ngModel)]="user.password" name="password" maxlength="30" placeholder="30字以内" 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">
      <div nz-form-control [nzValidateStatus]="createTime">
        <nz-datepicker [(ngModel)]="user.createTime" name="createTime"></nz-datepicker>
      </div>
      <input nz-input formControlName="organizationId" maxlength="20" placeholder="20字以内" />
    </div>
    <div nz-form-label nz-col [nzSpan]="4"><label>过期日期</label></div>
    <div nz-form-control nz-col [nzSpan]="8">
      <div nz-form-control [nzValidateStatus]="expireTime">
        <nz-datepicker [(ngModel)]="user.expireTime" name="expireTime"></nz-datepicker>
      <div nz-form-control >
        <nz-datepicker style="width: 290px;" formControlName="expireTime"></nz-datepicker>
      </div>
    </div>
  </div>
src/app/routes/users/installer/edit/edit.component.ts
@@ -1,9 +1,10 @@
import { NzModalSubject, NzMessageService } from 'ng-zorro-antd';
import { Component, OnInit } from '@angular/core';
import { ModalHelper } from '@delon/theme';
import { HttpClient } from '@angular/common/http';
import { environment } from '../../../../../environments/environment';
import { DateService } from '../../../../core/services/date.service';
import {NzModalSubject, NzMessageService} from 'ng-zorro-antd';
import {Component, OnInit} from '@angular/core';
import {ModalHelper} from '@delon/theme';
import {HttpClient} from '@angular/common/http';
import {environment} from '../../../../../environments/environment';
import {DateService} from '../../../../core/services/date.service';
import {FormGroup, FormBuilder, FormControl, Validators} from '@angular/forms';
@Component({
  selector: 'app-edit',
@@ -13,42 +14,47 @@
export class UserInstallerEditComponent implements OnInit {
  user: any;
  private validateForm: FormGroup;
  constructor(
    private modalHelper: ModalHelper,
    private subject: NzModalSubject,
    public dateSrv: DateService,
    public msgSrv: NzMessageService,
    public http: HttpClient) { }
    public http: HttpClient,
    private formBuilder: FormBuilder
  ) {}
  ngOnInit() {
//    if (this.user.id > 0) {
//      this.http.get(environment.SERVER_BASH_URL + '/user/operate_user/' + this.user.id).subscribe((res: any) => {
//        this.user = res;
//        this.user.createTime = this.dateSrv.date_format(this.user.createTime, 'YYYY-MM-DD');
//        this.user.expireTime = this.dateSrv.date_format(this.user.expireTime, 'YYYY-MM-DD');
//      });
//    } else {
//      this.user.createTime = this.dateSrv.today('YYYY-MM-DD');
//      this.user.expireTime = this.dateSrv.today('YYYY-MM-DD');
//    }
    const user = this.user;
    this.validateForm = this.formBuilder.group({
      name: [user.name],
      mobile: [user.mobile, [Validators.pattern("^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\\d{8}$")]],
      email: [user.email],
      weixin: [user.weixin],
      organizationId: [user.organizationId],
      expireTime: [user.expireTime],
      id: [user.id]
    });
  }
  save() {
    if (this.user.name == null || this.user.name === '') {
      this.msgSrv.error('请输入姓名');
    } else if (this.user.mobile == null || this.user.mobile === '') {
      this.msgSrv.error('请输入账号');
    } else if (this.user.email == null || this.user.email === '') {
      this.msgSrv.error('请输入电子邮件');
    } else if (this.user.password == null || this.user.password === '') {
      this.msgSrv.error('请输入密码');
    } else {
      this.http.post(environment.SERVER_BASH_URL + '/operateUser/operateUser', this.user).subscribe(() => {
    const validateForm = this.validateForm;
    const controls = validateForm.controls;
    if (validateForm.valid) {
      for (const i in controls) {
        controls[i].disable();
      }
      this.http.post(environment.SERVER_BASH_URL + '/operateUser/operateUser', validateForm.value).subscribe(() => {
        this.subject.next('true');
        this.close();
      });
    } else {
      for (const i in controls) {
        controls[i].markAsDirty();
      }
    }
  }
  close() {
src/app/routes/users/installer/installer.component.html
@@ -12,7 +12,7 @@
      </div>
      <div nz-col [nzSpan]="8" class="mb-md">
        <div nz-form-item class="d-flex">
          <div nz-form-label><label for="u_mobile">账号</label></div>
          <div nz-form-label><label for="u_mobile">账号/电话</label></div>
          <div nz-form-control class="flex-1">
            <nz-input [(ngModel)]="q.u_mobile" name="u_mobile" [nzSize]="'large'" [nzPlaceHolder]="'请输入账号'" nzId="u_mobile"></nz-input>
          </div>
@@ -20,7 +20,7 @@
      </div>
      <div nz-col [nzSpan]="8" class="mb-md">
        <button nz-button type="submit" [nzType]="'primary'" [nzLoading]="loading" [nzSize]="'large'">查询</button>
        <button nz-button type="reset" (click)="load(true)" [nzSize]="'large'" class="mx-sm">重置</button>
        <button nz-button type="reset" [nzSize]="'large'" class="mx-sm">重置</button>
      </div>
    </div>
  </form>
@@ -41,7 +41,7 @@
  </div>
  <nz-table #nzTable
            [nzAjaxData]="data"
            [nzLoading]="http.loading"
            [nzLoading]="loading"
            [nzTotal]="total"
            [(nzPageIndex)]="q.pi"
            [nzPageSize]="q.ps"
@@ -53,10 +53,9 @@
        <label nz-checkbox [(ngModel)]="allChecked" [nzIndeterminate]="indeterminate" (ngModelChange)="checkAll($event)"></label>
      </th>
      <th nz-th><span>姓名</span></th>
      <th nz-th><span>账号</span></th>
      <th nz-th><span>账号/电话</span></th>
      <th nz-th><span>电子邮件</span></th>
      <th nz-th><span>微信号</span></th>
      <th nz-th><span>密码</span></th>
      <th nz-th><span>组织</span></th>
      <th nz-th><span>创建日期</span></th>
      <th nz-th>
@@ -76,18 +75,15 @@
      <td nz-td>{{i.mobile}}</td>
      <td nz-td>{{i.email}}</td>
      <td nz-td>{{i.weixin}}</td>
      <td nz-td>{{i.password}}</td>
      <td nz-td>{{i.organizationId}}</td>
      <td nz-td>{{format_date(i.createTime)}}</td>
      <td nz-td>{{format_date(i.expireTime)}}</td>
      <td nz-td>
        <a (click)="edit(i)">编辑</a>
        <ng-container *ngIf="i.isDelete == '0'">
        <span nz-table-divider></span>
          <nz-popconfirm [nzTitle]="'确定要删除该用户吗?'" [nzOkText]="'Yes'" [nzCancelText]="'No'" (nzOnConfirm)="delete(i)" >
            <a nz-popconfirm>删除</a>
          </nz-popconfirm>
         </ng-container>
      </td>
    </tr>
    </tbody>
src/app/routes/users/installer/installer.component.ts
@@ -1,10 +1,10 @@
import { Component, OnInit } from '@angular/core';
import { NzMessageService } from 'ng-zorro-antd';
import { ModalHelper } from '@delon/theme';
import { HttpClient } from '@angular/common/http';
import { UserInstallerEditComponent } from './edit/edit.component';
import { environment } from '../../../../environments/environment';
import { DateService } from '../../../core/services/date.service';
import {Component, OnInit} from '@angular/core';
import {NzMessageService} from 'ng-zorro-antd';
import {ModalHelper} from '@delon/theme';
import {HttpClient} from '@angular/common/http';
import {UserInstallerEditComponent} from './edit/edit.component';
import {environment} from '../../../../environments/environment';
import {DateService} from '../../../core/services/date.service';
@Component({
  selector: 'app-installer',
@@ -28,6 +28,7 @@
  allChecked = false;
  indeterminate = false;
  sortMap: any = {};
  loading: boolean = true;
  constructor(
    public http: HttpClient,
@@ -44,39 +45,15 @@
      this.q.pi = 1;
    }
    this.http.get(environment.SERVER_BASH_URL + '/operateUser/list', {params: this.q}).subscribe((res: any) => {
      // let data = res.data;
      // const total = res.total;
      //
      // if (this.q.sorter !== '') {
      //   const s = this.q.sorter.split('_');
      //   data.sort((prev, next) => {
      //     if (s[1] === 'descend') {
      //       return moment(next[s[0]]).unix() - moment(prev[s[0]]).unix();
      //     }
      //     return moment(prev[s[0]]).unix() - moment(next[s[0]]).unix();
      //   });
      // }
      //
      // if (this.q.u_name) {
      //   data = data.filter(d => d.name.indexOf(this.q.u_name) > -1);
      // }
      // if (this.q.u_mobile) {
      //   data = data.filter(d => d.mobile.toString().indexOf(this.q.u_mobile) > -1);
      // }
      //
      // const start = (this.q.pi - 1) * this.q.ps;
      // this.data = data.slice(start, start + this.q.ps);
      // this.total = total;
      this.data = res.data.data;
      this.total = res.data.total;
      this.dataChange(this.data);
      this.loading = false;
    });
  }
  edit(user) {
    this.modalHelper.static(UserInstallerEditComponent, { user }).subscribe(() => {
    this.modalHelper.static(UserInstallerEditComponent, {user}).subscribe(() => {
      this.load(true);
      this.msgSrv.success('安装用户修改成功!');
    });
@@ -84,14 +61,14 @@
  add() {
    const user = {};
    this.modalHelper.static(UserInstallerEditComponent, { user }).subscribe(() => {
    this.modalHelper.static(UserInstallerEditComponent, {user}).subscribe(() => {
      this.load(true);
      this.msgSrv.success('安装用户保存成功!');
    });
  }
  delete(user) {
    this.http.post(environment.SERVER_BASH_URL + '/operateUser/operateUser/id',user).subscribe((res: any) => {
    this.http.post(environment.SERVER_BASH_URL + '/operateUser/operateUser/id', user).subscribe((res: any) => {
      this.msgSrv.success('安装用户删除成功!');
      this.load(true);
    });
@@ -103,6 +80,7 @@
      ids.push(i.id);
    });
    this.http.post(environment.SERVER_BASH_URL + '/operateUser/operateUsers/ids', ids).subscribe((res: any) => {
      this.msgSrv.success('安装用户删除成功!');
      this.load(true);
    });
  }
@@ -144,6 +122,8 @@
  }
  format_date(date) {
    return this.dateSrv.date_format(date, 'YYYY-MM-DD');
    if (date) {
      return this.dateSrv.date_format(date, 'YYYY-MM-DD');
    }
  }
}