<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE HTML>
<html>
<head>
    <title>能辉</title>
    <meta name="decorator" content="base" />
    <link rel="stylesheet" href="${ctxPlugin}/static/css/reset.css" media="all">
    <style>
        .layui-card{box-shadow: none;}
        /*.layui-btn + .layui-btn {
            margin-left: 35px;
        }*/
    </style>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-form layui-card">
        <div class="layui-tab  layui-tab-brief">
            <ul class="layui-tab-title">
                <sfTags:pagePermission authFlag="DZBG_KHXXBG_DSH_T" html='<li class="sf-tab"><a href="${ctx}/entryChanges/customerInformationChange/changeWaitAuditList">待审核</a></li>'/>
                <sfTags:pagePermission authFlag="DZBG_KHXXBG_BGJL_T" html='<li class="layui-this sf-tab"><a href="${ctx}/entryChanges/customerInformationChange/changeList">变更记录</a></li>'/>
                <button class="layui-btn f-r mt-10 mr-15 pl-10 pr-10 " type="reset"  onclick="reset()" >
                    <i class="layui-icon fs-12">&#xe9aa;</i>
                    重置
                </button>
                <button class="layui-btn f-r mt-10 mr-15 pl-10 pr-10 " lay-submit lay-filter="LAY-user-back-search" data-type="reload">
                    <i class="layui-icon fs-12">&#xe615;</i>
                    查询
                </button>
            </ul>
        </div>
        <div class="layui-card-body" id="searchForm">
            <div class="layui-form-item">
                <input hidden name="status" value="3,4,0">
                <div class="layui-col-lg2 layui-col-sm3">
                    <label class="layui-form-label">变更状态：</label>
                    <div class="layui-input-block">
                        <select name="auditStatus" lay-search>
                            <option value="">请选择</option>
                            <option value="3">审核通过</option>
                            <option value="4">审核驳回</option>
                            <option value="0">已撤回</option>
                        </select>
                    </div>
                </div>
                <div class="layui-col-lg2 layui-col-sm3">
                    <label class="layui-form-label">变更单号：</label>
                    <div class="layui-input-block">
                        <input type="text" name="number" id="number" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-col-lg2 layui-col-sm3">
                    <label class="layui-form-label">电站编号：</label>
                    <div class="layui-input-block">
                        <input type="text" name="powerStationCode" id="powerStationCode" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-col-lg2 layui-col-sm3">
                    <label class="layui-form-label">业主姓名：</label>
                    <div class="layui-input-block">
                        <input type="text" name="tenantName" id="tenantName" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-col-lg4 layui-col-sm6">
                    <label class="layui-form-label">申请时间：</label>
                    <div class="layui-input-block">
                        <div class="layui-col-xs5">
                            <input type="text" name="createTimeMin" class="layui-input" id="createEndStartTime" placeholder="开始日期" autocomplete="off">
                        </div>
                        <div class="layui-col-xs2 text-c lh-30">
                            —
                        </div>
                        <div class="layui-col-xs5">
                            <input type="text" name="createTimeMax" class="layui-input" id="createEndEndTime" placeholder="结束日期" autocomplete="off">
                        </div>
                    </div>
                </div>

                <div class="layui-col-lg4 layui-col-sm6">
                    <label class="layui-form-label">审核时间：</label>
                    <div class="layui-input-block">
                        <div class="layui-col-xs5">
                            <input type="text" name="auditStartTime" class="layui-input" id="auditStartTime" placeholder="开始日期" autocomplete="off">
                        </div>
                        <div class="layui-col-xs2 text-c lh-30">
                            —
                        </div>
                        <div class="layui-col-xs5">
                            <input type="text" name="auditEndTime" class="layui-input" id="auditEndTime" placeholder="结束日期" autocomplete="off">
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>

    <div class='layui-card'>
        <div class="layui-card-body">
            <table class="layui-hide" lay-skin="row" id="test" lay-filter="test"></table>
            <script type="text/html" id="toolbarDemo">
                <sfTags:pagePermission authFlag="DZBG_KHXXBG_BGJL_DC_B" html='<button class="layui-btn layui-btn-sm" lay-event="export" id="exportBtn"><i class="layui-icon layui-icon-export"></i>导出列表</button>'/>
            </script>
        </div>
    </div>

</div>


<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>

