MinderExplorer.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. MWF.xApplication.Execution = MWF.xApplication.Execution || {};
  2. MWF.xDesktop.requireApp("Template", "Explorer", null, false);
  3. MWF.xDesktop.requireApp("Execution", "WorkMinder", null, false);
  4. MWF.require("MWF.widget.Identity", null,false);
  5. MWF.xApplication.Execution.MinderExplorer = new Class({
  6. Extends: MWF.widget.Common,
  7. Implements: [Options, Events],
  8. options: {
  9. "style": "default"
  10. },
  11. initialize: function (node, app, actions, options) {
  12. this.app = app;
  13. this.lp = app.lp;
  14. this.path = "/x_component_Execution/$MinderExplorer/";
  15. this.actions = actions;
  16. this.options.style = this.getViewStyle();
  17. this.setOptions(options);
  18. this.loadCss();
  19. this.node = $(node);
  20. },
  21. loadCss: function () {
  22. this.cssPath = "/x_component_Execution/$MinderExplorer/" + this.options.style + "/css.wcss";
  23. this._loadCss();
  24. },
  25. load: function () {
  26. this.middleContent = this.app.middleContent;
  27. //this.middleContent.setStyles({"margin-top":"0px","border":"0px solid #f00"});
  28. this.createNaviContent();
  29. //this.createContentDiv();
  30. this.resizeWindow();
  31. this.app.addEvent("resize", function(){
  32. this.resizeWindow();
  33. }.bind(this));
  34. },
  35. resizeWindow: function(){
  36. var size = this.app.middleContent.getSize();
  37. this.naviDiv.setStyles({"height":(size.y-40)+"px"});
  38. this.naviContentDiv.setStyles({"height":(size.y-180)+"px"});
  39. this.contentDiv.setStyles({"height":(size.y-40)+"px"});
  40. //this.viewContainer.setStyles({"height":(size.y-90)+"px"});
  41. },
  42. createNaviContent: function(){
  43. this.naviDiv = new Element("div.naviDiv",{
  44. "styles":this.css.naviDiv
  45. }).inject(this.middleContent);
  46. this.naviTitleDiv = new Element("div.naviTitleDiv",{
  47. "styles":this.css.naviTitleDiv,
  48. "text": this.lp.minderExplorerTitle
  49. }).inject(this.naviDiv);
  50. this.naviContentDiv = new Element("div.naviContentDiv",{"styles":this.css.naviContentDiv}).inject(this.naviDiv);
  51. this.naviBottomDiv = new Element("div.naviBottomDiv",{"styles":this.css.naviBottomDiv}).inject(this.naviDiv);
  52. this.createContentDiv();
  53. var jsonUrl = this.path+"navi.json";
  54. MWF.getJSON(jsonUrl, function(json){
  55. json.each(function(data, i){
  56. var naviContentLi = new Element("li.naviContentLi",{"styles":this.css.naviContentLi}).inject(this.naviContentDiv);
  57. naviContentLi.addEvents({
  58. "mouseover" : function(ev){
  59. if(this.bindObj.currentNaviItem != this.node)this.node.setStyles( this.styles )
  60. }.bind({"styles": this.css.naviContentLi_over, "node":naviContentLi, "bindObj": this }) ,
  61. "mouseout" : function(ev){
  62. if(this.bindObj.currentNaviItem != this.node)this.node.setStyles( this.styles )
  63. }.bind({"styles": this.css.naviContentLi, "node":naviContentLi, "bindObj": this }) ,
  64. "click" : function(ev){
  65. if( this.bindObj.currentNaviItem )this.bindObj.currentNaviItem.setStyles( this.bindObj.css.naviContentLi );
  66. this.node.setStyles( this.styles );
  67. this.bindObj.currentNaviItem = this.node;
  68. if( this.action && this.bindObj[this.action] ){
  69. this.bindObj[this.action]();
  70. }
  71. }.bind({"styles": this.css.naviContentLi_current, "node":naviContentLi, "bindObj": this, "action" : data.action })
  72. });
  73. var naviContentImg = new Element("img.naviContentImg",{
  74. "styles":this.css.naviContentImg,
  75. "src":"/x_component_Execution/$Main/default/icon/"+data.icon
  76. }).inject(naviContentLi);
  77. var naviContentSpan = new Element("span.naviContentSpan",{
  78. "styles":this.css.naviContentSpan,
  79. "text":data.title
  80. }).inject(naviContentLi);
  81. if( i == 0 ){
  82. naviContentLi.click();
  83. }
  84. }.bind(this));
  85. }.bind(this));
  86. },
  87. createContentDiv: function(){
  88. this.contentDiv = new Element("div.contentDiv",{"styles":this.css.contentDiv}).inject(this.middleContent);
  89. },
  90. openCenterWork: function(){
  91. this.contentDiv.empty();
  92. this.loadCategoryBar();
  93. this.loadToolbar();
  94. //this.loadView();
  95. },
  96. loadCategoryBar : function(){
  97. var _self = this;
  98. this.categoryBar = new Element("div.categoryBar",{"styles":this.css.categoryBar}).inject(this.contentDiv);
  99. this.allCategoryNode = new Element("li.allCategoryNode", {
  100. "styles": this.css.categoryNode,
  101. "text" : "全部"
  102. }).inject(this.categoryBar);
  103. this.allCategoryNode.addEvents({
  104. "mouseover" : function(){ if( this.currentCategoryNode != this.allCategoryNode)this.allCategoryNode.setStyles(this.css.categoryNode_over) }.bind(this),
  105. "mouseout" : function(){ if( this.currentCategoryNode != this.allCategoryNode)this.allCategoryNode.setStyles(this.css.categoryNode) }.bind(this),
  106. "click":function(){
  107. if( this.currentCategoryNode )this.currentCategoryNode.setStyles(this.css.categoryNode);
  108. this.currentCategoryNode = this.allCategoryNode;
  109. this.allCategoryNode.setStyles(this.css.categoryNode_current);
  110. this.loadView( )
  111. }.bind(this)
  112. });
  113. this.actions.getCategoryCountAll( function( json ){
  114. json.data = json.data || [];
  115. json.data.each( function( d ){
  116. var categoryNode = new Element("li.categoryNode", {
  117. "styles": this.css.categoryNode,
  118. "text" : d.workTypeName + "(" + d.centerCount +")"
  119. }).inject(this.categoryBar);
  120. categoryNode.store( "workTypeName" , d.workTypeName );
  121. categoryNode.addEvents({
  122. "mouseover" : function(){ if( _self.currentCategoryNode != this.node)this.node.setStyles(_self.css.categoryNode_over) }.bind({node : categoryNode }),
  123. "mouseout" : function(){ if( _self.currentCategoryNode != this.node)this.node.setStyles(_self.css.categoryNode) }.bind({node : categoryNode }),
  124. "click":function(){
  125. if( _self.currentCategoryNode )_self.currentCategoryNode.setStyles(_self.css.categoryNode);
  126. _self.currentCategoryNode = this.node;
  127. this.node.setStyles(_self.css.categoryNode_current);
  128. _self.loadView( )
  129. }.bind({ name : d.workTypeName, node : categoryNode })
  130. })
  131. }.bind(this))
  132. }.bind(this), null, false
  133. );
  134. this.allCategoryNode.click();
  135. },
  136. loadToolbar: function(){
  137. this.toolbar = new Element("div",{
  138. styles : this.css.toolbar
  139. }).inject(this.categoryBar);
  140. //this.toolbarTextNode = new Element("div",{
  141. // styles : this.css.toolbarTextNode,
  142. // text: this.lp.workTask.centerWork,
  143. //}).inject(this.toolbar);
  144. this.fileterNode = new Element("div",{
  145. styles : this.css.fileterNode
  146. }).inject(this.toolbar);
  147. this.loadFilter();
  148. },
  149. loadFilter: function () {
  150. var _self = this;
  151. var html = "<table bordr='0' cellpadding='5' cellspacing='0' styles='filterTable'>" +
  152. "<tr>" +
  153. //" <td styles='filterTableTitle' lable='year'></td>" +
  154. //" <td styles='filterTableValue' item='year'></td>" +
  155. //" <td styles='filterTableTitle' lable='workLevel'></td>" +
  156. //" <td styles='filterTableValue' item='workLevel'></td>" +
  157. //" <td styles='filterTableTitle' lable='workType'></td>" +
  158. //" <td styles='filterTableValue' item='workType'></td>" +
  159. //" <td styles='filterTableTitle' lable='star'></td>" +
  160. //" <td styles='filterTableValue' item='star'></td>" +
  161. " <td styles='filterTableValue' item='workTitle'></td>" +
  162. " <td styles='filterTableValue' item='searchAction'></td>" +
  163. " <td styles='filterTableValue' item='returnAction' style='display:none;'></td>" +
  164. "</tr>" +
  165. "</table>";
  166. this.fileterNode.set("html", html);
  167. MWF.xDesktop.requireApp("Template", "MForm", function () {
  168. this.filter = new MForm(this.fileterNode, {}, {
  169. style: "execution",
  170. isEdited: true,
  171. itemTemplate: {
  172. year: {
  173. "text": this.lp.yearCount +":", "type": "select", "className": "inputSelectUnformatWidth",
  174. "selectValue": function () {
  175. var years = [], year = new Date().getFullYear();
  176. for (var i = 0; i < 6; i++) years.push(year--);
  177. return years;
  178. }
  179. },
  180. workLevel: {
  181. "text": this.lp.level +":", "type": "select","className": "inputSelectUnformatWidth",
  182. "selectValue": this.lp.workForm.workLevelValue.split(",")
  183. },
  184. workType: {
  185. "text": this.lp.type +":","type": "select","className": "inputSelectUnformatWidth",
  186. "selectValue": this.lp.workForm.workTypeValue.split(",")
  187. },
  188. star: {"text": this.lp.starWork +":", "type": "select", "className": "inputSelectUnformatWidth", "selectValue": this.lp.starWorkText.split(",")},
  189. workTitle: { "style":this.css.filterTitle , defaultValue : this.lp.searchText, "event" : {
  190. focus : function( item ){ if(item.get("value")==_self.lp.searchText)item.setValue("") },
  191. blur : function( item ){ if(item.get("value").trim()=="")item.setValue(_self.lp.searchText) },
  192. keydown: function( item, ev){
  193. if (ev.code == 13){ //回车,搜索
  194. _self.fileterNode.getElements("[item='returnAction']").setStyle("display","");
  195. _self.loadView( );
  196. }
  197. }.bind(this)
  198. }},
  199. searchAction: {
  200. "type": "button", "value": this.lp.search, "style": this.css.filterButton,
  201. "event": {
  202. "click": function () {
  203. _self.fileterNode.getElements("[item='returnAction']").setStyle("display","");
  204. _self.loadView( );
  205. }
  206. }
  207. },
  208. returnAction : {
  209. "type": "button", "value": this.lp.return, "style": this.css.filterButton,
  210. "event": {
  211. "click": function () {
  212. _self.filter.getItem("workTitle").setValue( _self.lp.searchText );
  213. _self.fileterNode.getElements("[item='returnAction']").setStyle("display","none");
  214. _self.loadView();
  215. }
  216. }
  217. }
  218. }
  219. }, this.app, this.css);
  220. this.filter.load();
  221. }.bind(this), true);
  222. },
  223. loadView : function( ){
  224. var filterData = {};
  225. if( this.currentCategoryNode ){
  226. var value = this.currentCategoryNode.retrieve("workTypeName");
  227. if( value && value != "" ){
  228. filterData.workTypes = [value];
  229. }
  230. }
  231. if( this.filter ){
  232. var fd = this.filter.getResult(true, ",", true, true, true);
  233. //fd.title = fd.title.replace(this.lp.searchText,"");
  234. fd.workTitle = fd.workTitle.replace(this.lp.searchText,"");
  235. fd.maxCharacterNumber = "-1";
  236. for( var key in fd ){
  237. if( fd[key] != "" ){
  238. filterData[key] = fd[key];
  239. }
  240. }
  241. }
  242. var flag = false;
  243. if( this.viewContainer ){
  244. flag = true;
  245. this.viewContainer.destroy();
  246. }
  247. this.viewContainer = Element("div",{
  248. "styles" : this.css.viewContainer
  249. }).inject(this.contentDiv);
  250. this.setViewSize();
  251. if( !flag ){
  252. this.setViewSizeFun = this.setViewSize.bind(this);
  253. this.app.addEvent("resize", this.setViewSizeFun );
  254. }
  255. if( this.view ){
  256. this.view.destroy();
  257. }
  258. this.getViewStyle();
  259. this.view = new MWF.xApplication.Execution.MinderExplorer.WorkView( this.viewContainer, this.app, this, {
  260. templateUrl : this.path+ ( this.getViewStyle() == "default" ? "listItem.json" : "listItem_graph.json" ),
  261. "scrollEnable" : true
  262. }, {
  263. lp : this.lp.centerWorkView
  264. });
  265. if( filterData )this.view.filterData = filterData;
  266. this.view.load();
  267. },
  268. getViewStyle : function(){
  269. if( this.viewStyle ) return this.viewStyle;
  270. this.actions.getProfileByCode( { "configCode" : "MIND_LISTSTYLE"} ,function( json ){
  271. if( json.data ){
  272. this.viewStyle = ( json.data.configValue == "ICON" ? "graph" : "default");
  273. }else{
  274. this.viewStyle = "default";
  275. }
  276. }.bind(this), function(){
  277. this.viewStyle = "default";
  278. }.bind(this), false );
  279. return this.viewStyle || "default";
  280. },
  281. setViewSize: function(){
  282. var size = this.app.middleContent.getSize();
  283. var categoryBarSzie = this.categoryBar ? this.categoryBar.getSize() : {x:0, y:0};
  284. this.viewContainer.setStyles({"height":(size.y - categoryBarSzie.y - 56 )+"px"});
  285. }
  286. });
  287. MWF.xApplication.Execution.MinderExplorer.WorkView = new Class({
  288. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  289. _createDocument: function(data){
  290. return new MWF.xApplication.Execution.MinderExplorer.WorkDocument(this.viewNode, data, this.explorer, this);
  291. },
  292. _getCurrentPageData: function(callback, count){
  293. if (!count)count = 20;
  294. var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  295. if(id=="(0)")this.app.createShade();
  296. var filter = this.filterData || {};
  297. this.actions.getCenterWorkListNext(id, count, filter, function (json) {
  298. if (callback)callback(json);
  299. this.app.destroyShade();
  300. }.bind(this))
  301. },
  302. _removeDocument: function(documentData, all){
  303. //this.actions.deleteSchedule(documentData.id, function(json){
  304. // this.reload();
  305. // this.app.notice(this.app.lp.deleteDocumentOK, "success");
  306. //}.bind(this));
  307. },
  308. _create: function(){
  309. },
  310. _openDocument: function( documentData ){
  311. var workMinder = new MWF.xApplication.Execution.WorkMinder( this.explorer, documentData, {});
  312. workMinder.load();
  313. },
  314. _queryCreateViewNode: function(){
  315. },
  316. _postCreateViewNode: function( viewNode ){
  317. },
  318. _queryCreateViewHead:function(){
  319. },
  320. _postCreateViewHead: function( headNode ){
  321. }
  322. });
  323. MWF.xApplication.Execution.MinderExplorer.WorkDocument = new Class({
  324. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  325. mouseoverDocument : function(){
  326. this.node.getElements("[styles='documentItemTitleNode']").setStyles(this.css["documentItemTitleNode_over"]);
  327. this.node.getElements("[styles='documentItemIconNode']").setStyles(this.css["documentItemIconNode_over"]);
  328. this.node.getElements("[styles='documentItemStatNode']").setStyles(this.css["documentItemStatNode_over"]);
  329. },
  330. mouseoutDocument : function(){
  331. this.node.getElements("[styles='documentItemTitleNode']").setStyles(this.css["documentItemTitleNode"]);
  332. this.node.getElements("[styles='documentItemIconNode']").setStyles(this.css["documentItemIconNode"]);
  333. this.node.getElements("[styles='documentItemStatNode']").setStyles(this.css["documentItemStatNode"]);
  334. },
  335. _queryCreateDocumentNode:function( itemData ){
  336. },
  337. _postCreateDocumentNode: function( itemNode, itemData ){
  338. },
  339. removeCenterWork : function(itemData){
  340. //如果是管理员有删除部署的中心工作的权限
  341. //if(isAdmin){
  342. // return true;
  343. //}
  344. return false;
  345. }
  346. });