<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增【接口信息管理】')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-interfaceinfo-add">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">接口名称：</label>
                <div class="col-sm-8">
                    <input name="interfaceName" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">所属部门：</label>
                <div class="col-sm-8">
                    <input name="deptName" class="form-control" type="text" onclick="selectDeptTree()" id="treeName" placeholder="请选择归属部门" required>
                    <input name="deptId" id="treeId" type="hidden">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">信息项：</label>
                <div class="col-sm-8">
                    <input name="infoItem" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">使用场景描述：</label>
                <div class="col-sm-8">
                    <input name="usageScenarios" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">共享方式：</label>
                <div class="col-sm-8">
                    <select name="shareType" disabled class="form-control m-b" th:with="type=${@dict.getType('share_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">请求方式：</label>
                <div class="col-sm-8">
                    <select name="interfaceType" class="form-control m-b" th:with="type=${@dict.getType('interface_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">环境：</label>
                <div class="col-sm-8">
                    <input name="env" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">签名服务地址：</label>
                <div class="col-sm-8">
                    <input name="signServeraddress" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">接口地址：</label>
                <div class="col-sm-8">
                    <input name="interfaceAddress" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">IAM方式：</label>
                <div class="col-sm-8">
                    <input name="typeIam" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">AK/SK方式：</label>
                <div class="col-sm-8">
                    <input name="typeAksk" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        let prefix = ctx + "system/interfaceinfo"
        let shareType = [[${shareType}]];
        $(function(){
            $("select[name='shareType']").val(shareType);
        });

        $("#form-interfaceinfo-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                let data = $("#form-interfaceinfo-add").serializeArray();
                data.push({"name": "shareType", "value": shareType});
                $.operate.save(prefix + "/add", data);
            }
        }

        /*用户管理-新增-选择部门树*/
        function selectDeptTree() {
            var treeId = $("#treeId").val();
            var deptId = $.common.isEmpty(treeId) ? "100" : $("#treeId").val();
            var url = ctx + "system/dept/selectDeptTree/" + deptId;
            var options = {
                title: '选择部门',
                width: "380",
                url: url,
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            var tree = layero.find("iframe")[0].contentWindow.$._tree;
            if ($.tree.notAllowParents(tree)) {
                var body = layer.getChildFrame('body', index);
                $("#treeId").val(body.find('#treeId').val());
                $("#treeName").val(body.find('#treeName').val());
                layer.close(index);
            }
        }
    </script>
</body>
</html>