<script type="text/javascript">
    var table;
    var $;
    layui.config({
        base: '${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'tableExt', 'jquery', 'layer','laydate','form'], function(){
        $ = layui.jquery;
        tableExt = layui.tableExt;
        var layer = layui.layer;
        var laydate = layui.laydate;
        var  form = layui.form;
        table = tableExt.getLayTable();
        //开始日期
        var endStartTime = laydate.render({
            elem: '#createEndStartTime'
            ,done: function(value, date){
                //更新结束日期的最小日期
                endEndTime.config.min = lay.extend({}, date, {
                    month: date.month - 1
                });
                //自动弹出结束日期的选择器
                endEndTime.config.elem[0].focus();
            }
        });
        //结束日期
        var endEndTime = laydate.render({
            elem: '#createEndEndTime'
            ,done: function(value, date){
                //更新开始日期的最大日期
                endStartTime.config.max = lay.extend({}, date, {
                    month: date.month - 1
                });
            }
        });

        //开始日期
        var auditStartTime = laydate.render({
            elem: '#auditStartTime'
            ,done: function(value, date){
                //更新结束日期的最小日期
                auditEndTime.config.min = lay.extend({}, date, {
                    month: date.month - 1
                });
                //自动弹出结束日期的选择器
                auditEndTime.config.elem[0].focus();
            }
        });
        //结束日期
        var auditEndTime = laydate.render({
            elem: '#auditEndTime'
            ,done: function(value, date){
                //更新开始日期的最大日期
                auditStartTime.config.max = lay.extend({}, date, {
                    month: date.month - 1
                });
            }
        });
        var lookExamine = '${fns:checkPagePermission(request, "DZBG_KHXXBG_BGJL_CK_B")}';
        tableExt.render({
            elem: '#test'
            ,toolbar : '#toolbarDemo'
            , height: 'full-180'
            ,defaultToolbar : false
            , limits : [ 20, 50, 100 ]
            , limit:20
            , page : true //开启分页
            ,url: '${ctx}/entryChanges/customerInformationChange/getListData?status=3,4,0'
            ,cols: [[
                {type: 'numbers',title:'序号'}
              /*  ,{field:'id', title: '操作',toolbar: '#table-toolbar',align: 'center',minWidth: 150}*/
                ,{field:'number', title: '变更单号',align: 'center',exportable: true
                ,templet:function (d){
                      if(lookExamine==0){
                          return '<a href="#" class="layui-table-link" onclick="lookDetail(\'' + d.id + '\')">' + d.number + '</a>';
                      }else {
                          return d.number;
                      }
                    }
                }
                ,{field:'status', title: '变更状态',align: 'center',exportable: true
                    ,templet:function(d){
                        if(d.status=='3'){
                            return "审核通过";
                        }else if(d.status=='4'){
                            return "审核驳回";
                        }else if(d.status=='0'){
                            return "已撤回";
                        }else{
                            return "";
                        }
                    },expFormat:function(d){
                        if(d.status=='3'){
                            return "审核通过";
                        }else if(d.status=='4'){
                            return "审核驳回";
                        }else if(d.status=='0'){
                            return "已撤回";
                        }else{
                            return "";
                        }
                    }
                }
                ,{field:'change_count', title: '变更次数',align: 'center',exportable: true}
                , {field: 'change_status', title: '资方审核状态', minWidth: '100', sort: false, align: 'center', exportable: true
                    ,templet: function (d) {
                        let info = "";
                        if (d.change_type == '1'){
                            info = "业主信息变更";
                        }else if (d.change_type == '7'){
                            info = "电站地址变更";
                        }
                        if(d.change_status=='10' || d.change_status=='40'){
                            return info+"审批拒绝";
                        }else if(d.change_status=='20'){
                            return info+"待审核";
                        }else if(d.change_status=='15'){
                            return info+"审核中";
                        }else if(d.change_status=='30'){
                            return info+"审核通过";
                        }
                        return "";
                    },
                    expFormat: function (d) {
                        let info = "";
                        if (d.change_type == '1'){
                            info = "业主信息变更";
                        }else if (d.change_type == '7'){
                            info = "电站地址变更";
                        }
                        if(d.change_status=='10' || d.change_status=='40'){
                            return info+"审批拒绝";
                        }else if(d.change_status=='20'){
                            return info+"待审核";
                        }else if(d.change_status=='15'){
                            return info+"审核中";
                        }else if(d.change_status=='30'){
                            return info+"已完成";
                        }
                        return "";
                    }
                }
                , {field: 'change_reason', title: '资方审核结果', minWidth: '100', sort: false, align: 'center', exportable: true}
                ,{field:'power_station_code', title: '电站编号',align: 'center',exportable: true}
                ,{field:'tenant_name', title: '业主姓名',align: 'center',exportable: true}
                ,{field:'id_code', title: '身份证号',align: 'center',exportable: true}
                ,{field:'create_name', title: '变更申请人',align: 'center',exportable: true}
                ,{field:'createTime', title: '申请时间',align: 'center',exportable: true}
                ,{field:'tenant_name', title: '审核人',align: 'center',exportable: true}
                ,{field:'auditTime', title: '审核时间',align: 'center',exportable: true}
            ]]
            ,done: function(res, curr, count){

            },exportOpt:{                           //导出选项配置
                ele:'#exportBtn',                   //导出的Dom元素
                headerTitle: '客户信息变更-变更记录',             //excel表格的标题
                pageData:false,                     //true:导出的数据为页面数据，false:最大导出maxAmount条数据
                maxAmount: 1000,                    //当pageData为false生效
                fileName: '客户信息变更-变更记录',
                where: function (){                 //当pageData为false时生效，过滤的条件
                    return _serializeJson($("#searchForm"));
                }
            }
        });

        //头工具栏事件
        table.on('toolbar(test)', function (obj) {
            switch (obj.event){
                case 'add':
                    layer.open({
                        title:'新增',
                        type: 2,
                        area: ["90%", "90%"],
                        content: '${ctx}/set/process/addProcessPage'
                    })
                    break;

            }
        })

        //监听行工具事件
        table.on('tool(test)', function(obj){
            var data = obj.data;
        });

        //监听搜索
        form.on('submit(LAY-user-back-search)', function(data){
            var field = data.field;
            //执行重载
            table.reload('test', {
                where: field,
                page:{
                    curr:1
                }
            });
        });



    });


    function lookDetail(id){
        layer.open({
            title:'变更详情',
            type: 2,
            area: ["100%", "100%"],
            content: '${ctx}/entryChanges/customerInformationChange/toChangeAudit?form=look&id='+id
        })
    }

    function reload(){
        table.reload('test', {
            page:{
                curr:1
            }
        });
    }

    function reset(){
        layui.form.render();
        $("#searchForm").find("select").val("");
        $("#searchForm").find("input").val("");
    }

</script>
</body>
</html>


