Documenteditor.js 97 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066
  1. MWF.xDesktop.requireApp("process.Xform", "$Module", null, false);
  2. MWF.xApplication.process.Xform.Documenteditor = MWF.APPDocumenteditor = new Class({
  3. Extends: MWF.APP$Module,
  4. options: {
  5. "moduleEvents": ["load", "queryLoad", "beforeLoad", "postLoad", "afterLoad"],
  6. "docPageHeight": 850.4,
  7. "docPageFullWidth": 794,
  8. "pageShow": "single"
  9. },
  10. initialize: function(node, json, form, options){
  11. this.node = $(node);
  12. this.node.store("module", this);
  13. this.json = json;
  14. this.form = form;
  15. this.field = true;
  16. },
  17. _loadCss: function(reload){
  18. var key = encodeURIComponent(this.cssPath);
  19. if (!reload && o2.widget.css[key]){
  20. this.css = o2.widget.css[key];
  21. }else{
  22. this.cssPath = (this.cssPath.indexOf("?")!=-1) ? this.cssPath+"&v="+o2.version.v : this.cssPath+"?v="+o2.version.v;
  23. var r = new Request.JSON({
  24. url: this.cssPath,
  25. secure: false,
  26. async: false,
  27. method: "get",
  28. noCache: false,
  29. onSuccess: function(responseJSON, responseText){
  30. this.css = responseJSON;
  31. o2.widget.css[key] = responseJSON;
  32. }.bind(this),
  33. onError: function(text, error){
  34. console.log(error + text);
  35. }
  36. });
  37. r.send();
  38. }
  39. },
  40. load: function(){
  41. this._loadModuleEvents();
  42. if (this.fireEvent("queryLoad")){
  43. this.fireEvent("beforeLoad");
  44. this.cssPath = this.form.path+this.form.options.style+"/doc.wcss";
  45. this._loadCss();
  46. this._queryLoaded();
  47. this._loadUserInterface(function(){
  48. this.fireEvent("postLoad");
  49. this.fireEvent("afterLoad");
  50. this.fireEvent("load");
  51. this.form.app.addEvent("resize", function(){
  52. // if (this.options.pageShow!=="double"){
  53. // this._doublePage();
  54. // }else{
  55. this._singlePage();
  56. // }
  57. this._checkScale();
  58. }.bind(this));
  59. }.bind(this));
  60. this._loadStyles();
  61. this._afterLoaded();
  62. }
  63. },
  64. _createNewPage: function(){
  65. var pageNode = new Element("div.doc_layout_page", {"styles": this.css.doc_page}).inject(this.contentNode);
  66. var pageContentNode = new Element("div.doc_layout_page_content", {"styles": this.css.doc_layout_page_content}).inject(pageNode);
  67. pageNode.set("data-pagecount", this.pages.length+1);
  68. this.pages.push(pageNode);
  69. return pageNode;
  70. },
  71. _getShow: function(name, typeItem, scriptItem){
  72. switch (this.json[typeItem]) {
  73. case "y":
  74. return true;
  75. case "n":
  76. return false;
  77. case "a":
  78. if (["copies", "secret", "priority", "attachment", "annotation", "copyto", "copyto2"].indexOf(name!=-1)){
  79. return !!this.data[name] && (!!this.data[name].length);
  80. }
  81. return true;
  82. case "s":
  83. if (this.json[scriptItem] && this.json[scriptItem].code){
  84. return !!this.form.Macro.exec(this.json[scriptItem].code, this);
  85. }
  86. return true;
  87. }
  88. },
  89. _createPage: function(callback){
  90. debugger;
  91. var pageContentNode = this._createNewPage().getFirst();
  92. // var html = '<div class="doc_block doc_layout_copiesSecretPriority">';
  93. // if (this._getShow("copies", "copiesShow", "copiesShowScript")) html += ' <div class="doc_layout_copies"></div>';
  94. // if (this._getShow("secret", "secretShow", "secretShowScript")) html += ' <div class="doc_layout_secret"></div>';
  95. // if (this._getShow("priority", "priorityShow", "priorityShowScript")) html += ' <div class="doc_layout_priority"></div>';
  96. // html += '</div>'
  97. // if (this._getShow("redHeader", "redHeaderShow", "redHeaderShowScript")) html += '<div class="doc_block doc_layout_redHeader"></div>';
  98. //
  99. // if (this._getShow("signer", "signerShow", "signerShowScript")){
  100. // this.json.fileup = true;
  101. // html += '<table class="doc_block doc_layout_filenoup" width="100%" cellpadding="0" cellspacing="0" border="0">' +
  102. // '<tr><td class="doc_layout_filenoup_fileno_td">';
  103. // if (this._getShow("fileno", "filenoShow", "filenoShowScript")) html += ' <span> </span><span class="doc_layout_filenoup_fileno"></span>';
  104. //
  105. // html += ' </td><td class="doc_layout_filenoup_signer_td">' +
  106. // ' <table class="doc_layout_filenoup_signer_table" cellpadding="0" cellspacing="0" border="0">' +
  107. // ' <tr><td class="doc_layout_filenoup_signerTitle_td">'+
  108. // ' <span class="doc_layout_filenoup_signer"></span>' +
  109. // ' </td><td class="doc_layout_filenoup_signerContent_td">' +
  110. // ' <span class="doc_layout_filenoup_signerContent"></span><span> </span>' +
  111. // ' </td></tr>' +
  112. // ' </table>' +
  113. // ' </td></tr>' +
  114. // '</table>';
  115. // }else{
  116. // if (this._getShow("fileno", "filenoShow", "filenoShowScript")) html += '<div class=\"doc_block doc_layout_fileno\"></div>';
  117. // }
  118. // html += "<div color=\"#ff0000\" class=\"doc_block doc_layout_redline\"></div>";
  119. // if (this._getShow("subject", "subjectShow", "subjectShowScript")) html += "<div class=\"doc_block doc_layout_subject\"></div>";
  120. // if (this._getShow("mainSend", "mainSendShow", "mainSendShowScript")) html += "<div class=\"doc_block doc_layout_mainSend\"></div>";
  121. // html += "<div class=\"doc_block doc_layout_filetext\"></div>";
  122. //
  123. // if (this._getShow("attachment", "attachmentShow", "attachmentShowScript")){
  124. // html += '<table class="doc_block doc_layout_attachment" width="100%" cellpadding="0" cellspacing="0" border="0">' +
  125. // ' <tr><td class="doc_layout_attachment_title_td">' +
  126. // ' <span>  </span><span class="doc_layout_attachment_title"></span>' +
  127. // ' </td><td class="doc_layout_attachment_content_td">' +
  128. // ' <span class="doc_layout_attachment_content"></span>' +
  129. // ' </td></tr>' +
  130. // '</table>';
  131. // };
  132. //
  133. // // html += '<table class="doc_block doc_layout_issuance" cellpadding="0" cellspacing="0" border="0">' +
  134. // // ' <tr><td class="doc_layout_issuanceUnit"></td></tr>' +
  135. // // ' <tr><td class="doc_layout_issuanceDate"></td></tr>' +
  136. // // '</table>'doc_layout_edition_read
  137. //
  138. // var showIssuanceUnit = this._getShow("issuanceUnit", "issuanceUnitShow", "issuanceUnitShowScript");
  139. // var showIssuanceDate = this._getShow("issuanceDate", "issuanceDateShow", "issuanceDateShowScript");
  140. // if (showIssuanceUnit || showIssuanceDate){
  141. // html += '<div class="doc_block" style="overflow: hidden;"><table class="doc_layout_issuance" cellpadding="0" cellspacing="0" border="0">';
  142. // if (showIssuanceUnit) html += ' <tr><td class="doc_layout_issuanceUnit"></td></tr>';
  143. // if (showIssuanceDate) html += ' <tr><td class="doc_layout_issuanceDate"></td></tr>';
  144. // html += '</table></div>';
  145. // }
  146. // if (this._getShow("annotation", "annotationShow", "annotationShowScript")) html += '<div class="doc_block doc_layout_annotation"></div>';
  147. //
  148. // html += '<table class="doc_block doc_layout_edition" width="100%" cellpadding="0" cellspacing="0" border="0">' +
  149. // ' <tr><td class="doc_layout_edition_copyto">';
  150. //
  151. // if (this._getShow("copyto", "copytoShow", "copytoShowScript")){
  152. // html += ' <table class="doc_layout_edition_copyto_table" align="center" cellpadding="0" cellspacing="0" border="0">' +
  153. // ' <tr>' +
  154. // ' <td class="doc_layout_edition_copyto_title"></td>' +
  155. // ' <td class="doc_layout_edition_copyto_content"></td>' +
  156. // ' </tr>' +
  157. // ' </table>';
  158. // }
  159. //
  160. //
  161. // html += ' </td></tr><tr><td class="doc_layout_edition_issuance">'+
  162. // ' <table class="doc_layout_edition_issuance_table" align="center" width="100%" cellpadding="0" cellspacing="0" border="0">' +
  163. // ' <tr>';
  164. //
  165. // if (this._getShow("editionUnit", "editionUnitShow", "editionUnitShowScript")) html += '<td class="doc_layout_edition_issuance_unit"></td>';
  166. // if (this._getShow("editionDate", "editionDateShow", "editionDateShowScript")) html += '<td class="doc_layout_edition_issuance_date"></td>';
  167. //
  168. // html += ' </tr>' +
  169. // ' </table>' +
  170. // '</td></tr>' +
  171. // '</table>';
  172. //@todo
  173. // '<table class="doc_block doc_layout_filenoup" width="100%" cellpadding="0" cellspacing="0" border="0">' +
  174. // ' <tr><td class="doc_layout_filenoup_fileno_td">' +
  175. // ' <span> </span><span class="doc_layout_filenoup_fileno">浙移发〔2019〕20号</span>' +
  176. // ' </td><td class="doc_layout_filenoup_signer_td">' +
  177. // ' <table class="doc_layout_filenoup_signer_table" cellpadding="0" cellspacing="0" border="0">' +
  178. // ' <tr><td class="doc_layout_filenoup_signerTitle_td">' +
  179. // ' <span class="doc_layout_filenoup_signer">签发人:</span>' +
  180. // ' </td><td class="doc_layout_filenoup_signerContent_td">' +
  181. // ' <span class="doc_layout_filenoup_signerContent"></span><span> </span>' +
  182. // ' </td></tr>' +
  183. // ' </table>' +
  184. // ' </td></tr>' +
  185. // '</table>'+
  186. //
  187. //
  188. // "<div class=\"doc_block doc_layout_fileno\"></div>" +
  189. // "<div color=\"#ff0000\" class=\"doc_block doc_layout_redline\"></div>" +
  190. // "<div class=\"doc_block doc_layout_subject\"></div>" +
  191. // "<div class=\"doc_block doc_layout_mainSend\">:</div>"+
  192. // "<div class=\"doc_block doc_layout_filetext\"></div>" +
  193. //
  194. // '<table class="doc_block doc_layout_attachment" width="100%" cellpadding="0" cellspacing="0" border="0">' +
  195. // ' <tr><td class="doc_layout_attachment_title_td">' +
  196. // ' <span>  </span><span class="doc_layout_attachment_title"></span>' +
  197. // ' </td><td class="doc_layout_attachment_content_td">' +
  198. // ' <span class="doc_layout_attachment_content"></span>' +
  199. // ' </td></tr>' +
  200. // '</table>' +
  201. // '<table class="doc_block doc_layout_issuance" cellpadding="0" cellspacing="0" border="0">' +
  202. // ' <tr><td class="doc_layout_issuanceUnit"></td></tr>' +
  203. // ' <tr><td class="doc_layout_issuanceDate"></td></tr>' +
  204. // '</table>' +
  205. // '<div class="doc_block doc_layout_annotation"></div>'+
  206. // // pageContentNode.set("html", html);
  207. // //
  208. // // pageContentNode = this._createNewPage().getFirst();
  209. // // html = '' +
  210. // '<table class="doc_block doc_layout_edition" width="100%" cellpadding="0" cellspacing="0" border="0">' +
  211. // ' <tr><td class="doc_layout_edition_copyto">' +
  212. // ' <table class="doc_layout_edition_copyto_table" align="center" cellpadding="0" cellspacing="0" border="0">' +
  213. // ' <tr>' +
  214. // ' <td class="doc_layout_edition_copyto_title"></td>' +
  215. // ' <td class="doc_layout_edition_copyto_content"></td>' +
  216. // ' </tr>' +
  217. // ' </table>' +
  218. // ' </td></tr>' +
  219. // ' <tr><td class="doc_layout_edition_issuance">' +
  220. // ' <table class="doc_layout_edition_issuance_table" align="center" width="100%" cellpadding="0" cellspacing="0" border="0">' +
  221. // ' <tr>' +
  222. // ' <td class="doc_layout_edition_issuance_unit"></td>' +
  223. // ' <td class="doc_layout_edition_issuance_date"></td>' +
  224. // ' </tr>' +
  225. // ' </table>' +
  226. // ' </td></tr>' +
  227. // '</table>';
  228. var control = this.getShowControl();
  229. this.json.fileup = !!(control.signer);
  230. //this.json.documentTempleteType!="cus"
  231. this.getTempleteJson(function(){
  232. var templete = this.json.documentTempleteName || "standard";
  233. pageContentNode.loadHtml("/x_component_process_FormDesigner/Module/Documenteditor/templete/"+this.templeteJson[templete].file, function(){
  234. if (this.attachmentTemplete){
  235. var attNode = pageContentNode.getElement(".doc_layout_attachment_content");
  236. if (attNode) attNode.empty();
  237. }
  238. if (callback) callback(control);
  239. }.bind(this));
  240. }.bind(this));
  241. },
  242. getTempleteJson: function(callback){
  243. if (this.templeteJson){
  244. if (callback) callback();
  245. }else{
  246. o2.getJSON("/x_component_process_FormDesigner/Module/Documenteditor/templete/templete.json", function(json){
  247. this.templeteJson = json;
  248. if (callback) callback();
  249. }.bind(this));
  250. }
  251. },
  252. getShowControl: function(){
  253. var control = {};
  254. control.copies = this._getShow("copies", "copiesShow", "copiesShowScript");
  255. control.secret = this._getShow("secret", "secretShow", "secretShowScript");
  256. control.priority = this._getShow("priority", "priorityShow", "priorityShowScript");
  257. control.redHeader = this._getShow("redHeader", "redHeaderShow", "redHeaderShowScript");
  258. control.redLine = this._getShow("redLine", "redLineShow", "redLineShowScript");
  259. control.signer = this._getShow("signer", "signerShow", "signerShowScript");
  260. control.fileno = this._getShow("fileno", "filenoShow", "filenoShowScript");
  261. control.subject = this._getShow("subject", "subjectShow", "subjectShowScript");
  262. control.mainSend = this._getShow("mainSend", "mainSendShow", "mainSendShowScript");
  263. control.attachment = this._getShow("attachment", "attachmentShow", "attachmentShowScript");
  264. control.issuanceUnit = this._getShow("issuanceUnit", "issuanceUnitShow", "issuanceUnitShowScript");
  265. control.issuanceDate = this._getShow("issuanceDate", "issuanceDateShow", "issuanceDateShowScript");
  266. control.annotation = this._getShow("annotation", "annotationShow", "annotationShowScript");
  267. control.copyto = this._getShow("copyto", "copytoShow", "copytoShowScript");
  268. control.copyto2 = this._getShow("copyto2", "copyto2Show", "copyto2ShowScript");
  269. control.editionUnit = this._getShow("editionUnit", "editionUnitShow", "editionUnitShowScript");
  270. control.editionDate = this._getShow("editionDate", "editionDateShow", "editionDateShowScript");
  271. control.meetingAttend = this._getShow("meetingAttend", "meetingAttendShow", "meetingAttendShowScript");
  272. control.meetingLeave = this._getShow("meetingLeave", "meetingLeaveShow", "meetingLeaveShowScript");
  273. control.meetingSit = this._getShow("meetingSit", "meetingSitShow", "meetingSitShowScript");
  274. return control;
  275. },
  276. // _getEdit: function(name, typeItem, scriptItem){
  277. // switch (this.json[typeItem]) {
  278. // case "y":
  279. // return true;
  280. // case "n":
  281. // return false;
  282. // // case "a":
  283. // // if (["copies", "secret", "priority", "attachment", "annotation", "copyto"].indexOf(name!=-1)){
  284. // // return !!this.data[name] && (!!this.data[name].length);
  285. // // }
  286. // // return true;
  287. // case "s":
  288. // if (this.json[scriptItem] && this.json[scriptItem].code){
  289. // return !!this.form.Macro.exec(this.json[scriptItem].code, this);
  290. // }
  291. // return true;
  292. // }
  293. // },
  294. getEditControl: function(){
  295. var control = {};
  296. control.copies = this._getEdit("copies", "copiesEdit", "copiesEditScript");
  297. control.secret = this._getEdit("secret", "secretEdit", "secretEditScript");
  298. control.priority = this._getEdit("priority", "priorityEdit", "priorityEditScript");
  299. control.redHeader = this._getEdit("redHeader", "redHeaderEdit", "redHeaderEditScript");
  300. control.signer = this._getEdit("signer", "signerEdit", "signerEditScript");
  301. control.fileno = this._getEdit("fileno", "filenoEdit", "filenoEditScript");
  302. control.subject = this._getEdit("subject", "subjectEdit", "subjectEditScript");
  303. control.mainSend = this._getEdit("mainSend", "mainSendEdit", "mainSendEditScript");
  304. control.attachment = this._getEdit("attachment", "attachmentEdit", "attachmentEditScript");
  305. control.issuanceUnit = this._getEdit("issuanceUnit", "issuanceUnitEdit", "issuanceUnitEditScript");
  306. control.issuanceDate = this._getEdit("issuanceDate", "issuanceDateEdit", "issuanceDateEditScript");
  307. control.annotation = this._getEdit("annotation", "annotationEdit", "annotationEditScript");
  308. control.copyto = this._getEdit("copyto", "copytoEdit", "copytoEditScript");
  309. control.copyto2 = this._getEdit("copyto2", "copyto2Edit", "copyto2EditScript");
  310. control.editionUnit = this._getEdit("editionUnit", "editionUnitEdit", "editionUnitEditScript");
  311. control.editionDate = this._getEdit("editionDate", "editionDateEdit", "editionDateEditScript");
  312. control.meetingAttend = this._getShow("meetingAttend", "meetingAttendEdit", "meetingAttendEditScript");
  313. control.meetingLeave = this._getShow("meetingLeave", "meetingLeaveEdit", "meetingLeaveEditScript");
  314. control.meetingSit = this._getShow("meetingSit", "meetingSitEdit", "meetingSitEditScript");
  315. return control;
  316. },
  317. //份数 密级 紧急程度
  318. _loadCopiesSecretPriority: function(){
  319. this.layout_copiesSecretPriority = this.contentNode.getElement(".doc_layout_copiesSecretPriority");
  320. if (this.layout_copiesSecretPriority) this.layout_copiesSecretPriority.setStyles(this.css.doc_layout_copiesSecretPriority);
  321. this.layout_copies = this.contentNode.getElement(".doc_layout_copies");
  322. if (this.layout_copies) this.layout_copies.setStyles(this.css.doc_layout_copies);
  323. this.layout_secret = this.contentNode.getElement(".doc_layout_secret");
  324. if (this.layout_secret) this.layout_secret.setStyles(this.css.doc_layout_secret);
  325. this.layout_priority = this.contentNode.getElement(".doc_layout_priority");
  326. if (this.layout_priority) this.layout_priority.setStyles(this.css.doc_layout_priority);
  327. },
  328. //红头
  329. _loadRedHeader: function(){
  330. this.layout_redHeader = this.contentNode.getElement(".doc_layout_redHeader");
  331. if (this.layout_redHeader) this.layout_redHeader.setStyles(this.css.doc_layout_redHeader);
  332. },
  333. //文号签发人(上行文)
  334. _loadFileNoUp: function(){
  335. this.layout_filenoArea = this.contentNode.getElement(".doc_layout_fileno_area");
  336. this.layout_fileNoUpTable = this.contentNode.getElement(".doc_layout_filenoup");
  337. if (this.layout_fileNoUpTable) this.layout_fileNoUpTable.setStyles(this.css.doc_layout_filenoup);
  338. var td = this.contentNode.getElement(".doc_layout_filenoup_fileno_td");
  339. if (td) td.setStyles(this.css.doc_layout_filenoup_fileno_td);
  340. this.layout_fileno = this.contentNode.getElement(".doc_layout_filenoup_fileno");
  341. if (this.layout_fileno) this.layout_fileno.setStyles(this.css.doc_layout_filenoup_fileno);
  342. td = this.contentNode.getElement(".doc_layout_filenoup_signer_td");
  343. if (td) td.setStyles(this.css.doc_layout_filenoup_signer_td);
  344. var node = this.contentNode.getElement(".doc_layout_filenoup_signer_table");
  345. if (node) node.setStyles(this.css.doc_layout_filenoup_signer_table);
  346. node = this.contentNode.getElement(".doc_layout_filenoup_signerTitle_td");
  347. if (node) node.setStyles(this.css.doc_layout_filenoup_signerTitle_td);
  348. this.layout_signerTitle = this.contentNode.getElement(".doc_layout_filenoup_signer");
  349. if (this.layout_signerTitle) this.layout_signerTitle.setStyles(this.css.doc_layout_filenoup_signer);
  350. node = this.contentNode.getElement(".doc_layout_filenoup_signerContent_td");
  351. if (node) node.setStyles(this.css.doc_layout_filenoup_signerContent_td);
  352. this.layout_signer = this.contentNode.getElement(".doc_layout_filenoup_signerContent");
  353. if (this.layout_signer) this.layout_signer.setStyles(this.css.doc_layout_filenoup_signerContent);
  354. },
  355. //文号
  356. _loadFileNo: function(){
  357. this.layout_fileNoUpTable = this.contentNode.getElement(".doc_layout_filenoup");
  358. this.layout_filenoArea = this.contentNode.getElement(".doc_layout_fileno_area");
  359. this.layout_fileno = this.contentNode.getElement(".doc_layout_fileno");
  360. if (this.layout_fileno) this.layout_fileno.setStyles(this.css.doc_layout_fileno);
  361. },
  362. //红线
  363. _loadRedLine: function(){
  364. this.layout_redLine = this.contentNode.getElement(".doc_layout_redline");
  365. if (this.layout_redLine) this.layout_redLine.setStyles(this.css.doc_layout_redline);
  366. },
  367. //标题
  368. _loadSubject:function(){
  369. this.layout_subject = this.contentNode.getElement(".doc_layout_subject");
  370. if (this.layout_subject) this.layout_subject.setStyles(this.css.doc_layout_subject);
  371. },
  372. //主送
  373. _loadMainSend: function(){
  374. this.layout_mainSend = this.contentNode.getElement(".doc_layout_mainSend");
  375. if (this.layout_mainSend) this.layout_mainSend.setStyles(this.css.doc_layout_mainSend);
  376. },
  377. //正文
  378. // _createFiletext: function(filetextNode, node, where){
  379. // if (!filetextNode){
  380. // var filetextNode = new Element("div.doc_layout_filetext").inject(node, where);
  381. // filetextNode.addClass("doc_block");
  382. // filetextNode.setAttribute('contenteditable', true);
  383. // }
  384. // CKEDITOR.disableAutoInline = true;
  385. // var filetextEditor = CKEDITOR.inline(filetextNode, this._getEditorConfig());
  386. // filetextNode.store("editor", filetextEditor);
  387. // if (!this.filetextEditors) this.filetextEditors = [];
  388. // this.filetextEditors.push(filetextEditor);
  389. //
  390. // filetextEditor.on( 'blur', function(e) {
  391. // // var filetextNode = e.editor.container.$;
  392. // // var pageNode = filetextNode.getParent(".doc_layout_page");
  393. // // this._checkSplitPage(pageNode);
  394. // // this._repage();
  395. // }.bind(this));
  396. //
  397. // return filetextNode;
  398. // },
  399. _loadFiletext: function(){
  400. this.layout_filetext = this.contentNode.getElement(".doc_layout_filetext");
  401. this.layout_filetext.setStyles(this.css.doc_layout_filetext);
  402. //this.layout_filetext = this.contentNode.getElement(".doc_layout_filetext");
  403. // if (this.layout_filetexts.length){
  404. // this.layout_filetexts.each(function(layout_filetext){
  405. // layout_filetext.setStyles(this.css.doc_layout_filetext);
  406. // }.bind(this));
  407. // }
  408. },
  409. //附件
  410. _loadAttachment: function(){
  411. this.layout_attachmentTable = this.contentNode.getElement(".doc_layout_attachment");
  412. if (this.layout_attachmentTable) this.layout_attachmentTable.setStyles(this.css.doc_layout_attachment);
  413. var node = this.contentNode.getElement(".doc_layout_attachment_title_td");
  414. if (node) node.setStyles(this.css.doc_layout_attachment_title_td);
  415. this.layout_attachmentTitle = this.contentNode.getElement(".doc_layout_attachment_title");
  416. if (node) node.setStyles(this.css.doc_layout_attachment_title);
  417. node = this.contentNode.getElement(".doc_layout_attachment_content_td");
  418. if (node) node.setStyles(this.css.doc_layout_attachment_content_td);
  419. this.layout_attachment = this.contentNode.getElement(".doc_layout_attachment_content");
  420. if (this.layout_attachment) this.layout_attachment.setStyles(this.css.doc_layout_attachment_content);
  421. },
  422. //发布单位
  423. _loadIssuance: function(){
  424. this.layout_issuanceTable = this.contentNode.getElement(".doc_layout_issuance");
  425. this.layout_issuanceUnit = this.contentNode.getElement(".doc_layout_issuanceUnit");
  426. this.layout_issuanceDate = this.contentNode.getElement(".doc_layout_issuanceDate");
  427. if (this.layout_issuanceTable) this.layout_issuanceTable.setStyles(this.css.doc_layout_issuance);
  428. if (this.layout_issuanceUnit) this.layout_issuanceUnit.setStyles(this.css.doc_layout_issuanceUnit);
  429. if (this.layout_issuanceDate) this.layout_issuanceDate.setStyles(this.css.doc_layout_issuanceDate);
  430. },
  431. //附注
  432. _loadAnnotation: function(){
  433. this.layout_annotation = this.contentNode.getElement(".doc_layout_annotation");
  434. if (this.layout_annotation) this.layout_annotation.setStyles(this.css.doc_layout_annotation);
  435. },
  436. //版记
  437. _loadEdition: function(){
  438. this.layout_editionArea = this.contentNode.getElement(".doc_layout_editionArea");
  439. this.layout_edition = this.contentNode.getElement(".doc_layout_edition");
  440. if (this.layout_edition) this.layout_edition.setStyles(this.css.doc_layout_edition);
  441. var node = this.contentNode.getElement(".doc_layout_edition_copyto");
  442. if (node) node.setStyles(this.css.doc_layout_edition_copyto);
  443. node = this.contentNode.getElement(".doc_layout_edition_copyto_table");
  444. if (node) node.setStyles(this.css.doc_layout_edition_copyto_table);
  445. var node = this.contentNode.getElement(".doc_layout_edition_copyto2");
  446. if (node) node.setStyles(this.css.doc_layout_edition_copyto);
  447. node = this.contentNode.getElement(".doc_layout_edition_copyto2_table");
  448. if (node) node.setStyles(this.css.doc_layout_edition_copyto_table);
  449. this.layout_copytoTitle = this.contentNode.getElement(".doc_layout_edition_copyto_title");
  450. if (this.layout_copytoTitle) this.layout_copytoTitle.setStyles(this.css.doc_layout_edition_copyto_title);
  451. this.layout_copytoContent = this.contentNode.getElement(".doc_layout_edition_copyto_content");
  452. if (this.layout_copytoContent) this.layout_copytoContent.setStyles(this.css.doc_layout_edition_copyto_content);
  453. this.layout_copyto2Title = this.contentNode.getElement(".doc_layout_edition_copyto2_title");
  454. if (this.layout_copyto2Title) this.layout_copyto2Title.setStyles(this.css.doc_layout_edition_copyto_title);
  455. this.layout_copyto2Content = this.contentNode.getElement(".doc_layout_edition_copyto2_content");
  456. if (this.layout_copyto2Content) this.layout_copyto2Content.setStyles(this.css.doc_layout_edition_copyto_content);
  457. var issuance = this.contentNode.getElement(".doc_layout_edition_issuance");
  458. if (issuance) issuance.setStyles(this.css.doc_layout_edition_issuance);
  459. var issuance_table = this.contentNode.getElement(".doc_layout_edition_issuance_table");
  460. if (issuance_table) issuance_table.setStyles(this.css.doc_layout_edition_issuance_table);
  461. this.layout_edition_issuance_unit = this.contentNode.getElement(".doc_layout_edition_issuance_unit");
  462. if (this.layout_edition_issuance_unit) this.layout_edition_issuance_unit.setStyles(this.css.doc_layout_edition_issuance_unit);
  463. this.layout_edition_issuance_date = this.contentNode.getElement(".doc_layout_edition_issuance_date");
  464. if (this.layout_edition_issuance_date) this.layout_edition_issuance_date.setStyles(this.css.doc_layout_edition_issuance_date);
  465. },
  466. _loadMeeting: function(){
  467. this.layout_meetingAttendArea = this.contentNode.getElement(".doc_layout_meeting_attend");
  468. this.layout_meetingAttendTitle = this.contentNode.getElement(".doc_layout_meeting_attend_title");
  469. this.layout_meetingAttendContent = this.contentNode.getElement(".doc_layout_meeting_attend_content");
  470. this.layout_meetingLeaveArea = this.contentNode.getElement(".doc_layout_meeting_leave");
  471. this.layout_meetingLeaveTitle = this.contentNode.getElement(".doc_layout_meeting_leave_title");
  472. this.layout_meetingLeaveContent = this.contentNode.getElement(".doc_layout_meeting_leave_content");
  473. this.layout_meetingSitArea = this.contentNode.getElement(".doc_layout_meeting_sit");
  474. this.layout_meetingSitTitle = this.contentNode.getElement(".doc_layout_meeting_sit_title");
  475. this.layout_meetingSitContent = this.contentNode.getElement(".doc_layout_meeting_sit_content");
  476. },
  477. _loadPageLayout: function(control){
  478. this._loadCopiesSecretPriority();
  479. this._loadRedHeader();
  480. if (this.json.fileup){
  481. this._loadFileNoUp();
  482. }else{
  483. this._loadFileNo();
  484. }
  485. if (!this.layout_fileno) this._loadFileNo();
  486. this._loadRedLine();
  487. this._loadSubject();
  488. this._loadMainSend();
  489. this._loadFiletext();
  490. this._loadAttachment();
  491. this._loadIssuance();
  492. this._loadAnnotation();
  493. this._loadEdition();
  494. //会议纪要
  495. this._loadMeeting();
  496. this.reSetShow(control);
  497. this.reSetEdit();
  498. // 份数: this.layout_copies
  499. // 密级: this.layout_secret
  500. // 紧急程度: this.layout_priority
  501. // 红头: this.layout_redHeader
  502. // 上行文编号签发: this.layout_fileNoUpTable
  503. // 文号: this.layout_fileno
  504. // 签发: this.layout_signerTitle
  505. // 签发人: this.layout_signer
  506. // 文号: this.layout_fileno
  507. // 红线: this.layout_redLine
  508. // 标题: this.layout_subject
  509. // 主送单位: this.layout_mainSend
  510. // 正文: this.layout_filetexts
  511. // 附件: this.layout_attachmentTitle
  512. // 附件: this.layout_attachment
  513. // 单位: this.layout_issuanceUnit
  514. // 签发时间: this.layout_issuanceDate
  515. // 附注: this.layout_annotation
  516. // 抄送: this.layout_copytoTitle
  517. // 抄送: this.layout_copytoContent
  518. // 版记单位 this.layout_edition_issuance_unit
  519. // 版记日期 this.layout_edition_issuance_date
  520. },
  521. reSetShow: function(control){
  522. debugger;
  523. if (!control) control = this.getShowControl();
  524. var m = function(s){ return (control[s]) ? "show" : "hide"; }
  525. if (this.layout_copies) this.layout_copies[m("copies")]();
  526. if (this.layout_secret) this.layout_secret[m("secret")]();
  527. if (this.layout_priority) this.layout_priority[m("priority")]();
  528. if (this.layout_redHeader) this.layout_redHeader[m("redHeader")]();
  529. if (this.layout_redLine) this.layout_redLine[m("redLine")]();
  530. if (this.layout_fileNoUpTable) this.layout_fileNoUpTable[m("signer")]();
  531. if (this.layout_filenoArea) this.layout_filenoArea[(!control.signer) ? "show" : "hide"]();
  532. if (this.layout_fileno) this.layout_fileno[m("fileno")]();
  533. if (this.layout_subject) this.layout_subject[m("subject")]();
  534. if (this.layout_mainSend) this.layout_mainSend[m("mainSend")]();
  535. if (this.layout_attachmentTable) this.layout_attachmentTable[m("attachment")]();
  536. if (this.layout_issuanceUnit) this.layout_issuanceUnit[m("issuanceUnit")]();
  537. if (this.layout_issuanceDate) this.layout_issuanceDate[m("issuanceDate")]();
  538. if (this.layout_annotation) this.layout_annotation[m("annotation")]();
  539. debugger;
  540. if ((!control.copyto || !this.layout_copytoContent) && (!control.copyto2 || !this.layout_copyto2Content) && (!control.editionUnit || !this.layout_edition_issuance_unit) && (!control.editionDate || !this.layout_edition_issuance_date)){
  541. if (this.layout_editionArea) this.layout_editionArea.hide();
  542. }else{
  543. if ((!control.copyto || !this.layout_copytoContent) && (!control.copyto2 || !this.layout_copyto2Content) ){
  544. if (this.layout_edition){
  545. if (this.layout_copytoContent) this.layout_copytoContent.getParent("tr").destroy();
  546. if (this.layout_copyto2Content) this.layout_copyto2Content.getParent("tr").destroy();
  547. if (this.layout_edition) this.layout_edition.getElement("tr").getElements("td").setStyles({
  548. "border-top": "solid windowtext 1.5pt"
  549. });
  550. }
  551. }else if (!control.copyto || !this.layout_copytoContent){
  552. if (this.layout_copytoContent) this.layout_copytoContent.getParent("tr").destroy();
  553. //if (this.layout_copyto2Content) this.layout_edition.getElement("tr").destroy();
  554. if (this.layout_edition) this.layout_edition.getElement("tr").getElements("td").setStyles({
  555. "border-top": "solid windowtext 1.5pt"
  556. });
  557. }else if (!control.copyto2 || !this.layout_copyto2Content) {
  558. if (this.layout_copyto2Content) this.layout_copyto2Content.getParent("tr").destroy();
  559. if (this.layout_edition) this.layout_edition.getElement("tr").getElements("td").setStyles({
  560. "border-bottom": "solid windowtext 1.0pt"
  561. });
  562. }
  563. if ((!control.editionUnit || !this.layout_edition_issuance_unit) && (!control.editionDate || !this.layout_edition_issuance_date)){
  564. if (this.layout_editionArea && (this.layout_edition_issuance_date || this.layout_edition_issuance_unit)){
  565. var trs = this.layout_editionArea.getElement("table").rows;
  566. trs.item(trs.length-1).destroy();
  567. trs = this.layout_editionArea.getElement("table").rows;
  568. var tr = trs.item(trs.length-1);
  569. if (tr){
  570. tr.getElements("td").setStyles({
  571. "border-bottom": "solid windowtext 1.5pt"
  572. });
  573. }
  574. }
  575. }
  576. if (this.layout_editionArea) this.layout_editionArea.show();
  577. if (this.layout_copytoTitle) this.layout_copytoTitle[m("copyto")]();
  578. if (this.layout_copytoContent) this.layout_copytoContent[m("copyto")]();
  579. if (this.layout_copyto2Title) this.layout_copyto2Title[m("copyto2")]();
  580. if (this.layout_copyto2Content) this.layout_copyto2Content[m("copyto2")]();
  581. if (this.layout_edition_issuance_unit) this.layout_edition_issuance_unit[m("editionUnit")]();
  582. if (this.layout_edition_issuance_date) this.layout_edition_issuance_date[m("editionDate")]();
  583. }
  584. if (this.layout_meetingAttendArea) this.layout_meetingAttendArea[m("meetingAttend")]();
  585. if (this.layout_meetingLeaveArea) this.layout_meetingLeaveArea[m("meetingLeave")]();
  586. if (this.layout_meetingSitArea) this.layout_meetingSitArea[m("meetingSit")]();
  587. // this.layout_annotation[m("annotation")]();
  588. // this.layout_annotation[m("annotation")]();
  589. // this.layout_annotation[m("annotation")]();
  590. },
  591. reSetEdit: function(control){
  592. //未进行数据绑定时,可允许编辑
  593. if (!control) var control = this.getEditControl();
  594. if (!!this.json.subjectValueData && this.json.subjectValueType=="data") this.layout_subject.set("contenteditable", control.subject);
  595. // this.layout_subject.addEvent("keydown", function(e){
  596. // debugger;
  597. // if (this.json.subjectValueType=="data" && this.json.subjectValueData){
  598. // // var v = e.target.get("HTML");
  599. // // this.form.businessData.data[this.json.subjectValueData] = v
  600. // var module = this.form.all[this.json.subjectValueData];
  601. // if (module){
  602. // var bindFun = module.node.retrieve(this.json.id+"bindFun");
  603. // module.node
  604. // }
  605. // }
  606. // }.bind(this));
  607. },
  608. _loadUserInterface: function(callback){
  609. this.node.empty();
  610. this.node.setStyles(this.form.css.documentEditorNode);
  611. this.pages = [];
  612. this.allowEdit = this._isAllowEdit();
  613. this.allowPrint = this._isAllowPrint();
  614. this.toolNode = new Element("div", {"styles": this.css.doc_toolbar}).inject(this.node);
  615. this.contentNode = new Element("div", {"styles": this.css.doc_content}).inject(this.node);
  616. if (!this.form.isLoaded){
  617. this.form.addEvent("afterModulesLoad", function(){this.loadDocumentEditor(callback);}.bind(this));
  618. }else{
  619. this.loadDocumentEditor(callback);
  620. }
  621. },
  622. loadDocumentEditor: function(callback){
  623. //this.contentNode.addEvent("resize", this._checkScale.bind(this));
  624. this._loadToolbars();
  625. this._loadFiletextPage(function(){
  626. if (this.options.pageShow!=="double"){
  627. this._singlePage();
  628. }else{
  629. this._doublePage();
  630. }
  631. this.form.addEvent("afterSave", function(){
  632. this.resetData();
  633. }.bind(this));
  634. if (this.json.toWord=="y"){
  635. if (this.json.toWordTrigger=="open") this.docToWord();
  636. if (this.json.toWordTrigger=="save") this.form.addEvent("beforeSave", this.docToWord.bind(this));
  637. if (this.json.toWordTrigger=="submit") this.form.addEvent("beforeProcess", this.docToWord.bind(this));
  638. }
  639. if (!layout.mobile) this.loadSideToolbar();
  640. if (callback) callback();
  641. }.bind(this));
  642. },
  643. resizeSidebar: function(){
  644. if (this.sidebarNode){
  645. var fileTextNode = this.contentNode.getElement("div.doc_layout_filetext");
  646. if (fileTextNode){
  647. this.sidebarNode.position({
  648. relativeTo: fileTextNode,
  649. position: 'topLeft',
  650. edge: 'topRight',
  651. offset: {"x": -20}
  652. });
  653. }
  654. }
  655. },
  656. loadSideToolbar: function(){
  657. if (this.allowEdit){
  658. if (this.pages.length){
  659. var fileTextNode = this.pages[0].getElement("div.doc_layout_filetext");
  660. if (fileTextNode){
  661. this.sidebarNode = new Element("div", {"styles": this.css.doc_sidebar}).inject(this.node);
  662. this.resizeSidebar();
  663. this.scrollNode = this.sidebarNode.getParentSrcollNode();
  664. if (this.scrollNode){
  665. this.scrollNode.addEvent("scroll", function(){
  666. this.resizeSidebar();
  667. }.bind(this));
  668. }
  669. html = "<span MWFnodetype=\"MWFToolBarButton\" MWFButtonImage=\"/x_component_process_Xform/$Form/default/icon/editdoc.png\" title=\""+MWF.xApplication.process.Xform.LP.editdoc+"\" MWFButtonAction=\"_switchReadOrEditInline\" MWFButtonText=\""+MWF.xApplication.process.Xform.LP.editdoc+"\"></span>";
  670. this.sidebarNode.set("html", html);
  671. MWF.require("MWF.widget.Toolbar", function() {
  672. this.sideToolbar = new MWF.widget.Toolbar(this.sidebarNode, {"style": "documentEdit_side"}, this);
  673. this.sideToolbar.load();
  674. }.bind(this));
  675. }
  676. }
  677. }
  678. },
  679. _returnScale: function(){
  680. this.isScale = false;
  681. this.scale = 0;
  682. this.contentNode.setStyles({
  683. "transform":"scale(1)",
  684. });
  685. if (this.pages.length){
  686. this.pages.each(function(page){
  687. page.setStyles({
  688. "transform":"scale(1)",
  689. });
  690. });
  691. }
  692. this.node.setStyles({
  693. "height": "auto"
  694. });
  695. },
  696. _checkScale: function(offset){
  697. debugger;
  698. offset = 0;
  699. if (this.pages.length){
  700. var pageSize = this.pages[0].getSize();
  701. var contentSize = this.node.getSize();
  702. var contentWidth = (offset) ? contentSize.x-20-offset : contentSize.x-20;
  703. if (contentWidth<pageSize.x){
  704. this.isScale = true;
  705. var scale = (contentWidth)/pageSize.x;
  706. this.scale = scale;
  707. this.zoom();
  708. this.resetNodeSize();
  709. // var h = this.node.getSize().y;
  710. // h = h - contentSize.y*(1-scale);
  711. //
  712. // this.node.setStyles({
  713. // "height":""+h+"px"
  714. // });
  715. // this.contentNode.setStyles({
  716. // "transform":"scale(1, "+scale+")",
  717. // "transform-origin": "0px 0px",
  718. // "overflow": "visible"
  719. // });
  720. //
  721. // this._singlePage();
  722. // this.pages.each(function(page){
  723. // page.setStyles({
  724. // "transform":"scale("+scale+", 1)",
  725. // "transform-origin": "0px 0px",
  726. // "overflow": "visible",
  727. // "margin-left": "10px"
  728. // });
  729. // });
  730. //
  731. // if (this.doublePageAction) this.doublePageAction.hide();
  732. }
  733. }
  734. },
  735. zoom: function(scale){
  736. if (scale) this.scale = scale;
  737. var w = this.node.getSize().x;
  738. w = w/this.scale;
  739. this.contentNode.setStyles({
  740. "transform":"scale("+this.scale+")",
  741. "transform-origin": "0px 0px",
  742. "overflow": "hidden",
  743. "width": ""+w+"px"
  744. });
  745. // this._singlePage();
  746. // this.pages.each(function(page){
  747. // page.setStyles({
  748. // "transform":"scale("+this.scale+", 1)",
  749. // "transform-origin": "0px 0px",
  750. // "overflow": "visible",
  751. // "margin-left": "10px"
  752. // });
  753. // });
  754. },
  755. _switchReadOrEdit: function(){
  756. if (this.eiitMode){
  757. this._readFiletext();
  758. if (this.allowEdit) this.toolbar.childrenButton[0].setText(MWF.xApplication.process.Xform.LP.editdoc);
  759. this.eiitMode = false;
  760. }else{
  761. this._editFiletext();
  762. if (this.allowEdit) this.toolbar.childrenButton[0].setText(MWF.xApplication.process.Xform.LP.editdocCompleted)
  763. this.eiitMode = true;
  764. }
  765. },
  766. _switchReadOrEditInline: function(){
  767. if (this.eiitMode){
  768. this._readFiletext();
  769. if (this.allowEdit){
  770. if (!layout.mobile) this.sideToolbar.childrenButton[0].setText(MWF.xApplication.process.Xform.LP.editdoc);
  771. this.toolbar.childrenButton[0].setText(MWF.xApplication.process.Xform.LP.editdoc);
  772. }
  773. this.eiitMode = false;
  774. }else{
  775. this._editFiletext("inline");
  776. if (this.allowEdit){
  777. if (!layout.mobile) this.sideToolbar.childrenButton[0].setText(MWF.xApplication.process.Xform.LP.editdocCompleted);
  778. this.toolbar.childrenButton[0].setText(MWF.xApplication.process.Xform.LP.editdocCompleted);
  779. }
  780. this.eiitMode = true;
  781. }
  782. },
  783. _printDoc: function(){
  784. this.toWord(function(data){
  785. if (this.form.businessData.work && !this.form.businessData.work.completedTime){
  786. this.form.workAction.getAttachmentStream(data.id, this.form.businessData.work.id);
  787. }else{
  788. this.form.workAction.getWorkcompletedAttachmentStream(data.id, ((this.form.businessData.workCompleted) ? this.form.businessData.workCompleted.id : this.form.businessData.work.id));
  789. }
  790. }.bind(this), "$doc.doc");
  791. },
  792. _readFiletext: function(){
  793. //this._returnScale();
  794. this.zoom(1);
  795. if (this.filetextEditor) this.filetextEditor.destroy();
  796. if (this.filetextScrollNode){
  797. if (this.reLocationFiletextToolbarFun){
  798. this.filetextScrollNode.removeEvent("scroll", this.reLocationFiletextToolbarFun);
  799. //this.form.app.removeEvent("resize", this.reLocationFiletextToolbarFun);
  800. this.reLocationFiletextToolbarFun = null;
  801. }
  802. this.filetextScrollNode = null;
  803. }
  804. if (this.filetextToolbarNode) this.filetextToolbarNode = null;
  805. this.layout_filetext.setAttribute('contenteditable', false);
  806. this.data = this.getData();
  807. //this._checkSplitPage(this.pages[0]);
  808. this._repage();
  809. },
  810. _editFiletext: function(inline){
  811. this._returnScale();
  812. this.zoom(1);
  813. this._singlePage();
  814. this.pages = [];
  815. this.contentNode.empty();
  816. this._createPage(function(control){
  817. this._loadPageLayout(control);
  818. // var docData = this._getBusinessData();
  819. // if (!docData) docData = this._getDefaultData();
  820. this.setData(this.data);
  821. this._checkScale();
  822. this.node.setStyles({
  823. "height":"auto"
  824. });
  825. this._createEditor(inline);
  826. }.bind(this));
  827. },
  828. _createEditor: function(inline){
  829. if (this.allowEdit){
  830. this.loadCkeditorFiletext(function(e){
  831. debugger;
  832. e.editor.focus();
  833. e.editor.getSelection().scrollIntoView();
  834. //this.getFiletextToolber();
  835. //this.filetextToolbarNode.inject(this.layout_filetext.getOffsetParent());
  836. this.locationFiletextToolbar();
  837. }.bind(this), inline);
  838. }
  839. },
  840. getFiletextToolber: function(){
  841. if (this.filetextEditor) {
  842. if (!this.filetextToolbarNode) {
  843. var className = "cke_editor_" + this.filetextEditor.name;
  844. var filetextToolbarNode = $$("." + className)[0];
  845. this.filetextToolbarNode = filetextToolbarNode;
  846. //filetextToolbarNode.destroy();
  847. }
  848. }
  849. },
  850. reLocationFiletextToolbar: function(){
  851. this.getFiletextToolber();
  852. // if (this.filetextToolbarNode){
  853. // this.filetextToolbarNode.setStyle("display", "block");
  854. // var offsetNode = this.layout_filetext.getOffsetParent();
  855. //
  856. // this.filetextToolbarNode.setStyle("left", 0);
  857. // var h = this.filetextToolbarNode.getSize().y;
  858. // var p = this.layout_filetext.getPosition(offsetNode).y-h;
  859. //
  860. // var postion = this.layout_filetext.getPosition(this.form.app.content);
  861. // if (postion.y-h<0){
  862. // this.filetextToolbarNode.inject(this.form.app.content);
  863. // this.filetextToolbarNode.setStyle("top", 0);
  864. // this.filetextToolbarNode.setStyle("left", ""+postion.x+"px");
  865. // }else{
  866. // this.filetextToolbarNode.inject(offsetNode);
  867. // this.filetextToolbarNode.setStyle("top", "" + p + "px");
  868. // this.filetextToolbarNode.setStyle("left", 0);
  869. // this.filetextToolbarNode.setStyle("left", "auto");
  870. // }
  871. // }
  872. if (this.filetextToolbarNode){
  873. if (!this.filetextScrollNode){
  874. var scrollNode = this.contentNode;
  875. while (scrollNode && (scrollNode.getScrollSize().y<=scrollNode.getSize().y || (scrollNode.getStyle("overflow")!=="auto" && scrollNode.getStyle("overflow-y")!=="auto"))){
  876. scrollNode = scrollNode.getParent();
  877. }
  878. this.filetextScrollNode = scrollNode;
  879. }
  880. var h = this.filetextToolbarNode.getSize().y;
  881. var position = this.layout_filetext.getPosition(this.form.app.content);
  882. var size = this.layout_filetext.getSize();
  883. var contentSize = this.filetextScrollNode.getSize();
  884. if (position.y<0 && size.y+position.y+h<contentSize.y){
  885. var top = size.y+position.y;
  886. this.filetextToolbarNode.setStyle("top", ""+top+"px");
  887. }else if (position.y-h<0){
  888. this.filetextToolbarNode.setStyle("top", 0);
  889. }else{
  890. var p = this.layout_filetext.getPosition().y-h;
  891. this.filetextToolbarNode.setStyle("top", "" + p + "px");
  892. }
  893. }
  894. //
  895. // this.filetextToolbarNode.inject(offsetNode);
  896. //
  897. //
  898. // this.filetextToolbarNode.setStyle("top", ""+p+"px");
  899. },
  900. locationFiletextToolbar: function(){
  901. this.reLocationFiletextToolbar();
  902. if (this.filetextToolbarNode) {
  903. var scrollNode = this.contentNode;
  904. while (scrollNode && (scrollNode.getScrollSize().y<=scrollNode.getSize().y || (scrollNode.getStyle("overflow")!=="auto" && scrollNode.getStyle("overflow-y")!=="auto"))){
  905. scrollNode = scrollNode.getParent();
  906. }
  907. if (scrollNode){
  908. this.filetextScrollNode = scrollNode;
  909. this.reLocationFiletextToolbarFun = this.reLocationFiletextToolbar.bind(this);
  910. this.filetextScrollNode.addEvent("scroll", this.reLocationFiletextToolbarFun);
  911. }
  912. }
  913. },
  914. _isAllowEdit:function(){
  915. if (this.readonly) return false;
  916. if (this.json.allowEdit=="n") return false;
  917. if (this.json.allowEdit=="s"){
  918. if (this.json.allowEditScript && this.json.allowEditScript.code){
  919. return !!this.form.Macro.exec(this.json.allowEditScript.code, this);
  920. }
  921. }
  922. return true;
  923. },
  924. _isAllowPrint: function(){
  925. if (this.json.allowPrint=="n") return false;
  926. if (this.json.allowPrint=="s"){
  927. if (this.json.allowPrintScript && this.json.allowPrintScript.code){
  928. return !!this.form.Macro.exec(this.json.allowPrintScript.code, this);
  929. }
  930. }
  931. return true;
  932. },
  933. _getEdit: function(name, typeItem, scriptItem){
  934. switch (this.json[typeItem]) {
  935. case "y":
  936. return true;
  937. case "n":
  938. return false;
  939. case "s":
  940. if (this.json[scriptItem] && this.json[scriptItem].code){
  941. return !!this.form.Macro.exec(this.json[scriptItem].code, this);
  942. }
  943. return true;
  944. }
  945. },
  946. loadCkeditorStyle: function(node){
  947. if (node){
  948. o2.load("ckeditor", function(){
  949. //CKEDITOR.disableAutoInline = true;
  950. node.setAttribute('contenteditable', true);
  951. var editor = CKEDITOR.inline(this.layout_filetext, this._getEditorConfig());
  952. this.filetextEditor.on("instanceReady", function(e){
  953. if (callback) callback(e);
  954. }.bind(this));
  955. }.bind(this));
  956. }
  957. },
  958. _loadToolbars: function(){
  959. var html ="";
  960. if (this.allowEdit){
  961. //html += "<span MWFnodetype=\"MWFToolBarButton\" MWFButtonImage=\"/x_component_process_Xform/$Form/default/icon/editdoc.png\" title=\""+MWF.xApplication.process.Xform.LP.editdoc+"\" MWFButtonAction=\"_switchReadOrEdit\" MWFButtonText=\""+MWF.xApplication.process.Xform.LP.editdoc+"\"></span>";
  962. html += "<span MWFnodetype=\"MWFToolBarButton\" MWFButtonImage=\"/x_component_process_Xform/$Form/default/icon/editdoc.png\" title=\""+MWF.xApplication.process.Xform.LP.editdoc+"\" MWFButtonAction=\"_switchReadOrEditInline\" MWFButtonText=\""+MWF.xApplication.process.Xform.LP.editdoc+"\"></span>";
  963. //html += "<span MWFnodetype=\"MWFToolBarButton\" MWFButtonImage=\"/x_component_process_Xform/$Form/default/icon/headerdoc.png\" title=\""+MWF.xApplication.process.Xform.LP.headerdoc+"\" MWFButtonAction=\"_redheaderDoc\" MWFButtonText=\""+MWF.xApplication.process.Xform.LP.headerdoc+"\"></span>";
  964. }
  965. if (this.allowPrint){
  966. html += "<span MWFnodetype=\"MWFToolBarButton\" MWFButtonImage=\"/x_component_process_Xform/$Form/default/icon/print.png\" title=\""+MWF.xApplication.process.Xform.LP.printdoc+"\" MWFButtonAction=\"_printDoc\" MWFButtonText=\""+MWF.xApplication.process.Xform.LP.printdoc+"\"></span>";
  967. }
  968. this.toolbarNode = new Element("div", {"styles": this.css.doc_toolbar_node}).inject(this.toolNode);
  969. this.toolbarNode.set("html", html);
  970. MWF.require("MWF.widget.Toolbar", function() {
  971. this.toolbar = new MWF.widget.Toolbar(this.toolbarNode, {"style": "documentEdit"}, this);
  972. this.toolbar.load();
  973. }.bind(this));
  974. this.doublePageAction = new Element("div", {"styles": this.css.doc_toolbar_doublePage, "text": MWF.xApplication.process.Xform.LP.doublePage}).inject(this.toolbarNode);
  975. this.doublePageAction.addEvent("click", function(){
  976. if (this.options.pageShow!=="double"){
  977. this._doublePage();
  978. }else{
  979. this._singlePage();
  980. }
  981. }.bind(this));
  982. // this.zoomSelectAction = new Element("select", {"styles": {"float": "right"}}).inject(this.toolbarNode);
  983. // var options = "<option value='2'>200%</option> " +
  984. // "<option value='1.75'>175%</option>" +
  985. // "<option value='1.5'>150%</option>" +
  986. // "<option value='1' selected>100%</option>" +
  987. // "<option value='0.75'>75%</option>" +
  988. // "<option value='0.5'>50%</option>" +
  989. // "<option value='0.25'>25%</option>"
  990. // this.zoomSelectAction.set("html", options);
  991. // this.zoomSelectAction.addEvent("change", function(e){
  992. // this._returnScale();
  993. // this.scale = e.target.options[e.target.selectedIndex].value;
  994. // this.zoom();
  995. // }.bind(this));
  996. },
  997. _repage: function(delay){
  998. if (this.options.pageShow!=="double"){
  999. this._singlePage();
  1000. }else{
  1001. this._doublePage();
  1002. }
  1003. if (delay){
  1004. if (!this.form.isLoaded){
  1005. this.form.addEvent("afterLoad", this._checkScale.bind(this));
  1006. }else{
  1007. this._checkScale();
  1008. }
  1009. }else{
  1010. this._checkScale();
  1011. }
  1012. },
  1013. _singlePage: function(){
  1014. //if (this.eiitMode) this._readFiletext();
  1015. this.zoom(1);
  1016. this._checkScale();
  1017. var w = this.contentNode.getSize().x;
  1018. var count = 1;
  1019. var docPageFullWidth = (this.scale) ? this.scale*this.options.docPageFullWidth : this.options.docPageFullWidth;
  1020. //var docPageFullWidth = this.options.docPageFullWidt;
  1021. var pageWidth = count * docPageFullWidth;
  1022. var margin = (w-pageWidth)/(count+1);
  1023. if (this.isScale){
  1024. margin = "10";
  1025. }
  1026. if (this.scale) margin = margin/this.scale;
  1027. this.pages.each(function(page, i){
  1028. page.setStyles({
  1029. "float": "left",
  1030. "margin-left": ""+margin+"px"
  1031. });
  1032. });
  1033. this.resetNodeSize();
  1034. // this.pages.each(function(page){
  1035. // page.setStyle("float", "none");
  1036. // });
  1037. this.resizeSidebar();
  1038. this.options.pageShow="single";
  1039. this.doublePageAction.set("text", MWF.xApplication.process.Xform.LP.doublePage);
  1040. },
  1041. resetNodeSize: function(){
  1042. var contentSize = this.contentNode.getSize();
  1043. var toolbarSize = this.toolNode.getSize();
  1044. contentHeight = contentSize.y;
  1045. var h = contentHeight+toolbarSize.y+20;
  1046. //h = h - contentSize.y*(1-this.scale);
  1047. this.node.setStyles({
  1048. "height":""+h+"px"
  1049. });
  1050. },
  1051. createWaitSplitPage: function(){
  1052. debugger;
  1053. this.node.mask({
  1054. "style": {
  1055. "background-color": "#cccccc",
  1056. "opacity": 0.3
  1057. }
  1058. });
  1059. this.waitSplitPageNode = new Element("div", {"styles": this.form.css.waitSplitPageNode, "text": MWF.xApplication.process.Xform.LP.computePage}).inject(this.node);
  1060. this.waitSplitPageNode.position({
  1061. "relativeTo": this.node,
  1062. "position": "topRight",
  1063. "edge": "topRight",
  1064. "offset": {
  1065. "x": -10,
  1066. "y": 45
  1067. }
  1068. });
  1069. //this.form.notice(MWF.xApplication.process.Xform.LP.computePage, "info", this.node);
  1070. },
  1071. clearWaitSplitPage: function(){
  1072. this.node.unmask();
  1073. if (this.waitSplitPageNode) this.waitSplitPageNode.destroy();
  1074. this.waitSplitPageNode = null;
  1075. },
  1076. _doublePage: function(){
  1077. if (this.eiitMode) this._switchReadOrEditInline();
  1078. this.zoom(1);
  1079. this.createWaitSplitPage();
  1080. window.setTimeout(function(){
  1081. this._checkSplitPage(this.pages[0]);
  1082. this.zoom(1);
  1083. var w = this.contentNode.getSize().x;
  1084. var toPageWidth = (w-100)/2;
  1085. scale = toPageWidth/this.options.docPageFullWidth;
  1086. if (scale<1) this.zoom(scale);
  1087. var docPageFullWidth = (this.scale) ? this.scale*this.options.docPageFullWidth : this.options.docPageFullWidth;
  1088. //var docPageFullWidth = this.options.docPageFullWidth;
  1089. var w = this.contentNode.getSize().x;
  1090. var count = (w/docPageFullWidth).toInt();
  1091. var pages = this.contentNode.getElements(".doc_layout_page");
  1092. count = Math.min(pages.length, count);
  1093. var pageWidth = count * docPageFullWidth;
  1094. var margin = (w-pageWidth)/(count+1);
  1095. if (this.scale) margin = margin/(this.scale);
  1096. this.pages.each(function(page, i){
  1097. page.setStyles({
  1098. "float": "left",
  1099. "margin-left": ""+margin+"px"
  1100. });
  1101. });
  1102. // this.pages.each(function(page, i){
  1103. // if ((i % 2)===0){
  1104. // page.setStyle("float", "left");
  1105. // }else{
  1106. // page.setStyle("float", "right");
  1107. // }
  1108. // });
  1109. this.resetNodeSize();
  1110. this.options.pageShow="double";
  1111. this.doublePageAction.set("text", MWF.xApplication.process.Xform.LP.singlePage);
  1112. this.resizeSidebar();
  1113. this.clearWaitSplitPage();
  1114. }.bind(this), 1000);
  1115. },
  1116. _getDefaultData: function(){
  1117. return this.json.defaultValue;
  1118. //return Object.clone(MWF.xApplication.process.Xform.LP.documentEditor);
  1119. },
  1120. _loadFiletextPage: function(callback){
  1121. this.data = this._getBusinessData();
  1122. if (!this.data) this.data = this._getDefaultData();
  1123. this._computeData(true);
  1124. this._createPage(function(control){
  1125. this._loadPageLayout(control);
  1126. // this.data = this._getBusinessData();
  1127. // if (!this.data) this.data = this._getDefaultData();
  1128. this.setData(this.data);
  1129. // this._checkSplitPage(this.pages[0]);
  1130. //this._repage(true);
  1131. //this.loadCkeditorFiletext();
  1132. if (!this.readonly){
  1133. //if (this.json.allowEditFiletext!==false) this.loadCkeditorFiletext();
  1134. // if (this.json.allowEditRedheader) this.loadCkeditorRedheader();
  1135. // if (this.json.allowEditSubject) this.loadCkeditorSubject();
  1136. // if (this.json.allowEditMainSend) this.loadCkeditorMainSend();
  1137. // if (this.json.allowEditFileNo) this.loadCkeditorFileNo();
  1138. // if (this.json.allowEditSigner) this.loadCkeditorSigner();
  1139. // if (this.json.allowEditAttachment) this.loadCkeditorAttachment();
  1140. }
  1141. if (callback) callback();
  1142. }.bind(this));
  1143. },
  1144. _getEditorConfig: function(){
  1145. // var mathElements = [
  1146. // 'math',
  1147. // 'maction',
  1148. // 'maligngroup',
  1149. // 'malignmark',
  1150. // 'menclose',
  1151. // 'merror',
  1152. // 'mfenced',
  1153. // 'mfrac',
  1154. // 'mglyph',
  1155. // 'mi',
  1156. // 'mlabeledtr',
  1157. // 'mlongdiv',
  1158. // 'mmultiscripts',
  1159. // 'mn',
  1160. // 'mo',
  1161. // 'mover',
  1162. // 'mpadded',
  1163. // 'mphantom',
  1164. // 'mroot',
  1165. // 'mrow',
  1166. // 'ms',
  1167. // 'mscarries',
  1168. // 'mscarry',
  1169. // 'msgroup',
  1170. // 'msline',
  1171. // 'mspace',
  1172. // 'msqrt',
  1173. // 'msrow',
  1174. // 'mstack',
  1175. // 'mstyle',
  1176. // 'msub',
  1177. // 'msup',
  1178. // 'msubsup',
  1179. // 'mtable',
  1180. // 'mtd',
  1181. // 'mtext',
  1182. // 'mtr',
  1183. // 'munder',
  1184. // 'munderover',
  1185. // 'semantics',
  1186. // 'annotation',
  1187. // 'annotation-xml'
  1188. // ];
  1189. //CKEDITOR.plugins.addExternal('ckeditor_wiris', 'https://ckeditor.com/docs/ckeditor4/4.13.0/examples/assets/plugins/ckeditor_wiris/', 'plugin.js');
  1190. var editorConfig = {
  1191. qtRows: 20, // Count of rows
  1192. qtColumns: 20, // Count of columns
  1193. qtBorder: '1', // Border of inserted table
  1194. qtWidth: '95%', // Width of inserted table
  1195. qtStyle: { 'border-collapse' : 'collapse' },
  1196. qtClass: 'test', // Class of table
  1197. qtCellPadding: '0', // Cell padding table
  1198. qtCellSpacing: '0', // Cell spacing table
  1199. qtPreviewBorder: '4px double black', // preview table border
  1200. qtPreviewSize: '4px', // Preview table cell size
  1201. qtPreviewBackground: '#c8def4', // preview table background (hover)
  1202. // format_tags: '标题一;标题二;标题三;标题四;正文', // entries is displayed in "Paragraph format"
  1203. format_tags: '标题一;标题二;正文(标题三,四)', // entries is displayed in "Paragraph format"
  1204. 'format_标题一': {
  1205. name: '标题一',
  1206. element: 'div',
  1207. styles: {
  1208. 'font-family': '黑体',
  1209. 'font-size': '16pt'
  1210. }
  1211. },
  1212. 'format_标题二': {
  1213. name: '标题二',
  1214. element: 'div',
  1215. styles: {
  1216. 'font-family': '楷体',
  1217. 'font-size': '16pt'
  1218. }
  1219. },
  1220. // 'format_标题三': {
  1221. // name: '标题三',
  1222. // element: 'div',
  1223. // styles: {
  1224. // 'font-family': '仿宋',
  1225. // 'font-size': '16pt'
  1226. // }
  1227. // },
  1228. // 'format_标题四': {
  1229. // name: '标题四',
  1230. // element: 'div',
  1231. // styles: {
  1232. // 'font-family': '仿宋',
  1233. // 'font-size': '16pt'
  1234. // }
  1235. // },
  1236. 'format_正文(标题三,四)': {
  1237. name: '正文(标题三,四)',
  1238. element: 'div',
  1239. styles: {
  1240. 'font-family': '仿宋',
  1241. 'font-size': '16pt'
  1242. }
  1243. }
  1244. };
  1245. editorConfig.toolbarGroups = [
  1246. { name: 'document', groups: [ 'mode', 'document', 'doctools' ] },
  1247. { name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
  1248. { name: 'editing', groups: [ 'find', 'selection', 'spellchecker', 'editing' ] },
  1249. { name: 'forms', groups: [ 'forms' ] },
  1250. { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
  1251. { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi', 'paragraph' ] },
  1252. { name: 'links', groups: [ 'links' ] },
  1253. { name: 'insert', groups: [ 'insert' ] },
  1254. { name: 'styles', groups: [ 'styles' ] },
  1255. { name: 'colors', groups: [ 'colors' ] },
  1256. { name: 'tools', groups: [ 'tools' ] },
  1257. { name: 'others', groups: [ 'others' ] },
  1258. { name: 'about', groups: [ 'about' ] }
  1259. ];
  1260. //editorConfig.extraPlugins = "ecnet,colordialog,tableresize,quicktable,mathjax,ckeditor_wiris";
  1261. //editorConfig.extraPlugins = "ecnet,colordialog,quicktable,tableresize,eqneditor";
  1262. //editorConfig.extraPlugins = "tableresize,quicktable";
  1263. editorConfig.extraPlugins = "quicktable,tableresize";
  1264. //editorConfig.mathJaxLib = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=TeX-AMS_HTML',
  1265. editorConfig.removeButtons = 'NumberedList,Source,Save,NewPage,Preview,Print,Templates,Paste,PasteFromWord,Scayt,Form,Checkbox,Radio,TextField,Textarea,Select,Button,ImageButton,HiddenField,Bold,Italic,Underline,Strike,Subscript,Superscript,CopyFormatting,RemoveFormat,BulletedList,Outdent,Indent,Blockquote,CreateDiv,BidiLtr,BidiRtl,Language,Link,Unlink,Anchor,Image,Flash,HorizontalRule,Smiley,SpecialChar,PageBreak,Iframe,TextColor,BGColor,Maximize,ShowBlocks,About,Styles,Font,FontSize';
  1266. //editorConfig.extraAllowedContent = mathElements.join(' ') + '(*)[*]{*};img[data-mathml,data-custom-editor,role](Wirisformula)';
  1267. //editorConfig.removeButtons = 'NewPage,Templates,Scayt,Form,Checkbox,Radio,TextField,Textarea,Select,Button,ImageButton,HiddenField,Bold,Italic,Underline,Strike,Subscript,Superscript,Blockquote,CreateDiv,BidiLtr,BidiRtl,Language,Link,Unlink,Anchor,Image,Flash,HorizontalRule,Smiley,SpecialChar,Iframe,Styles,Font,FontSize,TextColor,BGColor,ShowBlocks,About';
  1268. editorConfig.removePlugins = ['magicline'];
  1269. editorConfig.enterMode = 3;
  1270. // editorConfig.extraPlugins = ['ecnet','mathjax'];
  1271. // editorConfig.removePlugins = ['magicline'];
  1272. // editorConfig.mathJaxLib = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=TeX-AMS_HTML';
  1273. return editorConfig;
  1274. },
  1275. _checkSplitPage: function(pageNode){
  1276. if (this.layout_edition) this.layout_edition.setStyles({ "position": "static"});
  1277. var contentNode = pageNode.getFirst();
  1278. if (contentNode.getSize().y>this.options.docPageHeight){
  1279. this._splitPage(pageNode);
  1280. }
  1281. var i = pageNode.get("data-pagecount").toInt();
  1282. if (i && this.pages.length-1>=i){
  1283. this._checkSplitPage(this.pages[i]);
  1284. }
  1285. if (this.layout_edition) this.layout_edition.setStyles({ "position": "absolute", "bottom": "0px" });
  1286. },
  1287. _splitFiletextNodeOneWord:function(lnode, nextPageNode){
  1288. var text = lnode.textContent;
  1289. var len = text.length;
  1290. var left = text.substring(0, len-1);
  1291. var right = text.substring(len-1, len);
  1292. lnode.textContent = left;
  1293. nextPageNode.textContent = right+nextPageNode.textContent;
  1294. //nextPageNode.appendText(right, "top");
  1295. },
  1296. _splitFiletext: function(node, nextPageNode, nextFiletextNode, pageNode){
  1297. var contentNode = pageNode.getFirst();
  1298. var lnode = node.lastChild;
  1299. if (!lnode){
  1300. if (node.parentNode) node.parentNode.removeChild(node);
  1301. //node.remove();
  1302. }else{
  1303. while (contentNode.getSize().y>this.options.docPageHeight && lnode) {
  1304. var tmpnode = lnode.previousSibling;
  1305. var nodeType = lnode.nodeType;
  1306. if (!nextPageNode) nextPageNode = nextFiletextNode;
  1307. if (nodeType == Node.ELEMENT_NODE) {
  1308. if (lnode.tagName == "table") {
  1309. lnode.inject(nextPageNode);
  1310. } else if (lnode.tagName == "BR") {
  1311. if (lnode.parentNode) lnode.parentNode.removeChild(lnode);
  1312. } else {
  1313. var id = lnode.get("data-pagePart");
  1314. if (!id){
  1315. id = (new o2.widget.UUID()).toString();
  1316. lnode.set("data-pagePart", id);
  1317. }
  1318. var tmpNode = nextPageNode.getFirst();
  1319. if (tmpNode && tmpNode.get("data-pagePart")==id){
  1320. nextPageNode = tmpNode;
  1321. }else{
  1322. nextPageNode = lnode.clone(false).inject(nextPageNode, "top");
  1323. }
  1324. //var subnode = lnode.getLast();
  1325. this._splitFiletext(lnode, nextPageNode, nextFiletextNode, pageNode);
  1326. if (!lnode.firstChild) if (lnode.parentNode) lnode.parentNode.removeChild(lnode);
  1327. nextPageNode = nextPageNode.getParent();
  1328. }
  1329. } else if (nodeType == Node.TEXT_NODE) {
  1330. var nextPageTextNode = nextPageNode.insertBefore(document.createTextNode(""), nextPageNode.firstChild);
  1331. while ((contentNode.getSize().y > this.options.docPageHeight) && lnode.textContent) {
  1332. //console.log(contentNode.getSize().y);
  1333. this._splitFiletextNodeOneWord(lnode, nextPageTextNode)
  1334. }
  1335. if (!lnode.textContent) if (lnode.parentNode) lnode.parentNode.removeChild(lnode); //lnode.remove();
  1336. } else {
  1337. //lnode.remove();
  1338. if (lnode.parentNode) lnode.parentNode.removeChild(lnode);
  1339. }
  1340. lnode = tmpnode;
  1341. }
  1342. if (!node.lastChild) if (node.parentNode) node.parentNode.removeChild(node); //node.remove();
  1343. }
  1344. //this._checkSplitPage(pageNode);
  1345. },
  1346. _splitPage: function(pageNode){
  1347. var contentNode = pageNode.getFirst();
  1348. var blockNodes = pageNode.getElements(".doc_block");
  1349. if (blockNodes.length){
  1350. var blockNode = blockNodes[blockNodes.length-1];
  1351. var idx = this.pages.indexOf(pageNode);
  1352. if (this.pages.length<=idx+1) this._createNewPage();
  1353. var nextPage = this.pages[idx+1];
  1354. if (blockNode.hasClass("doc_layout_filetext")){
  1355. var filetextNode = nextPage.getElement(".doc_layout_filetext");
  1356. if (!filetextNode){
  1357. filetextNode = new Element("div.doc_layout_filetext").inject(nextPage.getFirst(), "top");
  1358. //filetextNode.setAttribute('contenteditable', true);
  1359. }
  1360. if (!filetextNode.hasClass("doc_block"))filetextNode.addClass("doc_block");
  1361. //var nextEditor = filetextNode.retrieve("editor");
  1362. var node = blockNode;
  1363. var nextPageNode = filetextNode;
  1364. this._splitFiletext(node, nextPageNode, filetextNode, pageNode);
  1365. }else{
  1366. blockNode.inject(nextPage.getFirst(), "top");
  1367. //var contentNode = pageNode.getFirst();
  1368. if (contentNode.getSize().y>this.options.docPageHeight){
  1369. this._splitPage(pageNode);
  1370. }
  1371. }
  1372. }
  1373. },
  1374. loadCkeditorFiletext: function(callback, inline){
  1375. if (this.layout_filetext){
  1376. o2.load("/o2_lib/htmleditor/ckeditor4130/ckeditor.js", function(){
  1377. CKEDITOR.disableAutoInline = true;
  1378. this.layout_filetext.setAttribute('contenteditable', true);
  1379. if (inline){
  1380. this.filetextEditor = CKEDITOR.inline(this.layout_filetext, this._getEditorConfig());
  1381. }else{
  1382. this.filetextEditor = CKEDITOR.replace(this.layout_filetext, this._getEditorConfig());
  1383. }
  1384. this.filetextEditor.on("instanceReady", function(e){
  1385. if (callback) callback(e);
  1386. }.bind(this));
  1387. this.filetextEditor.on( 'focus', function( e ) {
  1388. window.setTimeout(this.reLocationFiletextToolbar.bind(this), 10);
  1389. }.bind(this) );
  1390. // this.filetextEditor.on("key", function(e){
  1391. // debugger;
  1392. // }.bind(this));
  1393. }.bind(this));
  1394. }
  1395. },
  1396. _loadEvents: function(editorConfig){
  1397. Object.each(this.json.events, function(e, key){
  1398. if (e.code){
  1399. this.editor.on(key, function(event){
  1400. return this.form.Macro.fire(e.code, this, event);
  1401. }.bind(this), this);
  1402. }
  1403. }.bind(this));
  1404. },
  1405. _bindFieldChange: function(name,dataItem, dom){
  1406. var field = this.form.all[this.json[dataItem]];
  1407. if (field){
  1408. var bindFun = function(){
  1409. this._computeItemFieldData(name, dataItem);
  1410. //if (this.data[name]){
  1411. if (this[dom]){
  1412. if (dom=="layout_redHeader" || dom=="layout_subject"){
  1413. this[dom].set("html", this.data[name]|| "");
  1414. }else if (dom=="layout_attachment"){
  1415. this.setAttachmentData();
  1416. }else{
  1417. this[dom].set("text", this.data[name]|| "");
  1418. }
  1419. }
  1420. this.reSetShow();
  1421. //}
  1422. }.bind(this);
  1423. field.node.store(this.json.id+"bindFun", bindFun);
  1424. field.addModuleEvent("change", bindFun);
  1425. }
  1426. },
  1427. _computeItemFieldData: function(name, dataItem){
  1428. var v = "";
  1429. var module = this.form.all[this.json[dataItem]];
  1430. if (module && module.getData) v = module.getData();
  1431. if (!v) v = this.form.businessData.data[this.json[dataItem]];
  1432. if (v){
  1433. var t = o2.typeOf(v);
  1434. switch (t) {
  1435. case "string":
  1436. switch (name) {
  1437. case "issuanceDate":
  1438. case "editionDate":
  1439. var d = new Date(v);
  1440. if (d.isValid()){
  1441. var y = d.getFullYear();
  1442. var m = d.getMonth();
  1443. var day = d.getDate();
  1444. m = m +1;
  1445. this.data[name] = ""+y+"年"+m+"月"+day+"日";
  1446. }else{
  1447. this.data[name] = v;
  1448. }
  1449. //this.data[name] = (new Date(v).isValid()) ? Date.parse(v).format("%Y年%m月%d%日") : v;
  1450. break;
  1451. case "mainSend":
  1452. this.data[name] = v + ":";
  1453. break;
  1454. default:
  1455. this.data[name] = v;
  1456. }
  1457. break;
  1458. case "array":
  1459. var strs = [];
  1460. v.each(function(value){
  1461. if (o2.typeOf(value)=="object" && value.distinguishedName){
  1462. strs.push(value.name);
  1463. }else{
  1464. strs.push(value.toString());
  1465. }
  1466. });
  1467. //if (strs.length){
  1468. switch (name) {
  1469. case "attachment":
  1470. // this.data[name] = strs.map(function(n, i){ var j = i+1; return j+"、"+n}).join("<br>");
  1471. var atts = strs.map(function(a){
  1472. return (a.indexOf(".")!=-1) ? a.substring(0, a.lastIndexOf(".")) : a;
  1473. });
  1474. this.data[name] = atts;
  1475. break;
  1476. case "issuanceDate":
  1477. case "editionDate":
  1478. var tmpStrs = strs.map(function(n, i){
  1479. var d = Date.parse(n);
  1480. return (d.isValid()) ? d.format("“%Y年%m月%d%日") : n;
  1481. });
  1482. this.data[name] = tmpStrs.join(",")
  1483. break;
  1484. case "mainSend":
  1485. debugger;
  1486. this.data[name] = strs.join(",") + ":";
  1487. break;
  1488. default:
  1489. this.data[name] = strs.join(",");
  1490. }
  1491. //}
  1492. break;
  1493. default:
  1494. this.data[name] = v.toString();
  1495. }
  1496. }else{
  1497. this.data[name] = this.json.defaultValue[name];
  1498. }
  1499. },
  1500. computeData: function(){
  1501. this._computeData(false);
  1502. this.setData(this.data);
  1503. },
  1504. _computeItemData: function(name, typeItem, dataItem, scriptItem, ev, dom){
  1505. switch (this.json[typeItem]) {
  1506. case "data":
  1507. if (this.json[dataItem]){
  1508. if (ev) this._bindFieldChange(name, dataItem, dom);
  1509. this._computeItemFieldData(name, dataItem);
  1510. }
  1511. break;
  1512. case "script":
  1513. debugger;
  1514. if (this.json[scriptItem] && this.json[scriptItem].code){
  1515. var v = this.form.Macro.exec(this.json[scriptItem].code, this);
  1516. this.data[name] = v;
  1517. if (name=="attachment"){
  1518. //this.data[name] = (typeOf(v)=="array") ? v.map(function(n, i){ var j = i+1; return j+"、"+n}).join("<br>") : v;
  1519. this.data[name] = (typeOf(v)=="array") ? v : [v];
  1520. }
  1521. if (name=="issuanceDate" || name=="editionDate"){
  1522. var d = Date.parse(v);
  1523. this.data[name] = (d.isValid()) ? d.format("“%Y年%m月%d%日") : v;
  1524. }
  1525. }
  1526. break;
  1527. }
  1528. },
  1529. _computeData: function(ev){
  1530. this._computeItemData("copies", "copiesValueType", "copiesValueData", "copiesValueScript", ev, "layout_copies");
  1531. this._computeItemData("secret", "secretValueType", "secretValueData", "secretValueScript", ev, "layout_secret");
  1532. this._computeItemData("priority", "priorityValueType", "priorityValueData", "priorityValueScript", ev, "layout_priority");
  1533. this._computeItemData("redHeader", "redHeaderValueType", "redHeaderValueData", "redHeaderValueScript", ev, "layout_redHeader");
  1534. this._computeItemData("fileno", "filenoValueType", "filenoValueData", "filenoValueScript", ev, "layout_fileno");
  1535. this._computeItemData("signer", "signerValueType", "signerValueData", "signerValueScript", ev, "layout_signer");
  1536. this._computeItemData("subject", "subjectValueType", "subjectValueData", "subjectValueScript", ev, "layout_subject");
  1537. this._computeItemData("mainSend", "mainSendValueType", "mainSendValueData", "mainSendValueScript", ev, "layout_mainSend");
  1538. this._computeItemData("attachment", "attachmentValueType", "attachmentValueData", "attachmentValueScript", ev, "layout_attachment");
  1539. this._computeItemData("issuanceUnit", "issuanceUnitValueType", "issuanceUnitValueData", "issuanceUnitValueScript", ev, "layout_issuanceUnit");
  1540. this._computeItemData("issuanceDate", "issuanceDateValueType", "issuanceDateValueData", "issuanceDateValueScript", ev, "layout_issuanceDate");
  1541. this._computeItemData("annotation", "annotationValueType", "annotationValueData", "annotationValueScript", ev, "layout_annotation");
  1542. this._computeItemData("copyto", "copytoValueType", "copytoValueData", "copytoValueScript", ev, "layout_copytoContent");
  1543. this._computeItemData("copyto2", "copyto2ValueType", "copyto2ValueData", "copyto2ValueScript", ev, "layout_copyto2Content");
  1544. this._computeItemData("editionUnit", "editionUnitValueType", "editionUnitValueData", "editionUnitValueScript", ev, "layout_edition_issuance_unit");
  1545. this._computeItemData("editionDate", "editionDateValueType", "editionDateValueData", "editionDateValueScript", ev, "layout_edition_issuance_date");
  1546. this._computeItemData("meetingAttend", "meetingAttendValueType", "meetingAttendValueData", "meetingAttendValueScript", ev, "layout_meetingAttendContent");
  1547. this._computeItemData("meetingLeave", "meetingLeaveValueType", "meetingLeaveValueData", "meetingLeaveValueScript", ev, "layout_meetingLeaveContent");
  1548. this._computeItemData("meetingSit", "meetingSitValueType", "meetingSitValueData", "meetingSitValueScript", ev, "layout_meetingSitContent");
  1549. },
  1550. _loadValue: function(){
  1551. var data = this._getBusinessData();
  1552. },
  1553. reload: function(){
  1554. this.resetData();
  1555. },
  1556. resetData: function(){
  1557. this._computeData(false);
  1558. this.pages = [];
  1559. this.contentNode.empty();
  1560. if (this.allowEdit) this.toolbar.childrenButton[0].setText(MWF.xApplication.process.Xform.LP.editdoc);
  1561. this.eiitMode = false;
  1562. this._createPage(function(control){
  1563. this._loadPageLayout(control);
  1564. this.setData(this.data);
  1565. this._checkSplitPage(this.pages[0]);
  1566. this._repage();
  1567. }.bind(this));
  1568. },
  1569. getData: function(){
  1570. //if (this.eiitMode){
  1571. if (this.layout_copies) this.data.copies = this.layout_copies.get("text");
  1572. if (this.layout_secret) this.data.secret = this.layout_secret.get("text");
  1573. if (this.layout_priority) this.data.priority = this.layout_priority.get("text");
  1574. if (this.layout_redHeader) this.data.redHeader = this.layout_redHeader.get("html");
  1575. if (this.layout_fileno) this.data.fileno = this.layout_fileno.get("text");
  1576. if (this.layout_signerTitle) this.data.signerTitle = this.layout_signerTitle.get("text");
  1577. if (this.layout_signer) this.data.signer = this.layout_signer.get("text");
  1578. if (this.layout_subject) this.data.subject = this.layout_subject.get("html");
  1579. if (this.layout_mainSend) this.data.mainSend = this.layout_mainSend.get("text");
  1580. if (this.eiitMode) if (this.layout_filetext) this.data.filetext = this.layout_filetext.get("html");
  1581. if (this.layout_signer) this.data.signer = this.layout_signer.get("text");
  1582. if (this.layout_attachmentTitle) this.data.attachmentTitle = this.layout_attachmentTitle.get("text");
  1583. if (this.layout_attachment){
  1584. this._computeItemData("attachment", "attachmentValueType", "attachmentValueData", "attachmentValueScript", false, "layout_attachment");
  1585. // var atts = [];
  1586. // var nodes = this.layout_attachment.getElements(".doc_layout_attachment_content_name");
  1587. // if (nodes.length){
  1588. // nodes.each(function(node){
  1589. // atts.push(node.get("text"));
  1590. // });
  1591. // }
  1592. // this.data.attachment = atts;
  1593. }
  1594. if (this.layout_issuanceUnit) this.data.issuanceUnit = this.layout_issuanceUnit.get("text");
  1595. if (this.layout_issuanceDate) this.data.issuanceDate = this.layout_issuanceDate.get("text");
  1596. if (this.layout_annotation) this.data.annotation = this.layout_annotation.get("text");
  1597. if (this.layout_copytoTitle) this.data.copytoTitle = this.layout_copytoTitle.get("text");
  1598. if (this.layout_copytoContent) this.data.copyto = this.layout_copytoContent.get("text");
  1599. if (this.layout_copyto2Title) this.data.copyto2Title = this.layout_copyto2Title.get("text");
  1600. if (this.layout_copyto2Content) this.data.copyto2 = this.layout_copyto2Content.get("text");
  1601. if (this.layout_edition_issuance_unit) this.data.editionUnit = this.layout_edition_issuance_unit.get("text");
  1602. if (this.layout_edition_issuance_date) this.data.editionDate = this.layout_edition_issuance_date.get("text");
  1603. if (this.layout_meetingAttendTitle) this.data.meetingAttendTitle = this.layout_meetingAttendTitle.get("text");
  1604. if (this.layout_meetingLeaveTitle) this.data.meetingLeaveTitle = this.layout_meetingLeaveTitle.get("text");
  1605. if (this.layout_meetingSitTitle) this.data.meetingSitTitle = this.layout_meetingSitTitle.get("text");
  1606. if (this.layout_meetingAttendContent) this.data.meetingAttend = this.layout_meetingAttendContent.get("html");
  1607. if (this.layout_meetingLeaveContent) this.data.meetingLeave = this.layout_meetingLeaveContent.get("html");
  1608. if (this.layout_meetingSitContent) this.data.meetingSit = this.layout_meetingSitContent.get("html");
  1609. //}
  1610. return this.data;
  1611. },
  1612. setAttachmentData: function(){
  1613. if (!this.attachmentTemplete){
  1614. this.attachmentTemplete = this.layout_attachment.get("html");
  1615. }
  1616. this.layout_attachment.empty();
  1617. if (this.data.attachment && this.data.attachment.length && this.data.attachment.each){
  1618. //var tmpdiv = new Element("div", {"styles": {"display":"none"}}).inject(document.body);
  1619. var tmpdiv = new Element("div");
  1620. this.data.attachment.each(function(name, idx){
  1621. tmpdiv.set("html", this.attachmentTemplete);
  1622. var serialNode = tmpdiv.getElement(".doc_layout_attachment_content_serial");
  1623. var nameNode = tmpdiv.getElement(".doc_layout_attachment_content_name");
  1624. if (serialNode) serialNode.set("text", idx+1);
  1625. if (nameNode) nameNode.set("text", name);
  1626. var html = tmpdiv.get("html");
  1627. tmpdiv.empty();
  1628. this.layout_attachment.appendHTML(html);
  1629. }.bind(this));
  1630. tmpdiv.destroy();
  1631. }
  1632. },
  1633. setData: function(data){
  1634. if (data){
  1635. debugger;
  1636. this.data = data;
  1637. // this.data["$json"] = this.json;
  1638. this._setBusinessData(data);
  1639. if (this.layout_copies) this.layout_copies.set("text", data.copies || " ");
  1640. if (this.layout_secret) this.layout_secret.set("text", data.secret || " ");
  1641. if (this.layout_priority) this.layout_priority.set("text", data.priority || " ");
  1642. if (this.layout_redHeader) this.layout_redHeader.set("html", data.redHeader || "");
  1643. if (this.layout_fileno) this.layout_fileno.set("text", data.fileno || " ");
  1644. if (this.layout_signerTitle) this.layout_signerTitle.set("text", data.signerTitle || " ");
  1645. if (this.layout_signer) this.layout_signer.set("text", data.signer || " ");
  1646. if (this.layout_subject) this.layout_subject.set("html", data.subject || " ");
  1647. if (this.layout_mainSend) this.layout_mainSend.set("text", data.mainSend || " ");
  1648. if (this.layout_filetext) this.layout_filetext.set("html", data.filetext || "");
  1649. if (this.layout_signer) this.layout_signer.set("text", data.signer || "");
  1650. if (this.layout_attachmentTitle) this.layout_attachmentTitle.set("text", data.attachmentTitle || " ");
  1651. if (this.layout_attachment){
  1652. this.setAttachmentData();
  1653. }
  1654. if (this.layout_issuanceUnit) this.layout_issuanceUnit.set("text", data.issuanceUnit || " ");
  1655. if (this.layout_issuanceDate) this.layout_issuanceDate.set("text", data.issuanceDate || " ");
  1656. if (this.layout_annotation) this.layout_annotation.set("text", data.annotation || " ");
  1657. if (this.layout_copytoTitle) this.layout_copytoTitle.set("text", data.copytoTitle || " ");
  1658. if (this.layout_copytoContent) this.layout_copytoContent.set("text", data.copyto || " ");
  1659. if (this.layout_copyto2Title) this.layout_copyto2Title.set("text", data.copyto2Title || " ");
  1660. if (this.layout_copyto2Content) this.layout_copyto2Content.set("text", data.copyto2 || " ");
  1661. if (this.layout_edition_issuance_unit) this.layout_edition_issuance_unit.set("text", data.editionUnit || " ");
  1662. if (this.layout_edition_issuance_date) this.layout_edition_issuance_date.set("text", data.editionDate || " ");
  1663. if (this.layout_meetingAttendTitle) this.layout_meetingAttendTitle.set("text", data.meetingAttendTitle || this.json.defaultValue.meetingAttendTitle || " ");
  1664. if (this.layout_meetingLeaveTitle) this.layout_meetingLeaveTitle.set("text", data.meetingLeaveTitle || this.json.defaultValue.meetingLeaveTitle || " ");
  1665. if (this.layout_meetingSitTitle) this.layout_meetingSitTitle.set("text", data.meetingSitTitle || this.json.defaultValue.meetingSitTitle || " ");
  1666. if (this.layout_meetingAttendContent) this.layout_meetingAttendContent.set("html", data.meetingAttend || " ");
  1667. if (this.layout_meetingLeaveContent) this.layout_meetingLeaveContent.set("html", data.meetingLeave || " ");
  1668. if (this.layout_meetingSitContent) this.layout_meetingSitContent.set("html", data.meetingSit || " ");
  1669. }
  1670. },
  1671. createErrorNode: function(text){
  1672. var node = new Element("div");
  1673. var iconNode = new Element("div", {
  1674. "styles": {
  1675. "width": "20px",
  1676. "height": "20px",
  1677. "float": "left",
  1678. "background": "url("+"/x_component_process_Xform/$Form/default/icon/error.png) center center no-repeat"
  1679. }
  1680. }).inject(node);
  1681. var textNode = new Element("div", {
  1682. "styles": {
  1683. "line-height": "20px",
  1684. "margin-left": "20px",
  1685. "color": "red",
  1686. "word-break": "keep-all"
  1687. },
  1688. "text": text
  1689. }).inject(node);
  1690. return node;
  1691. },
  1692. notValidationMode: function(text){
  1693. if (!this.isNotValidationMode){
  1694. this.isNotValidationMode = true;
  1695. this.node.store("borderStyle", this.node.getStyles("border-left", "border-right", "border-top", "border-bottom"));
  1696. this.node.setStyle("border", "1px solid red");
  1697. this.errNode = this.createErrorNode(text).inject(this.node, "after");
  1698. this.showNotValidationMode(this.node);
  1699. }
  1700. },
  1701. showNotValidationMode: function(node){
  1702. var p = node.getParent("div");
  1703. if (p){
  1704. if (p.get("MWFtype") == "tab$Content"){
  1705. if (p.getParent("div").getStyle("display")=="none"){
  1706. var contentAreaNode = p.getParent("div").getParent("div");
  1707. var tabAreaNode = contentAreaNode.getPrevious("div");
  1708. var idx = contentAreaNode.getChildren().indexOf(p.getParent("div"));
  1709. var tabNode = tabAreaNode.getLast().getFirst().getChildren()[idx];
  1710. tabNode.click();
  1711. p = tabAreaNode.getParent("div");
  1712. }
  1713. }
  1714. this.showNotValidationMode(p);
  1715. }
  1716. },
  1717. validationMode: function(){
  1718. if (this.isNotValidationMode){
  1719. this.isNotValidationMode = false;
  1720. this.node.setStyles(this.node.retrieve("borderStyle"));
  1721. if (this.errNode){
  1722. this.errNode.destroy();
  1723. this.errNode = null;
  1724. }
  1725. }
  1726. },
  1727. validationConfigItem: function(routeName, data){
  1728. var flag = (data.status=="all") ? true: (routeName == data.decision);
  1729. if (flag){
  1730. var n = this.getData();
  1731. var v = (data.valueType=="value") ? n : n.length;
  1732. switch (data.operateor){
  1733. case "isnull":
  1734. if (!v){
  1735. this.notValidationMode(data.prompt);
  1736. return false;
  1737. }
  1738. break;
  1739. case "notnull":
  1740. if (v){
  1741. this.notValidationMode(data.prompt);
  1742. return false;
  1743. }
  1744. break;
  1745. case "gt":
  1746. if (v>data.value){
  1747. this.notValidationMode(data.prompt);
  1748. return false;
  1749. }
  1750. break;
  1751. case "lt":
  1752. if (v<data.value){
  1753. this.notValidationMode(data.prompt);
  1754. return false;
  1755. }
  1756. break;
  1757. case "equal":
  1758. if (v==data.value){
  1759. this.notValidationMode(data.prompt);
  1760. return false;
  1761. }
  1762. break;
  1763. case "neq":
  1764. if (v!=data.value){
  1765. this.notValidationMode(data.prompt);
  1766. return false;
  1767. }
  1768. break;
  1769. case "contain":
  1770. if (v.indexOf(data.value)!=-1){
  1771. this.notValidationMode(data.prompt);
  1772. return false;
  1773. }
  1774. break;
  1775. case "notcontain":
  1776. if (v.indexOf(data.value)==-1){
  1777. this.notValidationMode(data.prompt);
  1778. return false;
  1779. }
  1780. break;
  1781. }
  1782. }
  1783. return true;
  1784. },
  1785. validationConfig: function(routeName, opinion){
  1786. if (this.json.validationConfig){
  1787. if (this.json.validationConfig.length){
  1788. for (var i=0; i<this.json.validationConfig.length; i++) {
  1789. var data = this.json.validationConfig[i];
  1790. if (!this.validationConfigItem(routeName, data)) return false;
  1791. }
  1792. }
  1793. return true;
  1794. }
  1795. return true;
  1796. },
  1797. validation: function(routeName, opinion){
  1798. if (!this.validationConfig(routeName, opinion)) return false;
  1799. if (!this.json.validation) return true;
  1800. if (!this.json.validation.code) return true;
  1801. var flag = this.form.Macro.exec(this.json.validation.code, this);
  1802. if (!flag) flag = MWF.xApplication.process.Xform.LP.notValidation;
  1803. if (flag.toString()!="true"){
  1804. this.notValidationMode(flag);
  1805. return false;
  1806. }
  1807. return true;
  1808. },
  1809. removeDisplayNone: function(node){
  1810. var n = node.getFirst();
  1811. while (n){
  1812. if (n.getStyle("display")=="none"){
  1813. var tmp = n.getNext();
  1814. n.destroy();
  1815. n = tmp;
  1816. }else{
  1817. n = this.removeDisplayNone(n);
  1818. n = n.getNext();
  1819. }
  1820. }
  1821. return node;
  1822. },
  1823. toWord: function(callback, name){
  1824. var toEdit = false;
  1825. if (this.eiitMode){
  1826. toEdit = true;
  1827. this._readFiletext();
  1828. }
  1829. //this._returnScale();
  1830. this.zoom(1);
  1831. this.pages = [];
  1832. this.contentNode.empty();
  1833. this._createPage(function(control){
  1834. this._loadPageLayout(control);
  1835. this.setData(this.data);
  1836. this._checkScale();
  1837. this.node.setStyles({
  1838. "height":"auto"
  1839. });
  1840. //var content = this.contentNode.getFirst().getFirst().get("html");
  1841. var tmpNode = this.contentNode.getFirst().getFirst().clone(true);
  1842. tmpNode = this.removeDisplayNone(tmpNode);
  1843. var content = tmpNode.get("html");
  1844. var body = {
  1845. "fileName": name || this.json.toWordFilename || "$doc.doc",
  1846. "site": this.json.toWordSite || "$doc",
  1847. "content": content
  1848. };
  1849. o2.Actions.get("x_processplatform_assemble_surface").docToWord(this.form.businessData.work.id, body, function(json){
  1850. if (this.form.businessData.workCompleted){
  1851. o2.Actions.get("x_processplatform_assemble_surface").getAttachmentWorkcompleted(json.data.id, this.form.businessData.workCompleted.id,function(attjson){
  1852. if (callback) callback(attjson.data);
  1853. this.showToWord(attjson.data);
  1854. }.bind(this));
  1855. }else{
  1856. o2.Actions.get("x_processplatform_assemble_surface").getAttachment(json.data.id, this.form.businessData.work.id,function(attjson){
  1857. if (callback) callback(attjson.data);
  1858. this.showToWord(attjson.data);
  1859. }.bind(this));
  1860. }
  1861. }.bind(this));
  1862. tmpNode.destroy();
  1863. if (!toEdit){
  1864. this._readFiletext();
  1865. }else{
  1866. this._createEditor();
  1867. }
  1868. }.bind(this));
  1869. },
  1870. docToWord: function(){
  1871. var flag = true;
  1872. if (this.json.toWordConditionScript && this.json.toWordConditionScript.code){
  1873. flag = !!this.form.Macro.exec(this.json.toWordConditionScript.code, this);
  1874. }
  1875. if (flag){
  1876. this.toWord();
  1877. }
  1878. },
  1879. showToWord: function(att){
  1880. var site = this.json.toWordSite || "$doc";
  1881. var attModule = this.form.all[site];
  1882. if (attModule){
  1883. attModule.attachmentController.clear();
  1884. attModule.attachmentController.addAttachment(att);
  1885. }
  1886. }
  1887. });