notes_write.jsp

来自「java jsp教程」· JSP 代码 · 共 377 行

JSP
377
字号
<!--\webapps\jsp\notes_Write.jsp by zhangl-->

<%@ page  contentType="text/html;charset=GBK" %>
<%@ page import="java.util.*"%>
<%@ page import="com.icss.j2ee.util.PageScrollUtil" %>
<%@ page import="com.icss.resourceone.sdk.configuration.ConfigManager"%>
<%@ page import="com.icss.resourceone.sdk.configuration.Parameter"%>
<%@ page import="com.icss.cnpc.msgnote.util.CommonUtil" %>
<%@ page import="com.icss.cnpc.msgnote.util.StringUtility" %>
<%@ page import="com.icss.cnpc.msgnote.util.DateUtility" %>

<%
    response.setHeader("Pragma", "No-cache");
    response.setHeader("Cache-Control", "no-cache");
    response.setDateHeader("Expires", 0);

%>

<%
    //int PageNum = PageScrollUtil.getPageNum();
    String contextpath = request.getContextPath();
	String number = StringUtility.filterNullObject((String)request.getParameter("attachnum"));
	
	String arg_noteTitle = StringUtility.filterNullObject((String)request.getAttribute("arg_noteTitle"));
	String arg_sendPerson = StringUtility.filterNullObject((String)request.getAttribute("arg_sendPerson"));
	String arg_sendUnit = StringUtility.filterNullObject((String)request.getAttribute("arg_sendUnit"));
	String arg_status = StringUtility.filterNullObject((String)request.getAttribute("arg_status"));
	String arg_impdegree = StringUtility.filterNullObject((String)request.getAttribute("arg_impdegree"));
	String pagenumber = StringUtility.filterNullObject((String)request.getAttribute("pagenumber"));
	
	String right = StringUtility.filterNullObject((String)request.getAttribute("right"));
	String isreturn = StringUtility.filterNullObject((String)request.getAttribute("isreturn"));
	
	String islarge = (String)request.getAttribute("islarge");
	
	String argnoteTitle = StringUtility.filterNullObject((String)request.getAttribute("argnoteTitle"));
	String argimpdegree = StringUtility.filterNullObject((String)request.getAttribute("argimpdegree"));
	String argnoteBody = StringUtility.filterNullObject((String)request.getAttribute("argnoteBody"));
	String argdate = StringUtility.filterNullObject((String)request.getAttribute("argdate"));
	String argcurUnit = StringUtility.filterNullObject((String)request.getAttribute("argcurUnit"));
	
    int attachnum = new Integer(number).intValue();
	
	String rootorgid = (String)request.getAttribute("rootorgid");
    String isAudit = (String)request.getAttribute("isAudit");
    String isState = (String)request.getAttribute("isState");
	System.out.println("[check]notes_Write.jsp---->"+rootorgid+"|"+isAudit+"|"+isState);
%>
<html>
<head>
<title>发送公告</title>
<meta http-equiv="Content-Type" content="text/html;charset=GBK">
<link rel="stylesheet" href="<%=contextpath%>/css/style.css" type="text/css">
<script language="JavaScript" src="<%=contextpath%>/include/common.js"></script>
<SCRIPT language=JavaScript>

var attachnum = <%=attachnum%>;
var curnum = 0;
var allnum = 0;

function addatt(src)
{
  
  if(allnum > (attachnum-1) || curnum > (attachnum-1))
  {
    alert("附件最多不能超过"+attachnum+"个");
	document.all.display1.style.display = "none";   
	document.all.display.style.display = "none";
	return false;
  }
maxNum = <%=attachnum%>;
 for(var i=0; i<maxNum; i++)
 {
 	var obj = document.all["file" + i];
	if(obj != null && obj.style)
	{
		if(obj.style.display && obj.style.display != "block")
		{
			obj.style.display = "block";
			break;
		}
	}
 }
 curnum ++;
 allnum ++;

 if(i >= maxNum - 1)
 {
 	src.parentElement.parentElement.parentElement.style.display = "none";
 }
}

