Documenteditor.js 139 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020
  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", "loadPage"],
  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. if (!this.json.isDelay){
  42. this.active();
  43. }
  44. },
  45. active: function(){
  46. this._loadModuleEvents();
  47. if (this.fireEvent("queryLoad")){
  48. this.fireEvent("beforeLoad");
  49. this.cssPath = this.form.path+this.form.options.style+"/doc.wcss";
  50. this._loadCss();
  51. this._queryLoaded();
  52. this._loadUserInterface(function(){
  53. this.fireEvent("postLoad");
  54. this.fireEvent("afterLoad");
  55. this.fireEvent("load");
  56. this.form.app.addEvent("resize", function(){
  57. // if (this.options.pageShow!=="double"){
  58. // this._doublePage();
  59. // }else{
  60. this._singlePage();
  61. // }
  62. this._checkScale();
  63. }.bind(this));
  64. }.bind(this));
  65. this._loadStyles();
  66. this._afterLoaded();
  67. }
  68. },
  69. _createNewPage: function(){
  70. var pageNode = new Element("div.doc_layout_page", {"styles": this.css.doc_page}).inject(this.contentNode);
  71. var pageContentNode = new Element("div.doc_layout_page_content", {"styles": this.css.doc_layout_page_content}).inject(pageNode);
  72. pageNode.set("data-pagecount", this.pages.length+1);
  73. this.pages.push(pageNode);
  74. return pageNode;
  75. },
  76. _getShow: function(name, typeItem, scriptItem){
  77. switch (this.json[typeItem]) {
  78. case "y":
  79. return true;
  80. case "n":
  81. return false;
  82. case "a":
  83. if (["copies", "secret", "priority", "attachment", "annotation", "copyto", "copyto2"].indexOf(name!=-1)){
  84. return !!this.data[name] && (!!this.data[name].length);
  85. }
  86. return true;
  87. case "s":
  88. if (this.json[scriptItem] && this.json[scriptItem].code){
  89. return !!this.form.Macro.exec(this.json[scriptItem].code, this);
  90. }
  91. return true;
  92. default:
  93. return true;
  94. }
  95. },
  96. _createPage: function(callback){
  97. var pageContentNode = this._createNewPage().getFirst();
  98. var control = this.getShowControl();
  99. this.json.fileup = !!(control.signer);
  100. if (this.json.css && this.json.css.code && !this.styleNode){
  101. var cssText = this.form.parseCSS(this.json.css.code);
  102. cssText = cssText.replace(/documenteditor_table/g, 'documenteditor_table'+this.form.json.id+this.json.id)
  103. // var rex = new RegExp("(.+)(?=\\{)", "g");
  104. // var match;
  105. // var id = this.json.id.replace(/\-/g, "");
  106. // var prefix = this.form.json.id+this.json.id;
  107. //
  108. // while ((match = rex.exec(cssText)) !== null) {
  109. // var rulesStr = match[0];
  110. // if (rulesStr.indexOf(",")!=-1){
  111. // var rules = rulesStr.split(/\s*,\s*/g);
  112. // rules = rules.map(function(r){
  113. // return r+prefix;
  114. // });
  115. // var rule = rules.join(", ");
  116. // cssText = cssText.substring(0, match.index) + rule + cssText.substring(rex.lastIndex, cssText.length);
  117. // rex.lastIndex = rex.lastIndex + (prefix.length*rules.length);
  118. //
  119. // }else{
  120. // var rule = match[0]+prefix;
  121. // cssText = cssText.substring(0, match.index) + rule + cssText.substring(rex.lastIndex, cssText.length);
  122. // rex.lastIndex = rex.lastIndex + prefix.length;
  123. // }
  124. // }
  125. var styleNode = document.createElement("style");
  126. styleNode.setAttribute("type", "text/css");
  127. styleNode.id="style"+this.json.id;
  128. //styleNode.inject(pageContentNode);
  129. styleNode.inject(this.node, "top");
  130. if(styleNode.styleSheet){
  131. var setFunc = function(){
  132. styleNode.styleSheet.cssText = cssText;
  133. };
  134. if(styleNode.styleSheet.disabled){
  135. setTimeout(setFunc, 10);
  136. }else{
  137. setFunc();
  138. }
  139. }else{
  140. var cssTextNode = document.createTextNode(cssText);
  141. styleNode.appendChild(cssTextNode);
  142. }
  143. this.styleNode = styleNode;
  144. }
  145. if (this.json.documentTempleteType=="cus"){
  146. pageContentNode.loadHtml(o2.filterUrl(this.json.documentTempleteUrl), function(){
  147. if (this.json.toWordPageNumber=="y") this.doPageStyles(pageContentNode);
  148. if (this.attachmentTemplete){
  149. var attNode = pageContentNode.getElement(".doc_layout_attachment_content");
  150. if (attNode) attNode.empty();
  151. }
  152. if (callback) callback(control);
  153. this.fireEvent("loadPage");
  154. }.bind(this));
  155. }else{
  156. this.getTempleteJson(function(){
  157. var templete = this.json.documentTempleteName || "standard";
  158. pageContentNode.loadHtml(o2.filterUrl("../x_component_process_FormDesigner/Module/Documenteditor/templete/"+this.templeteJson[templete].file), function(){
  159. if (this.json.toWordPageNumber=="y") this.doPageStyles(pageContentNode);
  160. if (this.attachmentTemplete){
  161. var attNode = pageContentNode.getElement(".doc_layout_attachment_content");
  162. if (attNode) attNode.empty();
  163. }
  164. if (callback) callback(control);
  165. this.fireEvent("loadPage");
  166. }.bind(this));
  167. }.bind(this));
  168. }
  169. },
  170. doPageStyles: function(pageContentNode){
  171. var style = pageContentNode.getLast("style");
  172. if (style){
  173. var origin = window.location.origin;
  174. var header = o2.filterUrl(origin+"/x_component_process_FormDesigner/Module/Documenteditor/header.htm");
  175. var text = style.get("html");
  176. var pageRex = /(?:@page\s*\{)([\s\S]*?)(?:\})/;
  177. var arr = text.match(pageRex);
  178. if (arr && arr.length){
  179. cssText = arr[2];
  180. if (cssText){
  181. var last = cssText.substr(cssText.length-1,1);
  182. if (last!==";") cssText = cssText+";";
  183. cssText += "mso-page-border-surround-header:no;\n" +
  184. " mso-page-border-surround-footer:no;\n" +
  185. " mso-footnote-separator:url(\""+header+"\") fs;\n" +
  186. " mso-footnote-continuation-separator:url(\""+header+"\") fcs;\n" +
  187. " mso-endnote-separator:url(\""+header+"\") es;\n" +
  188. " mso-endnote-continuation-separator:url(\""+header+"\") ecs;\n" +
  189. " mso-facing-pages:yes;";
  190. text = text.replace(arr[0], arr[1]+cssText+arr[3]);
  191. }
  192. }else{
  193. text += "@page\n" +
  194. " {mso-page-border-surround-header:no;\n" +
  195. " mso-page-border-surround-footer:no;\n" +
  196. " mso-footnote-separator:url(\""+header+"\") fs;\n" +
  197. " mso-footnote-continuation-separator:url(\""+header+"\") fcs;\n" +
  198. " mso-endnote-separator:url(\""+header+"\") es;\n" +
  199. " mso-endnote-continuation-separator:url(\""+header+"\") ecs;\n" +
  200. " mso-facing-pages:yes;}"
  201. }
  202. pageRex = /(@page\s*WordSection1\s*\{)([\s\S]*?)(\})/;
  203. arr = text.match(pageRex);
  204. if (arr && arr.length){
  205. cssText = arr[2];
  206. if (cssText){
  207. var last = cssText.substr(cssText.length-1,1);
  208. if (last!==";") cssText = cssText+";";
  209. cssText += "mso-header-margin:42.55pt;\n" +
  210. " mso-footer-margin:70.9pt;\n" +
  211. " mso-even-footer:url(\""+header+"\") ef1;\n" +
  212. " mso-footer:url(\""+header+"\") f1;\n" +
  213. " mso-paper-source:0;";
  214. text = text.replace(arr[0], arr[1]+cssText+arr[3]);
  215. }
  216. }else{
  217. text += "@page WordSection1\n" +
  218. " {size:595.3pt 841.9pt;\n" +
  219. " margin:104.9pt 73.7pt 99.25pt 79.4pt;\n" +
  220. " layout-grid:15.6pt;\n" +
  221. " line-height:normal;\n" +
  222. " font-size:16.0pt;\n" +
  223. " font-family:仿宋;\n" +
  224. " letter-spacing:-0.4pt;\n" +
  225. " mso-header-margin:42.55pt;\n" +
  226. " mso-footer-margin:70.9pt;\n" +
  227. " mso-even-footer:url(\""+header+"\") ef1;\n" +
  228. " mso-footer:url(\""+header+"\") f1;\n" +
  229. " mso-paper-source:0;\n" +
  230. " }"
  231. }
  232. style.set("html", text)
  233. }
  234. },
  235. getTempleteJson: function(callback){
  236. if (this.templeteJson){
  237. if (callback) callback();
  238. }else{
  239. o2.getJSON(o2.filterUrl("../x_component_process_FormDesigner/Module/Documenteditor/templete/templete.json"), function(json){
  240. this.templeteJson = json;
  241. if (callback) callback();
  242. }.bind(this));
  243. }
  244. },
  245. getShowControl: function(){
  246. var control = {};
  247. control.copiesSecretPriority = this._getShow("copiesSecretPriority", "copiesSecretPriorityShow", "copiesSecretPriorityShowScript");
  248. control.copies = this._getShow("copies", "copiesShow", "copiesShowScript");
  249. control.secret = this._getShow("secret", "secretShow", "secretShowScript");
  250. control.priority = this._getShow("priority", "priorityShow", "priorityShowScript");
  251. control.redHeader = this._getShow("redHeader", "redHeaderShow", "redHeaderShowScript");
  252. control.redLine = this._getShow("redLine", "redLineShow", "redLineShowScript");
  253. control.signer = this._getShow("signer", "signerShow", "signerShowScript");
  254. control.fileno = this._getShow("fileno", "filenoShow", "filenoShowScript");
  255. control.subject = this._getShow("subject", "subjectShow", "subjectShowScript");
  256. control.mainSend = this._getShow("mainSend", "mainSendShow", "mainSendShowScript");
  257. control.attachment = this._getShow("attachment", "attachmentShow", "attachmentShowScript");
  258. control.issuanceUnit = this._getShow("issuanceUnit", "issuanceUnitShow", "issuanceUnitShowScript");
  259. control.issuanceDate = this._getShow("issuanceDate", "issuanceDateShow", "issuanceDateShowScript");
  260. control.annotation = this._getShow("annotation", "annotationShow", "annotationShowScript");
  261. control.copyto = this._getShow("copyto", "copytoShow", "copytoShowScript");
  262. control.copyto2 = this._getShow("copyto2", "copyto2Show", "copyto2ShowScript");
  263. control.editionUnit = this._getShow("editionUnit", "editionUnitShow", "editionUnitShowScript");
  264. control.editionDate = this._getShow("editionDate", "editionDateShow", "editionDateShowScript");
  265. control.meetingAttend = this._getShow("meetingAttend", "meetingAttendShow", "meetingAttendShowScript");
  266. control.meetingLeave = this._getShow("meetingLeave", "meetingLeaveShow", "meetingLeaveShowScript");
  267. control.meetingSit = this._getShow("meetingSit", "meetingSitShow", "meetingSitShowScript");
  268. control.meetingRecord = this._getShow("meetingRecord", "meetingRecordShow", "meetingRecordShowScript");
  269. return control;
  270. },
  271. // _getEdit: function(name, typeItem, scriptItem){
  272. // switch (this.json[typeItem]) {
  273. // case "y":
  274. // return true;
  275. // case "n":
  276. // return false;
  277. // // case "a":
  278. // // if (["copies", "secret", "priority", "attachment", "annotation", "copyto"].indexOf(name!=-1)){
  279. // // return !!this.data[name] && (!!this.data[name].length);
  280. // // }
  281. // // return true;
  282. // case "s":
  283. // if (this.json[scriptItem] && this.json[scriptItem].code){
  284. // return !!this.form.Macro.exec(this.json[scriptItem].code, this);
  285. // }
  286. // return true;
  287. // }
  288. // },
  289. getEditControl: function(){
  290. var control = {};
  291. control.copies = this._getEdit("copies", "copiesEdit", "copiesEditScript");
  292. control.secret = this._getEdit("secret", "secretEdit", "secretEditScript");
  293. control.priority = this._getEdit("priority", "priorityEdit", "priorityEditScript");
  294. control.redHeader = this._getEdit("redHeader", "redHeaderEdit", "redHeaderEditScript");
  295. control.signer = this._getEdit("signer", "signerEdit", "signerEditScript");
  296. control.fileno = this._getEdit("fileno", "filenoEdit", "filenoEditScript");
  297. control.subject = this._getEdit("subject", "subjectEdit", "subjectEditScript");
  298. control.mainSend = this._getEdit("mainSend", "mainSendEdit", "mainSendEditScript");
  299. control.attachment = this._getEdit("attachment", "attachmentEdit", "attachmentEditScript");
  300. control.issuanceUnit = this._getEdit("issuanceUnit", "issuanceUnitEdit", "issuanceUnitEditScript");
  301. control.issuanceDate = this._getEdit("issuanceDate", "issuanceDateEdit", "issuanceDateEditScript");
  302. control.annotation = this._getEdit("annotation", "annotationEdit", "annotationEditScript");
  303. control.copyto = this._getEdit("copyto", "copytoEdit", "copytoEditScript");
  304. control.copyto2 = this._getEdit("copyto2", "copyto2Edit", "copyto2EditScript");
  305. control.editionUnit = this._getEdit("editionUnit", "editionUnitEdit", "editionUnitEditScript");
  306. control.editionDate = this._getEdit("editionDate", "editionDateEdit", "editionDateEditScript");
  307. control.meetingAttend = this._getShow("meetingAttend", "meetingAttendEdit", "meetingAttendEditScript");
  308. control.meetingLeave = this._getShow("meetingLeave", "meetingLeaveEdit", "meetingLeaveEditScript");
  309. control.meetingSit = this._getShow("meetingSit", "meetingSitEdit", "meetingSitEditScript");
  310. control.meetingRecord = this._getShow("meetingRecord", "meetingRecordEdit", "meetingRecordEditScript");
  311. return control;
  312. },
  313. //份数 密级 紧急程度
  314. _loadCopiesSecretPriority: function(){
  315. this.layout_copiesSecretPriority = this.contentNode.getElement(".doc_layout_copiesSecretPriority");
  316. if (this.layout_copiesSecretPriority) this.layout_copiesSecretPriority.setStyles(this.css.doc_layout_copiesSecretPriority);
  317. this.layout_copies = this.contentNode.getElement(".doc_layout_copies");
  318. if (this.layout_copies) this.layout_copies.setStyles(this.css.doc_layout_copies);
  319. this.layout_secret = this.contentNode.getElement(".doc_layout_secret");
  320. if (this.layout_secret) this.layout_secret.setStyles(this.css.doc_layout_secret);
  321. this.layout_priority = this.contentNode.getElement(".doc_layout_priority");
  322. if (this.layout_priority) this.layout_priority.setStyles(this.css.doc_layout_priority);
  323. this.layout_copiesSecretPriority_blank = this.contentNode.getElement(".doc_layout_copiesSecretPriority_blank");
  324. },
  325. //红头
  326. _loadRedHeader: function(){
  327. this.layout_redHeader = this.contentNode.getElement(".doc_layout_redHeader");
  328. if (this.layout_redHeader) this.layout_redHeader.setStyles(this.css.doc_layout_redHeader);
  329. },
  330. //文号签发人(上行文)
  331. _loadFileNoUp: function(){
  332. this.layout_filenoArea = this.contentNode.getElement(".doc_layout_fileno_area");
  333. this.layout_fileNoUpTable = this.contentNode.getElement(".doc_layout_filenoup");
  334. if (this.layout_fileNoUpTable) this.layout_fileNoUpTable.setStyles(this.css.doc_layout_filenoup);
  335. var td = this.contentNode.getElement(".doc_layout_filenoup_fileno_td");
  336. if (td) td.setStyles(this.css.doc_layout_filenoup_fileno_td);
  337. this.layout_fileno = this.contentNode.getElement(".doc_layout_filenoup_fileno");
  338. if (this.layout_fileno) this.layout_fileno.setStyles(this.css.doc_layout_filenoup_fileno);
  339. td = this.contentNode.getElement(".doc_layout_filenoup_signer_td");
  340. if (td) td.setStyles(this.css.doc_layout_filenoup_signer_td);
  341. var node = this.contentNode.getElement(".doc_layout_filenoup_signer_table");
  342. if (node) node.setStyles(this.css.doc_layout_filenoup_signer_table);
  343. node = this.contentNode.getElement(".doc_layout_filenoup_signerTitle_td");
  344. if (node) node.setStyles(this.css.doc_layout_filenoup_signerTitle_td);
  345. this.layout_signerTitle = this.contentNode.getElement(".doc_layout_filenoup_signer");
  346. if (this.layout_signerTitle) this.layout_signerTitle.setStyles(this.css.doc_layout_filenoup_signer);
  347. node = this.contentNode.getElement(".doc_layout_filenoup_signerContent_td");
  348. if (node) node.setStyles(this.css.doc_layout_filenoup_signerContent_td);
  349. this.layout_signer = this.contentNode.getElement(".doc_layout_filenoup_signerContent");
  350. if (this.layout_signer) this.layout_signer.setStyles(this.css.doc_layout_filenoup_signerContent);
  351. if (!this.layout_fileno){
  352. this.layout_fileNoUpTable = this.contentNode.getElement(".doc_layout_filenoup");
  353. this.layout_filenoArea = this.contentNode.getElement(".doc_layout_fileno_area");
  354. this.layout_fileno = this.contentNode.getElement(".doc_layout_fileno");
  355. if (this.layout_fileno) this.layout_fileno.setStyles(this.css.doc_layout_fileno);
  356. }
  357. },
  358. //文号
  359. _loadFileNo: function(){
  360. this.layout_fileNoUpTable = this.contentNode.getElement(".doc_layout_filenoup");
  361. this.layout_filenoArea = this.contentNode.getElement(".doc_layout_fileno_area");
  362. this.layout_fileno = this.contentNode.getElement(".doc_layout_fileno");
  363. if (this.layout_fileno) this.layout_fileno.setStyles(this.css.doc_layout_fileno);
  364. td = this.contentNode.getElement(".doc_layout_filenoup_signer_td");
  365. if (td) td.setStyles(this.css.doc_layout_filenoup_signer_td);
  366. var node = this.contentNode.getElement(".doc_layout_filenoup_signer_table");
  367. if (node) node.setStyles(this.css.doc_layout_filenoup_signer_table);
  368. node = this.contentNode.getElement(".doc_layout_filenoup_signerTitle_td");
  369. if (node) node.setStyles(this.css.doc_layout_filenoup_signerTitle_td);
  370. this.layout_signerTitle = this.contentNode.getElement(".doc_layout_filenoup_signer");
  371. if (this.layout_signerTitle) this.layout_signerTitle.setStyles(this.css.doc_layout_filenoup_signer);
  372. node = this.contentNode.getElement(".doc_layout_filenoup_signerContent_td");
  373. if (node) node.setStyles(this.css.doc_layout_filenoup_signerContent_td);
  374. this.layout_signer = this.contentNode.getElement(".doc_layout_filenoup_signerContent");
  375. if (this.layout_signer) this.layout_signer.setStyles(this.css.doc_layout_filenoup_signerContent);
  376. if (!this.layout_fileno){
  377. this.layout_filenoArea = this.contentNode.getElement(".doc_layout_fileno_area");
  378. this.layout_fileNoUpTable = this.contentNode.getElement(".doc_layout_filenoup");
  379. if (this.layout_fileNoUpTable) this.layout_fileNoUpTable.setStyles(this.css.doc_layout_filenoup);
  380. var td = this.contentNode.getElement(".doc_layout_filenoup_fileno_td");
  381. if (td) td.setStyles(this.css.doc_layout_filenoup_fileno_td);
  382. this.layout_fileno = this.contentNode.getElement(".doc_layout_filenoup_fileno");
  383. if (this.layout_fileno) this.layout_fileno.setStyles(this.css.doc_layout_filenoup_fileno);
  384. }
  385. },
  386. //红线
  387. _loadRedLine: function(){
  388. this.layout_redLine = this.contentNode.getElement(".doc_layout_redline");
  389. if (this.layout_redLine) this.layout_redLine.setStyles(this.css.doc_layout_redline);
  390. },
  391. //标题
  392. _loadSubject:function(){
  393. this.layout_subject = this.contentNode.getElement(".doc_layout_subject");
  394. if (this.layout_subject) this.layout_subject.setStyles(this.css.doc_layout_subject);
  395. },
  396. //主送
  397. _loadMainSend: function(){
  398. this.layout_mainSend = this.contentNode.getElement(".doc_layout_mainSend");
  399. if (this.layout_mainSend) this.layout_mainSend.setStyles(this.css.doc_layout_mainSend);
  400. },
  401. //正文
  402. // _createFiletext: function(filetextNode, node, where){
  403. // if (!filetextNode){
  404. // var filetextNode = new Element("div.doc_layout_filetext").inject(node, where);
  405. // filetextNode.addClass("doc_block");
  406. // filetextNode.setAttribute('contenteditable', true);
  407. // }
  408. // CKEDITOR.disableAutoInline = true;
  409. // var filetextEditor = CKEDITOR.inline(filetextNode, this._getEditorConfig());
  410. // filetextNode.store("editor", filetextEditor);
  411. // if (!this.filetextEditors) this.filetextEditors = [];
  412. // this.filetextEditors.push(filetextEditor);
  413. //
  414. // filetextEditor.on( 'blur', function(e) {
  415. // // var filetextNode = e.editor.container.$;
  416. // // var pageNode = filetextNode.getParent(".doc_layout_page");
  417. // // this._checkSplitPage(pageNode);
  418. // // this._repage();
  419. // }.bind(this));
  420. //
  421. // return filetextNode;
  422. // },
  423. _loadFiletext: function(){
  424. this.layout_filetext = this.contentNode.getElement(".doc_layout_filetext");
  425. this.layout_filetext.addClass("css"+this.form.json.id+this.json.id);
  426. this.layout_filetext.setStyles(this.css.doc_layout_filetext);
  427. //this.layout_filetext = this.contentNode.getElement(".doc_layout_filetext");
  428. // if (this.layout_filetexts.length){
  429. // this.layout_filetexts.each(function(layout_filetext){
  430. // layout_filetext.setStyles(this.css.doc_layout_filetext);
  431. // }.bind(this));
  432. // }
  433. },
  434. //附件
  435. _loadAttachment: function(){
  436. this.layout_attachmentTable = this.contentNode.getElement(".doc_layout_attachment");
  437. if (this.layout_attachmentTable) this.layout_attachmentTable.setStyles(this.css.doc_layout_attachment);
  438. var node = this.contentNode.getElement(".doc_layout_attachment_title_td");
  439. if (node) node.setStyles(this.css.doc_layout_attachment_title_td);
  440. this.layout_attachmentTitle = this.contentNode.getElement(".doc_layout_attachment_title");
  441. if (node) node.setStyles(this.css.doc_layout_attachment_title);
  442. node = this.contentNode.getElement(".doc_layout_attachment_content_td");
  443. if (node) node.setStyles(this.css.doc_layout_attachment_content_td);
  444. this.layout_attachment = this.contentNode.getElement(".doc_layout_attachment_content");
  445. if (this.layout_attachment) this.layout_attachment.setStyles(this.css.doc_layout_attachment_content);
  446. },
  447. //发布单位
  448. _loadIssuance: function(){
  449. this.layout_issuanceTable = this.contentNode.getElement(".doc_layout_issuance");
  450. this.layout_issuanceUnit = this.contentNode.getElement(".doc_layout_issuanceUnit");
  451. this.layout_issuanceDate = this.contentNode.getElement(".doc_layout_issuanceDate");
  452. if (this.layout_issuanceTable) this.layout_issuanceTable.setStyles(this.css.doc_layout_issuance);
  453. if (this.layout_issuanceUnit) this.layout_issuanceUnit.setStyles(this.css.doc_layout_issuanceUnit);
  454. if (this.layout_issuanceDate) this.layout_issuanceDate.setStyles(this.css.doc_layout_issuanceDate);
  455. },
  456. //附注
  457. _loadAnnotation: function(){
  458. this.layout_annotation = this.contentNode.getElement(".doc_layout_annotation");
  459. if (this.layout_annotation) this.layout_annotation.setStyles(this.css.doc_layout_annotation);
  460. },
  461. //版记
  462. _loadEdition: function(){
  463. this.layout_editionArea = this.contentNode.getElement(".doc_layout_editionArea");
  464. this.layout_edition = this.contentNode.getElement(".doc_layout_edition");
  465. if (this.layout_edition) this.layout_edition.setStyles(this.css.doc_layout_edition);
  466. var node = this.contentNode.getElement(".doc_layout_edition_copyto");
  467. if (node) node.setStyles(this.css.doc_layout_edition_copyto);
  468. node = this.contentNode.getElement(".doc_layout_edition_copyto_table");
  469. if (node) node.setStyles(this.css.doc_layout_edition_copyto_table);
  470. var node = this.contentNode.getElement(".doc_layout_edition_copyto2");
  471. if (node) node.setStyles(this.css.doc_layout_edition_copyto);
  472. node = this.contentNode.getElement(".doc_layout_edition_copyto2_table");
  473. if (node) node.setStyles(this.css.doc_layout_edition_copyto_table);
  474. this.layout_copytoTitle = this.contentNode.getElement(".doc_layout_edition_copyto_title");
  475. if (this.layout_copytoTitle) this.layout_copytoTitle.setStyles(this.css.doc_layout_edition_copyto_title);
  476. this.layout_copytoContent = this.contentNode.getElement(".doc_layout_edition_copyto_content");
  477. if (this.layout_copytoContent) this.layout_copytoContent.setStyles(this.css.doc_layout_edition_copyto_content);
  478. this.layout_copyto2Title = this.contentNode.getElement(".doc_layout_edition_copyto2_title");
  479. if (this.layout_copyto2Title) this.layout_copyto2Title.setStyles(this.css.doc_layout_edition_copyto_title);
  480. this.layout_copyto2Content = this.contentNode.getElement(".doc_layout_edition_copyto2_content");
  481. if (this.layout_copyto2Content) this.layout_copyto2Content.setStyles(this.css.doc_layout_edition_copyto_content);
  482. var issuance = this.contentNode.getElement(".doc_layout_edition_issuance");
  483. if (issuance) issuance.setStyles(this.css.doc_layout_edition_issuance);
  484. var issuance_table = this.contentNode.getElement(".doc_layout_edition_issuance_table");
  485. if (issuance_table) issuance_table.setStyles(this.css.doc_layout_edition_issuance_table);
  486. this.layout_edition_issuance_unit = this.contentNode.getElement(".doc_layout_edition_issuance_unit");
  487. if (this.layout_edition_issuance_unit) this.layout_edition_issuance_unit.setStyles(this.css.doc_layout_edition_issuance_unit);
  488. this.layout_edition_issuance_date = this.contentNode.getElement(".doc_layout_edition_issuance_date");
  489. if (this.layout_edition_issuance_date) this.layout_edition_issuance_date.setStyles(this.css.doc_layout_edition_issuance_date);
  490. },
  491. _loadMeeting: function(){
  492. this.layout_meetingAttendArea = this.contentNode.getElement(".doc_layout_meeting_attend");
  493. this.layout_meetingAttendTitle = this.contentNode.getElement(".doc_layout_meeting_attend_title");
  494. this.layout_meetingAttendContent = this.contentNode.getElement(".doc_layout_meeting_attend_content");
  495. this.layout_meetingLeaveArea = this.contentNode.getElement(".doc_layout_meeting_leave");
  496. this.layout_meetingLeaveTitle = this.contentNode.getElement(".doc_layout_meeting_leave_title");
  497. this.layout_meetingLeaveContent = this.contentNode.getElement(".doc_layout_meeting_leave_content");
  498. this.layout_meetingSitArea = this.contentNode.getElement(".doc_layout_meeting_sit");
  499. this.layout_meetingSitTitle = this.contentNode.getElement(".doc_layout_meeting_sit_title");
  500. this.layout_meetingSitContent = this.contentNode.getElement(".doc_layout_meeting_sit_content");
  501. this.layout_meetingRecordArea = this.contentNode.getElement(".doc_layout_meeting_record");
  502. this.layout_meetingRecordTitle = this.contentNode.getElement(".doc_layout_meeting_record_title");
  503. this.layout_meetingRecordContent = this.contentNode.getElement(".doc_layout_meeting_record_content");
  504. },
  505. _loadCustom: function(){
  506. debugger;
  507. var nodes = this.contentNode.getElements(".doc_layout");
  508. nodes.each(function(node){
  509. var name = node.get("data-doc-layout");
  510. if (!this.customLayouts) this.customLayouts = [];
  511. this.customLayouts.push({
  512. "name": name,
  513. "node": node,
  514. });
  515. this[name] = node;
  516. }.bind(this));
  517. },
  518. _loadPageLayout: function(control){
  519. this._loadCopiesSecretPriority();
  520. this._loadRedHeader();
  521. if (this.json.fileup){
  522. this._loadFileNoUp();
  523. }else{
  524. this._loadFileNo();
  525. }
  526. if (!this.layout_fileno) this._loadFileNo();
  527. this._loadRedLine();
  528. this._loadSubject();
  529. this._loadMainSend();
  530. this._loadFiletext();
  531. this._loadAttachment();
  532. this._loadIssuance();
  533. this._loadAnnotation();
  534. this._loadEdition();
  535. //会议纪要
  536. this._loadMeeting();
  537. //自定义
  538. this._loadCustom();
  539. debugger;
  540. this.reSetShow(control);
  541. this.reSetEdit();
  542. // 份数: this.layout_copies
  543. // 密级: this.layout_secret
  544. // 紧急程度: this.layout_priority
  545. // 红头: this.layout_redHeader
  546. // 上行文编号签发: this.layout_fileNoUpTable
  547. // 文号: this.layout_fileno
  548. // 签发: this.layout_signerTitle
  549. // 签发人: this.layout_signer
  550. // 文号: this.layout_fileno
  551. // 红线: this.layout_redLine
  552. // 标题: this.layout_subject
  553. // 主送单位: this.layout_mainSend
  554. // 正文: this.layout_filetexts
  555. // 附件: this.layout_attachmentTitle
  556. // 附件: this.layout_attachment
  557. // 单位: this.layout_issuanceUnit
  558. // 签发时间: this.layout_issuanceDate
  559. // 附注: this.layout_annotation
  560. // 抄送: this.layout_copytoTitle
  561. // 抄送: this.layout_copytoContent
  562. // 版记单位 this.layout_edition_issuance_unit
  563. // 版记日期 this.layout_edition_issuance_date
  564. },
  565. reSetShow: function(control){
  566. if (!control) control = this.getShowControl();
  567. var m = function(s){ return (control[s]) ? "show" : "hide"; }
  568. if (this.layout_copiesSecretPriority) this.layout_copiesSecretPriority[m("copiesSecretPriority")]();
  569. // control.copies = this._getShow("copies", "copiesShow", "copiesShowScript");
  570. // control.secret = this._getShow("secret", "secretShow", "secretShowScript");
  571. // control.priority = this._getShow("priority", "priorityShow", "priorityShowScript");
  572. var n = 0;
  573. if (!control.copies) n++;
  574. if (!control.secret) n++;
  575. if (!control.priority) n++;
  576. if (this.layout_copiesSecretPriority_blank){
  577. while (n>0){
  578. this.layout_copiesSecretPriority_blank.empty();
  579. this.layout_copiesSecretPriority_blank.appendHTML("<span style='font-size:16.0pt'>&nbsp;</span>");
  580. n--;
  581. }
  582. }
  583. if (this.layout_copies) this.layout_copies[m("copies")]();
  584. if (this.layout_secret) this.layout_secret[m("secret")]();
  585. if (this.layout_priority) this.layout_priority[m("priority")]();
  586. if (this.layout_redHeader) this.layout_redHeader[m("redHeader")]();
  587. if (this.layout_redLine) this.layout_redLine[m("redLine")]();
  588. if (this.layout_fileNoUpTable) this.layout_fileNoUpTable[m("signer")]();
  589. if (this.layout_filenoArea) this.layout_filenoArea[(!control.signer) ? "show" : "hide"]();
  590. debugger;
  591. if (this.layout_signerTitle) this.layout_signerTitle[m("signer")]();
  592. if (this.layout_signer) this.layout_signer[m("signer")]();
  593. if (this.layout_fileno) this.layout_fileno[m("fileno")]();
  594. if (this.layout_subject) this.layout_subject[m("subject")]();
  595. if (this.layout_mainSend) this.layout_mainSend[m("mainSend")]();
  596. if (this.layout_attachmentTable) this.layout_attachmentTable[m("attachment")]();
  597. if (this.layout_issuanceUnit) this.layout_issuanceUnit[m("issuanceUnit")]();
  598. if (this.layout_issuanceDate) this.layout_issuanceDate[m("issuanceDate")]();
  599. debugger;
  600. if (this.layout_issuanceUnit && this.layout_issuanceDate){
  601. var table = this.layout_issuanceUnit.getParent("table")
  602. if (table && !table.hasClass("doc_layout_headIssuance")) {
  603. var unitWidth = o2.getTextSize(this.layout_issuanceUnit.get("text"), {
  604. "font-size": "16pt",
  605. "font-family": "'Times New Roman',仿宋",
  606. "letter-spacing": "-0.4pt"
  607. }).x;
  608. var dateWidth = o2.getTextSize(this.layout_issuanceDate.get("text"), {
  609. "font-size": "16pt",
  610. "font-family": "'Times New Roman',仿宋",
  611. "letter-spacing": "-0.4pt"
  612. }).x;
  613. // var unitWidth = this.layout_issuanceUnit.getSize().x;
  614. // var dateWidth = this.layout_issuanceDate.getSize().x;
  615. if (unitWidth < dateWidth) {
  616. var flagTd = this.layout_issuanceUnit.getParent("td").getNext("td");
  617. if (flagTd) {
  618. var pt = ((dateWidth - unitWidth) / 96) * 72 + 32 + 32;
  619. flagTd.setStyle("width", "" + pt + "pt");
  620. }
  621. table = this.layout_issuanceDate.getParent("table");
  622. table.setStyle("width", "auto");
  623. flagTd = this.layout_issuanceDate.getParent("td").getNext("td");
  624. if (flagTd) flagTd.setStyle("width", "32pt");
  625. var p = this.layout_issuanceDate.getParent("p");
  626. if (p) p.setStyle("text-align", "right");
  627. } else {
  628. var flagTd = this.layout_issuanceUnit.getParent("td").getNext("td");
  629. if (flagTd) flagTd.setStyle("width", "32pt");
  630. var table = this.layout_issuanceUnit.getParent("table");
  631. var x = table.getSize().x;
  632. table = this.layout_issuanceDate.getParent("table");
  633. table.setStyle("width", "" + x + "px");
  634. flagTd = this.layout_issuanceDate.getParent("td").getNext("td");
  635. if (flagTd) flagTd.setStyle("width", "32pt");
  636. var p = this.layout_issuanceDate.getParent("p");
  637. if (p) p.setStyle("text-align", "center");
  638. }
  639. }
  640. }
  641. if (this.layout_annotation) this.layout_annotation[m("annotation")]();
  642. 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)){
  643. if (this.layout_editionArea) this.layout_editionArea.hide();
  644. }else{
  645. if ((!control.copyto || !this.layout_copytoContent) && (!control.copyto2 || !this.layout_copyto2Content) ){
  646. if (this.layout_edition){
  647. if (this.layout_copytoContent) this.layout_copytoContent.getParent("tr").destroy();
  648. if (this.layout_copyto2Content) this.layout_copyto2Content.getParent("tr").destroy();
  649. // if (this.layout_edition) this.layout_edition.getElement("tr").getElements("td")[0].setStyles({
  650. // "border-top": "solid windowtext 1.5pt",
  651. // "mso-border-top-alt": "solid windowtext 1pt"
  652. // });
  653. }
  654. }else if (!control.copyto || !this.layout_copytoContent){
  655. if (this.layout_copytoContent) this.layout_copytoContent.getParent("tr").destroy();
  656. //if (this.layout_copyto2Content) this.layout_edition.getElement("tr").destroy();
  657. // if (this.layout_edition) this.layout_edition.getElement("tr").getElements("td").setStyles({
  658. // "border-top": "solid windowtext 1.5pt",
  659. // "mso-border-top-alt": "solid windowtext 1pt"
  660. // });
  661. }else if (!control.copyto2 || !this.layout_copyto2Content) {
  662. if (this.layout_copyto2Content) this.layout_copyto2Content.getParent("tr").destroy();
  663. // if (this.layout_edition) this.layout_edition.getElement("tr").getElements("td").setStyles({
  664. // "border-bottom": "solid windowtext 0.75pt",
  665. // "mso-border-bottom-alt": "solid windowtext 0.75pt"
  666. // });
  667. }
  668. if ((!control.editionUnit || !this.layout_edition_issuance_unit) && (!control.editionDate || !this.layout_edition_issuance_date)){
  669. if (this.layout_editionArea && (this.layout_edition_issuance_date || this.layout_edition_issuance_unit)){
  670. var trs = this.layout_editionArea.getElement("table").rows;
  671. trs.item(trs.length-1).destroy();
  672. // trs = this.layout_editionArea.getElement("table").rows;
  673. // var tr = trs.item(trs.length-1);
  674. // if (tr){
  675. // tr.getElements("td").setStyles({
  676. // "border-bottom": "solid windowtext 1.5pt",
  677. // "mso-border-bottom-alt": "solid windowtext 1pt"
  678. // });
  679. // }
  680. }
  681. }
  682. if (this.layout_editionArea && (this.layout_edition_issuance_date || this.layout_edition_issuance_unit)){
  683. trs = this.layout_editionArea.getElement("table").rows;
  684. for (var i=0; i<trs.length; i++){
  685. var tds = trs.item(i).cells;
  686. for (var n=0; n<tds.length; n++){
  687. var td = tds.item(n);
  688. var tdClass = td.get("class");
  689. var tdClassList = (tdClass) ? tdClass.split(/\s+/g) : [];
  690. if (tdClassList.indexOf("line_top_thin_bottom_thick") != -1) tdClassList = tdClassList.erase("line_top_thin_bottom_thick");
  691. if (tdClassList.indexOf("line_top_thick_bottom_thin") != -1) tdClassList = tdClassList.erase("line_top_thick_bottom_thin");
  692. if (tdClassList.indexOf("line_top_thick_bottom_thick") != -1) tdClassList = tdClassList.erase("line_top_thick_bottom_thick");
  693. if (tdClassList.indexOf("line_top_thin_bottom_thin") == -1) tdClassList.unshift("line_top_thin_bottom_thin");
  694. // td.setStyles({
  695. // "border-top": "solid windowtext 0.75pt",
  696. // "mso-border-top-alt": "solid windowtext 0.75pt",
  697. // "border-bottom": "solid windowtext 0.75pt",
  698. // "mso-border-bottom-alt": "solid windowtext 0.75pt",
  699. // });
  700. if (i==0 && i!=(trs.length-1)){
  701. if (tdClassList.indexOf("line_top_thin_bottom_thin") != -1) tdClassList = tdClassList.erase("line_top_thin_bottom_thin");
  702. tdClassList.unshift("line_top_thick_bottom_thin");
  703. // td.setStyles({
  704. // "border-top": "solid windowtext 1.5pt",
  705. // "mso-border-top-alt": "solid windowtext 1pt"
  706. // });
  707. }else if (i==0 && i==(trs.length-1)){
  708. if (tdClassList.indexOf("line_top_thin_bottom_thin") != -1) tdClassList = tdClassList.erase("line_top_thin_bottom_thin");
  709. tdClassList.unshift("line_top_thick_bottom_thick");
  710. }else if (i!=0 && i==(trs.length-1)){
  711. if (tdClassList.indexOf("line_top_thin_bottom_thin") != -1) tdClassList = tdClassList.erase("line_top_thin_bottom_thin");
  712. tdClassList.unshift("line_top_thin_bottom_thick");
  713. }
  714. // if (i==(trs.length-1)){
  715. // if (tdClassList.indexOf("line_bottom_thin") != -1) tdClassList = tdClassList.erase("line_bottom_thin");
  716. // if (tdClassList.indexOf("line_bottom_thick") == -1) tdClassList.push("line_bottom_thick");
  717. // // td.setStyles({
  718. // // "border-bottom": "solid windowtext 1.5pt",
  719. // // "mso-border-bottom-alt": "solid windowtext 1pt"
  720. // // });
  721. // }
  722. tdClass = tdClassList.join(" ");
  723. td.set("class", tdClass);
  724. }
  725. }
  726. }
  727. var coptyToTitleNode = (this.layout_copytoTitle || this.layout_copyto2Title);
  728. if (coptyToTitleNode){
  729. var editionTable = coptyToTitleNode.getParent("table");
  730. if (editionTable) if (editionTable.get("data-compute-style")=="y"){
  731. var rows = editionTable.rows;
  732. for (var i=0; i<rows.length; i++){
  733. var cell = rows[i].cells[0];
  734. var tmp = cell.getElement(".doc_layout_edition_issuance_unit");
  735. if (!tmp) tmp = cell.getElement(".doc_layout_edition_issuance_date");
  736. if (!tmp){
  737. var text = cell.get("text").trim();
  738. var l = 14*text.length;
  739. var wl = 19*text.length;
  740. cell.setStyles({
  741. "max-width": ""+l+"pt",
  742. "min-width": ""+l+"pt",
  743. "width": ""+wl+"pt"
  744. });
  745. }
  746. }
  747. }
  748. }
  749. if (this.layout_editionArea) this.layout_editionArea.show();
  750. if (this.layout_copytoTitle) this.layout_copytoTitle[m("copyto")]();
  751. if (this.layout_copytoContent) this.layout_copytoContent[m("copyto")]();
  752. if (this.layout_copyto2Title) this.layout_copyto2Title[m("copyto2")]();
  753. if (this.layout_copyto2Content) this.layout_copyto2Content[m("copyto2")]();
  754. if (this.layout_edition_issuance_unit) this.layout_edition_issuance_unit[m("editionUnit")]();
  755. if (this.layout_edition_issuance_date) this.layout_edition_issuance_date[m("editionDate")]();
  756. }
  757. if (this.layout_meetingAttendArea) this.layout_meetingAttendArea[m("meetingAttend")]();
  758. if (this.layout_meetingLeaveArea) this.layout_meetingLeaveArea[m("meetingLeave")]();
  759. if (this.layout_meetingSitArea) this.layout_meetingSitArea[m("meetingSit")]();
  760. if (this.layout_meetingRecordArea) this.layout_meetingRecordArea[m("meetingRecord")]();
  761. // this.layout_annotation[m("annotation")]();
  762. // this.layout_annotation[m("annotation")]();
  763. // this.layout_annotation[m("annotation")]();
  764. },
  765. reSetEdit: function(control){
  766. //未进行数据绑定时,可允许编辑
  767. if (!control) var control = this.getEditControl();
  768. if (this.layout_subject){
  769. if (!this.json.subjectValueData && this.json.subjectValueType=="data"){
  770. this.layout_subject.set("contenteditable", control.subject);
  771. // this.layout_subject.addEvent("blur", function(){
  772. // this.getData();
  773. // }.bind(this))
  774. this.layout_subject.addEvent("blur", function(e){
  775. var subject = this.layout_subject.get("text");
  776. if (!subject){
  777. this.layout_subject.set("html", this.data.subject);
  778. this.form.app.notice(MWF.xApplication.process.Xform.LP.subjectEmpty, "error", this.layout_subject, {"x": "center","y":"top"}, {"x": 0,"y":60});
  779. e.preventDefault();
  780. e.stopPropagation();
  781. }else{
  782. this.getData();
  783. }
  784. }.bind(this));
  785. }
  786. }
  787. if (this.layout_issuanceUnit){
  788. if (!this.json.issuanceUnitValueData && this.json.issuanceUnitValueType=="data"){
  789. this.layout_issuanceUnit.set("contenteditable", control.issuanceUnit);
  790. // this.layout_issuanceUnit.addEvent("blur", function(){
  791. // this.getData();
  792. // }.bind(this))
  793. this.layout_issuanceUnit.addEvent("blur", function(e){
  794. var issuanceUnit = this.layout_issuanceUnit.get("text");
  795. if (!issuanceUnit){
  796. this.layout_issuanceUnit.set("html", this.data.issuanceUnit);
  797. this.form.app.notice(MWF.xApplication.process.Xform.LP.issuanceUnitEmpty, "error", this.layout_issuanceUnit, {"x": "center","y":"top"}, {"x": 0,"y":60});
  798. e.preventDefault();
  799. e.stopPropagation();
  800. }else{
  801. this.getData();
  802. }
  803. }.bind(this));
  804. }
  805. }
  806. // this.layout_subject.addEvent("keydown", function(e){
  807. // debugger;
  808. // if (this.json.subjectValueType=="data" && this.json.subjectValueData){
  809. // // var v = e.target.get("HTML");
  810. // // this.form.businessData.data[this.json.subjectValueData] = v
  811. // var module = this.form.all[this.json.subjectValueData];
  812. // if (module){
  813. // var bindFun = module.node.retrieve(this.json.id+"bindFun");
  814. // module.node
  815. // }
  816. // }
  817. // }.bind(this));
  818. },
  819. _loadUserInterface: function(callback){
  820. this.node.empty();
  821. this.node.setStyles(this.form.css.documentEditorNode);
  822. this.pages = [];
  823. this.allowEdit = this._isAllowEdit();
  824. this.allowPrint = this._isAllowPrint();
  825. this.allowHistory = this._isAllowHistory();
  826. this.toolNode = new Element("div", {"styles": this.css.doc_toolbar}).inject(this.node);
  827. this.contentNode = new Element("div#doc_content", {"styles": this.css.doc_content}).inject(this.node);
  828. if (!this.form.isLoaded){
  829. this.form.addEvent("afterModulesLoad", function(){this.loadDocumentEditor(callback);}.bind(this));
  830. }else{
  831. this.loadDocumentEditor(callback);
  832. }
  833. },
  834. loadDocumentEditor: function(callback){
  835. this._loadToolbars();
  836. this._loadFiletextPage(function(){
  837. if (this.options.pageShow!=="double"){
  838. this._singlePage();
  839. }else{
  840. this._doublePage();
  841. }
  842. // this.form.addEvent("beforeProcess", function(){
  843. // this.resetData();
  844. // if (this.checkSaveNewEdition()) this.saveNewDataEdition();
  845. // this.notSaveResetData = true;
  846. // }.bind(this));
  847. this.form.addEvent("beforeSave", function(){
  848. this.resetData();
  849. this.checkSaveNewEdition();
  850. //if (!this.notSaveResetData) this.resetData();
  851. }.bind(this));
  852. if (this.json.toWord=="y"){
  853. if (this.json.toWordTrigger=="open") this.docToWord();
  854. if (this.json.toWordTrigger=="save") this.form.addEvent("beforeSave", this.docToWord.bind(this));
  855. if (this.json.toWordTrigger=="submit") this.form.addEvent("beforeProcess", this.docToWord.bind(this));
  856. }
  857. if (!layout.mobile) this.loadSideToolbar();
  858. o2.load("../o2_lib/diff-match-patch/diff_match_patch.js");
  859. if (this.form.businessData.data["$work"]){
  860. var id = this.form.businessData.data["$work"].job;
  861. o2.Actions.load("x_processplatform_assemble_surface").DocumentVersionAction.listWithJobCategory(id, this.json.id, function(json){
  862. this.historyDocumentList = json.data;
  863. if (this.historyDocumentList.length){
  864. o2.Actions.load("x_processplatform_assemble_surface").DocumentVersionAction.get(this.historyDocumentList[this.historyDocumentList.length-1].id, function(json){
  865. var data = JSON.parse(json.data.data);
  866. this.originaHistoryData = data.data;
  867. }.bind(this));
  868. }
  869. }.bind(this));
  870. }
  871. if (callback) callback();
  872. }.bind(this));
  873. if (!this.form.documenteditorList) this.form.documenteditorList=[];
  874. this.form.documenteditorList.push(this);
  875. },
  876. checkSaveNewEdition: function(callback){
  877. debugger;
  878. if (!this.allowEdit || !this.data.filetext || this.data.filetext == this.json.defaultValue.filetext) return false;
  879. if (this.form.businessData.work){
  880. var originaData = this.form.businessData.originalData[this.json.id];
  881. var editionData = {"category": this.json.id};
  882. if (!originaData || !originaData.filetext || !this.originaHistoryData){
  883. //保存原始版本
  884. this.originaHistoryData = {"data": this.data.filetext};
  885. editionData.data = JSON.stringify({"data": this.data.filetext});
  886. }else if (originaData.filetext!=this.data.filetext){
  887. //保存历史版本
  888. var data = this.data.filetext;
  889. var earlyData = originaData.filetext;
  890. var dmp = new diff_match_patch();
  891. var diff_d = dmp.diff_main(earlyData, data);
  892. dmp.diff_cleanupSemantic(diff_d);
  893. var patch_list = dmp.patch_make(earlyData, data, diff_d);
  894. editionData.data = JSON.stringify({"patchs": dmp.patch_toText(patch_list)});
  895. }else{
  896. return false;
  897. }
  898. o2.Actions.load("x_processplatform_assemble_surface").DocumentVersionAction.create(this.form.businessData.work.id, editionData, function(json){
  899. //originaData.filetext = this.data.filetext;
  900. if (callback) callback();
  901. }.bind(this));
  902. }
  903. },
  904. // saveNewDataEdition: function(callback){
  905. // if (this.form.businessData.work){
  906. // var editionData = {"category": this.json.id};
  907. // if (this.form.businessData.originalData[this.json.id] && this.form.businessData.originalData[this.json.id].filetext){
  908. // var data = this.data.filetext;
  909. // var earlyData = this.form.businessData.originalData[this.json.id].filetext;
  910. // var dmp = new diff_match_patch();
  911. // var diff_d = dmp.diff_main(earlyData, data);
  912. // dmp.diff_cleanupSemantic(diff_d);
  913. // var patch_list = dmp.patch_make(earlyData, data, diff_d);
  914. // editionData.data = {"patchs": dmp.patch_toText(patch_list)};
  915. //
  916. // }else{
  917. // editionData.data = {"data": this.data.filetext};
  918. // }
  919. // o2.Actions.load("x_processplatform_assemble_surface").DocumentVersionAction.create(this.form.businessData.work.id, editionData, function(json){
  920. // this.form.businessData.originalData[this.json.id] = this.data.filetext;
  921. // if (callback) callback();
  922. // }.bind(this));
  923. // }
  924. // },
  925. resizeToolbar: function(){
  926. if (this.toolbarNode){
  927. var p = this.toolNode.getPosition(this.scrollNode);
  928. var size = this.toolNode.getSize();
  929. var pl = this.toolbarNode.getStyle("padding-left").toInt();
  930. var pr = this.toolbarNode.getStyle("padding-right").toInt();
  931. var x = size.x-pl-pr;
  932. //var pNode = this.toolNode.getOffsetParent();
  933. var paddingTop = this.form.node.getStyle("padding-top");
  934. try {
  935. paddingTop = paddingTop.toInt();
  936. }catch (e) {
  937. paddingTop = 0;
  938. }
  939. if (p.y<paddingTop){
  940. this.toolbarNode.inject(this.scrollNode);
  941. this.toolbarNode.setStyles({
  942. "position": "absolute",
  943. "width": ""+x+"px",
  944. "z-index": 200,
  945. "top": paddingTop+"px",
  946. "left": ""+p.x+"px"
  947. });
  948. }else{
  949. this.toolbarNode.inject(this.toolNode);
  950. this.toolbarNode.setStyles({"position": "static"});
  951. }
  952. }
  953. },
  954. resizeSidebar: function(){
  955. if (this.sidebarNode){
  956. var fileTextNode = this.contentNode.getElement("div.doc_layout_filetext");
  957. if (fileTextNode){
  958. this.sidebarNode.position({
  959. relativeTo: fileTextNode,
  960. position: 'topLeft',
  961. edge: 'topRight',
  962. offset: {"x": -20, "y": 60}
  963. });
  964. var p = fileTextNode.getPosition(this.form.app.content);
  965. var ptop = fileTextNode.getPosition(this.node);
  966. //if ((p.y+s.y)<0) this.sidebarNode.setStyle("top", p.y+s.y);
  967. if (p.y<0){
  968. var top = ptop.y-p.y+200;
  969. this.sidebarNode.setStyle("top", top);
  970. }
  971. // var p = fileTextNode.getPosition();
  972. // this.sidebarNode.setStyle("top", p.y);
  973. }
  974. }
  975. },
  976. loadSideToolbar: function(){
  977. if (this.allowEdit){
  978. if (this.pages.length){
  979. var fileTextNode = this.pages[0].getElement("div.doc_layout_filetext");
  980. if (fileTextNode){
  981. this.sidebarNode = new Element("div", {"styles": this.css.doc_sidebar}).inject(this.node);
  982. this.resizeSidebar();
  983. this.scrollNode = this.sidebarNode.getParentSrcollNode();
  984. if (this.scrollNode){
  985. this.scrollNode.addEvent("scroll", function(){
  986. this.resizeSidebar();
  987. }.bind(this));
  988. }
  989. 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>";
  990. this.sidebarNode.set("html", html);
  991. MWF.require("MWF.widget.Toolbar", function() {
  992. this.sideToolbar = new MWF.widget.Toolbar(this.sidebarNode, {"style": "documentEdit_side"}, this);
  993. this.sideToolbar.load();
  994. }.bind(this));
  995. }
  996. }
  997. }
  998. },
  999. _returnScale: function(){
  1000. this.isScale = false;
  1001. this.scale = 0;
  1002. this.contentNode.setStyles({
  1003. "transform":"scale(1)",
  1004. });
  1005. if (this.pages.length){
  1006. this.pages.each(function(page){
  1007. page.setStyles({
  1008. "transform":"scale(1)",
  1009. });
  1010. });
  1011. }
  1012. this.node.setStyles({
  1013. "height": "auto"
  1014. });
  1015. },
  1016. _checkScale: function(offset){
  1017. offset = 0;
  1018. if (this.pages.length){
  1019. //var pageSize = this.pages[0].getSize();
  1020. var pageSize_x = this.options.docPageFullWidth
  1021. var contentSize = this.contentNode.getSize();
  1022. var contentWidth = (offset) ? contentSize.x-20-offset : contentSize.x-20;
  1023. if (contentWidth<pageSize_x){
  1024. this.isScale = true;
  1025. var scale = (contentWidth)/pageSize_x;
  1026. this.scale = scale;
  1027. this.zoom();
  1028. this.resetNodeSize();
  1029. }
  1030. }
  1031. },
  1032. zoom: function(scale){
  1033. if (scale) this.scale = scale;
  1034. if (this.zoomSelectAction){
  1035. for (var i=0; i<this.zoomSelectAction.options.length; i++){
  1036. var option = this.zoomSelectAction.options[i];
  1037. if (Math.abs(this.scale-option.value.toFloat())<0.05){
  1038. option.set("selected", true);
  1039. break;
  1040. }
  1041. }
  1042. }
  1043. var w = this.node.getSize().x;
  1044. if (this.history && this.history.historyListAreaNode) w = w-this.history.historyListAreaNode.getComputedSize().totalWidth-2;
  1045. w = w/this.scale;
  1046. this.contentNode.setStyles({
  1047. "transform":"scale("+this.scale+")",
  1048. "transform-origin": "0px 0px",
  1049. "overflow": "auto",
  1050. "width": ""+w+"px"
  1051. });
  1052. },
  1053. _switchReadOrEdit: function(){
  1054. if (this.editMode){
  1055. this._readFiletext();
  1056. if (this.allowEdit) {
  1057. var button = this.toolbar.childrenButton[0];
  1058. button.setText((layout.mobile) ? MWF.xApplication.process.Xform.LP.editdoc_mobile : MWF.xApplication.process.Xform.LP.editdoc);
  1059. button.picNode.getElement("img").set("src", "../x_component_process_Xform/$Form/default/icon/editdoc.png");
  1060. //this.getFullWidthFlagNode().dispose();
  1061. }
  1062. this.editMode = false;
  1063. }else{
  1064. this._editFiletext();
  1065. if (this.allowEdit) {
  1066. var button = this.toolbar.childrenButton[0];
  1067. button.setText((layout.mobile) ? MWF.xApplication.process.Xform.LP.editdocCompleted_mobile : MWF.xApplication.process.Xform.LP.editdocCompleted);
  1068. button.picNode.getElement("img").set("src", "../x_component_process_Xform/$Form/default/icon/editdoc_completed.png");
  1069. //this.toolbar.node.inject(this.getFullWidthFlagNode());
  1070. }
  1071. this.editMode = true;
  1072. }
  1073. },
  1074. _switchReadOrEditInline: function(){
  1075. if (this.editMode){
  1076. this._readFiletext();
  1077. if (this.allowEdit){
  1078. if (!layout.mobile) {
  1079. var button = this.sideToolbar.childrenButton[0];
  1080. button.setText((layout.mobile) ? MWF.xApplication.process.Xform.LP.editdoc_mobile : MWF.xApplication.process.Xform.LP.editdoc);
  1081. button.picNode.getElement("img").set("src", "../x_component_process_Xform/$Form/default/icon/editdoc.png");
  1082. //this.getFullWidthFlagNode().dispose();
  1083. }
  1084. button = this.toolbar.childrenButton[0];
  1085. button.setText((layout.mobile) ? MWF.xApplication.process.Xform.LP.editdoc_mobile : MWF.xApplication.process.Xform.LP.editdoc);
  1086. button.picNode.getElement("img").set("src", "../x_component_process_Xform/$Form/default/icon/editdoc.png");
  1087. //this.getFullWidthFlagNode().dispose();
  1088. // if (!layout.mobile)this.sideToolbar.childrenButton[0].setText(MWF.xApplication.process.Xform.LP.editdoc);
  1089. // this.toolbar.childrenButton[0].setText(MWF.xApplication.process.Xform.LP.editdoc);
  1090. }
  1091. this.editMode = false;
  1092. }else{
  1093. this._editFiletext("inline");
  1094. if (this.allowEdit){
  1095. if (!layout.mobile) {
  1096. var button = this.sideToolbar.childrenButton[0];
  1097. button.setText((layout.mobile) ? MWF.xApplication.process.Xform.LP.editdocCompleted_mobile : MWF.xApplication.process.Xform.LP.editdocCompleted);
  1098. button.picNode.getElement("img").set("src", "../x_component_process_Xform/$Form/default/icon/editdoc_completed.png");
  1099. //this.toolbar.node.inject(this.getFullWidthFlagNode());
  1100. }
  1101. button = this.toolbar.childrenButton[0];
  1102. button.setText((layout.mobile) ? MWF.xApplication.process.Xform.LP.editdocCompleted_mobile : MWF.xApplication.process.Xform.LP.editdocCompleted);
  1103. button.picNode.getElement("img").set("src", "../x_component_process_Xform/$Form/default/icon/editdoc_completed.png");
  1104. //this.toolbar.node.inject(this.getFullWidthFlagNode());
  1105. // if (!layout.mobile) this.sideToolbar.childrenButton[0].setText(MWF.xApplication.process.Xform.LP.editdocCompleted);
  1106. // this.toolbar.childrenButton[0].setText(MWF.xApplication.process.Xform.LP.editdocCompleted);
  1107. }
  1108. this.editMode = true;
  1109. }
  1110. },
  1111. // getFullWidthFlagNode: function(){
  1112. // if (!this.fullWidthFlagNode){
  1113. // this.fullWidthFlagNode = new Element("span", {
  1114. // "styles": {
  1115. // "line-height": "26px",
  1116. // "color": "#999999",
  1117. // "font-size": "12px"
  1118. // },
  1119. // "text": MWF.xApplication.process.Xform.LP.fullWidth
  1120. // });
  1121. // }
  1122. // return this.fullWidthFlagNode;
  1123. // },
  1124. _printDoc: function(){
  1125. var scale = this.scale;
  1126. this.toWord(function(data){
  1127. if (this.form.businessData.work && !this.form.businessData.work.completedTime){
  1128. this.form.workAction.getAttachmentStream(data.id, this.form.businessData.work.id);
  1129. }else{
  1130. this.form.workAction.getWorkcompletedAttachmentStream(data.id, ((this.form.businessData.workCompleted) ? this.form.businessData.workCompleted.id : this.form.businessData.work.id));
  1131. }
  1132. this.scaleTo(scale);
  1133. }.bind(this));
  1134. },
  1135. _historyDoc: function(){
  1136. this.getHistory(function(){
  1137. //this.history.play();
  1138. }.bind(this));
  1139. },
  1140. getHistory: function(callback){
  1141. if (this.history){
  1142. this.history.active(function(){
  1143. if (callback) callback();
  1144. });
  1145. }else{
  1146. MWF.xDesktop.requireApp("process.Xform", "widget.DocumentHistory", function(){
  1147. this.history = new MWF.xApplication.process.Xform.widget.DocumentHistory(this);
  1148. this.history.load(function(){
  1149. if (callback) callback();
  1150. });
  1151. }.bind(this));
  1152. }
  1153. },
  1154. htmlToText: function(html){
  1155. var tmpdiv = new Element("div", {"html": html});
  1156. var text = tmpdiv.get("text");
  1157. tmpdiv.destroy();
  1158. return text;
  1159. },
  1160. _readFiletext: function(){
  1161. //this._returnScale();
  1162. //this.zoom(1);
  1163. var scale = this.scale;
  1164. if (this.filetextEditor) this.filetextEditor.destroy();
  1165. if (this.filetextScrollNode){
  1166. if (this.reLocationFiletextToolbarFun){
  1167. this.filetextScrollNode.removeEvent("scroll", this.reLocationFiletextToolbarFun);
  1168. //this.form.app.removeEvent("resize", this.reLocationFiletextToolbarFun);
  1169. this.reLocationFiletextToolbarFun = null;
  1170. }
  1171. this.filetextScrollNode = null;
  1172. }
  1173. if (this.filetextToolbarNode) this.filetextToolbarNode = null;
  1174. this.layout_filetext.setAttribute('contenteditable', false);
  1175. this.data = this.getData();
  1176. // debugger;
  1177. if (!this.data.filetext){
  1178. //this.data.filetext = this.json.defaultValue.filetext;
  1179. this.layout_filetext.set("html", this.json.defaultValue.filetext);
  1180. }
  1181. //this._checkSplitPage(this.pages[0]);
  1182. this._repage();
  1183. this.scaleTo(scale);
  1184. },
  1185. _editFiletext: function(inline){
  1186. this._returnScale();
  1187. this.zoom(1);
  1188. this._singlePage();
  1189. this.pages = [];
  1190. this.contentNode.empty();
  1191. this._createPage(function(control){
  1192. this._loadPageLayout(control);
  1193. // var docData = this._getBusinessData();
  1194. // if (!docData) docData = this._getDefaultData();
  1195. if (this.data.filetext == this.json.defaultValue.filetext) this.data.filetext = "  ";
  1196. this.setData(this.data);
  1197. this._checkScale();
  1198. this.node.setStyles({
  1199. "height":"auto"
  1200. });
  1201. this._createEditor(inline);
  1202. }.bind(this));
  1203. },
  1204. _createEditor: function(inline){
  1205. if (this.allowEdit){
  1206. this.loadCkeditorFiletext(function(e){
  1207. e.editor.focus();
  1208. var text = this.data.filetext.replace(/\u3000*/g, "");
  1209. if (!text){
  1210. var range = e.editor.createRange();
  1211. range.moveToElementEditEnd(e.editor.editable());
  1212. range.select();
  1213. range.scrollIntoView();
  1214. }else{
  1215. e.editor.getSelection().scrollIntoView();
  1216. }
  1217. //e.editor.getSelection().scrollIntoView();
  1218. var text = this.data.filetext.replace(/\u3000*/g, "");
  1219. if (!text){
  1220. var range = e.editor.createRange();
  1221. range.moveToElementEditEnd(e.editor.editable());
  1222. range.select();
  1223. range.scrollIntoView();
  1224. }else{
  1225. e.editor.getSelection().scrollIntoView();
  1226. }
  1227. // e.editor.getSelection().scrollIntoView();
  1228. //
  1229. //this.getFiletextToolber();
  1230. //this.filetextToolbarNode.inject(this.layout_filetext.getOffsetParent());
  1231. this.locationFiletextToolbar();
  1232. }.bind(this), inline);
  1233. }
  1234. },
  1235. getFiletextToolber: function(){
  1236. if (this.filetextEditor) {
  1237. if (!this.filetextToolbarNode) {
  1238. var className = "cke_editor_" + this.filetextEditor.name;
  1239. var filetextToolbarNode = $$("." + className)[0];
  1240. this.filetextToolbarNode = filetextToolbarNode;
  1241. //filetextToolbarNode.destroy();
  1242. }
  1243. }
  1244. },
  1245. reLocationFiletextToolbar: function(){
  1246. this.getFiletextToolber();
  1247. // if (this.filetextToolbarNode){
  1248. // this.filetextToolbarNode.setStyle("display", "block");
  1249. // var offsetNode = this.layout_filetext.getOffsetParent();
  1250. //
  1251. // this.filetextToolbarNode.setStyle("left", 0);
  1252. // var h = this.filetextToolbarNode.getSize().y;
  1253. // var p = this.layout_filetext.getPosition(offsetNode).y-h;
  1254. //
  1255. // var postion = this.layout_filetext.getPosition(this.form.app.content);
  1256. // if (postion.y-h<0){
  1257. // this.filetextToolbarNode.inject(this.form.app.content);
  1258. // this.filetextToolbarNode.setStyle("top", 0);
  1259. // this.filetextToolbarNode.setStyle("left", ""+postion.x+"px");
  1260. // }else{
  1261. // this.filetextToolbarNode.inject(offsetNode);
  1262. // this.filetextToolbarNode.setStyle("top", "" + p + "px");
  1263. // this.filetextToolbarNode.setStyle("left", 0);
  1264. // this.filetextToolbarNode.setStyle("left", "auto");
  1265. // }
  1266. // }
  1267. if (this.filetextToolbarNode){
  1268. if (!this.filetextScrollNode){
  1269. var scrollNode = this.contentNode;
  1270. while (scrollNode && (scrollNode.getScrollSize().y<=scrollNode.getSize().y || (scrollNode.getStyle("overflow")!=="auto" && scrollNode.getStyle("4-y")!=="auto"))){
  1271. scrollNode = scrollNode.getParent();
  1272. }
  1273. this.filetextScrollNode = scrollNode;
  1274. }
  1275. var h = this.filetextToolbarNode.getSize().y;
  1276. var position = this.layout_filetext.getPosition();
  1277. var size = this.layout_filetext.getSize();
  1278. var contentSize = this.filetextScrollNode.getSize();
  1279. if (position.y<0 && size.y+position.y+h<contentSize.y){
  1280. // var top = size.y+position.y;
  1281. // this.filetextToolbarNode.setStyle("top", ""+top+"px");
  1282. var tp = this.toolbar.node.getPosition();
  1283. var tsy = this.toolbar.node.getSize().y;
  1284. var h = tp.y+tsy;
  1285. this.filetextToolbarNode.setStyle("top", ""+h+"px");
  1286. }else if (position.y-h<0){
  1287. var tp = this.toolbar.node.getPosition();
  1288. var tsy = this.toolbar.node.getSize().y;
  1289. var h = tp.y+tsy;
  1290. this.filetextToolbarNode.setStyle("top", ""+h+"px");
  1291. }else{
  1292. var p = this.layout_filetext.getPosition().y-h;
  1293. this.filetextToolbarNode.setStyle("top", "" + p + "px");
  1294. }
  1295. }
  1296. //
  1297. // this.filetextToolbarNode.inject(offsetNode);
  1298. //
  1299. //
  1300. // this.filetextToolbarNode.setStyle("top", ""+p+"px");
  1301. },
  1302. locationFiletextToolbar: function(){
  1303. this.reLocationFiletextToolbar();
  1304. if (this.filetextToolbarNode) {
  1305. var scrollNode = this.contentNode;
  1306. while (scrollNode && (scrollNode.getScrollSize().y<=scrollNode.getSize().y || (scrollNode.getStyle("overflow")!=="auto" && scrollNode.getStyle("overflow-y")!=="auto"))){
  1307. scrollNode = scrollNode.getParent();
  1308. }
  1309. if (scrollNode){
  1310. this.filetextScrollNode = scrollNode;
  1311. this.reLocationFiletextToolbarFun = this.reLocationFiletextToolbar.bind(this);
  1312. this.filetextScrollNode.addEvent("scroll", this.reLocationFiletextToolbarFun);
  1313. }
  1314. }
  1315. },
  1316. _isAllowEdit:function(){
  1317. if (this.readonly) return false;
  1318. if (this.json.allowEdit=="n") return false;
  1319. if (this.json.allowEdit=="s"){
  1320. if (this.json.allowEditScript && this.json.allowEditScript.code){
  1321. return !!this.form.Macro.exec(this.json.allowEditScript.code, this);
  1322. }
  1323. }
  1324. return true;
  1325. },
  1326. _isAllowPrint: function(){
  1327. if (this.json.allowPrint=="n") return false;
  1328. if (this.json.allowPrint=="s"){
  1329. if (this.json.allowPrintScript && this.json.allowPrintScript.code){
  1330. return !!this.form.Macro.exec(this.json.allowPrintScript.code, this);
  1331. }
  1332. }
  1333. return true;
  1334. },
  1335. _isAllowHistory: function(){
  1336. if (this.json.allowHistory=="n") return false;
  1337. if (this.json.allowHistory=="s"){
  1338. if (this.json.allowHistoryScript && this.json.allowHistoryScript.code){
  1339. return !!this.form.Macro.exec(this.json.allowHistoryScript.code, this);
  1340. }
  1341. }
  1342. return true;
  1343. },
  1344. _getEdit: function(name, typeItem, scriptItem){
  1345. switch (this.json[typeItem]) {
  1346. case "y":
  1347. return true;
  1348. case "n":
  1349. return false;
  1350. case "s":
  1351. if (this.json[scriptItem] && this.json[scriptItem].code){
  1352. return !!this.form.Macro.exec(this.json[scriptItem].code, this);
  1353. }
  1354. return true;
  1355. }
  1356. },
  1357. loadCkeditorStyle: function(node){
  1358. if (node){
  1359. o2.load("ckeditor", function(){
  1360. //CKEDITOR.disableAutoInline = true;
  1361. node.setAttribute('contenteditable', true);
  1362. var editor = CKEDITOR.inline(this.layout_filetext, this._getEditorConfig());
  1363. this.filetextEditor.on("instanceReady", function(e){
  1364. if (callback) callback(e);
  1365. }.bind(this));
  1366. }.bind(this));
  1367. }
  1368. },
  1369. _loadToolbars: function(){
  1370. var html ="";
  1371. var editdoc, printdoc, history;
  1372. if (layout.mobile){
  1373. editdoc = MWF.xApplication.process.Xform.LP.editdoc_mobile;
  1374. printdoc = MWF.xApplication.process.Xform.LP.printdoc_mobile;
  1375. history = MWF.xApplication.process.Xform.LP.history_mobile;
  1376. }else{
  1377. editdoc = MWF.xApplication.process.Xform.LP.editdoc;
  1378. printdoc = MWF.xApplication.process.Xform.LP.printdoc;
  1379. history = MWF.xApplication.process.Xform.LP.history;
  1380. }
  1381. if (this.allowEdit){
  1382. //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>";
  1383. html += "<span MWFnodetype=\"MWFToolBarButton\" MWFButtonImage=\"../x_component_process_Xform/$Form/default/icon/editdoc.png\" title=\""+editdoc+"\" MWFButtonAction=\"_switchReadOrEditInline\" MWFButtonText=\""+editdoc+"\"></span>";
  1384. //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>";
  1385. }
  1386. if (this.allowPrint){
  1387. html += "<span MWFnodetype=\"MWFToolBarButton\" MWFButtonImage=\"../x_component_process_Xform/$Form/default/icon/print.png\" title=\""+printdoc+"\" MWFButtonAction=\"_printDoc\" MWFButtonText=\""+printdoc+"\"></span>";
  1388. }
  1389. if (this.allowHistory){
  1390. html += "<span MWFnodetype=\"MWFToolBarButton\" MWFButtonImage=\"../x_component_process_Xform/$Form/default/icon/versions.png\" title=\""+history+"\" MWFButtonAction=\"_historyDoc\" MWFButtonText=\""+history+"\"></span>";
  1391. }
  1392. // if (this.json.fullWidth=="y"){
  1393. // html += "<span style='line-height: 26px; color: #999999; font-size: 12px'>已启用半角空格自动转换为全角空格,如需输入半角空格,请使用:SHIFT+空格</span>"
  1394. // }
  1395. this.toolbarNode = new Element("div", {"styles": this.css.doc_toolbar_node}).inject(this.toolNode);
  1396. this.toolbarNode.set("html", html);
  1397. MWF.require("MWF.widget.Toolbar", function() {
  1398. this.toolbar = new MWF.widget.Toolbar(this.toolbarNode, {"style": "documentEdit"}, this);
  1399. this.toolbar.load();
  1400. }.bind(this));
  1401. if (!layout.mobile){
  1402. this.scrollNode = this.toolbarNode.getParentSrcollNode();
  1403. if (this.scrollNode){
  1404. this.scrollNode.addEvent("scroll", function(){
  1405. this.resizeToolbar();
  1406. }.bind(this));
  1407. }
  1408. }
  1409. //if (this.json.canDoublePage!=="n" && !layout.mobile){
  1410. this.doublePageAction = new Element("div", {"styles": this.css.doc_toolbar_doublePage, "text": MWF.xApplication.process.Xform.LP.doublePage}).inject(this.toolbarNode);
  1411. this.doublePageAction.addEvent("click", function(){
  1412. if (this.options.pageShow!=="double"){
  1413. this._doublePage();
  1414. }else{
  1415. this.options.pageShow="single";
  1416. this.reload();
  1417. //this._singlePage();
  1418. }
  1419. }.bind(this));
  1420. if (this.json.canDoublePage!=="n" && !layout.mobile) this.doublePageAction.hide();
  1421. //}
  1422. this.zoomActionArea = new Element("div", {"styles": {"float": "right", "margin-right": "10px"}}).inject(this.toolbarNode);
  1423. if (this.json.isScale !== "y") this.zoomActionArea.hide();
  1424. this.zoomAddAction = new Element("div", {
  1425. "styles": {
  1426. "float": "right",
  1427. "margin-top": "3px",
  1428. "height": "20px",
  1429. "width": "20px",
  1430. "text-align": "center",
  1431. "line-height": "20px",
  1432. "border": "1px solid #cccccc",
  1433. "background-color": "#ffffff",
  1434. "margin-left": "5px"
  1435. },
  1436. "text": "+"
  1437. }).inject(this.zoomActionArea);
  1438. this.zoomSelectAction = new Element("select", {
  1439. "styles": {
  1440. "float": "right",
  1441. "margin-top": "3px",
  1442. "height": "20px",
  1443. "width": "60px",
  1444. "text-align": "center",
  1445. "line-height": "20px",
  1446. "border": "1px solid #cccccc",
  1447. "background-color": "#ffffff",
  1448. "margin-left": "5px"
  1449. },
  1450. "text": "100%"
  1451. }).inject(this.zoomActionArea);
  1452. this.zoomSubAction = new Element("div", {
  1453. "styles": {
  1454. "float": "right",
  1455. "margin-top": "3px",
  1456. "height": "20px",
  1457. "width": "20px",
  1458. "text-align": "center",
  1459. "line-height": "20px",
  1460. "border": "1px solid #cccccc",
  1461. "background-color": "#ffffff",
  1462. "margin-left": "5px"
  1463. },
  1464. "text": "-"
  1465. }).inject(this.zoomActionArea);
  1466. // this.zoomSelectAction = new Element("select", {"styles": {"float": "right"}}).inject(this.toolbarNode);
  1467. var options = "<option value='2'>200%</option> " +
  1468. "<option value='1.95'>195%</option>" +
  1469. "<option value='1.9'>190%</option>" +
  1470. "<option value='1.85'>185%</option>" +
  1471. "<option value='1.8'>180%</option>" +
  1472. "<option value='1.75'>175%</option>" +
  1473. "<option value='1.7'>170%</option>" +
  1474. "<option value='1.65'>165%</option>" +
  1475. "<option value='1.6'>160%</option>" +
  1476. "<option value='1.55'>155%</option>" +
  1477. "<option value='1.5'>150%</option> " +
  1478. "<option value='1.45'>145%</option>" +
  1479. "<option value='1.4'>140%</option>" +
  1480. "<option value='1.35'>135%</option>" +
  1481. "<option value='1.3'>130%</option>" +
  1482. "<option value='1.25'>125%</option>" +
  1483. "<option value='1.2'>120%</option>" +
  1484. "<option value='1.15'>115%</option>" +
  1485. "<option value='1.1'>110%</option>" +
  1486. "<option value='1.05'>105%</option>" +
  1487. "<option value='1' selected>100%</option>" +
  1488. "<option value='0.95'>95%</option>" +
  1489. "<option value='0.90'>90%</option>" +
  1490. "<option value='0.85'>85%</option>" +
  1491. "<option value='0.80'>80%</option>" +
  1492. "<option value='0.75'>75%</option>" +
  1493. "<option value='0.70'>70%</option>" +
  1494. "<option value='0.65'>65%</option>" +
  1495. "<option value='0.6'>60%</option>" +
  1496. "<option value='0.55'>55%</option>" +
  1497. "<option value='0.5'>50%</option>";
  1498. this.zoomSelectAction.set("html", options);
  1499. this.zoomSelectAction.addEvent("change", function(e){
  1500. this.scaleTo(e.target.options[e.target.selectedIndex].value);
  1501. }.bind(this));
  1502. this.zoomAddAction.addEvent("click", function(){
  1503. debugger;
  1504. var i = (this.scale/0.05).toInt();
  1505. if (i*0.05<this.scale) i++;
  1506. var v = i*0.05;
  1507. //var v = this.zoomSelectAction.options[this.zoomSelectAction.selectedIndex].value.toFloat();
  1508. v = v+0.05;
  1509. if (v<0.5) v = 0.5;
  1510. if (v>2) v = 2;
  1511. this.scaleTo(v);
  1512. }.bind(this));
  1513. this.zoomSubAction.addEvent("click", function(){
  1514. var i = (this.scale/0.05).toInt();
  1515. if (i*0.05<this.scale) i++;
  1516. var v = i*0.05;
  1517. //var v = this.zoomSelectAction.options[this.zoomSelectAction.selectedIndex].value.toFloat();
  1518. v = v-0.05;
  1519. if (v<0.5) v = 0.5;
  1520. if (v>2) v = 2;
  1521. this.scaleTo(v);
  1522. }.bind(this));
  1523. },
  1524. scaleTo: function(scale){
  1525. this._returnScale();
  1526. this.scale = scale;
  1527. this.zoom();
  1528. var w = this.contentNode.getSize().x;
  1529. var count = 1;
  1530. var docPageFullWidth = (this.scale) ? this.scale*this.options.docPageFullWidth : this.options.docPageFullWidth;
  1531. var pageWidth = count * docPageFullWidth;
  1532. var margin = (w-pageWidth)/(count+1);
  1533. if (this.isScale){
  1534. margin = "10";
  1535. }
  1536. if (this.scale) margin = margin/this.scale;
  1537. if (margin < 10){
  1538. var offset = 10-margin;
  1539. margin = 10;
  1540. this.contentNode.scrollTo(offset, 0);
  1541. }
  1542. this.pages.each(function(page, i){
  1543. page.setStyles({
  1544. "float": "left",
  1545. "margin-left": ""+margin+"px"
  1546. });
  1547. });
  1548. this.resetNodeSize();
  1549. },
  1550. _repage: function(delay){
  1551. if (this.options.pageShow!=="double"){
  1552. this._singlePage();
  1553. }else{
  1554. this._doublePage();
  1555. }
  1556. if (delay){
  1557. if (!this.form.isLoaded){
  1558. this.form.addEvent("afterLoad", this._checkScale.bind(this));
  1559. }else{
  1560. this._checkScale();
  1561. }
  1562. }else{
  1563. this._checkScale();
  1564. }
  1565. },
  1566. _singlePage: function(){
  1567. //if (this.editMode) this._readFiletext();
  1568. var scale = this.singlePageZoom || 1;
  1569. if( this.singlePageZoom && this.singlePageZoom.toInt() != 1 ){
  1570. this.isScale = true;
  1571. this.scale = this.singlePageZoom;
  1572. this.singlePageZoom = null;
  1573. }
  1574. this.zoom(scale);
  1575. this._checkScale();
  1576. var w = this.contentNode.getSize().x;
  1577. var count = 1;
  1578. var docPageFullWidth = (this.scale) ? this.scale*this.options.docPageFullWidth : this.options.docPageFullWidth;
  1579. //var docPageFullWidth = this.options.docPageFullWidt;
  1580. var pageWidth = count * docPageFullWidth;
  1581. var margin = (w-pageWidth)/(count+1);
  1582. if (this.isScale){
  1583. margin = "10";
  1584. }
  1585. if (this.scale) margin = margin/this.scale;
  1586. this.pages.each(function(page, i){
  1587. page.setStyles({
  1588. "float": "left",
  1589. "margin-left": ""+margin+"px"
  1590. });
  1591. });
  1592. this.resetNodeSize();
  1593. // this.pages.each(function(page){
  1594. // page.setStyle("float", "none");
  1595. // });
  1596. this.resizeSidebar();
  1597. this.options.pageShow="single";
  1598. this.doublePageAction.set("text", MWF.xApplication.process.Xform.LP.doublePage);
  1599. },
  1600. resetNodeSize: function(){
  1601. var contentSize = this.contentNode.getSize();
  1602. var toolbarSize = this.toolNode.getSize();
  1603. contentHeight = contentSize.y;
  1604. var h = contentHeight+toolbarSize.y+20;
  1605. //h = h - contentSize.y*(1-this.scale);
  1606. this.node.setStyles({
  1607. "height":""+h+"px"
  1608. });
  1609. this.resizeSidebar();
  1610. },
  1611. createWaitSplitPage: function(){
  1612. this.node.mask({
  1613. "style": {
  1614. "background-color": "#cccccc",
  1615. "opacity": 0.3
  1616. }
  1617. });
  1618. this.waitSplitPageNode = new Element("div", {"styles": this.form.css.waitSplitPageNode, "text": MWF.xApplication.process.Xform.LP.computePage}).inject(this.node);
  1619. this.waitSplitPageNode.position({
  1620. "relativeTo": this.node,
  1621. "position": "topRight",
  1622. "edge": "topRight",
  1623. "offset": {
  1624. "x": -10,
  1625. "y": 45
  1626. }
  1627. });
  1628. //this.form.notice(MWF.xApplication.process.Xform.LP.computePage, "info", this.node);
  1629. },
  1630. clearWaitSplitPage: function(){
  1631. this.node.unmask();
  1632. if (this.waitSplitPageNode) this.waitSplitPageNode.destroy();
  1633. this.waitSplitPageNode = null;
  1634. },
  1635. _doublePage: function(){
  1636. if (this.editMode) this._switchReadOrEditInline();
  1637. if( this.zoomSelectAction ){
  1638. this.singlePageZoom = ( this.zoomSelectAction.options[this.zoomSelectAction.selectedIndex].value ).toFloat();
  1639. }
  1640. this.zoom(1);
  1641. this.createWaitSplitPage();
  1642. window.setTimeout(function(){
  1643. this._checkSplitPage(this.pages[0]);
  1644. this.zoom(1);
  1645. var w = this.contentNode.getSize().x;
  1646. var toPageWidth = (w-100)/2;
  1647. scale = toPageWidth/this.options.docPageFullWidth;
  1648. if (scale<1) this.zoom(scale);
  1649. var docPageFullWidth = (this.scale) ? this.scale*this.options.docPageFullWidth : this.options.docPageFullWidth;
  1650. //var docPageFullWidth = this.options.docPageFullWidth;
  1651. var w = this.contentNode.getSize().x;
  1652. var count = (w/docPageFullWidth).toInt();
  1653. var pages = this.contentNode.getElements(".doc_layout_page");
  1654. count = Math.min(pages.length, count);
  1655. var pageWidth = count * docPageFullWidth;
  1656. var margin = (w-pageWidth)/(count+1);
  1657. if (this.scale) margin = margin/(this.scale);
  1658. this.pages.each(function(page, i){
  1659. page.setStyles({
  1660. "float": "left",
  1661. "margin-left": ""+margin+"px"
  1662. });
  1663. });
  1664. // this.pages.each(function(page, i){
  1665. // if ((i % 2)===0){
  1666. // page.setStyle("float", "left");
  1667. // }else{
  1668. // page.setStyle("float", "right");
  1669. // }
  1670. // });
  1671. this.resetNodeSize();
  1672. this.options.pageShow="double";
  1673. this.doublePageAction.set("text", MWF.xApplication.process.Xform.LP.singlePage);
  1674. this.resizeSidebar();
  1675. this.clearWaitSplitPage();
  1676. }.bind(this), 1000);
  1677. },
  1678. _getDefaultData: function(){
  1679. return Object.clone(this.json.defaultValue);
  1680. //return Object.clone(MWF.xApplication.process.Xform.LP.documentEditor);
  1681. },
  1682. _loadFiletextPage: function(callback){
  1683. this.data = this._getBusinessData();
  1684. if (!this.data) this.data = this._getDefaultData();
  1685. this._computeData(true);
  1686. this._createPage(function(control){
  1687. this._loadPageLayout(control);
  1688. // this.data = this._getBusinessData();
  1689. // if (!this.data) this.data = this._getDefaultData();
  1690. this.setData(this.data);
  1691. // this._checkSplitPage(this.pages[0]);
  1692. //this._repage(true);
  1693. //this.loadCkeditorFiletext();
  1694. if (!this.readonly){
  1695. //if (this.json.allowEditFiletext!==false) this.loadCkeditorFiletext();
  1696. // if (this.json.allowEditRedheader) this.loadCkeditorRedheader();
  1697. // if (this.json.allowEditSubject) this.loadCkeditorSubject();
  1698. // if (this.json.allowEditMainSend) this.loadCkeditorMainSend();
  1699. // if (this.json.allowEditFileNo) this.loadCkeditorFileNo();
  1700. // if (this.json.allowEditSigner) this.loadCkeditorSigner();
  1701. // if (this.json.allowEditAttachment) this.loadCkeditorAttachment();
  1702. }
  1703. if (callback) callback();
  1704. }.bind(this));
  1705. },
  1706. _getEditorConfig: function(){
  1707. // var mathElements = [
  1708. // 'math',
  1709. // 'maction',
  1710. // 'maligngroup',
  1711. // 'malignmark',
  1712. // 'menclose',
  1713. // 'merror',
  1714. // 'mfenced',
  1715. // 'mfrac',
  1716. // 'mglyph',
  1717. // 'mi',
  1718. // 'mlabeledtr',
  1719. // 'mlongdiv',
  1720. // 'mmultiscripts',
  1721. // 'mn',
  1722. // 'mo',
  1723. // 'mover',
  1724. // 'mpadded',
  1725. // 'mphantom',
  1726. // 'mroot',
  1727. // 'mrow',
  1728. // 'ms',
  1729. // 'mscarries',
  1730. // 'mscarry',
  1731. // 'msgroup',
  1732. // 'msline',
  1733. // 'mspace',
  1734. // 'msqrt',
  1735. // 'msrow',
  1736. // 'mstack',
  1737. // 'mstyle',
  1738. // 'msub',
  1739. // 'msup',
  1740. // 'msubsup',
  1741. // 'mtable',
  1742. // 'mtd',
  1743. // 'mtext',
  1744. // 'mtr',
  1745. // 'munder',
  1746. // 'munderover',
  1747. // 'semantics',
  1748. // 'annotation',
  1749. // 'annotation-xml'
  1750. // ];
  1751. //CKEDITOR.plugins.addExternal('ckeditor_wiris', 'https://ckeditor.com/docs/ckeditor4/4.13.0/examples/assets/plugins/ckeditor_wiris/', 'plugin.js');
  1752. debugger;
  1753. var editorConfig = {
  1754. qtRows: 20, // Count of rows
  1755. qtColumns: 20, // Count of columns
  1756. qtBorder: '1', // Border of inserted table
  1757. qtWidth: '95%', // Width of inserted table
  1758. qtStyle: { 'border-collapse' : 'collapse' },
  1759. qtClass: 'documenteditor_table'+this.form.json.id+this.json.id, // Class of table
  1760. qtCellPadding: '0', // Cell padding table
  1761. qtCellSpacing: '0', // Cell spacing table
  1762. qtPreviewBorder: '4px double black', // preview table border
  1763. qtPreviewSize: '4px', // Preview table cell size
  1764. qtPreviewBackground: '#c8def4', // preview table background (hover)
  1765. // format_tags: '标题一;标题二;标题三;标题四;正文', // entries is displayed in "Paragraph format"
  1766. format_tags: '标题一;标题二;正文(标题三,四)', // entries is displayed in "Paragraph format"
  1767. 'format_标题一': {
  1768. name: '标题一(三号黑体)',
  1769. element: 'div',
  1770. styles: {
  1771. 'font-family': '黑体',
  1772. 'font-size': '16pt'
  1773. }
  1774. },
  1775. 'format_标题二': {
  1776. name: '标题二(三号楷体)',
  1777. element: 'div',
  1778. styles: {
  1779. 'font-family': '楷体',
  1780. 'font-size': '16pt'
  1781. }
  1782. },
  1783. // 'format_标题三': {
  1784. // name: '标题三',
  1785. // element: 'div',
  1786. // styles: {
  1787. // 'font-family': '仿宋',
  1788. // 'font-size': '16pt'
  1789. // }
  1790. // },
  1791. // 'format_标题四': {
  1792. // name: '标题四',
  1793. // element: 'div',
  1794. // styles: {
  1795. // 'font-family': '仿宋',
  1796. // 'font-size': '16pt'
  1797. // }
  1798. // },
  1799. 'format_正文(标题三,四)': {
  1800. name: '正文(标题三,四)',
  1801. element: 'div',
  1802. styles: {
  1803. 'font-family': '仿宋',
  1804. 'font-size': '16pt'
  1805. }
  1806. }
  1807. };
  1808. editorConfig.toolbarGroups = [
  1809. { name: 'document', groups: [ 'mode', 'document', 'doctools' ] },
  1810. { name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
  1811. { name: 'editing', groups: [ 'find', 'selection', 'spellchecker', 'editing' ] },
  1812. { name: 'forms', groups: [ 'forms' ] },
  1813. { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
  1814. { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi', 'paragraph' ] },
  1815. { name: 'links', groups: [ 'links' ] },
  1816. { name: 'insert', groups: [ 'insert' ] },
  1817. { name: 'styles', groups: [ 'styles' ] },
  1818. { name: 'colors', groups: [ 'colors' ] },
  1819. { name: 'tools', groups: [ 'tools' ] },
  1820. { name: 'others', groups: [ 'others' ] },
  1821. { name: 'about', groups: [ 'about' ] }
  1822. ];
  1823. //editorConfig.extraPlugins = "ecnet,colordialog,tableresize,quicktable,mathjax,ckeditor_wiris";
  1824. //editorConfig.extraPlugins = "ecnet,colordialog,quicktable,tableresize,eqneditor";
  1825. //editorConfig.extraPlugins = "tableresize,quicktable";
  1826. editorConfig.extraPlugins = "quicktable,tableresize";
  1827. //editorConfig.mathJaxLib = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=TeX-AMS_HTML',
  1828. 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';
  1829. //editorConfig.extraAllowedContent = mathElements.join(' ') + '(*)[*]{*};img[data-mathml,data-custom-editor,role](Wirisformula)';
  1830. editorConfig.pasteFromWordRemoveFontStyles = false;
  1831. editorConfig.pasteFromWordRemoveStyles = false;
  1832. //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';
  1833. editorConfig.removePlugins = ['magicline'];
  1834. editorConfig.enterMode = 3;
  1835. // editorConfig.extraPlugins = ['ecnet','mathjax'];
  1836. // editorConfig.removePlugins = ['magicline'];
  1837. // editorConfig.mathJaxLib = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=TeX-AMS_HTML';
  1838. return editorConfig;
  1839. },
  1840. _checkSplitPage: function(pageNode){
  1841. if (this.layout_edition) this.layout_edition.setStyles({ "position": "static"});
  1842. var contentNode = pageNode.getFirst();
  1843. if (contentNode.getSize().y>this.options.docPageHeight){
  1844. this._splitPage(pageNode);
  1845. }
  1846. var i = pageNode.get("data-pagecount").toInt();
  1847. if (i && this.pages.length-1>=i){
  1848. this._checkSplitPage(this.pages[i]);
  1849. }
  1850. if (this.layout_edition) this.layout_edition.setStyles({ "position": "absolute", "bottom": "0px" });
  1851. },
  1852. _splitFiletextNodeOneWord:function(lnode, nextPageNode){
  1853. var text = lnode.textContent;
  1854. var len = text.length;
  1855. var left = text.substring(0, len-1);
  1856. var right = text.substring(len-1, len);
  1857. lnode.textContent = left;
  1858. nextPageNode.textContent = right+nextPageNode.textContent;
  1859. //nextPageNode.appendText(right, "top");
  1860. },
  1861. _splitFiletext: function(node, nextPageNode, nextFiletextNode, pageNode){
  1862. var contentNode = pageNode.getFirst();
  1863. var lnode = node.lastChild;
  1864. if (!lnode){
  1865. if (node.parentNode) node.parentNode.removeChild(node);
  1866. //node.remove();
  1867. }else{
  1868. while (contentNode.getSize().y>this.options.docPageHeight && lnode) {
  1869. var tmpnode = lnode.previousSibling;
  1870. var nodeType = lnode.nodeType;
  1871. if (!nextPageNode) nextPageNode = nextFiletextNode;
  1872. if (nodeType == Node.ELEMENT_NODE) {
  1873. if (lnode.tagName == "table") {
  1874. lnode.inject(nextPageNode);
  1875. } else if (lnode.tagName == "BR") {
  1876. if (lnode.parentNode) lnode.parentNode.removeChild(lnode);
  1877. } else {
  1878. var id = lnode.get("data-pagePart");
  1879. if (!id){
  1880. id = (new o2.widget.UUID()).toString();
  1881. lnode.set("data-pagePart", id);
  1882. }
  1883. var tmpNode = nextPageNode.getFirst();
  1884. if (tmpNode && tmpNode.get("data-pagePart")==id){
  1885. nextPageNode = tmpNode;
  1886. }else{
  1887. nextPageNode = lnode.clone(false).inject(nextPageNode, "top");
  1888. }
  1889. //var subnode = lnode.getLast();
  1890. this._splitFiletext(lnode, nextPageNode, nextFiletextNode, pageNode);
  1891. if (!lnode.firstChild) if (lnode.parentNode) lnode.parentNode.removeChild(lnode);
  1892. nextPageNode = nextPageNode.getParent();
  1893. }
  1894. } else if (nodeType == Node.TEXT_NODE) {
  1895. var nextPageTextNode = nextPageNode.insertBefore(document.createTextNode(""), nextPageNode.firstChild);
  1896. while ((contentNode.getSize().y > this.options.docPageHeight) && lnode.textContent) {
  1897. //console.log(contentNode.getSize().y);
  1898. this._splitFiletextNodeOneWord(lnode, nextPageTextNode)
  1899. }
  1900. if (!lnode.textContent) if (lnode.parentNode) lnode.parentNode.removeChild(lnode); //lnode.remove();
  1901. } else {
  1902. //lnode.remove();
  1903. if (lnode.parentNode) lnode.parentNode.removeChild(lnode);
  1904. }
  1905. lnode = tmpnode;
  1906. }
  1907. if (!node.lastChild) if (node.parentNode) node.parentNode.removeChild(node); //node.remove();
  1908. }
  1909. //this._checkSplitPage(pageNode);
  1910. },
  1911. _splitPage: function(pageNode){
  1912. var contentNode = pageNode.getFirst();
  1913. var blockNodes = pageNode.getElements(".doc_block");
  1914. if (blockNodes.length){
  1915. var blockNode = blockNodes[blockNodes.length-1];
  1916. var idx = this.pages.indexOf(pageNode);
  1917. if (this.pages.length<=idx+1) this._createNewPage();
  1918. var nextPage = this.pages[idx+1];
  1919. if (blockNode.hasClass("doc_layout_filetext")){
  1920. var filetextNode = nextPage.getElement(".doc_layout_filetext");
  1921. if (!filetextNode){
  1922. filetextNode = new Element("div.doc_layout_filetext").inject(nextPage.getFirst(), "top");
  1923. //filetextNode.setAttribute('contenteditable', true);
  1924. }
  1925. if (!filetextNode.hasClass("doc_block"))filetextNode.addClass("doc_block");
  1926. //var nextEditor = filetextNode.retrieve("editor");
  1927. var node = blockNode;
  1928. var nextPageNode = filetextNode;
  1929. this._splitFiletext(node, nextPageNode, filetextNode, pageNode);
  1930. }else{
  1931. blockNode.inject(nextPage.getFirst(), "top");
  1932. //var contentNode = pageNode.getFirst();
  1933. if (contentNode.getSize().y>this.options.docPageHeight){
  1934. this._splitPage(pageNode);
  1935. }
  1936. }
  1937. }
  1938. },
  1939. transWidth: function(node){
  1940. if (!node) return '';
  1941. while (node){
  1942. if (node.nodeType==3){
  1943. node.nodeValue = node.nodeValue.replace(/\x20/g, " ");
  1944. }else if (node.nodeType==8){
  1945. //nothing
  1946. }else{
  1947. this.transWidth(node.firstChild);
  1948. }
  1949. node = node.nextSibling;
  1950. }
  1951. },
  1952. insertFullWidth: function(node, txt){
  1953. if (!node) return '';
  1954. while (node){
  1955. if (node.nodeType==3){
  1956. node.nodeValue = txt+node.nodeValue;
  1957. return true;
  1958. }else if (node.nodeType==8){
  1959. //nothing
  1960. }else{
  1961. var flag = this.insertFullWidth(node.firstChild, txt);
  1962. if (flag) return true;
  1963. }
  1964. node = node.nextSibling;
  1965. }
  1966. },
  1967. loadCkeditorFiletext: function(callback, inline){
  1968. if (this.layout_filetext){
  1969. o2.load("../o2_lib/htmleditor/ckeditor4130/ckeditor.js", function(){
  1970. CKEDITOR.disableAutoInline = true;
  1971. this.layout_filetext.setAttribute('contenteditable', true);
  1972. if (inline){
  1973. this.filetextEditor = CKEDITOR.inline(this.layout_filetext, this._getEditorConfig());
  1974. }else{
  1975. this.filetextEditor = CKEDITOR.replace(this.layout_filetext, this._getEditorConfig());
  1976. }
  1977. this.filetextEditor.on("instanceReady", function(e){
  1978. if (callback) callback(e);
  1979. }.bind(this));
  1980. this.filetextEditor.on( 'focus', function( e ) {
  1981. window.setTimeout(this.reLocationFiletextToolbar.bind(this), 10);
  1982. }.bind(this) );
  1983. this.filetextEditor.on( 'paste', function( e ) {
  1984. var html = e.data.dataValue;
  1985. //if (this.json.fullWidth=="y") html = html.replace(/\x20/g, " ");
  1986. var tmp = new Element("div")
  1987. tmp.set("html", html);
  1988. var pList = tmp.getElements("p");
  1989. pList.each(function(p, i){
  1990. //if (Browser.name=="ie"){
  1991. if (this.json.fullWidth!=="n") this.transWidth(p);
  1992. if (!p.getParent("table")){
  1993. var text = p.get("text");
  1994. var rex = /^\u3000*/;
  1995. var m = text.match(rex);
  1996. var l = (m[0]) ? Math.max((2-m[0].length), 0): 2;
  1997. var txt = "";
  1998. // for (var i=0; i<l; i++) txt+=" ";
  1999. // this.insertFullWidth(p.getFirst(), txt);
  2000. for (var i=0; i<l; i++) p.appendText(" ","top");
  2001. }
  2002. //}else{
  2003. // var textIndent = p.getStyle("text-indent");
  2004. // if (textIndent.toInt()) p.appendText("  ","top");
  2005. //}
  2006. }.bind(this));
  2007. e.data.dataValue = tmp.get("html");
  2008. tmp.destroy();
  2009. }.bind(this) );
  2010. if (this.json.textIndent!=="n"){
  2011. // this.filetextEditor.addCommand( 'textIndent_P', {
  2012. // exec: function( editor ) {
  2013. // debugger;
  2014. // editor.insertHtml("<br><div>  </div>");
  2015. // }
  2016. // } );
  2017. // this.filetextEditor.setKeystroke( CKEDITOR.CTRL + 13, 'textIndent_P' );
  2018. this.layout_filetext.addEvent("keyup", function(ev){
  2019. if (ev.code==13) this.filetextEditor.insertText("  ");
  2020. }.bind(this));
  2021. //
  2022. // this.filetextEditor.on("key", function(e){
  2023. // if (e.data.keyCode==13){
  2024. // e.editor.insertText("  ");
  2025. // //e.cancel();
  2026. // }
  2027. // }.bind(this));
  2028. }
  2029. if (this.json.fullWidth!=="n"){
  2030. this.filetextEditor.addCommand( 'insertHalfSpace', {
  2031. exec: function( editor ) {
  2032. editor.insertText(" ");
  2033. }
  2034. } );
  2035. this.filetextEditor.setKeystroke( CKEDITOR.SHIFT + 32, 'insertHalfSpace' );
  2036. this.filetextEditor.on("key", function(e){
  2037. if (this.json.fullWidth!=="n") if (e.data.keyCode==32){
  2038. e.editor.insertText(" ");
  2039. e.cancel();
  2040. }
  2041. }.bind(this));
  2042. }
  2043. }.bind(this));
  2044. }
  2045. },
  2046. _loadEvents: function(editorConfig){
  2047. Object.each(this.json.events, function(e, key){
  2048. if (e.code){
  2049. this.editor.on(key, function(event){
  2050. return this.form.Macro.fire(e.code, this, event);
  2051. }.bind(this), this);
  2052. }
  2053. }.bind(this));
  2054. },
  2055. _bindFieldChange: function(name,dataItem, dom){
  2056. var field = this.form.all[this.json[dataItem]];
  2057. if (field){
  2058. var bindFun = function(){
  2059. this._computeItemFieldData(name, dataItem);
  2060. //if (this.data[name]){
  2061. if (this[dom]){
  2062. if (dom=="layout_redHeader" || dom=="layout_subject" || dom=="layout_issuanceUnit" || dom=="layout_meetingAttendContent" || dom=="layout_meetingLeaveContent" || dom=="layout_meetingSitContent" || dom=="layout_meetingRecordContent"){
  2063. this[dom].set("html", this.data[name]|| "");
  2064. }else if (dom=="layout_attachment"){
  2065. this.setAttachmentData();
  2066. }else{
  2067. this[dom].set("text", this.data[name]|| "");
  2068. }
  2069. }
  2070. this.reSetShow();
  2071. //}
  2072. }.bind(this);
  2073. field.node.store(this.json.id+"bindFun", bindFun);
  2074. field.addModuleEvent("change", bindFun);
  2075. }
  2076. },
  2077. _computeItemFieldData: function(name, dataItem, dataItemNode){
  2078. var v = "";
  2079. var module = (dataItemNode) ? this.form.all[dataItemNode] : this.form.all[this.json[dataItem]];
  2080. if (module && module.getData) v = module.getData();
  2081. if (!v) v = (dataItemNode) ? this.form.businessData.data[dataItemNode] : this.form.businessData.data[this.json[dataItem]];
  2082. if (v){
  2083. var t = o2.typeOf(v);
  2084. switch (t) {
  2085. case "string":
  2086. switch (name) {
  2087. case "issuanceDate":
  2088. case "editionDate":
  2089. var d = new Date(v);
  2090. debugger;
  2091. if (d.isValid() && d.getFullYear()!=1970){
  2092. var y = d.getFullYear();
  2093. var m = d.getMonth();
  2094. var day = d.getDate();
  2095. m = m +1;
  2096. this.data[name] = ""+y+"年"+m+"月"+day+"日";
  2097. }else{
  2098. this.data[name] = v;
  2099. }
  2100. //this.data[name] = (new Date(v).isValid()) ? Date.parse(v).format("%Y年%m月%d%日") : v;
  2101. break;
  2102. case "mainSend":
  2103. this.data[name] = v + ":";
  2104. break;
  2105. default:
  2106. this.data[name] = v;
  2107. }
  2108. break;
  2109. case "array":
  2110. var strs = [];
  2111. v.each(function(value){
  2112. if (o2.typeOf(value)=="object" && value.distinguishedName){
  2113. strs.push(value.name);
  2114. }else{
  2115. strs.push(value.toString());
  2116. }
  2117. });
  2118. //if (strs.length){
  2119. switch (name) {
  2120. case "attachment":
  2121. // this.data[name] = strs.map(function(n, i){ var j = i+1; return j+"、"+n}).join("<br>");
  2122. var atts = strs.map(function(a){
  2123. return (a.indexOf(".")!=-1) ? a.substring(0, a.lastIndexOf(".")) : a;
  2124. });
  2125. this.data[name] = atts;
  2126. break;
  2127. case "issuanceDate":
  2128. case "editionDate":
  2129. var tmpStrs = strs.map(function(n, i){
  2130. var d = Date.parse(n);
  2131. if (d.isValid() && d.getFullYear()!=1970){
  2132. var y = d.getFullYear();
  2133. var m = d.getMonth();
  2134. var day = d.getDate();
  2135. m = m +1;
  2136. return ""+y+"年"+m+"月"+day+"日";
  2137. }else{
  2138. return n;
  2139. }
  2140. //return () ? d.format("%Y年%m月%d日") : n;
  2141. });
  2142. this.data[name] = tmpStrs.join(",");
  2143. break;
  2144. case "mainSend":
  2145. this.data[name] = strs.join(",") + ":";
  2146. break;
  2147. default:
  2148. this.data[name] = strs.join(",");
  2149. }
  2150. //}
  2151. break;
  2152. default:
  2153. this.data[name] = v.toString();
  2154. }
  2155. }else{
  2156. this.data[name] = this.json.defaultValue[name];
  2157. }
  2158. },
  2159. computeData: function(){
  2160. this._computeData(false);
  2161. this.setData(this.data);
  2162. },
  2163. _computeItemData: function(name, typeItem, dataItem, scriptItem, ev, dom){
  2164. switch (this.json[typeItem]) {
  2165. case "data":
  2166. if (this.json[dataItem]){
  2167. if (ev) this._bindFieldChange(name, dataItem, dom);
  2168. this._computeItemFieldData(name, dataItem);
  2169. }
  2170. break;
  2171. case "script":
  2172. if (this.json[scriptItem] && this.json[scriptItem].code){
  2173. var v = this.form.Macro.exec(this.json[scriptItem].code, this);
  2174. this.data[name] = v;
  2175. if (name=="attachment"){
  2176. //this.data[name] = (typeOf(v)=="array") ? v.map(function(n, i){ var j = i+1; return j+"、"+n}).join("<br>") : v;
  2177. this.data[name] = (typeOf(v)=="array") ? v : [v];
  2178. }
  2179. if (name=="issuanceDate" || name=="editionDate"){
  2180. var d = Date.parse(v);
  2181. if (d.isValid() && d.getFullYear()!=1970){
  2182. var y = d.getFullYear();
  2183. var m = d.getMonth();
  2184. var day = d.getDate();
  2185. m = m +1;
  2186. this.data[name] = ""+y+"年"+m+"月"+day+"日";
  2187. }else{
  2188. this.data[name] = v;
  2189. }
  2190. //this.data[name] = (d.isValid() && d.getFullYear()!=1970) ? d.format("%Y年%m月%d日") : v;
  2191. }
  2192. }
  2193. break;
  2194. }
  2195. },
  2196. _computeCustomItemData: function(name, field, ev){
  2197. //if (this.json.customFields[l.name]){
  2198. if (ev) this._bindCustomFieldChange(name, field, name);
  2199. this._computeItemFieldData(name, null, field);
  2200. //}
  2201. },
  2202. _bindCustomFieldChange: function(name, dataItem, dom){
  2203. var field = this.form.all[dataItem];
  2204. if (field){
  2205. var bindFun = function(){
  2206. this._computeItemFieldData(name, null, dataItem);
  2207. //if (this.data[name]){
  2208. if (this[dom]){
  2209. debugger;
  2210. if (dom=="layout_redHeader" || dom=="layout_subject" || dom=="layout_issuanceUnit"){
  2211. this[dom].set("html", this.data[name]|| "");
  2212. }else if (dom=="layout_attachment"){
  2213. this.setAttachmentData();
  2214. }else{
  2215. this[dom].set("text", this.data[name]|| "");
  2216. }
  2217. }
  2218. this.reSetShow();
  2219. //}
  2220. }.bind(this);
  2221. field.node.store(this.json.id+"bindFun", bindFun);
  2222. field.addModuleEvent("change", bindFun);
  2223. }
  2224. },
  2225. _computeData: function(ev){
  2226. this._computeItemData("copies", "copiesValueType", "copiesValueData", "copiesValueScript", ev, "layout_copies");
  2227. this._computeItemData("secret", "secretValueType", "secretValueData", "secretValueScript", ev, "layout_secret");
  2228. this._computeItemData("priority", "priorityValueType", "priorityValueData", "priorityValueScript", ev, "layout_priority");
  2229. this._computeItemData("redHeader", "redHeaderValueType", "redHeaderValueData", "redHeaderValueScript", ev, "layout_redHeader");
  2230. this._computeItemData("fileno", "filenoValueType", "filenoValueData", "filenoValueScript", ev, "layout_fileno");
  2231. this._computeItemData("signer", "signerValueType", "signerValueData", "signerValueScript", ev, "layout_signer");
  2232. this._computeItemData("subject", "subjectValueType", "subjectValueData", "subjectValueScript", ev, "layout_subject");
  2233. this._computeItemData("mainSend", "mainSendValueType", "mainSendValueData", "mainSendValueScript", ev, "layout_mainSend");
  2234. this._computeItemData("attachment", "attachmentValueType", "attachmentValueData", "attachmentValueScript", ev, "layout_attachment");
  2235. this._computeItemData("issuanceUnit", "issuanceUnitValueType", "issuanceUnitValueData", "issuanceUnitValueScript", ev, "layout_issuanceUnit");
  2236. this._computeItemData("issuanceDate", "issuanceDateValueType", "issuanceDateValueData", "issuanceDateValueScript", ev, "layout_issuanceDate");
  2237. this._computeItemData("annotation", "annotationValueType", "annotationValueData", "annotationValueScript", ev, "layout_annotation");
  2238. this._computeItemData("copyto", "copytoValueType", "copytoValueData", "copytoValueScript", ev, "layout_copytoContent");
  2239. this._computeItemData("copyto2", "copyto2ValueType", "copyto2ValueData", "copyto2ValueScript", ev, "layout_copyto2Content");
  2240. this._computeItemData("editionUnit", "editionUnitValueType", "editionUnitValueData", "editionUnitValueScript", ev, "layout_edition_issuance_unit");
  2241. this._computeItemData("editionDate", "editionDateValueType", "editionDateValueData", "editionDateValueScript", ev, "layout_edition_issuance_date");
  2242. this._computeItemData("meetingAttend", "meetingAttendValueType", "meetingAttendValueData", "meetingAttendValueScript", ev, "layout_meetingAttendContent");
  2243. this._computeItemData("meetingLeave", "meetingLeaveValueType", "meetingLeaveValueData", "meetingLeaveValueScript", ev, "layout_meetingLeaveContent");
  2244. this._computeItemData("meetingSit", "meetingSitValueType", "meetingSitValueData", "meetingSitValueScript", ev, "layout_meetingSitContent");
  2245. this._computeItemData("meetingRecord", "meetingRecordValueType", "meetingRecordValueData", "meetingRecordValueScript", ev, "layout_meetingRecordContent");
  2246. Object.each(this.json.customFields, function(field, k){
  2247. this._computeCustomItemData(k, field, ev);
  2248. }.bind(this));
  2249. // if (this.customLayouts){
  2250. // this.customLayouts.each(function(l){
  2251. // this._computeCustomItemData(l, ev);
  2252. // }.bind(this))
  2253. // }
  2254. },
  2255. _loadValue: function(){
  2256. var data = this._getBusinessData();
  2257. },
  2258. reload: function(){
  2259. this.resetData();
  2260. },
  2261. resetData: function(diffFiletext){
  2262. if (this.editMode){ this._switchReadOrEditInline(); }
  2263. this._computeData(false);
  2264. this.pages = [];
  2265. this.contentNode.empty();
  2266. if (this.allowEdit) this.toolbar.childrenButton[0].setText((layout.mobile) ? MWF.xApplication.process.Xform.LP.editdoc_mobile : MWF.xApplication.process.Xform.LP.editdoc);
  2267. this.editMode = false;
  2268. this._createPage(function(control){
  2269. this._loadPageLayout(control);
  2270. this.setData(this.data, diffFiletext);
  2271. //this._checkSplitPage(this.pages[0]);
  2272. debugger;
  2273. this._repage();
  2274. }.bind(this));
  2275. },
  2276. isEmpty: function(){
  2277. var data = this.getData();
  2278. if( typeOf(data) !== "object" )return true;
  2279. return !data.filetext || data.filetext===this.json.defaultValue.filetext;
  2280. },
  2281. getData: function(){
  2282. //if (this.editMode){
  2283. debugger;
  2284. if (this.layout_copies) this.data.copies = this.layout_copies.get("text");
  2285. if (this.layout_secret) this.data.secret = this.layout_secret.get("text");
  2286. if (this.layout_priority) this.data.priority = this.layout_priority.get("text");
  2287. if (this.layout_redHeader) this.data.redHeader = this.layout_redHeader.get("html");
  2288. if (this.layout_fileno) this.data.fileno = this.layout_fileno.get("text");
  2289. if (this.layout_signerTitle) this.data.signerTitle = this.layout_signerTitle.get("text");
  2290. if (this.layout_signer) this.data.signer = this.layout_signer.get("text");
  2291. if (this.layout_subject) this.data.subject = this.layout_subject.get("html");
  2292. if (this.layout_mainSend) this.data.mainSend = this.layout_mainSend.get("text");
  2293. if (this.editMode) if (this.layout_filetext){
  2294. var text = this.layout_filetext.get("text");
  2295. text = text.replace(/\u3000*/g, "");
  2296. if (text && text !==this.json.defaultValue.filetext){
  2297. this.data.filetext = this.layout_filetext.get("html");
  2298. }else{
  2299. this.data.filetext = "";
  2300. }
  2301. }
  2302. if (this.layout_signer) this.data.signer = this.layout_signer.get("text");
  2303. if (this.layout_attachmentTitle) this.data.attachmentTitle = this.layout_attachmentTitle.get("text");
  2304. if (this.layout_attachment){
  2305. this._computeItemData("attachment", "attachmentValueType", "attachmentValueData", "attachmentValueScript", false, "layout_attachment");
  2306. // var atts = [];
  2307. // var nodes = this.layout_attachment.getElements(".doc_layout_attachment_content_name");
  2308. // if (nodes.length){
  2309. // nodes.each(function(node){
  2310. // atts.push(node.get("text"));
  2311. // });
  2312. // }
  2313. // this.data.attachment = atts;
  2314. }
  2315. if (this.layout_issuanceUnit) this.data.issuanceUnit = this.layout_issuanceUnit.get("html");
  2316. if (this.layout_issuanceDate) this.data.issuanceDate = this.layout_issuanceDate.get("text");
  2317. if (this.layout_annotation) this.data.annotation = this.layout_annotation.get("text");
  2318. if (this.layout_copytoTitle) this.data.copytoTitle = this.layout_copytoTitle.get("text");
  2319. if (this.layout_copytoContent) this.data.copyto = this.layout_copytoContent.get("text");
  2320. if (this.layout_copyto2Title) this.data.copyto2Title = this.layout_copyto2Title.get("text");
  2321. if (this.layout_copyto2Content) this.data.copyto2 = this.layout_copyto2Content.get("text");
  2322. if (this.layout_edition_issuance_unit) this.data.editionUnit = this.layout_edition_issuance_unit.get("text");
  2323. if (this.layout_edition_issuance_date) this.data.editionDate = this.layout_edition_issuance_date.get("text");
  2324. if (this.layout_meetingAttendTitle) this.data.meetingAttendTitle = this.layout_meetingAttendTitle.get("text");
  2325. if (this.layout_meetingLeaveTitle) this.data.meetingLeaveTitle = this.layout_meetingLeaveTitle.get("text");
  2326. if (this.layout_meetingSitTitle) this.data.meetingSitTitle = this.layout_meetingSitTitle.get("text");
  2327. if (this.layout_meetingAttendContent) this.data.meetingAttend = this.layout_meetingAttendContent.get("html");
  2328. if (this.layout_meetingLeaveContent) this.data.meetingLeave = this.layout_meetingLeaveContent.get("html");
  2329. if (this.layout_meetingSitContent) this.data.meetingSit = this.layout_meetingSitContent.get("html");
  2330. if (this.layout_meetingRecordContent) this.data.meetingRecord = this.layout_meetingRecordContent.get("html");
  2331. if (this.customLayouts){
  2332. this.customLayouts.each(function(l){
  2333. this.data[l.name] = l.node.get("html");
  2334. }.bind(this))
  2335. }
  2336. //}
  2337. return this.data;
  2338. },
  2339. setAttachmentData: function(){
  2340. if (!this.attachmentTemplete){
  2341. this.attachmentTemplete = this.layout_attachment.get("html");
  2342. }
  2343. this.layout_attachment.empty();
  2344. if (this.data.attachment && this.data.attachment.length && this.data.attachment.each){
  2345. //var tmpdiv = new Element("div", {"styles": {"display":"none"}}).inject(document.body);
  2346. var tmpdiv = new Element("div");
  2347. this.data.attachment.each(function(name, idx){
  2348. tmpdiv.set("html", this.attachmentTemplete);
  2349. var serialNode = tmpdiv.getElement(".doc_layout_attachment_content_serial");
  2350. var nameNode = tmpdiv.getElement(".doc_layout_attachment_content_name");
  2351. if (serialNode) serialNode.set("text", idx+1);
  2352. if (nameNode) nameNode.set("text", name);
  2353. var html = tmpdiv.get("html");
  2354. tmpdiv.empty();
  2355. this.layout_attachment.appendHTML(html);
  2356. }.bind(this));
  2357. tmpdiv.destroy();
  2358. }
  2359. },
  2360. setData: function(data, diffFiletext){
  2361. if (data){
  2362. this.data = data;
  2363. // this.data["$json"] = this.json;
  2364. this._setBusinessData(data);
  2365. if (this.layout_copies){
  2366. if (data.copies){
  2367. this.layout_copies.set("text", data.copies || " ");
  2368. }else{
  2369. this.layout_copies.set("html", "<span>&nbsp</span>");
  2370. }
  2371. }
  2372. if (this.layout_secret){
  2373. if (data.secret){
  2374. this.layout_secret.set("text", data.secret || " ");
  2375. }else{
  2376. this.layout_secret.set("html", "<span>&nbsp</span>");
  2377. }
  2378. }
  2379. if (this.layout_priority){
  2380. if (data.priority){
  2381. this.layout_priority.set("text", data.priority || " ");
  2382. }else{
  2383. this.layout_priority.set("html", "<span>&nbsp</span>");
  2384. }
  2385. }
  2386. if (this.layout_redHeader) this.layout_redHeader.set("html", data.redHeader || "");
  2387. if (this.layout_fileno) this.layout_fileno.set("text", data.fileno || " ");
  2388. if (this.layout_signerTitle) this.layout_signerTitle.set("text", data.signerTitle || " ");
  2389. if (this.layout_signer) this.layout_signer.set("text", data.signer || " ");
  2390. if (this.layout_subject) this.layout_subject.set("html", data.subject || " ");
  2391. if (this.layout_mainSend) this.layout_mainSend.set("text", data.mainSend || " ");
  2392. if (diffFiletext) {
  2393. this.layout_filetext.set("html", diffFiletext);
  2394. }else if (this.layout_filetext){
  2395. //this.layout_filetext.set("placeholder", this.json.defaultValue.filetext);
  2396. this.layout_filetext.set("html", data.filetext || "  ");
  2397. }
  2398. if (this.layout_signer) this.layout_signer.set("text", data.signer || "");
  2399. if (this.layout_attachmentTitle) this.layout_attachmentTitle.set("text", data.attachmentTitle || " ");
  2400. if (this.layout_attachment){
  2401. this.setAttachmentData();
  2402. }
  2403. if (this.layout_issuanceUnit) this.layout_issuanceUnit.set("html", data.issuanceUnit || " ");
  2404. if (this.layout_issuanceDate) this.layout_issuanceDate.set("text", data.issuanceDate || " ");
  2405. if (this.layout_annotation) this.layout_annotation.set("text", data.annotation || " ");
  2406. if (this.layout_copytoTitle) this.layout_copytoTitle.set("text", data.copytoTitle || " ");
  2407. if (this.layout_copytoContent) this.layout_copytoContent.set("text", data.copyto || " ");
  2408. if (this.layout_copyto2Title) this.layout_copyto2Title.set("text", data.copyto2Title || " ");
  2409. if (this.layout_copyto2Content) this.layout_copyto2Content.set("text", data.copyto2 || " ");
  2410. if (this.layout_edition_issuance_unit) this.layout_edition_issuance_unit.set("text", data.editionUnit || " ");
  2411. if (this.layout_edition_issuance_date) this.layout_edition_issuance_date.set("text", data.editionDate || " ");
  2412. if (this.layout_meetingAttendTitle) this.layout_meetingAttendTitle.set("text", data.meetingAttendTitle || this.json.defaultValue.meetingAttendTitle || " ");
  2413. if (this.layout_meetingLeaveTitle) this.layout_meetingLeaveTitle.set("text", data.meetingLeaveTitle || this.json.defaultValue.meetingLeaveTitle || " ");
  2414. if (this.layout_meetingSitTitle) this.layout_meetingSitTitle.set("text", data.meetingSitTitle || this.json.defaultValue.meetingSitTitle || " ");
  2415. if (this.layout_meetingAttendContent) this.layout_meetingAttendContent.set("html", data.meetingAttend || " ");
  2416. if (this.layout_meetingLeaveContent) this.layout_meetingLeaveContent.set("html", data.meetingLeave || " ");
  2417. if (this.layout_meetingSitContent) this.layout_meetingSitContent.set("html", data.meetingSit || " ");
  2418. if (this.layout_meetingRecordContent) this.layout_meetingRecordContent.set("html", data.meetingRecord || " ");
  2419. if (this.customLayouts){
  2420. this.customLayouts.each(function(l){
  2421. l.node.set("html", this.data[l.name] || " ");
  2422. }.bind(this))
  2423. }
  2424. debugger;
  2425. if (this.layout_issuanceUnit && this.layout_issuanceDate ){
  2426. var table = this.layout_issuanceUnit.getParent("table")
  2427. if (table && !table.hasClass("doc_layout_headIssuance")){
  2428. var unitWidth = o2.getTextSize(this.layout_issuanceUnit.get("text"), {
  2429. "font-size":"16pt",
  2430. "font-family":"'Times New Roman',仿宋",
  2431. "letter-spacing": "-0.4pt"
  2432. }).x;
  2433. var dateWidth = o2.getTextSize(this.layout_issuanceDate.get("text"), {
  2434. "font-size":"16pt",
  2435. "font-family":"'Times New Roman',仿宋",
  2436. "letter-spacing": "-0.4pt"
  2437. }).x;
  2438. // var unitWidth = this.layout_issuanceUnit.getSize().x;
  2439. // var dateWidth = this.layout_issuanceDate.getSize().x;
  2440. if (unitWidth<dateWidth){
  2441. var flagTd = this.layout_issuanceUnit.getParent("td").getNext("td");
  2442. if (flagTd){
  2443. var pt = ((dateWidth-unitWidth)/96)*72 +32+32;
  2444. flagTd.setStyle("width", ""+pt+"pt");
  2445. }
  2446. table = this.layout_issuanceDate.getParent("table");
  2447. table.setStyle("width", "auto");
  2448. flagTd = this.layout_issuanceDate.getParent("td").getNext("td");
  2449. if (flagTd) flagTd.setStyle("width", "32pt");
  2450. var p = this.layout_issuanceDate.getParent("p");
  2451. if (p) p.setStyle("text-align", "right");
  2452. }else{
  2453. var flagTd = this.layout_issuanceUnit.getParent("td").getNext("td");
  2454. if (flagTd) flagTd.setStyle("width", "32pt");
  2455. var table = this.layout_issuanceUnit.getParent("table");
  2456. var x = table.getSize().x;
  2457. table = this.layout_issuanceDate.getParent("table");
  2458. table.setStyle("width", ""+x+"px");
  2459. flagTd = this.layout_issuanceDate.getParent("td").getNext("td");
  2460. if (flagTd) flagTd.setStyle("width", "32pt");
  2461. var p = this.layout_issuanceDate.getParent("p");
  2462. if (p) p.setStyle("text-align", "center");
  2463. }
  2464. }
  2465. }
  2466. var coptyToTitleNode = (this.layout_copytoTitle || this.layout_copyto2Title);
  2467. if (coptyToTitleNode){
  2468. var editionTable = coptyToTitleNode.getParent("table");
  2469. if (editionTable) if (editionTable.get("data-compute-style")=="y"){
  2470. var rows = editionTable.rows;
  2471. for (var i=0; i<rows.length; i++){
  2472. var cell = rows[i].cells[0];
  2473. var tmp = cell.getElement(".doc_layout_edition_issuance_unit");
  2474. if (!tmp) tmp = cell.getElement(".doc_layout_edition_issuance_date");
  2475. if (!tmp){
  2476. var text = cell.get("text").trim();
  2477. var l = 14*text.length;
  2478. var wl = 19*text.length;
  2479. cell.setStyles({
  2480. "max-width": ""+l+"pt !important",
  2481. "min-width": ""+l+"pt !important",
  2482. "width": ""+wl+"pt"
  2483. });
  2484. }
  2485. }
  2486. }
  2487. }
  2488. }
  2489. },
  2490. createErrorNode: function(text){
  2491. var node = new Element("div");
  2492. var iconNode = new Element("div", {
  2493. "styles": {
  2494. "width": "20px",
  2495. "height": "20px",
  2496. "float": "left",
  2497. "background": "url("+"../x_component_process_Xform/$Form/default/icon/error.png) center center no-repeat"
  2498. }
  2499. }).inject(node);
  2500. var textNode = new Element("div", {
  2501. "styles": {
  2502. "line-height": "20px",
  2503. "margin-left": "20px",
  2504. "color": "red",
  2505. "word-break": "keep-all"
  2506. },
  2507. "text": text
  2508. }).inject(node);
  2509. return node;
  2510. },
  2511. notValidationMode: function(text){
  2512. if (!this.isNotValidationMode){
  2513. this.isNotValidationMode = true;
  2514. this.node.store("borderStyle", this.node.getStyles("border-left", "border-right", "border-top", "border-bottom"));
  2515. this.node.setStyle("border", "1px solid red");
  2516. this.errNode = this.createErrorNode(text).inject(this.node, "after");
  2517. this.showNotValidationMode(this.node);
  2518. }
  2519. },
  2520. showNotValidationMode: function(node){
  2521. var p = node.getParent("div");
  2522. if (p){
  2523. if (p.get("MWFtype") == "tab$Content"){
  2524. if (p.getParent("div").getStyle("display")=="none"){
  2525. var contentAreaNode = p.getParent("div").getParent("div");
  2526. var tabAreaNode = contentAreaNode.getPrevious("div");
  2527. var idx = contentAreaNode.getChildren().indexOf(p.getParent("div"));
  2528. var tabNode = tabAreaNode.getLast().getFirst().getChildren()[idx];
  2529. tabNode.click();
  2530. p = tabAreaNode.getParent("div");
  2531. }
  2532. }
  2533. this.showNotValidationMode(p);
  2534. }
  2535. },
  2536. validationMode: function(){
  2537. if (this.isNotValidationMode){
  2538. this.isNotValidationMode = false;
  2539. this.node.setStyles(this.node.retrieve("borderStyle"));
  2540. if (this.errNode){
  2541. this.errNode.destroy();
  2542. this.errNode = null;
  2543. }
  2544. }
  2545. },
  2546. validationConfigItem: function(routeName, data){
  2547. var flag = (data.status=="all") ? true: (routeName == data.decision);
  2548. if (flag){
  2549. var n = this.getData();
  2550. var v = (data.valueType=="value") ? n : n.length;
  2551. switch (data.operateor){
  2552. case "isnull":
  2553. if (!v){
  2554. this.notValidationMode(data.prompt);
  2555. return false;
  2556. }
  2557. break;
  2558. case "notnull":
  2559. if (v){
  2560. this.notValidationMode(data.prompt);
  2561. return false;
  2562. }
  2563. break;
  2564. case "gt":
  2565. if (v>data.value){
  2566. this.notValidationMode(data.prompt);
  2567. return false;
  2568. }
  2569. break;
  2570. case "lt":
  2571. if (v<data.value){
  2572. this.notValidationMode(data.prompt);
  2573. return false;
  2574. }
  2575. break;
  2576. case "equal":
  2577. if (v==data.value){
  2578. this.notValidationMode(data.prompt);
  2579. return false;
  2580. }
  2581. break;
  2582. case "neq":
  2583. if (v!=data.value){
  2584. this.notValidationMode(data.prompt);
  2585. return false;
  2586. }
  2587. break;
  2588. case "contain":
  2589. if (v.indexOf(data.value)!=-1){
  2590. this.notValidationMode(data.prompt);
  2591. return false;
  2592. }
  2593. break;
  2594. case "notcontain":
  2595. if (v.indexOf(data.value)==-1){
  2596. this.notValidationMode(data.prompt);
  2597. return false;
  2598. }
  2599. break;
  2600. }
  2601. }
  2602. return true;
  2603. },
  2604. validationConfig: function(routeName, opinion){
  2605. if (this.json.validationConfig){
  2606. if (this.json.validationConfig.length){
  2607. for (var i=0; i<this.json.validationConfig.length; i++) {
  2608. var data = this.json.validationConfig[i];
  2609. if (!this.validationConfigItem(routeName, data)) return false;
  2610. }
  2611. }
  2612. return true;
  2613. }
  2614. return true;
  2615. },
  2616. validation: function(routeName, opinion){
  2617. if (!this.validationConfig(routeName, opinion)) return false;
  2618. if (!this.json.validation) return true;
  2619. if (!this.json.validation.code) return true;
  2620. this.currentRouteName = routeName;
  2621. var flag = this.form.Macro.exec(this.json.validation.code, this);
  2622. this.currentRouteName = "";
  2623. if (!flag) flag = MWF.xApplication.process.Xform.LP.notValidation;
  2624. if (flag.toString()!="true"){
  2625. this.notValidationMode(flag);
  2626. return false;
  2627. }
  2628. return true;
  2629. },
  2630. removeDisplayNone: function(node){
  2631. var n = node.getFirst();
  2632. while (n){
  2633. if (n.getStyle("display")=="none"){
  2634. var tmp = n.getNext();
  2635. n.destroy();
  2636. n = tmp;
  2637. }else{
  2638. n = this.removeDisplayNone(n);
  2639. n = n.getNext();
  2640. }
  2641. }
  2642. return node;
  2643. },
  2644. toWord: function(callback, name){
  2645. debugger;
  2646. var docNmae = name || "";
  2647. if (!docNmae){
  2648. try{
  2649. docNmae = this.json.toWordFilename || this.form.businessData.data.subject || this.form.businessData.data["$work"].title
  2650. }catch (e) {}
  2651. }
  2652. var toEdit = false;
  2653. if (this.editMode){
  2654. toEdit = true;
  2655. this._readFiletext();
  2656. }
  2657. //this._returnScale();
  2658. this.zoom(1);
  2659. this.pages = [];
  2660. this.contentNode.empty();
  2661. this._createPage(function(control){
  2662. this._loadPageLayout(control);
  2663. this.setData(this.data);
  2664. this._checkScale();
  2665. this.node.setStyles({
  2666. "height":"auto"
  2667. });
  2668. //var content = this.contentNode.getFirst().getFirst().get("html");
  2669. var tmpNode = this.contentNode.getFirst().getFirst().clone(true);
  2670. var htmlNode = tmpNode.getLast();
  2671. htmlNode = this.removeDisplayNone(htmlNode);
  2672. var nodes = tmpNode.querySelectorAll("[data-w-style]");
  2673. if (nodes.length){
  2674. for (var i=0; i<nodes.length; i++){
  2675. var n = nodes.item(i);
  2676. wStyle = n.dataset["wStyle"];
  2677. var styles = wStyle.split(/\s*\;\s*/g);
  2678. styles.each(function(style){
  2679. if (style){
  2680. try{
  2681. s = style.split(/\s*\:\s*/g);
  2682. n.setStyle(s[0], s[1]);
  2683. }catch(e) {}
  2684. }
  2685. });
  2686. }
  2687. }
  2688. var content = "<html xmlns:v=\"urn:schemas-microsoft-com:vml\"><head><meta charset=\"UTF-8\" /></head><body>"+tmpNode.get("html")+"</body></html>";
  2689. var fileName = docNmae || this.json.toWordFilename || "$doc";
  2690. var n = fileName.lastIndexOf(".");
  2691. var ex = fileName.substring(n, fileName.length).toLowerCase();
  2692. if (ex!==".doc" && ex!==".docx") fileName = fileName+".doc";
  2693. var body = {
  2694. "fileName": fileName,
  2695. "site": this.json.toWordSite || "$doc",
  2696. "content": content
  2697. };
  2698. o2.Actions.get("x_processplatform_assemble_surface").docToWord(this.form.businessData.work.id, body, function(json){
  2699. if (this.form.businessData.workCompleted){
  2700. o2.Actions.get("x_processplatform_assemble_surface").getAttachmentWorkcompleted(json.data.id, this.form.businessData.workCompleted.id,function(attjson){
  2701. if (callback) callback(attjson.data);
  2702. this.showToWord(attjson.data);
  2703. }.bind(this));
  2704. }else{
  2705. o2.Actions.get("x_processplatform_assemble_surface").getAttachment(json.data.id, this.form.businessData.work.id,function(attjson){
  2706. if (callback) callback(attjson.data);
  2707. this.showToWord(attjson.data);
  2708. }.bind(this));
  2709. }
  2710. }.bind(this));
  2711. tmpNode.destroy();
  2712. if (!toEdit){
  2713. this._readFiletext();
  2714. }else{
  2715. this._createEditor("inline");
  2716. }
  2717. }.bind(this));
  2718. },
  2719. docToWord: function(){
  2720. var flag = true;
  2721. if (this.json.toWordConditionScript && this.json.toWordConditionScript.code){
  2722. flag = !!this.form.Macro.exec(this.json.toWordConditionScript.code, this);
  2723. }
  2724. if (flag){
  2725. this.toWord();
  2726. }
  2727. },
  2728. showToWord: function(att_word){
  2729. var site = this.json.toWordSite || "$doc";
  2730. var attModule = this.form.all[site];
  2731. if (attModule){
  2732. var atts = [];
  2733. attModule.attachmentController.attachments.each(function(att){
  2734. if (att.data.name!==att_word.name){
  2735. atts.push(att.data)
  2736. }
  2737. }.bind(this));
  2738. attModule.attachmentController.clear();
  2739. atts.each(function (att) {
  2740. //if (att.site===this.json.id || (this.json.isOpenInOffice && this.json.officeControlName===att.site)) this.attachmentController.addAttachment(att);
  2741. if ((att.site === attModule.json.id) && att.name!==att_word.name) attModule.attachmentController.addAttachment(att);
  2742. }.bind(this));
  2743. // attModule.attachmentController.reloadAttachments();
  2744. attModule.attachmentController.addAttachment(att_word);
  2745. }
  2746. }
  2747. });