<%@ 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" />
    <link rel="stylesheet" href="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/style/formSelects-v4.css" media="all">
    <link rel="stylesheet" type="text/css" href="${ctxPlugin}/lib/font/iconfont.css" />
    <style>html{background-color: #fff;padding-bottom: 50px;}</style>
</head>
<body>
<div class="layui-form">
    <div class="layui-card-body">

                <div class="layui-col-xs12 mb-10 pr-30">
                    <div class="layui-inline layui-col-xs7">
                        <label class="layui-form-label w-130"><i class="red">*</i>开户支行：</label>
                        <div class="layui-input-block ">
                            <input type="text" name="bankName" id="bankName"  autocomplete="off" placeholder="请输入" lay-verify="required" class="layui-input" value="">
                        </div>
                    </div>
                    <div class="layui-inline layui-col-xs5">
                        <label class="layui-form-label" ><i class="red">*</i>联行号：</label>
                        <div class="layui-inline" >
                            <input type="text" name="number" id="number" lay-verify="required" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-col-xs12 mb-10 pr-30">
                    <div class="layui-inline layui-col-xs7">
                        <label class="layui-form-label">资方：</label>
                        <div class="layui-input-block" >
                            <select name="capitals" id="capitals"  xm-select="capitals" xm-select-type="1" xm-select-height="25px" xm-select-show-count="6">
                                <option value="">请选择</option>
                                <c:forEach items="${paterns}" var="data">
                                    <option value="${data.columns.id}">${data.columns.name}</option>
                                </c:forEach>
                            </select>
                        </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 src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/lib/formSelects-v4.js"></script>
<script>
    var count = 1;
    var formSelects;
    layui.config({
        base: '${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['form','jquery','layedit', 'formSelects'], function () {
        $ = layui.jquery,
            form = layui.form,
            layer = layui.layer,
            formSelects = layui.formSelects;

        form.on('submit(component-form-element)',function(){
            var number = $("#number").val();
            var bankName = $("#bankName").val();
            var capitals = formSelects.value('capitals', "valStr");
            $.ajax({
                type: 'post',
                data: {number: number, bankName: bankName, capitals: capitals},
                url: "${ctx}/sysSettings/linkNumber/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>