MinderExplorer.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  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='title'></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. title: { "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("title").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. for( var key in fd ){
  235. if( fd[key] != "" ){
  236. filterData[key] = fd[key];
  237. }
  238. }
  239. }
  240. var flag = false;
  241. if( this.viewContainer ){
  242. flag = true;
  243. this.viewContainer.destroy();
  244. }
  245. this.viewContainer = Element("div",{
  246. "styles" : this.css.viewContainer
  247. }).inject(this.contentDiv);
  248. this.setViewSize();
  249. if( !flag ){
  250. this.setViewSizeFun = this.setViewSize.bind(this);
  251. this.app.addEvent("resize", this.setViewSizeFun );
  252. }
  253. if( this.view ){
  254. this.view.destroy();
  255. }
  256. this.getViewStyle();
  257. this.view = new MWF.xApplication.Execution.MinderExplorer.WorkView( this.viewContainer, this.app, this, {
  258. templateUrl : this.path+ ( this.getViewStyle() == "default" ? "listItem.json" : "listItem_graph.json" ),
  259. "scrollEnable" : true
  260. }, {
  261. lp : this.lp.centerWorkView
  262. })
  263. if( filterData )this.view.filterData = filterData;
  264. this.view.load();
  265. },
  266. getViewStyle : function(){
  267. if( this.viewStyle ) return this.viewStyle;
  268. this.actions.getProfileByCode( { "configCode" : "MIND_LISTSTYLE"} ,function( json ){
  269. if( json.data ){
  270. this.viewStyle = ( json.data.configValue == "ICON" ? "graph" : "default");
  271. }else{
  272. this.viewStyle = "default";
  273. }
  274. }.bind(this), function(){
  275. this.viewStyle = "default";
  276. }.bind(this), false );
  277. return this.viewStyle || "default";
  278. },
  279. setViewSize: function(){
  280. var size = this.app.middleContent.getSize();
  281. var categoryBarSzie = this.categoryBar ? this.categoryBar.getSize() : {x:0, y:0};
  282. this.viewContainer.setStyles({"height":(size.y - categoryBarSzie.y - 56 )+"px"});
  283. }
  284. })
  285. MWF.xApplication.Execution.MinderExplorer.WorkView = new Class({
  286. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  287. _createDocument: function(data){
  288. return new MWF.xApplication.Execution.MinderExplorer.WorkDocument(this.viewNode, data, this.explorer, this);
  289. },
  290. _getCurrentPageData: function(callback, count){
  291. if (!count)count = 20;
  292. var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  293. var filter = this.filterData || {};
  294. this.actions.getCenterWorkListNext(id, count, filter, function (json) {
  295. if (callback)callback(json);
  296. }.bind(this))
  297. },
  298. _removeDocument: function(documentData, all){
  299. //this.actions.deleteSchedule(documentData.id, function(json){
  300. // this.reload();
  301. // this.app.notice(this.app.lp.deleteDocumentOK, "success");
  302. //}.bind(this));
  303. },
  304. _create: function(){
  305. },
  306. _openDocument: function( documentData ){
  307. var workMinder = new MWF.xApplication.Execution.WorkMinder( this.explorer, documentData, {});
  308. workMinder.load();
  309. },
  310. _queryCreateViewNode: function(){
  311. },
  312. _postCreateViewNode: function( viewNode ){
  313. },
  314. _queryCreateViewHead:function(){
  315. },
  316. _postCreateViewHead: function( headNode ){
  317. }
  318. })
  319. MWF.xApplication.Execution.MinderExplorer.WorkDocument = new Class({
  320. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  321. mouseoverDocument : function(){
  322. this.node.getElements("[styles='documentItemTitleNode']").setStyles(this.css["documentItemTitleNode_over"]);
  323. this.node.getElements("[styles='documentItemIconNode']").setStyles(this.css["documentItemIconNode_over"]);
  324. this.node.getElements("[styles='documentItemStatNode']").setStyles(this.css["documentItemStatNode_over"]);
  325. },
  326. mouseoutDocument : function(){
  327. this.node.getElements("[styles='documentItemTitleNode']").setStyles(this.css["documentItemTitleNode"]);
  328. this.node.getElements("[styles='documentItemIconNode']").setStyles(this.css["documentItemIconNode"]);
  329. this.node.getElements("[styles='documentItemStatNode']").setStyles(this.css["documentItemStatNode"]);
  330. },
  331. _queryCreateDocumentNode:function( itemData ){
  332. },
  333. _postCreateDocumentNode: function( itemNode, itemData ){
  334. },
  335. removeCenterWork : function(itemData){
  336. //如果是管理员有删除部署的中心工作的权限
  337. //if(isAdmin){
  338. // return true;
  339. //}
  340. return false;
  341. }
  342. })