<div class="list-template">
  <div class="list-template__content">
    <div class="list-template__top" nz-row>
      <div nz-col nzXl='18' class="list-template__searchBox"></div>
      <div nz-col nzXl='6' class="list-template__btns">
        <button nz-button *ngIf="coopBtns.add" class="btn ml8 default" (click)="showModal()">新增</button>
      </div>
    </div>
    <div class="list-template__bottom">
      <nz-table class="list-template__nzTable" [nzData]="listOfData" nzSize="middle" [nzShowPagination]="false"
        [nzLoading]="loading1">
        <thead>
          <tr class="thead">
            <th nzWidth="16%">单位名称</th>
            <th nzWidth="16%">单位类型</th>
            <th nzWidth="16%">联系人</th>
            <th nzWidth="16%">联系电话</th>
            <th nzWidth="16%">单位地址</th>
            <th nzWidth="20%">操作</th>
          </tr>
        </thead>
        <tbody>
          <tr *ngFor="let data of listOfData;let index=index;">
            <td>{{ data.name }}</td>
            <td>{{ data.transType ? data.transType.name : '' }}</td>
            <td>{{ data.contacts }}</td>
            <td>{{ data.mphone }}</td>
            <td>{{ data.address }}</td>
            <td>
              <div class="coop">
                <span *ngIf="coopBtns.edit" (click)="edit(data)">修改</span>
                <span *ngIf="coopBtns.del" (click)="del(data)">删除</span>
              </div>
            </td>
          </tr>
        </tbody>
      </nz-table>
      <div class="list-template__pagination">
        <nz-pagination [(nzPageIndex)]="pageIndex" [(nzTotal)]="listLength" nzShowSizeChanger [(nzPageSize)]="pageSize"
          (nzPageIndexChange)="getList()" (nzPageSizeChange)="getList()">
        </nz-pagination>
      </div>
    </div>
  </div>
