<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<!DOCTYPE HTML>
<html>
<head>
    <meta name="decorator" content="base"/>
    <link rel="stylesheet" href="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="${ctxPlugin}/static/css/reset.css">
    <link rel="stylesheet" href="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/dist/viewer.css" media="all">
    <style>html {
        background-color: #fff;
        padding-bottom: 50px;
    }

    td, th {
        text-align: center !important;
    }
    .hh{
        line-height: 34px;
        margin: 0 0 0 20px;
        padding: 0 0 0 15px;
        font-size: 16px;
    }

    hr {
        margin:0px
    }
    .tot{
        margin: 6px 0px 0px 20px;
    }

    </style>
</head>

<body>
<div class="layui-form">
    <div class="layui-card">
        <span class="hh" >电站信息</span>
        <hr>
        <div class="layui-col-xs12 mt-10 mb-10 pr-30 pl-30">
            <table class="layui-table">
                <thead>
                <th style="width: 8%">序号</th>
                <th>电站编码</th>
                <th style="width: 10%">客户姓名</th>
                <th>安装地址</th>
                <th>设计容量（W）</th>
                <th style="width: 15%">登记时间</th>
                <th style="width: 8%">选择</th>
                </thead>
                <tbody id="entryTbody">
                <c:forEach items="${entryList}" var="entry" varStatus="vs">
                    <tr data-entryId="${entry.columns.id}">
                        <td>${vs.count}</td>
                        <td class="power_station_code">${entry.columns.power_station_code}</td>
                        <td class="tenant_name">${entry.columns.tenant_name}</td>
                        <td class="customerAddress" >${entry.columns.address}</td>
                        <td class="design_capacity">${entry.columns.design_capacity}</td>
                        <td class="createTime" ><fmt:formatDate value="${entry.columns.create_time}" pattern="yyyy-MM-dd"/></td>
                        <td> <input type="checkbox" name="confirmChoice"  lay-skin="primary" value="${entry.columns.id}"> </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
        </div>
    </div>
    <div class="operate-footer">
        <button type="button"  id="confirmChoice" class="layui-btn" onclick="confirmChoice();">确定</button>
        <button type="button" class="layui-btn layui-btn-primary " onclick="closeDiv();">取消</button>
    </div>
</div>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script type="text/javascript">
    //初始数据
    var $form;
    var form;
    var $;
    var imgs = '';
    var myreg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
    layui.config({
        base: '${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['form', 'layedit', 'laydate', 'jquery', 'layer', 'element', 'upload'], function () {
        $ = layui.jquery;
        form = layui.form;
        var element = layui.element;
        $form = $('form');
    })

    function confirmChoice(){
        if($("input[type=checkbox]:checked").length==0){
            layer.msg("请选择匹配的物料!");
            return;
        }

        var entryList=[];

        $("input[type=checkbox]:checked").each(function (){
            var obj= $(this).parents('tr');
            var entryId=obj.attr("data-entryId");
            var power_station_code=obj.find(".power_station_code").text();
            var tenant_name=obj.find(".tenant_name").text();
            var customerAddress=obj.find(".customerAddress").text();
            var design_capacity=obj.find(".design_capacity").text();
            var createTime=obj.find(".createTime").text();

            var obData={
                entryId:entryId
                ,powerStationCode:power_station_code
                ,tenantName:tenant_name
                ,customerAddress:customerAddress
                ,designCapacity:design_capacity
                ,createTime:createTime
            }
            entryList.push(obData);
        })

            parent.getCustomerEntryList(entryList);
            closeSelf();

    }

    function closeSelf(){
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    }

    function closeDiv() {
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index);
    }

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


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