Property.js 173 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793
  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. debugger;
  124. this.loadActionArea();
  125. this.loadActionStylesArea();
  126. this.loadHTMLArea();
  127. this.loadJSONArea();
  128. this.loadFormSelect();
  129. this.loadSubformSelect();
  130. this.loadComponentSelect();
  131. //this.loadPageSelect();
  132. this.loadWidgetSelect();
  133. this.loadANNModelSelect();
  134. //this.loadViewSelect();
  135. this.loadValidation();
  136. this.loadIconSelect();
  137. this.loadLabelFlagSelect();
  138. this.loadImageClipper();
  139. this.loadImageFileSelect();
  140. this.loadParameterEditor();
  141. this.loadContextRoot();
  142. this.loadUnitTypeSelector();
  143. this.loadSourceTestRestful();
  144. this.loadSidebarPosition();
  145. this.loadViewFilter();
  146. this.loadViewFilterWithTemplate();
  147. this.loadStatementFilter();
  148. this.loadStatementFilterWithTemplate();
  149. this.loadDocumentTempleteSelect();
  150. this.loadFieldConfig();
  151. this.loadElSelectIcon();
  152. this.loadVueElementUI();
  153. this.loadElCommonPreview();
  154. this.loadElTreeData();
  155. this.loadElTDropDownData();
  156. this.loadElCarouselContent();
  157. if ( !this.ignoreSection ){
  158. this.loadSectionMerger();
  159. this.loadSectionDisplayer();
  160. }
  161. this.loadSmartBISelect();
  162. this.loadDictionaryItem();
  163. this.loadQueryViewItem();
  164. this.loadQueryStatementItem();
  165. this.loadHelp();
  166. this.ready = true;
  167. if( this.postShow )this.postShow();
  168. this.checkLoaded( true );
  169. // this.loadScriptIncluder();
  170. // this.loadDictionaryIncluder();
  171. //this.testRestful();
  172. // this.loadScriptInput();
  173. //MWF.process.widget.EventsEditor
  174. }
  175. }.bind(this));
  176. }else{
  177. this.propertyContent.setStyle("display", "block");
  178. this.fireEvent("postShow");
  179. }
  180. (new Fx.Scroll(layout.desktop.node)).toTop();
  181. },
  182. isLoaded: function(){
  183. return this.ready && this.loadingCount === this.loadedCount;
  184. },
  185. checkLoaded: function( flag ){
  186. if(!flag)this.loadedCount++;
  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. // var editor = new MWF.widget.HtmlEditor(htmlNode);
  401. // editor.load(function(){
  402. // editor.editor.setValue(copy.outerHTML)
  403. // }.bind(this));
  404. //}.bind(this));
  405. o2.load("JSBeautifier_html", function(){
  406. htmlNode.set("text", html_beautify(copy.outerHTML, {"indent_size":1}));
  407. o2.require("o2.widget.ace", function(){
  408. MWF.widget.ace.load(function(){
  409. o2.load("../o2_lib/ace/src-min-noconflict/ext-static_highlight.js", function(){
  410. var highlight = ace.require("ace/ext/static_highlight");
  411. highlight(htmlNode, {mode: "ace/mode/html", theme: "ace/theme/eclipse", "fontSize": 16});
  412. }.bind(this));
  413. }.bind(this));
  414. }.bind(this));
  415. copy.destroy();
  416. }.bind(this));
  417. }.bind(this)
  418. });
  419. }
  420. }.bind(this));
  421. }
  422. },
  423. loadSidebarPosition: function(){
  424. var nodes = this.propertyContent.getElements(".MWFSidebarReposition");
  425. if (nodes.length){
  426. nodes.each(function(node){
  427. node.addEvent("click", function(){
  428. this.module.json.styles.top = "";
  429. this.module.loadPosition();
  430. }.bind(this));
  431. }.bind(this));
  432. }
  433. },
  434. loadANNModelSelect: function(){
  435. var nodes = this.propertyContent.getElements(".MWFANNModelSelect");
  436. if (nodes.length){
  437. this.getModelList(function(){
  438. nodes.each(function(node){
  439. var select = new Element("select").inject(node);
  440. select.addEvent("change", function(e){
  441. this.setValue(e.target.getParent("div").get("name"), e.target.options[e.target.selectedIndex].value, select);
  442. }.bind(this));
  443. this.setModelSelectOptions(node, select);
  444. var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
  445. refreshNode.addEvent("click", function(e){
  446. this.getModelList(function(){
  447. this.setModelSelectOptions(node, select);
  448. }.bind(this), true);
  449. }.bind(this));
  450. }.bind(this));
  451. }.bind(this));
  452. }
  453. },
  454. getModelList: function(callback, refresh){
  455. if (!this.models || refresh){
  456. var action = o2.Actions.get("x_query_assemble_designer");
  457. if (action.listModel) action.listModel(function(json){
  458. this.models = json.data;
  459. if (callback) callback();
  460. }.bind(this));
  461. }else{
  462. if (callback) callback();
  463. }
  464. },
  465. setModelSelectOptions: function(node, select){
  466. var name = node.get("name");
  467. select.empty();
  468. var option = new Element("option", {"text": "none"}).inject(select);
  469. this.models.each(function(model){
  470. var option = new Element("option", {
  471. "text": model.name,
  472. "value": model.id,
  473. "selected": (this.data[name]==model.id)
  474. }).inject(select);
  475. }.bind(this));
  476. },
  477. loadFormSelect: function(){
  478. var formNodes = this.propertyContent.getElements(".MWFFormSelect");
  479. if (formNodes.length){
  480. this.loadingCount++;
  481. this.getFormList(function(){
  482. formNodes.each(function(node){
  483. var select = new Element("select").inject(node);
  484. select.addEvent("change", function(e){
  485. var value = e.target.options[e.target.selectedIndex].value;
  486. this.setValue(e.target.getParent("div").get("name"), value, select);
  487. }.bind(this));
  488. this.setFormSelectOptions(node, select);
  489. var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
  490. refreshNode.addEvent("click", function(e){
  491. this.getFormList(function(){
  492. this.setFormSelectOptions(node, select);
  493. }.bind(this), true);
  494. }.bind(this));
  495. var openNode = new Element("div", {"styles": this.form.css.propertyOpenFormNode}).inject(node);
  496. openNode.addEvent("click", function(e){
  497. var name = node.get("name");
  498. this._openForm( this.data[name] );
  499. }.bind(this));
  500. //select.addEvent("click", function(e){
  501. // this.setFormSelectOptions(node, select);
  502. //}.bind(this));
  503. }.bind(this));
  504. this.checkLoaded();
  505. }.bind(this));
  506. }
  507. },
  508. setFormSelectOptions: function(node, select){
  509. var name = node.get("name");
  510. select.empty();
  511. var option = new Element("option", {"text": "none"}).inject(select);
  512. this.forms.each(function(form){
  513. if( this.form.json.id !== form.id ){
  514. var option = new Element("option", {
  515. "text": form.name,
  516. "value": form.id,
  517. "selected": (this.data[name]==form.id)
  518. }).inject(select);
  519. }
  520. }.bind(this));
  521. },
  522. getFormList: function(callback, refresh){
  523. if (!this.forms || refresh){
  524. this.form.designer.actions.listForm(this.form.designer.application.id, function(json){
  525. this.forms = json.data;
  526. if (callback) callback();
  527. }.bind(this));
  528. }else{
  529. if (callback) callback();
  530. }
  531. },
  532. loadComponentSelect: function(){
  533. var componentSlectNodes = this.propertyContent.getElements(".MWFComponentSelect");
  534. if (componentSlectNodes.length){
  535. componentSlectNodes.each( function( node ){
  536. var name = node.get("name");
  537. var select;
  538. this.getComponentList(function(){
  539. select = new Element("select").inject(node);
  540. select.addEvent("change", function(e){
  541. var value = select.options[select.selectedIndex].value;
  542. this.setValue(name, value, select);
  543. }.bind(this));
  544. this.setComponentSelectOptions(node, select);
  545. var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
  546. refreshNode.addEvent("click", function(e){
  547. this.getComponentList(function(){
  548. this.setComponentSelectOptions(node, select);
  549. }.bind(this), true);
  550. }.bind(this));
  551. }.bind(this), false );
  552. return select;
  553. }.bind(this))
  554. }
  555. },
  556. setComponentSelectOptions: function(node, select){
  557. var name = node.get("name");
  558. var value = this.data[name] || "";
  559. select.empty();
  560. var option = new Element("option", {"text": "none"}).inject(select);
  561. this.components.each(function(component){
  562. var option = new Element("option", {
  563. "text": component.title,
  564. "value": component.path,
  565. "selected": (this.data[name]==component.path)
  566. }).inject(select);
  567. }.bind(this));
  568. },
  569. getComponentList: function(callback, refresh){
  570. if (!this.components || refresh){
  571. o2.Actions.load("x_component_assemble_control").ComponentAction.listAll( function(json){
  572. this.components = json.data;
  573. if (callback) callback();
  574. }.bind(this), null, false);
  575. }else{
  576. if (callback) callback();
  577. }
  578. },
  579. loadSubformSelect: function(){
  580. var subformContainers = this.propertyContent.getElements(".MWFSubFormSelectContainer");
  581. if (subformContainers.length){
  582. subformContainers.each( function( container ){
  583. var appSelectNode = container.getElement(".MWFSubformAppSelect");
  584. var formSelectNode = container.getElement(".MWFSubformSelect");
  585. var formSelect;
  586. var appNodeName = appSelectNode.get("name");
  587. var formNodeName = formSelectNode.get("name");
  588. this.loadProcessApplictionSelect( appSelectNode, appNodeName, function( apps ){
  589. var oldValue = this.data[appNodeName] || "";
  590. this.data[appNodeName] = !apps.length ? "" : apps[0].data.id;
  591. if( oldValue !== this.data[appNodeName] ){
  592. this.getSubFormList(function(){
  593. this.setSubformSelectOptions(formSelectNode, formSelect);
  594. formSelect.fireEvent("change", [null, {
  595. name: appNodeName,
  596. fromValue: oldValue,
  597. toValue: this.data[appNodeName]
  598. }]);
  599. }.bind(this), true, appNodeName);
  600. }
  601. }.bind(this));
  602. formSelect = this._loadSubformSelect( formSelectNode, formNodeName, appNodeName ) ;
  603. }.bind(this))
  604. }
  605. },
  606. loadProcessApplictionSelect : function( node, appNodeName, callback ){
  607. var application = appNodeName ? this.data[appNodeName] : "";
  608. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function() {
  609. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  610. "title" : this.form.designer.lp.selectApplication,
  611. "type": "application",
  612. "count" : 1,
  613. "names": application ? [ {id : application} ] : [],
  614. "onChange": function (apps) {
  615. callback(apps)
  616. }.bind(this)
  617. });
  618. }.bind(this))
  619. },
  620. _loadSubformSelect : function( node, formNodeName, appNodeName ){
  621. this.subforms = null;
  622. var select = new Element("select").inject(node);
  623. var oldValue = this.data[formNodeName];
  624. this.getSubFormList(function(){
  625. select.addEvent("change", function(e, appChange){
  626. var value = select.options[select.selectedIndex].value;
  627. if( appChange ){
  628. this.setValue(formNodeName, value, select, true);
  629. this.checkHistory([appChange.name, formNodeName], [appChange.fromValue, oldValue], [appChange.toValue, value] )
  630. }else{
  631. this.setValue(formNodeName, value, select);
  632. }
  633. oldValue = value;
  634. }.bind(this));
  635. this.setSubformSelectOptions(node, select);
  636. var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
  637. refreshNode.addEvent("click", function(e){
  638. this.getSubFormList(function(){
  639. this.setSubformSelectOptions(node, select);
  640. }.bind(this), true, appNodeName);
  641. }.bind(this));
  642. var openNode = new Element("div", {"styles": this.form.css.propertyOpenFormNode}).inject(node);
  643. openNode.addEvent("click", function(e){
  644. var name = node.get("name");
  645. this._openForm( this.data[name] );
  646. }.bind(this));
  647. }.bind(this), false, appNodeName );
  648. return select;
  649. },
  650. setSubformSelectOptions: function(node, select){
  651. var name = node.get("name");
  652. select.empty();
  653. var option = new Element("option", {"text": "none"}).inject(select);
  654. this.subforms.each(function(subforms){
  655. if( this.form.json.id !== subforms.id ){
  656. var option = new Element("option", {
  657. "text": subforms.name,
  658. "value": subforms.id,
  659. "selected": (this.data[name]==subforms.id)
  660. }).inject(select);
  661. }
  662. }.bind(this));
  663. },
  664. getSubFormList: function(callback, refresh, appNodeName){
  665. var application = appNodeName ? this.data[appNodeName] : "";
  666. if (!this.subforms || refresh){
  667. this.form.designer.actions.listForm( application || this.form.designer.application.id, function(json){
  668. this.subforms = json.data;
  669. if (callback) callback();
  670. }.bind(this));
  671. }else{
  672. if (callback) callback();
  673. }
  674. },
  675. _openForm: function( formId ){
  676. var pre = this.appType === "cms" ? "cms" : "process";
  677. if( formId && formId !== "none" ){
  678. this.form.designer.actions.getForm(formId, function(json){
  679. var options = {
  680. "style": layout.desktop.formDesignerStyle || "default",
  681. "appId": pre+".FormDesigner"+formId,
  682. "id": formId
  683. };
  684. layout.openApplication(null, pre+".FormDesigner", options);
  685. }.bind(this), function () {
  686. return true;
  687. })
  688. }
  689. },
  690. loadPageSelect: function(){
  691. var pageNodes = this.propertyContent.getElements(".MWFPageSelect");
  692. if (pageNodes.length){
  693. this.getPageList(function(){
  694. pageNodes.each(function(node){
  695. var select = new Element("select").inject(node);
  696. select.addEvent("change", function(e){
  697. var value = e.target.options[e.target.selectedIndex].value;
  698. this.setValue(e.target.getParent("div").get("name"), value, select);
  699. }.bind(this));
  700. this.setPageSelectOptions(node, select);
  701. var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
  702. refreshNode.addEvent("click", function(e){
  703. this.getPageList(function(){
  704. this.setPageSelectOptions(node, select);
  705. }.bind(this), true);
  706. }.bind(this));
  707. }.bind(this));
  708. }.bind(this));
  709. }
  710. },
  711. setPageSelectOptions: function(node, select){
  712. var name = node.get("name");
  713. select.empty();
  714. var option = new Element("option", {"text": "none"}).inject(select);
  715. this.pages.each(function(page){
  716. if( this.form.json.id !== page.id ){
  717. var option = new Element("option", {
  718. "text": page.name,
  719. "value": page.id,
  720. "selected": (this.data[name]==page.id)
  721. }).inject(select);
  722. }
  723. }.bind(this));
  724. },
  725. getPageList: function(callback, refresh){
  726. if (!this.pages || refresh){
  727. this.form.designer.actions.listPage(this.form.designer.application.id, function(json){
  728. this.pages = json.data;
  729. if (callback) callback();
  730. }.bind(this));
  731. }else{
  732. if (callback) callback();
  733. }
  734. },
  735. loadWidgetSelect: function(){
  736. var wdigetContainers = this.propertyContent.getElements(".MWFWidgetSelectContainer");
  737. if (wdigetContainers.length){
  738. wdigetContainers.each( function( container ){
  739. var appSelectNode = container.getElement(".MWFWidgetAppSelect");
  740. var widgetSelectNode = container.getElement(".MWFWidgetSelect");
  741. var widgetSelect;
  742. var appNodeName = appSelectNode.get("name");
  743. var widgetNodeName = widgetSelectNode.get("name");
  744. this.loadPortalApplictionSelect( appSelectNode, appNodeName, function( apps ){
  745. var oldValue = this.data[appNodeName] || "";
  746. this.data[appNodeName] = !apps.length ? "" : apps[0].data.id;
  747. if( oldValue !== this.data[appNodeName] ){
  748. this.getWidgetList(function(){
  749. this.setWidgetSelectOptions(widgetSelectNode, widgetSelect);
  750. widgetSelect.fireEvent("change", [null, {
  751. name: appNodeName,
  752. fromValue: oldValue,
  753. toValue: this.data[appNodeName]
  754. }]);
  755. }.bind(this), true, appNodeName);
  756. }
  757. }.bind(this));
  758. widgetSelect = this._loadWidgetSelect( widgetSelectNode, widgetNodeName, appNodeName ) ;
  759. }.bind(this));
  760. }
  761. },
  762. loadPortalApplictionSelect : function( node, appNodeName, callback ){
  763. var application = appNodeName ? this.data[appNodeName] : "";
  764. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function() {
  765. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  766. "title" : this.form.designer.lp.selectApplication,
  767. "type": "portal",
  768. "count" : 1,
  769. "names": application ? [ {id : application} ] : [],
  770. "onChange": function (apps) {
  771. callback(apps)
  772. }.bind(this)
  773. });
  774. }.bind(this))
  775. },
  776. _loadWidgetSelect : function( node, widgetNodeName, appNodeName ){
  777. this.widgets = null;
  778. var select = new Element("select").inject(node);
  779. var oldValue = this.data[widgetNodeName];
  780. this.getWidgetList(function(){
  781. select.addEvent("change", function(e, appChange){
  782. var value = select.options[select.selectedIndex].value;
  783. if( appChange ){
  784. this.setValue(widgetNodeName, value, select, true);
  785. this.checkHistory([appChange.name, widgetNodeName], [appChange.fromValue, oldValue], [appChange.toValue, value] )
  786. }else{
  787. this.setValue(widgetNodeName, value, select);
  788. }
  789. oldValue = value;
  790. }.bind(this));
  791. this.setWidgetSelectOptions(node, select);
  792. var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
  793. refreshNode.addEvent("click", function(e){
  794. this.getWidgetList(function(){
  795. this.setWidgetSelectOptions(node, select);
  796. }.bind(this), true, appNodeName);
  797. }.bind(this));
  798. var openNode = new Element("div", {"styles": this.form.css.propertyOpenFormNode}).inject(node);
  799. openNode.addEvent("click", function(e){
  800. var name = node.get("name");
  801. var widgetId = this.data[name];
  802. if( widgetId && widgetId !== "none" ){
  803. this.form.designer.actions.getWidget(widgetId, function(json){
  804. var options = {
  805. "appId": "portal.WidgetDesigner"+widgetId,
  806. "id": widgetId
  807. };
  808. layout.openApplication(null, "portal.WidgetDesigner", options);
  809. }.bind(this), function () {
  810. return true;
  811. })
  812. }
  813. }.bind(this));
  814. }.bind(this), false, appNodeName );
  815. return select;
  816. },
  817. setWidgetSelectOptions: function(node, select){
  818. var name = node.get("name");
  819. select.empty();
  820. var option = new Element("option", {"text": "none"}).inject(select);
  821. this.widgets.each(function(widget){
  822. if( this.form.json.id !== widget.id ){
  823. var option = new Element("option", {
  824. "text": widget.name,
  825. "value": widget.id,
  826. "selected": (this.data[name]==widget.id)
  827. }).inject(select);
  828. }
  829. }.bind(this));
  830. },
  831. getWidgetList: function(callback, refresh, appNodeName){
  832. var application = appNodeName ? this.data[appNodeName] : "";
  833. if (!this.widgets || refresh){
  834. this.form.designer.actions.listWidget(application || this.form.designer.application.id, function(json){
  835. this.widgets = json.data;
  836. if (callback) callback();
  837. }.bind(this));
  838. }else{
  839. if (callback) callback();
  840. }
  841. },
  842. // clearStyles: function(node){
  843. // node.removeProperty("style");
  844. // var subNode = node.getFirst();
  845. // while (subNode){
  846. // this.clearStyles(subNode);
  847. // subNode = subNode.getNext();
  848. // }
  849. // },
  850. loadDocumentTempleteSelect: function(){
  851. var nodes = this.propertyContent.getElements(".MWFDocumentTempleteSelect");
  852. if (nodes.length){
  853. o2.getJSON("../x_component_process_FormDesigner/Module/Documenteditor/templete/templete.json", function(json){
  854. nodes.each(function(node){
  855. var name = node.get("name");
  856. Object.each(json, function(o, k){
  857. new Element("option", {
  858. "text": o.name,
  859. "value": k,
  860. "selected": (this.data[name]==k)
  861. }).inject(node);
  862. }.bind(this));
  863. var oldValue = this.data[name];
  864. node.addEvent("change", function(e){
  865. var value = e.target.options[e.target.selectedIndex].value;
  866. var name1 = e.target.options[e.target.selectedIndex].get("text");
  867. this.changeJsonDate([name1], value);
  868. this.changeData(name1, node, oldValue);
  869. this.checkHistory([name, name1], [oldValue, oldValue], [value, value])
  870. oldValue = this.data[name];
  871. }.bind(this));
  872. }.bind(this));
  873. }.bind(this));
  874. }
  875. },
  876. loadStatementFilter: function(){
  877. var nodes = this.propertyContent.getElements(".MWFStatementFilter");
  878. var filtrData = this.data.filterList;
  879. var parameterData = this.data.parameterList;
  880. var oldFiltrData = Array.clone( filtrData || [] );
  881. var oldParameterData = Array.clone( parameterData || [] );
  882. nodes.each(function(node){
  883. MWF.xDesktop.requireApp("query.StatementDesigner", "widget.ViewFilter", function(){
  884. var _slef = this;
  885. this.viewFilter = new MWF.xApplication.query.StatementDesigner.widget.ViewFilter(node, this.form.designer, {"filtrData": filtrData, "customData": null, "parameterData": parameterData}, {
  886. "statementId" : this.data.queryStatement ? this.data.queryStatement.id : "",
  887. "withForm" : true,
  888. "onChange": function(ids){
  889. var data = this.getData();
  890. _slef.changeJsonDate(["filterList"], data.filterData);
  891. _slef.changeJsonDate(["parameterList"], data.parameterData);
  892. //_slef.changeJsonDate(["data", "customFilterEntryList"], data.customData);
  893. _slef.checkHistory( "filterList", oldFiltrData, data.filterData );
  894. _slef.checkHistory( "parameterList", oldParameterData, data.parameterData );
  895. oldFiltrData = Array.clone( data.filterData );
  896. oldParameterData = Array.clone( data.parameterData );
  897. }
  898. });
  899. }.bind(this));
  900. }.bind(this));
  901. },
  902. loadStatementFilterWithTemplate: function(){
  903. var nodes = this.propertyContent.getElements(".MWFStatementFilterWithTemplate");
  904. var filtrData = this.data.statementFilterList;
  905. var parameterData = this.data.statementParameterList;
  906. var oldFiltrData = Array.clone( filtrData || [] );
  907. var oldParameterData = Array.clone( parameterData || [] );
  908. nodes.each(function(node){
  909. var statementField = node.dataset["statement"];
  910. MWF.xDesktop.requireApp("query.StatementDesigner", "widget.ViewFilterWithTemplate", function(){
  911. var _slef = this;
  912. this.viewFilterWithTemplate = new MWF.xApplication.query.StatementDesigner.widget.ViewFilterWithTemplate(node, this.form.designer,
  913. {"filtrData": filtrData, "customData": null, "parameterData": parameterData},
  914. {
  915. "statementId" : this.data[statementField] ? this.data[statementField].id : "",
  916. "withForm" : true,
  917. "onChange": function(ids){
  918. var data = this.getData();
  919. _slef.changeJsonDate(["statementFilterList"], data.filterData);
  920. _slef.changeJsonDate(["statementParameterList"], data.parameterData);
  921. _slef.checkHistory("statementFilterList", oldFiltrData, data.filterData);
  922. _slef.checkHistory( "statementParameterList", oldParameterData, data.parameterData );
  923. oldFiltrData = Array.clone( data.filterData );
  924. oldParameterData = Array.clone( data.parameterData );
  925. }
  926. }
  927. );
  928. }.bind(this));
  929. }.bind(this));
  930. },
  931. loadViewFilter: function(){
  932. var nodes = this.propertyContent.getElements(".MWFViewFilter");
  933. var filtrData = this.data.filterList;
  934. var oldValue = Array.clone(filtrData || []);
  935. nodes.each(function(node){
  936. MWF.xDesktop.requireApp("query.ViewDesigner", "widget.ViewFilter", function(){
  937. var _slef = this;
  938. new MWF.xApplication.query.ViewDesigner.widget.ViewFilter(node, this.form.designer, {"filtrData": filtrData, "customData": null}, {
  939. "onChange": function(ids){
  940. var data = this.getData();
  941. _slef.changeJsonDate(["filterList"], data.data);
  942. _slef.checkHistory("filterList", oldValue, data.data);
  943. oldValue = Array.clone(data.data);
  944. //_slef.changeJsonDate(["data", "customFilterEntryList"], data.customData);
  945. }
  946. });
  947. }.bind(this));
  948. }.bind(this));
  949. },
  950. loadViewFilterWithTemplate: function(){
  951. var nodes = this.propertyContent.getElements(".MWFViewFilterWithTemplate");
  952. var filtrData = this.data.viewFilterList;
  953. var oldValue = Array.clone(filtrData || []);
  954. nodes.each(function(node){
  955. MWF.xDesktop.requireApp("query.ViewDesigner", "widget.ViewFilterWithTemplate", function(){
  956. var _slef = this;
  957. new MWF.xApplication.query.ViewDesigner.widget.ViewFilterWithTemplate(node, this.form.designer, {"filtrData": filtrData, "customData": null}, {
  958. "onChange": function(ids){
  959. var data = this.getData();
  960. _slef.changeJsonDate(["viewFilterList"], data.data);
  961. _slef.checkHistory("viewFilterList", oldValue, data.data);
  962. oldValue = Array.clone(data.data);
  963. //_slef.changeJsonDate(["data", "customFilterEntryList"], data.customData);
  964. }
  965. });
  966. }.bind(this));
  967. }.bind(this));
  968. },
  969. loadViewSelect: function(){
  970. var viewNodes = this.propertyContent.getElements(".MWFViewSelect");
  971. if (viewNodes.length){
  972. this.getViewList(function(){
  973. viewNodes.each(function(node){
  974. var select = new Element("select").inject(node);
  975. select.addEvent("change", function(e){
  976. var viewId = e.target.options[e.target.selectedIndex].value;
  977. var viewName = e.target.options[e.target.selectedIndex].get("text");
  978. this.setValue(e.target.getParent("div").get("name"), viewId);
  979. this.setValue(e.target.getParent("div").get("name")+"Name", viewName);
  980. }.bind(this));
  981. this.setViewSelectOptions(node, select);
  982. var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
  983. refreshNode.addEvent("click", function(e){
  984. this.getViewList(function(){
  985. this.setViewSelectOptions(node, select);
  986. }.bind(this), true);
  987. }.bind(this));
  988. //select.addEvent("click", function(e){
  989. // this.setFormSelectOptions(node, select);
  990. //}.bind(this));
  991. }.bind(this));
  992. }.bind(this));
  993. }
  994. },
  995. setViewSelectOptions: function(node, select){
  996. var name = node.get("name");
  997. select.empty();
  998. var option = new Element("option", {"text": "none"}).inject(select);
  999. this.views.each(function(view){
  1000. var option = new Element("option", {
  1001. "text": view.name,
  1002. "value": view.id,
  1003. "selected": (this.data[name]==view.id)
  1004. }).inject(select);
  1005. }.bind(this));
  1006. },
  1007. getViewList: function(callback, refresh){
  1008. if (!this.views || refresh){
  1009. this.form.designer.actions.listView(this.form.designer.application.id, function(json){
  1010. this.views = json.data;
  1011. if (callback) callback();
  1012. }.bind(this));
  1013. }else{
  1014. if (callback) callback();
  1015. }
  1016. },
  1017. loadValidation: function(){
  1018. var nodes = this.propertyContent.getElements(".MWFValidation");
  1019. if (nodes.length){
  1020. nodes.each(function(node){
  1021. var name = node.get("name");
  1022. MWF.xDesktop.requireApp("process.FormDesigner", "widget.ValidationEditor", function(){
  1023. var validationEditor = new MWF.xApplication.process.FormDesigner.widget.ValidationEditor(node, this.designer, {
  1024. "onChange": function(){
  1025. var oldVaue = this.data[name];
  1026. var data = validationEditor.getValidationData();
  1027. this.data[name] = data;
  1028. this.checkHistory(name, oldVaue, data);
  1029. }.bind(this)
  1030. });
  1031. validationEditor.load(this.data[name])
  1032. }.bind(this));
  1033. //new MWF.xApplication.process.FormDesigner.widget.ValidationEditor(node, this.designer);
  1034. }.bind(this));
  1035. }
  1036. },
  1037. loadFieldConfig: function(){
  1038. var nodes = this.propertyContent.getElements(".MWFFieldConfigArea");
  1039. if (nodes.length){
  1040. nodes.each(function(node){
  1041. var name = node.get("name");
  1042. var data;
  1043. if( this.data[name] ){
  1044. data = this.data[name];
  1045. }else{
  1046. data = this.data[name] = [];
  1047. }
  1048. var oldValue = Array.clone(data);
  1049. MWF.xDesktop.requireApp("process.FormDesigner", "widget.FiledConfigurator", function(){
  1050. var filedConfigurator = new MWF.xApplication.process.FormDesigner.widget.FiledConfigurator(node, this.designer, {
  1051. "title": node.get("data-title"),
  1052. "hasRefresh": true,
  1053. "onRefresh": function () {
  1054. var _self = this;
  1055. if( typeOf(this.data[name]) === "array" && this.data[name].length > 0 ){
  1056. //this.form.designer.lp.selectIcon
  1057. this.form.designer.confirm( "", node, "导入字段确认", "本操作从数据模板的内部组件获取字段。如果执行本操作,之前配置的字段会被替换,是否继续?", 300, 200, function(){
  1058. if( !_self.module.getExpImpFieldJson )return;
  1059. filedConfigurator.data = _self.module.getExpImpFieldJson();
  1060. filedConfigurator.reloadContent();
  1061. _self.data[name] = filedConfigurator.data;
  1062. _self.checkHistory(name, oldValue, _self.data[name]);
  1063. oldValue = Array.clone( _self.data[name] || [] );
  1064. this.close();
  1065. }, function(){
  1066. this.close();
  1067. })
  1068. }else{
  1069. if( !_self.module.getExpImpFieldJson )return;
  1070. filedConfigurator.data = _self.module.getExpImpFieldJson();
  1071. filedConfigurator.reloadContent();
  1072. _self.data[name] = filedConfigurator.data;
  1073. _self.checkHistory(name, oldValue, _self.data[name]);
  1074. oldValue = Array.clone(_self.data[name] || [] );
  1075. }
  1076. }.bind(this),
  1077. "onChange": function(){
  1078. this.data[name] = filedConfigurator.getData();
  1079. this.checkHistory(name, oldValue, this.data[name]);
  1080. oldValue = Array.clone(this.data[name] || []);
  1081. }.bind(this)
  1082. }, data);
  1083. filedConfigurator.load()
  1084. }.bind(this));
  1085. }.bind(this));
  1086. }
  1087. },
  1088. // _loadVue: function(callback){
  1089. // if (!window.Vue){
  1090. // o2.load(["vue", "elementui"], { "sequence": true }, callback);
  1091. // }else{
  1092. // if (callback) callback();
  1093. // }
  1094. // },
  1095. loadElCommonPreview: function(){
  1096. var nodes = this.propertyContent.getElements(".MWFElCommonPreview");
  1097. if (nodes.length) {
  1098. nodes.each(function(node){
  1099. node.removeEvents("click")
  1100. node.addEvent("click", function(){
  1101. if (this.module.resetElement) this.module.resetElement();
  1102. }.bind(this));
  1103. }.bind(this));
  1104. }
  1105. },
  1106. loadVueElementUI: function(){
  1107. var nodes = this.propertyContent.getElements(".MWFElementColor");
  1108. if (nodes.length) {
  1109. this._loadVue(function(){
  1110. var _self = this;
  1111. nodes.each(function(node){
  1112. var name = node.get("name");
  1113. var v = _self.data[name] || "";
  1114. var oldValue = v;
  1115. var data = {};
  1116. data[name] = v;
  1117. new Vue({
  1118. data: data,
  1119. methods: {
  1120. change: function(color){
  1121. _self.data[name] = color;
  1122. _self.changeData(name, null, oldValue);
  1123. oldValue = _self.data[name];
  1124. }
  1125. }
  1126. }).$mount(node);
  1127. });
  1128. }.bind(this));
  1129. }
  1130. },
  1131. _loadVue: function(callback){
  1132. if (!window.Vue){
  1133. o2.loadAll({"css": "../o2_lib/vue/element/index.css", "js": ["vue", "elementui"]}, { "sequence": true }, callback);
  1134. }else{
  1135. if (callback) callback();
  1136. }
  1137. },
  1138. loadElSelectIcon: function(){
  1139. var nodes = this.propertyContent.getElements(".MWFElIcon");
  1140. if (nodes.length){
  1141. var _self = this;
  1142. 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"];
  1143. nodes.each(function(node){
  1144. var name = node.get("name");
  1145. var data = this.data[name] || "";
  1146. var oldValue = data;
  1147. var area = new Element("div", {
  1148. "styles": {
  1149. "height": "300px",
  1150. "overflow": "auto",
  1151. "font-size": "24px"
  1152. }
  1153. }).inject(node);
  1154. icons.forEach(function(i){
  1155. if (data==i){
  1156. area.appendHTML("<i style=\"background-color: #999999; padding:5px}\" @click='selected' data-icon=\""+i+"\" class=\""+i+" mainColor_bg\"></i>");
  1157. }else{
  1158. area.appendHTML("<i style='cursor: pointer; padding:5px' @click='selected' data-icon=\""+i+"\" class='"+i+"'></i>");
  1159. }
  1160. });
  1161. this._loadVue(function(){
  1162. new Vue({
  1163. methods:{
  1164. selected: function(e){
  1165. var iNode = (e.target || e.srcElement);
  1166. if (iNode && iNode.hasClass("mainColor_bg")){
  1167. iNode.removeClass("mainColor_bg");
  1168. _self.data[name] = "";
  1169. _self.changeData(name, null, oldValue);
  1170. oldValue = _self.data[name];
  1171. }else{
  1172. this.$el.getElements("i").forEach(function(el){
  1173. if (el.hasClass("mainColor_bg")) el.removeClass("mainColor_bg");
  1174. });
  1175. if (iNode){
  1176. iNode.addClass("mainColor_bg");
  1177. var iconName = iNode.dataset["icon"];
  1178. _self.data[name] = iconName;
  1179. _self.changeData(name, null, oldValue);
  1180. oldValue = _self.data[name];
  1181. }
  1182. }
  1183. }
  1184. }
  1185. }).$mount(node);
  1186. }.bind(this));
  1187. // MWF.xDesktop.requireApp("process.FormDesigner", "widget.FiledConfigurator", function(){
  1188. // var filedConfigurator = new MWF.xApplication.process.FormDesigner.widget.FiledConfigurator(node, this.designer, {
  1189. // "onChange": function(){
  1190. // this.data[name] = filedConfigurator.getData();
  1191. // }.bind(this)
  1192. // }, data);
  1193. // filedConfigurator.load()
  1194. // }.bind(this));
  1195. }.bind(this));
  1196. }
  1197. },
  1198. loadIconSelect: function(){
  1199. var nodes = this.propertyContent.getElements(".MWFIcon");
  1200. if (nodes.length){
  1201. nodes.each(function(node){
  1202. var id = node.get("name");
  1203. var icon = this.data[id];
  1204. var iconNode = new Element("div", {"styles": this.form.css.processIconNode}).inject(node);
  1205. if (icon) iconNode.setStyles({"background": "url("+icon+") center center no-repeat"});
  1206. var selectNode = new Element("div", {"styles": this.form.css.processIconSelectNode, "text": this.form.designer.lp.selectIcon}).inject(node);
  1207. selectNode.addEvent("click", function(){
  1208. this.selectIcon(node);
  1209. }.bind(this));
  1210. }.bind(this));
  1211. }
  1212. },
  1213. selectIcon: function(node){
  1214. if (!node.iconMenu){
  1215. var tr = node.getParent("tr");
  1216. var p = tr.getPosition(this.form.designer.content);
  1217. var iconSelectMenu = new MWF.widget.Menu(node, {"left": p.x-330, "top": p.y, "event": "click", "style": "processIcon"});
  1218. //var iconSelectMenu = new MWF.widget.Menu(node, {"event": "click", "style": "processIcon"});
  1219. iconSelectMenu.load();
  1220. node.iconMenu = iconSelectMenu;
  1221. var _self = this;
  1222. for (var i=0; i<=48; i++){
  1223. var icon = "../x_component_process_ProcessManager/$Explorer/default/processIcon/process_icon_"+i+".png";
  1224. var item = iconSelectMenu.addMenuItem("", "click", function(){
  1225. var id = node.get("name");
  1226. var src = this.item.getElement("img").get("src");
  1227. _self.data[id] = src;
  1228. node.getFirst("div").setStyle("background-image", "url("+src+")");
  1229. }, icon);
  1230. item.iconName = icon;
  1231. }
  1232. }
  1233. },
  1234. loadLabelFlagSelect: function(){
  1235. var nodes = this.propertyContent.getElements(".MWFLabelFlag");
  1236. if (nodes.length){
  1237. nodes.each(function(node){
  1238. var id = node.get("name");
  1239. var icon = this.data[id];
  1240. var iconNode = new Element("div", {"styles": this.form.css.labelFlagNode}).inject(node);
  1241. if (icon) iconNode.setStyles({"background": "url("+icon+") center center no-repeat"});
  1242. var selectNode = new Element("div", {"styles": this.form.css.processIconSelectNode, "text": this.form.designer.lp.empty}).inject(node);
  1243. selectNode.addEvent("click", function(e){
  1244. var id = node.get("name");
  1245. var oldValue = this.data[id];
  1246. this.data[id] = "";
  1247. node.getFirst("div").setStyle("background-image", "");
  1248. this.changeData(id, null, oldValue);
  1249. e.stopPropagation();
  1250. }.bind(this));
  1251. var selectNode = new Element("div", {"styles": this.form.css.processIconSelectNode, "text": this.form.designer.lp.select}).inject(node);
  1252. selectNode.addEvent("click", function(){
  1253. this.selectLabelFlag(node);
  1254. }.bind(this));
  1255. }.bind(this));
  1256. }
  1257. },
  1258. selectLabelFlag: function(node){
  1259. if (!node.iconMenu){
  1260. var iconSelectMenu = new MWF.widget.Menu(node, {"event": "click", "style": "labelFlag"});
  1261. iconSelectMenu.load();
  1262. node.iconMenu = iconSelectMenu;
  1263. var _self = this;
  1264. for (var i=1; i<=21; i++){
  1265. var icon = "../x_component_process_FormDesigner/Module/Label/default/icon/flag/"+i+".png";
  1266. var item = iconSelectMenu.addMenuItem("", "click", function(){
  1267. var id = node.get("name");
  1268. var src = this.item.getElement("img").get("src");
  1269. var oldValue = _self.data[id];
  1270. _self.data[id] = src;
  1271. node.getFirst("div").setStyle("background-image", "url("+src+")");
  1272. _self.changeData(id, null, oldValue);
  1273. }, icon);
  1274. item.iconName = icon;
  1275. }
  1276. }
  1277. },
  1278. loadImageFileSelect: function(){
  1279. // var nodes = this.propertyContent.getElements(".MWFImageFileSelect");
  1280. // if (nodes.length){
  1281. //
  1282. //
  1283. //
  1284. //
  1285. // this.getFileList(function(){
  1286. // nodes.each(function(node){
  1287. // var select = new Element("select").inject(node);
  1288. // select.addEvent("change", function(e){
  1289. // this.setValue(e.target.getParent("div").get("name"), e.target.options[e.target.selectedIndex].value, select);
  1290. //
  1291. // }.bind(this));
  1292. // this.setFileSelectOptions(node, select);
  1293. //
  1294. // var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
  1295. // refreshNode.addEvent("click", function(e){
  1296. // this.getFileList(function(){
  1297. // this.setFileSelectOptions(node, select);
  1298. // }.bind(this), true);
  1299. // }.bind(this));
  1300. // }.bind(this));
  1301. // }.bind(this));
  1302. // }
  1303. },
  1304. setFileSelectOptions: function(node, select){
  1305. var name = node.get("name");
  1306. select.empty();
  1307. var option = new Element("option", {"text": "none"}).inject(select);
  1308. this.files.each(function(file){
  1309. var option = new Element("option", {
  1310. "text": file.name,
  1311. "value": file.id,
  1312. "selected": (this.data[name]==file.id)
  1313. }).inject(select);
  1314. }.bind(this));
  1315. },
  1316. getFileList: function(callback, refresh){
  1317. if (!this.files || refresh){
  1318. this.form.designer.actions.listFile(this.form.designer.application.id, function(json){
  1319. this.files = json.data;
  1320. if (callback) callback();
  1321. }.bind(this));
  1322. }else{
  1323. if (callback) callback();
  1324. }
  1325. },
  1326. loadImageClipper: function(){
  1327. var nodes = this.propertyContent.getElements(".MWFImageClipper");
  1328. if (nodes.length){
  1329. nodes.each(function(node){
  1330. var id = node.get("name");
  1331. var selectNode = new Element("div", {"styles": this.form.css.processIconSelectNode, "text": this.form.designer.lp.selectImage}).inject(node);
  1332. selectNode.addEvent("click", function(){
  1333. this.selectImage(node, id);
  1334. }.bind(this));
  1335. }.bind(this));
  1336. }
  1337. },
  1338. createUploadFileAreaNode: function(node, name){
  1339. this.uploadFileAreaNode = new Element("div");
  1340. var html = "<input name=\"file\" multiple type=\"file\" accept=\"images/*\" />";
  1341. this.uploadFileAreaNode.set("html", html);
  1342. this.fileUploadNode = this.uploadFileAreaNode.getFirst();
  1343. this.fileUploadNode.addEvent("change", function(){
  1344. //var fileId = attachment.data.id;
  1345. var files = this.fileUploadNode.files;
  1346. if (files.length){
  1347. var count = files.length;
  1348. for (var i = 0; i < files.length; i++) {
  1349. var file = files.item(i);
  1350. var formData = new FormData();
  1351. formData.append('file', file);
  1352. MWF.xDesktop.uploadImage(
  1353. this.form.json.id,
  1354. (this.module.form.moduleType=="page") ? "portalPage" : "processPlatformForm",
  1355. formData,
  1356. file,
  1357. function(json){
  1358. var id = json.id;
  1359. var src = MWF.xDesktop.getImageSrc(id);
  1360. var data = {"imageSrc": src, "imageId": id};
  1361. this.changeJsonDate(name, data);
  1362. this.changeData(name, node, null);
  1363. }.bind(this)
  1364. );
  1365. }
  1366. }
  1367. }.bind(this));
  1368. },
  1369. selectImage: function(node, name){
  1370. if (!this.uploadFileAreaNode){
  1371. this.createUploadFileAreaNode(node, name);
  1372. }
  1373. //this.fileUploadNode.set("accept", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
  1374. this.fileUploadNode.set("multiple", false);
  1375. var fileNode = this.uploadFileAreaNode.getFirst();
  1376. fileNode.set("accept", ".png,.jpg,.bmp,.gif,.jpeg,.jpe");
  1377. fileNode.click();
  1378. //MWF.xDesktop.requireApp("process.FormDesigner", "widget.ImageClipper", function(){
  1379. // var size = this.module.node.getSize();
  1380. // var image = new MWF.xApplication.process.FormDesigner.widget.ImageClipper(this.designer, {
  1381. // "title": this.form.designer.lp.selectImage,
  1382. // "width": (this.data.styles.width) ? size.x : 0,
  1383. // "height": (this.data.styles.height) ? size.y : 0,
  1384. // "imageUrl" : this.data.imageSrc,
  1385. // "reference" : this.form.json.id,
  1386. // "referenceType": (this.module.form.moduleType=="page") ? "portalPage" : "processPlatformForm",
  1387. // "onChange": function(){
  1388. // var data = {"imageSrc": image.imageSrc, "imageId": image.imageId};
  1389. // this.changeJsonDate(name, data);
  1390. // this.changeData(name, node, null);
  1391. // }.bind(this)
  1392. // });
  1393. // image.load(this.data[name])
  1394. //}.bind(this));
  1395. },
  1396. loadEventsEditor: function(){
  1397. var events = this.propertyContent.getElement(".MWFEventsArea");
  1398. if (events){
  1399. var name = events.get("name");
  1400. var eventsObj = this.data[name];
  1401. MWF.xDesktop.requireApp("process.FormDesigner", "widget.EventsEditor", function(){
  1402. var eventsEditor = new MWF.xApplication.process.FormDesigner.widget.EventsEditor(events, this.designer, {
  1403. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  1404. "maxObj": this.designer.formContentNode || this.designer.pageContentNode,
  1405. "onChange": function (eventName, newValue, oldValue, compareName) {
  1406. this.checkHistory(name+"."+eventName, oldValue, newValue, null, compareName ? (name+"."+compareName) : "");
  1407. }.bind(this)
  1408. });
  1409. eventsEditor.load(eventsObj, this.data, name);
  1410. }.bind(this));
  1411. }
  1412. },
  1413. testRestful: function(){
  1414. var node = this.propertyContent.getElements(".MWFTestRestful");
  1415. if (node){
  1416. var resultNode = node.getLast();
  1417. node.getFirst().addEvent("click", function(){
  1418. }.bind(this));
  1419. }
  1420. },
  1421. loadContextRoot: function(){
  1422. var nodes = this.propertyContent.getElements(".MWFContextRoot");
  1423. if (nodes){
  1424. nodes.each(function(node){
  1425. var name = node.get("name");
  1426. var selects = node.getElements("select");
  1427. var rootSelect = selects[0];
  1428. var actionSelect = selects[1];
  1429. var methodSelect = selects[2];
  1430. var pathInput = node.getElement("input");
  1431. //var select = new Element("select").inject(node);
  1432. //var methodSelect = new Element("select").inject(node);
  1433. var getValue = function(){
  1434. var v;
  1435. try {
  1436. v = JSON.parse(this.data[name]);
  1437. }catch(e){
  1438. v = {"root": this.data[name], "action":"", "method": "", "uri": ""};
  1439. }
  1440. return v
  1441. }.bind(this);
  1442. var value = getValue();
  1443. var resetRootSelects = function(){
  1444. var root = rootSelect.options[rootSelect.selectedIndex].value;
  1445. var action = o2.Actions.load(root);
  1446. actionSelect.empty();
  1447. methodSelect.empty();
  1448. pathInput.set("value", "");
  1449. var value = getValue();
  1450. Object.each(action, function(o, key){
  1451. var option = new Element("option", {"value": key, "text": key, "selected": (value.action==key)}).inject(actionSelect);
  1452. });
  1453. return JSON.stringify({"root": root, "action":"", "method": "", "uri": ""});
  1454. };
  1455. var resetActionSelects = function(){
  1456. var root = rootSelect.options[rootSelect.selectedIndex].value;
  1457. var actionName = actionSelect.options[actionSelect.selectedIndex].value;
  1458. var action = o2.Actions.load(root);
  1459. methodSelect.empty();
  1460. pathInput.set("value", "");
  1461. var value = getValue();
  1462. Object.each(action[actionName].action.actions, function(o, key){
  1463. var option = new Element("option", {"value": key, "text": key, "selected": (value.method==key)}).inject(methodSelect);
  1464. });
  1465. return JSON.stringify({"root": root, "action":actionName, "method": "", "uri": ""});
  1466. };
  1467. var resetMethodSelects = function(){
  1468. var root = rootSelect.options[rootSelect.selectedIndex].value;
  1469. var actionName = actionSelect.options[actionSelect.selectedIndex].value;
  1470. var methodName = methodSelect.options[methodSelect.selectedIndex].value;
  1471. var action = o2.Actions.load(root);
  1472. var uri = action[actionName].action.actions[methodName].uri;
  1473. pathInput.set("value", uri);
  1474. return JSON.stringify({"root": root, "action":actionName, "method": methodName, "uri": uri});
  1475. };
  1476. Object.each(layout.serviceAddressList, function(v, key){
  1477. var option = new Element("option", {"value": key, "text": v.name, "selected": (value.root==key)}).inject(rootSelect);
  1478. }.bind(this));
  1479. var option = new Element("option", {"value": "x_program_center", "text": MWF.APPFD.LP.propertyTemplate.centerServer, "selected": (value.root=="x_program_center")}).inject(rootSelect);
  1480. resetRootSelects()
  1481. resetActionSelects();
  1482. resetMethodSelects();
  1483. rootSelect.addEvent("change", function(){
  1484. resetRootSelects();
  1485. resetActionSelects();
  1486. var data = resetMethodSelects();
  1487. this.changeJsonDate(name, data);
  1488. this.changeData(name, node, value);
  1489. }.bind(this));
  1490. actionSelect.addEvent("change", function(){
  1491. resetActionSelects();
  1492. var data = resetMethodSelects();
  1493. this.changeJsonDate(name, data);
  1494. this.changeData(name, node, value);
  1495. }.bind(this));
  1496. methodSelect.addEvent("change", function(){
  1497. var data = resetMethodSelects();
  1498. this.changeJsonDate(name, data);
  1499. this.changeData(name, node, value);
  1500. }.bind(this));
  1501. }.bind(this));
  1502. }
  1503. },
  1504. loadSourceTestRestful: function(){
  1505. var nodes = this.propertyContent.getElements(".MWFSourceTestRestful");
  1506. if (nodes.length){
  1507. nodes.each(function(node){
  1508. var button = node.getFirst();
  1509. var content = node.getLast();
  1510. //var button = new Element("input", {"type": "button", "value": "Test"}).inject(node);
  1511. button.addEvent("click", function(e){
  1512. this.testSourceRestful(content);
  1513. }.bind(this));
  1514. }.bind(this));
  1515. }
  1516. },
  1517. testSourceRestful: function(content){
  1518. var service;
  1519. try {
  1520. service = JSON.parse(this.module.json.contextRoot);
  1521. }catch(e){
  1522. service = {"root": this.module.json.contextRoot, "action":"", "method": "", "url": ""};
  1523. }
  1524. var address = this._getO2Address(service.root);
  1525. var uri = this._getO2Uri(this.module, address);
  1526. this._invoke(this.module, uri, function(json){
  1527. content.empty();
  1528. MWF.require("MWF.widget.JsonParse", function(){
  1529. var jsonParse = new MWF.widget.JsonParse(json, content, null);
  1530. jsonParse.load();
  1531. }.bind(this));
  1532. }.bind(this));
  1533. },
  1534. _getO2Address: function(contextRoot){
  1535. var addressObj = layout.serviceAddressList[contextRoot];
  1536. var address = "";
  1537. var defaultPort = layout.config.app_protocol==='https' ? "443" : "80";
  1538. if (addressObj){
  1539. var appPort = addressObj.port || window.location.port;
  1540. address = layout.config.app_protocol+"//"+(addressObj.host || window.location.hostname)+((!appPort || appPort.toString()===defaultPort) ? "" : ":"+appPort)+addressObj.context;
  1541. }else{
  1542. var host = layout.desktop.centerServer.host || window.location.hostname;
  1543. var port = layout.desktop.centerServer.port || window.location.port;
  1544. address = layout.config.app_protocol+"//"+host+((!port || port.toString()===defaultPort) ? "" : ":"+port)+"/"+contextRoot;
  1545. }
  1546. return address;
  1547. },
  1548. _getO2Uri: function(module, address){
  1549. //var uri = module.json.path || module.json.selectPath;
  1550. var uri = module.json.path;
  1551. var pars = {};
  1552. MWF.require("MWF.xScript.Macro", null, false);
  1553. var macro = new MWF.Macro["PageContext"]({"businessData": {}, "json": {}, "options": {}});
  1554. if (module.json.parameters){
  1555. Object.each(module.json.parameters, function(v, key){
  1556. if (uri.indexOf("{"+key+"}")!==-1){
  1557. var reg = new RegExp("{"+key+"}", "g");
  1558. uri = uri.replace(reg, encodeURIComponent((v && v.code) ? (macro.exec(v.code, this) || "") : v));
  1559. }else{
  1560. pars[key] = v;
  1561. }
  1562. }.bind(this));
  1563. }
  1564. var data = null;
  1565. if (module.json.requestBody){
  1566. if (module.json.requestBody.code){
  1567. data = macro.exec(module.json.requestBody.code, this)
  1568. }
  1569. }
  1570. if (module.json.httpMethod==="GET" || module.json.httpMethod==="OPTIONS" || module.json.httpMethod==="HEAD" || module.json.httpMethod==="DELETE"){
  1571. var tag = "?";
  1572. if (uri.indexOf("?")!==-1) tag = "&";
  1573. Object.each(pars, function(v, k){
  1574. var value = (v && v.code) ? (macro.exec(v.code, this) || "") : v;
  1575. uri = uri+tag+k+"="+value;
  1576. }.bind(this));
  1577. }else{
  1578. Object.each(pars, function(v, k){
  1579. if (!data) data = {};
  1580. var value = (v && v.code) ? (macro.exec(v.code, this) || "") : v;
  1581. data[k] = value;
  1582. }.bind(this));
  1583. }
  1584. this.body = data;
  1585. return {"uri": address+uri, "body": data};
  1586. },
  1587. _invoke: function(module, uri, callback){
  1588. MWF.restful(module.json.httpMethod, uri.uri, JSON.encode(uri.body), function(json){
  1589. //this.data = json;
  1590. if (callback) callback(json);
  1591. }.bind(this), true, true);
  1592. },
  1593. loadUnitTypeSelector: function(){
  1594. var nodes = this.propertyContent.getElements(".MWFFormUnitTypeSelector");
  1595. if (nodes.length){
  1596. this.getUnitTypeList(function(){
  1597. nodes.each(function(node){
  1598. var select = new Element("select").inject(node);
  1599. select.addEvent("change", function(e){
  1600. this.setValue(e.target.getParent("div").get("name"), e.target.options[e.target.selectedIndex].value);
  1601. }.bind(this));
  1602. this.setUnitTypeSelectOptions(node, select);
  1603. this.setValue(select.getParent("div").get("name"), select.options[select.selectedIndex].value, null, true);
  1604. // var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
  1605. // refreshNode.addEvent("click", function(e){
  1606. // this.getUnitTypeList(function(){
  1607. // this.setUnitTypeSelectOptions(node, select);
  1608. // }.bind(this), true);
  1609. // }.bind(this));
  1610. }.bind(this));
  1611. }.bind(this));
  1612. }
  1613. },
  1614. setUnitTypeSelectOptions: function(node, select){
  1615. var name = node.get("name");
  1616. select.empty();
  1617. var option = new Element("option", {"value":"all", "text": this.form.designer.lp.all, "selected": (!this.data[name] || this.data[name]==="all")}).inject(select);
  1618. this.unitTypeList.each(function(unitType){
  1619. var option = new Element("option", {
  1620. "text": unitType,
  1621. "value": unitType,
  1622. "selected": (this.data[name]===unitType)
  1623. }).inject(select);
  1624. }.bind(this));
  1625. },
  1626. getUnitTypeList: function(callback, refresh){
  1627. if (!this.unitTypeList || refresh){
  1628. //MWF.xDesktop.requireApp("Org", "Actions.RestActions", function(){
  1629. // var action = new MWF.xApplication.Org.Actions.RestActions();
  1630. var action = MWF.Actions.get("x_organization_assemble_control");
  1631. action.listUnitType(function(json){
  1632. this.unitTypeList = json.data.valueList;
  1633. if (callback) callback();
  1634. }.bind(this));
  1635. //}.bind(this));
  1636. }else{
  1637. if (callback) callback();
  1638. }
  1639. },
  1640. loadParameterEditor: function(){
  1641. var pars = this.propertyContent.getElements(".MWFParameterArea");
  1642. if (pars){
  1643. pars.each(function(par){
  1644. var name = par.get("name");
  1645. if (!this.data[name]) this.data[name] = {};
  1646. var parObj = this.data[name];
  1647. MWF.xDesktop.requireApp("process.FormDesigner", "widget.ParameterEditor", function(){
  1648. var parameterEditor = new MWF.xApplication.process.FormDesigner.widget.ParameterEditor(par, this.designer, {
  1649. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  1650. "maxObj": this.designer.formContentNode,
  1651. "onChange": function (eventName, newValue, oldValue, compareName) {
  1652. this.checkHistory(name+"."+eventName, oldValue, newValue, null, compareName ? (name+"."+compareName) : "");
  1653. }.bind(this)
  1654. });
  1655. parameterEditor.load(parObj, this.data, name);
  1656. }.bind(this));
  1657. }.bind(this));
  1658. }
  1659. },
  1660. loadArrayList: function(){
  1661. var arrays = this.propertyContent.getElements(".MWFArraylist");
  1662. arrays.each(function(node){
  1663. var title = node.get("title");
  1664. var name = node.get("name");
  1665. var arr = this.data[name];
  1666. if (!arr) arr = [];
  1667. MWF.require("MWF.widget.Arraylist", function(){
  1668. var arraylist = new MWF.widget.Arraylist(node, {
  1669. "title": title,
  1670. "onChange": function(){
  1671. var oldValue = this.data[name];
  1672. this.data[name] = arraylist.toArray();
  1673. this.checkHistory(name, oldValue, this.data[name]);
  1674. }.bind(this)
  1675. });
  1676. arraylist.load(arr);
  1677. }.bind(this));
  1678. node.addEvent("keydown", function(e){e.stopPropagation();});
  1679. }.bind(this));
  1680. },
  1681. loadHtmlEditorArea: function(){
  1682. var htmlAreas = this.propertyContent.getElements(".MWFHtmlEditorArea");
  1683. htmlAreas.each(function(node){
  1684. var title = node.get("title");
  1685. var name = node.get("name");
  1686. var scriptContent = this.data[name];
  1687. MWF.require("MWF.widget.HtmlEditorArea", function(){
  1688. var htmlArea = new MWF.widget.HtmlEditorArea(node, {
  1689. "title": title,
  1690. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  1691. "maxObj": this.designer.formContentNode || this.designer.pageContentNode,
  1692. "onChange": function(){
  1693. var oldValue = this.data[name];
  1694. this.data[name] = htmlArea.getValue();
  1695. this.changeData(name, null, oldValue);
  1696. htmlArea.isChanged = true;
  1697. }.bind(this),
  1698. // "onBlur": function(){
  1699. // if (htmlArea.isChanged){
  1700. // this.changeData(name, node, "");
  1701. // htmlArea.isChanged = false;
  1702. // }
  1703. // }.bind(this),
  1704. "onSave": function(){
  1705. this.designer.saveForm();
  1706. }.bind(this)
  1707. });
  1708. var htmlContentData = {"code": scriptContent};
  1709. htmlArea.htmlContentData = htmlContentData;
  1710. htmlArea.load(htmlContentData);
  1711. node.htmlArea = htmlArea;
  1712. }.bind(this));
  1713. }.bind(this));
  1714. },
  1715. loadStylesList: function(){
  1716. var _self = this;
  1717. var styleSelNodes = this.propertyContent.getElements(".MWFFormStyle");
  1718. styleSelNodes.each(function(node){
  1719. if (this.module.form.stylesList){
  1720. if (!this.data.formStyleType) this.data.formStyleType = "default";
  1721. var mode = ( this.form.options.mode || "" ).toLowerCase() === "mobile" ? "mobile" : "pc";
  1722. Object.each(this.module.form.stylesList, function(s, key){
  1723. if( s.mode.contains( mode ) ){
  1724. new Element("option", {
  1725. "text": s.name,
  1726. "value": key,
  1727. "selected": ((!this.data.formStyleType && key=="default") || (this.data.formStyleType==key))
  1728. }).inject(node)
  1729. }
  1730. }.bind(this));
  1731. }else{
  1732. node.getParent("tr").setStyle("display", "none");
  1733. }
  1734. var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node, "after");
  1735. refreshNode.addEvent("click", function(e){
  1736. _self.changeData(this.get("name"), this );
  1737. }.bind(node));
  1738. }.bind(this));
  1739. },
  1740. // loadStylesList: function(){
  1741. // var _self = this;
  1742. // var styleSelNodes = this.propertyContent.getElements(".MWFFormStyle");
  1743. // styleSelNodes.each(function(node){
  1744. // if (this.module.form.stylesList){
  1745. // if (!this.data.formStyleType) this.data.formStyleType = "default";
  1746. // var mode = ( this.form.options.mode || "" ).toLowerCase() === "mobile" ? "mobile" : "pc";
  1747. // Object.each(this.module.form.stylesList, function(s, key){
  1748. // if( s.mode.contains( mode ) ){
  1749. // new Element("option", {
  1750. // "text": s.name,
  1751. // "value": key,
  1752. // "selected": ((!this.data.formStyleType && key=="default") || (this.data.formStyleType==key))
  1753. // }).inject(node)
  1754. // }
  1755. // }.bind(this));
  1756. // }else{
  1757. // node.getParent("tr").setStyle("display", "none");
  1758. // }
  1759. //
  1760. // var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node, "after");
  1761. // refreshNode.addEvent("click", function(e){
  1762. // _self.changeData(this.get("name"), this );
  1763. // }.bind(node));
  1764. // }.bind(this));
  1765. // },
  1766. loadDivTemplateType: function(){
  1767. var nodes = this.propertyContent.getElements(".MWFDivTemplate");
  1768. if (nodes.length){
  1769. var keys = [];
  1770. //if (this.module.form.stylesList) {
  1771. // if (this.module.form.stylesList[this.module.form.json.formStyleType]){
  1772. // var styles = this.module.form.stylesList[this.module.form.json.formStyleType][this.module.moduleName];
  1773. // if (styles) {
  1774. // Object.each(styles, function (v, k) {
  1775. // keys.push(k);
  1776. // }.bind(this));
  1777. // }
  1778. // }
  1779. //}
  1780. if (this.module.form.templateStyles && this.module.form.templateStyles[this.module.moduleName]) {
  1781. var styles = this.module.form.templateStyles[this.module.moduleName];
  1782. if (styles) {
  1783. Object.each(styles, function (v, k) {
  1784. keys.push(k);
  1785. }.bind(this));
  1786. }
  1787. }
  1788. nodes.each(function(node){
  1789. node.empty();
  1790. new Element("option", {
  1791. "text": "default",
  1792. "value": "default",
  1793. "selected": (!this.data.templateType || this.data.templateType=="default")
  1794. }).inject(node);
  1795. if (keys.length){
  1796. keys.each(function(k){
  1797. new Element("option", {
  1798. "text": styles[k].name,
  1799. "value": k,
  1800. "selected": (this.data.templateType==k)
  1801. }).inject(node)
  1802. }.bind(this));
  1803. }else{
  1804. node.getParent("tr").setStyle("display", "none");
  1805. }
  1806. }.bind(this));
  1807. }
  1808. },
  1809. loadPersonInput: function(){
  1810. var personMultipleNodes = this.propertyContent.getElements(".MWFPersonMultiple");
  1811. var personIdentityNodes = this.propertyContent.getElements(".MWFPersonIdentity");
  1812. var personUnitNodes = this.propertyContent.getElements(".MWFPersonUnit");
  1813. var dutyNodes = this.propertyContent.getElements(".MWFDutySelector");
  1814. var dutyNameNodes = this.propertyContent.getElements(".MWFPersonDuty");
  1815. var viewNodes = this.propertyContent.getElements(".MWFViewSelect");
  1816. var cmsviewNodes = this.propertyContent.getElements(".MWFCMSViewSelect");
  1817. var queryviewNodes = this.propertyContent.getElements(".MWFQueryViewSelect");
  1818. var queryStatementNodes = this.propertyContent.getElements(".MWFQueryStatementSelect");
  1819. var querystatNodes = this.propertyContent.getElements(".MWFQueryStatSelect");
  1820. var fileNodes = this.propertyContent.getElements(".MWFImageFileSelect");
  1821. var processFileNodes = this.propertyContent.getElements(".MWFProcessImageFileSelect");
  1822. var cmsFileNodes = this.propertyContent.getElements(".MWFCMSImageFileSelect");
  1823. var scriptNodes = this.propertyContent.getElements(".MWFScriptSelect");
  1824. var formStyleNodes = this.propertyContent.getElements(".MWFFormStyleSelect");
  1825. var dictionaryNodes = this.propertyContent.getElements(".MWFDictionarySelect");
  1826. var queryImportModelNodes = this.propertyContent.getElements(".MWFQueryImportModelSelect");
  1827. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function(){
  1828. personMultipleNodes.each(function(node){
  1829. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1830. "types": node.get("data-types").split(","),
  1831. "names": this.data[node.get("name")],
  1832. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  1833. });
  1834. }.bind(this));
  1835. personIdentityNodes.each(function(node){
  1836. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1837. "type": "identity",
  1838. "names": this.data[node.get("name")],
  1839. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  1840. });
  1841. }.bind(this));
  1842. personUnitNodes.each(function(node){
  1843. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1844. "type": "unit",
  1845. "names": this.data[node.get("name")],
  1846. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  1847. });
  1848. }.bind(this));
  1849. dutyNodes.each(function(node){
  1850. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1851. "type": "duty",
  1852. "names": this.data[node.get("name")],
  1853. "onChange": function(ids){this.addDutyItem(node, ids);}.bind(this),
  1854. "onRemoveDuty": function(item){this.removeDutyItem(node, item);}.bind(this)
  1855. });
  1856. }.bind(this));
  1857. dutyNameNodes.each(function(node){
  1858. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1859. "type": "dutyName",
  1860. "names": this.data[node.get("name")],
  1861. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  1862. });
  1863. }.bind(this));
  1864. viewNodes.each(function(node){
  1865. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1866. "type": "View",
  1867. "count": 1,
  1868. "names": [this.data[node.get("name")]],
  1869. "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
  1870. });
  1871. }.bind(this));
  1872. cmsviewNodes.each(function(node){
  1873. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1874. "type": "CMSView",
  1875. "count": 1,
  1876. "names": [this.data[node.get("name")]],
  1877. "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
  1878. });
  1879. }.bind(this));
  1880. queryviewNodes.each(function(node){
  1881. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1882. "type": "QueryView",
  1883. "count": node.dataset["count"] || 1,
  1884. "names": typeOf(this.data[node.get("name")]) === "array" ? this.data[node.get("name")] : [this.data[node.get("name")]],
  1885. "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
  1886. });
  1887. }.bind(this));
  1888. queryStatementNodes.each(function(node){
  1889. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1890. "type": "QueryStatement",
  1891. "count": 1,
  1892. "viewEnable": true,
  1893. "names": [this.data[node.get("name")]],
  1894. "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
  1895. });
  1896. }.bind(this));
  1897. querystatNodes.each(function(node){
  1898. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1899. "type": "QueryStat",
  1900. "count": 1,
  1901. "names": [this.data[node.get("name")]],
  1902. "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
  1903. });
  1904. }.bind(this));
  1905. queryImportModelNodes.each(function(node){
  1906. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1907. "type": "QueryImportModel",
  1908. "count": 1,
  1909. "names": [this.data[node.get("name")]],
  1910. "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
  1911. });
  1912. }.bind(this));
  1913. scriptNodes.each(function(node){
  1914. var ps = new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1915. "type": "Script",
  1916. "count": node.dataset["count"] || 1,
  1917. "names": (!node.dataset["count"] || node.dataset["count"].toInt()==1) ? [this.data[node.get("name")]] : this.data[node.get("name")],
  1918. "onChange": function(ids){
  1919. this.saveScriptSelectItem(node, ids);
  1920. }.bind(this)
  1921. });
  1922. node.store("selector", ps);
  1923. var actionNode = node.getNext();
  1924. if (actionNode.hasClass("MWFScriptSelectAction")){
  1925. var _self = this;
  1926. var copyNode = actionNode.getFirst();
  1927. var pasteNode = actionNode.getLast();
  1928. copyNode.store("slectNode", node);
  1929. pasteNode.store("slectNode", node);
  1930. copyNode.addEvent("click", function(e){
  1931. var selectNode = this.retrieve("slectNode");
  1932. if (selectNode){
  1933. var name = node.get("name");
  1934. var data = _self.data[name];
  1935. if (data){
  1936. var str = JSON.encode(data);
  1937. o2.DL.open({
  1938. "isTitle": false,
  1939. "width": 400,
  1940. "height": 500,
  1941. "html": "<textarea style='width: 99%; height: 98%'>"+str+"</textarea>",
  1942. "buttonList": [{
  1943. "type": "ok",
  1944. "text": "ok",
  1945. "action": function(){this.close();}
  1946. }]
  1947. })
  1948. }
  1949. }
  1950. });
  1951. pasteNode.addEvent("click", function(e){
  1952. var selectNode = this.retrieve("slectNode");
  1953. if (selectNode){
  1954. o2.DL.open({
  1955. "isTitle": false,
  1956. "width": 400,
  1957. "height": 500,
  1958. "html": "<textarea style='width: 99%; height: 98%'></textarea>",
  1959. "buttonList": [{
  1960. "type": "ok",
  1961. "text": "ok",
  1962. "action": function(){
  1963. var dataStr = this.content.getElement("textarea").get("value");
  1964. try{
  1965. var data = JSON.decode(dataStr);
  1966. var s = selectNode.retrieve("selector");
  1967. s.setData(data);
  1968. _self.saveScriptSelectItem(selectNode, s.identitys);
  1969. }catch(e){
  1970. throw e;
  1971. }
  1972. this.close();
  1973. }
  1974. },{
  1975. "type": "cancel",
  1976. "text": "cancel",
  1977. "action": function(){this.close();}
  1978. }]
  1979. })
  1980. }
  1981. });
  1982. }
  1983. }.bind(this));
  1984. var _self = this;
  1985. formStyleNodes.each(function(node){
  1986. var data = this.data[node.get("name")];
  1987. if( typeOf( data ) === "string" ){
  1988. for( var key in this.module.form.stylesList ){
  1989. var s = this.module.form.stylesList[key];
  1990. if( ((!data && key=="default") || (data==key)) ){
  1991. data = {
  1992. name : s.name,
  1993. id : key
  1994. };
  1995. break;
  1996. }
  1997. }
  1998. }
  1999. debugger;
  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. "appType": this.appType === 'cms' ? 'cms' : 'process',
  2007. "stylesUrl": this.appType === 'cms' ? "../x_component_cms_FormDesigner/Module/Form/skin/config.json" : null
  2008. },
  2009. "validFun" : function (ids) {
  2010. var flag = true;
  2011. if( ids.length === 0 ){
  2012. this.designer.notice(MWF.APPFD.LP.mustSelectFormStyle, "error");
  2013. flag = false;
  2014. }else if( ids[0].data.type === "script" ){
  2015. debugger;
  2016. this.designer.actions.getScriptByName( ids[0].data.name, ids[0].data.application || ids[0].data.appId, function( json ) {
  2017. try{
  2018. var f = eval("(function(){\n return "+json.data.text+"\n})");
  2019. var j = f();
  2020. if( typeOf(j) !== "object" ){
  2021. this.designer.notice( MWF.APPFD.LP.notValidJson, "error" );
  2022. flag = false;
  2023. }
  2024. }catch (e) {
  2025. this.designer.notice( MWF.APPFD.LP.notValidJson +":"+ e.message, "error" );
  2026. flag = false;
  2027. }
  2028. }.bind(this), function () {
  2029. flag = false;
  2030. }, false);
  2031. }
  2032. return flag;
  2033. }.bind(this),
  2034. "onChange": function(ids){
  2035. var d = ids[0].data;
  2036. var data;
  2037. if( d.type === "script" ){
  2038. data = {
  2039. "type" : "script",
  2040. "name": d.name,
  2041. "alias": d.alias,
  2042. "id": d.id,
  2043. "appName" : d.appName || d.applicationName,
  2044. "appId": d.appId,
  2045. "application": d.application
  2046. };
  2047. }else{
  2048. data = d.id;
  2049. }
  2050. var name = node.get("name");
  2051. var oldValue = this.data[name];
  2052. this.data[name] = data;
  2053. this.changeData(name, node, oldValue);
  2054. }.bind(this)
  2055. });
  2056. var next = node.getNext();
  2057. if( next && next.get("class") === "MWFScriptSelectRefresh" ){
  2058. var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(next);
  2059. refreshNode.addEvent("click", function(e){
  2060. _self.changeData(this.get("name"), this );
  2061. }.bind(node));
  2062. }
  2063. }.bind(this));
  2064. dictionaryNodes.each(function(node){
  2065. var data = this.data[node.get("name")];
  2066. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  2067. "type": "Dictionary",
  2068. "count": node.dataset["count"] || 0,
  2069. "names": typeOf(data)==="array" ? data : [data],
  2070. "onChange": function(ids){
  2071. var data = [];
  2072. var name = node.get("name");
  2073. if( ids.length > 0 ){
  2074. // var d = ids[0].data;
  2075. ids.each( function (id) {
  2076. var d = id.data;
  2077. data.push({
  2078. "type" : "dictionary",
  2079. "name": d.name,
  2080. "alias": d.alias,
  2081. "id": d.id,
  2082. "appName" : d.appName || d.applicationName,
  2083. "appAlias" : d.appAlias || d.applicationAlias,
  2084. "appId": d.appId,
  2085. "application": d.application,
  2086. "appType" : d.appType
  2087. })
  2088. });
  2089. }
  2090. var oldValue = this.data[name];
  2091. this.data[name] = data;
  2092. this.changeData(name, node, oldValue);
  2093. }.bind(this)
  2094. });
  2095. }.bind(this));
  2096. fileNodes.each(function(node){
  2097. var d = this.data[node.get("name")];
  2098. var data = d || {};
  2099. //this.form
  2100. if (d && typeOf(d)==="string"){
  2101. if (this.form.page){
  2102. data = {"id": d, "portal": this.form.application}
  2103. }else{
  2104. data = {"id": d, "application": this.form.application}
  2105. }
  2106. }
  2107. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  2108. "type": "PortalFile",
  2109. "count": 1,
  2110. "isImage": true,
  2111. "values": (data.id) ? [data.id] : [],
  2112. "onChange": function(ids){this.saveFileItem(node, ids);}.bind(this)
  2113. });
  2114. }.bind(this));
  2115. processFileNodes.each(function(node){
  2116. var d = this.data[node.get("name")];
  2117. var data = d || {};
  2118. //this.form
  2119. if (d && typeOf(d)==="string"){
  2120. if (this.form.page){
  2121. data = {"id": d, "portal": this.form.application}
  2122. }else{
  2123. data = {"id": d, "application": this.form.application}
  2124. }
  2125. }
  2126. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  2127. "type": "ProcessFile",
  2128. "count": 1,
  2129. "isImage": true,
  2130. "values": (data.id) ? [data.id] : [],
  2131. "onChange": function(ids){this.saveFileItem(node, ids);}.bind(this)
  2132. });
  2133. }.bind(this));
  2134. cmsFileNodes.each(function(node){
  2135. var d = this.data[node.get("name")];
  2136. var data = d || {};
  2137. //this.form
  2138. if (d && typeOf(d)==="string"){
  2139. data = {"id": d, "appId": this.form.application || this.form.appId}
  2140. }
  2141. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  2142. "type": "CMSFile",
  2143. "count": 1,
  2144. "isImage": true,
  2145. "values": (data.id) ? [data.id] : [],
  2146. "onChange": function(ids){this.saveFileItem(node, ids);}.bind(this)
  2147. });
  2148. }.bind(this));
  2149. }.bind(this));
  2150. },
  2151. loadDictionaryItem: function(){
  2152. var dictItemContainers = this.propertyContent.getElements(".MWFDictionaryItemContainer");
  2153. dictItemContainers.each(function (container) {
  2154. var dictNode = container.getElement(".MWFDictionaryNode");
  2155. var dictItemNode = container.getElement(".MWFDictionaryItemNode");
  2156. var dictItemSelect;
  2157. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function() {
  2158. var data = this.data[dictNode.get("name")];
  2159. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(dictNode, this.form.designer, {
  2160. "type": "Dictionary",
  2161. "count": dictNode.dataset["count"] || 0,
  2162. "names": typeOf(data) === "array" ? data : [data],
  2163. "onChange": function (ids) {
  2164. var data = [];
  2165. var name = dictNode.get("name");
  2166. if (ids.length > 0) {
  2167. // var d = ids[0].data;
  2168. ids.each(function (id) {
  2169. var d = id.data;
  2170. data.push({
  2171. "type": "dictionary",
  2172. "name": d.name,
  2173. "alias": d.alias,
  2174. "id": d.id,
  2175. "appName": d.appName || d.applicationName,
  2176. "appAlias": d.appAlias || d.applicationAlias,
  2177. "appId": d.appId,
  2178. "application": d.application,
  2179. "appType": d.appType
  2180. })
  2181. });
  2182. }
  2183. var oldValue = this.data[name];
  2184. this.data[name] = data;
  2185. this.changeData(name, dictNode, oldValue);
  2186. changeDictItemValue("");
  2187. dictItemSelect.reload();
  2188. }.bind(this)
  2189. });
  2190. }.bind(this));
  2191. var changeDictItemValue = function (newValue) {
  2192. var name = dictItemNode.get("name");
  2193. var oldValue = this.data[name];
  2194. this.data[name] = newValue;
  2195. this.checkHistory(name, oldValue, newValue);
  2196. }.bind(this);
  2197. MWF.xDesktop.requireApp("process.FormDesigner", "widget.DictItemSelector", function() {
  2198. dictItemSelect = new MWF.xApplication.process.FormDesigner.widget.DictItemSelector(dictItemNode, this, {
  2199. onChange: function (newValue) {
  2200. changeDictItemValue( newValue );
  2201. }.bind(this)
  2202. });
  2203. }.bind(this))
  2204. }.bind(this));
  2205. },
  2206. loadQueryViewItem: function(){
  2207. var containers = this.propertyContent.getElements(".MWFQueryViewItemContainer");
  2208. containers.each(function (container) {
  2209. var viewNode = container.getElement(".MWFQueryViewNode");
  2210. var viewColumnSelects = container.getElements(".MWFViewColumnSelect");
  2211. viewColumnSelects.each(function (select) {
  2212. select.addEvent("change", function () {
  2213. var name = select.get("name");
  2214. //var oldValue = this.data[name];
  2215. var value = select.options[select.selectedIndex].value;
  2216. this.setValue(name, value, select);
  2217. //this.checkHistory(name, oldValue, this.data[name]);
  2218. }.bind(this))
  2219. }.bind(this));
  2220. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function() {
  2221. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(viewNode, this.form.designer, {
  2222. "type": "QueryView",
  2223. "count": 1,
  2224. "names": [this.data[viewNode.get("name")]],
  2225. "onChange": function (ids) {
  2226. var name = viewNode.get("name");
  2227. var oldValue = this.data[name];
  2228. if (ids[0]) {
  2229. var view = ids[0].data;
  2230. var data = {
  2231. "name": view.name,
  2232. "alias": view.alias,
  2233. "id": view.id,
  2234. "appName": view.appName || view.applicationName || view.query,
  2235. "appId": view.appId,
  2236. "application": view.application || view.query
  2237. };
  2238. this.data[name] = data;
  2239. } else {
  2240. this.data[name] = null;
  2241. }
  2242. this.checkHistory(name, oldValue, this.data[name]);
  2243. loadSelectsOptions( function () {
  2244. changSelectsIndex(0);
  2245. }.bind(this));
  2246. }.bind(this)
  2247. });
  2248. }.bind(this));
  2249. var changSelectsIndex = function (idx) {
  2250. viewColumnSelects.each(function (select) {
  2251. select.selectedIndex = idx;
  2252. select.fireEvent("change");
  2253. }.bind(this))
  2254. }.bind(this);
  2255. var loadSelectsOptions = function ( callback ) {
  2256. var name = viewNode.get("name");
  2257. var view = this.data[name];
  2258. if( view && view.id ){
  2259. MWF.Actions.get("x_query_assemble_designer").getView(view.id, function(json){
  2260. var viewData = JSON.decode(json.data.data);
  2261. var columnList = viewData.selectEntryList || viewData.selectList;
  2262. viewColumnSelects.each(function (select) {
  2263. select.empty();
  2264. var sname = select.get("name");
  2265. new Element("option", { value: "" }).inject( select );
  2266. new Element("option", { value: "bundle", text: "bundle", selected: this.data[sname] === "bundle" }).inject( select );
  2267. columnList.each(function ( column ) {
  2268. new Element("option", {
  2269. value: column.column,
  2270. text: column.displayName + "(" + column.column + ")",
  2271. selected: this.data[sname] === column.column
  2272. }).inject( select );
  2273. }.bind(this))
  2274. }.bind(this));
  2275. if(callback)callback();
  2276. }.bind(this), function () {
  2277. return true
  2278. });
  2279. }else{
  2280. viewColumnSelects.each(function (select) {
  2281. select.empty();
  2282. });
  2283. if(callback)callback();
  2284. }
  2285. }.bind(this)
  2286. loadSelectsOptions();
  2287. }.bind(this));
  2288. },
  2289. loadQueryStatementItem: function(){
  2290. var containers = this.propertyContent.getElements(".MWFQueryStatementItemContainer");
  2291. containers.each(function (container) {
  2292. var viewNode = container.getElement(".MWFQueryStatementNode");
  2293. var viewColumnSelects = container.getElements(".MWFStatementItemSelect");
  2294. viewColumnSelects.each(function (select) {
  2295. select.addEvent("change", function () {
  2296. var name = select.get("name");
  2297. //var oldValue = this.data[name];
  2298. var value = select.options[select.selectedIndex].value;
  2299. this.setValue(name, value, select);
  2300. //this.checkHistory(name, oldValue, this.data[name]);
  2301. }.bind(this))
  2302. }.bind(this));
  2303. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function() {
  2304. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(viewNode, this.form.designer, {
  2305. "type": "QueryStatement",
  2306. "count": 1,
  2307. "names": [this.data[viewNode.get("name")]],
  2308. "onChange": function (ids) {
  2309. var name = viewNode.get("name");
  2310. var oldValue = this.data[name];
  2311. if (ids[0]) {
  2312. var view = ids[0].data;
  2313. var data = {
  2314. "name": view.name,
  2315. "alias": view.alias,
  2316. "id": view.id,
  2317. "appName": view.appName || view.applicationName || view.query,
  2318. "appId": view.appId,
  2319. "application": view.application || view.query
  2320. };
  2321. this.data[name] = data;
  2322. } else {
  2323. this.data[name] = null;
  2324. }
  2325. this.checkHistory(name, oldValue, this.data[name]);
  2326. if( this.viewFilterWithTemplate )this.viewFilterWithTemplate.resetStatementData(view.id);
  2327. loadSelectsOptions( function () {
  2328. changSelectsIndex(0);
  2329. }.bind(this));
  2330. }.bind(this)
  2331. });
  2332. }.bind(this));
  2333. var changSelectsIndex = function (idx) {
  2334. viewColumnSelects.each(function (select) {
  2335. select.selectedIndex = idx;
  2336. select.fireEvent("change");
  2337. }.bind(this))
  2338. }.bind(this);
  2339. var loadSelectsOptions = function ( callback ) {
  2340. var name = viewNode.get("name");
  2341. var view = this.data[name];
  2342. if( view && view.id ){
  2343. MWF.Actions.load("x_query_assemble_designer").StatementAction.get(view.id, function(json){
  2344. var viewData = JSON.decode(json.data.view || {});
  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. debugger;
  2723. var multiActionArea = this.propertyContent.getElements(".MWFMultiActionArea");
  2724. multiActionArea.each(function(node){
  2725. var name = node.get("name");
  2726. var actionContent = this.data[name];
  2727. var oldValue = actionContent ? JSON.parse( JSON.stringify(actionContent) ) : actionContent;
  2728. MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function(){
  2729. var options = {
  2730. "iconType": this.data.iconType,
  2731. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  2732. "isSystemTool" : true,
  2733. "target" : node.get("data-target"),
  2734. "onChange": function(historyOptions){
  2735. historyOptions = historyOptions || {};
  2736. this.data[name] = actionEditor.data;
  2737. this.changeData(name, null, oldValue, true);
  2738. this.checkHistory(name, oldValue, null, false, name + historyOptions.compareName, historyOptions.force );
  2739. oldValue = JSON.parse( JSON.stringify(this.data[name]) );
  2740. }.bind(this)
  2741. };
  2742. if(node.get("data-systemToolsAddress")){
  2743. options.systemToolsAddress = node.get("data-systemToolsAddress");
  2744. }
  2745. var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, options);
  2746. actionEditor.load(actionContent);
  2747. }.bind(this));
  2748. }.bind(this));
  2749. var actionAreas = this.propertyContent.getElements(".MWFActionArea");
  2750. actionAreas.each(function(node){
  2751. var name = node.get("name");
  2752. var actionContent = this.data[name];
  2753. var oldValue = actionContent ? JSON.parse( JSON.stringify(actionContent) ) : actionContent;
  2754. MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function(){
  2755. // var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, {
  2756. // "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  2757. // "noCreate": true,
  2758. // "noDelete": true,
  2759. // "noCode": true,
  2760. // "onChange": function(){
  2761. // this.data[name] = actionEditor.data;
  2762. // }.bind(this)
  2763. // });
  2764. // actionEditor.load(this.module.defaultToolBarsData);
  2765. var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
  2766. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  2767. "onChange": function(historyOptions){
  2768. historyOptions = historyOptions || {};
  2769. this.data[name] = actionEditor.data;
  2770. this.changeData(name, null, oldValue, true);
  2771. this.checkHistory(name, oldValue, null, false, name + historyOptions.compareName, historyOptions.force );
  2772. oldValue = JSON.parse( JSON.stringify(this.data[name]) );
  2773. }.bind(this)
  2774. });
  2775. actionEditor.load(actionContent);
  2776. }.bind(this));
  2777. }.bind(this));
  2778. var actionAreas = this.propertyContent.getElements(".MWFDefaultActionArea");
  2779. actionAreas.each(function(node){
  2780. var name = node.get("name");
  2781. var actionContent = this.data[name] || this.module.defaultToolBarsData;
  2782. var oldValue = actionContent ? JSON.parse( JSON.stringify(actionContent) ) : actionContent;
  2783. MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function(){
  2784. var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
  2785. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  2786. "isSystemTool" : true,
  2787. "noCreate": true,
  2788. "noDelete": false,
  2789. "noCode": true,
  2790. "noReadShow": true,
  2791. "target" : node.get("data-target"),
  2792. "noEditShow": true,
  2793. "onChange": function(historyOptions){
  2794. historyOptions = historyOptions || {};
  2795. this.data[name] = actionEditor.data;
  2796. this.changeData(name, null, oldValue, true);
  2797. this.checkHistory(name, oldValue, null, false, name + historyOptions.compareName, historyOptions.force );
  2798. oldValue = JSON.parse( JSON.stringify(this.data[name]) );
  2799. }.bind(this)
  2800. });
  2801. actionEditor.load(actionContent);
  2802. // var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, {
  2803. // "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  2804. // "onChange": function(){
  2805. // this.data[name] = actionEditor.data;
  2806. // }.bind(this)
  2807. // });
  2808. // actionEditor.load(actionContent);
  2809. }.bind(this));
  2810. }.bind(this));
  2811. },
  2812. loadMaplist: function(){
  2813. var maplists = this.propertyContent.getElements(".MWFMaplist");
  2814. maplists.each(function(node){
  2815. var title = node.get("title");
  2816. var name = node.get("name");
  2817. var lName = name.toLowerCase();
  2818. var collapse = node.get("collapse");
  2819. var mapObj = this.data[name];
  2820. if (!mapObj) mapObj = {};
  2821. MWF.require("MWF.widget.Maplist", function(){
  2822. node.empty();
  2823. var maplist = new MWF.widget.Maplist(node, {
  2824. "title": title,
  2825. "collapse": (collapse) ? true : false,
  2826. "onChange": function(){
  2827. var oldData = this.data[name];
  2828. this.changeJsonDate(name, maplist.toJson());
  2829. this.changeStyle(name, oldData);
  2830. this.changeData(name, null, oldData);
  2831. }.bind(this),
  2832. "onDelete": function(key){
  2833. this.module.deletePropertiesOrStyles(name, key);
  2834. }.bind(this),
  2835. "isProperty": (lName.contains("properties") || lName.contains("property") || lName.contains("attribute"))
  2836. });
  2837. maplist.load(mapObj);
  2838. this.maplists[name] = maplist;
  2839. }.bind(this));
  2840. }.bind(this));
  2841. },
  2842. //loadPropertyTab: function(){
  2843. // var tabNodes = this.propertyContent.getElements(".MWFTab");
  2844. // if (tabNodes.length){
  2845. // var tmpNode = this.propertyContent.getFirst();
  2846. // var tabAreaNode = new Element("div", {
  2847. // "styles": this.form.css.propertyTabNode
  2848. // }).inject(tmpNode, "before");
  2849. //
  2850. // MWF.require("MWF.widget.Tab", function(){
  2851. // var tab = new MWF.widget.Tab(tabAreaNode, {"style": "formPropertyList"});
  2852. // tab.load();
  2853. // var tabPages = [];
  2854. // tabNodes.each(function(node){
  2855. // if (node.getStyle("display")!="none"){
  2856. // var page = tab.addTab(node, node.get("title"), false);
  2857. // tabPages.push(page);
  2858. // page.contentScrollNode = new Element("div", {"styles": {"height": "100%", "overflow": "hidden"}}).inject(page.contentNodeArea);
  2859. // node.inject(page.contentScrollNode);
  2860. // this.setScrollBar(page.contentScrollNode, "small", null, null);
  2861. // }
  2862. // }.bind(this));
  2863. // tabPages[0].showTab();
  2864. //
  2865. // this.propertyTab = tab;
  2866. //
  2867. // this.designer.resizeNode();
  2868. // }.bind(this), false);
  2869. // }
  2870. //},
  2871. loadPropertyTab: function(){
  2872. var tabNodes = this.propertyContent.getElements(".MWFTab");
  2873. if( this.ignoreSection ){
  2874. tabNodes = tabNodes.filter(function(node){
  2875. return node.get("title") !== MWF.xApplication.process.FormDesigner.LP.propertyTemplate.section;
  2876. })
  2877. }
  2878. var groupObject = {}; //data-group 属性可以表示不同的分组
  2879. if (tabNodes.length){
  2880. tabNodes.each( function(node){
  2881. var group = node.get("data-group") || "default";
  2882. groupObject[group] = groupObject[group] || [];
  2883. groupObject[group].push( node );
  2884. }.bind(this))
  2885. }
  2886. for( var group in groupObject ){
  2887. if( group === "default" ){
  2888. var tmpNode = this.propertyContent.getFirst();
  2889. var tabAreaNode = new Element("div", {
  2890. "styles": this.form.css.propertyTabNode
  2891. }).inject(tmpNode, "before");
  2892. MWF.require("MWF.widget.Tab", function(){
  2893. var tab = new MWF.widget.Tab(tabAreaNode, {"style": "formPropertyList"});
  2894. tab.load();
  2895. var tabPages = [];
  2896. groupObject["default"].each(function(node){
  2897. if (node.getStyle("display")!="none"){
  2898. var page = tab.addTab(node, node.get("title"), false);
  2899. tabPages.push(page);
  2900. page.contentScrollNode = new Element("div", {"styles": {"height": "100%", "overflow": "hidden"}}).inject(page.contentNodeArea);
  2901. node.inject(page.contentScrollNode);
  2902. this.setScrollBar(page.contentScrollNode, "small", null, null);
  2903. }
  2904. }.bind(this));
  2905. tabPages[this.propertyTabIndex || 0].showTab();
  2906. this.propertyTab = tab;
  2907. this.designer.resizeNode();
  2908. }.bind(this), false);
  2909. }else{
  2910. var tmpNode = groupObject[group][0];
  2911. var tabAreaNode = new Element("div", {
  2912. "styles": this.form.css.propertyTabNode
  2913. }).inject(tmpNode, "before");
  2914. MWF.require("MWF.widget.Tab", function(){
  2915. var tab = new MWF.widget.Tab(tabAreaNode, {"style": tmpNode.get("data-style") || "formPropertyList"});
  2916. tab.load();
  2917. var tabPages = [];
  2918. groupObject[group].each(function(node) {
  2919. var page = tab.addTab(node, node.get("title"), false);
  2920. tabPages.push(page);
  2921. node.store("tab", page);
  2922. if (node.getStyle("display") === "none"){
  2923. page.disableTab( true );
  2924. node.show();
  2925. }
  2926. }.bind(this));
  2927. for( var i=0; i<tabPages.length; i++ ){
  2928. if( !tabPages[i].disabled ){
  2929. tabPages[i].showTab();
  2930. break
  2931. }
  2932. }
  2933. }.bind(this), false);
  2934. }
  2935. }
  2936. },
  2937. setEditNodeEvent: function(){
  2938. var property = this;
  2939. // var inputs = this.process.propertyListNode.getElements(".editTableInput");
  2940. var inputs = this.propertyContent.getElements("input");
  2941. inputs.each(function(input){
  2942. var jsondata = input.get("name");
  2943. if (this.module){
  2944. var id = this.data.pid;
  2945. //var id = this.form.json.id;
  2946. // input.set("name", this.form.options.mode+id+jsondata);
  2947. input.set("name", id+jsondata);
  2948. }
  2949. if (jsondata){
  2950. var inputType = input.get("type").toLowerCase();
  2951. switch (inputType){
  2952. case "radio":
  2953. input.addEvent("change", function(e){
  2954. property.setRadioValue(jsondata, this);
  2955. });
  2956. input.addEvent("blur", function(e){
  2957. property.setRadioValue(jsondata, this, true);
  2958. });
  2959. input.addEvent("keydown", function(e){
  2960. e.stopPropagation();
  2961. });
  2962. property.setRadioValue(jsondata, input, true);
  2963. break;
  2964. case "checkbox":
  2965. input.addEvent("change", function(e){
  2966. property.setCheckboxValue(jsondata, this, true);
  2967. });
  2968. input.addEvent("click", function(e){
  2969. property.setCheckboxValue(jsondata, this);
  2970. });
  2971. input.addEvent("keydown", function(e){
  2972. e.stopPropagation();
  2973. });
  2974. break;
  2975. default:
  2976. input.addEvent("change", function(e){
  2977. var v = (this.type==="number") ? this.value.toFloat() : this.value;
  2978. property.setValue(jsondata, v, this);
  2979. });
  2980. input.addEvent("blur", function(e){
  2981. var v = (this.type==="number") ? this.value.toFloat() : this.value;
  2982. property.setValue(jsondata, v, this, true);
  2983. });
  2984. input.addEvent("keydown", function(e){
  2985. if (e.code==13){
  2986. var v = (this.type==="number") ? this.value.toFloat() : this.value;
  2987. property.setValue(jsondata, v, this);
  2988. }
  2989. e.stopPropagation();
  2990. });
  2991. }
  2992. }
  2993. }.bind(this));
  2994. var selects = this.propertyContent.getElements("select");
  2995. selects.each(function(select){
  2996. var jsondata = select.get("name");
  2997. if (jsondata){
  2998. select.addEvent("change", function(e){
  2999. property.setSelectValue(jsondata, this);
  3000. });
  3001. //property.setSelectValue(jsondata, select);
  3002. }
  3003. });
  3004. var textareas = this.propertyContent.getElements("textarea");
  3005. textareas.each(function(input){
  3006. var jsondata = input.get("name");
  3007. if (jsondata){
  3008. input.addEvent("change", function(e){
  3009. property.setValue(jsondata, this.value);
  3010. });
  3011. input.addEvent("blur", function(e){
  3012. property.setValue(jsondata, this.value);
  3013. });
  3014. input.addEvent("keydown", function(e){
  3015. e.stopPropagation();
  3016. });
  3017. }
  3018. }.bind(this));
  3019. },
  3020. checkHistory: function(name, oldValue, newValue, notSetEditStyle, compareName, force){
  3021. if( this.isLoaded() && this.module.form.history ){
  3022. this.module.checkPropertyHistory(name, oldValue, newValue, notSetEditStyle, compareName, force);
  3023. }
  3024. },
  3025. changeStyle: function(name, oldData){
  3026. this.module.setPropertiesOrStyles(name, oldData);
  3027. },
  3028. changeData: function(name, input, oldValue, notCheckHistory, historyNotSetEditStyle){
  3029. if(!notCheckHistory){
  3030. var flag = false;
  3031. if( input && input.hasAttribute )flag = input.hasAttribute("data-notAutoHistory");
  3032. if(!flag)this.checkHistory(name, oldValue, null, historyNotSetEditStyle);
  3033. }
  3034. this.module._setEditStyle(name, input, oldValue);
  3035. },
  3036. changeJsonDate: function(key, value){
  3037. if (typeOf(key)!=="array") key = [key];
  3038. var o = this.data;
  3039. var len = key.length-1;
  3040. key.each(function(n, i){
  3041. if (i<len) {
  3042. if (!o.hasOwnProperty(n)) o[n] = {};
  3043. //if (!o[n]) o[n] = {};
  3044. o = o[n];
  3045. }
  3046. }.bind(this));
  3047. o[key[len]] = value;
  3048. //this.data[key] = value;
  3049. },
  3050. setRadioValue: function(name, input, notCheckHistory){
  3051. if (input.checked){
  3052. var i = name.indexOf("*");
  3053. var names = (i==-1) ? name.split(".") : name.substr(i+1, name.length).split(".");
  3054. var value = input.value;
  3055. if (value=="false") value = false;
  3056. if (value=="true") value = true;
  3057. var oldValue = this.data;
  3058. for (var idx = 0; idx<names.length; idx++){
  3059. if (!oldValue[names[idx]]){
  3060. oldValue = oldValue[names[idx]];
  3061. //oldValue = null;
  3062. break;
  3063. }else{
  3064. oldValue = oldValue[names[idx]];
  3065. }
  3066. }
  3067. // var value = input.value;
  3068. // if (value==="false") value = false;
  3069. // if (value==="true") value = true;
  3070. //var oldValue = this.data[name];
  3071. this.changeJsonDate(names, value);
  3072. //由于加载property的时候,会自动setRadioValue,这时候就不要检查历史了notCheckHistory
  3073. var historyNotSetEditStyle = false;
  3074. //但是ElementUI有isPropertyLoaded判断,这个时候又需要setEditStyle了。
  3075. if( this.module && this.module.vm )historyNotSetEditStyle = false;
  3076. this.changeData(name, input, oldValue, notCheckHistory, historyNotSetEditStyle);
  3077. }
  3078. },
  3079. setCheckboxValue: function(name, input, notCheckHistory){
  3080. //var id = this.module.json.id;
  3081. //var id = this.form.json.id;
  3082. var id = this.data.pid;
  3083. // var checkboxList = $$("input[name='"+this.form.options.mode+id+name+"']");
  3084. var checkboxList = $$("input[name='"+id+name+"']");
  3085. var values = [];
  3086. checkboxList.each(function(checkbox){
  3087. if (checkbox.get("checked")){
  3088. values.push(checkbox.value);
  3089. }
  3090. });
  3091. var oldValue = this.data[name];
  3092. //this.data[name] = values;
  3093. this.changeJsonDate(name, values);
  3094. this.changeData(name, input, oldValue, notCheckHistory);
  3095. },
  3096. setSelectValue: function(name, select){
  3097. var idx = select.selectedIndex;
  3098. var options = select.getElements("option");
  3099. var value = "";
  3100. if (options[idx]){
  3101. value = options[idx].get("value");
  3102. }
  3103. var oldValue = this.data[name];
  3104. //this.data[name] = value;
  3105. this.changeJsonDate(name, value);
  3106. this.changeData(name, select, oldValue);
  3107. },
  3108. setValue: function(name, value, obj, notCheckHistory){
  3109. if (name==="id"){
  3110. if (value!==this.module.json.id) {
  3111. if (!value) {
  3112. this.designer.notice(MWF.APPFD.LP.notNullId, "error", this.module.form.designer.propertyContentArea, {
  3113. x: "right",
  3114. y: "bottom"
  3115. });
  3116. obj.focus();
  3117. return false;
  3118. }else if ( value.test(/^\d+$/) ) {
  3119. this.designer.notice(MWF.APPFD.LP.notNumberId, "error", this.module.form.designer.propertyContentArea, {
  3120. x: "right",
  3121. y: "bottom"
  3122. });
  3123. obj.focus();
  3124. return false;
  3125. }else if ( value.indexOf("..") > -1 ) {
  3126. this.designer.notice(MWF.APPFD.LP.notDoubleDotId, "error", this.module.form.designer.propertyContentArea, {
  3127. x: "right",
  3128. y: "bottom"
  3129. });
  3130. obj.focus();
  3131. return false;
  3132. }else if ( /\{|\}|\<|\>|\!|\'|\"|\,|\;/i.test( value ) ) {
  3133. this.designer.notice(MWF.APPFD.LP.notSpecialCharacterId, "error", this.module.form.designer.propertyContentArea, {
  3134. x: "right",
  3135. y: "bottom"
  3136. });
  3137. obj.focus();
  3138. return false;
  3139. } else {
  3140. var check = this.module.form.checkModuleId(value, this.module.json.type);
  3141. if (check.elementConflict) {
  3142. this.designer.notice(MWF.APPFD.LP.repetitionsId, "error", this.module.form.designer.propertyContentArea, {
  3143. x: "right",
  3144. y: "bottom"
  3145. });
  3146. obj.focus();
  3147. return false;
  3148. } else {
  3149. var json = this.module.form.json.moduleList[this.module.json.id];
  3150. this.module.form.json.moduleList[value] = json;
  3151. delete this.module.form.json.moduleList[this.module.json.id];
  3152. }
  3153. }
  3154. if( this.alertMode )return;
  3155. if( (this.module.json.type || "").substr(0, 2) === "El" ){
  3156. for( var key in this.module.json ){
  3157. if( value === key ){
  3158. var text = Object.keys(this.module.json).join(", ");
  3159. this.alertMode = true;
  3160. this.designer.alert("error", "center", MWF.APPFD.LP.invalidElementUIId, text, 800, 300, function(){
  3161. this.alertMode = false;
  3162. }.bind(this));
  3163. return false;
  3164. }
  3165. }
  3166. }
  3167. // if (this.module.form.json.moduleList[value]){
  3168. // this.designer.notice(MWF.APPFD.LP.repetitionsId, "error", this.module.form.designer.propertyContentArea, {x:"right", y:"bottom"});
  3169. // obj.focus();
  3170. // return false;
  3171. // }else{
  3172. // var flag = false;
  3173. // if (this.module.form.subformList){
  3174. // Object.each(this.module.form.subformList, function(o, k){
  3175. // if (o.subformData.moduleList[value] && o.subformData.moduleList[value] ) flag = true;
  3176. // });
  3177. // }
  3178. // if (flag){
  3179. // this.designer.notice(MWF.APPFD.LP.repetitionsId, "error", this.module.form.designer.propertyContentArea, {x:"right", y:"bottom"});
  3180. // obj.focus();
  3181. // return false;
  3182. // }else{
  3183. // var json = this.module.form.json.moduleList[this.module.json.id];
  3184. // this.module.form.json.moduleList[value]=json;
  3185. // delete this.module.form.json.moduleList[this.module.json.id];
  3186. // }
  3187. // }
  3188. }
  3189. }
  3190. //var oldValue = this.data[name];
  3191. var names = name.split(".");
  3192. var oldValue = this.data;
  3193. for (var idx = 0; idx<names.length; idx++){
  3194. if (!oldValue.hasOwnProperty(names[idx])){
  3195. oldValue = null;
  3196. break;
  3197. }else{
  3198. oldValue = oldValue[names[idx]];
  3199. }
  3200. }
  3201. //this.data[name] = value;
  3202. this.changeJsonDate(names, value);
  3203. this.changeData(name, obj, oldValue, notCheckHistory);
  3204. },
  3205. setEditNodeStyles: function(node){
  3206. var nodes = node.getChildren();
  3207. if (nodes.length){
  3208. nodes.each(function(el){
  3209. var cName = el.get("class");
  3210. if (cName){
  3211. if (this.form.css[cName]) el.setStyles(this.form.css[cName]);
  3212. }
  3213. this.setEditNodeStyles(el);
  3214. }.bind(this));
  3215. }
  3216. },
  3217. loadScriptInput: function(){
  3218. var scriptNodes = this.propertyContent.getElements(".MWFScript");
  3219. scriptNodes.each(function(node){
  3220. MWF.require("MWF.widget.ScriptEditor", function(){
  3221. var script = new MWF.widget.ScriptEditor(node, {
  3222. "onPostSave": function(script){
  3223. this.saveScriptItem(node, script);
  3224. }.bind(this),
  3225. "onQueryDelete": function(script){
  3226. this.deleteScriptItem(node, script);
  3227. }.bind(this)
  3228. });
  3229. this.setScriptItems(script, node);
  3230. }.bind(this));
  3231. }.bind(this));
  3232. },
  3233. deleteScriptItem: function(node, script){
  3234. var jsondata = node.get("name");
  3235. this.data[jsondata].erase(script.data.id);
  3236. this.process.scripts[script.data.id] = null;
  3237. delete this.process.scripts[script.data.id];
  3238. this.process.process.scriptList.erase(script.data);
  3239. },
  3240. saveScriptItem: function(node, script){
  3241. var jsondata = node.get("name");
  3242. var scriptList = this.data[jsondata];
  3243. var data = script.data;
  3244. var scriptData = this.process.scripts[script.data.id];
  3245. if (!scriptData){
  3246. this.process.process.scriptList.push(data);
  3247. this.process.scripts[script.data.id] = data;
  3248. }
  3249. if (scriptList.indexOf(data.id) == -1){
  3250. this.data[jsondata].push(data.id);
  3251. }
  3252. },
  3253. setScriptItems: function(script, node){
  3254. var jsondata = node.get("name");
  3255. var scriptList = this.data[jsondata];
  3256. scriptList.each(function(id){
  3257. if (id){
  3258. var data = this.process.scripts[id];
  3259. if (data) script.setScriptItem(data);
  3260. }
  3261. }.bind(this));
  3262. },
  3263. loadSmartBISelect: function(){
  3264. var SmartBINodes = this.propertyContent.getElements(".MWFSmartBISelect");
  3265. var SmartBIToolbarNodes = this.propertyContent.getElements(".MWFSmartBIToolbar");
  3266. var SmartBILeftTreeNodes = this.propertyContent.getElements(".MWFSmartBILeftTree");
  3267. if (SmartBINodes.length){
  3268. var SmartBIAction = o2.Actions.load("x_custom_smartbi_assemble_control");
  3269. var node = SmartBINodes[0];
  3270. var select = new Element("select").inject(node);
  3271. if (SmartBIAction) this.setSmartBIOptions(select);
  3272. select.addEvent("change", function(e){
  3273. var value = e.target.options[e.target.selectedIndex].value;
  3274. this.setValue(e.target.getParent("div").get("name"), value, select);
  3275. }.bind(this));
  3276. var refreshNode = new Element("div.propertyRefreshFormNode",{styles:this.form.css.propertyRefreshFormNode}).inject(node);
  3277. refreshNode.addEvent("click",function(){
  3278. SmartBIAction.ResourceAction.sync(function(){
  3279. this.setSmartBIOptions(select)
  3280. }.bind(this))
  3281. }.bind(this))
  3282. }
  3283. if(SmartBIToolbarNodes.length){
  3284. SmartBIToolbarNodes.addEvent("change",function(e){
  3285. var value = e.target.get("value");
  3286. if (value=="false") value = false;
  3287. if (value=="true") value = true;
  3288. this.setValue(e.target.getParent("div").get("name"), value);
  3289. }.bind(this));
  3290. }
  3291. if(SmartBILeftTreeNodes.length){
  3292. SmartBILeftTreeNodes.addEvent("change",function(e){
  3293. var value = e.target.get("value");
  3294. if (value=="false") value = false;
  3295. if (value=="true") value = true;
  3296. this.setValue(e.target.getParent("div").get("name"), value);
  3297. }.bind(this));
  3298. }
  3299. },
  3300. setSmartBIOptions:function(node){
  3301. node.empty();
  3302. new Element("option",{text:"none",value:"none"}).inject(node);
  3303. var SmartBIAction = o2.Actions.load("x_custom_smartbi_assemble_control");
  3304. var selectedValue = this.data.smartbiresource;
  3305. SmartBIAction.ResourceAction.list(function(json){
  3306. json.data.each(function(d){
  3307. new Element("option", {
  3308. "text": d.name,
  3309. "value": d.resid,
  3310. "selected": (selectedValue==d.resid)
  3311. }).inject(node);
  3312. });
  3313. });
  3314. },
  3315. loadHelp: function () {
  3316. var nodes = this.propertyContent.getElements(".MWFHelp");
  3317. if (nodes.length){
  3318. nodes.each(function(node){
  3319. var html = node.get("text");
  3320. node.empty();
  3321. MWF.xDesktop.requireApp("Template", "MTooltips", function() {
  3322. new MTooltips(this.designer.node, node, this.designer, {}, {
  3323. "nodeStyles":{
  3324. "max-width": "370px",
  3325. "width": "370px",
  3326. "line-height": "24px",
  3327. "font-size": "14px"
  3328. },
  3329. "onCustomContent": function (content, node) {
  3330. content.set("html", html);
  3331. }
  3332. });
  3333. }.bind(this))
  3334. }.bind(this));
  3335. }
  3336. }
  3337. });
  3338. MWF.xApplication.process.FormDesigner.PropertyMulti = new Class({
  3339. Extends: MWF.xApplication.process.FormDesigner.Property,
  3340. Implements: [Options, Events],
  3341. initialize: function(form, modules, propertyNode, designer, options){
  3342. this.setOptions(options);
  3343. this.modules = modules;
  3344. this.form = form;
  3345. // this.data = module.json;
  3346. this.data = {};
  3347. this.htmlPath = this.options.path;
  3348. this.designer = designer;
  3349. this.maplists = {};
  3350. this.propertyNode = propertyNode;
  3351. },
  3352. load: function(){
  3353. if (this.fireEvent("queryLoad")){
  3354. MWF.getRequestText(this.htmlPath, function(responseText, responseXML){
  3355. this.htmlString = responseText;
  3356. MWF.require("MWF.widget.JsonTemplate", function(){
  3357. this.fireEvent("postLoad");
  3358. }.bind(this));
  3359. }.bind(this));
  3360. }
  3361. },
  3362. show: function(){
  3363. if (!this.propertyContent){
  3364. if (this.htmlString){
  3365. this.htmlString = o2.bindJson(this.htmlString, {"lp": MWF.xApplication.process.FormDesigner.LP.propertyTemplate});
  3366. this.JsonTemplate = new MWF.widget.JsonTemplate({}, this.htmlString);
  3367. this.propertyContent = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.propertyNode);
  3368. this.propertyContent.set("html", this.JsonTemplate.load());
  3369. this.setEditNodeEvent();
  3370. this.setEditNodeStyles(this.propertyContent);
  3371. this.loadPropertyTab();
  3372. this.loadMaplist();
  3373. this.loadScriptArea();
  3374. this.loadTreeData();
  3375. this.loadArrayList();
  3376. //this.loadEventsEditor();
  3377. //this.loadHTMLArea();
  3378. //this.loadJSONArea();
  3379. // this.loadScriptInput();
  3380. //MWF.process.widget.EventsEditor
  3381. }
  3382. }else{
  3383. this.propertyContent.setStyle("display", "block");
  3384. }
  3385. },
  3386. hide: function(){
  3387. if (this.propertyContent) this.propertyContent.destroy();
  3388. },
  3389. loadMaplist: function(){
  3390. var maplists = this.propertyContent.getElements(".MWFMaplist");
  3391. maplists.each(function(node){
  3392. var title = node.get("title");
  3393. var name = node.get("name");
  3394. var lName = name.toLowerCase();
  3395. var collapse = node.get("collapse");
  3396. var mapObj = this.data[name];
  3397. if (!mapObj) mapObj = {};
  3398. MWF.require("MWF.widget.Maplist", function(){
  3399. node.empty();
  3400. var maplist = new MWF.widget.Maplist(node, {
  3401. "title": title,
  3402. "collapse": (collapse) ? true : false,
  3403. "onChange": function(){
  3404. var oldData = this.getOldValueList(name);
  3405. this.changeJsonDate(name, maplist.toJson());
  3406. this.changeStyle(name, oldData);
  3407. this.changeData(name, null, oldData);
  3408. this.checkHistory( name, oldData );
  3409. this.reshowProperty();
  3410. }.bind(this),
  3411. "onDelete": function(key){
  3412. this.modules.each(function (module) {
  3413. module.deletePropertiesOrStyles(name, key);
  3414. })
  3415. }.bind(this),
  3416. "isProperty": (lName.contains("properties") || lName.contains("property") || lName.contains("attribute"))
  3417. });
  3418. maplist.load(mapObj);
  3419. this.maplists[name] = maplist;
  3420. }.bind(this));
  3421. }.bind(this));
  3422. },
  3423. setEditNodeEvent: function(){
  3424. var property = this;
  3425. // var inputs = this.process.propertyListNode.getElements(".editTableInput");
  3426. var inputs = this.propertyContent.getElements("input");
  3427. inputs.each(function(input){
  3428. var jsondata = input.get("name");
  3429. if (this.module){
  3430. var id = this.data.pid;
  3431. //var id = this.form.json.id;
  3432. // input.set("name", this.form.options.mode+id+jsondata);
  3433. input.set("name", id+jsondata);
  3434. }
  3435. if (jsondata){
  3436. var inputType = input.get("type").toLowerCase();
  3437. switch (inputType){
  3438. case "radio":
  3439. input.addEvent("change", function(e){
  3440. var oldValueList = property.getOldValueList(jsondata);
  3441. property.setRadioValue(jsondata, this, true);
  3442. property.checkHistory( jsondata, oldValueList );
  3443. property.reshowProperty();
  3444. });
  3445. input.addEvent("blur", function(e){
  3446. property.setRadioValue(jsondata, this, true);
  3447. });
  3448. input.addEvent("keydown", function(e){
  3449. e.stopPropagation();
  3450. });
  3451. property.setRadioValue(jsondata, input, true);
  3452. break;
  3453. case "checkbox":
  3454. input.addEvent("change", function(e){
  3455. property.setCheckboxValue(jsondata, this, true);
  3456. });
  3457. input.addEvent("click", function(e){
  3458. var oldValueList = property.getOldValueList(jsondata);
  3459. property.setCheckboxValue(jsondata, this, true);
  3460. property.checkHistory( jsondata, oldValueList );
  3461. property.reshowProperty();
  3462. });
  3463. input.addEvent("keydown", function(e){
  3464. e.stopPropagation();
  3465. });
  3466. break;
  3467. default:
  3468. input.addEvent("change", function(e){
  3469. var oldValueList = property.getOldValueList(jsondata);
  3470. var v = (this.type==="number") ? this.value.toFloat() : this.value;
  3471. property.setValue(jsondata, v, this, true);
  3472. property.checkHistory( jsondata, oldValueList );
  3473. property.reshowProperty();
  3474. });
  3475. input.addEvent("blur", function(e){
  3476. var v = (this.type==="number") ? this.value.toFloat() : this.value;
  3477. property.setValue(jsondata, v, this, true);
  3478. });
  3479. input.addEvent("keydown", function(e){
  3480. if (e.code==13){
  3481. var oldValueList = property.getOldValueList(jsondata);
  3482. var v = (this.type==="number") ? this.value.toFloat() : this.value;
  3483. property.setValue(jsondata, v, this, true);
  3484. property.checkHistory( jsondata, oldValueList );
  3485. property.reshowProperty();
  3486. }
  3487. e.stopPropagation();
  3488. });
  3489. }
  3490. }
  3491. }.bind(this));
  3492. var selects = this.propertyContent.getElements("select");
  3493. selects.each(function(select){
  3494. var jsondata = select.get("name");
  3495. if (jsondata){
  3496. select.addEvent("change", function(e){
  3497. var oldValueList = property.getOldValueList(jsondata);
  3498. property.setSelectValue(jsondata, this);
  3499. property.checkHistory( jsondata, oldValueList );
  3500. });
  3501. //property.setSelectValue(jsondata, select);
  3502. }
  3503. });
  3504. var textareas = this.propertyContent.getElements("textarea");
  3505. textareas.each(function(input){
  3506. var jsondata = input.get("name");
  3507. if (jsondata){
  3508. input.addEvent("change", function(e){
  3509. var oldValueList = property.getOldValueList(jsondata);
  3510. property.setValue(jsondata, this.value);
  3511. property.checkHistory( jsondata, oldValueList );
  3512. });
  3513. input.addEvent("blur", function(e){
  3514. property.setValue(jsondata, this.value, true);
  3515. });
  3516. input.addEvent("keydown", function(e){
  3517. e.stopPropagation();
  3518. });
  3519. }
  3520. }.bind(this));
  3521. },
  3522. changeStyle: function(name){
  3523. this.modules.each(function(module){
  3524. module.setPropertiesOrStyles(name);
  3525. }.bind(this));
  3526. },
  3527. getOldValueList: function(name){
  3528. var oldValueList = [];
  3529. this.modules.each(function(module){
  3530. var value = module.json[name];
  3531. var v = o2.typeOf( value ) === "object" ? Object.clone(value) : value;
  3532. oldValueList.push( v );
  3533. }.bind(this));
  3534. return oldValueList;
  3535. },
  3536. checkHistory: function(name, oldValueList, newValue){
  3537. if( this.form.history ){
  3538. var newV = typeOf( newValue ) === "object" ? Object.clone(newValue) : newValue;
  3539. this.form.checkMultiPropertyHistory(name, oldValueList, newV, this.modules);
  3540. }
  3541. },
  3542. changeData: function(name, input, oldValue){
  3543. this.modules.each(function(module){
  3544. module._setEditStyle(name, input, oldValue);
  3545. }.bind(this));
  3546. },
  3547. changeJsonDate: function(key, value){
  3548. //alert(key+": "+value );
  3549. this.modules.each(function(module){
  3550. var v = typeOf(value) === "object" ? Object.clone(value) : value;
  3551. module.json[key] = v;
  3552. }.bind(this));
  3553. },
  3554. reshowProperty: function(){
  3555. this.modules.each(function(module){
  3556. if( module.property )module.property.reset();
  3557. }.bind(this));
  3558. }
  3559. });