<!DOCTYPE html>
<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 required" style="width: 10%">人员</label>
            <div class="layui-input-inline" style="width: 25%">
                <input type="hidden" id="ry" name="ry">
                <input type="text" id="ryxm" name="ryxm" lay-verify="required" lay-reqtext="人员不能为空" class="layui-input"
                       readonly>
            </div>
            <label class="layui-form-label" style="width: 10%">单位</label>
            <div class="layui-input-inline" style="width: 35%">
                <input type="hidden" id="dw" name="dw">
                <input type="text" id="dwmc" name="dwmc" class="layui-input" readonly>
            </div>
        </div>

<!--        <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: 650px">
                <input type="hidden" id="dw" name="dw">
                <input type="text" id="dwmc" name="dwmc" class="layui-input" readonly>
            </div>
        </div>-->

        <div class="layui-form-item layui-inline" style="width: 100%">
<!--            <label class="layui-form-label" style="width: 10%">单位类型</label>
            <div class="layui-input-inline" style="width: 25% ">
                <input type="hidden" id="dwlx" name="dwlx" class="layui-input">
                <input type="text" id="dwlxmc" name="dwlxmc" class="layui-input" readonly>
            </div>-->
            <label class="layui-form-label" style="width: 10%">学历</label>
            <div class="layui-input-inline" style="width: 25%">
                <input type="hidden" id="xl" name="xl" class="layui-input">
                <input type="text" id="xlmc" name="xlmc" class="layui-input" readonly>
            </div>
            <label class="layui-form-label" style="width: 10%">职称</label>
            <div class="layui-input-inline" style="width: 35%">
                <input type="hidden" id="zc" name="zc" class="layui-input">
                <input type="text" id="zcmc" name="zcmc" class="layui-input" readonly>
            </div>
        </div>

        <div class="layui-form-item layui-inline" style="width: 100%">
            <label class="layui-form-label required" style="width: 10%">项目角色</label>
            <div class="layui-input-inline" style="width: 25%">
                <input type="hidden" id="xmjsmc" name="xmjsmc" class="layui-input">
                <select name="xmjs" id="xmjs" lay-verify="required" lay-reqtext="项目角色不能为空" lay-filter="xmjs">
                    <option th:each="item:${xmjsList}" th:text="${item.name}" th:value="${item.code}"></option>
                </select>
            </div>
            <label class="layui-form-label" style="width: 10%">本项目分工</label>
            <div class="layui-input-inline" style="width: 35%">
                <input type="text" id="bxmfg" name="bxmfg" autocomplete="off"
                       style="position: absolute; z-index: 2; margin:2px; width: 90%; height: 90%; border: none"
                       class="layui-input">
                <select name="bxmfgmc" id="bxmfgmc" lay-search="" lay-filter="bxmfg">
                    <option value="">选择或输入本项目分工</option>
                    <option th:each="item:${bxmfgList}" th:text="${item.name}" th:value="${item.name}"></option>
                </select>
            </div>

        </div>

        <div class="layui-form-item layui-inline" style="width: 100%">
            <label class="layui-form-label" style="width: 10%">投入工作总月数</label>
            <div class="layui-input-inline" style="width: 25%">
                <input type="number" min="1" id="trgzzys" name="trgzzys" value="1" class="layui-input">
            </div>

        </div>

        <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: 250px">
                <input type="number" id="sxbh" name="sxbh" class="layui-input" autocomplete="off">
            </div>-->

        </div>

        <!-- 右侧悬浮按钮 -->
        <div class="right-bottom-btn">
            <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="@{/js/lay-config.js}" charset="utf-8"></script>
<script type="text/javascript" th:inline="javascript">
    AjaxUtil.ctx = /*[[@{/}]]*/'';
    layui.use(['form', 'layer', 'tableSelect'], function () {
        var form = layui.form,
            tableSelect = layui.tableSelect;

        var prjMember = parent.getMember();
        $("#ry").val(prjMember.ry);
        $("#ryxm").val(prjMember.ryxm);
        $("#dw").val(prjMember.dw);
        $("#dwmc").val(prjMember.dwmc);
        $("#dwlx").val(prjMember.dwlx);
        $("#dwlxmc").val(prjMember.dwlxmc);
        $("#zc").val(prjMember.zc);
        $("#zcmc").val(prjMember.zcmc);
        $("#xl").val(prjMember.xl);
        $("#xlmc").val(prjMember.xlmc);
        $("#xmjsmc").val(prjMember.xmjsmc);
        $("#bxmfg").val(prjMember.bxmfg);
        $("#sxbh").val(prjMember.sxbh);
        $("#trgzzys").val(prjMember.trgzzys);

        //下拉框回显
        function set_select(id, value) {
            let obj = $("#" + id)
            //不精准查询
            // obj.find("option:contains('"+value+"')").attr("selected",true)
            //精准查询
            obj.find("option:contains('" + value + "')").map(function () {
                if ($(this).text() == value) {
                    $(this).attr("selected", true)
                }
            });
            obj.parent().find(".layui-select-title").find("input").val(value)
        }

        if ($("#xmjsmc").val() != null && $("xmjsmc").val() != "") {
            set_select('xmjs', $("#xmjsmc").val());
        }

        //监听项目角色
        form.on('select(xmjs)', function (data) {
            let text = data.elem.selectedOptions[0].text;
            $("#xmjsmc").val(text);
        });
        //监听项目分工
        form.on('select(bxmfg)', function (data) {
            let text = data.elem.selectedOptions[0].text;
            $("#bxmfg").val(text);
        });

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            if (data.field.bxmfg != "") {
                AjaxUtil.post({
                    url: AjaxUtil.ctx + "prjProjectdivision/doAdd",
                    data: data.field
                });
            }

            parent.setMember(data.field);
            parent.setUpdateFlag();
            parent.layer.close(parent.layer.getFrameIndex(window.name));// 关闭子窗口

            return false;
        });

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