Process.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. if( !id )return;
  43. this.processAction.getProcess(function(json){
  44. if (callback) callback.apply(this, [json]);
  45. }.bind(this), failure, ((typeOf(id)==="string") ? id : (typeOf(id)=="string") ? id : id.id), async);
  46. },
  47. _newItemSelected: function(data, selector, item){
  48. return new MWF.xApplication.Selector.Process.ItemSelected(data, selector, item)
  49. },
  50. _listItemByPinyin: function(callback, failure, key){
  51. return false;
  52. },
  53. _newItem: function(data, selector, container, level){
  54. return new MWF.xApplication.Selector.Process.Item(data, selector, container, level);
  55. }
  56. });
  57. MWF.xApplication.Selector.Process.Item = new Class({
  58. Extends: MWF.xApplication.Selector.Person.Item,
  59. _getShowName: function(){
  60. return this.data.name;
  61. },
  62. _setIcon: function(){
  63. this.iconNode.setStyle("background-image", "url("+"/x_component_Selector/$Selector/default/icon/processicon.png)");
  64. },
  65. _getTtiteText: function(){
  66. return this.data.name;
  67. },
  68. loadSubItem: function(){
  69. return false;
  70. },
  71. checkSelectedSingle: function(){
  72. var selectedItem = this.selector.options.values.filter(function(item, index){
  73. if (typeOf(item)==="object") return (this.data.id === item.id) || (this.data.name === item.name) ;
  74. if (typeOf(item)==="string") return (this.data.id === item) || (this.data.name === item);
  75. return false;
  76. }.bind(this));
  77. if (selectedItem.length){
  78. this.selectedSingle();
  79. }
  80. },
  81. checkSelected: function(){
  82. var selectedItem = this.selector.selectedItems.filter(function(item, index){
  83. return (item.data.id === this.data.id) || (item.data.name === this.data.name);
  84. }.bind(this));
  85. if (selectedItem.length){
  86. //selectedItem[0].item = this;
  87. selectedItem[0].addItem(this);
  88. this.selectedItem = selectedItem[0];
  89. this.setSelected();
  90. }
  91. }
  92. });
  93. MWF.xApplication.Selector.Process.ItemSelected = new Class({
  94. Extends: MWF.xApplication.Selector.Person.ItemSelected,
  95. _getShowName: function(){
  96. return this.data.name;
  97. },
  98. _setIcon: function(){
  99. this.iconNode.setStyle("background-image", "url("+"/x_component_Selector/$Selector/default/icon/processicon.png)");
  100. },
  101. check: function(){
  102. if (this.selector.items.length){
  103. var items = this.selector.items.filter(function(item, index){
  104. return (item.data.id === this.data.id) || (item.data.name === this.data.name);
  105. }.bind(this));
  106. this.items = items;
  107. if (items.length){
  108. items.each(function(item){
  109. item.selectedItem = this;
  110. item.setSelected();
  111. }.bind(this));
  112. }
  113. }
  114. }
  115. });
  116. MWF.xApplication.Selector.Process.ItemCategory = new Class({
  117. Extends: MWF.xApplication.Selector.Person.ItemCategory,
  118. _getShowName: function(){
  119. return this.data.name;
  120. },
  121. createNode: function(){
  122. this.node = new Element("div", {
  123. "styles": this.selector.css.selectorItemCategory_department
  124. }).inject(this.container);
  125. },
  126. _setIcon: function(){
  127. this.iconNode.setStyle("background-image", "url("+"/x_component_Selector/$Selector/default/icon/applicationicon.png)");
  128. },
  129. loadSub: function(callback){
  130. if (!this.loaded){
  131. this.selector.action.listProcess(function(subJson){
  132. subJson.data.each(function(subData){
  133. subData.applicationName = this.data.name;
  134. subData.application = this.data.id;
  135. var category = this.selector._newItem(subData, this.selector, this.children, this.level+1);
  136. }.bind(this));
  137. this.loaded = true;
  138. if (callback) callback();
  139. }.bind(this), null, this.data.id);
  140. }else{
  141. if (callback) callback();
  142. }
  143. },
  144. _hasChild: function(){
  145. return (this.data.processList && this.data.processList.length);
  146. },
  147. check: function(){}
  148. });