flow_initiate2_notmodifyform.jsp
上传用户:jhtang88
上传日期:2014-01-27
资源大小:28528k
文件大小:19k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. <%@ page contentType="text/html;charset=utf-8" %>
  2. <%@ page import="cn.js.fan.security.*"%>
  3. <%@ page import="cn.js.fan.util.*"%>
  4. <%@ page import="java.util.*"%>
  5. <%@ page import="cn.js.fan.web.*"%>
  6. <%@ page import="com.redmoon.oa.pvg.*"%>
  7. <%@ page import="java.util.Calendar" %>
  8. <%@ page import="cn.js.fan.db.Paginator"%>
  9. <%@ page import="com.redmoon.oa.flow.*"%>
  10. <html><head>
  11. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  12. <link href="common.css" rel="stylesheet" type="text/css">
  13. <%@ include file="inc/nocache.jsp"%>
  14. <jsp:useBean id="strutil" scope="page" class="cn.js.fan.util.StrUtil"/>
  15. <jsp:useBean id="docmanager" scope="page" class="com.redmoon.oa.flow.DocumentMgr"/>
  16. <jsp:useBean id="dir" scope="page" class="com.redmoon.oa.flow.Directory"/>
  17. <%
  18. String dir_code = "";
  19. String dir_name = "";
  20. String flowTitle = ParamUtil.get(request, "flowTitle");
  21. int id = 0;
  22. Privilege privilege = new Privilege();
  23. String correct_result = "操作成功!";
  24. int flowId = ParamUtil.getInt(request, "flowId");
  25. WorkflowDb wfd = new WorkflowDb();
  26. wfd = wfd.getWorkflowDb(flowId);
  27. id = wfd.getDocId();
  28. Document doc = new Document();
  29. doc = doc.getDocument(id);
  30. dir_code = doc.getDirCode();
  31. Document template = null;
  32. Leaf leaf = dir.getLeaf(dir_code);
  33. dir_name = leaf.getName();
  34. String strtemplateId = ParamUtil.get(request, "templateId");
  35. int templateId = Document.NOTEMPLATE;
  36. if (!strtemplateId.trim().equals("")) {
  37. if (StrUtil.isNumeric(strtemplateId))
  38. templateId = Integer.parseInt(strtemplateId);
  39. }
  40. if (templateId==Document.NOTEMPLATE) {
  41. if (leaf!=null)
  42. templateId = leaf.getTemplateId();
  43. }
  44. if (templateId!=Document.NOTEMPLATE) {
  45. template = docmanager.getDocument(templateId);
  46. }
  47. String op = ParamUtil.get(request, "op");
  48. String work = ParamUtil.get(request, "work"); // init modify
  49. if (op.equals("add")) {
  50. String action = ParamUtil.get(request, "action");
  51. if (action.equals("selTemplate")){
  52. int tid = ParamUtil.getInt(request, "templateId");
  53. template = docmanager.getDocument(tid);
  54. }
  55. }
  56. if (op.equals("edit")) {
  57. String action = ParamUtil.get(request, "action");
  58. try {
  59. id = ParamUtil.getInt(request, "id");
  60. doc = docmanager.getDocument(id);
  61. dir_code = doc.getDirCode();
  62. if (action.equals("selTemplate")) {
  63. int tid = ParamUtil.getInt(request, "templateId");
  64. doc.setTemplateId(tid);
  65. doc.updateTemplateId();
  66. }
  67. if (doc!=null) {
  68. template = doc.getTemplate();
  69. }
  70. } catch (ErrMsgException e) {
  71. out.print(strutil.makeErrMsg(e.getMessage(), "red", "green"));
  72. return;
  73. }
  74. if (action.equals("changeAttachOrders")) {
  75. int attachId = ParamUtil.getInt(request, "attachId");
  76. String direction = ParamUtil.get(request, "direction");
  77. // 取得第一页的内容
  78. DocContent dc = new DocContent();
  79. dc = dc.getDocContent(id, 1);
  80. dc.moveAttachment(attachId, direction);
  81. }
  82. }
  83. if (op.equals("editarticle")) {
  84. op = "edit";
  85. try {
  86. doc = docmanager.getDocumentByCode(request, dir_code, privilege);
  87. dir_code = doc.getDirCode();
  88. } catch (ErrMsgException e) {
  89. out.print(strutil.makeErrMsg(e.getMessage(),"red", "green"));
  90. return;
  91. }
  92. }
  93. if (doc!=null) {
  94. id = doc.getID();
  95. Leaf lfn = new Leaf();
  96. lfn = lfn.getLeaf(doc.getDirCode());
  97. dir_name = lfn.getName();
  98. }
  99. %>
  100. <title><%=doc!=null?doc.getTitle():""%></title>
  101. <style type="text/css">
  102. <!--
  103. td {  font-family: "Arial", "Helvetica", "sans-serif"; font-size: 14px; font-style: normal; line-height: 150%; font-weight: normal}
  104. .style2 {color: #FF3300}
  105. -->
  106. </style>
  107. <script language=JavaScript src='inc/formpost.js'></script>
  108. <script language="JavaScript">
  109. <!--
  110. <%
  111. if (doc!=null) {
  112. out.println("var id=" + doc.getID() + ";");
  113. }
  114. %>
  115. var op = "<%=op%>";
  116. var work = "<%=work%>";
  117. function SubmitWithFileDdxc() {
  118. addform.webedit.isDdxc = 1;
  119. if (document.addform.title.value == "") {
  120. alert("请输入文章标题.");
  121. document.addform.title.focus();
  122. return false;
  123. }
  124. loadDataToWebeditCtrlWithHTMLCode(addform, addform.webedit, document.getElementById("idTemporary").innerHTML);
  125. addform.webedit.MTUpload();
  126. // 因为Upload()中启用了线程的,所以函数在执行后,会立即反回,使得下句中得不到ReturnMessage的值
  127. // 原因是此时服务器的返回信息还没收到
  128. // alert("ReturnMessage=" + addform.webedit.ReturnMessage);
  129. }
  130. function SubmitWithFileThread() {
  131. if (document.addform.title.value.length == 0) {
  132. alert("请输入文章标题.");
  133. document.addform.title.focus();
  134. return false;
  135. }
  136. loadDataToWebeditCtrlWithHTMLCode(addform, addform.webedit, document.getElementById("idTemporary").innerHTML);
  137. addform.webedit.Upload();
  138. // 因为Upload()中启用了线程的,所以函数在执行后,会立即反回,使得下句中得不到ReturnMessage的值
  139. // 原因是此时服务器的返回信息还没收到
  140. // alert("ReturnMessage=" + addform.webedit.ReturnMessage);
  141. }
  142. function SubmitWithFile(){
  143. if (document.addform.title.value == "") {
  144. alert("请输入文章标题.");
  145. document.addform.title.focus();
  146. return false;
  147. }
  148. loadDataToWebeditCtrlWithHTMLCode(addform, addform.webedit, document.getElementById("idTemporary").innerHTML);
  149. addform.webedit.UploadArticle();
  150. if (addform.webedit.ReturnMessage == "<%=correct_result%>")
  151. doAfter(true);
  152. else
  153. doAfter(false);
  154. }
  155. function SubmitWithoutFile() {
  156. if (document.addform.title.value == "") {
  157. alert("请输入文章标题.");
  158. document.addform.title.focus();
  159. return false;
  160. }
  161. addform.isuploadfile.value = "false";
  162. loadDataToWebeditCtrlWithHTMLCode(addform, addform.webedit, document.getElementById("idTemporary").innerHTML);
  163. addform.webedit.UploadMode = 0;
  164. addform.webedit.UploadArticle();
  165. addform.isuploadfile.value = "true";
  166. if (addform.webedit.ReturnMessage == "<%=correct_result%>")
  167. doAfter(true);
  168. else
  169. doAfter(false);
  170. }
  171. function ClearAll() {
  172. document.addform.title.value=""
  173. oEdit1.putHTML(" ");
  174. }
  175. function doAfter(isSucceed) {
  176. if (isSucceed) {
  177. if (op=="edit")
  178. {
  179. if (work=="modify")
  180. location.href = "flow_modify3.jsp?flowId=<%=flowId%>";
  181. else
  182. location.href = "flow_initiate3.jsp?flowId=<%=flowId%>";
  183. }
  184. else {
  185. location.href = "flow_initiate3.jsp?flowId=<%=flowId%>";
  186.     }
  187. }
  188. else {
  189. alert(addform.webedit.ReturnMessage);
  190. }
  191. }
  192. function showvote(isshow)
  193. {
  194. if (addform.isvote.checked)
  195. {
  196. addform.vote.style.display = "";
  197. }
  198. else
  199. {
  200. addform.vote.style.display = "none";
  201. }
  202. }
  203. function selTemplate(id)
  204. {
  205. if (addform.templateId.value!=id) {
  206. addform.templateId.value = id;
  207. // 此处注意当模式对话框的路径在admin下时,退出后本页路径好象被改为admin了
  208. <%if (doc!=null) {%>
  209. window.location.href="<%=Global.getRootPath()%>/flow_initiate2.jsp?op=edit&work=init&flowId=<%=flowId%>&action=selTemplate&id=<%=id%>&dir_code=<%=StrUtil.UrlEncode(dir_code)%>&dir_name=<%=StrUtil.UrlEncode(dir_name)%>&templateId=" + id;
  210. <%}else{%>
  211. if (id!=-1)
  212. window.location.href="<%=Global.getRootPath()%>/flow_initiate2.jsp?op=add&work=init&flowId=<%=flowId%>&action=selTemplate&dir_code=<%=StrUtil.UrlEncode(dir_code)%>&dir_name=<%=StrUtil.UrlEncode(dir_name)%>&templateId=" + id;
  213. <%}%>
  214. }
  215. }
  216. function window_onload() {
  217. }
  218. function createdoc(doc_id)
  219. {
  220. addform.redmoonoffice.AddField("doc_id", doc_id);
  221. addform.redmoonoffice.NewWordDoc();
  222. // EnableAction("SAVE", false); // 在新建文件时,点击保存按钮有时会出错,原因不详,另外,当点击保存时,因为控件支持保存按钮事件的自动上传,这样会自动增加文件,所以此处也应禁止保存按钮
  223. }
  224. function createExcel(doc_id)
  225. {
  226. addform.redmoonoffice.AddField("doc_id", doc_id);
  227. addform.redmoonoffice.NewExcel();
  228. // 因为excel保存时,会响应多次save事件,会导致产生多余的空excel文件
  229. EnableAction("SAVE", false); // 在新建文件时,点击保存按钮有时会出错,原因不详,另外,当点击保存时,因为控件支持保存按钮事件的自动上传,这样会自动增加文件,所以此处也应禁止保存按钮
  230. }
  231. // 控件完成上传后,调用Operate()
  232. function OfficeOperate() {
  233. alert(addform.redmoonoffice.ReturnMessage);
  234. window.location.reload();
  235. }
  236. // 手工上传
  237. function uploaddoc(doc_id) {
  238. addform.redmoonoffice.Clear();
  239. addform.redmoonoffice.AddField("doc_id", doc_id);
  240. addform.redmoonoffice.UploadDoc();
  241. window.location.reload();
  242. // alert(addform.redmoonoffice.ReturnMessage);
  243. }
  244. /* 禁止或使能拷贝、保存等操作
  245.  * action: COPY 或 SAVE
  246.  * isEnabled : true 或 false
  247. */
  248. function EnableAction(action, isEnabled) {
  249. addform.redmoonoffice.EnableAction(action, isEnabled);
  250. }
  251. //-->
  252. </script>
  253. </head>
  254. <body bgcolor="#FFFFFF" text="#000000" onLoad="window_onload()">
  255. <TABLE width="98%" BORDER=0 align="center" CELLPADDING=0 CELLSPACING=0 class="main">
  256.   <TR bgcolor="#FFFFFF">
  257.     <TD colspan="2" class="right-title">&nbsp;&nbsp;
  258.       <%
  259. if (op.equals("add")) {%>
  260. 添加流程
  261. <%}else{%>
  262. 预览表单及上传附件--
  263. <%
  264. Leaf dlf = new Leaf();
  265. if (doc!=null) {
  266. dlf = dlf.getLeaf(doc.getDirCode());
  267. }
  268. if (doc!=null && dlf.getType()==2) {%>
  269. <%=dlf.getName()%>
  270. <%}else{%>
  271. <%=dir_name%>
  272. <%}%>
  273. <%}%>
  274. <%=wfd.getTitle()%></TD>
  275.   </TR>
  276.   <TR valign="top" bgcolor="#FFFFFF">
  277.     <TD width="" height="430" colspan="2" style="background-attachment: fixed; background-image: url(images/bg_bottom.jpg); background-repeat: no-repeat">
  278.           <table border="0" cellspacing="1" width="100%" cellpadding="2" align="center">
  279. <form name="addform" action="fwebedit_do.jsp" method="post">
  280.             
  281.             <tr align="center">
  282.               <td width="100%" colspan="2" align="left" valign="top" class="unnamed2">
  283. <div id="idTemporary" name="idTemporary" style="display:">
  284. <%
  285. String content = doc.getContent(1);
  286. if (!op.equals("add")) {
  287. if (doc!=null) {
  288. if (content.trim().equals("")) {
  289. FormDb rd = new FormDb();
  290. rd = rd.getFormDb(leaf.getFormCode());
  291. out.print(rd.getContent());
  292. }
  293. else {
  294. %>
  295. <%=content%>
  296. <% }
  297. }
  298. }%>
  299. </div>              </td>
  300.             </tr>
  301.             
  302.             <tr>
  303.               <td height="25" colspan=2 align="center" bgcolor="#FFFFFF">
  304.   <%
  305.   if (doc!=null) {
  306.   Vector attachments = doc.getAttachments(1);
  307.   Iterator ir = attachments.iterator();
  308.   while (ir.hasNext()) {
  309.    Attachment am = (Attachment) ir.next(); %>
  310. <table width="82%"  border="0" cellspacing="0" cellpadding="0">
  311.                       <tr>
  312.                         <td width="7%" align="center"><img src=images/attach.gif width="17" height="17"></td>
  313.                         <td width="93%">&nbsp;
  314.                           <input name="attach_name<%=am.getId()%>" value="<%=am.getName()%>" size="30">
  315. &nbsp;<a href="javascript:changeAttachName('<%=am.getId()%>', '<%=doc.getID()%>', '<%="attach_name"+am.getId()%>')">更改</a>                        &nbsp;<a href="javascript:delAttach('<%=am.getId()%>', '<%=doc.getID()%>')">删除</a>&nbsp;&nbsp;<a target=_blank href="flow_getfile.jsp?attachId=<%=am.getId()%>&flowId=<%=flowId%>">查看</a>&nbsp;<a href="?op=edit&id=<%=doc.getID()%>&action=changeAttachOrders&direction=up&attachId=<%=am.getId()%>&flowId=<%=flowId%>"><img src="images/arrow_up.gif" alt="往上" width="16" height="20" border="0" align="absmiddle"></a>&nbsp;<a href="?op=edit&id=<%=doc.getID()%>&action=changeAttachOrders&direction=down&attachId=<%=am.getId()%>&flowId=<%=flowId%>"><img src="images/arrow_down.gif" alt="往下" width="16" height="20" border="0" align="absmiddle"></a></td>
  316.                       </tr>
  317.                 </table>
  318. <%}
  319.   }
  320.   %>   </td>
  321.             </tr>
  322.             <tr>
  323.               <td height="153" colspan=2 align=center bgcolor="#FFFFFF">
  324.   <table  border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
  325.                 <tr>
  326.                   <td bgcolor="#FFFFFF"><%
  327. Calendar cal = Calendar.getInstance();
  328. String year = "" + (cal.get(cal.YEAR));
  329. String month = "" + (cal.get(cal.MONTH) + 1);
  330. com.redmoon.oa.Config cfg = new com.redmoon.oa.Config();
  331. String filepath = cfg.get("file_flow") + "/" + year + "/" + month;
  332. %><object classid="CLSID:DE757F80-F499-48D5-BF39-90BC8BA54D8C" codebase="<%=request.getContextPath()%>/activex/webedit.cab#version=4,0,1,1" width=400 height=173 align="middle" id="webedit">
  333.                       <param name="Encode" value="utf-8">
  334.   <param name="MaxSize" value="<%=Global.MaxSize%>"> <!--上传字节-->
  335.                       <param name="ForeColor" value="(0,255,0)">
  336.                       <param name="BgColor" value="(0,0,0)">
  337.                       <param name="ForeColorBar" value="(255,255,255)">
  338.                       <param name="BgColorBar" value="(0,0,255)">
  339.                       <param name="ForeColorBarPre" value="(0,0,0)">
  340.                       <param name="BgColorBarPre" value="(200,200,200)">
  341.                       <param name="FilePath" value="<%=filepath%>">
  342.                       <param name="Relative" value="1">
  343.                       <!--上传后的文件需放在服务器上的路径-->
  344.                       <param name="Server" value="<%=request.getServerName()%>">
  345.                       <param name="Port" value="<%=request.getServerPort()%>">
  346.                       <param name="VirtualPath" value="<%=Global.virtualPath%>">
  347.                       <param name="PostScript" value="<%=Global.virtualPath%>/flow_initiate2_do.jsp">
  348.                       <param name="PostScriptDdxc" value="<%=Global.virtualPath%>/ddxc.jsp">
  349.                       <param name="SegmentLen" value="204800">
  350.                     </object></td>
  351.                 </tr>
  352.               </table>              </td>
  353.             </tr>
  354.             <tr>
  355.               <td height="30" colspan=2 align=center bgcolor="#FFFFFF">
  356.   <table id="table_create" name="table_create" style="display:none" width="403"  border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#D6D7DE">
  357.                 <tr>
  358.                   <td width="419" align="center" background="images/top-right.gif" class="right-title">撰写文档</td>
  359.                 </tr>
  360.                 <tr>
  361.                   <td align="center" bgcolor="#DBEED9">
  362.   <object id="redmoonoffice" classid="CLSID:D01B1EDF-E803-46FB-B4DC-90F585BC7EEE" 
  363. codebase="<%=request.getContextPath()%>/activex/rmoffice.cab#version=2,0,0,1" width="316" height="43" viewastext="viewastext">
  364.                       <param name="Encode" value="utf-8" />
  365.                       <param name="BackColor" value="0000ff00" />
  366.                       <param name="Server" value="<%=Global.server%>" />
  367.                       <param name="Port" value="<%=Global.port%>" />
  368.                       <!--设置是否自动上传-->
  369.                       <param name="isAutoUpload" value="1" />
  370.                       <!--设置文件大小不超过1M-->
  371.                       <param name="MaxSize" value="1024000" />
  372.                       <!--设置自动上传前出现提示对话框-->
  373.                       <param name="isConfirmUpload" value="1" />
  374.                       <!--设置IE状态栏是否显示信息-->
  375.                       <param name="isShowStatus" value="0" />
  376.                       <param name="PostScript" value="<%=Global.virtualPath%>/flow_document_add.jsp" />
  377.                     </object>
  378.                       <!--<input name="remsg" type="button" onclick='alert(redmoonoffice.ReturnMessage)' value="查看上传后的返回信息" />-->                  </td>
  379.                 </tr>
  380.                 <tr>
  381.                   <td align="center" bgcolor="#DBEED9" height="30">&nbsp;
  382.                       <input name="button" type=button class="singleboarder" onClick="javascript:createdoc('<%=doc.getID()%>')" value=新建Word文件>
  383.                       &nbsp;
  384.                       <input name="button3" type=button class="singleboarder" onClick="javascript:createExcel('<%=doc.getID()%>')" value=新建Excel文件>
  385.                       &nbsp;
  386.                   <input name="button2" type=button class="singleboarder" onClick="javascript:uploaddoc('<%=doc.getID()%>')" value="上传文件"></td></tr>
  387.               </table></td>
  388.             </tr>
  389.             <tr>
  390.               <td height="30" colspan=2 align=center bgcolor="#FFFFFF">
  391.   <input type=button class="singleboarder" value="上一步" onClick="window.location.href='flow_modify1.jsp?flowId=<%=flowId%>'">
  392.   <%
  393.   String action = "";
  394.   if (op.equals("add"))
  395.    action = "添 加";
  396.   else
  397.    action = "下一步";
  398.   %>
  399.   <%if (templateId==-1) {%>
  400.               <!--<input name="cmdok3" type="button" class="singleboarder" value="<%=action%>(单线程)" onClick="return SubmitWithFileThread()">-->
  401.               <%}
  402.   if (templateId==-1) {%>
  403.   <input name="cmdok" type="button" class="singleboarder" value=" <%=action%> " onClick="return SubmitWithFile()">
  404.   <%}%>
  405. <!--&nbsp;
  406. <input name="notuploadfile" type="button" class="singleboarder" value="<%=action%>(不上传图片)" onClick="return SubmitWithoutFile()">
  407. -->&nbsp;&nbsp;
  408. <input name="button22" type=button class="singleboarder" onClick="table_create.style.display=''" value="创建Office文件">
  409. <input type="hidden" name="title" value="<%=wfd.getTitle()%>">
  410. <input type="hidden" name="op" value="<%=op%>">
  411. <input type="hidden" name="dir_code" value="<%=dir_code%>">
  412. <input type="hidden" name="flowId" value="<%=flowId%>">
  413. <input type="hidden" name="examine" value="<%=Document.EXAMINE_PASS%>">
  414. <input type="hidden" name=isuploadfile value="true">
  415. <input type="hidden" name=id value="<%=doc!=null?""+doc.getID():""%>">
  416. </td>
  417.             </tr>
  418.     </form>
  419.         </table>
  420. <table width="100%"  border="0">
  421.           
  422.           <tr>
  423.             <form name="form3" action="?" method="post"><td align="center">
  424. <input name="newname" type="hidden">
  425. </td></form>
  426.           </tr>
  427.         </table> </TD>
  428.   </TR>
  429. </TABLE>
  430. <iframe id="hideframe" name="hideframe" src="fwebedit_do.jsp" width=0 height=0></iframe>
  431. </body>
  432. <script>
  433. function findObj(theObj, theDoc)
  434. {
  435.   var p, i, foundObj;
  436.   
  437.   if(!theDoc) theDoc = document;
  438.   if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  439.   {
  440.     theDoc = parent.frames[theObj.substring(p+1)].document;
  441.     theObj = theObj.substring(0,p);
  442.   }
  443.   if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  444.   for (i=0; !foundObj && i < theDoc.forms.length; i++) 
  445.     foundObj = theDoc.forms[i][theObj];
  446.   for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
  447.     foundObj = findObj(theObj,theDoc.layers[i].document);
  448.   if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  449.   
  450.   return foundObj;
  451. }
  452. function changeAttachName(attach_id, doc_id, nm) {
  453. var obj = findObj(nm);
  454. // document.frames.hideframe.location.href = "fwebedit_do.jsp?op=changeattachname&page_num=1&doc_id=" + doc_id + "&attach_id=" + attach_id + "&newname=" + obj.value
  455. form3.action = "flow_initiate2_do.jsp?op=changeattachname&page_num=1&doc_id=" + doc_id + "&attach_id=" + attach_id;
  456. form3.newname.value = obj.value;
  457. form3.submit();
  458. }
  459. function delAttach(attach_id, doc_id) {
  460. if (!window.confirm("您确定要删除吗?")) {
  461. return;
  462. }
  463. document.frames.hideframe.location.href = "flow_initiate2_do.jsp?op=delAttach&page_num=1&doc_id=" + doc_id + "&attach_id=" + attach_id
  464. }
  465. </script>
  466. </html>