easyui多图片上传+预览切换+支持IE8
引入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的更多相关文章
- 兼容好的JS图片上传预览代码
转 : http://www.codefans.net/articles/1395.shtml 兼容好的JS图片上传预览代码 (谷歌,IE11) <html xmlns="http:/ ...
- Jquery图片上传预览效果
uploadPreview.js jQuery.fn.extend({ uploadPreview: function (opts) { var _self = this, _this = $(thi ...
- [前端 4] 使用Js实现图片上传预览
导读:今天做图片上传预览,刚开始的做法是,先将图片上传到Nginx,然后重新加载页面才能看到这个图片.在这个过程中,用户一直都看不到自己上传的文件是什么样子.Ps:我发现我真的有强迫症了,都告诉我说不 ...
- Javascript之图片上传预览
使用Javascript之图片上传预览,我们无需上传到服务器中,兼容所有浏览器. 关键方法是使用微软库filter:progid:DXImageTransform.Microsoft.AlphaIma ...
- HTML5 图片上传预览
<!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="utf-8& ...
- ASP.NET工作笔记之一:图片上传预览及无刷新上传
转自:http://www.cnblogs.com/sibiyellow/archive/2012/04/27/jqueryformjs.html 最近项目里面涉及到无刷新上传图片的功能,其实也就是上 ...
- php 图片上传预览(转)
网上找的图片上传预览: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:/ ...
- js实现图片上传预览及进度条
原文js实现图片上传预览及进度条 最近在做图片上传的时候,由于产品设计的比较fashion,上网找了比较久还没有现成的,因此自己做了一个,实现的功能如下: 1:去除浏览器<input type= ...
- html 图片上传预览
Html5 upload img 2012年12月27日 20:36 <!DOCTYPE HTML> <html> <head> <meta http-equ ...
随机推荐
- CodeForces - 444C
F - DZY Loves Colors DZY loves colors, and he enjoys painting. On a colorful day, DZY gets a colorfu ...
- : LDAP & Implementation
LDAP LDAP是轻量目录访问协议,英文全称是Lightweight Directory Access Protocol,一般都简称为LDAP.它是基于X.500标准的,但是简单多了并且可以根据需要 ...
- centos7忘记密码处理办法
centos7忘记密码处理办法 此界面按e进入grub编辑界面 进入grub编辑界面.把linux16这行的ro修改为rw init=/sysroot/bin/sh. 按ctrl+x进入单用户模式 登 ...
- PostgreSQL获取所有表名、字段名、字段类型、注释
转载自:http://blog.csdn.net/cicon/article/details/51577655 获取表名及注释: select relname as tabname,cast(obj_ ...
- mongodb 超出内存限制
mongodb 查询数据默认占用最大内存为100M,如果查询涉及到大量数据进行$group.$sort时会抛出类似以下的异常: Received error :: { $err: \"Exc ...
- ubuntu16.04下docker安装和简单使用
前提条件 操作系统 docker-ce支持的ubuntu版本: Bionic 18.04 (LTS) Xenial 16.04 (LTS) Trusty 14.04 (LTS) 卸载旧版本docker ...
- 几种不同格式的json解析
原文地址:http://blog.csdn.net/whx405831799/article/details/42171191 给服务端发送请求后,服务端会返回一连串的数据,这些数据在大部分情况下都是 ...
- 并发之lock的condition接口
13.死磕Java并发-----J.U.C之Condition 12.Condition使用总结 11.Java并发编程系列之十七:Condition接口 === 13.死磕Java并发-----J. ...
- [UE4]记录瞬移目标点
1.判定射线是否击中一个物体:LineTraceByChannel的Return Value返回值 2.击中的目标点:LineTraceByChannel.Out Hit.Location,如图提示文 ...
- (转)cenntos 安装mongodb
转自 https://www.cnblogs.com/layezi/p/7290082.html 安装前注意: 此教程是通过yum安装的.仅限64位centos系统 安装步骤: 1.创建仓库文件: 1 ...