Viewer.js 96 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198
  1. MWF.xApplication.query = MWF.xApplication.query || {};
  2. MWF.xApplication.query.Query = MWF.xApplication.query.Query || {};
  3. MWF.require("MWF.widget.Common", null, false);
  4. MWF.require("o2.widget.Paging", null, false);
  5. MWF.require("MWF.xScript.Macro", null, false);
  6. MWF.xDesktop.requireApp("query.Query", "lp.zh-cn", null, false);
  7. MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({
  8. Implements: [Options, Events],
  9. Extends: MWF.widget.Common,
  10. options: {
  11. "style": "default",
  12. "skin" : null,
  13. "resizeNode": true,
  14. "paging" : "scroll",
  15. "perPageCount" : 50,
  16. "isload": "true",
  17. "export": false,
  18. "moduleEvents": ["queryLoad", "postLoad", "postLoadPageData", "postLoadPage", "selectRow", "unselectRow",
  19. "queryLoadItemRow", "postLoadItemRow", "queryLoadCategoryRow", "postLoadCategoryRow"]
  20. // "actions": {
  21. // "lookup": {"uri": "/jaxrs/view/flag/{view}/query/{application}/execute", "method":"PUT"},
  22. // "getView": {"uri": "/jaxrs/view/flag/{view}/query/{application}"}
  23. //
  24. // },
  25. // "actionRoot": "x_query_assemble_surface"
  26. },
  27. initialize: function(container, json, options, app, parentMacro){
  28. //本类有三种事件,
  29. //一种是通过 options 传进来的事件,包括 loadView、openDocument、select
  30. //一种是用户配置的 事件, 在this.options.moduleEvents 中定义的作为类事件
  31. //还有一种也是用户配置的事件,不在this.options.moduleEvents 中定义的作为 this.node 的DOM事件
  32. this.setOptions(options);
  33. this.path = "/x_component_query_Query/$Viewer/";
  34. this.cssPath = "/x_component_query_Query/$Viewer/"+this.options.style+"/css.wcss";
  35. this._loadCss();
  36. this.lp = MWF.xApplication.query.Query.LP;
  37. this.app = app;
  38. this.container = $(container);
  39. this.json = json;
  40. this.parentMacro = parentMacro;
  41. this.originalJson = Object.clone(json);
  42. this.viewJson = null;
  43. this.filterItems = [];
  44. this.searchStatus = "none"; //none, custom, default
  45. this.items = [];
  46. this.selectedItems = [];
  47. this.hideColumns = [];
  48. this.openColumns = [];
  49. this.gridJson = null;
  50. if (this.options.isload){
  51. this.init(function(){
  52. this.load();
  53. }.bind(this));
  54. }
  55. },
  56. loadView: function(){
  57. if (this.viewJson){
  58. this.reload();
  59. }else{
  60. this.init(function(){
  61. this.load();
  62. }.bind(this));
  63. }
  64. },
  65. init: function(callback){
  66. if (this.json.data){
  67. this.viewJson = JSON.decode(this.json.data);
  68. if (callback) callback();
  69. }else{
  70. this.getView(callback);
  71. }
  72. },
  73. load: function(){
  74. this.loadMacro( function () {
  75. this._loadModuleEvents();
  76. if (this.fireEvent("queryLoad")){
  77. this._loadUserInterface();
  78. //this._loadStyles();
  79. this._loadDomEvents();
  80. }
  81. }.bind(this))
  82. },
  83. _loadUserInterface : function(){
  84. this.loadLayout();
  85. this.createActionbarNode();
  86. this.createSearchNode();
  87. this.createViewNode({"filterList": this.json.filter ? this.json.filter.clone() : null});
  88. if (this.options.resizeNode){
  89. this.setContentHeightFun = this.setContentHeight.bind(this);
  90. this.container.addEvent("resize", this.setContentHeightFun);
  91. this.setContentHeightFun();
  92. }
  93. },
  94. loadLayout: function(){
  95. this.node = new Element("div", {"styles": this.css.node}).inject(this.container);
  96. this.actionbarAreaNode = new Element("div.actionbarAreaNode", {"styles": this.css.actionbarAreaNode}).inject(this.node);
  97. //if (this.options.export) this.exportAreaNode = new Element("div", {"styles": this.css.exportAreaNode}).inject(this.node);
  98. this.searchAreaNode = new Element("div", {"styles": this.css.searchAreaNode}).inject(this.node);
  99. this.viewAreaNode = new Element("div", {"styles": this.css.viewAreaNode}).inject(this.node);
  100. // this.viewPageNode = new Element("div", {"styles": this.css.viewPageNode}).inject(this.node);
  101. this.viewPageAreaNode = new Element("div", {"styles": this.css.viewPageAreaNode}).inject(this.node);
  102. },
  103. loadMacro: function (callback) {
  104. MWF.require("MWF.xScript.Macro", function () {
  105. this.Macro = new MWF.Macro.ViewContext(this);
  106. if (callback) callback();
  107. }.bind(this));
  108. },
  109. createExportNode: function(){
  110. if (this.options.export){
  111. MWF.require("MWF.widget.Toolbar", function(){
  112. this.toolbar = new MWF.widget.Toolbar(this.actionbarAreaNode, {"style": "simple"}, this); //this.exportAreaNode
  113. var actionNode = new Element("div", {
  114. "id": "",
  115. "MWFnodetype": "MWFToolBarButton",
  116. "MWFButtonImage": this.path+""+this.options.style+"/icon/export.png",
  117. "title": this.lp.exportExcel,
  118. "MWFButtonAction": "exportView",
  119. "MWFButtonText": this.lp.exportExcel
  120. }).inject(this.actionbarAreaNode); //this.exportAreaNode
  121. this.toolbar.load();
  122. }.bind(this));
  123. //this.exportNode = new Element("button", {"text": this.lp.exportExcel}).inject(this.exportAreaNode);
  124. }
  125. },
  126. exportView: function(){
  127. var action = MWF.Actions.get("x_query_assemble_surface");
  128. var filterData = this.json.filter ? this.json.filter.clone() : [];
  129. if (this.filterItems.length){
  130. this.filterItems.each(function(filter){
  131. filterData.push(filter.data);
  132. }.bind(this));
  133. }
  134. action.exportViewWithQuery(this.json.viewName, this.json.application, {"filterList": filterData}, function(json){
  135. var uri = action.action.actions.getViewExcel.uri;
  136. uri = uri.replace("{flag}", json.data.id);
  137. uri = action.action.address+uri;
  138. var a = new Element("a", {"href": uri, "target":"_blank"});
  139. a.click();
  140. a.destroy();
  141. }.bind(this));
  142. },
  143. setContentHeight: function(){
  144. var size = this.node.getSize();
  145. var searchSize = this.searchAreaNode.getComputedSize();
  146. var h = size.y-searchSize.totalHeight;
  147. //if (this.exportAreaNode){
  148. // var exportSize = this.exportAreaNode.getComputedSize();
  149. // h = h-exportSize.totalHeight;
  150. //}
  151. if( this.actionbarAreaNode ){
  152. var exportSize = this.actionbarAreaNode.getComputedSize();
  153. h = h-exportSize.totalHeight;
  154. }
  155. var pageSize = this.viewPageAreaNode.getComputedSize();
  156. h = h-pageSize.totalHeight;
  157. this.viewAreaNode.setStyle("height", ""+h+"px");
  158. },
  159. createLoadding: function(){
  160. this.loadingAreaNode = new Element("div", {"styles": this.css.viewLoadingAreaNode}).inject(this.contentAreaNode);
  161. new Element("div", {"styles": {"height": "5px"}}).inject(this.loadingAreaNode);
  162. var loadingNode = new Element("div", {"styles": this.css.viewLoadingNode}).inject(this.loadingAreaNode);
  163. new Element("div", {"styles": this.css.viewLoadingIconNode}).inject(loadingNode);
  164. var loadingTextNode = new Element("div", {"styles": this.css.viewLoadingTextNode}).inject(loadingNode);
  165. loadingTextNode.set("text", "loading...");
  166. },
  167. createActionbarNode : function(){
  168. this.actionbarAreaNode.empty();
  169. if( typeOf(this.json.showActionbar) === "boolean" && this.json.showActionbar !== true )return;
  170. if( typeOf( this.viewJson.actionbarHidden ) === "boolean" ){
  171. if( this.viewJson.actionbarHidden === true || !this.viewJson.actionbarList || !this.viewJson.actionbarList.length )return;
  172. this.actionbar = new MWF.xApplication.query.Query.Viewer.Actionbar(this.actionbarAreaNode, this.viewJson.actionbarList[0], this, {});
  173. this.actionbar.load();
  174. }else{ //兼容以前的ExportNode
  175. this.createExportNode();
  176. }
  177. },
  178. createViewNode: function(data){
  179. this.viewAreaNode.empty();
  180. var viewStyles = this.viewJson.viewStyles;
  181. this.contentAreaNode = new Element("div", {"styles":
  182. (viewStyles && viewStyles["container"]) ? viewStyles["container"] : this.css.contentAreaNode
  183. }).inject(this.viewAreaNode);
  184. this.viewTable = new Element("table", {
  185. "styles": this.css.viewTitleTableNode,
  186. "border": "0px",
  187. "cellPadding": "0",
  188. "cellSpacing": "0"
  189. }).inject(this.contentAreaNode);
  190. if( viewStyles ){
  191. if( viewStyles["tableProperties"] )this.viewTable.set(viewStyles["tableProperties"]);
  192. if( viewStyles["table"] )this.viewTable.setStyles(viewStyles["table"]);
  193. }
  194. this.createLoadding();
  195. var viewTitleCellNode = (viewStyles && viewStyles["titleTd"]) ? viewStyles["titleTd"] : this.css.viewTitleCellNode;
  196. if (this.json.isTitle!=="no"){
  197. this.viewTitleLine = new Element("tr", {
  198. "styles": (viewStyles && viewStyles["titleTr"]) ? viewStyles["titleTr"] : this.css.viewTitleLineNode
  199. }).inject(this.viewTable);
  200. //if (this.json.select==="single" || this.json.select==="multi") {
  201. this.selectTitleCell = new Element("td", {
  202. "styles": viewTitleCellNode
  203. }).inject(this.viewTitleLine);
  204. this.selectTitleCell.setStyle("width", "10px");
  205. if (this.json.titleStyles) this.selectTitleCell.setStyles(this.json.titleStyles);
  206. //}
  207. //序号
  208. if (this.viewJson.isSequence==="yes"){
  209. this.sequenceTitleCell = new Element("td", {
  210. "styles": viewTitleCellNode
  211. }).inject(this.viewTitleLine);
  212. this.sequenceTitleCell.setStyle("width", "10px");
  213. if (this.json.titleStyles) this.sequenceTitleCell.setStyles(this.json.titleStyles);
  214. }
  215. this.entries = {};
  216. this.viewJson.selectList.each(function(column){
  217. this.entries[column.column] = column;
  218. if (!column.hideColumn){
  219. var viewCell = new Element("td", {
  220. "styles": viewTitleCellNode,
  221. "text": column.displayName
  222. }).inject(this.viewTitleLine);
  223. var size = MWF.getTextSize(column.displayName, viewTitleCellNode);
  224. viewCell.setStyle("min-width", ""+size.x+"px");
  225. if (this.json.titleStyles) viewCell.setStyles(this.json.titleStyles);
  226. }else{
  227. this.hideColumns.push(column.column);
  228. }
  229. if (column.allowOpen) this.openColumns.push(column.column);
  230. }.bind(this));
  231. this.lookup(data);
  232. }else{
  233. this.viewJson.selectList.each(function(column){
  234. if (column.hideColumn) this.hideColumns.push(column.column);
  235. if (!column.allowOpen) this.openColumns.push(column.column);
  236. }.bind(this));
  237. this.lookup(data);
  238. }
  239. },
  240. // _loadPageCountNode: function(){
  241. // this.viewPageContentNode.empty();
  242. //
  243. // var size = this.viewPageAreaNode.getSize();
  244. // var w1 = this.viewPageFirstNode.getSize().x*2;
  245. // var w2 = this.viewPageContentNode.getStyle("margin-left").toInt();
  246. // var w = size.x-w1-w2;
  247. //
  248. // var bw = this.css.viewPageButtonNode.width.toInt()+this.css.viewPageButtonNode["margin-right"].toInt();
  249. // var count = (w/bw).toInt()-2;
  250. // if (count>10) count = 10;
  251. // this.showPageCount = Math.min(count, this.pages);
  252. //
  253. // var tmp = this.showPageCount/2;
  254. // var n = tmp.toInt();
  255. // var left = this.currentPage-n;
  256. // if (left<=0) left = 1;
  257. // var right = this.showPageCount + left-1;
  258. // if (right>this.pages) right = this.pages;
  259. // left = right-this.showPageCount+1;
  260. // if (left<=1) left = 1;
  261. //
  262. // this.viewPagePrevNode = new Element("div", {"styles": this.css.viewPagePrevButtonNode}).inject(this.viewPageContentNode);
  263. // this.loadPageButtonEvent(this.viewPagePrevNode, "viewPagePrevButtonNode_over", "viewPagePrevButtonNode_up", "viewPagePrevButtonNode_down", function(){
  264. // if (this.currentPage>1) this.currentPage--;
  265. // this.loadCurrentPageData();
  266. // }.bind(this));
  267. //
  268. // for (i=left; i<=right; i++){
  269. // var node = new Element("div", {"styles": this.css.viewPageButtonNode, "text": i}).inject(this.viewPageContentNode);
  270. // if (i==this.currentPage){
  271. // node.setStyles(this.css.viewPageButtonNode_current);
  272. // }else{
  273. // this.loadPageButtonEvent(node, "viewPageButtonNode_over", "viewPageButtonNode_up", "viewPageButtonNode_down", function(e){
  274. // this.currentPage = e.target.get("text").toInt();
  275. // this.loadCurrentPageData();
  276. // }.bind(this));
  277. // }
  278. // }
  279. // this.viewPageNextNode = new Element("div", {"styles": this.css.viewPageNextButtonNode}).inject(this.viewPageContentNode);
  280. // this.loadPageButtonEvent(this.viewPageNextNode, "viewPageNextButtonNode_over", "viewPageNextButtonNode_up", "viewPageNextButtonNode_down", function(){
  281. // if (this.currentPage<=this.pages-1) this.currentPage++;
  282. // this.loadCurrentPageData();
  283. // }.bind(this));
  284. // },
  285. // loadPageButtonEvent: function(node, over, out, down, click){
  286. // node.addEvents({
  287. // "mouseover": function(){node.setStyles(this.css[over])}.bind(this),
  288. // "mouseout": function(){node.setStyles(this.css[out])}.bind(this),
  289. // "mousedown": function(){node.setStyles(this.css[down])}.bind(this),
  290. // "mouseup": function(){node.setStyles(this.css[out])}.bind(this),
  291. // "click": click
  292. // });
  293. // },
  294. // _loadPageNode: function(){
  295. // this.viewPageAreaNode.empty();
  296. // this.viewPageFirstNode = new Element("div", {"styles": this.css.viewPageFirstLastNode, "text": this.lp.firstPage}).inject(this.viewPageAreaNode);
  297. // this.viewPageContentNode = new Element("div", {"styles": this.css.viewPageContentNode}).inject(this.viewPageAreaNode);
  298. // this.viewPageLastNode = new Element("div", {"styles": this.css.viewPageFirstLastNode, "text": this.lp.lastPage}).inject(this.viewPageAreaNode);
  299. // this._loadPageCountNode();
  300. //
  301. // this.loadPageButtonEvent(this.viewPageFirstNode, "viewPageFirstLastNode_over", "viewPageFirstLastNode_up", "viewPageFirstLastNode_down", function(){
  302. // this.currentPage = 1;
  303. // this.loadCurrentPageData();
  304. // }.bind(this));
  305. // this.loadPageButtonEvent(this.viewPageLastNode, "viewPageFirstLastNode_over", "viewPageFirstLastNode_up", "viewPageFirstLastNode_down", function(){
  306. // this.currentPage = this.pages;
  307. // this.loadCurrentPageData();
  308. // }.bind(this));
  309. // },
  310. _loadPageNode : function(){
  311. this.viewPageAreaNode.empty();
  312. if( !this.paging ){
  313. var json;
  314. if( !this.viewJson.pagingList || !this.viewJson.pagingList.length ){
  315. json = {
  316. "firstPageText": this.lp.firstPage,
  317. "lastPageText": this.lp.lastPage
  318. };
  319. }else{
  320. json = this.viewJson.pagingList[0];
  321. }
  322. this.paging = new MWF.xApplication.query.Query.Viewer.Paging(this.viewPageAreaNode, json, this, {});
  323. this.paging.load();
  324. }else{
  325. this.paging.reload();
  326. }
  327. },
  328. _initPage: function(){
  329. this.count = this.bundleItems.length;
  330. var i = this.count/this.json.pageSize;
  331. this.pages = (i.toInt()<i) ? i.toInt()+1 : i;
  332. this.currentPage = 1;
  333. },
  334. lookup: function(data){
  335. this.getLookupAction(function(){
  336. if (this.json.application){
  337. var d = data || {};
  338. d.count = this.json.count;
  339. this.lookupAction.bundleView(this.json.id, d, function(json){
  340. this.bundleItems = json.data.valueList;
  341. this._initPage();
  342. if (this.bundleItems.length){
  343. this.loadCurrentPageData( function () {
  344. this.fireEvent("postLoad"); //用户配置的事件
  345. }.bind(this));
  346. }else{
  347. //this._loadPageNode();
  348. this.viewPageAreaNode.empty();
  349. if (this.loadingAreaNode){
  350. this.loadingAreaNode.destroy();
  351. this.loadingAreaNode = null;
  352. }
  353. this.fireEvent("postLoad"); //用户配置的事件
  354. }
  355. }.bind(this));
  356. }
  357. }.bind(this));
  358. },
  359. loadCurrentPageData: function( callback ){
  360. //是否需要在翻页的时候清空之前的items ?
  361. this.items = [];
  362. var p = this.currentPage;
  363. var d = {};
  364. var valueList = this.bundleItems.slice((p-1)*this.json.pageSize,this.json.pageSize*p);
  365. d.bundleList = valueList;
  366. while (this.viewTable.rows.length>1){
  367. this.viewTable.deleteRow(-1);
  368. }
  369. //this.createLoadding();
  370. this.loadViewRes = this.lookupAction.loadView(this.json.name, this.json.application, d, function(json){
  371. this.viewData = json.data;
  372. this.fireEvent("postLoadPageData");
  373. if (this.viewJson.group.column){
  374. this.gridJson = json.data.groupGrid;
  375. this.loadGroupData();
  376. }else{
  377. this.gridJson = json.data.grid;
  378. this.loadData();
  379. }
  380. if (this.gridJson.length) this._loadPageNode();
  381. if (this.loadingAreaNode){
  382. this.loadingAreaNode.destroy();
  383. this.loadingAreaNode = null;
  384. }
  385. this.fireEvent("loadView"); //options 传入的事件
  386. this.fireEvent("postLoadPage");
  387. if(callback)callback();
  388. }.bind(this));
  389. },
  390. loadData: function(){
  391. if (this.gridJson.length){
  392. // if( !this.options.paging ){
  393. this.gridJson.each(function(line, i){
  394. this.items.push(new MWF.xApplication.query.Query.Viewer.Item(this, line, null, i));
  395. }.bind(this));
  396. // }else{
  397. // this.loadPaging();
  398. // }
  399. }else{
  400. if (this.viewPageAreaNode) this.viewPageAreaNode.empty();
  401. }
  402. },
  403. loadPaging : function(){
  404. this.isItemsLoading = false;
  405. this.pageNumber = 0;
  406. this.isItemsLoaded = false;
  407. this.isSetedScroll = false;
  408. this.setScroll();
  409. this.loadDataByPaging()
  410. },
  411. setScroll : function(){
  412. if( this.options.paging && !this.isSetedScroll ){
  413. this.contentAreaNode.setStyle("overflow","auto");
  414. this.scrollContainerFun = function(){
  415. var scrollSize = this.contentAreaNode.getScrollSize();
  416. var clientSize = this.contentAreaNode.getSize();
  417. var scrollHeight = scrollSize.y - clientSize.y;
  418. //alert( "clientSize.y=" + clientSize.y + " scrollSize.y="+scrollSize.y + " this.contentAreaNode.scrollTop="+this.contentAreaNode.scrollTop);
  419. if (this.contentAreaNode.scrollTop + 150 > scrollHeight ) {
  420. if (!this.isItemsLoaded) this.loadDataByPaging();
  421. }
  422. }.bind(this);
  423. this.isSetedScroll = true;
  424. this.contentAreaNode.addEvent("scroll", this.scrollContainerFun )
  425. }
  426. },
  427. loadDataByPaging : function(){
  428. if( this.isItemsLoading )return;
  429. if( !this.isItemsLoaded ){
  430. var from = Math.min( this.pageNumber * this.options.perPageCount , this.gridJson.length);
  431. var to = Math.min( ( this.pageNumber + 1 ) * this.options.perPageCount + 1 , this.gridJson.length);
  432. this.isItemsLoading = true;
  433. for( var i = from; i<to; i++ ){
  434. this.items.push(new MWF.xApplication.query.Query.Viewer.Item(this, this.gridJson[i], null, i));
  435. }
  436. this.isItemsLoading = false;
  437. this.pageNumber ++;
  438. if( to == this.gridJson.length )this.isItemsLoaded = true;
  439. }
  440. },
  441. loadGroupData: function(){
  442. if (this.selectTitleCell && !this.selectTitleCell.retrieve("expandLoaded") ){
  443. if( this.viewJson.viewStyles && this.viewJson.viewStyles["groupCollapseNode"] ){
  444. this.expandAllNode = new Element("span", {
  445. styles : this.viewJson.viewStyles["groupCollapseNode"]
  446. }).inject( this.selectTitleCell );
  447. this.selectTitleCell.setStyle("cursor", "pointer");
  448. }else{
  449. this.selectTitleCell.set("html", "<span style='font-family: Webdings'>"+"<img src='/x_component_query_Query/$Viewer/"+this.options.style+"/icon/expand.png'/>"+"</span>");
  450. }
  451. this.selectTitleCell.setStyle("cursor", "pointer");
  452. this.selectTitleCell.addEvent("click", this.expandOrCollapseAll.bind(this));
  453. this.selectTitleCell.store("expandLoaded", true);
  454. }
  455. this.expandAll = false;
  456. if (this.gridJson.length){
  457. var i = 0;
  458. this.gridJson.each(function(data){
  459. this.items.push(new MWF.xApplication.query.Query.Viewer.ItemCategory(this, data, i));
  460. i += data.list.length;
  461. }.bind(this));
  462. if (this.json.isExpand=="yes") this.expandOrCollapseAll();
  463. }else{
  464. if (this.viewPageAreaNode) this.viewPageAreaNode.empty();
  465. }
  466. },
  467. expandOrCollapseAll: function(){
  468. if( this.viewJson.viewStyles && this.viewJson.viewStyles["groupCollapseNode"] ){
  469. var span = this.selectTitleCell.getElement("span");
  470. if( this.expandAll ){
  471. this.items.each(function(item){
  472. item.collapse();
  473. span.setStyles( this.viewJson.viewStyles["groupCollapseNode"] );
  474. }.bind(this));
  475. this.expandAll = false;
  476. }else{
  477. this.items.each(function(item, i){
  478. window.setTimeout(function(){
  479. item.expand();
  480. }.bind(this), 10*i+5);
  481. span.setStyles( this.viewJson.viewStyles["groupExpandNode"] );
  482. this.expandAll = true;
  483. }.bind(this));
  484. }
  485. }else{
  486. var icon = this.selectTitleCell.getElement("span");
  487. if (icon.get("html").indexOf("expand.png")===-1){
  488. this.items.each(function(item){
  489. item.collapse();
  490. icon.set("html", "<img src='/x_component_query_Query/$Viewer/"+this.options.style+"/icon/expand.png'/>");
  491. }.bind(this));
  492. this.expandAll = false;
  493. }else{
  494. this.items.each(function(item, i){
  495. window.setTimeout(function(){
  496. item.expand();
  497. }.bind(this), 10*i+5);
  498. icon.set("html", "<img src='/x_component_query_Query/$Viewer/"+this.options.style+"/icon/down.png'/>");
  499. }.bind(this));
  500. this.expandAll = true;
  501. }
  502. }
  503. },
  504. getView: function(callback){
  505. this.getLookupAction(function(){
  506. if (this.json.application){
  507. this.getViewRes = this.lookupAction.getView(this.json.viewName, this.json.application, function(json){
  508. this.viewJson = JSON.decode(json.data.data);
  509. this.json = Object.merge(this.json, json.data);
  510. if (callback) callback();
  511. }.bind(this));
  512. // this.lookupAction.invoke({"name": "getView","async": true, "parameter": {"view": this.json.viewName, "application": this.json.application},"success": function(json){
  513. // this.viewJson = JSON.decode(json.data.data);
  514. // this.json = Object.merge(this.json, json.data);
  515. // //var viewData = JSON.decode(json.data.data);
  516. // if (callback) callback();
  517. // }.bind(this)});
  518. }else{
  519. this.getViewRes = this.lookupAction.getViewById(this.json.viewId, function(json){
  520. this.viewJson = JSON.decode(json.data.data);
  521. this.json.application = json.data.query;
  522. this.json = Object.merge(this.json, json.data);
  523. if (callback) callback();
  524. }.bind(this));
  525. }
  526. }.bind(this));
  527. },
  528. getLookupAction: function(callback){
  529. if (!this.lookupAction){
  530. this.lookupAction = MWF.Actions.get("x_query_assemble_surface");
  531. if (callback) callback();
  532. // var _self = this;
  533. // MWF.require("MWF.xDesktop.Actions.RestActions", function(){
  534. // this.lookupAction = new MWF.xDesktop.Actions.RestActions("", this.options.actionRoot, "");
  535. // this.lookupAction.getActions = function(actionCallback){
  536. // this.actions = _self.options.actions;
  537. // if (actionCallback) actionCallback();
  538. // };
  539. // if (callback) callback();
  540. // }.bind(this));
  541. }else{
  542. if (callback) callback();
  543. }
  544. },
  545. hide: function(){
  546. this.node.setStyle("display", "none");
  547. },
  548. reload: function(){
  549. this.node.setStyle("display", "block");
  550. if (this.loadingAreaNode) this.loadingAreaNode.setStyle("display", "block");
  551. this.filterItems.each(function(filter){
  552. filter.destroy();
  553. }.bind(this));
  554. this.filterItems = [];
  555. if (this.viewSearchInputNode) this.viewSearchInputNode.set("text", this.lp.searchKeywork);
  556. this.closeCustomSearch();
  557. this.viewAreaNode.empty();
  558. this.createViewNode({"filterList": this.json.filter ? this.json.filter.clone() : null});
  559. },
  560. getFilter: function(){
  561. var filterData = [];
  562. if (this.searchStatus==="custom"){
  563. if (this.filterItems.length){
  564. this.filterItems.each(function(filter){
  565. filterData.push(filter.data);
  566. }.bind(this));
  567. }
  568. }
  569. if (this.searchStatus==="default"){
  570. var key = this.viewSearchInputNode.get("value");
  571. if (key && key!==this.lp.searchKeywork){
  572. this.viewJson.customFilterList.each(function(entry){
  573. if (entry.formatType==="textValue"){
  574. var d = {
  575. "path": entry.path,
  576. "value": key,
  577. "formatType": entry.formatType,
  578. "logic": "or",
  579. "comparison": "like"
  580. };
  581. filterData.push(d);
  582. }
  583. if (entry.formatType==="numberValue"){
  584. var v = key.toFloat();
  585. if (!isNaN(v)){
  586. var d = {
  587. "path": entry.path,
  588. "value": v,
  589. "formatType": entry.formatType,
  590. "logic": "or",
  591. "comparison": "like"
  592. };
  593. filterData.push(d);
  594. }
  595. }
  596. }.bind(this));
  597. }
  598. }
  599. return (filterData.length) ? filterData : null;
  600. },
  601. getData: function(){
  602. if (this.selectedItems.length){
  603. var arr = [];
  604. this.selectedItems.each(function(item){
  605. arr.push(item.data);
  606. });
  607. return arr;
  608. }else{
  609. return [];
  610. }
  611. },
  612. _loadModuleEvents : function(){
  613. Object.each(this.viewJson.events, function(e, key){
  614. if (e.code){
  615. if (this.options.moduleEvents.indexOf(key)!==-1){
  616. this.addEvent(key, function(event, target){
  617. return this.Macro.fire(e.code, target || this, event);
  618. }.bind(this));
  619. }
  620. }
  621. }.bind(this));
  622. },
  623. _loadDomEvents: function(){
  624. Object.each(this.viewJson.events, function(e, key){
  625. if (e.code){
  626. if (this.options.moduleEvents.indexOf(key)===-1){
  627. this.node.addEvent(key, function(event){
  628. return this.Macro.fire(e.code, this, event);
  629. }.bind(this));
  630. }
  631. }
  632. }.bind(this));
  633. },
  634. //搜索相关开始
  635. createSearchNode: function(){
  636. if (this.viewJson.customFilterList && this.viewJson.customFilterList.length){
  637. this.searchStatus = "default";
  638. this.loadFilterSearch();
  639. }else{
  640. this.loadSimpleSearch();
  641. }
  642. },
  643. loadSimpleSearch: function(){
  644. return false;
  645. this.searchSimpleNode = new Element("div", {"styles": this.css.searchSimpleNode}).inject(this.searchAreaNode);
  646. this.searchSimpleButtonNode = new Element("div", {"styles": this.css.searchSimpleButtonNode}).inject(this.searchSimpleNode);
  647. this.searchSimpleInputNode = new Element("input", {"type":"text", "styles": this.css.searchSimpleInputNode, "value": this.lp.searchKeywork}).inject(this.searchSimpleNode);
  648. this.searchSimpleButtonNode.addEvent("click", function(){
  649. this.search();
  650. }.bind(this));
  651. this.searchSimpleInputNode.addEvents({
  652. "focus": function(){
  653. if (this.searchSimpleInputNode.get("value")===this.lp.searchKeywork) this.searchSimpleInputNode.set("value", "");
  654. }.bind(this),
  655. "blur": function(){if (!this.searchSimpleInputNode.get("value")) this.searchSimpleInputNode.set("value", this.lp.searchKeywork);}.bind(this),
  656. "keydown": function(e){
  657. if (e.code===13) this.search();
  658. }.bind(this)
  659. });
  660. },
  661. search: function(){
  662. if (this.gridJson){
  663. var key = this.searchSimpleInputNode.get("value");
  664. var rows = this.viewTable.rows;
  665. var first = (this.json.isTitle!=="no") ? 1 : 0;
  666. for (var i = first; i<rows.length; i++){
  667. var tr = rows[i];
  668. if (!key || key==this.lp.searchKeywork){
  669. if (tr.getStyle("display")==="none") tr.setStyle("display", "table-row");
  670. }else{
  671. if (tr.get("text").indexOf(key)!==-1){
  672. if (tr.getStyle("display")==="none") tr.setStyle("display", "table-row");
  673. }else{
  674. if (tr.getStyle("display")!=="none") tr.setStyle("display", "none");
  675. }
  676. }
  677. }
  678. //if (this.viewPageAreaNode) this.viewPageAreaNode.hide();
  679. }
  680. },
  681. loadFilterSearch: function(){
  682. this.viewSearchCustomActionNode = new Element("div", {"styles": this.css.viewFilterSearchCustomActionNode, "text": this.lp.customSearch}).inject(this.searchAreaNode);
  683. this.viewSearchInputAreaNode = new Element("div", {"styles": this.css.viewFilterSearchInputAreaNode}).inject(this.searchAreaNode);
  684. this.viewSearchIconNode = new Element("div", {"styles": this.css.viewFilterSearchIconNode}).inject(this.viewSearchInputAreaNode);
  685. this.viewSearchInputBoxNode = new Element("div", {"styles": this.css.viewFilterSearchInputBoxNode}).inject(this.viewSearchInputAreaNode);
  686. this.viewSearchInputNode = new Element("input", {"styles": this.css.viewFilterSearchInputNode, "value": this.lp.searchKeywork}).inject(this.viewSearchInputBoxNode);
  687. this.viewSearchInputNode.addEvents({
  688. "focus": function(){
  689. if (this.viewSearchInputNode.get("value")===this.lp.searchKeywork) this.viewSearchInputNode.set("value", "");
  690. }.bind(this),
  691. "blur": function(){if (!this.viewSearchInputNode.get("value")) this.viewSearchInputNode.set("value", this.lp.searchKeywork);}.bind(this),
  692. "keydown": function(e){
  693. if (e.code===13) this.searchView();
  694. }.bind(this)
  695. });
  696. this.viewSearchIconNode.addEvents({
  697. "click": function(){this.searchView();}.bind(this)
  698. });
  699. this.viewSearchCustomActionNode.addEvents({
  700. "click": function(){this.loadCustomSearch();}.bind(this)
  701. });
  702. },
  703. searchView: function(){
  704. if (this.viewJson.customFilterList) {
  705. var key = this.viewSearchInputNode.get("value");
  706. if (key && key !== this.lp.searchKeywork) {
  707. var filterData = this.json.filter ? this.json.filter : [];
  708. this.filterItems = [];
  709. this.viewJson.customFilterList.each(function (entry) {
  710. if (entry.formatType === "textValue") {
  711. var d = {
  712. "path": entry.path,
  713. "value": key,
  714. "formatType": entry.formatType,
  715. "logic": "or",
  716. "comparison": "like"
  717. };
  718. filterData.push(d);
  719. this.filterItems.push({"data":d});
  720. }
  721. if (entry.formatType === "numberValue") {
  722. var v = key.toFloat();
  723. if (!isNaN(v)) {
  724. var d = {
  725. "path": entry.path,
  726. "value": v,
  727. "formatType": entry.formatType,
  728. "logic": "or",
  729. "comparison": "like"
  730. };
  731. filterData.push(d);
  732. this.filterItems.push({"data":d});
  733. }
  734. }
  735. }.bind(this));
  736. this.createViewNode({"filterList": filterData});
  737. }else{
  738. this.createViewNode();
  739. }
  740. }
  741. },
  742. searchCustomView: function(){
  743. if (this.filterItems.length){
  744. var filterData = this.json.filter ? this.json.filter.clone() : [];
  745. this.filterItems.each(function(filter){
  746. filterData.push(filter.data);
  747. }.bind(this));
  748. this.createViewNode({"filterList": filterData});
  749. }else{
  750. this.createViewNode({"filterList": this.json.filter ? this.json.filter.clone() : null});
  751. }
  752. },
  753. loadCustomSearch: function(){
  754. debugger;
  755. this.viewSearchIconNode.setStyle("display", "none");
  756. this.viewSearchInputBoxNode.setStyle("display", "none");
  757. this.viewSearchCustomActionNode.setStyle("display", "none");
  758. if (!this.searchMorph) this.searchMorph = new Fx.Morph(this.viewSearchInputAreaNode);
  759. var x = this.viewSearchInputAreaNode.getParent().getSize().x-2-20;
  760. this.css.viewFilterSearchInputAreaNode_custom.width = ""+x+"px";
  761. var x1 = this.viewSearchInputAreaNode.getSize().x-2;
  762. this.viewSearchInputAreaNode.setStyle("width", ""+x1+"px");
  763. this.searchMorph.start(this.css.viewFilterSearchInputAreaNode_custom).chain(function(){
  764. this.searchStatus = "custom";
  765. this.css.viewFilterSearchInputAreaNode_custom.width = "auto";
  766. this.viewSearchInputAreaNode.setStyle("width", "auto");
  767. if (this.viewSearchCustomContentNode){
  768. this.viewSearchCustomCloseActionNode.setStyle("display", "block");
  769. this.viewSearchCustomContentNode.setStyle("display", "block");
  770. }else{
  771. this.loadCustomSearchContent();
  772. }
  773. if(this.setContentHeightFun)this.setContentHeightFun();
  774. }.bind(this));
  775. this.searchCustomView();
  776. },
  777. loadCustomSearchContent: function(){
  778. this.viewSearchCustomCloseActionNode = new Element("div", {"styles": this.css.viewFilterSearchCustomCloseActionNode}).inject(this.viewSearchInputAreaNode);
  779. this.viewSearchCustomContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomContentNode}).inject(this.viewSearchInputAreaNode);
  780. this.viewSearchCustomPathContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomPathContentNode}).inject(this.viewSearchCustomContentNode);
  781. this.viewSearchCustomComparisonContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomComparisonContentNode}).inject(this.viewSearchCustomContentNode);
  782. this.viewSearchCustomValueContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomValueContentNode}).inject(this.viewSearchCustomContentNode);
  783. this.viewSearchCustomAddContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomAddContentNode}).inject(this.viewSearchCustomContentNode);
  784. this.viewSearchCustomAddIconNode = new Element("div", {"styles": this.css.viewFilterSearchCustomAddIconNode}).inject(this.viewSearchCustomAddContentNode);
  785. this.viewSearchCustomFilterContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomFilterContentNode}).inject(this.viewSearchCustomContentNode);
  786. this.loadViewSearchCustomList();
  787. this.viewSearchCustomCloseActionNode.addEvents({
  788. "click": function(){this.closeCustomSearch();}.bind(this)
  789. });
  790. this.viewSearchCustomAddIconNode.addEvents({
  791. "click": function(){this.viewSearchCustomAddToFilter();}.bind(this)
  792. });
  793. },
  794. loadViewSearchCustomList: function(){
  795. this.viewSearchCustomPathListNode = new Element("select", {
  796. "styles": this.css.viewFilterSearchCustomPathListNode,
  797. "multiple": true
  798. }).inject(this.viewSearchCustomPathContentNode);
  799. this.viewSearchCustomComparisonListNode = new Element("select", {
  800. "styles": this.css.viewFilterSearchCustomComparisonListNode,
  801. "multiple": true
  802. }).inject(this.viewSearchCustomComparisonContentNode);
  803. this.viewJson.customFilterList.each(function(entry){
  804. var option = new Element("option", {
  805. "style": this.css.viewFilterSearchOptionNode,
  806. "value": entry.path,
  807. "text": entry.title
  808. }).inject(this.viewSearchCustomPathListNode);
  809. option.store("entry", entry);
  810. }.bind(this));
  811. this.viewSearchCustomPathListNode.addEvent("change", function(){
  812. this.loadViewSearchCustomComparisonList();
  813. }.bind(this));
  814. },
  815. loadViewSearchCustomComparisonList: function(){
  816. var idx = this.viewSearchCustomPathListNode.selectedIndex;
  817. var option = this.viewSearchCustomPathListNode.options[idx];
  818. var entry = option.retrieve("entry");
  819. if (entry){
  820. var selectableList = this.getCustomSelectScriptResult(entry);
  821. switch (entry.formatType){
  822. case "numberValue":
  823. this.loadComparisonSelect(this.lp.numberFilter);
  824. if( selectableList.length > 0 ){
  825. this.loadViewSerchCustomSelectByScript(selectableList)
  826. }else{
  827. this.loadViewSearchCustomValueNumberInput();
  828. }
  829. break;
  830. case "dateTimeValue":
  831. this.loadComparisonSelect(this.lp.dateFilter);
  832. if( selectableList.length > 0 ){
  833. this.loadViewSerchCustomSelectByScript(selectableList)
  834. }else {
  835. this.loadViewSearchCustomValueDateTimeInput();
  836. }
  837. break;
  838. case "dateValue":
  839. this.loadComparisonSelect(this.lp.dateFilter);
  840. if( selectableList.length > 0 ){
  841. this.loadViewSerchCustomSelectByScript(selectableList)
  842. }else {
  843. this.loadViewSearchCustomValueDateInput();
  844. }
  845. break;
  846. case "timeValue":
  847. this.loadComparisonSelect(this.lp.dateFilter);
  848. if( selectableList.length > 0 ){
  849. this.loadViewSerchCustomSelectByScript(selectableList)
  850. }else {
  851. this.loadViewSearchCustomValueTimeInput();
  852. }
  853. break;
  854. case "booleanValue":
  855. this.loadComparisonSelect(this.lp.booleanFilter);
  856. if( selectableList.length > 0 ){
  857. this.loadViewSerchCustomSelectByScript(selectableList)
  858. }else {
  859. this.loadViewSearchCustomValueBooleanInput();
  860. }
  861. break;
  862. default:
  863. this.loadComparisonSelect(this.lp.textFilter);
  864. if( selectableList.length > 0 ){
  865. this.loadViewSerchCustomSelectByScript(selectableList)
  866. }else {
  867. this.loadViewSearchCustomValueTextInput();
  868. }
  869. }
  870. }
  871. },
  872. getCustomSelectScriptResult : function( entry ){
  873. var scriptResult = [];
  874. if( entry.valueType === "script" ){
  875. if( entry.valueScript && entry.valueScript.code ){
  876. var result = this.Macro.exec(entry.valueScript.code, this);
  877. var array = typeOf( result ) === "array" ? result : [result];
  878. for( var i=0; i<array.length; i++ ){
  879. if( array[i].indexOf( "|" ) > -1 ){
  880. var arr = array[i].split("|");
  881. scriptResult.push({ "text" : arr[0], "value" : arr[1] })
  882. }else{
  883. scriptResult.push({ "text" : array[i], "value" : array[i] })
  884. }
  885. }
  886. }
  887. }
  888. return scriptResult;
  889. },
  890. loadViewSerchCustomSelectByScript: function( array ){
  891. this.viewSearchCustomValueContentNode.empty();
  892. this.viewSearchCustomValueNode = new Element("select", {
  893. "styles": this.css.viewFilterSearchCustomComparisonListNode,
  894. "multiple": true
  895. }).inject(this.viewSearchCustomValueContentNode);
  896. array.each(function( v ){
  897. var option = new Element("option", {
  898. "style": this.css.viewFilterSearchOptionNode,
  899. "value": v.value,
  900. "text": v.text,
  901. "selected" : array.length === 1
  902. }).inject(this.viewSearchCustomValueNode);
  903. }.bind(this));
  904. },
  905. loadViewSearchCustomValueNumberInput: function(){
  906. this.viewSearchCustomValueContentNode.empty();
  907. this.viewSearchCustomValueNode = new Element("input", {
  908. "styles": this.css.viewFilterSearchCustomValueNode,
  909. "type": "number"
  910. }).inject(this.viewSearchCustomValueContentNode);
  911. },
  912. loadViewSearchCustomValueDateTimeInput: function(){
  913. this.viewSearchCustomValueContentNode.empty();
  914. this.viewSearchCustomValueNode = new Element("input", {
  915. "styles": this.css.viewFilterSearchCustomValueNode,
  916. "type": "text",
  917. "readonly": true
  918. }).inject(this.viewSearchCustomValueContentNode);
  919. MWF.require("MWF.widget.Calendar", function(){
  920. this.calendar = new MWF.widget.Calendar(this.viewSearchCustomValueNode, {
  921. "style": "xform",
  922. "isTime": true,
  923. "secondEnable" : true,
  924. "target": this.container,
  925. "format": "db"
  926. });
  927. }.bind(this));
  928. },
  929. loadViewSearchCustomValueDateInput: function(){
  930. this.viewSearchCustomValueContentNode.empty();
  931. this.viewSearchCustomValueNode = new Element("input", {
  932. "styles": this.css.viewFilterSearchCustomValueNode,
  933. "type": "text",
  934. "readonly": true
  935. }).inject(this.viewSearchCustomValueContentNode);
  936. MWF.require("MWF.widget.Calendar", function(){
  937. this.calendar = new MWF.widget.Calendar(this.viewSearchCustomValueNode, {
  938. "style": "xform",
  939. "isTime": false,
  940. "target": this.container,
  941. "format": "%Y-%m-%d"
  942. });
  943. }.bind(this));
  944. },
  945. loadViewSearchCustomValueTimeInput: function(){
  946. this.viewSearchCustomValueContentNode.empty();
  947. this.viewSearchCustomValueNode = new Element("input", {
  948. "styles": this.css.viewFilterSearchCustomValueNode,
  949. "type": "text",
  950. "readonly": true
  951. }).inject(this.viewSearchCustomValueContentNode);
  952. MWF.require("MWF.widget.Calendar", function(){
  953. this.calendar = new MWF.widget.Calendar(this.viewSearchCustomValueNode, {
  954. "style": "xform",
  955. "timeOnly": true,
  956. "target": this.container,
  957. "format": "%H:%M:%S"
  958. });
  959. }.bind(this));
  960. },
  961. loadViewSearchCustomValueBooleanInput: function(){
  962. this.viewSearchCustomValueContentNode.empty();
  963. this.viewSearchCustomValueNode = new Element("select", {
  964. "styles": this.css.viewFilterSearchCustomValueSelectNode,
  965. "multiple": true
  966. }).inject(this.viewSearchCustomValueContentNode);
  967. new Element("option", {"value": "true","text": this.lp.yes}).inject(this.viewSearchCustomValueNode);
  968. new Element("option", {"value": "false","text": this.lp.no}).inject(this.viewSearchCustomValueNode);
  969. },
  970. loadViewSearchCustomValueTextInput: function(){
  971. this.viewSearchCustomValueContentNode.empty();
  972. this.viewSearchCustomValueNode = new Element("textarea", {
  973. "styles": this.css.viewFilterSearchCustomValueNode
  974. }).inject(this.viewSearchCustomValueContentNode);
  975. },
  976. loadComparisonSelect:function(obj){
  977. this.viewSearchCustomComparisonListNode.empty();
  978. Object.each(obj, function(v, k){
  979. var option = new Element("option", {"value": k,"text": v}).inject(this.viewSearchCustomComparisonListNode);
  980. }.bind(this));
  981. },
  982. closeCustomSearch: function(){
  983. if (this.viewSearchCustomContentNode && this.viewSearchCustomContentNode.getStyle("display")==="block"){
  984. this.viewSearchCustomCloseActionNode.setStyle("display", "none");
  985. this.viewSearchCustomContentNode.setStyle("display", "none");
  986. var x = this.viewSearchInputAreaNode.getParent().getSize().x;
  987. x1 = x-2-10-90;
  988. this.css.viewFilterSearchInputAreaNode.width = ""+x1+"px";
  989. var x1 = this.viewSearchInputAreaNode.getSize().x-2;
  990. this.viewSearchInputAreaNode.setStyle("width", ""+x1+"px");
  991. if (!this.searchMorph) this.searchMorph = new Fx.Morph(this.viewSearchInputAreaNode);
  992. this.searchMorph.start(this.css.viewFilterSearchInputAreaNode).chain(function(){
  993. this.searchStatus = "default";
  994. this.css.viewFilterSearchInputAreaNode.width = "auto";
  995. this.viewSearchInputAreaNode.setStyle("margin-right", "90px");
  996. this.viewSearchIconNode.setStyle("display", "block");
  997. this.viewSearchInputBoxNode.setStyle("display", "block");
  998. this.viewSearchCustomActionNode.setStyle("display", "block");
  999. if(this.setContentHeightFun)this.setContentHeightFun();
  1000. }.bind(this));
  1001. this.createViewNode({"filterList": this.json.filter ? this.json.filter.clone() : null});
  1002. }
  1003. },
  1004. viewSearchCustomAddToFilter: function(){
  1005. var pathIdx = this.viewSearchCustomPathListNode.selectedIndex;
  1006. var comparisonIdx = this.viewSearchCustomComparisonListNode.selectedIndex;
  1007. if (pathIdx===-1){
  1008. MWF.xDesktop.notice("error", {"x": "left", "y": "top"}, this.lp.filterErrorTitle, this.viewSearchCustomPathListNode, {"x": 0, "y": 85});
  1009. return false;
  1010. }
  1011. if (comparisonIdx===-1){
  1012. MWF.xDesktop.notice("error", {"x": "left", "y": "top"}, this.lp.filterErrorComparison, this.viewSearchCustomComparisonListNode, {"x": 0, "y": 85});
  1013. return false;
  1014. }
  1015. var pathOption = this.viewSearchCustomPathListNode.options[pathIdx];
  1016. var entry = pathOption.retrieve("entry");
  1017. if (entry){
  1018. var pathTitle = entry.title;
  1019. var path = entry.path;
  1020. var comparison = this.viewSearchCustomComparisonListNode.options[comparisonIdx].get("value");
  1021. var comparisonTitle = this.viewSearchCustomComparisonListNode.options[comparisonIdx].get("text");
  1022. var value = "";
  1023. if( entry.valueType === "script" && entry.valueScript && entry.valueScript.code ){
  1024. var idx = this.viewSearchCustomValueNode.selectedIndex;
  1025. if (idx!==-1){
  1026. var v = this.viewSearchCustomValueNode.options[idx].get("value");
  1027. value = entry.formatType === "booleanValue" ? (v==="true") : v;
  1028. }
  1029. }else{
  1030. switch (entry.formatType){
  1031. case "numberValue":
  1032. value = this.viewSearchCustomValueNode.get("value");
  1033. break;
  1034. case "dateTimeValue":
  1035. value = this.viewSearchCustomValueNode.get("value");
  1036. break;
  1037. case "booleanValue":
  1038. var idx = this.viewSearchCustomValueNode.selectedIndex;
  1039. if (idx!==-1){
  1040. var v = this.viewSearchCustomValueNode.options[idx].get("value");
  1041. value = (v==="true");
  1042. }
  1043. break;
  1044. default:
  1045. value = this.viewSearchCustomValueNode.get("value");
  1046. }
  1047. }
  1048. if (value===""){
  1049. MWF.xDesktop.notice("error", {"x": "left", "y": "top"}, this.lp.filterErrorValue, this.viewSearchCustomValueContentNode, {"x": 0, "y": 85});
  1050. return false;
  1051. }
  1052. this.filterItems.push(new MWF.xApplication.query.Query.Viewer.Filter(this, {
  1053. "logic": "and",
  1054. "path": path,
  1055. "title": pathTitle,
  1056. "comparison": comparison,
  1057. "comparisonTitle": comparisonTitle,
  1058. "value": value,
  1059. "formatType": (entry.formatType=="datetimeValue") ? "dateTimeValue": entry.formatType
  1060. }, this.viewSearchCustomFilterContentNode));
  1061. this.searchCustomView();
  1062. }
  1063. },
  1064. searchViewRemoveFilter: function(filter){
  1065. this.filterItems.erase(filter);
  1066. filter.destroy();
  1067. this.searchCustomView()
  1068. },
  1069. //搜索相关结束
  1070. //api 使用 开始
  1071. getParentEnvironment : function(){
  1072. return this.parentMacro ? this.parentMacro.environment : null;
  1073. },
  1074. getViewInfor : function(){
  1075. return this.json;
  1076. },
  1077. getPageInfor : function(){
  1078. return {
  1079. pages : this.pages,
  1080. perPageCount : this.options.perPageCount,
  1081. currentPageNumber : this.currentPage
  1082. };
  1083. },
  1084. getPageData : function () {
  1085. return this.gridJson;
  1086. },
  1087. toPage : function( pageNumber, callback ){
  1088. this.currentPage = pageNumber;
  1089. this.loadCurrentPageData( callback );
  1090. },
  1091. getSelectedData : function(){
  1092. return this.getData();
  1093. },
  1094. selectAll : function(){
  1095. var flag = this.json.select || this.viewJson.select || "none";
  1096. if ( flag==="multi"){
  1097. this.items.each( function (item) {
  1098. if( item.clazzType === "item" ){
  1099. item.selected();
  1100. }else{
  1101. item.expand();
  1102. if( item.items ){
  1103. item.items.each( function (it) {
  1104. it.selected();
  1105. })
  1106. }
  1107. }
  1108. })
  1109. }
  1110. },
  1111. unSelectAll : function(){
  1112. var flag = this.json.select || this.viewJson.select || "none";
  1113. if ( flag==="multi"){
  1114. this.items.each( function (item) {
  1115. if( item.clazzType === "item" ){
  1116. item.unSelected();
  1117. }else{
  1118. if(item.items){
  1119. item.items.each( function (it) {
  1120. it.unSelected();
  1121. })
  1122. }
  1123. }
  1124. })
  1125. }
  1126. },
  1127. setFilter : function( filter ){
  1128. if( !filter )filter = [];
  1129. if( typeOf( filter ) === "object" )filter = [ filter ];
  1130. this.json.filter = filter;
  1131. if( this.viewAreaNode ){
  1132. this.createViewNode({"filterList": this.json.filter ? this.json.filter.clone() : null});
  1133. }
  1134. },
  1135. switchView : function( json ){
  1136. debugger;
  1137. // json = {
  1138. // "application": application,
  1139. // "viewName": viewName,
  1140. // "isTitle": "yes",
  1141. // "select": "none",
  1142. // "titleStyles": titleStyles,
  1143. // "itemStyles": itemStyles,
  1144. // "isExpand": "no",
  1145. // "filter": filter
  1146. // }
  1147. this.node.setStyle("display", "block");
  1148. if (this.loadingAreaNode) this.loadingAreaNode.setStyle("display", "block");
  1149. this.searchMorph = null;
  1150. this.viewSearchCustomContentNode = null;
  1151. var newJson = Object.merge( Object.clone(this.originalJson), json );
  1152. this.container.empty();
  1153. this.initialize( this.container, newJson, Object.clone(this.options), this.app, this.parentMacro);
  1154. },
  1155. confirm: function (type, e, title, text, width, height, ok, cancel, callback, mask, style) {
  1156. this.app.confirm(type, e, title, text, width, height, ok, cancel, callback, mask, style)
  1157. },
  1158. alert: function (type, title, text, width, height) {
  1159. this.app.alert(type, "center", title, text, width, height);
  1160. },
  1161. notice: function (content, type, target, where, offset, option) {
  1162. this.app.notice(content, type, target, where, offset, option)
  1163. }
  1164. //api 使用 结束
  1165. });
  1166. MWF.xApplication.query.Query.Viewer.Item = new Class({
  1167. initialize: function(view, data, prev, i){
  1168. this.view = view;
  1169. this.data = data;
  1170. this.css = this.view.css;
  1171. this.isSelected = false;
  1172. this.prev = prev;
  1173. this.idx = i;
  1174. this.clazzType = "item";
  1175. this.load();
  1176. },
  1177. load: function(){
  1178. this.view.fireEvent("queryLoadItemRow", [null, this]);
  1179. var viewStyles = this.view.viewJson.viewStyles;
  1180. var viewContentTdNode = ( viewStyles && viewStyles["contentTd"] ) ? viewStyles["contentTd"] : this.css.viewContentTdNode;
  1181. this.node = new Element("tr", {
  1182. "styles": ( viewStyles && viewStyles["contentTr"] ) ? viewStyles["contentTr"] : this.css.viewContentTrNode
  1183. });
  1184. if (this.prev){
  1185. this.node.inject(this.prev.node, "after");
  1186. }else{
  1187. this.node.inject(this.view.viewTable);
  1188. }
  1189. //if (this.view.json.select==="single" || this.view.json.select==="multi"){
  1190. this.selectTd = new Element("td", { "styles": viewContentTdNode }).inject(this.node);
  1191. this.selectTd.setStyles({"cursor": "pointer"});
  1192. if (this.view.json.itemStyles) this.selectTd.setStyles(this.view.json.itemStyles);
  1193. //}
  1194. //序号
  1195. if (this.view.viewJson.isSequence==="yes"){
  1196. this.sequenceTd = new Element("td", {"styles": viewContentTdNode}).inject(this.node);
  1197. this.sequenceTd.setStyle("width", "10px");
  1198. var s= 1+this.view.json.pageSize*(this.view.currentPage-1)+this.idx;
  1199. this.sequenceTd.set("text", s);
  1200. }
  1201. Object.each(this.view.entries, function(c, k){
  1202. var cell = this.data.data[k];
  1203. if (cell === undefined) cell = "";
  1204. //if (cell){
  1205. if (this.view.hideColumns.indexOf(k)===-1){
  1206. var td = new Element("td", {"styles": viewContentTdNode}).inject(this.node);
  1207. if (k!== this.view.viewJson.group.column){
  1208. //var v = (this.view.entries[k].code) ? MWF.Macro.exec(this.view.entries[k].code, {"value": cell, "gridData": this.view.gridJson, "data": this.view.viewData, "entry": this.data}) : cell;
  1209. var v = cell;
  1210. if (c.isHtml){
  1211. td.set("html", v);
  1212. }else{
  1213. td.set("text", v);
  1214. }
  1215. }
  1216. if (this.view.openColumns.indexOf(k)!==-1){
  1217. this.setOpenWork(td, c)
  1218. }
  1219. if (this.view.json.itemStyles) td.setStyles(this.view.json.itemStyles);
  1220. }
  1221. //}
  1222. }.bind(this));
  1223. // Object.each(this.data.data, function(cell, k){
  1224. // if (this.view.hideColumns.indexOf(k)===-1){
  1225. // var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(this.node);
  1226. // if (k!== this.view.viewJson.group.column){
  1227. // var v = (this.view.entries[k].code) ? MWF.Macro.exec(this.view.entries[k].code, {"value": cell, "gridData": this.view.gridJson, "data": this.view.viewData, "entry": this.data}) : cell;
  1228. // td.set("text", v);
  1229. // }
  1230. // if (this.view.openColumns.indexOf(k)!==-1){
  1231. // this.setOpenWork(td)
  1232. // }
  1233. // if (this.view.json.itemStyles) td.setStyles(this.view.json.itemStyles);
  1234. // }
  1235. // }.bind(this));
  1236. this.setEvent();
  1237. this.view.fireEvent("postLoadItemRow", [null, this]);
  1238. },
  1239. setOpenWork: function(td, column){
  1240. td.setStyle("cursor", "pointer");
  1241. if( column.clickCode ){
  1242. // if( !this.view.Macro ){
  1243. // MWF.require("MWF.xScript.Macro", function () {
  1244. // this.view.businessData = {};
  1245. // this.view.Macro = new MWF.Macro.PageContext(this.view);
  1246. // }.bind(this), false);
  1247. // }
  1248. td.addEvent("click", function( ev ){
  1249. var result = this.view.Macro.fire(column.clickCode, this, ev);
  1250. ev.stopPropagation();
  1251. return result;
  1252. }.bind(this));
  1253. }else{
  1254. if (this.view.json.type==="cms"){
  1255. td.addEvent("click", function(ev){
  1256. this.openCms(ev)
  1257. ev.stopPropagation();
  1258. }.bind(this));
  1259. }else{
  1260. td.addEvent("click", function(ev){
  1261. this.openWorkAndCompleted(ev)
  1262. ev.stopPropagation();
  1263. }.bind(this));
  1264. }
  1265. }
  1266. },
  1267. openCms: function(e){
  1268. var options = {"documentId": this.data.bundle};
  1269. this.view.fireEvent("openDocument", [options, this]); //options 传入的事件
  1270. layout.desktop.openApplication(e, "cms.Document", options);
  1271. },
  1272. openWorkAndCompleted: function(e){
  1273. MWF.Actions.get("x_processplatform_assemble_surface").listWorkByJob(this.data.bundle, function(json){
  1274. var workCompletedCount = json.data.workCompletedList.length;
  1275. var workCount = json.data.workList.length;
  1276. var count = workCount+workCompletedCount;
  1277. if (count===1){
  1278. if (workCompletedCount) {
  1279. this.openWorkCompleted(json.data.workCompletedList[0].id, e);
  1280. }else{
  1281. this.openWork(json.data.workList[0].id, e);
  1282. }
  1283. }else if (count>1){
  1284. var worksAreaNode = this.createWorksArea();
  1285. json.data.workCompletedList.each(function(work){
  1286. this.createWorkCompletedNode(work, worksAreaNode);
  1287. }.bind(this));
  1288. json.data.workList.each(function(work){
  1289. this.createWorkNode(work, worksAreaNode);
  1290. }.bind(this));
  1291. this.showWorksArea(worksAreaNode, e);
  1292. }else{
  1293. }
  1294. }.bind(this));
  1295. },
  1296. createWorkNode: function(work, worksAreaNode){
  1297. var worksAreaContentNode = worksAreaNode.getLast();
  1298. var node = new Element("div", {"styles": this.css.workAreaNode}).inject(worksAreaContentNode);
  1299. var actionNode = new Element("div", {"styles": this.css.workAreaActionNode, "text": this.view.lp.open}).inject(node);
  1300. actionNode.store("workId", work.id);
  1301. actionNode.addEvent("click", function(e){
  1302. this.openWork(e.target.retrieve("workId"), e);
  1303. this.mask.hide();
  1304. worksAreaNode.destroy();
  1305. }.bind(this));
  1306. var areaNode = new Element("div", {"styles": this.css.workAreaLeftNode}).inject(node);
  1307. var titleNode = new Element("div", {"styles": this.css.workAreaTitleNode, "text": work.title}).inject(areaNode);
  1308. var contentNode = new Element("div", {"styles": this.css.workAreaContentNode}).inject(areaNode);
  1309. new Element("div", {"styles": this.css.workAreaContentTitleNode, "text": this.view.lp.activity+": "}).inject(contentNode);
  1310. new Element("div", {"styles": this.css.workAreaContentTextNode, "text": work.activityName}).inject(contentNode);
  1311. var taskUsers = [];
  1312. MWF.Actions.get("x_processplatform_assemble_surface").listTaskByWork(work.id, function(json){
  1313. json.data.each(function(task){
  1314. taskUsers.push(MWF.name.cn(task.person));
  1315. }.bind(this));
  1316. new Element("div", {"styles": this.css.workAreaContentTitleNode, "text": this.view.lp.taskPeople+": "}).inject(contentNode);
  1317. new Element("div", {"styles": this.css.workAreaContentTextNode, "text": taskUsers.join(", ")}).inject(contentNode);
  1318. }.bind(this));
  1319. },
  1320. createWorkCompletedNode: function(work, worksAreaNode){
  1321. var worksAreaContentNode = worksAreaNode.getLast();
  1322. var node = new Element("div", {"styles": this.css.workAreaNode}).inject(worksAreaContentNode);
  1323. var actionNode = new Element("div", {"styles": this.css.workAreaActionNode, "text": this.view.lp.open}).inject(node);
  1324. actionNode.store("workId", work.id);
  1325. actionNode.addEvent("click", function(e){
  1326. this.mask.hide();
  1327. var id = e.target.retrieve("workId");
  1328. worksAreaNode.destroy();
  1329. this.openWorkCompleted(id, e);
  1330. }.bind(this));
  1331. var areaNode = new Element("div", {"styles": this.css.workAreaLeftNode}).inject(node);
  1332. var titleNode = new Element("div", {"styles": this.css.workAreaTitleNode, "text": work.title}).inject(areaNode);
  1333. var contentNode = new Element("div", {"styles": this.css.workAreaContentNode}).inject(areaNode);
  1334. new Element("div", {"styles": this.css.workAreaContentTitleNode, "text": this.view.lp.activity+": "}).inject(contentNode);
  1335. new Element("div", {"styles": this.css.workAreaContentTextNode, "text": this.view.lp.processCompleted}).inject(contentNode);
  1336. },
  1337. createWorksArea: function(){
  1338. var worksAreaNode = new Element("div", {"styles": this.css.worksAreaNode});
  1339. var worksAreaTitleNode = new Element("div", {"styles": this.css.worksAreaTitleNode}).inject(worksAreaNode);
  1340. var worksAreaTitleCloseNode = new Element("div", {"styles": this.css.worksAreaTitleCloseNode}).inject(worksAreaTitleNode);
  1341. worksAreaTitleCloseNode.addEvent("click", function(e){
  1342. this.mask.hide();
  1343. e.target.getParent().getParent().destroy();
  1344. }.bind(this));
  1345. var worksAreaContentNode = new Element("div", {"styles": this.css.worksAreaContentNode}).inject(worksAreaNode);
  1346. return worksAreaNode;
  1347. },
  1348. showWorksArea: function(node, e){
  1349. MWF.require("MWF.widget.Mask", null, false);
  1350. this.mask = new MWF.widget.Mask({"style": "desktop", "loading": false});
  1351. this.mask.loadNode(this.view.container);
  1352. node.inject(this.view.node);
  1353. this.setWorksAreaPosition(node, e.target);
  1354. },
  1355. setWorksAreaPosition: function(node, td){
  1356. var p = td.getPosition(this.view.container);
  1357. var containerS = this.view.container.getSize();
  1358. var containerP = this.view.container.getPosition(this.view.container.getOffsetParent());
  1359. var s = node.getSize();
  1360. var offX = p.x+s.x-containerS.x;
  1361. offX = (offX>0) ? offX+20 : 0;
  1362. var offY = p.y+s.y-containerS.y;
  1363. offY = (offY>0) ? offY+5 : 0;
  1364. node.position({
  1365. "relativeTo": td,
  1366. "position": "lefttop",
  1367. "edge": "lefttop",
  1368. "offset": {
  1369. "x": 0-offX,
  1370. "y": 0-offY
  1371. }
  1372. });
  1373. },
  1374. openWork: function(id, e){
  1375. var options = {"workId": id};
  1376. this.view.fireEvent("openDocument", [options, this]); //options 传入的事件
  1377. layout.desktop.openApplication(e, "process.Work", options);
  1378. },
  1379. openWorkCompleted: function(id, e){
  1380. var options = {"workCompletedId": id};
  1381. this.view.fireEvent("openDocument", [options, this]); //options 传入的事件
  1382. layout.desktop.openApplication(e, "process.Work", options);
  1383. },
  1384. setEvent: function(){
  1385. var flag = this.view.json.select || this.view.viewJson.select || "none";
  1386. if ( flag ==="single" || flag==="multi"){
  1387. this.node.addEvents({
  1388. "mouseover": function(){
  1389. if (!this.isSelected){
  1390. var viewStyles = this.view.viewJson.viewStyles;
  1391. if( viewStyles ){
  1392. if( flag === "single" ){
  1393. this.selectTd.setStyles( viewStyles["radioNode"] );
  1394. }else{
  1395. this.selectTd.setStyles( viewStyles["checkboxNode"] );
  1396. }
  1397. }else{
  1398. var iconName = "checkbox";
  1399. if (flag==="single") iconName = "radiobox";
  1400. this.selectTd.setStyles({"background": "url("+"/x_component_query_Query/$Viewer/default/icon/"+iconName+".png) center center no-repeat"});
  1401. }
  1402. }
  1403. }.bind(this),
  1404. "mouseout": function(){
  1405. if (!this.isSelected) this.selectTd.setStyles({"background": "transparent"});
  1406. }.bind(this),
  1407. "click": function(){this.select();}.bind(this)
  1408. });
  1409. }
  1410. },
  1411. select: function(){
  1412. var flag = this.view.json.select || this.view.viewJson.select || "none";
  1413. if (this.isSelected){
  1414. if (flag==="single"){
  1415. this.unSelectedSingle();
  1416. }else{
  1417. this.unSelected();
  1418. }
  1419. }else{
  1420. if (flag==="single"){
  1421. this.selectedSingle();
  1422. }else{
  1423. this.selected();
  1424. }
  1425. }
  1426. this.view.fireEvent("select"); //options 传入的事件
  1427. },
  1428. selected: function(){
  1429. this.view.selectedItems.push(this);
  1430. var viewStyles = this.view.viewJson.viewStyles;
  1431. if( viewStyles ){
  1432. this.selectTd.setStyles( viewStyles["checkedCheckboxNode"] );
  1433. this.node.setStyles( viewStyles["contentSelectedTr"] );
  1434. }else{
  1435. this.selectTd.setStyles({"background": "url("+"/x_component_query_Query/$Viewer/default/icon/checkbox_checked.png) center center no-repeat"});
  1436. this.node.setStyles(this.css.viewContentTrNode_selected);
  1437. }
  1438. this.isSelected = true;
  1439. this.view.fireEvent("selectRow", [this]);
  1440. },
  1441. unSelected: function(){
  1442. this.view.selectedItems.erase(this);
  1443. this.selectTd.setStyles({"background": "transparent"});
  1444. var viewStyles = this.view.viewJson.viewStyles;
  1445. if( viewStyles ){
  1446. this.node.setStyles( viewStyles["contentTr"] );
  1447. }else{
  1448. this.node.setStyles(this.css.viewContentTrNode);
  1449. }
  1450. this.isSelected = false;
  1451. this.view.fireEvent("unselectRow", [this]);
  1452. },
  1453. selectedSingle: function(){
  1454. if (this.view.currentSelectedItem) this.view.currentSelectedItem.unSelectedSingle();
  1455. this.view.selectedItems = [this];
  1456. this.view.currentSelectedItem = this;
  1457. var viewStyles = this.view.viewJson.viewStyles;
  1458. if( viewStyles ){
  1459. this.selectTd.setStyles( viewStyles["checkedRadioNode"] );
  1460. this.node.setStyles( viewStyles["contentSelectedTr"] );
  1461. }else {
  1462. this.selectTd.setStyles({"background": "url(" + "/x_component_query_Query/$Viewer/default/icon/radiobox_checked.png) center center no-repeat"});
  1463. this.node.setStyles(this.css.viewContentTrNode_selected);
  1464. }
  1465. this.isSelected = true;
  1466. this.view.fireEvent("selectRow", [this]);
  1467. },
  1468. unSelectedSingle: function(){
  1469. this.view.selectedItems = [];
  1470. this.view.currentSelectedItem = null;
  1471. this.selectTd.setStyles({"background": "transparent"});
  1472. var viewStyles = this.view.viewJson.viewStyles;
  1473. if( viewStyles ){
  1474. this.node.setStyles( viewStyles["contentTr"] );
  1475. }else{
  1476. this.node.setStyles(this.css.viewContentTrNode);
  1477. }
  1478. this.isSelected = false;
  1479. this.view.fireEvent("unselectRow", [this]);
  1480. }
  1481. });
  1482. MWF.xApplication.query.Query.Viewer.ItemCategory = new Class({
  1483. initialize: function(view, data, i){
  1484. this.view = view;
  1485. this.data = data;
  1486. this.css = this.view.css;
  1487. this.items = [];
  1488. this.loadChild = false;
  1489. this.idx = i;
  1490. this.clazzType = "category";
  1491. this.load();
  1492. },
  1493. load: function(){
  1494. this.view.fireEvent("queryLoadCategoryRow", [null, this]);
  1495. var viewStyles = this.view.viewJson.viewStyles;
  1496. var viewContentCategoryTdNode = ( viewStyles && viewStyles["contentGroupTd"] ) ? viewStyles["contentGroupTd"] : this.css.viewContentCategoryTdNode;
  1497. this.node = new Element("tr", {
  1498. "styles": (viewStyles && viewStyles["contentTr"]) ? viewStyles["contentTr"] : this.css.viewContentTrNode
  1499. }).inject(this.view.viewTable);
  1500. //if (this.view.json.select==="single" || this.view.json.select==="multi"){
  1501. this.selectTd = new Element("td", {"styles": viewContentCategoryTdNode}).inject(this.node);
  1502. if (this.view.json.itemStyles) this.selectTd.setStyles(this.view.json.itemStyles);
  1503. //}
  1504. this.categoryTd = new Element("td", {
  1505. "styles": viewContentCategoryTdNode,
  1506. "colspan": this.view.viewJson.selectList.length+1
  1507. }).inject(this.node);
  1508. this.groupColumn = null;
  1509. for (var c = 0; c<this.view.viewJson.selectList.length; c++){
  1510. if (this.view.viewJson.selectList[c].column === this.view.viewJson.group.column){
  1511. this.groupColumn = this.view.viewJson.selectList[c];
  1512. break;
  1513. }
  1514. }
  1515. if (this.groupColumn){
  1516. //var text = (this.groupColumn.code) ? MWF.Macro.exec(this.groupColumn.code, {"value": this.data.group, "gridData": this.view.gridJson, "data": this.view.viewData, "entry": this.data}) : this.data.group;
  1517. var text = this.data.group;
  1518. }else{
  1519. var text = this.data.group;
  1520. }
  1521. if( viewStyles && viewStyles["groupCollapseNode"] ){
  1522. this.expandNode = new Element("span", {
  1523. styles : viewStyles["groupCollapseNode"]
  1524. }).inject( this.categoryTd );
  1525. new Element("span", { text : text }).inject( this.categoryTd );
  1526. // this.categoryTd.set("text", text );
  1527. }else{
  1528. this.categoryTd.set("html", "<span style='font-family: Webdings'><img src='/x_component_query_Query/$Viewer/"+this.view.options.style+"/icon/expand.png'/></span> "+text);
  1529. }
  1530. this.expanded = false;
  1531. if (this.view.json.itemStyles) this.categoryTd.setStyles(this.view.json.itemStyles);
  1532. this.setEvent();
  1533. this.view.fireEvent("postLoadCategoryRow", [null, this]);
  1534. },
  1535. setEvent: function(){
  1536. //if (this.selectTd){
  1537. this.node.addEvents({
  1538. "click": function(){this.expandOrCollapse();}.bind(this)
  1539. });
  1540. //}
  1541. },
  1542. expandOrCollapse: function(){
  1543. // var t = this.node.getElement("span").get("html");
  1544. // if (t.indexOf("expand.png")===-1){
  1545. // this.collapse();
  1546. // }else{
  1547. // this.expand();
  1548. // }
  1549. if( this.expanded ){
  1550. this.collapse();
  1551. }else{
  1552. this.expand();
  1553. }
  1554. },
  1555. collapse: function(){
  1556. this.items.each(function(item){
  1557. item.node.setStyle("display", "none");
  1558. }.bind(this));
  1559. if( this.expandNode ){
  1560. this.expandNode.setStyles( this.view.viewJson.viewStyles["groupCollapseNode"] )
  1561. }else{
  1562. this.node.getElement("span").set("html", "<img src='/x_component_query_Query/$Viewer/"+this.view.options.style+"/icon/expand.png'/>");
  1563. }
  1564. this.expanded = false;
  1565. },
  1566. expand: function(){
  1567. this.items.each(function(item){
  1568. item.node.setStyle("display", "table-row");
  1569. }.bind(this));
  1570. if( this.expandNode ){
  1571. this.expandNode.setStyles( this.view.viewJson.viewStyles["groupExpandNode"] )
  1572. }else{
  1573. this.node.getElement("span").set("html", "<img src='/x_component_query_Query/$Viewer/"+this.view.options.style+"/icon/down.png'/>");
  1574. }
  1575. this.expanded = true;
  1576. if (!this.loadChild){
  1577. //window.setTimeout(function(){
  1578. this.data.list.each(function(line, i){
  1579. var s = this.idx+i;
  1580. this.lastItem = new MWF.xApplication.query.Query.Viewer.Item(this.view, line, (this.lastItem || this), s);
  1581. this.items.push(this.lastItem);
  1582. }.bind(this));
  1583. this.loadChild = true;
  1584. //}.bind(this), 10);
  1585. }
  1586. }
  1587. });
  1588. MWF.xApplication.query.Query.Viewer.Filter = new Class({
  1589. initialize: function(viewer, data, node){
  1590. this.viewer = viewer;
  1591. this.data = data;
  1592. this.css = this.viewer.css;
  1593. this.content = node;
  1594. this.load();
  1595. },
  1596. load: function(){
  1597. this.node = new Element("div", {"styles": this.css.viewSearchFilterNode}).inject(this.content);
  1598. if (this.viewer.filterItems.length){
  1599. this.logicNode = new Element("div", {"styles": this.css.viewSearchFilterSelectAreaNode}).inject(this.node);
  1600. this.logicSelectNode = new Element("div", {
  1601. "styles": this.css.viewSearchFilterSelectNode,
  1602. "text": this.viewer.lp.and,
  1603. "value": "and"
  1604. }).inject(this.logicNode);
  1605. this.logicSelectButtonNode = new Element("div", {"styles": this.css.viewSearchFilterSelectButtonNode}).inject(this.logicNode);
  1606. this.logicNode.addEvents({
  1607. "click": function(){
  1608. var v = this.logicSelectNode.get("value");
  1609. if (v==="and"){
  1610. this.logicSelectButtonNode.setStyle("float", "left");
  1611. this.logicSelectNode.setStyle("float", "right");
  1612. this.logicSelectNode.set({
  1613. "text": this.viewer.lp.or,
  1614. "value": "or"
  1615. });
  1616. this.data.logic = "or";
  1617. }else{
  1618. this.logicSelectButtonNode.setStyle("float", "right");
  1619. this.logicSelectNode.setStyle("float", "left");
  1620. this.logicSelectNode.set({
  1621. "text": this.viewer.lp.and,
  1622. "value": "and"
  1623. });
  1624. this.data.logic = "and";
  1625. }
  1626. this.viewer.searchCustomView();
  1627. }.bind(this)
  1628. });
  1629. }
  1630. this.titleNode = new Element("div", {"styles": this.css.viewSearchFilterTextNode, "text": this.data.title}).inject(this.node);
  1631. this.comparisonTitleNode = new Element("div", {"styles": this.css.viewSearchFilterTextNode, "text": this.data.comparisonTitle}).inject(this.node);
  1632. this.valueNode = new Element("div", {"styles": this.css.viewSearchFilterTextNode, "text": "\""+this.data.value+"\""}).inject(this.node);
  1633. this.deleteNode = new Element("div", {"styles": this.css.viewSearchFilterDeleteNode}).inject(this.node);
  1634. this.node.addEvents({
  1635. "mouseover": function(){
  1636. this.node.setStyles(this.css.viewSearchFilterNode_over);
  1637. this.deleteNode.setStyles(this.css.viewSearchFilterDeleteNode_over);
  1638. }.bind(this),
  1639. "mouseout": function(){
  1640. this.node.setStyles(this.css.viewSearchFilterNode);
  1641. this.deleteNode.setStyles(this.css.viewSearchFilterDeleteNode);
  1642. }.bind(this)
  1643. });
  1644. this.deleteNode.addEvent("click", function(){
  1645. this.viewer.searchViewRemoveFilter(this);
  1646. }.bind(this));
  1647. },
  1648. destroy: function(){
  1649. this.node.destroy();
  1650. MWF.release(this);
  1651. }
  1652. });
  1653. MWF.xApplication.query.Query.Viewer.Actionbar = new Class({
  1654. Implements: [Events],
  1655. options: {
  1656. "style" : "default",
  1657. "moduleEvents": ["load", "queryLoad", "postLoad", "afterLoad"]
  1658. },
  1659. initialize: function(node, json, form, options){
  1660. this.node = $(node);
  1661. this.node.store("module", this);
  1662. this.json = json;
  1663. this.form = form;
  1664. this.view = form;
  1665. },
  1666. hide: function(){
  1667. var dsp = this.node.getStyle("display");
  1668. if (dsp!=="none") this.node.store("mwf_display", dsp);
  1669. this.node.setStyle("display", "none");
  1670. },
  1671. show: function(){
  1672. var dsp = this.node.retrieve("mwf_display", dsp);
  1673. this.node.setStyle("display", dsp);
  1674. },
  1675. load: function(){
  1676. this._loadModuleEvents();
  1677. if (this.fireEvent("queryLoad")){
  1678. //this._queryLoaded();
  1679. this._loadUserInterface();
  1680. this._loadStyles();
  1681. this._loadDomEvents();
  1682. //this._loadEvents();
  1683. //this._afterLoaded();
  1684. this.fireEvent("postLoad");
  1685. this.fireEvent("load");
  1686. }
  1687. },
  1688. _loadStyles: function(){
  1689. if (this.json.styles) Object.each(this.json.styles, function(value, key){
  1690. if ((value.indexOf("x_processplatform_assemble_surface")!=-1 || value.indexOf("x_portal_assemble_surface")!=-1 || value.indexOf("x_cms_assemble_control")!=-1)){
  1691. var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface");
  1692. var host2 = MWF.Actions.getHost("x_portal_assemble_surface");
  1693. var host3 = MWF.Actions.getHost("x_cms_assemble_control");
  1694. if (value.indexOf("/x_processplatform_assemble_surface")!==-1){
  1695. value = value.replace("/x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  1696. }else if (value.indexOf("x_processplatform_assemble_surface")!==-1){
  1697. value = value.replace("x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  1698. }
  1699. if (value.indexOf("/x_portal_assemble_surface")!==-1){
  1700. value = value.replace("/x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  1701. }else if (value.indexOf("x_portal_assemble_surface")!==-1){
  1702. value = value.replace("x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  1703. }
  1704. if (value.indexOf("/x_cms_assemble_control")!==-1){
  1705. value = value.replace("/x_cms_assemble_control", host3+"/x_cms_assemble_control");
  1706. }else if (value.indexOf("x_cms_assemble_control")!==-1){
  1707. value = value.replace("x_cms_assemble_control", host3+"/x_cms_assemble_control");
  1708. }
  1709. }
  1710. this.node.setStyle(key, value);
  1711. }.bind(this));
  1712. // if (["x_processplatform_assemble_surface", "x_portal_assemble_surface"].indexOf(root.toLowerCase())!==-1){
  1713. // var host = MWF.Actions.getHost(root);
  1714. // return (flag==="/") ? host+this.json.template : host+"/"+this.json.template
  1715. // }
  1716. //if (this.json.styles) this.node.setStyles(this.json.styles);
  1717. },
  1718. _loadModuleEvents : function(){
  1719. Object.each(this.json.events, function(e, key){
  1720. if (e.code){
  1721. if (this.options.moduleEvents.indexOf(key)!==-1){
  1722. this.addEvent(key, function(event){
  1723. return this.form.Macro.fire(e.code, this, event);
  1724. }.bind(this));
  1725. }
  1726. }
  1727. }.bind(this));
  1728. },
  1729. _loadDomEvents: function(){
  1730. Object.each(this.json.events, function(e, key){
  1731. if (e.code){
  1732. if (this.options.moduleEvents.indexOf(key)===-1){
  1733. this.node.addEvent(key, function(event){
  1734. return this.form.Macro.fire(e.code, this, event);
  1735. }.bind(this));
  1736. }
  1737. }
  1738. }.bind(this));
  1739. },
  1740. _loadEvents: function(){
  1741. Object.each(this.json.events, function(e, key){
  1742. if (e.code){
  1743. if (this.options.moduleEvents.indexOf(key)!==-1){
  1744. this.addEvent(key, function(event){
  1745. return this.form.Macro.fire(e.code, this, event);
  1746. }.bind(this));
  1747. }else{
  1748. this.node.addEvent(key, function(event){
  1749. return this.form.Macro.fire(e.code, this, event);
  1750. }.bind(this));
  1751. }
  1752. }
  1753. }.bind(this));
  1754. },
  1755. addModuleEvent: function(key, fun){
  1756. if (this.options.moduleEvents.indexOf(key)!==-1){
  1757. this.addEvent(key, function(event){
  1758. return (fun) ? fun(this, event) : null;
  1759. }.bind(this));
  1760. }else{
  1761. this.node.addEvent(key, function(event){
  1762. return (fun) ? fun(this, event) : null;
  1763. }.bind(this));
  1764. }
  1765. },
  1766. _loadUserInterface: function(){
  1767. // if (this.form.json.mode == "Mobile"){
  1768. // this.node.empty();
  1769. // }else if (COMMON.Browser.Platform.isMobile){
  1770. // this.node.empty();
  1771. // }else{
  1772. this.toolbarNode = this.node.getFirst("div");
  1773. if( !this.toolbarNode ){
  1774. this.toolbarNode = new Element("div").inject( this.node );
  1775. }
  1776. this.toolbarNode.empty();
  1777. MWF.require("MWF.widget.Toolbar", function(){
  1778. this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {
  1779. "style": this.json.style,
  1780. "onPostLoad" : function(){
  1781. this.fireEvent("afterLoad");
  1782. }.bind(this)
  1783. }, this);
  1784. if (this.json.actionStyles) this.toolbarWidget.css = this.json.actionStyles;
  1785. //alert(this.readonly)
  1786. if (this.json.hideSystemTools){
  1787. this.setCustomToolbars(this.json.tools, this.toolbarNode);
  1788. this.toolbarWidget.load();
  1789. }else{
  1790. if (this.json.defaultTools){
  1791. this.setToolbars(this.json.defaultTools, this.toolbarNode, this.readonly);
  1792. this.setCustomToolbars(this.json.tools, this.toolbarNode);
  1793. this.toolbarWidget.load();
  1794. }else{
  1795. MWF.getJSON(this.form.path+"toolbars.json", function(json){
  1796. this.setToolbars(json, this.toolbarNode, this.readonly, true);
  1797. this.setCustomToolbars(this.json.tools, this.toolbarNode);
  1798. this.toolbarWidget.load();
  1799. }.bind(this), null);
  1800. }
  1801. }
  1802. }.bind(this));
  1803. // }
  1804. },
  1805. setCustomToolbars: function(tools, node){
  1806. var path = "/x_component_process_FormDesigner/Module/Actionbar/";
  1807. var iconPath = "";
  1808. if( this.json.customIconStyle ){
  1809. iconPath = this.json.customIconStyle+"/";
  1810. }
  1811. tools.each(function(tool){
  1812. var flag = true;
  1813. if (this.readonly){
  1814. flag = tool.readShow;
  1815. }else{
  1816. flag = tool.editShow;
  1817. }
  1818. if (flag){
  1819. flag = true;
  1820. // if (tool.control){
  1821. // flag = this.form.businessData.control[tool.control]
  1822. // }
  1823. if (tool.condition){
  1824. var hideFlag = this.form.Macro.exec(tool.condition, this);
  1825. flag = !hideFlag;
  1826. }
  1827. if (flag){
  1828. var actionNode = new Element("div", {
  1829. "id": tool.id,
  1830. "MWFnodetype": tool.type,
  1831. "MWFButtonImage": path+""+this.form.options.style+"/custom/"+iconPath+tool.img,
  1832. "title": tool.title,
  1833. "MWFButtonAction": "runCustomAction",
  1834. "MWFButtonText": tool.text
  1835. }).inject(node);
  1836. if( this.json.customIconOverStyle ){
  1837. actionNode.set("MWFButtonImageOver" , path+""+this.form.options.style +"/custom/"+this.json.customIconOverStyle+ "/" +tool.img );
  1838. }
  1839. if( tool.properties ){
  1840. actionNode.set(tool.properties);
  1841. }
  1842. if (tool.actionScript){
  1843. actionNode.store("script", tool.actionScript);
  1844. }
  1845. if (tool.sub){
  1846. var subNode = node.getLast();
  1847. this.setCustomToolbars(tool.sub, subNode);
  1848. }
  1849. }
  1850. }
  1851. }.bind(this));
  1852. },
  1853. setToolbarItem: function(tool, node, readonly, noCondition){
  1854. //var path = "/x_component_process_FormDesigner/Module/Actionbar/";
  1855. var path = "/x_component_query_ViewDesigner/$View/";
  1856. var flag = true;
  1857. // if (tool.control){
  1858. // flag = this.form.businessData.control[tool.control]
  1859. // }
  1860. if (!noCondition) if (tool.condition){
  1861. var hideFlag = this.form.Macro.exec(tool.condition, this);
  1862. flag = flag && (!hideFlag);
  1863. }
  1864. if (readonly) if (!tool.read) flag = false;
  1865. if (flag){
  1866. var actionNode = new Element("div", {
  1867. "id": tool.id,
  1868. "MWFnodetype": tool.type,
  1869. //"MWFButtonImage": this.form.path+""+this.form.options.style+"/actionbar/"+tool.img,
  1870. //"MWFButtonImage": path+(this.options.style||"default") +"/tools/"+ (this.json.style || "default") +"/"+tool.img,
  1871. "MWFButtonImage": path+this.options.style+"/actionbar/"+ ( this.json.iconStyle || "default" ) +"/"+tool.img,
  1872. "title": tool.title,
  1873. "MWFButtonAction": tool.action,
  1874. "MWFButtonText": tool.text
  1875. }).inject(node);
  1876. if( this.json.iconOverStyle ){
  1877. actionNode.set("MWFButtonImageOver" , path+""+this.options.style+"/actionbar/"+this.json.iconOverStyle+"/"+tool.img );
  1878. //actionNode.set("MWFButtonImageOver" , path+""+(this.options.style||"default")+"/tools/"+( this.json.iconOverStyle || "default" )+"/"+tool.img );
  1879. }
  1880. if( tool.properties ){
  1881. actionNode.set(tool.properties);
  1882. }
  1883. if (tool.sub){
  1884. var subNode = node.getLast();
  1885. this.setToolbars(tool.sub, subNode, readonly, noCondition);
  1886. }
  1887. }
  1888. },
  1889. setToolbars: function(tools, node, readonly, noCondition){
  1890. tools.each(function(tool){
  1891. this.setToolbarItem(tool, node, readonly, noCondition);
  1892. }.bind(this));
  1893. },
  1894. runCustomAction: function(bt){
  1895. var script = bt.node.retrieve("script");
  1896. this.form.Macro.exec(script, this);
  1897. },
  1898. exportView : function(){
  1899. this.form.exportView();
  1900. },
  1901. deleteWork: function(){
  1902. this.form.deleteWork();
  1903. }
  1904. });
  1905. MWF.xApplication.query.Query.Viewer.Paging = new Class({
  1906. Implements: [Events],
  1907. options: {
  1908. "style" : "default",
  1909. "moduleEvents": ["load", "queryLoad", "postLoad", "afterLoad","jump"]
  1910. },
  1911. initialize: function(node, json, form, options){
  1912. this.node = $(node);
  1913. this.node.store("module", this);
  1914. this.json = json;
  1915. this.form = form;
  1916. this.view = form;
  1917. },
  1918. hide: function(){
  1919. var dsp = this.node.getStyle("display");
  1920. if (dsp!=="none") this.node.store("mwf_display", dsp);
  1921. this.node.setStyle("display", "none");
  1922. },
  1923. show: function(){
  1924. var dsp = this.node.retrieve("mwf_display", dsp);
  1925. this.node.setStyle("display", dsp);
  1926. },
  1927. load: function(){
  1928. this._loadModuleEvents();
  1929. if (this.fireEvent("queryLoad")){
  1930. //this._queryLoaded();
  1931. this._loadUserInterface();
  1932. this._loadStyles();
  1933. this._loadDomEvents();
  1934. //this._loadEvents();
  1935. //this._afterLoaded();
  1936. this.fireEvent("postLoad");
  1937. }
  1938. },
  1939. _loadStyles: function(){
  1940. if (this.json.styles) Object.each(this.json.styles, function(value, key){
  1941. if ((value.indexOf("x_processplatform_assemble_surface")!=-1 || value.indexOf("x_portal_assemble_surface")!=-1 || value.indexOf("x_cms_assemble_control")!=-1)){
  1942. var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface");
  1943. var host2 = MWF.Actions.getHost("x_portal_assemble_surface");
  1944. var host3 = MWF.Actions.getHost("x_cms_assemble_control");
  1945. if (value.indexOf("/x_processplatform_assemble_surface")!==-1){
  1946. value = value.replace("/x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  1947. }else if (value.indexOf("x_processplatform_assemble_surface")!==-1){
  1948. value = value.replace("x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  1949. }
  1950. if (value.indexOf("/x_portal_assemble_surface")!==-1){
  1951. value = value.replace("/x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  1952. }else if (value.indexOf("x_portal_assemble_surface")!==-1){
  1953. value = value.replace("x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  1954. }
  1955. if (value.indexOf("/x_cms_assemble_control")!==-1){
  1956. value = value.replace("/x_cms_assemble_control", host3+"/x_cms_assemble_control");
  1957. }else if (value.indexOf("x_cms_assemble_control")!==-1){
  1958. value = value.replace("x_cms_assemble_control", host3+"/x_cms_assemble_control");
  1959. }
  1960. }
  1961. this.node.setStyle(key, value);
  1962. }.bind(this));
  1963. // if (["x_processplatform_assemble_surface", "x_portal_assemble_surface"].indexOf(root.toLowerCase())!==-1){
  1964. // var host = MWF.Actions.getHost(root);
  1965. // return (flag==="/") ? host+this.json.template : host+"/"+this.json.template
  1966. // }
  1967. //if (this.json.styles) this.node.setStyles(this.json.styles);
  1968. },
  1969. _loadModuleEvents : function(){
  1970. Object.each(this.json.events, function(e, key){
  1971. if (e.code){
  1972. if (this.options.moduleEvents.indexOf(key)!==-1){
  1973. this.addEvent(key, function(event){
  1974. return this.form.Macro.fire(e.code, this, event);
  1975. }.bind(this));
  1976. }
  1977. }
  1978. }.bind(this));
  1979. },
  1980. _loadDomEvents: function(){
  1981. Object.each(this.json.events, function(e, key){
  1982. if (e.code){
  1983. if (this.options.moduleEvents.indexOf(key)===-1){
  1984. this.node.addEvent(key, function(event){
  1985. return this.form.Macro.fire(e.code, this, event);
  1986. }.bind(this));
  1987. }
  1988. }
  1989. }.bind(this));
  1990. },
  1991. _loadEvents: function(){
  1992. Object.each(this.json.events, function(e, key){
  1993. if (e.code){
  1994. if (this.options.moduleEvents.indexOf(key)!==-1){
  1995. this.addEvent(key, function(event){
  1996. return this.form.Macro.fire(e.code, this, event);
  1997. }.bind(this));
  1998. }else{
  1999. this.node.addEvent(key, function(event){
  2000. return this.form.Macro.fire(e.code, this, event);
  2001. }.bind(this));
  2002. }
  2003. }
  2004. }.bind(this));
  2005. },
  2006. addModuleEvent: function(key, fun){
  2007. if (this.options.moduleEvents.indexOf(key)!==-1){
  2008. this.addEvent(key, function(event){
  2009. return (fun) ? fun(this, event) : null;
  2010. }.bind(this));
  2011. }else{
  2012. this.node.addEvent(key, function(event){
  2013. return (fun) ? fun(this, event) : null;
  2014. }.bind(this));
  2015. }
  2016. },
  2017. _loadUserInterface: function(){
  2018. // if (this.form.json.mode == "Mobile"){
  2019. // this.node.empty();
  2020. // }else if (COMMON.Browser.Platform.isMobile){
  2021. // this.node.empty();
  2022. // }else{
  2023. this.loadPaging( true )
  2024. },
  2025. reload : function(){
  2026. this.loadPaging( false )
  2027. },
  2028. loadPaging : function( firstLoading ){
  2029. // this.pagingNode = this.node.getFirst("div");
  2030. // if( !this.pagingNode ){
  2031. // this.pagingNode = new Element("div").inject( this.node );
  2032. // }
  2033. // this.pagingNode.empty();
  2034. this.node.empty();
  2035. this.paging = new o2.widget.Paging(this.node, {
  2036. //style : this.options.skin && this.options.skin.pagingBar ? this.options.skin.pagingBar : "default",
  2037. countPerPage: this.view.json.pageSize || this.view.options.perPageCount,
  2038. visiblePages: this.json.visiblePages ? this.json.visiblePages.toInt() : 9,
  2039. currentPage: this.view.currentPage,
  2040. itemSize: this.view.count,
  2041. pageSize: this.view.pages,
  2042. hasNextPage: typeOf( this.json.hasPreNextPage ) === "boolean" ? this.json.hasPreNextPage : true,
  2043. hasPrevPage: typeOf( this.json.hasPreNextPage ) === "boolean" ? this.json.hasPreNextPage : true,
  2044. hasTruningBar: typeOf( this.json.hasTruningBar ) === "boolean" ? this.json.hasTruningBar : true,
  2045. hasBatchTuring: typeOf( this.json.hasBatchTuring ) === "boolean" ? this.json.hasBatchTuring : true,
  2046. hasFirstPage: typeOf( this.json.hasFirstLastPage ) === "boolean" ? this.json.hasFirstLastPage : true,
  2047. hasLastPage: typeOf( this.json.hasFirstLastPage ) === "boolean" ? this.json.hasFirstLastPage : true,
  2048. hasJumper: typeOf( this.json.hasPageJumper ) === "boolean" ? this.json.hasPageJumper : true,
  2049. hiddenWithDisable: false,
  2050. hiddenWithNoItem: true,
  2051. text: {
  2052. prePage: this.json.prePageText,
  2053. nextPage: this.json.nextPageText,
  2054. firstPage: this.json.firstPageText,
  2055. lastPage: this.json.lastPageText
  2056. },
  2057. onJumpingPage : function( pageNum, itemNum ){
  2058. this.view.currentPage = pageNum;
  2059. this.fireEvent("jump");
  2060. this.view.loadCurrentPageData();
  2061. }.bind(this),
  2062. onPostLoad : function () {
  2063. if( firstLoading ){
  2064. if(this.view.setContentHeightFun)this.view.setContentHeightFun();
  2065. this.fireEvent("load");
  2066. }
  2067. this.fireEvent("afterLoad");
  2068. }.bind(this)
  2069. }, this.json.pagingStyles || {});
  2070. this.paging.load();
  2071. }
  2072. });