<!-- start 面包屑 -->
<app-breadcrumb></app-breadcrumb>
<!-- end 面包屑 -->
<!--条件搜索-->

<div class="inner-content">
    <form nz-form [formGroup]="searchForm" (ngSubmit)="search(searchForm.value)">
        <div nz-row>
            <div nz-col nzSpan="8" *ngIf="roleType == 5 && adminFlag == 1">
                <nz-form-item>
                    <nz-form-label [nzSpan]="8">部门</nz-form-label>
                    <nz-form-control [nzSpan]="14">
                        <nz-select nzShowSearch nzAllowClear formControlName="orgId">
                            <nz-option *ngFor="let item of orgArray" nzLabel="{{item.name}}" nzValue="{{item.id}}"></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 nzShowSearch nzAllowClear formControlName="type">
                            <nz-option nzLabel="进账" nzValue="1"></nz-option>
                            <nz-option nzLabel="出账" nzValue="2"></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 nzShowSearch nzAllowClear formControlName="sourceType">
                            <nz-option nzLabel="金额充值" nzValue="1"></nz-option>
                            <nz-option nzLabel="油卡充值" nzValue="2"></nz-option>
                            <nz-option nzLabel="回收余额" nzValue="3"></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-range-picker
                                formControlName="createTime"
                                [nzShowTime]="{ nzHideDisabledOptions: true}"
                                nzFormat="yyyy-MM-dd HH:mm:ss"
                        ></nz-range-picker>
                    </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">
    <div *ngIf="roleType == 5 && adminFlag == 0" style="width: 100%;text-align: center;">
        <nz-row [nzGutter]="16">
            <nz-col [nzSpan]="24">
                <nz-statistic [nzValue]="'￥' + accountObject['amounts']" [nzTitle]="'账户余额'"></nz-statistic>
            </nz-col>
        </nz-row>
    </div>
    <span>共计 {{dataObject.total?dataObject.total:0}} 条数据</span>
    <div class="operating-button">
        <button *ngIf="roleType ==  5 && adminFlag == 1" nz-button nzType="primary" class="right-btn" (click)="showRechargeModal()" ><i nz-icon nzType="plus" nzTheme="outline"></i>账户充值</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="130px" *ngIf="roleType == 5 && adminFlag == 1">部门</th>
            <th nzWidth="100px">类型</th>
            <th nzWidth="100px">交易金额</th>
            <th nzWidth="120px">变更前金额</th>
            <th nzWidth="120px">变更后金额</th>
            <th nzWidth="100px">来源类型</th>
            <th nzWidth="300px">来源内容</th>
            <th nzWidth="130px">操作人</th>
            <th nzWidth="200px">记录时间</th>
           <!-- <th nzWidth="100px" nzRight="0px">操作</th>-->
        </tr>
        </thead>
        <tbody>
        <tr *ngFor="let data of basicTable.data;let i = index">
            <td *ngIf="roleType == 5 && adminFlag == 1">{{data.orgName}}</td>
            <td>{{data.type | companyAmountRecordType}}</td>
            <td>￥{{data.amount}}</td>
            <td>￥{{data.beforeAmount}}</td>
            <td>￥{{data.afterAmount}}</td>
            <td>{{data.sourceType | companyAmountRecordSourceType}}</td>
            <td>{{data.sourceContent}}</td>
            <td>{{data.opUserName}}</td>
            <td>{{data.createTime | 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><a [routerLink]="['/admin/tuanyou-agent/agent-edit']" [queryParams]="{agentKey: data.agentKey}">修改</a></li>
                    </ul>
                </nz-dropdown-menu>
            </td>-->
        </tr>
        </tbody>
    </nz-table>
</div>

<nz-modal [(nzVisible)]="rechargeModal" nzTitle="账户充值" (nzOnCancel)="closeRechargeModal()" nzWidth="500px" [nzFooter]="null">
    <form nz-form [formGroup]="rechargeForm">
        <nz-form-item>
            <nz-form-label [nzSpan]="6" nzRequired >部门</nz-form-label>
            <nz-form-control [nzSpan]="14">
                <nz-select nzShowSearch nzAllowClear nzPlaceHolder="请选择部门" formControlName="orgId">
                    <nz-option *ngFor="let data of orgArray" nzLabel="{{data.name}}" nzValue="{{data.id}}"></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-input-number style="width: 100%" formControlName="amount" [nzMin]="0" [nzMax]="9999999" [nzStep]="1" [nzPrecision]="2"></nz-input-number>
            </nz-form-control>
        </nz-form-item>
        <nz-form-item>
            <nz-form-label [nzSpan]="6" nzRequired >验证码</nz-form-label>
            <nz-form-control [nzSpan]="14">
                <nz-input-group nzSearch [nzAddOnAfter]="suffixButton">
                    <input nz-input formControlName="smsCode" />
                </nz-input-group>
                <ng-template #suffixButton>
                    <button nz-button nzType="primary" [disabled]="smsCodeBtnLoading" (click)="sendSmsCode()">{{smsCodeBtnName}}</button>
                </ng-template>
                <span *ngIf="smsCodeBtnLoading" nz-typography nzType="warning">验证码已发送！5分钟内有效</span>
            </nz-form-control>
        </nz-form-item>
        <div style="text-align: center;">
            <button nz-button nzType="primary" style="width: 150px;" [nzLoading]="submitRechargeBtnLoading" (click)="submitRecharge()">确定</button>
        </div>
    </form>
</nz-modal>
