<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="UTF-8">
	<title></title>
	<link rel="stylesheet"  th:href="@{/layui/css/layui.css}"  media="all">

</head>
<body>
<div class="layui-container">
	<div id="vl_registe">
		<div>
			<p class="userinfo" style="margin-top: 30px">
				<label class="layui-form-label" style="    margin-left: -40px;    width: 98px;">流程名称:</label>
				<input type="text" name="name" id="name" value="" style="    width: 280px;" placeholder="流程名称" class="layui-input" onfocus="userNameFocus()" autocomplete="off" />
			</p>
			<p class="userinfo" style="margin-top: 40px">
				<label class="layui-form-label" style="    margin-left: -40px;    width: 98px;">流程描述:</label>
				<input type="text" name="content" id="content" style="    width: 280px;" value="" placeholder="流程描述" class="layui-input"  autocomplete="off" />
			</p>
		</div>
	</div>

	<div class="layui-row" align="center" style="margin-top: 50px;">
		<button type="button" class="layui-btn" id="test3" style="background-color: #005ba7;"><i class="layui-icon"></i>选择文件</button>
		<button type="button" class="layui-btn" id="test9" style="background-color: #005ba7;margin-left:10px;width:100px;">开始上传</button>
	</div>

</div>
</body>

<script th:src="@{/js/plugins/jquery.min.js}"></script>
<script th:src="@{/layui/layui.js}" ></script>
<script>

    layui.use('upload', function(){
        var $ = layui.jquery
            ,upload = layui.upload;
        //选完文件后不自动上传
        upload.render({
            elem: '#test3'
            ,url: '/bpm/user/improtDeployMent'
            ,size: 20480 //限制文件大小, 单位 KB5
            ,auto : false
            ,data: {
                name: function(){
                    return $('#name').val();
                },
                content:function () {
                    return $('#content').val();
                }
            }
            ,accept: 'file' //普通文件
            ,exts: 'json' //只允许上传xlsx文件
            //,multiple: true
            ,bindAction: '#test9'
            ,before: function(obj){ //obj参数包含的信息，跟 choose回调完全一致，可参见上文。
                layer.msg('上传文件中', {
                    icon: 16,
                    time : -1
                });
            }
            ,done: function(res){
                console.info("there" + res);
                console.log(res)
                if (res.code==200){
                    layer.msg("上传文件成功");
                    setTimeout(function(){
                        parent.location.reload();
                    },1000)
                }else if (res.code==201){
                    layer.msg("上传流程名称不可为空");
                    setTimeout(function(){
                        parent.location.reload();
                    },1000)
                }else if (res.code==202){
                    layer.msg("上传流程描述不可为空");
                    setTimeout(function(){
                        parent.location.reload();
                    },1000)
                }
                else {
                    layer.msg("上传文件失败");
                    parent.location.reload();
                }
            }
        });
    });
</script>
</html>