<%@ 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">
    <style>
        .layui-form-select dl{
            max-height:200px;
            width: 80%;
        }
    </style>
</head>
<body>
<div class="aaa">
    <div class="layui-form layui-card">
        <div class="layui-card-body over pt-20 pb-40 h-300" action="" id="detailSet">
            <div class="layui-col-xs12 mb-15 pr-30">
                <div class="layui-inline layui-col-xs6">
                    <label class="layui-form-label w-130"><i class="red">*</i>物料类型：</label>
                    <div class="layui-input-block ">
                        <select class="" id="type" name="type" lay-verify="required" lay-filter="type" >
                            <option value="">请选择类型</option>
                            <option value="1" <c:if test="${set.columns.type eq 1}" >selected</c:if>>逆变器</option>
                            <option value="2" <c:if test="${set.columns.type eq 2}" >selected</c:if>>并网箱</option>
                            <option value="3" <c:if test="${set.columns.type eq 3}" >selected</c:if>>组件</option>
                            <option value="4" <c:if test="${set.columns.type eq 4}" >selected</c:if>>支架</option>
                        </select>
                    </div>
                </div>

                <div class="layui-inline layui-col-xs6">
                    <label class="layui-form-label w-130"><i class="red">*</i>物料规格：</label>
                    <div class="layui-input-block w-200" >
                        <input type="text" name="model" lay-verify="required"  autocomplete="off" class="layui-input" value="${set.columns.model}" <c:if test="${set.columns.type eq 3}">oninput="value=value.replace(/[^\d]/g,'')"</c:if> >
                            <span class="pos-a h-32 lh-32 layui-span-unit <c:if test="${set.columns.type ne '3'}">layui-hide</c:if>" >W</span>

                    </div>
                </div>
            </div>
            <div class="layui-col-xs12 mb-15 pr-30">
                <div class="layui-inline layui-col-xs12">
                    <label class="layui-form-label w-130">描述：</label>
                    <div class="layui-input-block w-200" >
                        <textarea name="remarks" id="remarks" class="layui-textarea">${set.columns.remarks}</textarea>

                    </div>
                </div>
            </div>
            <input type="hidden" name="id" id="id" value="${set.columns.id}">

        </dev>

        <div class="layui-form-item operate-footer" style="text-align: center;">
            <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>
</div>

<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 $form;
    var form;
    var upload;
    var $;
    var myreg=/^[1][3,4,5,6,7,8,9][0-9]{9}$/;
    var reg =/^(0|[1-9][0-9]*)(\.\d+)?$/;
    layui.use(['form', 'table', 'upload', 'jquery'], function () {
        $ = layui.jquery;
        form = layui.form;
        upload = layui.upload;
        $form = $('form');



        form.verify({
            site:function(value,item){
                if(!$.trim(value)){
                    return "所属服务商不能为空,请选择服务商后保存！";
                }
            }
        });

        form.on('select(type)', function (data) {
           var ch=data.value;
           if('3'== ch){
               $(".layui-span-unit").removeClass("layui-hide");
               $("input[name='model']").attr("oninput","value=value.replace(/[^0-9]/g,'')");
               $("input[name='model']").val($("input[name='model']").val().replace(/[^\d.]/g,""));
           }else{
               $(".layui-span-unit").addClass("layui-hide");
               $("input[name='model']").removeAttr("oninput")
           }
        });

        var conFlag=false;
        form.on('submit(confirm)', function(data){
            if(conFlag){
                return;
            }
            conFlag=true;
            $.ajax({
                url:'${ctx}/planManage/saveElectricMaterialSet',
                method:'post',
                data:JSON.stringify(data.field),
                contentType: 'application/json',
                dataType:'JSON',
                success:function(res){
                    if(res.code=="200"){
                        parent.layer.msg("保存成功",{time:1000});
                        closeDiv();
                        parent.table.reload('test');
                    }else{
                        layer.msg(res.errMsg,{time:1000},function (){
                            conFlag=false;
                        });
                    }
                },
                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;
    }
</script>
</body>
</html>
