PlatApp.js 9.4 KB

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