WorkContent.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. MWF.xApplication.BAM.summary = MWF.xApplication.BAM.summary || {};
  2. MWF.xDesktop.requireApp("BAM", "summary.TaskContent", null, false);
  3. MWF.xApplication.BAM.summary.WorkContent = new Class({
  4. Extends: MWF.xApplication.BAM.summary.TaskContent,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default"
  8. },
  9. initialize: function(summary, node, data, options){
  10. this.setOptions(options);
  11. this.summary = summary;
  12. this.app = this.summary.app;
  13. this.css = this.app.css;
  14. this.lp = this.app.lp;
  15. this.container = $(node);
  16. this.category = "application";
  17. this.data = this.summary.categoryData;
  18. this.maxColumn = 10;
  19. this.barOptions = {"style": "work"};
  20. this.load();
  21. },
  22. load: function(){
  23. this.loadArea(this.lp.work);
  24. this.loadBarData(this.loadBar.bind(this));
  25. },
  26. loadCategory: function(){
  27. var id = new MWF.widget.UUID();
  28. var html = "<input name='"+id+"TaskRankCategory' type='radio' value='application' checked>"+this.lp.application+
  29. "<input name='"+id+"TaskRankCategory' type='radio' value='process'>"+this.lp.process
  30. this.categoryNode.set("html", html);
  31. var _self = this;
  32. this.categoryNode.getElements("input").addEvent("click", function(){
  33. _self.category = this.value;
  34. _self.reload();
  35. });
  36. },
  37. reloadMaxChart: function(){
  38. this.node.inject(this.maxNode);
  39. this.node.setStyles(this.css.taskContentNode_max);
  40. this.chartAreaNode.setStyles(this.css.contentChartAreaNode_max);
  41. this.actionNode.setStyles(this.css.taskRankActionNode_max);
  42. var tabSize = this.chartAreaNode.getSize();
  43. var h = tabSize.y-80;
  44. this.countNode.setStyle("height", ""+h+"px");
  45. this.expiredNode.setStyle("height", ""+h+"px");
  46. this.expiredCountNode.setStyle("height", ""+h+"px");
  47. if (this.timeoutRateNode) this.timeoutRateNode.setStyle("height", ""+h+"px");
  48. if (this.timelinessRateNode) this.timelinessRateNode.setStyle("height", ""+h+"px");
  49. this.maxColumn = Math.round(tabSize.x/40);
  50. this.barOptions = {"marginBottom": 100, "delay": 10, "style": "work_max"};
  51. this.reload();
  52. },
  53. loadBar: function(){
  54. MWF.require("MWF.widget.chart.Bar", function(){
  55. this.countPage.addEvent("show", function(){
  56. if (!this.countBar){
  57. this.countBar = this.loadBarChart(this.countNode, this[this.category+"Data"].workCount.slice(0,this.maxColumn),this.barOptions);
  58. } else {
  59. this.countBar.transition();
  60. }
  61. }.bind(this));
  62. this.expiredPage.addEvent("show", function(){
  63. if (!this.elapsedBar){
  64. this.elapsedBar = this.loadBarChart(this.expiredNode, this[this.category+"Data"].workDuration.slice(0,this.maxColumn),this.barOptions);
  65. } else {
  66. this.elapsedBar.transition();
  67. }
  68. }.bind(this));
  69. this.expiredCountPage.addEvent("show", function(){
  70. if (!this.elapsedCountBar){
  71. this.elapsedCountBar = this.loadBarChart(this.expiredCountNode, this[this.category+"Data"].workElapsedCount.slice(0,this.maxColumn),this.barOptions);
  72. } else {
  73. this.elapsedCountBar.transition();
  74. }
  75. }.bind(this));
  76. this.timeoutRatePage.addEvent("show", function(){
  77. if (!this.timeoutBar){
  78. var options = (this.barOptions) ? Object.clone(this.barOptions) : {};
  79. options.tickFormat = ".0%";
  80. options.dataFormat = ".1%";
  81. this.timeoutBar = this.loadBarChart(this.timeoutRateNode, this[this.category+"Data"].workTimeoutRate.slice(0,this.maxColumn),options);
  82. } else {
  83. this.timeoutBar.transition();
  84. }
  85. }.bind(this));
  86. if (this.countPage.isShow){
  87. this.countPage.showIm();
  88. }else{
  89. this.countPage.showTabIm();
  90. }
  91. }.bind(this));
  92. },
  93. loadApplicationData: function(callback){
  94. if (!this.applicationData){
  95. this.applicationData = this.app.actions.getWorkContentData(this.summary.categoryData.application || []);
  96. if (callback) callback();
  97. }else{
  98. if (callback) callback();
  99. }
  100. },
  101. loadProcessData: function(callback){
  102. if (!this.processData){
  103. this.processData = this.app.actions.getWorkContentData(this.summary.categoryData.process || []);
  104. if (callback) callback();
  105. }else{
  106. if (callback) callback();
  107. }
  108. },
  109. loadActivityData: function(callback){
  110. if (!this.activityData){
  111. this.activityData = this.app.actions.getWorkContentData(this.summary.categoryData.activity || [], function(i){return i.processName+"-"+i.name});
  112. if (callback) callback();
  113. }else{
  114. if (callback) callback();
  115. }
  116. }
  117. });