Property.js 173 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801
  1. MWF.require("MWF.widget.Common", null, false);
  2. MWF.require("MWF.widget.JsonTemplate", null, false);
  3. MWF.xApplication.process.FormDesigner.Property = MWF.FCProperty = new Class({
  4. Extends: MWF.widget.Common,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "path": "../x_component_process_FormDesigner/property/property.html"
  9. },
  10. initialize: function(module, propertyNode, designer, options){
  11. this.setOptions(options);
  12. this.module = module;
  13. this.form = module.form;
  14. this.data = module.json;
  15. // this.data.pid = this.form.options.mode+this.form.json.id+this.data.id;
  16. this.data.pid = this.getPid();
  17. this.htmlPath = this.options.path;
  18. this.designer = designer;
  19. this.maplists = {};
  20. this.propertyNode = propertyNode;
  21. },
  22. getPid: function(){
  23. if( !this.form.pidList )this.form.pidList = [];
  24. var id = this.form.options.mode + this.data.id;
  25. var idx = 0;
  26. while ( this.form.pidList.contains( id ) ){
  27. idx++;
  28. id = id+"_"+idx;
  29. }
  30. this.form.pidList.push( id );
  31. var suffix = idx ? ( "_"+idx ) : "";
  32. return this.form.options.mode + this.form.json.id + this.data.id + suffix;
  33. },
  34. load: function(){
  35. if (this.fireEvent("queryLoad")){
  36. MWF.getRequestText(this.htmlPath, function(responseText, responseXML){
  37. this.htmlString = responseText;
  38. this.fireEvent("postLoad");
  39. }.bind(this));
  40. }
  41. this.propertyNode.addEvent("keydown", function(e){e.stopPropagation();});
  42. },
  43. reset: function(){
  44. this.propertyTabIndex = 0;
  45. if(this.propertyContent){
  46. var isShow = this.propertyContent.offsetParent !== null;
  47. if( isShow && this.propertyTab && this.propertyTab.pages){
  48. var tab = this.propertyTab;
  49. var showPage = tab.showPage || tab.pages[0];
  50. if( showPage ){
  51. this.propertyTabIndex = tab.pages.indexOf( showPage );
  52. this.propertyTabScrollY = showPage.contentScrollNode.getScroll().y;
  53. }
  54. }
  55. this.propertyContent.destroy();
  56. this.propertyContent = null;
  57. if( isShow ){
  58. this.show();
  59. }
  60. }
  61. },
  62. editProperty: function(td){
  63. },
  64. getHtmlString: function(callback){
  65. if (!this.htmlString){
  66. MWF.getRequestText(this.htmlPath, function(responseText, responseXML){
  67. this.htmlString = responseText;
  68. if (callback) callback();
  69. }.bind(this));
  70. }else{
  71. if (callback) callback();
  72. }
  73. },
  74. show: function(){
  75. if (!this.propertyContent){
  76. this.ignoreSection = false;
  77. this.getHtmlString(function(){
  78. if (this.htmlString) {
  79. var lp;
  80. if (this.options.appType === "cms") {
  81. this.appType = "cms";
  82. lp = MWF.xApplication.cms.FormDesigner.LP.propertyTemplate;
  83. this.ignoreSection = true;
  84. } else if (this.designer && this.designer.options && this.designer.options.name && this.designer.options.name.indexOf("cms") === 0) {
  85. this.appType = "cms";
  86. lp = MWF.xApplication.cms.FormDesigner.LP.propertyTemplate;
  87. this.ignoreSection = true;
  88. } else {
  89. lp = MWF.xApplication.process.FormDesigner.LP.propertyTemplate;
  90. if( this.module && this.module.node ) {
  91. var parentNode = this.module.node.getParent("div[mwftype='datatable'],div[mwftype='datatemplate']");
  92. this.ignoreSection = !!parentNode;
  93. }
  94. }
  95. this.htmlString = o2.bindJson(this.htmlString, {"lp": lp});
  96. // this.htmlString = o2.bindJson(this.htmlString, {"lp": MWF.xApplication.process.FormDesigner.LP.propertyTemplate});
  97. this.JsonTemplate = new MWF.widget.JsonTemplate(this.data, this.htmlString);
  98. this.propertyContent = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.propertyNode);
  99. // var htmlStr = this.JsonTemplate.load();
  100. // this.propertyContent.injectHtml(htmlStr, {"bind": {"lp": MWF.xApplication.process.FormDesigner.LP.propertyTemplate}});
  101. this.propertyContent.set("html", this.JsonTemplate.load());
  102. this.loadingCount = 0;
  103. this.loadedCount = 0;
  104. this.ready = false;
  105. if (this.module.hasOwnProperty("isPropertyLoaded")) { //ElementUI需要判断isPropertyLoaded为true的时候才会setEditStyle
  106. this.module.isPropertyLoaded = false;
  107. }
  108. this.setEditNodeEvent();
  109. this.setEditNodeStyles(this.propertyContent);
  110. this.loadPropertyTab();
  111. this.loadMaplist();
  112. this.loadStylesList();
  113. this.loadDivTemplateType();
  114. this.loadPersonInput();
  115. this.loadFormFieldInput();
  116. this.loadScriptArea();
  117. this.loadScriptListArea();
  118. this.loadCssArea();
  119. this.loadHtmlEditorArea();
  120. this.loadTreeData();
  121. this.loadArrayList();
  122. this.loadEventsEditor();
  123. this.loadActionArea();
  124. this.loadActionStylesArea();
  125. this.loadHTMLArea();
  126. this.loadJSONArea();
  127. this.loadFormSelect();
  128. this.loadSubformSelect();
  129. this.loadComponentSelect();
  130. //this.loadPageSelect();
  131. this.loadWidgetSelect();
  132. this.loadANNModelSelect();
  133. //this.loadViewSelect();
  134. this.loadValidation();
  135. this.loadIconSelect();
  136. this.loadLabelFlagSelect();
  137. this.loadImageClipper();
  138. this.loadImageFileSelect();
  139. this.loadParameterEditor();
  140. this.loadContextRoot();
  141. this.loadUnitTypeSelector();
  142. this.loadSourceTestRestful();
  143. this.loadSidebarPosition();
  144. this.loadViewFilter();
  145. this.loadViewFilterWithTemplate();
  146. this.loadStatementFilter();
  147. this.loadStatementFilterWithTemplate();
  148. this.loadDocumentTempleteSelect();
  149. this.loadFieldConfig();
  150. this.loadElSelectIcon();
  151. this.loadVueElementUI();
  152. this.loadElCommonPreview();
  153. this.loadElTreeData();
  154. this.loadElTDropDownData();
  155. this.loadElCarouselContent();
  156. if ( !this.ignoreSection ){
  157. this.loadSectionMerger();
  158. this.loadSectionDisplayer();
  159. }
  160. this.loadSmartBISelect();
  161. this.loadDictionaryItem();
  162. this.loadQueryViewItem();
  163. this.loadQueryStatementItem();
  164. this.loadHelp();
  165. this.ready = true;
  166. if( this.postShow )this.postShow();
  167. this.checkLoaded( true );
  168. // this.loadScriptIncluder();
  169. // this.loadDictionaryIncluder();
  170. //this.testRestful();
  171. // this.loadScriptInput();
  172. //MWF.process.widget.EventsEditor
  173. }
  174. }.bind(this));
  175. }else{
  176. this.propertyContent.setStyle("display", "block");
  177. this.fireEvent("postShow");
  178. }
  179. (new Fx.Scroll(layout.desktop.node)).toTop();
  180. },
  181. isLoaded: function(){
  182. return this.ready && this.loadingCount === this.loadedCount;
  183. },
  184. checkLoaded: function( flag ){
  185. if(!flag)this.loadedCount++;
  186. debugger;
  187. if( this.ready && this.loadingCount === this.loadedCount ){
  188. if(this.module.hasOwnProperty("isPropertyLoaded"))this.module.isPropertyLoaded = true;
  189. if( this.propertyTabScrollY && this.propertyTab && this.propertyTab.pages ){
  190. var tab = this.propertyTab;
  191. var showPage = tab.showPage || tab.pages[0];
  192. if( showPage ){
  193. showPage.contentScrollNode.scrollTo(0, this.propertyTabScrollY);
  194. this.propertyTabScrollY = null;
  195. }
  196. }
  197. this.fireEvent("postShow");
  198. }
  199. },
  200. hide: function(){
  201. //this.JsonTemplate = null;
  202. //this.propertyNode.set("html", "");
  203. if (this.propertyContent) this.propertyContent.setStyle("display", "none");
  204. },
  205. destroy: function(){
  206. if (this.propertyContent){
  207. this.propertyContent.destroy();
  208. }
  209. MWF.release(this);
  210. },
  211. loadElTreeData: function(){
  212. var arrays = this.propertyContent.getElements(".MWFElTreeData");
  213. arrays.each(function(node){
  214. this.loadingCount++;
  215. var title = node.get("title");
  216. var name = node.get("name");
  217. var json = this.data[name];
  218. if (!json) json = [];
  219. var oldValue = Array.clone(json);
  220. MWF.requireApp("process.FormDesigner", "widget.ElTreeEditor", function(){
  221. var treeEditor = new MWF.xApplication.process.FormDesigner.widget.ElTreeEditor(node, {
  222. "title": title,
  223. "maxObj": this.designer.formContentNode || this.designer.pageContentNode,
  224. "onChange": function(historyOptions){
  225. // this.data[name] = Object.assign(this.data[name], treeEditor.toJson());
  226. // this.data[name] = treeEditor.toJson();
  227. // this.module.json[name] = this.data[name];
  228. //
  229. historyOptions = historyOptions || {};
  230. this.checkHistory(name, oldValue, json, false, name + historyOptions.compareName, historyOptions.force);
  231. oldValue = Array.clone(json);
  232. this.module._refreshTree();
  233. }.bind(this)
  234. });
  235. treeEditor.load(json);
  236. this.checkLoaded();
  237. }.bind(this));
  238. node.addEvent("keydown", function(e){e.stopPropagation();});
  239. }.bind(this));
  240. },
  241. loadElTDropDownData: function(){
  242. var arrays = this.propertyContent.getElements(".MWFElTDropdownData");
  243. arrays.each(function(node){
  244. var title = node.get("title");
  245. var name = node.get("name");
  246. var json = this.data[name];
  247. if (!json) json = [];
  248. var oldValue = Array.clone(json);
  249. this.loadingCount++;
  250. MWF.requireApp("process.FormDesigner", "widget.ElDropdownItemEditor", function(){
  251. var treeEditor = new MWF.xApplication.process.FormDesigner.widget.ElDropdownItemEditor(node, {
  252. "title": title,
  253. "maxObj": this.designer.formContentNode || this.designer.pageContentNode,
  254. "onChange": function(historyOptions){
  255. historyOptions = historyOptions || {};
  256. this.checkHistory(name, oldValue, json, false, name + historyOptions.compareName, historyOptions.force);
  257. oldValue = Array.clone(json);
  258. }.bind(this)
  259. });
  260. treeEditor.load(json);
  261. this.checkLoaded();
  262. }.bind(this));
  263. node.addEvent("keydown", function(e){e.stopPropagation();});
  264. }.bind(this));
  265. },
  266. loadElCarouselContent: function(){
  267. var arrays = this.propertyContent.getElements(".MWFElCarouselContent");
  268. arrays.each(function(node){
  269. var title = node.get("title");
  270. var name = node.get("name");
  271. var json = this.data[name];
  272. if (!json) json = [];
  273. var oldValue = Array.clone(json);
  274. this.loadingCount++;
  275. MWF.requireApp("process.FormDesigner", "widget.ElCarouselContent", function(){
  276. var treeEditor = new MWF.xApplication.process.FormDesigner.widget.ElCarouselContent(node, {
  277. "title": title,
  278. "maxObj": this.designer.formContentNode || this.designer.pageContentNode,
  279. "onChange": function( historyOptions ){
  280. historyOptions = historyOptions || {};
  281. this.checkHistory(name, oldValue, json, false, name + historyOptions.compareName, historyOptions.force);
  282. oldValue = Array.clone(json);
  283. }.bind(this)
  284. });
  285. treeEditor.load(json);
  286. this.checkLoaded();
  287. }.bind(this));
  288. node.addEvent("keydown", function(e){e.stopPropagation();});
  289. }.bind(this));
  290. },
  291. loadTreeData: function(){
  292. var arrays = this.propertyContent.getElements(".MWFTreeData");
  293. arrays.each(function(node){
  294. var title = node.get("title");
  295. var name = node.get("name");
  296. var json = this.data[name];
  297. if (!json) json = [];
  298. this.loadingCount++;
  299. MWF.require("MWF.widget.TreeEditor", function(){
  300. var oldValue = Array.clone(this.data[name] || []);
  301. var treeEditor = new MWF.widget.TreeEditor(node, {
  302. "title": title,
  303. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  304. "onChange": function( historyOptions ){
  305. historyOptions = historyOptions || {};
  306. this.data[name] = treeEditor.toJson();
  307. this.module.json[name] = this.data[name];
  308. this.checkHistory(name, oldValue, this.data[name], false, name + historyOptions.compareName, historyOptions.force);
  309. this.module._refreshTree();
  310. oldValue = this.data[name];
  311. }.bind(this)
  312. // "onChange": function(){
  313. // var oldValue = this.data[name];
  314. // this.data[name] = treeEditor.toJson();
  315. // this.module.json[name] = this.data[name];
  316. // this.checkHistory(name, oldValue, this.data[name]);
  317. // this.module._refreshTree();
  318. // }.bind(this)
  319. });
  320. treeEditor.load(json);
  321. this.checkLoaded();
  322. }.bind(this));
  323. node.addEvent("keydown", function(e){e.stopPropagation();});
  324. }.bind(this));
  325. },
  326. loadSectionMerger: function(){
  327. var arrays = this.propertyContent.getElements(".MWFSectionMergeArea");
  328. arrays.each(function(node){
  329. // var title = node.get("title");
  330. // var name = node.get("name");
  331. // var json = this.data[name];
  332. // if (!json) json = {};
  333. this.loadingCount++;
  334. MWF.requireApp("process.FormDesigner", "widget.SectionMerger", function(){
  335. var merger = new MWF.xApplication.process.FormDesigner.widget.SectionMerger(node, this, {
  336. // "title": title,
  337. "maxObj": this.designer.formContentNode || this.designer.pageContentNode,
  338. "onChange": function(){
  339. }.bind(this),
  340. "onPostLoad": function () {
  341. this.checkLoaded();
  342. }.bind(this)
  343. });
  344. merger.load(this.data);
  345. }.bind(this));
  346. node.addEvent("keydown", function(e){e.stopPropagation();});
  347. }.bind(this));
  348. },
  349. loadSectionDisplayer: function(){
  350. var arrays = this.propertyContent.getElements(".MWFSectionDisplayerArea");
  351. arrays.each(function(node){
  352. this.loadingCount++;
  353. MWF.requireApp("process.FormDesigner", "widget.SectionDisplayer", function(){
  354. var merger = new MWF.xApplication.process.FormDesigner.widget.SectionDisplayer(node, this, {
  355. // "title": title,
  356. "maxObj": this.designer.formContentNode || this.designer.pageContentNode,
  357. "onChange": function(){
  358. }.bind(this),
  359. "onPostLoad": function () {
  360. this.checkLoaded();
  361. }.bind(this)
  362. });
  363. merger.load(this.data);
  364. }.bind(this));
  365. node.addEvent("keydown", function(e){e.stopPropagation();});
  366. }.bind(this));
  367. },
  368. loadJSONArea: function(){
  369. var jsonNode = this.propertyContent.getElement(".MWFJSONArea");
  370. if (jsonNode){
  371. this.propertyTab.pages.each(function(page){
  372. if (page.contentNode === jsonNode.parentElement){
  373. page.setOptions({
  374. "onShow": function(){
  375. jsonNode.empty();
  376. MWF.require("MWF.widget.JsonParse", function(){
  377. this.json = new MWF.widget.JsonParse(this.module.json, jsonNode, null);
  378. this.json.load();
  379. }.bind(this));
  380. }.bind(this)
  381. });
  382. }
  383. }.bind(this));
  384. }
  385. },
  386. loadHTMLArea: function(){
  387. var htmlNode = this.propertyContent.getElement(".MWFHTMLArea");
  388. if (htmlNode){
  389. var copy = this.module.node.clone(true, true);
  390. copy.clearStyles(true);
  391. htmlNode.set("text", copy.outerHTML);
  392. copy.destroy();
  393. this.propertyTab.pages.each(function(page){
  394. if (page.contentNode == htmlNode.parentElement){
  395. page.setOptions({
  396. "onShow": function(){
  397. var copy = this.module.node.clone(true, true);
  398. copy.clearStyles(true);
  399. //MWF.require("MWF.widget.HtmlEditor", function(){
  400. // debugger;
  401. // var editor = new MWF.widget.HtmlEditor(htmlNode);
  402. // editor.load(function(){
  403. // editor.editor.setValue(copy.outerHTML)
  404. // }.bind(this));
  405. //}.bind(this));
  406. o2.load("JSBeautifier_html", function(){
  407. htmlNode.set("text", html_beautify(copy.outerHTML, {"indent_size":1}));
  408. o2.require("o2.widget.ace", function(){
  409. MWF.widget.ace.load(function(){
  410. o2.load("../o2_lib/ace/src-min-noconflict/ext-static_highlight.js", function(){
  411. var highlight = ace.require("ace/ext/static_highlight");
  412. highlight(htmlNode, {mode: "ace/mode/html", theme: "ace/theme/eclipse", "fontSize": 16});
  413. }.bind(this));
  414. }.bind(this));
  415. }.bind(this));
  416. copy.destroy();
  417. }.bind(this));
  418. }.bind(this)
  419. });
  420. }
  421. }.bind(this));
  422. }
  423. },
  424. loadSidebarPosition: function(){
  425. var nodes = this.propertyContent.getElements(".MWFSidebarReposition");
  426. if (nodes.length){
  427. nodes.each(function(node){
  428. node.addEvent("click", function(){
  429. this.module.json.styles.top = "";
  430. this.module.loadPosition();
  431. }.bind(this));
  432. }.bind(this));
  433. }
  434. },
  435. loadANNModelSelect: function(){
  436. var nodes = this.propertyContent.getElements(".MWFANNModelSelect");
  437. if (nodes.length){
  438. this.getModelList(function(){
  439. nodes.each(function(node){
  440. var select = new Element("select").inject(node);
  441. select.addEvent("change", function(e){
  442. this.setValue(e.target.getParent("div").get("name"), e.target.options[e.target.selectedIndex].value, select);
  443. }.bind(this));
  444. this.setModelSelectOptions(node, select);
  445. var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
  446. refreshNode.addEvent("click", function(e){
  447. this.getModelList(function(){
  448. this.setModelSelectOptions(node, select);
  449. }.bind(this), true);
  450. }.bind(this));
  451. }.bind(this));
  452. }.bind(this));
  453. }
  454. },
  455. getModelList: function(callback, refresh){
  456. if (!this.models || refresh){
  457. var action = o2.Actions.get("x_query_assemble_designer");
  458. if (action.listModel) action.listModel(function(json){
  459. this.models = json.data;
  460. if (callback) callback();
  461. }.bind(this));
  462. }else{
  463. if (callback) callback();
  464. }
  465. },
  466. setModelSelectOptions: function(node, select){
  467. var name = node.get("name");
  468. select.empty();
  469. var option = new Element("option", {"text": "none"}).inject(select);
  470. this.models.each(function(model){
  471. var option = new Element("option", {
  472. "text": model.name,
  473. "value": model.id,
  474. "selected": (this.data[name]==model.id)
  475. }).inject(select);
  476. }.bind(this));
  477. },
  478. loadFormSelect: function(){
  479. var formNodes = this.propertyContent.getElements(".MWFFormSelect");
  480. if (formNodes.length){
  481. this.loadingCount++;
  482. this.getFormList(function(){
  483. formNodes.each(function(node){
  484. var select = new Element("select").inject(node);
  485. select.addEvent("change", function(e){
  486. var value = e.target.options[e.target.selectedIndex].value;
  487. this.setValue(e.target.getParent("div").get("name"), value, select);
  488. }.bind(this));
  489. this.setFormSelectOptions(node, select);
  490. var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
  491. refreshNode.addEvent("click", function(e){
  492. this.getFormList(function(){
  493. this.setFormSelectOptions(node, select);
  494. }.bind(this), true);
  495. }.bind(this));
  496. var openNode = new Element("div", {"styles": this.form.css.propertyOpenFormNode}).inject(node);
  497. openNode.addEvent("click", function(e){
  498. var name = node.get("name");
  499. this._openForm( this.data[name] );
  500. }.bind(this));
  501. //select.addEvent("click", function(e){
  502. // this.setFormSelectOptions(node, select);
  503. //}.bind(this));
  504. }.bind(this));
  505. this.checkLoaded();
  506. }.bind(this));
  507. }
  508. },
  509. setFormSelectOptions: function(node, select){
  510. var name = node.get("name");
  511. select.empty();
  512. var option = new Element("option", {"text": "none"}).inject(select);
  513. this.forms.each(function(form){
  514. if( this.form.json.id !== form.id ){
  515. var option = new Element("option", {
  516. "text": form.name,
  517. "value": form.id,
  518. "selected": (this.data[name]==form.id)
  519. }).inject(select);
  520. }
  521. }.bind(this));
  522. },
  523. getFormList: function(callback, refresh){
  524. if (!this.forms || refresh){
  525. this.form.designer.actions.listForm(this.form.designer.application.id, function(json){
  526. this.forms = json.data;
  527. if (callback) callback();
  528. }.bind(this));
  529. }else{
  530. if (callback) callback();
  531. }
  532. },
  533. loadComponentSelect: function(){
  534. var componentSlectNodes = this.propertyContent.getElements(".MWFComponentSelect");
  535. if (componentSlectNodes.length){
  536. componentSlectNodes.each( function( node ){
  537. var name = node.get("name");
  538. var select;
  539. this.getComponentList(function(){
  540. select = new Element("select").inject(node);
  541. select.addEvent("change", function(e){
  542. var value = select.options[select.selectedIndex].value;
  543. this.setValue(name, value, select);
  544. }.bind(this));
  545. this.setComponentSelectOptions(node, select);
  546. var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
  547. refreshNode.addEvent("click", function(e){
  548. this.getComponentList(function(){
  549. this.setComponentSelectOptions(node, select);
  550. }.bind(this), true);
  551. }.bind(this));
  552. }.bind(this), false );
  553. return select;
  554. }.bind(this))
  555. }
  556. },
  557. setComponentSelectOptions: function(node, select){
  558. var name = node.get("name");
  559. var value = this.data[name] || "";
  560. select.empty();
  561. var option = new Element("option", {"text": "none"}).inject(select);
  562. this.components.each(function(component){
  563. var option = new Element("option", {
  564. "text": component.title,
  565. "value": component.path,
  566. "selected": (this.data[name]==component.path)
  567. }).inject(select);
  568. }.bind(this));
  569. },
  570. getComponentList: function(callback, refresh){
  571. if (!this.components || refresh){
  572. o2.Actions.load("x_component_assemble_control").ComponentAction.listAll( function(json){
  573. this.components = json.data;
  574. if (callback) callback();
  575. }.bind(this), null, false);
  576. }else{
  577. if (callback) callback();
  578. }
  579. },
  580. loadSubformSelect: function(){
  581. var subformContainers = this.propertyContent.getElements(".MWFSubFormSelectContainer");
  582. if (subformContainers.length){
  583. subformContainers.each( function( container ){
  584. var appSelectNode = container.getElement(".MWFSubformAppSelect");
  585. var formSelectNode = container.getElement(".MWFSubformSelect");
  586. var formSelect;
  587. var appNodeName = appSelectNode.get("name");
  588. var formNodeName = formSelectNode.get("name");
  589. this.loadProcessApplictionSelect( appSelectNode, appNodeName, function( apps ){
  590. var oldValue = this.data[appNodeName] || "";
  591. this.data[appNodeName] = !apps.length ? "" : apps[0].data.id;
  592. if( oldValue !== this.data[appNodeName] ){
  593. this.getSubFormList(function(){
  594. this.setSubformSelectOptions(formSelectNode, formSelect);
  595. formSelect.fireEvent("change", [null, {
  596. name: appNodeName,
  597. fromValue: oldValue,
  598. toValue: this.data[appNodeName]
  599. }]);
  600. }.bind(this), true, appNodeName);
  601. }
  602. }.bind(this));
  603. formSelect = this._loadSubformSelect( formSelectNode, formNodeName, appNodeName ) ;
  604. }.bind(this))
  605. }
  606. },
  607. loadProcessApplictionSelect : function( node, appNodeName, callback ){
  608. var application = appNodeName ? this.data[appNodeName] : "";
  609. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function() {
  610. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  611. "title" : this.form.designer.lp.selectApplication,
  612. "type": "application",
  613. "count" : 1,
  614. "names": application ? [ {id : application} ] : [],
  615. "onChange": function (apps) {
  616. callback(apps)
  617. }.bind(this)
  618. });
  619. }.bind(this))
  620. },
  621. _loadSubformSelect : function( node, formNodeName, appNodeName ){
  622. this.subforms = null;
  623. var select = new Element("select").inject(node);
  624. var oldValue = this.data[formNodeName];
  625. this.getSubFormList(function(){
  626. select.addEvent("change", function(e, appChange){
  627. var value = select.options[select.selectedIndex].value;
  628. if( appChange ){
  629. this.setValue(formNodeName, value, select, true);
  630. this.checkHistory([appChange.name, formNodeName], [appChange.fromValue, oldValue], [appChange.toValue, value] )
  631. }else{
  632. this.setValue(formNodeName, value, select);
  633. }
  634. oldValue = value;
  635. }.bind(this));
  636. this.setSubformSelectOptions(node, select);
  637. var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
  638. refreshNode.addEvent("click", function(e){
  639. this.getSubFormList(function(){
  640. this.setSubformSelectOptions(node, select);
  641. }.bind(this), true, appNodeName);
  642. }.bind(this));
  643. var openNode = new Element("div", {"styles": this.form.css.propertyOpenFormNode}).inject(node);
  644. openNode.addEvent("click", function(e){
  645. var name = node.get("name");
  646. this._openForm( this.data[name] );
  647. }.bind(this));
  648. }.bind(this), false, appNodeName );
  649. return select;
  650. },
  651. setSubformSelectOptions: function(node, select){
  652. var name = node.get("name");
  653. select.empty();
  654. var option = new Element("option", {"text": "none"}).inject(select);
  655. this.subforms.each(function(subforms){
  656. if( this.form.json.id !== subforms.id ){
  657. var option = new Element("option", {
  658. "text": subforms.name,
  659. "value": subforms.id,
  660. "selected": (this.data[name]==subforms.id)
  661. }).inject(select);
  662. }
  663. }.bind(this));
  664. },
  665. getSubFormList: function(callback, refresh, appNodeName){
  666. var application = appNodeName ? this.data[appNodeName] : "";
  667. if (!this.subforms || refresh){
  668. this.form.designer.actions.listForm( application || this.form.designer.application.id, function(json){
  669. this.subforms = json.data;
  670. if (callback) callback();
  671. }.bind(this));
  672. }else{
  673. if (callback) callback();
  674. }
  675. },
  676. _openForm: function( formId ){
  677. var pre = this.appType === "cms" ? "cms" : "process";
  678. if( formId && formId !== "none" ){
  679. this.form.designer.actions.getForm(formId, function(json){
  680. var options = {
  681. "style": layout.desktop.formDesignerStyle || "default",
  682. "appId": pre+".FormDesigner"+formId,
  683. "id": formId
  684. };
  685. layout.openApplication(null, pre+".FormDesigner", options);
  686. }.bind(this), function () {
  687. return true;
  688. })
  689. }
  690. },
  691. loadPageSelect: function(){
  692. var pageNodes = this.propertyContent.getElements(".MWFPageSelect");
  693. if (pageNodes.length){
  694. this.getPageList(function(){
  695. pageNodes.each(function(node){
  696. var select = new Element("select").inject(node);
  697. select.addEvent("change", function(e){
  698. var value = e.target.options[e.target.selectedIndex].value;
  699. this.setValue(e.target.getParent("div").get("name"), value, select);
  700. }.bind(this));
  701. this.setPageSelectOptions(node, select);
  702. var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
  703. refreshNode.addEvent("click", function(e){
  704. this.getPageList(function(){
  705. this.setPageSelectOptions(node, select);
  706. }.bind(this), true);
  707. }.bind(this));
  708. }.bind(this));
  709. }.bind(this));
  710. }
  711. },
  712. setPageSelectOptions: function(node, select){
  713. var name = node.get("name");
  714. select.empty();
  715. var option = new Element("option", {"text": "none"}).inject(select);
  716. this.pages.each(function(page){
  717. if( this.form.json.id !== page.id ){
  718. var option = new Element("option", {
  719. "text": page.name,
  720. "value": page.id,
  721. "selected": (this.data[name]==page.id)
  722. }).inject(select);
  723. }
  724. }.bind(this));
  725. },
  726. getPageList: function(callback, refresh){
  727. if (!this.pages || refresh){
  728. this.form.designer.actions.listPage(this.form.designer.application.id, function(json){
  729. this.pages = json.data;
  730. if (callback) callback();
  731. }.bind(this));
  732. }else{
  733. if (callback) callback();
  734. }
  735. },
  736. loadWidgetSelect: function(){
  737. var wdigetContainers = this.propertyContent.getElements(".MWFWidgetSelectContainer");
  738. if (wdigetContainers.length){
  739. wdigetContainers.each( function( container ){
  740. var appSelectNode = container.getElement(".MWFWidgetAppSelect");
  741. var widgetSelectNode = container.getElement(".MWFWidgetSelect");
  742. var widgetSelect;
  743. var appNodeName = appSelectNode.get("name");
  744. var widgetNodeName = widgetSelectNode.get("name");
  745. this.loadPortalApplictionSelect( appSelectNode, appNodeName, function( apps ){
  746. var oldValue = this.data[appNodeName] || "";
  747. this.data[appNodeName] = !apps.length ? "" : apps[0].data.id;
  748. if( oldValue !== this.data[appNodeName] ){
  749. this.getWidgetList(function(){
  750. this.setWidgetSelectOptions(widgetSelectNode, widgetSelect);
  751. widgetSelect.fireEvent("change", [null, {
  752. name: appNodeName,
  753. fromValue: oldValue,
  754. toValue: this.data[appNodeName]
  755. }]);
  756. }.bind(this), true, appNodeName);
  757. }
  758. }.bind(this));
  759. widgetSelect = this._loadWidgetSelect( widgetSelectNode, widgetNodeName, appNodeName ) ;
  760. }.bind(this));
  761. }
  762. },
  763. loadPortalApplictionSelect : function( node, appNodeName, callback ){
  764. var application = appNodeName ? this.data[appNodeName] : "";
  765. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function() {
  766. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  767. "title" : this.form.designer.lp.selectApplication,
  768. "type": "portal",
  769. "count" : 1,
  770. "names": application ? [ {id : application} ] : [],
  771. "onChange": function (apps) {
  772. callback(apps)
  773. }.bind(this)
  774. });
  775. }.bind(this))
  776. },
  777. _loadWidgetSelect : function( node, widgetNodeName, appNodeName ){
  778. this.widgets = null;
  779. var select = new Element("select").inject(node);
  780. var oldValue = this.data[widgetNodeName];
  781. this.getWidgetList(function(){
  782. select.addEvent("change", function(e, appChange){
  783. var value = select.options[select.selectedIndex].value;
  784. if( appChange ){
  785. this.setValue(widgetNodeName, value, select, true);
  786. this.checkHistory([appChange.name, widgetNodeName], [appChange.fromValue, oldValue], [appChange.toValue, value] )
  787. }else{
  788. this.setValue(widgetNodeName, value, select);
  789. }
  790. oldValue = value;
  791. }.bind(this));
  792. this.setWidgetSelectOptions(node, select);
  793. var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
  794. refreshNode.addEvent("click", function(e){
  795. this.getWidgetList(function(){
  796. this.setWidgetSelectOptions(node, select);
  797. }.bind(this), true, appNodeName);
  798. }.bind(this));
  799. var openNode = new Element("div", {"styles": this.form.css.propertyOpenFormNode}).inject(node);
  800. openNode.addEvent("click", function(e){
  801. var name = node.get("name");
  802. var widgetId = this.data[name];
  803. if( widgetId && widgetId !== "none" ){
  804. this.form.designer.actions.getWidget(widgetId, function(json){
  805. var options = {
  806. "appId": "portal.WidgetDesigner"+widgetId,
  807. "id": widgetId
  808. };
  809. layout.openApplication(null, "portal.WidgetDesigner", options);
  810. }.bind(this), function () {
  811. return true;
  812. })
  813. }
  814. }.bind(this));
  815. }.bind(this), false, appNodeName );
  816. return select;
  817. },
  818. setWidgetSelectOptions: function(node, select){
  819. var name = node.get("name");
  820. select.empty();
  821. var option = new Element("option", {"text": "none"}).inject(select);
  822. this.widgets.each(function(widget){
  823. if( this.form.json.id !== widget.id ){
  824. var option = new Element("option", {
  825. "text": widget.name,
  826. "value": widget.id,
  827. "selected": (this.data[name]==widget.id)
  828. }).inject(select);
  829. }
  830. }.bind(this));
  831. },
  832. getWidgetList: function(callback, refresh, appNodeName){
  833. var application = appNodeName ? this.data[appNodeName] : "";
  834. if (!this.widgets || refresh){
  835. this.form.designer.actions.listWidget(application || this.form.designer.application.id, function(json){
  836. this.widgets = json.data;
  837. if (callback) callback();
  838. }.bind(this));
  839. }else{
  840. if (callback) callback();
  841. }
  842. },
  843. // clearStyles: function(node){
  844. // node.removeProperty("style");
  845. // var subNode = node.getFirst();
  846. // while (subNode){
  847. // this.clearStyles(subNode);
  848. // subNode = subNode.getNext();
  849. // }
  850. // },
  851. loadDocumentTempleteSelect: function(){
  852. var nodes = this.propertyContent.getElements(".MWFDocumentTempleteSelect");
  853. if (nodes.length){
  854. o2.getJSON("../x_component_process_FormDesigner/Module/Documenteditor/templete/templete.json", function(json){
  855. nodes.each(function(node){
  856. var name = node.get("name");
  857. Object.each(json, function(o, k){
  858. new Element("option", {
  859. "text": o.name,
  860. "value": k,
  861. "selected": (this.data[name]==k)
  862. }).inject(node);
  863. }.bind(this));
  864. var oldValue = this.data[name];
  865. node.addEvent("change", function(e){
  866. var value = e.target.options[e.target.selectedIndex].value;
  867. var name1 = e.target.options[e.target.selectedIndex].get("text");
  868. this.changeJsonDate([name1], value);
  869. this.changeData(name1, node, oldValue);
  870. this.checkHistory([name, name1], [oldValue, oldValue], [value, value])
  871. oldValue = this.data[name];
  872. }.bind(this));
  873. }.bind(this));
  874. }.bind(this));
  875. }
  876. },
  877. loadStatementFilter: function(){
  878. var nodes = this.propertyContent.getElements(".MWFStatementFilter");
  879. var filtrData = this.data.filterList;
  880. var parameterData = this.data.parameterList;
  881. var oldFiltrData = Array.clone( filtrData || [] );
  882. var oldParameterData = Array.clone( parameterData || [] );
  883. nodes.each(function(node){
  884. MWF.xDesktop.requireApp("query.StatementDesigner", "widget.ViewFilter", function(){
  885. var _slef = this;
  886. this.viewFilter = new MWF.xApplication.query.StatementDesigner.widget.ViewFilter(node, this.form.designer, {"filtrData": filtrData, "customData": null, "parameterData": parameterData}, {
  887. "statementId" : this.data.queryStatement ? this.data.queryStatement.id : "",
  888. "withForm" : true,
  889. "onChange": function(ids){
  890. var data = this.getData();
  891. _slef.changeJsonDate(["filterList"], data.filterData);
  892. _slef.changeJsonDate(["parameterList"], data.parameterData);
  893. //_slef.changeJsonDate(["data", "customFilterEntryList"], data.customData);
  894. _slef.checkHistory( "filterList", oldFiltrData, data.filterData );
  895. _slef.checkHistory( "parameterList", oldParameterData, data.parameterData );
  896. oldFiltrData = Array.clone( data.filterData );
  897. oldParameterData = Array.clone( data.parameterData );
  898. }
  899. });
  900. }.bind(this));
  901. }.bind(this));
  902. },
  903. loadStatementFilterWithTemplate: function(){
  904. var nodes = this.propertyContent.getElements(".MWFStatementFilterWithTemplate");
  905. var filtrData = this.data.statementFilterList;
  906. var parameterData = this.data.statementParameterList;
  907. var oldFiltrData = Array.clone( filtrData || [] );
  908. var oldParameterData = Array.clone( parameterData || [] );
  909. nodes.each(function(node){
  910. var statementField = node.dataset["statement"];
  911. MWF.xDesktop.requireApp("query.StatementDesigner", "widget.ViewFilterWithTemplate", function(){
  912. var _slef = this;
  913. this.viewFilterWithTemplate = new MWF.xApplication.query.StatementDesigner.widget.ViewFilterWithTemplate(node, this.form.designer,
  914. {"filtrData": filtrData, "customData": null, "parameterData": parameterData},
  915. {
  916. "statementId" : this.data[statementField] ? this.data[statementField].id : "",
  917. "withForm" : true,
  918. "onChange": function(ids){
  919. var data = this.getData();
  920. _slef.changeJsonDate(["statementFilterList"], data.filterData);
  921. _slef.changeJsonDate(["statementParameterList"], data.parameterData);
  922. _slef.checkHistory("statementFilterList", oldFiltrData, data.filterData);
  923. _slef.checkHistory( "statementParameterList", oldParameterData, data.parameterData );
  924. oldFiltrData = Array.clone( data.filterData );
  925. oldParameterData = Array.clone( data.parameterData );
  926. }
  927. }
  928. );
  929. }.bind(this));
  930. }.bind(this));
  931. },
  932. loadViewFilter: function(){
  933. var nodes = this.propertyContent.getElements(".MWFViewFilter");
  934. var filtrData = this.data.filterList;
  935. var oldValue = Array.clone(filtrData || []);
  936. nodes.each(function(node){
  937. MWF.xDesktop.requireApp("query.ViewDesigner", "widget.ViewFilter", function(){
  938. var _slef = this;
  939. new MWF.xApplication.query.ViewDesigner.widget.ViewFilter(node, this.form.designer, {"filtrData": filtrData, "customData": null}, {
  940. "onChange": function(ids){
  941. var data = this.getData();
  942. _slef.changeJsonDate(["filterList"], data.data);
  943. _slef.checkHistory("filterList", oldValue, data.data);
  944. oldValue = Array.clone(data.data);
  945. //_slef.changeJsonDate(["data", "customFilterEntryList"], data.customData);
  946. }
  947. });
  948. }.bind(this));
  949. }.bind(this));
  950. },
  951. loadViewFilterWithTemplate: function(){
  952. var nodes = this.propertyContent.getElements(".MWFViewFilterWithTemplate");
  953. var filtrData = this.data.viewFilterList;
  954. var oldValue = Array.clone(filtrData || []);
  955. nodes.each(function(node){
  956. MWF.xDesktop.requireApp("query.ViewDesigner", "widget.ViewFilterWithTemplate", function(){
  957. var _slef = this;
  958. new MWF.xApplication.query.ViewDesigner.widget.ViewFilterWithTemplate(node, this.form.designer, {"filtrData": filtrData, "customData": null}, {
  959. "onChange": function(ids){
  960. var data = this.getData();
  961. _slef.changeJsonDate(["viewFilterList"], data.data);
  962. _slef.checkHistory("viewFilterList", oldValue, data.data);
  963. oldValue = Array.clone(data.data);
  964. //_slef.changeJsonDate(["data", "customFilterEntryList"], data.customData);
  965. }
  966. });
  967. }.bind(this));
  968. }.bind(this));
  969. },
  970. loadViewSelect: function(){
  971. var viewNodes = this.propertyContent.getElements(".MWFViewSelect");
  972. if (viewNodes.length){
  973. this.getViewList(function(){
  974. viewNodes.each(function(node){
  975. var select = new Element("select").inject(node);
  976. select.addEvent("change", function(e){
  977. var viewId = e.target.options[e.target.selectedIndex].value;
  978. var viewName = e.target.options[e.target.selectedIndex].get("text");
  979. this.setValue(e.target.getParent("div").get("name"), viewId);
  980. this.setValue(e.target.getParent("div").get("name")+"Name", viewName);
  981. }.bind(this));
  982. this.setViewSelectOptions(node, select);
  983. var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
  984. refreshNode.addEvent("click", function(e){
  985. this.getViewList(function(){
  986. this.setViewSelectOptions(node, select);
  987. }.bind(this), true);
  988. }.bind(this));
  989. //select.addEvent("click", function(e){
  990. // this.setFormSelectOptions(node, select);
  991. //}.bind(this));
  992. }.bind(this));
  993. }.bind(this));
  994. }
  995. },
  996. setViewSelectOptions: function(node, select){
  997. var name = node.get("name");
  998. select.empty();
  999. var option = new Element("option", {"text": "none"}).inject(select);
  1000. this.views.each(function(view){
  1001. var option = new Element("option", {
  1002. "text": view.name,
  1003. "value": view.id,
  1004. "selected": (this.data[name]==view.id)
  1005. }).inject(select);
  1006. }.bind(this));
  1007. },
  1008. getViewList: function(callback, refresh){
  1009. if (!this.views || refresh){
  1010. this.form.designer.actions.listView(this.form.designer.application.id, function(json){
  1011. this.views = json.data;
  1012. if (callback) callback();
  1013. }.bind(this));
  1014. }else{
  1015. if (callback) callback();
  1016. }
  1017. },
  1018. loadValidation: function(){
  1019. var nodes = this.propertyContent.getElements(".MWFValidation");
  1020. if (nodes.length){
  1021. nodes.each(function(node){
  1022. var name = node.get("name");
  1023. MWF.xDesktop.requireApp("process.FormDesigner", "widget.ValidationEditor", function(){
  1024. var validationEditor = new MWF.xApplication.process.FormDesigner.widget.ValidationEditor(node, this.designer, {
  1025. "onChange": function(){
  1026. var oldVaue = this.data[name];
  1027. var data = validationEditor.getValidationData();
  1028. this.data[name] = data;
  1029. this.checkHistory(name, oldVaue, data);
  1030. }.bind(this)
  1031. });
  1032. validationEditor.load(this.data[name])
  1033. }.bind(this));
  1034. //new MWF.xApplication.process.FormDesigner.widget.ValidationEditor(node, this.designer);
  1035. }.bind(this));
  1036. }
  1037. },
  1038. loadFieldConfig: function(){
  1039. var nodes = this.propertyContent.getElements(".MWFFieldConfigArea");
  1040. if (nodes.length){
  1041. nodes.each(function(node){
  1042. var name = node.get("name");
  1043. var data;
  1044. if( this.data[name] ){
  1045. data = this.data[name];
  1046. }else{
  1047. data = this.data[name] = [];
  1048. }
  1049. var oldValue = Array.clone(data);
  1050. MWF.xDesktop.requireApp("process.FormDesigner", "widget.FiledConfigurator", function(){
  1051. var filedConfigurator = new MWF.xApplication.process.FormDesigner.widget.FiledConfigurator(node, this.designer, {
  1052. "title": node.get("data-title"),
  1053. "hasRefresh": true,
  1054. "onRefresh": function () {
  1055. var _self = this;
  1056. if( typeOf(this.data[name]) === "array" && this.data[name].length > 0 ){
  1057. //this.form.designer.lp.selectIcon
  1058. this.form.designer.confirm( "", node, "导入字段确认", "本操作从数据模板的内部组件获取字段。如果执行本操作,之前配置的字段会被替换,是否继续?", 300, 200, function(){
  1059. if( !_self.module.getExpImpFieldJson )return;
  1060. filedConfigurator.data = _self.module.getExpImpFieldJson();
  1061. filedConfigurator.reloadContent();
  1062. _self.data[name] = filedConfigurator.data;
  1063. _self.checkHistory(name, oldValue, _self.data[name]);
  1064. oldValue = Array.clone( _self.data[name] || [] );
  1065. this.close();
  1066. }, function(){
  1067. this.close();
  1068. })
  1069. }else{
  1070. if( !_self.module.getExpImpFieldJson )return;
  1071. filedConfigurator.data = _self.module.getExpImpFieldJson();
  1072. filedConfigurator.reloadContent();
  1073. _self.data[name] = filedConfigurator.data;
  1074. _self.checkHistory(name, oldValue, _self.data[name]);
  1075. oldValue = Array.clone(_self.data[name] || [] );
  1076. }
  1077. }.bind(this),
  1078. "onChange": function(){
  1079. this.data[name] = filedConfigurator.getData();
  1080. this.checkHistory(name, oldValue, this.data[name]);
  1081. oldValue = Array.clone(this.data[name] || []);
  1082. }.bind(this)
  1083. }, data);
  1084. filedConfigurator.load()
  1085. }.bind(this));
  1086. }.bind(this));
  1087. }
  1088. },
  1089. // _loadVue: function(callback){
  1090. // if (!window.Vue){
  1091. // o2.load(["vue", "elementui"], { "sequence": true }, callback);
  1092. // }else{
  1093. // if (callback) callback();
  1094. // }
  1095. // },
  1096. loadElCommonPreview: function(){
  1097. var nodes = this.propertyContent.getElements(".MWFElCommonPreview");
  1098. if (nodes.length) {
  1099. nodes.each(function(node){
  1100. node.removeEvents("click")
  1101. node.addEvent("click", function(){
  1102. if (this.module.resetElement) this.module.resetElement();
  1103. }.bind(this));
  1104. }.bind(this));
  1105. }
  1106. },
  1107. loadVueElementUI: function(){
  1108. var nodes = this.propertyContent.getElements(".MWFElementColor");
  1109. if (nodes.length) {
  1110. this._loadVue(function(){
  1111. var _self = this;
  1112. nodes.each(function(node){
  1113. var name = node.get("name");
  1114. var v = _self.data[name] || "";
  1115. var oldValue = v;
  1116. var data = {};
  1117. data[name] = v;
  1118. new Vue({
  1119. data: data,
  1120. methods: {
  1121. change: function(color){
  1122. _self.data[name] = color;
  1123. _self.changeData(name, null, oldValue);
  1124. oldValue = _self.data[name];
  1125. }
  1126. }
  1127. }).$mount(node);
  1128. });
  1129. }.bind(this));
  1130. }
  1131. },
  1132. _loadVue: function(callback){
  1133. if (!window.Vue){
  1134. o2.loadAll({"css": "../o2_lib/vue/element/index.css", "js": ["vue", "elementui"]}, { "sequence": true }, callback);
  1135. }else{
  1136. if (callback) callback();
  1137. }
  1138. },
  1139. loadElSelectIcon: function(){
  1140. var nodes = this.propertyContent.getElements(".MWFElIcon");
  1141. if (nodes.length){
  1142. var _self = this;
  1143. var icons = ["el-icon-platform-eleme","el-icon-eleme","el-icon-delete-solid","el-icon-delete","el-icon-s-tools","el-icon-setting","el-icon-user-solid","el-icon-user","el-icon-phone","el-icon-phone-outline","el-icon-more","el-icon-more-outline","el-icon-star-on","el-icon-star-off","el-icon-s-goods","el-icon-goods","el-icon-warning","el-icon-warning-outline","el-icon-question","el-icon-info","el-icon-remove","el-icon-circle-plus","el-icon-success","el-icon-error","el-icon-zoom-in","el-icon-zoom-out","el-icon-remove-outline","el-icon-circle-plus-outline","el-icon-circle-check","el-icon-circle-close","el-icon-s-help","el-icon-help","el-icon-minus","el-icon-plus","el-icon-check","el-icon-close","el-icon-picture","el-icon-picture-outline","el-icon-picture-outline-round","el-icon-upload","el-icon-upload2","el-icon-download","el-icon-camera-solid","el-icon-camera","el-icon-video-camera-solid","el-icon-video-camera","el-icon-message-solid","el-icon-bell","el-icon-s-cooperation","el-icon-s-order","el-icon-s-platform","el-icon-s-fold","el-icon-s-unfold","el-icon-s-operation","el-icon-s-promotion","el-icon-s-home","el-icon-s-release","el-icon-s-ticket","el-icon-s-management","el-icon-s-open","el-icon-s-shop","el-icon-s-marketing","el-icon-s-flag","el-icon-s-comment","el-icon-s-finance","el-icon-s-claim","el-icon-s-custom","el-icon-s-opportunity","el-icon-s-data","el-icon-s-check","el-icon-s-grid","el-icon-menu","el-icon-share","el-icon-d-caret","el-icon-caret-left","el-icon-caret-right","el-icon-caret-bottom","el-icon-caret-top","el-icon-bottom-left","el-icon-bottom-right","el-icon-back","el-icon-right","el-icon-bottom","el-icon-top","el-icon-top-left","el-icon-top-right","el-icon-arrow-left","el-icon-arrow-right","el-icon-arrow-down","el-icon-arrow-up","el-icon-d-arrow-left","el-icon-d-arrow-right","el-icon-video-pause","el-icon-video-play","el-icon-refresh","el-icon-refresh-right","el-icon-refresh-left","el-icon-finished","el-icon-sort","el-icon-sort-up","el-icon-sort-down","el-icon-rank","el-icon-loading","el-icon-view","el-icon-c-scale-to-original","el-icon-date","el-icon-edit","el-icon-edit-outline","el-icon-folder","el-icon-folder-opened","el-icon-folder-add","el-icon-folder-remove","el-icon-folder-delete","el-icon-folder-checked","el-icon-tickets","el-icon-document-remove","el-icon-document-delete","el-icon-document-copy","el-icon-document-checked","el-icon-document","el-icon-document-add","el-icon-printer","el-icon-paperclip","el-icon-takeaway-box","el-icon-search","el-icon-monitor","el-icon-attract","el-icon-mobile","el-icon-scissors","el-icon-umbrella","el-icon-headset","el-icon-brush","el-icon-mouse","el-icon-coordinate","el-icon-magic-stick","el-icon-reading","el-icon-data-line","el-icon-data-board","el-icon-pie-chart","el-icon-data-analysis","el-icon-collection-tag","el-icon-film","el-icon-suitcase","el-icon-suitcase-1","el-icon-receiving","el-icon-collection","el-icon-files","el-icon-notebook-1","el-icon-notebook-2","el-icon-toilet-paper","el-icon-office-building","el-icon-school","el-icon-table-lamp","el-icon-house","el-icon-no-smoking","el-icon-smoking","el-icon-shopping-cart-full","el-icon-shopping-cart-1","el-icon-shopping-cart-2","el-icon-shopping-bag-1","el-icon-shopping-bag-2","el-icon-sold-out","el-icon-sell","el-icon-present","el-icon-box","el-icon-bank-card","el-icon-money","el-icon-coin","el-icon-wallet","el-icon-discount","el-icon-price-tag","el-icon-news","el-icon-guide","el-icon-male","el-icon-female","el-icon-thumb","el-icon-cpu","el-icon-link","el-icon-connection","el-icon-open","el-icon-turn-off","el-icon-set-up","el-icon-chat-round","el-icon-chat-line-round","el-icon-chat-square","el-icon-chat-dot-round","el-icon-chat-dot-square","el-icon-chat-line-square","el-icon-message","el-icon-postcard","el-icon-position","el-icon-turn-off-microphone","el-icon-microphone","el-icon-close-notification","el-icon-bangzhu","el-icon-time","el-icon-odometer","el-icon-crop","el-icon-aim","el-icon-switch-button","el-icon-full-screen","el-icon-copy-document","el-icon-mic","el-icon-stopwatch","el-icon-medal-1","el-icon-medal","el-icon-trophy","el-icon-trophy-1","el-icon-first-aid-kit","el-icon-discover","el-icon-place","el-icon-location","el-icon-location-outline","el-icon-location-information","el-icon-add-location","el-icon-delete-location","el-icon-map-location","el-icon-alarm-clock","el-icon-timer","el-icon-watch-1","el-icon-watch","el-icon-lock","el-icon-unlock","el-icon-key","el-icon-service","el-icon-mobile-phone","el-icon-bicycle","el-icon-truck","el-icon-ship","el-icon-basketball","el-icon-football","el-icon-soccer","el-icon-baseball","el-icon-wind-power","el-icon-light-rain","el-icon-lightning","el-icon-heavy-rain","el-icon-sunrise","el-icon-sunrise-1","el-icon-sunset","el-icon-sunny","el-icon-cloudy","el-icon-partly-cloudy","el-icon-cloudy-and-sunny","el-icon-moon","el-icon-moon-night","el-icon-dish","el-icon-dish-1","el-icon-food","el-icon-chicken","el-icon-fork-spoon","el-icon-knife-fork","el-icon-burger","el-icon-tableware","el-icon-sugar","el-icon-dessert","el-icon-ice-cream","el-icon-hot-water","el-icon-water-cup","el-icon-coffee-cup","el-icon-cold-drink","el-icon-goblet","el-icon-goblet-full","el-icon-goblet-square","el-icon-goblet-square-full","el-icon-refrigerator","el-icon-grape","el-icon-watermelon","el-icon-cherry","el-icon-apple","el-icon-pear","el-icon-orange","el-icon-coffee","el-icon-ice-tea","el-icon-ice-drink","el-icon-milk-tea","el-icon-potato-strips","el-icon-lollipop","el-icon-ice-cream-square","el-icon-ice-cream-round"];
  1144. nodes.each(function(node){
  1145. var name = node.get("name");
  1146. var data = this.data[name] || "";
  1147. var oldValue = data;
  1148. var area = new Element("div", {
  1149. "styles": {
  1150. "height": "300px",
  1151. "overflow": "auto",
  1152. "font-size": "24px"
  1153. }
  1154. }).inject(node);
  1155. icons.forEach(function(i){
  1156. if (data==i){
  1157. area.appendHTML("<i style=\"background-color: #999999; padding:5px}\" @click='selected' data-icon=\""+i+"\" class=\""+i+" mainColor_bg\"></i>");
  1158. }else{
  1159. area.appendHTML("<i style='cursor: pointer; padding:5px' @click='selected' data-icon=\""+i+"\" class='"+i+"'></i>");
  1160. }
  1161. });
  1162. this._loadVue(function(){
  1163. new Vue({
  1164. methods:{
  1165. selected: function(e){
  1166. var iNode = (e.target || e.srcElement);
  1167. if (iNode && iNode.hasClass("mainColor_bg")){
  1168. iNode.removeClass("mainColor_bg");
  1169. _self.data[name] = "";
  1170. _self.changeData(name, null, oldValue);
  1171. oldValue = _self.data[name];
  1172. }else{
  1173. this.$el.getElements("i").forEach(function(el){
  1174. if (el.hasClass("mainColor_bg")) el.removeClass("mainColor_bg");
  1175. });
  1176. if (iNode){
  1177. iNode.addClass("mainColor_bg");
  1178. var iconName = iNode.dataset["icon"];
  1179. _self.data[name] = iconName;
  1180. _self.changeData(name, null, oldValue);
  1181. oldValue = _self.data[name];
  1182. }
  1183. }
  1184. }
  1185. }
  1186. }).$mount(node);
  1187. }.bind(this));
  1188. // MWF.xDesktop.requireApp("process.FormDesigner", "widget.FiledConfigurator", function(){
  1189. // var filedConfigurator = new MWF.xApplication.process.FormDesigner.widget.FiledConfigurator(node, this.designer, {
  1190. // "onChange": function(){
  1191. // debugger;
  1192. // this.data[name] = filedConfigurator.getData();
  1193. // }.bind(this)
  1194. // }, data);
  1195. // filedConfigurator.load()
  1196. // }.bind(this));
  1197. }.bind(this));
  1198. }
  1199. },
  1200. loadIconSelect: function(){
  1201. var nodes = this.propertyContent.getElements(".MWFIcon");
  1202. if (nodes.length){
  1203. nodes.each(function(node){
  1204. var id = node.get("name");
  1205. var icon = this.data[id];
  1206. var iconNode = new Element("div", {"styles": this.form.css.processIconNode}).inject(node);
  1207. if (icon) iconNode.setStyles({"background": "url("+icon+") center center no-repeat"});
  1208. var selectNode = new Element("div", {"styles": this.form.css.processIconSelectNode, "text": this.form.designer.lp.selectIcon}).inject(node);
  1209. selectNode.addEvent("click", function(){
  1210. this.selectIcon(node);
  1211. }.bind(this));
  1212. }.bind(this));
  1213. }
  1214. },
  1215. selectIcon: function(node){
  1216. if (!node.iconMenu){
  1217. var tr = node.getParent("tr");
  1218. var p = tr.getPosition(this.form.designer.content);
  1219. var iconSelectMenu = new MWF.widget.Menu(node, {"left": p.x-330, "top": p.y, "event": "click", "style": "processIcon"});
  1220. //var iconSelectMenu = new MWF.widget.Menu(node, {"event": "click", "style": "processIcon"});
  1221. iconSelectMenu.load();
  1222. node.iconMenu = iconSelectMenu;
  1223. var _self = this;
  1224. for (var i=0; i<=48; i++){
  1225. var icon = "../x_component_process_ProcessManager/$Explorer/default/processIcon/process_icon_"+i+".png";
  1226. var item = iconSelectMenu.addMenuItem("", "click", function(){
  1227. var id = node.get("name");
  1228. var src = this.item.getElement("img").get("src");
  1229. _self.data[id] = src;
  1230. node.getFirst("div").setStyle("background-image", "url("+src+")");
  1231. }, icon);
  1232. item.iconName = icon;
  1233. }
  1234. }
  1235. },
  1236. loadLabelFlagSelect: function(){
  1237. var nodes = this.propertyContent.getElements(".MWFLabelFlag");
  1238. if (nodes.length){
  1239. nodes.each(function(node){
  1240. var id = node.get("name");
  1241. var icon = this.data[id];
  1242. var iconNode = new Element("div", {"styles": this.form.css.labelFlagNode}).inject(node);
  1243. if (icon) iconNode.setStyles({"background": "url("+icon+") center center no-repeat"});
  1244. var selectNode = new Element("div", {"styles": this.form.css.processIconSelectNode, "text": this.form.designer.lp.empty}).inject(node);
  1245. selectNode.addEvent("click", function(e){
  1246. var id = node.get("name");
  1247. var oldValue = this.data[id];
  1248. this.data[id] = "";
  1249. node.getFirst("div").setStyle("background-image", "");
  1250. this.changeData(id, null, oldValue);
  1251. e.stopPropagation();
  1252. }.bind(this));
  1253. var selectNode = new Element("div", {"styles": this.form.css.processIconSelectNode, "text": this.form.designer.lp.select}).inject(node);
  1254. selectNode.addEvent("click", function(){
  1255. this.selectLabelFlag(node);
  1256. }.bind(this));
  1257. }.bind(this));
  1258. }
  1259. },
  1260. selectLabelFlag: function(node){
  1261. if (!node.iconMenu){
  1262. var iconSelectMenu = new MWF.widget.Menu(node, {"event": "click", "style": "labelFlag"});
  1263. iconSelectMenu.load();
  1264. node.iconMenu = iconSelectMenu;
  1265. var _self = this;
  1266. for (var i=1; i<=21; i++){
  1267. var icon = "../x_component_process_FormDesigner/Module/Label/default/icon/flag/"+i+".png";
  1268. var item = iconSelectMenu.addMenuItem("", "click", function(){
  1269. var id = node.get("name");
  1270. var src = this.item.getElement("img").get("src");
  1271. var oldValue = _self.data[id];
  1272. _self.data[id] = src;
  1273. node.getFirst("div").setStyle("background-image", "url("+src+")");
  1274. _self.changeData(id, null, oldValue);
  1275. }, icon);
  1276. item.iconName = icon;
  1277. }
  1278. }
  1279. },
  1280. loadImageFileSelect: function(){
  1281. // var nodes = this.propertyContent.getElements(".MWFImageFileSelect");
  1282. // if (nodes.length){
  1283. //
  1284. //
  1285. //
  1286. //
  1287. // this.getFileList(function(){
  1288. // nodes.each(function(node){
  1289. // var select = new Element("select").inject(node);
  1290. // select.addEvent("change", function(e){
  1291. // this.setValue(e.target.getParent("div").get("name"), e.target.options[e.target.selectedIndex].value, select);
  1292. //
  1293. // }.bind(this));
  1294. // this.setFileSelectOptions(node, select);
  1295. //
  1296. // var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
  1297. // refreshNode.addEvent("click", function(e){
  1298. // this.getFileList(function(){
  1299. // this.setFileSelectOptions(node, select);
  1300. // }.bind(this), true);
  1301. // }.bind(this));
  1302. // }.bind(this));
  1303. // }.bind(this));
  1304. // }
  1305. },
  1306. setFileSelectOptions: function(node, select){
  1307. var name = node.get("name");
  1308. select.empty();
  1309. var option = new Element("option", {"text": "none"}).inject(select);
  1310. this.files.each(function(file){
  1311. var option = new Element("option", {
  1312. "text": file.name,
  1313. "value": file.id,
  1314. "selected": (this.data[name]==file.id)
  1315. }).inject(select);
  1316. }.bind(this));
  1317. },
  1318. getFileList: function(callback, refresh){
  1319. if (!this.files || refresh){
  1320. this.form.designer.actions.listFile(this.form.designer.application.id, function(json){
  1321. this.files = json.data;
  1322. if (callback) callback();
  1323. }.bind(this));
  1324. }else{
  1325. if (callback) callback();
  1326. }
  1327. },
  1328. loadImageClipper: function(){
  1329. var nodes = this.propertyContent.getElements(".MWFImageClipper");
  1330. if (nodes.length){
  1331. nodes.each(function(node){
  1332. var id = node.get("name");
  1333. var selectNode = new Element("div", {"styles": this.form.css.processIconSelectNode, "text": this.form.designer.lp.selectImage}).inject(node);
  1334. selectNode.addEvent("click", function(){
  1335. this.selectImage(node, id);
  1336. }.bind(this));
  1337. }.bind(this));
  1338. }
  1339. },
  1340. createUploadFileAreaNode: function(node, name){
  1341. this.uploadFileAreaNode = new Element("div");
  1342. var html = "<input name=\"file\" multiple type=\"file\" accept=\"images/*\" />";
  1343. this.uploadFileAreaNode.set("html", html);
  1344. this.fileUploadNode = this.uploadFileAreaNode.getFirst();
  1345. this.fileUploadNode.addEvent("change", function(){
  1346. //var fileId = attachment.data.id;
  1347. var files = this.fileUploadNode.files;
  1348. if (files.length){
  1349. var count = files.length;
  1350. for (var i = 0; i < files.length; i++) {
  1351. var file = files.item(i);
  1352. var formData = new FormData();
  1353. formData.append('file', file);
  1354. MWF.xDesktop.uploadImage(
  1355. this.form.json.id,
  1356. (this.module.form.moduleType=="page") ? "portalPage" : "processPlatformForm",
  1357. formData,
  1358. file,
  1359. function(json){
  1360. var id = json.id;
  1361. var src = MWF.xDesktop.getImageSrc(id);
  1362. var data = {"imageSrc": src, "imageId": id};
  1363. this.changeJsonDate(name, data);
  1364. this.changeData(name, node, null);
  1365. }.bind(this)
  1366. );
  1367. }
  1368. }
  1369. }.bind(this));
  1370. },
  1371. selectImage: function(node, name){
  1372. if (!this.uploadFileAreaNode){
  1373. this.createUploadFileAreaNode(node, name);
  1374. }
  1375. //this.fileUploadNode.set("accept", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
  1376. this.fileUploadNode.set("multiple", false);
  1377. var fileNode = this.uploadFileAreaNode.getFirst();
  1378. fileNode.set("accept", ".png,.jpg,.bmp,.gif,.jpeg,.jpe");
  1379. fileNode.click();
  1380. //MWF.xDesktop.requireApp("process.FormDesigner", "widget.ImageClipper", function(){
  1381. // var size = this.module.node.getSize();
  1382. // var image = new MWF.xApplication.process.FormDesigner.widget.ImageClipper(this.designer, {
  1383. // "title": this.form.designer.lp.selectImage,
  1384. // "width": (this.data.styles.width) ? size.x : 0,
  1385. // "height": (this.data.styles.height) ? size.y : 0,
  1386. // "imageUrl" : this.data.imageSrc,
  1387. // "reference" : this.form.json.id,
  1388. // "referenceType": (this.module.form.moduleType=="page") ? "portalPage" : "processPlatformForm",
  1389. // "onChange": function(){
  1390. // var data = {"imageSrc": image.imageSrc, "imageId": image.imageId};
  1391. // this.changeJsonDate(name, data);
  1392. // this.changeData(name, node, null);
  1393. // }.bind(this)
  1394. // });
  1395. // image.load(this.data[name])
  1396. //}.bind(this));
  1397. },
  1398. loadEventsEditor: function(){
  1399. var events = this.propertyContent.getElement(".MWFEventsArea");
  1400. if (events){
  1401. var name = events.get("name");
  1402. var eventsObj = this.data[name];
  1403. MWF.xDesktop.requireApp("process.FormDesigner", "widget.EventsEditor", function(){
  1404. var eventsEditor = new MWF.xApplication.process.FormDesigner.widget.EventsEditor(events, this.designer, {
  1405. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  1406. "maxObj": this.designer.formContentNode || this.designer.pageContentNode,
  1407. "onChange": function (eventName, newValue, oldValue, compareName) {
  1408. this.checkHistory(name+"."+eventName, oldValue, newValue, null, compareName ? (name+"."+compareName) : "");
  1409. }.bind(this)
  1410. });
  1411. eventsEditor.load(eventsObj, this.data, name);
  1412. }.bind(this));
  1413. }
  1414. },
  1415. testRestful: function(){
  1416. var node = this.propertyContent.getElements(".MWFTestRestful");
  1417. if (node){
  1418. var resultNode = node.getLast();
  1419. node.getFirst().addEvent("click", function(){
  1420. }.bind(this));
  1421. }
  1422. },
  1423. loadContextRoot: function(){
  1424. var nodes = this.propertyContent.getElements(".MWFContextRoot");
  1425. if (nodes){
  1426. nodes.each(function(node){
  1427. var name = node.get("name");
  1428. var selects = node.getElements("select");
  1429. var rootSelect = selects[0];
  1430. var actionSelect = selects[1];
  1431. var methodSelect = selects[2];
  1432. var pathInput = node.getElement("input");
  1433. //var select = new Element("select").inject(node);
  1434. //var methodSelect = new Element("select").inject(node);
  1435. var getValue = function(){
  1436. var v;
  1437. try {
  1438. v = JSON.parse(this.data[name]);
  1439. }catch(e){
  1440. v = {"root": this.data[name], "action":"", "method": "", "uri": ""};
  1441. }
  1442. return v
  1443. }.bind(this);
  1444. var value = getValue();
  1445. var resetRootSelects = function(){
  1446. var root = rootSelect.options[rootSelect.selectedIndex].value;
  1447. var action = o2.Actions.load(root);
  1448. actionSelect.empty();
  1449. methodSelect.empty();
  1450. pathInput.set("value", "");
  1451. var value = getValue();
  1452. Object.each(action, function(o, key){
  1453. var option = new Element("option", {"value": key, "text": key, "selected": (value.action==key)}).inject(actionSelect);
  1454. });
  1455. return JSON.stringify({"root": root, "action":"", "method": "", "uri": ""});
  1456. };
  1457. var resetActionSelects = function(){
  1458. var root = rootSelect.options[rootSelect.selectedIndex].value;
  1459. var actionName = actionSelect.options[actionSelect.selectedIndex].value;
  1460. var action = o2.Actions.load(root);
  1461. methodSelect.empty();
  1462. pathInput.set("value", "");
  1463. var value = getValue();
  1464. Object.each(action[actionName].action.actions, function(o, key){
  1465. var option = new Element("option", {"value": key, "text": key, "selected": (value.method==key)}).inject(methodSelect);
  1466. });
  1467. return JSON.stringify({"root": root, "action":actionName, "method": "", "uri": ""});
  1468. };
  1469. var resetMethodSelects = function(){
  1470. var root = rootSelect.options[rootSelect.selectedIndex].value;
  1471. var actionName = actionSelect.options[actionSelect.selectedIndex].value;
  1472. var methodName = methodSelect.options[methodSelect.selectedIndex].value;
  1473. var action = o2.Actions.load(root);
  1474. var uri = action[actionName].action.actions[methodName].uri;
  1475. pathInput.set("value", uri);
  1476. return JSON.stringify({"root": root, "action":actionName, "method": methodName, "uri": uri});
  1477. };
  1478. Object.each(layout.serviceAddressList, function(v, key){
  1479. var option = new Element("option", {"value": key, "text": v.name, "selected": (value.root==key)}).inject(rootSelect);
  1480. }.bind(this));
  1481. var option = new Element("option", {"value": "x_program_center", "text": MWF.APPFD.LP.propertyTemplate.centerServer, "selected": (value.root=="x_program_center")}).inject(rootSelect);
  1482. resetRootSelects()
  1483. resetActionSelects();
  1484. resetMethodSelects();
  1485. rootSelect.addEvent("change", function(){
  1486. resetRootSelects();
  1487. resetActionSelects();
  1488. var data = resetMethodSelects();
  1489. this.changeJsonDate(name, data);
  1490. this.changeData(name, node, value);
  1491. }.bind(this));
  1492. actionSelect.addEvent("change", function(){
  1493. resetActionSelects();
  1494. var data = resetMethodSelects();
  1495. this.changeJsonDate(name, data);
  1496. this.changeData(name, node, value);
  1497. }.bind(this));
  1498. methodSelect.addEvent("change", function(){
  1499. var data = resetMethodSelects();
  1500. this.changeJsonDate(name, data);
  1501. this.changeData(name, node, value);
  1502. }.bind(this));
  1503. }.bind(this));
  1504. }
  1505. },
  1506. loadSourceTestRestful: function(){
  1507. var nodes = this.propertyContent.getElements(".MWFSourceTestRestful");
  1508. if (nodes.length){
  1509. nodes.each(function(node){
  1510. var button = node.getFirst();
  1511. var content = node.getLast();
  1512. //var button = new Element("input", {"type": "button", "value": "Test"}).inject(node);
  1513. button.addEvent("click", function(e){
  1514. this.testSourceRestful(content);
  1515. }.bind(this));
  1516. }.bind(this));
  1517. }
  1518. },
  1519. testSourceRestful: function(content){
  1520. var service;
  1521. try {
  1522. service = JSON.parse(this.module.json.contextRoot);
  1523. }catch(e){
  1524. service = {"root": this.module.json.contextRoot, "action":"", "method": "", "url": ""};
  1525. }
  1526. var address = this._getO2Address(service.root);
  1527. var uri = this._getO2Uri(this.module, address);
  1528. this._invoke(this.module, uri, function(json){
  1529. content.empty();
  1530. MWF.require("MWF.widget.JsonParse", function(){
  1531. var jsonParse = new MWF.widget.JsonParse(json, content, null);
  1532. jsonParse.load();
  1533. }.bind(this));
  1534. }.bind(this));
  1535. },
  1536. _getO2Address: function(contextRoot){
  1537. var addressObj = layout.serviceAddressList[contextRoot];
  1538. var address = "";
  1539. var defaultPort = layout.config.app_protocol==='https' ? "443" : "80";
  1540. if (addressObj){
  1541. var appPort = addressObj.port || window.location.port;
  1542. address = layout.config.app_protocol+"//"+(addressObj.host || window.location.hostname)+((!appPort || appPort.toString()===defaultPort) ? "" : ":"+appPort)+addressObj.context;
  1543. }else{
  1544. var host = layout.desktop.centerServer.host || window.location.hostname;
  1545. var port = layout.desktop.centerServer.port || window.location.port;
  1546. address = layout.config.app_protocol+"//"+host+((!port || port.toString()===defaultPort) ? "" : ":"+port)+"/"+contextRoot;
  1547. }
  1548. return address;
  1549. },
  1550. _getO2Uri: function(module, address){
  1551. //var uri = module.json.path || module.json.selectPath;
  1552. var uri = module.json.path;
  1553. var pars = {};
  1554. MWF.require("MWF.xScript.Macro", null, false);
  1555. var macro = new MWF.Macro["PageContext"]({"businessData": {}, "json": {}, "options": {}});
  1556. if (module.json.parameters){
  1557. Object.each(module.json.parameters, function(v, key){
  1558. if (uri.indexOf("{"+key+"}")!==-1){
  1559. var reg = new RegExp("{"+key+"}", "g");
  1560. uri = uri.replace(reg, encodeURIComponent((v && v.code) ? (macro.exec(v.code, this) || "") : v));
  1561. }else{
  1562. pars[key] = v;
  1563. }
  1564. }.bind(this));
  1565. }
  1566. var data = null;
  1567. if (module.json.requestBody){
  1568. if (module.json.requestBody.code){
  1569. data = macro.exec(module.json.requestBody.code, this)
  1570. }
  1571. }
  1572. if (module.json.httpMethod==="GET" || module.json.httpMethod==="OPTIONS" || module.json.httpMethod==="HEAD" || module.json.httpMethod==="DELETE"){
  1573. var tag = "?";
  1574. if (uri.indexOf("?")!==-1) tag = "&";
  1575. Object.each(pars, function(v, k){
  1576. var value = (v && v.code) ? (macro.exec(v.code, this) || "") : v;
  1577. uri = uri+tag+k+"="+value;
  1578. }.bind(this));
  1579. }else{
  1580. Object.each(pars, function(v, k){
  1581. if (!data) data = {};
  1582. var value = (v && v.code) ? (macro.exec(v.code, this) || "") : v;
  1583. data[k] = value;
  1584. }.bind(this));
  1585. }
  1586. this.body = data;
  1587. return {"uri": address+uri, "body": data};
  1588. },
  1589. _invoke: function(module, uri, callback){
  1590. MWF.restful(module.json.httpMethod, uri.uri, JSON.encode(uri.body), function(json){
  1591. //this.data = json;
  1592. if (callback) callback(json);
  1593. }.bind(this), true, true);
  1594. },
  1595. loadUnitTypeSelector: function(){
  1596. var nodes = this.propertyContent.getElements(".MWFFormUnitTypeSelector");
  1597. if (nodes.length){
  1598. this.getUnitTypeList(function(){
  1599. nodes.each(function(node){
  1600. var select = new Element("select").inject(node);
  1601. select.addEvent("change", function(e){
  1602. this.setValue(e.target.getParent("div").get("name"), e.target.options[e.target.selectedIndex].value);
  1603. }.bind(this));
  1604. this.setUnitTypeSelectOptions(node, select);
  1605. this.setValue(select.getParent("div").get("name"), select.options[select.selectedIndex].value, null, true);
  1606. // var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
  1607. // refreshNode.addEvent("click", function(e){
  1608. // this.getUnitTypeList(function(){
  1609. // this.setUnitTypeSelectOptions(node, select);
  1610. // }.bind(this), true);
  1611. // }.bind(this));
  1612. }.bind(this));
  1613. }.bind(this));
  1614. }
  1615. },
  1616. setUnitTypeSelectOptions: function(node, select){
  1617. var name = node.get("name");
  1618. select.empty();
  1619. var option = new Element("option", {"value":"all", "text": this.form.designer.lp.all, "selected": (!this.data[name] || this.data[name]==="all")}).inject(select);
  1620. this.unitTypeList.each(function(unitType){
  1621. var option = new Element("option", {
  1622. "text": unitType,
  1623. "value": unitType,
  1624. "selected": (this.data[name]===unitType)
  1625. }).inject(select);
  1626. }.bind(this));
  1627. },
  1628. getUnitTypeList: function(callback, refresh){
  1629. if (!this.unitTypeList || refresh){
  1630. //MWF.xDesktop.requireApp("Org", "Actions.RestActions", function(){
  1631. // var action = new MWF.xApplication.Org.Actions.RestActions();
  1632. var action = MWF.Actions.get("x_organization_assemble_control");
  1633. action.listUnitType(function(json){
  1634. this.unitTypeList = json.data.valueList;
  1635. if (callback) callback();
  1636. }.bind(this));
  1637. //}.bind(this));
  1638. }else{
  1639. if (callback) callback();
  1640. }
  1641. },
  1642. loadParameterEditor: function(){
  1643. var pars = this.propertyContent.getElements(".MWFParameterArea");
  1644. if (pars){
  1645. pars.each(function(par){
  1646. var name = par.get("name");
  1647. if (!this.data[name]) this.data[name] = {};
  1648. var parObj = this.data[name];
  1649. MWF.xDesktop.requireApp("process.FormDesigner", "widget.ParameterEditor", function(){
  1650. var parameterEditor = new MWF.xApplication.process.FormDesigner.widget.ParameterEditor(par, this.designer, {
  1651. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  1652. "maxObj": this.designer.formContentNode,
  1653. "onChange": function (eventName, newValue, oldValue, compareName) {
  1654. debugger;
  1655. this.checkHistory(name+"."+eventName, oldValue, newValue, null, compareName ? (name+"."+compareName) : "");
  1656. }.bind(this)
  1657. });
  1658. parameterEditor.load(parObj, this.data, name);
  1659. }.bind(this));
  1660. }.bind(this));
  1661. }
  1662. },
  1663. loadArrayList: function(){
  1664. var arrays = this.propertyContent.getElements(".MWFArraylist");
  1665. arrays.each(function(node){
  1666. var title = node.get("title");
  1667. var name = node.get("name");
  1668. var arr = this.data[name];
  1669. if (!arr) arr = [];
  1670. MWF.require("MWF.widget.Arraylist", function(){
  1671. var arraylist = new MWF.widget.Arraylist(node, {
  1672. "title": title,
  1673. "onChange": function(){
  1674. var oldValue = this.data[name];
  1675. this.data[name] = arraylist.toArray();
  1676. this.checkHistory(name, oldValue, this.data[name]);
  1677. }.bind(this)
  1678. });
  1679. arraylist.load(arr);
  1680. }.bind(this));
  1681. node.addEvent("keydown", function(e){e.stopPropagation();});
  1682. }.bind(this));
  1683. },
  1684. loadHtmlEditorArea: function(){
  1685. var htmlAreas = this.propertyContent.getElements(".MWFHtmlEditorArea");
  1686. htmlAreas.each(function(node){
  1687. var title = node.get("title");
  1688. var name = node.get("name");
  1689. var scriptContent = this.data[name];
  1690. MWF.require("MWF.widget.HtmlEditorArea", function(){
  1691. var htmlArea = new MWF.widget.HtmlEditorArea(node, {
  1692. "title": title,
  1693. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  1694. "maxObj": this.designer.formContentNode || this.designer.pageContentNode,
  1695. "onChange": function(){
  1696. debugger;
  1697. var oldValue = this.data[name];
  1698. this.data[name] = htmlArea.getValue();
  1699. this.changeData(name, null, oldValue);
  1700. htmlArea.isChanged = true;
  1701. }.bind(this),
  1702. // "onBlur": function(){
  1703. // if (htmlArea.isChanged){
  1704. // this.changeData(name, node, "");
  1705. // htmlArea.isChanged = false;
  1706. // }
  1707. // }.bind(this),
  1708. "onSave": function(){
  1709. this.designer.saveForm();
  1710. }.bind(this)
  1711. });
  1712. htmlArea.load({"code": scriptContent});
  1713. }.bind(this));
  1714. }.bind(this));
  1715. },
  1716. loadStylesList: function(){
  1717. var _self = this;
  1718. var styleSelNodes = this.propertyContent.getElements(".MWFFormStyle");
  1719. styleSelNodes.each(function(node){
  1720. if (this.module.form.stylesList){
  1721. if (!this.data.formStyleType) this.data.formStyleType = "default";
  1722. var mode = ( this.form.options.mode || "" ).toLowerCase() === "mobile" ? "mobile" : "pc";
  1723. Object.each(this.module.form.stylesList, function(s, key){
  1724. if( s.mode.contains( mode ) ){
  1725. new Element("option", {
  1726. "text": s.name,
  1727. "value": key,
  1728. "selected": ((!this.data.formStyleType && key=="default") || (this.data.formStyleType==key))
  1729. }).inject(node)
  1730. }
  1731. }.bind(this));
  1732. }else{
  1733. node.getParent("tr").setStyle("display", "none");
  1734. }
  1735. var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node, "after");
  1736. refreshNode.addEvent("click", function(e){
  1737. _self.changeData(this.get("name"), this );
  1738. }.bind(node));
  1739. }.bind(this));
  1740. },
  1741. // loadStylesList: function(){
  1742. // var _self = this;
  1743. // var styleSelNodes = this.propertyContent.getElements(".MWFFormStyle");
  1744. // styleSelNodes.each(function(node){
  1745. // if (this.module.form.stylesList){
  1746. // if (!this.data.formStyleType) this.data.formStyleType = "default";
  1747. // var mode = ( this.form.options.mode || "" ).toLowerCase() === "mobile" ? "mobile" : "pc";
  1748. // Object.each(this.module.form.stylesList, function(s, key){
  1749. // if( s.mode.contains( mode ) ){
  1750. // new Element("option", {
  1751. // "text": s.name,
  1752. // "value": key,
  1753. // "selected": ((!this.data.formStyleType && key=="default") || (this.data.formStyleType==key))
  1754. // }).inject(node)
  1755. // }
  1756. // }.bind(this));
  1757. // }else{
  1758. // node.getParent("tr").setStyle("display", "none");
  1759. // }
  1760. //
  1761. // var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node, "after");
  1762. // refreshNode.addEvent("click", function(e){
  1763. // _self.changeData(this.get("name"), this );
  1764. // }.bind(node));
  1765. // }.bind(this));
  1766. // },
  1767. loadDivTemplateType: function(){
  1768. var nodes = this.propertyContent.getElements(".MWFDivTemplate");
  1769. if (nodes.length){
  1770. var keys = [];
  1771. //if (this.module.form.stylesList) {
  1772. // if (this.module.form.stylesList[this.module.form.json.formStyleType]){
  1773. // var styles = this.module.form.stylesList[this.module.form.json.formStyleType][this.module.moduleName];
  1774. // if (styles) {
  1775. // Object.each(styles, function (v, k) {
  1776. // keys.push(k);
  1777. // }.bind(this));
  1778. // }
  1779. // }
  1780. //}
  1781. if (this.module.form.templateStyles && this.module.form.templateStyles[this.module.moduleName]) {
  1782. var styles = this.module.form.templateStyles[this.module.moduleName];
  1783. if (styles) {
  1784. Object.each(styles, function (v, k) {
  1785. keys.push(k);
  1786. }.bind(this));
  1787. }
  1788. }
  1789. nodes.each(function(node){
  1790. node.empty();
  1791. new Element("option", {
  1792. "text": "default",
  1793. "value": "default",
  1794. "selected": (!this.data.templateType || this.data.templateType=="default")
  1795. }).inject(node);
  1796. if (keys.length){
  1797. keys.each(function(k){
  1798. new Element("option", {
  1799. "text": styles[k].name,
  1800. "value": k,
  1801. "selected": (this.data.templateType==k)
  1802. }).inject(node)
  1803. }.bind(this));
  1804. }else{
  1805. node.getParent("tr").setStyle("display", "none");
  1806. }
  1807. }.bind(this));
  1808. }
  1809. },
  1810. loadPersonInput: function(){
  1811. var personMultipleNodes = this.propertyContent.getElements(".MWFPersonMultiple");
  1812. var personIdentityNodes = this.propertyContent.getElements(".MWFPersonIdentity");
  1813. var personUnitNodes = this.propertyContent.getElements(".MWFPersonUnit");
  1814. var dutyNodes = this.propertyContent.getElements(".MWFDutySelector");
  1815. var dutyNameNodes = this.propertyContent.getElements(".MWFPersonDuty");
  1816. var viewNodes = this.propertyContent.getElements(".MWFViewSelect");
  1817. var cmsviewNodes = this.propertyContent.getElements(".MWFCMSViewSelect");
  1818. var queryviewNodes = this.propertyContent.getElements(".MWFQueryViewSelect");
  1819. var queryStatementNodes = this.propertyContent.getElements(".MWFQueryStatementSelect");
  1820. var querystatNodes = this.propertyContent.getElements(".MWFQueryStatSelect");
  1821. var fileNodes = this.propertyContent.getElements(".MWFImageFileSelect");
  1822. var processFileNodes = this.propertyContent.getElements(".MWFProcessImageFileSelect");
  1823. var cmsFileNodes = this.propertyContent.getElements(".MWFCMSImageFileSelect");
  1824. var scriptNodes = this.propertyContent.getElements(".MWFScriptSelect");
  1825. var formStyleNodes = this.propertyContent.getElements(".MWFFormStyleSelect");
  1826. var dictionaryNodes = this.propertyContent.getElements(".MWFDictionarySelect");
  1827. var queryImportModelNodes = this.propertyContent.getElements(".MWFQueryImportModelSelect");
  1828. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function(){
  1829. personMultipleNodes.each(function(node){
  1830. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1831. "types": node.get("data-types").split(","),
  1832. "names": this.data[node.get("name")],
  1833. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  1834. });
  1835. }.bind(this));
  1836. personIdentityNodes.each(function(node){
  1837. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1838. "type": "identity",
  1839. "names": this.data[node.get("name")],
  1840. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  1841. });
  1842. }.bind(this));
  1843. personUnitNodes.each(function(node){
  1844. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1845. "type": "unit",
  1846. "names": this.data[node.get("name")],
  1847. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  1848. });
  1849. }.bind(this));
  1850. dutyNodes.each(function(node){
  1851. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1852. "type": "duty",
  1853. "names": this.data[node.get("name")],
  1854. "onChange": function(ids){this.addDutyItem(node, ids);}.bind(this),
  1855. "onRemoveDuty": function(item){this.removeDutyItem(node, item);}.bind(this)
  1856. });
  1857. }.bind(this));
  1858. dutyNameNodes.each(function(node){
  1859. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1860. "type": "dutyName",
  1861. "names": this.data[node.get("name")],
  1862. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  1863. });
  1864. }.bind(this));
  1865. viewNodes.each(function(node){
  1866. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1867. "type": "View",
  1868. "count": 1,
  1869. "names": [this.data[node.get("name")]],
  1870. "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
  1871. });
  1872. }.bind(this));
  1873. cmsviewNodes.each(function(node){
  1874. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1875. "type": "CMSView",
  1876. "count": 1,
  1877. "names": [this.data[node.get("name")]],
  1878. "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
  1879. });
  1880. }.bind(this));
  1881. queryviewNodes.each(function(node){
  1882. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1883. "type": "QueryView",
  1884. "count": node.dataset["count"] || 1,
  1885. "names": typeOf(this.data[node.get("name")]) === "array" ? this.data[node.get("name")] : [this.data[node.get("name")]],
  1886. "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
  1887. });
  1888. }.bind(this));
  1889. queryStatementNodes.each(function(node){
  1890. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1891. "type": "QueryStatement",
  1892. "count": 1,
  1893. "viewEnable": true,
  1894. "names": [this.data[node.get("name")]],
  1895. "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
  1896. });
  1897. }.bind(this));
  1898. querystatNodes.each(function(node){
  1899. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1900. "type": "QueryStat",
  1901. "count": 1,
  1902. "names": [this.data[node.get("name")]],
  1903. "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
  1904. });
  1905. }.bind(this));
  1906. queryImportModelNodes.each(function(node){
  1907. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1908. "type": "QueryImportModel",
  1909. "count": 1,
  1910. "names": [this.data[node.get("name")]],
  1911. "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
  1912. });
  1913. }.bind(this));
  1914. scriptNodes.each(function(node){
  1915. var ps = new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1916. "type": "Script",
  1917. "count": node.dataset["count"] || 1,
  1918. "names": (!node.dataset["count"] || node.dataset["count"].toInt()==1) ? [this.data[node.get("name")]] : this.data[node.get("name")],
  1919. "onChange": function(ids){
  1920. this.saveScriptSelectItem(node, ids);
  1921. }.bind(this)
  1922. });
  1923. node.store("selector", ps);
  1924. var actionNode = node.getNext();
  1925. if (actionNode.hasClass("MWFScriptSelectAction")){
  1926. var _self = this;
  1927. var copyNode = actionNode.getFirst();
  1928. var pasteNode = actionNode.getLast();
  1929. copyNode.store("slectNode", node);
  1930. pasteNode.store("slectNode", node);
  1931. copyNode.addEvent("click", function(e){
  1932. var selectNode = this.retrieve("slectNode");
  1933. if (selectNode){
  1934. var name = node.get("name");
  1935. var data = _self.data[name];
  1936. if (data){
  1937. var str = JSON.encode(data);
  1938. o2.DL.open({
  1939. "isTitle": false,
  1940. "width": 400,
  1941. "height": 500,
  1942. "html": "<textarea style='width: 99%; height: 98%'>"+str+"</textarea>",
  1943. "buttonList": [{
  1944. "type": "ok",
  1945. "text": "ok",
  1946. "action": function(){this.close();}
  1947. }]
  1948. })
  1949. }
  1950. }
  1951. });
  1952. pasteNode.addEvent("click", function(e){
  1953. var selectNode = this.retrieve("slectNode");
  1954. if (selectNode){
  1955. o2.DL.open({
  1956. "isTitle": false,
  1957. "width": 400,
  1958. "height": 500,
  1959. "html": "<textarea style='width: 99%; height: 98%'></textarea>",
  1960. "buttonList": [{
  1961. "type": "ok",
  1962. "text": "ok",
  1963. "action": function(){
  1964. var dataStr = this.content.getElement("textarea").get("value");
  1965. try{
  1966. var data = JSON.decode(dataStr);
  1967. var s = selectNode.retrieve("selector");
  1968. s.setData(data);
  1969. _self.saveScriptSelectItem(selectNode, s.identitys);
  1970. }catch(e){
  1971. throw e;
  1972. }
  1973. this.close();
  1974. }
  1975. },{
  1976. "type": "cancel",
  1977. "text": "cancel",
  1978. "action": function(){this.close();}
  1979. }]
  1980. })
  1981. }
  1982. });
  1983. }
  1984. }.bind(this));
  1985. var _self = this;
  1986. formStyleNodes.each(function(node){
  1987. var data = this.data[node.get("name")];
  1988. if( typeOf( data ) === "string" ){
  1989. for( var key in this.module.form.stylesList ){
  1990. var s = this.module.form.stylesList[key];
  1991. if( ((!data && key=="default") || (data==key)) ){
  1992. data = {
  1993. name : s.name,
  1994. id : key
  1995. };
  1996. break;
  1997. }
  1998. }
  1999. }
  2000. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  2001. "type": "FormStyle",
  2002. "count": 1,
  2003. "names": [data],
  2004. "selectorOptions" : {
  2005. "mode" : ( this.form.options.mode || "" ).toLowerCase() === "mobile" ? "mobile" : "pc"
  2006. },
  2007. "validFun" : function (ids) {
  2008. var flag = true;
  2009. if( ids.length === 0 ){
  2010. this.designer.notice(MWF.APPFD.LP.mustSelectFormStyle, "error");
  2011. flag = false;
  2012. }else if( ids[0].data.type === "script" ){
  2013. this.designer.actions.getScriptByName( ids[0].data.name, ids[0].data.application, function( json ) {
  2014. try{
  2015. var f = eval("(function(){\n return "+json.data.text+"\n})");
  2016. var j = f();
  2017. if( typeOf(j) !== "object" ){
  2018. this.designer.notice( MWF.APPFD.LP.notValidJson, "error" );
  2019. flag = false;
  2020. }
  2021. }catch (e) {
  2022. this.designer.notice( MWF.APPFD.LP.notValidJson +":"+ e.message, "error" );
  2023. flag = false;
  2024. }
  2025. }.bind(this), function () {
  2026. flag = false;
  2027. }, false);
  2028. }
  2029. return flag;
  2030. }.bind(this),
  2031. "onChange": function(ids){
  2032. var d = ids[0].data;
  2033. var data;
  2034. if( d.type === "script" ){
  2035. data = {
  2036. "type" : "script",
  2037. "name": d.name,
  2038. "alias": d.alias,
  2039. "id": d.id,
  2040. "appName" : d.appName || d.applicationName,
  2041. "appId": d.appId,
  2042. "application": d.application
  2043. };
  2044. }else{
  2045. data = d.id;
  2046. }
  2047. var name = node.get("name");
  2048. var oldValue = this.data[name];
  2049. this.data[name] = data;
  2050. this.changeData(name, node, oldValue);
  2051. }.bind(this)
  2052. });
  2053. var next = node.getNext();
  2054. if( next && next.get("class") === "MWFScriptSelectRefresh" ){
  2055. var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(next);
  2056. refreshNode.addEvent("click", function(e){
  2057. _self.changeData(this.get("name"), this );
  2058. }.bind(node));
  2059. }
  2060. }.bind(this));
  2061. dictionaryNodes.each(function(node){
  2062. var data = this.data[node.get("name")];
  2063. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  2064. "type": "Dictionary",
  2065. "count": node.dataset["count"] || 0,
  2066. "names": typeOf(data)==="array" ? data : [data],
  2067. "onChange": function(ids){
  2068. var data = [];
  2069. var name = node.get("name");
  2070. if( ids.length > 0 ){
  2071. // var d = ids[0].data;
  2072. ids.each( function (id) {
  2073. var d = id.data;
  2074. data.push({
  2075. "type" : "dictionary",
  2076. "name": d.name,
  2077. "alias": d.alias,
  2078. "id": d.id,
  2079. "appName" : d.appName || d.applicationName,
  2080. "appAlias" : d.appAlias || d.applicationAlias,
  2081. "appId": d.appId,
  2082. "application": d.application,
  2083. "appType" : d.appType
  2084. })
  2085. });
  2086. }
  2087. var oldValue = this.data[name];
  2088. this.data[name] = data;
  2089. this.changeData(name, node, oldValue);
  2090. }.bind(this)
  2091. });
  2092. }.bind(this));
  2093. fileNodes.each(function(node){
  2094. var d = this.data[node.get("name")];
  2095. var data = d || {};
  2096. //this.form
  2097. if (d && typeOf(d)==="string"){
  2098. if (this.form.page){
  2099. data = {"id": d, "portal": this.form.application}
  2100. }else{
  2101. data = {"id": d, "application": this.form.application}
  2102. }
  2103. }
  2104. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  2105. "type": "PortalFile",
  2106. "count": 1,
  2107. "isImage": true,
  2108. "values": (data.id) ? [data.id] : [],
  2109. "onChange": function(ids){this.saveFileItem(node, ids);}.bind(this)
  2110. });
  2111. }.bind(this));
  2112. processFileNodes.each(function(node){
  2113. var d = this.data[node.get("name")];
  2114. var data = d || {};
  2115. //this.form
  2116. if (d && typeOf(d)==="string"){
  2117. if (this.form.page){
  2118. data = {"id": d, "portal": this.form.application}
  2119. }else{
  2120. data = {"id": d, "application": this.form.application}
  2121. }
  2122. }
  2123. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  2124. "type": "ProcessFile",
  2125. "count": 1,
  2126. "isImage": true,
  2127. "values": (data.id) ? [data.id] : [],
  2128. "onChange": function(ids){this.saveFileItem(node, ids);}.bind(this)
  2129. });
  2130. }.bind(this));
  2131. cmsFileNodes.each(function(node){
  2132. var d = this.data[node.get("name")];
  2133. var data = d || {};
  2134. //this.form
  2135. if (d && typeOf(d)==="string"){
  2136. data = {"id": d, "appId": this.form.application || this.form.appId}
  2137. }
  2138. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  2139. "type": "CMSFile",
  2140. "count": 1,
  2141. "isImage": true,
  2142. "values": (data.id) ? [data.id] : [],
  2143. "onChange": function(ids){this.saveFileItem(node, ids);}.bind(this)
  2144. });
  2145. }.bind(this));
  2146. }.bind(this));
  2147. },
  2148. loadDictionaryItem: function(){
  2149. var dictItemContainers = this.propertyContent.getElements(".MWFDictionaryItemContainer");
  2150. dictItemContainers.each(function (container) {
  2151. var dictNode = container.getElement(".MWFDictionaryNode");
  2152. var dictItemNode = container.getElement(".MWFDictionaryItemNode");
  2153. var dictItemSelect;
  2154. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function() {
  2155. var data = this.data[dictNode.get("name")];
  2156. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(dictNode, this.form.designer, {
  2157. "type": "Dictionary",
  2158. "count": dictNode.dataset["count"] || 0,
  2159. "names": typeOf(data) === "array" ? data : [data],
  2160. "onChange": function (ids) {
  2161. var data = [];
  2162. var name = dictNode.get("name");
  2163. if (ids.length > 0) {
  2164. // var d = ids[0].data;
  2165. ids.each(function (id) {
  2166. var d = id.data;
  2167. data.push({
  2168. "type": "dictionary",
  2169. "name": d.name,
  2170. "alias": d.alias,
  2171. "id": d.id,
  2172. "appName": d.appName || d.applicationName,
  2173. "appAlias": d.appAlias || d.applicationAlias,
  2174. "appId": d.appId,
  2175. "application": d.application,
  2176. "appType": d.appType
  2177. })
  2178. });
  2179. }
  2180. var oldValue = this.data[name];
  2181. this.data[name] = data;
  2182. this.changeData(name, dictNode, oldValue);
  2183. changeDictItemValue("");
  2184. dictItemSelect.reload();
  2185. }.bind(this)
  2186. });
  2187. }.bind(this));
  2188. var changeDictItemValue = function (newValue) {
  2189. debugger;
  2190. var name = dictItemNode.get("name");
  2191. var oldValue = this.data[name];
  2192. this.data[name] = newValue;
  2193. this.checkHistory(name, oldValue, newValue);
  2194. }.bind(this);
  2195. MWF.xDesktop.requireApp("process.FormDesigner", "widget.DictItemSelector", function() {
  2196. dictItemSelect = new MWF.xApplication.process.FormDesigner.widget.DictItemSelector(dictItemNode, this, {
  2197. onChange: function (newValue) {
  2198. changeDictItemValue( newValue );
  2199. }.bind(this)
  2200. });
  2201. }.bind(this))
  2202. }.bind(this));
  2203. },
  2204. loadQueryViewItem: function(){
  2205. var containers = this.propertyContent.getElements(".MWFQueryViewItemContainer");
  2206. containers.each(function (container) {
  2207. var viewNode = container.getElement(".MWFQueryViewNode");
  2208. var viewColumnSelects = container.getElements(".MWFViewColumnSelect");
  2209. viewColumnSelects.each(function (select) {
  2210. select.addEvent("change", function () {
  2211. var name = select.get("name");
  2212. //var oldValue = this.data[name];
  2213. var value = select.options[select.selectedIndex].value;
  2214. this.setValue(name, value, select);
  2215. //this.checkHistory(name, oldValue, this.data[name]);
  2216. }.bind(this))
  2217. }.bind(this));
  2218. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function() {
  2219. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(viewNode, this.form.designer, {
  2220. "type": "QueryView",
  2221. "count": 1,
  2222. "names": [this.data[viewNode.get("name")]],
  2223. "onChange": function (ids) {
  2224. var name = viewNode.get("name");
  2225. var oldValue = this.data[name];
  2226. if (ids[0]) {
  2227. var view = ids[0].data;
  2228. var data = {
  2229. "name": view.name,
  2230. "alias": view.alias,
  2231. "id": view.id,
  2232. "appName": view.appName || view.applicationName || view.query,
  2233. "appId": view.appId,
  2234. "application": view.application || view.query
  2235. };
  2236. this.data[name] = data;
  2237. } else {
  2238. this.data[name] = null;
  2239. }
  2240. this.checkHistory(name, oldValue, this.data[name]);
  2241. loadSelectsOptions( function () {
  2242. changSelectsIndex(0);
  2243. }.bind(this));
  2244. }.bind(this)
  2245. });
  2246. }.bind(this));
  2247. var changSelectsIndex = function (idx) {
  2248. viewColumnSelects.each(function (select) {
  2249. select.selectedIndex = idx;
  2250. select.fireEvent("change");
  2251. }.bind(this))
  2252. }.bind(this);
  2253. var loadSelectsOptions = function ( callback ) {
  2254. var name = viewNode.get("name");
  2255. var view = this.data[name];
  2256. if( view && view.id ){
  2257. MWF.Actions.get("x_query_assemble_designer").getView(view.id, function(json){
  2258. var viewData = JSON.decode(json.data.data);
  2259. var columnList = viewData.selectEntryList || viewData.selectList;
  2260. viewColumnSelects.each(function (select) {
  2261. select.empty();
  2262. var sname = select.get("name");
  2263. new Element("option", { value: "" }).inject( select );
  2264. new Element("option", { value: "bundle", text: "bundle", selected: this.data[sname] === "bundle" }).inject( select );
  2265. columnList.each(function ( column ) {
  2266. new Element("option", {
  2267. value: column.column,
  2268. text: column.displayName + "(" + column.column + ")",
  2269. selected: this.data[sname] === column.column
  2270. }).inject( select );
  2271. }.bind(this))
  2272. }.bind(this));
  2273. if(callback)callback();
  2274. }.bind(this), function () {
  2275. return true
  2276. });
  2277. }else{
  2278. viewColumnSelects.each(function (select) {
  2279. select.empty();
  2280. });
  2281. if(callback)callback();
  2282. }
  2283. }.bind(this)
  2284. loadSelectsOptions();
  2285. }.bind(this));
  2286. },
  2287. loadQueryStatementItem: function(){
  2288. var containers = this.propertyContent.getElements(".MWFQueryStatementItemContainer");
  2289. containers.each(function (container) {
  2290. debugger;
  2291. var viewNode = container.getElement(".MWFQueryStatementNode");
  2292. var viewColumnSelects = container.getElements(".MWFStatementItemSelect");
  2293. viewColumnSelects.each(function (select) {
  2294. select.addEvent("change", function () {
  2295. var name = select.get("name");
  2296. //var oldValue = this.data[name];
  2297. var value = select.options[select.selectedIndex].value;
  2298. this.setValue(name, value, select);
  2299. //this.checkHistory(name, oldValue, this.data[name]);
  2300. }.bind(this))
  2301. }.bind(this));
  2302. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function() {
  2303. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(viewNode, this.form.designer, {
  2304. "type": "QueryStatement",
  2305. "count": 1,
  2306. "names": [this.data[viewNode.get("name")]],
  2307. "onChange": function (ids) {
  2308. var name = viewNode.get("name");
  2309. var oldValue = this.data[name];
  2310. if (ids[0]) {
  2311. var view = ids[0].data;
  2312. var data = {
  2313. "name": view.name,
  2314. "alias": view.alias,
  2315. "id": view.id,
  2316. "appName": view.appName || view.applicationName || view.query,
  2317. "appId": view.appId,
  2318. "application": view.application || view.query
  2319. };
  2320. this.data[name] = data;
  2321. } else {
  2322. this.data[name] = null;
  2323. }
  2324. this.checkHistory(name, oldValue, this.data[name]);
  2325. if( this.viewFilterWithTemplate )this.viewFilterWithTemplate.resetStatementData(view.id);
  2326. loadSelectsOptions( function () {
  2327. changSelectsIndex(0);
  2328. }.bind(this));
  2329. }.bind(this)
  2330. });
  2331. }.bind(this));
  2332. var changSelectsIndex = function (idx) {
  2333. viewColumnSelects.each(function (select) {
  2334. select.selectedIndex = idx;
  2335. select.fireEvent("change");
  2336. }.bind(this))
  2337. }.bind(this);
  2338. var loadSelectsOptions = function ( callback ) {
  2339. var name = viewNode.get("name");
  2340. var view = this.data[name];
  2341. if( view && view.id ){
  2342. MWF.Actions.load("x_query_assemble_designer").StatementAction.get(view.id, function(json){
  2343. var viewData = JSON.decode(json.data.view || {});
  2344. debugger;
  2345. var columnList = viewData.data.selectEntryList || viewData.data.selectList || [];
  2346. viewColumnSelects.each(function (select) {
  2347. select.empty();
  2348. var sname = select.get("name");
  2349. new Element("option", { value: "" }).inject( select );
  2350. columnList.each(function ( column ) {
  2351. new Element("option", {
  2352. value: column.path,
  2353. text: column.displayName + "(" + column.path + ")",
  2354. selected: this.data[sname] === column.path
  2355. }).inject( select );
  2356. }.bind(this))
  2357. }.bind(this))
  2358. if(callback)callback();
  2359. }.bind(this), function () {
  2360. return true;
  2361. });
  2362. }else{
  2363. viewColumnSelects.each(function (select) {
  2364. select.empty();
  2365. });
  2366. if(callback)callback();
  2367. }
  2368. }.bind(this)
  2369. loadSelectsOptions();
  2370. }.bind(this));
  2371. },
  2372. loadDictionaryIncluder : function(){
  2373. var nodes = this.propertyContent.getElements(".MWFDictionaryIncluder");
  2374. if (nodes.length){
  2375. nodes.each(function(node){
  2376. var name = node.get("name");
  2377. MWF.xDesktop.requireApp("process.FormDesigner", "widget.DictionaryIncluder", function(){
  2378. var dictionaryIncluder = new MWF.xApplication.process.FormDesigner.widget.DictionaryIncluder(node, this.designer, {
  2379. "onChange": function(){
  2380. var oldValue = this.data[name];
  2381. var data = dictionaryIncluder.getData();
  2382. this.data[name] = data;
  2383. this.checkHistory(name, oldValue, this.data[name]);
  2384. }.bind(this)
  2385. });
  2386. dictionaryIncluder.load(this.data[name])
  2387. }.bind(this));
  2388. }.bind(this));
  2389. }
  2390. },
  2391. loadScriptIncluder : function(){
  2392. var nodes = this.propertyContent.getElements(".MWFScriptIncluder");
  2393. if (nodes.length){
  2394. nodes.each(function(node){
  2395. var name = node.get("name");
  2396. MWF.xDesktop.requireApp("process.FormDesigner", "widget.ScriptIncluder", function(){
  2397. var scriptIncluder = new MWF.xApplication.process.FormDesigner.widget.ScriptIncluder(node, this.designer, {
  2398. "onChange": function(){
  2399. var oldValue = this.data[name];
  2400. var data = scriptIncluder.getData();
  2401. this.data[name] = data;
  2402. this.checkHistory(name, oldValue, this.data[name]);
  2403. }.bind(this)
  2404. });
  2405. scriptIncluder.load(this.data[name])
  2406. }.bind(this));
  2407. }.bind(this));
  2408. }
  2409. },
  2410. saveFileItem: function(node, ids){
  2411. var oldValue = this.data[node.get("name")];
  2412. if (ids[0]){
  2413. var file = ids[0].data;
  2414. this.data[node.get("name")] = file;
  2415. }else{
  2416. this.data[node.get("name")] = null;
  2417. }
  2418. this.changeData(node.get("name"), null, oldValue);
  2419. },
  2420. saveViewItem: function(node, ids){
  2421. var name = node.get("name");
  2422. var oldValue = this.data[name];
  2423. var count = (node.dataset["count"] || 1).toInt();
  2424. if( !ids )ids = [];
  2425. if( count === 1 ){
  2426. if (ids[0]){
  2427. var view = ids[0].data;
  2428. this.data[node.get("name")] = {
  2429. "name": view.name,
  2430. "alias": view.alias,
  2431. "id": view.id,
  2432. "appName" : view.appName || view.applicationName || view.query,
  2433. "appId": view.appId,
  2434. "application": view.application || view.query
  2435. };
  2436. }else{
  2437. this.data[node.get("name")] = null;
  2438. }
  2439. }else{
  2440. this.data[node.get("name")] = ids.map(function (id) {
  2441. var view = id.data;
  2442. return {
  2443. "name": view.name,
  2444. "alias": view.alias,
  2445. "id": view.id,
  2446. "appName" : view.appName || view.applicationName || view.query,
  2447. "appId": view.appId,
  2448. "application": view.application || view.query
  2449. };
  2450. })
  2451. }
  2452. this.checkHistory(name, oldValue, this.data[name]);
  2453. if (this.module._checkView) this.module._checkView(null, name, oldValue, this.data[name]);
  2454. },
  2455. removeViewItem: function(node, item){
  2456. },
  2457. saveScriptSelectItem: function(node, ids){
  2458. var count = (node.dataset["count"] || 1).toInt();
  2459. if (count==1){
  2460. if (ids[0]){
  2461. var script = ids[0].data;
  2462. var data = {
  2463. "appType": script.appType,
  2464. "type" : "script",
  2465. "name": script.name,
  2466. "alias": script.alias,
  2467. "id": script.id,
  2468. "appName" : script.appName || script.applicationName,
  2469. "appId": script.appId,
  2470. "application": script.application
  2471. };
  2472. var name = node.get("name");
  2473. var oldValue = this.data[name];
  2474. this.data[name] = data;
  2475. // this.changeJsonDate(name, data );
  2476. this.changeData(name, node, oldValue);
  2477. }else{
  2478. // this.data[node.get("name")] = null;
  2479. }
  2480. }else{
  2481. var scriptValues = [];
  2482. ids.each(function(s){
  2483. var scriptValue = {
  2484. "appType": s.data.appType,
  2485. "type" : "script",
  2486. "name": s.data.name,
  2487. "alias": s.data.alias,
  2488. "id": s.data.id,
  2489. "appName" : s.data.appName || s.data.applicationName,
  2490. "appId": s.data.appId,
  2491. "application": s.data.application
  2492. }
  2493. scriptValues.push(scriptValue);
  2494. }.bind(this));
  2495. var name = node.get("name");
  2496. var oldValue = this.data[name];
  2497. this.data[name] = scriptValues;
  2498. this.changeData(name, node, oldValue);
  2499. }
  2500. },
  2501. removeDutyItem: function(node, item){
  2502. if (item.data.id){
  2503. var values = JSON.decode(this.data[node.get("name")] || []);
  2504. var value = values.filter(function(v){
  2505. return v.id == item.data.id;
  2506. });
  2507. value.each(function(v) {
  2508. values = values.erase(v);
  2509. });
  2510. var name = node.get("name");
  2511. var oldValue = this.data[name];
  2512. this.data[name] = JSON.encode(values);
  2513. this.checkHistory(name, oldValue, this.data[name]);
  2514. }
  2515. item.node.destroy();
  2516. MWF.release(item);
  2517. delete item;
  2518. },
  2519. addDutyItem: function(node, ids){
  2520. var value = this.data[node.get("name")] || "";
  2521. if (!value) value = "[]";
  2522. var values = JSON.decode(value);
  2523. ids.each(function(id){
  2524. if (id.data.dutyId){
  2525. for (var i=0; i<values.length; i++){
  2526. if (values[i].dutyId===id.data.dutyId){
  2527. values[i].name = id.data.name;
  2528. values[i].code = id.data.code;
  2529. break;
  2530. }
  2531. }
  2532. }else{
  2533. id.data.dutyId = new MWF.widget.UUID().toString();
  2534. values.push({"name": id.data.name, "id": id.data.id, "dutyId": id.data.dutyId, "code": id.data.code});
  2535. }
  2536. }.bind(this));
  2537. var name = node.get("name");
  2538. var oldValue = this.data[name];
  2539. this.data[name] = JSON.encode(values);
  2540. this.checkHistory(name, oldValue, this.data[name]);
  2541. },
  2542. loadFormFieldInput: function(){
  2543. var fieldNodes = this.propertyContent.getElements(".MWFFormFieldPerson");
  2544. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function(){
  2545. fieldNodes.each(function(node){
  2546. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  2547. "type": "formField",
  2548. "application": this.form.json.application,
  2549. "fieldType": "person",
  2550. "names": this.data[node.get("name")],
  2551. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  2552. });
  2553. }.bind(this));
  2554. }.bind(this));
  2555. },
  2556. savePersonItem: function(node, ids){
  2557. var values = [];
  2558. ids.each(function(id){
  2559. values.push(MWF.org.parseOrgData(id.data));
  2560. }.bind(this));
  2561. var name = node.get("name");
  2562. var oldValue = this.data[name];
  2563. this.data[name] = values;
  2564. this.checkHistory(name, oldValue, this.data[name]);
  2565. },
  2566. loadScriptListArea: function(){
  2567. var scriptAreas = this.propertyContent.getElements(".MWFScriptListArea");
  2568. scriptAreas.each(function (node) {
  2569. this._loadScriptListArea(node)
  2570. }.bind(this));
  2571. var formulaAreas = this.propertyContent.getElements(".MWFFormulaListArea");
  2572. formulaAreas.each(function (node) {
  2573. this._loadScriptListArea(node, "formula")
  2574. }.bind(this));
  2575. },
  2576. _loadScriptListArea: function(node, style){
  2577. node.empty();
  2578. var name = node.get("name");
  2579. if( !this.data[name] )this.data[name] = [];
  2580. this.data[name].each(function (d, index) {
  2581. var contentNode = new Element("div").inject(node);
  2582. var title = d.title;
  2583. if( !d.script ){
  2584. d.script = {"code": "", "html": ""};
  2585. }
  2586. var scriptContent = d.script;
  2587. var mode = node.dataset["mode"];
  2588. MWF.require("MWF.widget.ScriptArea", function(){
  2589. var scriptArea = new MWF.widget.ScriptArea(contentNode, {
  2590. "title": title,
  2591. "isbind": false,
  2592. "mode": mode || "javascript",
  2593. "maxObj": this.designer.formContentNode || this.designer.pageContentNode,
  2594. "onChange": function(){
  2595. if (this.module.form.scriptDesigner) this.module.form.scriptDesigner.addScriptItem(this.data[name][index].script, "code", this.data[name][index], "script");
  2596. var oldValue = this.data[name][index].script.code;
  2597. var json = scriptArea.toJson();
  2598. this.data[name][index].script.code = json.code;
  2599. this.checkHistory(name+"."+index+".script.code", oldValue, json.code);
  2600. }.bind(this),
  2601. "onSave": function(){
  2602. this.designer.saveForm();
  2603. }.bind(this),
  2604. "style": style || "default",
  2605. "runtime": "web"
  2606. });
  2607. scriptArea.load(scriptContent);
  2608. this["scriptArea_"+d.id] = scriptArea;
  2609. }.bind(this));
  2610. }.bind(this))
  2611. },
  2612. loadScriptArea: function(){
  2613. var scriptAreas = this.propertyContent.getElements(".MWFScriptArea");
  2614. var formulaAreas = this.propertyContent.getElements(".MWFFormulaArea");
  2615. this.loadScriptEditor(scriptAreas);
  2616. this.loadScriptEditor(formulaAreas, "formula");
  2617. },
  2618. loadScriptEditor: function(scriptAreas, style){
  2619. scriptAreas.each(function(node){
  2620. var title = node.get("title");
  2621. var name = node.get("name");
  2622. if (!this.data[name]) this.data[name] = {"code": "", "html": ""};
  2623. var scriptContent = this.data[name];
  2624. var mode = node.dataset["mode"];
  2625. MWF.require("MWF.widget.ScriptArea", function(){
  2626. var scriptArea = new MWF.widget.ScriptArea(node, {
  2627. "title": title,
  2628. "isbind": false,
  2629. "mode": mode || "javascript",
  2630. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  2631. "maxObj": this.designer.formContentNode || this.designer.pageContentNode,
  2632. "onChange": function(){
  2633. //this.data[name] = scriptArea.toJson();
  2634. if (!this.data[name]){
  2635. this.data[name] = {"code": "", "html": ""};
  2636. if (this.module.form.scriptDesigner) this.module.form.scriptDesigner.addScriptItem(this.data[name], "code", this.data, name);
  2637. }
  2638. var oldValue = this.data[name].code;
  2639. var json = scriptArea.toJson();
  2640. this.data[name].code = json.code;
  2641. this.checkHistory(name+".code", oldValue, json.code);
  2642. // console.log("script changed " + this.data[name].code);
  2643. //this.data[name].html = json.html;
  2644. }.bind(this),
  2645. "onSave": function(){
  2646. this.designer.saveForm();
  2647. }.bind(this),
  2648. "style": style || "default",
  2649. "runtime": "web"
  2650. });
  2651. scriptArea.load(scriptContent);
  2652. }.bind(this));
  2653. }.bind(this));
  2654. },
  2655. loadCssArea: function(style){
  2656. var cssAreas = this.propertyContent.getElements(".MWFCssArea");
  2657. cssAreas.each(function(node){
  2658. var title = node.get("title");
  2659. var name = node.get("name");
  2660. if (!this.data[name]) this.data[name] = {"code": "", "html": ""};
  2661. var cssContent = this.data[name];
  2662. o2.require("o2.widget.CssArea", function(){
  2663. var cssArea = new o2.widget.CssArea(node, {
  2664. "title": title,
  2665. "maxObj": this.designer.formContentNode || this.designer.pageContentNode,
  2666. "onChange": function(){
  2667. //this.data[name] = scriptArea.toJson();
  2668. if (!this.data[name]){
  2669. this.data[name] = {"code": "", "html": ""};
  2670. if (this.module.form.scriptDesigner) this.module.form.scriptDesigner.addScriptItem(this.data[name], "code", this.data, name);
  2671. }
  2672. var json = cssArea.toJson();
  2673. this.data[name].code = json.code;
  2674. cssArea.isChanged = true;
  2675. //this.data[name].html = json.html;
  2676. }.bind(this),
  2677. "onBlur": function(){
  2678. if (cssArea.isChanged){
  2679. this.changeData(name, node, "");
  2680. cssArea.isChanged = false;
  2681. }
  2682. }.bind(this),
  2683. "onSave": function(){
  2684. this.designer.saveForm();
  2685. }.bind(this),
  2686. "style": style || "default"
  2687. });
  2688. cssArea.load(cssContent);
  2689. }.bind(this));
  2690. }.bind(this));
  2691. },
  2692. loadActionStylesArea: function(){
  2693. var _self = this;
  2694. var actionAreas = this.propertyContent.getElements(".MWFActionStylesArea");
  2695. actionAreas.each(function(node){
  2696. var name = node.get("name");
  2697. var actionStyles = this.data[name];
  2698. MWF.require("MWF.widget.Maplist", function(){
  2699. var maps = [];
  2700. Object.each(actionStyles, function(v, k){
  2701. var mapNode = new Element("div").inject(node);
  2702. mapNode.empty();
  2703. var maplist = new MWF.widget.Maplist(mapNode, {
  2704. "title": k,
  2705. "collapse": true,
  2706. "onChange": function(){
  2707. var oldData = Object.clone(_self.data[name]);
  2708. maps.each(function(o){
  2709. _self.data[name][o.key] = o.map.toJson();
  2710. }.bind(this));
  2711. _self.changeData(name, node, oldData, true);
  2712. _self.checkHistory(name+"."+k, oldData[k], _self.data[name][k]);
  2713. }
  2714. });
  2715. maps.push({"key": k, "map": maplist});
  2716. maplist.load(v);
  2717. }.bind(this));
  2718. }.bind(this));
  2719. }.bind(this));
  2720. },
  2721. loadActionArea: function(){
  2722. var multiActionArea = this.propertyContent.getElements(".MWFMultiActionArea");
  2723. multiActionArea.each(function(node){
  2724. var name = node.get("name");
  2725. var actionContent = this.data[name];
  2726. var oldValue = actionContent ? JSON.parse( JSON.stringify(actionContent) ) : actionContent;
  2727. MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function(){
  2728. var options = {
  2729. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  2730. "isSystemTool" : true,
  2731. "target" : node.get("data-target"),
  2732. "onChange": function( historyOptions ){
  2733. historyOptions = historyOptions || {};
  2734. this.data[name] = actionEditor.data;
  2735. this.changeData(name, null, oldValue, true);
  2736. this.checkHistory(name, oldValue, null, false, name + historyOptions.compareName, historyOptions.force );
  2737. oldValue = JSON.parse( JSON.stringify(this.data[name]) );
  2738. }.bind(this)
  2739. };
  2740. if(node.get("data-systemToolsAddress")){
  2741. options.systemToolsAddress = node.get("data-systemToolsAddress");
  2742. }
  2743. var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, options);
  2744. actionEditor.load(actionContent);
  2745. }.bind(this));
  2746. }.bind(this));
  2747. var actionAreas = this.propertyContent.getElements(".MWFActionArea");
  2748. actionAreas.each(function(node){
  2749. var name = node.get("name");
  2750. var actionContent = this.data[name];
  2751. var oldValue = actionContent ? JSON.parse( JSON.stringify(actionContent) ) : actionContent;
  2752. MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function(){
  2753. // debugger;
  2754. // var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, {
  2755. // "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  2756. // "noCreate": true,
  2757. // "noDelete": true,
  2758. // "noCode": true,
  2759. // "onChange": function(){
  2760. // this.data[name] = actionEditor.data;
  2761. // }.bind(this)
  2762. // });
  2763. // actionEditor.load(this.module.defaultToolBarsData);
  2764. var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
  2765. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  2766. "onChange": function(historyOptions){
  2767. historyOptions = historyOptions || {};
  2768. this.data[name] = actionEditor.data;
  2769. this.changeData(name, null, oldValue, true);
  2770. this.checkHistory(name, oldValue, null, false, name + historyOptions.compareName, historyOptions.force );
  2771. oldValue = JSON.parse( JSON.stringify(this.data[name]) );
  2772. }.bind(this)
  2773. });
  2774. actionEditor.load(actionContent);
  2775. }.bind(this));
  2776. }.bind(this));
  2777. var actionAreas = this.propertyContent.getElements(".MWFDefaultActionArea");
  2778. actionAreas.each(function(node){
  2779. var name = node.get("name");
  2780. var actionContent = this.data[name] || this.module.defaultToolBarsData;
  2781. var oldValue = actionContent ? JSON.parse( JSON.stringify(actionContent) ) : actionContent;
  2782. MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function(){
  2783. var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
  2784. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  2785. "isSystemTool" : true,
  2786. "noCreate": true,
  2787. "noDelete": false,
  2788. "noCode": true,
  2789. "noReadShow": true,
  2790. "target" : node.get("data-target"),
  2791. "noEditShow": true,
  2792. "onChange": function(historyOptions){
  2793. historyOptions = historyOptions || {};
  2794. this.data[name] = actionEditor.data;
  2795. this.changeData(name, null, oldValue, true);
  2796. this.checkHistory(name, oldValue, null, false, name + historyOptions.compareName, historyOptions.force );
  2797. oldValue = JSON.parse( JSON.stringify(this.data[name]) );
  2798. }.bind(this)
  2799. });
  2800. actionEditor.load(actionContent);
  2801. // var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, {
  2802. // "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  2803. // "onChange": function(){
  2804. // this.data[name] = actionEditor.data;
  2805. // }.bind(this)
  2806. // });
  2807. // actionEditor.load(actionContent);
  2808. }.bind(this));
  2809. }.bind(this));
  2810. },
  2811. loadMaplist: function(){
  2812. var maplists = this.propertyContent.getElements(".MWFMaplist");
  2813. maplists.each(function(node){
  2814. var title = node.get("title");
  2815. var name = node.get("name");
  2816. var lName = name.toLowerCase();
  2817. var collapse = node.get("collapse");
  2818. var mapObj = this.data[name];
  2819. if (!mapObj) mapObj = {};
  2820. MWF.require("MWF.widget.Maplist", function(){
  2821. node.empty();
  2822. var maplist = new MWF.widget.Maplist(node, {
  2823. "title": title,
  2824. "collapse": (collapse) ? true : false,
  2825. "onChange": function(){
  2826. //this.data[name] = maplist.toJson();
  2827. //
  2828. debugger;
  2829. var oldData = this.data[name];
  2830. this.changeJsonDate(name, maplist.toJson());
  2831. this.changeStyle(name, oldData);
  2832. this.changeData(name, null, oldData);
  2833. }.bind(this),
  2834. "onDelete": function(key){
  2835. this.module.deletePropertiesOrStyles(name, key);
  2836. }.bind(this),
  2837. "isProperty": (lName.contains("properties") || lName.contains("property") || lName.contains("attribute"))
  2838. });
  2839. maplist.load(mapObj);
  2840. this.maplists[name] = maplist;
  2841. }.bind(this));
  2842. }.bind(this));
  2843. },
  2844. //loadPropertyTab: function(){
  2845. // var tabNodes = this.propertyContent.getElements(".MWFTab");
  2846. // if (tabNodes.length){
  2847. // var tmpNode = this.propertyContent.getFirst();
  2848. // var tabAreaNode = new Element("div", {
  2849. // "styles": this.form.css.propertyTabNode
  2850. // }).inject(tmpNode, "before");
  2851. //
  2852. // MWF.require("MWF.widget.Tab", function(){
  2853. // var tab = new MWF.widget.Tab(tabAreaNode, {"style": "formPropertyList"});
  2854. // tab.load();
  2855. // var tabPages = [];
  2856. // tabNodes.each(function(node){
  2857. // if (node.getStyle("display")!="none"){
  2858. // var page = tab.addTab(node, node.get("title"), false);
  2859. // tabPages.push(page);
  2860. // page.contentScrollNode = new Element("div", {"styles": {"height": "100%", "overflow": "hidden"}}).inject(page.contentNodeArea);
  2861. // node.inject(page.contentScrollNode);
  2862. // this.setScrollBar(page.contentScrollNode, "small", null, null);
  2863. // }
  2864. // }.bind(this));
  2865. // tabPages[0].showTab();
  2866. //
  2867. // this.propertyTab = tab;
  2868. //
  2869. // this.designer.resizeNode();
  2870. // }.bind(this), false);
  2871. // }
  2872. //},
  2873. loadPropertyTab: function(){
  2874. var tabNodes = this.propertyContent.getElements(".MWFTab");
  2875. if( this.ignoreSection ){
  2876. tabNodes = tabNodes.filter(function(node){
  2877. return node.get("title") !== MWF.xApplication.process.FormDesigner.LP.propertyTemplate.section;
  2878. })
  2879. }
  2880. var groupObject = {}; //data-group 属性可以表示不同的分组
  2881. if (tabNodes.length){
  2882. tabNodes.each( function(node){
  2883. var group = node.get("data-group") || "default";
  2884. groupObject[group] = groupObject[group] || [];
  2885. groupObject[group].push( node );
  2886. }.bind(this))
  2887. }
  2888. for( var group in groupObject ){
  2889. if( group === "default" ){
  2890. var tmpNode = this.propertyContent.getFirst();
  2891. var tabAreaNode = new Element("div", {
  2892. "styles": this.form.css.propertyTabNode
  2893. }).inject(tmpNode, "before");
  2894. MWF.require("MWF.widget.Tab", function(){
  2895. var tab = new MWF.widget.Tab(tabAreaNode, {"style": "formPropertyList"});
  2896. tab.load();
  2897. var tabPages = [];
  2898. groupObject["default"].each(function(node){
  2899. if (node.getStyle("display")!="none"){
  2900. var page = tab.addTab(node, node.get("title"), false);
  2901. tabPages.push(page);
  2902. page.contentScrollNode = new Element("div", {"styles": {"height": "100%", "overflow": "hidden"}}).inject(page.contentNodeArea);
  2903. node.inject(page.contentScrollNode);
  2904. this.setScrollBar(page.contentScrollNode, "small", null, null);
  2905. }
  2906. }.bind(this));
  2907. tabPages[this.propertyTabIndex || 0].showTab();
  2908. this.propertyTab = tab;
  2909. this.designer.resizeNode();
  2910. }.bind(this), false);
  2911. }else{
  2912. var tmpNode = groupObject[group][0];
  2913. var tabAreaNode = new Element("div", {
  2914. "styles": this.form.css.propertyTabNode
  2915. }).inject(tmpNode, "before");
  2916. MWF.require("MWF.widget.Tab", function(){
  2917. var tab = new MWF.widget.Tab(tabAreaNode, {"style": tmpNode.get("data-style") || "formPropertyList"});
  2918. tab.load();
  2919. var tabPages = [];
  2920. groupObject[group].each(function(node) {
  2921. var page = tab.addTab(node, node.get("title"), false);
  2922. tabPages.push(page);
  2923. node.store("tab", page);
  2924. if (node.getStyle("display") === "none"){
  2925. page.disableTab( true );
  2926. node.show();
  2927. }
  2928. }.bind(this));
  2929. for( var i=0; i<tabPages.length; i++ ){
  2930. if( !tabPages[i].disabled ){
  2931. tabPages[i].showTab();
  2932. break
  2933. }
  2934. }
  2935. }.bind(this), false);
  2936. }
  2937. }
  2938. },
  2939. setEditNodeEvent: function(){
  2940. var property = this;
  2941. // var inputs = this.process.propertyListNode.getElements(".editTableInput");
  2942. var inputs = this.propertyContent.getElements("input");
  2943. inputs.each(function(input){
  2944. var jsondata = input.get("name");
  2945. if (this.module){
  2946. var id = this.data.pid;
  2947. //var id = this.form.json.id;
  2948. // input.set("name", this.form.options.mode+id+jsondata);
  2949. input.set("name", id+jsondata);
  2950. }
  2951. if (jsondata){
  2952. var inputType = input.get("type").toLowerCase();
  2953. switch (inputType){
  2954. case "radio":
  2955. input.addEvent("change", function(e){
  2956. property.setRadioValue(jsondata, this);
  2957. });
  2958. input.addEvent("blur", function(e){
  2959. property.setRadioValue(jsondata, this, true);
  2960. });
  2961. input.addEvent("keydown", function(e){
  2962. e.stopPropagation();
  2963. });
  2964. property.setRadioValue(jsondata, input, true);
  2965. break;
  2966. case "checkbox":
  2967. input.addEvent("change", function(e){
  2968. property.setCheckboxValue(jsondata, this, true);
  2969. });
  2970. input.addEvent("click", function(e){
  2971. property.setCheckboxValue(jsondata, this);
  2972. });
  2973. input.addEvent("keydown", function(e){
  2974. e.stopPropagation();
  2975. });
  2976. break;
  2977. default:
  2978. input.addEvent("change", function(e){
  2979. var v = (this.type==="number") ? this.value.toFloat() : this.value;
  2980. property.setValue(jsondata, v, this);
  2981. });
  2982. input.addEvent("blur", function(e){
  2983. var v = (this.type==="number") ? this.value.toFloat() : this.value;
  2984. property.setValue(jsondata, v, this, true);
  2985. });
  2986. input.addEvent("keydown", function(e){
  2987. if (e.code==13){
  2988. var v = (this.type==="number") ? this.value.toFloat() : this.value;
  2989. property.setValue(jsondata, v, this);
  2990. }
  2991. e.stopPropagation();
  2992. });
  2993. }
  2994. }
  2995. }.bind(this));
  2996. var selects = this.propertyContent.getElements("select");
  2997. selects.each(function(select){
  2998. var jsondata = select.get("name");
  2999. if (jsondata){
  3000. select.addEvent("change", function(e){
  3001. property.setSelectValue(jsondata, this);
  3002. });
  3003. //property.setSelectValue(jsondata, select);
  3004. }
  3005. });
  3006. var textareas = this.propertyContent.getElements("textarea");
  3007. textareas.each(function(input){
  3008. var jsondata = input.get("name");
  3009. if (jsondata){
  3010. input.addEvent("change", function(e){
  3011. property.setValue(jsondata, this.value);
  3012. });
  3013. input.addEvent("blur", function(e){
  3014. property.setValue(jsondata, this.value);
  3015. });
  3016. input.addEvent("keydown", function(e){
  3017. e.stopPropagation();
  3018. });
  3019. }
  3020. }.bind(this));
  3021. },
  3022. checkHistory: function(name, oldValue, newValue, notSetEditStyle, compareName, force){
  3023. if( this.isLoaded() && this.module.form.history ){
  3024. this.module.checkPropertyHistory(name, oldValue, newValue, notSetEditStyle, compareName, force);
  3025. }
  3026. },
  3027. changeStyle: function(name, oldData){
  3028. this.module.setPropertiesOrStyles(name, oldData);
  3029. },
  3030. changeData: function(name, input, oldValue, notCheckHistory, historyNotSetEditStyle){
  3031. if(!notCheckHistory){
  3032. var flag = false;
  3033. if( input && input.hasAttribute )flag = input.hasAttribute("data-notAutoHistory");
  3034. if(!flag)this.checkHistory(name, oldValue, null, historyNotSetEditStyle);
  3035. }
  3036. this.module._setEditStyle(name, input, oldValue);
  3037. },
  3038. changeJsonDate: function(key, value){
  3039. if (typeOf(key)!=="array") key = [key];
  3040. var o = this.data;
  3041. var len = key.length-1;
  3042. key.each(function(n, i){
  3043. if (i<len) {
  3044. if (!o.hasOwnProperty(n)) o[n] = {};
  3045. //if (!o[n]) o[n] = {};
  3046. o = o[n];
  3047. }
  3048. }.bind(this));
  3049. o[key[len]] = value;
  3050. //this.data[key] = value;
  3051. },
  3052. setRadioValue: function(name, input, notCheckHistory){
  3053. if (input.checked){
  3054. var i = name.indexOf("*");
  3055. var names = (i==-1) ? name.split(".") : name.substr(i+1, name.length).split(".");
  3056. var value = input.value;
  3057. if (value=="false") value = false;
  3058. if (value=="true") value = true;
  3059. var oldValue = this.data;
  3060. for (var idx = 0; idx<names.length; idx++){
  3061. if (!oldValue[names[idx]]){
  3062. oldValue = oldValue[names[idx]];
  3063. //oldValue = null;
  3064. break;
  3065. }else{
  3066. oldValue = oldValue[names[idx]];
  3067. }
  3068. }
  3069. // var value = input.value;
  3070. // if (value==="false") value = false;
  3071. // if (value==="true") value = true;
  3072. //var oldValue = this.data[name];
  3073. this.changeJsonDate(names, value);
  3074. //由于加载property的时候,会自动setRadioValue,这时候就不要检查历史了notCheckHistory
  3075. var historyNotSetEditStyle = false;
  3076. //但是ElementUI有isPropertyLoaded判断,这个时候又需要setEditStyle了。
  3077. if( this.module && this.module.vm )historyNotSetEditStyle = false;
  3078. this.changeData(name, input, oldValue, notCheckHistory, historyNotSetEditStyle);
  3079. }
  3080. },
  3081. setCheckboxValue: function(name, input, notCheckHistory){
  3082. //var id = this.module.json.id;
  3083. //var id = this.form.json.id;
  3084. var id = this.data.pid;
  3085. // var checkboxList = $$("input[name='"+this.form.options.mode+id+name+"']");
  3086. var checkboxList = $$("input[name='"+id+name+"']");
  3087. var values = [];
  3088. checkboxList.each(function(checkbox){
  3089. if (checkbox.get("checked")){
  3090. values.push(checkbox.value);
  3091. }
  3092. });
  3093. var oldValue = this.data[name];
  3094. //this.data[name] = values;
  3095. this.changeJsonDate(name, values);
  3096. this.changeData(name, input, oldValue, notCheckHistory);
  3097. },
  3098. setSelectValue: function(name, select){
  3099. var idx = select.selectedIndex;
  3100. var options = select.getElements("option");
  3101. var value = "";
  3102. if (options[idx]){
  3103. value = options[idx].get("value");
  3104. }
  3105. var oldValue = this.data[name];
  3106. //this.data[name] = value;
  3107. this.changeJsonDate(name, value);
  3108. this.changeData(name, select, oldValue);
  3109. },
  3110. setValue: function(name, value, obj, notCheckHistory){
  3111. debugger;
  3112. if (name==="id"){
  3113. if (value!==this.module.json.id) {
  3114. if (!value) {
  3115. this.designer.notice(MWF.APPFD.LP.notNullId, "error", this.module.form.designer.propertyContentArea, {
  3116. x: "right",
  3117. y: "bottom"
  3118. });
  3119. obj.focus();
  3120. return false;
  3121. }else if ( value.test(/^\d+$/) ) {
  3122. this.designer.notice(MWF.APPFD.LP.notNumberId, "error", this.module.form.designer.propertyContentArea, {
  3123. x: "right",
  3124. y: "bottom"
  3125. });
  3126. obj.focus();
  3127. return false;
  3128. }else if ( value.indexOf("..") > -1 ) {
  3129. this.designer.notice(MWF.APPFD.LP.notDoubleDotId, "error", this.module.form.designer.propertyContentArea, {
  3130. x: "right",
  3131. y: "bottom"
  3132. });
  3133. obj.focus();
  3134. return false;
  3135. }else if ( /\{|\}|\<|\>|\!|\'|\"|\,|\;/i.test( value ) ) {
  3136. this.designer.notice(MWF.APPFD.LP.notSpecialCharacterId, "error", this.module.form.designer.propertyContentArea, {
  3137. x: "right",
  3138. y: "bottom"
  3139. });
  3140. obj.focus();
  3141. return false;
  3142. } else {
  3143. var check = this.module.form.checkModuleId(value, this.module.json.type);
  3144. if (check.elementConflict) {
  3145. this.designer.notice(MWF.APPFD.LP.repetitionsId, "error", this.module.form.designer.propertyContentArea, {
  3146. x: "right",
  3147. y: "bottom"
  3148. });
  3149. obj.focus();
  3150. return false;
  3151. } else {
  3152. var json = this.module.form.json.moduleList[this.module.json.id];
  3153. this.module.form.json.moduleList[value] = json;
  3154. delete this.module.form.json.moduleList[this.module.json.id];
  3155. }
  3156. }
  3157. if( this.alertMode )return;
  3158. if( (this.module.json.type || "").substr(0, 2) === "El" ){
  3159. for( var key in this.module.json ){
  3160. if( value === key ){
  3161. var text = Object.keys(this.module.json).join(", ");
  3162. this.alertMode = true;
  3163. this.designer.alert("error", "center", MWF.APPFD.LP.invalidElementUIId, text, 800, 300, function(){
  3164. this.alertMode = false;
  3165. }.bind(this));
  3166. return false;
  3167. }
  3168. }
  3169. }
  3170. // if (this.module.form.json.moduleList[value]){
  3171. // this.designer.notice(MWF.APPFD.LP.repetitionsId, "error", this.module.form.designer.propertyContentArea, {x:"right", y:"bottom"});
  3172. // obj.focus();
  3173. // return false;
  3174. // }else{
  3175. // var flag = false;
  3176. // if (this.module.form.subformList){
  3177. // Object.each(this.module.form.subformList, function(o, k){
  3178. // if (o.subformData.moduleList[value] && o.subformData.moduleList[value] ) flag = true;
  3179. // });
  3180. // }
  3181. // if (flag){
  3182. // this.designer.notice(MWF.APPFD.LP.repetitionsId, "error", this.module.form.designer.propertyContentArea, {x:"right", y:"bottom"});
  3183. // obj.focus();
  3184. // return false;
  3185. // }else{
  3186. // var json = this.module.form.json.moduleList[this.module.json.id];
  3187. // this.module.form.json.moduleList[value]=json;
  3188. // delete this.module.form.json.moduleList[this.module.json.id];
  3189. // }
  3190. // }
  3191. }
  3192. }
  3193. //var oldValue = this.data[name];
  3194. var names = name.split(".");
  3195. var oldValue = this.data;
  3196. for (var idx = 0; idx<names.length; idx++){
  3197. if (!oldValue.hasOwnProperty(names[idx])){
  3198. oldValue = null;
  3199. break;
  3200. }else{
  3201. oldValue = oldValue[names[idx]];
  3202. }
  3203. }
  3204. //this.data[name] = value;
  3205. this.changeJsonDate(names, value);
  3206. this.changeData(name, obj, oldValue, notCheckHistory);
  3207. },
  3208. setEditNodeStyles: function(node){
  3209. var nodes = node.getChildren();
  3210. if (nodes.length){
  3211. nodes.each(function(el){
  3212. var cName = el.get("class");
  3213. if (cName){
  3214. if (this.form.css[cName]) el.setStyles(this.form.css[cName]);
  3215. }
  3216. this.setEditNodeStyles(el);
  3217. }.bind(this));
  3218. }
  3219. },
  3220. loadScriptInput: function(){
  3221. var scriptNodes = this.propertyContent.getElements(".MWFScript");
  3222. scriptNodes.each(function(node){
  3223. MWF.require("MWF.widget.ScriptEditor", function(){
  3224. var script = new MWF.widget.ScriptEditor(node, {
  3225. "onPostSave": function(script){
  3226. this.saveScriptItem(node, script);
  3227. }.bind(this),
  3228. "onQueryDelete": function(script){
  3229. this.deleteScriptItem(node, script);
  3230. }.bind(this)
  3231. });
  3232. this.setScriptItems(script, node);
  3233. }.bind(this));
  3234. }.bind(this));
  3235. },
  3236. deleteScriptItem: function(node, script){
  3237. var jsondata = node.get("name");
  3238. this.data[jsondata].erase(script.data.id);
  3239. this.process.scripts[script.data.id] = null;
  3240. delete this.process.scripts[script.data.id];
  3241. this.process.process.scriptList.erase(script.data);
  3242. },
  3243. saveScriptItem: function(node, script){
  3244. var jsondata = node.get("name");
  3245. var scriptList = this.data[jsondata];
  3246. var data = script.data;
  3247. var scriptData = this.process.scripts[script.data.id];
  3248. if (!scriptData){
  3249. this.process.process.scriptList.push(data);
  3250. this.process.scripts[script.data.id] = data;
  3251. }
  3252. if (scriptList.indexOf(data.id) == -1){
  3253. this.data[jsondata].push(data.id);
  3254. }
  3255. },
  3256. setScriptItems: function(script, node){
  3257. var jsondata = node.get("name");
  3258. var scriptList = this.data[jsondata];
  3259. scriptList.each(function(id){
  3260. if (id){
  3261. var data = this.process.scripts[id];
  3262. if (data) script.setScriptItem(data);
  3263. }
  3264. }.bind(this));
  3265. },
  3266. loadSmartBISelect: function(){
  3267. var SmartBINodes = this.propertyContent.getElements(".MWFSmartBISelect");
  3268. var SmartBIToolbarNodes = this.propertyContent.getElements(".MWFSmartBIToolbar");
  3269. var SmartBILeftTreeNodes = this.propertyContent.getElements(".MWFSmartBILeftTree");
  3270. if (SmartBINodes.length){
  3271. var SmartBIAction = o2.Actions.load("x_custom_smartbi_assemble_control");
  3272. var node = SmartBINodes[0];
  3273. var select = new Element("select").inject(node);
  3274. if (SmartBIAction) this.setSmartBIOptions(select);
  3275. select.addEvent("change", function(e){
  3276. var value = e.target.options[e.target.selectedIndex].value;
  3277. this.setValue(e.target.getParent("div").get("name"), value, select);
  3278. }.bind(this));
  3279. var refreshNode = new Element("div.propertyRefreshFormNode",{styles:this.form.css.propertyRefreshFormNode}).inject(node);
  3280. refreshNode.addEvent("click",function(){
  3281. SmartBIAction.ResourceAction.sync(function(){
  3282. this.setSmartBIOptions(select)
  3283. }.bind(this))
  3284. }.bind(this))
  3285. }
  3286. if(SmartBIToolbarNodes.length){
  3287. SmartBIToolbarNodes.addEvent("change",function(e){
  3288. var value = e.target.get("value");
  3289. if (value=="false") value = false;
  3290. if (value=="true") value = true;
  3291. this.setValue(e.target.getParent("div").get("name"), value);
  3292. }.bind(this));
  3293. }
  3294. if(SmartBILeftTreeNodes.length){
  3295. SmartBILeftTreeNodes.addEvent("change",function(e){
  3296. var value = e.target.get("value");
  3297. if (value=="false") value = false;
  3298. if (value=="true") value = true;
  3299. this.setValue(e.target.getParent("div").get("name"), value);
  3300. }.bind(this));
  3301. }
  3302. },
  3303. setSmartBIOptions:function(node){
  3304. node.empty();
  3305. new Element("option",{text:"none",value:"none"}).inject(node);
  3306. var SmartBIAction = o2.Actions.load("x_custom_smartbi_assemble_control");
  3307. var selectedValue = this.data.smartbiresource;
  3308. SmartBIAction.ResourceAction.list(function(json){
  3309. json.data.each(function(d){
  3310. new Element("option", {
  3311. "text": d.name,
  3312. "value": d.resid,
  3313. "selected": (selectedValue==d.resid)
  3314. }).inject(node);
  3315. });
  3316. });
  3317. },
  3318. loadHelp: function () {
  3319. var nodes = this.propertyContent.getElements(".MWFHelp");
  3320. if (nodes.length){
  3321. nodes.each(function(node){
  3322. var html = node.get("text");
  3323. node.empty();
  3324. MWF.xDesktop.requireApp("Template", "MTooltips", function() {
  3325. new MTooltips(this.designer.node, node, this.designer, {}, {
  3326. "nodeStyles":{
  3327. "max-width": "370px",
  3328. "width": "370px",
  3329. "line-height": "24px",
  3330. "font-size": "14px"
  3331. },
  3332. "onCustomContent": function (content, node) {
  3333. content.set("html", html);
  3334. }
  3335. });
  3336. }.bind(this))
  3337. }.bind(this));
  3338. }
  3339. }
  3340. });
  3341. MWF.xApplication.process.FormDesigner.PropertyMulti = new Class({
  3342. Extends: MWF.xApplication.process.FormDesigner.Property,
  3343. Implements: [Options, Events],
  3344. initialize: function(form, modules, propertyNode, designer, options){
  3345. this.setOptions(options);
  3346. this.modules = modules;
  3347. this.form = form;
  3348. // this.data = module.json;
  3349. this.data = {};
  3350. this.htmlPath = this.options.path;
  3351. this.designer = designer;
  3352. this.maplists = {};
  3353. this.propertyNode = propertyNode;
  3354. },
  3355. load: function(){
  3356. if (this.fireEvent("queryLoad")){
  3357. MWF.getRequestText(this.htmlPath, function(responseText, responseXML){
  3358. this.htmlString = responseText;
  3359. MWF.require("MWF.widget.JsonTemplate", function(){
  3360. this.fireEvent("postLoad");
  3361. }.bind(this));
  3362. }.bind(this));
  3363. }
  3364. },
  3365. show: function(){
  3366. if (!this.propertyContent){
  3367. if (this.htmlString){
  3368. this.htmlString = o2.bindJson(this.htmlString, {"lp": MWF.xApplication.process.FormDesigner.LP.propertyTemplate});
  3369. this.JsonTemplate = new MWF.widget.JsonTemplate({}, this.htmlString);
  3370. this.propertyContent = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.propertyNode);
  3371. this.propertyContent.set("html", this.JsonTemplate.load());
  3372. this.setEditNodeEvent();
  3373. this.setEditNodeStyles(this.propertyContent);
  3374. this.loadPropertyTab();
  3375. this.loadMaplist();
  3376. this.loadScriptArea();
  3377. this.loadTreeData();
  3378. this.loadArrayList();
  3379. //this.loadEventsEditor();
  3380. //this.loadHTMLArea();
  3381. //this.loadJSONArea();
  3382. // this.loadScriptInput();
  3383. //MWF.process.widget.EventsEditor
  3384. }
  3385. }else{
  3386. this.propertyContent.setStyle("display", "block");
  3387. }
  3388. },
  3389. hide: function(){
  3390. if (this.propertyContent) this.propertyContent.destroy();
  3391. },
  3392. loadMaplist: function(){
  3393. var maplists = this.propertyContent.getElements(".MWFMaplist");
  3394. maplists.each(function(node){
  3395. var title = node.get("title");
  3396. var name = node.get("name");
  3397. var lName = name.toLowerCase();
  3398. var collapse = node.get("collapse");
  3399. var mapObj = this.data[name];
  3400. if (!mapObj) mapObj = {};
  3401. MWF.require("MWF.widget.Maplist", function(){
  3402. node.empty();
  3403. var maplist = new MWF.widget.Maplist(node, {
  3404. "title": title,
  3405. "collapse": (collapse) ? true : false,
  3406. "onChange": function(){
  3407. //this.data[name] = maplist.toJson();
  3408. debugger;
  3409. var oldData = this.getOldValueList(name);
  3410. this.changeJsonDate(name, maplist.toJson());
  3411. this.changeStyle(name, oldData);
  3412. this.changeData(name, null, oldData);
  3413. this.checkHistory( name, oldData );
  3414. this.reshowProperty();
  3415. }.bind(this),
  3416. "onDelete": function(key){
  3417. this.modules.each(function (module) {
  3418. module.deletePropertiesOrStyles(name, key);
  3419. })
  3420. }.bind(this),
  3421. "isProperty": (lName.contains("properties") || lName.contains("property") || lName.contains("attribute"))
  3422. });
  3423. maplist.load(mapObj);
  3424. this.maplists[name] = maplist;
  3425. }.bind(this));
  3426. }.bind(this));
  3427. },
  3428. setEditNodeEvent: function(){
  3429. var property = this;
  3430. // var inputs = this.process.propertyListNode.getElements(".editTableInput");
  3431. var inputs = this.propertyContent.getElements("input");
  3432. inputs.each(function(input){
  3433. var jsondata = input.get("name");
  3434. if (this.module){
  3435. var id = this.data.pid;
  3436. //var id = this.form.json.id;
  3437. // input.set("name", this.form.options.mode+id+jsondata);
  3438. input.set("name", id+jsondata);
  3439. }
  3440. if (jsondata){
  3441. var inputType = input.get("type").toLowerCase();
  3442. switch (inputType){
  3443. case "radio":
  3444. input.addEvent("change", function(e){
  3445. var oldValueList = property.getOldValueList(jsondata);
  3446. property.setRadioValue(jsondata, this, true);
  3447. property.checkHistory( jsondata, oldValueList );
  3448. property.reshowProperty();
  3449. });
  3450. input.addEvent("blur", function(e){
  3451. property.setRadioValue(jsondata, this, true);
  3452. });
  3453. input.addEvent("keydown", function(e){
  3454. e.stopPropagation();
  3455. });
  3456. property.setRadioValue(jsondata, input, true);
  3457. break;
  3458. case "checkbox":
  3459. input.addEvent("change", function(e){
  3460. property.setCheckboxValue(jsondata, this, true);
  3461. });
  3462. input.addEvent("click", function(e){
  3463. var oldValueList = property.getOldValueList(jsondata);
  3464. property.setCheckboxValue(jsondata, this, true);
  3465. property.checkHistory( jsondata, oldValueList );
  3466. property.reshowProperty();
  3467. });
  3468. input.addEvent("keydown", function(e){
  3469. e.stopPropagation();
  3470. });
  3471. break;
  3472. default:
  3473. input.addEvent("change", function(e){
  3474. var oldValueList = property.getOldValueList(jsondata);
  3475. var v = (this.type==="number") ? this.value.toFloat() : this.value;
  3476. property.setValue(jsondata, v, this, true);
  3477. property.checkHistory( jsondata, oldValueList );
  3478. property.reshowProperty();
  3479. });
  3480. input.addEvent("blur", function(e){
  3481. var v = (this.type==="number") ? this.value.toFloat() : this.value;
  3482. property.setValue(jsondata, v, this, true);
  3483. });
  3484. input.addEvent("keydown", function(e){
  3485. if (e.code==13){
  3486. var oldValueList = property.getOldValueList(jsondata);
  3487. var v = (this.type==="number") ? this.value.toFloat() : this.value;
  3488. property.setValue(jsondata, v, this, true);
  3489. property.checkHistory( jsondata, oldValueList );
  3490. property.reshowProperty();
  3491. }
  3492. e.stopPropagation();
  3493. });
  3494. }
  3495. }
  3496. }.bind(this));
  3497. var selects = this.propertyContent.getElements("select");
  3498. selects.each(function(select){
  3499. var jsondata = select.get("name");
  3500. if (jsondata){
  3501. select.addEvent("change", function(e){
  3502. var oldValueList = property.getOldValueList(jsondata);
  3503. property.setSelectValue(jsondata, this);
  3504. property.checkHistory( jsondata, oldValueList );
  3505. });
  3506. //property.setSelectValue(jsondata, select);
  3507. }
  3508. });
  3509. var textareas = this.propertyContent.getElements("textarea");
  3510. textareas.each(function(input){
  3511. var jsondata = input.get("name");
  3512. if (jsondata){
  3513. input.addEvent("change", function(e){
  3514. var oldValueList = property.getOldValueList(jsondata);
  3515. property.setValue(jsondata, this.value);
  3516. property.checkHistory( jsondata, oldValueList );
  3517. });
  3518. input.addEvent("blur", function(e){
  3519. property.setValue(jsondata, this.value, true);
  3520. });
  3521. input.addEvent("keydown", function(e){
  3522. e.stopPropagation();
  3523. });
  3524. }
  3525. }.bind(this));
  3526. },
  3527. changeStyle: function(name){
  3528. this.modules.each(function(module){
  3529. module.setPropertiesOrStyles(name);
  3530. }.bind(this));
  3531. },
  3532. getOldValueList: function(name){
  3533. var oldValueList = [];
  3534. this.modules.each(function(module){
  3535. var value = module.json[name];
  3536. var v = o2.typeOf( value ) === "object" ? Object.clone(value) : value;
  3537. oldValueList.push( v );
  3538. }.bind(this));
  3539. return oldValueList;
  3540. },
  3541. checkHistory: function(name, oldValueList, newValue){
  3542. if( this.form.history ){
  3543. var newV = typeOf( newValue ) === "object" ? Object.clone(newValue) : newValue;
  3544. this.form.checkMultiPropertyHistory(name, oldValueList, newV, this.modules);
  3545. }
  3546. },
  3547. changeData: function(name, input, oldValue){
  3548. this.modules.each(function(module){
  3549. module._setEditStyle(name, input, oldValue);
  3550. }.bind(this));
  3551. },
  3552. changeJsonDate: function(key, value){
  3553. //alert(key+": "+value );
  3554. this.modules.each(function(module){
  3555. var v = typeOf(value) === "object" ? Object.clone(value) : value;
  3556. module.json[key] = v;
  3557. }.bind(this));
  3558. },
  3559. reshowProperty: function(){
  3560. this.modules.each(function(module){
  3561. if( module.property )module.property.reset();
  3562. }.bind(this));
  3563. }
  3564. });