var delnum="";
function delatt(flag,j)
{
  curfile = eval("document.all."+flag+".style");
  var fileTD = document.getElementById("fileTD" + j);
  if(fileTD)
  {
  	fileTD.innerHTML = "<input name=\"uploadfile" + j + "\" type=\"file\">";
  }
  curfile.display = "none";
  //attnums--;
  curnum --;
  allnum --;
  delnum=","+j+delnum;
  document.NotesForm.deletenum.value = delnum;;
  if(allnum <= 0)//if(attnums < 0)
  {
    //document.all.display1.style.display = "none";   
	document.all.display.style.display = "";
  }
  else
  {
    if(allnum > attachnum-1)
   {
  	//document.all.display1.style.display = "none";   
	document.all.display.style.display = "none";
	document.all.display2.style.display = "none";
   }
   else
   {
    document.all.display.style.display = "";   
	//document.all.display1.style.display = "";
	}
  }
}

function save(flag)
{
    if(!_CheckForm1()){
    	return false
    	 }
	  if(!filterCharter(document.NotesForm.noteTitle)){
    	return false;
     }
	  if(!filterCharter(document.NotesForm.noteBody)){
    	return false;
     }
	if(getLength(document.NotesForm.noteBody.value) > 2056){
	  alert("输入内容不能超过1028个汉字!");
	  return false;
	   }
		 var sform = document.NotesForm;
		 var filesnum=0;
		 for(var ii=0;ii<sform.length;ii++){
		 	if(sform.elements[ii].type == "file")
		 	filesnum++; 
		 }
		 document.NotesForm.filesnumber.value = filesnum;
		
   NotesForm.operate.value=flag;
   var str;
   str = "<%=contextpath%>/servlet/NoteSaveServlet";
   document.NotesForm.action="<%=contextpath%>/servlet/NoteSaveServlet";
   document.NotesForm.submit();
}

function commit(flag)
{
        if(!_CheckForm()){
    	return false
    	 }
		var str2 = document.NotesForm.validDate.value;
		if(Compare_Date("<%=DateUtility.getCurrentDate()%>",str2))
	    {
		 alert("有效期小于当前日期!");
		 return false;
		}

		 	  if(!filterCharter(document.NotesForm.noteTitle)){
    	return false;
     }
	  if(!filterCharter(document.NotesForm.noteBody)){
    	return false;
     }
		 if(getLength(document.NotesForm.noteBody.value) > 2056){
	       alert("输入内容不能超过1028个汉字!");
	     return false;
	     }
		 var sform = document.NotesForm;
		 var filesnum=0;
		 for(var ii=0;ii<sform.length;ii++){
		 	if(sform.elements[ii].type == "file")
		 	filesnum++;
		 
		 }
   document.NotesForm.filesnumber.value = filesnum;
   NotesForm.operate.value=flag;
   document.NotesForm.action="<%=contextpath%>/servlet/NoteSaveServlet";
   document.NotesForm.submit();
}


