add.html 8.46 KB
<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<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-picture-add">
<!--        <div class="form-group">-->
<!--            <label class="col-sm-3 control-label is-required">关联的单据编码-->
<!--                :</label>-->
<!--            <div class="col-sm-8">-->
<!--                <input name="referCode" id="referCode" class="form-control" type="text" required>-->
<!--            </div>-->
<!--        </div>-->
<!--        <div class="form-group">-->
<!--            <label class="col-sm-3 control-label">图片关联类型, 可以是出库单类型或入库单类型等:</label>-->
<!--            <div class="col-sm-8">-->
<!--                <select name="referType" id="referType" class="form-control m-b">-->
<!--                    <option value="">所有</option>-->
<!--                </select>-->
<!--                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>-->
<!--            </div>-->
<!--        </div>-->
<!--        <div class="form-group">-->
<!--            <label class="col-sm-3 control-label">图片名称-->
<!--                :</label>-->
<!--            <div class="col-sm-8">-->
<!--                <input name="name" id="name" 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="formate" id="formate" 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="size" id="size" class="form-control" type="text">-->
<!--            </div>-->
<!--        </div>-->
<!--        <div class="form-group">-->
<!--            <label class="col-sm-3 control-label">创建时间:</label>-->
<!--            <div class="col-sm-8">-->
<!--                <div class="input-group date">-->
<!--                    <input name="created" id="created" 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 class="form-group">-->
<!--            <label class="col-sm-3 control-label">创建人-->
<!--                :</label>-->
<!--            <div class="col-sm-8">-->
<!--                <input name="createdby" id="createdby" 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="device" id="device" class="form-control" type="text">-->
<!--            </div>-->
<!--        </div>-->
<!--        <div class="form-group">-->
<!--            <label class="col-sm-3 control-label">设备MEID-->
<!--                :</label>-->
<!--            <div class="col-sm-8">-->
<!--                <input name="meid" id="meid" class="form-control" type="text">-->
<!--            </div>-->
<!--        </div>-->
<!--        <div class="form-group">-->
<!--            <label class="col-sm-3 control-label">设备IP-->
<!--                :</label>-->
<!--            <div class="col-sm-8">-->
<!--                <input name="ip" id="ip" class="form-control" type="text">-->
<!--            </div>-->
<!--        </div>-->
<!--        <div class="form-group">-->
<!--            <label class="col-sm-3 control-label">用户上传的图片备注信息:</label>-->
<!--            <div class="col-sm-8">-->
<!--                <textarea name="description" class="form-control"></textarea>-->
<!--            </div>-->
<!--        </div>-->
<!--        <div class="form-group">-->
<!--            <label class="col-sm-3 control-label">删除标记:</label>-->
<!--            <div class="col-sm-8">-->
<!--                <select name="deleted" class="form-control m-b">-->
<!--                    <option value="">所有</option>-->
<!--                </select>-->
<!--                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>-->
<!--            </div>-->
<!--        </div>-->
        <div class="form-group">
            <label class="col-sm-3 control-label">上传图片:</label>
            <div class="col-sm-6">
                <input id="picture" name="picture" class="form-control" type="file" >
            </div>
            <div class="col-sm-6" id="picturePreview" name="picturePreview"></div>
        </div>
        <div class="form-group">
            <div class="form-control-static col-sm-offset-9">
<!--                <button  id="blobSubmit" class="btn btn-primary" type="button">提交</button>-->
                <button onclick="$.modal.close()" class="btn btn-danger" type="button">关闭</button>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<th:block th:include="include :: bootstrap-fileinput-css"/>
<th:block th:include="include :: bootstrap-fileinput-js"/>
<script type="text/javascript">

    //初始化fileinput
    var FileInput = function () {
        var oFile = new Object();
        //初始化fileinput控件(第一次初始化)
        oFile.Init = function(ctrlName, uploadUrl) {
            var control = $('#' + ctrlName);
            //初始化上传控件的样式
            control.fileinput({
                language: 'zh', //设置语言
                uploadUrl: uploadUrl, //上传的地址
                allowedFileExtensions: ['jpg', 'gif', 'png', 'pdf'], //接收的文件后缀
                showUpload: true, //是否显示上传按钮
                showCaption: false, //是否显示标题
                browseClass: "btn btn-primary", //按钮样式
                maxFileCount: 1, //表示允许同时上传的最大文件个数
                enctype: 'multipart/form-data',
                validateInitialCount:true,
                previewFileIcon: "<i class='glyphicon glyphicon-king'></i>",
                msgFilesTooMany: "选择上传的文件数量({n}) 超过允许的最大数值{m}!",
                uploadExtraData:function (previewId, index) { //传参
                    var data = {

                    };
                    return data;
                }
            });
            //导入文件上传完成之后的事件
            control.on("fileuploaded", function (event, data, previewId, index) {
                let plugin = $('#picture').data('fileinput');

            });
        }
        return oFile;
    };
    //初始化fileinput
    var oFileInput = new FileInput();
    //参数1:控件id、参数2:上传地址
    oFileInput.Init("picture", ctx + 'file/picture/uploadReport');

    var prefix = ctx + "file/picture"
    $("#form-picture-add").validate({
        focusCleanup: true
    });
    // function submitHandler() {
    //     if ($.validate.form()) {
    //         $.operate.save(prefix + "/add", $('#form-picture-add').serialize());
    //     }
    // }

    // $("input[name='created']").datetimepicker({
    //     format: "yyyy-mm-dd",
    //     minView: "month",
    //     autoclose: true
    // });
    //
    $('#blobSubmit').on('click', function(){
        var formdata = new FormData();
        formdata.append("picture", $('#picture')[0].files[0]);
        formdata.append("referCode", $("#referCode").val());
        formdata.append("referType", $("#referType").val());
        formdata.append("url", $("#url").val());
        $.ajax({
            url: ctx + "file/picture/add",
            data: formdata,
            type: "post",
            processData: false,
            contentType: false,
            success: function(result) {
                $.operate.saveSuccess(result);
            }
        })
    })
</script>
</body>
</html>