Process.js 6.2 KB

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