function _CheckForm()
 {
     return !Is_Null(document.NotesForm.noteTitle,1,'请填写公告标题!') && !Is_Null(document.NotesForm.noteBody,1,'请填写公告内容!')
     && !Is_Null(document.NotesForm.validDate,1,'请填写有效期!') && is_date(document.NotesForm.validDate,1,'请输入\'2005-06-01\'形式日期') 
     && !Is_Null(document.NotesForm.orgname,1,'请填写公告发布范围!');
 }
 
 function _CheckForm1()
 {
     return !Is_Null(document.NotesForm.noteTitle,1,'请填写公告标题!') && !Is_Null(document.NotesForm.noteBody,1,'请填写公告内容!');
  }
 
 function _Add()
 {

  if(!_CheckForm()){
    return false;
  }

  if (NotesForm.FullFileName.value==""){
  document.NotesForm.action="/officeaffair/noteswriteservlet?HasFJFlag=0";
  }
  else{
  document.NotesForm.action="/officeaffair/noteswriteservlet?HasFJFlag=1";
  }
  document.NotesForm.submit();
 }
 
    function _BackTo()
 {
 if(NotesForm.right.value == 3){
 window.location="<%=contextpath%>/servlet/NoteManageListServlet?noteTitle="+NotesForm.noteTitle1.value+"&sendPerson="+NotesForm.sendPerson1.value+"&sendUnit="+NotesForm.sendUnit1.value+"&status="+NotesForm.status1.value+"&impdegree="+NotesForm.impdegree1.value;
 }
 if(NotesForm.right.value == 1){
 window.location="<%=contextpath%>/servlet/MyNoteInfoServlet?noteTitle="+NotesForm.noteTitle1.value+"&sendPerson="+NotesForm.sendPerson1.value+"&sendUnit="+NotesForm.sendUnit1.value+"&status="+NotesForm.status1.value+"&impdegree="+NotesForm.impdegree1.value;
 }
 }
 
 function _Reset()
 {
  document.NotesForm.noteTitle.value="";
  document.NotesForm.impdegree.options[0].selected = true;
  //document.NotesForm.sendUnit.options[0].selected = true;
  document.NotesForm.orgname.value="";
  document.NotesForm.orgid.value="";
  document.NotesForm.validDate.value="";
  document.NotesForm.noteBody.value="";
  document.NotesForm.noteTitle.focus;
 }
 
 function alertUser()
 {
   if(<%=islarge%>==1)
   {
     alert("附件大小超出限制!");
   }
 
 }
 
 function popUpCalendarDlg(ctrlobj) {
	showx = event.screenX - event.offsetX - 4 - 210 ; // + deltaX;
	showy = event.screenY - event.offsetY + 18; // + deltaY;
	newWINwidth = 210 + 4 + 18;
	retval = window.showModalDialog("<%=request.getContextPath()%>/include/date.htm", "", "dialogWidth:220px; dialogHeight:220px; dialogLeft:"+showx+"px; dialogTop:"+showy+"px; status:no; directories:yes;scroll:no;Resizable:no; "  );
	if( retval != null ){
		ctrlobj.value = retval;
	}
}

function selectUnit() {
  		wx=200;
		wy=200;
		urlstr="<%=request.getContextPath()%>/jsp/msgnote/noteRangeTree.jsp?rootorgid=<%=rootorgid%>&isAudit=<%=isAudit%>&isState=<%=isState%>";
		x=(window.screen.width-wx)/2;
		y=(window.screen.height-wy)/2;
		wposition=",left="+x+",top="+y;
		window.open(urlstr,"选择发布范围","width="+wx+",height="+wy+",scrollbars=no,status=no"+wposition); 
} 

</SCRIPT>

