QueryStat.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. MWF.xApplication.Selector = MWF.xApplication.Selector || {};
  2. MWF.xDesktop.requireApp("Selector", "Person", null, false);
  3. MWF.xApplication.Selector.QueryStat = new Class({
  4. Extends: MWF.xApplication.Selector.Person,
  5. options: {
  6. "style": "default",
  7. "count": 0,
  8. "title": MWF.xApplication.Selector.LP.selectView,
  9. "values": [],
  10. "names": [],
  11. "expand": false
  12. },
  13. loadSelectItems: function(addToNext){
  14. this.queryAction.listApplication(function(json){
  15. if (json.data.length){
  16. json.data.each(function(data){
  17. if (data.statList && data.statList.length){
  18. var category = this._newItemCategory(data, this, this.itemAreaNode);
  19. data.statList.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.statList || [];
  34. },
  35. _newItemCategory: function(data, selector, item, level){
  36. return new MWF.xApplication.Selector.QueryStat.ItemCategory(data, selector, item, level)
  37. },
  38. _listItemByKey: function(callback, failure, key){
  39. return false;
  40. },
  41. _getItem: function(callback, failure, id, async){
  42. this.queryAction.getStat(function(json){
  43. if (callback) callback.apply(this, [json]);
  44. }.bind(this), failure, ((typeOf(id)==="string") ? id : id.id), async);
  45. },
  46. _newItemSelected: function(data, selector, item){
  47. return new MWF.xApplication.Selector.QueryStat.ItemSelected(data, selector, item)
  48. },
  49. _listItemByPinyin: function(callback, failure, key){
  50. return false;
  51. },
  52. _newItem: function(data, selector, container, level){
  53. return new MWF.xApplication.Selector.QueryStat.Item(data, selector, container, level);
  54. }
  55. });
  56. MWF.xApplication.Selector.QueryStat.Item = new Class({
  57. Extends: MWF.xApplication.Selector.Person.Item,
  58. _getShowName: function(){
  59. return this.data.name;
  60. },
  61. _setIcon: function(){
  62. this.iconNode.setStyle("background-image", "url("+"/x_component_Selector/$Selector/default/icon/view.png)");
  63. },
  64. loadSubItem: function(){
  65. return false;
  66. },
  67. checkSelectedSingle: function(){
  68. var selectedItem = this.selector.options.values.filter(function(item, index){
  69. if (typeOf(item)==="object") return (this.data.id === item.id) || (this.data.name === item.name) ;
  70. if (typeOf(item)==="string") return (this.data.id === item) || (this.data.name === item);
  71. return false;
  72. }.bind(this));
  73. if (selectedItem.length){
  74. this.selectedSingle();
  75. }
  76. },
  77. checkSelected: function(){
  78. var selectedItem = this.selector.selectedItems.filter(function(item, index){
  79. return (item.data.id === this.data.id) || (item.data.name === this.data.name);
  80. }.bind(this));
  81. if (selectedItem.length){
  82. //selectedItem[0].item = this;
  83. selectedItem[0].addItem(this);
  84. this.selectedItem = selectedItem[0];
  85. this.setSelected();
  86. }
  87. }
  88. });
  89. MWF.xApplication.Selector.QueryStat.ItemSelected = new Class({
  90. Extends: MWF.xApplication.Selector.Person.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/view.png)");
  96. },
  97. check: function(){
  98. if (this.selector.items.length){
  99. var items = this.selector.items.filter(function(item, index){
  100. return (item.data.id === this.data.id) || (item.data.name === this.data.name);
  101. }.bind(this));
  102. this.items = items;
  103. if (items.length){
  104. items.each(function(item){
  105. item.selectedItem = this;
  106. item.setSelected();
  107. }.bind(this));
  108. }
  109. }
  110. }
  111. });
  112. MWF.xApplication.Selector.QueryStat.ItemCategory = new Class({
  113. Extends: MWF.xApplication.Selector.Person.ItemCategory,
  114. _getShowName: function(){
  115. return this.data.name;
  116. },
  117. createNode: function(){
  118. this.node = new Element("div", {
  119. "styles": this.selector.css.selectorItemCategory_department
  120. }).inject(this.container);
  121. },
  122. _setIcon: function(){
  123. this.iconNode.setStyle("background-image", "url("+"/x_component_Selector/$Selector/default/icon/applicationicon.png)");
  124. },
  125. _hasChild: function(){
  126. return (this.data.statList && this.data.statList.length);
  127. },
  128. check: function(){}
  129. });