<%@ 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">
</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_HSZ_T_${partner}" html='<a href="${ctx}/customerEntry/findRecycleBinList/${partner}"><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>
        <form class="layui-card-body layuiadmin-card-header-auto" 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">
                        <input type="text" name="powerStationCode" id="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" id="tenantName" class="layui-input">
                    </div>
                </div>
                <c:if test="${user.userType ne '6' && user.userType ne '7'}">
                    <div class="layui-col-lg2 layui-col-sm3" style="width: 33.3%">
                        <label class="layui-form-label">代理商名称：</label>
                        <div class="layui-input-block" >
                            <select name="traderId" id="traderId" lay-search>
                                <option value="">请选择</option>
                                <c:forEach items="${traderList}" var="trader">
                                    <option value="${trader.columns.id}">${trader.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">--%>
<%--                            <input type="text" name="traderMobile" id="traderMobile" 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="checkAcceptBy" id="checkAcceptBy">
                                <option value="">请选择</option>
                                <c:forEach items="${empList}" var="emp">
                                    <option value="${emp.columns.user_id}">${emp.columns.name}</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                </c:if>
                <c:if test="${'2' ne ifTop}">
                    <div class="layui-col-lg2 layui-col-sm3" style="width: 33.3%">
                        <label class="layui-form-label">二级代理商：</label>
                        <div class="layui-input-block">
                            <select name="twoTrader" lay-search>
                                <option value="">请选择</option>
                                <c:forEach items="${twoTrader}" var="trader">
                                    <option value="${trader.columns.id}">${trader.columns.name}</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                </c:if>
                <%--<div class="layui-col-lg2 layui-col-sm3">
                    <label class="layui-form-label">安装地址：</label>
                    <div class="layui-input-block">
                        <input type="text" name="tenantAddress" id="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">
                        <select name="installWay" id="installWay">
                            <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">
                        <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" >
                        <select name="projectCode" id="projectId">
                            <option value="">请选择</option>
                            <c:forEach items="${projectList}" var="project">
                                <option value="${project.columns.id}">${project.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" >
                        <select name="roofType" id="roofType">
                            <option value="">请选择</option>
                            <option value="平屋顶">平屋顶</option>
                            <option value="斜屋顶">斜屋顶</option>
                            <option value="庭院">庭院</option>
                        </select>
                    </div>
                </div>
                <div class="layui-col-lg2 layui-col-sm3">
                    <label class="layui-form-label">方案类型：</label>
                    <div class="layui-input-block" >
                        <select name="plan" id="plan">
                            <option value="">请选择</option>
                            <c:forEach items="${plans}" var="plan">
                                <option value="${plan.columns.id}">${plan.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">--%>
<%--                        <input type="text" name="remarks" id="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="deliverBy" id="deliverBy">
                            <option value="">请选择</option>
                            <c:forEach items="${empList}" var="emp">
                                <option value="${emp.columns.user_id}">${emp.columns.name}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="layui-col-lg4 layui-col-sm6">
                    <label class="layui-form-label">状态：</label>
                    <div class="layui-input-block" >
                        <select name="status" id="status" xm-select="ProvinceName" xm-select-type="1" xm-select-height="25px" xm-select-show-count="6" >
                            <option value="">请选择</option>
                            <option value="1">待审核</option>
                            <option value="2">审核驳回</option>
                            <option value="3">待下单</option>
                            <option value="4">待收货</option>
                            <option value="5">待安装</option>
                            <option value="6">待并网</option>
                            <option value="7">待验收</option>
                            <option value="10">验收驳回</option>
                            <option value="8">待交付</option>
                            <option value="9">待归档</option>
                            <option value="11">归档驳回</option>
                            <option value="a">已完成</option>
                        </select>
                    </div>
                </div>
                <div class="layui-col-lg6 layui-col-sm6">
                    <label class="layui-form-label">安装地址：</label>
                    <div class="layui-input-block">
                        <div class="layui-col-lg2 layui-col-sm2 pr-10">
                            <select name="province" id="province"
                                    lay-filter="province" lay-search>
                                <option value="">请选择省</option>
                                <c:forEach items="${pros}" var="pro">
                                    <option value="${pro.columns.ProvinceName}"
                                            title="${pro.columns.ProvinceID }"
                                            <c:if test="${entry.province eq pro.columns.ProvinceName}">selected</c:if>>${pro.columns.ProvinceName}</option>
                                </c:forEach>
                            </select>
                        </div>
                        <div class="layui-col-lg2 layui-col-sm2 pr-10">
                            <select name="city" id="city"  lay-filter="city"
                                    lay-search>
                                <option value="">请选择市</option>

                            </select>
                        </div>
                        <div class="layui-col-lg2 layui-col-sm2 pr-10">
                            <select name="area" id="area"  lay-search>
                                <option value="">请选择县/区</option>

                            </select>
                        </div>
                        <div class="layui-col-lg6 layui-col-sm6">

                            <input type="text" name="address"
                                   autocomplete="off" class="layui-input layui-col-lg2 "
                                   value="${entry.customerAddress}">
                        </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" readonly name="createTimeMin" class="layui-input" id="createEndStartTime" placeholder="开始日期" value="${monthAgo}">
                        </div>
                        <div class="layui-col-xs2 text-c lh-30">
                            —
                        </div>
                        <div class="layui-col-xs5">
                            <input type="text" readonly name="createTimeMax" class="layui-input" id="createEndEndTime" placeholder="结束日期" value="${today}">
                        </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" readonly name="matchTimeMin" class="layui-input" id="matchTimeMin" placeholder="开始日期">
                        </div>
                        <div class="layui-col-xs2 text-c lh-30">
                            —
                        </div>
                        <div class="layui-col-xs5">
                            <input type="text" readonly name="matchTimeMax" class="layui-input" id="matchTimeMax" placeholder="结束日期">
                        </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" readonly name="installTimeMin" class="layui-input" id="installEndStartTime" placeholder="开始日期">
                        </div>
                        <div class="layui-col-xs2 text-c lh-30">
                            —
                        </div>
                        <div class="layui-col-xs5">
                            <input type="text" readonly name="installTimeMax" class="layui-input" id="installEndEndTime" placeholder="结束日期">
                        </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" readonly name="mergeTimeMin" class="layui-input" id="mergeEndStartTime" placeholder="开始日期">
                        </div>
                        <div class="layui-col-xs2 text-c lh-30">
                            —
                        </div>
                        <div class="layui-col-xs5">
                            <input type="text" readonly name="mergeTimeMax" class="layui-input" id="mergeEndEndTime" placeholder="结束日期">
                        </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" readonly name="checkAcceptTimeMin" class="layui-input" id="acceptEndStartTime" placeholder="开始日期">
                        </div>
                        <div class="layui-col-xs2 text-c lh-30">
                            —
                        </div>
                        <div class="layui-col-xs5">
                            <input type="text" readonly name="checkAcceptTimeMax" class="layui-input" id="acceptEndEndTime" placeholder="结束日期">
                        </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" readonly name="deliverTimeMin" class="layui-input" id="deliverEndStartTime" placeholder="开始日期">
                        </div>
                        <div class="layui-col-xs2 text-c lh-30">
                            —
                        </div>
                        <div class="layui-col-xs5">
                            <input type="text" readonly name="deliverTimeMax" class="layui-input" id="deliverEndEndTime" placeholder="结束日期">
                        </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" readonly name="indocTimeMin" class="layui-input" id="endStartTime" placeholder="开始日期">
                        </div>
                        <div class="layui-col-xs2 text-c lh-30">
                            —
                        </div>
                        <div class="layui-col-xs5">
                            <input type="text" readonly name="indocTimeMax" class="layui-input" id="endEndTime" placeholder="结束日期">
                        </div>
                    </div>
                </div>

            </div>
        </form>
    </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">
                   <%-- <sfTags:pagePermission authFlag="XMGL_XMCX_XMCX_DELETE_B" html='<button class="layui-btn layui-btn-sm" lay-event="deleteBtn" id="deleteBtn"><i class="layui-icon layui-icon-ok-circle"></i>删除</button>'/>--%>
                    <%--<sfTags:pagePermission authFlag="XMGL_XMCX_XMCX_DCWL_B" html='<button class="layui-btn layui-btn-sm" lay-event="exportfittingBtn" id="exportfittingBtn"><i class="layui-icon layui-icon-ok-circle"></i>导出物料</button>'/>--%>
                    <sfTags:pagePermission authFlag="XMGL_XMCX_XMCX_DC_B" html='<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>
    var entrycount=0;
    layui.config({
        base: '${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'tableExt', 'jquery', 'layer','laypage','laydate','form', 'formSelects'], function(){
        //layui.use(['table','layer','laypage','laydate','form'], function(){
        $ = layui.$;
        tableExt = layui.tableExt;
        layer = layui.layer;
        laypage = layui.laypage;
        laydate = layui.laydate;
        formSelects = layui.formSelects;
        form = layui.form;
        table = tableExt.getLayTable();

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

        var downloadReport = '${fns:checkPagePermission(request, "XMGL_XMCX_XMCX_XZYSBG_B")}';
        var downloadForm = '${fns:checkPagePermission(request, "XMGL_XMCX_XMCX_XZJFQSB_B")}';

        //开始日期
        var createEndStartTime = laydate.render({
            elem: '#createEndStartTime'
            /* ,type: 'datetime'*/
            ,done: function(value, date){
                //更新结束日期的最小日期
                createEndEndTime.config.min = lay.extend({}, date, {
                    month: date.month - 1
                });
                //自动弹出结束日期的选择器
                createEndEndTime.config.elem[0].focus();
            }
        });
        //结束日期
        var createEndEndTime = laydate.render({
            elem: '#createEndEndTime'
            /* ,type: 'datetime'*/
            ,done: function(value, date){
                //更新开始日期的最大日期
                /*createEndStartTime.config.max = lay.extend({}, date, {
                    month: date.month - 1
                });*/
            }
        });

        var matchTimeMin = laydate.render({
            elem: '#matchTimeMin'
            /* ,type: 'datetime'*/
            ,done: function(value, date){
                //更新结束日期的最小日期
                matchTimeMax.config.min = lay.extend({}, date, {
                    month: date.month - 1
                });
                //自动弹出结束日期的选择器
                matchTimeMax.config.elem[0].focus();
            }
        });
        //结束日期
        var matchTimeMax = laydate.render({
            elem: '#matchTimeMax'
            /* ,type: 'datetime'*/
            ,done: function(value, date){
                //更新开始日期的最大日期
                /*installEndStartTime.config.max = lay.extend({}, date, {
                    month: date.month - 1
                });*/
            }
        });
        //开始日期
        var installEndStartTime = laydate.render({
            elem: '#installEndStartTime'
            /* ,type: 'datetime'*/
            ,done: function(value, date){
                //更新结束日期的最小日期
                installEndEndTime.config.min = lay.extend({}, date, {
                    month: date.month - 1
                });
                //自动弹出结束日期的选择器
                installEndEndTime.config.elem[0].focus();
            }
        });
        //结束日期
        var installEndEndTime = laydate.render({
            elem: '#installEndEndTime'
            /* ,type: 'datetime'*/
            ,done: function(value, date){
                //更新开始日期的最大日期
                /*installEndStartTime.config.max = lay.extend({}, date, {
                    month: date.month - 1
                });*/
            }
        });

        //开始日期
        var mergeEndStartTime = laydate.render({
            elem: '#mergeEndStartTime'
            /* ,type: 'datetime'*/
            ,done: function(value, date){
                //更新结束日期的最小日期
                mergeEndEndTime.config.min = lay.extend({}, date, {
                    month: date.month - 1
                });
                //自动弹出结束日期的选择器
                mergeEndEndTime.config.elem[0].focus();
            }
        });
        //结束日期
        var mergeEndEndTime = laydate.render({
            elem: '#mergeEndEndTime'
            /* ,type: 'datetime'*/
            ,done: function(value, date){
                //更新开始日期的最大日期
                /*mergeEndStartTime.config.max = lay.extend({}, date, {
                    month: date.month - 1
                });*/
            }
        });

        //开始日期
        var acceptEndStartTime = laydate.render({
            elem: '#acceptEndStartTime'
            /* ,type: 'datetime'*/
            ,done: function(value, date){
                //更新结束日期的最小日期
                acceptEndEndTime.config.min = lay.extend({}, date, {
                    month: date.month - 1
                });
                //自动弹出结束日期的选择器
                acceptEndEndTime.config.elem[0].focus();
            }
        });
        //结束日期
        var acceptEndEndTime = laydate.render({
            elem: '#acceptEndEndTime'
            /* ,type: 'datetime'*/
            ,done: function(value, date){
                //更新开始日期的最大日期
               /* acceptEndStartTime.config.max = lay.extend({}, date, {
                    month: date.month - 1
                });*/
            }
        });

        //开始日期
        var deliverEndStartTime = laydate.render({
            elem: '#deliverEndStartTime'
            /* ,type: 'datetime'*/
            ,done: function(value, date){
                //更新结束日期的最小日期
                deliverEndEndTime.config.min = lay.extend({}, date, {
                    month: date.month - 1
                });
                //自动弹出结束日期的选择器
                deliverEndEndTime.config.elem[0].focus();
            }
        });
        //结束日期
        var deliverEndEndTime = laydate.render({
            elem: '#deliverEndEndTime'
            /* ,type: 'datetime'*/
            ,done: function(value, date){
                //更新开始日期的最大日期
               /* deliverEndStartTime.config.max = lay.extend({}, date, {
                    month: date.month - 1
                });*/
            }
        });

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



        tableExt.render({
            elem: '#test'
            , title:'项目查询'
            , height: 'full-330'
            , toolbar: '#toolbarDemo'
            , defaultToolbar: false
            , limits : [ 20, 50, 100 ]
            , limit:20
            , page : true //开启分页
            , url: '${ctx}/customerEntry/findRecycleBinOrders?partner='+'${partner}'
            , where: _serializeJson($("#searchForm"))
            , method:"post"
            , cols: [[
                {type: 'numbers',fixed:'left',title:'序号'}
                ,{field : 'id', minWidth : '4%',checkbox : true,align : 'center',fixed: 'left'}
                , {field: 'power_station_code', title: '电站编码',minWidth: 200, sort: false, align: 'center',fixed:'left',
                    exportable: true,
                    templet: function (d) {
                        return '<a href="#" class="layui-table-link" onclick="psDetail(\'' + d.id + '\')">' + d.power_station_code + '</a>';
                    }}
                , {field: 'tenant_name', title: '业主姓名', minWidth: 150, sort: false, align: 'center',fixed:'left', exportable: true}
                , {field: 'scheme_type_name', title: '方案类型', minWidth: 150, align: 'center', exportable: true}
                , {
                    field: 'planName',
                    title: '方案名称',
                    minWidth: 100,
                    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.planName+'</a>';
                        }else if(isBlank(d.planName)){
                            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.planName+'</a>';
                        }
                    }
                }
                // , {
                //     field: 'planName',
                //     title: '验收报告',
                //     minWidth: 100,
                //     sort: false,
                //     align: 'center',
                //     templet: function (d) {
                //         if (isBlank(d.receiving_report_id)) {
                //             return '——';
                //         }
                //         return downloadReport == '0'? '<a href="#" class="layui-table-link" onclick="downloadReport(\''+d.id+'\')">查看</a>': '';
                //     }
                // }
                , {field: 'projectCode', title: '产品编号', minWidth: 130, sort: false, align: 'center', exportable: true}
                , {field: 'projectName', title: '产品名称', minWidth: 130, sort: false, align: 'center', exportable: true}
                , {
                    field: 'examine_remarks',
                    title: '审核备注',
                    minWidth: 130,
                    sort: false,
                    align: 'center',
                    exportable: true
                }
                , {field: 'capacity', title: '实际安装容量', minWidth: 150, sort: false, align: 'center', exportable: true}
                , {
                    field: 'component_num',
                    title: '安装组件块数',
                    minWidth: 150,
                    sort: false,
                    align: 'center',
                    exportable: true
                }
                , {field: 'traderName', title: '代理商名称', minWidth: 130, sort: false, align: 'center', exportable: true}
                , {field: 'traderMobile', title: '代理商电话', minWidth: 130, sort: false, align: 'center', exportable: true}
                <c:if test="${'2' ne ifTop}">
                , {field: 'createTraderName',title: '二级代理商',minWidth: '150',sort: false,align: 'center',exportable: true
                    ,templet: function (d) {
                        if(d.distributor_id==d.create_trader_id){
                            return "";
                        }else{
                            return d.createTraderName
                        }
                    },
                    expFormat: function (d) {
                        if(d.distributor_id==d.create_trader_id){
                            return "";
                        }else{
                            return d.createTraderName
                        }
                    }
                }
                </c:if>
                , {field: 'engineer_name', title: '施工团队', minWidth: 150, align: 'center', exportable: true}
                , {field: 'mobile', title: '联系电话', minWidth: 130, sort: false, align: 'center', exportable: true}
                , {field: 'address', title: '安装地址', minWidth: 130, sort: false, align: 'center', exportable: true}
                , {field: 'roof_type', title: '屋顶类型', minWidth: 130, sort: false, align: 'center', exportable: true}
                , {field: 'angle', title: '朝向角度', minWidth: 130, sort: false, align: 'center', exportable: true}
                , {field: 'distance', title: '估算并网距离（米）', minWidth: 180, sort: false, align: 'center', exportable: true}
                /*, {
                    field: 'hire_status',
                    title: '租赁状态',
                    minWidth: 130,
                    sort: false,
                    align: 'center',
                    exportable: true,
                    templet: function (d) {
                        if (d.hire_status == '2') {
                            return "否";
                        } else {
                            return "是";
                        }
                    },
                    expFormat: function (d) {
                        if(d.status=='2'){
                            return "否";
                        }else{
                            return "是";
                        }
                    }}*/
                // , {
                //     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: 'creator', 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: 150, sort: false, align: 'center',exportable:true}
                , {field: 'examine_time', title: '匹配时间',minWidth: 180, sort: false, align: 'center',exportable:true}*/
                , {field: 'order_time', title: '下单时间',minWidth: 180, sort: false, align: 'center',exportable:true}
                , {field: 'receive_time', title: '收货时间',minWidth: 180, sort: false, align: 'center',exportable:true}
                , {field: 'install_time', title: '安装时间',minWidth: 180, sort: false, align: 'center',exportable:true}
                , {field: 'merge_time', title: '并网时间',minWidth: 180, sort: false, align: 'center',exportable:true}
                <c:if test="${user.userType ne '6' && user.userType ne '7'}">
                , {field: 'check_accept_name', title: '验收人',minWidth: 150, sort: false, align: 'center',exportable:true}
                </c:if>
                , {field: 'check_accept_time', title: '验收时间',minWidth: 180, sort: false, align: 'center',exportable:true}
                , {field: 'deliver_name', title: '交付人',minWidth: 150, sort: false, align: 'center',exportable:true}
                , {field: 'deliver_time', title: '交付时间',minWidth: 180, sort: false, align: 'center',exportable:true}
                , {field: 'indoc_name', title: '录档人',minWidth: 150, sort: false, align: 'center',exportable:true}
                , {field: 'indoc_time', title: '录档时间',minWidth: 180, sort: false, align: 'center',exportable:true}
            ]]
            ,exportOpt:{                           //导出选项配置
                ele:'#exportBtn',                   //导出的Dom元素
                headerTitle: '项目查询',             //excel表格的标题
                pageData:false,                     //true:导出的数据为页面数据，false:最大导出maxAmount条数据
                maxAmount: 5000,                    //当pageData为false生效
                fileName: '项目查询',
                where: function (){                 //当pageData为false时生效，过滤的条件
                    return _serializeJson($("#searchForm"));
                }
            },done: function(res, curr, count){
                //得到数据总量
                entrycount = count;
            }
        });

        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 '';
            }
        }

        table.on('toolbar(test)',function(obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            if(obj.event === 'deleteBtn'){
                var data = checkStatus.data;
                console.log(data)
                if (data.length <1) {
                    layer.msg("请选择数据",{icon:5,anim:6});
                    return false;
                }
        var chename = "";
                var ids = [];
                for(var i=0; i<checkStatus.data.length; i++){
                    if(checkStatus.data[i].status=='8' || checkStatus.data[i].status=='9' ||checkStatus.data[i].status=='11'||checkStatus.data[i].status=='a'){
                        chename = "300";
                        return
                    }
                    ids.push(checkStatus.data[i].id);
                }
                 if(chename =='300'){
                     layer.msg("选择的数据中有不可删除信息",{icon:5,anim:6});
                     return false;
                 }
                layer.confirm('确认要删除吗？', {
                    icon:3,
                    btn:['确定','取消'] //按钮
                }, function(){
                    $.ajax({
                        type: 'post',
                        url: '${ctx}/customerEntry/batchDeleteOrder',

                        contentType: 'application/json',
                        data: JSON.stringify(ids),
                        success: function(data){
                            if (data.code === '200') {
                                layer.msg('操作成功', {time: 1000});
                                searchOrder();
                            }else if(data.code === '501'){
                                layer.msg(data.errMsg, {time: 1000});
                            }else {
                                layer.msg('操作失败', {time: 1000});
                            }
                        }
                    })
                });

            }else  if (obj.event === 'exportfittingBtn') {
                if(entrycount<1){
                    layer.msg('当前无数据导出', {time: 1000});
                    return ;
                }

                let hideSubmitForm = document.createElement("form");
                hideSubmitForm.id = "tempForm1";
                hideSubmitForm.method = "post";
                hideSubmitForm.action = "${ctx}/excel/doExportUserExcel";
                hideSubmitForm.target = "_blank";
                hideSubmitForm.appendChild(createHideInput("status",isBlank($("#status").val())?"":$("#status").val()));
                hideSubmitForm.appendChild(createHideInput("projectId", isBlank($("#projectId").val())?"":$("#projectId").val()));
                hideSubmitForm.appendChild(createHideInput("powerStationCode", isBlank($("#powerStationCode").val())?"":$("#powerStationCode").val()));
                hideSubmitForm.appendChild(createHideInput("traderId", isBlank($("#traderId").val())?"":$("#traderId").val()));
                hideSubmitForm.appendChild(createHideInput("traderMobile", isBlank($("#traderMobile").val())?"":$("#traderMobile").val()));
                hideSubmitForm.appendChild(createHideInput("tenantName", isBlank($("#tenantName").val())?"":$("#tenantName").val()));
                hideSubmitForm.appendChild(createHideInput("checkAcceptBy", isBlank($("#checkAcceptBy").val())?"":$("#checkAcceptBy").val()));
                hideSubmitForm.appendChild(createHideInput("tenantAddress", isBlank($("#tenantAddress").val())?"":$("#tenantAddress").val()));
                hideSubmitForm.appendChild(createHideInput("installWay", isBlank($("#installWay").val())?"":$("#installWay").val()));
                hideSubmitForm.appendChild(createHideInput("roofType", isBlank($("#roofType").val())?"":$("#roofType").val()));
                hideSubmitForm.appendChild(createHideInput("plan", isBlank($("#plan").val())?"":$("#plan").val()));
                hideSubmitForm.appendChild(createHideInput("remarks", isBlank($("#remarks").val())?"":$("#remarks").val()));
                hideSubmitForm.appendChild(createHideInput("deliverBy", isBlank($("#deliverBy").val())?"":$("#deliverBy").val()));
                hideSubmitForm.appendChild(createHideInput("createTimeMin", isBlank($("#createEndStartTime").val())?"":$("#createEndStartTime").val()));
                hideSubmitForm.appendChild(createHideInput("createTimeMax", isBlank($("#createEndStartTime").val())?"":$("#createEndStartTime").val()));
                hideSubmitForm.appendChild(createHideInput("examineTimeMin", isBlank($("#matchTimeMin").val())?"":$("#matchTimeMin").val()));
                hideSubmitForm.appendChild(createHideInput("examineTimeMax", isBlank($("#matchTimeMax").val())?"":$("#matchTimeMax").val()));

                hideSubmitForm.appendChild(createHideInput("installEndEndTime", isBlank($("#installEndStartTime").val())?"":$("#installEndStartTime").val()));
                hideSubmitForm.appendChild(createHideInput("installEndEndTime", isBlank($("#installEndEndTime").val())?"":$("#installEndEndTime").val()));
                hideSubmitForm.appendChild(createHideInput("mergeTimeMin",isBlank($("#mergeEndStartTime").val())?"": $("#mergeEndStartTime").val()));
                hideSubmitForm.appendChild(createHideInput("mergeTimeMax", isBlank($("#mergeEndEndTime").val())?"":$("#mergeEndEndTime").val()));
                hideSubmitForm.appendChild(createHideInput("checkAcceptTimeMin", isBlank($("#acceptEndStartTime").val())?"":$("#acceptEndStartTime").val()));
                hideSubmitForm.appendChild(createHideInput("checkAcceptTimeMax", isBlank($("#acceptEndEndTime").val())?"":$("#acceptEndEndTime").val()));
                hideSubmitForm.appendChild(createHideInput("deliverTimeMin", isBlank($("#deliverEndStartTime").val())?"":$("#deliverEndStartTime").val()));
                hideSubmitForm.appendChild(createHideInput("deliverTimeMax", isBlank($("#deliverEndEndTime").val())?"":$("#deliverEndEndTime").val()));
                hideSubmitForm.appendChild(createHideInput("indocTimeMin", isBlank($("#endStartTime").val())?"":$("#endStartTime").val()));
                hideSubmitForm.appendChild(createHideInput("indocTimeMax", isBlank($("#endEndTime").val())?"":$("#endEndTime").val()));
                hideSubmitForm.addEventListener('onsubmit', function(){
                    // this.openDownloadWindow(name);
                });
                document.body.appendChild(hideSubmitForm);
                hideSubmitForm.submit();
                document.body.removeChild(hideSubmitForm);

                //  window.open("${ctx}/excel/doExportUserExcel?status=3&"+$("#searchForm"))
            }

        });
        document.addEventListener('keydown', function (event) {
            if (event.keyCode === 13) {
                //执行相关操作
                $("#searchBtn").click();
            }
        });
        form.on('select(province)', function (data) {
            var province = $(data.elem).find("option:selected").attr("title");
            provinceOrder(province);
        });
        form.on('select(city)', function (data) {
            var city = $(data.elem).find("option:selected").attr("title");
            cityOrder(city);

        });

        function provinceOrder(province) {
            $("#city").empty();
            $("#area").empty();
            if (isBlank(province)) {
                $("#city").append("<option value=''>市</option>");
                return "";
            }
            $.ajax({
                type: "POST",
                url: "${ctx}/main/redirect/getCitysByProId",
                data: {
                    province: province
                },
                success: function (result) {

                    if (result == "205") {
                        layer.msg("暂无数据!")
                        return
                    }
                    var html = " <option value=''>市</option>";
                    for (var i = 0; i < result.length; i++) {
                        var city = result[i];
                        html = html + '<option value="' + city.columns.CityName + '" title="' + city.columns.CityID + '">' + city.columns.CityName + '</option>';
                    }
                    $("#city").append(html);
                    form.render('select');
                }
            });

        }

        function cityOrder(city, arean) {
            $("#area").empty()
            if (isBlank(city)) {
                $("#area").append("<option value=''>区/县</option>");
                return "";
            }
            $.ajax({
                type: "POST",
                url: "${ctx}/main/redirect/getAreaByCityId",
                data: {
                    city: city
                },
                success: function (result) {
                    if (result == "205") {
                        layer.msg("暂无数据!")
                        return
                    }
                    var html = "<option value=''>区/县</option>";
                    for (var i = 0; i < result.length; i++) {
                        var area = result[i];
                        html = html + '<option value="' + area.columns.DistrictName + '" value="' + area.columns.DistrictId + '">' + area.columns.DistrictName + '</option>';
                    }
                    $("#area").append(html);
                    if (!isBlank(arean)) {
                        $("#area").val(arean)
                    }

                    form.render('select');
                }
            });

        }

        function  createHideInput(name, value){
            let hideInput = document.createElement("input");
            hideInput.type = "hidden";
            hideInput.name = name;
            hideInput.value = value;
            return hideInput;
        };
        //监听搜索
        form.on('submit(LAY-user-back-search)', function(data){
            var field = data.field;
            //执行重载
            tableExt.reload('test', {
                where: field,
                page:{
                    curr:1
                }
            });
        });
    })

    function downloadReport(id){
        layer.open({
            type: 2,
            title: '验收报告',
            content: '${ctx}/customerEntry/downloadReport?opt=down&id=' + id,
            area: ['100%','100%']
        });
    }

    function downloadAttach(attach){
        attach=decodeURI(attach);
        attach = attach.replace(/\+/g,"%2B"); //
        window.location.href = '${commonStaticImgPath}' + attach;
    }

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

    function deliver(){

    }

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

            }
        });
    }

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

    function downloadImg(attach) {
        var name = attach.substring(0, attach.lastIndexOf(".") - 1);
        var suffix = attach.substring(attach.lastIndexOf("."));
        window.open('${commonStaticImgPath}'+attach)
       // location.href = '${ctx}/technical/imgDownload?path=' + '${commonStaticImgPath}' + attach + "&fileGS=" + suffix + "&name=" + name;
    }

    function inDoc(id){

    }

    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>

