<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
<th:block th:include="include :: header('新增API权限认证')" />
<th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-apiSecurity-add">
			<div class="form-group">
				<label class="col-sm-3 control-label">API接口服务key：</label>
				<div class="col-sm-8">
					<input id="apiKey" name="apiKey" class="form-control"
						required="required" type="text" maxlength="25">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">API接口服务secret：</label>
				<div class="col-sm-8">
					<input id="apiSecret" name="apiSecret" class="form-control"
						required="required" type="text" maxlength="25">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">API接口服务状态：</label>
				<div class="col-sm-8">
					<label class="toggle-switch switch-solid"> <input
						required="required" type="checkbox" id="apiStatus" checked>
						<span></span>
					</label>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">API接口服务类型：</label>
				<div class="col-sm-8">
					<select name="apiType" class="form-control m-b" required="required"
						th:with="type=${@dict.getType('t_api_type')}">
						<option th:each="dict : ${type}" th:text="${dict.dictLabel}"
							th:value="${dict.dictValue}"></option>
					</select>
				</div>
			</div>
		</form>
	</div>
	<div th:include="include::footer"></div>
	<th:block th:include="include :: select2-js" />
	<script type="text/javascript">
		var prefix = ctx + "bussiness/apiSecurity"
		$("#form-apiSecurity-add").validate({
			rules : {
				xxxx : {
					required : true,
				},
			},
			focusCleanup : true
		});

		function submitHandler() {
			if ($.validate.form()) {

				var data = $("#form-apiSecurity-add").serializeArray();
				var apiStatus = $("input[id='apiStatus']").is(':checked') == true ? 1
						: 0;
				data.push({
					"name" : "apiStatus",
					"value" : apiStatus
				});
				$.operate.save(prefix + "/add", data);
			}
		}
	</script>
</body>
</html>
