<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<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, maximum-scale=1">
    <link rel="stylesheet" th:href="@{/lib/layui/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/css/public.css}" media="all">
    <style>

        .layui-form-item label{
            width: 15%;
        }
        .layui-input-block input{
            width: 90%;
        }
        .layui-input-block textarea{
            width: 90%;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form" style="margin-left: -15px; margin-right: 20px">
    <div class="layui-form-item">
        <label class="layui-form-label required">项目名称</label>
        <div class="layui-input-block">
            <input type="hidden" name="xmid" id="xmid" th:value="${projects.id}">
            <input type="text" name="name" id="name" th:value="${projects.projectName}"
                   lay-verify="required"
                   lay-reqtext="项目名称不能为空！"
                   autocomplete="off"
                   placeholder="请输入项目名称..." maxlength="30"
                   class="layui-input"  readonly>
            <div style=" margin-left: 7%;
            color:#e74c3c;
            font-weight: bold;"> 注:不可编辑！</div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">项目编码</label>
        <div class="layui-input-block">
            <input type="text" name="code" id="code" lay-verify="required" th:value="${projects.code}" lay-reqtext="岗位编码不能为空" autocomplete="off" placeholder="请输入项目编码..."
                   class="layui-input" readonly>
            <div style=" margin-left: 7%;
            color:#e74c3c;
            font-weight: bold;">注：不可编辑！</div>
            <!-- 项目编码 采用  12- 20位的编码格式 ，编码组成 为  YYYYMMDD-XXX-NNNN ; YYYYMMDD 表示为8 位日期 XXX:3位项目类型或部门代码 “NNNN”： 4位 序列号 -->
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">进度描述</label>
        <div class="layui-input-block">
            <textarea name="progress" id="progress" class="layui-textarea" autocomplete="off"></textarea>
        </div>
    </div>

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

    </div>

</div>
<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'], function () {
        var form = layui.form,
            layer = layui.layer;
        // 模块类型
        var type = 'prjProject';

        form.on('submit(saveBtn)', function (data) {
            var formData = {
                xmId: $('#xmid').val(),
                code: $('#code').val(),
                progress: $('#progress').val()
            };
            console.log(formData);
            var index = layer.alert('确认提交吗？', function () {
                var loading = layer.load(0, {shade: 0.1});
                console.log(data.field);
                AjaxUtil.post({
                    url: AjaxUtil.ctx + "bug/progressupdate/"+ type,
                    data: formData,
                    success: function (res) {
                        layer.close(index);
                        layer.close(loading);
                        if (res.code === 0) {
                            layer.msg(res.message,{icon:1}, function () {
                                // 重载表格
                                parent.setUpdateFlag();
                                var iframeIndex = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(iframeIndex);
                            });
                        } else {
                            layer.msg(res.message, {icon:2});
                        }
                    },
                    error: function (error) {
                        layer.close(index);
                    }
                });
            });
            return false;
        });

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

    });
</script>
</body>
</html>