cyx-ament-pc/cyx-admin/src/main/resources/templates/base/affairs/upload.html

81 lines
2.7 KiB
HTML

<!DOCTYPE html>
<html lang="zh">
<head>
<th:block th:include="include :: header('文件上传')"/>
<th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-content">
<div class="form-group">
<label class="font-noraml">多文件上传</label>
<div class="file-loading">
<input id="multipleFile" multiple name="files" type="file">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: bootstrap-fileinput-js"/>
<script th:inline="javascript">
$(document).ready(function () {
// 多图上传
$("#multipleFile").fileinput({
uploadUrl: ctx + 'common/uploads',
uploadAsync: false,
layoutTemplates: {
actionUpload:''
}
}).on('filebatchuploadsuccess', function (event, data, previewId, index) {
let _type = parent.parent.a_upload_type;
let _url = _type === '1'?'/base/affairs/commit':'/base/advancedparty/edit';
let _id = parent.parent.a_upload_id;
let header = parent.parent.a_header;
let deptName = parent.parent.a_deptName;
let shotName = parent.parent.a_shotName;
let _index = parent.parent.a_upload_index;
let _data = null;
let _fileNames = data.response.fileNames;
if(_type === '1'){
_data = {
id:_id,
header:header,
deptName:deptName,
shotName:shotName,
files:_fileNames
}
}else{
_data = {
id:_id,
events:_fileNames
}
}
console.log(_data)
$.ajax({
url:_url,
type:'post',
dataType:'json',
data:_data,
success(res){
if(res.code === 0){
layer.msg('上传成功', {icon: 1});
setTimeout(function () {
parent.layer.close(_index);
},1000)
}
}
})
}).on('fileremoved', function (event, id, index) {
$("input[name='" + event.currentTarget.id + "']").val('')
});
});
</script>
</body>
</html>