Viewer.js 97 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215
  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, async ){
  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), null, async === false ? false : true );
  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.filterItems = [];
  750. this.createViewNode();
  751. }
  752. }
  753. },
  754. searchCustomView: function(){
  755. if (this.filterItems.length){
  756. var filterData = this.json.filter ? this.json.filter.clone() : [];
  757. this.filterItems.each(function(filter){
  758. filterData.push(filter.data);
  759. }.bind(this));
  760. this.createViewNode({"filterList": filterData});
  761. }else{
  762. this.createViewNode({"filterList": this.json.filter ? this.json.filter.clone() : null});
  763. }
  764. },
  765. loadCustomSearch: function(){
  766. if( this.lastFilterItems ){
  767. this.filterItems = this.lastFilterItems;
  768. }else{
  769. this.filterItems = [];
  770. }
  771. debugger;
  772. this.viewSearchIconNode.setStyle("display", "none");
  773. this.viewSearchInputBoxNode.setStyle("display", "none");
  774. this.viewSearchCustomActionNode.setStyle("display", "none");
  775. if (!this.searchMorph) this.searchMorph = new Fx.Morph(this.viewSearchInputAreaNode);
  776. var x = this.viewSearchInputAreaNode.getParent().getSize().x-2-20;
  777. this.css.viewFilterSearchInputAreaNode_custom.width = ""+x+"px";
  778. var x1 = this.viewSearchInputAreaNode.getSize().x-2;
  779. this.viewSearchInputAreaNode.setStyle("width", ""+x1+"px");
  780. this.searchMorph.start(this.css.viewFilterSearchInputAreaNode_custom).chain(function(){
  781. this.searchStatus = "custom";
  782. this.css.viewFilterSearchInputAreaNode_custom.width = "auto";
  783. this.viewSearchInputAreaNode.setStyle("width", "auto");
  784. if (this.viewSearchCustomContentNode){
  785. this.viewSearchCustomCloseActionNode.setStyle("display", "block");
  786. this.viewSearchCustomContentNode.setStyle("display", "block");
  787. }else{
  788. this.loadCustomSearchContent();
  789. }
  790. if(this.setContentHeightFun)this.setContentHeightFun();
  791. }.bind(this));
  792. this.searchCustomView();
  793. },
  794. loadCustomSearchContent: function(){
  795. this.viewSearchCustomCloseActionNode = new Element("div", {"styles": this.css.viewFilterSearchCustomCloseActionNode}).inject(this.viewSearchInputAreaNode);
  796. this.viewSearchCustomContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomContentNode}).inject(this.viewSearchInputAreaNode);
  797. this.viewSearchCustomPathContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomPathContentNode}).inject(this.viewSearchCustomContentNode);
  798. this.viewSearchCustomComparisonContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomComparisonContentNode}).inject(this.viewSearchCustomContentNode);
  799. this.viewSearchCustomValueContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomValueContentNode}).inject(this.viewSearchCustomContentNode);
  800. this.viewSearchCustomAddContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomAddContentNode}).inject(this.viewSearchCustomContentNode);
  801. this.viewSearchCustomAddIconNode = new Element("div", {"styles": this.css.viewFilterSearchCustomAddIconNode}).inject(this.viewSearchCustomAddContentNode);
  802. this.viewSearchCustomFilterContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomFilterContentNode}).inject(this.viewSearchCustomContentNode);
  803. this.loadViewSearchCustomList();
  804. this.viewSearchCustomCloseActionNode.addEvents({
  805. "click": function(){this.closeCustomSearch();}.bind(this)
  806. });
  807. this.viewSearchCustomAddIconNode.addEvents({
  808. "click": function(){this.viewSearchCustomAddToFilter();}.bind(this)
  809. });
  810. },
  811. loadViewSearchCustomList: function(){
  812. this.viewSearchCustomPathListNode = new Element("select", {
  813. "styles": this.css.viewFilterSearchCustomPathListNode,
  814. "multiple": true
  815. }).inject(this.viewSearchCustomPathContentNode);
  816. this.viewSearchCustomComparisonListNode = new Element("select", {
  817. "styles": this.css.viewFilterSearchCustomComparisonListNode,
  818. "multiple": true
  819. }).inject(this.viewSearchCustomComparisonContentNode);
  820. this.viewJson.customFilterList.each(function(entry){
  821. var option = new Element("option", {
  822. "style": this.css.viewFilterSearchOptionNode,
  823. "value": entry.path,
  824. "text": entry.title
  825. }).inject(this.viewSearchCustomPathListNode);
  826. option.store("entry", entry);
  827. }.bind(this));
  828. this.viewSearchCustomPathListNode.addEvent("change", function(){
  829. this.loadViewSearchCustomComparisonList();
  830. }.bind(this));
  831. },
  832. loadViewSearchCustomComparisonList: function(){
  833. var idx = this.viewSearchCustomPathListNode.selectedIndex;
  834. var option = this.viewSearchCustomPathListNode.options[idx];
  835. var entry = option.retrieve("entry");
  836. if (entry){
  837. var selectableList = this.getCustomSelectScriptResult(entry);
  838. switch (entry.formatType){
  839. case "numberValue":
  840. this.loadComparisonSelect(this.lp.numberFilter);
  841. if( selectableList.length > 0 ){
  842. this.loadViewSerchCustomSelectByScript(selectableList)
  843. }else{
  844. this.loadViewSearchCustomValueNumberInput();
  845. }
  846. break;
  847. case "dateTimeValue":
  848. this.loadComparisonSelect(this.lp.dateFilter);
  849. if( selectableList.length > 0 ){
  850. this.loadViewSerchCustomSelectByScript(selectableList)
  851. }else {
  852. this.loadViewSearchCustomValueDateTimeInput();
  853. }
  854. break;
  855. case "dateValue":
  856. this.loadComparisonSelect(this.lp.dateFilter);
  857. if( selectableList.length > 0 ){
  858. this.loadViewSerchCustomSelectByScript(selectableList)
  859. }else {
  860. this.loadViewSearchCustomValueDateInput();
  861. }
  862. break;
  863. case "timeValue":
  864. this.loadComparisonSelect(this.lp.dateFilter);
  865. if( selectableList.length > 0 ){
  866. this.loadViewSerchCustomSelectByScript(selectableList)
  867. }else {
  868. this.loadViewSearchCustomValueTimeInput();
  869. }
  870. break;
  871. case "booleanValue":
  872. this.loadComparisonSelect(this.lp.booleanFilter);
  873. if( selectableList.length > 0 ){
  874. this.loadViewSerchCustomSelectByScript(selectableList)
  875. }else {
  876. this.loadViewSearchCustomValueBooleanInput();
  877. }
  878. break;
  879. default:
  880. this.loadComparisonSelect(this.lp.textFilter);
  881. if( selectableList.length > 0 ){
  882. this.loadViewSerchCustomSelectByScript(selectableList)
  883. }else {
  884. this.loadViewSearchCustomValueTextInput();
  885. }
  886. }
  887. }
  888. },
  889. getCustomSelectScriptResult : function( entry ){
  890. var scriptResult = [];
  891. if( entry.valueType === "script" ){
  892. if( entry.valueScript && entry.valueScript.code ){
  893. var result = this.Macro.exec(entry.valueScript.code, this);
  894. var array = typeOf( result ) === "array" ? result : [result];
  895. for( var i=0; i<array.length; i++ ){
  896. if( array[i].indexOf( "|" ) > -1 ){
  897. var arr = array[i].split("|");
  898. scriptResult.push({ "text" : arr[0], "value" : arr[1] })
  899. }else{
  900. scriptResult.push({ "text" : array[i], "value" : array[i] })
  901. }
  902. }
  903. }
  904. }
  905. return scriptResult;
  906. },
  907. loadViewSerchCustomSelectByScript: function( array ){
  908. this.viewSearchCustomValueContentNode.empty();
  909. this.viewSearchCustomValueNode = new Element("select", {
  910. "styles": this.css.viewFilterSearchCustomComparisonListNode,
  911. "multiple": true
  912. }).inject(this.viewSearchCustomValueContentNode);
  913. array.each(function( v ){
  914. var option = new Element("option", {
  915. "style": this.css.viewFilterSearchOptionNode,
  916. "value": v.value,
  917. "text": v.text,
  918. "selected" : array.length === 1
  919. }).inject(this.viewSearchCustomValueNode);
  920. }.bind(this));
  921. },
  922. loadViewSearchCustomValueNumberInput: function(){
  923. this.viewSearchCustomValueContentNode.empty();
  924. this.viewSearchCustomValueNode = new Element("input", {
  925. "styles": this.css.viewFilterSearchCustomValueNode,
  926. "type": "number"
  927. }).inject(this.viewSearchCustomValueContentNode);
  928. },
  929. loadViewSearchCustomValueDateTimeInput: function(){
  930. this.viewSearchCustomValueContentNode.empty();
  931. this.viewSearchCustomValueNode = new Element("input", {
  932. "styles": this.css.viewFilterSearchCustomValueNode,
  933. "type": "text",
  934. "readonly": true
  935. }).inject(this.viewSearchCustomValueContentNode);
  936. MWF.require("MWF.widget.Calendar", function(){
  937. this.calendar = new MWF.widget.Calendar(this.viewSearchCustomValueNode, {
  938. "style": "xform",
  939. "isTime": true,
  940. "secondEnable" : true,
  941. "target": this.container,
  942. "format": "db"
  943. });
  944. }.bind(this));
  945. },
  946. loadViewSearchCustomValueDateInput: function(){
  947. this.viewSearchCustomValueContentNode.empty();
  948. this.viewSearchCustomValueNode = new Element("input", {
  949. "styles": this.css.viewFilterSearchCustomValueNode,
  950. "type": "text",
  951. "readonly": true
  952. }).inject(this.viewSearchCustomValueContentNode);
  953. MWF.require("MWF.widget.Calendar", function(){
  954. this.calendar = new MWF.widget.Calendar(this.viewSearchCustomValueNode, {
  955. "style": "xform",
  956. "isTime": false,
  957. "target": this.container,
  958. "format": "%Y-%m-%d"
  959. });
  960. }.bind(this));
  961. },
  962. loadViewSearchCustomValueTimeInput: function(){
  963. this.viewSearchCustomValueContentNode.empty();
  964. this.viewSearchCustomValueNode = new Element("input", {
  965. "styles": this.css.viewFilterSearchCustomValueNode,
  966. "type": "text",
  967. "readonly": true
  968. }).inject(this.viewSearchCustomValueContentNode);
  969. MWF.require("MWF.widget.Calendar", function(){
  970. this.calendar = new MWF.widget.Calendar(this.viewSearchCustomValueNode, {
  971. "style": "xform",
  972. "timeOnly": true,
  973. "target": this.container,
  974. "format": "%H:%M:%S"
  975. });
  976. }.bind(this));
  977. },
  978. loadViewSearchCustomValueBooleanInput: function(){
  979. this.viewSearchCustomValueContentNode.empty();
  980. this.viewSearchCustomValueNode = new Element("select", {
  981. "styles": this.css.viewFilterSearchCustomValueSelectNode,
  982. "multiple": true
  983. }).inject(this.viewSearchCustomValueContentNode);
  984. new Element("option", {"value": "true","text": this.lp.yes}).inject(this.viewSearchCustomValueNode);
  985. new Element("option", {"value": "false","text": this.lp.no}).inject(this.viewSearchCustomValueNode);
  986. },
  987. loadViewSearchCustomValueTextInput: function(){
  988. this.viewSearchCustomValueContentNode.empty();
  989. this.viewSearchCustomValueNode = new Element("textarea", {
  990. "styles": this.css.viewFilterSearchCustomValueNode
  991. }).inject(this.viewSearchCustomValueContentNode);
  992. },
  993. loadComparisonSelect:function(obj){
  994. this.viewSearchCustomComparisonListNode.empty();
  995. Object.each(obj, function(v, k){
  996. var option = new Element("option", {"value": k,"text": v}).inject(this.viewSearchCustomComparisonListNode);
  997. }.bind(this));
  998. },
  999. closeCustomSearch: function(){
  1000. if (this.viewSearchCustomContentNode && this.viewSearchCustomContentNode.getStyle("display")==="block"){
  1001. this.viewSearchCustomCloseActionNode.setStyle("display", "none");
  1002. this.viewSearchCustomContentNode.setStyle("display", "none");
  1003. var x = this.viewSearchInputAreaNode.getParent().getSize().x;
  1004. x1 = x-2-10-90;
  1005. this.css.viewFilterSearchInputAreaNode.width = ""+x1+"px";
  1006. var x1 = this.viewSearchInputAreaNode.getSize().x-2;
  1007. this.viewSearchInputAreaNode.setStyle("width", ""+x1+"px");
  1008. if (!this.searchMorph) this.searchMorph = new Fx.Morph(this.viewSearchInputAreaNode);
  1009. this.searchMorph.start(this.css.viewFilterSearchInputAreaNode).chain(function(){
  1010. this.searchStatus = "default";
  1011. this.css.viewFilterSearchInputAreaNode.width = "auto";
  1012. this.viewSearchInputAreaNode.setStyle("margin-right", "90px");
  1013. this.viewSearchIconNode.setStyle("display", "block");
  1014. this.viewSearchInputBoxNode.setStyle("display", "block");
  1015. this.viewSearchCustomActionNode.setStyle("display", "block");
  1016. if(this.setContentHeightFun)this.setContentHeightFun();
  1017. }.bind(this));
  1018. this.lastFilterItems = this.filterItems;
  1019. this.createViewNode({"filterList": this.json.filter ? this.json.filter.clone() : null});
  1020. }
  1021. },
  1022. viewSearchCustomAddToFilter: function(){
  1023. var pathIdx = this.viewSearchCustomPathListNode.selectedIndex;
  1024. var comparisonIdx = this.viewSearchCustomComparisonListNode.selectedIndex;
  1025. if (pathIdx===-1){
  1026. MWF.xDesktop.notice("error", {"x": "left", "y": "top"}, this.lp.filterErrorTitle, this.viewSearchCustomPathListNode, {"x": 0, "y": 85});
  1027. return false;
  1028. }
  1029. if (comparisonIdx===-1){
  1030. MWF.xDesktop.notice("error", {"x": "left", "y": "top"}, this.lp.filterErrorComparison, this.viewSearchCustomComparisonListNode, {"x": 0, "y": 85});
  1031. return false;
  1032. }
  1033. var pathOption = this.viewSearchCustomPathListNode.options[pathIdx];
  1034. var entry = pathOption.retrieve("entry");
  1035. if (entry){
  1036. var pathTitle = entry.title;
  1037. var path = entry.path;
  1038. var comparison = this.viewSearchCustomComparisonListNode.options[comparisonIdx].get("value");
  1039. var comparisonTitle = this.viewSearchCustomComparisonListNode.options[comparisonIdx].get("text");
  1040. var value = "";
  1041. if( entry.valueType === "script" && entry.valueScript && entry.valueScript.code ){
  1042. var idx = this.viewSearchCustomValueNode.selectedIndex;
  1043. if (idx!==-1){
  1044. var v = this.viewSearchCustomValueNode.options[idx].get("value");
  1045. value = entry.formatType === "booleanValue" ? (v==="true") : v;
  1046. }
  1047. }else{
  1048. switch (entry.formatType){
  1049. case "numberValue":
  1050. value = this.viewSearchCustomValueNode.get("value");
  1051. break;
  1052. case "dateTimeValue":
  1053. value = this.viewSearchCustomValueNode.get("value");
  1054. break;
  1055. case "booleanValue":
  1056. var idx = this.viewSearchCustomValueNode.selectedIndex;
  1057. if (idx!==-1){
  1058. var v = this.viewSearchCustomValueNode.options[idx].get("value");
  1059. value = (v==="true");
  1060. }
  1061. break;
  1062. default:
  1063. value = this.viewSearchCustomValueNode.get("value");
  1064. }
  1065. }
  1066. if (value===""){
  1067. MWF.xDesktop.notice("error", {"x": "left", "y": "top"}, this.lp.filterErrorValue, this.viewSearchCustomValueContentNode, {"x": 0, "y": 85});
  1068. return false;
  1069. }
  1070. this.filterItems.push(new MWF.xApplication.query.Query.Viewer.Filter(this, {
  1071. "logic": "and",
  1072. "path": path,
  1073. "title": pathTitle,
  1074. "comparison": comparison,
  1075. "comparisonTitle": comparisonTitle,
  1076. "value": value,
  1077. "formatType": (entry.formatType=="datetimeValue") ? "dateTimeValue": entry.formatType
  1078. }, this.viewSearchCustomFilterContentNode));
  1079. this.searchCustomView();
  1080. }
  1081. },
  1082. searchViewRemoveFilter: function(filter){
  1083. this.filterItems.erase(filter);
  1084. filter.destroy();
  1085. this.searchCustomView()
  1086. },
  1087. //搜索相关结束
  1088. //api 使用 开始
  1089. getParentEnvironment : function(){
  1090. return this.parentMacro ? this.parentMacro.environment : null;
  1091. },
  1092. getViewInfor : function(){
  1093. return this.json;
  1094. },
  1095. getPageInfor : function(){
  1096. return {
  1097. pages : this.pages,
  1098. perPageCount : this.options.perPageCount,
  1099. currentPageNumber : this.currentPage
  1100. };
  1101. },
  1102. getPageData : function () {
  1103. return this.gridJson;
  1104. },
  1105. toPage : function( pageNumber, callback ){
  1106. this.currentPage = pageNumber;
  1107. this.loadCurrentPageData( callback );
  1108. },
  1109. getSelectedData : function(){
  1110. return this.getData();
  1111. },
  1112. selectAll : function(){
  1113. var flag = this.json.select || this.viewJson.select || "none";
  1114. if ( flag==="multi"){
  1115. this.items.each( function (item) {
  1116. if( item.clazzType === "item" ){
  1117. item.selected();
  1118. }else{
  1119. item.expand();
  1120. if( item.items ){
  1121. item.items.each( function (it) {
  1122. it.selected();
  1123. })
  1124. }
  1125. }
  1126. })
  1127. }
  1128. },
  1129. unSelectAll : function(){
  1130. var flag = this.json.select || this.viewJson.select || "none";
  1131. if ( flag==="multi"){
  1132. this.items.each( function (item) {
  1133. if( item.clazzType === "item" ){
  1134. item.unSelected();
  1135. }else{
  1136. if(item.items){
  1137. item.items.each( function (it) {
  1138. it.unSelected();
  1139. })
  1140. }
  1141. }
  1142. })
  1143. }
  1144. },
  1145. setFilter : function( filter ){
  1146. if( !filter )filter = [];
  1147. if( typeOf( filter ) === "object" )filter = [ filter ];
  1148. this.json.filter = filter;
  1149. if( this.viewAreaNode ){
  1150. this.createViewNode({"filterList": this.json.filter ? this.json.filter.clone() : null});
  1151. }
  1152. },
  1153. switchView : function( json ){
  1154. debugger;
  1155. // json = {
  1156. // "application": application,
  1157. // "viewName": viewName,
  1158. // "isTitle": "yes",
  1159. // "select": "none",
  1160. // "titleStyles": titleStyles,
  1161. // "itemStyles": itemStyles,
  1162. // "isExpand": "no",
  1163. // "filter": filter
  1164. // }
  1165. this.node.setStyle("display", "block");
  1166. if (this.loadingAreaNode) this.loadingAreaNode.setStyle("display", "block");
  1167. this.searchMorph = null;
  1168. this.viewSearchCustomContentNode = null;
  1169. var newJson = Object.merge( Object.clone(this.originalJson), json );
  1170. this.container.empty();
  1171. this.initialize( this.container, newJson, Object.clone(this.options), this.app, this.parentMacro);
  1172. },
  1173. confirm: function (type, e, title, text, width, height, ok, cancel, callback, mask, style) {
  1174. this.app.confirm(type, e, title, text, width, height, ok, cancel, callback, mask, style)
  1175. },
  1176. alert: function (type, title, text, width, height) {
  1177. this.app.alert(type, "center", title, text, width, height);
  1178. },
  1179. notice: function (content, type, target, where, offset, option) {
  1180. this.app.notice(content, type, target, where, offset, option)
  1181. }
  1182. //api 使用 结束
  1183. });
  1184. MWF.xApplication.query.Query.Viewer.Item = new Class({
  1185. initialize: function(view, data, prev, i){
  1186. this.view = view;
  1187. this.data = data;
  1188. this.css = this.view.css;
  1189. this.isSelected = false;
  1190. this.prev = prev;
  1191. this.idx = i;
  1192. this.clazzType = "item";
  1193. this.load();
  1194. },
  1195. load: function(){
  1196. this.view.fireEvent("queryLoadItemRow", [null, this]);
  1197. var viewStyles = this.view.viewJson.viewStyles;
  1198. var viewContentTdNode = ( viewStyles && viewStyles["contentTd"] ) ? viewStyles["contentTd"] : this.css.viewContentTdNode;
  1199. this.node = new Element("tr", {
  1200. "styles": ( viewStyles && viewStyles["contentTr"] ) ? viewStyles["contentTr"] : this.css.viewContentTrNode
  1201. });
  1202. if (this.prev){
  1203. this.node.inject(this.prev.node, "after");
  1204. }else{
  1205. this.node.inject(this.view.viewTable);
  1206. }
  1207. //if (this.view.json.select==="single" || this.view.json.select==="multi"){
  1208. this.selectTd = new Element("td", { "styles": viewContentTdNode }).inject(this.node);
  1209. this.selectTd.setStyles({"cursor": "pointer"});
  1210. if (this.view.json.itemStyles) this.selectTd.setStyles(this.view.json.itemStyles);
  1211. //}
  1212. //序号
  1213. if (this.view.viewJson.isSequence==="yes"){
  1214. this.sequenceTd = new Element("td", {"styles": viewContentTdNode}).inject(this.node);
  1215. this.sequenceTd.setStyle("width", "10px");
  1216. var s= 1+this.view.json.pageSize*(this.view.currentPage-1)+this.idx;
  1217. this.sequenceTd.set("text", s);
  1218. }
  1219. Object.each(this.view.entries, function(c, k){
  1220. var cell = this.data.data[k];
  1221. if (cell === undefined) cell = "";
  1222. //if (cell){
  1223. if (this.view.hideColumns.indexOf(k)===-1){
  1224. var td = new Element("td", {"styles": viewContentTdNode}).inject(this.node);
  1225. if (k!== this.view.viewJson.group.column){
  1226. //var v = (this.view.entries[k].code) ? MWF.Macro.exec(this.view.entries[k].code, {"value": cell, "gridData": this.view.gridJson, "data": this.view.viewData, "entry": this.data}) : cell;
  1227. var v = cell;
  1228. if (c.isHtml){
  1229. td.set("html", v);
  1230. }else{
  1231. td.set("text", v);
  1232. }
  1233. }
  1234. if (this.view.openColumns.indexOf(k)!==-1){
  1235. this.setOpenWork(td, c)
  1236. }
  1237. if (this.view.json.itemStyles) td.setStyles(this.view.json.itemStyles);
  1238. }
  1239. //}
  1240. }.bind(this));
  1241. // Object.each(this.data.data, function(cell, k){
  1242. // if (this.view.hideColumns.indexOf(k)===-1){
  1243. // var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(this.node);
  1244. // if (k!== this.view.viewJson.group.column){
  1245. // 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;
  1246. // td.set("text", v);
  1247. // }
  1248. // if (this.view.openColumns.indexOf(k)!==-1){
  1249. // this.setOpenWork(td)
  1250. // }
  1251. // if (this.view.json.itemStyles) td.setStyles(this.view.json.itemStyles);
  1252. // }
  1253. // }.bind(this));
  1254. this.setEvent();
  1255. this.view.fireEvent("postLoadItemRow", [null, this]);
  1256. },
  1257. setOpenWork: function(td, column){
  1258. td.setStyle("cursor", "pointer");
  1259. if( column.clickCode ){
  1260. // if( !this.view.Macro ){
  1261. // MWF.require("MWF.xScript.Macro", function () {
  1262. // this.view.businessData = {};
  1263. // this.view.Macro = new MWF.Macro.PageContext(this.view);
  1264. // }.bind(this), false);
  1265. // }
  1266. td.addEvent("click", function( ev ){
  1267. var result = this.view.Macro.fire(column.clickCode, this, ev);
  1268. ev.stopPropagation();
  1269. return result;
  1270. }.bind(this));
  1271. }else{
  1272. if (this.view.json.type==="cms"){
  1273. td.addEvent("click", function(ev){
  1274. this.openCms(ev)
  1275. ev.stopPropagation();
  1276. }.bind(this));
  1277. }else{
  1278. td.addEvent("click", function(ev){
  1279. this.openWorkAndCompleted(ev)
  1280. ev.stopPropagation();
  1281. }.bind(this));
  1282. }
  1283. }
  1284. },
  1285. openCms: function(e){
  1286. var options = {"documentId": this.data.bundle};
  1287. this.view.fireEvent("openDocument", [options, this]); //options 传入的事件
  1288. layout.desktop.openApplication(e, "cms.Document", options);
  1289. },
  1290. openWorkAndCompleted: function(e){
  1291. MWF.Actions.get("x_processplatform_assemble_surface").listWorkByJob(this.data.bundle, function(json){
  1292. var workCompletedCount = json.data.workCompletedList.length;
  1293. var workCount = json.data.workList.length;
  1294. var count = workCount+workCompletedCount;
  1295. if (count===1){
  1296. if (workCompletedCount) {
  1297. this.openWorkCompleted(json.data.workCompletedList[0].id, e);
  1298. }else{
  1299. this.openWork(json.data.workList[0].id, e);
  1300. }
  1301. }else if (count>1){
  1302. var worksAreaNode = this.createWorksArea();
  1303. json.data.workCompletedList.each(function(work){
  1304. this.createWorkCompletedNode(work, worksAreaNode);
  1305. }.bind(this));
  1306. json.data.workList.each(function(work){
  1307. this.createWorkNode(work, worksAreaNode);
  1308. }.bind(this));
  1309. this.showWorksArea(worksAreaNode, e);
  1310. }else{
  1311. }
  1312. }.bind(this));
  1313. },
  1314. createWorkNode: function(work, worksAreaNode){
  1315. var worksAreaContentNode = worksAreaNode.getLast();
  1316. var node = new Element("div", {"styles": this.css.workAreaNode}).inject(worksAreaContentNode);
  1317. var actionNode = new Element("div", {"styles": this.css.workAreaActionNode, "text": this.view.lp.open}).inject(node);
  1318. actionNode.store("workId", work.id);
  1319. actionNode.addEvent("click", function(e){
  1320. this.openWork(e.target.retrieve("workId"), e);
  1321. this.mask.hide();
  1322. worksAreaNode.destroy();
  1323. }.bind(this));
  1324. var areaNode = new Element("div", {"styles": this.css.workAreaLeftNode}).inject(node);
  1325. var titleNode = new Element("div", {"styles": this.css.workAreaTitleNode, "text": work.title}).inject(areaNode);
  1326. var contentNode = new Element("div", {"styles": this.css.workAreaContentNode}).inject(areaNode);
  1327. new Element("div", {"styles": this.css.workAreaContentTitleNode, "text": this.view.lp.activity+": "}).inject(contentNode);
  1328. new Element("div", {"styles": this.css.workAreaContentTextNode, "text": work.activityName}).inject(contentNode);
  1329. var taskUsers = [];
  1330. MWF.Actions.get("x_processplatform_assemble_surface").listTaskByWork(work.id, function(json){
  1331. json.data.each(function(task){
  1332. taskUsers.push(MWF.name.cn(task.person));
  1333. }.bind(this));
  1334. new Element("div", {"styles": this.css.workAreaContentTitleNode, "text": this.view.lp.taskPeople+": "}).inject(contentNode);
  1335. new Element("div", {"styles": this.css.workAreaContentTextNode, "text": taskUsers.join(", ")}).inject(contentNode);
  1336. }.bind(this));
  1337. },
  1338. createWorkCompletedNode: function(work, worksAreaNode){
  1339. var worksAreaContentNode = worksAreaNode.getLast();
  1340. var node = new Element("div", {"styles": this.css.workAreaNode}).inject(worksAreaContentNode);
  1341. var actionNode = new Element("div", {"styles": this.css.workAreaActionNode, "text": this.view.lp.open}).inject(node);
  1342. actionNode.store("workId", work.id);
  1343. actionNode.addEvent("click", function(e){
  1344. this.mask.hide();
  1345. var id = e.target.retrieve("workId");
  1346. worksAreaNode.destroy();
  1347. this.openWorkCompleted(id, e);
  1348. }.bind(this));
  1349. var areaNode = new Element("div", {"styles": this.css.workAreaLeftNode}).inject(node);
  1350. var titleNode = new Element("div", {"styles": this.css.workAreaTitleNode, "text": work.title}).inject(areaNode);
  1351. var contentNode = new Element("div", {"styles": this.css.workAreaContentNode}).inject(areaNode);
  1352. new Element("div", {"styles": this.css.workAreaContentTitleNode, "text": this.view.lp.activity+": "}).inject(contentNode);
  1353. new Element("div", {"styles": this.css.workAreaContentTextNode, "text": this.view.lp.processCompleted}).inject(contentNode);
  1354. },
  1355. createWorksArea: function(){
  1356. var worksAreaNode = new Element("div", {"styles": this.css.worksAreaNode});
  1357. var worksAreaTitleNode = new Element("div", {"styles": this.css.worksAreaTitleNode}).inject(worksAreaNode);
  1358. var worksAreaTitleCloseNode = new Element("div", {"styles": this.css.worksAreaTitleCloseNode}).inject(worksAreaTitleNode);
  1359. worksAreaTitleCloseNode.addEvent("click", function(e){
  1360. this.mask.hide();
  1361. e.target.getParent().getParent().destroy();
  1362. }.bind(this));
  1363. var worksAreaContentNode = new Element("div", {"styles": this.css.worksAreaContentNode}).inject(worksAreaNode);
  1364. return worksAreaNode;
  1365. },
  1366. showWorksArea: function(node, e){
  1367. MWF.require("MWF.widget.Mask", null, false);
  1368. this.mask = new MWF.widget.Mask({"style": "desktop", "loading": false});
  1369. this.mask.loadNode(this.view.container);
  1370. node.inject(this.view.node);
  1371. this.setWorksAreaPosition(node, e.target);
  1372. },
  1373. setWorksAreaPosition: function(node, td){
  1374. var p = td.getPosition(this.view.container);
  1375. var containerS = this.view.container.getSize();
  1376. var containerP = this.view.container.getPosition(this.view.container.getOffsetParent());
  1377. var s = node.getSize();
  1378. var offX = p.x+s.x-containerS.x;
  1379. offX = (offX>0) ? offX+20 : 0;
  1380. var offY = p.y+s.y-containerS.y;
  1381. offY = (offY>0) ? offY+5 : 0;
  1382. node.position({
  1383. "relativeTo": td,
  1384. "position": "lefttop",
  1385. "edge": "lefttop",
  1386. "offset": {
  1387. "x": 0-offX,
  1388. "y": 0-offY
  1389. }
  1390. });
  1391. },
  1392. openWork: function(id, e){
  1393. var options = {"workId": id};
  1394. this.view.fireEvent("openDocument", [options, this]); //options 传入的事件
  1395. layout.desktop.openApplication(e, "process.Work", options);
  1396. },
  1397. openWorkCompleted: function(id, e){
  1398. var options = {"workCompletedId": id};
  1399. this.view.fireEvent("openDocument", [options, this]); //options 传入的事件
  1400. layout.desktop.openApplication(e, "process.Work", options);
  1401. },
  1402. setEvent: function(){
  1403. var flag = this.view.json.select || this.view.viewJson.select || "none";
  1404. if ( flag ==="single" || flag==="multi"){
  1405. this.node.addEvents({
  1406. "mouseover": function(){
  1407. if (!this.isSelected){
  1408. var viewStyles = this.view.viewJson.viewStyles;
  1409. if( viewStyles ){
  1410. if( flag === "single" ){
  1411. this.selectTd.setStyles( viewStyles["radioNode"] );
  1412. }else{
  1413. this.selectTd.setStyles( viewStyles["checkboxNode"] );
  1414. }
  1415. }else{
  1416. var iconName = "checkbox";
  1417. if (flag==="single") iconName = "radiobox";
  1418. this.selectTd.setStyles({"background": "url("+"../x_component_query_Query/$Viewer/default/icon/"+iconName+".png) center center no-repeat"});
  1419. }
  1420. }
  1421. }.bind(this),
  1422. "mouseout": function(){
  1423. if (!this.isSelected) this.selectTd.setStyles({"background": "transparent"});
  1424. }.bind(this),
  1425. "click": function(){this.select();}.bind(this)
  1426. });
  1427. }
  1428. },
  1429. select: function(){
  1430. var flag = this.view.json.select || this.view.viewJson.select || "none";
  1431. if (this.isSelected){
  1432. if (flag==="single"){
  1433. this.unSelectedSingle();
  1434. }else{
  1435. this.unSelected();
  1436. }
  1437. }else{
  1438. if (flag==="single"){
  1439. this.selectedSingle();
  1440. }else{
  1441. this.selected();
  1442. }
  1443. }
  1444. this.view.fireEvent("select"); //options 传入的事件
  1445. },
  1446. selected: function(){
  1447. this.view.selectedItems.push(this);
  1448. var viewStyles = this.view.viewJson.viewStyles;
  1449. if( viewStyles ){
  1450. this.selectTd.setStyles( viewStyles["checkedCheckboxNode"] );
  1451. this.node.setStyles( viewStyles["contentSelectedTr"] );
  1452. }else{
  1453. this.selectTd.setStyles({"background": "url("+"../x_component_query_Query/$Viewer/default/icon/checkbox_checked.png) center center no-repeat"});
  1454. this.node.setStyles(this.css.viewContentTrNode_selected);
  1455. }
  1456. this.isSelected = true;
  1457. this.view.fireEvent("selectRow", [this]);
  1458. },
  1459. unSelected: function(){
  1460. this.view.selectedItems.erase(this);
  1461. this.selectTd.setStyles({"background": "transparent"});
  1462. var viewStyles = this.view.viewJson.viewStyles;
  1463. if( viewStyles ){
  1464. this.node.setStyles( viewStyles["contentTr"] );
  1465. }else{
  1466. this.node.setStyles(this.css.viewContentTrNode);
  1467. }
  1468. this.isSelected = false;
  1469. this.view.fireEvent("unselectRow", [this]);
  1470. },
  1471. selectedSingle: function(){
  1472. if (this.view.currentSelectedItem) this.view.currentSelectedItem.unSelectedSingle();
  1473. this.view.selectedItems = [this];
  1474. this.view.currentSelectedItem = this;
  1475. var viewStyles = this.view.viewJson.viewStyles;
  1476. if( viewStyles ){
  1477. this.selectTd.setStyles( viewStyles["checkedRadioNode"] );
  1478. this.node.setStyles( viewStyles["contentSelectedTr"] );
  1479. }else {
  1480. this.selectTd.setStyles({"background": "url(" + "../x_component_query_Query/$Viewer/default/icon/radiobox_checked.png) center center no-repeat"});
  1481. this.node.setStyles(this.css.viewContentTrNode_selected);
  1482. }
  1483. this.isSelected = true;
  1484. this.view.fireEvent("selectRow", [this]);
  1485. },
  1486. unSelectedSingle: function(){
  1487. this.view.selectedItems = [];
  1488. this.view.currentSelectedItem = null;
  1489. this.selectTd.setStyles({"background": "transparent"});
  1490. var viewStyles = this.view.viewJson.viewStyles;
  1491. if( viewStyles ){
  1492. this.node.setStyles( viewStyles["contentTr"] );
  1493. }else{
  1494. this.node.setStyles(this.css.viewContentTrNode);
  1495. }
  1496. this.isSelected = false;
  1497. this.view.fireEvent("unselectRow", [this]);
  1498. }
  1499. });
  1500. MWF.xApplication.query.Query.Viewer.ItemCategory = new Class({
  1501. initialize: function(view, data, i){
  1502. this.view = view;
  1503. this.data = data;
  1504. this.css = this.view.css;
  1505. this.items = [];
  1506. this.loadChild = false;
  1507. this.idx = i;
  1508. this.clazzType = "category";
  1509. this.load();
  1510. },
  1511. load: function(){
  1512. this.view.fireEvent("queryLoadCategoryRow", [null, this]);
  1513. var viewStyles = this.view.viewJson.viewStyles;
  1514. var viewContentCategoryTdNode = ( viewStyles && viewStyles["contentGroupTd"] ) ? viewStyles["contentGroupTd"] : this.css.viewContentCategoryTdNode;
  1515. this.node = new Element("tr", {
  1516. "styles": (viewStyles && viewStyles["contentTr"]) ? viewStyles["contentTr"] : this.css.viewContentTrNode
  1517. }).inject(this.view.viewTable);
  1518. //if (this.view.json.select==="single" || this.view.json.select==="multi"){
  1519. this.selectTd = new Element("td", {"styles": viewContentCategoryTdNode}).inject(this.node);
  1520. if (this.view.json.itemStyles) this.selectTd.setStyles(this.view.json.itemStyles);
  1521. //}
  1522. this.categoryTd = new Element("td", {
  1523. "styles": viewContentCategoryTdNode,
  1524. "colspan": this.view.viewJson.selectList.length+1
  1525. }).inject(this.node);
  1526. this.groupColumn = null;
  1527. for (var c = 0; c<this.view.viewJson.selectList.length; c++){
  1528. if (this.view.viewJson.selectList[c].column === this.view.viewJson.group.column){
  1529. this.groupColumn = this.view.viewJson.selectList[c];
  1530. break;
  1531. }
  1532. }
  1533. if (this.groupColumn){
  1534. //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;
  1535. var text = this.data.group;
  1536. }else{
  1537. var text = this.data.group;
  1538. }
  1539. if( viewStyles && viewStyles["groupCollapseNode"] ){
  1540. this.expandNode = new Element("span", {
  1541. styles : viewStyles["groupCollapseNode"]
  1542. }).inject( this.categoryTd );
  1543. new Element("span", { text : text }).inject( this.categoryTd );
  1544. // this.categoryTd.set("text", text );
  1545. }else{
  1546. 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);
  1547. }
  1548. this.expanded = false;
  1549. if (this.view.json.itemStyles) this.categoryTd.setStyles(this.view.json.itemStyles);
  1550. this.setEvent();
  1551. this.view.fireEvent("postLoadCategoryRow", [null, this]);
  1552. },
  1553. setEvent: function(){
  1554. //if (this.selectTd){
  1555. this.node.addEvents({
  1556. "click": function(){this.expandOrCollapse();}.bind(this)
  1557. });
  1558. //}
  1559. },
  1560. expandOrCollapse: function(){
  1561. // var t = this.node.getElement("span").get("html");
  1562. // if (t.indexOf("expand.png")===-1){
  1563. // this.collapse();
  1564. // }else{
  1565. // this.expand();
  1566. // }
  1567. if( this.expanded ){
  1568. this.collapse();
  1569. }else{
  1570. this.expand();
  1571. }
  1572. },
  1573. collapse: function(){
  1574. this.items.each(function(item){
  1575. item.node.setStyle("display", "none");
  1576. }.bind(this));
  1577. if( this.expandNode ){
  1578. this.expandNode.setStyles( this.view.viewJson.viewStyles["groupCollapseNode"] )
  1579. }else{
  1580. this.node.getElement("span").set("html", "<img src='../x_component_query_Query/$Viewer/"+this.view.options.style+"/icon/expand.png'/>");
  1581. }
  1582. this.expanded = false;
  1583. },
  1584. expand: function(){
  1585. this.items.each(function(item){
  1586. item.node.setStyle("display", "table-row");
  1587. }.bind(this));
  1588. if( this.expandNode ){
  1589. this.expandNode.setStyles( this.view.viewJson.viewStyles["groupExpandNode"] )
  1590. }else{
  1591. this.node.getElement("span").set("html", "<img src='../x_component_query_Query/$Viewer/"+this.view.options.style+"/icon/down.png'/>");
  1592. }
  1593. this.expanded = true;
  1594. if (!this.loadChild){
  1595. //window.setTimeout(function(){
  1596. this.data.list.each(function(line, i){
  1597. var s = this.idx+i;
  1598. this.lastItem = new MWF.xApplication.query.Query.Viewer.Item(this.view, line, (this.lastItem || this), s);
  1599. this.items.push(this.lastItem);
  1600. }.bind(this));
  1601. this.loadChild = true;
  1602. //}.bind(this), 10);
  1603. }
  1604. }
  1605. });
  1606. MWF.xApplication.query.Query.Viewer.Filter = new Class({
  1607. initialize: function(viewer, data, node){
  1608. this.viewer = viewer;
  1609. this.data = data;
  1610. this.css = this.viewer.css;
  1611. this.content = node;
  1612. this.load();
  1613. },
  1614. load: function(){
  1615. this.node = new Element("div", {"styles": this.css.viewSearchFilterNode}).inject(this.content);
  1616. if (this.viewer.filterItems.length){
  1617. this.logicNode = new Element("div", {"styles": this.css.viewSearchFilterSelectAreaNode}).inject(this.node);
  1618. this.logicSelectNode = new Element("div", {
  1619. "styles": this.css.viewSearchFilterSelectNode,
  1620. "text": this.viewer.lp.and,
  1621. "value": "and"
  1622. }).inject(this.logicNode);
  1623. this.logicSelectButtonNode = new Element("div", {"styles": this.css.viewSearchFilterSelectButtonNode}).inject(this.logicNode);
  1624. this.logicNode.addEvents({
  1625. "click": function(){
  1626. var v = this.logicSelectNode.get("value");
  1627. if (v==="and"){
  1628. this.logicSelectButtonNode.setStyle("float", "left");
  1629. this.logicSelectNode.setStyle("float", "right");
  1630. this.logicSelectNode.set({
  1631. "text": this.viewer.lp.or,
  1632. "value": "or"
  1633. });
  1634. this.data.logic = "or";
  1635. }else{
  1636. this.logicSelectButtonNode.setStyle("float", "right");
  1637. this.logicSelectNode.setStyle("float", "left");
  1638. this.logicSelectNode.set({
  1639. "text": this.viewer.lp.and,
  1640. "value": "and"
  1641. });
  1642. this.data.logic = "and";
  1643. }
  1644. this.viewer.searchCustomView();
  1645. }.bind(this)
  1646. });
  1647. }
  1648. this.titleNode = new Element("div", {"styles": this.css.viewSearchFilterTextNode, "text": this.data.title}).inject(this.node);
  1649. this.comparisonTitleNode = new Element("div", {"styles": this.css.viewSearchFilterTextNode, "text": this.data.comparisonTitle}).inject(this.node);
  1650. this.valueNode = new Element("div", {"styles": this.css.viewSearchFilterTextNode, "text": "\""+this.data.value+"\""}).inject(this.node);
  1651. this.deleteNode = new Element("div", {"styles": this.css.viewSearchFilterDeleteNode}).inject(this.node);
  1652. this.node.addEvents({
  1653. "mouseover": function(){
  1654. this.node.setStyles(this.css.viewSearchFilterNode_over);
  1655. this.deleteNode.setStyles(this.css.viewSearchFilterDeleteNode_over);
  1656. }.bind(this),
  1657. "mouseout": function(){
  1658. this.node.setStyles(this.css.viewSearchFilterNode);
  1659. this.deleteNode.setStyles(this.css.viewSearchFilterDeleteNode);
  1660. }.bind(this)
  1661. });
  1662. this.deleteNode.addEvent("click", function(){
  1663. this.viewer.searchViewRemoveFilter(this);
  1664. }.bind(this));
  1665. },
  1666. destroy: function(){
  1667. this.node.destroy();
  1668. MWF.release(this);
  1669. }
  1670. });
  1671. MWF.xApplication.query.Query.Viewer.Actionbar = new Class({
  1672. Implements: [Events],
  1673. options: {
  1674. "style" : "default",
  1675. "moduleEvents": ["load", "queryLoad", "postLoad", "afterLoad"]
  1676. },
  1677. initialize: function(node, json, form, options){
  1678. this.node = $(node);
  1679. this.node.store("module", this);
  1680. this.json = json;
  1681. this.form = form;
  1682. this.view = form;
  1683. },
  1684. hide: function(){
  1685. var dsp = this.node.getStyle("display");
  1686. if (dsp!=="none") this.node.store("mwf_display", dsp);
  1687. this.node.setStyle("display", "none");
  1688. },
  1689. show: function(){
  1690. var dsp = this.node.retrieve("mwf_display", dsp);
  1691. this.node.setStyle("display", dsp);
  1692. },
  1693. load: function(){
  1694. this._loadModuleEvents();
  1695. if (this.fireEvent("queryLoad")){
  1696. //this._queryLoaded();
  1697. this._loadUserInterface();
  1698. this._loadStyles();
  1699. this._loadDomEvents();
  1700. //this._loadEvents();
  1701. //this._afterLoaded();
  1702. this.fireEvent("postLoad");
  1703. this.fireEvent("load");
  1704. }
  1705. },
  1706. _loadStyles: function(){
  1707. if (this.json.styles) Object.each(this.json.styles, function(value, key){
  1708. if ((value.indexOf("x_processplatform_assemble_surface")!=-1 || value.indexOf("x_portal_assemble_surface")!=-1 || value.indexOf("x_cms_assemble_control")!=-1)){
  1709. var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface");
  1710. var host2 = MWF.Actions.getHost("x_portal_assemble_surface");
  1711. var host3 = MWF.Actions.getHost("x_cms_assemble_control");
  1712. if (value.indexOf("/x_processplatform_assemble_surface")!==-1){
  1713. value = value.replace("/x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  1714. }else if (value.indexOf("x_processplatform_assemble_surface")!==-1){
  1715. value = value.replace("x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  1716. }
  1717. if (value.indexOf("/x_portal_assemble_surface")!==-1){
  1718. value = value.replace("/x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  1719. }else if (value.indexOf("x_portal_assemble_surface")!==-1){
  1720. value = value.replace("x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  1721. }
  1722. if (value.indexOf("/x_cms_assemble_control")!==-1){
  1723. value = value.replace("/x_cms_assemble_control", host3+"/x_cms_assemble_control");
  1724. }else if (value.indexOf("x_cms_assemble_control")!==-1){
  1725. value = value.replace("x_cms_assemble_control", host3+"/x_cms_assemble_control");
  1726. }
  1727. }
  1728. this.node.setStyle(key, value);
  1729. }.bind(this));
  1730. // if (["x_processplatform_assemble_surface", "x_portal_assemble_surface"].indexOf(root.toLowerCase())!==-1){
  1731. // var host = MWF.Actions.getHost(root);
  1732. // return (flag==="/") ? host+this.json.template : host+"/"+this.json.template
  1733. // }
  1734. //if (this.json.styles) this.node.setStyles(this.json.styles);
  1735. },
  1736. _loadModuleEvents : function(){
  1737. Object.each(this.json.events, function(e, key){
  1738. if (e.code){
  1739. if (this.options.moduleEvents.indexOf(key)!==-1){
  1740. this.addEvent(key, function(event){
  1741. return this.form.Macro.fire(e.code, this, event);
  1742. }.bind(this));
  1743. }
  1744. }
  1745. }.bind(this));
  1746. },
  1747. _loadDomEvents: function(){
  1748. Object.each(this.json.events, function(e, key){
  1749. if (e.code){
  1750. if (this.options.moduleEvents.indexOf(key)===-1){
  1751. this.node.addEvent(key, function(event){
  1752. return this.form.Macro.fire(e.code, this, event);
  1753. }.bind(this));
  1754. }
  1755. }
  1756. }.bind(this));
  1757. },
  1758. _loadEvents: function(){
  1759. Object.each(this.json.events, function(e, key){
  1760. if (e.code){
  1761. if (this.options.moduleEvents.indexOf(key)!==-1){
  1762. this.addEvent(key, function(event){
  1763. return this.form.Macro.fire(e.code, this, event);
  1764. }.bind(this));
  1765. }else{
  1766. this.node.addEvent(key, function(event){
  1767. return this.form.Macro.fire(e.code, this, event);
  1768. }.bind(this));
  1769. }
  1770. }
  1771. }.bind(this));
  1772. },
  1773. addModuleEvent: function(key, fun){
  1774. if (this.options.moduleEvents.indexOf(key)!==-1){
  1775. this.addEvent(key, function(event){
  1776. return (fun) ? fun(this, event) : null;
  1777. }.bind(this));
  1778. }else{
  1779. this.node.addEvent(key, function(event){
  1780. return (fun) ? fun(this, event) : null;
  1781. }.bind(this));
  1782. }
  1783. },
  1784. _loadUserInterface: function(){
  1785. // if (this.form.json.mode == "Mobile"){
  1786. // this.node.empty();
  1787. // }else if (COMMON.Browser.Platform.isMobile){
  1788. // this.node.empty();
  1789. // }else{
  1790. this.toolbarNode = this.node.getFirst("div");
  1791. if( !this.toolbarNode ){
  1792. this.toolbarNode = new Element("div").inject( this.node );
  1793. }
  1794. this.toolbarNode.empty();
  1795. MWF.require("MWF.widget.Toolbar", function(){
  1796. this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {
  1797. "style": this.json.style,
  1798. "onPostLoad" : function(){
  1799. this.fireEvent("afterLoad");
  1800. }.bind(this)
  1801. }, this);
  1802. if (this.json.actionStyles) this.toolbarWidget.css = this.json.actionStyles;
  1803. //alert(this.readonly)
  1804. if (this.json.hideSystemTools){
  1805. this.setCustomToolbars(this.json.tools, this.toolbarNode);
  1806. this.toolbarWidget.load();
  1807. }else{
  1808. if (this.json.defaultTools){
  1809. this.setToolbars(this.json.defaultTools, this.toolbarNode, this.readonly);
  1810. this.setCustomToolbars(this.json.tools, this.toolbarNode);
  1811. this.toolbarWidget.load();
  1812. }else{
  1813. MWF.getJSON(this.form.path+"toolbars.json", function(json){
  1814. this.setToolbars(json, this.toolbarNode, this.readonly, true);
  1815. this.setCustomToolbars(this.json.tools, this.toolbarNode);
  1816. this.toolbarWidget.load();
  1817. }.bind(this), null);
  1818. }
  1819. }
  1820. }.bind(this));
  1821. // }
  1822. },
  1823. setCustomToolbars: function(tools, node){
  1824. var path = "../x_component_process_FormDesigner/Module/Actionbar/";
  1825. var iconPath = "";
  1826. if( this.json.customIconStyle ){
  1827. iconPath = this.json.customIconStyle+"/";
  1828. }
  1829. tools.each(function(tool){
  1830. var flag = true;
  1831. if (this.readonly){
  1832. flag = tool.readShow;
  1833. }else{
  1834. flag = tool.editShow;
  1835. }
  1836. if (flag){
  1837. flag = true;
  1838. // if (tool.control){
  1839. // flag = this.form.businessData.control[tool.control]
  1840. // }
  1841. if (tool.condition){
  1842. var hideFlag = this.form.Macro.exec(tool.condition, this);
  1843. flag = !hideFlag;
  1844. }
  1845. if (flag){
  1846. var actionNode = new Element("div", {
  1847. "id": tool.id,
  1848. "MWFnodetype": tool.type,
  1849. "MWFButtonImage": path+""+this.form.options.style+"/custom/"+iconPath+tool.img,
  1850. "title": tool.title,
  1851. "MWFButtonAction": "runCustomAction",
  1852. "MWFButtonText": tool.text
  1853. }).inject(node);
  1854. if( this.json.customIconOverStyle ){
  1855. actionNode.set("MWFButtonImageOver" , path+""+this.form.options.style +"/custom/"+this.json.customIconOverStyle+ "/" +tool.img );
  1856. }
  1857. if( tool.properties ){
  1858. actionNode.set(tool.properties);
  1859. }
  1860. if (tool.actionScript){
  1861. actionNode.store("script", tool.actionScript);
  1862. }
  1863. if (tool.sub){
  1864. var subNode = node.getLast();
  1865. this.setCustomToolbars(tool.sub, subNode);
  1866. }
  1867. }
  1868. }
  1869. }.bind(this));
  1870. },
  1871. setToolbarItem: function(tool, node, readonly, noCondition){
  1872. //var path = "../x_component_process_FormDesigner/Module/Actionbar/";
  1873. var path = "../x_component_query_ViewDesigner/$View/";
  1874. var flag = true;
  1875. // if (tool.control){
  1876. // flag = this.form.businessData.control[tool.control]
  1877. // }
  1878. if (!noCondition) if (tool.condition){
  1879. var hideFlag = this.form.Macro.exec(tool.condition, this);
  1880. flag = flag && (!hideFlag);
  1881. }
  1882. if (readonly) if (!tool.read) flag = false;
  1883. if (flag){
  1884. var actionNode = new Element("div", {
  1885. "id": tool.id,
  1886. "MWFnodetype": tool.type,
  1887. //"MWFButtonImage": this.form.path+""+this.form.options.style+"/actionbar/"+tool.img,
  1888. //"MWFButtonImage": path+(this.options.style||"default") +"/tools/"+ (this.json.style || "default") +"/"+tool.img,
  1889. "MWFButtonImage": path+this.options.style+"/actionbar/"+ ( this.json.iconStyle || "default" ) +"/"+tool.img,
  1890. "title": tool.title,
  1891. "MWFButtonAction": tool.action,
  1892. "MWFButtonText": tool.text
  1893. }).inject(node);
  1894. if( this.json.iconOverStyle ){
  1895. actionNode.set("MWFButtonImageOver" , path+""+this.options.style+"/actionbar/"+this.json.iconOverStyle+"/"+tool.img );
  1896. //actionNode.set("MWFButtonImageOver" , path+""+(this.options.style||"default")+"/tools/"+( this.json.iconOverStyle || "default" )+"/"+tool.img );
  1897. }
  1898. if( tool.properties ){
  1899. actionNode.set(tool.properties);
  1900. }
  1901. if (tool.sub){
  1902. var subNode = node.getLast();
  1903. this.setToolbars(tool.sub, subNode, readonly, noCondition);
  1904. }
  1905. }
  1906. },
  1907. setToolbars: function(tools, node, readonly, noCondition){
  1908. tools.each(function(tool){
  1909. this.setToolbarItem(tool, node, readonly, noCondition);
  1910. }.bind(this));
  1911. },
  1912. runCustomAction: function(bt){
  1913. var script = bt.node.retrieve("script");
  1914. this.form.Macro.exec(script, this);
  1915. },
  1916. exportView : function(){
  1917. this.form.exportView();
  1918. },
  1919. deleteWork: function(){
  1920. this.form.deleteWork();
  1921. }
  1922. });
  1923. MWF.xApplication.query.Query.Viewer.Paging = new Class({
  1924. Implements: [Events],
  1925. options: {
  1926. "style" : "default",
  1927. "moduleEvents": ["load", "queryLoad", "postLoad", "afterLoad","jump"]
  1928. },
  1929. initialize: function(node, json, form, options){
  1930. this.node = $(node);
  1931. this.node.store("module", this);
  1932. this.json = json;
  1933. this.form = form;
  1934. this.view = form;
  1935. },
  1936. hide: function(){
  1937. var dsp = this.node.getStyle("display");
  1938. if (dsp!=="none") this.node.store("mwf_display", dsp);
  1939. this.node.setStyle("display", "none");
  1940. },
  1941. show: function(){
  1942. var dsp = this.node.retrieve("mwf_display", dsp);
  1943. this.node.setStyle("display", dsp);
  1944. },
  1945. load: function(){
  1946. this._loadModuleEvents();
  1947. if (this.fireEvent("queryLoad")){
  1948. //this._queryLoaded();
  1949. this._loadUserInterface();
  1950. this._loadStyles();
  1951. this._loadDomEvents();
  1952. //this._loadEvents();
  1953. //this._afterLoaded();
  1954. this.fireEvent("postLoad");
  1955. }
  1956. },
  1957. _loadStyles: function(){
  1958. if (this.json.styles) Object.each(this.json.styles, function(value, key){
  1959. if ((value.indexOf("x_processplatform_assemble_surface")!=-1 || value.indexOf("x_portal_assemble_surface")!=-1 || value.indexOf("x_cms_assemble_control")!=-1)){
  1960. var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface");
  1961. var host2 = MWF.Actions.getHost("x_portal_assemble_surface");
  1962. var host3 = MWF.Actions.getHost("x_cms_assemble_control");
  1963. if (value.indexOf("/x_processplatform_assemble_surface")!==-1){
  1964. value = value.replace("/x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  1965. }else if (value.indexOf("x_processplatform_assemble_surface")!==-1){
  1966. value = value.replace("x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  1967. }
  1968. if (value.indexOf("/x_portal_assemble_surface")!==-1){
  1969. value = value.replace("/x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  1970. }else if (value.indexOf("x_portal_assemble_surface")!==-1){
  1971. value = value.replace("x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  1972. }
  1973. if (value.indexOf("/x_cms_assemble_control")!==-1){
  1974. value = value.replace("/x_cms_assemble_control", host3+"/x_cms_assemble_control");
  1975. }else if (value.indexOf("x_cms_assemble_control")!==-1){
  1976. value = value.replace("x_cms_assemble_control", host3+"/x_cms_assemble_control");
  1977. }
  1978. }
  1979. this.node.setStyle(key, value);
  1980. }.bind(this));
  1981. // if (["x_processplatform_assemble_surface", "x_portal_assemble_surface"].indexOf(root.toLowerCase())!==-1){
  1982. // var host = MWF.Actions.getHost(root);
  1983. // return (flag==="/") ? host+this.json.template : host+"/"+this.json.template
  1984. // }
  1985. //if (this.json.styles) this.node.setStyles(this.json.styles);
  1986. },
  1987. _loadModuleEvents : function(){
  1988. Object.each(this.json.events, function(e, key){
  1989. if (e.code){
  1990. if (this.options.moduleEvents.indexOf(key)!==-1){
  1991. this.addEvent(key, function(event){
  1992. return this.form.Macro.fire(e.code, this, event);
  1993. }.bind(this));
  1994. }
  1995. }
  1996. }.bind(this));
  1997. },
  1998. _loadDomEvents: function(){
  1999. Object.each(this.json.events, function(e, key){
  2000. if (e.code){
  2001. if (this.options.moduleEvents.indexOf(key)===-1){
  2002. this.node.addEvent(key, function(event){
  2003. return this.form.Macro.fire(e.code, this, event);
  2004. }.bind(this));
  2005. }
  2006. }
  2007. }.bind(this));
  2008. },
  2009. _loadEvents: function(){
  2010. Object.each(this.json.events, function(e, key){
  2011. if (e.code){
  2012. if (this.options.moduleEvents.indexOf(key)!==-1){
  2013. this.addEvent(key, function(event){
  2014. return this.form.Macro.fire(e.code, this, event);
  2015. }.bind(this));
  2016. }else{
  2017. this.node.addEvent(key, function(event){
  2018. return this.form.Macro.fire(e.code, this, event);
  2019. }.bind(this));
  2020. }
  2021. }
  2022. }.bind(this));
  2023. },
  2024. addModuleEvent: function(key, fun){
  2025. if (this.options.moduleEvents.indexOf(key)!==-1){
  2026. this.addEvent(key, function(event){
  2027. return (fun) ? fun(this, event) : null;
  2028. }.bind(this));
  2029. }else{
  2030. this.node.addEvent(key, function(event){
  2031. return (fun) ? fun(this, event) : null;
  2032. }.bind(this));
  2033. }
  2034. },
  2035. _loadUserInterface: function(){
  2036. // if (this.form.json.mode == "Mobile"){
  2037. // this.node.empty();
  2038. // }else if (COMMON.Browser.Platform.isMobile){
  2039. // this.node.empty();
  2040. // }else{
  2041. this.loadPaging( true )
  2042. },
  2043. reload : function(){
  2044. this.loadPaging( false )
  2045. },
  2046. loadPaging : function( firstLoading ){
  2047. // this.pagingNode = this.node.getFirst("div");
  2048. // if( !this.pagingNode ){
  2049. // this.pagingNode = new Element("div").inject( this.node );
  2050. // }
  2051. // this.pagingNode.empty();
  2052. this.node.empty();
  2053. this.paging = new o2.widget.Paging(this.node, {
  2054. //style : this.options.skin && this.options.skin.pagingBar ? this.options.skin.pagingBar : "default",
  2055. countPerPage: this.view.json.pageSize || this.view.options.perPageCount,
  2056. visiblePages: layout.mobile?5:(this.json.visiblePages ? this.json.visiblePages.toInt() : 9),
  2057. currentPage: this.view.currentPage,
  2058. itemSize: this.view.count,
  2059. pageSize: this.view.pages,
  2060. hasNextPage: typeOf( this.json.hasPreNextPage ) === "boolean" ? this.json.hasPreNextPage : true,
  2061. hasPrevPage: typeOf( this.json.hasPreNextPage ) === "boolean" ? this.json.hasPreNextPage : true,
  2062. hasTruningBar: typeOf( this.json.hasTruningBar ) === "boolean" ? this.json.hasTruningBar : true,
  2063. hasBatchTuring: typeOf( this.json.hasBatchTuring ) === "boolean" ? this.json.hasBatchTuring : true,
  2064. hasFirstPage: typeOf( this.json.hasFirstLastPage ) === "boolean" ? this.json.hasFirstLastPage : (layout.mobile?false:true),
  2065. hasLastPage: typeOf( this.json.hasFirstLastPage ) === "boolean" ? this.json.hasFirstLastPage : (layout.mobile?false:true),
  2066. hasJumper: typeOf( this.json.hasPageJumper ) === "boolean" ? this.json.hasPageJumper : (layout.mobile?false:true),
  2067. hiddenWithDisable: false,
  2068. hiddenWithNoItem: true,
  2069. text: {
  2070. prePage: this.json.prePageText,
  2071. nextPage: this.json.nextPageText,
  2072. firstPage: this.json.firstPageText,
  2073. lastPage: this.json.lastPageText
  2074. },
  2075. onJumpingPage : function( pageNum, itemNum ){
  2076. this.view.currentPage = pageNum;
  2077. this.fireEvent("jump");
  2078. this.view.loadCurrentPageData( null, false );
  2079. }.bind(this),
  2080. onPostLoad : function () {
  2081. if( firstLoading ){
  2082. if(this.view.setContentHeightFun)this.view.setContentHeightFun();
  2083. this.fireEvent("load");
  2084. }
  2085. this.fireEvent("afterLoad");
  2086. }.bind(this)
  2087. }, this.json.pagingStyles || {});
  2088. this.paging.load();
  2089. }
  2090. });