Process.js 6.4 KB

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