<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <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" 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" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card layui-form">
        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
                <sfTags:pagePermission authFlag="XTSZ_JSJSZ_T" html='<li><a href="${ctx}/settlementSchemeSet/settleSetPage">结算基础价</a></li>'/>
                <sfTags:pagePermission authFlag="XTSZ_JSJSZ_JLZC_T" html='<li><a href="${ctx}/rewardsPunishWaySet/rewardsWayPage">奖励政策</a></li>'/>
                <sfTags:pagePermission authFlag="XTSZ_JSJSZ_CFZC_T" html='<li class="layui-this"><a href="${ctx}/rewardsPunishWaySet/punishWayPage">惩罚政策</a></li>'/>
            </ul>
        </div>

        <div class="layui-card-body">
            <table class="layui-hide " id="test" lay-filter="test"></table>
        </div>

    </div>
</div>
</div>
<script type="text/html" id="table-toolbar">
    <sfTags:pagePermission authFlag="XTSZ_JSJSZ_CFZC_BJ_B" html='<a class="layui-table-opt-link" lay-event="editWay">编辑</a>'/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <sfTags:pagePermission authFlag="XTSZ_JSJSZ_CFZC_BGJL_B" html='<a class="layui-table-opt-link" lay-event="lookRecord">变更记录</a>'/>
</script>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/data.js"></script>
<script type="text/javascript">
    var saveMark = false;
    //初始数据
    var $form;
    var form;
    var upload;
    var $;
    var table;
    layui.config({
        base: '${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'tableExt', 'jquery', 'layer','laypage','laydate','form','excel'], function(){
        $ = layui.$
            ,form = layui.form
            ,tableExt = layui.tableExt;
        laydate = layui.laydate;
        table = layui.table;

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

        //方案信息列表
        tableExt.render({
            elem: '#test'
            , height: 'full-130'
            , id: 'test'
            , defaultToolbar: false
            , url: '${ctx}/rewardsPunishWaySet/punishWayListDate'
            , layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
            , method:"post"
            , cols: [[
                {field: 'number', title: '序号', align: 'center', type: 'numbers'}
                ,{field:'id', title: '操作',minWidth: 150,toolbar: '#table-toolbar',align: 'center'}
                , {field: 'status', title: '状态', minWidth: 100, align: 'center',templet: function (d) {
                        if (d.status == "1") {
                            return "生效中";
                        } else if (d.status == "0") {
                            return "已失效";
                        }
                        return "--";
                    }}
                , {field: 'number', title: '方案编号', minWidth: 130, align: 'center'}
                , {field: 'status', title: '方案详情', minWidth:600, align: 'center'
                    ,templet: function (d) {
                        var str='';
                        if(d.type=='2'){
                          str+='并网天数超过'+d.low_data+'天（含'+d.low_data+'天）少于'+d.high_data+'天（含'+d.high_data+'天），处罚安装容量*'+d.ratio_data+'元/W';
                        }else if(d.type=='3'){
                          str+='单户装机容量≤'+d.high_data+'千瓦，基础结算价格每瓦减少'+d.ratio_data+'元';
                        }
                        return str;
                    }
                }
                , {field: 'settlement_nodes', title: '结算节点', minWidth: 200, align: 'center'}
                , {field: 'low_time', minWidth: 200, title: '有效期', align: 'center'
                    ,templet: function (d){
                        return d.low_time+' 至 '+d.high_time;
                    }
                }
            ],
            ]
            ,exportOpt:{                           //导出选项配置
                ele:'#exportBtn',                   //导出的Dom元素
                headerTitle: '奖励政策',             //excel表格的标题
                pageData:false,                     //true:导出的数据为页面数据，false:最大导出maxAmount条数据
                maxAmount: 1000,                    //当pageData为false生效
                fileName: '奖励政策',
                where: function (){
                    return _serializeJson($("#searchForm"));
                }
            }
        });

        table.on('tool(test)',function(obj) {
            var data = obj.data;
            var id = data.id;
            if (obj.event === 'editWay') {
                layer.open({
                    title:'编辑',
                    type: 2,
                    area: ["60%", "70%"],
                    content: '${ctx}/rewardsPunishWaySet/savePunishWayPage?id='+id
                })
            } if (obj.event === 'lookRecord') {
                layer.open({
                    title:'变更记录',
                    type: 2,
                    area: ["60%", "50%"],
                    content: '${ctx}/rewardsPunishWaySet/getChangeRecord?id='+id
                })
            }
        });

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

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

    });

    function reload(){
        table.reload('test', {
            page:{
                curr:1
            }
        });
    }

    function reset(){
        layui.form.render();
        $("#searchForm").find("select").val("");
        $("#searchForm").find("input").val("");
    }

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







