<page-header-wrapper title="Zorro案例">
</page-header-wrapper>

<nz-card [nzBordered]="false">
    <form nz-form (ngSubmit)="getData()" class="search__form">
        <div nz-row [nzGutter]="{ xs: 8, sm: 8, md: 24, lg: 24, xl: 48, xxl: 48 }">
            <div nz-col nzMd="8" nzSm="24">
                <nz-form-item>
                    <nz-form-label nzFor="no">规则编号</nz-form-label>
                    <nz-form-control>
                        <input nz-input [(ngModel)]="q.no" name="no" placeholder="请输入" id="no" />
                    </nz-form-control>
                </nz-form-item>
            </div>
            <div nz-col nzMd="8" nzSm="24">
                <nz-form-item>
                    <nz-form-label nzFor="status">使用状态</nz-form-label>
                    <nz-form-control>
                        <nz-select [(ngModel)]="q.status" name="status" id="status" [nzPlaceHolder]="'请选择'"
                            [nzShowSearch]="true">
                            <nz-option *ngFor="let i of status; let idx = index" [nzLabel]="i.text" [nzValue]="idx">
                            </nz-option>
                        </nz-select>
                    </nz-form-control>
                </nz-form-item>
            </div>
            <div nz-col nzMd="8" nzSm="24" *ngIf="expandForm">
                <nz-form-item>
                    <nz-form-label nzFor="callNo">调用次数</nz-form-label>
                    <nz-form-control>
                        <input nz-input id="callNo" />
                    </nz-form-control>
                </nz-form-item>
            </div>
            <div nz-col nzMd="8" nzSm="24" *ngIf="expandForm">
                <nz-form-item>
                    <nz-form-label nzFor="updatedAt">更新日期</nz-form-label>
                    <nz-form-control>
                        <nz-date-picker id="updatedAt" style="width: 100%;"></nz-date-picker>
                    </nz-form-control>
                </nz-form-item>
            </div>
            <div nz-col nzMd="8" nzSm="24" *ngIf="expandForm">
                <nz-form-item>
                    <nz-form-label nzFor="status2">使用状态</nz-form-label>
                    <nz-form-control>
                        <nz-select [nzPlaceHolder]="'请选择'" nzId="status2" [nzShowSearch]="true">
                            <nz-option *ngFor="let i of status; let idx = index" [nzLabel]="i.text" [nzValue]="idx">
                            </nz-option>
                        </nz-select>
                    </nz-form-control>
                </nz-form-item>
            </div>
            <div nz-col [nzSpan]="8" [class.text-right]="expandForm">
                <button nz-button type="button" [nzType]="'primary'" (click)="action(modalContent)">新增</button>
                <button nz-button type="submit" [nzType]="'primary'" [nzLoading]="loading">查询</button>
                <button nz-button type="reset" (click)="reset()" class="mx-sm">重置</button>
                <a (click)="expandForm = !expandForm">
                    {{ expandForm ? '收起' : '展开' }}
                    <i nz-icon [nzType]="expandForm ? 'up' : 'down'"></i>
                </a>
            </div>
        </div>
    </form>

    <ng-container *ngIf="selectedRows.length > 0">
        <button nz-button class="mb-md">批量操作</button>
        <button nz-button nz-dropdown [nzDropdownMenu]="batchMenu" nzPlacement="bottomLeft">
            更多操作
            <i nz-icon nzType="down"></i>
        </button>
        <nz-dropdown-menu #batchMenu="nzDropdownMenu">
            <ul nz-menu>
                <li nz-menu-item (click)="remove()">删除</li>
                <li nz-menu-item (click)="approval()">批量审批</li>
            </ul>
        </nz-dropdown-menu>
    </ng-container>
    <div>
        <nz-alert [nzType]="'info'" [nzShowIcon]="true" [nzMessage]="message">
            <ng-template #message>
                已选择
                <strong class="text-primary">{{ selectedRows.length }}</strong> 项&nbsp;&nbsp; 服务调用总计 <strong>{{
                    totalCallNo }}</strong> 万
                <a *ngIf="selectedRows.length > 0" (click)="clearCheck()" class="ml-lg">清空</a>
            </ng-template>
        </nz-alert>
    </div>

    <nz-table #rowSelectionTable nzShowPagination nzShowSizeChanger [nzData]="data">
        <thead>
            <tr>
                <th [(nzChecked)]="checkedAll" [nzIndeterminate]="indeterminate"
                    (nzCheckedChange)="onAllChecked($event)">
                </th>
                <th>No</th>
                <th>Name</th>
                <th>Description</th>
                <th>Option</th>
            </tr>
        </thead>
        <tbody>
            <tr *ngFor="let data of rowSelectionTable.data">
                <td [nzShowCheckbox]="true" [(nzChecked)]="data.checked" [nzDisabled]="data.disabled"
                    (nzCheckedChange)="onItemChecked($event,data)">
                </td>
                <td>{{ data.no }}</td>
                <td>{{ data.callNo }}</td>
                <td>{{ data.description }}</td>
                <td>
                    <a (click)="action(modalContent,data)">Edit</a>
                    <nz-divider nzType="vertical"></nz-divider>
                    <a (click)="deleteAction(data)">Delete </a>
                </td>
            </tr>
        </tbody>
    </nz-table>
</nz-card>



<ng-template #modalContent>
    <nz-form-item>
        <nz-form-label nzFor="no">描述</nz-form-label>
        <nz-form-control>
            <input nz-input [(ngModel)]="description" name="description" placeholder="请输入" id="no" />
        </nz-form-control>
    </nz-form-item>
</ng-template>