Process.js 6.4 KB

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