<%@ 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" />
    <style>html{background-color: #fff;padding-bottom: 50px;}</style>
</head>
<body>
<div class="layui-form">
    <div class="layui-card-body">
        <div id="textDiv">
            <div class="layui-form-item">
                <div class="contentBody ">
                    <label class="layui-form-label"><i class="mark">*</i>产品线名称：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="name" lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                    <div class="f-l layui-word-aux lh-30"></div>
                    <label class="layui-form-label"><i class="mark">*</i>业务属性：</label>
                    <div class="layui-input-inline">
                        <select  name="attribute" id="attribute">
                            <option value="">请选择</option>
                     <%--       <option value="1">纯租25年业务</option>--%>
                            <option value="2">经营性租赁</option>
                            <option value="3">融资租赁</option>
                            <option value="4">光伏贷</option>
                            <option value="5">全款</option>
                            <option value="6">其他</option>
                        </select>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="operate-footer">
        <input type="button" value="保存" class="layui-btn " lay-submit lay-filter="component-form-element">
        <input type="button" value="取消" class="layui-btn layui-btn-primary" onclick="cancel()">
    </div>
</div>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script>
    var count = 1;
    layui.config({
        base: '${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['form','jquery','layedit'], function () {
        $ = layui.jquery,
            form = layui.form,
            layer = layui.layer;

        form.on('submit(component-form-element)',function(){
            var name = $("input[name=name]").val();
            var attribute = $("#attribute").val();
            if (isBlank(attribute)) {
                layer.msg("请选择业务类型", {icon: 5, anim: 6});
                return;
            }
            $.ajax({
                type: 'post',
                data: {name: name, attribute: attribute},
                url: "${ctx}/productLine/set/add",
                success: function (data) {
                    if (data.code == '200') {
                        //先得到当前iframe层的索引
                        var index = parent.layer.getFrameIndex(window.name);
                        //再执行关闭
                        layer.msg('添加成功！', {icon:1,time:1000},function(){
                            parent.layer.close(index);
                            parent.location.reload(); //刷新父页面
                        })
                    } else {
                        layer.msg(data.msg, {icon: 2});
                    }
                },
                error: function (e) {
                    layer.msg("请刷新！", {icon: 2});
                    return;
                }
            })
        })


    });

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

    function cancel(){
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    }
</script>
</body>
</html>