PlatApp.js 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. MWF.xApplication.Selector = MWF.xApplication.Selector || {};
  2. MWF.xDesktop.requireApp("Selector", "Person", null, false);
  3. MWF.xApplication.Selector.PlatApp = 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 = "platApp";
  16. this.className = "platApp";
  17. },
  18. loadSelectItems: function(addToNext){
  19. var categorys = [
  20. {"name": MWF.SelectorLP.processPlatform, "id": "processPlatform"},
  21. {"name": MWF.SelectorLP.cms, "id": "cms"},
  22. {"name": MWF.SelectorLP.portal, "id": "portal"},
  23. {"name": MWF.SelectorLP.query, "id": "query"},
  24. {"name": MWF.SelectorLP.service, "id": "service"}
  25. ]
  26. //window.setTimeout(function(){
  27. categorys.each(function(data){
  28. switch (data.id){
  29. case "processPlatform":
  30. this.processAction.listApplication(function(json){ data.appList = json.data; }.bind(this), null, false);
  31. break;
  32. case "cms":
  33. this.cmsAction.listColumn(function(json){ data.appList = json.data; }.bind(this), null, false);
  34. break;
  35. case "portal":
  36. this.portalDesignerAction.listApplication(function(json){ data.appList = json.data; }.bind(this), null, false);
  37. break;
  38. case "query":
  39. this.queryAction.listApplication(function(json){ data.appList = json.data; }.bind(this), null, false);
  40. break;
  41. case "service":
  42. data.appList = [
  43. { "id": "invoke", "name": "服务" },
  44. { "id": "agent", "name": "代理" }
  45. ];
  46. break;
  47. default:
  48. this.processAction.listApplication(function(json){ data.appList = json.data; }.bind(this), null, false);
  49. };
  50. var category = this._newItemCategory(data, this, this.itemAreaNode);
  51. if (data.appList && data.appList.length){
  52. data.appList.each(function(d){
  53. debugger;
  54. d.moduleType = data.id;
  55. if (d.moduleType=="cms") d.name = d.appName;
  56. var item = this._newItem(d, this, category.children);
  57. this.items.push(item);
  58. }.bind(this));
  59. }
  60. }.bind(this));
  61. //}.bind(this), 1);
  62. },
  63. _scrollEvent: function(y){
  64. return true;
  65. },
  66. _getChildrenItemIds: function(data){
  67. debugger;
  68. return data.appList || [];
  69. },
  70. _newItemCategory: function(data, selector, item, level){
  71. return new MWF.xApplication.Selector.PlatApp.ItemCategory(data, selector, item, level)
  72. },
  73. _listItemByKey: function(callback, failure, key){
  74. return false;
  75. },
  76. _getItem: function(callback, failure, id, async){
  77. if( !id )return;
  78. this.processAction.getProcess(function(json){
  79. if (callback) callback.apply(this, [json]);
  80. }.bind(this), failure, ((typeOf(id)==="string") ? id : (typeOf(id)=="string") ? id : id.id), async);
  81. },
  82. _newItemSelected: function(data, selector, item){
  83. return new MWF.xApplication.Selector.PlatApp.ItemSelected(data, selector, item)
  84. },
  85. _listItemByPinyin: function(callback, failure, key){
  86. return false;
  87. },
  88. _newItem: function(data, selector, container, level){
  89. return new MWF.xApplication.Selector.PlatApp.Item(data, selector, container, level);
  90. }
  91. });
  92. MWF.xApplication.Selector.PlatApp.Item = new Class({
  93. Extends: MWF.xApplication.Selector.Person.Item,
  94. _getShowName: function(){
  95. switch (this.data.moduleType){
  96. case "processPlatform":
  97. return this.data.name;
  98. case "cms":
  99. return this.data.appName;
  100. case "portal":
  101. return this.data.name;
  102. case "query":
  103. return this.data.name;
  104. case "service":
  105. return this.data.name;
  106. default:
  107. return this.data.name;
  108. };
  109. },
  110. _setIcon: function(){
  111. this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/default/icon/processicon.png)");
  112. },
  113. _getTtiteText: function(){
  114. return this.data.name;
  115. },
  116. loadSubItem: function(){
  117. return false;
  118. },
  119. checkSelectedSingle: function(){
  120. var selectedItem = this.selector.options.values.filter(function(item, index){
  121. if (typeOf(item)==="object"){
  122. // return (this.data.id === item.id);
  123. if( this.data.id && item.id ){
  124. return this.data.id === item.id;
  125. }else{
  126. return this.data.name === item.name;
  127. }
  128. }
  129. if (typeOf(item)==="string") return (this.data.id === item) || (this.data.name === item);
  130. return false;
  131. }.bind(this));
  132. if (selectedItem.length){
  133. this.selectedSingle();
  134. }
  135. },
  136. checkSelected: function(){
  137. var selectedItem = this.selector.selectedItems.filter(function(item, index){
  138. if( item.data.id && this.data.id){
  139. return item.data.id === this.data.id;
  140. }else{
  141. return item.data.name === this.data.name;
  142. }
  143. }.bind(this));
  144. if (selectedItem.length){
  145. //selectedItem[0].item = this;
  146. selectedItem[0].addItem(this);
  147. this.selectedItem = selectedItem[0];
  148. this.setSelected();
  149. }
  150. }
  151. });
  152. MWF.xApplication.Selector.PlatApp.ItemSelected = new Class({
  153. Extends: MWF.xApplication.Selector.Person.ItemSelected,
  154. _getShowName: function(){
  155. switch (this.data.moduleType){
  156. case "processPlatform":
  157. return this.data.name;
  158. case "cms":
  159. return this.data.appName;
  160. case "portal":
  161. return this.data.name;
  162. case "query":
  163. return this.data.name;
  164. case "service":
  165. return this.data.name;
  166. default:
  167. return this.data.name;
  168. };
  169. },
  170. _setIcon: function(){
  171. this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/default/icon/processicon.png)");
  172. },
  173. check: function(){
  174. if (this.selector.items.length){
  175. var items = this.selector.items.filter(function(item, index){
  176. debugger;
  177. if( item.data.id && this.data.id){
  178. return item.data.id === this.data.id;
  179. }else{
  180. return item.data.name === this.data.name;
  181. }
  182. }.bind(this));
  183. this.items = items;
  184. if (items.length){
  185. items.each(function(item){
  186. item.selectedItem = this;
  187. item.setSelected();
  188. }.bind(this));
  189. }
  190. }
  191. }
  192. });
  193. MWF.xApplication.Selector.PlatApp.ItemCategory = new Class({
  194. Extends: MWF.xApplication.Selector.Person.ItemCategory,
  195. _getShowName: function(){
  196. return this.data.name;
  197. },
  198. createNode: function(){
  199. this.node = new Element("div", {
  200. "styles": this.selector.css.selectorItemCategory_department
  201. }).inject(this.container);
  202. },
  203. _setIcon: function(){
  204. this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/default/icon/applicationicon.png)");
  205. },
  206. loadSub: function(callback){
  207. if (!this.loaded){
  208. if (this.data.id=="processPlatform"){
  209. this.selector.processAction.listApplication(function(subJson){
  210. subJson.data.each(function(subData){
  211. var category = this.selector._newItem(subData, this.selector, this.children, this.level+1);
  212. this.selector.items.push( category );
  213. }.bind(this));
  214. this.loaded = true;
  215. if (callback) callback();
  216. }.bind(this));
  217. }else{
  218. this.loaded = true;
  219. if (callback) callback();
  220. }
  221. // this.selector.action.listProcess(function(subJson){
  222. // subJson.data.each(function(subData){
  223. // subData.applicationName = this.data.name;
  224. // subData.application = this.data.id;
  225. // var category = this.selector._newItem(subData, this.selector, this.children, this.level+1);
  226. // this.selector.items.push( category );
  227. // }.bind(this));
  228. //
  229. // this.loaded = true;
  230. // if (callback) callback();
  231. // }.bind(this), null, this.data.id);
  232. }else{
  233. if (callback) callback();
  234. }
  235. },
  236. _hasChild: function(){
  237. return true;
  238. },
  239. check: function(){}
  240. });