📄 personfile.jsp
字号:
<%@page language="java" contentType="text/html;charset=GBK"%>
<%@page import="java.util.*,java.text.*,oa.main.DealString,javax.swing.tree.DefaultMutableTreeNode"%>
<%
oa.bean.PersonFileBean myFileBean = null;
oa.bean.RightBean rb = null;
try{
myFileBean = new oa.bean.PersonFileBean();
rb = new oa.bean.RightBean();
//数据处理过程
if(myFileBean.getConn()==null || rb.getConn() == null)
{
%>
数据库无法响应,请<a href="javascript:window.history.back(-1);">返回</a>重试
<%out.close();
}
DealString ds = new DealString();
//取得职工号
String strPersonNo = ds.toString((String)session.getAttribute("zgbh"));
//String strPersonNo = ds.toString((String)request.getParameter("txt_personno"));
//取得命令动词
String strCMD = ds.toString((String)request.getParameter("txt_cmd"));
//取得文件根号
String strParentID = ds.toString((String)request.getParameter("txt_parentID"));
if (strParentID.equals("")) strParentID="0";//根文件夹
//取得文件号
String strFileID = ds.toString((String)request.getParameter("txt_fileID"));
if (strFileID.equals("")) strFileID="0";//根文件夹
//取得屏幕分辨率
String strWidth = ds.toString((String)request.getParameter("w"));
if(!strWidth.equals(""))session.setAttribute("SCREEN",strWidth);
if(strWidth.equals(""))strWidth = (String)session.getAttribute("SCREEN");
String args="txt_parentID="+strParentID+"&txt_fileID="+strFileID;
String strAlt="";//置于文件图标上的提示信息
//--define
String strFolderList="";
String strFolderNameList="";
int nRowCount=7;//定义一行有几个元素
if (strWidth.equals("1024")) nRowCount=8;
if (strWidth.equals("800")) nRowCount=6;
//--enddef
myFileBean.setPersonID(strPersonNo);
myFileBean.setstrFileID(strFileID);
myFileBean.setParentID(strParentID);
DefaultMutableTreeNode root=null;
DefaultMutableTreeNode currentNode=null;
root=myFileBean.build1LevTree();
//如果没有这个职工的个人文件柜数据,则为他生成一个根文件夹
if ( (root==null) && (strParentID.equals("0")) ) {
myFileBean.addRoot();
root=myFileBean.build1LevTree();
}
rb.setUID(strPersonNo);
String strTotalSpace = rb.getConfValue("文件柜大小");
int nUsed = myFileBean.getUsedSpace(strPersonNo);
int nTotal = Integer.parseInt(strTotalSpace);
int nTotalByte = nTotal*1024*1024;
boolean IsFull=false;
if(nUsed>=nTotalByte){//((Math.abs(nTotalByte-nUsed)<(5*1024*1024)))||
// nUsed=nTotalByte;
IsFull=true;
}
String strUsedSpace="";
java.text.DecimalFormat f=new java.text.DecimalFormat("#####.##");
if(nUsed<1024)
strUsedSpace = "<font color=#FF0000>" + nUsed + "</font>字节";
else if(nUsed<1048576)
strUsedSpace = "<font color=#FF0000>" + f.format((float)(nUsed/1024.0)) + "</font>KB";
else
strUsedSpace = "<font color=#FF0000>" + f.format((float)(nUsed/1024.0/1024.0)) + "</font>MB";
int nPercent= (int)Math.ceil((nUsed/1024.0/1024.0)*100/nTotal);
String go = "personFileDownload.jsp?download=1&txt_parentID="+strParentID+"&txt_fileID="+strFileID +"&txt_cmd=DOWNLOAD";
String download = ds.toString((String)request.getParameter("download"));
%>
<html>
<head><title>个人文件柜</title>
<link href="../css/person.css" type=text/css rel=stylesheet>
<script language="javascript" src="../scripts/ctrStyles.js"></script>
<script>
var body;
</script>
</head>
<body oncontextmenu="onclickhide()">
<form name=form1 action="personFile.jsp" method=post>
<!-- <input type=hidden name="txt_personno" value="<%=strPersonNo%>"> -->
<input type=hidden name="txt_parentID" size="20" value="<%=strParentID%>">
<input type=hidden name="txt_fileID" size="20" value="<%=strFileID%>">
<input type=hidden name="txt_cmd" size="20" value="<%=strCMD%>">
</form>
<table border="0" width="100%"><td><!-- 控制总宽度的表 -->
<table border="0" cellspacing=0 height=61 width=526 background="../images/master.gif">
<tr><td colspan=2> </td></tr>
<tr>
<td width="50%" height=25 valign=bottom STYLE="font-family:宋体;font-size:12pt;">
<!--<IMG SRC="./fileImgs/folder24.gif" BORDER="0" valign=bottom>-->
<b>
<%
if (strParentID.equals("0")) out.println("我的文件夹[<font face='Arial,Helvetic' color=#6600FF size=2>"+strTotalSpace+"M</font>]");
else out.println((String) ((Hashtable) root.getUserObject()).get("WJMC"));
%>
</b>
<%if(strParentID.equals("0")){%>
<td width=25%>
<table border="1" width=100% cellspacing=0 cellpadding=0><td>
<table border="0" width=100% cellspacing=0 cellpadding=0>
<tr><td align=center colspan=3><font color=#339900>使用<%=strUsedSpace%> 占<font color=#6600FF><%if (nPercent<=100)out.print(nPercent);else out.print("100");%>%</font></font></td>
</tr>
<tr height=10><td align=center background="../images/space.gif" width="<%=(nPercent)%>%" >
</td>
<td bgcolor="CC99CC" width="<%=100-nPercent%>%" height=10>
</td>
</tr>
</table></td></table>
</td><%}%>
<td valign=bottom width="30%">
<input <%if (IsFull) out.print("disabled");%> type="button" value="上传文件" name="B_upload" onclick="upload()" > <input type="button" value="新建目录" name="B_mkdir" onclick="mkdir()" <%if (IsFull) out.print("disabled");%>>
</td>
</tr>
<tr><td colspan=2> </td></tr>
</table>
<!-- 横条 -->
<!--<table border="0" width="95%" height="5" bgcolor="#6974D8"><td></td></table>-->
<table border="0" width="95%" height="480">
<tr>
<%
int nFileCount;
if (root!=null){
nFileCount=root.getChildCount();
}else{
nFileCount=0;
}
/*
*文件夹内容------------------------------------------------------------------------->
*/
%>
<td width="80%" height="100%" valign="top">
<table border="0" width="100%" >
<%
/*
*文件夹的一行---------------------------------------------------------------------->
*/
int i=0;
do {
%>
<table border="0" width="100%" height="64">
<tr width="100%" height="64" >
<%
for(int j=0;j<nRowCount;j++){
//if (i>=nFileCount) break;
//上一级目录
Hashtable hs=(Hashtable) root.getUserObject();
String strCurrentFML= (String) hs.get("FMLBH");
if ( i==0 && !strCurrentFML.equals("-1") && (j==0) ) {
%>
<td width="80" height="80">
<!-- 上一级目录的格子 -->
<table border="0" width="100%" height="80">
<tr>
<td width="100%" height="40" align="center" style="cursor:hand" onclick="backToParent('<%=strCurrentFML%>')" >
<%strFolderList=strCurrentFML;strFolderNameList="上层文件夹";%>
<img width="48" height="48" border="0" src="../sharedfiles/fileImgs/back.gif" align="center"></td>
</tr>
<tr>
<td width="100%" height="40" align="center" valign="top"><b>[返回]</b></td>
</tr>
</table>
<!-- 上一级目录的格子完毕 -->
</td>
<%
continue;
}
%>
<td width="80" height="80" valign="top">
<!-- 一个格子 -->
<table border="0" width="80" height="80" style="word-break:break-all;">
<tr>
<%
if(i<nFileCount) {
currentNode = (DefaultMutableTreeNode) root.getChildAt(i);
String strfileid_temp=(String) ((Hashtable) currentNode.getUserObject()).get("WJBH");
String strfileclass_temp=(String) ((Hashtable) currentNode.getUserObject()).get("WJLB");
String strfileExt_temp=(String) ((Hashtable)currentNode.getUserObject()).get("WJKZM");
String strImg="../sharedfiles/fileImgs/";
i++;
String strfilename=(String) ((Hashtable) currentNode.getUserObject()).get("WJMC");
if (strfileclass_temp.equals("D"))
{
strImg+=myFileBean.getFileIMG("DIR");
if(strFolderList.equals("")){
strFolderList+=strfileid_temp;
strFolderNameList+=(String)((Hashtable)currentNode.getUserObject()).get("WJMC");
}
else{
strFolderList+=","+strfileid_temp;
strFolderNameList+=","+(String)((Hashtable)currentNode.getUserObject()).get("WJMC");
}
}
if (strfileclass_temp.equals("F"))
{
String strWJDX = "";
int n_WJDX = Integer.parseInt((String)((Hashtable)currentNode.getUserObject()).get("WJDX"));
if(n_WJDX<1024)
strWJDX = n_WJDX + "字节";
else if(n_WJDX<1048576)
strWJDX = f.format((float)(n_WJDX/1024.0)) + "KB";
else
strWJDX = f.format((float)(n_WJDX/1024.0/1024.0)) + "MB";
strAlt = strfilename+" 文件大小:"+strWJDX;
strImg+=myFileBean.getFileIMG(strfileExt_temp);
}
%>
<td width="100%" height="40" align="center" valign="top" title="<%=strAlt%>" style="cursor:hand" onclick="openFile('<%=strfileid_temp%>','<%=strfileclass_temp%>')" oncontextmenu="onclickshow('<%=strfileid_temp%>','<%=strfileclass_temp%>')">
<img width="48" height="48" border="0" src="<%=strImg%>" align="center"></td>
</tr>
<tr>
<%
if (strfileclass_temp.equals("D")) {
%>
<td width="100%" height="40" align="center" valign="top" title="<%=strfilename%>">
<% }
if (strfileclass_temp.equals("F")) {
%>
<td width="100%" height="40" align="center" valign="top" title="<%=strAlt%>">
<% }
strfilename=myFileBean.formatFileName(strfilename,10,4);
out.print(strfilename);
%>
</td>
</tr>
</table>
<%
}else{
%>
<table border="0" width="100%" height="100%"></table>
<%
}
%>
<!-- 格子完毕 -->
</td>
<%
}//end for j
/*
*文件夹一行完---------------------------------------------------------------------->
*/
%>
</tr>
</table>
<%
/*
*文件夹内容完---------------------------------------------------------------------->
*/
}while(i<nFileCount);//end while;
%>
</table>
</tr>
</table>
</td></table><!-- 控制宽度的表完 -->
<%
String cfile="personFilesCtrl.jsp?&txt_folderlist="+strFolderList+"&txt_foldernamelist="+ds.toASCII(strFolderNameList);
%>
<jsp:include page="<%=cfile%>"/>
<Script>
if(body==null)
body=document.body;
function openFile(fileid,fileclass) {
//是文件夹
if (fileclass=="D"){
form1.txt_cmd.value = "OPEN";
//将parentID设为当前选中的文件的ID
form1.txt_parentID.value = fileid;
form1.action = "personFile.jsp";
form1.submit();
}
//是文件
if (fileclass=="F"){
form1.txt_fileID.value = fileid;
download();
}
}//end function openFile
//无参数打开文件夹
function openDIR(){
//是文件夹
form1.txt_cmd.value = "OPEN";
var fileid=form1.txt_fileID.value;
form1.txt_parentID.value=fileid;
form1.action = "personFile.jsp";
form1.submit();
}
function backToParent(parentid){
form1.txt_cmd.value = "OPEN";
//将parentID设为当前选中的文件的ID
form1.txt_parentID.value = parentid;
form1.action = "personFile.jsp";
form1.submit();
}
function upload(){
var go = "personFileUpload.jsp?<%=args%>&txt_cmd=UPLOAD";
var oawin = window.open(go,"_blank","toolbar=0,location=0,status=yes,menubar=0,scrollbars=yes,resizable=no,width=400,height=200");
oawin.focus();
//oawin.opener=window;
}
function mkdir(){
var strNewDIRName="";
strNewDIRName=window.prompt("请输入新的文件夹的名:","");
if ((strNewDIRName!=null) && (strNewDIRName!="")){
if (!checkFilename(strNewDIRName)){
alert("您所取的名称不合法,请确实其小于50个字,并且不包含/\等非法字符!");
return false;
}
form1.txt_cmd.value = "MKDIR";
form1.action = "../../PersonFileServlet?txt_newfilename="+strNewDIRName;
form1.submit();
}
}
function download_OLD(){
form1.txt_cmd.value = "DOWNLOAD";
form1.action = "../../PersonFileServlet";
form1.submit();
}
function download(){
var fileid=form1.txt_fileID.value;
var go = "personFileDownload.jsp?download=1&txt_parentID=<%=strParentID%>&txt_fileID="+fileid +"&txt_cmd=DOWNLOAD";
//var oawin = window.open(go,"_blank","toolbar=0,location=0,status=yes,menubar=0,scrollbars=yes,resizable=no,width=400,height=200");
//oawin.focus();
form1.action = go;
form1.submit();
}
function rename()
{
<%--/* var strNewName="";
strNewName=window.prompt("请输入一个新的名字:","");
if ((strNewName!=null) && (strNewName!="")){
if (!checkFilename(strNewName)){
alert("您所取的名称不合法,请确实其小于50个字,并且不包含\/等非法字符!");
return false;
}
form1.txt_cmd.value = "RENAME";
form1.action = "../../PersonFileServlet?txt_newfilename="+strNewName;
form1.submit();
}
*/--%> form1.txt_cmd.value="RENAME";
form1.action="";
var url = "newFileName.jsp?zgbh=<%=strPersonNo%>&fileID="+form1.txt_fileID.value+"&parentID="+form1.txt_parentID.value;
var hWnd = window.open(url,"HelpWindow4","width=350,height=80,resizable=no,scrollbars=no,menubar=no");
if ((window != null) && (!hWnd.opener))
hWnd.opener = window;
hWnd.focus();
}
function delfile(){
if (confirm("确实要删除这个文件吗?")){
form1.txt_cmd.value = "DEL";
form1.action = "../../PersonFileServlet";
form1.submit();
}
}
function delDIR(){
if (confirm("这个文件夹下的所有内容将被删除,确实要删除这个文件夹吗?")){
form1.txt_cmd.value = "DELTREE";
form1.action = "../../PersonFileServlet";
form1.submit();
}
}
//检查文件名是否合法,1.长度<50,2,不含下列字符/\
function checkFilename(strfilename){
if (strfilename.length>50) return false;
if (strfilename.match(/[\/\\]/)==null) {
return true;
}
return false;
}
function chooseDIR()
{
var url = "";
url = "chooseDIR.jsp?zgbh=<%=strPersonNo%>";
var hWnd = window.open(url,"HelpWindow","width=450,height=300,resizable=no,scrollbars=yes");
if ((window != null) && (!hWnd.opener))
hWnd.opener = window;
hWnd.focus();
}
function moveToDIR(target)
{
form1.txt_cmd.value = "moveToDIR";
form1.action = "../../PersonFileServlet?targetFolder="+target;
form1.submit();
}
</Script>
<%
if(download!=null&&download.equals("1"))
{
%>
<jsp:include page="<%=go%>"/>
<%
}
%>
</body>
</html>
<%}catch(Exception e){oa.main.Logger.log("ERROR:oa.person.personFile.jsp=>");e.printStackTrace(oa.main.Logger.log);}
finally{
if(myFileBean!=null)myFileBean.closeConn();
if(rb!=null)rb.closeConn();
}%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -