ViewExplorer.js 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069
  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.app.addEvent("resize", function(){this.setContentSize();}.bind(this));
  50. },
  51. loadQuryView : function(){
  52. var viewJson = {
  53. "application": this.revealData.appName,
  54. "viewName": this.revealData.name,
  55. "isTitle": "yes",
  56. "select": "none",
  57. "titleStyles": this.css.normalThNode,
  58. "itemStyles": {},
  59. "isExpand": "no",
  60. "filter": []
  61. };
  62. this.view = new MWF.xApplication.cms.Module.QueryViewer(this.elementContentNode, viewJson, {
  63. "hasAction" : this.options.isAdmin,
  64. "resizeNode": true,
  65. "selectEnable" : this.selectEnable,
  66. "onSelect": function(){
  67. this.fireEvent("select");
  68. }.bind(this)
  69. }, this.app, this.searchContainer);
  70. this.setContentSize();
  71. },
  72. //loadView : function(){
  73. // var viewJson = {
  74. // "application": this.columnData.id,
  75. // "viewName": this.revealData.name,
  76. // "isTitle": "yes",
  77. // "select": "none", //none , single, multi
  78. // "titleStyles": this.css.normalThNode,
  79. // "isExpand": "no",
  80. // "itemStyles": {}
  81. // };
  82. //
  83. // this.view = new MWF.xApplication.cms.Module.Viewer(this.elementContentNode, viewJson, {
  84. // "type" : "cms",
  85. // "hasAction" : this.options.isAdmin,
  86. // "actions": {
  87. // //"lookup": {"uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}/execute", "method":"PUT"},
  88. // //"getView": {"uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}"},
  89. // "lookup": {"uri": "/jaxrs/view/{view}/execute", "method":"PUT"},
  90. // "getView": {"uri": "/jaxrs/view/{view}"},
  91. // "deleteDocument" : {"uri":"/jaxrs/document/{id}","method": "DELETE"}
  92. // },
  93. // "actionRoot": "x_query_assemble_surface",
  94. // "resizeNode": true,
  95. // "selectEnable" : this.selectEnable,
  96. // "onSelect": function(){
  97. // this.fireEvent("select");
  98. // }.bind(this)
  99. // }, this.app, this.searchContainer);
  100. //
  101. // this.setContentSize();
  102. //},
  103. selectMode : function(){
  104. this.selectEnable = true;
  105. this.view.selectMode()
  106. },
  107. disableSelectMode : function(){
  108. this.selectEnable = false;
  109. this.view.disableSelectMode()
  110. },
  111. getSelectedIds : function(){
  112. return this.view.getSelectedIds();
  113. },
  114. setContentSize: function(){
  115. var toolbarSize = this.toolbarNode ? this.toolbarNode.getSize() : {"x":0,"y":0};
  116. var titlebarSize = {"x":0,"y":0}; //this.app.titleBar ? this.app.titleBar.getSize() : {"x":0,"y":0};
  117. var nodeSize = this.app.node.getSize();
  118. var pt = 0; //this.elementContentNode.getStyle("padding-top").toFloat();
  119. var pb = 0; // this.elementContentNode.getStyle("padding-bottom").toFloat();
  120. var filterConditionSize = this.filterConditionNode ? this.filterConditionNode.getSize() : {"x":0,"y":0};
  121. var height = nodeSize.y-toolbarSize.y-pt-pb-filterConditionSize.y-titlebarSize.y;
  122. this.elementContentNode.setStyle("height", ""+height+"px");
  123. if( this.view )this.view.setContentHeight();
  124. }
  125. });
  126. MWF.xApplication.cms.Module.QueryViewer = new Class({
  127. Implements: [Options, Events],
  128. Extends: MWF.QViewer,
  129. options: {
  130. "style": "default",
  131. "hasAction" : false, //cxy add
  132. "resizeNode": true,
  133. "paging" : "scroll",
  134. "perPageCount" : 50,
  135. "selectEnable" : false
  136. },
  137. initialize: function(container, json, options, app, searchContainer){
  138. this.setOptions(options);
  139. this.app = app;
  140. this.searchContainer = searchContainer;
  141. this.path = "/x_component_cms_Module/$ViewExplorer/";
  142. this.cssPath = "/x_component_cms_Module/$ViewExplorer/"+this.options.style+"/viewer.wcss";
  143. this._loadCss();
  144. this.lp = MWF.xApplication.query.Query.LP;
  145. this.container = $(container);
  146. this.json = json;
  147. this.viewJson = null;
  148. this.filterItems = [];
  149. this.searchStatus = "none"; //none, custom, default
  150. this.selectEnable = this.options.selectEnable;
  151. this.items = [];
  152. this.selectedItems = [];
  153. this.hideColumns = [];
  154. this.openColumns = [];
  155. this.gridJson = null;
  156. this.init(function(){
  157. this.load();
  158. }.bind(this));
  159. },
  160. selectMode : function(){
  161. this.selectEnable = true;
  162. this.createSelectTh();
  163. this.items.each( function (it) {
  164. it.createSelectTd();
  165. }.bind(this));
  166. },
  167. disableSelectMode : function(){
  168. this.selectEnable = false;
  169. this.destroySelectTh();
  170. this.items.each( function (it) {
  171. it.destroySelectTd();
  172. }.bind(this));
  173. },
  174. destroySelectTh : function(){
  175. if( this.selectTh ){
  176. this.selectTh.destroy();
  177. this.selectTh = null;
  178. }
  179. },
  180. createSelectTh : function(){
  181. this.selectTh = new Element("th",{styles:{width:"20px"}}).inject(this.viewTitleLine, "top");
  182. this.checkboxElement = new Element("input", {
  183. "type": "checkbox"
  184. }).inject(this.selectTh);
  185. this.checkboxElement.addEvent("click", function () {
  186. this.selectAll()
  187. }.bind(this));
  188. },
  189. selectAll : function () {
  190. var flag = this.checkboxElement.get("checked");
  191. this.items.each(function (it) {
  192. if (it.checkboxElement)it.checkboxElement.set("checked", flag)
  193. }.bind(this))
  194. },
  195. getSelectedIds : function(){
  196. var checkedItems = [];
  197. this.items.each(function (it) {
  198. if (it.checkboxElement.get("checked")) {
  199. checkedItems.push( it.data.bundle )
  200. }
  201. }.bind(this));
  202. return checkedItems;
  203. },
  204. getSelectedItems : function(){
  205. var checkedItems = [];
  206. this.items.each(function (it) {
  207. if (it.checkboxElement.get("checked")) {
  208. checkedItems.push( it )
  209. }
  210. }.bind(this));
  211. return checkedItems;
  212. },
  213. createViewNode: function(data){
  214. this.viewAreaNode.empty();
  215. this.contentAreaNode = new Element("div.contentAreaNode", {"styles": this.css.contentAreaNode}).inject(this.viewAreaNode);
  216. this.viewTable = new Element("table.viewTable", {
  217. "styles": this.css.viewTitleTableNode,
  218. "border": "0px",
  219. "cellPadding": "0",
  220. "cellSpacing": "0"
  221. }).inject(this.contentAreaNode);
  222. this.createLoadding();
  223. if (this.json.isTitle!=="no"){
  224. this.viewTitleLine = new Element("tr", {"styles": this.css.viewTitleLineNode}).inject(this.viewTable);
  225. if( this.selectEnable ){
  226. this.createSelectTh();
  227. }
  228. //if (this.json.select==="single" || this.json.select==="multi") {
  229. //this.selectTitleCell = new Element("td", {
  230. // "styles": this.css.viewTitleCellNode
  231. //}).inject(this.viewTitleLine);
  232. //this.selectTitleCell.setStyle("width", "10px");
  233. //if (this.json.titleStyles) this.selectTitleCell.setStyles(this.json.titleStyles);
  234. //}
  235. this.entries = {};
  236. this.viewJson.selectList.each(function(column){
  237. this.entries[column.column] = column;
  238. if (!column.hideColumn){
  239. var viewCell = new Element("td", {
  240. "styles": this.css.viewTitleCellNode,
  241. "text": column.displayName
  242. }).inject(this.viewTitleLine);
  243. var size = MWF.getTextSize(column.displayName, this.css.viewTitleCellNode);
  244. viewCell.setStyle("min-width", ""+size.x+"px");
  245. if (this.json.titleStyles) viewCell.setStyles(this.json.titleStyles);
  246. }else{
  247. this.hideColumns.push(column.column);
  248. }
  249. if (column.allowOpen) this.openColumns.push(column.column);
  250. }.bind(this));
  251. if( this.options.hasAction ){
  252. var viewCell = new Element("td", {
  253. "styles": this.css.viewTitleCellNode,
  254. "text": "操作"
  255. }).inject(this.viewTitleLine);
  256. viewCell.setStyle("width","40px");
  257. if (this.json.titleStyles) viewCell.setStyles(this.json.titleStyles);
  258. }
  259. this.lookup(data);
  260. }else{
  261. this.viewJson.selectList.each(function(column){
  262. if (column.hideColumn) this.hideColumns.push(column.column);
  263. if (!column.allowOpen) this.openColumns.push(column.column);
  264. }.bind(this));
  265. this.lookup(data);
  266. }
  267. },
  268. loadLayout: function(){
  269. this.node = new Element("div", {"styles": this.css.node}).inject(this.container);
  270. this.searchAreaNode = new Element("div", {"styles": this.css.searchAreaNode}).inject(this.searchContainer || this.node );
  271. this.viewAreaNode = new Element("div.viewAreaNode", {"styles": this.css.viewAreaNode}).inject(this.node);
  272. },
  273. //loadData: function(){
  274. // if (this.gridJson.length){
  275. // this.gridJson.each(function(line, i){
  276. // this.items.push(new MWF.xApplication.cms.Module.QueryViewer.Item(this, line, null, i));
  277. // }.bind(this));
  278. // }
  279. //},
  280. loadData: function(){
  281. if (this.gridJson.length){
  282. if( !this.options.paging ){
  283. this.gridJson.each(function(line, i){
  284. this.items.push(new MWF.xApplication.cms.Module.QueryViewer.Item(this, line, null, i));
  285. }.bind(this));
  286. }else{
  287. this.loadPaging();
  288. }
  289. }
  290. },
  291. loadPaging : function(){
  292. this.isItemsLoading = false;
  293. this.pageNumber = 0;
  294. this.isItemsLoaded = false;
  295. this.isSetedScroll = false;
  296. this.setScroll();
  297. this.loadDataByPaging()
  298. },
  299. setScroll : function(){
  300. if( this.options.paging && !this.isSetedScroll ){
  301. this.contentAreaNode.setStyle("overflow","auto");
  302. this.scrollContainerFun = function(){
  303. var scrollSize = this.contentAreaNode.getScrollSize();
  304. var clientSize = this.contentAreaNode.getSize();
  305. var scrollHeight = scrollSize.y - clientSize.y;
  306. //alert( "clientSize.y=" + clientSize.y + " scrollSize.y="+scrollSize.y + " this.contentAreaNode.scrollTop="+this.contentAreaNode.scrollTop);
  307. if (this.contentAreaNode.scrollTop + 150 > scrollHeight ) {
  308. if (!this.isItemsLoaded) this.loadDataByPaging();
  309. }
  310. }.bind(this);
  311. this.isSetedScroll = true;
  312. this.contentAreaNode.addEvent("scroll", this.scrollContainerFun )
  313. }
  314. },
  315. loadDataByPaging : function(){
  316. if( this.isItemsLoading )return;
  317. if( !this.isItemsLoaded ){
  318. var from = Math.min( this.pageNumber * this.options.perPageCount , this.gridJson.length);
  319. var to = Math.min( ( this.pageNumber + 1 ) * this.options.perPageCount + 1 , this.gridJson.length);
  320. this.isItemsLoading = true;
  321. for( var i = from; i<to; i++ ){
  322. this.items.push(new MWF.xApplication.cms.Module.QueryViewer.Item(this, this.gridJson[i], null, i));
  323. }
  324. this.isItemsLoading = false;
  325. this.pageNumber ++;
  326. if( to == this.gridJson.length )this.isItemsLoaded = true;
  327. }
  328. },
  329. loadGroupData: function(){
  330. if (this.selectTitleCell){
  331. this.selectTitleCell.set("html", "<span style='font-family: Webdings'>"+"<img src='/x_component_process_Application/$Viewer/"+this.options.style+"/icon/expand.png'/>"+"</span>");
  332. this.selectTitleCell.setStyle("cursor", "pointer");
  333. this.selectTitleCell.addEvent("click", this.expandOrCollapseAll.bind(this));
  334. }
  335. if (this.gridJson.length){
  336. this.gridJson.each(function(data){
  337. this.items.push(new MWF.xApplication.cms.Module.QueryViewer.ItemCategory(this, data));
  338. }.bind(this));
  339. if (this.json.isExpand=="yes")this.expandOrCollapseAll();
  340. }
  341. },
  342. createSearchNode: function(){
  343. if (this.viewJson.customFilterList && this.viewJson.customFilterList.length){
  344. this.searchStatus = "default";
  345. this.loadFilterSearch();
  346. this.originalSearchContainerWidth = this.searchContainer.getSize().x;
  347. this.viewSearchCustomActionNode.addEvents({
  348. "click": function(){
  349. var x = this.searchContainer.getParent().getParent().getSize().x;
  350. this.searchContainer.setStyle("width", Math.min( 800, x ) + "px" );
  351. }.bind(this)
  352. });
  353. }else{
  354. this.searchStatus = "simple";
  355. this.loadSimpleSearch();
  356. }
  357. },
  358. loadSimpleSearch: function(){
  359. this.searchSimpleNode = new Element("div", {"styles": this.css.searchSimpleNode}).inject(this.searchAreaNode);
  360. this.searchSimpleButtonNode = new Element("div", {"styles": this.css.searchSimpleButtonNode}).inject(this.searchSimpleNode);
  361. this.searchSimpleWarpNode = new Element("div", {"style": "margin-right: 40px; margin-left: 5px; height: 24px; overflow: hidden;"}).inject(this.searchSimpleNode);
  362. this.searchSimpleInputNode = new Element("input", {"type":"text", "styles": this.css.searchSimpleInputNode, "value": this.lp.searchKeywork}).inject(this.searchSimpleWarpNode);
  363. this.searchSimpleButtonNode.addEvent("click", function(){
  364. this.search();
  365. }.bind(this));
  366. this.searchSimpleInputNode.addEvents({
  367. "focus": function(){
  368. if (this.searchSimpleInputNode.get("value")===this.lp.searchKeywork) this.searchSimpleInputNode.set("value", "");
  369. }.bind(this),
  370. "blur": function(){if (!this.searchSimpleInputNode.get("value")) this.searchSimpleInputNode.set("value", this.lp.searchKeywork);}.bind(this),
  371. "keydown": function(e){
  372. if (e.code===13) this.search();
  373. }.bind(this)
  374. });
  375. },
  376. setContentHeight: function(){
  377. if( this.viewSearchCustomCloseActionNode && !this.setCustomSearchCloseEvent ){
  378. this.viewSearchCustomCloseActionNode.addEvent("click", function(){
  379. this.searchContainer.setStyle("width", this.originalSearchContainerWidth + "px" );
  380. }.bind(this));
  381. this.setCustomSearchCloseEvent = true;
  382. }
  383. if(this.viewSearchInputAreaNode)this.viewSearchInputAreaNode.setStyle("width","auto");
  384. if( this.node && this.searchContainer && this.viewAreaNode ){
  385. var size = this.node.getSize();
  386. var searchSize = this.searchContainer.getParent().getParent().getSize();
  387. var h = size.y-searchSize.y;
  388. this.viewAreaNode.setStyle("height", ""+h+"px");
  389. }
  390. }
  391. });
  392. MWF.xApplication.cms.Module.QueryViewer.Item = new Class({
  393. Extends : MWF.xApplication.query.Query.Viewer.Item,
  394. load: function(){
  395. var _self = this;
  396. this.node = new Element("tr", {"styles": this.css.viewContentTrNode});
  397. if (this.prev){
  398. this.node.inject(this.prev.node, "after");
  399. }else{
  400. this.node.inject(this.view.viewTable);
  401. }
  402. this.node.addEvents({
  403. mouseover : function(){ this.setStyles(_self.css.viewContentTrNode_over) },
  404. mouseout : function(){ this.setStyles(_self.css.viewContentTrNode) }
  405. });
  406. if( this.view.selectEnable ){
  407. this.createSelectTd();
  408. }
  409. //if (this.view.json.select==="single" || this.view.json.select==="multi"){
  410. //this.selectTd = new Element("td", {"styles": this.css.viewContentTdNode}).inject(this.node);
  411. //this.selectTd.setStyles({"cursor": "pointer"});
  412. //if (this.view.json.itemStyles) this.selectTd.setStyles(this.view.json.itemStyles);
  413. //}
  414. //Object.each(this.data.data, function(cell, k){
  415. // if (this.view.hideColumns.indexOf(k)===-1){
  416. // var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(this.node);
  417. // if (k!== this.view.viewJson.group.column){
  418. // 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;
  419. // td.set("text", v);
  420. // }
  421. // if (this.view.openColumns.indexOf(k)!==-1){
  422. // this.setOpenWork(td)
  423. // }
  424. // if (this.view.json.itemStyles) td.setStyles(this.view.json.itemStyles);
  425. // }
  426. //}.bind(this));
  427. this.view.viewJson.selectList.each(function(column){
  428. var k = column.column;
  429. var cell = this.data.data[column.column];
  430. if (this.view.hideColumns.indexOf(k)===-1){
  431. var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(this.node);
  432. if (k!== this.view.viewJson.group.column){
  433. 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;
  434. td.set("text", v);
  435. }
  436. if (this.view.openColumns.indexOf(k)!==-1){
  437. this.setOpenWork(td)
  438. }
  439. if (this.view.json.itemStyles) td.setStyles(this.view.json.itemStyles);
  440. }
  441. }.bind(this));
  442. if( this.view.options.hasAction ){
  443. var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(this.node);
  444. this.loadActions( td );
  445. if (this.view.json.itemStyles) td.setStyles(this.view.json.itemStyles);
  446. }
  447. this.setEvent();
  448. },
  449. destroySelectTd : function(){
  450. if( this.checboxTd ){
  451. this.checboxTd.destroy();
  452. this.checboxTd = null;
  453. }
  454. },
  455. createSelectTd : function(){
  456. if( this.checboxTd )return;
  457. this.checboxTd = new Element("td").inject(this.node, "top");
  458. this.checkboxElement = new Element("input", {
  459. "type": "checkbox",
  460. "events" : { click : function(ev){ ev.stopPropagation(); } }
  461. }).inject(this.checboxTd);
  462. this.checboxTd.addEvent("click", function(ev){
  463. this.checkboxElement.set("checked", !this.checkboxElement.get("checked") );
  464. ev.stopPropagation();
  465. }.bind(this));
  466. },
  467. loadActions : function( container ){
  468. this.deleteNode = new Element("div", {"styles": this.css.actionDeleteNode, "title": "删除"}).inject(container);
  469. this.deleteNode.addEvents({
  470. "mouseover": function(){this.deleteNode.setStyles(this.css.actionDeleteNode_over);}.bind(this),
  471. "mouseout": function(){this.deleteNode.setStyles(this.css.actionDeleteNode);}.bind(this),
  472. "mousedown": function(){this.deleteNode.setStyles(this.css.actionDeleteNode_down);}.bind(this),
  473. "mouseup": function(){this.deleteNode.setStyles(this.css.actionDeleteNode_over);}.bind(this),
  474. "click": function(e){
  475. this.remove(e);
  476. e.stopPropagation();
  477. }.bind(this)
  478. });
  479. this.editNode = new Element("div", {"styles": this.css.actionEditNode, "title": "编辑"}).inject(container);
  480. this.editNode.addEvents({
  481. "mouseover": function(){this.editNode.setStyles(this.css.actionEditNode_over);}.bind(this),
  482. "mouseout": function(){this.editNode.setStyles(this.css.actionEditNode);}.bind(this),
  483. "mousedown": function(){this.editNode.setStyles(this.css.actionEditNode_down);}.bind(this),
  484. "mouseup": function(){this.editNode.setStyles(this.css.actionEditNode_over);}.bind(this),
  485. "click": function(e){
  486. this.editCMSDocument();
  487. e.stopPropagation();
  488. }.bind(this)
  489. });
  490. },
  491. setOpenWork: function(td){
  492. td.setStyle("cursor", "pointer");
  493. td.addEvent("click", function(){
  494. this.openCMSDocument()
  495. }.bind(this));
  496. },
  497. openCMSDocument : function( isEdited ){
  498. var appId = "cms.Document"+this.data.bundle;
  499. if (layout.desktop.apps[appId]){
  500. layout.desktop.apps[appId].setCurrent();
  501. }else {
  502. var options = {
  503. "documentId": this.data.bundle,
  504. "readonly" : !isEdited
  505. };
  506. layout.desktop.openApplication(null, "cms.Document", options);
  507. }
  508. },
  509. editCMSDocument : function(){
  510. this.openCMSDocument( true );
  511. },
  512. remove: function(e){
  513. var text = "删除后不能恢复,你确定要删除该文档?";
  514. var _self = this;
  515. this.node.setStyles(this.css.viewContentTrNode_delete);
  516. this.readyRemove = true;
  517. this.view.app.confirm("warn", e, "删除确认", text, 350, 120, function(){
  518. _self.removeCMSDocument(_self, false);
  519. this.close();
  520. }, function(){
  521. _self.node.setStyles(_self.css.viewContentTrNode );
  522. _self.readyRemove = false;
  523. this.close();
  524. });
  525. },
  526. removeCMSDocument: function(){
  527. var id = this.data.bundle;
  528. //this.view.lookupAction.invoke({"name": "deleteDocument","async": true, "parameter": {"id": id },"success": function(json){
  529. // this.readyRemove = false;
  530. // this.node.destroy();
  531. // this.view.app.notice("删除成功", "success");
  532. // MWF.release(this);
  533. //}.bind(this)});
  534. MWF.Actions.get("x_cms_assemble_control").removeDocument(id, function(json){
  535. this.readyRemove = false;
  536. this.node.destroy();
  537. this.view.app.notice("删除成功", "success");
  538. MWF.release(this);
  539. }.bind(this));
  540. }
  541. });
  542. MWF.xApplication.cms.Module.QueryViewer.ItemCategory = new Class({
  543. Extends : MWF.xApplication.query.Query.Viewer.ItemCategory,
  544. load: function(){
  545. this.node = new Element("tr", {"styles": this.css.viewContentTrNode}).inject(this.view.viewTable);
  546. //if (this.view.json.select==="single" || this.view.json.select==="multi"){
  547. this.selectTd = new Element("td", {"styles": this.css.viewContentCategoryTdNode}).inject(this.node);
  548. if (this.view.json.itemStyles) this.selectTd.setStyles(this.view.json.itemStyles);
  549. //}
  550. var colsapn = this.view.viewJson.selectList.length;
  551. if( this.view.options.hasAction ){
  552. colsapn ++
  553. }
  554. this.categoryTd = new Element("td", {
  555. "styles": this.css.viewContentCategoryTdNode,
  556. "colspan": colsapn
  557. }).inject(this.node);
  558. this.groupColumn = null;
  559. for (var c = 0; c<this.view.viewJson.selectList.length; c++){
  560. if (this.view.viewJson.selectList[c].column === this.view.viewJson.group.column){
  561. this.groupColumn = this.view.viewJson.selectList[c];
  562. break;
  563. }
  564. }
  565. if (this.groupColumn){
  566. 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;
  567. }else{
  568. var text = this.data.group;
  569. }
  570. 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);
  571. if (this.view.json.itemStyles) this.categoryTd.setStyles(this.view.json.itemStyles);
  572. this.setEvent();
  573. },
  574. expand: function(){
  575. this.items.each(function(item){
  576. item.node.setStyle("display", "table-row");
  577. }.bind(this));
  578. this.node.getElement("span").set("html", "<img src='/x_component_process_Application/$Viewer/"+this.view.options.style+"/icon/down.png'/>");
  579. if (!this.loadChild){
  580. //window.setTimeout(function(){
  581. this.data.list.each(function(line){
  582. this.items.push(new MWF.xApplication.cms.Module.QueryViewer.Item(this.view, line, this));
  583. }.bind(this));
  584. this.loadChild = true;
  585. //}.bind(this), 10);
  586. }
  587. }
  588. });
  589. //MWF.xApplication.cms.Module.Viewer = new Class({
  590. // Implements: [Options, Events],
  591. // Extends: MWF.xApplication.process.Application.Viewer,
  592. // options: {
  593. // "style": "default",
  594. // "hasAction" : false, //cxy add
  595. // "resizeNode": true,
  596. // "actions": {
  597. // //"lookup": {"uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}/execute", "method":"PUT"},
  598. // //"getView": {"uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}"},
  599. // "lookup": {"uri": "/jaxrs/view/{view}/execute", "method":"PUT"},
  600. // "getView": {"uri": "/jaxrs/view/{view}"},
  601. // "listWorkByJob": {"uri": "/jaxrs/job/{job}/find/work/workcompleted"},
  602. // "listTaskByWork": {"uri": "/jaxrs/work/{id}/assignment/manage"}
  603. //
  604. // },
  605. // "actionRoot": "x_processplatform_assemble_surface"
  606. // },
  607. // initialize: function(container, json, options, app, searchContainer){
  608. // this.setOptions(options);
  609. // this.app = app;
  610. // this.searchContainer = searchContainer;
  611. //
  612. // this.path = "/x_component_cms_Module/$ViewExplorer/";
  613. // this.cssPath = "/x_component_cms_Module/$ViewExplorer/"+this.options.style+"/viewer.wcss";
  614. // this._loadCss();
  615. // this.lp = MWF.xApplication.process.Application.LP;
  616. //
  617. // this.container = $(container);
  618. // this.json = json;
  619. //
  620. // this.viewJson = null;
  621. // this.filterItems = [];
  622. // this.searchStatus = "none"; //none, custom, default
  623. //
  624. //
  625. // this.items = [];
  626. // this.selectedItems = [];
  627. // this.hideColumns = [];
  628. // this.openColumns = [];
  629. //
  630. // this.gridJson = null;
  631. //
  632. // this.init(function(){
  633. // this.load();
  634. // }.bind(this));
  635. // },
  636. // selectMode : function(){
  637. // this.selectEnable = true;
  638. // this.createSelectTh();
  639. // this.items.each( function (it) {
  640. // it.createSelectTd();
  641. // }.bind(this));
  642. // },
  643. // disableSelectMode : function(){
  644. // this.selectEnable = false;
  645. // this.destroySelectTh();
  646. // this.items.each( function (it) {
  647. // it.destroySelectTd();
  648. // }.bind(this));
  649. // },
  650. // destroySelectTh : function(){
  651. // if( this.selectTh ){
  652. // this.selectTh.destroy();
  653. // this.selectTh = null;
  654. // }
  655. // },
  656. // createSelectTh : function(){
  657. // this.selectTh = new Element("th").inject(this.viewTitleLine, "top");
  658. // this.checkboxElement = new Element("input", {
  659. // "type": "checkbox"
  660. // }).inject(this.selectTh);
  661. // this.checkboxElement.addEvent("click", function () {
  662. // this.selectAll()
  663. // }.bind(this));
  664. // },
  665. // selectAll : function () {
  666. // var flag = this.checkboxElement.get("checked");
  667. // this.items.each(function (it) {
  668. // if (it.checkboxElement)it.checkboxElement.set("checked", flag)
  669. // }.bind(this))
  670. // },
  671. // getSelectedIds : function(){
  672. // var checkedItems = [];
  673. // this.items.each(function (it) {
  674. // if (it.checkboxElement.get("checked")) {
  675. // checkedItems.push( it.data.bundle )
  676. // }
  677. // }.bind(this));
  678. // return checkedItems;
  679. // },
  680. // getSelectedItems : function(){
  681. // var checkedItems = [];
  682. // this.items.each(function (it) {
  683. // if (it.checkboxElement.get("checked")) {
  684. // checkedItems.push( it )
  685. // }
  686. // }.bind(this));
  687. // return checkedItems;
  688. // },
  689. // createViewNode: function(data){
  690. // this.viewAreaNode.empty();
  691. // this.contentAreaNode = new Element("div", {"styles": this.css.contentAreaNode}).inject(this.viewAreaNode);
  692. //
  693. // this.viewTable = new Element("table", {
  694. // "styles": this.css.viewTitleTableNode,
  695. // "border": "0px",
  696. // "cellPadding": "0",
  697. // "cellSpacing": "0"
  698. // }).inject(this.contentAreaNode);
  699. // this.createLoadding();
  700. //
  701. // if (this.json.isTitle!=="no"){
  702. // this.viewTitleLine = new Element("tr", {"styles": this.css.viewTitleLineNode}).inject(this.viewTable);
  703. //
  704. // //if (this.json.select==="single" || this.json.select==="multi") {
  705. // this.selectTitleCell = new Element("td", {
  706. // "styles": this.css.viewTitleCellNode
  707. // }).inject(this.viewTitleLine);
  708. // this.selectTitleCell.setStyle("width", "10px");
  709. // if (this.json.titleStyles) this.selectTitleCell.setStyles(this.json.titleStyles);
  710. // //}
  711. // this.entries = {};
  712. // this.viewJson.selectList.each(function(column){
  713. // this.entries[column.column] = column;
  714. //
  715. // if (!column.hideColumn){
  716. // var viewCell = new Element("td", {
  717. // "styles": this.css.viewTitleCellNode,
  718. // "text": column.displayName
  719. // }).inject(this.viewTitleLine);
  720. // if (this.json.titleStyles) viewCell.setStyles(this.json.titleStyles);
  721. // }else{
  722. // this.hideColumns.push(column.column);
  723. // }
  724. // if (column.allowOpen) this.openColumns.push(column.column);
  725. // }.bind(this));
  726. //
  727. // if( this.options.hasAction ){
  728. // var viewCell = new Element("td", {
  729. // "styles": this.css.viewTitleCellNode,
  730. // "text": "操作"
  731. // }).inject(this.viewTitleLine);
  732. // viewCell.setStyle("width","40px");
  733. // if (this.json.titleStyles) viewCell.setStyles(this.json.titleStyles);
  734. // }
  735. //
  736. // this.lookup(data);
  737. // }else{
  738. // this.viewJson.selectEntryList.each(function(column){
  739. // if (column.hideColumn) this.hideColumns.push(column.column);
  740. // if (!column.allowOpen) this.openColumns.push(column.column);
  741. // }.bind(this));
  742. // this.lookup(data);
  743. // }
  744. // },
  745. // lookup: function(data){
  746. // this.getLookupAction(function(){
  747. // if (this.json.application){
  748. // this.lookupAction.invoke({"name": "lookup","async": true, "data": (data || null), "parameter": {"view": this.json.name, "application": this.json.application},"success": function(json){
  749. // this.viewData = json.data;
  750. // if (this.viewJson.group.column){
  751. // this.gridJson = json.data.groupGrid;
  752. // this.loadGroupData();
  753. // }else{
  754. // this.gridJson = json.data.grid;
  755. // this.loadData();
  756. // }
  757. // if (this.loadingAreaNode){
  758. // this.loadingAreaNode.destroy();
  759. // this.loadingAreaNode = null;
  760. // }
  761. // }.bind(this)});
  762. // }
  763. // }.bind(this));
  764. // },
  765. // loadLayout: function(){
  766. // this.node = new Element("div", {"styles": this.css.node}).inject(this.container);
  767. // this.searchAreaNode = new Element("div", {"styles": this.css.searchAreaNode}).inject(this.searchContainer || this.node );
  768. // this.viewAreaNode = new Element("div", {"styles": this.css.viewAreaNode}).inject(this.node);
  769. // },
  770. // loadData: function(){
  771. // if (this.gridJson.length){
  772. // this.gridJson.each(function(line, i){
  773. // this.items.push(new MWF.xApplication.cms.Module.Viewer.Item(this, line, null, i));
  774. // }.bind(this));
  775. // }
  776. // },
  777. // loadGroupData: function(){
  778. // if (this.selectTitleCell){
  779. // this.selectTitleCell.set("html", "<span style='font-family: Webdings'>"+"<img src='/x_component_process_Application/$Viewer/"+this.options.style+"/icon/expand.png'/>"+"</span>");
  780. // this.selectTitleCell.setStyle("cursor", "pointer");
  781. // this.selectTitleCell.addEvent("click", this.expandOrCollapseAll.bind(this));
  782. // }
  783. //
  784. // if (this.gridJson.length){
  785. // this.gridJson.each(function(data){
  786. // this.items.push(new MWF.xApplication.cms.Module.Viewer.ItemCategory(this, data));
  787. // }.bind(this));
  788. //
  789. // if (this.json.isExpand=="yes")this.expandOrCollapseAll();
  790. // }
  791. // },
  792. // setContentHeight: function(){
  793. // if( this.node && this.searchAreaNode && this.viewAreaNode ){
  794. // var size = this.node.getSize();
  795. // var searchSize = this.searchAreaNode.getSize();
  796. // var h = size.y-searchSize.y;
  797. // this.viewAreaNode.setStyle("height", ""+h+"px");
  798. // }
  799. // }
  800. //});
  801. //
  802. //MWF.xApplication.cms.Module.Viewer.Item = new Class({
  803. // Extends : MWF.xApplication.process.Application.Viewer.Item,
  804. // load: function(){
  805. // var _self = this;
  806. // this.node = new Element("tr", {"styles": this.css.viewContentTrNode});
  807. // if (this.prev){
  808. // this.node.inject(this.prev.node, "after");
  809. // }else{
  810. // this.node.inject(this.view.viewTable);
  811. // }
  812. // this.node.addEvents({
  813. // mouseover : function(){ this.setStyles(_self.css.viewContentTrNode_over) },
  814. // mouseout : function(){ this.setStyles(_self.css.viewContentTrNode) }
  815. // });
  816. //
  817. // if( this.view.selectEnable ){
  818. // this.createSelectTd();
  819. // }
  820. //
  821. // //if (this.view.json.select==="single" || this.view.json.select==="multi"){
  822. // this.selectTd = new Element("td", {"styles": this.css.viewContentTdNode}).inject(this.node);
  823. // this.selectTd.setStyles({"cursor": "pointer"});
  824. // if (this.view.json.itemStyles) this.selectTd.setStyles(this.view.json.itemStyles);
  825. // //}
  826. //
  827. // debugger;
  828. // this.view.viewJson.selectList.each(function(column){
  829. // var k = column.column;
  830. // var cell = this.data.data[column.column];
  831. //
  832. // if (this.view.hideColumns.indexOf(k)===-1){
  833. // var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(this.node);
  834. // if (k!== this.view.viewJson.group.column){
  835. // 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;
  836. // td.set("text", v);
  837. // }
  838. // if (this.view.openColumns.indexOf(k)!==-1){
  839. // this.setOpenWork(td)
  840. // }
  841. // if (this.view.json.itemStyles) td.setStyles(this.view.json.itemStyles);
  842. // }
  843. //
  844. // }.bind(this));
  845. //
  846. // //Object.each(this.data.data, function(cell, k){
  847. // // if (this.view.hideColumns.indexOf(k)===-1){
  848. // // var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(this.node);
  849. // // if (k!== this.view.viewJson.group.column){
  850. // // 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;
  851. // // td.set("text", v);
  852. // // }
  853. // // if (this.view.openColumns.indexOf(k)!==-1){
  854. // // this.setOpenWork(td)
  855. // // }
  856. // // if (this.view.json.itemStyles) td.setStyles(this.view.json.itemStyles);
  857. // // }
  858. // //}.bind(this));
  859. //
  860. // if( this.view.options.hasAction ){
  861. // var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(this.node);
  862. // this.loadActions( td );
  863. // if (this.view.json.itemStyles) td.setStyles(this.view.json.itemStyles);
  864. // }
  865. //
  866. // this.setEvent();
  867. // },
  868. //
  869. // loadActions : function( container ){
  870. // this.deleteNode = new Element("div", {"styles": this.css.actionDeleteNode, "title": "删除"}).inject(container);
  871. // this.deleteNode.addEvents({
  872. // "mouseover": function(){this.deleteNode.setStyles(this.css.actionDeleteNode_over);}.bind(this),
  873. // "mouseout": function(){this.deleteNode.setStyles(this.css.actionDeleteNode);}.bind(this),
  874. // "mousedown": function(){this.deleteNode.setStyles(this.css.actionDeleteNode_down);}.bind(this),
  875. // "mouseup": function(){this.deleteNode.setStyles(this.css.actionDeleteNode_over);}.bind(this),
  876. // "click": function(e){
  877. // this.remove(e);
  878. // e.stopPropagation();
  879. // }.bind(this)
  880. // });
  881. //
  882. // this.editNode = new Element("div", {"styles": this.css.actionEditNode, "title": "编辑"}).inject(container);
  883. // this.editNode.addEvents({
  884. // "mouseover": function(){this.editNode.setStyles(this.css.actionEditNode_over);}.bind(this),
  885. // "mouseout": function(){this.editNode.setStyles(this.css.actionEditNode);}.bind(this),
  886. // "mousedown": function(){this.editNode.setStyles(this.css.actionEditNode_down);}.bind(this),
  887. // "mouseup": function(){this.editNode.setStyles(this.css.actionEditNode_over);}.bind(this),
  888. // "click": function(e){
  889. // this.editCMSDocument();
  890. // e.stopPropagation();
  891. // }.bind(this)
  892. // });
  893. // },
  894. // destroySelectTd : function(){
  895. // if( this.checboxTd ){
  896. // this.checboxTd.destroy();
  897. // this.checboxTd = null;
  898. // }
  899. // },
  900. // createSelectTd : function(){
  901. // if( this.checboxTd )return;
  902. // this.checboxTd = new Element("td").inject(this.node, "top");
  903. // this.checboxTd.addEvent("click", function(ev){
  904. // ev.stopPropagation();
  905. // });
  906. // this.checkboxElement = new Element("input", {
  907. // "type": "checkbox"
  908. // }).inject(this.checboxTd);
  909. // },
  910. // setOpenWork: function(td){
  911. // td.setStyle("cursor", "pointer");
  912. // td.addEvent("click", function(){
  913. // this.openCMSDocument()
  914. // }.bind(this));
  915. // },
  916. // openCMSDocument : function( isEdited ){
  917. // var appId = "cms.Document"+this.data.bundle;
  918. // if (layout.desktop.apps[appId]){
  919. // layout.desktop.apps[appId].setCurrent();
  920. // }else {
  921. // var options = {
  922. // "documentId": this.data.bundle,
  923. // "readonly" : !isEdited
  924. // };
  925. // layout.desktop.openApplication(null, "cms.Document", options);
  926. // }
  927. // },
  928. // editCMSDocument : function(){
  929. // this.openCMSDocument( true );
  930. // },
  931. // remove: function(e){
  932. // var text = "删除后不能恢复,你确定要删除该文档?";
  933. // var _self = this;
  934. // this.node.setStyles(this.css.viewContentTrNode_delete);
  935. // this.readyRemove = true;
  936. // this.view.app.confirm("warn", e, "删除确认", text, 350, 120, function(){
  937. //
  938. // _self.removeCMSDocument(_self, false);
  939. //
  940. // this.close();
  941. //
  942. // }, function(){
  943. // _self.node.setStyles(_self.css.viewContentTrNode );
  944. // _self.readyRemove = false;
  945. // this.close();
  946. // });
  947. // },
  948. // removeCMSDocument: function(){
  949. // var id = this.data.bundle;
  950. // MWF.Actions.get("x_cms_assemble_control").removeDocument(id, function(json){
  951. // //this.viewJson = JSON.decode(json.data.data);
  952. // //this.json = Object.merge(this.json, json.data);
  953. // this.readyRemove = false;
  954. // this.node.destroy();
  955. // this.view.app.notice("删除成功", "success");
  956. // MWF.release(this);
  957. // }.bind(this));
  958. // }
  959. //
  960. //});
  961. //
  962. //MWF.xApplication.cms.Module.Viewer.ItemCategory = new Class({
  963. // Extends : MWF.xApplication.process.Application.Viewer.ItemCategory,
  964. // load: function(){
  965. // this.node = new Element("tr", {"styles": this.css.viewContentTrNode}).inject(this.view.viewTable);
  966. // //if (this.view.json.select==="single" || this.view.json.select==="multi"){
  967. // this.selectTd = new Element("td", {"styles": this.css.viewContentCategoryTdNode}).inject(this.node);
  968. // if (this.view.json.itemStyles) this.selectTd.setStyles(this.view.json.itemStyles);
  969. // //}
  970. //
  971. // var colsapn = this.view.viewJson.selectList.length;
  972. // if( this.view.options.hasAction ){
  973. // colsapn ++
  974. // }
  975. //
  976. // this.categoryTd = new Element("td", {
  977. // "styles": this.css.viewContentCategoryTdNode,
  978. // "colspan": colsapn
  979. // }).inject(this.node);
  980. //
  981. // this.groupColumn = null;
  982. // for (var c = 0; c<this.view.viewJson.selectList.length; c++){
  983. // if (this.view.viewJson.selectList[c].column === this.view.viewJson.group.column){
  984. // this.groupColumn = this.view.viewJson.selectList[c];
  985. // break;
  986. // }
  987. // }
  988. // if (this.groupColumn){
  989. // 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;
  990. // }else{
  991. // var text = this.data.group;
  992. // }
  993. //
  994. // 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);
  995. // if (this.view.json.itemStyles) this.categoryTd.setStyles(this.view.json.itemStyles);
  996. //
  997. // this.setEvent();
  998. // },
  999. // expand: function(){
  1000. // this.items.each(function(item){
  1001. // item.node.setStyle("display", "table-row");
  1002. // }.bind(this));
  1003. // this.node.getElement("span").set("html", "<img src='/x_component_process_Application/$Viewer/"+this.view.options.style+"/icon/down.png'/>");
  1004. // if (!this.loadChild){
  1005. // //window.setTimeout(function(){
  1006. // this.data.list.each(function(line){
  1007. // this.items.push(new MWF.xApplication.cms.Module.Viewer.Item(this.view, line, this));
  1008. // }.bind(this));
  1009. // this.loadChild = true;
  1010. // //}.bind(this), 10);
  1011. // }
  1012. // }
  1013. //});