add.html
8.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<!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>