Viewer.js 96 KB

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