引入css和js:

<link href="${pageContext.request.contextPath}/plugin/dialog/dialog.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="${pageContext.request.contextPath}/plugin/dialog/dialog.js"></script>

代码:

  <!--------------- 多图片+上下切换预览功能开始 -----Autohr:li_hao------------------>
<div class="fitem item2" style="height:auto">
<label style="vertical-align:top">应用截图 </label>
<span>
<jsp:include page="/plugin/dialog/uploadManyImgs.jsp">
<jsp:param value="126" name="width"/>
<jsp:param value="26" name="height"/>
<jsp:param value="" name="assetId"/>
<jsp:param value="setfileid" name="hiddenId"/>
</jsp:include>
</span>
</div>
<div style="display: block;width: 100%;">
<table id="assetTable">
<thead>
<tr>
<th data-options="field:'id',width:80,align:'center',sortable:true,formatter:imgformater">应用截图</th>
<th data-options="field:'name',width:80,align:'center'">名称</th>
<th data-options="field:'fileSize',width:80,align:'center'">文件大小(MB)</th>
<!-- <th data-options="field:'createTimeString',width:180,align:'center'">上传日期</th> -->
<!-- <th data-options="field:'createUserName',width:80,align:'center'">上传人</th> -->
<th data-options="field:'createTimeString',width:80,align:'center',formatter:operformatter">删除</th>
</tr>
</thead>
</table>
<input type="hidden" id="appimgs" name="microAppEntity.appimgs" value="${microAppEntity.appimgs }">
</div>
<div class="mask"></div>
<div class="dialog">
<div>
<div style="width:130px;height:25px;margin:0 auto; ">
<img style='width:30px;height:30px;cursor:pointer;' onclick='toLeft()' src='${pageContext.request.contextPath}/plugin/dialog/images/left.png'>
<img style='width:30px;height:30px;margin-left:60px;cursor:pointer;' onclick='toRight()' src='${pageContext.request.contextPath}/plugin/dialog/images/right.png'>
</div>
</div>
<a href="javascript:void(0)" class="close" title="关闭" style="color:black;margin-bottom:20px;">关闭</a>
<div class="dialog-content">
</div>
</div>
<input type="hidden" id="imgid_before" name="imgid_before">
<input type="hidden" id="imgid_after" name="imgid_after">
<input type="hidden" id="imgindex" name="imgindex">
<!--------------- 多图片+上下切换预览功能结束 -----Autohr:li_hao------------------>

js代码:

