Duty.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. MWF.xApplication.Selector = MWF.xApplication.Selector || {};
  2. MWF.xDesktop.requireApp("Selector", "Person", null, false);
  3. MWF.xApplication.Selector.Duty = new Class({
  4. Extends: MWF.xApplication.Selector.Person,
  5. options: {
  6. "style": "default",
  7. "count": 0,
  8. "title": MWF.xApplication.Selector.LP.selectDuty,
  9. "values": [],
  10. "expand": false
  11. },
  12. loadSelectItems: function(addToNext){
  13. this.orgAction.listUnitdutyName(function(json){
  14. json.data.nameList.each(function(data){
  15. var category = this._newItem(data, this, this.itemAreaNode);
  16. }.bind(this));
  17. }.bind(this));
  18. },
  19. _scrollEvent: function(y){
  20. return true;
  21. },
  22. _getChildrenItemIds: function(){
  23. return null;
  24. },
  25. _newItemCategory: function(type, data, selector, item, level){
  26. return new MWF.xApplication.Selector.Duty[type](data, selector, item, level)
  27. },
  28. _listItemByKey: function(callback, failure, key){
  29. this.orgAction.listUnitdutyNameByKey(function(json){
  30. if (callback) callback.apply(this, [{"data": json.data.nameList}]);
  31. }.bind(this), failure, key);
  32. },
  33. _getItem: function(callback, failure, id, async){
  34. if (callback) callback.apply(this, [{"data": {"name": id, "id":id}}]);
  35. },
  36. _newItemSelected: function(data, selector, item){
  37. return new MWF.xApplication.Selector.Duty.ItemSelected(data, selector, item)
  38. },
  39. _listItemByPinyin: function(callback, failure, key){
  40. this.orgAction.listUnitdutyNameByKey(function(json){
  41. if (callback) callback.apply(this, [{"data": json.data.nameList}]);
  42. }.bind(this), failure, key);
  43. },
  44. _newItem: function(data, selector, container, level){
  45. return new MWF.xApplication.Selector.Duty.Item({"name":data, "id":data}, selector, container, level);
  46. }
  47. });
  48. MWF.xApplication.Selector.Duty.Item = new Class({
  49. Extends: MWF.xApplication.Selector.Person.Item,
  50. _getShowName: function(){
  51. return this.data.name;
  52. },
  53. _getTtiteText: function(){
  54. return this.data.name;
  55. },
  56. _setIcon: function() {
  57. this.iconNode.setStyle("background-image", "url(" + "/x_component_Selector/$Selector/default/icon/duty.png)");
  58. },
  59. checkSelectedSingle: function(){
  60. var selectedItem = this.selector.options.values.filter(function(item, index){
  61. if (typeOf(item)==="object") return (this.data.id === item.id) || (this.data.name === item.name) ;
  62. if (typeOf(item)==="string") return (this.data.id === item) || (this.data.name === item);
  63. return false;
  64. }.bind(this));
  65. if (selectedItem.length){
  66. this.selectedSingle();
  67. }
  68. },
  69. checkSelected: function(){
  70. var selectedItem = this.selector.selectedItems.filter(function(item, index){
  71. return (item.data.id === this.data.id) || (item.data.name === this.data.name);
  72. }.bind(this));
  73. if (selectedItem.length){
  74. //selectedItem[0].item = this;
  75. selectedItem[0].addItem(this);
  76. this.selectedItem = selectedItem[0];
  77. this.setSelected();
  78. }
  79. }
  80. });
  81. MWF.xApplication.Selector.Duty.ItemSelected = new Class({
  82. Extends: MWF.xApplication.Selector.Person.ItemSelected,
  83. _getShowName: function(){
  84. return this.data.name;
  85. },
  86. _setIcon: function(){
  87. this.iconNode.setStyle("background-image", "url("+"/x_component_Selector/$Selector/default/icon/duty.png)");
  88. }
  89. });