<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" 
      xmlns:sec="http://www.pollix.at/thymeleaf/shiro">
<head th:replace="admin/common/html/tableHead :: head(~{::title},~{::link},~{::style})">

<title th:text=${title}></title>
<!-- 这儿引用单独的css link -->
<!-- Ladda for Bootstrap 3按钮加载进度插件 -->
<link rel="stylesheet" th:href="@{/static/admin/assets/js/button/ladda/ladda.min.css}">
<!-- bootstrap-table表单样式 -->
<link th:href="@{/static/admin/assets/js/bootstrap/css/bootstrap-table/bootstrap-table.min.css}" rel="stylesheet"/>
<!-- 用户界面自定义css -->
<link th:href="@{/static/admin/user/css/user-add.css}" rel="stylesheet"/>
<style type="text/css"></style>
</head>

<body>

<div class="content-wrap">
	<div class="row">
		<div class="col-sm-12">
			<div class="nest" id="elementClose">
				<div class="">
				</div>
				<div class="body-nest" id="element">
					<div class="panel-body">
						<form  class="form-horizontal m" id="form-add">
									<div class="form-group">
										<label class="col-sm-3 control-label ">字典标签：</label>
										<div class="col-sm-8">
											<input class="form-control" type="text" id="dictLabel" name="dictLabel"/>
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-3 control-label ">字典键值：</label>
										<div class="col-sm-8">
											<input class="form-control" type="text" id="dictValue" name="dictValue"/>
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-3 control-label ">字典类型：</label>
										<div class="col-sm-8">
											<input class="form-control" type="hidden"  id="dictType" name="dictType" th:value="${dictType}"/>
											<input class="form-control" type="text" disabled="disabled" th:value="${dictType}"/>
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-3 control-label ">样式属性（其他样式扩展）：</label>
										<div class="col-sm-8">
											<input class="form-control" type="text" id="cssClass" name="cssClass"/>
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-3 control-label ">字典排序：</label>
										<div class="col-sm-8">
											<input class="form-control" type="number" id="dictSort" name="dictSort"/>
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-3 control-label ">表格回显样式：</label>
										<div class="col-sm-8">
											<select name="listClass" id="listClass" class="form-control m-b valid" aria-invalid="false">
											    <option value="">---请选择---</option>
							                    <option value="default"  selected="selected">默认</option>
							                    <option value="primary">主要</option>
							                    <option value="success">成功</option>
							                    <option value="info">信息</option>
							                    <option value="warning">警告</option>
							                    <option value="important">危险</option>
							                </select>
										</div>
									</div>
									
							        <div  v-if="menu.type == 1" class="form-group">
										<label class="col-sm-3 control-label ">是否默认：</label>
										<div class="col-sm-8">
									 	   <select class="form-control" id="isDefault" name="isDefault"  >
												<option value="Y">是</option>
												<option value="N">否</option>
											</select>
										</div>
									</div>
							        <div  v-if="menu.type == 1" class="form-group">
								        <label class="col-sm-3 control-label ">状态：</label>
								        <div class="col-sm-8">
									         <select class="form-control" id="dataStatus" name="dataStatus"  >
												 <option value="0">正常</option>
											 	 <option value="1">停用</option>
											 </select>
										</div>
								    </div>
									<div class="form-group">
										<label class="col-sm-3 control-label ">备注：</label>
										<div class="col-sm-8">
											<input class="form-control" type="text" id="remark" name="remark"/>
										</div>
									</div>
									<div class="form-group">
										<div class="form-control-static col-sm-offset-9">
											<button id="submit" type="submit" class="btn btn-primary">提交</button>
											<button onclick="$.modal.close()" class="btn btn-danger" type="button">关闭</button>
										</div>
									</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

<!-- 通用js -->
<div th:include="admin/common/html/js :: onload_js">
   
</div>
<!-- bootstarp 表格 -->
<script th:src="@{/static/admin/assets/js/bootstrap/js/bootstrap-table/bootstrap-table.min.js}" type="text/javascript"></script>
<script th:src="@{/static/admin/assets/js/bootstrap/js/bootstrap-table/locale/bootstrap-table-zh-CN.min.js}" type="text/javascript"></script>
<script th:src="@{/static/admin/assets/js/bootstrap/js/base_list.js}" type="text/javascript"></script>


<!-- 弹窗 -->
<script  th:src="@{/static/admin/assets/js/layer/layer.js}" type="text/javascript"></script>
<!-- 遮罩层 -->
<script  th:src="@{/static/admin/assets/js/blockUI/jquery.blockUI.js}" type="text/javascript"></script>
<!-- jqueryForm序列化 -->
<script  th:src="@{/static/js/jqueryFormSerializeJson.js}" type="text/javascript"></script>
<script type="text/javascript">

$(function(){
	 $(".MyDate").datetimepicker({
		 	format: "yyyy-mm-dd hh:00:00",
	        startDate: new Date(),
	        autoclose: true,
	        todayBtn: true,
	        language: 'zh-CN',
	        initialDate:new Date(),
	        minView: 1      
	    });
	
})


$("#form-add").validate({
	rules:{
		name:{
			required:true,
			minlength: 2,
			maxlength: 20,
			remote: {
                url: rootPath + "/DictDataController/checkNameUnique",
                type: "post",
                dataType: "json",
                dataFilter: function(data, type) {
                    if (data == "0")
                    	return true;
                    else 
                    	return false;
                }
            }
		}
	},
	messages: {
        "name": {
            remote: "名称已经存在"
        }
    },
	submitHandler:function(form){
		add();
	}
});

/**
 * 用户添加方法
 */
function add() {
	var dataFormJson=$("#form-add").serialize();
	$.ajax({
		cache : true,
		type : "POST",
		url : rootPath + "/DictDataController/add",
		data : dataFormJson,
		async : false,
		error : function(request) {
			$.modal.alertError("系统错误");
		},
		success : function(data) {
			$.operate.saveSuccess(data);
		}
	});
}
$("#submit").click(function () {
	//关闭弹窗
	var mylay = parent.layer.getFrameIndex(window.name);
	parent.layer.close(mylay);
	window.parent.location.reload();
})

</script>


</body>


</html>
