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

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. <link href="cms/default.css" rel="stylesheet" type="text/css">
  14. <%@ include file="inc/nocache.jsp"%>
  15. <jsp:useBean id="strutil" scope="page" class="cn.js.fan.util.StrUtil"/>
  16. <jsp:useBean id="docmanager" scope="page" class="com.redmoon.oa.flow.DocumentMgr"/>
  17. <jsp:useBean id="dir" scope="page" class="com.redmoon.oa.flow.Directory"/>
  18. <%
  19. String dir_code = "";
  20. String dir_name = "";
  21. String flowTitle = ParamUtil.get(request, "flowTitle");
  22. int id = 0;
  23. Privilege privilege = new Privilege();
  24. String correct_result = "操作成功!";
  25. int flowId = ParamUtil.getInt(request, "flowId");
  26. WorkflowDb wfd = new WorkflowDb();
  27. wfd = wfd.getWorkflowDb(flowId);
  28. id = wfd.getDocId();
  29. Document doc = new Document();
  30. doc = doc.getDocument(id);
  31. dir_code = doc.getDirCode();
  32. Document template = null;
  33. Leaf leaf = dir.getLeaf(dir_code);
  34. dir_name = leaf.getName();
  35. String strtemplateId = ParamUtil.get(request, "templateId");
  36. int templateId = Document.NOTEMPLATE;
  37. if (!strtemplateId.trim().equals("")) {
  38. if (StrUtil.isNumeric(strtemplateId))
  39. templateId = Integer.parseInt(strtemplateId);
  40. }
  41. if (templateId==Document.NOTEMPLATE) {
  42. if (leaf!=null)
  43. templateId = leaf.getTemplateId();
  44. }
  45. if (templateId!=Document.NOTEMPLATE) {
  46. template = docmanager.getDocument(templateId);
  47. }
  48. String op = ParamUtil.get(request, "op");
  49. String work = ParamUtil.get(request, "work"); // init modify
  50. if (op.equals("add")) {
  51. String action = ParamUtil.get(request, "action");
  52. if (action.equals("selTemplate")){
  53. int tid = ParamUtil.getInt(request, "templateId");
  54. template = docmanager.getDocument(tid);
  55. }
  56. }
  57. if (op.equals("edit")) {
  58. String action = ParamUtil.get(request, "action");
  59. try {
  60. id = ParamUtil.getInt(request, "id");
  61. doc = docmanager.getDocument(id);
  62. dir_code = doc.getDirCode();
  63. if (action.equals("selTemplate")) {
  64. int tid = ParamUtil.getInt(request, "templateId");
  65. doc.setTemplateId(tid);
  66. doc.updateTemplateId();
  67. }
  68. if (doc!=null) {
  69. template = doc.getTemplate();
  70. }
  71. } catch (ErrMsgException e) {
  72. out.print(strutil.makeErrMsg(e.getMessage(), "red", "green"));
  73. return;
  74. }
  75. if (action.equals("changeAttachOrders")) {
  76. int attachId = ParamUtil.getInt(request, "attachId");
  77. String direction = ParamUtil.get(request, "direction");
  78. // 取得第一页的内容
  79. DocContent dc = new DocContent();
  80. dc = dc.getDocContent(id, 1);
  81. dc.moveAttachment(attachId, direction);
  82. }
  83. }
  84. if (op.equals("editarticle")) {
  85. op = "edit";
  86. try {
  87. doc = docmanager.getDocumentByCode(request, dir_code, privilege);
  88. dir_code = doc.getDirCode();
  89. } catch (ErrMsgException e) {
  90. out.print(strutil.makeErrMsg(e.getMessage(),"red", "green"));
  91. return;
  92. }
  93. }
  94. if (doc!=null) {
  95. id = doc.getID();
  96. Leaf lfn = new Leaf();
  97. lfn = lfn.getLeaf(doc.getDirCode());
  98. dir_name = lfn.getName();
  99. }
  100. %>
  101. <title><%=doc!=null?doc.getTitle():""%></title>
  102. <style type="text/css">
  103. <!--
  104. td {  font-family: "Arial", "Helvetica", "sans-serif"; font-size: 14px; font-style: normal; line-height: 150%; font-weight: normal}
  105. .style2 {color: #FF3300}
  106. -->
  107. </style>
  108. <script language=JavaScript src='scripts/formpost.js'></script>
  109. <script language="JavaScript">
  110. <!--
  111. <%
  112. if (doc!=null) {
  113. out.println("var id=" + doc.getID() + ";");
  114. }
  115. %>
  116. var op = "<%=op%>";
  117. var work = "<%=work%>";
  118. function SubmitWithFileDdxc() {
  119. addform.webedit.isDdxc = 1;
  120. if (document.addform.title.value.length == 0) {
  121. alert("请输入文章标题.");
  122. document.addform.title.focus();
  123. return false;
  124. }
  125. loadDataToWebeditCtrl(addform, addform.webedit);
  126. addform.webedit.MTUpload();
  127. // 因为Upload()中启用了线程的,所以函数在执行后,会立即反回,使得下句中得不到ReturnMessage的值
  128. // 原因是此时服务器的返回信息还没收到
  129. // alert("ReturnMessage=" + addform.webedit.ReturnMessage);
  130. }
  131. function SubmitWithFileThread() {
  132. if (document.addform.title.value.length == 0) {
  133. alert("请输入文章标题.");
  134. document.addform.title.focus();
  135. return false;
  136. }
  137. loadDataToWebeditCtrl(addform, addform.webedit);
  138. addform.webedit.Upload();
  139. // 因为Upload()中启用了线程的,所以函数在执行后,会立即反回,使得下句中得不到ReturnMessage的值
  140. // 原因是此时服务器的返回信息还没收到
  141. // alert("ReturnMessage=" + addform.webedit.ReturnMessage);
  142. }
  143. function SubmitWithFile(){
  144. if (document.addform.title.value.length == 0) {
  145. alert("请输入文章标题.");
  146. document.addform.title.focus();
  147. return false;
  148. }
  149. loadDataToWebeditCtrl(addform, addform.webedit);
  150. addform.webedit.UploadArticle();
  151. if (addform.webedit.ReturnMessage == "<%=correct_result%>")
  152. doAfter(true);
  153. else
  154. doAfter(false);
  155. }
  156. function SubmitWithoutFile() {
  157. if (document.addform.title.value.length == 0) {
  158. alert("请输入文章标题.");
  159. document.addform.title.focus();
  160. return false;
  161. }
  162. addform.isuploadfile.value = "false";
  163. loadDataToWebeditCtrl(addform, addform.webedit);
  164. addform.webedit.UploadMode = 0;
  165. addform.webedit.UploadArticle();
  166. addform.isuploadfile.value = "true";
  167. if (addform.webedit.ReturnMessage == "<%=correct_result%>")
  168. doAfter(true);
  169. else
  170. doAfter(false);
  171. }
  172. function ClearAll() {
  173. document.addform.title.value=""
  174. oEdit1.putHTML(" ");
  175. }
  176. function doAfter(isSucceed) {
  177. if (isSucceed) {
  178. if (op=="edit")
  179. {
  180. if (work=="modify")
  181. location.href = "flow_modify3.jsp?flowId=<%=flowId%>";
  182. else
  183. location.href = "flow_initiate3.jsp?flowId=<%=flowId%>";
  184. }
  185. else {
  186. location.href = "flow_initiate3.jsp?flowId=<%=flowId%>";
  187.     }
  188. }
  189. else {
  190. alert(addform.webedit.ReturnMessage);
  191. }
  192. }
  193. function showvote(isshow)
  194. {
  195. if (addform.isvote.checked)
  196. {
  197. addform.vote.style.display = "";
  198. }
  199. else
  200. {
  201. addform.vote.style.display = "none";
  202. }
  203. }
  204. function selTemplate(id)
  205. {
  206. if (addform.templateId.value!=id) {
  207. addform.templateId.value = id;
  208. // 此处注意当模式对话框的路径在admin下时,退出后本页路径好象被改为admin了
  209. <%if (doc!=null) {%>
  210. 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;
  211. <%}else{%>
  212. if (id!=-1)
  213. 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;
  214. <%}%>
  215. }
  216. }
  217. //-->
  218. </script>
  219. <script language=JavaScript src='scripts/language/schi/editor_lang.js'></script>
  220. <%
  221. if (request.getHeader("User-Agent").indexOf("MSIE")!=-1){
  222. out.println("<script language=JavaScript src='scripts/editor.js'></script>");
  223. }
  224. else{
  225. out.println("<script language=JavaScript src='scripts/moz/editor.js'></script>");
  226. }
  227. %>
  228. </head>
  229. <body bgcolor="#FFFFFF" text="#000000">
  230. <TABLE width="98%" BORDER=0 align="center" CELLPADDING=0 CELLSPACING=0>
  231.   <TR valign="top" bgcolor="#FFFFFF">
  232.     <TD width="" height="430" colspan="2" style="background-attachment: fixed; background-image: url(images/bg_bottom.jpg); background-repeat: no-repeat">
  233.           <TABLE cellSpacing=0 cellPadding=0 width="100%">
  234.             <TBODY>
  235.               <TR>
  236.                 <TD class=head>
  237. <%
  238. if (op.equals("add")) {%>
  239. 添加流程
  240. <%}else{%>
  241. 修改--
  242. <%
  243. Leaf dlf = new Leaf();
  244. if (doc!=null) {
  245. dlf = dlf.getLeaf(doc.getDirCode());
  246. }
  247. if (doc!=null && dlf.getType()==2) {%>
  248. <a href="cms/document_list_m.jsp?dir_code=<%=StrUtil.UrlEncode(dir_code)%>&dir_name=<%=StrUtil.UrlEncode(dir_name)%>"><%=dlf.getName()%></a>
  249. <%}else{%>
  250. <%=dir_name%>
  251. <%}%>
  252. <%}%>
  253. </TD>
  254.               </TR>
  255.             </TBODY>
  256.           </TABLE>
  257. <form name="addform" action="/admin/fwebedit_do.jsp" method="post">
  258.           <table border="0" cellspacing="1" width="100%" cellpadding="2" align="center">
  259.             <tr align="center" bgcolor="#F2F2F2">
  260.               <td height="20" colspan=2 align=center><b><%=doc!=null?doc.getTitle():""%></b>&nbsp;<input type="hidden" name=isuploadfile value="true">
  261.   <input type="hidden" name=id value="<%=doc!=null?""+doc.getID():""%>"> </td>
  262.             </tr>
  263.             
  264.             <tr>
  265.               <td align="left" valign="middle" bgcolor="#F2F2F2" class="unnamed2"><span class="p14">流程类型</span>:</td>
  266.               <td bgcolor="#F2F2F2"><span class="p14">
  267.                 <%=dir_name%>
  268.               </span></td>
  269.             </tr>
  270.             <tr>
  271.               <td align="left" class="unnamed2" valign="middle">名&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;称:</td>
  272.               <td width="90%" bgcolor="#FFFFFF">
  273.                   <%=wfd.getTitle()%>
  274.                   <input type="hidden" name="op" value="<%=op%>">
  275.               <input type="hidden" name="title" value="<%=wfd.getTitle()%>">
  276.               <input type="hidden" name="dir_code" value="<%=dir_code%>">
  277.   <input type="hidden" name="flowId" value="<%=flowId%>">
  278.   <input type="hidden" name="examine" value="<%=Document.EXAMINE_PASS%>"></td>
  279.             </tr>
  280.             <tr align="center">
  281.               <td colspan="2" valign="top" bgcolor="#F2F2F2" class="unnamed2">
  282. <pre id="idTemporary" name="idTemporary" style="display:none">
  283. <%
  284. if (!op.equals("add")) {
  285. if (doc!=null) {
  286. if (doc.getContent(1).trim().equals("")) {
  287. FormDb rd = new FormDb();
  288. rd = rd.getFormDb(leaf.getFormCode());
  289. out.print(rd.getContent());
  290. }
  291. else {
  292. %>
  293. <%=strutil.HTMLEncode(strutil.getNullString(doc.getContent(1)))%>
  294. <% }
  295. }
  296. }%>
  297. </pre>
  298. <pre id="divTemplate" name="divTemplate" style="display:none">
  299. <%if (template!=null) {%>
  300. <%=template.getContent(1)%>
  301. <%}%>
  302. </pre>
  303.  <script>
  304. var oEdit1 = new InnovaEditor("oEdit1");
  305. oEdit1.width="100%";
  306. oEdit1.height="500";
  307. oEdit1.features=["FullScreen","Preview","Print","Search","SpellCheck",
  308. "Cut","Copy","Paste","PasteWord","PasteText","|","Undo","Redo","|",
  309. "ForeColor","BackColor","|","Bookmark","Hyperlink",
  310. "HTMLFullSource","HTMLSource","XHTMLFullSource",
  311. "XHTMLSource","BRK","Numbering","Bullets","|","Indent","Outdent","LTR","RTL","|","Image","Flash","Media","|","InternalLink","CustomObject","|",
  312. "Table","Guidelines","Absolute","|","Characters","Line",
  313. "Form","Clean","ClearAll","BRK",
  314. "StyleAndFormatting","TextFormatting","ListFormatting","BoxFormatting",
  315. "ParagraphFormatting","CssText","Styles","|",
  316. "Paragraph","FontName","FontSize","|",
  317. "Bold","Italic",
  318. "Underline","Strikethrough","|","Superscript","Subscript","|",
  319. "JustifyLeft","JustifyCenter","JustifyRight","JustifyFull"]; 
  320. <%if (templateId!=-1) {%>
  321. oEdit1.RENDER(document.getElementById("divTemplate").innerHTML);
  322. <%}else{%>
  323. oEdit1.RENDER(document.getElementById("idTemporary").innerHTML);
  324. <%}%>
  325. </script>            </td>
  326.             </tr>
  327.             <tr>
  328.               <td width="10%" align="right" bgcolor="#FFFFFF">提示:</td>
  329.               <td bgcolor="#FFFFFF">
  330.   回车可用Shift+Enter   </td>
  331.             </tr>
  332.             <tr>
  333.               <td height="25" colspan=2 align="center" bgcolor="#FFFFFF">
  334.   <%
  335.   if (doc!=null) {
  336.   Vector attachments = doc.getAttachments(1);
  337.   Iterator ir = attachments.iterator();
  338.   while (ir.hasNext()) {
  339.    Attachment am = (Attachment) ir.next(); %>
  340. <table width="98%"  border="0" cellspacing="0" cellpadding="0">
  341.                       <tr>
  342.                         <td width="7%" align="center"><img src=images/attach.gif width="17" height="17"></td>
  343.                         <td width="93%">&nbsp;
  344.                           <input name="attach_name<%=am.getId()%>" value="<%=am.getName()%>" size="30">
  345. &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="<%=am.getVisualPath() + "/" + am.getDiskName()%>">查看</a>&nbsp;<a href="?op=edit&id=<%=doc.getID()%>&action=changeAttachOrders&direction=up&attachId=<%=am.getId()%>"><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()%>"><img src="images/arrow_down.gif" alt="往下" width="16" height="20" border="0" align="absmiddle"></a></td>
  346.                       </tr>
  347.                     </table>
  348. <%}
  349.   }
  350.   %>   </td>
  351.             </tr>
  352.             <tr>
  353.               <td height="153" colspan=2 align=center bgcolor="#FFFFFF">
  354.   <table  border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
  355.                 <tr>
  356.                   <td bgcolor="#FFFFFF"><%
  357. Calendar cal = Calendar.getInstance();
  358. String year = "" + (cal.get(cal.YEAR));
  359. String month = "" + (cal.get(cal.MONTH) + 1);
  360. String filepath = "upfile/document/" + year + "/" + month;
  361. %><object classid="CLSID:DE757F80-F499-48D5-BF39-90BC8BA54D8C" codebase="<%=request.getContextPath()%>/activex/webedit.cab#version=4,0,1,1" width=400 height=280 align="middle" id="webedit">
  362.                       <param name="Encode" value="utf-8">
  363.   <param name="MaxSize" value="<%=Global.MaxSize%>"> <!--上传字节-->
  364.                       <param name="ForeColor" value="(0,255,0)">
  365.                       <param name="BgColor" value="(0,0,0)">
  366.                       <param name="ForeColorBar" value="(255,255,255)">
  367.                       <param name="BgColorBar" value="(0,0,255)">
  368.                       <param name="ForeColorBarPre" value="(0,0,0)">
  369.                       <param name="BgColorBarPre" value="(200,200,200)">
  370.                       <param name="FilePath" value="<%=filepath%>">
  371.                       <param name="Relative" value="1">
  372.                       <!--上传后的文件需放在服务器上的路径-->
  373.                       <param name="Server" value="<%=request.getServerName()%>">
  374.                       <param name="Port" value="<%=request.getServerPort()%>">
  375.                       <param name="VirtualPath" value="<%=Global.virtualPath%>">
  376.                       <param name="PostScript" value="<%=Global.virtualPath%>/flow_initiate2_do.jsp">
  377.                       <param name="PostScriptDdxc" value="<%=Global.virtualPath%>/ddxc.jsp">
  378.                       <param name="SegmentLen" value="204800">
  379.                     </object></td>
  380.                 </tr>
  381.               </table>              </td>
  382.             </tr>
  383.             <tr>
  384.               <td height="30" colspan=2 align=center bgcolor="#FFFFFF">
  385.   <input type=button class="singleboarder" value="上一步" onClick="window.location.href='flow_modify1.jsp?flowId=<%=flowId%>'">
  386.   <%
  387.   String action = "";
  388.   if (op.equals("add"))
  389.    action = "添 加";
  390.   else
  391.    action = "下一步";
  392.   %>
  393.   <%if (templateId==-1) {%>
  394.               <!--<input name="cmdok3" type="button" class="singleboarder" value="<%=action%>(单线程)" onClick="return SubmitWithFileThread()">-->
  395.               <%}
  396.   if (templateId==-1) {%>
  397.   <input name="cmdok" type="button" class="singleboarder" value=" <%=action%> " onClick="return SubmitWithFile()">
  398.   <%}%>
  399. &nbsp;
  400. <input name="notuploadfile" type="button" class="singleboarder" value="<%=action%>(不上传图片)" onClick="return SubmitWithoutFile()">
  401. &nbsp;
  402.       <input name="cmdcancel" type="button" class="singleboarder" onClick="ClearAll()" value=" 清 空 ">
  403. &nbsp;
  404. &nbsp;
  405. <input name="remsg" type="button" class="singleboarder" onClick='alert(webedit.ReturnMessage)' value="返回信息">
  406. &nbsp;</td>
  407.             </tr>
  408.         </table>
  409.     </form>
  410. <table width="100%"  border="0">
  411.           
  412.           <tr>
  413.             <form name="form3" action="?" method="post"><td align="center">
  414. <input name="newname" type="hidden">
  415. </td></form>
  416.           </tr>
  417.         </table>
  418. </TD>
  419.   </TR>
  420. </TABLE>
  421. <iframe id="hideframe" name="hideframe" src="fwebedit_do.jsp" width=0 height=0></iframe>
  422. </body>
  423. <script>
  424. function findObj(theObj, theDoc)
  425. {
  426.   var p, i, foundObj;
  427.   
  428.   if(!theDoc) theDoc = document;
  429.   if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  430.   {
  431.     theDoc = parent.frames[theObj.substring(p+1)].document;
  432.     theObj = theObj.substring(0,p);
  433.   }
  434.   if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  435.   for (i=0; !foundObj && i < theDoc.forms.length; i++) 
  436.     foundObj = theDoc.forms[i][theObj];
  437.   for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
  438.     foundObj = findObj(theObj,theDoc.layers[i].document);
  439.   if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  440.   
  441.   return foundObj;
  442. }
  443. function changeAttachName(attach_id, doc_id, nm) {
  444. var obj = findObj(nm);
  445. // document.frames.hideframe.location.href = "fwebedit_do.jsp?op=changeattachname&page_num=1&doc_id=" + doc_id + "&attach_id=" + attach_id + "&newname=" + obj.value
  446. form3.action = "fwebedit_do.jsp?op=changeattachname&page_num=1&doc_id=" + doc_id + "&attach_id=" + attach_id;
  447. form3.newname.value = obj.value;
  448. form3.submit();
  449. }
  450. function delAttach(attach_id, doc_id) {
  451. if (!window.confirm("您确定要删除吗?")) {
  452. return;
  453. }
  454. document.frames.hideframe.location.href = "fwebedit_do.jsp?op=delAttach&page_num=1&doc_id=" + doc_id + "&attach_id=" + attach_id
  455. }
  456. </script>
  457. </html>