<%@ 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" />
    <style>
        .xm-select-parent .xm-select {
            min-height: 32px;
        }
    </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="ZCGL_ZJGL_ZJGL_T" html='<a href="${ctx}/customer/customerEntryRent/entryRentList"><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" >
                        <select name="projectIds" id="projectIds" lay-search>
                            <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">
                        <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" 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" >
                            <select name="traderIds" id="traderIds"  xm-select="traderIds" xm-select-type="1" xm-select-height="25px" xm-select-show-count="6">
                                <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">
                        <input type="text" name="tenantName" id="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="mobile" id="mobile" 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="uniformity" id="uniformity">
                            <option value="">请选择</option>
                            <option value="0">未支付</option>
                            <option value="1">已支付</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="whetherToPay" id="whetherToPay">
                            <option value="">请选择</option>
                            <option value="0">未到期</option>
                            <option value="1">未支付</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" readonly name="payTimeMin" class="layui-input" id="payTimeMin" placeholder="开始日期">
                        </div>
                        <div class="layui-col-xs2 text-c lh-30">
                            —
                        </div>
                        <div class="layui-col-xs5">
                            <input type="text" readonly name="payTimeMax" class="layui-input" id="payTimeMax" placeholder="结束日期">
                        </div>
                    </div>
                </div>


                <div class="layui-col-lg4 layui-col-sm6">
                    <label class="layui-form-label">项目公司：</label>
                    <div class="layui-input-block" >
                        <select name="projectCompanyIds" id="projectCompanyIds" xm-select="projectCompanyIds" xm-select-type="1" xm-select-height="25px" xm-select-show-count="6" >
                            <option value="">请选择</option>
                            <c:forEach var="company" items="${company}">
                                <option value="${company.columns.id}"  >${company.columns.name}</option>
                            </c:forEach>
                        </select>
                    </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="ZJGL_PLZF_B" html='<button class="layui-btn layui-btn-sm" lay-event="importCode" id="importCode"><i class="layui-icon layui-icon-ok-circle"></i>批量支付</button>'/>
                  <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 formSelects;
    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;
        form = layui.form;
        table = tableExt.getLayTable();
        formSelects = layui.formSelects;

        //开始日期
        var installEndStartTime = laydate.render({
            elem: '#payTimeMin'
            /* ,type: 'datetime'*/
            ,done: function(value, date){
                //更新结束日期的最小日期
                payTimeMax.config.min = lay.extend({}, date, {
                    month: date.month - 1
                });
                //自动弹出结束日期的选择器
                payTimeMax.config.elem[0].focus();
            }
        });
        //结束日期
        var payTimeMax = laydate.render({
            elem: '#payTimeMax'
            /* ,type: 'datetime'*/
            ,done: function(value, date){
                //更新开始日期的最大日期
                /*installEndStartTime.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}/customer/customerEntryRent/ajaxEntryRentList'
            , where: _serializeJson($("#searchForm"))
            , cols: [[
                {type: 'numbers',fixed:'left',title:'序号'}
                ,{field : 'id', minWidth : '4%',checkbox : true,align : 'center'}
                , {
                    field: 'power_station_code', title: '电站编码', minWidth: 150, sort: false, align: 'center',
                    exportable: true,
                    templet: function (d) {
                        return '<a href="#" class="layui-table-link" onclick="psDetail(\'' + d.entry_id + '\')">' + d.power_station_code + '</a>';
                    }
                }
                ,
                , {field: 'project_code', title: '产品编号', minWidth: 130, sort: false, align: 'center', exportable: true}
                , {field: 'project_name', title: '产品名称', minWidth: 130, sort: false, align: 'center', exportable: true}
                , {field: 'trader_name', title: '代理商名称', minWidth: 130, sort: false, align: 'center', exportable: true}
                , {field: 'trader_tel', title: '代理商电话', minWidth: 130, sort: false, align: 'center', exportable: true}
                , {field: 'tenant_name', title: '业主姓名', minWidth: 150, sort: false, align: 'center', exportable: true}
                /*, {field: 'id_code', title: '身份证号码',minWidth: 150, sort: false, align: 'center'}*/
                , {field: 'mobile', title: '联系电话', minWidth: 130, sort: false, align: 'center', exportable: true}
                , {
                    field: 'id', title: '支付记录', minWidth: 200, sort: false, align: 'center',
                    templet: function (d) {
                        if (!isBlank(d.the_period_rent)) {
                            return '<a href="#" class="layui-table-link" onclick="rentDetail(\'' + d.entry_id + '\')">支付记录</a>';
                        } else {
                            return "";
                        }
                    }
                }
                , {field: 'the_period_rent', title: '上期租金',minWidth: 130, sort: false, align: 'center', exportable:true}
                , {field: 'pay_status', title: '支付状态',minWidth: 130, sort: false, align: 'center',exportable:true,  templet:function(d){
                        if(d.pay_status=='0'){
                            return "未支付";
                        }else if(d.pay_status=='1'){
                            return "已支付";
                        }else{
                            return "未支付";
                        }
                    },expFormat:function(d){
                        if(d.pay_status=='0'){
                            return "未支付";
                        }else if(d.pay_status=='1'){
                            return "已支付";
                        }else{
                            return "未支付";
                        }
                    }}
                , {field: 'rent_staus', title: '当期状态',minWidth: 130, sort: false, align: 'center',exportable:true,  templet:function(d){
                        if(d.pay_status=='1'){
                            return "已支付";
                        }else
                        if(d.rent_staus=='0'){
                            return "未到期";
                        }else{
                            return "未支付";
                        }
                    },expFormat:function(d){
                        if(d.pay_status=='1'){
                            return "已支付";
                        }
                        if(d.rent_staus=='0'){
                            return "未到期";
                        }else{
                            return "未支付";
                        }
                    }}
                , {field: 'pay_time', title: '支付日期',minWidth: 180, sort: false, align: 'center',exportable:true}
                , {field: 'current_payable', title: '当期应付',minWidth: 150, sort: false, align: 'center',exportable:true}
                , {field: 'meet_time', title: '应付日期',minWidth: 180, sort: false, align: 'center',exportable:true}
                , {field: 'sd', title: '是否支付',minWidth: 180, sort: false, align: 'center',exportable:true,hide: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){

            }
        });

        table.on('toolbar(test)',function(obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            if (obj.event === 'importCode') {
                layer.open({
                    title: '导入已支付',
                    type: 2,
                    area: ['550px', '300px'],
                    content: '${ctx}/customer/customerEntryRent/importCustomerRent'
                });
            }

        });

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


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

    function searchOrder() {
        layer.closeAll();
        //执行重载
        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 rentDetail(id){
        layer.open({
            type: 2
            , title: '支付记录'
            , content: '${ctx}/customer/customerEntryRent/entryRentListHis?entryId=' + id
            , area: ['80%', '88%']
            , yes: function(index, layero){

            }
        });
    }

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



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

