<!-- start 面包屑 -->
<app-breadcrumb></app-breadcrumb>
<!-- end 面包屑 -->
<!--条件搜索-->
<nz-spin [nzSpinning]="loadingObject.spinning" nzTip="{{loadingObject.msg}}">
  <div class="inner-content">
    <form nz-form [formGroup]="searchForm" (ngSubmit)="search(searchForm.value)">
      <div nz-row>
        <div nz-col nzSpan="8">
          <nz-form-item>
            <nz-form-label [nzSpan]="8">终端类型</nz-form-label>
            <nz-form-control [nzSpan]="14">
              <nz-select nzAllowClear formControlName="termType">
                <nz-option *ngFor="let item of termTypeArray" nzLabel="{{item.codeName}}" nzValue="{{item.codeValue}}"></nz-option>
              </nz-select>
            </nz-form-control>
          </nz-form-item>
        </div>
        <div nz-col nzSpan="8">
          <nz-form-item>
            <nz-form-label [nzSpan]="8">版本类型</nz-form-label>
            <nz-form-control [nzSpan]="14">
              <nz-select nzAllowClear formControlName="versionType">
                <nz-option *ngFor="let item of versionTypeArray" nzLabel="{{item.codeName}}" nzValue="{{item.codeValue}}"></nz-option>
              </nz-select>
            </nz-form-control>
          </nz-form-item>
        </div>
        <div nz-col nzSpan="8">
          <nz-form-item>
            <nz-form-label [nzSpan]="8">状态</nz-form-label>
            <nz-form-control [nzSpan]="14">
              <nz-select nzAllowClear formControlName="status">
                <nz-option nzLabel="已发布" nzValue="1"></nz-option>
                <nz-option nzLabel="未发布" nzValue="2"></nz-option>
              </nz-select>
            </nz-form-control>
          </nz-form-item>
        </div>
      </div>

      <div nz-row>
        <div nz-col nzSpan="24" class="search-button">
          <button nz-button nzType="primary"><i nz-icon nzType="search" nzTheme="outline"></i>搜索</button>
          <button nz-button nzType="default" (click)="resetForm()"><i nz-icon nzType="reload" nzTheme="outline"></i>重置</button>
        </div>
      </div>
    </form>
  </div>

  <div class="inner-content">
    <span>共计 {{dataObject.total?dataObject.total:0}} 条数据</span>
    <div class="operating-button">
      <button nz-button nzType="primary" class="right-btn" (click)="showEditModal(null)">新增版本</button>
    </div>
    <!--数组表格 -->
    <nz-table #basicTable
              [nzData]="dataObject.list"
              [nzTotal]="dataObject.total"
              [nzFrontPagination]="false"
              [nzLoading]="tableLoading"
              [nzPageIndex]="whereObject.pageNum"
              (nzPageIndexChange)="requestData($event)"
              [nzScroll]="{ x: '1150px'}">
      <thead>
      <tr>
        <th nzWidth="80px">终端类型</th>
        <th nzWidth="80px">版本类型</th>
        <th nzWidth="80px">版本号</th>
        <th nzWidth="80px">状态</th>
        <th nzWidth="150px">版本内容</th>
        <th nzWidth="140px">创建时间</th>
        <th nzWidth="140px">发布时间</th>
        <th nzWidth="150px" nzRight="0px">操作</th>
      </tr>
      </thead>
      <tbody>
      <tr *ngFor="let data of basicTable.data;let i = index">
        <td>{{data.termType}}</td>
        <td>{{data.versionType == 1?'小版本':'大版本'}}</td>
        <td>{{data.version}}</td>
        <td>{{data.status == 1?'已发布':'未发布'}}</td>
        <td nzEllipsis>{{data.content}}</td>
        <td>{{data.createTime | date : 'yyyy-MM-dd HH:mm:ss'}}</td>
        <td>{{data.releaseTime | date : 'yyyy-MM-dd HH:mm:ss'}}</td>
        <td nzRight="0px" class="table-td-operation">
          <a nz-dropdown [nzDropdownMenu]="menu">其他操作  <i nz-icon nzType="down"></i> </a>
          <nz-dropdown-menu #menu="nzDropdownMenu">
            <ul nz-menu nzSelectable>
              <li nz-menu-item (click)="showOpenDetail(data)"><a >查看详情</a></li>
              <li nz-menu-item *ngIf="data.status == 2"  (click)="showReleaseConfirm(data.id)"><a >发布版本</a></li>
              <li nz-menu-item *ngIf="data.status == 2"  (click)="showDelConfirm(data.id)"><a >删除版本</a></li>
            </ul>
          </nz-dropdown-menu>
        </td>
      </tr>
      </tbody>
    </nz-table>
  </div>
