<div class="content priority">
  <div class="contentInner">
    <div class="list-template" id="wechatTable">
      <div class="list-template__content">
        <div class="list-template__bottom">
          <div class="list-template__top" nz-row>
            <div nz-col nzLg="24" class="list-template__btns">
              <button nz-button class="btn default" (click)="addWechatModal()">新增</button>
            </div>
          </div>
          <nz-table class="list-template__nzTable" [nzData]="wechatList" nzSize="middle" [nzShowPagination]="false"
            [nzLoading]="loading1" [nzScroll]="{ y: tableWechatHeight + 'px' }">
            <thead>
              <tr class="thead">
                <th nzWidth="14%">名称|appId</th>
                <th nzWidth="22%">appSecret|agentId</th>
                <th nzWidth="8%">是否企业号</th>
                <th nzWidth="12%">token更新时间</th>
                <th nzWidth="20%">服务地址|服务域名</th>
                <th nzWidth="8%">是否启用</th>
                <th nzWidth="16%">操作</th>
              </tr>
            </thead>
            <tbody>
              <tr *ngFor="let data of wechatList;let i = index">
                <td>{{data.name}}<br>{{data.appId}}</td>
                <td>{{data.appSecret}}<br>{{data.agentId}}</td>
                <td>{{data.qy ? '是' : '否'}}</td>
                <td>{{data.atuTime | date: 'yyyy-MM-dd HH:mm:ss'}}</td>
                <td>{{data.url}}<br>{{data.domain}}</td>
                <td>{{data.active ? '是' : '否'}}</td>
                <td>
                  <div class="coop">
                    <span (click)="showDelModal(data,'您确认要删除吗？','删除','del')">删除</span>
                    <span (click)="editWechat(data)">编辑</span>
                    <span (click)="showDelModal(data,'您确认要重置获取token吗？','重置','delToken')">重置token</span>
                  </div>
                </td>
              </tr>
            </tbody>
          </nz-table>
        </div>
      </div>
    </div>
  </div>
</div>

<!-- 操作成功/失败提示框 -->
<app-prompt-modal *ngIf="promptModalShow" [content]="promptContent" [success]="ifSuccess" [show]="promptModalShow"
  [info]="promptInfo">
</app-prompt-modal>

<!-- 删除模态框 -->
<app-dialog-delete [delModal]="delModal" (hideDelModalEvent)="hideDelModal()" [btnLoading]="btnLoading"
(confirmDelEvent)="confirmDel()" [content]="tipsMsg1"></app-dialog-delete>

