<div class="list-template">
  <div class="list-template__content">
    <div class="list-template__top" nz-row>
      <div nz-col nzXl='16' class="list-template__searchBox">
        <div class="list-template__searchItem">
          <span class="label">名称</span>：
          <input nz-input class="formItem" placeholder="请输入名称" [(ngModel)]="searchDto.name" />
        </div>
        <div class="list-template__searchItem">
          <span class="label">编码</span>：
          <input nz-input class="formItem" placeholder="请输入编码" [(ngModel)]="searchDto.code" />
        </div>
        <div class="list-template__searchItem">
          <span class="label">大类</span>：
          <nz-select class="formItem" [nzDropdownMatchSelectWidth]="false" nzShowSearch nzAllowClear nzPlaceHolder="请选择大类" [(ngModel)]="searchDto.mainType">
            <ng-container *ngFor="let option of productCategoryTypeListSearch1">
              <nz-option *ngIf="!isLoading" [nzLabel]="option.name" [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>
        </div>
      </div>
      <div nz-col nzLg="8" class="list-template__btns">
        <button nz-button class="btn default ml8" (click)='search()'>搜索</button>
        <button nz-button class="btn default ml8" (click)='reset()'>重置</button>
        <button nz-button *ngIf="coopBtns.add" class="btn default ml8" (click)="addModal()">新增</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="8%">编码</th>
            <th nzWidth="8%">名称</th>
            <th nzWidth="8%">型号</th>
            <th nzWidth="8%">品牌</th>
            <th nzWidth="8%">单位</th>
            <th nzWidth="8%">大类</th>
            <th nzWidth="8%">小类</th>
            <th nzWidth="11%">描述</th>
            <th nzWidth="11%">供应商</th>
            <th nzWidth="11%">生产商</th>
            <th nzWidth="11%">操作</th>
          </tr>
        </thead>
        <tbody>
          <tr *ngFor="let data of listOfData;let i = index">
            <td>{{data.code}}</td>
            <td>{{data.name}}</td>
            <td>{{data.model}}</td>
            <td>{{data.brand}}</td>
            <td>{{data.unit}}</td>
            <td>{{data.mainTypeDTO?.name}}</td>
            <td>{{data.subTypeDTO?.name}}</td>
            <td>{{data.description}}</td>
            <td>{{data.supplierList | dataToName:'name':'，'}}</td>
            <td>{{data.manufacturerList | dataToName:'name':'，'}}</td>
            <td>
              <div class="coop">
                <span *ngIf="coopBtns.commonFault" (click)="commonFault($event, data)">常见故障</span>
                <span *ngIf="coopBtns.edit" (click)="edit($event, data)">编辑</span>
                <span *ngIf="coopBtns.del" (click)="showDelModal($event, data,'您确认要删除吗？','删除','del')">删除</span>
              </div>
            </td>
          </tr>
        </tbody>
      </nz-table>
      <div class="list-template__pagination">
        <nz-pagination [(nzPageIndex)]="pageIndex" [(nzTotal)]="listLength" [(nzPageSize)]="pageSize" nzShowSizeChanger
          (nzPageIndexChange)="getList(0)" (nzPageSizeChange)="getList(0)">
        </nz-pagination>
      </div>
    </div>
  </div>

  <!-- 新增/编辑模态框 -->
  <div class="save display_flex justify-content_flex-center align-items_center add" *ngIf="modal">
    <div class="modalBody">
      <div class="title">{{modelName}}<i class="icon_transport transport-guanbi" (click)="hideAddModal()"></i></div>
      <div class="content">
        <form nz-form [formGroup]="validateForm" class="addForm">
          <nz-form-item>
            <nz-form-label [nzSpan]="5" nzRequired nzFor="name">名&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;称</nz-form-label>
            <nz-form-control [nzSpan]="19" 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]="5" nzRequired nzFor="model">型&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号</nz-form-label>
            <nz-form-control [nzSpan]="19" nzErrorTip="请输入型号!">
              <nz-input-group>
                  <input formControlName="model" nz-input placeholder="请输入型号">
              </nz-input-group>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item>
            <nz-form-label [nzSpan]="5" nzRequired nzFor="brand">品&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;牌</nz-form-label>
            <nz-form-control [nzSpan]="19" nzErrorTip="请输入品牌!">
              <nz-input-group>
                  <input formControlName="brand" nz-input placeholder="请输入品牌">
              </nz-input-group>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item>
            <nz-form-label [nzSpan]="5" nzRequired nzFor="unit">单&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;位</nz-form-label>
            <nz-form-control [nzSpan]="19" nzErrorTip="请输入单位!">
              <nz-input-group>
                  <input formControlName="unit" nz-input placeholder="请输入单位">
              </nz-input-group>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item>
            <nz-form-label [nzSpan]="5" nzRequired nzFor="mainType">大&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;类</nz-form-label>
            <nz-form-control [nzSpan]="19" nzErrorTip="请选择大类!">
              <nz-select [nzDropdownMatchSelectWidth]="false" formControlName="mainType" nzShowSearch
                nzPlaceHolder="请选择大类" (ngModelChange)="changeMainType($event)">
                <ng-container *ngFor="let data of productCategoryTypeList1">
                  <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]="5" nzFor="subType">&nbsp;&nbsp;&nbsp;小&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;类</nz-form-label>
            <nz-form-control [nzSpan]="19" nzErrorTip="请选择小类!">
              <nz-select [nzDropdownMatchSelectWidth]="false" formControlName="subType" nzShowSearch
                nzPlaceHolder="请选择小类">
                <ng-container *ngFor="let data of productCategoryTypeList2">
                  <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]="5" nzFor="description">&nbsp;&nbsp;&nbsp;描&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;述</nz-form-label>
            <nz-form-control [nzSpan]="19" nzErrorTip="请输入描述!">
              <nz-input-group>
                <textarea rows="3" nz-input formControlName="description" placeholder="请输入描述"></textarea>
              </nz-input-group>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item>
            <nz-form-label [nzSpan]="5" nzFor="supplierIds">&nbsp;&nbsp;&nbsp;供&nbsp;应&nbsp;商</nz-form-label>
            <nz-form-control [nzSpan]="19" nzErrorTip="请选择供应商!">
              <nz-select nzMode="multiple" (nzOnSearch)="changeInp('1', 'company', $event)" (nzOpenChange)="openSupplier($event)" [nzDropdownMatchSelectWidth]="false" nzServerSearch nzShowSearch nzAllowClear formControlName="supplierIds" nzPlaceHolder="请选择供应商">
                <ng-container *ngFor="let option of companyList1">
                  <nz-option *ngIf="!isLoading" [nzLabel]="option.name" [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>
          <nz-form-item>
            <nz-form-label [nzSpan]="5" nzFor="manufacturerIds">&nbsp;&nbsp;&nbsp;生&nbsp;产&nbsp;商</nz-form-label>
            <nz-form-control [nzSpan]="19" nzErrorTip="请选择生产商!">
              <nz-select nzMode="multiple" (nzOnSearch)="changeInp('2', 'company', $event)" (nzOpenChange)="openManufacturer($event)" [nzDropdownMatchSelectWidth]="false" nzServerSearch nzShowSearch nzAllowClear formControlName="manufacturerIds" nzPlaceHolder="请选择生产商">
                <ng-container *ngFor="let option of companyList2">
                  <nz-option *ngIf="!isLoading" [nzLabel]="option.name" [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)="submitForm()" [nzLoading]="btnLoading">确认</button>
        <button class="btn cancel" nz-button nzType="default" (click)="hideAddModal()">取消</button>
      </div>
    </div>
  </div>
  <!-- 模态框 -->
  <app-dialog-delete [delModal]="delModal" (hideDelModalEvent)="hideDelModal()" [btnLoading]="btnLoading"
    (confirmDelEvent)="confirmDel()" [content]="tipsMsg1"></app-dialog-delete>
</div>
<!-- 操作成功/失败提示框 -->
<app-prompt-modal *ngIf="promptModalShow" [content]="promptContent" [success]="ifSuccess" [show]="promptModalShow"
  [info]="promptInfo">
</app-prompt-modal>

<!-- 常见故障 -->
<app-assets-product-management-prompt-modal
  *ngIf="assetsProductManagementPromptModalShow"
  [show]="assetsProductManagementPromptModalShow"
  [id]="commonFaultId"
  (closeModelHs)="closeModelAssetsProductManagement($event)"
></app-assets-product-management-prompt-modal>
