添加图片预览imageView方法

This commit is contained in:
RuoYi
2019-05-05 16:41:43 +08:00
parent 342eda526d
commit 27c0a440d7
4 changed files with 51 additions and 2 deletions

View File

@ -139,6 +139,12 @@ $(function() {
}
expandFlag = expandFlag ? false: true;
})
// 按下ESC按钮关闭弹层
$('body', document).on('keyup', function(e) {
if (e.which === 27) {
$.modal.closeAll();
}
});
});
/** 刷新选项卡 */

View File

@ -131,6 +131,23 @@
selectionIds = _[func](selectionIds, rowIds);
}
});
// 图片预览事件
$("#" + $.table._option.id).on('click', '.img-circle', function() {
var src = $(this).attr('src');
var target = $(this).data('target');
if($.common.equals("self", target)) {
layer.open({
title: false,
type: 1,
closeBtn: false,
shadeClose: true,
area: ['auto', 'auto'],
content: "<img src='" + src + "' />"
});
} else if ($.common.equals("blank", target)) {
window.open(src);
}
});
},
// 当所有数据被加载时触发
onLoadSuccess: function(data) {
@ -174,6 +191,17 @@
actions.push('</div>');
return actions.join('');
},
// 图片预览
imageView: function (value, path, target) {
var _path = $.common.isEmpty(path) ? '/profile/upload' : path;
// blank or self
var _target = $.common.isEmpty(target) ? 'self' : target;
if ($.common.isNotEmpty(value)) {
return $.common.sprintf("<img class='img-circle img-xs' data-target='%s' src='%s/%s'/>", _target, _path, value);
} else {
return $.common.nullToStr(value);
}
},
// 搜索-默认第一个form
search: function(formId) {
var currentId = $.common.isEmpty(formId) ? $('form').attr('id') : formId;