<!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-edit" th:object="${tUInterfaceinfo}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">接口名称：</label>
                <div class="col-sm-8">
                    <input name="interfaceName" th:field="*{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="interfaceName" th:field="*{code}" class="form-control" type="text" disabled>
                </div>
            </div>
            <div class="form-group" th:hidden="${hideSecretKey}">
                <label class="col-sm-3 control-label is-required">秘钥：</label>
                <div class="col-sm-8">
                    <input name="interfaceName" th:field="*{secretKey}" class="form-control" type="text" disabled>
                </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" th:field="*{deptName}" type="text" onclick="selectDeptTree()" id="treeName" placeholder="请选择归属部门" required>
                    <input name="deptId" id="treeId" type="hidden" th:field="*{deptId}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">信息项：</label>
                <div class="col-sm-8">
                    <input name="infoItem" th:field="*{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" th:field="*{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}" th:field="*{shareType}"></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}" th:field="*{interfaceType}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">环境：</label>
                <div class="col-sm-8">
                    <input name="env" th:field="*{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" th:field="*{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" th:field="*{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" th:field="*{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" th:field="*{typeAksk}" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "system/interfaceinfo";
        $("#form-interfaceinfo-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                let data = $("#form-interfaceinfo-edit").serializeArray();
                data.push({"name": "shareType", "value": $("select[name='shareType']").val()});
                $.operate.save(prefix + "/edit", 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>
