增加上传功能

This commit is contained in:
duxp 2023-08-25 16:18:59 +08:00
parent fd6b46c365
commit f26e4602ed
7 changed files with 146 additions and 9 deletions

View File

@ -177,7 +177,7 @@
align: 'center',
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.upload(\'' + row.id + '\')"><i class="fa fa-edit"></i>上传附件</a> ');
actions.push('<a data-id="'+row.id+'" class="openUpload btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)"><i class="fa fa-edit"></i>上传附件</a> ');
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>查看详情</a> ');
// actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
@ -187,7 +187,25 @@
}]
};
$.table.init(options);
$("#bootstrap-table").on('click','.openUpload',function () {
let _id = $(this)[0].dataset.id;
layer.open({
title:'上传附件',
area:['80%','80%'],
type:2,
content:'/base/affairs/upload',
success(res,index){
//传值
parent.closeIndex = index;
parent.a_upload_id = _id;
},
end(){
$.table.search()
}
})
})
});
</script>
</body>
</html>

View File

@ -185,7 +185,7 @@
align: 'center',
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.upload(\'' + row.id + '\')"><i class="fa fa-edit"></i>上传附件</a> ');
actions.push('<a data-id="'+row.id+'" class="openUpload btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)"><i class="fa fa-edit"></i>上传附件</a> ');
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>查看详情</a> ');
// actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
@ -195,6 +195,23 @@
}]
};
$.table.init(options);
$("#bootstrap-table").on('click','.openUpload',function () {
let _id = $(this)[0].dataset.id;
layer.open({
title:'上传附件',
area:['80%','80%'],
type:2,
content:'/base/affairs/upload',
success(res,index){
//传值
parent.closeIndex = index;
parent.a_upload_id = _id;
},
end(){
$.table.search()
}
})
})
});
</script>
</body>

View File

@ -177,7 +177,7 @@
align: 'center',
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.upload(\'' + row.id + '\')"><i class="fa fa-edit"></i>上传附件</a> ');
actions.push('<a data-id="'+row.id+'" class="openUpload btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)"><i class="fa fa-edit"></i>上传附件</a> ');
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>查看详情</a> ');
// actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
@ -187,6 +187,23 @@
}]
};
$.table.init(options);
$("#bootstrap-table").on('click','.openUpload',function () {
let _id = $(this)[0].dataset.id;
layer.open({
title:'上传附件',
area:['80%','80%'],
type:2,
content:'/base/affairs/upload',
success(res,index){
//传值
parent.closeIndex = index;
parent.a_upload_id = _id;
},
end(){
$.table.search()
}
})
})
});
</script>
</body>

View File

@ -0,0 +1,67 @@
<!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">
let _fileArr = [];
$(document).ready(function () {
// 多图上传
$("#multipleFile").fileinput({
uploadUrl: ctx + 'common/uploads',
uploadAsync: false,
layoutTemplates: {
actionUpload:''
}
}).on('filebatchuploadsuccess', function (event, data, previewId, index) {
let _fileNames = data.response.fileNames;
$.ajax({
url:'/base/affairs/edit',
type:'post',
dataType:'json',
data:{
id:parent.parent.a_upload_id,
files:_fileNames
},
success(res){
if(res.code === 0){
layer.msg('上传成功', {icon: 1});
setTimeout(function () {
parent.layer.close(parent.parent.closeIndex);
},1000)
}
}
})
}).on('fileremoved', function (event, id, index) {
$("input[name='" + event.currentTarget.id + "']").val('')
});
//保存数据
$("#submitUploadData0825").click(function () {
console.log(parent.parent.a_upload_id,'ddd');
})
});
</script>
</body>
</html>

View File

@ -161,7 +161,7 @@
align: 'center',
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.upload(\'' + row.id + '\')"><i class="fa fa-edit"></i>上传附件</a> ');
actions.push('<a data-id="'+row.id+'" class="openUpload btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)"><i class="fa fa-edit"></i>上传附件</a> ');
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>查看详情</a> ');
// actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
@ -171,6 +171,23 @@
}]
};
$.table.init(options);
$("#bootstrap-table").on('click','.openUpload',function () {
let _id = $(this)[0].dataset.id;
layer.open({
title:'上传附件',
area:['80%','80%'],
type:2,
content:'/base/affairs/upload',
success(res,index){
//传值
parent.closeIndex = index;
parent.a_upload_id = _id;
},
end(){
$.table.search()
}
})
})
});
</script>
</body>

View File

@ -19,7 +19,7 @@
<input id="singleFile" name="file" type="file">
</div>
</div>
<div class="form-group">
<label class="font-noraml">多文件上传</label>
<div class="file-loading">
@ -39,7 +39,7 @@
<th:block th:include="include :: footer" />
<th:block th:include="include :: bootstrap-fileinput-js" />
<script th:inline="javascript">
$(document).ready(function () {
// 单图上传
$("#singleFile").fileinput({
@ -55,7 +55,7 @@
}).on('fileremoved', function (event, id, index) {
$("input[name='" + event.currentTarget.id + "']").val('')
})
// 多图上传
$("#multipleFile").fileinput({
uploadUrl: ctx + 'common/uploads',

View File

@ -679,11 +679,12 @@
let _strHtml = "";
_deptData = res.data;
_data.forEach(item => {
let _json = JSON.parse(item.json);
_strHtml += '<div class="item_inline" style="align-items: flex-start">' +
'<div style="font-size: 14px;color: #ffffff;width: 120px;">'+item.dept+'</div>' +
'<div class="inline_content" style="margin-left: 10px">' +
'<p>日常考核分:100</p>' +
'<p>年度考核分:95</p>' +
'<p>日常考核分:'+_json['日常考核指标']+'</p>' +
'<p>年度考核分:'+_json['年度考核指标']+'</p>' +
'</div>' +
'</div>';
});