</nz-spin>


<nz-modal [(nzVisible)]="editVersionModal" nzTitle="新增版本" (nzOnCancel)="closeEditModal()" nzWidth="500px" [nzFooter]="null">
  <form nz-form [formGroup]="editVersionModalForm">
    <nz-form-item>
      <nz-form-label [nzSpan]="6" nzRequired>终端类型</nz-form-label>
      <nz-form-control [nzSpan]="14">
        <nz-select formControlName="termType">
          <nz-option *ngFor="let data of termTypeArray" nzLabel="{{data.codeName}}" nzValue="{{data.codeValue}}"></nz-option>
        </nz-select>
      </nz-form-control>
    </nz-form-item>

    <nz-form-item>
      <nz-form-label [nzSpan]="6" nzRequired>版本类型</nz-form-label>
      <nz-form-control [nzSpan]="14">
        <nz-select formControlName="versionType">
          <nz-option *ngFor="let data of versionTypeArray" nzLabel="{{data.codeName}}" nzValue="{{data.codeValue}}"></nz-option>
        </nz-select>
      </nz-form-control>
    </nz-form-item>

    <nz-form-item>
      <nz-form-label [nzSpan]="6" nzRequired>新版本号</nz-form-label>
      <nz-form-control [nzSpan]="14">
        <input nz-input formControlName="version" placeholder="请输入新版本号" />
      </nz-form-control>
    </nz-form-item>

    <nz-form-item>
      <nz-form-label [nzSpan]="6" nzRequired>版本内容</nz-form-label>
      <nz-form-control [nzSpan]="14">
        <textarea rows="4" nz-input placeholder="版本更新内容" formControlName="content"></textarea>
      </nz-form-control>
    </nz-form-item>

    <nz-form-item>
      <nz-form-label [nzSpan]="6" nzRequired>更新文件</nz-form-label>
      <nz-form-control [nzSpan]="14">
        <nz-upload
          nzAction="http://122.9.135.148:9902/v1/fileUpload/uploadfile"
          (nzChange)="fileHandleChange($event)"
        >
          <button nz-button><i nz-icon nzType="upload"></i>文件上传</button>
        </nz-upload>
      </nz-form-control>
    </nz-form-item>

    <div style="text-align: center;">
      <button nz-button nzType="primary" style="width: 150px;" (click)="submitEdit()">确定</button>
    </div>
  </form>
</nz-modal>


<nz-modal [(nzVisible)]="versionDetailModal" nzTitle="版本详情" (nzOnCancel)="closeVersionDetail()" nzWidth="500px" [nzFooter]="null">
  <nz-descriptions nzBordered nzLayout="vertical">
    <nz-descriptions-item nzTitle="终端类型" [nzSpan]="1">{{versionDetailObject.termType}}</nz-descriptions-item>
    <nz-descriptions-item nzTitle="版本类型" [nzSpan]="1">{{versionDetailObject.versionType == 1?'小版本':'大版本'}}</nz-descriptions-item>
    <nz-descriptions-item nzTitle="版本编号" [nzSpan]="1">{{versionDetailObject.version}}</nz-descriptions-item>
    <nz-descriptions-item nzTitle="文件路径" [nzSpan]="3"><a target="_blank" href="{{versionDetailObject.fileUrl}}">{{versionDetailObject.fileUrl}}</a></nz-descriptions-item>
    <nz-descriptions-item nzTitle="版本内容" [nzSpan]="3">
      <pre>{{versionDetailObject.content}}</pre>
    </nz-descriptions-item>
  </nz-descriptions>
</nz-modal>
