<!--
 * @Description  : 
 * @Version      : 1.0
 * @Author       : Shiming
 * @Date         : 2022-01-12 10:52:50
 * @LastEditors  : Shiming
 * @LastEditTime : 2022-02-24 10:31:05
 * @FilePath     : \\tms-obc-web\\src\\app\\routes\\contract-management\\components\\contract-template\\contract-template.component.html
 * Copyright (C) 2022 huzhenhong. All rights reserved.
-->

<!-- 搜索表单 -->
<nz-card>
  <div nz-row nzGutter="8">
    <!-- 查询字段小于或等于3个时，不显示伸缩按钮 -->
    <div nz-col nzSpan="24" *ngIf="queryFieldCount <= 4">
      <sf
        #sf
        [schema]="schema"
        [ui]="ui"
        [mode]="'search'"
        [disabled]="!sf?.valid"
        [loading]="false"
        (formSubmit)="st?.load(1)"
        (formReset)="resetSF()"
      ></sf>
    </div>

    <!-- 查询字段大于3个时，根据展开状态调整布局 -->
    <ng-container>
      <div nz-col [nzSpan]="_$expand ? 24 : 18">
        <sf #sf [schema]="schema" [ui]="ui" [compact]="true" [button]="'none'">
          <ng-template sf-template="signTime" let-me let-ui="ui" let-schema="schema">
            <nz-range-picker [nzShowTime]="true" [(ngModel)]="sf.value.signTime"></nz-range-picker>
          </ng-template>
          <ng-template sf-template="effectiveEndTime" let-me let-ui="ui" let-schema="schema">
            <nz-range-picker [nzShowTime]="true" [(ngModel)]="sf.value.effectiveEndTime"></nz-range-picker>
          </ng-template>
        </sf>
      </div>
      <div nz-col [nzSpan]="_$expand ? 24 : 6" [class.text-right]="_$expand">
        <button
          nz-button
          nzType="primary"
          [disabled]="!sf.valid"
          [nzLoading]="service.http.loading"
          (click)="st?.load(1)"
          acl
          [acl-ability]="['CONTRACT-INDEX-listFrame']"
          >查询</button
        >
        <button nz-button (click)="resetSF()">重置</button>
        <button nz-button nzType="link" (click)="expandToggle()">
          {{ !_$expand ? '展开' : '收起' }}
          <i nz-icon [nzType]="!_$expand ? 'down' : 'up'"></i>
        </button>
      </div>
    </ng-container>
  </div>
</nz-card>

<nz-card>
  <div class="NewBtn">
    <button nz-button nzType="primary" (click)="creatTemplate()" acl [acl-ability]="['CONTRACT-TEMPLATE-new']"> 新建 </button>
  </div>
  <div style="margin-top: 15px">
    <st
      #st
      [bordered]="true"
      [data]="service.$api_get_contractTemplate_page"
      [columns]="columns"
      [req]="{ method: 'POST', allInBody: true, reName: { pi: 'pageIndex', ps: 'pageSize' }, params: reqParams }"
      [res]="{ reName: { list: 'data.records', total: 'data.total' } }"
      [page]="{ show: true, showSize: true, pageSizes: [10, 20, 30, 50, 100, 200, 300, 500, 1000] }"
      [loading]="false"
    >
      <ng-template st-row="templateName" let-item let-index="index">
        <a (click)="service.openURL(item?.contractFilePath)">{{ item.templateName }}</a>
        <!-- <a (click)="view(item)">{{ item.templateName }}</a> -->
      </ng-template>
    </st>
  </div>
</nz-card>
