增加上传功能

This commit is contained in:
duxp 2023-08-25 16:40:57 +08:00
parent f26e4602ed
commit d42b51d172
7 changed files with 65 additions and 19 deletions

View File

@ -121,7 +121,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-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
return actions.join('');
@ -129,6 +129,24 @@
}]
};
$.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.a_upload_id = _id;
parent.a_upload_index = index;
parent.a_upload_type = "2";
},
end(){
$.table.search()
}
})
})
});
</script>
</body>

View File

@ -105,7 +105,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> ');
@ -115,6 +115,24 @@
}]
};
$.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.a_upload_id = _id;
parent.a_upload_index = index;
parent.a_upload_type = "2";
},
end(){
$.table.search()
}
})
})
});
</script>
</body>

View File

@ -196,8 +196,9 @@
content:'/base/affairs/upload',
success(res,index){
//传值
parent.closeIndex = index;
parent.a_upload_id = _id;
parent.a_upload_index = index;
parent.a_upload_type = "1";
},
end(){
$.table.search()

View File

@ -204,8 +204,9 @@
content:'/base/affairs/upload',
success(res,index){
//传值
parent.closeIndex = index;
parent.a_upload_id = _id;
parent.a_upload_index = index;
parent.a_upload_type = "1";
},
end(){
$.table.search()

View File

@ -196,8 +196,9 @@
content:'/base/affairs/upload',
success(res,index){
//传值
parent.closeIndex = index;
parent.a_upload_id = _id;
parent.a_upload_index = index;
parent.a_upload_type = "1";
},
end(){
$.table.search()

View File

@ -24,8 +24,6 @@
<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({
@ -35,20 +33,33 @@
actionUpload:''
}
}).on('filebatchuploadsuccess', function (event, data, previewId, index) {
let _type = parent.parent.a_upload_type;
let _url = _type === '1'?'/base/affairs/edit':'/base/advancedparty/edit';
let _id = parent.parent.a_upload_id;
let _index = parent.parent.a_upload_index;
let _data = null;
let _fileNames = data.response.fileNames;
if(_type === '1'){
_data = {
id:_id,
files:_fileNames
}
}else{
_data = {
id:_id,
events:_fileNames
}
}
$.ajax({
url:'/base/affairs/edit',
url:_url,
type:'post',
dataType:'json',
data:{
id:parent.parent.a_upload_id,
files:_fileNames
},
data:_data,
success(res){
if(res.code === 0){
layer.msg('上传成功', {icon: 1});
setTimeout(function () {
parent.layer.close(parent.parent.closeIndex);
parent.layer.close(_index);
},1000)
}
}
@ -56,11 +67,6 @@
}).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>

View File

@ -180,8 +180,9 @@
content:'/base/affairs/upload',
success(res,index){
//传值
parent.closeIndex = index;
parent.a_upload_id = _id;
parent.a_upload_index = index;
parent.a_upload_type = "1";
},
end(){
$.table.search()