Viewer.js 95 KB

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