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

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. loadDataToWebeditCtrl(addform, addform.webedit);
  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. loadDataToWebeditCtrl(addform, addform.webedit);
  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. loadDataToWebeditCtrl(addform, addform.webedit);
  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. loadDataToWebeditCtrl(addform, addform.webedit);
  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. cws_Size(320);
  218. }
  219. function createdoc(doc_id)
  220. {
  221. addform.redmoonoffice.AddField("doc_id", doc_id);
  222. addform.redmoonoffice.NewWordDoc();
  223. // EnableAction("SAVE", false); // 在新建文件时,点击保存按钮有时会出错,原因不详,另外,当点击保存时,因为控件支持保存按钮事件的自动上传,这样会自动增加文件,所以此处也应禁止保存按钮
  224. }
  225. function createExcel(doc_id)
  226. {
  227. addform.redmoonoffice.AddField("doc_id", doc_id);
  228. addform.redmoonoffice.NewExcel();
  229. // 因为excel保存时,会响应多次save事件,会导致产生多余的空excel文件
  230. EnableAction("SAVE", false); // 在新建文件时,点击保存按钮有时会出错,原因不详,另外,当点击保存时,因为控件支持保存按钮事件的自动上传,这样会自动增加文件,所以此处也应禁止保存按钮
  231. }
  232. // 控件完成上传后,调用Operate()
  233. function OfficeOperate() {
  234. alert(addform.redmoonoffice.ReturnMessage);
  235. window.location.reload();
  236. }
  237. // 手工上传
  238. function uploaddoc(doc_id) {
  239. addform.redmoonoffice.Clear();
  240. addform.redmoonoffice.AddField("doc_id", doc_id);
  241. addform.redmoonoffice.UploadDoc();
  242. window.location.reload();
  243. // alert(addform.redmoonoffice.ReturnMessage);
  244. }
  245. /* 禁止或使能拷贝、保存等操作
  246.  * action: COPY 或 SAVE
  247.  * isEnabled : true 或 false
  248. */
  249. function EnableAction(action, isEnabled) {
  250. addform.redmoonoffice.EnableAction(action, isEnabled);
  251. }
  252. //-->
  253. </script>
  254. </head>
  255. <body bgcolor="#FFFFFF" text="#000000" onLoad="window_onload()">
  256. <TABLE width="98%" BORDER=0 align="center" CELLPADDING=0 CELLSPACING=0 class="main">
  257.   <TR bgcolor="#FFFFFF">
  258.     <TD colspan="2" class="right-title">&nbsp;&nbsp;
  259.       <%
  260. if (op.equals("add")) {%>
  261. 添加流程
  262. <%}else{%>
  263. 修改表单--
  264. <%
  265. Leaf dlf = new Leaf();
  266. if (doc!=null) {
  267. dlf = dlf.getLeaf(doc.getDirCode());
  268. }
  269. if (doc!=null && dlf.getType()==2) {%>
  270. <%=dlf.getName()%>
  271. <%}else{%>
  272. <%=dir_name%>
  273. <%}%>
  274. <%}%>
  275. <%=wfd.getTitle()%></TD>
  276.   </TR>
  277.   <TR valign="top" bgcolor="#FFFFFF">
  278.     <TD width="" height="430" colspan="2" style="background-attachment: fixed; background-image: url(images/bg_bottom.jpg); background-repeat: no-repeat">
  279.           <table border="0" cellspacing="1" width="100%" cellpadding="2" align="center">
  280. <form name="addform" action="fwebedit_do.jsp" method="post">
  281.             
  282.             <tr align="center">
  283.               <td colspan="2" align="left" valign="top" bgcolor="#F2F2F2" class="unnamed2">
  284. <div id="idTemporary" name="idTemporary" style="display:none">
  285. <%
  286. String content = doc.getContent(1);
  287. if (!op.equals("add")) {
  288. if (doc!=null) {
  289. if (content.trim().equals("")) {
  290. FormDb rd = new FormDb();
  291. rd = rd.getFormDb(leaf.getFormCode());
  292. out.print(rd.getContent());
  293. }
  294. else {
  295. %>
  296. <%=content%>
  297. <% }
  298. }
  299. }%>
  300. </div>
  301. <div id="divTemplate" name="divTemplate" style="display:none">
  302. <%if (template!=null) {
  303. content = template.getContent(1);
  304. %>
  305. <%=content%>
  306. <%}%>
  307. </div>
  308. <%@ include file="editor_full/editor.jsp"%>
  309. <script>
  310. <%if (templateId!=-1) {%>
  311. setHTML(document.getElementById("divTemplate").innerHTML);
  312. <%}else{%>
  313. // alert(document.getElementById("idTemporary").innerHTML);
  314. setHTML(document.getElementById("idTemporary").innerHTML);
  315. <%}%>
  316. </script>              </td>
  317.             </tr>
  318.             <tr>
  319.               <td width="10%" align="right" bgcolor="#FFFFFF">提示:</td>
  320.               <td width="90%" bgcolor="#FFFFFF">
  321.   回车可用Shift+Enter   </td>
  322.             </tr>
  323.             <tr>
  324.               <td height="25" colspan=2 align="center" bgcolor="#FFFFFF">
  325.   <%
  326.   if (doc!=null) {
  327.   Vector attachments = doc.getAttachments(1);
  328.   Iterator ir = attachments.iterator();
  329.   while (ir.hasNext()) {
  330.    Attachment am = (Attachment) ir.next(); %>
  331. <table width="98%"  border="0" cellspacing="0" cellpadding="0">
  332.                       <tr>
  333.                         <td width="7%" align="center"><img src=images/attach.gif width="17" height="17"></td>
  334.                         <td width="93%">&nbsp;
  335.                           <input name="attach_name<%=am.getId()%>" value="<%=am.getName()%>" size="30">
  336. &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>
  337.                       </tr>
  338.                     </table>
  339. <%}
  340.   }
  341.   %>   </td>
  342.             </tr>
  343.             <tr>
  344.               <td height="153" colspan=2 align=center bgcolor="#FFFFFF">
  345.   <table  border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
  346.                 <tr>
  347.                   <td bgcolor="#FFFFFF"><%
  348. Calendar cal = Calendar.getInstance();
  349. String year = "" + (cal.get(cal.YEAR));
  350. String month = "" + (cal.get(cal.MONTH) + 1);
  351. com.redmoon.oa.Config cfg = new com.redmoon.oa.Config();
  352. String filepath = cfg.get("file_flow") + "/" + year + "/" + month;
  353. %><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">
  354.                       <param name="Encode" value="utf-8">
  355.   <param name="MaxSize" value="<%=Global.MaxSize%>"> <!--上传字节-->
  356.                       <param name="ForeColor" value="(0,255,0)">
  357.                       <param name="BgColor" value="(0,0,0)">
  358.                       <param name="ForeColorBar" value="(255,255,255)">
  359.                       <param name="BgColorBar" value="(0,0,255)">
  360.                       <param name="ForeColorBarPre" value="(0,0,0)">
  361.                       <param name="BgColorBarPre" value="(200,200,200)">
  362.                       <param name="FilePath" value="<%=filepath%>">
  363.                       <param name="Relative" value="1">
  364.                       <!--上传后的文件需放在服务器上的路径-->
  365.                       <param name="Server" value="<%=request.getServerName()%>">
  366.                       <param name="Port" value="<%=request.getServerPort()%>">
  367.                       <param name="VirtualPath" value="<%=Global.virtualPath%>">
  368.                       <param name="PostScript" value="<%=Global.virtualPath%>/flow_initiate2_do.jsp">
  369.                       <param name="PostScriptDdxc" value="<%=Global.virtualPath%>/ddxc.jsp">
  370.                       <param name="SegmentLen" value="204800">
  371.                     </object></td>
  372.                 </tr>
  373.               </table>              </td>
  374.             </tr>
  375.             <tr>
  376.               <td height="30" colspan=2 align=center bgcolor="#FFFFFF">
  377.   <table id="table_create" name="table_create" style="display:none" width="403"  border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#D6D7DE">
  378.                 <tr>
  379.                   <td width="419" align="center" background="images/top-right.gif" class="right-title">撰写文档</td>
  380.                 </tr>
  381.                 <tr>
  382.                   <td align="center" bgcolor="#DBEED9">
  383.   <object id="redmoonoffice" classid="CLSID:D01B1EDF-E803-46FB-B4DC-90F585BC7EEE" 
  384. codebase="<%=request.getContextPath()%>/activex/rmoffice.cab#version=2,0,0,1" width="316" height="43" viewastext="viewastext">
  385.                       <param name="Encode" value="utf-8" />
  386.                       <param name="BackColor" value="0000ff00" />
  387.                       <param name="Server" value="<%=Global.server%>" />
  388.                       <param name="Port" value="<%=Global.port%>" />
  389.                       <!--设置是否自动上传-->
  390.                       <param name="isAutoUpload" value="1" />
  391.                       <!--设置文件大小不超过1M-->
  392.                       <param name="MaxSize" value="1024000" />
  393.                       <!--设置自动上传前出现提示对话框-->
  394.                       <param name="isConfirmUpload" value="1" />
  395.                       <!--设置IE状态栏是否显示信息-->
  396.                       <param name="isShowStatus" value="0" />
  397.                       <param name="PostScript" value="<%=Global.virtualPath%>/flow_document_add.jsp" />
  398.                     </object>
  399.                       <!--<input name="remsg" type="button" onclick='alert(redmoonoffice.ReturnMessage)' value="查看上传后的返回信息" />-->                  </td>
  400.                 </tr>
  401.                 <tr>
  402.                   <td align="center" bgcolor="#DBEED9" height="30">&nbsp;
  403.                       <input name="button" type=button class="singleboarder" onClick="javascript:createdoc('<%=doc.getID()%>')" value=新建Word文件>
  404.                       &nbsp;
  405.                       <input name="button3" type=button class="singleboarder" onClick="javascript:createExcel('<%=doc.getID()%>')" value=新建Excel文件>
  406.                       &nbsp;
  407.                   <input name="button2" type=button class="singleboarder" onClick="javascript:uploaddoc('<%=doc.getID()%>')" value="上传文件"></td></tr>
  408.               </table></td>
  409.             </tr>
  410.             <tr>
  411.               <td height="30" colspan=2 align=center bgcolor="#FFFFFF">
  412.   <input type=button class="singleboarder" value="上一步" onClick="window.location.href='flow_modify1.jsp?flowId=<%=flowId%>'">
  413.   <%
  414.   String action = "";
  415.   if (op.equals("add"))
  416.    action = "添 加";
  417.   else
  418.    action = "下一步";
  419.   %>
  420.   <%if (templateId==-1) {%>
  421.               <!--<input name="cmdok3" type="button" class="singleboarder" value="<%=action%>(单线程)" onClick="return SubmitWithFileThread()">-->
  422.               <%}
  423.   if (templateId==-1) {%>
  424.   <input name="cmdok" type="button" class="singleboarder" value=" <%=action%> " onClick="return SubmitWithFile()">
  425.   <%}%>
  426. &nbsp;
  427. <input name="notuploadfile" type="button" class="singleboarder" value="<%=action%>(不上传图片)" onClick="return SubmitWithoutFile()">
  428. &nbsp;&nbsp;
  429. <input name="button22" type=button class="singleboarder" onClick="table_create.style.display=''" value="创建文件">
  430. <input type="hidden" name="title" value="<%=wfd.getTitle()%>">
  431. <input type="hidden" name="op" value="<%=op%>">
  432. <input type="hidden" name="dir_code" value="<%=dir_code%>">
  433. <input type="hidden" name="flowId" value="<%=flowId%>">
  434. <input type="hidden" name="examine" value="<%=Document.EXAMINE_PASS%>">
  435. <input type="hidden" name=isuploadfile value="true">
  436. <input type="hidden" name=id value="<%=doc!=null?""+doc.getID():""%>"></td>
  437.             </tr>
  438.     </form>
  439.         </table>
  440. <table width="100%"  border="0">
  441.           
  442.           <tr>
  443.             <form name="form3" action="?" method="post"><td align="center">
  444. <input name="newname" type="hidden">
  445. </td></form>
  446.           </tr>
  447.         </table> </TD>
  448.   </TR>
  449. </TABLE>
  450. <iframe id="hideframe" name="hideframe" src="fwebedit_do.jsp" width=0 height=0></iframe>
  451. </body>
  452. <script>
  453. function findObj(theObj, theDoc)
  454. {
  455.   var p, i, foundObj;
  456.   
  457.   if(!theDoc) theDoc = document;
  458.   if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  459.   {
  460.     theDoc = parent.frames[theObj.substring(p+1)].document;
  461.     theObj = theObj.substring(0,p);
  462.   }
  463.   if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  464.   for (i=0; !foundObj && i < theDoc.forms.length; i++) 
  465.     foundObj = theDoc.forms[i][theObj];
  466.   for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
  467.     foundObj = findObj(theObj,theDoc.layers[i].document);
  468.   if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  469.   
  470.   return foundObj;
  471. }
  472. function changeAttachName(attach_id, doc_id, nm) {
  473. var obj = findObj(nm);
  474. // document.frames.hideframe.location.href = "fwebedit_do.jsp?op=changeattachname&page_num=1&doc_id=" + doc_id + "&attach_id=" + attach_id + "&newname=" + obj.value
  475. form3.action = "flow_initiate2_do.jsp?op=changeattachname&page_num=1&doc_id=" + doc_id + "&attach_id=" + attach_id;
  476. form3.newname.value = obj.value;
  477. form3.submit();
  478. }
  479. function delAttach(attach_id, doc_id) {
  480. if (!window.confirm("您确定要删除吗?")) {
  481. return;
  482. }
  483. document.frames.hideframe.location.href = "flow_initiate2_do.jsp?op=delAttach&page_num=1&doc_id=" + doc_id + "&attach_id=" + attach_id
  484. }
  485. </script>
  486. </html>