<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE HTML>
<html>
<head>
    <meta name="decorator" content="base" />
    <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">
    <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" 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 name="id" hidden value="${settingInfo.columns.id}">
                        <input type="text" name="name" lay-verify="required" autocomplete="off" value="${settingInfo.columns.name}" 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" <c:if test="${settingInfo.columns.attribute eq '1'}">selected</c:if>>纯租25年业务</option>--%>
                            <option value="2" <c:if test="${settingInfo.columns.attribute eq '2'}">selected</c:if>>经营性租赁</option>
                            <option value="3" <c:if test="${settingInfo.columns.attribute eq '3'}">selected</c:if>>融资租赁</option>
                            <option value="4" <c:if test="${settingInfo.columns.attribute eq '4'}">selected</c:if>>光伏贷</option>
                            <option value="5" <c:if test="${settingInfo.columns.attribute eq '5'}">selected</c:if>>全款</option>
                            <option value="6" <c:if test="${settingInfo.columns.attribute eq '6'}">selected</c:if>>其他</option>
                        </select>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="operate-footer">
        <button class="layui-btn " lay-submit lay-filter="component-form-element">保存</button>
        <button class="layui-btn layui-btn-primary" onclick="cancel()">取消</button>
    </div>
</div>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script src="${ctxPlugin}/lib/ueditor/1.4.3/third-party/jquery-1.10.2.js"></script>
<script>
    layui.use(['form','table'], function(){
        var $ = layui.$;
        form = layui.form;
        form.verify({
            loginNameRule:[/^[0-9A-Za-z]{6,20}$/,'登录名只能是6-20位数字字母组合'],
            passwordRule: [/^[0-9A-Za-z]{6,20}$/,'登录名只能是6-20位数字字母组合'],
        });

        form.on('submit(component-form-element)',function(){
            var id = $("input[name=id]").val();
            var name = $("input[name=name]").val();
            var attribute = $("#attribute").val();
            if (isBlank(attribute)) {
                layer.msg("请选择变更后状态", {icon: 5, anim: 6});
                return;
            }
            $.ajax({
                type: 'post',
                data: {id: id, name: name, attribute: attribute},
                url: "${ctx}/productLine/set/edit",
                success: function (data) {
                    if (data.code == '200') {
                        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>