</div>
<!-- 新增/编辑模态框 -->
<div class="save add display_flex align-items_center justify-content_flex-center" *ngIf="modal">
  <div class="modalBody">
    <div class="title">{{add?"新增":"编辑"}}单位管理<i class="icon_transport transport-guanbi" (click)="hideModal()"></i>
    </div>
    <overlay-scrollbars #osComponentRef1 class="content">
      <form nz-form [formGroup]="validateForm" class="addForm" (ngSubmit)="submitForm()">
        <nz-form-item>
          <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="name">单位名称</nz-form-label>
          <nz-form-control nzErrorTip="请填写单位名称!">
            <nz-input-group>
              <input nz-input formControlName="name" placeholder="请填写单位名称" />
            </nz-input-group>
          </nz-form-control>
        </nz-form-item>
        <nz-form-item>
          <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="transType">单位类型</nz-form-label>
          <nz-form-control nzErrorTip="请选择单位类型!">
            <nz-select [nzDropdownMatchSelectWidth]="false" nzShowSearch nzAllowClear
              formControlName="transType" nzPlaceHolder="请选择单位类型" (ngModelChange)="transTypeChange()">
              <nz-option [nzLabel]="data.name" [nzValue]="data.id" *ngFor="let data of transTypes">
              </nz-option>
            </nz-select>
          </nz-form-control>
        </nz-form-item>
        <nz-form-item>
          <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="contacts">联系人</nz-form-label>
          <nz-form-control nzErrorTip="请填写联系人!">
            <nz-input-group>
              <input nz-input formControlName="contacts" placeholder="请填写联系人" />
            </nz-input-group>
          </nz-form-control>
        </nz-form-item>
        <nz-form-item>
          <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="mphone">联系电话</nz-form-label>
          <nz-form-control nzErrorTip="请填写联系电话!">
            <nz-input-group>
              <input nz-input formControlName="mphone" placeholder="请填写联系电话" />
            </nz-input-group>
          </nz-form-control>
        </nz-form-item>
        <!-- 司机信息 -->
        <ng-container *ngIf="isShowDateType">
          <div nz-row>
            <div nz-col nzSpan="10">
              <nz-form-item style="margin: 0;">
                <nz-form-label [nzSm]="24" [nzXs]="24" nzRequired nzFor="laborerName0">司机信息</nz-form-label>
                <nz-form-control nzErrorTip="请输入司机姓名!">
                  <nz-input-group>
                    <input nz-input formControlName="laborerName0" placeholder="请输入司机姓名" />
                  </nz-input-group>
                </nz-form-control>
              </nz-form-item>
            </div>
            <div nz-col nzSpan="10" nzOffset="1">
              <nz-form-item style="margin: 0;">
                <nz-form-label [nzSm]="24" [nzXs]="24" nzRequired nzFor="laborerPhone0" style="opacity: 0;">司机联系电话</nz-form-label>
                <nz-form-control nzErrorTip="请输入司机联系电话!">
                  <nz-input-group>
                    <input nz-input formControlName="laborerPhone0" placeholder="请输入司机联系电话" />
                  </nz-input-group>
                </nz-form-control>
              </nz-form-item>
            </div>
          </div>
          <div nz-row *ngFor="let item of laborers;let index = index">
            <div nz-col nzSpan="10">
              <nz-form-item style="margin: 0;">
                <nz-form-label [nzSm]="24" [nzXs]="24" nzRequired [nzFor]="item[0].name" hidden>司机信息</nz-form-label>
                <nz-form-control nzErrorTip="请输入司机姓名!">
                  <nz-input-group>
                    <input nz-input [formControlName]="item[0].name" placeholder="请输入司机姓名" [attr.id]="item[0].id" />
                  </nz-input-group>
                </nz-form-control>
              </nz-form-item>
            </div>
            <div nz-col nzSpan="10" nzOffset="1">
              <nz-form-item style="margin: 0;">
                <nz-form-label [nzSm]="24" [nzXs]="24" nzRequired [nzFor]="item[1].name" hidden>司机联系电话</nz-form-label>
                <nz-form-control nzErrorTip="请输入司机联系电话!">
                  <nz-input-group>
                    <input nz-input [formControlName]="item[1].name" placeholder="请输入司机联系电话" [attr.id]="item[1].id" />
                  </nz-input-group>
                </nz-form-control>
              </nz-form-item>
            </div>
            <div nz-col nzSpan="2" nzOffset="1">
              <i nz-icon nzType="minus-circle-o" (click)="removeLaborer(index, $event)" style="font-size:20px;cursor: pointer;margin-top: 10px;"></i>
            </div>
          </div>
          <button nz-button nzType="dashed" class="add-button" (click)="addLaborer($event)">
            <i nz-icon nzType="plus"></i>
            添加司机信息
          </button>
        </ng-container>
        <!-- 车牌号码 -->
        <ng-container *ngIf="isShowDateType">
          <div nz-row>
            <div nz-col nzSpan="24">
              <nz-form-item style="margin: 0;">
                <nz-form-label [nzSm]="24" [nzXs]="24" nzRequired nzFor="carNo0">车牌号码</nz-form-label>
                <nz-form-control nzErrorTip="请输入车牌号码!">
                  <nz-input-group>
                    <input nz-input formControlName="carNo0" placeholder="请输入车牌号码" />
                  </nz-input-group>
                </nz-form-control>
              </nz-form-item>
            </div>
          </div>
          <div nz-row *ngFor="let item of carNos;let index = index">
            <div nz-col nzSpan="21">
              <nz-form-item style="margin: 0;">
                <nz-form-label [nzSm]="24" [nzXs]="24" nzRequired [nzFor]="item.name" hidden>车牌号码</nz-form-label>
                <nz-form-control nzErrorTip="请输入车牌号码!">
                  <nz-input-group>
                    <input nz-input [formControlName]="item.name" placeholder="请输入车牌号码" [attr.id]="item.id" />
                  </nz-input-group>
                </nz-form-control>
              </nz-form-item>
            </div>
            <div nz-col nzSpan="2" nzOffset="1">
              <i nz-icon nzType="minus-circle-o" (click)="removeCarNo(index, $event)" style="font-size:20px;cursor: pointer;margin-top: 10px;"></i>
            </div>
          </div>
          <button nz-button nzType="dashed" class="add-button" (click)="addCarNo($event)">
            <i nz-icon nzType="plus"></i>
            添加车牌号码
          </button>
        </ng-container>
        <nz-form-item>
          <nz-form-label [nzSm]="10" [nzXs]="24" nzFor="businessCode">{{isShowDateType ? '营运证件号' : '危险物经营许可证编号'}}</nz-form-label>
          <nz-form-control nzErrorTip="请填写{{isShowDateType ? '营运证件号' : '危险物经营许可证编号'}}!">
            <nz-input-group>
              <input nz-input formControlName="businessCode" placeholder="请填写{{isShowDateType ? '营运证件号' : '危险物经营许可证编号'}}" />
            </nz-input-group>
          </nz-form-control>
        </nz-form-item>
        <nz-form-item>
          <nz-form-label [nzSm]="6" [nzXs]="24" nzFor="address">单位地址</nz-form-label>
          <nz-form-control nzErrorTip="请填写单位地址!">
            <nz-input-group>
              <input nz-input formControlName="address" placeholder="请填写单位地址" />
            </nz-input-group>
          </nz-form-control>
        </nz-form-item>
      </form>
    </overlay-scrollbars>
    <div class="display_flex justify-content_flex-center">
      <button nzType="primary" nz-button (click)="submitForm()" [nzLoading]="btnLoading">确认</button>
      <button class="btn cancel" nz-button nzType="default" (click)="hideModal()">取消</button>
    </div>
  </div>
</div>
<!-- 删除模态框 -->
<app-dialog-delete [delModal]="delModal" (hideDelModalEvent)="hideDelModal()" [btnLoading]="btnLoading"
  (confirmDelEvent)="confirmDel()" content="您确认要删除吗？">
</app-dialog-delete>
<!-- 操作成功/失败提示框 -->
<app-prompt-modal *ngIf="promptModalShow" [content]="promptContent" [success]="ifSuccess" [show]="promptModalShow"
  [info]="promptInfo"></app-prompt-modal>

<!-- 遮罩 -->
<app-mask *ngIf="maskFlag"></app-mask>
