<%@ page contentType="text/html;charset=gbk" %>
<%@ page import="net.sz600.system.SzAnnex" %>
<%@ page import="net.sz600.system.SzAnnexInfo" %>
<%@ page import="java.util.*" %>
<%@ include file="/sessionInfo.jsp"%>
<html>
    <head>
    <BASE target="_self">    
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="0">
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title></title>
    <link href="<%=strSkin_SESSION%>/css2007.css" rel="stylesheet" type="text/css">
    </head>
<BODY>
<%
    String obj = SzConvert.toSpaceStr(request.getParameter("obj"));
%>

<TABLE width="100%" border="0" cellpadding="0" cellspacing="0" align="center">
<form name="form" method="post" action="uploadImageOk.jsp"  ENCTYPE="multipart/form-data">
  <input type="hidden" name="filepath">
  <input type="hidden" name="obj" value="<%=obj%>">
  <TR>
    <TD align="center" height="30"><b>请选择本地图片(gif,bmp,jpeg,jpg,png)：</b></td>
  </tr>
  <TR>
    <TD align="center" height="30"><INPUT TYPE="file" SIZE="60" NAME="file1"></td>
  </tr>
  <tr>
    <td align="center" height="30">
        <input type="button" value="确定" class="btnClass" OnClick="javascript:upload();">
        <input type="button" value="关闭" class="btnClass" OnClick="javascript:window.close();">
    </td>
  </tr>
</form>
</TABLE>
<table width="100%" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="1" cellspacing="0">
  <tr class="trClassTitle">
    <td>图片名称</td>
    <td>大小</td>
    <td>上传人员</td>
    <td>上传时间</td>
    <td>操作</td>    
  </tr>
<%
  String tableName = SzConvert.toSpaceStr((String)session.getAttribute("SzPicture" + iMKID_SESSION));
  if (tableName.equals("")) {
	  tableName = "SZXT_TPFJ";
  }
  SzAnnex szAnnex = new SzAnnex(tableName);
  SzAnnexInfo annexInfo = null;
  Iterator iter = szAnnex.getArrayList("FJXX=" + iDLID_SESSION + " order by FJSJ DESC").iterator();
  while (iter != null && iter.hasNext()) {
	  annexInfo = (SzAnnexInfo)iter.next();
%>
  <tr>
    <td><%=annexInfo.getFJMC()%></td>
    <td><%=annexInfo.getFJDX()%></td>
    <td><%=annexInfo.getFJDLXM()%></td>
    <td><%=annexInfo.getFJSJ()%></td>
    <td>
    	<a href="#" OnClick="javascript:ImgOk('<%=annexInfo.getFJLJ()%>');">选定</a>
    	<a href="../../../<%=annexInfo.getFJLJ()%>" target="_blank">预览</a>
<!--
    	<a href="#" OnClick="javascript:Del('<%=annexInfo.getFJID()%>');">删除</a>
-->
    </td>
  </tr>
<%	  
  }
%>
</table>
<SCRIPT LANGUAGE="JavaScript">
  function upload() {
    var v = form.file1.value;
    if (form.file1.value == "") {
    	alert("请选择要本地图片");
    	form.file1.focus();  
    	return false;  	
    }
    //通过js判断是否为图片："gif,GIF,bmp,BMP,jpeg,JPEG,jpg,JPG,png,PNG"
    var vLen = v.length;
    var vExt = v.substring(vLen - 4, vLen);
    
    if (vLen > 4 ) {
        if (vExt == ".gif" || vExt == ".GIF" || vExt == ".bmp" || vExt == ".BMP" || vExt == ".jpeg"
             || vExt == ".jpg" || vExt == ".JPG" || vExt == ".png" || vExt == ".PNG" || vExt == ".JPEG") {
             //是图片类型，可提交
             form.submit();
             return true;
        }
    }    
    alert("上传图片格式不正确");
    return false;
        
  }
  
  function ImgOk(vPath) {
      var vObj = form.obj.value;
      var oWindow = window.dialogArguments;
      eval("oWindow." + vObj + ".value='" + vPath + "';");   
      window.close();
  }
  
  function Del(vID) {
      if (confirm("删除后网站无法显示该图片，是否继续")) {
	document.location.href="uploadImageOk.jsp?OPERATOR=delete&FJID=" + vID;	
      }
  }

</SCRIPT>
</BODY>
</HTML>
