Company.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. MWF.xApplication.Selector = MWF.xApplication.Selector || {};
  2. MWF.xDesktop.requireApp("Selector", "Actions.RestActions", null, false);
  3. MWF.xDesktop.requireApp("Selector", "Department", null, false);
  4. MWF.xApplication.Selector.Company = new Class({
  5. Extends: MWF.xApplication.Selector.Department,
  6. options: {
  7. "style": "default",
  8. "count": 0,
  9. "title": "Select Department",
  10. "companys": [],
  11. "departments": [],
  12. "values": [],
  13. "names": [],
  14. "expand": false
  15. },
  16. initialize: function(container, options){
  17. this.setOptions(options);
  18. this.options.groups = [];
  19. this.options.roles = [];
  20. this.path = "/x_component_Selector/$Selector/";
  21. this.cssPath = "/x_component_Selector/$Selector/"+this.options.style+"/css.wcss";
  22. this._loadCss();
  23. this.container = $(container);
  24. this.action = new MWF.xApplication.Selector.Actions.RestActions();
  25. this.lastPeople = "";
  26. this.pageCount = "13";
  27. this.selectedItems = [];
  28. this.items = [];
  29. },
  30. loadSelectItems: function(addToNext){
  31. this.action.listTopCompany(function(json){
  32. json.data.each(function(data){
  33. var category = this._newItem(data, this, this.itemAreaNode);
  34. }.bind(this));
  35. }.bind(this));
  36. },
  37. _scrollEvent: function(y){
  38. return true;
  39. },
  40. _getChildrenItemIds: function(){
  41. return null;
  42. },
  43. _newItemCategory: function(type, data, selector, item, level){
  44. return new MWF.xApplication.Selector.Department[type](data, selector, item, level)
  45. },
  46. _listItemByKey: function(callback, failure, key){
  47. this.action.listIdentityByKey(function(json){
  48. if (callback) callback.apply(this, [json]);
  49. }.bind(this), failure, key);
  50. },
  51. _getItem: function(callback, failure, id, async){
  52. this.action.getCompany(function(json){
  53. if (callback) callback.apply(this, [json]);
  54. }.bind(this), failure, id, async);
  55. },
  56. _newItemSelected: function(data, selector, item){
  57. return new MWF.xApplication.Selector.Company.ItemSelected(data, selector, item)
  58. },
  59. _listItemByPinyin: function(callback, failure, key){
  60. this.action.listIdentityByPinyin(function(json){
  61. if (callback) callback.apply(this, [json]);
  62. }.bind(this), failure, key);
  63. },
  64. _newItem: function(data, selector, container, level){
  65. return new MWF.xApplication.Selector.Company.Item(data, selector, container, level);
  66. }
  67. });
  68. MWF.xApplication.Selector.Company.Item = new Class({
  69. Extends: MWF.xApplication.Selector.Department.Item,
  70. _getShowName: function(){
  71. return this.data.name;
  72. },
  73. _setIcon: function(){
  74. this.iconNode.setStyle("background-image", "url("+"/x_component_Selector/$Selector/default/icon/companyicon.png)");
  75. },
  76. loadSubItem: function(){
  77. this.children = new Element("div", {
  78. "styles": this.selector.css.selectorItemCategoryChildrenNode,
  79. }).inject(this.node, "after");
  80. this.children.setStyle("display", "block");
  81. // if (!this.selector.options.expand) this.children.setStyle("display", "none");
  82. this.selector.action.listSubCompany(function(subJson){
  83. subJson.data.each(function(subData){
  84. var category = this.selector._newItem(subData, this.selector, this.children, this.level+1);
  85. }.bind(this));
  86. }.bind(this), null, this.data.name);
  87. },
  88. });
  89. MWF.xApplication.Selector.Company.ItemSelected = new Class({
  90. Extends: MWF.xApplication.Selector.Department.ItemSelected,
  91. _getShowName: function(){
  92. return this.data.name;
  93. },
  94. _setIcon: function(){
  95. this.iconNode.setStyle("background-image", "url("+"/x_component_Selector/$Selector/default/icon/companyicon.png)");
  96. }
  97. });