From 8dfa1834e30bf11f8d7b4f4bf052a4dc2aa3fe55 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Thu, 11 Jul 2019 10:01:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E5=9B=BE=E7=89=87=E9=A2=84?= =?UTF-8?q?=E8=A7=88=E6=94=AF=E6=8C=81=E8=AE=BE=E7=BD=AE=E5=AE=BD=E9=AB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/static/ruoyi/js/ry-ui.js | 31 ++++++++++++------- .../resources/templates/demo/table/image.html | 9 +++--- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js b/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js index 6dfcb105a..ecefd2a71 100644 --- a/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js +++ b/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js @@ -154,6 +154,8 @@ $.btTable.on('click', '.img-circle', function() { var src = $(this).attr('src'); var target = $(this).data('target'); + var height = $(this).data('height'); + var width = $(this).data('width'); if($.common.equals("self", target)) { layer.open({ title: false, @@ -161,7 +163,7 @@ closeBtn: true, shadeClose: true, area: ['auto', 'auto'], - content: "" + content: "" }); } else if ($.common.equals("blank", target)) { window.open(src); @@ -214,12 +216,17 @@ return actions.join(''); }, // 图片预览 - imageView: function (value, path, target) { - var _path = $.common.isEmpty(path) ? '/profile/upload' : path; + imageView: function (value, height, width, target) { + if ($.common.isEmpty(width)) { + width = 'auto'; + } + if ($.common.isEmpty(height)) { + height = 'auto'; + } // blank or self var _target = $.common.isEmpty(target) ? 'self' : target; if ($.common.isNotEmpty(value)) { - return $.common.sprintf("", _target, _path, value); + return $.common.sprintf("", width, height, _target, value); } else { return $.common.nullToStr(value); } @@ -574,16 +581,16 @@ } if ($.common.isEmpty(title)) { title = false; - }; + } if ($.common.isEmpty(url)) { url = "/404.html"; - }; + } if ($.common.isEmpty(width)) { width = 800; - }; + } if ($.common.isEmpty(height)) { height = ($(window).height() - 50); - }; + } if ($.common.isEmpty(callback)) { callback = function(index, layero) { var iframeWin = layero.find('iframe')[0]; @@ -646,16 +653,16 @@ } if ($.common.isEmpty(title)) { title = false; - }; + } if ($.common.isEmpty(url)) { url = "/404.html"; - }; + } if ($.common.isEmpty(width)) { width = 800; - }; + } if ($.common.isEmpty(height)) { height = ($(window).height() - 50); - }; + } var index = layer.open({ type: 2, area: [width + 'px', height + 'px'], diff --git a/ruoyi-admin/src/main/resources/templates/demo/table/image.html b/ruoyi-admin/src/main/resources/templates/demo/table/image.html index 51af7e2a0..814cb67db 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/table/image.html +++ b/ruoyi-admin/src/main/resources/templates/demo/table/image.html @@ -40,13 +40,12 @@ { title: '图片', formatter: function(value, row, index) { - // 图片自由组合 - // 'img/profile.jpg' - 'http://ruoyi.vip/' 变成 http://ruoyi.vip/img/profile.jpg - // 'ruoyi.png' - 'http://ruoyi.vip/' 变成 http://ruoyi.vip/ruoyi.jpg + // 图片自由组合(注意:如存储在本地需要带上 '/profile/upload' + 数据库路径) + // 如:/profile/upload/2019/08/08/3b7a839aced67397bac694d77611ce72.png if(index % 2 == 0){ - return $.table.imageView('img/profile.jpg', 'http://demo.ruoyi.vip/'); + return $.table.imageView('http://demo.ruoyi.vip/img/profile.jpg'); }else { - return $.table.imageView('ruoyi.png', 'http://demo.ruoyi.vip/'); + return $.table.imageView('http://demo.ruoyi.vip/ruoyi.png'); } } },