<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charSet="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>编辑</title>
    <link rel="stylesheet" th:href="@{/lib/layui/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/css/public.css}" media="all">
    <link rel="stylesheet" th:href="@{/lib/font-awesome-4.7.0/css/font-awesome.min.css}" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<form class="layui-form" action="" lay-filter="formDemo">
    <div class="layui-form layuimini-form">
        <div class="layui-form-item layui-inline" style="width: 100%">
            <label class="layui-form-label" style="width: 70px">专家姓名</label>
            <div class="layui-input-inline" style="width: 270px">
                <input type="text" id="zjxm" name="zjxm" autocomplete="off" class="layui-input">
            </div>
            <label class="layui-form-label required" style="width: 70px">身份证号</label>
            <div class="layui-input-inline" style="width: 270px">
                <input type="text" id="sfzh" name="sfzh" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-inline" style="width: 100%">
            <label class="layui-form-label required" style="width: 70px">职称</label>
            <div class="layui-input-inline" style="width: 270px">
                <input type="text" id="zc" name="zc" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>

        <!-- 右侧悬浮按钮 -->
        <div class="right-bottom-btn">
            <button type="button" class="layui-btn" lay-submit lay-filter="saveBtn">
                <i class="layui-icon layui-icon-ok"></i>确定
            </button>
            <button class="layui-btn" lay-filter="cancleBtn">
                <i class="layui-icon layui-icon-close"></i>取消
            </button>
        </div>
    </div>
</form>

<script th:src="@{/lib/jquery-3.4.1/jquery-3.4.1.min.js}" charSet="utf-8"></script>
<script th:src="@{/lib/layui/layui.js}" charSet="utf-8"></script>
<script th:src="@{/lib/coco-message/coco-message.js}" charSet="utf-8"></script>
<script th:src="@{/lib/xm-select-v1.2.2/xm-select.js}" charSet="utf-8"></script>
<script th:src="@{/js/lay-config.js}" charSet="utf-8"></script>

<script type="text/javascript" th:inline="javascript">
    AjaxUtil.ctx = /*[[@{/}]]*/'';
    layui.use(['form', 'tableSelect', 'laydate'], function () {
        var form = layui.form;

        var zjf = parent.getExpert();
        $("#zjxm").val(zjf.zjxm);
        $("#sfzh").val(zjf.sfzh);
        $("#fysq").val(zjf.fysq);
        $("#bzfy").val(zjf.bzfy);
        $("#zc").val(zjf.zc);
        form.render();

        // var sqje = $("#sqje").val();
        // var fyyt = $("#fyyt").val;
        // var bzjehs = $("#bzjehs").val;
        // var bzjebhs = $("#bzjebhs").val;
        // var bz = parseFloat($("#bz").val());

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            // 获取身份证号
            var sfzhm = document.getElementById('sfzh').value;

            // 身份证号的正则表达式
            var sfzhRegex = /^(\d{15}|\d{18}|\d{17}[xX])$/;

            // 检查身份证号是否合法
            if (!sfzhRegex.test(sfzhm)) {
                // 弹窗提示身份证号不合法
                layer.msg('身份证号格式不正确，请重新输入', {icon: 2});
                return false; // 阻止表单提交
            }

            // 如果身份证号合法，执行提交操作
            parent.setExpert(data.field);
            parent.setUpdateFlag();
            parent.layer.close(parent.layer.getFrameIndex(window.name)); // 关闭子窗口
        });

        // 监听取消按钮
        $("button[lay-filter='cancleBtn']").click(function () {
            var iframeIndex = parent.layer.getFrameIndex(window.name);
            parent.layer.close(iframeIndex);
        });
    });
</script>
</body>
</html>