<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增档案管理')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-dangan-add">
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">系统名称：</label>
                        <div class="col-sm-8">
                            <input id="danganName" name="danganName" class="form-control" type="text" required>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">系统状态：</label>
                        <div class="col-sm-8">
                            <select name="status" class="form-control m-b" th:with="type=${@dict.getType('sys_dangan_status')}"  >
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </div>
                    </div>
                </div>
            </div>



            <div class="row">


                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">系统编号：</label>
                        <div class="col-sm-8">
                            <input id="danganNo" name="danganNo" class="form-control" type="text" required>
                        </div>
                    </div>
                </div>




                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">系统私钥：</label>
                        <div class="col-sm-8">
                            <input id="keyId" name="keyId" class="form-control" type="text" required>
                        </div>
                    </div>
                </div>

            </div>






            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">系统负责人：</label>
                        <div class="col-sm-8">
                            <input name="sysPerson" class="form-control" type="text">
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">架构模式：</label>
                        <div class="col-sm-8">
                            <select name="mode" class="form-control m-b" th:with="type=${@dict.getType('sys_dangan_mode')}"  >
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">类别：</label>
                        <div class="col-sm-8">
                            <input name="fileType" class="form-control" type="text">
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">型号/版本：</label>
                        <div class="col-sm-8">
                            <input name="model" class="form-control" type="text">
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">所属项目ID：</label>
                        <div class="col-sm-8">
                            <input name="projectId" class="form-control" type="text">
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">品牌：</label>
                        <div class="col-sm-8">
                            <input name="brand" class="form-control" type="text">
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">运行设备ID：</label>
                        <div class="col-sm-8">
                            <input name="runDeviceId" class="form-control" type="text">
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">关联设备ID：</label>
                        <div class="col-sm-8">
                            <input name="relateDeviceId" class="form-control" type="text">
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">维护项目ID：</label>
                        <div class="col-sm-8">
                            <input name="maintainItemId" class="form-control" type="text">
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">厂家质保期：</label>
                        <div class="col-sm-8">
                            <input name="factoryTime" class="form-control" type="text">
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">项目质保期：</label>
                        <div class="col-sm-8">
                            <input name="projectTime" class="form-control" type="text">
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">使用单位：</label>
                        <div class="col-sm-8">
                            <input name="useUnit" class="form-control" type="text">
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">介质：</label>
                        <div class="col-sm-8">
                            <input name="medium" class="form-control" type="text">
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">维护时间：</label>
                        <div class="col-sm-8">
                            <div class="input-group">
                                <input name="maintainTime" id="maintainTime" class="form-control" placeholder="yyyy-MM-dd HH:mm:ss" type="text">
                                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">认证页面地址：</label>
                        <div class="col-sm-8">
                            <input name="pageAddress" class="form-control">
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">系统状态检测地址：</label>
                        <div class="col-sm-8">
                            <input name="testAddress" class="form-control" type="text">
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">系统建设厂商：</label>
                        <div class="col-sm-8">
                            <input name="buildFactory" class="form-control" type="text">
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">建设时间：</label>
                        <div class="col-sm-8">
                            <div class="input-group date">
                                <input name="buildFactoryTime" class="form-control" placeholder="yyyy-MM-dd" type="text">
                                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">厂商负责人：</label>
                        <div class="col-sm-8">
                            <input name="factoryPerson" class="form-control" type="text">
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">厂商负责人电话：</label>
                        <div class="col-sm-8">
                            <input name="factoryPersonPhone" class="form-control" type="text">
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">

                    <div class="form-group">
                        <label class="col-sm-3 control-label">开发语言：</label>
                        <div class="col-sm-8">
                            <input name="language" class="form-control" type="text">
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">部署服务器IP：</label>
                        <div class="col-sm-8">
                            <input name="serverIp" class="form-control" type="text">
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">服务器位置：</label>
                        <div class="col-sm-8">
                            <input name="serverLocation" class="form-control" type="text">
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">服务器配置信息：</label>
                        <div class="col-sm-8">
                            <input name="serverInfo" class="form-control" type="text">
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">是否专用服务器：</label>
                        <div class="col-sm-8">
                            <select name="serverBasedYesNo" class="form-control m-b" th:with="type=${@dict.getType('sys_dangan_yes_no')}"  >
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">运维负责人：</label>
                        <div class="col-sm-8">
                            <input name="opsPerson" class="form-control" type="text">
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">主管单位：</label>
                        <div class="col-sm-8">
                            <input name="chargeUnit" class="form-control" type="text">
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <input type="hidden" id="fileName" name="fileName">
                        <input type="hidden" id="filePath" name="filePath">
                        <label class="col-sm-3 control-label ">文档信息：</label>
                        <div class="col-sm-8">
                            <input id="file" name="file" class="form-control" type="file"  onchange="uploadFile();" multiple >
                            <div id="fileinfo">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-12">
                    <div class="form-group">
                        <label class="col-sm-1 control-label">备注：</label>
                        <div class="col-sm-9">
                            <textarea name="remark" class="form-control" type="text"></textarea>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "system/dangan"
        $("#form-dangan-add").validate({
            onkeyup: false,
            rules:{
                danganName:{
                    remote: {
                        url: prefix + "/checkDanganNameUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                            "danganName": function() {
                                return $.common.trim($("#danganName").val());
                            }
                        },
                        dataFilter: function(data, type) {
                            return $.validate.unique(data);
                        }
                    }
                }
            },
            messages: {
                "danganName": {
                    remote: "档案名称已经存在"
                },
            },
            focusCleanup: true
        });

        layui.use('laydate', function() {
            var laydate = layui.laydate;
            laydate.render({
                elem: '#maintainTime',
                type: 'datetime',
                trigger: 'click'
            });
        });

        function uploadFile(){
            var formData = new FormData();
            if ($('#file')[0].files[0] == null) {
                $.modal.alertWarning("请先选择文件路径");
                return false;
            }
            var this_1=  document.getElementById('file');
            var files = this_1.files;

            for (var i = 0, len = files.length; i < len; i++) {
                formData.append('files', files[i]);
            }
            $.ajax({
                url: ctx + "common/uploadMultipart",
                type: 'post',
                cache: false,
                data: formData,
                processData: false,
                contentType: false,
                dataType: "json",
                success: function(result) {
                    console.log(result);
                    if(result.code == '0'){
                        $("#fileName").val(result.fileName);
                        $("#filePath").val(result.url);
                        var fileArr = new Array();
                        var fileNames =result.fileName;
                        if(null!=fileNames && fileNames.length>0){
                            $("#fileinfo").empty();
                            fileArr = fileNames.split(",");
                            for(var i=0;i<fileArr.length;i++){
                                var html = "";
                                html = "<input type='text' value='"+fileArr[i]+"' class='form-control' style='border: none;' readonly>";
                                $("#fileinfo").append(html);
                            }
                        }

                    }
                }
            });
        }


        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-dangan-add').serialize());
            }
        }


        $("input[name='buildFactoryTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
    </script>
</body>
</html>