ViewExplorer.js 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322
  1. MWF.xApplication.cms = MWF.xApplication.cms || {};
  2. MWF.xApplication.cms.Module = MWF.xApplication.cms.Module || {};
  3. MWF.require("MWF.xAction.org.express.RestActions", null,false);
  4. MWF.xDesktop.requireApp("cms.Module", "lp."+MWF.language, null, false);
  5. MWF.xDesktop.requireApp("cms.Module", "package", null, false);
  6. MWF.xDesktop.requireApp("process.Application", "Viewer", null, false);
  7. MWF.xDesktop.requireApp("query.Query", "Viewer", null, false);
  8. MWF.xApplication.cms.Module.ViewExplorer = new Class({
  9. Extends: MWF.widget.Common,
  10. Implements: [Options, Events],
  11. options: {
  12. "style": "default",
  13. "isAdmin": false,
  14. "searchKey" : ""
  15. },
  16. initialize: function( node, app, columnData, categoryData, revealData, options, searchNode ){
  17. this.setOptions(options);
  18. this.node = node;
  19. this.app = app;
  20. this.columnData = columnData;
  21. this.categoryData = categoryData;
  22. this.revealData = revealData;
  23. this.searchNode = searchNode;
  24. this.path = "../x_component_cms_Module/$ViewExplorer/";
  25. this.cssPath = "../x_component_cms_Module/$ViewExplorer/"+this.options.style+"/css.wcss";
  26. this._loadCss();
  27. },
  28. reload: function(){
  29. this.node.empty();
  30. this.searchNode.empty();
  31. this.load();
  32. },
  33. load : function(){
  34. this.loadContentNode();
  35. this.loadQuryView();
  36. //if( this.revealData.viewType ){
  37. // this.loadQuryView(); //QeuryView
  38. //}else{
  39. // this.loadView(); //CMSView
  40. //}
  41. },
  42. loadContentNode: function(){
  43. this.elementContentNode = new Element("div", {
  44. "styles": this.css.elementContentNode
  45. }).inject(this.node);
  46. this.searchContainer = new Element("div",{
  47. "styles" : this.css.searchContainer
  48. }).inject( this.searchNode );
  49. this.resizeFun = function(){this.setContentSize();}.bind(this);
  50. this.app.addEvent("resize", this.resizeFun );
  51. },
  52. loadQuryView : function(){
  53. var viewJson = {
  54. "application": this.revealData.appName,
  55. "viewName": this.revealData.name,
  56. "isTitle": "yes",
  57. "select": "none",
  58. "titleStyles": this.css.normalThNode,
  59. "itemStyles": {},
  60. // "isExpand": "no",
  61. "filter": []
  62. };
  63. this.view = new MWF.xApplication.cms.Module.QueryViewer(this.elementContentNode, viewJson, {
  64. "hasAction" : this.options.isAdmin,
  65. "resizeNode": true,
  66. "selectEnable" : this.selectEnable,
  67. "onSelect": function(){
  68. this.fireEvent("select");
  69. }.bind(this)
  70. }, this.app, this.searchContainer);
  71. this.setContentSize();
  72. },
  73. //loadView : function(){
  74. // var viewJson = {
  75. // "application": this.columnData.id,
  76. // "viewName": this.revealData.name,
  77. // "isTitle": "yes",
  78. // "select": "none", //none , single, multi
  79. // "titleStyles": this.css.normalThNode,
  80. // "isExpand": "no",
  81. // "itemStyles": {}
  82. // };
  83. //
  84. // this.view = new MWF.xApplication.cms.Module.Viewer(this.elementContentNode, viewJson, {
  85. // "type" : "cms",
  86. // "hasAction" : this.options.isAdmin,
  87. // "actions": {
  88. // //"lookup": {"uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}/execute", "method":"PUT"},
  89. // //"getView": {"uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}"},
  90. // "lookup": {"uri": "/jaxrs/view/{view}/execute", "method":"PUT"},
  91. // "getView": {"uri": "/jaxrs/view/{view}"},
  92. // "deleteDocument" : {"uri":"/jaxrs/document/{id}","method": "DELETE"}
  93. // },
  94. // "actionRoot": "x_query_assemble_surface",
  95. // "resizeNode": true,
  96. // "selectEnable" : this.selectEnable,
  97. // "onSelect": function(){
  98. // this.fireEvent("select");
  99. // }.bind(this)
  100. // }, this.app, this.searchContainer);
  101. //
  102. // this.setContentSize();
  103. //},
  104. selectMode : function(){
  105. this.selectEnable = true;
  106. this.view.selectMode()
  107. },
  108. disableSelectMode : function(){
  109. this.selectEnable = false;
  110. this.view.disableSelectMode()
  111. },
  112. getSelectedIds : function(){
  113. return this.view.getSelectedIds();
  114. },
  115. setContentSize: function(){
  116. var toolbarSize = this.toolbarNode ? this.toolbarNode.getSize() : {"x":0,"y":0};
  117. var titlebarSize = {"x":0,"y":0}; //this.app.titleBar ? this.app.titleBar.getSize() : {"x":0,"y":0};
  118. var nodeSize = this.app.node.getSize();
  119. var pt = 0; //this.elementContentNode.getStyle("padding-top").toFloat();
  120. var pb = 0; // this.elementContentNode.getStyle("padding-bottom").toFloat();
  121. var filterConditionSize = this.filterConditionNode ? this.filterConditionNode.getSize() : {"x":0,"y":0};
  122. var height = nodeSize.y-toolbarSize.y-pt-pb-filterConditionSize.y-titlebarSize.y;
  123. this.elementContentNode.setStyle("height", ""+height+"px");
  124. if( this.view )this.view.setContentHeight();
  125. }
  126. });
  127. MWF.xApplication.cms.Module.QueryViewer = new Class({
  128. Implements: [Options, Events],
  129. Extends: MWF.QViewer,
  130. options: {
  131. "style": "default",
  132. "hasAction" : false, //cxy add
  133. "resizeNode": true,
  134. "paging" : "scroll",
  135. "perPageCount" : 50,
  136. "selectEnable" : false
  137. },
  138. initialize: function(container, json, options, app, searchContainer){
  139. this.setOptions(options);
  140. this.app = app;
  141. this.searchContainer = searchContainer;
  142. this.path = "../x_component_cms_Module/$ViewExplorer/";
  143. this.cssPath = "../x_component_cms_Module/$ViewExplorer/"+this.options.style+"/viewer.wcss";
  144. this._loadCss();
  145. this.lp = MWF.xApplication.query.Query.LP;
  146. this.container = $(container);
  147. this.json = json;
  148. this.viewJson = null;
  149. this.filterItems = [];
  150. this.searchStatus = "none"; //none, custom, default
  151. this.originalJson = Object.clone(json);
  152. this.selectEnable = this.options.selectEnable;
  153. this.items = [];
  154. this.selectedItems = [];
  155. this.hideColumns = [];
  156. this.openColumns = [];
  157. this.gridJson = null;
  158. this.init(function(){
  159. this.load();
  160. }.bind(this));
  161. },
  162. selectMode : function(){
  163. this.selectEnable = true;
  164. this.createSelectTh();
  165. this.items.each( function (it) {
  166. if( it.clazzType == "category" ){
  167. it.items.each( function(i){
  168. i.createSelectTd();
  169. })
  170. }else{
  171. it.createSelectTd();
  172. }
  173. }.bind(this));
  174. },
  175. disableSelectMode : function(){
  176. this.selectEnable = false;
  177. this.destroySelectTh();
  178. this.items.each( function (it) {
  179. if( it.clazzType == "category" ){
  180. it.items.each( function(i){
  181. i.destroySelectTd();
  182. })
  183. }else{
  184. it.destroySelectTd();
  185. }
  186. }.bind(this));
  187. },
  188. destroySelectTh : function(){
  189. if( this.selectTh ){
  190. this.selectTh.destroy();
  191. this.selectTh = null;
  192. }
  193. },
  194. createSelectTh : function(){
  195. var viewStyles = this.viewJson.viewStyles;
  196. var viewTitleCellNode = (viewStyles && viewStyles["titleTd"]) ? viewStyles["titleTd"] : this.css.viewTitleCellNode;
  197. this.selectTh = new Element("td",{
  198. styles: viewTitleCellNode
  199. }).inject(this.viewTitleLine, "top");
  200. this.selectTh.setStyles({width:"20px"});
  201. this.checkboxElement = new Element("input", {
  202. "type": "checkbox"
  203. }).inject(this.selectTh);
  204. this.checkboxElement.addEvent("click", function () {
  205. this.selectAll()
  206. }.bind(this));
  207. },
  208. selectAll : function () {
  209. var flag = this.checkboxElement.get("checked");
  210. this.items.each(function (it) {
  211. if( it.clazzType == "category" ){
  212. it.expand();
  213. it.items.each( function(i){
  214. if (i.checkboxElement)i.checkboxElement.set("checked", flag)
  215. })
  216. }else{
  217. if (it.checkboxElement)it.checkboxElement.set("checked", flag)
  218. }
  219. }.bind(this))
  220. },
  221. getSelectedIds : function(){
  222. var checkedItems = [];
  223. this.items.each(function (it) {
  224. if( it.clazzType == "category" ){
  225. it.items.each( function(i){
  226. if (i.checkboxElement.get("checked")) {
  227. checkedItems.push( i.data.bundle )
  228. }
  229. })
  230. }else{
  231. if (it.checkboxElement.get("checked")) {
  232. checkedItems.push( it.data.bundle )
  233. }
  234. }
  235. }.bind(this));
  236. return checkedItems;
  237. },
  238. getSelectedItems : function(){
  239. var checkedItems = [];
  240. this.items.each(function (it) {
  241. if( it.clazzType == "category" ){
  242. it.items.each( function(i){
  243. if (i.checkboxElement.get("checked")) {
  244. checkedItems.push( i )
  245. }
  246. })
  247. }else{
  248. if (it.checkboxElement.get("checked")) {
  249. checkedItems.push( it )
  250. }
  251. }
  252. }.bind(this));
  253. return checkedItems;
  254. },
  255. createViewNode: function(data){
  256. this.viewAreaNode.empty();
  257. var viewStyles = this.viewJson.viewStyles;
  258. this.contentAreaNode = new Element("div", {"styles":
  259. (viewStyles && viewStyles["container"]) ? viewStyles["container"] : this.css.contentAreaNode
  260. }).inject(this.viewAreaNode);
  261. this.viewTable = new Element("table.viewTable", {
  262. "styles": this.css.viewTitleTableNode,
  263. "border": "0px",
  264. "cellPadding": "0",
  265. "cellSpacing": "0"
  266. }).inject(this.contentAreaNode);
  267. if( viewStyles ){
  268. if( viewStyles["tableProperties"] )this.viewTable.set(viewStyles["tableProperties"]);
  269. if( viewStyles["table"] )this.viewTable.setStyles(viewStyles["table"]);
  270. }
  271. this.createLoadding();
  272. var viewTitleCellNode = (viewStyles && viewStyles["titleTd"]) ? viewStyles["titleTd"] : this.css.viewTitleCellNode;
  273. debugger;
  274. if (this.json.isTitle!=="no"){
  275. this.viewTitleLine = new Element("tr.viewTitleLine", {
  276. "styles": (viewStyles && viewStyles["titleTr"]) ? viewStyles["titleTr"] : this.css.viewTitleLineNode
  277. }).inject(this.viewTable);
  278. if( this.selectEnable ){
  279. this.createSelectTh();
  280. }
  281. //if (this.json.select==="single" || this.json.select==="multi") {
  282. this.selectTitleCell = new Element("td", {
  283. "styles": viewTitleCellNode
  284. }).inject(this.viewTitleLine);
  285. this.selectTitleCell.setStyle("width", "10px");
  286. // if (this.json.titleStyles) this.selectTitleCell.setStyles(this.json.titleStyles);
  287. //}
  288. this.viewJson.firstTdHidden = true;
  289. if( this.json.defaultSelectedScript )this.json.defaultSelectedScript = "";
  290. if( this.viewJson.defaultSelectedScript )this.viewJson.defaultSelectedScript = "";
  291. if( this.json.selectedAbleScript )this.json.selectedAbleScript = "";
  292. if( this.viewJson.selectedAbleScript )this.viewJson.selectedAbleScript = "";
  293. if( this.isSelectTdHidden() ){
  294. this.selectTitleCell.hide();
  295. }
  296. //序号
  297. if (this.viewJson.isSequence==="yes"){
  298. this.sequenceTitleCell = new Element("td", {
  299. "styles": viewTitleCellNode
  300. }).inject(this.viewTitleLine);
  301. this.sequenceTitleCell.setStyle("width", "10px");
  302. // if (this.json.titleStyles) this.sequenceTitleCell.setStyles(this.json.titleStyles);
  303. }
  304. this.entries = {};
  305. this.viewJson.selectList.each(function(column){
  306. this.entries[column.column] = column;
  307. if (!column.hideColumn){
  308. var viewCell = new Element("td", {
  309. "styles": viewTitleCellNode,
  310. "text": column.displayName
  311. }).inject(this.viewTitleLine);
  312. var size = MWF.getTextSize(column.displayName, viewTitleCellNode);
  313. viewCell.setStyle("min-width", ""+size.x+"px");
  314. // if (this.json.titleStyles) viewCell.setStyles(this.json.titleStyles);
  315. }else{
  316. this.hideColumns.push(column.column);
  317. }
  318. if (column.allowOpen) this.openColumns.push(column.column);
  319. }.bind(this));
  320. if( this.options.hasAction ){
  321. var viewCell = new Element("td", {
  322. "styles": viewTitleCellNode,
  323. "text": this.lp.action
  324. }).inject(this.viewTitleLine);
  325. viewCell.setStyle("width","40px");
  326. // if (this.json.titleStyles) viewCell.setStyles(this.json.titleStyles);
  327. }
  328. this.lookup(data);
  329. }else{
  330. this.entries = {};
  331. this.viewJson.selectList.each(function(column){
  332. this.entries[column.column] = column;
  333. if (column.hideColumn) this.hideColumns.push(column.column);
  334. if (!column.allowOpen) this.openColumns.push(column.column);
  335. }.bind(this));
  336. this.lookup(data);
  337. }
  338. },
  339. loadLayout: function(){
  340. this.node = new Element("div", {"styles": this.css.node}).inject(this.container);
  341. this.actionbarAreaNode = new Element("div.actionbarAreaNode", {"styles": this.css.actionbarAreaNode}).inject(this.node);
  342. // if (this.options.export) this.exportAreaNode = new Element("div", {"styles": this.css.exportAreaNode}).inject(this.node);
  343. this.searchAreaNode = new Element("div", {"styles": this.css.searchAreaNode}).inject(this.searchContainer || this.node );
  344. this.viewAreaNode = new Element("div.viewAreaNode", {"styles": this.css.viewAreaNode}).inject(this.node);
  345. // this.viewPageNode = new Element("div", {"styles": this.css.viewPageNode}).inject(this.node);
  346. this.viewPageAreaNode = new Element("div", {"styles": this.css.viewPageAreaNode}).inject(this.node);
  347. },
  348. //loadData: function(){
  349. // if (this.gridJson.length){
  350. // this.gridJson.each(function(line, i){
  351. // this.items.push(new MWF.xApplication.cms.Module.QueryViewer.Item(this, line, null, i));
  352. // }.bind(this));
  353. // }
  354. //},
  355. loadData: function(){
  356. if( this.checkboxElement ){
  357. this.checkboxElement.set("checked", false )
  358. }
  359. if (this.gridJson.length){
  360. if( !this.options.paging ){
  361. this.gridJson.each(function(line, i){
  362. this.items.push(new MWF.xApplication.cms.Module.QueryViewer.Item(this, line, null, i));
  363. }.bind(this));
  364. }else{
  365. this.loadPaging();
  366. }
  367. }else{
  368. if (this.viewPageAreaNode) this.viewPageAreaNode.empty();
  369. }
  370. },
  371. loadPaging : function(){
  372. this.isItemsLoading = false;
  373. this.pageNumber = 0;
  374. this.isItemsLoaded = false;
  375. this.isSetedScroll = false;
  376. this.setScroll();
  377. this.loadDataByPaging()
  378. },
  379. setScroll : function(){
  380. if( this.options.paging && !this.isSetedScroll ){
  381. this.contentAreaNode.setStyle("overflow","auto");
  382. this.scrollContainerFun = function(){
  383. var scrollSize = this.contentAreaNode.getScrollSize();
  384. var clientSize = this.contentAreaNode.getSize();
  385. var scrollHeight = scrollSize.y - clientSize.y;
  386. //alert( "clientSize.y=" + clientSize.y + " scrollSize.y="+scrollSize.y + " this.contentAreaNode.scrollTop="+this.contentAreaNode.scrollTop);
  387. if (this.contentAreaNode.scrollTop + 150 > scrollHeight ) {
  388. if (!this.isItemsLoaded) this.loadDataByPaging();
  389. }
  390. }.bind(this);
  391. this.isSetedScroll = true;
  392. this.contentAreaNode.addEvent("scroll", this.scrollContainerFun )
  393. }
  394. },
  395. loadDataByPaging : function(){
  396. if( this.isItemsLoading )return;
  397. if( !this.isItemsLoaded ){
  398. var from = Math.min( this.pageNumber * this.options.perPageCount , this.gridJson.length);
  399. var to = Math.min( ( this.pageNumber + 1 ) * this.options.perPageCount + 1 , this.gridJson.length);
  400. this.isItemsLoading = true;
  401. for( var i = from; i<to; i++ ){
  402. this.items.push(new MWF.xApplication.cms.Module.QueryViewer.Item(this, this.gridJson[i], null, i));
  403. }
  404. this.isItemsLoading = false;
  405. this.pageNumber ++;
  406. if( to == this.gridJson.length )this.isItemsLoaded = true;
  407. }
  408. },
  409. loadGroupData: function(){
  410. if( this.checkboxElement ){
  411. this.checkboxElement.set("checked", false )
  412. }
  413. if (this.selectTitleCell && !this.selectTitleCell.retrieve("expandLoaded") ){
  414. if( this.viewJson.viewStyles && this.viewJson.viewStyles["groupCollapseNode"] ){
  415. this.expandAllNode = new Element("span", {
  416. styles : this.viewJson.viewStyles["groupCollapseNode"]
  417. }).inject( this.selectTitleCell );
  418. this.selectTitleCell.setStyle("cursor", "pointer");
  419. }else{
  420. this.selectTitleCell.set("html", "<span style='font-family: Webdings'>"+"<img src='../x_component_query_Query/$Viewer/"+this.options.style+"/icon/expand.png'/>"+"</span>");
  421. }
  422. this.selectTitleCell.setStyle("cursor", "pointer");
  423. this.selectTitleCell.addEvent("click", this.expandOrCollapseAll.bind(this));
  424. this.selectTitleCell.store("expandLoaded", true);
  425. }
  426. // this.expandAll = false;
  427. if (this.gridJson.length){
  428. var i = 0;
  429. this.gridJson.each(function(data){
  430. this.items.push(new MWF.xApplication.cms.Module.QueryViewer.ItemCategory(this, data, i));
  431. i += data.list.length;
  432. }.bind(this));
  433. if (this.getExpandFlag()=="yes")this.expandOrCollapseAll();
  434. }else{
  435. if (this.viewPageAreaNode) this.viewPageAreaNode.empty();
  436. }
  437. },
  438. createSearchNode: function(){
  439. if (this.viewJson.customFilterList && this.viewJson.customFilterList.length){
  440. this.searchStatus = "default";
  441. this.loadFilterSearch();
  442. this.originalSearchContainerWidth = this.searchContainer.getSize().x;
  443. this.viewSearchCustomActionNode.addEvents({
  444. "click": function(){
  445. var parent = this.searchContainer.getParent();
  446. if( parent ){
  447. var x = parent.getParent().getSize().x;
  448. this.searchContainer.setStyle("width", Math.min( 800, x ) + "px" );
  449. }
  450. }.bind(this)
  451. });
  452. }else{
  453. this.searchStatus = "simple";
  454. this.loadSimpleSearch();
  455. }
  456. },
  457. loadSimpleSearch: function(){
  458. return false;
  459. this.searchSimpleNode = new Element("div", {"styles": this.css.searchSimpleNode}).inject(this.searchAreaNode);
  460. this.searchSimpleButtonNode = new Element("div", {"styles": this.css.searchSimpleButtonNode}).inject(this.searchSimpleNode);
  461. this.searchSimpleWarpNode = new Element("div", {"style": "margin-right: 40px; margin-left: 5px; height: 24px; overflow: hidden;"}).inject(this.searchSimpleNode);
  462. this.searchSimpleInputNode = new Element("input", {"type":"text", "styles": this.css.searchSimpleInputNode, "value": this.lp.searchKeywork}).inject(this.searchSimpleWarpNode);
  463. this.searchSimpleButtonNode.addEvent("click", function(){
  464. this.search();
  465. }.bind(this));
  466. this.searchSimpleInputNode.addEvents({
  467. "focus": function(){
  468. if (this.searchSimpleInputNode.get("value")===this.lp.searchKeywork) this.searchSimpleInputNode.set("value", "");
  469. }.bind(this),
  470. "blur": function(){if (!this.searchSimpleInputNode.get("value")) this.searchSimpleInputNode.set("value", this.lp.searchKeywork);}.bind(this),
  471. "keydown": function(e){
  472. if (e.code===13) this.search();
  473. }.bind(this)
  474. });
  475. },
  476. _loadPageNode : function(){
  477. this.viewPageAreaNode.empty();
  478. if( this.viewJson.pagingbarHidden === true ){
  479. return;
  480. }
  481. if( !this.paging ){
  482. var json;
  483. if( !this.viewJson.pagingList || !this.viewJson.pagingList.length ){
  484. json = {
  485. "firstPageText": this.lp.firstPage,
  486. "lastPageText": this.lp.lastPage
  487. };
  488. }else{
  489. json = this.viewJson.pagingList[0];
  490. }
  491. this.paging = new MWF.xApplication.query.Query.Viewer.Paging(this.viewPageAreaNode, json, this, {useMainColor: true});
  492. this.paging.load();
  493. }else{
  494. this.paging.reload();
  495. }
  496. },
  497. setContentHeight: function(){
  498. if( this.viewSearchCustomCloseActionNode && !this.setCustomSearchCloseEvent ){
  499. this.viewSearchCustomCloseActionNode.addEvent("click", function(){
  500. this.searchContainer.setStyle("width", this.originalSearchContainerWidth + "px" );
  501. }.bind(this));
  502. this.setCustomSearchCloseEvent = true;
  503. }
  504. if(this.viewSearchInputAreaNode)this.viewSearchInputAreaNode.setStyle("width","auto");
  505. debugger;
  506. if( this.node && this.searchContainer && this.viewAreaNode ){
  507. var size = this.node.getSize();
  508. var searchSize;
  509. var parent = this.searchContainer.getParent();
  510. if( parent ){
  511. searchSize = parent.getParent().getSize();
  512. }else{
  513. searchSize = this.searchContainer.getSize();
  514. }
  515. var h = size.y-searchSize.y; // - 80; //80是视图翻页条的高度
  516. if( this.actionbarAreaNode ){
  517. var exportSize = this.actionbarAreaNode.getComputedSize();
  518. h = h-exportSize.totalHeight;
  519. }
  520. var pageSize = this.viewPageAreaNode.getComputedSize();
  521. h = h-pageSize.totalHeight;
  522. this.viewAreaNode.setStyle("height", ""+h+"px");
  523. }
  524. }
  525. });
  526. MWF.xApplication.cms.Module.QueryViewer.Item = new Class({
  527. Extends : MWF.xApplication.query.Query.Viewer.Item,
  528. load: function(){
  529. this.view.fireEvent("queryLoadItemRow", [null, this]);
  530. var _self = this;
  531. var viewStyles = this.view.viewJson.viewStyles;
  532. var viewContentTdNode = ( viewStyles && viewStyles["contentTd"] ) ? viewStyles["contentTd"] : this.css.viewContentTdNode;
  533. this.node = new Element("tr", {
  534. "styles": ( viewStyles && viewStyles["contentTr"] ) ? viewStyles["contentTr"] : this.css.viewContentTrNode
  535. });
  536. if (this.prev){
  537. this.node.inject(this.prev.node, "after");
  538. }else{
  539. this.node.inject(this.view.viewTable);
  540. }
  541. this.node.addEvents({
  542. mouseover : function(){ this.setStyles(_self.css.viewContentTrNode_over) },
  543. mouseout : function(){ this.setStyles(_self.css.viewContentTrNode) }
  544. });
  545. if( this.view.selectEnable ){
  546. this.createSelectTd();
  547. }
  548. //if (this.view.json.select==="single" || this.view.json.select==="multi"){
  549. this.selectTd = new Element("td", { "styles": viewContentTdNode }).inject(this.node);
  550. this.selectTd.setStyles({"cursor": "pointer"});
  551. if (this.view.json.itemStyles) this.selectTd.setStyles(this.view.json.itemStyles);
  552. //}
  553. if( this.view.isSelectTdHidden() ){
  554. this.selectTd.hide();
  555. }
  556. //Object.each(this.data.data, function(cell, k){
  557. // if (this.view.hideColumns.indexOf(k)===-1){
  558. // var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(this.node);
  559. // if (k!== this.view.viewJson.group.column){
  560. // 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;
  561. // td.set("text", v);
  562. // }
  563. // if (this.view.openColumns.indexOf(k)!==-1){
  564. // this.setOpenWork(td)
  565. // }
  566. // if (this.view.json.itemStyles) td.setStyles(this.view.json.itemStyles);
  567. // }
  568. //}.bind(this));
  569. //序号
  570. var sequence = 1+this.view.json.pageSize*(this.view.currentPage-1)+this.idx;
  571. this.data["$sequence"] = sequence;
  572. if (this.view.viewJson.isSequence==="yes"){
  573. this.sequenceTd = new Element("td", {"styles": viewContentTdNode}).inject(this.node);
  574. this.sequenceTd.setStyles({
  575. "width": "30px",
  576. "text-align": "center"
  577. });
  578. this.sequenceTd.set("text", sequence);
  579. }
  580. this.view.viewJson.selectList.each(function(column){
  581. var k = column.column;
  582. var cell = this.data.data[column.column];
  583. if (this.view.hideColumns.indexOf(k)===-1){
  584. var td = new Element("td", {"styles": viewContentTdNode}).inject(this.node);
  585. if (k!== this.view.viewJson.group.column){
  586. //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;
  587. //td.set("text", cell);
  588. var v = cell;
  589. if (column.isHtml){
  590. td.set("html", v);
  591. }else{
  592. td.set("text", v);
  593. }
  594. }
  595. if (this.view.openColumns.indexOf(k)!==-1){
  596. this.setOpenWork(td, column)
  597. }
  598. if (this.view.json.itemStyles) td.setStyles(this.view.json.itemStyles);
  599. }
  600. }.bind(this));
  601. if( this.view.options.hasAction ){
  602. var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(this.node);
  603. this.loadActions( td );
  604. if (this.view.json.itemStyles) td.setStyles(this.view.json.itemStyles);
  605. }
  606. this.setEvent();
  607. this.view.fireEvent("postLoadItemRow", [null, this]);
  608. },
  609. destroySelectTd : function(){
  610. if( this.checboxTd ){
  611. this.checboxTd.destroy();
  612. this.checboxTd = null;
  613. }
  614. },
  615. createSelectTd : function(){
  616. if( this.checboxTd )return;
  617. var viewStyles = this.view.viewJson.viewStyles;
  618. var viewContentTdNode = ( viewStyles && viewStyles["contentTd"] ) ? viewStyles["contentTd"] : this.css.viewContentTdNode;
  619. this.checboxTd = new Element("td", {styles:viewContentTdNode}).inject(this.node, "top");
  620. this.checkboxElement = new Element("input", {
  621. "type": "checkbox",
  622. "events" : { click : function(ev){ ev.stopPropagation(); } }
  623. }).inject(this.checboxTd);
  624. this.checboxTd.addEvent("click", function(ev){
  625. this.checkboxElement.set("checked", !this.checkboxElement.get("checked") );
  626. ev.stopPropagation();
  627. }.bind(this));
  628. },
  629. loadActions : function( container ){
  630. this.deleteNode = new Element("div.o2icon-delete", {"styles": this.css.actionDeleteNode, "title": this.view.lp.delete }).inject(container);
  631. this.deleteNode.addEvents({
  632. "mouseover": function(){
  633. this.deleteNode.setStyles(this.css.actionDeleteNode_over);
  634. this.deleteNode.addClass("mainColor_color");
  635. }.bind(this),
  636. "mouseout": function(){
  637. this.deleteNode.setStyles(this.css.actionDeleteNode);
  638. this.deleteNode.removeClass("mainColor_color");
  639. }.bind(this),
  640. //"mousedown": function(){this.deleteNode.setStyles(this.css.actionDeleteNode_down);}.bind(this),
  641. //"mouseup": function(){this.deleteNode.setStyles(this.css.actionDeleteNode_over);}.bind(this),
  642. "click": function(e){
  643. this.remove(e);
  644. e.stopPropagation();
  645. }.bind(this)
  646. });
  647. this.editNode = new Element("div.o2icon-edit2", {"styles": this.css.actionEditNode, "title": this.view.lp.edit }).inject(container);
  648. this.editNode.addEvents({
  649. "mouseover": function(){
  650. this.editNode.setStyles(this.css.actionEditNode_over);
  651. this.editNode.addClass("mainColor_color");
  652. }.bind(this),
  653. "mouseout": function(){
  654. this.editNode.setStyles(this.css.actionEditNode);
  655. this.editNode.removeClass("mainColor_color");
  656. }.bind(this),
  657. //"mousedown": function(){this.editNode.setStyles(this.css.actionEditNode_down);}.bind(this),
  658. //"mouseup": function(){this.editNode.setStyles(this.css.actionEditNode_over);}.bind(this),
  659. "click": function(e){
  660. this.editCMSDocument();
  661. e.stopPropagation();
  662. }.bind(this)
  663. });
  664. },
  665. setOpenWork: function(td, column){
  666. td.setStyle("cursor", "pointer");
  667. if( column.clickCode ) {
  668. // if( !this.view.Macro ){
  669. // MWF.require("MWF.xScript.Macro", function () {
  670. // this.view.businessData = {};
  671. // this.view.Macro = new MWF.Macro.PageContext(this.view);
  672. // }.bind(this), false);
  673. // }
  674. td.addEvent("click", function( ev ){
  675. var result = this.view.Macro.fire(column.clickCode, this, ev);
  676. ev.stopPropagation();
  677. return result;
  678. }.bind(this));
  679. }else{
  680. if (this.view.json.type==="cms"){
  681. td.addEvent("click", function(ev){
  682. this.openCMSDocument(false)
  683. ev.stopPropagation();
  684. }.bind(this));
  685. }else{
  686. td.addEvent("click", function(ev){
  687. this.openWorkAndCompleted(ev)
  688. ev.stopPropagation();
  689. }.bind(this));
  690. }
  691. }
  692. },
  693. openCMSDocument : function( isEdited ){
  694. var appId = "cms.Document"+this.data.bundle;
  695. if (layout.desktop.apps[appId]){
  696. if (!layout.desktop.apps[appId].window){
  697. layout.desktop.apps[appId] = null;
  698. layout.openApplication(null, layout.desktop.apps[appId].options.name, layout.desktop.apps[appId].options, layout.desktop.apps[appId].options.app, false, this, false);
  699. }else{
  700. layout.desktop.apps[appId].setCurrent();
  701. }
  702. //layout.desktop.apps[appId].setCurrent();
  703. }else {
  704. var options = {
  705. "documentId": this.data.bundle,
  706. "readonly" : !isEdited
  707. };
  708. layout.desktop.openApplication(null, "cms.Document", options);
  709. }
  710. },
  711. editCMSDocument : function(){
  712. this.openCMSDocument( true );
  713. },
  714. remove: function(e){
  715. var text = this.view.lp.deleteConfirmContent;
  716. var _self = this;
  717. this.node.setStyles(this.css.viewContentTrNode_delete);
  718. this.readyRemove = true;
  719. this.view.app.confirm("warn", e, this.view.lp.deleteConfirmTitle, text, 350, 120, function(){
  720. _self.removeCMSDocument(_self, false);
  721. this.close();
  722. }, function(){
  723. _self.node.setStyles(_self.css.viewContentTrNode );
  724. _self.readyRemove = false;
  725. this.close();
  726. });
  727. },
  728. removeCMSDocument: function(){
  729. var id = this.data.bundle;
  730. //this.view.lookupAction.invoke({"name": "deleteDocument","async": true, "parameter": {"id": id },"success": function(json){
  731. // this.readyRemove = false;
  732. // this.node.destroy();
  733. // this.view.app.notice("删除成功", "success");
  734. // MWF.release(this);
  735. //}.bind(this)});
  736. MWF.Actions.get("x_cms_assemble_control").removeDocument(id, function(json){
  737. this.readyRemove = false;
  738. this.node.destroy();
  739. this.view.app.notice( this.view.lp.deleteSuccessNotice, "success");
  740. MWF.release(this);
  741. }.bind(this));
  742. }
  743. });
  744. MWF.xApplication.cms.Module.QueryViewer.ItemCategory = new Class({
  745. Extends : MWF.xApplication.query.Query.Viewer.ItemCategory,
  746. load: function(){
  747. this.view.fireEvent("queryLoadCategoryRow", [null, this]);
  748. var viewStyles = this.view.viewJson.viewStyles;
  749. var viewContentCategoryTdNode = ( viewStyles && viewStyles["contentGroupTd"] ) ? viewStyles["contentGroupTd"] : this.css.viewContentCategoryTdNode;
  750. this.node = new Element("tr", {
  751. "styles": (viewStyles && viewStyles["contentTr"]) ? viewStyles["contentTr"] : this.css.viewContentTrNode
  752. }).inject(this.view.viewTable);
  753. //if (this.view.json.select==="single" || this.view.json.select==="multi"){
  754. this.selectTd = new Element("td", {"styles": viewContentCategoryTdNode}).inject(this.node);
  755. if (this.view.json.itemStyles) this.selectTd.setStyles(this.view.json.itemStyles);
  756. //}
  757. var colsapn = this.view.viewJson.selectList.length+1;
  758. if( this.view.options.hasAction ){
  759. colsapn ++
  760. }
  761. this.categoryTd = new Element("td", {
  762. "styles": viewContentCategoryTdNode,
  763. "colspan": colsapn
  764. }).inject(this.node);
  765. this.groupColumn = null;
  766. for (var c = 0; c<this.view.viewJson.selectList.length; c++){
  767. if (this.view.viewJson.selectList[c].column === this.view.viewJson.group.column){
  768. this.groupColumn = this.view.viewJson.selectList[c];
  769. break;
  770. }
  771. }
  772. if (this.groupColumn){
  773. //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;
  774. var text = this.data.group;
  775. }else{
  776. var text = this.data.group;
  777. }
  778. if( viewStyles && viewStyles["groupCollapseNode"] ){
  779. this.expandNode = new Element("span", {
  780. styles : viewStyles["groupCollapseNode"]
  781. }).inject( this.categoryTd );
  782. new Element("span", { text : text }).inject( this.categoryTd );
  783. // this.categoryTd.set("text", text );
  784. }else{
  785. 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);
  786. }
  787. this.expanded = false;
  788. if (this.view.json.itemStyles) this.categoryTd.setStyles(this.view.json.itemStyles);
  789. this.setEvent();
  790. this.view.fireEvent("postLoadCategoryRow", [null, this]);
  791. },
  792. expand: function( from ){
  793. this.items.each(function(item){
  794. item.node.setStyle("display", "table-row");
  795. }.bind(this));
  796. if( this.expandNode ){
  797. this.expandNode.setStyles( this.view.viewJson.viewStyles["groupExpandNode"] )
  798. }else{
  799. this.node.getElement("span").set("html", "<img src='../x_component_query_Query/$Viewer/"+this.view.options.style+"/icon/down.png'/>");
  800. }
  801. this.expanded = true;
  802. if (!this.loadChild){
  803. //window.setTimeout(function(){
  804. this.data.list.each(function(line, i){
  805. var s = this.idx+i;
  806. this.lastItem = new MWF.xApplication.cms.Module.QueryViewer.Item(this.view, line, (this.lastItem || this), s);
  807. this.items.push(this.lastItem);
  808. //this.items.push(new MWF.xApplication.cms.Module.QueryViewer.Item(this.view, line, this));
  809. }.bind(this));
  810. this.loadChild = true;
  811. //}.bind(this), 10);
  812. }
  813. if( from !== "view" ){
  814. this.view.checkExpandAllStatus();
  815. }
  816. }
  817. });
  818. //MWF.xApplication.cms.Module.Viewer = new Class({
  819. // Implements: [Options, Events],
  820. // Extends: MWF.xApplication.process.Application.Viewer,
  821. // options: {
  822. // "style": "default",
  823. // "hasAction" : false, //cxy add
  824. // "resizeNode": true,
  825. // "actions": {
  826. // //"lookup": {"uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}/execute", "method":"PUT"},
  827. // //"getView": {"uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}"},
  828. // "lookup": {"uri": "/jaxrs/view/{view}/execute", "method":"PUT"},
  829. // "getView": {"uri": "/jaxrs/view/{view}"},
  830. // "listWorkByJob": {"uri": "/jaxrs/job/{job}/find/work/workcompleted"},
  831. // "listTaskByWork": {"uri": "/jaxrs/work/{id}/assignment/manage"}
  832. //
  833. // },
  834. // "actionRoot": "x_processplatform_assemble_surface"
  835. // },
  836. // initialize: function(container, json, options, app, searchContainer){
  837. // this.setOptions(options);
  838. // this.app = app;
  839. // this.searchContainer = searchContainer;
  840. //
  841. // this.path = "../x_component_cms_Module/$ViewExplorer/";
  842. // this.cssPath = "../x_component_cms_Module/$ViewExplorer/"+this.options.style+"/viewer.wcss";
  843. // this._loadCss();
  844. // this.lp = MWF.xApplication.process.Application.LP;
  845. //
  846. // this.container = $(container);
  847. // this.json = json;
  848. //
  849. // this.viewJson = null;
  850. // this.filterItems = [];
  851. // this.searchStatus = "none"; //none, custom, default
  852. //
  853. //
  854. // this.items = [];
  855. // this.selectedItems = [];
  856. // this.hideColumns = [];
  857. // this.openColumns = [];
  858. //
  859. // this.gridJson = null;
  860. //
  861. // this.init(function(){
  862. // this.load();
  863. // }.bind(this));
  864. // },
  865. // selectMode : function(){
  866. // this.selectEnable = true;
  867. // this.createSelectTh();
  868. // this.items.each( function (it) {
  869. // it.createSelectTd();
  870. // }.bind(this));
  871. // },
  872. // disableSelectMode : function(){
  873. // this.selectEnable = false;
  874. // this.destroySelectTh();
  875. // this.items.each( function (it) {
  876. // it.destroySelectTd();
  877. // }.bind(this));
  878. // },
  879. // destroySelectTh : function(){
  880. // if( this.selectTh ){
  881. // this.selectTh.destroy();
  882. // this.selectTh = null;
  883. // }
  884. // },
  885. // createSelectTh : function(){
  886. // this.selectTh = new Element("th").inject(this.viewTitleLine, "top");
  887. // this.checkboxElement = new Element("input", {
  888. // "type": "checkbox"
  889. // }).inject(this.selectTh);
  890. // this.checkboxElement.addEvent("click", function () {
  891. // this.selectAll()
  892. // }.bind(this));
  893. // },
  894. // selectAll : function () {
  895. // var flag = this.checkboxElement.get("checked");
  896. // this.items.each(function (it) {
  897. // if (it.checkboxElement)it.checkboxElement.set("checked", flag)
  898. // }.bind(this))
  899. // },
  900. // getSelectedIds : function(){
  901. // var checkedItems = [];
  902. // this.items.each(function (it) {
  903. // if (it.checkboxElement.get("checked")) {
  904. // checkedItems.push( it.data.bundle )
  905. // }
  906. // }.bind(this));
  907. // return checkedItems;
  908. // },
  909. // getSelectedItems : function(){
  910. // var checkedItems = [];
  911. // this.items.each(function (it) {
  912. // if (it.checkboxElement.get("checked")) {
  913. // checkedItems.push( it )
  914. // }
  915. // }.bind(this));
  916. // return checkedItems;
  917. // },
  918. // createViewNode: function(data){
  919. // this.viewAreaNode.empty();
  920. // this.contentAreaNode = new Element("div", {"styles": this.css.contentAreaNode}).inject(this.viewAreaNode);
  921. //
  922. // this.viewTable = new Element("table", {
  923. // "styles": this.css.viewTitleTableNode,
  924. // "border": "0px",
  925. // "cellPadding": "0",
  926. // "cellSpacing": "0"
  927. // }).inject(this.contentAreaNode);
  928. // this.createLoadding();
  929. //
  930. // if (this.json.isTitle!=="no"){
  931. // this.viewTitleLine = new Element("tr", {"styles": this.css.viewTitleLineNode}).inject(this.viewTable);
  932. //
  933. // //if (this.json.select==="single" || this.json.select==="multi") {
  934. // this.selectTitleCell = new Element("td", {
  935. // "styles": this.css.viewTitleCellNode
  936. // }).inject(this.viewTitleLine);
  937. // this.selectTitleCell.setStyle("width", "10px");
  938. // if (this.json.titleStyles) this.selectTitleCell.setStyles(this.json.titleStyles);
  939. // //}
  940. // this.entries = {};
  941. // this.viewJson.selectList.each(function(column){
  942. // this.entries[column.column] = column;
  943. //
  944. // if (!column.hideColumn){
  945. // var viewCell = new Element("td", {
  946. // "styles": this.css.viewTitleCellNode,
  947. // "text": column.displayName
  948. // }).inject(this.viewTitleLine);
  949. // if (this.json.titleStyles) viewCell.setStyles(this.json.titleStyles);
  950. // }else{
  951. // this.hideColumns.push(column.column);
  952. // }
  953. // if (column.allowOpen) this.openColumns.push(column.column);
  954. // }.bind(this));
  955. //
  956. // if( this.options.hasAction ){
  957. // var viewCell = new Element("td", {
  958. // "styles": this.css.viewTitleCellNode,
  959. // "text": "操作"
  960. // }).inject(this.viewTitleLine);
  961. // viewCell.setStyle("width","40px");
  962. // if (this.json.titleStyles) viewCell.setStyles(this.json.titleStyles);
  963. // }
  964. //
  965. // this.lookup(data);
  966. // }else{
  967. // this.viewJson.selectEntryList.each(function(column){
  968. // if (column.hideColumn) this.hideColumns.push(column.column);
  969. // if (!column.allowOpen) this.openColumns.push(column.column);
  970. // }.bind(this));
  971. // this.lookup(data);
  972. // }
  973. // },
  974. // lookup: function(data){
  975. // this.getLookupAction(function(){
  976. // if (this.json.application){
  977. // this.lookupAction.invoke({"name": "lookup","async": true, "data": (data || null), "parameter": {"view": this.json.name, "application": this.json.application},"success": function(json){
  978. // this.viewData = json.data;
  979. // if (this.viewJson.group.column){
  980. // this.gridJson = json.data.groupGrid;
  981. // this.loadGroupData();
  982. // }else{
  983. // this.gridJson = json.data.grid;
  984. // this.loadData();
  985. // }
  986. // if (this.loadingAreaNode){
  987. // this.loadingAreaNode.destroy();
  988. // this.loadingAreaNode = null;
  989. // }
  990. // }.bind(this)});
  991. // }
  992. // }.bind(this));
  993. // },
  994. // loadLayout: function(){
  995. // this.node = new Element("div", {"styles": this.css.node}).inject(this.container);
  996. // this.searchAreaNode = new Element("div", {"styles": this.css.searchAreaNode}).inject(this.searchContainer || this.node );
  997. // this.viewAreaNode = new Element("div", {"styles": this.css.viewAreaNode}).inject(this.node);
  998. // },
  999. // loadData: function(){
  1000. // if (this.gridJson.length){
  1001. // this.gridJson.each(function(line, i){
  1002. // this.items.push(new MWF.xApplication.cms.Module.Viewer.Item(this, line, null, i));
  1003. // }.bind(this));
  1004. // }
  1005. // },
  1006. // loadGroupData: function(){
  1007. // if (this.selectTitleCell){
  1008. // this.selectTitleCell.set("html", "<span style='font-family: Webdings'>"+"<img src='../x_component_process_Application/$Viewer/"+this.options.style+"/icon/expand.png'/>"+"</span>");
  1009. // this.selectTitleCell.setStyle("cursor", "pointer");
  1010. // this.selectTitleCell.addEvent("click", this.expandOrCollapseAll.bind(this));
  1011. // }
  1012. //
  1013. // if (this.gridJson.length){
  1014. // this.gridJson.each(function(data){
  1015. // this.items.push(new MWF.xApplication.cms.Module.Viewer.ItemCategory(this, data));
  1016. // }.bind(this));
  1017. //
  1018. // if (this.json.isExpand=="yes")this.expandOrCollapseAll();
  1019. // }
  1020. // },
  1021. // setContentHeight: function(){
  1022. // if( this.node && this.searchAreaNode && this.viewAreaNode ){
  1023. // var size = this.node.getSize();
  1024. // var searchSize = this.searchAreaNode.getSize();
  1025. // var h = size.y-searchSize.y;
  1026. // this.viewAreaNode.setStyle("height", ""+h+"px");
  1027. // }
  1028. // }
  1029. //});
  1030. //
  1031. //MWF.xApplication.cms.Module.Viewer.Item = new Class({
  1032. // Extends : MWF.xApplication.process.Application.Viewer.Item,
  1033. // load: function(){
  1034. // var _self = this;
  1035. // this.node = new Element("tr", {"styles": this.css.viewContentTrNode});
  1036. // if (this.prev){
  1037. // this.node.inject(this.prev.node, "after");
  1038. // }else{
  1039. // this.node.inject(this.view.viewTable);
  1040. // }
  1041. // this.node.addEvents({
  1042. // mouseover : function(){ this.setStyles(_self.css.viewContentTrNode_over) },
  1043. // mouseout : function(){ this.setStyles(_self.css.viewContentTrNode) }
  1044. // });
  1045. //
  1046. // if( this.view.selectEnable ){
  1047. // this.createSelectTd();
  1048. // }
  1049. //
  1050. // //if (this.view.json.select==="single" || this.view.json.select==="multi"){
  1051. // this.selectTd = new Element("td", {"styles": this.css.viewContentTdNode}).inject(this.node);
  1052. // this.selectTd.setStyles({"cursor": "pointer"});
  1053. // if (this.view.json.itemStyles) this.selectTd.setStyles(this.view.json.itemStyles);
  1054. // //}
  1055. //
  1056. // debugger;
  1057. // this.view.viewJson.selectList.each(function(column){
  1058. // var k = column.column;
  1059. // var cell = this.data.data[column.column];
  1060. //
  1061. // if (this.view.hideColumns.indexOf(k)===-1){
  1062. // var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(this.node);
  1063. // if (k!== this.view.viewJson.group.column){
  1064. // 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;
  1065. // td.set("text", v);
  1066. // }
  1067. // if (this.view.openColumns.indexOf(k)!==-1){
  1068. // this.setOpenWork(td)
  1069. // }
  1070. // if (this.view.json.itemStyles) td.setStyles(this.view.json.itemStyles);
  1071. // }
  1072. //
  1073. // }.bind(this));
  1074. //
  1075. // //Object.each(this.data.data, function(cell, k){
  1076. // // if (this.view.hideColumns.indexOf(k)===-1){
  1077. // // var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(this.node);
  1078. // // if (k!== this.view.viewJson.group.column){
  1079. // // 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;
  1080. // // td.set("text", v);
  1081. // // }
  1082. // // if (this.view.openColumns.indexOf(k)!==-1){
  1083. // // this.setOpenWork(td)
  1084. // // }
  1085. // // if (this.view.json.itemStyles) td.setStyles(this.view.json.itemStyles);
  1086. // // }
  1087. // //}.bind(this));
  1088. //
  1089. // if( this.view.options.hasAction ){
  1090. // var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(this.node);
  1091. // this.loadActions( td );
  1092. // if (this.view.json.itemStyles) td.setStyles(this.view.json.itemStyles);
  1093. // }
  1094. //
  1095. // this.setEvent();
  1096. // },
  1097. //
  1098. // loadActions : function( container ){
  1099. // this.deleteNode = new Element("div", {"styles": this.css.actionDeleteNode, "title": "删除"}).inject(container);
  1100. // this.deleteNode.addEvents({
  1101. // "mouseover": function(){this.deleteNode.setStyles(this.css.actionDeleteNode_over);}.bind(this),
  1102. // "mouseout": function(){this.deleteNode.setStyles(this.css.actionDeleteNode);}.bind(this),
  1103. // "mousedown": function(){this.deleteNode.setStyles(this.css.actionDeleteNode_down);}.bind(this),
  1104. // "mouseup": function(){this.deleteNode.setStyles(this.css.actionDeleteNode_over);}.bind(this),
  1105. // "click": function(e){
  1106. // this.remove(e);
  1107. // e.stopPropagation();
  1108. // }.bind(this)
  1109. // });
  1110. //
  1111. // this.editNode = new Element("div", {"styles": this.css.actionEditNode, "title": "编辑"}).inject(container);
  1112. // this.editNode.addEvents({
  1113. // "mouseover": function(){this.editNode.setStyles(this.css.actionEditNode_over);}.bind(this),
  1114. // "mouseout": function(){this.editNode.setStyles(this.css.actionEditNode);}.bind(this),
  1115. // "mousedown": function(){this.editNode.setStyles(this.css.actionEditNode_down);}.bind(this),
  1116. // "mouseup": function(){this.editNode.setStyles(this.css.actionEditNode_over);}.bind(this),
  1117. // "click": function(e){
  1118. // this.editCMSDocument();
  1119. // e.stopPropagation();
  1120. // }.bind(this)
  1121. // });
  1122. // },
  1123. // destroySelectTd : function(){
  1124. // if( this.checboxTd ){
  1125. // this.checboxTd.destroy();
  1126. // this.checboxTd = null;
  1127. // }
  1128. // },
  1129. // createSelectTd : function(){
  1130. // if( this.checboxTd )return;
  1131. // this.checboxTd = new Element("td").inject(this.node, "top");
  1132. // this.checboxTd.addEvent("click", function(ev){
  1133. // ev.stopPropagation();
  1134. // });
  1135. // this.checkboxElement = new Element("input", {
  1136. // "type": "checkbox"
  1137. // }).inject(this.checboxTd);
  1138. // },
  1139. // setOpenWork: function(td){
  1140. // td.setStyle("cursor", "pointer");
  1141. // td.addEvent("click", function(){
  1142. // this.openCMSDocument()
  1143. // }.bind(this));
  1144. // },
  1145. // openCMSDocument : function( isEdited ){
  1146. // var appId = "cms.Document"+this.data.bundle;
  1147. // if (layout.desktop.apps[appId]){
  1148. // layout.desktop.apps[appId].setCurrent();
  1149. // }else {
  1150. // var options = {
  1151. // "documentId": this.data.bundle,
  1152. // "readonly" : !isEdited
  1153. // };
  1154. // layout.desktop.openApplication(null, "cms.Document", options);
  1155. // }
  1156. // },
  1157. // editCMSDocument : function(){
  1158. // this.openCMSDocument( true );
  1159. // },
  1160. // remove: function(e){
  1161. // var text = "删除后不能恢复,你确定要删除该文档?";
  1162. // var _self = this;
  1163. // this.node.setStyles(this.css.viewContentTrNode_delete);
  1164. // this.readyRemove = true;
  1165. // this.view.app.confirm("warn", e, "删除确认", text, 350, 120, function(){
  1166. //
  1167. // _self.removeCMSDocument(_self, false);
  1168. //
  1169. // this.close();
  1170. //
  1171. // }, function(){
  1172. // _self.node.setStyles(_self.css.viewContentTrNode );
  1173. // _self.readyRemove = false;
  1174. // this.close();
  1175. // });
  1176. // },
  1177. // removeCMSDocument: function(){
  1178. // var id = this.data.bundle;
  1179. // MWF.Actions.get("x_cms_assemble_control").removeDocument(id, function(json){
  1180. // //this.viewJson = JSON.decode(json.data.data);
  1181. // //this.json = Object.merge(this.json, json.data);
  1182. // this.readyRemove = false;
  1183. // this.node.destroy();
  1184. // this.view.app.notice("删除成功", "success");
  1185. // MWF.release(this);
  1186. // }.bind(this));
  1187. // }
  1188. //
  1189. //});
  1190. //
  1191. //MWF.xApplication.cms.Module.Viewer.ItemCategory = new Class({
  1192. // Extends : MWF.xApplication.process.Application.Viewer.ItemCategory,
  1193. // load: function(){
  1194. // this.node = new Element("tr", {"styles": this.css.viewContentTrNode}).inject(this.view.viewTable);
  1195. // //if (this.view.json.select==="single" || this.view.json.select==="multi"){
  1196. // this.selectTd = new Element("td", {"styles": this.css.viewContentCategoryTdNode}).inject(this.node);
  1197. // if (this.view.json.itemStyles) this.selectTd.setStyles(this.view.json.itemStyles);
  1198. // //}
  1199. //
  1200. // var colsapn = this.view.viewJson.selectList.length;
  1201. // if( this.view.options.hasAction ){
  1202. // colsapn ++
  1203. // }
  1204. //
  1205. // this.categoryTd = new Element("td", {
  1206. // "styles": this.css.viewContentCategoryTdNode,
  1207. // "colspan": colsapn
  1208. // }).inject(this.node);
  1209. //
  1210. // this.groupColumn = null;
  1211. // for (var c = 0; c<this.view.viewJson.selectList.length; c++){
  1212. // if (this.view.viewJson.selectList[c].column === this.view.viewJson.group.column){
  1213. // this.groupColumn = this.view.viewJson.selectList[c];
  1214. // break;
  1215. // }
  1216. // }
  1217. // if (this.groupColumn){
  1218. // 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;
  1219. // }else{
  1220. // var text = this.data.group;
  1221. // }
  1222. //
  1223. // this.categoryTd.set("html", "<span style='font-family: Webdings'><img src='../x_component_process_Application/$Viewer/"+this.view.options.style+"/icon/expand.png'/></span> "+text);
  1224. // if (this.view.json.itemStyles) this.categoryTd.setStyles(this.view.json.itemStyles);
  1225. //
  1226. // this.setEvent();
  1227. // },
  1228. // expand: function(){
  1229. // this.items.each(function(item){
  1230. // item.node.setStyle("display", "table-row");
  1231. // }.bind(this));
  1232. // this.node.getElement("span").set("html", "<img src='../x_component_process_Application/$Viewer/"+this.view.options.style+"/icon/down.png'/>");
  1233. // if (!this.loadChild){
  1234. // //window.setTimeout(function(){
  1235. // this.data.list.each(function(line){
  1236. // this.items.push(new MWF.xApplication.cms.Module.Viewer.Item(this.view, line, this));
  1237. // }.bind(this));
  1238. // this.loadChild = true;
  1239. // //}.bind(this), 10);
  1240. // }
  1241. // }
  1242. //});