<!-- 新增/编辑模态框 -->
<div class="save display_flex justify-content_flex-center align-items_center add" *ngIf="modalWechat">
  <div class="modalBody">
    <div class="title">{{modelName}}<i class="icon_transport transport-guanbi" (click)="hideWechatModal()"></i></div>
    <div class="content">
      <form nz-form [formGroup]="validateWechatForm" class="addForm">
        <nz-form-item>
          <nz-form-label [nzSpan]="6" nzRequired nzFor="name">名称</nz-form-label>
          <nz-form-control [nzSpan]="18" nzErrorTip="请输入名称!">
            <nz-input-group>
              <input formControlName="name" nz-input placeholder="请输入名称">
            </nz-input-group>
          </nz-form-control>
        </nz-form-item>
        <nz-form-item>
          <nz-form-label [nzSpan]="6" nzRequired nzFor="appId">appId</nz-form-label>
          <nz-form-control [nzSpan]="18" nzErrorTip="请输入appId!">
            <nz-input-group>
              <input formControlName="appId" nz-input placeholder="请输入appId">
            </nz-input-group>
          </nz-form-control>
        </nz-form-item>
        <nz-form-item>
          <nz-form-label [nzSpan]="6" nzRequired nzFor="appSecret">appSecret</nz-form-label>
          <nz-form-control [nzSpan]="18" nzErrorTip="请输入appSecret!">
            <nz-input-group>
              <input formControlName="appSecret" nz-input placeholder="请输入appSecret">
            </nz-input-group>
          </nz-form-control>
        </nz-form-item>
        <nz-form-item>
          <nz-form-label [nzSpan]="6" nzRequired nzFor="agentId">agentId</nz-form-label>
          <nz-form-control [nzSpan]="18" nzErrorTip="请输入agentId!">
            <nz-input-group>
              <input formControlName="agentId" nz-input placeholder="请输入agentId">
            </nz-input-group>
          </nz-form-control>
        </nz-form-item>
        <nz-form-item>
          <nz-form-label [nzSpan]="6" nzRequired nzFor="url">服务地址</nz-form-label>
          <nz-form-control [nzSpan]="18" nzErrorTip="请输入服务地址!">
            <nz-input-group>
              <input formControlName="url" nz-input placeholder="请输入服务地址">
            </nz-input-group>
          </nz-form-control>
        </nz-form-item>
        <nz-form-item>
          <nz-form-label [nzSpan]="6" nzRequired nzFor="domain">服务域名</nz-form-label>
          <nz-form-control [nzSpan]="18" nzErrorTip="请输入服务域名!">
            <nz-input-group>
              <input formControlName="domain" nz-input placeholder="请输入服务域名">
            </nz-input-group>
          </nz-form-control>
        </nz-form-item>
        <nz-form-item>
          <nz-form-label [nzSpan]="7" nzRequired nzFor="active">是否启用</nz-form-label>
          <nz-form-control [nzSpan]="17" nzErrorTip="请选择是否启用!">
            <nz-radio-group formControlName="active">
              <label nz-radio [nzValue]="true">是</label>
              <label nz-radio [nzValue]="false">否</label>
            </nz-radio-group>
          </nz-form-control>
        </nz-form-item>
        <nz-form-item>
          <nz-form-label [nzSpan]="7" nzRequired nzFor="qy">是否企业号</nz-form-label>
          <nz-form-control [nzSpan]="17" nzErrorTip="请选择是否企业号!">
            <nz-radio-group formControlName="qy">
              <label nz-radio [nzValue]="true">是</label>
              <label nz-radio [nzValue]="false">否</label>
            </nz-radio-group>
          </nz-form-control>
        </nz-form-item>
        <nz-form-item>
          <nz-form-label [nzSpan]="6" nzRequired nzFor="type">类型</nz-form-label>
          <nz-form-control [nzSpan]="18" nzErrorTip="请选择类型!">
            <nz-select [nzDropdownMatchSelectWidth]="false" formControlName="type" nzShowSearch
              nzPlaceHolder="请选择类型" nzServerSearch>
              <ng-container *ngFor="let data of typeList">
                <nz-option *ngIf="!isLoading" [nzLabel]="data.name" [nzValue]="data.id"></nz-option>
              </ng-container>
              <nz-option *ngIf="isLoading" nzDisabled nzCustomContent>
                <i nz-icon nzType="loading" class="loading-icon"></i> 搜索中...
              </nz-option>
            </nz-select>
          </nz-form-control>
        </nz-form-item>
        <nz-form-item>
          <nz-form-label [nzSpan]="7" nzRequired nzFor="bindAccount">绑定工号</nz-form-label>
          <nz-form-control [nzSpan]="17" nzErrorTip="请选择绑定工号!">
            <nz-radio-group formControlName="bindAccount" (ngModelChange)="changeBindAccount($event)">
              <label nz-radio [nzValue]="true">是</label>
              <label nz-radio [nzValue]="false">否</label>
            </nz-radio-group>
          </nz-form-control>
        </nz-form-item>
        <nz-form-item *ngIf="!validateWechatForm.value.bindAccount">
          <nz-form-label [nzSpan]="7" nzRequired nzFor="createUser">自动创建用户</nz-form-label>
          <nz-form-control [nzSpan]="17" nzErrorTip="请选择自动创建用户!">
            <nz-radio-group formControlName="createUser" (ngModelChange)="changeCreateUser($event)">
              <label nz-radio [nzValue]="true">是</label>
              <label nz-radio [nzValue]="false">否</label>
            </nz-radio-group>
          </nz-form-control>
        </nz-form-item>
        <nz-form-item *ngIf="validateWechatForm.value.createUser">
          <nz-form-label [nzSpan]="6" nzRequired nzFor="defaultRole">关联角色</nz-form-label>
          <nz-form-control [nzSpan]="18" nzErrorTip="请选择关联角色!">
            <nz-select [nzDropdownMatchSelectWidth]="false" formControlName="defaultRole" nzShowSearch
            nzPlaceHolder="请选择关联角色" nzServerSearch>
              <ng-container *ngFor="let option of defaultRoleList">
                <nz-option *ngIf="!isLoading" [nzLabel]="option.role" [nzValue]="option.id"></nz-option>
              </ng-container>
              <nz-option *ngIf="isLoading" nzDisabled nzCustomContent>
                <i nz-icon nzType="loading" class="loading-icon"></i> 搜索中...
              </nz-option>
            </nz-select>
          </nz-form-control>
        </nz-form-item>
      </form>
    </div>
    <div class=" display_flex justify-content_flex-center">
      <button nzType="primary" nz-button (click)="submitWechatForm()" [nzLoading]="btnLoading">确认</button>
      <button class="btn cancel" nz-button nzType="default" (click)="hideWechatModal()">取消</button>
    </div>
  </div>
</div>
