Process.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. MWF.xApplication.Selector = MWF.xApplication.Selector || {};
  2. MWF.xDesktop.requireApp("Selector", "Person", null, false);
  3. MWF.xApplication.Selector.Process = new Class({
  4. Extends: MWF.xApplication.Selector.Person,
  5. options: {
  6. "style": "default",
  7. "count": 0,
  8. "title": MWF.xApplication.Selector.LP.selectProcess,
  9. "values": [],
  10. "names": [],
  11. "expand": false
  12. },
  13. loadSelectItems: function(addToNext){
  14. this.processAction.listApplicationStartable(function(json){
  15. if (json.data.length){
  16. json.data.each(function(data){
  17. if (data.processList && data.processList.length){
  18. var category = this._newItemCategory(data, this, this.itemAreaNode);
  19. data.processList.each(function(d){
  20. d.applicationName = data.name;
  21. var item = this._newItem(d, this, category.children);
  22. this.items.push(item);
  23. }.bind(this));
  24. }
  25. }.bind(this));
  26. }
  27. }.bind(this));
  28. },
  29. _scrollEvent: function(y){
  30. return true;
  31. },
  32. _getChildrenItemIds: function(data){
  33. return data.processList || [];
  34. },
  35. _newItemCategory: function(data, selector, item, level){
  36. return new MWF.xApplication.Selector.Process.ItemCategory(data, selector, item, level)
  37. },
  38. _listItemByKey: function(callback, failure, key){
  39. return false;
  40. },
  41. _getItem: function(callback, failure, id, async){
  42. this.processAction.getProcess(function(json){
  43. if (callback) callback.apply(this, [json]);
  44. }.bind(this), failure, ((typeOf(id)==="string") ? id : (typeOf(id)=="string") ? id : id.id), async);
  45. },
  46. _newItemSelected: function(data, selector, item){
  47. return new MWF.xApplication.Selector.Process.ItemSelected(data, selector, item)
  48. },
  49. _listItemByPinyin: function(callback, failure, key){
  50. return false;
  51. },
  52. _newItem: function(data, selector, container, level){
  53. return new MWF.xApplication.Selector.Process.Item(data, selector, container, level);
  54. }
  55. });
  56. MWF.xApplication.Selector.Process.Item = new Class({
  57. Extends: MWF.xApplication.Selector.Person.Item,
  58. _getShowName: function(){
  59. return this.data.name;
  60. },
  61. _setIcon: function(){
  62. this.iconNode.setStyle("background-image", "url("+"/x_component_Selector/$Selector/default/icon/processicon.png)");
  63. },
  64. _getTtiteText: function(){
  65. return this.data.name;
  66. },
  67. loadSubItem: function(){
  68. return false;
  69. },
  70. checkSelectedSingle: function(){
  71. var selectedItem = this.selector.options.values.filter(function(item, index){
  72. if (typeOf(item)==="object") return (this.data.id === item.id) || (this.data.name === item.name) ;
  73. if (typeOf(item)==="string") return (this.data.id === item) || (this.data.name === item);
  74. return false;
  75. }.bind(this));
  76. if (selectedItem.length){
  77. this.selectedSingle();
  78. }
  79. },
  80. checkSelected: function(){
  81. var selectedItem = this.selector.selectedItems.filter(function(item, index){
  82. return (item.data.id === this.data.id) || (item.data.name === this.data.name);
  83. }.bind(this));
  84. if (selectedItem.length){
  85. //selectedItem[0].item = this;
  86. selectedItem[0].addItem(this);
  87. this.selectedItem = selectedItem[0];
  88. this.setSelected();
  89. }
  90. }
  91. });
  92. MWF.xApplication.Selector.Process.ItemSelected = new Class({
  93. Extends: MWF.xApplication.Selector.Person.ItemSelected,
  94. _getShowName: function(){
  95. return this.data.name;
  96. },
  97. _setIcon: function(){
  98. this.iconNode.setStyle("background-image", "url("+"/x_component_Selector/$Selector/default/icon/processicon.png)");
  99. },
  100. check: function(){
  101. if (this.selector.items.length){
  102. var items = this.selector.items.filter(function(item, index){
  103. return (item.data.id === this.data.id) || (item.data.name === this.data.name);
  104. }.bind(this));
  105. this.items = items;
  106. if (items.length){
  107. items.each(function(item){
  108. item.selectedItem = this;
  109. item.setSelected();
  110. }.bind(this));
  111. }
  112. }
  113. }
  114. });
  115. MWF.xApplication.Selector.Process.ItemCategory = new Class({
  116. Extends: MWF.xApplication.Selector.Person.ItemCategory,
  117. _getShowName: function(){
  118. return this.data.name;
  119. },
  120. createNode: function(){
  121. this.node = new Element("div", {
  122. "styles": this.selector.css.selectorItemCategory_department
  123. }).inject(this.container);
  124. },
  125. _setIcon: function(){
  126. this.iconNode.setStyle("background-image", "url("+"/x_component_Selector/$Selector/default/icon/applicationicon.png)");
  127. },
  128. loadSub: function(callback){
  129. if (!this.loaded){
  130. this.selector.action.listProcess(function(subJson){
  131. subJson.data.each(function(subData){
  132. subData.applicationName = this.data.name;
  133. subData.application = this.data.id;
  134. var category = this.selector._newItem(subData, this.selector, this.children, this.level+1);
  135. }.bind(this));
  136. this.loaded = true;
  137. if (callback) callback();
  138. }.bind(this), null, this.data.id);
  139. }else{
  140. if (callback) callback();
  141. }
  142. },
  143. _hasChild: function(){
  144. return (this.data.processList && this.data.processList.length);
  145. },
  146. check: function(){}
  147. });