ViewExplorer.js 45 KB

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