<title>用户提现记录表</title>
<!--当前位置开始-->
<div class="layui-card layadmin-header">
    <div class="layui-breadcrumb" lay-filter="breadcrumb">
        <script type="text/html" template lay-done="layui.data.updateMainBreadcrumb();">
        </script>
    </div>
</div>
<!--当前位置结束-->
<style>
    /* 重写样式 */
</style>
<script type="text/html" template lay-type="Post" lay-url="{{ layui.setter.apiUrl }}Api/CoreCmsUserTocash/GetIndex" lay-done="layui.data.done(d);">
    <div class="layui-form coreshop-search-form">
        <div class="layui-form-item">
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input type="text" name="userId" id="userId" placeholder="请输入用户序列" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input type="text" name="accountName" id="accountName" placeholder="请输入账户名" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <select name="status" id="status" lay-filter="conditionCode">
                        <option value="">请选择提现状态</option>
                        {{# layui.each(d.data.userTocashTypes, function(index, item){ }}
                        <option value="{{ item.value }}">{{ item.title }}</option>
                        {{# }); }}
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <div class="layui-input-inline" style="width: 260px;">
                    <input type="text" name="createTime" id="searchTime-CoreCmsUserTocash-createTime" placeholder="请输入起止时间" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <button class="layui-btn layui-btn-sm" lay-submit lay-filter="LAY-app-CoreCmsUserTocash-search"><i class="layui-icon layui-icon-search"></i>筛选</button>
            </div>
        </div>
    </div>
</script>
<div class="table-body">
    <table id="LAY-app-CoreCmsUserTocash-tableBox" lay-filter="LAY-app-CoreCmsUserTocash-tableBox"></table>
</div>

<script type="text/html" id="LAY-app-CoreCmsUserTocash-toolbar">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="selectExportExcel"><i class="layui-icon layui-icon-add-circle"></i>选择导出</button>
        <button class="layui-btn layui-btn-sm" lay-event="queryExportExcel"><i class="layui-icon layui-icon-download-circle"></i>查询导出</button>
    </div>
</script>

<script>
    var indexData;
    var debug = layui.setter.debug;
    layui.data.done = function (d) {
        //开启调试情况下获取接口赋值数据
        if (debug) { console.log(d); }

        indexData = d.data;
        layui.use(['index', 'table', 'laydate', 'util', 'coreHelper'],
            function () {
                var $ = layui.$
                    , admin = layui.admin
                    , table = layui.table
                    , form = layui.form
                    , laydate = layui.laydate
                    , setter = layui.setter
                    , coreHelper = layui.coreHelper
                    , util = layui.util
                    , view = layui.view;

                laydate.render({
                    elem: '#searchTime-CoreCmsUserTocash-createTime',
                    type: 'datetime',
                    range: '到',
                });
                //重载form
                form.render();
                var searchwhere;
                //监听搜索
                form.on('submit(LAY-app-CoreCmsUserTocash-search)',
                    function (data) {
                        var field = data.field;
                        searchwhere = field;
                        //执行重载
                        table.reload('LAY-app-CoreCmsUserTocash-tableBox', { where: field });
                    });
                //数据绑定
                table.render({
                    elem: '#LAY-app-CoreCmsUserTocash-tableBox',
                    url: layui.setter.apiUrl + 'Api/CoreCmsUserTocash/GetPageList',
                    method: 'POST',
                    toolbar: '#LAY-app-CoreCmsUserTocash-toolbar',
                    defaultToolbar: ['filter', 'print', 'exports'],
                    height: 'full-189',//无面包屑127,搜索框189,1行62
                    page: true,
                    limit: 30,
                    limits: [10, 15, 20, 25, 30, 50, 100, 200],
                    text: { none: '暂无相关数据' },
                    cols: [
                        [
                            { type: "checkbox", fixed: "left" },
                            { field: 'id', title: 'ID号', width: 60, sort: false },
                            {
                                field: 'userNickName', title: '用户', sort: false, width: 105, templet: function (d) {
                                    return d.userNickName + '（' + d.userId + '）';
                                }
                            },
                            {
                                field: 'operating', title: '操作', width: 100, align: 'center', templet: function (data) {
                                    var html = '';
                                    if (data.status == 1) {
                                        html += '<a  class="layui-btn layui-btn-xs option-yes" data-type="2" data-id="' + data.id + '">通过</a>';
                                        html += '<a  class="layui-btn layui-btn-danger layui-btn-xs option-no" data-type="3" data-id="' + data.id + '" >驳回</a>';
                                    }
                                    return html;
                                }
                            },
                            { field: 'money', title: '提现金额', sort: false, width: 80, templet: function (data) { return '￥' + data.money }  },
                            { field: 'bankName', title: '银行名称', sort: false, width: 105 },
                            { field: 'bankCode', title: '银行缩写', sort: false, width: 65 },
                            //{ field: 'bankAreaId', title: '账号地区ID', sort: false, width: 105 },
                            { field: 'accountBank', title: '开户行', sort: false },
                            { field: 'accountName', title: '账户名', sort: false, width: 105 },
                            { field: 'cardNumber', title: '卡号', sort: false, width: 145 },
                            { field: 'withdrawals', title: '提现服务费', sort: false, width: 85 },
                            {
                                field: 'status', title: '提现状态', sort: false, width: 65, templet: function (data) {
                                    for (var i = 0; i < d.data.userTocashTypes.length; i++) {
                                        if (data.status == d.data.userTocashTypes[i].value) {
                                            return d.data.userTocashTypes[i].title;
                                        }
                                    }
                                    return "";
                                }
                            },
                            { field: 'createTime', title: '创建时间', width: 130, sort: false },
                            { field: 'updateTime', title: '更新时间', width: 130, sort: false },
                        ]
                    ]
                });
                //监听排序事件
                table.on('sort(LAY-app-CoreCmsUserTocash-tableBox)', function (obj) {
                    table.reload('LAY-app-CoreCmsUserTocash-tableBox', {
                        initSort: obj, //记录初始排序，如果不设的话，将无法标记表头的排序状态。
                        where: { //请求参数（注意：这里面的参数可任意定义，并非下面固定的格式）
                            orderField: obj.field, //排序字段
                            orderDirection: obj.type //排序方式
                        }
                    });
                });
                //头工具栏事件
                table.on('toolbar(LAY-app-CoreCmsUserTocash-tableBox)', function (obj) {
                    var checkStatus = table.checkStatus(obj.config.id);
                    switch (obj.event) {
                        case 'selectExportExcel':
                            doSelectExportExcel(checkStatus);
                            break;
                        case 'queryExportExcel':
                            doQueryExportexcel();
                            break;
                    };
                });
                //监听工具条
                table.on('tool(LAY-app-CoreCmsUserTocash-tableBox)',
                    function (obj) {
                        if (obj.event === 'detail') {
                            doDetails(obj);
                        }
                    });
                //执行预览操作
                function doDetails(obj) {
                    coreHelper.Post("Api/CoreCmsUserTocash/GetDetails", { id: obj.data.id }, function (e) {
                        if (e.code === 0) {
                            admin.popup({ shadeClose: false,
                                title: '查看详情',
                                area: ['600px', '400px'],
                                id: 'LAY-popup-CoreCmsUserTocash-details',
                                success: function (layero, index) {
                                    view(this.id).render('base/CoreCmsUserTocash/details', { data: e.data }).done(function () {
                                        form.render();
                                    });
                                }
                            });
                        } else {
                            layer.msg(e.msg);
                        }
                    });
                }
                //执行查询条件导出excel
                function doQueryExportexcel() {
                    layer.confirm('确定根据当前的查询条件导出数据吗？',
                        function (index) {
                            var field = searchwhere;
                            coreHelper.PostForm("Api/CoreCmsUserTocash/QueryExportExcel", field, function (e) {
                                if (debug) { console.log(e); } //开启调试返回数据
                                if (e.code === 0) {
                                    window.open(e.data);
                                } else {
                                    layer.msg(e.msg);
                                }
                            });
                        });
                }
                //执行选择目录导出数据
                function doSelectExportExcel(checkStatus) {
                    var checkData = checkStatus.data;
                    if (checkData.length === 0) {
                        return layer.msg('请选择您要导出的数据');
                    }
                    layer.confirm('确定导出选择的内容吗？',
                        function (index) {
                            var delidsStr = [];
                            layui.each(checkData,
                                function (index, item) {
                                    delidsStr.push(item.id);
                                });
                            layer.close(index);
                            coreHelper.Post("Api/CoreCmsUserTocash/SelectExportExcel", { id: delidsStr }, function (e) {
                                if (debug) { console.log(e); } //开启调试返回数据
                                if (e.code === 0) {
                                    window.open(e.data);
                                } else {
                                    layer.msg(e.msg);
                                }
                            });
                        });
                }
                //监听 表格复选框操作
                //审核驳回
                $(document).on('click', '.option-no', function () {
                    var id = $(this).attr('data-id');
                    var type = $(this).attr('data-type');
                    layer.confirm('您确定做此操作吗？', {
                        btn: ['确认', '取消'] //按钮
                    }, function () {
                        coreHelper.Post("Api/CoreCmsUserTocash/SetStatus", { 'id': id, 'data': type }, function (e) {
                            if (debug) { console.log(e); } //开启调试返回数据
                            if (e.code === 0) {
                                layui.table.reload('LAY-app-CoreCmsUserTocash-tableBox'); //重载表格
                                layer.msg(e.msg);
                            } else {
                                layer.msg(e.msg);
                            }
                        });
                    }, function () {
                        layer.close(1);
                    });
                });
                //审核通过
                $(document).on('click', '.option-yes', function () {
                    var id = $(this).attr('data-id');
                    var type = $(this).attr('data-type');
                    layer.confirm('您确定做此操作吗？', {
                        btn: ['确认', '取消'] //按钮
                    }, function () {
                        coreHelper.Post("Api/CoreCmsUserTocash/SetStatus", { 'id': id, 'data': type }, function (e) {
                            if (debug) { console.log(e); } //开启调试返回数据
                            if (e.code === 0) {
                                layui.table.reload('LAY-app-CoreCmsUserTocash-tableBox'); //重载表格
                                layer.msg(e.msg);
                            } else {
                                layer.msg(e.msg);
                            }
                        });
                    }, function () {
                        layer.close(1);
                    });
                });
            });
    };
</script>