<style type="text/css">
<!--
.style1 {color: #0000FF}
-->
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000" background="<%=request.getContextPath()%>/images/grid.gif"  leftmargin="0" topmargin="10" onLoad="javascript:alertUser()">
<p> </p>
<form name=NotesForm method="post" enctype="multipart/form-data">
<input type="hidden" name="operate" value="">
<input type="hidden" name="savetype" value="">
<input type="hidden" name="filesnumber" value="">
<input type="hidden" name="attachnum" value="<%=number%>">
<input type="hidden" name="deletenum">
<input type="hidden" name="noteTitle1" value="<%=arg_noteTitle%>">
<input type="hidden" name="sendPerson1" value="<%=arg_sendPerson%>">
<input type="hidden" name="sendUnit1" value="<%=arg_sendUnit%>">
<input type="hidden" name="status1" value="<%=arg_status%>">
<input type="hidden" name="impdegree1" value="<%=arg_impdegree%>">
<input name="pagenumber" type="hidden" value="<%=pagenumber%>">
<input name="right" type="hidden" value="<%=right%>">
<input name="orgid" type="hidden">
      <table width="500" border="0" align="center"><tr><td>
      <table width="100%" border="0" align="center" cellpadding="2" cellspacing="1"  bordercolordark="#DFDFFF" bordercolorlight="#003366" bgcolor="#6699CC">
          <tr bgcolor="#EEF4FF"> 
            <td height="24" <%if(CommonUtil.Is1tN().equals("1")){%>colspan="4"<%}{%>colspan="2"<%}%> align="center" bgcolor="#a6d0f2">公告内容</td>
          </tr>
          <tr bgcolor="#EEF4FF"> 
            <td width="22%" align="center">标题</td>
            <td <%if(CommonUtil.Is1tN().equals("1")){%>colspan="3"<%}%> align="left">    
                <input name="noteTitle" type="text" size="45" maxlength="50" value="<%=argnoteTitle%>">*
            </td>
          </tr>
          <tr bgcolor="#EEF4FF"> 
            <td align="center">重要程度</td>
            <td align="left"> 
                <select name="impdegree">
                  <option value="0" <%if(argimpdegree.equals("0")){%>selected<%}%>>一般</option>
                  <option value="1" <%if(argimpdegree.equals("1")){%>selected<%}%>>紧急</option>
                </select>
            </td>
            <td bgcolor="EEF4FF" width="22%"><div align="center">发布范围</div></td>
            <td align="left" valign="top" bgcolor="EEF4FF" width="23%"><input type="text" name="orgname" id="orgname" readonly=""><img src="<%=request.getContextPath()%>/images/icon-15.gif" name="unit" width="22" height="15" class="bt1" style="cursor:hand;" onClick="selectUnit()"></td>
          </tr>
          <tr bgcolor="#EEF4FF">
            <td align="center">有效期</td>
            <td align="left" <%if(CommonUtil.Is1tN().equals("1")){%>colspan="3"<%}%>><input name="validDate" type="text" id="Notes_Title" readonly size="10" value="<%=argdate%>"><img src="<%=contextpath%>/images/calendar.gif" onClick="popUpCalendarDlg(validDate);" style="cursor:hand"></td>
          </tr>
          <tr bgcolor="#EEF4FF"> 
            <td valign="middle" align="center">内&nbsp;容</td>
            <td align="left" valign="top" <%if(CommonUtil.Is1tN().equals("1")){%>colspan="3"<%}%>> 
                <textarea name="noteBody" cols="40" rows="16"><%=argnoteBody%></textarea>
            </td>
          </tr>
		  <%
		     for(int j = 0; j < attachnum; j++)
			 {
		  %>
          <tr bgcolor="#EEF4FF" id="file<%=j%>" style="display:none">
            <td height="27"><div align="center">附件</div></td>
            <td height="27" align="center" valign="top" <%if(CommonUtil.Is1tN().equals("1")){%>colspan="3"<%}%>>
			 <table border="0" width="100%">
			  <tr>
			   <td id="fileTD<%=j%>"><input name="uploadfile<%=j%>" type="file"></td>
			   <td><div align="right"><img src="<%=contextpath%>/images/delete.gif" style="cursor: hand" onclick="javascript:delatt('file<%=j%>','<%=j%>')"></div></td>
			  </tr>
			 </table>
			</td>
          </tr>
		  <%
		    }
		  %>
          <tr bgcolor="#EEF4FF" id="display">
            <td height="27" <%if(CommonUtil.Is1tN().equals("1")){%>colspan="4"<%}{%>colspan="2"<%}%>>
			<div align="center">
			<img src="<%=request.getContextPath()%>/images//buttons/attachmentadd.gif" style="cursor: hand" onClick="addatt(this)">
			</div></td>
          </tr>
		  <tr bgcolor="#EEF4FF" valign="bottom" id="display2" >
              <td height="27" <%if(CommonUtil.Is1tN().equals("1")){%>colspan="4"<%}{%>colspan="2"<%}%> align="center">
			    <font color="#0000FF">最多能添加<%=String.valueOf(CommonUtil.getAttachNum())%>个附件,每个附件最大为<%=String.valueOf(CommonUtil.getAttachSize())%>M
              </font></td>
          </tr>
  </table>
  </td></tr></table>
	<br><br>
	<center>
		<img style="CURSOR: hand" onClick='save("save")' src="<%=contextpath%>/images/save.gif" border=0>&nbsp;&nbsp;
		<img style="CURSOR: hand" onClick='commit("commit")' src="<%=contextpath%>/images/send.gif" border=0>&nbsp;&nbsp;
		<img style="CURSOR: hand" onClick=javascript:_Reset() src="<%=contextpath%>/images/reset.gif" border=0>&nbsp;&nbsp;
		<%if(isreturn.equals("")){%>
		<img style="CURSOR: hand" onClick='javascript:_BackTo()' src="<%=contextpath%>/images/return.gif" border=0>&nbsp;&nbsp;
		<%}%>
	</center>
</form>

<script>
//fileChange();
</script>

</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?