<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>：
          <nz-select class="formItem" [nzDropdownMatchSelectWidth]="false" nzServerSearch nzShowSearch
            (nzOnSearch)="changeInp('search', 'assetProduct', $event)" nzAllowClear nzPlaceHolder="请选择关联产品" [(ngModel)]="searchDto.productId">
            <ng-container *ngFor="let option of assetProductsearchList">
              <nz-option *ngIf="!isLoading" [nzLabel]="option.name + '(' + option.brand + ')' + '(' + option.model + ')'" [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="14%">耗材名称</th>
            <th nzWidth="14%">型号</th>
            <th nzWidth="14%">库存</th>
            <th nzWidth="14%">单位</th>
            <th nzWidth="14%">供应商</th>
            <th nzWidth="14%">单价(元)</th>
            <th nzWidth="16%">操作</th>
          </tr>
        </thead>
        <tbody>
          <tr *ngFor="let data of listOfData;let i = index">
            <td>{{data.name}}</td>
            <td>{{data.model}}</td>
            <td>{{data.stock}}</td>
            <td>{{data.unit}}</td>
            <td>{{data.supplierDTO?.name}}</td>
            <td>{{data.price}}</td>
            <td>
              <div class="coop">
                <span *ngIf="coopBtns.edit" (click)="edit($event, data)">编辑</span>
                <span *ngIf="coopBtns.del" (click)="showDelModal($event, data,'您确认要删除吗？','删除','del')">删除</span>
								<span *ngIf="coopBtns.log" (click)="showLogModal($event, data)">日志</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>耗材名称</nz-form-label>
            <nz-form-control [nzSpan]="19" nzErrorTip="请输入耗材名称!">
              {{productDto.name}}
            </nz-form-control>
          </nz-form-item>
          <nz-form-item>
            <nz-form-label [nzSpan]="5" nzRequired>型&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号</nz-form-label>
            <nz-form-control [nzSpan]="19" nzErrorTip="请输入型号!">
              {{productDto.model}}
            </nz-form-control>
          </nz-form-item>
          <nz-form-item>
            <nz-form-label [nzSpan]="5" nzRequired>单&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;位</nz-form-label>
            <nz-form-control [nzSpan]="19" nzErrorTip="请输入耗材单位!">
              {{productDto.unit}}
            </nz-form-control>
          </nz-form-item>
          <nz-form-item>
            <nz-form-label [nzSpan]="5" nzRequired nzFor="productId">产&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;品</nz-form-label>
            <nz-form-control [nzSpan]="19" nzErrorTip="请选择产品!">
              <nz-select (nzOnSearch)="changeInp('add', 'assetProduct', $event)" [nzDropdownMatchSelectWidth]="false" nzServerSearch nzShowSearch formControlName="productId" nzPlaceHolder="请选择产品" (ngModelChange)="changeAssetProduct($event)">
                <ng-container *ngFor="let option of assetProductaddList">
                  <nz-option *ngIf="!isLoading" [nzLabel]="option.name + '(' + option.brand + ')' + '(' + option.model + ')'" [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" nzRequired nzFor="supplierId">供&nbsp;应&nbsp;商</nz-form-label>
            <nz-form-control [nzSpan]="19" nzErrorTip="请选择供应商!">
              <nz-select [nzDropdownMatchSelectWidth]="false" nzAllowClear formControlName="supplierId" nzPlaceHolder="请选择供应商">
                <ng-container *ngFor="let option of companyList">
                  <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" nzRequired nzFor="stock">库存</nz-form-label>
            <nz-form-control [nzSpan]="19" nzErrorTip="请填写库存!">
              <nz-input-number class="w100" nz-input formControlName="stock" nzPlaceHolder="请填写库存" [nzMin]="0" [nzStep]="0.01" [nzPrecision]="2"></nz-input-number>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item>
            <nz-form-label [nzSpan]="5" nzRequired nzFor="price">单价</nz-form-label>
            <nz-form-control [nzSpan]="19" nzErrorTip="请填写单价!">
              <nz-input-number class="w100" nz-input formControlName="price" nzPlaceHolder="请填写单价" [nzMin]="0" [nzStep]="0.01" [nzPrecision]="2"></nz-input-number>
            </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>
	
	<!-- 日志查看模态框 -->
	<div class="save add display_flex align-items_center justify-content_flex-center" *ngIf="logModal">
	  <div class="modalBody modalLogBody">
	    <div class="title">日志查看<i class="icon_transport transport-guanbi" (click)="hideModal()"></i>
	    </div>
	    <div class="content">
	      <div class="list-template__bottom">
	        <nz-table class="list-template__nzTable" [nzData]="listLogOfData" nzSize="middle" [nzShowPagination]="false"
	          [nzLoading]="loading2">
	          <thead>
	            <tr class="thead">
								<th>事件单号</th>
								<th>动作</th>
	              <th>操作时间</th>
	              <th>操作人</th>
	              <th>调整记录</th>
	            </tr>
	          </thead>
	          <tbody>
	            <tr *ngFor="let data of listLogOfData">
								<td>{{data.incidentDTO?data.incidentDTO.incidentsign:'-'}}</td>
								<td>{{ data.operationType ? data.operationType.name : '-' }}</td>
	              <td>{{ data.time|date:'yyyy-MM-dd HH:mm'}}</td>
	              <td>{{ data.operator ? data.operator.name : '-' }}</td>
	              <td>{{ data.logRemark ? data.logRemark : '-' }}</td>
	            </tr>
	          </tbody>
	        </nz-table>
	      </div>
				<div class="list-template__pagination">
				  <nz-pagination [(nzPageIndex)]="pageLogIndex" [(nzTotal)]="listLogLength" nzShowSizeChanger [(nzPageSize)]="pageLogSize"
				    (nzPageIndexChange)="getLogList()" (nzPageSizeChange)="getLogList()">
				  </nz-pagination>
				</div>
	    </div>
	    <div class="display_flex justify-content_flex-center">
	      <button class="btn" nz-button nzType="primary" (click)="hideModal()">知道了</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>
