Viewer.js 118 KB

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