<%@ 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="CKGL_CKQRD_DQRD_T" html='<a href="${ctx}/customerEntry/outWaitConfirm"><li class="">待确认订单</li></a>'/>
                <sfTags:pagePermission authFlag="CKGL_CKQRD_YQRD_T" html='<a href="${ctx}/customerEntry/outConfirm"><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" 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" autocomplete="off">
                    </div>
                </div>

                <div class="layui-col-lg2 layui-col-sm3">
                    <label class="layui-form-label">代理商名称：</label>
                    <div class="layui-input-block" >
                        <select name="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" class="layui-input" autocomplete="off">
                    </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" autocomplete="off">
                    </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" autocomplete="off">
                    </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="installTimeMin" class="layui-input pointer" readonly id="installTimeMin" placeholder="开始日期">
                        </div>
                        <div class="layui-col-xs2 text-c lh-30">
                            —
                        </div>
                        <div class="layui-col-xs5">
                            <input type="text" name="installTimeMax" class="layui-input pointer" readonly id="installTimeMax" 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" name="confirmTimeMin" class="layui-input pointer" readonly id="confirmTimeMin" placeholder="开始日期">
                        </div>
                        <div class="layui-col-xs2 text-c lh-30">
                            —
                        </div>
                        <div class="layui-col-xs5">
                            <input type="text" name="confirmTimeMax" class="layui-input pointer" readonly id="confirmTimeMax" placeholder="结束日期">
                        </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>
        </div>
    </div>
</div>
<!-- toolbar -->
<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
    </div>
</script>
<!-- 电站编码 -->
<script type="text/html" id="stationCodeTpl">
    <a href="#" class="layui-table-link" onclick="psDetail('{{d.entry_id}}','{{d.id}}')">{{d.power_station_code}}</a>
</script>

<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.$;
        tableExt = layui.tableExt;
        layer = layui.layer;
        laypage = layui.laypage;
        laydate = layui.laydate;
        form = layui.form;
        table = tableExt.getLayTable();

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

        laydate.render({
            elem: '#confirmTimeMin'
            ,done: function(value, date){
                //更新结束日期的最小日期
                confirmEndTime.config.min = lay.extend({}, date, {
                    month: date.month - 1
                });
                //自动弹出结束日期的选择器
                confirmEndTime.config.elem[0].focus();
            }
        });
        //结束日期
        var confirmEndTime = laydate.render({
            elem: '#confirmTimeMax'
            ,done: function(value, date){
            }
        });

        tableExt.render({
            elem: '#test'
            , title:'并网验收'
            , height: 'full-220'
            , toolbar: '#toolbarDemo'
            , defaultToolbar: false
            , limits : [ 20, 50, 100 ]
            , limit:20
            , page : true //开启分页
            , url: '${ctx}/customerEntry/outWaitConfirmData?confirmStatus=2'
            , cols: [[
                {type: 'numbers',fixed:'left',title:'序号'}
                , {field: 'power_station_code', title: '电站编码',minWidth: 200, sort: false, align: 'center', fixed: 'left',exportable:true, templet: '#stationCodeTpl'}
                , {
                    field: 'materialList',
                    title: '物料清单',
                    minWidth: 150,
                    sort: false,
                    align: 'center',
                    templet: function (d) {
                        return "<a href=\"#\" class=\"layui-table-link layui-icon   \" style='font-size:14px;' onclick=\"materialDetail('" + d.id + "')\">查看</a>&nbsp;&nbsp;";
                    }
                }
                , {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: 'mobile', title: '联系方式',minWidth: 130, sort: false, align: 'center', exportable:true}

                , {field: 'install_time', title: '安装完成时间',minWidth: 180, sort: false, align: 'center',exportable:true}
                , {field: 'confirm_time', title: '确认时间',minWidth: 180, sort: false, align: 'center',exportable:true}
            ]]
        });

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

    //查看详情
    function psDetail(entryId,id){
        layer.open({
            type: 2
            , title: '电站详情'
            , content: '${ctx}/customerEntry/entryDetailFromOut?entryId=' + entryId + '&outId=' + 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 materialDetail(id) {
        layer.open({
            type: 2,
            title: "查看",
            resize: false,
            area: ['80%', '70%'],
            content: '${ctx}/customerEntry/materialList?id=' + 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>

