<form nz-form nc-adaptive-form [formGroup]="_companyForm" nz-row [nzGutter]="24">

  <div nz-col [nzSpan]="24">
    <nz-form-item>
      <nz-form-label nzRequired>公司名称</nz-form-label>
      <nz-form-control [nzErrorTip]="controlErrorTemplate">
        <input nz-input formControlName="name" placeholder="请输入公司名称">
      </nz-form-control>
    </nz-form-item>
  </div>

  <div nz-col [nzSpan]="24">
    <nz-form-item>
      <nz-form-label nzRequired>公司简称</nz-form-label>
      <nz-form-control [nzErrorTip]="controlErrorTemplate">
        <input nz-input formControlName="alias" placeholder="请输入公司简称">
      </nz-form-control>
    </nz-form-item>
  </div>

  <div nz-col [nzSpan]="24" *ngIf="_companyForm.controls.userAccount">
    <nz-form-item>
      <nz-form-label nzRequired>管理员账号</nz-form-label>
      <nz-form-control [nzErrorTip]="controlErrorTemplate">
        <input nz-input formControlName="userAccount" placeholder="请输入管理员账号">
      </nz-form-control>
    </nz-form-item>
  </div>

  <div nz-col [nzSpan]="24" *ngIf="_companyForm.controls.userPassword">
    <nz-form-item>
      <nz-form-label nzRequired>管理员密码</nz-form-label>
      <nz-form-control [nzErrorTip]="controlErrorTemplate">
        <nz-input-group [nzSuffix]="passwordSuffixTemplate">
          <input formControlName="userPassword" nz-input placeholder="请输入管理员密码"
            [type]="_passwordVisible ? 'text' : 'password'">
          <ng-template #passwordSuffixTemplate>
            <i nz-icon [nzType]="_passwordVisible ? 'eye-invisible' : 'eye'"
              (click)="_passwordVisible = !_passwordVisible"></i>
          </ng-template>
        </nz-input-group>
      </nz-form-control>
    </nz-form-item>
  </div>

  <div nz-col [nzSpan]="24" *ngIf="_companyForm.controls.userName">
    <nz-form-item>
      <nz-form-label nzRequired>管理员姓名</nz-form-label>
      <nz-form-control [nzErrorTip]="controlErrorTemplate">
        <input nz-input formControlName="userName" placeholder="请输入管理员姓名">
      </nz-form-control>
    </nz-form-item>
  </div>

  <div nz-col [nzSpan]="24" *ngIf="_companyForm.controls.userMobileNumber">
    <nz-form-item>
      <nz-form-label nzRequired>管理员手机号</nz-form-label>
      <nz-form-control [nzErrorTip]="controlErrorTemplate">
        <input nz-input formControlName="userMobileNumber" placeholder="请输入管理员手机号">
      </nz-form-control>
    </nz-form-item>
  </div>

  <div nz-col [nzSpan]="24" *ngIf="!_companyForm.controls.userAccount">
    <nz-form-item>
      <nz-form-label nzRequired>有效状态</nz-form-label>
      <nz-form-control [nzErrorTip]="controlErrorTemplate">
        <nz-switch formControlName="enabled" nzCheckedChildren="有效" nzUnCheckedChildren="无效"></nz-switch>
      </nz-form-control>
    </nz-form-item>
  </div>

  <div nz-col [nzSpan]="24">
    <nz-form-item>
      <nz-form-label>标签</nz-form-label>
      <nz-form-control [nzErrorTip]="controlErrorTemplate">
        <nz-select #tagsInputMultiple
          formControlName="tags"
          nzPlaceHolder="请输入标签"
          nzMode="tags"
          [nzDropdownStyle]="{ display: tagsInputMultiple['searchValue'] ? '': 'none' }"
          nzAllowClear></nz-select>
      </nz-form-control>
    </nz-form-item>
  </div>

  <div nz-col [nzSpan]="24">
    <nz-form-item>
      <nz-form-label>授权应用</nz-form-label>
      <nz-form-control [nzErrorTip]="controlErrorTemplate">
        <nz-select formControlName="applications" nzPlaceHolder="请选择授权应用" nzMode="multiple"
          [nzLoading]="_applicationLoading" [compareWith]="_entityCompareWith" nzShowSearch nzAllowClear>
          <nz-option *ngFor="let application of _applicationList" [nzLabel]="application.name" [nzValue]="application">
          </nz-option>
        </nz-select>
      </nz-form-control>
    </nz-form-item>
  </div>

</form>

<ng-template #controlErrorTemplate let-control>
  <div *ngFor="let error of control.errors | keyvalue">{{ error.value }}</div>
</ng-template>
