<%@ page language="java" contentType="text/html; charset=utf-8"
         pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
    <meta name="renderer" content="webkit">
    <!-- 移动设备 viewport -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <jsp:include page="../../common.jsp" />
    <style>
        .layui-table th {
            text-align: center;
        }
    </style>
</head>

<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="search">
            <i class="layui-icon layui-icon-search"></i>
            查询
        </button>

    </div>
</script>

<body>
<div class="row animated fadeInRight" style="margin: 0;">
    <div class="wrapper wrapper-content mt5 right-content ml5 mr5">
        <div class="toolbar-panel bdd">
            <div class="toolbar-box">
                <div class="toolbar-head clearfix lgraybg pt5 pb10 pl10 bdbd">
                    <!-- 顶部按钮 -->
                    <div class="fl">
                        查询条件
                    </div>
                    <div class="tools fr">
                        <a href="javascript:void(0);" class="collapse dblock f14 dgray mr5">
                            <i class="fa-2x fa fa-angle-double-up"></i>
                        </a>
                    </div>
                </div>
            </div>
            <!--搜索条件 -->
            <div class="toolbar-body">
                <form class="layui-form" action="" lay-filter="condition" style="margin-top: 10px">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">用户ID</label>
                            <div class="layui-input-inline">
                                <input type="text" name="userId" id="userId" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">违规用户ID</label>
                            <div class="layui-input-inline">
                                <input type="text" name="causeUserId" id="causeUserId" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">结算身份证</label>
                            <div class="layui-input-inline">
                                <input type="text" name="idcardNo" id="idcardNo" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">注册手机号</label>
                            <div class="layui-input-inline">
                                <input type="text" name="regPhone" id="regPhone" class="layui-input">
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <!-- 表单数据 -->
    <div class="mb50 mt10">
        <div class="whitebg pl10 pr10">
            <table class="layui-hide" id="table" lay-filter="table"></table>
        </div>
    </div>
</div>

<script>

let form;
let table;

layui.use(['form', 'table'], function() {
    form = layui.form;
    table = layui.table;

    table.render({
        elem: '#table'
        , id: 'table'
        , url: ctx + '/riskBlacklist/page'
        , response: {
            statusCode: 200
        }
        , parseData: function (res) { //res 即为原始返回的数据
            return {
                "code": res.code, //解析接口状态
                "msg": res.message, //解析提示文本
                "count": res.data.total,
                "data": res.data.records
            };
        }
        , request: {
            pageName: 'current' //页码的参数名称，默认：page
            , limitName: 'size' //每页数据量的参数名，默认：limit
        }
        , even: true
        , title: '风控黑名单列表'
        , page: true //开启分页
        , defaultToolbar: ['filter']
        , toolbar: '#toolbarDemo'
        , cols: [[ //表头
             {type: 'checkbox', rowspan: 1}
            , {field: 'regPhone', title: '注册手机号', minWidth: 120}
            , {field: 'accountPhone', title: '结算手机号', minWidth: 130}
            , {field: 'idcardNo', title: '结算身份信息', minWidth: 228, templet: function (d) {
                    return d.idcardNo + " - " + d.certName;
                }}
            , {field: 'userId', title: '用户ID', minWidth: 80}
            , {field: 'causeUserId', title: '违规用户ID', minWidth: 100}
            , {field: 'remark', title: '违规信息', minWidth: 86}
            , {field: 'channel', title: '违规通道', minWidth: 86, templet: function(d) {
                    if (d.channel == '1') {
                        return "随行付";
                    }
                    if (d.channel == '3') {
                        return "瑞银信";
                    }
                    if (d.channel == '4') {
                        return '银盛';
                    }

                    return "-";
                }}
            , {field: 'payWay', title: '支付方式', minWidth: 86, templet: function(d) {
                    if (d.payWay == '01') {
                        return '支付宝';
                    }

                    if (d.payWay == '02') {
                        return '微信';
                    }

                    if (d.payWay == '03') {
                        return '银联';
                    }

                    return '-';
                }}
            , {field: 'createTime', title: '违规记录时间', minWidth: 160, templet : "<div>{{layui.util.toDateString(d.createTime,'yyyy-MM-dd HH:mm:ss')}}</div>"}
            , {field: 'userName', title: '实名姓名', minWidth: 86}
            , {field: 'alias', title: '商户简称', minWidth: 86}
            , {field: 'parentId', title: '上级ID', minWidth: 86}
            , {field: 'parentName', title: '上级姓名', minWidth: 86}
            , {field: 'grandParentId', title: '上上级ID', minWidth: 86}
            , {field: 'grandParentName', title: '上上级姓名', minWidth: 100}
        ]]
    });

    table.on('toolbar(table)', function (obj) {
       switch (obj.event) {
           case 'search':
               reload();
               break;
       }
    });
});

function reload() {
    debugger;
    let field = form.val('condition');
    table.reload("table", {
        where: field
    });
}
</script>
</body>
</html>
