<%@ 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" />
    <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 name="id" hidden value="${settingInfo.columns.id}">
                    <input type="text" name="bankName" id="bankName" lay-verify="required" autocomplete="off" value="${settingInfo.columns.bank_name}" class="layui-input">
                </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" value="${settingInfo.columns.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}" <c:if test="${settingInfo.columns.capitals eq data.columns.id}"> selected</c:if>  data-value="${data.columns.name}" >${data.columns.name}</option>
                        </c:forEach>
                    </select>
                </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 src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/lib/formSelects-v4.js"></script>
<script>
    var formSelects;
    layui.use(['form','table', 'formSelects'], function(){
        var $ = layui.$;
        form = layui.form;
        formSelects = layui.formSelects;
        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 number = $("#number").val();
            var bankName = $("#bankName").val();
            var capitals = formSelects.value('capitals', "valStr");
            console.log(capitals)
            if (isBlank(number)) {
                layer.msg("请输入联行号", {icon: 5, anim: 6});
                return;
            }
            if (isBlank(bankName)) {
                layer.msg("请输入开户行", {icon: 5, anim: 6});
                return;
            }
            $.ajax({
                type: 'post',
                data: {id:id, number: number, bankName: bankName, capitals: capitals},
                url: "${ctx}/sysSettings/linkNumber/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>
