<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>项目管理-待审核</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="decorator" content="base" />
    <link rel="stylesheet" type="text/css" href="${ctxPlugin}/static/css/reset.css" />
    <link rel="stylesheet" href="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/style/formSelects-v4.css" media="all">
    <link rel="stylesheet" type="text/css" href="${ctxPlugin}/lib/font/iconfont.css" />
</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="XMGL_XMGL_GDTAZSH_T" html='<a href="${ctx}/customerEntry/gdtazshCustomerList"><li class="layui-this">待审核管理</li></a>'/>
                <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" id="searchBtn" lay-submit lay-filter="LAY-user-back-search"><i class="layui-icon fs-12">&#xe615;</i>查询</button>
            </ul>
        </div>
        <div class="layui-card-body layuiadmin-card-header-auto" >
            <form class="layui-form layui-card" action="" id="searchForm">
            <div class="layui-form-item">
                <div class="layui-col-lg2 layui-col-sm3">
                    <label class="layui-form-label">产品编号：</label>
                    <div class="layui-input-block">
                        <select name="projectId" lay-search>
                            <option value="">请选择</option>
                            <c:forEach items="${projectList}" var="pro">
                                <option value="${pro.columns.id}" >${pro.columns.code}</option>
                            </c:forEach>

                        </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="projectName" 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" 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" 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="tenantAddress" 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="remarks" class="layui-input">
                    </div>
                </div>
                <%--<div class="layui-col-lg2 layui-col-sm3">
                    <label class="layui-form-label">安装方式：</label>
                    <div class="layui-input-block" >
                        <select name="method" >
                            <option value="">请选择</option>
                            <c:forEach items="${installWays}" var="installWay">
                                <option value="${installWay.columns.id}">${installWay.columns.name}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>--%>
                <div class="layui-col-lg2 layui-col-sm3">
                    <label class="layui-form-label">屋顶类型：</label>
                    <div class="layui-input-block" >
                        <select name="roofType" >
                            <option value="">请选择</option>
                            <option value="斜屋顶" >斜屋顶</option>
                            <option value="平屋顶" >平屋顶</option>
                        </select>
                    </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="开始日期">
                        </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="结束日期">
                        </div>
                    </div>
                </div>

            </div>
            </form>
        </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">
                <div class="layui-btn-container">
                    <button class="layui-btn layui-btn-sm" lay-event="export" id="exportBtn"><i class="layui-icon layui-icon-export"></i>导出列表</button>
                </div>
            </script>
        </div>
    </div>