$(document).ready(function() {

    //-------------------------- 多图片+预览功能(table数据加载)开始 -----Autohr:li_hao-----------------------------
getDataPagination("assetTable","",null,false);
//修改页面加载图片列表
if($("#method").val() == 'modify'){
var array = $("#appimgs").val().split(",");
if(array!="" && array!=null){
for(var i=0;i<array.length;i++){
var number = 0;
$.post("${pageContext.request.contextPath }/assetmgr/asset_queryOne.do",{assetId:array[i]},
function(data,status){
var data = eval('(' + data + ')');
var obj = new Object();
obj.row = data;
var size = Number(data.fileSize)/1024/1024;
data.fileSize = size.toFixed(2);
$('#assetTable').datagrid('insertRow',{index: number, row:data});
number++;
});
}
}
}
//-------------------------- 多图片+预览功能(table数据加载)结束 -----Autohr:li_hao----------------------------- }); //---------- 多图片+预览功能开始(弹出层:plugin/dialog) -----Autohr:li_hao-----------------------------
function imgformater(value,row,index) {
return "<img width=35 height=35 style='margin-top:4px;cursor:pointer;' onclick='showMask("+row.id+","+index+")' src='${pageContext.request.contextPath}/upload/upload_send.do?id="+row.id+"'>";
}
//弹出层
function showMask(id,index){
imgidHandle(index);
Dialog.open(450,450,'${pageContext.request.contextPath}/upload/upload_send.do?id='+id);
}
//上一张、下一张
function toLeftOrRight(id,index){
imgidHandle(index);
$(".imgclass").attr('src','${pageContext.request.contextPath}/upload/upload_send.do?id='+id);
}
//上一张、下一张id处理逻辑
function imgidHandle(index){
var rows = $('#assetTable').datagrid('getData').rows;
var imgid_before;
var imgid_after
if(index==0){ //第一张图片
if(rows.length==1){ //只有一张图片
imgid_before="";
imgid_after="";
}else{
imgid_before="";
imgid_after=rows[index+1].id;
}
}else if(index==rows.length-1){ //最后一张图片
imgid_before=rows[index-1].id;
imgid_after="";
}else{ //中间
imgid_before=rows[index-1].id;
imgid_after=rows[index+1].id;
}
$("#imgid_before").val(imgid_before);
$("#imgid_after").val(imgid_after);
$("#imgindex").val(index);
} //上一张
function toLeft(){
var imgid_before = $("#imgid_before").val(); //上一张图片id
var index_before = Number($("#imgindex").val())-Number(1); //上一行index
if(imgid_before==""){
alert("已经是第一张图片了!")
}else{
toLeftOrRight(imgid_before,index_before);
}
}
//下一张
function toRight(){
var imgid_after = $("#imgid_after").val(); //下一张图片id
var index_after = Number($("#imgindex").val())+Number(1); //下一行index
if(imgid_after==""){
alert("已经最后一张图片了!")
}else{
toLeftOrRight(imgid_after,index_after);
}
} function operformatter(value,row,index) {
return "<a href=\"javascript:delAttach('"+ row.id +"')\">" + "删除" +"</a>";
}
function delAttach(id){
var rows = $('#assetTable').datagrid('getData').rows;
for ( var i = 0; i < rows.length; i++) {
if(id == rows[i].id){
$('#assetTable').datagrid('deleteRow',i);
}
}
}
//---------- 多图片+预览功能结束(弹出层:plugin/dialog) -----Autohr:li_hao-----------------------------

easyui多图片上传+预览切换+支持IE8的更多相关文章

  1. 兼容好的JS图片上传预览代码

    转 : http://www.codefans.net/articles/1395.shtml 兼容好的JS图片上传预览代码 (谷歌,IE11) <html xmlns="http:/ ...

  2. Jquery图片上传预览效果

    uploadPreview.js jQuery.fn.extend({ uploadPreview: function (opts) { var _self = this, _this = $(thi ...

  3. [前端 4] 使用Js实现图片上传预览

    导读:今天做图片上传预览,刚开始的做法是,先将图片上传到Nginx,然后重新加载页面才能看到这个图片.在这个过程中,用户一直都看不到自己上传的文件是什么样子.Ps:我发现我真的有强迫症了,都告诉我说不 ...

  4. Javascript之图片上传预览

    使用Javascript之图片上传预览,我们无需上传到服务器中,兼容所有浏览器. 关键方法是使用微软库filter:progid:DXImageTransform.Microsoft.AlphaIma ...

  5. HTML5 图片上传预览

    <!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="utf-8& ...

  6. ASP.NET工作笔记之一:图片上传预览及无刷新上传

    转自:http://www.cnblogs.com/sibiyellow/archive/2012/04/27/jqueryformjs.html 最近项目里面涉及到无刷新上传图片的功能,其实也就是上 ...

  7. php 图片上传预览(转)

    网上找的图片上传预览: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:/ ...

  8. js实现图片上传预览及进度条

    原文js实现图片上传预览及进度条 最近在做图片上传的时候,由于产品设计的比较fashion,上网找了比较久还没有现成的,因此自己做了一个,实现的功能如下: 1:去除浏览器<input type= ...

  9. html 图片上传预览

    Html5 upload img 2012年12月27日 20:36 <!DOCTYPE HTML> <html> <head> <meta http-equ ...

随机推荐

  1. Centos上SSH连接过慢原因

    最近发现机房里有些centos机器进行ssh登陆非常慢且会超时,经过查看发现时GSPI认证过慢问题造成: 使用 ssh -v 发现 debug1: SSH2_MSG_SERVICE_ACCEPT re ...

  2. day03运算符 逻辑运算符

    今日内容 运算符 算术运算符 取模% 打印1~100基数 #模2余1的为基数 #以1 3 5 7 9结尾的为奇数 # count =1 # while count<100: # print(co ...

  3. c# 号码记录,车友

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  4. mongodb分片balance

    查看balance状态 mongos> sh.getBalancerState()true   通过balance锁查看balance活动 如果state是2,表示balance锁已经被获取 m ...

  5. day50 django第一天 自定义框架

    主要内容: 1.http协议 2.web框架 3.Django 1.http协议 1.1 http协议的简介 超文本传输协议(英文:Hyper Text Transfer Protocol,HTTP) ...

  6. ubuntu-docker入门到放弃(七)Dockerfile简介

    一.dockerfile基本结构 最简单的理解就是dockerfile实际上是一些命令的堆叠,有点像最基础的shell脚本,没有if 没有for,就是串行的一堆命令. 一般而言,dockerfile分 ...

  7. 【python】参数中的*args和**kwargs

    转自https://www.cnblogs.com/xuyuanyuan123/p/6674645.html#undefined 多个实参,放到一个元组里面,以*开头,可以传多个参数:**是形参中按照 ...

  8. 黄聪:xampp启动后mysql报Error

    2013-08-04 13:48:22 760 [ERROR] InnoDB: Attempted to open a previously opened tablespace. Previous t ...

  9. Kubernetes Kubelet安全认证连接Apiserver

    Kubelet使用安全认证连接Apiserver,可以用Token或证书连接.配置步骤如下. 1,生成Token命令 head -c /dev/urandom | od -An -t x | tr - ...

  10. micrometer自定义metrics

    micrometer提供了基于Java的monitor facade,其与springboot应用和prometheus的集成方式如下图展示 上图中展示的很清楚,应用通过micrometer采集和暴露 ...