<template>
    <div id="UpdatePassword">
        <el-table
                ref="tableData"
                :data="tableData"
                tooltip-effect="dark"
                style="width: 100%"
        >
            <!--<el-table-column type="selection" align="center"> </el-table-column>-->
            <el-table-column type="index" label="序号" width="50" align="center"></el-table-column>
            <el-table-column property="bank_name" label="银行名称" align="center"> </el-table-column>
            <el-table-column property="push_count" label="推送" align="center"> </el-table-column>
            <el-table-column property="approval_count" label="审批" align="center"> </el-table-column>
            <el-table-column property="help_count" label="放款" align="center"> </el-table-column>
            <el-table-column property="refuse_count" label="否决" align="center"> </el-table-column>
            <el-table-column property="sum_money" label="授信总额(万元)" align="center"> </el-table-column>



            <el-table-column label="平均授信(万元)" align="center">
                <template slot-scope="scope">
                    <span>{{ getAppropriate(scope.row.avg_money)}}</span>
                </template>
            </el-table-column>

            <el-table-column label="平均时效(天)" align="center">
                <template slot-scope="scope">
                    <span>{{  getAppropriate(scope.row.avg_time) }}</span>
                </template>
            </el-table-column>

            <el-table-column label="平均利率(%)" align="center">
                <template slot-scope="scope">
                    <span>{{  getAppropriate(scope.row.avg_rate) }}</span>
                </template>
            </el-table-column>


            <el-table-column label="对接成功率(%)" align="center">
                <template slot-scope="scope">
                    <span>{{  getAppropriate(scope.row.success_probability) }}</span>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page.sync="currentPage"
                :page-sizes="[10, 20, 30, 40]"
                :page-size.sync="limit"
                background
                layout="total, sizes, prev, pager, next, jumper"
                :total="total"
        >
        </el-pagination>
    </div>
</template>

<script>
    import {bankAll} from '../../api';
    export default {
        name: 'UpdatePassword',
        props: {},
        components: {},
        data: () => ({
            tableData:[],
            currentPage: 1,
            limit: 10,
            total:0,
        }),
        created() {
            this.select();
        },
        computed: {},
        methods: {
            handleSizeChange(val) {
                this.$set(this, `currentPage`, 1);
                this.select({skip: 0, limit: val});
            },
            handleCurrentChange(val) {
                this.select({skip: (val - 1) * this.limit, limit: this.limit});
            },
            async select({skip = 0, limit = 10}= {}){
                const  result  = await  bankAll({skip , limit});
                console.log(result,"sdssadsadsadsadsadsadasdasdsadsadasdsa")
                this.$set(this, `tableData`, result.data);
                this.$set(this, `total`, result.total);
            },
            getAppropriate(data){
                let value  =data + '';
                if (value.indexOf('.') == -1){
                    return value
                }else {
                    let index = value.indexOf('.');
                    return  value.substring(0,index+3)
                }
            }
        },
        mounted() {
        }
    };
</script>

<style lang="less" scoped>
    /deep/ .el-pagination {
        padding: 26px 20px;
        background-color: white;
    }

    /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active {
        background-color: red;
    }

</style>