</div>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/lib/formSelects-v4.js"></script>
<script>
    layui.config({
        base: '${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'tableExt', 'jquery', 'layer','laypage','laydate','form'], function(){
        //layui.use(['table','layer','laypage','laydate','form'], function(){
        $ = layui.$;
        tableExt = layui.tableExt;
        layer = layui.layer;
        laypage = layui.laypage;
        laydate = layui.laydate;
        form = layui.form;
        table = tableExt.getLayTable();

        var type = "${user.userType}";

        //开始日期
        var endStartTime = laydate.render({
            elem: '#createEndStartTime'
            /* ,type: 'datetime'*/
            ,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'
            /* ,type: 'datetime'*/
            ,done: function(value, date){
                //更新开始日期的最大日期
                endStartTime.config.max = lay.extend({}, date, {
                    month: date.month - 1
                });
            }
        });

        var toExamine = '${fns:checkPagePermission(request, "XMGL_XMGL_AZSH_T")}';

        tableExt.render({
            elem: '#test'
            , title:'待审核管理'
            , height: 'full-230'
            , toolbar: '#toolbarDemo'
            , defaultToolbar: false
            , limits : [ 20, 50, 100 ]
            , limit:20
            , page : true //开启分页
            , url: '${ctx}/customerEntry/getgdtazCustomerList'
            , cols: [[
                {type: 'numbers',fixed:'left',title:'序号'}
                , {field: 'id', title: '操作',minWidth:'180', sort: false, align: 'center',fixed: 'left', templet:function(d){
                        var html = "";


                        if(toExamine == '0'){
                            html +=  "<a href=\"#\" class=\"layui-table-link layui-icon  \" style='font-size:14px;' onclick=\"Prohibit('"+d.id+"')\">审核</a>&nbsp;&nbsp;";

                        }
                       if(!isBlank(html)){
                           return html;
                       }else {
                           return "--";
                       }


                    }}
                , {field: 'power_station_code', title: '电站编码',minWidth: 200, sort: false,fixed: 'left', align: 'center', exportable: true, templet: function(d){
                        var flag = d.flag;
                        var html="";
                        return html +  '<a href="#" class="layui-table-link" onclick="psDetail(\''+d.id+'\')">'+d.power_station_code+'</a>';
                    }}
                , {
                    field: 'sign_status',
                    title: '签约状态',
                    minWidth: '120',
                    sort: false,
                    fixed: 'left',
                    align: 'center',
                    exportable: true,
                    templet: function (d) {
                        if (d.sign_status === '1') {
                            return "待签约";
                        } else if (d.sign_status === '2') {
                            return "已签约";
                        } else if (d.sign_status === '3') {
                            return "待审核";
                        } else if (d.sign_status === '4') {
                            return "签署驳回";
                        } else if (d.sign_status === '5') {
                            return "已审核";
                        } else {
                            return "--";
                        }
                    },
                    expFormat: function (d) {
                        if (d.sign_status === '1') {
                            return "待签约";
                        } else if (d.sign_status === '2') {
                            return "已签约";
                        } else if (d.sign_status === '3') {
                            return "待审核";
                        } else if (d.sign_status === '4') {
                            return "签署驳回";
                        } else if (d.sign_status === '5') {
                            return "已审核";
                        } else {
                            return "--";
                        }
                    }
                }
                , {field: 'projectCode', title: '产品编号',minWidth:'130', sort: false, align: 'center',exportable:true}
                , {field: 'projectName', title: '产品名称',minWidth:'130', sort: false, align: 'center',exportable:true}
                , {
                    field: 'planName',
                    title: '方案名称',
                    minWidth: 150,
                    sort: false,
                    align: 'center',
                    exportable: true,
                    templet: function (d) {
                        if (d.scheme_type === '1') {
                            if (isBlank(d.scheme_id)) {
                                return '——';
                            }
                            return '<a href="#" class="layui-table-link" onclick="planDetail(\'' + d.id + '\')">' + d.scheme_name + '</a>';
                        } else if (isBlank(d.scheme_name)) {
                            return '<a href="#" class="layui-table-link" onclick="planDetail(\'' + d.id + '\')">查看方案</a>';
                        } else {
                            return '<a href="#" class="layui-table-link" onclick="planDetail(\'' + d.id + '\')">' + d.scheme_name + '</a>';
                        }
                    }
                }, {
                    field: 'province',
                    title: '项目名称',
                    minWidth: '180',
                    sort: false,
                    align: 'center',
                    exportable: true,
                    templet: function (d) {
                        return d.province + '' + d.area + d.tenant_name + d.actual_capacity / 1000 + "KW光伏电站";
                    },
                    expFormat: function (d) {
                        return d.province + '' + d.area + d.tenant_name + d.actual_capacity / 1000 + "KW光伏电站";
                    }
                }
                , {
                    field: 'design_capacity',
                    title: '设计安装容量(W)',
                    minWidth: 150,
                    sort: false,
                    align: 'center',
                    exportable: true
                }
                , {
                    field: 'distributorName',
                    title: '代理商名称',
                    minWidth: '150',
                    sort: false,
                    align: 'center',
                    exportable: true
                }
                , {
                    field: 'distributorMobile',
                    title: '代理商电话',
                    minWidth: '100',
                    sort: false,
                    align: 'center',
                    exportable: true
                }
                , {field: 'remarks', title: '备注', minWidth: 130, sort: false, align: 'center', exportable: true}
                , {field: 'tenant_name', title: '业主姓名', minWidth: '150', sort: false, align: 'center', exportable: true}
                , {field: 'address', title: '安装地址', minWidth: '100', sort: false, align: 'center', exportable: true}
                , {field: 'roof_type', title: '屋顶类型', minWidth: '100', sort: false, align: 'center', exportable: true}
                , {field: 'angle', title: '朝向角度(度)', minWidth: '100', sort: false, align: 'center', exportable: true}
                , {
                    field: 'product_line_name',
                    title: '产品线',
                    minWidth: '150',
                    sort: false,
                    align: 'center',
                    exportable: true
                }
                , {
                    field: 'product_line',
                    title: '业务属性',
                    minWidth: '100',
                    sort: false,
                    align: 'center',
                    exportable: true,
                    templet: function (d) {
                        return transAttribute(d.product_line);
                    },
                    expFormat: function (d) {
                        return transAttribute(d.product_line);
                    }
                }
                , {
                    field: 'project_company_name',
                    title: '所属项目公司',
                    minWidth: '150',
                    sort: false,
                    align: 'center',
                    exportable: true
                }
                , {field: 'remarks', title: '备注',minWidth:'150', sort: false, align: 'center',exportable:true}
                , {field: 'create_time', title: '登记时间',minWidth:'180', sort: false, align: 'center',exportable:true}
                , {field: 'examine_name', title: '审核人',minWidth:'100', sort: false, align: 'center',exportable:true}
                , {field: 'examine_remarks', title: '审核备注',minWidth:'150', sort: false, align: 'center',exportable:true}
                , {field: 'examine_time', title: '审核时间',minWidth:'180', sort: false, align: 'center',exportable:true}

            ]] ,done:function(res,cuss,count){
                $('span[data-pass="passed"]').parent().parent().parent().css('background-color','#ffeaf2');
                $('.layui-table-header .laytable-cell-checkbox input').attr('disabled','disabled');
            }
            ,exportOpt:{                           //导出选项配置
                ele:'#exportBtn',                   //导出的Dom元素
                headerTitle: '待审核管理',             //excel表格的标题
                pageData:false,                     //true:导出的数据为页面数据，false:最大导出maxAmount条数据
                maxAmount: 5000,                    //当pageData为false生效
                fileName: '待审核管理',
                where: function (){                 //当pageData为false时生效，过滤的条件
                    return _serializeJson($("#searchForm"));
                }
            }
        });

        function transAttribute(productLineAttribute) {
            switch (productLineAttribute) {
                case '1':
                    return '纯租25年业务';
                case '2':
                    return '经营性租赁';
                case '3':
                    return '融资租赁';
                case '4':
                    return '光伏贷';
                case '5':
                    return '全款';
                case '6':
                    return '其他';
                default:
                    return '';
            }
        }

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


    function searchOrder() {
        //执行重载
        var wherobj =_serializeJson($("#searchForm"));
        tableExt.reload('test', {
            where: wherobj
        });
    }

    //查看详情
    function psDetail(id){
        layer.open({
            type: 2
            , title: '电站详情'
            , content: '${ctx}/customerEntry/entryDetail?entryId=' + id
            , area: ['100%', '100%']
            , yes: function(index, layero){

            }
        });
    }

    function customerEntryFlag(id){
        layer.open({
            type: 2,
            content: "${ctx}/customerEntry/getFlagcustomerEntry?customerEntryId="+id //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
            ,title: "标记项目"
            ,area:["300px","260px"]
            ,closeBtn: 0
            ,shadeClose:true

        });
    }

    function editCustomerEntryFa(id){
        layer.open({
            type: 2,
            content: "${ctx}/customerEntry/getDqrCustomerEntryForm?entryId="+id //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
            ,area: ['83%','96%']
            ,title: false //不显示标题栏
            ,closeBtn: 0
            ,shadeClose:true
            /*,shade: 0.8*/
            /*  ,btn: ['确认生成', '取消']*/
            /*,btnAlign: 'c'*/
            /*,scrollbar:false*/
            ,cancel: function(){
                searchOrder();
            }
        });
    }

    function editCustomerEntry(id){
            layer.open({
                type: 2,
                content: "${ctx}/customerEntry/getUpdateCustomerEntryForm?entryId="+id //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
                ,area: ['83%','96%']
                ,title: false //不显示标题栏
                ,shade: 0.8
                /*  ,btn: ['确认生成', '取消']*/
                ,btnAlign: 'c'
                ,scrollbar:false
                ,cancel: function(){
                    searchOrder();
                }
            });
    }

    function findResult(id){
        layer.open({
            type: 2,
            title: '征信查询',
            content: '${ctx}/customerEntryExtra/findResult?id='+id,
            area : [ '650px', '316px' ],
            cancel:function(){
                table.reload('test'); //数据刷新
            }
        });
    }
    function preInputEntry(id){
        layer.open({
            type: 2,
            title: '进件申请',
            content: '${ctx}/customerEntryExtra/preInputEntry?id='+id,
            area: ['63%','85%']
        });
    }

    function lookInputEntryStatus(id,type){
        layer.open({
            type: 2,
            title: '查看进件状态',
            content: '${ctx}/customerEntryExtra/lookInputEntryStatus?id='+id+'&type='+type,
            area : [ '650px', '450px' ],
            cancel:function(){
                table.reload('test'); //数据刷新
            }
        });
    }

    function deleteWarranty(id){
        var indexla = layer.confirm('您确定要删除项目信息吗？', {
            icon: 3,
            btn: ['确定', '取消'] //按钮
        }, function () {
            $.ajax({
                type: "POST",
                url: "${ctx}/customerEntry/deleteCustomerEntry",
                data: {
                    cusId: id
                },
                success: function (result) {
                    if(result.code=='200'){
                        layer.msg('删除成功！', {icon: 1, time: 1000}, function () {
                            searchOrder();
                        });
                    }else {
                        console.log(result)
                        layer.msg('删除失败!', {icon: 2});
                    }
                },
                error:{
                }
            })
        }, function () {
            layer.close(indexla);
        });
    }

    function  admittance(id) {
        $.ajax({
            type: "POST",
            url: "${ctx}/customerEntry/shoudongCustomerEntry",
            data: {
                id: id
            },
            success: function (result) {
                if(result.code=='200'){
                    layer.msg('准入成功！', {icon: 1, time: 1000}, function () {
                        searchOrder();
                    });
                }else {
                    console.log(result)
                    layer.msg('准入失败!', {icon: 2});
                }
            },
            error:{
            }
        })
    }

    function Prohibit(id){
        layer.open({
            type: 2,
            content: "${ctx}/customerEntry/toGdtazMergeAccept?opt=fixAccept&id="+id //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
            ,area: ['100%', '100%']
            ,title: '审核信息' //不显示标题栏

        });
    }


    function planDetail(entryId){
        layer.open({
            type: 2,
            title: '查看',
            content: '${ctx}/planManage/viewMatchedPlan?entryId=' + entryId,
            area: ['80%','80%']
        });
    }

    function isBlank(val) {
        if (val == null || val == '' || val == undefined) {
            return true;
        }
        return false;
    }

    function reset(){
        layui.form.render();
        $("#searchForm").find("select").val("");
        $("#searchForm").find("input").val("");
    }
</script>
</body>
</html>

