<%@ 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">
    <link rel="stylesheet" href="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/style/formSelects-v4.css" media="all">
    <style>
        html{background-color: #fff;padding-bottom: 50px;}
        .layui-form-select dl{
            max-height:200px;
            width: 80%;
        }
        .border-s{padding: 6px 0; width: 95%; margin: 0 auto; border-radius: 10px;margin-bottom: 10px}
        .xm-select-parent .xm-select {
            min-height: 32px;
        }
        .layui-btn.black-cloth{display: block}
        .bzInp {
            width: 50px;
            border-color: #ddd;
            border-width: 1px;
            border-style: solid;
            background-color: #fff;
            border-radius: 2px;
            height: 24px;
            padding-left: 10px
        }
        .remoDiv{
            display: none;
        }
        .layui-table tr{
            text-align: center;
        }
        .layui-span-unit {
            right: 65px;
            top: -3px;
        }
    </style>
</head>
<body>

<div class="layui-form">
    <div class="layui-card mt-10">
        <div id="anyDiv" class="mt-40">
                <div class="layui-row border-s">
                    <div class="layui-col-xs10">
                        <input hidden id="id" name="id" value="${punishWay.id}">
                        <div class="layui-col-xs12 pr-30">
                            <c:if test="${punishWay.type eq '1'}">
                                <div class="layui-inline layui-col-xs12">
                                    <label class="layui-form-label"><i class="red">*</i>结算规则：</label>
                                    <div class="layui-input-block">
                                        <c:if test="${empty punishWay.highData}">
                                            当月完成安装容量 &gt= <input type="text" class="bzInp" name="lowData" lay-verify="required" value="${punishWay.lowData}" oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')">MW
                                            ，奖励当月安装容量 * <input type="text" class="bzInp" name="ratioData" lay-verify="required" value="${punishWay.ratioData}" oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')">元/W

                                        </c:if>
                                        <c:if test="${not empty punishWay.highData}">
                                            <input type="text" class="bzInp" name="lowData" lay-verify="required" value="${punishWay.lowData}" oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')">MW
                                            &lt= 当月完成安装容量 &lt <input type="text" class="bzInp" lay-verify="required" name="highData" value="${punishWay.highData}" oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')">MW
                                            ，奖励当月安装容量 * <input type="text" class="bzInp" name="ratioData" lay-verify="required" value="${punishWay.ratioData}" oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')">元/W
                                        </c:if>
                                    </div>
                                </div>
                            </c:if>

                            <c:if test="${punishWay.type eq '2'}">
                                <div class="layui-inline layui-col-xs12">
                                    <label class="layui-form-label"><i class="red">*</i>结算规则：</label>
                                    <div class="layui-input-block">
                                            <input type="text" class="bzInp" name="lowData" lay-verify="required" value="${punishWay.lowData}" oninput="value=value.replace(/[^\d]/g,'')">天
                                            &lt= 并网天数 &lt <input type="text" class="bzInp" lay-verify="required" name="highData" value="${punishWay.highData}" oninput="value=value.replace(/[^\d]/g,'')">天
                                            ，惩罚安装容量（W） * <input type="text" class="bzInp" name="ratioData" lay-verify="required" value="${punishWay.ratioData}" oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')">元
                                    </div>
                                </div>
                            </c:if>
                            <c:if test="${punishWay.type eq '3'}">
                                <div class="layui-inline layui-col-xs12">
                                    <label class="layui-form-label"><i class="red">*</i>结算规则：</label>
                                    <div class="layui-input-block">
                                        单机安装容量 &lt= <input type="text" class="bzInp" name="highData" lay-verify="required" value="${punishWay.highData}" oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')">KW
                                        ，基础结算价每瓦减少 <input type="text" class="bzInp" name="ratioData" lay-verify="required" value="${punishWay.ratioData}" oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')">元
                                    </div>
                                </div>
                            </c:if>
                            <div class="layui-inline layui-col-xs6 mt-20">
                                <label class="layui-form-label"><i class="red">*</i>有效期：</label>
                                <div class="layui-input-block">
                                    <div class="layui-col-xs5">
                                        <input type="text" name="lowTime" id="createTime" value="<fmt:formatDate value="${punishWay.lowTime}" pattern="yyyy-MM-dd"/>" class="layui-input"  lay-verify="required"  placeholder="生效日期">
                                    </div>
                                    <div class="layui-col-xs2 text-c lh-30">
                                        —
                                    </div>
                                    <div class="layui-col-xs5">
                                        <input type="text" name="highTime" id="endTime" class="layui-input"  value="<fmt:formatDate value="${punishWay.highTime}" pattern="yyyy-MM-dd"/>" lay-verify="required"  placeholder="失效日期">
                                    </div>
                                </div>
                            </div>
                        </div>

                    </div>
                </div>
        </div>

        <div class="layui-col-xs12 mb-20 pr-30 mt-20">
        </div>
    </div>
    <div class="operate-footer" >
        <input type="button" lay-submit lay-filter="confirm" id="confirm" class="layui-btn " value="保存">
        <input type="button"   value="取消" class="layui-btn layui-btn-primary " onclick="closeDiv();" >
    </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 type="text/javascript">
    //初始数据
    var form;
    var formSelects;
    var cou=0;
    var addIndex = '';
    layui.config({
        base: '${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'tableExt', 'jquery', 'layer','laypage','laydate','form','formSelects'], function(){
        $ = layui.jquery;
        form = layui.form;
        formSelects = layui.formSelects;
        var laydate = layui.laydate;

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

        form.on('submit(confirm)', function(data){
            $("#confirm").attr("disabled","true");
            console.log(JSON.stringify(data.field));
            $.ajax({
                url:'${ctx}/rewardsPunishWaySet/savePunishWay',
                method:'post',
                contentType : "application/json;charsetset=UTF-8",
                data:JSON.stringify(data.field),
                success:function(res){
                    if(res.code=="200"){
                        parent.layer.msg("保存成功",{time:2000});
                        closeDiv();
                        parent.table.reload('test');
                    } else{
                        layer.msg(res.errMsg,{time:2000});
                        $("#confirm").removeAttr("disabled");
                    }
                },
                error:function (data) {
                }
            }) ;
        });

    })

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

    function closeThisDiv(){
        $("#trades tr").remove();
        $("#choiceTrader").addClass("layui-hide")
        layer.close(addIndex);
    }
</script>
</body>
</html>




