Documenteditor.js 136 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967
  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. }
  775. }
  776. if (this.layout_issuanceUnit){
  777. if (!this.json.issuanceUnitValueData && this.json.issuanceUnitValueType=="data"){
  778. this.layout_issuanceUnit.set("contenteditable", control.issuanceUnit);
  779. this.layout_issuanceUnit.addEvent("blur", function(){
  780. this.getData();
  781. }.bind(this))
  782. }
  783. }
  784. // this.layout_subject.addEvent("keydown", function(e){
  785. // debugger;
  786. // if (this.json.subjectValueType=="data" && this.json.subjectValueData){
  787. // // var v = e.target.get("HTML");
  788. // // this.form.businessData.data[this.json.subjectValueData] = v
  789. // var module = this.form.all[this.json.subjectValueData];
  790. // if (module){
  791. // var bindFun = module.node.retrieve(this.json.id+"bindFun");
  792. // module.node
  793. // }
  794. // }
  795. // }.bind(this));
  796. },
  797. _loadUserInterface: function(callback){
  798. this.node.empty();
  799. this.node.setStyles(this.form.css.documentEditorNode);
  800. this.pages = [];
  801. this.allowEdit = this._isAllowEdit();
  802. this.allowPrint = this._isAllowPrint();
  803. this.allowHistory = this._isAllowHistory();
  804. this.toolNode = new Element("div", {"styles": this.css.doc_toolbar}).inject(this.node);
  805. this.contentNode = new Element("div#doc_content", {"styles": this.css.doc_content}).inject(this.node);
  806. if (!this.form.isLoaded){
  807. this.form.addEvent("afterModulesLoad", function(){this.loadDocumentEditor(callback);}.bind(this));
  808. }else{
  809. this.loadDocumentEditor(callback);
  810. }
  811. },
  812. loadDocumentEditor: function(callback){
  813. this._loadToolbars();
  814. this._loadFiletextPage(function(){
  815. if (this.options.pageShow!=="double"){
  816. this._singlePage();
  817. }else{
  818. this._doublePage();
  819. }
  820. // this.form.addEvent("beforeProcess", function(){
  821. // this.resetData();
  822. // if (this.checkSaveNewEdition()) this.saveNewDataEdition();
  823. // this.notSaveResetData = true;
  824. // }.bind(this));
  825. this.form.addEvent("beforeSave", function(){
  826. this.resetData();
  827. this.checkSaveNewEdition();
  828. //if (!this.notSaveResetData) this.resetData();
  829. }.bind(this));
  830. if (this.json.toWord=="y"){
  831. if (this.json.toWordTrigger=="open") this.docToWord();
  832. if (this.json.toWordTrigger=="save") this.form.addEvent("beforeSave", this.docToWord.bind(this));
  833. if (this.json.toWordTrigger=="submit") this.form.addEvent("beforeProcess", this.docToWord.bind(this));
  834. }
  835. if (!layout.mobile) this.loadSideToolbar();
  836. o2.load("../o2_lib/diff-match-patch/diff_match_patch.js");
  837. if (this.form.businessData.data["$work"]){
  838. var id = this.form.businessData.data["$work"].job;
  839. o2.Actions.load("x_processplatform_assemble_surface").DocumentVersionAction.listWithJobCategory(id, this.json.id, function(json){
  840. this.historyDocumentList = json.data;
  841. if (this.historyDocumentList.length){
  842. o2.Actions.load("x_processplatform_assemble_surface").DocumentVersionAction.get(this.historyDocumentList[this.historyDocumentList.length-1].id, function(json){
  843. var data = JSON.parse(json.data.data);
  844. this.originaHistoryData = data.data;
  845. }.bind(this));
  846. }
  847. }.bind(this));
  848. }
  849. if (callback) callback();
  850. }.bind(this));
  851. if (!this.form.documenteditorList) this.form.documenteditorList=[];
  852. this.form.documenteditorList.push(this);
  853. },
  854. checkSaveNewEdition: function(callback){
  855. debugger;
  856. if (!this.allowEdit || !this.data.filetext || this.data.filetext == this.json.defaultValue.filetext) return false;
  857. if (this.form.businessData.work){
  858. var originaData = this.form.businessData.originalData[this.json.id];
  859. var editionData = {"category": this.json.id};
  860. if (!originaData || !originaData.filetext || !this.originaHistoryData){
  861. //保存原始版本
  862. this.originaHistoryData = {"data": this.data.filetext};
  863. editionData.data = JSON.stringify({"data": this.data.filetext});
  864. }else if (originaData.filetext!=this.data.filetext){
  865. //保存历史版本
  866. var data = this.data.filetext;
  867. var earlyData = originaData.filetext;
  868. var dmp = new diff_match_patch();
  869. var diff_d = dmp.diff_main(earlyData, data);
  870. dmp.diff_cleanupSemantic(diff_d);
  871. var patch_list = dmp.patch_make(earlyData, data, diff_d);
  872. editionData.data = JSON.stringify({"patchs": dmp.patch_toText(patch_list)});
  873. }else{
  874. return false;
  875. }
  876. o2.Actions.load("x_processplatform_assemble_surface").DocumentVersionAction.create(this.form.businessData.work.id, editionData, function(json){
  877. //originaData.filetext = this.data.filetext;
  878. if (callback) callback();
  879. }.bind(this));
  880. }
  881. },
  882. // saveNewDataEdition: function(callback){
  883. // if (this.form.businessData.work){
  884. // var editionData = {"category": this.json.id};
  885. // if (this.form.businessData.originalData[this.json.id] && this.form.businessData.originalData[this.json.id].filetext){
  886. // var data = this.data.filetext;
  887. // var earlyData = this.form.businessData.originalData[this.json.id].filetext;
  888. // var dmp = new diff_match_patch();
  889. // var diff_d = dmp.diff_main(earlyData, data);
  890. // dmp.diff_cleanupSemantic(diff_d);
  891. // var patch_list = dmp.patch_make(earlyData, data, diff_d);
  892. // editionData.data = {"patchs": dmp.patch_toText(patch_list)};
  893. //
  894. // }else{
  895. // editionData.data = {"data": this.data.filetext};
  896. // }
  897. // o2.Actions.load("x_processplatform_assemble_surface").DocumentVersionAction.create(this.form.businessData.work.id, editionData, function(json){
  898. // this.form.businessData.originalData[this.json.id] = this.data.filetext;
  899. // if (callback) callback();
  900. // }.bind(this));
  901. // }
  902. // },
  903. resizeToolbar: function(){
  904. if (this.toolbarNode){
  905. var p = this.toolNode.getPosition(this.scrollNode);
  906. var size = this.toolNode.getSize();
  907. var pl = this.toolbarNode.getStyle("padding-left").toInt();
  908. var pr = this.toolbarNode.getStyle("padding-right").toInt();
  909. var x = size.x-pl-pr;
  910. //var pNode = this.toolNode.getOffsetParent();
  911. var paddingTop = this.form.node.getStyle("padding-top");
  912. try {
  913. paddingTop = paddingTop.toInt();
  914. }catch (e) {
  915. paddingTop = 0;
  916. }
  917. if (p.y<paddingTop){
  918. this.toolbarNode.inject(this.scrollNode);
  919. this.toolbarNode.setStyles({
  920. "position": "absolute",
  921. "width": ""+x+"px",
  922. "z-index": 200,
  923. "top": paddingTop+"px",
  924. "left": ""+p.x+"px"
  925. });
  926. }else{
  927. this.toolbarNode.inject(this.toolNode);
  928. this.toolbarNode.setStyles({"position": "static"});
  929. }
  930. }
  931. },
  932. resizeSidebar: function(){
  933. if (this.sidebarNode){
  934. var fileTextNode = this.contentNode.getElement("div.doc_layout_filetext");
  935. if (fileTextNode){
  936. this.sidebarNode.position({
  937. relativeTo: fileTextNode,
  938. position: 'topLeft',
  939. edge: 'topRight',
  940. offset: {"x": -20, "y": 60}
  941. });
  942. var p = fileTextNode.getPosition(this.form.app.content);
  943. var ptop = fileTextNode.getPosition(this.node);
  944. //if ((p.y+s.y)<0) this.sidebarNode.setStyle("top", p.y+s.y);
  945. if (p.y<0){
  946. var top = ptop.y-p.y+200;
  947. this.sidebarNode.setStyle("top", top);
  948. }
  949. // var p = fileTextNode.getPosition();
  950. // this.sidebarNode.setStyle("top", p.y);
  951. }
  952. }
  953. },
  954. loadSideToolbar: function(){
  955. if (this.allowEdit){
  956. if (this.pages.length){
  957. var fileTextNode = this.pages[0].getElement("div.doc_layout_filetext");
  958. if (fileTextNode){
  959. this.sidebarNode = new Element("div", {"styles": this.css.doc_sidebar}).inject(this.node);
  960. this.resizeSidebar();
  961. this.scrollNode = this.sidebarNode.getParentSrcollNode();
  962. if (this.scrollNode){
  963. this.scrollNode.addEvent("scroll", function(){
  964. this.resizeSidebar();
  965. }.bind(this));
  966. }
  967. 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>";
  968. this.sidebarNode.set("html", html);
  969. MWF.require("MWF.widget.Toolbar", function() {
  970. this.sideToolbar = new MWF.widget.Toolbar(this.sidebarNode, {"style": "documentEdit_side"}, this);
  971. this.sideToolbar.load();
  972. }.bind(this));
  973. }
  974. }
  975. }
  976. },
  977. _returnScale: function(){
  978. this.isScale = false;
  979. this.scale = 0;
  980. this.contentNode.setStyles({
  981. "transform":"scale(1)",
  982. });
  983. if (this.pages.length){
  984. this.pages.each(function(page){
  985. page.setStyles({
  986. "transform":"scale(1)",
  987. });
  988. });
  989. }
  990. this.node.setStyles({
  991. "height": "auto"
  992. });
  993. },
  994. _checkScale: function(offset){
  995. offset = 0;
  996. if (this.pages.length){
  997. //var pageSize = this.pages[0].getSize();
  998. var pageSize_x = this.options.docPageFullWidth
  999. var contentSize = this.contentNode.getSize();
  1000. var contentWidth = (offset) ? contentSize.x-20-offset : contentSize.x-20;
  1001. if (contentWidth<pageSize_x){
  1002. this.isScale = true;
  1003. var scale = (contentWidth)/pageSize_x;
  1004. this.scale = scale;
  1005. this.zoom();
  1006. this.resetNodeSize();
  1007. }
  1008. }
  1009. },
  1010. zoom: function(scale){
  1011. if (scale) this.scale = scale;
  1012. if (this.zoomSelectAction){
  1013. for (var i=0; i<this.zoomSelectAction.options.length; i++){
  1014. var option = this.zoomSelectAction.options[i];
  1015. if (Math.abs(this.scale-option.value.toFloat())<0.05){
  1016. option.set("selected", true);
  1017. break;
  1018. }
  1019. }
  1020. }
  1021. var w = this.node.getSize().x;
  1022. if (this.history && this.history.historyListAreaNode) w = w-this.history.historyListAreaNode.getComputedSize().totalWidth-2;
  1023. w = w/this.scale;
  1024. this.contentNode.setStyles({
  1025. "transform":"scale("+this.scale+")",
  1026. "transform-origin": "0px 0px",
  1027. "overflow": "auto",
  1028. "width": ""+w+"px"
  1029. });
  1030. },
  1031. _switchReadOrEdit: function(){
  1032. if (this.editMode){
  1033. this._readFiletext();
  1034. if (this.allowEdit) {
  1035. var button = this.toolbar.childrenButton[0];
  1036. button.setText((layout.mobile) ? MWF.xApplication.process.Xform.LP.editdoc_mobile : MWF.xApplication.process.Xform.LP.editdoc);
  1037. button.picNode.getElement("img").set("src", "../x_component_process_Xform/$Form/default/icon/editdoc.png");
  1038. //this.getFullWidthFlagNode().dispose();
  1039. }
  1040. this.editMode = false;
  1041. }else{
  1042. this._editFiletext();
  1043. if (this.allowEdit) {
  1044. var button = this.toolbar.childrenButton[0];
  1045. button.setText((layout.mobile) ? MWF.xApplication.process.Xform.LP.editdocCompleted_mobile : MWF.xApplication.process.Xform.LP.editdocCompleted);
  1046. button.picNode.getElement("img").set("src", "../x_component_process_Xform/$Form/default/icon/editdoc_completed.png");
  1047. //this.toolbar.node.inject(this.getFullWidthFlagNode());
  1048. }
  1049. this.editMode = true;
  1050. }
  1051. },
  1052. _switchReadOrEditInline: function(){
  1053. if (this.editMode){
  1054. this._readFiletext();
  1055. if (this.allowEdit){
  1056. if (!layout.mobile) {
  1057. var button = this.sideToolbar.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. button = this.toolbar.childrenButton[0];
  1063. button.setText((layout.mobile) ? MWF.xApplication.process.Xform.LP.editdoc_mobile : MWF.xApplication.process.Xform.LP.editdoc);
  1064. button.picNode.getElement("img").set("src", "../x_component_process_Xform/$Form/default/icon/editdoc.png");
  1065. //this.getFullWidthFlagNode().dispose();
  1066. // if (!layout.mobile)this.sideToolbar.childrenButton[0].setText(MWF.xApplication.process.Xform.LP.editdoc);
  1067. // this.toolbar.childrenButton[0].setText(MWF.xApplication.process.Xform.LP.editdoc);
  1068. }
  1069. this.editMode = false;
  1070. }else{
  1071. this._editFiletext("inline");
  1072. if (this.allowEdit){
  1073. if (!layout.mobile) {
  1074. var button = this.sideToolbar.childrenButton[0];
  1075. button.setText((layout.mobile) ? MWF.xApplication.process.Xform.LP.editdocCompleted_mobile : MWF.xApplication.process.Xform.LP.editdocCompleted);
  1076. button.picNode.getElement("img").set("src", "../x_component_process_Xform/$Form/default/icon/editdoc_completed.png");
  1077. //this.toolbar.node.inject(this.getFullWidthFlagNode());
  1078. }
  1079. button = this.toolbar.childrenButton[0];
  1080. button.setText((layout.mobile) ? MWF.xApplication.process.Xform.LP.editdocCompleted_mobile : MWF.xApplication.process.Xform.LP.editdocCompleted);
  1081. button.picNode.getElement("img").set("src", "../x_component_process_Xform/$Form/default/icon/editdoc_completed.png");
  1082. //this.toolbar.node.inject(this.getFullWidthFlagNode());
  1083. // if (!layout.mobile) this.sideToolbar.childrenButton[0].setText(MWF.xApplication.process.Xform.LP.editdocCompleted);
  1084. // this.toolbar.childrenButton[0].setText(MWF.xApplication.process.Xform.LP.editdocCompleted);
  1085. }
  1086. this.editMode = true;
  1087. }
  1088. },
  1089. // getFullWidthFlagNode: function(){
  1090. // if (!this.fullWidthFlagNode){
  1091. // this.fullWidthFlagNode = new Element("span", {
  1092. // "styles": {
  1093. // "line-height": "26px",
  1094. // "color": "#999999",
  1095. // "font-size": "12px"
  1096. // },
  1097. // "text": MWF.xApplication.process.Xform.LP.fullWidth
  1098. // });
  1099. // }
  1100. // return this.fullWidthFlagNode;
  1101. // },
  1102. _printDoc: function(){
  1103. var scale = this.scale;
  1104. this.toWord(function(data){
  1105. if (this.form.businessData.work && !this.form.businessData.work.completedTime){
  1106. this.form.workAction.getAttachmentStream(data.id, this.form.businessData.work.id);
  1107. }else{
  1108. this.form.workAction.getWorkcompletedAttachmentStream(data.id, ((this.form.businessData.workCompleted) ? this.form.businessData.workCompleted.id : this.form.businessData.work.id));
  1109. }
  1110. this.scaleTo(scale);
  1111. }.bind(this));
  1112. },
  1113. _historyDoc: function(){
  1114. this.getHistory(function(){
  1115. //this.history.play();
  1116. }.bind(this));
  1117. },
  1118. getHistory: function(callback){
  1119. if (this.history){
  1120. this.history.active(function(){
  1121. if (callback) callback();
  1122. });
  1123. }else{
  1124. MWF.xDesktop.requireApp("process.Xform", "widget.DocumentHistory", function(){
  1125. this.history = new MWF.xApplication.process.Xform.widget.DocumentHistory(this);
  1126. this.history.load(function(){
  1127. if (callback) callback();
  1128. });
  1129. }.bind(this));
  1130. }
  1131. },
  1132. htmlToText: function(html){
  1133. var tmpdiv = new Element("div", {"html": html});
  1134. var text = tmpdiv.get("text");
  1135. tmpdiv.destroy();
  1136. return text;
  1137. },
  1138. _readFiletext: function(){
  1139. //this._returnScale();
  1140. //this.zoom(1);
  1141. var scale = this.scale;
  1142. if (this.filetextEditor) this.filetextEditor.destroy();
  1143. if (this.filetextScrollNode){
  1144. if (this.reLocationFiletextToolbarFun){
  1145. this.filetextScrollNode.removeEvent("scroll", this.reLocationFiletextToolbarFun);
  1146. //this.form.app.removeEvent("resize", this.reLocationFiletextToolbarFun);
  1147. this.reLocationFiletextToolbarFun = null;
  1148. }
  1149. this.filetextScrollNode = null;
  1150. }
  1151. if (this.filetextToolbarNode) this.filetextToolbarNode = null;
  1152. this.layout_filetext.setAttribute('contenteditable', false);
  1153. this.data = this.getData();
  1154. // debugger;
  1155. if (!this.data.filetext){
  1156. //this.data.filetext = this.json.defaultValue.filetext;
  1157. this.layout_filetext.set("html", this.json.defaultValue.filetext);
  1158. }
  1159. //this._checkSplitPage(this.pages[0]);
  1160. this._repage();
  1161. this.scaleTo(scale);
  1162. },
  1163. _editFiletext: function(inline){
  1164. this._returnScale();
  1165. this.zoom(1);
  1166. this._singlePage();
  1167. this.pages = [];
  1168. this.contentNode.empty();
  1169. this._createPage(function(control){
  1170. this._loadPageLayout(control);
  1171. // var docData = this._getBusinessData();
  1172. // if (!docData) docData = this._getDefaultData();
  1173. if (this.data.filetext == this.json.defaultValue.filetext) this.data.filetext = "  ";
  1174. this.setData(this.data);
  1175. this._checkScale();
  1176. this.node.setStyles({
  1177. "height":"auto"
  1178. });
  1179. this._createEditor(inline);
  1180. }.bind(this));
  1181. },
  1182. _createEditor: function(inline){
  1183. if (this.allowEdit){
  1184. this.loadCkeditorFiletext(function(e){
  1185. e.editor.focus();
  1186. var text = this.data.filetext.replace(/\u3000*/g, "");
  1187. if (!text){
  1188. var range = e.editor.createRange();
  1189. range.moveToElementEditEnd(e.editor.editable());
  1190. range.select();
  1191. range.scrollIntoView();
  1192. }else{
  1193. e.editor.getSelection().scrollIntoView();
  1194. }
  1195. // e.editor.getSelection().scrollIntoView();
  1196. //
  1197. //this.getFiletextToolber();
  1198. //this.filetextToolbarNode.inject(this.layout_filetext.getOffsetParent());
  1199. this.locationFiletextToolbar();
  1200. }.bind(this), inline);
  1201. }
  1202. },
  1203. getFiletextToolber: function(){
  1204. if (this.filetextEditor) {
  1205. if (!this.filetextToolbarNode) {
  1206. var className = "cke_editor_" + this.filetextEditor.name;
  1207. var filetextToolbarNode = $$("." + className)[0];
  1208. this.filetextToolbarNode = filetextToolbarNode;
  1209. //filetextToolbarNode.destroy();
  1210. }
  1211. }
  1212. },
  1213. reLocationFiletextToolbar: function(){
  1214. this.getFiletextToolber();
  1215. // if (this.filetextToolbarNode){
  1216. // this.filetextToolbarNode.setStyle("display", "block");
  1217. // var offsetNode = this.layout_filetext.getOffsetParent();
  1218. //
  1219. // this.filetextToolbarNode.setStyle("left", 0);
  1220. // var h = this.filetextToolbarNode.getSize().y;
  1221. // var p = this.layout_filetext.getPosition(offsetNode).y-h;
  1222. //
  1223. // var postion = this.layout_filetext.getPosition(this.form.app.content);
  1224. // if (postion.y-h<0){
  1225. // this.filetextToolbarNode.inject(this.form.app.content);
  1226. // this.filetextToolbarNode.setStyle("top", 0);
  1227. // this.filetextToolbarNode.setStyle("left", ""+postion.x+"px");
  1228. // }else{
  1229. // this.filetextToolbarNode.inject(offsetNode);
  1230. // this.filetextToolbarNode.setStyle("top", "" + p + "px");
  1231. // this.filetextToolbarNode.setStyle("left", 0);
  1232. // this.filetextToolbarNode.setStyle("left", "auto");
  1233. // }
  1234. // }
  1235. if (this.filetextToolbarNode){
  1236. if (!this.filetextScrollNode){
  1237. var scrollNode = this.contentNode;
  1238. while (scrollNode && (scrollNode.getScrollSize().y<=scrollNode.getSize().y || (scrollNode.getStyle("overflow")!=="auto" && scrollNode.getStyle("4-y")!=="auto"))){
  1239. scrollNode = scrollNode.getParent();
  1240. }
  1241. this.filetextScrollNode = scrollNode;
  1242. }
  1243. var h = this.filetextToolbarNode.getSize().y;
  1244. var position = this.layout_filetext.getPosition();
  1245. var size = this.layout_filetext.getSize();
  1246. var contentSize = this.filetextScrollNode.getSize();
  1247. if (position.y<0 && size.y+position.y+h<contentSize.y){
  1248. // var top = size.y+position.y;
  1249. // this.filetextToolbarNode.setStyle("top", ""+top+"px");
  1250. var tp = this.toolbar.node.getPosition();
  1251. var tsy = this.toolbar.node.getSize().y;
  1252. var h = tp.y+tsy;
  1253. this.filetextToolbarNode.setStyle("top", ""+h+"px");
  1254. }else if (position.y-h<0){
  1255. var tp = this.toolbar.node.getPosition();
  1256. var tsy = this.toolbar.node.getSize().y;
  1257. var h = tp.y+tsy;
  1258. this.filetextToolbarNode.setStyle("top", ""+h+"px");
  1259. }else{
  1260. var p = this.layout_filetext.getPosition().y-h;
  1261. this.filetextToolbarNode.setStyle("top", "" + p + "px");
  1262. }
  1263. }
  1264. //
  1265. // this.filetextToolbarNode.inject(offsetNode);
  1266. //
  1267. //
  1268. // this.filetextToolbarNode.setStyle("top", ""+p+"px");
  1269. },
  1270. locationFiletextToolbar: function(){
  1271. this.reLocationFiletextToolbar();
  1272. if (this.filetextToolbarNode) {
  1273. var scrollNode = this.contentNode;
  1274. while (scrollNode && (scrollNode.getScrollSize().y<=scrollNode.getSize().y || (scrollNode.getStyle("overflow")!=="auto" && scrollNode.getStyle("overflow-y")!=="auto"))){
  1275. scrollNode = scrollNode.getParent();
  1276. }
  1277. if (scrollNode){
  1278. this.filetextScrollNode = scrollNode;
  1279. this.reLocationFiletextToolbarFun = this.reLocationFiletextToolbar.bind(this);
  1280. this.filetextScrollNode.addEvent("scroll", this.reLocationFiletextToolbarFun);
  1281. }
  1282. }
  1283. },
  1284. _isAllowEdit:function(){
  1285. if (this.readonly) return false;
  1286. if (this.json.allowEdit=="n") return false;
  1287. if (this.json.allowEdit=="s"){
  1288. if (this.json.allowEditScript && this.json.allowEditScript.code){
  1289. return !!this.form.Macro.exec(this.json.allowEditScript.code, this);
  1290. }
  1291. }
  1292. return true;
  1293. },
  1294. _isAllowPrint: function(){
  1295. if (this.json.allowPrint=="n") return false;
  1296. if (this.json.allowPrint=="s"){
  1297. if (this.json.allowPrintScript && this.json.allowPrintScript.code){
  1298. return !!this.form.Macro.exec(this.json.allowPrintScript.code, this);
  1299. }
  1300. }
  1301. return true;
  1302. },
  1303. _isAllowHistory: function(){
  1304. if (this.json.allowHistory=="n") return false;
  1305. if (this.json.allowHistory=="s"){
  1306. if (this.json.allowHistoryScript && this.json.allowHistoryScript.code){
  1307. return !!this.form.Macro.exec(this.json.allowHistoryScript.code, this);
  1308. }
  1309. }
  1310. return true;
  1311. },
  1312. _getEdit: function(name, typeItem, scriptItem){
  1313. switch (this.json[typeItem]) {
  1314. case "y":
  1315. return true;
  1316. case "n":
  1317. return false;
  1318. case "s":
  1319. if (this.json[scriptItem] && this.json[scriptItem].code){
  1320. return !!this.form.Macro.exec(this.json[scriptItem].code, this);
  1321. }
  1322. return true;
  1323. }
  1324. },
  1325. loadCkeditorStyle: function(node){
  1326. if (node){
  1327. o2.load("ckeditor", function(){
  1328. //CKEDITOR.disableAutoInline = true;
  1329. node.setAttribute('contenteditable', true);
  1330. var editor = CKEDITOR.inline(this.layout_filetext, this._getEditorConfig());
  1331. this.filetextEditor.on("instanceReady", function(e){
  1332. if (callback) callback(e);
  1333. }.bind(this));
  1334. }.bind(this));
  1335. }
  1336. },
  1337. _loadToolbars: function(){
  1338. var html ="";
  1339. var editdoc, printdoc, history;
  1340. if (layout.mobile){
  1341. editdoc = MWF.xApplication.process.Xform.LP.editdoc_mobile;
  1342. printdoc = MWF.xApplication.process.Xform.LP.printdoc_mobile;
  1343. history = MWF.xApplication.process.Xform.LP.history_mobile;
  1344. }else{
  1345. editdoc = MWF.xApplication.process.Xform.LP.editdoc;
  1346. printdoc = MWF.xApplication.process.Xform.LP.printdoc;
  1347. history = MWF.xApplication.process.Xform.LP.history;
  1348. }
  1349. if (this.allowEdit){
  1350. //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>";
  1351. html += "<span MWFnodetype=\"MWFToolBarButton\" MWFButtonImage=\"../x_component_process_Xform/$Form/default/icon/editdoc.png\" title=\""+editdoc+"\" MWFButtonAction=\"_switchReadOrEditInline\" MWFButtonText=\""+editdoc+"\"></span>";
  1352. //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>";
  1353. }
  1354. if (this.allowPrint){
  1355. html += "<span MWFnodetype=\"MWFToolBarButton\" MWFButtonImage=\"../x_component_process_Xform/$Form/default/icon/print.png\" title=\""+printdoc+"\" MWFButtonAction=\"_printDoc\" MWFButtonText=\""+printdoc+"\"></span>";
  1356. }
  1357. if (this.allowHistory){
  1358. html += "<span MWFnodetype=\"MWFToolBarButton\" MWFButtonImage=\"../x_component_process_Xform/$Form/default/icon/versions.png\" title=\""+history+"\" MWFButtonAction=\"_historyDoc\" MWFButtonText=\""+history+"\"></span>";
  1359. }
  1360. // if (this.json.fullWidth=="y"){
  1361. // html += "<span style='line-height: 26px; color: #999999; font-size: 12px'>已启用半角空格自动转换为全角空格,如需输入半角空格,请使用:SHIFT+空格</span>"
  1362. // }
  1363. this.toolbarNode = new Element("div", {"styles": this.css.doc_toolbar_node}).inject(this.toolNode);
  1364. this.toolbarNode.set("html", html);
  1365. MWF.require("MWF.widget.Toolbar", function() {
  1366. this.toolbar = new MWF.widget.Toolbar(this.toolbarNode, {"style": "documentEdit"}, this);
  1367. this.toolbar.load();
  1368. }.bind(this));
  1369. if (!layout.mobile){
  1370. this.scrollNode = this.toolbarNode.getParentSrcollNode();
  1371. if (this.scrollNode){
  1372. this.scrollNode.addEvent("scroll", function(){
  1373. this.resizeToolbar();
  1374. }.bind(this));
  1375. }
  1376. }
  1377. this.doublePageAction = new Element("div", {"styles": this.css.doc_toolbar_doublePage, "text": MWF.xApplication.process.Xform.LP.doublePage}).inject(this.toolbarNode);
  1378. this.doublePageAction.addEvent("click", function(){
  1379. if (this.options.pageShow!=="double"){
  1380. this._doublePage();
  1381. }else{
  1382. this.options.pageShow="single";
  1383. this.reload();
  1384. //this._singlePage();
  1385. }
  1386. }.bind(this));
  1387. if (layout.mobile) this.doublePageAction.hide();
  1388. this.zoomActionArea = new Element("div", {"styles": {"float": "right", "margin-right": "10px"}}).inject(this.toolbarNode);
  1389. if (this.json.isScale !== "y") this.zoomActionArea.hide();
  1390. this.zoomAddAction = new Element("div", {
  1391. "styles": {
  1392. "float": "right",
  1393. "margin-top": "3px",
  1394. "height": "20px",
  1395. "width": "20px",
  1396. "text-align": "center",
  1397. "line-height": "20px",
  1398. "border": "1px solid #cccccc",
  1399. "background-color": "#ffffff",
  1400. "margin-left": "5px"
  1401. },
  1402. "text": "+"
  1403. }).inject(this.zoomActionArea);
  1404. this.zoomSelectAction = new Element("select", {
  1405. "styles": {
  1406. "float": "right",
  1407. "margin-top": "3px",
  1408. "height": "20px",
  1409. "width": "60px",
  1410. "text-align": "center",
  1411. "line-height": "20px",
  1412. "border": "1px solid #cccccc",
  1413. "background-color": "#ffffff",
  1414. "margin-left": "5px"
  1415. },
  1416. "text": "100%"
  1417. }).inject(this.zoomActionArea);
  1418. this.zoomSubAction = new Element("div", {
  1419. "styles": {
  1420. "float": "right",
  1421. "margin-top": "3px",
  1422. "height": "20px",
  1423. "width": "20px",
  1424. "text-align": "center",
  1425. "line-height": "20px",
  1426. "border": "1px solid #cccccc",
  1427. "background-color": "#ffffff",
  1428. "margin-left": "5px"
  1429. },
  1430. "text": "-"
  1431. }).inject(this.zoomActionArea);
  1432. // this.zoomSelectAction = new Element("select", {"styles": {"float": "right"}}).inject(this.toolbarNode);
  1433. var options = "<option value='2'>200%</option> " +
  1434. "<option value='1.95'>195%</option>" +
  1435. "<option value='1.9'>190%</option>" +
  1436. "<option value='1.85'>185%</option>" +
  1437. "<option value='1.8'>180%</option>" +
  1438. "<option value='1.75'>175%</option>" +
  1439. "<option value='1.7'>170%</option>" +
  1440. "<option value='1.65'>165%</option>" +
  1441. "<option value='1.6'>160%</option>" +
  1442. "<option value='1.55'>155%</option>" +
  1443. "<option value='1.5'>150%</option> " +
  1444. "<option value='1.45'>145%</option>" +
  1445. "<option value='1.4'>140%</option>" +
  1446. "<option value='1.35'>135%</option>" +
  1447. "<option value='1.3'>130%</option>" +
  1448. "<option value='1.25'>125%</option>" +
  1449. "<option value='1.2'>120%</option>" +
  1450. "<option value='1.15'>115%</option>" +
  1451. "<option value='1.1'>110%</option>" +
  1452. "<option value='1.05'>105%</option>" +
  1453. "<option value='1' selected>100%</option>" +
  1454. "<option value='0.95'>95%</option>" +
  1455. "<option value='0.90'>90%</option>" +
  1456. "<option value='0.85'>85%</option>" +
  1457. "<option value='0.80'>80%</option>" +
  1458. "<option value='0.75'>75%</option>" +
  1459. "<option value='0.70'>70%</option>" +
  1460. "<option value='0.65'>65%</option>" +
  1461. "<option value='0.6'>60%</option>" +
  1462. "<option value='0.55'>55%</option>" +
  1463. "<option value='0.5'>50%</option>";
  1464. this.zoomSelectAction.set("html", options);
  1465. this.zoomSelectAction.addEvent("change", function(e){
  1466. this.scaleTo(e.target.options[e.target.selectedIndex].value);
  1467. }.bind(this));
  1468. this.zoomAddAction.addEvent("click", function(){
  1469. debugger;
  1470. var i = (this.scale/0.05).toInt();
  1471. if (i*0.05<this.scale) i++;
  1472. var v = i*0.05;
  1473. //var v = this.zoomSelectAction.options[this.zoomSelectAction.selectedIndex].value.toFloat();
  1474. v = v+0.05;
  1475. if (v<0.5) v = 0.5;
  1476. if (v>2) v = 2;
  1477. this.scaleTo(v);
  1478. }.bind(this));
  1479. this.zoomSubAction.addEvent("click", function(){
  1480. var i = (this.scale/0.05).toInt();
  1481. if (i*0.05<this.scale) i++;
  1482. var v = i*0.05;
  1483. //var v = this.zoomSelectAction.options[this.zoomSelectAction.selectedIndex].value.toFloat();
  1484. v = v-0.05;
  1485. if (v<0.5) v = 0.5;
  1486. if (v>2) v = 2;
  1487. this.scaleTo(v);
  1488. }.bind(this));
  1489. },
  1490. scaleTo: function(scale){
  1491. this._returnScale();
  1492. this.scale = scale;
  1493. this.zoom();
  1494. var w = this.contentNode.getSize().x;
  1495. var count = 1;
  1496. var docPageFullWidth = (this.scale) ? this.scale*this.options.docPageFullWidth : this.options.docPageFullWidth;
  1497. var pageWidth = count * docPageFullWidth;
  1498. var margin = (w-pageWidth)/(count+1);
  1499. if (this.isScale){
  1500. margin = "10";
  1501. }
  1502. if (this.scale) margin = margin/this.scale;
  1503. if (margin < 10){
  1504. var offset = 10-margin;
  1505. margin = 10;
  1506. this.contentNode.scrollTo(offset, 0);
  1507. }
  1508. this.pages.each(function(page, i){
  1509. page.setStyles({
  1510. "float": "left",
  1511. "margin-left": ""+margin+"px"
  1512. });
  1513. });
  1514. this.resetNodeSize();
  1515. },
  1516. _repage: function(delay){
  1517. if (this.options.pageShow!=="double"){
  1518. this._singlePage();
  1519. }else{
  1520. this._doublePage();
  1521. }
  1522. if (delay){
  1523. if (!this.form.isLoaded){
  1524. this.form.addEvent("afterLoad", this._checkScale.bind(this));
  1525. }else{
  1526. this._checkScale();
  1527. }
  1528. }else{
  1529. this._checkScale();
  1530. }
  1531. },
  1532. _singlePage: function(){
  1533. //if (this.editMode) this._readFiletext();
  1534. var scale = this.singlePageZoom || 1;
  1535. if( this.singlePageZoom && this.singlePageZoom.toInt() != 1 ){
  1536. this.isScale = true;
  1537. this.scale = this.singlePageZoom;
  1538. this.singlePageZoom = null;
  1539. }
  1540. this.zoom(scale);
  1541. this._checkScale();
  1542. var w = this.contentNode.getSize().x;
  1543. var count = 1;
  1544. var docPageFullWidth = (this.scale) ? this.scale*this.options.docPageFullWidth : this.options.docPageFullWidth;
  1545. //var docPageFullWidth = this.options.docPageFullWidt;
  1546. var pageWidth = count * docPageFullWidth;
  1547. var margin = (w-pageWidth)/(count+1);
  1548. if (this.isScale){
  1549. margin = "10";
  1550. }
  1551. if (this.scale) margin = margin/this.scale;
  1552. this.pages.each(function(page, i){
  1553. page.setStyles({
  1554. "float": "left",
  1555. "margin-left": ""+margin+"px"
  1556. });
  1557. });
  1558. this.resetNodeSize();
  1559. // this.pages.each(function(page){
  1560. // page.setStyle("float", "none");
  1561. // });
  1562. this.resizeSidebar();
  1563. this.options.pageShow="single";
  1564. this.doublePageAction.set("text", MWF.xApplication.process.Xform.LP.doublePage);
  1565. },
  1566. resetNodeSize: function(){
  1567. var contentSize = this.contentNode.getSize();
  1568. var toolbarSize = this.toolNode.getSize();
  1569. contentHeight = contentSize.y;
  1570. var h = contentHeight+toolbarSize.y+20;
  1571. //h = h - contentSize.y*(1-this.scale);
  1572. this.node.setStyles({
  1573. "height":""+h+"px"
  1574. });
  1575. this.resizeSidebar();
  1576. },
  1577. createWaitSplitPage: function(){
  1578. this.node.mask({
  1579. "style": {
  1580. "background-color": "#cccccc",
  1581. "opacity": 0.3
  1582. }
  1583. });
  1584. this.waitSplitPageNode = new Element("div", {"styles": this.form.css.waitSplitPageNode, "text": MWF.xApplication.process.Xform.LP.computePage}).inject(this.node);
  1585. this.waitSplitPageNode.position({
  1586. "relativeTo": this.node,
  1587. "position": "topRight",
  1588. "edge": "topRight",
  1589. "offset": {
  1590. "x": -10,
  1591. "y": 45
  1592. }
  1593. });
  1594. //this.form.notice(MWF.xApplication.process.Xform.LP.computePage, "info", this.node);
  1595. },
  1596. clearWaitSplitPage: function(){
  1597. this.node.unmask();
  1598. if (this.waitSplitPageNode) this.waitSplitPageNode.destroy();
  1599. this.waitSplitPageNode = null;
  1600. },
  1601. _doublePage: function(){
  1602. if (this.editMode) this._switchReadOrEditInline();
  1603. if( this.zoomSelectAction ){
  1604. this.singlePageZoom = ( this.zoomSelectAction.options[this.zoomSelectAction.selectedIndex].value ).toFloat();
  1605. }
  1606. this.zoom(1);
  1607. this.createWaitSplitPage();
  1608. window.setTimeout(function(){
  1609. this._checkSplitPage(this.pages[0]);
  1610. this.zoom(1);
  1611. var w = this.contentNode.getSize().x;
  1612. var toPageWidth = (w-100)/2;
  1613. scale = toPageWidth/this.options.docPageFullWidth;
  1614. if (scale<1) this.zoom(scale);
  1615. var docPageFullWidth = (this.scale) ? this.scale*this.options.docPageFullWidth : this.options.docPageFullWidth;
  1616. //var docPageFullWidth = this.options.docPageFullWidth;
  1617. var w = this.contentNode.getSize().x;
  1618. var count = (w/docPageFullWidth).toInt();
  1619. var pages = this.contentNode.getElements(".doc_layout_page");
  1620. count = Math.min(pages.length, count);
  1621. var pageWidth = count * docPageFullWidth;
  1622. var margin = (w-pageWidth)/(count+1);
  1623. if (this.scale) margin = margin/(this.scale);
  1624. this.pages.each(function(page, i){
  1625. page.setStyles({
  1626. "float": "left",
  1627. "margin-left": ""+margin+"px"
  1628. });
  1629. });
  1630. // this.pages.each(function(page, i){
  1631. // if ((i % 2)===0){
  1632. // page.setStyle("float", "left");
  1633. // }else{
  1634. // page.setStyle("float", "right");
  1635. // }
  1636. // });
  1637. this.resetNodeSize();
  1638. this.options.pageShow="double";
  1639. this.doublePageAction.set("text", MWF.xApplication.process.Xform.LP.singlePage);
  1640. this.resizeSidebar();
  1641. this.clearWaitSplitPage();
  1642. }.bind(this), 1000);
  1643. },
  1644. _getDefaultData: function(){
  1645. return Object.clone(this.json.defaultValue);
  1646. //return Object.clone(MWF.xApplication.process.Xform.LP.documentEditor);
  1647. },
  1648. _loadFiletextPage: function(callback){
  1649. this.data = this._getBusinessData();
  1650. if (!this.data) this.data = this._getDefaultData();
  1651. this._computeData(true);
  1652. this._createPage(function(control){
  1653. this._loadPageLayout(control);
  1654. // this.data = this._getBusinessData();
  1655. // if (!this.data) this.data = this._getDefaultData();
  1656. this.setData(this.data);
  1657. // this._checkSplitPage(this.pages[0]);
  1658. //this._repage(true);
  1659. //this.loadCkeditorFiletext();
  1660. if (!this.readonly){
  1661. //if (this.json.allowEditFiletext!==false) this.loadCkeditorFiletext();
  1662. // if (this.json.allowEditRedheader) this.loadCkeditorRedheader();
  1663. // if (this.json.allowEditSubject) this.loadCkeditorSubject();
  1664. // if (this.json.allowEditMainSend) this.loadCkeditorMainSend();
  1665. // if (this.json.allowEditFileNo) this.loadCkeditorFileNo();
  1666. // if (this.json.allowEditSigner) this.loadCkeditorSigner();
  1667. // if (this.json.allowEditAttachment) this.loadCkeditorAttachment();
  1668. }
  1669. if (callback) callback();
  1670. }.bind(this));
  1671. },
  1672. _getEditorConfig: function(){
  1673. // var mathElements = [
  1674. // 'math',
  1675. // 'maction',
  1676. // 'maligngroup',
  1677. // 'malignmark',
  1678. // 'menclose',
  1679. // 'merror',
  1680. // 'mfenced',
  1681. // 'mfrac',
  1682. // 'mglyph',
  1683. // 'mi',
  1684. // 'mlabeledtr',
  1685. // 'mlongdiv',
  1686. // 'mmultiscripts',
  1687. // 'mn',
  1688. // 'mo',
  1689. // 'mover',
  1690. // 'mpadded',
  1691. // 'mphantom',
  1692. // 'mroot',
  1693. // 'mrow',
  1694. // 'ms',
  1695. // 'mscarries',
  1696. // 'mscarry',
  1697. // 'msgroup',
  1698. // 'msline',
  1699. // 'mspace',
  1700. // 'msqrt',
  1701. // 'msrow',
  1702. // 'mstack',
  1703. // 'mstyle',
  1704. // 'msub',
  1705. // 'msup',
  1706. // 'msubsup',
  1707. // 'mtable',
  1708. // 'mtd',
  1709. // 'mtext',
  1710. // 'mtr',
  1711. // 'munder',
  1712. // 'munderover',
  1713. // 'semantics',
  1714. // 'annotation',
  1715. // 'annotation-xml'
  1716. // ];
  1717. //CKEDITOR.plugins.addExternal('ckeditor_wiris', 'https://ckeditor.com/docs/ckeditor4/4.13.0/examples/assets/plugins/ckeditor_wiris/', 'plugin.js');
  1718. debugger;
  1719. var editorConfig = {
  1720. qtRows: 20, // Count of rows
  1721. qtColumns: 20, // Count of columns
  1722. qtBorder: '1', // Border of inserted table
  1723. qtWidth: '95%', // Width of inserted table
  1724. qtStyle: { 'border-collapse' : 'collapse' },
  1725. qtClass: 'documenteditor_table'+this.form.json.id+this.json.id, // Class of table
  1726. qtCellPadding: '0', // Cell padding table
  1727. qtCellSpacing: '0', // Cell spacing table
  1728. qtPreviewBorder: '4px double black', // preview table border
  1729. qtPreviewSize: '4px', // Preview table cell size
  1730. qtPreviewBackground: '#c8def4', // preview table background (hover)
  1731. // format_tags: '标题一;标题二;标题三;标题四;正文', // entries is displayed in "Paragraph format"
  1732. format_tags: '标题一;标题二;正文(标题三,四)', // entries is displayed in "Paragraph format"
  1733. 'format_标题一': {
  1734. name: '标题一(三号黑体)',
  1735. element: 'div',
  1736. styles: {
  1737. 'font-family': '黑体',
  1738. 'font-size': '16pt'
  1739. }
  1740. },
  1741. 'format_标题二': {
  1742. name: '标题二(三号楷体)',
  1743. element: 'div',
  1744. styles: {
  1745. 'font-family': '楷体',
  1746. 'font-size': '16pt'
  1747. }
  1748. },
  1749. // 'format_标题三': {
  1750. // name: '标题三',
  1751. // element: 'div',
  1752. // styles: {
  1753. // 'font-family': '仿宋',
  1754. // 'font-size': '16pt'
  1755. // }
  1756. // },
  1757. // 'format_标题四': {
  1758. // name: '标题四',
  1759. // element: 'div',
  1760. // styles: {
  1761. // 'font-family': '仿宋',
  1762. // 'font-size': '16pt'
  1763. // }
  1764. // },
  1765. 'format_正文(标题三,四)': {
  1766. name: '正文(标题三,四)',
  1767. element: 'div',
  1768. styles: {
  1769. 'font-family': '仿宋',
  1770. 'font-size': '16pt'
  1771. }
  1772. }
  1773. };
  1774. editorConfig.toolbarGroups = [
  1775. { name: 'document', groups: [ 'mode', 'document', 'doctools' ] },
  1776. { name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
  1777. { name: 'editing', groups: [ 'find', 'selection', 'spellchecker', 'editing' ] },
  1778. { name: 'forms', groups: [ 'forms' ] },
  1779. { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
  1780. { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi', 'paragraph' ] },
  1781. { name: 'links', groups: [ 'links' ] },
  1782. { name: 'insert', groups: [ 'insert' ] },
  1783. { name: 'styles', groups: [ 'styles' ] },
  1784. { name: 'colors', groups: [ 'colors' ] },
  1785. { name: 'tools', groups: [ 'tools' ] },
  1786. { name: 'others', groups: [ 'others' ] },
  1787. { name: 'about', groups: [ 'about' ] }
  1788. ];
  1789. //editorConfig.extraPlugins = "ecnet,colordialog,tableresize,quicktable,mathjax,ckeditor_wiris";
  1790. //editorConfig.extraPlugins = "ecnet,colordialog,quicktable,tableresize,eqneditor";
  1791. //editorConfig.extraPlugins = "tableresize,quicktable";
  1792. editorConfig.extraPlugins = "quicktable,tableresize";
  1793. //editorConfig.mathJaxLib = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=TeX-AMS_HTML',
  1794. 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';
  1795. //editorConfig.extraAllowedContent = mathElements.join(' ') + '(*)[*]{*};img[data-mathml,data-custom-editor,role](Wirisformula)';
  1796. editorConfig.pasteFromWordRemoveFontStyles = false;
  1797. editorConfig.pasteFromWordRemoveStyles = false;
  1798. //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';
  1799. editorConfig.removePlugins = ['magicline'];
  1800. editorConfig.enterMode = 3;
  1801. // editorConfig.extraPlugins = ['ecnet','mathjax'];
  1802. // editorConfig.removePlugins = ['magicline'];
  1803. // editorConfig.mathJaxLib = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=TeX-AMS_HTML';
  1804. return editorConfig;
  1805. },
  1806. _checkSplitPage: function(pageNode){
  1807. if (this.layout_edition) this.layout_edition.setStyles({ "position": "static"});
  1808. var contentNode = pageNode.getFirst();
  1809. if (contentNode.getSize().y>this.options.docPageHeight){
  1810. this._splitPage(pageNode);
  1811. }
  1812. var i = pageNode.get("data-pagecount").toInt();
  1813. if (i && this.pages.length-1>=i){
  1814. this._checkSplitPage(this.pages[i]);
  1815. }
  1816. if (this.layout_edition) this.layout_edition.setStyles({ "position": "absolute", "bottom": "0px" });
  1817. },
  1818. _splitFiletextNodeOneWord:function(lnode, nextPageNode){
  1819. var text = lnode.textContent;
  1820. var len = text.length;
  1821. var left = text.substring(0, len-1);
  1822. var right = text.substring(len-1, len);
  1823. lnode.textContent = left;
  1824. nextPageNode.textContent = right+nextPageNode.textContent;
  1825. //nextPageNode.appendText(right, "top");
  1826. },
  1827. _splitFiletext: function(node, nextPageNode, nextFiletextNode, pageNode){
  1828. var contentNode = pageNode.getFirst();
  1829. var lnode = node.lastChild;
  1830. if (!lnode){
  1831. if (node.parentNode) node.parentNode.removeChild(node);
  1832. //node.remove();
  1833. }else{
  1834. while (contentNode.getSize().y>this.options.docPageHeight && lnode) {
  1835. var tmpnode = lnode.previousSibling;
  1836. var nodeType = lnode.nodeType;
  1837. if (!nextPageNode) nextPageNode = nextFiletextNode;
  1838. if (nodeType == Node.ELEMENT_NODE) {
  1839. if (lnode.tagName == "table") {
  1840. lnode.inject(nextPageNode);
  1841. } else if (lnode.tagName == "BR") {
  1842. if (lnode.parentNode) lnode.parentNode.removeChild(lnode);
  1843. } else {
  1844. var id = lnode.get("data-pagePart");
  1845. if (!id){
  1846. id = (new o2.widget.UUID()).toString();
  1847. lnode.set("data-pagePart", id);
  1848. }
  1849. var tmpNode = nextPageNode.getFirst();
  1850. if (tmpNode && tmpNode.get("data-pagePart")==id){
  1851. nextPageNode = tmpNode;
  1852. }else{
  1853. nextPageNode = lnode.clone(false).inject(nextPageNode, "top");
  1854. }
  1855. //var subnode = lnode.getLast();
  1856. this._splitFiletext(lnode, nextPageNode, nextFiletextNode, pageNode);
  1857. if (!lnode.firstChild) if (lnode.parentNode) lnode.parentNode.removeChild(lnode);
  1858. nextPageNode = nextPageNode.getParent();
  1859. }
  1860. } else if (nodeType == Node.TEXT_NODE) {
  1861. var nextPageTextNode = nextPageNode.insertBefore(document.createTextNode(""), nextPageNode.firstChild);
  1862. while ((contentNode.getSize().y > this.options.docPageHeight) && lnode.textContent) {
  1863. //console.log(contentNode.getSize().y);
  1864. this._splitFiletextNodeOneWord(lnode, nextPageTextNode)
  1865. }
  1866. if (!lnode.textContent) if (lnode.parentNode) lnode.parentNode.removeChild(lnode); //lnode.remove();
  1867. } else {
  1868. //lnode.remove();
  1869. if (lnode.parentNode) lnode.parentNode.removeChild(lnode);
  1870. }
  1871. lnode = tmpnode;
  1872. }
  1873. if (!node.lastChild) if (node.parentNode) node.parentNode.removeChild(node); //node.remove();
  1874. }
  1875. //this._checkSplitPage(pageNode);
  1876. },
  1877. _splitPage: function(pageNode){
  1878. var contentNode = pageNode.getFirst();
  1879. var blockNodes = pageNode.getElements(".doc_block");
  1880. if (blockNodes.length){
  1881. var blockNode = blockNodes[blockNodes.length-1];
  1882. var idx = this.pages.indexOf(pageNode);
  1883. if (this.pages.length<=idx+1) this._createNewPage();
  1884. var nextPage = this.pages[idx+1];
  1885. if (blockNode.hasClass("doc_layout_filetext")){
  1886. var filetextNode = nextPage.getElement(".doc_layout_filetext");
  1887. if (!filetextNode){
  1888. filetextNode = new Element("div.doc_layout_filetext").inject(nextPage.getFirst(), "top");
  1889. //filetextNode.setAttribute('contenteditable', true);
  1890. }
  1891. if (!filetextNode.hasClass("doc_block"))filetextNode.addClass("doc_block");
  1892. //var nextEditor = filetextNode.retrieve("editor");
  1893. var node = blockNode;
  1894. var nextPageNode = filetextNode;
  1895. this._splitFiletext(node, nextPageNode, filetextNode, pageNode);
  1896. }else{
  1897. blockNode.inject(nextPage.getFirst(), "top");
  1898. //var contentNode = pageNode.getFirst();
  1899. if (contentNode.getSize().y>this.options.docPageHeight){
  1900. this._splitPage(pageNode);
  1901. }
  1902. }
  1903. }
  1904. },
  1905. transWidth: function(node){
  1906. if (!node) return '';
  1907. while (node){
  1908. if (node.nodeType==3){
  1909. node.nodeValue = node.nodeValue.replace(/\x20/g, " ");
  1910. }else if (node.nodeType==8){
  1911. //nothing
  1912. }else{
  1913. this.transWidth(node.firstChild);
  1914. }
  1915. node = node.nextSibling;
  1916. }
  1917. },
  1918. insertFullWidth: function(node, txt){
  1919. if (!node) return '';
  1920. while (node){
  1921. if (node.nodeType==3){
  1922. node.nodeValue = txt+node.nodeValue;
  1923. return true;
  1924. }else if (node.nodeType==8){
  1925. //nothing
  1926. }else{
  1927. var flag = this.insertFullWidth(node.firstChild, txt);
  1928. if (flag) return true;
  1929. }
  1930. node = node.nextSibling;
  1931. }
  1932. },
  1933. loadCkeditorFiletext: function(callback, inline){
  1934. if (this.layout_filetext){
  1935. o2.load("../o2_lib/htmleditor/ckeditor4130/ckeditor.js", function(){
  1936. CKEDITOR.disableAutoInline = true;
  1937. this.layout_filetext.setAttribute('contenteditable', true);
  1938. if (inline){
  1939. this.filetextEditor = CKEDITOR.inline(this.layout_filetext, this._getEditorConfig());
  1940. }else{
  1941. this.filetextEditor = CKEDITOR.replace(this.layout_filetext, this._getEditorConfig());
  1942. }
  1943. this.filetextEditor.on("instanceReady", function(e){
  1944. if (callback) callback(e);
  1945. }.bind(this));
  1946. this.filetextEditor.on( 'focus', function( e ) {
  1947. window.setTimeout(this.reLocationFiletextToolbar.bind(this), 10);
  1948. }.bind(this) );
  1949. this.filetextEditor.on( 'paste', function( e ) {
  1950. var html = e.data.dataValue;
  1951. //if (this.json.fullWidth=="y") html = html.replace(/\x20/g, " ");
  1952. var tmp = new Element("div")
  1953. tmp.set("html", html);
  1954. var pList = tmp.getElements("p");
  1955. pList.each(function(p, i){
  1956. //if (Browser.name=="ie"){
  1957. if (this.json.fullWidth!=="n") this.transWidth(p);
  1958. if (!p.getParent("table")){
  1959. var text = p.get("text");
  1960. var rex = /^\u3000*/;
  1961. var m = text.match(rex);
  1962. var l = (m[0]) ? Math.max((2-m[0].length), 0): 2;
  1963. var txt = "";
  1964. // for (var i=0; i<l; i++) txt+=" ";
  1965. // this.insertFullWidth(p.getFirst(), txt);
  1966. for (var i=0; i<l; i++) p.appendText(" ","top");
  1967. }
  1968. //}else{
  1969. // var textIndent = p.getStyle("text-indent");
  1970. // if (textIndent.toInt()) p.appendText("  ","top");
  1971. //}
  1972. }.bind(this));
  1973. e.data.dataValue = tmp.get("html");
  1974. tmp.destroy();
  1975. }.bind(this) );
  1976. if (this.json.textIndent!=="n"){
  1977. // this.filetextEditor.addCommand( 'textIndent_P', {
  1978. // exec: function( editor ) {
  1979. // debugger;
  1980. // editor.insertHtml("<br><div>  </div>");
  1981. // }
  1982. // } );
  1983. // this.filetextEditor.setKeystroke( CKEDITOR.CTRL + 13, 'textIndent_P' );
  1984. this.layout_filetext.addEvent("keyup", function(ev){
  1985. if (ev.code==13) this.filetextEditor.insertText("  ");
  1986. }.bind(this));
  1987. //
  1988. // this.filetextEditor.on("key", function(e){
  1989. // if (e.data.keyCode==13){
  1990. // e.editor.insertText("  ");
  1991. // //e.cancel();
  1992. // }
  1993. // }.bind(this));
  1994. }
  1995. if (this.json.fullWidth!=="n"){
  1996. this.filetextEditor.addCommand( 'insertHalfSpace', {
  1997. exec: function( editor ) {
  1998. editor.insertText(" ");
  1999. }
  2000. } );
  2001. this.filetextEditor.setKeystroke( CKEDITOR.SHIFT + 32, 'insertHalfSpace' );
  2002. this.filetextEditor.on("key", function(e){
  2003. if (this.json.fullWidth!=="n") if (e.data.keyCode==32){
  2004. e.editor.insertText(" ");
  2005. e.cancel();
  2006. }
  2007. }.bind(this));
  2008. }
  2009. }.bind(this));
  2010. }
  2011. },
  2012. _loadEvents: function(editorConfig){
  2013. Object.each(this.json.events, function(e, key){
  2014. if (e.code){
  2015. this.editor.on(key, function(event){
  2016. return this.form.Macro.fire(e.code, this, event);
  2017. }.bind(this), this);
  2018. }
  2019. }.bind(this));
  2020. },
  2021. _bindFieldChange: function(name,dataItem, dom){
  2022. var field = this.form.all[this.json[dataItem]];
  2023. if (field){
  2024. var bindFun = function(){
  2025. this._computeItemFieldData(name, dataItem);
  2026. //if (this.data[name]){
  2027. if (this[dom]){
  2028. if (dom=="layout_redHeader" || dom=="layout_subject" || dom=="layout_issuanceUnit" || dom=="layout_meetingAttendContent" || dom=="layout_meetingLeaveContent" || dom=="layout_meetingSitContent" || dom=="layout_meetingRecordContent"){
  2029. this[dom].set("html", this.data[name]|| "");
  2030. }else if (dom=="layout_attachment"){
  2031. this.setAttachmentData();
  2032. }else{
  2033. this[dom].set("text", this.data[name]|| "");
  2034. }
  2035. }
  2036. this.reSetShow();
  2037. //}
  2038. }.bind(this);
  2039. field.node.store(this.json.id+"bindFun", bindFun);
  2040. field.addModuleEvent("change", bindFun);
  2041. }
  2042. },
  2043. _computeItemFieldData: function(name, dataItem, dataItemNode){
  2044. var v = "";
  2045. var module = (dataItemNode) ? this.form.all[dataItemNode] : this.form.all[this.json[dataItem]];
  2046. if (module && module.getData) v = module.getData();
  2047. if (!v) v = (dataItemNode) ? this.form.businessData.data[dataItemNode] : this.form.businessData.data[this.json[dataItem]];
  2048. if (v){
  2049. var t = o2.typeOf(v);
  2050. switch (t) {
  2051. case "string":
  2052. switch (name) {
  2053. case "issuanceDate":
  2054. case "editionDate":
  2055. var d = new Date(v);
  2056. debugger;
  2057. if (d.isValid() && d.getFullYear()!=1970){
  2058. var y = d.getFullYear();
  2059. var m = d.getMonth();
  2060. var day = d.getDate();
  2061. m = m +1;
  2062. this.data[name] = ""+y+"年"+m+"月"+day+"日";
  2063. }else{
  2064. this.data[name] = v;
  2065. }
  2066. //this.data[name] = (new Date(v).isValid()) ? Date.parse(v).format("%Y年%m月%d%日") : v;
  2067. break;
  2068. case "mainSend":
  2069. this.data[name] = v + ":";
  2070. break;
  2071. default:
  2072. this.data[name] = v;
  2073. }
  2074. break;
  2075. case "array":
  2076. var strs = [];
  2077. v.each(function(value){
  2078. if (o2.typeOf(value)=="object" && value.distinguishedName){
  2079. strs.push(value.name);
  2080. }else{
  2081. strs.push(value.toString());
  2082. }
  2083. });
  2084. //if (strs.length){
  2085. switch (name) {
  2086. case "attachment":
  2087. // this.data[name] = strs.map(function(n, i){ var j = i+1; return j+"、"+n}).join("<br>");
  2088. var atts = strs.map(function(a){
  2089. return (a.indexOf(".")!=-1) ? a.substring(0, a.lastIndexOf(".")) : a;
  2090. });
  2091. this.data[name] = atts;
  2092. break;
  2093. case "issuanceDate":
  2094. case "editionDate":
  2095. var tmpStrs = strs.map(function(n, i){
  2096. var d = Date.parse(n);
  2097. if (d.isValid() && d.getFullYear()!=1970){
  2098. var y = d.getFullYear();
  2099. var m = d.getMonth();
  2100. var day = d.getDate();
  2101. m = m +1;
  2102. return ""+y+"年"+m+"月"+day+"日";
  2103. }else{
  2104. return n;
  2105. }
  2106. //return () ? d.format("%Y年%m月%d日") : n;
  2107. });
  2108. this.data[name] = tmpStrs.join(",");
  2109. break;
  2110. case "mainSend":
  2111. this.data[name] = strs.join(",") + ":";
  2112. break;
  2113. default:
  2114. this.data[name] = strs.join(",");
  2115. }
  2116. //}
  2117. break;
  2118. default:
  2119. this.data[name] = v.toString();
  2120. }
  2121. }else{
  2122. this.data[name] = this.json.defaultValue[name];
  2123. }
  2124. },
  2125. computeData: function(){
  2126. this._computeData(false);
  2127. this.setData(this.data);
  2128. },
  2129. _computeItemData: function(name, typeItem, dataItem, scriptItem, ev, dom){
  2130. switch (this.json[typeItem]) {
  2131. case "data":
  2132. if (this.json[dataItem]){
  2133. if (ev) this._bindFieldChange(name, dataItem, dom);
  2134. this._computeItemFieldData(name, dataItem);
  2135. }
  2136. break;
  2137. case "script":
  2138. if (this.json[scriptItem] && this.json[scriptItem].code){
  2139. var v = this.form.Macro.exec(this.json[scriptItem].code, this);
  2140. this.data[name] = v;
  2141. if (name=="attachment"){
  2142. //this.data[name] = (typeOf(v)=="array") ? v.map(function(n, i){ var j = i+1; return j+"、"+n}).join("<br>") : v;
  2143. this.data[name] = (typeOf(v)=="array") ? v : [v];
  2144. }
  2145. if (name=="issuanceDate" || name=="editionDate"){
  2146. var d = Date.parse(v);
  2147. if (d.isValid() && d.getFullYear()!=1970){
  2148. var y = d.getFullYear();
  2149. var m = d.getMonth();
  2150. var day = d.getDate();
  2151. m = m +1;
  2152. this.data[name] = ""+y+"年"+m+"月"+day+"日";
  2153. }else{
  2154. this.data[name] = v;
  2155. }
  2156. //this.data[name] = (d.isValid() && d.getFullYear()!=1970) ? d.format("%Y年%m月%d日") : v;
  2157. }
  2158. }
  2159. break;
  2160. }
  2161. },
  2162. _computeCustomItemData: function(name, field, ev){
  2163. //if (this.json.customFields[l.name]){
  2164. if (ev) this._bindCustomFieldChange(name, field, name);
  2165. this._computeItemFieldData(name, null, field);
  2166. //}
  2167. },
  2168. _bindCustomFieldChange: function(name, dataItem, dom){
  2169. var field = this.form.all[dataItem];
  2170. if (field){
  2171. var bindFun = function(){
  2172. this._computeItemFieldData(name, null, dataItem);
  2173. //if (this.data[name]){
  2174. if (this[dom]){
  2175. debugger;
  2176. if (dom=="layout_redHeader" || dom=="layout_subject" || dom=="layout_issuanceUnit"){
  2177. this[dom].set("html", this.data[name]|| "");
  2178. }else if (dom=="layout_attachment"){
  2179. this.setAttachmentData();
  2180. }else{
  2181. this[dom].set("text", this.data[name]|| "");
  2182. }
  2183. }
  2184. this.reSetShow();
  2185. //}
  2186. }.bind(this);
  2187. field.node.store(this.json.id+"bindFun", bindFun);
  2188. field.addModuleEvent("change", bindFun);
  2189. }
  2190. },
  2191. _computeData: function(ev){
  2192. this._computeItemData("copies", "copiesValueType", "copiesValueData", "copiesValueScript", ev, "layout_copies");
  2193. this._computeItemData("secret", "secretValueType", "secretValueData", "secretValueScript", ev, "layout_secret");
  2194. this._computeItemData("priority", "priorityValueType", "priorityValueData", "priorityValueScript", ev, "layout_priority");
  2195. this._computeItemData("redHeader", "redHeaderValueType", "redHeaderValueData", "redHeaderValueScript", ev, "layout_redHeader");
  2196. this._computeItemData("fileno", "filenoValueType", "filenoValueData", "filenoValueScript", ev, "layout_fileno");
  2197. this._computeItemData("signer", "signerValueType", "signerValueData", "signerValueScript", ev, "layout_signer");
  2198. this._computeItemData("subject", "subjectValueType", "subjectValueData", "subjectValueScript", ev, "layout_subject");
  2199. this._computeItemData("mainSend", "mainSendValueType", "mainSendValueData", "mainSendValueScript", ev, "layout_mainSend");
  2200. this._computeItemData("attachment", "attachmentValueType", "attachmentValueData", "attachmentValueScript", ev, "layout_attachment");
  2201. this._computeItemData("issuanceUnit", "issuanceUnitValueType", "issuanceUnitValueData", "issuanceUnitValueScript", ev, "layout_issuanceUnit");
  2202. this._computeItemData("issuanceDate", "issuanceDateValueType", "issuanceDateValueData", "issuanceDateValueScript", ev, "layout_issuanceDate");
  2203. this._computeItemData("annotation", "annotationValueType", "annotationValueData", "annotationValueScript", ev, "layout_annotation");
  2204. this._computeItemData("copyto", "copytoValueType", "copytoValueData", "copytoValueScript", ev, "layout_copytoContent");
  2205. this._computeItemData("copyto2", "copyto2ValueType", "copyto2ValueData", "copyto2ValueScript", ev, "layout_copyto2Content");
  2206. this._computeItemData("editionUnit", "editionUnitValueType", "editionUnitValueData", "editionUnitValueScript", ev, "layout_edition_issuance_unit");
  2207. this._computeItemData("editionDate", "editionDateValueType", "editionDateValueData", "editionDateValueScript", ev, "layout_edition_issuance_date");
  2208. this._computeItemData("meetingAttend", "meetingAttendValueType", "meetingAttendValueData", "meetingAttendValueScript", ev, "layout_meetingAttendContent");
  2209. this._computeItemData("meetingLeave", "meetingLeaveValueType", "meetingLeaveValueData", "meetingLeaveValueScript", ev, "layout_meetingLeaveContent");
  2210. this._computeItemData("meetingSit", "meetingSitValueType", "meetingSitValueData", "meetingSitValueScript", ev, "layout_meetingSitContent");
  2211. this._computeItemData("meetingRecord", "meetingRecordValueType", "meetingRecordValueData", "meetingRecordValueScript", ev, "layout_meetingRecordContent");
  2212. Object.each(this.json.customFields, function(field, k){
  2213. this._computeCustomItemData(k, field, ev);
  2214. }.bind(this));
  2215. // if (this.customLayouts){
  2216. // this.customLayouts.each(function(l){
  2217. // this._computeCustomItemData(l, ev);
  2218. // }.bind(this))
  2219. // }
  2220. },
  2221. _loadValue: function(){
  2222. var data = this._getBusinessData();
  2223. },
  2224. reload: function(){
  2225. this.resetData();
  2226. },
  2227. resetData: function(diffFiletext){
  2228. if (this.editMode){ this._switchReadOrEditInline(); }
  2229. this._computeData(false);
  2230. this.pages = [];
  2231. this.contentNode.empty();
  2232. if (this.allowEdit) this.toolbar.childrenButton[0].setText((layout.mobile) ? MWF.xApplication.process.Xform.LP.editdoc_mobile : MWF.xApplication.process.Xform.LP.editdoc);
  2233. this.editMode = false;
  2234. this._createPage(function(control){
  2235. this._loadPageLayout(control);
  2236. this.setData(this.data, diffFiletext);
  2237. //this._checkSplitPage(this.pages[0]);
  2238. debugger;
  2239. this._repage();
  2240. }.bind(this));
  2241. },
  2242. isEmpty: function(){
  2243. var data = this.getData();
  2244. if( typeOf(data) !== "object" )return true;
  2245. return !data.filetext || data.filetext===this.json.defaultValue.filetext;
  2246. },
  2247. getData: function(){
  2248. //if (this.editMode){
  2249. debugger;
  2250. if (this.layout_copies) this.data.copies = this.layout_copies.get("text");
  2251. if (this.layout_secret) this.data.secret = this.layout_secret.get("text");
  2252. if (this.layout_priority) this.data.priority = this.layout_priority.get("text");
  2253. if (this.layout_redHeader) this.data.redHeader = this.layout_redHeader.get("html");
  2254. if (this.layout_fileno) this.data.fileno = this.layout_fileno.get("text");
  2255. if (this.layout_signerTitle) this.data.signerTitle = this.layout_signerTitle.get("text");
  2256. if (this.layout_signer) this.data.signer = this.layout_signer.get("text");
  2257. if (this.layout_subject) this.data.subject = this.layout_subject.get("html");
  2258. if (this.layout_mainSend) this.data.mainSend = this.layout_mainSend.get("text");
  2259. if (this.editMode) if (this.layout_filetext){
  2260. var text = this.layout_filetext.get("text");
  2261. text = text.replace(/\u3000*/g, "");
  2262. if (text && text !==this.json.defaultValue.filetext){
  2263. this.data.filetext = this.layout_filetext.get("html");
  2264. }else{
  2265. this.data.filetext = "";
  2266. }
  2267. }
  2268. if (this.layout_signer) this.data.signer = this.layout_signer.get("text");
  2269. if (this.layout_attachmentTitle) this.data.attachmentTitle = this.layout_attachmentTitle.get("text");
  2270. if (this.layout_attachment){
  2271. this._computeItemData("attachment", "attachmentValueType", "attachmentValueData", "attachmentValueScript", false, "layout_attachment");
  2272. // var atts = [];
  2273. // var nodes = this.layout_attachment.getElements(".doc_layout_attachment_content_name");
  2274. // if (nodes.length){
  2275. // nodes.each(function(node){
  2276. // atts.push(node.get("text"));
  2277. // });
  2278. // }
  2279. // this.data.attachment = atts;
  2280. }
  2281. if (this.layout_issuanceUnit) this.data.issuanceUnit = this.layout_issuanceUnit.get("html");
  2282. if (this.layout_issuanceDate) this.data.issuanceDate = this.layout_issuanceDate.get("text");
  2283. if (this.layout_annotation) this.data.annotation = this.layout_annotation.get("text");
  2284. if (this.layout_copytoTitle) this.data.copytoTitle = this.layout_copytoTitle.get("text");
  2285. if (this.layout_copytoContent) this.data.copyto = this.layout_copytoContent.get("text");
  2286. if (this.layout_copyto2Title) this.data.copyto2Title = this.layout_copyto2Title.get("text");
  2287. if (this.layout_copyto2Content) this.data.copyto2 = this.layout_copyto2Content.get("text");
  2288. if (this.layout_edition_issuance_unit) this.data.editionUnit = this.layout_edition_issuance_unit.get("text");
  2289. if (this.layout_edition_issuance_date) this.data.editionDate = this.layout_edition_issuance_date.get("text");
  2290. if (this.layout_meetingAttendTitle) this.data.meetingAttendTitle = this.layout_meetingAttendTitle.get("text");
  2291. if (this.layout_meetingLeaveTitle) this.data.meetingLeaveTitle = this.layout_meetingLeaveTitle.get("text");
  2292. if (this.layout_meetingSitTitle) this.data.meetingSitTitle = this.layout_meetingSitTitle.get("text");
  2293. if (this.layout_meetingAttendContent) this.data.meetingAttend = this.layout_meetingAttendContent.get("html");
  2294. if (this.layout_meetingLeaveContent) this.data.meetingLeave = this.layout_meetingLeaveContent.get("html");
  2295. if (this.layout_meetingSitContent) this.data.meetingSit = this.layout_meetingSitContent.get("html");
  2296. if (this.layout_meetingRecordContent) this.data.meetingRecord = this.layout_meetingRecordContent.get("html");
  2297. if (this.customLayouts){
  2298. this.customLayouts.each(function(l){
  2299. this.data[l.name] = l.node.get("html");
  2300. }.bind(this))
  2301. }
  2302. //}
  2303. return this.data;
  2304. },
  2305. setAttachmentData: function(){
  2306. if (!this.attachmentTemplete){
  2307. this.attachmentTemplete = this.layout_attachment.get("html");
  2308. }
  2309. this.layout_attachment.empty();
  2310. if (this.data.attachment && this.data.attachment.length && this.data.attachment.each){
  2311. //var tmpdiv = new Element("div", {"styles": {"display":"none"}}).inject(document.body);
  2312. var tmpdiv = new Element("div");
  2313. this.data.attachment.each(function(name, idx){
  2314. tmpdiv.set("html", this.attachmentTemplete);
  2315. var serialNode = tmpdiv.getElement(".doc_layout_attachment_content_serial");
  2316. var nameNode = tmpdiv.getElement(".doc_layout_attachment_content_name");
  2317. if (serialNode) serialNode.set("text", idx+1);
  2318. if (nameNode) nameNode.set("text", name);
  2319. var html = tmpdiv.get("html");
  2320. tmpdiv.empty();
  2321. this.layout_attachment.appendHTML(html);
  2322. }.bind(this));
  2323. tmpdiv.destroy();
  2324. }
  2325. },
  2326. setData: function(data, diffFiletext){
  2327. if (data){
  2328. this.data = data;
  2329. // this.data["$json"] = this.json;
  2330. this._setBusinessData(data);
  2331. if (this.layout_copies){
  2332. if (data.copies){
  2333. this.layout_copies.set("text", data.copies || " ");
  2334. }else{
  2335. this.layout_copies.set("html", "<span>&nbsp</span>");
  2336. }
  2337. }
  2338. if (this.layout_secret){
  2339. if (data.secret){
  2340. this.layout_secret.set("text", data.secret || " ");
  2341. }else{
  2342. this.layout_secret.set("html", "<span>&nbsp</span>");
  2343. }
  2344. }
  2345. if (this.layout_priority){
  2346. if (data.priority){
  2347. this.layout_priority.set("text", data.priority || " ");
  2348. }else{
  2349. this.layout_priority.set("html", "<span>&nbsp</span>");
  2350. }
  2351. }
  2352. if (this.layout_redHeader) this.layout_redHeader.set("html", data.redHeader || "");
  2353. if (this.layout_fileno) this.layout_fileno.set("text", data.fileno || " ");
  2354. if (this.layout_signerTitle) this.layout_signerTitle.set("text", data.signerTitle || " ");
  2355. if (this.layout_signer) this.layout_signer.set("text", data.signer || " ");
  2356. if (this.layout_subject) this.layout_subject.set("html", data.subject || " ");
  2357. if (this.layout_mainSend) this.layout_mainSend.set("text", data.mainSend || " ");
  2358. if (diffFiletext) {
  2359. this.layout_filetext.set("html", diffFiletext);
  2360. }else if (this.layout_filetext){
  2361. //this.layout_filetext.set("placeholder", this.json.defaultValue.filetext);
  2362. this.layout_filetext.set("html", data.filetext || "  ");
  2363. }
  2364. if (this.layout_signer) this.layout_signer.set("text", data.signer || "");
  2365. if (this.layout_attachmentTitle) this.layout_attachmentTitle.set("text", data.attachmentTitle || " ");
  2366. if (this.layout_attachment){
  2367. this.setAttachmentData();
  2368. }
  2369. if (this.layout_issuanceUnit) this.layout_issuanceUnit.set("html", data.issuanceUnit || " ");
  2370. if (this.layout_issuanceDate) this.layout_issuanceDate.set("text", data.issuanceDate || " ");
  2371. if (this.layout_annotation) this.layout_annotation.set("text", data.annotation || " ");
  2372. if (this.layout_copytoTitle) this.layout_copytoTitle.set("text", data.copytoTitle || " ");
  2373. if (this.layout_copytoContent) this.layout_copytoContent.set("text", data.copyto || " ");
  2374. if (this.layout_copyto2Title) this.layout_copyto2Title.set("text", data.copyto2Title || " ");
  2375. if (this.layout_copyto2Content) this.layout_copyto2Content.set("text", data.copyto2 || " ");
  2376. if (this.layout_edition_issuance_unit) this.layout_edition_issuance_unit.set("text", data.editionUnit || " ");
  2377. if (this.layout_edition_issuance_date) this.layout_edition_issuance_date.set("text", data.editionDate || " ");
  2378. if (this.layout_meetingAttendTitle) this.layout_meetingAttendTitle.set("text", data.meetingAttendTitle || this.json.defaultValue.meetingAttendTitle || " ");
  2379. if (this.layout_meetingLeaveTitle) this.layout_meetingLeaveTitle.set("text", data.meetingLeaveTitle || this.json.defaultValue.meetingLeaveTitle || " ");
  2380. if (this.layout_meetingSitTitle) this.layout_meetingSitTitle.set("text", data.meetingSitTitle || this.json.defaultValue.meetingSitTitle || " ");
  2381. if (this.layout_meetingAttendContent) this.layout_meetingAttendContent.set("html", data.meetingAttend || " ");
  2382. if (this.layout_meetingLeaveContent) this.layout_meetingLeaveContent.set("html", data.meetingLeave || " ");
  2383. if (this.layout_meetingSitContent) this.layout_meetingSitContent.set("html", data.meetingSit || " ");
  2384. if (this.layout_meetingRecordContent) this.layout_meetingRecordContent.set("html", data.meetingRecord || " ");
  2385. if (this.customLayouts){
  2386. this.customLayouts.each(function(l){
  2387. l.node.set("html", this.data[l.name] || " ");
  2388. }.bind(this))
  2389. }
  2390. debugger;
  2391. if (this.layout_issuanceUnit && this.layout_issuanceDate ){
  2392. var table = this.layout_issuanceUnit.getParent("table")
  2393. if (table && !table.hasClass("doc_layout_headIssuance")){
  2394. var unitWidth = o2.getTextSize(this.layout_issuanceUnit.get("text"), {
  2395. "font-size":"16pt",
  2396. "font-family":"'Times New Roman',仿宋",
  2397. "letter-spacing": "-0.4pt"
  2398. }).x;
  2399. var dateWidth = o2.getTextSize(this.layout_issuanceDate.get("text"), {
  2400. "font-size":"16pt",
  2401. "font-family":"'Times New Roman',仿宋",
  2402. "letter-spacing": "-0.4pt"
  2403. }).x;
  2404. // var unitWidth = this.layout_issuanceUnit.getSize().x;
  2405. // var dateWidth = this.layout_issuanceDate.getSize().x;
  2406. if (unitWidth<dateWidth){
  2407. var flagTd = this.layout_issuanceUnit.getParent("td").getNext("td");
  2408. if (flagTd){
  2409. var pt = ((dateWidth-unitWidth)/96)*72 +32+32;
  2410. flagTd.setStyle("width", ""+pt+"pt");
  2411. }
  2412. table = this.layout_issuanceDate.getParent("table");
  2413. table.setStyle("width", "auto");
  2414. flagTd = this.layout_issuanceDate.getParent("td").getNext("td");
  2415. if (flagTd) flagTd.setStyle("width", "32pt");
  2416. var p = this.layout_issuanceDate.getParent("p");
  2417. if (p) p.setStyle("text-align", "right");
  2418. }else{
  2419. var flagTd = this.layout_issuanceUnit.getParent("td").getNext("td");
  2420. if (flagTd) flagTd.setStyle("width", "32pt");
  2421. var table = this.layout_issuanceUnit.getParent("table");
  2422. var x = table.getSize().x;
  2423. table = this.layout_issuanceDate.getParent("table");
  2424. table.setStyle("width", ""+x+"px");
  2425. flagTd = this.layout_issuanceDate.getParent("td").getNext("td");
  2426. if (flagTd) flagTd.setStyle("width", "32pt");
  2427. var p = this.layout_issuanceDate.getParent("p");
  2428. if (p) p.setStyle("text-align", "center");
  2429. }
  2430. }
  2431. }
  2432. var coptyToTitleNode = (this.layout_copytoTitle || this.layout_copyto2Title);
  2433. if (coptyToTitleNode){
  2434. var editionTable = coptyToTitleNode.getParent("table");
  2435. if (editionTable) if (editionTable.get("data-compute-style")=="y"){
  2436. var rows = editionTable.rows;
  2437. for (var i=0; i<rows.length; i++){
  2438. var cell = rows[i].cells[0];
  2439. var tmp = cell.getElement(".doc_layout_edition_issuance_unit");
  2440. if (!tmp) tmp = cell.getElement(".doc_layout_edition_issuance_date");
  2441. if (!tmp){
  2442. var text = cell.get("text").trim();
  2443. var l = 14*text.length;
  2444. var wl = 19*text.length;
  2445. cell.setStyles({
  2446. "max-width": ""+l+"pt !important",
  2447. "min-width": ""+l+"pt !important",
  2448. "width": ""+wl+"pt"
  2449. });
  2450. }
  2451. }
  2452. }
  2453. }
  2454. }
  2455. },
  2456. createErrorNode: function(text){
  2457. var node = new Element("div");
  2458. var iconNode = new Element("div", {
  2459. "styles": {
  2460. "width": "20px",
  2461. "height": "20px",
  2462. "float": "left",
  2463. "background": "url("+"../x_component_process_Xform/$Form/default/icon/error.png) center center no-repeat"
  2464. }
  2465. }).inject(node);
  2466. var textNode = new Element("div", {
  2467. "styles": {
  2468. "line-height": "20px",
  2469. "margin-left": "20px",
  2470. "color": "red",
  2471. "word-break": "keep-all"
  2472. },
  2473. "text": text
  2474. }).inject(node);
  2475. return node;
  2476. },
  2477. notValidationMode: function(text){
  2478. if (!this.isNotValidationMode){
  2479. this.isNotValidationMode = true;
  2480. this.node.store("borderStyle", this.node.getStyles("border-left", "border-right", "border-top", "border-bottom"));
  2481. this.node.setStyle("border", "1px solid red");
  2482. this.errNode = this.createErrorNode(text).inject(this.node, "after");
  2483. this.showNotValidationMode(this.node);
  2484. }
  2485. },
  2486. showNotValidationMode: function(node){
  2487. var p = node.getParent("div");
  2488. if (p){
  2489. if (p.get("MWFtype") == "tab$Content"){
  2490. if (p.getParent("div").getStyle("display")=="none"){
  2491. var contentAreaNode = p.getParent("div").getParent("div");
  2492. var tabAreaNode = contentAreaNode.getPrevious("div");
  2493. var idx = contentAreaNode.getChildren().indexOf(p.getParent("div"));
  2494. var tabNode = tabAreaNode.getLast().getFirst().getChildren()[idx];
  2495. tabNode.click();
  2496. p = tabAreaNode.getParent("div");
  2497. }
  2498. }
  2499. this.showNotValidationMode(p);
  2500. }
  2501. },
  2502. validationMode: function(){
  2503. if (this.isNotValidationMode){
  2504. this.isNotValidationMode = false;
  2505. this.node.setStyles(this.node.retrieve("borderStyle"));
  2506. if (this.errNode){
  2507. this.errNode.destroy();
  2508. this.errNode = null;
  2509. }
  2510. }
  2511. },
  2512. validationConfigItem: function(routeName, data){
  2513. var flag = (data.status=="all") ? true: (routeName == data.decision);
  2514. if (flag){
  2515. var n = this.getData();
  2516. var v = (data.valueType=="value") ? n : n.length;
  2517. switch (data.operateor){
  2518. case "isnull":
  2519. if (!v){
  2520. this.notValidationMode(data.prompt);
  2521. return false;
  2522. }
  2523. break;
  2524. case "notnull":
  2525. if (v){
  2526. this.notValidationMode(data.prompt);
  2527. return false;
  2528. }
  2529. break;
  2530. case "gt":
  2531. if (v>data.value){
  2532. this.notValidationMode(data.prompt);
  2533. return false;
  2534. }
  2535. break;
  2536. case "lt":
  2537. if (v<data.value){
  2538. this.notValidationMode(data.prompt);
  2539. return false;
  2540. }
  2541. break;
  2542. case "equal":
  2543. if (v==data.value){
  2544. this.notValidationMode(data.prompt);
  2545. return false;
  2546. }
  2547. break;
  2548. case "neq":
  2549. if (v!=data.value){
  2550. this.notValidationMode(data.prompt);
  2551. return false;
  2552. }
  2553. break;
  2554. case "contain":
  2555. if (v.indexOf(data.value)!=-1){
  2556. this.notValidationMode(data.prompt);
  2557. return false;
  2558. }
  2559. break;
  2560. case "notcontain":
  2561. if (v.indexOf(data.value)==-1){
  2562. this.notValidationMode(data.prompt);
  2563. return false;
  2564. }
  2565. break;
  2566. }
  2567. }
  2568. return true;
  2569. },
  2570. validationConfig: function(routeName, opinion){
  2571. if (this.json.validationConfig){
  2572. if (this.json.validationConfig.length){
  2573. for (var i=0; i<this.json.validationConfig.length; i++) {
  2574. var data = this.json.validationConfig[i];
  2575. if (!this.validationConfigItem(routeName, data)) return false;
  2576. }
  2577. }
  2578. return true;
  2579. }
  2580. return true;
  2581. },
  2582. validation: function(routeName, opinion){
  2583. if (!this.validationConfig(routeName, opinion)) return false;
  2584. if (!this.json.validation) return true;
  2585. if (!this.json.validation.code) return true;
  2586. this.currentRouteName = routeName;
  2587. var flag = this.form.Macro.exec(this.json.validation.code, this);
  2588. this.currentRouteName = "";
  2589. if (!flag) flag = MWF.xApplication.process.Xform.LP.notValidation;
  2590. if (flag.toString()!="true"){
  2591. this.notValidationMode(flag);
  2592. return false;
  2593. }
  2594. return true;
  2595. },
  2596. removeDisplayNone: function(node){
  2597. var n = node.getFirst();
  2598. while (n){
  2599. if (n.getStyle("display")=="none"){
  2600. var tmp = n.getNext();
  2601. n.destroy();
  2602. n = tmp;
  2603. }else{
  2604. n = this.removeDisplayNone(n);
  2605. n = n.getNext();
  2606. }
  2607. }
  2608. return node;
  2609. },
  2610. toWord: function(callback, name){
  2611. debugger;
  2612. var docNmae = name || "";
  2613. if (!docNmae){
  2614. try{
  2615. docNmae = this.json.toWordFilename || this.form.businessData.data.subject || this.form.businessData.data["$work"].title
  2616. }catch (e) {}
  2617. }
  2618. var toEdit = false;
  2619. if (this.editMode){
  2620. toEdit = true;
  2621. this._readFiletext();
  2622. }
  2623. //this._returnScale();
  2624. this.zoom(1);
  2625. this.pages = [];
  2626. this.contentNode.empty();
  2627. this._createPage(function(control){
  2628. this._loadPageLayout(control);
  2629. this.setData(this.data);
  2630. this._checkScale();
  2631. this.node.setStyles({
  2632. "height":"auto"
  2633. });
  2634. //var content = this.contentNode.getFirst().getFirst().get("html");
  2635. var tmpNode = this.contentNode.getFirst().getFirst().clone(true);
  2636. var htmlNode = tmpNode.getLast();
  2637. htmlNode = this.removeDisplayNone(htmlNode);
  2638. var content = "<html xmlns:v=\"urn:schemas-microsoft-com:vml\"><head><meta charset=\"UTF-8\" /></head><body>"+tmpNode.get("html")+"</body></html>";
  2639. var fileName = docNmae || this.json.toWordFilename || "$doc";
  2640. var n = fileName.lastIndexOf(".");
  2641. var ex = fileName.substring(n, fileName.length).toLowerCase();
  2642. if (ex!==".doc" && ex!==".docx") fileName = fileName+".doc";
  2643. var body = {
  2644. "fileName": fileName,
  2645. "site": this.json.toWordSite || "$doc",
  2646. "content": content
  2647. };
  2648. o2.Actions.get("x_processplatform_assemble_surface").docToWord(this.form.businessData.work.id, body, function(json){
  2649. if (this.form.businessData.workCompleted){
  2650. o2.Actions.get("x_processplatform_assemble_surface").getAttachmentWorkcompleted(json.data.id, this.form.businessData.workCompleted.id,function(attjson){
  2651. if (callback) callback(attjson.data);
  2652. this.showToWord(attjson.data);
  2653. }.bind(this));
  2654. }else{
  2655. o2.Actions.get("x_processplatform_assemble_surface").getAttachment(json.data.id, this.form.businessData.work.id,function(attjson){
  2656. if (callback) callback(attjson.data);
  2657. this.showToWord(attjson.data);
  2658. }.bind(this));
  2659. }
  2660. }.bind(this));
  2661. tmpNode.destroy();
  2662. if (!toEdit){
  2663. this._readFiletext();
  2664. }else{
  2665. this._createEditor("inline");
  2666. }
  2667. }.bind(this));
  2668. },
  2669. docToWord: function(){
  2670. var flag = true;
  2671. if (this.json.toWordConditionScript && this.json.toWordConditionScript.code){
  2672. flag = !!this.form.Macro.exec(this.json.toWordConditionScript.code, this);
  2673. }
  2674. if (flag){
  2675. this.toWord();
  2676. }
  2677. },
  2678. showToWord: function(att_word){
  2679. var site = this.json.toWordSite || "$doc";
  2680. var attModule = this.form.all[site];
  2681. if (attModule){
  2682. var atts = [];
  2683. attModule.attachmentController.attachments.each(function(att){
  2684. if (att.data.name!==att_word.name){
  2685. atts.push(att.data)
  2686. }
  2687. }.bind(this));
  2688. attModule.attachmentController.clear();
  2689. atts.each(function (att) {
  2690. //if (att.site===this.json.id || (this.json.isOpenInOffice && this.json.officeControlName===att.site)) this.attachmentController.addAttachment(att);
  2691. if ((att.site === attModule.json.id) && att.name!==att_word.name) attModule.attachmentController.addAttachment(att);
  2692. }.bind(this));
  2693. // attModule.attachmentController.reloadAttachments();
  2694. attModule.attachmentController.addAttachment(att_word);
  2695. }
  2696. }
  2697. });