完成上传组件的开发
This commit is contained in:
@@ -2,4 +2,6 @@
|
||||
.img-list .item{width: 20%;}
|
||||
.img-list .item .thumb{margin: 10px 10px 0 0 ; border: 1px solid #efefef; height: 120px; border-radius: 4px; position: relative; overflow: hidden;}
|
||||
.img-list .item .thumb img{width: 100%;}
|
||||
.img-list .item .close{position: absolute; right: 5px; top: 5px; opacity: 1; width: 20px; height: 20px; font-size: 10px; text-align: center; line-height: 20px; color: #ffffff; border-radius: 50%; background: #333333;}
|
||||
.img-list .item .thumb .close{position: absolute; right: 5px; top: 5px; opacity: 1; width: 20px; height: 20px; font-size: 10px; text-align: center; line-height: 20px; color: #ffffff; border-radius: 50%; background: #333333;}
|
||||
.file-list{padding: 10px 0; display: flex; flex-direction: column;}
|
||||
.file-list .attach{line-height: 35px; border-bottom: 1px dotted #333333; cursor: pointer;}
|
||||
@@ -3,14 +3,16 @@ define(['jquery', 'bootstrap', 'validator'], function ($, undefined, Validator)
|
||||
config: {
|
||||
editor: {
|
||||
"full":['source', 'undo', 'redo', 'code', 'quote', 'cut',
|
||||
'plainpaste', 'wordpaste', 'justifyleft', 'justifycenter', 'justifyright',
|
||||
'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
|
||||
'superscript', 'clearhtml', 'quickformat', 'selectall', '/',
|
||||
'formatblock', 'fontname', 'fontsize', 'forecolor', 'hilitecolor', 'bold',
|
||||
'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', 'image', 'multiimage', 'media', 'insertfile', 'table', 'hr', 'baidumap',
|
||||
'anchor', 'link', 'unlink','fullscreen'],
|
||||
'plainpaste', 'wordpaste', 'justifyleft', 'justifycenter', 'justifyright',
|
||||
'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
|
||||
'superscript', 'clearhtml', 'quickformat', 'selectall', '/',
|
||||
'formatblock', 'fontname', 'fontsize', 'forecolor', 'hilitecolor', 'bold',
|
||||
'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', 'image', 'multiimage', 'media', 'insertfile', 'table', 'hr', 'baidumap',
|
||||
'anchor', 'link', 'unlink','fullscreen'
|
||||
],
|
||||
"base":['undo', 'redo', 'quote', 'formatblock', 'fontname', 'fontsize', 'forecolor', 'hilitecolor', 'bold',
|
||||
'italic', 'underline', 'strikethrough', 'lineheight', 'image', 'media', 'table'],
|
||||
'italic', 'underline', 'strikethrough', 'lineheight', 'image', 'media', 'table'
|
||||
],
|
||||
},
|
||||
fieldlisttpl: '<dd class="form-inline"><input type="text" name="<%=name%>[<%=index%>][key]" class="form-control" value="<%=row.key%>" size="10" /> <input type="text" name="<%=name%>[<%=index%>][value]" class="form-control" value="<%=row.value%>" /> <span class="btn btn-sm btn-danger btn-remove"><i class="fa fa-times"></i></span> <span class="btn btn-sm btn-primary btn-dragsort"><i class="fa fa-arrows"></i></span></dd>'
|
||||
},
|
||||
@@ -96,7 +98,7 @@ define(['jquery', 'bootstrap', 'validator'], function ($, undefined, Validator)
|
||||
}, form.data("validator-options") || {}));
|
||||
|
||||
//移除提交按钮的disabled类
|
||||
$(".layer-footer [type=submit],.fixed-footer [type=submit],.normal-footer [type=submit]", form).removeClass("disabled");
|
||||
$("button.btn[type=submit]", form).removeClass("disabled");
|
||||
},
|
||||
editor: function (form) {
|
||||
//绑定编辑器元素事件
|
||||
@@ -307,6 +309,7 @@ define(['jquery', 'bootstrap', 'validator'], function ($, undefined, Validator)
|
||||
var value = $('.picker-box input[type=hidden]').val().split(",");
|
||||
value = value.filter(val => val != $(this).parents('.item').data('id'))
|
||||
$(this).parents('.item').remove();
|
||||
console.log(value)
|
||||
if(value.length > 0){
|
||||
$('.picker-box input[type=hidden]').val(value.join(','));
|
||||
}else{
|
||||
@@ -589,13 +592,22 @@ define(['jquery', 'bootstrap', 'validator'], function ($, undefined, Validator)
|
||||
var value = field.val() ? field.val().split(",") : [];
|
||||
|
||||
if(param.limit == 1){
|
||||
var html = '<div class="item"><div class="thumb" data-id="'+fileList[0].id+'"><div class="close"><i class="fa fa-close"></i></div><img src="'+fileList[0].url+'" /></div></div>';
|
||||
if(param.type == 'image'){
|
||||
var html = '<div class="item"><div class="thumb" data-id="'+fileList[0].id+'"><div class="close"><i class="fa fa-close"></i></div><img src="'+fileList[0].url+'" /></div></div>';
|
||||
}else{
|
||||
var html = '<div class="item"><div class="attach" data-id="'+fileList[0].id+'"><div class="close"><i class="fa fa-close"></i></div><span>'+fileList[0].savename+'</span></div></div>';
|
||||
}
|
||||
|
||||
file.html(html);
|
||||
field.val(fileList[0].id);
|
||||
}else{
|
||||
for(var i = 0; i < fileList.length; i++){
|
||||
if(!value.includes((fileList[i].id).toString())){
|
||||
var html = '<div class="item"><div class="thumb" data-id="'+fileList[i].id+'"><div class="close"><i class="fa fa-close"></i></div><img src="'+fileList[i].url+'" /></div></div>';
|
||||
if(param.type == 'image'){
|
||||
var html = '<div class="item"><div class="thumb" data-id="'+fileList[i].id+'"><div class="close"><i class="fa fa-close"></i></div><img src="'+fileList[i].url+'" /></div></div>';
|
||||
}else{
|
||||
var html = '<div class="item"><div class="attach" data-id="'+fileList[i].id+'"><div class="close"><i class="fa fa-close"></i></div><span>'+fileList[i].savename+'</span></div></div>';
|
||||
}
|
||||
value.push(fileList[i].id);
|
||||
file.append(html);
|
||||
}
|
||||
|
||||
@@ -424,8 +424,8 @@ define(['jquery', 'bootstrap', 'webupload'], function ($, undefined, WebUploader
|
||||
},
|
||||
server: function(){
|
||||
var query = sent.parseUrl(window.location.href);
|
||||
if($('.img-list .item .thumb').length > 0){
|
||||
$('.img-list .item .thumb').on('click', function(){
|
||||
if($('.img-list .item .thumb, .file-list .item .attach').length > 0){
|
||||
$('.img-list .item .thumb, .file-list .item .attach').on('click', function(){
|
||||
if($(this).hasClass('selected')){
|
||||
Upload.config.upList = Upload.config.upList.filter(item => !sent.utils.isObjEqual(item, $(this).data()));
|
||||
$(this).removeClass('selected');
|
||||
|
||||
Reference in New Issue
Block a user