Viewer.js 117 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678
  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, callback){
  179. this.viewAreaNode.empty();
  180. this.selectedItems = [];
  181. var viewStyles = this.viewJson.viewStyles;
  182. this.contentAreaNode = new Element("div", {"styles":
  183. (viewStyles && viewStyles["container"]) ? viewStyles["container"] : this.css.contentAreaNode
  184. }).inject(this.viewAreaNode);
  185. this.viewTable = new Element("table", {
  186. "styles": this.css.viewTitleTableNode,
  187. "border": "0px",
  188. "cellPadding": "0",
  189. "cellSpacing": "0"
  190. }).inject(this.contentAreaNode);
  191. if( viewStyles ){
  192. if( viewStyles["tableProperties"] )this.viewTable.set(viewStyles["tableProperties"]);
  193. if( viewStyles["table"] )this.viewTable.setStyles(viewStyles["table"]);
  194. }
  195. this.createLoadding();
  196. var viewTitleCellNode = (viewStyles && viewStyles["titleTd"]) ? viewStyles["titleTd"] : this.css.viewTitleCellNode;
  197. if (this.json.isTitle!=="no"){
  198. this.viewTitleLine = new Element("tr", {
  199. "styles": (viewStyles && viewStyles["titleTr"]) ? viewStyles["titleTr"] : this.css.viewTitleLineNode
  200. }).inject(this.viewTable);
  201. //if (this.json.select==="single" || this.json.select==="multi") {
  202. this.selectTitleCell = new Element("td.selectTitleCell", {
  203. "styles": viewTitleCellNode
  204. }).inject(this.viewTitleLine);
  205. this.selectTitleCell.setStyle("width", "10px");
  206. if (this.json.titleStyles) this.selectTitleCell.setStyles(this.json.titleStyles);
  207. //}
  208. if( this.isSelectTdHidden() ){
  209. this.selectTitleCell.hide();
  210. }
  211. if( this.getSelectFlag() !== "multi" || !this.viewJson.allowSelectAll ){
  212. this.expandTitleCell = this.selectTitleCell;
  213. }
  214. //序号
  215. if (this.viewJson.isSequence==="yes"){
  216. this.sequenceTitleCell = new Element("td", {
  217. "styles": viewTitleCellNode
  218. }).inject(this.viewTitleLine);
  219. this.sequenceTitleCell.setStyle("width", "10px");
  220. if (this.json.titleStyles) this.sequenceTitleCell.setStyles(this.json.titleStyles);
  221. if( !this.expandTitleCell )this.expandTitleCell = this.sequenceTitleCell;
  222. }
  223. this.entries = {};
  224. debugger;
  225. this.viewJson.selectList.each(function(column){
  226. this.entries[column.column] = column;
  227. if (!column.hideColumn){
  228. var viewCell = new Element("td", {
  229. "styles": viewTitleCellNode,
  230. "text": column.displayName
  231. }).inject(this.viewTitleLine);
  232. var size = MWF.getTextSize(column.displayName, viewTitleCellNode);
  233. viewCell.setStyle("min-width", ""+size.x+"px");
  234. if (this.json.titleStyles) viewCell.setStyles(this.json.titleStyles);
  235. if( column.groupEntry && !this.expandTitleCell )this.expandTitleCell = viewCell;
  236. if( typeOf(column.titleStyles) === "object" )viewCell.setStyles(column.titleStyles);
  237. if( typeOf(column.titleProperties) === "object" )viewCell.setProperties(column.titleProperties);
  238. if( column.events && column.events.loadTitle && column.events.loadTitle.code ){
  239. var code = column.events.loadTitle.code;
  240. this.Macro.fire( code, {"node" : viewCell, "json" : column, "data" : column.displayName, "view" : this});
  241. }
  242. }else{
  243. this.hideColumns.push(column.column);
  244. }
  245. if (column.allowOpen) this.openColumns.push(column.column);
  246. }.bind(this));
  247. this.lookup(data, callback);
  248. }else{
  249. this.entries = {};
  250. this.viewJson.selectList.each(function(column){
  251. this.entries[column.column] = column;
  252. if (column.hideColumn) this.hideColumns.push(column.column);
  253. if (!column.allowOpen) this.openColumns.push(column.column);
  254. }.bind(this));
  255. this.lookup(data, callback);
  256. }
  257. },
  258. getSelectFlag : function(){
  259. if( this.options && this.options.select )return this.options.select;
  260. if( this.json && this.json.select )return this.json.select;
  261. if( this.viewJson && this.viewJson.select )return this.viewJson.select;
  262. // if( this.json.select === "single" || this.json.select === "multi" )return this.json.select;
  263. // if( this.viewJson.select === "single" || this.viewJson.select === "multi" )return this.viewJson.select;
  264. // if( this.options.select === "single" || this.options.select === "multi" )return this.options.select;
  265. return "none";
  266. },
  267. isSelectTdHidden :function(){
  268. if( !this.viewJson.firstTdHidden ){
  269. return false;
  270. }
  271. if( this.json.select === "single" || this.json.select === "multi" || this.json.defaultSelectedScript || this.viewJson.defaultSelectedScript ){
  272. return false;
  273. }
  274. if( this.viewJson.select === "single" || this.viewJson.select === "multi" ){
  275. return false;
  276. }
  277. if( this.options.select === "single" || this.options.select === "multi" ){
  278. return false;
  279. }
  280. if( this.viewJson.group && this.viewJson.group.column ){
  281. return false;
  282. }
  283. return true;
  284. },
  285. // _loadPageCountNode: function(){
  286. // this.viewPageContentNode.empty();
  287. //
  288. // var size = this.viewPageAreaNode.getSize();
  289. // var w1 = this.viewPageFirstNode.getSize().x*2;
  290. // var w2 = this.viewPageContentNode.getStyle("margin-left").toInt();
  291. // var w = size.x-w1-w2;
  292. //
  293. // var bw = this.css.viewPageButtonNode.width.toInt()+this.css.viewPageButtonNode["margin-right"].toInt();
  294. // var count = (w/bw).toInt()-2;
  295. // if (count>10) count = 10;
  296. // this.showPageCount = Math.min(count, this.pages);
  297. //
  298. // var tmp = this.showPageCount/2;
  299. // var n = tmp.toInt();
  300. // var left = this.currentPage-n;
  301. // if (left<=0) left = 1;
  302. // var right = this.showPageCount + left-1;
  303. // if (right>this.pages) right = this.pages;
  304. // left = right-this.showPageCount+1;
  305. // if (left<=1) left = 1;
  306. //
  307. // this.viewPagePrevNode = new Element("div", {"styles": this.css.viewPagePrevButtonNode}).inject(this.viewPageContentNode);
  308. // this.loadPageButtonEvent(this.viewPagePrevNode, "viewPagePrevButtonNode_over", "viewPagePrevButtonNode_up", "viewPagePrevButtonNode_down", function(){
  309. // if (this.currentPage>1) this.currentPage--;
  310. // this.loadCurrentPageData();
  311. // }.bind(this));
  312. //
  313. // for (i=left; i<=right; i++){
  314. // var node = new Element("div", {"styles": this.css.viewPageButtonNode, "text": i}).inject(this.viewPageContentNode);
  315. // if (i==this.currentPage){
  316. // node.setStyles(this.css.viewPageButtonNode_current);
  317. // }else{
  318. // this.loadPageButtonEvent(node, "viewPageButtonNode_over", "viewPageButtonNode_up", "viewPageButtonNode_down", function(e){
  319. // this.currentPage = e.target.get("text").toInt();
  320. // this.loadCurrentPageData();
  321. // }.bind(this));
  322. // }
  323. // }
  324. // this.viewPageNextNode = new Element("div", {"styles": this.css.viewPageNextButtonNode}).inject(this.viewPageContentNode);
  325. // this.loadPageButtonEvent(this.viewPageNextNode, "viewPageNextButtonNode_over", "viewPageNextButtonNode_up", "viewPageNextButtonNode_down", function(){
  326. // if (this.currentPage<=this.pages-1) this.currentPage++;
  327. // this.loadCurrentPageData();
  328. // }.bind(this));
  329. // },
  330. // loadPageButtonEvent: function(node, over, out, down, click){
  331. // node.addEvents({
  332. // "mouseover": function(){node.setStyles(this.css[over])}.bind(this),
  333. // "mouseout": function(){node.setStyles(this.css[out])}.bind(this),
  334. // "mousedown": function(){node.setStyles(this.css[down])}.bind(this),
  335. // "mouseup": function(){node.setStyles(this.css[out])}.bind(this),
  336. // "click": click
  337. // });
  338. // },
  339. // _loadPageNode: function(){
  340. // this.viewPageAreaNode.empty();
  341. // this.viewPageFirstNode = new Element("div", {"styles": this.css.viewPageFirstLastNode, "text": this.lp.firstPage}).inject(this.viewPageAreaNode);
  342. // this.viewPageContentNode = new Element("div", {"styles": this.css.viewPageContentNode}).inject(this.viewPageAreaNode);
  343. // this.viewPageLastNode = new Element("div", {"styles": this.css.viewPageFirstLastNode, "text": this.lp.lastPage}).inject(this.viewPageAreaNode);
  344. // this._loadPageCountNode();
  345. //
  346. // this.loadPageButtonEvent(this.viewPageFirstNode, "viewPageFirstLastNode_over", "viewPageFirstLastNode_up", "viewPageFirstLastNode_down", function(){
  347. // this.currentPage = 1;
  348. // this.loadCurrentPageData();
  349. // }.bind(this));
  350. // this.loadPageButtonEvent(this.viewPageLastNode, "viewPageFirstLastNode_over", "viewPageFirstLastNode_up", "viewPageFirstLastNode_down", function(){
  351. // this.currentPage = this.pages;
  352. // this.loadCurrentPageData();
  353. // }.bind(this));
  354. // },
  355. _loadPageNode : function(){
  356. this.viewPageAreaNode.empty();
  357. if( !this.paging ){
  358. var json;
  359. if( !this.viewJson.pagingList || !this.viewJson.pagingList.length ){
  360. json = {
  361. "firstPageText": this.lp.firstPage,
  362. "lastPageText": this.lp.lastPage
  363. };
  364. }else{
  365. json = this.viewJson.pagingList[0];
  366. }
  367. this.paging = new MWF.xApplication.query.Query.Viewer.Paging(this.viewPageAreaNode, json, this, {});
  368. this.paging.load();
  369. }else{
  370. this.paging.reload();
  371. }
  372. },
  373. _initPage: function(){
  374. this.count = this.bundleItems.length;
  375. var i = this.count/this.json.pageSize;
  376. this.pages = (i.toInt()<i) ? i.toInt()+1 : i;
  377. this.currentPage = this.options.defaultPage || 1;
  378. this.options.defaultPage = null;
  379. },
  380. lookup: function(data, callback){
  381. if( this.lookuping )return;
  382. this.lookuping = true;
  383. this.getLookupAction(function(){
  384. if (this.json.application){
  385. var d = data || {};
  386. d.count = this.json.count;
  387. this.lookupAction.bundleView(this.json.id, d, function(json){
  388. this.bundleItems = json.data.valueList;
  389. this._initPage();
  390. if (this.bundleItems.length){
  391. if( this.noDataTextNode )this.noDataTextNode.destroy();
  392. this.loadCurrentPageData( function () {
  393. this.fireEvent("postLoad"); //用户配置的事件
  394. this.lookuping = false;
  395. if(callback)callback(this);
  396. }.bind(this));
  397. }else{
  398. //this._loadPageNode();
  399. this.viewPageAreaNode.empty();
  400. if( this.viewJson.noDataText ){
  401. var noDataTextNodeStyle = this.css.noDataTextNode;
  402. if( this.viewJson.viewStyles && this.viewJson.viewStyles["noDataTextNode"] ){
  403. noDataTextNodeStyle = this.viewJson.viewStyles["noDataTextNode"];
  404. }
  405. this.noDataTextNode = new Element( "div", {
  406. "styles": noDataTextNodeStyle,
  407. "text" : this.viewJson.noDataText
  408. }).inject( this.contentAreaNode );
  409. }
  410. if (this.loadingAreaNode){
  411. this.loadingAreaNode.destroy();
  412. this.loadingAreaNode = null;
  413. }
  414. this.fireEvent("postLoad"); //用户配置的事件
  415. this.lookuping = false;
  416. if(callback)callback(this);
  417. }
  418. }.bind(this));
  419. }
  420. }.bind(this));
  421. },
  422. loadCurrentPageData: function( callback, async ){
  423. //是否需要在翻页的时候清空之前的items ?
  424. if( this.pageloading )return;
  425. this.pageloading = true;
  426. this.items = [];
  427. var p = this.currentPage;
  428. var d = {};
  429. var valueList = this.bundleItems.slice((p-1)*this.json.pageSize,this.json.pageSize*p);
  430. d.bundleList = valueList;
  431. while (this.viewTable.rows.length>1){
  432. this.viewTable.deleteRow(-1);
  433. }
  434. //this.createLoadding();
  435. this.loadViewRes = this.lookupAction.loadView(this.json.name, this.json.application, d, function(json){
  436. this.viewData = json.data;
  437. this.fireEvent("postLoadPageData");
  438. if (this.viewJson.group.column){
  439. this.gridJson = json.data.groupGrid;
  440. this.loadGroupData();
  441. }else{
  442. this.gridJson = json.data.grid;
  443. this.loadData();
  444. }
  445. if (this.gridJson.length) this._loadPageNode();
  446. if (this.loadingAreaNode){
  447. this.loadingAreaNode.destroy();
  448. this.loadingAreaNode = null;
  449. }
  450. this.pageloading = false;
  451. this.fireEvent("loadView"); //options 传入的事件
  452. this.fireEvent("postLoadPage");
  453. if(callback)callback();
  454. }.bind(this), null, async === false ? false : true );
  455. },
  456. getMode: function(){
  457. return this.viewJson.group.column ? "group" : "item";
  458. },
  459. createSelectAllNode: function(){
  460. if( this.getSelectFlag() === "multi" && this.viewJson.allowSelectAll ){
  461. if (this.selectTitleCell && !this.selectTitleCell.retrieve("selectAllLoaded") ){
  462. if( this.viewJson.viewStyles && this.viewJson.viewStyles["checkboxNode"] ){
  463. this.selectAllNode = this.selectTitleCell;
  464. this.selectAllNode.setStyles( this.viewJson.viewStyles["checkboxNode"] );
  465. // this.selectAllNode = new Element("div", {
  466. // styles : this.viewJson.viewStyles["checkboxNode"]
  467. // }).inject( this.selectTitleCell );
  468. }else{
  469. this.selectAllNode.html( "<img src='../x_component_query_Query/$Viewer/"+this.options.style+"/icon/checkbox.png'/>"+"</span>" )
  470. // this.selectAllNode = new Element("div",{
  471. // html : "<img src='../x_component_query_Query/$Viewer/"+this.options.style+"/icon/checkbox.png'/>"+"</span>",
  472. // style : "font-family: Webdings"
  473. // }).inject( this.selectTitleCell );
  474. }
  475. this.selectTitleCell.setStyle("cursor", "pointer");
  476. this.selectTitleCell.addEvent("click", function () {
  477. if( this.getSelectAllStatus() === "all" ){
  478. this.unSelectAll("view")
  479. }else{
  480. this.selectAll("view");
  481. }
  482. }.bind(this));
  483. this.selectTitleCell.store("selectAllLoaded", true);
  484. }
  485. }
  486. },
  487. loadData: function(){
  488. if( this.getSelectFlag() === "multi" && this.viewJson.allowSelectAll ) {
  489. if(this.selectTitleCell && this.selectTitleCell.retrieve("selectAllLoaded")){
  490. this.setUnSelectAllStyle();
  491. }else{
  492. this.createSelectAllNode();
  493. }
  494. }
  495. if (this.gridJson.length){
  496. // if( !this.options.paging ){
  497. this.gridJson.each(function(line, i){
  498. this.items.push(new MWF.xApplication.query.Query.Viewer.Item(this, line, null, i));
  499. }.bind(this));
  500. // }else{
  501. // this.loadPaging();
  502. // }
  503. }else{
  504. if (this.viewPageAreaNode) this.viewPageAreaNode.empty();
  505. }
  506. },
  507. loadPaging : function(){
  508. this.isItemsLoading = false;
  509. this.pageNumber = 0;
  510. this.isItemsLoaded = false;
  511. this.isSetedScroll = false;
  512. this.setScroll();
  513. this.loadDataByPaging()
  514. },
  515. setScroll : function(){
  516. if( this.options.paging && !this.isSetedScroll ){
  517. this.contentAreaNode.setStyle("overflow","auto");
  518. this.scrollContainerFun = function(){
  519. var scrollSize = this.contentAreaNode.getScrollSize();
  520. var clientSize = this.contentAreaNode.getSize();
  521. var scrollHeight = scrollSize.y - clientSize.y;
  522. //alert( "clientSize.y=" + clientSize.y + " scrollSize.y="+scrollSize.y + " this.contentAreaNode.scrollTop="+this.contentAreaNode.scrollTop);
  523. if (this.contentAreaNode.scrollTop + 150 > scrollHeight ) {
  524. if (!this.isItemsLoaded) this.loadDataByPaging();
  525. }
  526. }.bind(this);
  527. this.isSetedScroll = true;
  528. this.contentAreaNode.addEvent("scroll", this.scrollContainerFun )
  529. }
  530. },
  531. loadDataByPaging : function(){
  532. if( this.isItemsLoading )return;
  533. if( !this.isItemsLoaded ){
  534. var from = Math.min( this.pageNumber * this.options.perPageCount , this.gridJson.length);
  535. var to = Math.min( ( this.pageNumber + 1 ) * this.options.perPageCount + 1 , this.gridJson.length);
  536. this.isItemsLoading = true;
  537. for( var i = from; i<to; i++ ){
  538. this.items.push(new MWF.xApplication.query.Query.Viewer.Item(this, this.gridJson[i], null, i));
  539. }
  540. this.isItemsLoading = false;
  541. this.pageNumber ++;
  542. if( to == this.gridJson.length )this.isItemsLoaded = true;
  543. }
  544. },
  545. loadGroupData: function(){
  546. if( this.getSelectFlag() === "multi" && this.viewJson.allowSelectAll ) {
  547. if(this.selectTitleCell && this.selectTitleCell.retrieve("selectAllLoaded")){
  548. this.setUnSelectAllStyle();
  549. }else{
  550. this.createSelectAllNode();
  551. }
  552. }
  553. if( this.expandTitleCell ){
  554. if ( !this.expandTitleCell.retrieve("expandLoaded") ){
  555. if( this.viewJson.viewStyles && this.viewJson.viewStyles["groupCollapseNode"] ){
  556. this.expandAllNode = new Element("span", {
  557. styles : this.viewJson.viewStyles["groupCollapseNode"]
  558. }).inject( this.expandTitleCell, "top" );
  559. // this.selectTitleCell.setStyle("cursor", "pointer");
  560. }else{
  561. // this.selectTitleCell.set("html", "<span style='font-family: Webdings'>"+"<img src='../x_component_query_Query/$Viewer/"+this.options.style+"/icon/expand.png'/>"+"</span>");
  562. this.expandAllNode = new Element("span",{
  563. html : "<img src='../x_component_query_Query/$Viewer/"+this.options.style+"/icon/expand.png'/>"+"</span>",
  564. style : "font-family: Webdings"
  565. }).inject( this.expandTitleCell, "top" );
  566. }
  567. this.expandTitleCell.setStyle("cursor", "pointer");
  568. this.expandTitleCell.addEvent("click", this.expandOrCollapseAll.bind(this));
  569. this.expandTitleCell.store("expandLoaded", true);
  570. }else if( this.json.isExpand !=="yes" ){
  571. this.setCollapseAllStyle();
  572. }
  573. }
  574. // this.isAllExpanded = false;
  575. if (this.gridJson.length){
  576. var i = 0;
  577. this.gridJson.each(function(data){
  578. this.items.push(new MWF.xApplication.query.Query.Viewer.ItemCategory(this, data, i));
  579. i += data.list.length;
  580. }.bind(this));
  581. if (this.json.isExpand=="yes") this.expandOrCollapseAll();
  582. }else{
  583. if (this.viewPageAreaNode) this.viewPageAreaNode.empty();
  584. }
  585. },
  586. getView: function(callback){
  587. this.getLookupAction(function(){
  588. if (this.json.application){
  589. this.getViewRes = this.lookupAction.getView(this.json.viewName, this.json.application, function(json){
  590. this.viewJson = JSON.decode(json.data.data);
  591. this.json = Object.merge(this.json, json.data);
  592. if (callback) callback();
  593. }.bind(this));
  594. // this.lookupAction.invoke({"name": "getView","async": true, "parameter": {"view": this.json.viewName, "application": this.json.application},"success": function(json){
  595. // this.viewJson = JSON.decode(json.data.data);
  596. // this.json = Object.merge(this.json, json.data);
  597. // //var viewData = JSON.decode(json.data.data);
  598. // if (callback) callback();
  599. // }.bind(this)});
  600. }else{
  601. this.getViewRes = this.lookupAction.getViewById(this.json.viewId, function(json){
  602. this.viewJson = JSON.decode(json.data.data);
  603. this.json.application = json.data.query;
  604. this.json = Object.merge(this.json, json.data);
  605. if (callback) callback();
  606. }.bind(this));
  607. }
  608. }.bind(this));
  609. },
  610. getLookupAction: function(callback){
  611. if (!this.lookupAction){
  612. this.lookupAction = MWF.Actions.get("x_query_assemble_surface");
  613. if (callback) callback();
  614. // var _self = this;
  615. // MWF.require("MWF.xDesktop.Actions.RestActions", function(){
  616. // this.lookupAction = new MWF.xDesktop.Actions.RestActions("", this.options.actionRoot, "");
  617. // this.lookupAction.getActions = function(actionCallback){
  618. // this.actions = _self.options.actions;
  619. // if (actionCallback) actionCallback();
  620. // };
  621. // if (callback) callback();
  622. // }.bind(this));
  623. }else{
  624. if (callback) callback();
  625. }
  626. },
  627. hide: function(){
  628. this.node.setStyle("display", "none");
  629. },
  630. reload: function(){
  631. if( this.lookuping || this.pageloading )return;
  632. this.node.setStyle("display", "block");
  633. if (this.loadingAreaNode) this.loadingAreaNode.setStyle("display", "block");
  634. this.filterItems.each(function(filter){
  635. filter.destroy();
  636. }.bind(this));
  637. this.filterItems = [];
  638. if (this.viewSearchInputNode) this.viewSearchInputNode.set("text", this.lp.searchKeywork);
  639. this.closeCustomSearch();
  640. this.viewAreaNode.empty();
  641. this.createViewNode({"filterList": this.json.filter ? this.json.filter.clone() : null});
  642. },
  643. getFilter: function(){
  644. var filterData = [];
  645. if (this.searchStatus==="custom"){
  646. if (this.filterItems.length){
  647. this.filterItems.each(function(filter){
  648. filterData.push(filter.data);
  649. }.bind(this));
  650. }
  651. }
  652. if (this.searchStatus==="default"){
  653. var key = this.viewSearchInputNode.get("value");
  654. if (key && key!==this.lp.searchKeywork){
  655. this.viewJson.customFilterList.each(function(entry){
  656. if (entry.formatType==="textValue"){
  657. var d = {
  658. "path": entry.path,
  659. "value": key,
  660. "formatType": entry.formatType,
  661. "logic": "or",
  662. "comparison": "like"
  663. };
  664. filterData.push(d);
  665. }
  666. if (entry.formatType==="numberValue"){
  667. var v = key.toFloat();
  668. if (!isNaN(v)){
  669. var d = {
  670. "path": entry.path,
  671. "value": v,
  672. "formatType": entry.formatType,
  673. "logic": "or",
  674. "comparison": "like"
  675. };
  676. filterData.push(d);
  677. }
  678. }
  679. }.bind(this));
  680. }
  681. }
  682. return (filterData.length) ? filterData : null;
  683. },
  684. getData: function(){
  685. if (this.selectedItems.length){
  686. var arr = [];
  687. this.selectedItems.each(function(item){
  688. arr.push(item.data);
  689. });
  690. return arr;
  691. }else{
  692. return [];
  693. }
  694. },
  695. _loadModuleEvents : function(){
  696. Object.each(this.viewJson.events, function(e, key){
  697. if (e.code){
  698. if (this.options.moduleEvents.indexOf(key)!==-1){
  699. this.addEvent(key, function(event, target){
  700. return this.Macro.fire(e.code, target || this, event);
  701. }.bind(this));
  702. }
  703. }
  704. }.bind(this));
  705. },
  706. _loadDomEvents: function(){
  707. Object.each(this.viewJson.events, function(e, key){
  708. if (e.code){
  709. if (this.options.moduleEvents.indexOf(key)===-1){
  710. this.node.addEvent(key, function(event){
  711. return this.Macro.fire(e.code, this, event);
  712. }.bind(this));
  713. }
  714. }
  715. }.bind(this));
  716. },
  717. //搜索相关开始
  718. createSearchNode: function(){
  719. if (this.viewJson.customFilterList && this.viewJson.customFilterList.length){
  720. this.searchStatus = "default";
  721. this.loadFilterSearch();
  722. }else{
  723. this.loadSimpleSearch();
  724. }
  725. },
  726. loadSimpleSearch: function(){
  727. return false;
  728. this.searchSimpleNode = new Element("div", {"styles": this.css.searchSimpleNode}).inject(this.searchAreaNode);
  729. this.searchSimpleButtonNode = new Element("div", {"styles": this.css.searchSimpleButtonNode}).inject(this.searchSimpleNode);
  730. this.searchSimpleInputNode = new Element("input", {"type":"text", "styles": this.css.searchSimpleInputNode, "value": this.lp.searchKeywork}).inject(this.searchSimpleNode);
  731. this.searchSimpleButtonNode.addEvent("click", function(){
  732. this.search();
  733. }.bind(this));
  734. this.searchSimpleInputNode.addEvents({
  735. "focus": function(){
  736. if (this.searchSimpleInputNode.get("value")===this.lp.searchKeywork) this.searchSimpleInputNode.set("value", "");
  737. }.bind(this),
  738. "blur": function(){if (!this.searchSimpleInputNode.get("value")) this.searchSimpleInputNode.set("value", this.lp.searchKeywork);}.bind(this),
  739. "keydown": function(e){
  740. if (e.code===13) this.search();
  741. }.bind(this)
  742. });
  743. },
  744. search: function(){
  745. if (this.gridJson){
  746. var key = this.searchSimpleInputNode.get("value");
  747. var rows = this.viewTable.rows;
  748. var first = (this.json.isTitle!=="no") ? 1 : 0;
  749. for (var i = first; i<rows.length; i++){
  750. var tr = rows[i];
  751. if (!key || key==this.lp.searchKeywork){
  752. if (tr.getStyle("display")==="none") tr.setStyle("display", "table-row");
  753. }else{
  754. if (tr.get("text").indexOf(key)!==-1){
  755. if (tr.getStyle("display")==="none") tr.setStyle("display", "table-row");
  756. }else{
  757. if (tr.getStyle("display")!=="none") tr.setStyle("display", "none");
  758. }
  759. }
  760. }
  761. //if (this.viewPageAreaNode) this.viewPageAreaNode.hide();
  762. }
  763. },
  764. loadFilterSearch: function(){
  765. this.viewSearchCustomActionNode = new Element("div", {"styles": this.css.viewFilterSearchCustomActionNode, "text": this.lp.customSearch}).inject(this.searchAreaNode);
  766. this.viewSearchInputAreaNode = new Element("div", {"styles": this.css.viewFilterSearchInputAreaNode}).inject(this.searchAreaNode);
  767. this.viewSearchIconNode = new Element("div", {"styles": this.css.viewFilterSearchIconNode}).inject(this.viewSearchInputAreaNode);
  768. this.viewSearchInputBoxNode = new Element("div", {"styles": this.css.viewFilterSearchInputBoxNode}).inject(this.viewSearchInputAreaNode);
  769. this.viewSearchInputNode = new Element("input", {"styles": this.css.viewFilterSearchInputNode, "value": this.lp.searchKeywork}).inject(this.viewSearchInputBoxNode);
  770. this.viewSearchInputNode.addEvents({
  771. "focus": function(){
  772. if (this.viewSearchInputNode.get("value")===this.lp.searchKeywork) this.viewSearchInputNode.set("value", "");
  773. }.bind(this),
  774. "blur": function(){if (!this.viewSearchInputNode.get("value")) this.viewSearchInputNode.set("value", this.lp.searchKeywork);}.bind(this),
  775. "keydown": function(e){
  776. if (e.code===13) this.searchView();
  777. }.bind(this)
  778. });
  779. this.viewSearchIconNode.addEvents({
  780. "click": function(){this.searchView();}.bind(this)
  781. });
  782. this.viewSearchCustomActionNode.addEvents({
  783. "click": function(){this.loadCustomSearch();}.bind(this)
  784. });
  785. },
  786. searchView: function(){
  787. if (this.viewJson.customFilterList) {
  788. var key = this.viewSearchInputNode.get("value");
  789. if (key && key !== this.lp.searchKeywork) {
  790. var filterData = this.json.filter ? this.json.filter : [];
  791. this.filterItems = [];
  792. this.viewJson.customFilterList.each(function (entry) {
  793. if (entry.formatType === "textValue") {
  794. var d = {
  795. "path": entry.path,
  796. "value": key,
  797. "formatType": entry.formatType,
  798. "logic": "or",
  799. "comparison": "like"
  800. };
  801. filterData.push(d);
  802. this.filterItems.push({"data":d});
  803. }
  804. if (entry.formatType === "numberValue") {
  805. var v = key.toFloat();
  806. if (!isNaN(v)) {
  807. var d = {
  808. "path": entry.path,
  809. "value": v,
  810. "formatType": entry.formatType,
  811. "logic": "or",
  812. "comparison": "like"
  813. };
  814. filterData.push(d);
  815. this.filterItems.push({"data":d});
  816. }
  817. }
  818. }.bind(this));
  819. this.createViewNode({"filterList": filterData});
  820. }else{
  821. this.filterItems = [];
  822. this.createViewNode();
  823. }
  824. }
  825. },
  826. searchCustomView: function(){
  827. if (this.filterItems.length){
  828. var filterData = this.json.filter ? this.json.filter.clone() : [];
  829. this.filterItems.each(function(filter){
  830. filterData.push(filter.data);
  831. }.bind(this));
  832. this.createViewNode({"filterList": filterData});
  833. }else{
  834. this.createViewNode({"filterList": this.json.filter ? this.json.filter.clone() : null});
  835. }
  836. },
  837. loadCustomSearch: function(){
  838. if( this.lastFilterItems ){
  839. this.filterItems = this.lastFilterItems;
  840. }else{
  841. this.filterItems = [];
  842. }
  843. debugger;
  844. this.viewSearchIconNode.setStyle("display", "none");
  845. this.viewSearchInputBoxNode.setStyle("display", "none");
  846. this.viewSearchCustomActionNode.setStyle("display", "none");
  847. if (!this.searchMorph) this.searchMorph = new Fx.Morph(this.viewSearchInputAreaNode);
  848. var x = this.viewSearchInputAreaNode.getParent().getSize().x-2-20;
  849. this.css.viewFilterSearchInputAreaNode_custom.width = ""+x+"px";
  850. var x1 = this.viewSearchInputAreaNode.getSize().x-2;
  851. this.viewSearchInputAreaNode.setStyle("width", ""+x1+"px");
  852. this.searchMorph.start(this.css.viewFilterSearchInputAreaNode_custom).chain(function(){
  853. this.searchStatus = "custom";
  854. this.css.viewFilterSearchInputAreaNode_custom.width = "auto";
  855. this.viewSearchInputAreaNode.setStyle("width", "auto");
  856. if (this.viewSearchCustomContentNode){
  857. this.viewSearchCustomCloseActionNode.setStyle("display", "block");
  858. this.viewSearchCustomContentNode.setStyle("display", "block");
  859. }else{
  860. this.loadCustomSearchContent();
  861. }
  862. if(this.setContentHeightFun)this.setContentHeightFun();
  863. }.bind(this));
  864. this.searchCustomView();
  865. },
  866. loadCustomSearchContent: function(){
  867. this.viewSearchCustomCloseActionNode = new Element("div", {"styles": this.css.viewFilterSearchCustomCloseActionNode}).inject(this.viewSearchInputAreaNode);
  868. this.viewSearchCustomContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomContentNode}).inject(this.viewSearchInputAreaNode);
  869. this.viewSearchCustomPathContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomPathContentNode}).inject(this.viewSearchCustomContentNode);
  870. this.viewSearchCustomComparisonContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomComparisonContentNode}).inject(this.viewSearchCustomContentNode);
  871. this.viewSearchCustomValueContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomValueContentNode}).inject(this.viewSearchCustomContentNode);
  872. this.viewSearchCustomAddContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomAddContentNode}).inject(this.viewSearchCustomContentNode);
  873. this.viewSearchCustomAddIconNode = new Element("div", {"styles": this.css.viewFilterSearchCustomAddIconNode}).inject(this.viewSearchCustomAddContentNode);
  874. this.viewSearchCustomFilterContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomFilterContentNode}).inject(this.viewSearchCustomContentNode);
  875. this.loadViewSearchCustomList();
  876. this.viewSearchCustomCloseActionNode.addEvents({
  877. "click": function(){this.closeCustomSearch();}.bind(this)
  878. });
  879. this.viewSearchCustomAddIconNode.addEvents({
  880. "click": function(){this.viewSearchCustomAddToFilter();}.bind(this)
  881. });
  882. },
  883. loadViewSearchCustomList: function(){
  884. this.viewSearchCustomPathListNode = new Element("select", {
  885. "styles": this.css.viewFilterSearchCustomPathListNode,
  886. "multiple": true
  887. }).inject(this.viewSearchCustomPathContentNode);
  888. this.viewSearchCustomComparisonListNode = new Element("select", {
  889. "styles": this.css.viewFilterSearchCustomComparisonListNode,
  890. "multiple": true
  891. }).inject(this.viewSearchCustomComparisonContentNode);
  892. this.viewJson.customFilterList.each(function(entry){
  893. var option = new Element("option", {
  894. "style": this.css.viewFilterSearchOptionNode,
  895. "value": entry.path,
  896. "text": entry.title
  897. }).inject(this.viewSearchCustomPathListNode);
  898. option.store("entry", entry);
  899. }.bind(this));
  900. this.viewSearchCustomPathListNode.addEvent("change", function(){
  901. this.loadViewSearchCustomComparisonList();
  902. }.bind(this));
  903. },
  904. loadViewSearchCustomComparisonList: function(){
  905. var idx = this.viewSearchCustomPathListNode.selectedIndex;
  906. var option = this.viewSearchCustomPathListNode.options[idx];
  907. var entry = option.retrieve("entry");
  908. if (entry){
  909. var selectableList = this.getCustomSelectScriptResult(entry);
  910. switch (entry.formatType){
  911. case "numberValue":
  912. this.loadComparisonSelect(this.lp.numberFilter);
  913. if( selectableList.length > 0 ){
  914. this.loadViewSerchCustomSelectByScript(selectableList)
  915. }else{
  916. this.loadViewSearchCustomValueNumberInput();
  917. }
  918. break;
  919. case "dateTimeValue":
  920. this.loadComparisonSelect(this.lp.dateFilter);
  921. if( selectableList.length > 0 ){
  922. this.loadViewSerchCustomSelectByScript(selectableList)
  923. }else {
  924. this.loadViewSearchCustomValueDateTimeInput();
  925. }
  926. break;
  927. case "dateValue":
  928. this.loadComparisonSelect(this.lp.dateFilter);
  929. if( selectableList.length > 0 ){
  930. this.loadViewSerchCustomSelectByScript(selectableList)
  931. }else {
  932. this.loadViewSearchCustomValueDateInput();
  933. }
  934. break;
  935. case "timeValue":
  936. this.loadComparisonSelect(this.lp.dateFilter);
  937. if( selectableList.length > 0 ){
  938. this.loadViewSerchCustomSelectByScript(selectableList)
  939. }else {
  940. this.loadViewSearchCustomValueTimeInput();
  941. }
  942. break;
  943. case "booleanValue":
  944. this.loadComparisonSelect(this.lp.booleanFilter);
  945. if( selectableList.length > 0 ){
  946. this.loadViewSerchCustomSelectByScript(selectableList)
  947. }else {
  948. this.loadViewSearchCustomValueBooleanInput();
  949. }
  950. break;
  951. default:
  952. this.loadComparisonSelect(this.lp.textFilter);
  953. if( selectableList.length > 0 ){
  954. this.loadViewSerchCustomSelectByScript(selectableList)
  955. }else {
  956. this.loadViewSearchCustomValueTextInput();
  957. }
  958. }
  959. }
  960. },
  961. getCustomSelectScriptResult : function( entry ){
  962. var scriptResult = [];
  963. if( entry.valueType === "script" ){
  964. if( entry.valueScript && entry.valueScript.code ){
  965. var result = this.Macro.exec(entry.valueScript.code, this);
  966. var array = typeOf( result ) === "array" ? result : [result];
  967. for( var i=0; i<array.length; i++ ){
  968. if( array[i].indexOf( "|" ) > -1 ){
  969. var arr = array[i].split("|");
  970. scriptResult.push({ "text" : arr[0], "value" : arr[1] })
  971. }else{
  972. scriptResult.push({ "text" : array[i], "value" : array[i] })
  973. }
  974. }
  975. }
  976. }
  977. return scriptResult;
  978. },
  979. loadViewSerchCustomSelectByScript: function( array ){
  980. this.viewSearchCustomValueContentNode.empty();
  981. this.viewSearchCustomValueNode = new Element("select", {
  982. "styles": this.css.viewFilterSearchCustomComparisonListNode,
  983. "multiple": true
  984. }).inject(this.viewSearchCustomValueContentNode);
  985. array.each(function( v ){
  986. var option = new Element("option", {
  987. "style": this.css.viewFilterSearchOptionNode,
  988. "value": v.value,
  989. "text": v.text,
  990. "selected" : array.length === 1
  991. }).inject(this.viewSearchCustomValueNode);
  992. }.bind(this));
  993. },
  994. loadViewSearchCustomValueNumberInput: function(){
  995. this.viewSearchCustomValueContentNode.empty();
  996. this.viewSearchCustomValueNode = new Element("input", {
  997. "styles": this.css.viewFilterSearchCustomValueNode,
  998. "type": "number"
  999. }).inject(this.viewSearchCustomValueContentNode);
  1000. },
  1001. loadViewSearchCustomValueDateTimeInput: function(){
  1002. this.viewSearchCustomValueContentNode.empty();
  1003. this.viewSearchCustomValueNode = new Element("input", {
  1004. "styles": this.css.viewFilterSearchCustomValueNode,
  1005. "type": "text",
  1006. "readonly": true
  1007. }).inject(this.viewSearchCustomValueContentNode);
  1008. MWF.require("MWF.widget.Calendar", function(){
  1009. this.calendar = new MWF.widget.Calendar(this.viewSearchCustomValueNode, {
  1010. "style": "xform",
  1011. "isTime": true,
  1012. "secondEnable" : true,
  1013. "target": this.container,
  1014. "format": "db"
  1015. });
  1016. }.bind(this));
  1017. },
  1018. loadViewSearchCustomValueDateInput: function(){
  1019. this.viewSearchCustomValueContentNode.empty();
  1020. this.viewSearchCustomValueNode = new Element("input", {
  1021. "styles": this.css.viewFilterSearchCustomValueNode,
  1022. "type": "text",
  1023. "readonly": true
  1024. }).inject(this.viewSearchCustomValueContentNode);
  1025. MWF.require("MWF.widget.Calendar", function(){
  1026. this.calendar = new MWF.widget.Calendar(this.viewSearchCustomValueNode, {
  1027. "style": "xform",
  1028. "isTime": false,
  1029. "target": this.container,
  1030. "format": "%Y-%m-%d"
  1031. });
  1032. }.bind(this));
  1033. },
  1034. loadViewSearchCustomValueTimeInput: function(){
  1035. this.viewSearchCustomValueContentNode.empty();
  1036. this.viewSearchCustomValueNode = new Element("input", {
  1037. "styles": this.css.viewFilterSearchCustomValueNode,
  1038. "type": "text",
  1039. "readonly": true
  1040. }).inject(this.viewSearchCustomValueContentNode);
  1041. MWF.require("MWF.widget.Calendar", function(){
  1042. this.calendar = new MWF.widget.Calendar(this.viewSearchCustomValueNode, {
  1043. "style": "xform",
  1044. "timeOnly": true,
  1045. "target": this.container,
  1046. "format": "%H:%M:%S"
  1047. });
  1048. }.bind(this));
  1049. },
  1050. loadViewSearchCustomValueBooleanInput: function(){
  1051. this.viewSearchCustomValueContentNode.empty();
  1052. this.viewSearchCustomValueNode = new Element("select", {
  1053. "styles": this.css.viewFilterSearchCustomValueSelectNode,
  1054. "multiple": true
  1055. }).inject(this.viewSearchCustomValueContentNode);
  1056. new Element("option", {"value": "true","text": this.lp.yes}).inject(this.viewSearchCustomValueNode);
  1057. new Element("option", {"value": "false","text": this.lp.no}).inject(this.viewSearchCustomValueNode);
  1058. },
  1059. loadViewSearchCustomValueTextInput: function(){
  1060. this.viewSearchCustomValueContentNode.empty();
  1061. this.viewSearchCustomValueNode = new Element("textarea", {
  1062. "styles": this.css.viewFilterSearchCustomValueNode
  1063. }).inject(this.viewSearchCustomValueContentNode);
  1064. },
  1065. loadComparisonSelect:function(obj){
  1066. this.viewSearchCustomComparisonListNode.empty();
  1067. Object.each(obj, function(v, k){
  1068. var option = new Element("option", {"value": k,"text": v}).inject(this.viewSearchCustomComparisonListNode);
  1069. }.bind(this));
  1070. },
  1071. closeCustomSearch: function(){
  1072. if (this.viewSearchCustomContentNode && this.viewSearchCustomContentNode.getStyle("display")==="block"){
  1073. this.viewSearchCustomCloseActionNode.setStyle("display", "none");
  1074. this.viewSearchCustomContentNode.setStyle("display", "none");
  1075. var x = this.viewSearchInputAreaNode.getParent().getSize().x;
  1076. x1 = x-2-10-90;
  1077. this.css.viewFilterSearchInputAreaNode.width = ""+x1+"px";
  1078. var x1 = this.viewSearchInputAreaNode.getSize().x-2;
  1079. this.viewSearchInputAreaNode.setStyle("width", ""+x1+"px");
  1080. if (!this.searchMorph) this.searchMorph = new Fx.Morph(this.viewSearchInputAreaNode);
  1081. this.searchMorph.start(this.css.viewFilterSearchInputAreaNode).chain(function(){
  1082. this.searchStatus = "default";
  1083. this.css.viewFilterSearchInputAreaNode.width = "auto";
  1084. this.viewSearchInputAreaNode.setStyle("margin-right", "90px");
  1085. this.viewSearchIconNode.setStyle("display", "block");
  1086. this.viewSearchInputBoxNode.setStyle("display", "block");
  1087. this.viewSearchCustomActionNode.setStyle("display", "block");
  1088. if(this.setContentHeightFun)this.setContentHeightFun();
  1089. }.bind(this));
  1090. this.lastFilterItems = this.filterItems;
  1091. this.createViewNode({"filterList": this.json.filter ? this.json.filter.clone() : null});
  1092. }
  1093. },
  1094. viewSearchCustomAddToFilter: function(){
  1095. var pathIdx = this.viewSearchCustomPathListNode.selectedIndex;
  1096. var comparisonIdx = this.viewSearchCustomComparisonListNode.selectedIndex;
  1097. if (pathIdx===-1){
  1098. MWF.xDesktop.notice("error", {"x": "left", "y": "top"}, this.lp.filterErrorTitle, this.viewSearchCustomPathListNode, {"x": 0, "y": 85});
  1099. return false;
  1100. }
  1101. if (comparisonIdx===-1){
  1102. MWF.xDesktop.notice("error", {"x": "left", "y": "top"}, this.lp.filterErrorComparison, this.viewSearchCustomComparisonListNode, {"x": 0, "y": 85});
  1103. return false;
  1104. }
  1105. var pathOption = this.viewSearchCustomPathListNode.options[pathIdx];
  1106. var entry = pathOption.retrieve("entry");
  1107. if (entry){
  1108. var pathTitle = entry.title;
  1109. var path = entry.path;
  1110. var comparison = this.viewSearchCustomComparisonListNode.options[comparisonIdx].get("value");
  1111. var comparisonTitle = this.viewSearchCustomComparisonListNode.options[comparisonIdx].get("text");
  1112. var value = "";
  1113. if( entry.valueType === "script" && entry.valueScript && entry.valueScript.code ){
  1114. var idx = this.viewSearchCustomValueNode.selectedIndex;
  1115. if (idx!==-1){
  1116. var v = this.viewSearchCustomValueNode.options[idx].get("value");
  1117. value = entry.formatType === "booleanValue" ? (v==="true") : v;
  1118. }
  1119. }else{
  1120. switch (entry.formatType){
  1121. case "numberValue":
  1122. value = this.viewSearchCustomValueNode.get("value");
  1123. break;
  1124. case "dateTimeValue":
  1125. value = this.viewSearchCustomValueNode.get("value");
  1126. break;
  1127. case "booleanValue":
  1128. var idx = this.viewSearchCustomValueNode.selectedIndex;
  1129. if (idx!==-1){
  1130. var v = this.viewSearchCustomValueNode.options[idx].get("value");
  1131. value = (v==="true");
  1132. }
  1133. break;
  1134. default:
  1135. value = this.viewSearchCustomValueNode.get("value");
  1136. }
  1137. }
  1138. if (value===""){
  1139. MWF.xDesktop.notice("error", {"x": "left", "y": "top"}, this.lp.filterErrorValue, this.viewSearchCustomValueContentNode, {"x": 0, "y": 85});
  1140. return false;
  1141. }
  1142. this.filterItems.push(new MWF.xApplication.query.Query.Viewer.Filter(this, {
  1143. "logic": "and",
  1144. "path": path,
  1145. "title": pathTitle,
  1146. "comparison": comparison,
  1147. "comparisonTitle": comparisonTitle,
  1148. "value": value,
  1149. "formatType": (entry.formatType=="datetimeValue") ? "dateTimeValue": entry.formatType
  1150. }, this.viewSearchCustomFilterContentNode));
  1151. this.searchCustomView();
  1152. }
  1153. },
  1154. searchViewRemoveFilter: function(filter){
  1155. this.filterItems.erase(filter);
  1156. filter.destroy();
  1157. this.searchCustomView()
  1158. },
  1159. //搜索相关结束
  1160. //api 使用 开始
  1161. getParentEnvironment : function(){
  1162. return this.parentMacro ? this.parentMacro.environment : null;
  1163. },
  1164. getViewInfor : function(){
  1165. return this.json;
  1166. },
  1167. getPageInfor : function(){
  1168. return {
  1169. pages : this.pages,
  1170. perPageCount : this.options.perPageCount,
  1171. currentPageNumber : this.currentPage
  1172. };
  1173. },
  1174. getPageData : function () {
  1175. return this.gridJson;
  1176. },
  1177. toPage : function( pageNumber, callback ){
  1178. this.currentPage = pageNumber;
  1179. this.loadCurrentPageData( callback );
  1180. },
  1181. getSelectedData : function(){
  1182. return this.getData();
  1183. },
  1184. getSelectAllStatus : function(){
  1185. if( this.getSelectFlag()!=="multi")return;
  1186. if( !this.items.length )return "none";
  1187. var allFlag = true, noneFlag = true;
  1188. for( var i=0; i<this.items.length; i++ ){
  1189. var item = this.items[i];
  1190. if( item.clazzType === "item" ){
  1191. item.isSelected ? ( noneFlag = false ) : (allFlag = false);
  1192. }else{
  1193. var f = item.getSelectAllStatus();
  1194. if( f === "none" ){
  1195. allFlag = false;
  1196. }else if( f === "all" ){
  1197. noneFlag = false;
  1198. }else if(f==="some"){
  1199. allFlag = false;
  1200. noneFlag = false;
  1201. }
  1202. }
  1203. if( !allFlag && !noneFlag )return "some"
  1204. }
  1205. if( allFlag )return "all";
  1206. if( noneFlag )return "none";
  1207. return "some";
  1208. },
  1209. checkSelectAllStatus : function(){
  1210. if(!this.selectAllNode)return;
  1211. var status = this.getSelectAllStatus();
  1212. if( status === "all" ){
  1213. this.setSelectAllStyle()
  1214. }else{
  1215. this.setUnSelectAllStyle()
  1216. }
  1217. },
  1218. setSelectAllStyle : function () {
  1219. if(!this.selectAllNode)return;
  1220. if( this.viewJson.viewStyles && this.viewJson.viewStyles["checkedCheckboxNode"] ){
  1221. this.selectAllNode.setStyles( this.viewJson.viewStyles["checkedCheckboxNode"] );
  1222. }else {
  1223. this.selectAllNode.getElement("img").set("src",
  1224. '../x_component_query_Query/$Viewer/" + this.options.style + "/icon/checkbox_checked.png' )
  1225. }
  1226. },
  1227. setUnSelectAllStyle : function () {
  1228. if(!this.selectAllNode)return;
  1229. if( this.viewJson.viewStyles && this.viewJson.viewStyles["checkboxNode"] ){
  1230. this.selectAllNode.setStyles( this.viewJson.viewStyles["checkboxNode"] );
  1231. }else {
  1232. this.selectAllNode.getElement("img").set("src",
  1233. '../x_component_query_Query/$Viewer/" + this.options.style + "/icon/checkbox.png' )
  1234. }
  1235. },
  1236. selectAll : function(){
  1237. // var flag = this.json.select || this.viewJson.select || "none";
  1238. if ( this.getSelectFlag()==="multi"){
  1239. this.items.each( function (item) {
  1240. if( item.clazzType === "item" ){
  1241. item.selected("view");
  1242. }else{
  1243. item.selectAll("view");
  1244. // item.expand();
  1245. // if( item.items ){
  1246. // item.items.each( function (it) {
  1247. // it.selected();
  1248. // })
  1249. // }
  1250. }
  1251. })
  1252. if( this.viewJson.allowSelectAll ) {
  1253. this.setSelectAllStyle();
  1254. }
  1255. }
  1256. },
  1257. unSelectAll : function(){
  1258. // var flag = this.json.select || this.viewJson.select || "none";
  1259. if ( this.getSelectFlag()==="multi"){
  1260. this.items.each( function (item) {
  1261. if( item.clazzType === "item" ){
  1262. item.unSelected("view");
  1263. }else{
  1264. item.unSelectAll("view");
  1265. // if(item.items){
  1266. // item.items.each( function (it) {
  1267. // it.unSelected();
  1268. // })
  1269. // }
  1270. }
  1271. })
  1272. if( this.viewJson.allowSelectAll ) {
  1273. this.setUnSelectAllStyle();
  1274. }
  1275. }
  1276. },
  1277. getExpandAllStatus: function(){
  1278. if( !this.items.length )return "none";
  1279. var allFlag = true, noneFlag = true;
  1280. for( var i=0; i<this.items.length; i++ ){
  1281. var item = this.items[i];
  1282. item.expanded ? ( noneFlag = false ) : (allFlag = false);
  1283. if( !allFlag && !noneFlag )return "some"
  1284. }
  1285. if( allFlag )return "all";
  1286. if( noneFlag )return "none";
  1287. return "some";
  1288. },
  1289. checkExpandAllStatus: function(){
  1290. if(!this.expandAllNode)return;
  1291. var status = this.getExpandAllStatus();
  1292. if( status === "all" ){
  1293. this.setExpandAllStyle()
  1294. }else{
  1295. this.setCollapseAllStyle()
  1296. }
  1297. },
  1298. setExpandAllStyle: function(){
  1299. if(!this.expandAllNode)return;
  1300. if( this.viewJson.viewStyles && this.viewJson.viewStyles["groupExpandNode"] ){
  1301. this.expandAllNode.setStyles( this.viewJson.viewStyles["groupExpandNode"] );
  1302. }else{
  1303. this.expandAllNode.set("html", "<img src='../x_component_query_Query/$Viewer/"+this.options.style+"/icon/expand.png'/>");
  1304. }
  1305. },
  1306. setCollapseAllStyle : function(){
  1307. if(!this.expandAllNode)return;
  1308. if( this.viewJson.viewStyles && this.viewJson.viewStyles["groupCollapseNode"] ){
  1309. this.expandAllNode.setStyles( this.viewJson.viewStyles["groupCollapseNode"] );
  1310. }else{
  1311. this.expandAllNode.set("html", "<img src='../x_component_query_Query/$Viewer/"+this.options.style+"/icon/down.png'/>");
  1312. }
  1313. },
  1314. expandAll: function(){
  1315. this.items.each(function(item, i){
  1316. window.setTimeout(function(){
  1317. item.expand( "view" );
  1318. }.bind(this), 10*i+5);
  1319. }.bind(this));
  1320. this.setExpandAllStyle();
  1321. },
  1322. collapseAll: function(){
  1323. this.items.each(function(item){
  1324. item.collapse( "view" );
  1325. }.bind(this));
  1326. this.setCollapseAllStyle();
  1327. },
  1328. expandOrCollapseAll: function(){
  1329. this.getExpandAllStatus() === "all" ? this.collapseAll() : this.expandAll();
  1330. // if( this.viewJson.viewStyles && this.viewJson.viewStyles["groupCollapseNode"] ){
  1331. // var span = this.expandAllNode; //this.selectTitleCell.getElement("span");
  1332. // if( this.isAllExpanded ){
  1333. // this.items.each(function(item){
  1334. // item.collapse();
  1335. // span.setStyles( this.viewJson.viewStyles["groupCollapseNode"] );
  1336. // }.bind(this));
  1337. // this.isAllExpanded = false;
  1338. // }else{
  1339. // this.items.each(function(item, i){
  1340. // window.setTimeout(function(){
  1341. // item.expand();
  1342. // }.bind(this), 10*i+5);
  1343. //
  1344. // span.setStyles( this.viewJson.viewStyles["groupExpandNode"] );
  1345. // this.isAllExpanded = true;
  1346. // }.bind(this));
  1347. // }
  1348. // }else{
  1349. // var icon = this.expandAllNode; //this.selectTitleCell.getElement("span");
  1350. // if (icon.get("html").indexOf("expand.png")===-1){
  1351. // this.items.each(function(item){
  1352. // item.collapse();
  1353. // icon.set("html", "<img src='../x_component_query_Query/$Viewer/"+this.options.style+"/icon/expand.png'/>");
  1354. // }.bind(this));
  1355. // this.isAllExpanded = false;
  1356. // }else{
  1357. // this.items.each(function(item, i){
  1358. // window.setTimeout(function(){
  1359. // item.expand();
  1360. // }.bind(this), 10*i+5);
  1361. //
  1362. // icon.set("html", "<img src='../x_component_query_Query/$Viewer/"+this.options.style+"/icon/down.png'/>");
  1363. // }.bind(this));
  1364. // this.isAllExpanded = true;
  1365. // }
  1366. // }
  1367. },
  1368. setFilter : function( filter, callback ){
  1369. if( this.lookuping || this.pageloading )return;
  1370. if( !filter )filter = [];
  1371. if( typeOf( filter ) === "object" )filter = [ filter ];
  1372. this.json.filter = filter;
  1373. if( this.viewAreaNode ){
  1374. this.createViewNode({"filterList": this.json.filter ? this.json.filter.clone() : null}, callback);
  1375. }
  1376. },
  1377. switchView : function( json ){
  1378. debugger;
  1379. // json = {
  1380. // "application": application,
  1381. // "viewName": viewName,
  1382. // "isTitle": "yes",
  1383. // "select": "none",
  1384. // "titleStyles": titleStyles,
  1385. // "itemStyles": itemStyles,
  1386. // "isExpand": "no",
  1387. // "filter": filter
  1388. // }
  1389. this.node.setStyle("display", "block");
  1390. if (this.loadingAreaNode) this.loadingAreaNode.setStyle("display", "block");
  1391. this.searchMorph = null;
  1392. this.viewSearchCustomContentNode = null;
  1393. var newJson = Object.merge( Object.clone(this.originalJson), json );
  1394. this.container.empty();
  1395. this.initialize( this.container, newJson, Object.clone(this.options), this.app, this.parentMacro);
  1396. },
  1397. confirm: function (type, e, title, text, width, height, ok, cancel, callback, mask, style) {
  1398. this.app.confirm(type, e, title, text, width, height, ok, cancel, callback, mask, style)
  1399. },
  1400. alert: function (type, title, text, width, height) {
  1401. this.app.alert(type, "center", title, text, width, height);
  1402. },
  1403. notice: function (content, type, target, where, offset, option) {
  1404. this.app.notice(content, type, target, where, offset, option)
  1405. }
  1406. //api 使用 结束
  1407. });
  1408. MWF.xApplication.query.Query.Viewer.Item = new Class({
  1409. initialize: function(view, data, prev, i, category){
  1410. this.view = view;
  1411. this.data = data;
  1412. this.css = this.view.css;
  1413. this.isSelected = false;
  1414. this.category = category;
  1415. this.prev = prev;
  1416. this.idx = i;
  1417. this.clazzType = "item";
  1418. this.load();
  1419. },
  1420. load: function(){
  1421. this.view.fireEvent("queryLoadItemRow", [null, this]);
  1422. var viewStyles = this.view.viewJson.viewStyles;
  1423. var viewContentTdNode = ( viewStyles && viewStyles["contentTd"] ) ? viewStyles["contentTd"] : this.css.viewContentTdNode;
  1424. this.node = new Element("tr", {
  1425. "styles": ( viewStyles && viewStyles["contentTr"] ) ? viewStyles["contentTr"] : this.css.viewContentTrNode
  1426. });
  1427. if (this.prev){
  1428. this.node.inject(this.prev.node, "after");
  1429. }else{
  1430. this.node.inject(this.view.viewTable);
  1431. }
  1432. //if (this.view.json.select==="single" || this.view.json.select==="multi"){
  1433. this.selectTd = new Element("td", { "styles": viewContentTdNode }).inject(this.node);
  1434. this.selectTd.setStyles({"cursor": "pointer"});
  1435. if (this.view.json.itemStyles) this.selectTd.setStyles(this.view.json.itemStyles);
  1436. //var selectFlag = this.view.json.select || this.view.viewJson.select || "none";
  1437. var selectFlag = this.view.getSelectFlag();
  1438. if ( ["multi","single"].contains(selectFlag) && this.view.viewJson.selectBoxShow==="always") {
  1439. var viewStyles = this.view.viewJson.viewStyles;
  1440. if (viewStyles) {
  1441. if (selectFlag === "single") {
  1442. this.selectTd.setStyles(viewStyles["radioNode"]);
  1443. } else {
  1444. this.selectTd.setStyles(viewStyles["checkboxNode"]);
  1445. }
  1446. } else {
  1447. var iconName = "checkbox";
  1448. if (selectFlag === "single") iconName = "radiobox";
  1449. this.selectTd.setStyles({"background": "url(" + "../x_component_query_Query/$Viewer/default/icon/" + iconName + ".png) center center no-repeat"});
  1450. }
  1451. }
  1452. if( this.view.isSelectTdHidden() ){
  1453. this.selectTd.hide();
  1454. }
  1455. //}
  1456. //序号
  1457. if (this.view.viewJson.isSequence==="yes"){
  1458. this.sequenceTd = new Element("td", {"styles": viewContentTdNode}).inject(this.node);
  1459. this.sequenceTd.setStyle("width", "10px");
  1460. var s= 1+this.view.json.pageSize*(this.view.currentPage-1)+this.idx;
  1461. this.sequenceTd.set("text", s);
  1462. }
  1463. debugger;
  1464. Object.each(this.view.entries, function(c, k){
  1465. var cell = this.data.data[k];
  1466. if (cell === undefined) cell = "";
  1467. //if (cell){
  1468. if (this.view.hideColumns.indexOf(k)===-1){
  1469. var td = new Element("td", {"styles": viewContentTdNode}).inject(this.node);
  1470. if (k!== this.view.viewJson.group.column){
  1471. //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;
  1472. var v = cell;
  1473. if (c.isHtml){
  1474. td.set("html", v);
  1475. }else{
  1476. td.set("text", v);
  1477. }
  1478. if( typeOf(c.contentProperties) === "object" )td.setProperties(c.contentProperties);
  1479. if (this.view.json.itemStyles) td.setStyles(this.view.json.itemStyles);
  1480. if( typeOf(c.contentStyles) === "object" )td.setStyles(c.contentStyles);
  1481. }else{
  1482. if (this.view.json.itemStyles) td.setStyles(this.view.json.itemStyles);
  1483. }
  1484. if (this.view.openColumns.indexOf(k)!==-1){
  1485. this.setOpenWork(td, c)
  1486. }
  1487. if (k!== this.view.viewJson.group.column){
  1488. Object.each( c.events || {}, function (e , key) {
  1489. if(e.code){
  1490. if( key === "loadContent" ){
  1491. this.view.Macro.fire( e.code,
  1492. {"node" : td, "json" : c, "data" : v, "view": this.view, "row" : this});
  1493. }else if( key !== "loadTitle" ){
  1494. td.addEvent(key, function(event){
  1495. return this.view.Macro.fire(
  1496. e.code,
  1497. {"node" : td, "json" : c, "data" : v, "view": this.view, "row" : this},
  1498. event
  1499. );
  1500. }.bind(this));
  1501. }
  1502. }
  1503. }.bind(this));
  1504. }
  1505. }
  1506. //}
  1507. }.bind(this));
  1508. //默认选中
  1509. var defaultSelectedScript = this.view.json.defaultSelectedScript || this.view.viewJson.defaultSelectedScript;
  1510. if( !this.isSelected && defaultSelectedScript ){
  1511. // var flag = this.view.json.select || this.view.viewJson.select || "none";
  1512. // if ( flag ==="single" || flag==="multi"){
  1513. //
  1514. // }
  1515. var flag = this.view.Macro.exec( defaultSelectedScript,
  1516. {"node" : this.node, "data" : this.data, "view": this.view, "row" : this});
  1517. if( flag ){
  1518. if( flag === "multi" || flag === "single" ){
  1519. this.select( flag );
  1520. }else if( flag.toString() === "true" ){
  1521. var f = this.view.json.select || this.view.viewJson.select || "none";
  1522. if ( f ==="single" || f==="multi"){
  1523. this.select();
  1524. }
  1525. }
  1526. }
  1527. }
  1528. // Object.each(this.data.data, function(cell, k){
  1529. // if (this.view.hideColumns.indexOf(k)===-1){
  1530. // var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(this.node);
  1531. // if (k!== this.view.viewJson.group.column){
  1532. // 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;
  1533. // td.set("text", v);
  1534. // }
  1535. // if (this.view.openColumns.indexOf(k)!==-1){
  1536. // this.setOpenWork(td)
  1537. // }
  1538. // if (this.view.json.itemStyles) td.setStyles(this.view.json.itemStyles);
  1539. // }
  1540. // }.bind(this));
  1541. this.setEvent();
  1542. this.view.fireEvent("postLoadItemRow", [null, this]);
  1543. },
  1544. setOpenWork: function(td, column){
  1545. td.setStyle("cursor", "pointer");
  1546. if( column.clickCode ){
  1547. // if( !this.view.Macro ){
  1548. // MWF.require("MWF.xScript.Macro", function () {
  1549. // this.view.businessData = {};
  1550. // this.view.Macro = new MWF.Macro.PageContext(this.view);
  1551. // }.bind(this), false);
  1552. // }
  1553. td.addEvent("click", function( ev ){
  1554. var result = this.view.Macro.fire(column.clickCode, this, ev);
  1555. ev.stopPropagation();
  1556. return result;
  1557. }.bind(this));
  1558. }else{
  1559. if (this.view.json.type==="cms"){
  1560. td.addEvent("click", function(ev){
  1561. this.openCms(ev)
  1562. ev.stopPropagation();
  1563. }.bind(this));
  1564. }else{
  1565. td.addEvent("click", function(ev){
  1566. this.openWorkAndCompleted(ev)
  1567. ev.stopPropagation();
  1568. }.bind(this));
  1569. }
  1570. }
  1571. },
  1572. openCms: function(e){
  1573. var options = {"documentId": this.data.bundle};
  1574. this.view.fireEvent("openDocument", [options, this]); //options 传入的事件
  1575. layout.desktop.openApplication(e, "cms.Document", options);
  1576. },
  1577. openWorkAndCompleted: function(e){
  1578. MWF.Actions.get("x_processplatform_assemble_surface").listWorkByJob(this.data.bundle, function(json){
  1579. var workCompletedCount = json.data.workCompletedList.length;
  1580. var workCount = json.data.workList.length;
  1581. var count = workCount+workCompletedCount;
  1582. if (count===1){
  1583. if (workCompletedCount) {
  1584. this.openWorkCompleted(json.data.workCompletedList[0].id, e);
  1585. }else{
  1586. this.openWork(json.data.workList[0].id, e);
  1587. }
  1588. }else if (count>1){
  1589. var worksAreaNode = this.createWorksArea();
  1590. json.data.workCompletedList.each(function(work){
  1591. this.createWorkCompletedNode(work, worksAreaNode);
  1592. }.bind(this));
  1593. json.data.workList.each(function(work){
  1594. this.createWorkNode(work, worksAreaNode);
  1595. }.bind(this));
  1596. this.showWorksArea(worksAreaNode, e);
  1597. }else{
  1598. }
  1599. }.bind(this));
  1600. },
  1601. createWorkNode: function(work, worksAreaNode){
  1602. var worksAreaContentNode = worksAreaNode.getLast();
  1603. var node = new Element("div", {"styles": this.css.workAreaNode}).inject(worksAreaContentNode);
  1604. var actionNode = new Element("div", {"styles": this.css.workAreaActionNode, "text": this.view.lp.open}).inject(node);
  1605. actionNode.store("workId", work.id);
  1606. actionNode.addEvent("click", function(e){
  1607. this.openWork(e.target.retrieve("workId"), e);
  1608. this.mask.hide();
  1609. worksAreaNode.destroy();
  1610. }.bind(this));
  1611. var areaNode = new Element("div", {"styles": this.css.workAreaLeftNode}).inject(node);
  1612. var titleNode = new Element("div", {"styles": this.css.workAreaTitleNode, "text": work.title}).inject(areaNode);
  1613. var contentNode = new Element("div", {"styles": this.css.workAreaContentNode}).inject(areaNode);
  1614. new Element("div", {"styles": this.css.workAreaContentTitleNode, "text": this.view.lp.activity+": "}).inject(contentNode);
  1615. new Element("div", {"styles": this.css.workAreaContentTextNode, "text": work.activityName}).inject(contentNode);
  1616. var taskUsers = [];
  1617. MWF.Actions.get("x_processplatform_assemble_surface").listTaskByWork(work.id, function(json){
  1618. json.data.each(function(task){
  1619. taskUsers.push(MWF.name.cn(task.person));
  1620. }.bind(this));
  1621. new Element("div", {"styles": this.css.workAreaContentTitleNode, "text": this.view.lp.taskPeople+": "}).inject(contentNode);
  1622. new Element("div", {"styles": this.css.workAreaContentTextNode, "text": taskUsers.join(", ")}).inject(contentNode);
  1623. }.bind(this));
  1624. },
  1625. createWorkCompletedNode: function(work, worksAreaNode){
  1626. var worksAreaContentNode = worksAreaNode.getLast();
  1627. var node = new Element("div", {"styles": this.css.workAreaNode}).inject(worksAreaContentNode);
  1628. var actionNode = new Element("div", {"styles": this.css.workAreaActionNode, "text": this.view.lp.open}).inject(node);
  1629. actionNode.store("workId", work.id);
  1630. actionNode.addEvent("click", function(e){
  1631. this.mask.hide();
  1632. var id = e.target.retrieve("workId");
  1633. worksAreaNode.destroy();
  1634. this.openWorkCompleted(id, e);
  1635. }.bind(this));
  1636. var areaNode = new Element("div", {"styles": this.css.workAreaLeftNode}).inject(node);
  1637. var titleNode = new Element("div", {"styles": this.css.workAreaTitleNode, "text": work.title}).inject(areaNode);
  1638. var contentNode = new Element("div", {"styles": this.css.workAreaContentNode}).inject(areaNode);
  1639. new Element("div", {"styles": this.css.workAreaContentTitleNode, "text": this.view.lp.activity+": "}).inject(contentNode);
  1640. new Element("div", {"styles": this.css.workAreaContentTextNode, "text": this.view.lp.processCompleted}).inject(contentNode);
  1641. },
  1642. createWorksArea: function(){
  1643. var worksAreaNode = new Element("div", {"styles": this.css.worksAreaNode});
  1644. var worksAreaTitleNode = new Element("div", {"styles": this.css.worksAreaTitleNode}).inject(worksAreaNode);
  1645. var worksAreaTitleCloseNode = new Element("div", {"styles": this.css.worksAreaTitleCloseNode}).inject(worksAreaTitleNode);
  1646. worksAreaTitleCloseNode.addEvent("click", function(e){
  1647. this.mask.hide();
  1648. e.target.getParent().getParent().destroy();
  1649. }.bind(this));
  1650. var worksAreaContentNode = new Element("div", {"styles": this.css.worksAreaContentNode}).inject(worksAreaNode);
  1651. return worksAreaNode;
  1652. },
  1653. showWorksArea: function(node, e){
  1654. MWF.require("MWF.widget.Mask", null, false);
  1655. this.mask = new MWF.widget.Mask({"style": "desktop", "loading": false});
  1656. this.mask.loadNode(this.view.container);
  1657. node.inject(this.view.node);
  1658. this.setWorksAreaPosition(node, e.target);
  1659. },
  1660. setWorksAreaPosition: function(node, td){
  1661. var p = td.getPosition(this.view.container);
  1662. var containerS = this.view.container.getSize();
  1663. var containerP = this.view.container.getPosition(this.view.container.getOffsetParent());
  1664. var s = node.getSize();
  1665. var offX = p.x+s.x-containerS.x;
  1666. offX = (offX>0) ? offX+20 : 0;
  1667. var offY = p.y+s.y-containerS.y;
  1668. offY = (offY>0) ? offY+5 : 0;
  1669. node.position({
  1670. "relativeTo": td,
  1671. "position": "lefttop",
  1672. "edge": "lefttop",
  1673. "offset": {
  1674. "x": 0-offX,
  1675. "y": 0-offY
  1676. }
  1677. });
  1678. },
  1679. openWork: function(id, e){
  1680. var options = {"workId": id};
  1681. this.view.fireEvent("openDocument", [options, this]); //options 传入的事件
  1682. layout.desktop.openApplication(e, "process.Work", options);
  1683. },
  1684. openWorkCompleted: function(id, e){
  1685. var options = {"workCompletedId": id};
  1686. this.view.fireEvent("openDocument", [options, this]); //options 传入的事件
  1687. layout.desktop.openApplication(e, "process.Work", options);
  1688. },
  1689. setEvent: function(){
  1690. var flag = this.view.getSelectFlag();
  1691. if ( flag ==="single" || flag==="multi"){
  1692. this.node.addEvents({
  1693. "mouseover": function(){
  1694. if (!this.isSelected && this.view.viewJson.selectBoxShow !=="always" ){
  1695. var viewStyles = this.view.viewJson.viewStyles;
  1696. if( viewStyles ){
  1697. if( flag === "single" ){
  1698. this.selectTd.setStyles( viewStyles["radioNode"] );
  1699. }else{
  1700. this.selectTd.setStyles( viewStyles["checkboxNode"] );
  1701. }
  1702. }else{
  1703. var iconName = "checkbox";
  1704. if (flag==="single") iconName = "radiobox";
  1705. this.selectTd.setStyles({"background": "url("+"../x_component_query_Query/$Viewer/default/icon/"+iconName+".png) center center no-repeat"});
  1706. }
  1707. }
  1708. }.bind(this),
  1709. "mouseout": function(){
  1710. if (!this.isSelected && this.view.viewJson.selectBoxShow !=="always") this.selectTd.setStyles({"background": "transparent"});
  1711. }.bind(this),
  1712. "click": function(){this.select();}.bind(this)
  1713. });
  1714. }
  1715. },
  1716. select: function( force ){
  1717. // var flag = force || this.view.json.select || this.view.viewJson.select || "none";
  1718. var flag = force || this.view.getSelectFlag();
  1719. if (this.isSelected){
  1720. if (flag==="single"){
  1721. this.unSelectedSingle();
  1722. }else{
  1723. this.unSelected();
  1724. }
  1725. }else{
  1726. if (flag==="single"){
  1727. this.selectedSingle();
  1728. }else{
  1729. this.selected();
  1730. }
  1731. }
  1732. this.view.fireEvent("select"); //options 传入的事件
  1733. },
  1734. selected: function( from ){
  1735. this.view.selectedItems.push(this);
  1736. var viewStyles = this.view.viewJson.viewStyles;
  1737. if( viewStyles ){
  1738. this.selectTd.setStyles( viewStyles["checkedCheckboxNode"] );
  1739. this.node.setStyles( viewStyles["contentSelectedTr"] );
  1740. }else{
  1741. this.selectTd.setStyles({"background": "url("+"../x_component_query_Query/$Viewer/default/icon/checkbox_checked.png) center center no-repeat"});
  1742. this.node.setStyles(this.css.viewContentTrNode_selected);
  1743. }
  1744. this.isSelected = true;
  1745. if( from !== "view" && from !=="category" && this.view.viewJson.allowSelectAll ){
  1746. this.view.checkSelectAllStatus();
  1747. if( this.category )this.category.checkSelectAllStatus();
  1748. }
  1749. this.view.fireEvent("selectRow", [this]);
  1750. },
  1751. unSelected: function( from ){
  1752. this.view.selectedItems.erase(this);
  1753. var viewStyles = this.view.viewJson.viewStyles;
  1754. if( this.view.viewJson.selectBoxShow !=="always" ){
  1755. this.selectTd.setStyles({"background": "transparent"});
  1756. }else{
  1757. if (viewStyles) {
  1758. this.selectTd.setStyles(viewStyles["checkboxNode"]);
  1759. }else{
  1760. this.selectTd.setStyles({"background": "url(" + "../x_component_query_Query/$Viewer/default/icon/checkbox.png) center center no-repeat"});
  1761. }
  1762. }
  1763. if( viewStyles ){
  1764. this.node.setStyles( viewStyles["contentTr"] );
  1765. }else{
  1766. this.node.setStyles(this.css.viewContentTrNode);
  1767. }
  1768. this.isSelected = false;
  1769. if( from !== "view" && from !=="category" && this.view.viewJson.allowSelectAll ){
  1770. this.view.checkSelectAllStatus();
  1771. if( this.category )this.category.checkSelectAllStatus();
  1772. }
  1773. this.view.fireEvent("unselectRow", [this]);
  1774. },
  1775. selectedSingle: function(){
  1776. if (this.view.currentSelectedItem) this.view.currentSelectedItem.unSelectedSingle();
  1777. this.view.selectedItems = [this];
  1778. this.view.currentSelectedItem = this;
  1779. var viewStyles = this.view.viewJson.viewStyles;
  1780. if( viewStyles ){
  1781. this.selectTd.setStyles( viewStyles["checkedRadioNode"] );
  1782. this.node.setStyles( viewStyles["contentSelectedTr"] );
  1783. }else {
  1784. this.selectTd.setStyles({"background": "url(" + "../x_component_query_Query/$Viewer/default/icon/radiobox_checked.png) center center no-repeat"});
  1785. this.node.setStyles(this.css.viewContentTrNode_selected);
  1786. }
  1787. this.isSelected = true;
  1788. this.view.fireEvent("selectRow", [this]);
  1789. },
  1790. unSelectedSingle: function(){
  1791. this.view.selectedItems = [];
  1792. this.view.currentSelectedItem = null;
  1793. var viewStyles = this.view.viewJson.viewStyles;
  1794. if( this.view.viewJson.selectBoxShow !=="always" ){
  1795. this.selectTd.setStyles({"background": "transparent"});
  1796. }else{
  1797. if (viewStyles) {
  1798. this.selectTd.setStyles(viewStyles["radioNode"]);
  1799. }else{
  1800. this.selectTd.setStyles({"background": "url(" + "../x_component_query_Query/$Viewer/default/icon/radiobox.png) center center no-repeat"});
  1801. }
  1802. }
  1803. if( viewStyles ){
  1804. this.node.setStyles( viewStyles["contentTr"] );
  1805. }else{
  1806. this.node.setStyles(this.css.viewContentTrNode);
  1807. }
  1808. this.isSelected = false;
  1809. this.view.fireEvent("unselectRow", [this]);
  1810. }
  1811. });
  1812. MWF.xApplication.query.Query.Viewer.ItemCategory = new Class({
  1813. initialize: function(view, data, i){
  1814. this.view = view;
  1815. this.data = data;
  1816. this.css = this.view.css;
  1817. this.items = [];
  1818. this.loadChild = false;
  1819. this.idx = i;
  1820. this.clazzType = "category";
  1821. this.load();
  1822. },
  1823. load: function(){
  1824. this.view.fireEvent("queryLoadCategoryRow", [null, this]);
  1825. var viewStyles = this.view.viewJson.viewStyles;
  1826. var viewContentCategoryTdNode = ( viewStyles && viewStyles["contentGroupTd"] ) ? viewStyles["contentGroupTd"] : this.css.viewContentCategoryTdNode;
  1827. this.node = new Element("tr", {
  1828. "styles": (viewStyles && viewStyles["contentTr"]) ? viewStyles["contentTr"] : this.css.viewContentTrNode
  1829. }).inject(this.view.viewTable);
  1830. //if (this.view.json.select==="single" || this.view.json.select==="multi"){
  1831. this.selectTd = new Element("td", {"styles": viewContentCategoryTdNode}).inject(this.node);
  1832. if (this.view.json.itemStyles) this.selectTd.setStyles(this.view.json.itemStyles);
  1833. if( this.view.getSelectFlag() === "multi" && this.view.viewJson.allowSelectAll ){
  1834. this.selectAllNode = this.selectTd;
  1835. if( viewStyles && viewStyles["checkboxNode"] ){
  1836. this.selectAllNode.setStyles( viewStyles["checkboxNode"] )
  1837. // this.selectAllNode = new Element("span", {
  1838. // styles : viewStyles["checkboxNode"]
  1839. // }).inject( this.selectTd );
  1840. }else{
  1841. this.selectAllNode.set( "html", "<img src='../x_component_query_Query/$Viewer/"+this.options.style+"/icon/checkbox.png'/>"+"</span>" )
  1842. // this.selectAllNode = new Element("span",{
  1843. // html : "<img src='../x_component_query_Query/$Viewer/"+this.options.style+"/icon/checkbox.png'/>"+"</span>",
  1844. // style : "font-family: Webdings"
  1845. // }).inject( this.selectTd );
  1846. }
  1847. this.selectAllNode.setStyle("cursor", "pointer");
  1848. this.selectAllNode.addEvent("click", function (ev) {
  1849. if( this.getSelectAllStatus() === "all" ){
  1850. this.unSelectAll("category")
  1851. }else{
  1852. this.selectAll("category");
  1853. }
  1854. ev.stopPropagation();
  1855. }.bind(this));
  1856. }
  1857. // if( this.view.isSelectTdHidden() ){
  1858. // this.selectTd.hide();
  1859. // }
  1860. //}
  1861. this.categoryTd = new Element("td", {
  1862. "styles": viewContentCategoryTdNode,
  1863. "colspan": this.view.viewJson.selectList.length+1
  1864. }).inject(this.node);
  1865. this.groupColumn = null;
  1866. for (var c = 0; c<this.view.viewJson.selectList.length; c++){
  1867. if (this.view.viewJson.selectList[c].column === this.view.viewJson.group.column){
  1868. this.groupColumn = this.view.viewJson.selectList[c];
  1869. break;
  1870. }
  1871. }
  1872. if (this.groupColumn){
  1873. //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;
  1874. var text = this.data.group;
  1875. }else{
  1876. var text = this.data.group;
  1877. }
  1878. if( viewStyles && viewStyles["groupCollapseNode"] ){
  1879. this.expandNode = new Element("span", {
  1880. styles : viewStyles["groupCollapseNode"]
  1881. }).inject( this.categoryTd );
  1882. new Element("span", { text : text }).inject( this.categoryTd );
  1883. // this.categoryTd.set("text", text );
  1884. }else{
  1885. 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);
  1886. }
  1887. this.expanded = false;
  1888. if (this.view.json.itemStyles) this.categoryTd.setStyles(this.view.json.itemStyles);
  1889. debugger;
  1890. if( this.groupColumn ){
  1891. if( typeOf(this.groupColumn.contentStyles) === "object" )this.categoryTd.setStyles(this.groupColumn.contentStyles);
  1892. if( typeOf(this.groupColumn.contentProperties) === "object" )this.categoryTd.setProperties(this.groupColumn.contentProperties);
  1893. }
  1894. this.setEvent();
  1895. var column = this.groupColumn;
  1896. var td = this.categoryTd;
  1897. Object.each( column.events || {}, function (e , key) {
  1898. if(e.code){
  1899. if( key === "loadContent" ){
  1900. this.view.Macro.fire( e.code,
  1901. {"node" : td, "json" : column, "data" : this.data.group, "view": this.view, "row" : this});
  1902. }else if( key !== "loadTitle" ){
  1903. td.addEvent(key, function(event){
  1904. return this.view.Macro.fire(
  1905. e.code,
  1906. {"node" : td, "json" : column, "data" : this.data.group, "view": this.view, "row" : this},
  1907. event
  1908. );
  1909. }.bind(this));
  1910. }
  1911. }
  1912. }.bind(this));
  1913. this.view.fireEvent("postLoadCategoryRow", [null, this]);
  1914. },
  1915. getSelectAllStatus : function(){
  1916. if ( this.view.getSelectFlag()!=="multi")return;
  1917. if( !this.items.length )return "none";
  1918. var flag = "all";
  1919. var allFlag = true, noneFlag = true;
  1920. for( var i=0; i<this.items.length; i++ ){
  1921. var item = this.items[i];
  1922. item.isSelected ? ( noneFlag = false ) : (allFlag = false);
  1923. if( !allFlag && !noneFlag )return "some"
  1924. }
  1925. if( allFlag )return "all";
  1926. if( noneFlag )return "none";
  1927. return "some";
  1928. },
  1929. checkSelectAllStatus : function(){
  1930. if( !this.selectAllNode )return;
  1931. var status = this.getSelectAllStatus();
  1932. if( status === "all" ){
  1933. this.setSelectAllStyle()
  1934. }else{
  1935. this.setUnSelectAllStyle()
  1936. }
  1937. },
  1938. setSelectAllStyle : function () {
  1939. if( !this.selectAllNode )return;
  1940. if( this.view.viewJson.viewStyles && this.view.viewJson.viewStyles["checkedCheckboxNode"] ){
  1941. this.selectAllNode.setStyles( this.view.viewJson.viewStyles["checkedCheckboxNode"] );
  1942. }else {
  1943. this.selectAllNode.getElement("img").set("src",
  1944. '../x_component_query_Query/$Viewer/" + this.options.style + "/icon/checkbox_checked.png' )
  1945. }
  1946. },
  1947. setUnSelectAllStyle : function () {
  1948. if( !this.selectAllNode )return;
  1949. if( this.view.viewJson.viewStyles && this.view.viewJson.viewStyles["checkboxNode"] ){
  1950. this.selectAllNode.setStyles( this.view.viewJson.viewStyles["checkboxNode"] );
  1951. }else {
  1952. this.selectAllNode.getElement("img").set("src",
  1953. '../x_component_query_Query/$Viewer/" + this.options.style + "/icon/checkbox.png' )
  1954. }
  1955. },
  1956. selectAll : function( from ){
  1957. // var flag = this.json.select || this.viewJson.select || "none";
  1958. if ( this.view.getSelectFlag()==="multi"){
  1959. this.expand();
  1960. this.items.each( function (item) {
  1961. item.selected( from );
  1962. })
  1963. if( this.view.viewJson.allowSelectAll ){
  1964. this.setSelectAllStyle();
  1965. if( from !== "view" ){
  1966. this.view.checkSelectAllStatus();
  1967. }
  1968. }
  1969. }
  1970. },
  1971. unSelectAll : function( from ){
  1972. // var flag = this.json.select || this.viewJson.select || "none";
  1973. if ( this.view.getSelectFlag()==="multi"){
  1974. this.items.each( function (item) {
  1975. item.unSelected( from );
  1976. })
  1977. if( this.view.viewJson.allowSelectAll ) {
  1978. this.setUnSelectAllStyle();
  1979. if (from !== "view") {
  1980. this.view.checkSelectAllStatus();
  1981. }
  1982. }
  1983. }
  1984. },
  1985. setEvent: function(){
  1986. //if (this.selectTd){
  1987. this.node.addEvents({
  1988. "click": function(){this.expandOrCollapse();}.bind(this)
  1989. });
  1990. //}
  1991. },
  1992. expandOrCollapse: function(){
  1993. // var t = this.node.getElement("span").get("html");
  1994. // if (t.indexOf("expand.png")===-1){
  1995. // this.collapse();
  1996. // }else{
  1997. // this.expand();
  1998. // }
  1999. if( this.expanded ){
  2000. this.collapse();
  2001. }else{
  2002. this.expand();
  2003. }
  2004. },
  2005. collapse: function( from ){
  2006. this.items.each(function(item){
  2007. item.node.setStyle("display", "none");
  2008. }.bind(this));
  2009. if( this.expandNode ){
  2010. this.expandNode.setStyles( this.view.viewJson.viewStyles["groupCollapseNode"] )
  2011. }else{
  2012. this.node.getElement("span").set("html", "<img src='../x_component_query_Query/$Viewer/"+this.view.options.style+"/icon/expand.png'/>");
  2013. }
  2014. this.expanded = false;
  2015. if( from !== "view" ){
  2016. this.view.checkExpandAllStatus();
  2017. }
  2018. },
  2019. expand: function( from ){
  2020. this.items.each(function(item){
  2021. item.node.setStyle("display", "table-row");
  2022. }.bind(this));
  2023. if( this.expandNode ){
  2024. this.expandNode.setStyles( this.view.viewJson.viewStyles["groupExpandNode"] )
  2025. }else{
  2026. this.node.getElement("span").set("html", "<img src='../x_component_query_Query/$Viewer/"+this.view.options.style+"/icon/down.png'/>");
  2027. }
  2028. this.expanded = true;
  2029. if (!this.loadChild){
  2030. //window.setTimeout(function(){
  2031. this.data.list.each(function(line, i){
  2032. var s = this.idx+i;
  2033. this.lastItem = new MWF.xApplication.query.Query.Viewer.Item(this.view, line, (this.lastItem || this), s, this);
  2034. this.items.push(this.lastItem);
  2035. }.bind(this));
  2036. this.loadChild = true;
  2037. //}.bind(this), 10);
  2038. }
  2039. if( from !== "view" ){
  2040. this.view.checkExpandAllStatus();
  2041. }
  2042. }
  2043. });
  2044. MWF.xApplication.query.Query.Viewer.Filter = new Class({
  2045. initialize: function(viewer, data, node){
  2046. this.viewer = viewer;
  2047. this.data = data;
  2048. this.css = this.viewer.css;
  2049. this.content = node;
  2050. this.load();
  2051. },
  2052. load: function(){
  2053. this.node = new Element("div", {"styles": this.css.viewSearchFilterNode}).inject(this.content);
  2054. if (this.viewer.filterItems.length){
  2055. this.logicNode = new Element("div", {"styles": this.css.viewSearchFilterSelectAreaNode}).inject(this.node);
  2056. this.logicSelectNode = new Element("div", {
  2057. "styles": this.css.viewSearchFilterSelectNode,
  2058. "text": this.viewer.lp.and,
  2059. "value": "and"
  2060. }).inject(this.logicNode);
  2061. this.logicSelectButtonNode = new Element("div", {"styles": this.css.viewSearchFilterSelectButtonNode}).inject(this.logicNode);
  2062. this.logicNode.addEvents({
  2063. "click": function(){
  2064. var v = this.logicSelectNode.get("value");
  2065. if (v==="and"){
  2066. this.logicSelectButtonNode.setStyle("float", "left");
  2067. this.logicSelectNode.setStyle("float", "right");
  2068. this.logicSelectNode.set({
  2069. "text": this.viewer.lp.or,
  2070. "value": "or"
  2071. });
  2072. this.data.logic = "or";
  2073. }else{
  2074. this.logicSelectButtonNode.setStyle("float", "right");
  2075. this.logicSelectNode.setStyle("float", "left");
  2076. this.logicSelectNode.set({
  2077. "text": this.viewer.lp.and,
  2078. "value": "and"
  2079. });
  2080. this.data.logic = "and";
  2081. }
  2082. this.viewer.searchCustomView();
  2083. }.bind(this)
  2084. });
  2085. }
  2086. this.titleNode = new Element("div", {"styles": this.css.viewSearchFilterTextNode, "text": this.data.title}).inject(this.node);
  2087. this.comparisonTitleNode = new Element("div", {"styles": this.css.viewSearchFilterTextNode, "text": this.data.comparisonTitle}).inject(this.node);
  2088. this.valueNode = new Element("div", {"styles": this.css.viewSearchFilterTextNode, "text": "\""+this.data.value+"\""}).inject(this.node);
  2089. this.deleteNode = new Element("div", {"styles": this.css.viewSearchFilterDeleteNode}).inject(this.node);
  2090. this.node.addEvents({
  2091. "mouseover": function(){
  2092. this.node.setStyles(this.css.viewSearchFilterNode_over);
  2093. this.deleteNode.setStyles(this.css.viewSearchFilterDeleteNode_over);
  2094. }.bind(this),
  2095. "mouseout": function(){
  2096. this.node.setStyles(this.css.viewSearchFilterNode);
  2097. this.deleteNode.setStyles(this.css.viewSearchFilterDeleteNode);
  2098. }.bind(this)
  2099. });
  2100. this.deleteNode.addEvent("click", function(){
  2101. this.viewer.searchViewRemoveFilter(this);
  2102. }.bind(this));
  2103. },
  2104. destroy: function(){
  2105. this.node.destroy();
  2106. MWF.release(this);
  2107. }
  2108. });
  2109. MWF.xApplication.query.Query.Viewer.Actionbar = new Class({
  2110. Implements: [Events],
  2111. options: {
  2112. "style" : "default",
  2113. "moduleEvents": ["load", "queryLoad", "postLoad", "afterLoad"]
  2114. },
  2115. initialize: function(node, json, form, options){
  2116. this.node = $(node);
  2117. this.node.store("module", this);
  2118. this.json = json;
  2119. this.form = form;
  2120. this.view = form;
  2121. },
  2122. hide: function(){
  2123. var dsp = this.node.getStyle("display");
  2124. if (dsp!=="none") this.node.store("mwf_display", dsp);
  2125. this.node.setStyle("display", "none");
  2126. },
  2127. show: function(){
  2128. var dsp = this.node.retrieve("mwf_display", dsp);
  2129. this.node.setStyle("display", dsp);
  2130. },
  2131. load: function(){
  2132. this._loadModuleEvents();
  2133. if (this.fireEvent("queryLoad")){
  2134. //this._queryLoaded();
  2135. this._loadUserInterface();
  2136. this._loadStyles();
  2137. this._loadDomEvents();
  2138. //this._loadEvents();
  2139. //this._afterLoaded();
  2140. this.fireEvent("postLoad");
  2141. this.fireEvent("load");
  2142. }
  2143. },
  2144. _loadStyles: function(){
  2145. if (this.json.styles) Object.each(this.json.styles, function(value, key){
  2146. if ((value.indexOf("x_processplatform_assemble_surface")!=-1 || value.indexOf("x_portal_assemble_surface")!=-1 || value.indexOf("x_cms_assemble_control")!=-1)){
  2147. var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface");
  2148. var host2 = MWF.Actions.getHost("x_portal_assemble_surface");
  2149. var host3 = MWF.Actions.getHost("x_cms_assemble_control");
  2150. if (value.indexOf("/x_processplatform_assemble_surface")!==-1){
  2151. value = value.replace("/x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  2152. }else if (value.indexOf("x_processplatform_assemble_surface")!==-1){
  2153. value = value.replace("x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  2154. }
  2155. if (value.indexOf("/x_portal_assemble_surface")!==-1){
  2156. value = value.replace("/x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  2157. }else if (value.indexOf("x_portal_assemble_surface")!==-1){
  2158. value = value.replace("x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  2159. }
  2160. if (value.indexOf("/x_cms_assemble_control")!==-1){
  2161. value = value.replace("/x_cms_assemble_control", host3+"/x_cms_assemble_control");
  2162. }else if (value.indexOf("x_cms_assemble_control")!==-1){
  2163. value = value.replace("x_cms_assemble_control", host3+"/x_cms_assemble_control");
  2164. }
  2165. }
  2166. this.node.setStyle(key, value);
  2167. }.bind(this));
  2168. // if (["x_processplatform_assemble_surface", "x_portal_assemble_surface"].indexOf(root.toLowerCase())!==-1){
  2169. // var host = MWF.Actions.getHost(root);
  2170. // return (flag==="/") ? host+this.json.template : host+"/"+this.json.template
  2171. // }
  2172. //if (this.json.styles) this.node.setStyles(this.json.styles);
  2173. },
  2174. _loadModuleEvents : function(){
  2175. Object.each(this.json.events, function(e, key){
  2176. if (e.code){
  2177. if (this.options.moduleEvents.indexOf(key)!==-1){
  2178. this.addEvent(key, function(event){
  2179. return this.form.Macro.fire(e.code, this, event);
  2180. }.bind(this));
  2181. }
  2182. }
  2183. }.bind(this));
  2184. },
  2185. _loadDomEvents: function(){
  2186. Object.each(this.json.events, function(e, key){
  2187. if (e.code){
  2188. if (this.options.moduleEvents.indexOf(key)===-1){
  2189. this.node.addEvent(key, function(event){
  2190. return this.form.Macro.fire(e.code, this, event);
  2191. }.bind(this));
  2192. }
  2193. }
  2194. }.bind(this));
  2195. },
  2196. _loadEvents: function(){
  2197. Object.each(this.json.events, function(e, key){
  2198. if (e.code){
  2199. if (this.options.moduleEvents.indexOf(key)!==-1){
  2200. this.addEvent(key, function(event){
  2201. return this.form.Macro.fire(e.code, this, event);
  2202. }.bind(this));
  2203. }else{
  2204. this.node.addEvent(key, function(event){
  2205. return this.form.Macro.fire(e.code, this, event);
  2206. }.bind(this));
  2207. }
  2208. }
  2209. }.bind(this));
  2210. },
  2211. addModuleEvent: function(key, fun){
  2212. if (this.options.moduleEvents.indexOf(key)!==-1){
  2213. this.addEvent(key, function(event){
  2214. return (fun) ? fun(this, event) : null;
  2215. }.bind(this));
  2216. }else{
  2217. this.node.addEvent(key, function(event){
  2218. return (fun) ? fun(this, event) : null;
  2219. }.bind(this));
  2220. }
  2221. },
  2222. _loadUserInterface: function(){
  2223. // if (this.form.json.mode == "Mobile"){
  2224. // this.node.empty();
  2225. // }else if (COMMON.Browser.Platform.isMobile){
  2226. // this.node.empty();
  2227. // }else{
  2228. this.toolbarNode = this.node.getFirst("div");
  2229. if( !this.toolbarNode ){
  2230. this.toolbarNode = new Element("div").inject( this.node );
  2231. }
  2232. this.toolbarNode.empty();
  2233. MWF.require("MWF.widget.Toolbar", function(){
  2234. this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {
  2235. "style": this.json.style,
  2236. "onPostLoad" : function(){
  2237. this.fireEvent("afterLoad");
  2238. }.bind(this)
  2239. }, this);
  2240. if (this.json.actionStyles) this.toolbarWidget.css = this.json.actionStyles;
  2241. //alert(this.readonly)
  2242. if (this.json.hideSystemTools){
  2243. this.setCustomToolbars(this.json.tools, this.toolbarNode);
  2244. this.toolbarWidget.load();
  2245. }else{
  2246. if (this.json.defaultTools){
  2247. this.setToolbars(this.json.defaultTools, this.toolbarNode, this.readonly);
  2248. this.setCustomToolbars(this.json.tools, this.toolbarNode);
  2249. this.toolbarWidget.load();
  2250. }else{
  2251. MWF.getJSON(this.form.path+"toolbars.json", function(json){
  2252. this.setToolbars(json, this.toolbarNode, this.readonly, true);
  2253. this.setCustomToolbars(this.json.tools, this.toolbarNode);
  2254. this.toolbarWidget.load();
  2255. }.bind(this), null);
  2256. }
  2257. }
  2258. }.bind(this));
  2259. // }
  2260. },
  2261. setCustomToolbars: function(tools, node){
  2262. var path = "../x_component_process_FormDesigner/Module/Actionbar/";
  2263. var iconPath = "";
  2264. if( this.json.customIconStyle ){
  2265. iconPath = this.json.customIconStyle+"/";
  2266. }
  2267. tools.each(function(tool){
  2268. var flag = true;
  2269. if (this.readonly){
  2270. flag = tool.readShow;
  2271. }else{
  2272. flag = tool.editShow;
  2273. }
  2274. if (flag){
  2275. flag = true;
  2276. // if (tool.control){
  2277. // flag = this.form.businessData.control[tool.control]
  2278. // }
  2279. if (tool.condition){
  2280. var hideFlag = this.form.Macro.exec(tool.condition, this);
  2281. flag = !hideFlag;
  2282. }
  2283. if (flag){
  2284. var actionNode = new Element("div", {
  2285. "id": tool.id,
  2286. "MWFnodetype": tool.type,
  2287. "MWFButtonImage": path+""+this.form.options.style+"/custom/"+iconPath+tool.img,
  2288. "title": tool.title,
  2289. "MWFButtonAction": "runCustomAction",
  2290. "MWFButtonText": tool.text
  2291. }).inject(node);
  2292. if( this.json.customIconOverStyle ){
  2293. actionNode.set("MWFButtonImageOver" , path+""+this.form.options.style +"/custom/"+this.json.customIconOverStyle+ "/" +tool.img );
  2294. }
  2295. if( tool.properties ){
  2296. actionNode.set(tool.properties);
  2297. }
  2298. if (tool.actionScript){
  2299. actionNode.store("script", tool.actionScript);
  2300. }
  2301. if (tool.sub){
  2302. var subNode = node.getLast();
  2303. this.setCustomToolbars(tool.sub, subNode);
  2304. }
  2305. }
  2306. }
  2307. }.bind(this));
  2308. },
  2309. setToolbarItem: function(tool, node, readonly, noCondition){
  2310. //var path = "../x_component_process_FormDesigner/Module/Actionbar/";
  2311. var path = "../x_component_query_ViewDesigner/$View/";
  2312. var flag = true;
  2313. // if (tool.control){
  2314. // flag = this.form.businessData.control[tool.control]
  2315. // }
  2316. if (!noCondition) if (tool.condition){
  2317. var hideFlag = this.form.Macro.exec(tool.condition, this);
  2318. flag = flag && (!hideFlag);
  2319. }
  2320. if (readonly) if (!tool.read) flag = false;
  2321. if (flag){
  2322. var actionNode = new Element("div", {
  2323. "id": tool.id,
  2324. "MWFnodetype": tool.type,
  2325. //"MWFButtonImage": this.form.path+""+this.form.options.style+"/actionbar/"+tool.img,
  2326. //"MWFButtonImage": path+(this.options.style||"default") +"/tools/"+ (this.json.style || "default") +"/"+tool.img,
  2327. "MWFButtonImage": path+this.options.style+"/actionbar/"+ ( this.json.iconStyle || "default" ) +"/"+tool.img,
  2328. "title": tool.title,
  2329. "MWFButtonAction": tool.action,
  2330. "MWFButtonText": tool.text
  2331. }).inject(node);
  2332. if( this.json.iconOverStyle ){
  2333. actionNode.set("MWFButtonImageOver" , path+""+this.options.style+"/actionbar/"+this.json.iconOverStyle+"/"+tool.img );
  2334. //actionNode.set("MWFButtonImageOver" , path+""+(this.options.style||"default")+"/tools/"+( this.json.iconOverStyle || "default" )+"/"+tool.img );
  2335. }
  2336. if( tool.properties ){
  2337. actionNode.set(tool.properties);
  2338. }
  2339. if (tool.sub){
  2340. var subNode = node.getLast();
  2341. this.setToolbars(tool.sub, subNode, readonly, noCondition);
  2342. }
  2343. }
  2344. },
  2345. setToolbars: function(tools, node, readonly, noCondition){
  2346. tools.each(function(tool){
  2347. this.setToolbarItem(tool, node, readonly, noCondition);
  2348. }.bind(this));
  2349. },
  2350. runCustomAction: function(bt){
  2351. var script = bt.node.retrieve("script");
  2352. this.form.Macro.exec(script, this);
  2353. },
  2354. exportView : function(){
  2355. this.form.exportView();
  2356. },
  2357. deleteWork: function(){
  2358. this.form.deleteWork();
  2359. }
  2360. });
  2361. MWF.xApplication.query.Query.Viewer.Paging = new Class({
  2362. Implements: [Events],
  2363. options: {
  2364. "style" : "default",
  2365. "moduleEvents": ["load", "queryLoad", "postLoad", "afterLoad","jump"]
  2366. },
  2367. initialize: function(node, json, form, options){
  2368. this.node = $(node);
  2369. this.node.store("module", this);
  2370. this.json = json;
  2371. this.form = form;
  2372. this.view = form;
  2373. },
  2374. hide: function(){
  2375. var dsp = this.node.getStyle("display");
  2376. if (dsp!=="none") this.node.store("mwf_display", dsp);
  2377. this.node.setStyle("display", "none");
  2378. },
  2379. show: function(){
  2380. var dsp = this.node.retrieve("mwf_display", dsp);
  2381. this.node.setStyle("display", dsp);
  2382. },
  2383. load: function(){
  2384. this._loadModuleEvents();
  2385. if (this.fireEvent("queryLoad")){
  2386. //this._queryLoaded();
  2387. this._loadUserInterface();
  2388. this._loadStyles();
  2389. this._loadDomEvents();
  2390. //this._loadEvents();
  2391. //this._afterLoaded();
  2392. this.fireEvent("postLoad");
  2393. }
  2394. },
  2395. _loadStyles: function(){
  2396. if (this.json.styles) Object.each(this.json.styles, function(value, key){
  2397. if ((value.indexOf("x_processplatform_assemble_surface")!=-1 || value.indexOf("x_portal_assemble_surface")!=-1 || value.indexOf("x_cms_assemble_control")!=-1)){
  2398. var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface");
  2399. var host2 = MWF.Actions.getHost("x_portal_assemble_surface");
  2400. var host3 = MWF.Actions.getHost("x_cms_assemble_control");
  2401. if (value.indexOf("/x_processplatform_assemble_surface")!==-1){
  2402. value = value.replace("/x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  2403. }else if (value.indexOf("x_processplatform_assemble_surface")!==-1){
  2404. value = value.replace("x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  2405. }
  2406. if (value.indexOf("/x_portal_assemble_surface")!==-1){
  2407. value = value.replace("/x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  2408. }else if (value.indexOf("x_portal_assemble_surface")!==-1){
  2409. value = value.replace("x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  2410. }
  2411. if (value.indexOf("/x_cms_assemble_control")!==-1){
  2412. value = value.replace("/x_cms_assemble_control", host3+"/x_cms_assemble_control");
  2413. }else if (value.indexOf("x_cms_assemble_control")!==-1){
  2414. value = value.replace("x_cms_assemble_control", host3+"/x_cms_assemble_control");
  2415. }
  2416. }
  2417. this.node.setStyle(key, value);
  2418. }.bind(this));
  2419. // if (["x_processplatform_assemble_surface", "x_portal_assemble_surface"].indexOf(root.toLowerCase())!==-1){
  2420. // var host = MWF.Actions.getHost(root);
  2421. // return (flag==="/") ? host+this.json.template : host+"/"+this.json.template
  2422. // }
  2423. //if (this.json.styles) this.node.setStyles(this.json.styles);
  2424. },
  2425. _loadModuleEvents : function(){
  2426. Object.each(this.json.events, function(e, key){
  2427. if (e.code){
  2428. if (this.options.moduleEvents.indexOf(key)!==-1){
  2429. this.addEvent(key, function(event){
  2430. return this.form.Macro.fire(e.code, this, event);
  2431. }.bind(this));
  2432. }
  2433. }
  2434. }.bind(this));
  2435. },
  2436. _loadDomEvents: function(){
  2437. Object.each(this.json.events, function(e, key){
  2438. if (e.code){
  2439. if (this.options.moduleEvents.indexOf(key)===-1){
  2440. this.node.addEvent(key, function(event){
  2441. return this.form.Macro.fire(e.code, this, event);
  2442. }.bind(this));
  2443. }
  2444. }
  2445. }.bind(this));
  2446. },
  2447. _loadEvents: function(){
  2448. Object.each(this.json.events, function(e, key){
  2449. if (e.code){
  2450. if (this.options.moduleEvents.indexOf(key)!==-1){
  2451. this.addEvent(key, function(event){
  2452. return this.form.Macro.fire(e.code, this, event);
  2453. }.bind(this));
  2454. }else{
  2455. this.node.addEvent(key, function(event){
  2456. return this.form.Macro.fire(e.code, this, event);
  2457. }.bind(this));
  2458. }
  2459. }
  2460. }.bind(this));
  2461. },
  2462. addModuleEvent: function(key, fun){
  2463. if (this.options.moduleEvents.indexOf(key)!==-1){
  2464. this.addEvent(key, function(event){
  2465. return (fun) ? fun(this, event) : null;
  2466. }.bind(this));
  2467. }else{
  2468. this.node.addEvent(key, function(event){
  2469. return (fun) ? fun(this, event) : null;
  2470. }.bind(this));
  2471. }
  2472. },
  2473. _loadUserInterface: function(){
  2474. // if (this.form.json.mode == "Mobile"){
  2475. // this.node.empty();
  2476. // }else if (COMMON.Browser.Platform.isMobile){
  2477. // this.node.empty();
  2478. // }else{
  2479. this.loadPaging( true )
  2480. },
  2481. reload : function(){
  2482. this.loadPaging( false )
  2483. },
  2484. loadPaging : function( firstLoading ){
  2485. // this.pagingNode = this.node.getFirst("div");
  2486. // if( !this.pagingNode ){
  2487. // this.pagingNode = new Element("div").inject( this.node );
  2488. // }
  2489. // this.pagingNode.empty();
  2490. this.node.empty();
  2491. this.paging = new o2.widget.Paging(this.node, {
  2492. //style : this.options.skin && this.options.skin.pagingBar ? this.options.skin.pagingBar : "default",
  2493. countPerPage: this.view.json.pageSize || this.view.options.perPageCount,
  2494. visiblePages: layout.mobile?5:(this.json.visiblePages ? this.json.visiblePages.toInt() : 9),
  2495. currentPage: this.view.currentPage,
  2496. itemSize: this.view.count,
  2497. pageSize: this.view.pages,
  2498. hasNextPage: typeOf( this.json.hasPreNextPage ) === "boolean" ? this.json.hasPreNextPage : true,
  2499. hasPrevPage: typeOf( this.json.hasPreNextPage ) === "boolean" ? this.json.hasPreNextPage : true,
  2500. hasTruningBar: typeOf( this.json.hasTruningBar ) === "boolean" ? this.json.hasTruningBar : true,
  2501. hasBatchTuring: typeOf( this.json.hasBatchTuring ) === "boolean" ? this.json.hasBatchTuring : true,
  2502. hasFirstPage: typeOf( this.json.hasFirstLastPage ) === "boolean" ? this.json.hasFirstLastPage : (layout.mobile?false:true),
  2503. hasLastPage: typeOf( this.json.hasFirstLastPage ) === "boolean" ? this.json.hasFirstLastPage : (layout.mobile?false:true),
  2504. hasJumper: typeOf( this.json.hasPageJumper ) === "boolean" ? this.json.hasPageJumper : (layout.mobile?false:true),
  2505. hiddenWithDisable: false,
  2506. hiddenWithNoItem: true,
  2507. text: {
  2508. prePage: this.json.prePageText,
  2509. nextPage: this.json.nextPageText,
  2510. firstPage: this.json.firstPageText,
  2511. lastPage: this.json.lastPageText
  2512. },
  2513. onJumpingPage : function( pageNum, itemNum ){
  2514. this.view.currentPage = pageNum;
  2515. this.fireEvent("jump");
  2516. this.view.loadCurrentPageData( null, false );
  2517. }.bind(this),
  2518. onPostLoad : function () {
  2519. if( firstLoading ){
  2520. if(this.view.setContentHeightFun)this.view.setContentHeightFun();
  2521. this.fireEvent("load");
  2522. }
  2523. this.fireEvent("afterLoad");
  2524. }.bind(this)
  2525. }, this.json.pagingStyles || {});
  2526. this.paging.load();
  2527. }
  2528. });