function upload(tab,tablist,fileNumLimit=5,data,data1,datakeyname,name,url) {
var uploaderImgLogo = WebUploader.create({
// 选完文件后,是否自动上传。
auto: true,
// swf文件路径
swf: '__STATIC__/webuploader/Uploader.swf',
server: url,
// 选择文件的按钮。可选。
// 内部根据当前运行是创建,可能是input元素,也可能是flash.
pick: {
id:'#'+tab,
multiple:true
},
// dnd: false,
paste: document.body,
accept: {
title: '图片',
extensions: 'png,gif,jpg,jpeg,bmp',
mimeTypes: '.png,.gif,.jpg,.jpeg,.bmp',
},
// 不压缩image, 默认如果是jpeg,文件上传前会压缩一把再上传!
resize: false,
disableGlobalDnd: true,
fileNumLimit:1,
threads:5,
thumb:true,
compress:false,
prepareNextFile: true,
formData: function(){return $.extend(true, {}, userInfo);},
chunked:false,
duplicate: true
});
var imgLogoListData = [];
newdata = data.split(',')
newdata1 = data1.split(',')
console.log(newdata)
console.log(newdata1)
if(newdata.length > 0 && newdata[0] !=="") {
var html = '';
$('#'+tablist).css('margin-top','10px');
/*newdata.forEach(v=>{
console.log(v)
imgLogoListData.push(v);
html += '
';
var imgurl =
html += '
';
html += '
';
html += '删除';
html += '
';
html += '
';
html += '
100%
';
html += '
';
html += '
';
})*/
for(var i=0;i';
html += '';
html += '';
html += '删除';
html += '
';
html += '';
html += '
100%
';
html += '
';
html += '';
}
$('#'+tablist).html(html);
$('#'+tablist).children().children('h4').children('.jsdelzip').on('click', function() {
var thisId = $(this).attr('img-id');
$(this).parent().parent().remove();
$.each(imgLogoListData,function(index, item) {
if (thisId == item) {
imgLogoListData.splice(index,1);
return false;
}
});
setLogoVal(name);
});
}
/*
var html = '';
$('#logoList').css('margin-top','10px');
imgLogoListData.push(=$value1?>);
html += '';
html += '
" style="width: 100px;height: 100px;cursor: move;">';
html += '
';
html += '删除';
html += '
';
html += '
';
html += '
100%
';
html += '
';
html += '
';
$('#logoList').html(html);
$('#logoList').children().children('h4').children('.jsdelzip').on('click', function() {
var thisId = $(this).attr('img-id');
$(this).parent().parent().remove();
$.each(imgLogoListData,function(index, item) {
if (thisId == item) {
imgLogoListData.splice(index,1);
return false;
}
});
setLogoVal();
});
*/
var thisIndex1 = 0;
var imgLogoList = $("#"+tablist);
uploaderImgLogo.on( 'fileQueued', function( file ) {
var html = '';
html += '';
html += '
';
html += '
' + file.name + '
';
html += '
等待上传...
';
html += '
';
imgLogoList.append(html);
imgLogoList.css('margin-top','10px');
var img = imgLogoList.children('#'+file.id).find('img');
uploaderImgLogo.makeThumb(file, function (error, src) {
if (error) {
return;
}
img.attr('src', src);
}, 300, 300);
});
// 文件上传过程中创建进度条实时显示。
uploaderImgLogo.on( 'uploadProgress', function( file, percentage ) {
var $li = $( '#'+file.id ),
$percent = $li.find('.progress .progress-bar');
// 避免重复创建
if ( !$percent.length ) {
$percent = $('').appendTo( $li ).find('.progress-bar');
}
$li.find('p.state').text('上传中');
$percent.css( 'width', percentage * 100 + '%' );
$percent.text( (percentage * 100).toFixed(0) + '%' );
});
uploaderImgLogo.on( 'uploadSuccess', function( file , response) {
imgLogoListData.push(Number(response.id));
console.log(imgLogoListData)
setLogoVal(name);
$( '#'+file.id ).find('p.state').text('已上传').fadeOut(800);
//alert(JSON.stringify(response));
$('#'+file.id).find('h4.info').append('删除');
$('#'+file.id).find('.jsdelzip').on('click',function() {
uploaderImgLogo.removeFile( file.id );
$('#'+file.id).remove();
$.each(imgLogoListData,function(index, item) {
if (response.id == item) {
imgLogoListData.splice(index,1);
return false;
}
});
setLogoVal(name);
console.log(imgIconListData);
return false;
});
});
uploaderImgLogo.on('uploadError', function(file) {
$( '#'+file.id ).find('p.state').text('上传出错');
});
uploaderImgLogo.on( 'uploadComplete', function(file) {
$( '#'+file.id ).find('.progress').fadeOut();
});
function setLogoVal(keyName)
{
var logo = '';
$.each(imgLogoListData,function(index, item) {
logo += item + ',';
});
logo = logo.substring(0, logo.length - 1);
console.log(logo)
$("input[name='config["+keyName+"]']").val(logo);
}
}
function documentUpload(tab,tablist,fileNumLimit=5,data,data1,datakeyname,name,url) {
console.log(data)
console.log(data1)
var uploaderImgLogo = WebUploader.create({
// 选完文件后,是否自动上传。
auto: true,
// swf文件路径
swf: '__STATIC__/webuploader/Uploader.swf',
server: url,
// 选择文件的按钮。可选。
// 内部根据当前运行是创建,可能是input元素,也可能是flash.
pick: {
id:'#'+tab,
multiple:true
},
// dnd: false,
paste: document.body,
accept: {
title: '图片',
extensions: 'png,gif,jpg,jpeg,bmp',
mimeTypes: '.png,.gif,.jpg,.jpeg,.bmp',
},
// 不压缩image, 默认如果是jpeg,文件上传前会压缩一把再上传!
resize: false,
disableGlobalDnd: true,
fileNumLimit:1,
threads:5,
thumb:true,
compress:false,
prepareNextFile: true,
formData: function(){return $.extend(true, {}, userInfo);},
chunked:false,
duplicate: true
});
var imgLogoListData = [];
newdata = data.split(',')
newdata1 = data1.split(',')
console.log(newdata)
console.log(newdata1)
if(newdata.length > 0 && newdata[0] !=="" ) {
var html = '';
$('#'+tablist).css('margin-top','10px');
/*newdata.forEach(v=>{
console.log(v)
imgLogoListData.push(v);
html += '';
var imgurl =
html += '
';
html += '
';
html += '删除';
html += '
';
html += '
';
html += '
100%
';
html += '
';
html += '
';
})*/
for(var i=0;i';
html += '';
html += '';
html += '删除';
html += '
';
html += '';
html += '
100%
';
html += '
';
html += '';
}
$('#'+tablist).html(html);
$('#'+tablist).children().children('h4').children('.jsdelzip').on('click', function() {
var thisId = $(this).attr('img-id');
$(this).parent().parent().remove();
$.each(imgLogoListData,function(index, item) {
if (thisId == item) {
imgLogoListData.splice(index,1);
return false;
}
});
setLogoVal(name);
});
}
var thisIndex1 = 0;
var imgLogoList = $("#"+tablist);
uploaderImgLogo.on( 'fileQueued', function( file ) {
var html = '';
html += '';
html += '
';
html += '
' + file.name + '
';
html += '
等待上传...
';
html += '
';
imgLogoList.append(html);
imgLogoList.css('margin-top','10px');
var img = imgLogoList.children('#'+file.id).find('img');
uploaderImgLogo.makeThumb(file, function (error, src) {
if (error) {
return;
}
img.attr('src', src);
}, 300, 300);
});
// 文件上传过程中创建进度条实时显示。
uploaderImgLogo.on( 'uploadProgress', function( file, percentage ) {
var $li = $( '#'+file.id ),
$percent = $li.find('.progress .progress-bar');
// 避免重复创建
if ( !$percent.length ) {
$percent = $('').appendTo( $li ).find('.progress-bar');
}
$li.find('p.state').text('上传中');
$percent.css( 'width', percentage * 100 + '%' );
$percent.text( (percentage * 100).toFixed(0) + '%' );
});
uploaderImgLogo.on( 'uploadSuccess', function( file , response) {
imgLogoListData.push(Number(response.id));
console.log(imgLogoListData)
setLogoVal(name);
$( '#'+file.id ).find('p.state').text('已上传').fadeOut(800);
//alert(JSON.stringify(response));
$('#'+file.id).find('h4.info').append('删除');
$('#'+file.id).find('.jsdelzip').on('click',function() {
uploaderImgLogo.removeFile( file.id );
$('#'+file.id).remove();
$.each(imgLogoListData,function(index, item) {
if (response.id == item) {
imgLogoListData.splice(index,1);
return false;
}
});
setLogoVal(name);
console.log(imgIconListData);
return false;
});
});
uploaderImgLogo.on('uploadError', function(file) {
$( '#'+file.id ).find('p.state').text('上传出错');
});
uploaderImgLogo.on( 'uploadComplete', function(file) {
$( '#'+file.id ).find('.progress').fadeOut();
});
function setLogoVal(keyName)
{
var logo = '';
$.each(imgLogoListData,function(index, item) {
logo += item + ',';
});
logo = logo.substring(0, logo.length - 1);
console.log(keyName)
console.log(logo)
$("input[name='"+keyName+"']").val(logo);
}
}