新增
$("#attachmentsFile").fileinput({
theme: "fa",
showPreview: true, //是否显示预览
hideThumbnailContent: true,//是否在缩略图中隐藏预览内容(图像,pdf内容,文本内容等)。
showUpload: false, //隐藏上传按钮
showRemove: false, //隐藏清除按钮
overwriteInitial: false,
language: 'zh',
browseClass: "btn btn-hinfo",
browseLabel: "附件",
layoutTemplates: {
//actionDelete: '',//去除上传预览的缩列图中的删除图标
actionUpload: '',//去除上传预览的缩列图中的上传图标
actionZoom: '',//去除上传预览的缩列图中的预览图标
},
}).on('change', function (event) {
}).on('filepredelete', function (event, key, jqXHR, data) {
return !confirm('确定删除原文件?删除后不可恢复!');
});
修改
function initFileInput(id) {
var initialPreviews = [], initialPreviewConfigs = [];
$.ajax({
url: '/attachment/fileinfos',
type: "GET",
async: false,
data: {id: id},
success: function (res) {
if (res.success == true) {
if(res.data.length>0){
res.data.forEach(function (element, index) {
initialPreviews.push(element.path);
initialPreviewConfigs.push({
previewAsData: false,
downloadUrl: element.path,
caption: defaultValue(element.fileName,"附件"+index),
width: '120px',
url: '/attachment/delete',
key: element.id,
extra: function() {
return {id: element.id};
}
});
});
}
} else {
toastr.error(res.message);
}
},
error: function (res) {
toastr.error("请求失败");
},
complete: function () {
closeModalWithJs(pageData.updateModal);
}
});
$("#attachmentsFileU").fileinput('destroy');
$("#attachmentsFileU").fileinput({
theme: "fa",
uploadUrl: "不然没有新文件删除按钮",
showPreview: true, //是否显示预览
hideThumbnailContent: true,//是否在缩略图中隐藏预览内容(图像,pdf内容,文本内容等)。
showUpload: false, //隐藏上传按钮
showRemove: false, //隐藏清除按钮
showClose: false, //隐藏右上角叉
overwriteInitial: false,
language: 'zh',
browseClass: "btn btn-hinfo",
browseLabel: "附件",
msgDuplicateFile: '"{name}"文件已经存在',
initialPreviewAsData: true, // 确定你是否仅发送预览数据,而不是原始标记
initialPreview: initialPreviews,
initialPreviewConfig: initialPreviewConfigs,
layoutTemplates: {
//actionDelete: '',//去除上传预览的缩列图中的删除图标
actionUpload: '',//去除上传预览的缩列图中的上传图标
actionZoom: '',//去除上传预览的缩列图中的预览图标
},
}).on('change', function (event) {
}).on('filepredelete', function (event, key, jqXHR, data) {
return !confirm('确定删除原文件?删除后不可恢复!');
});
}