Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 

129 строки
5.1 KiB

  1. const ContractCharging = {
  2. route : 'contract/charging/:groupId',
  3. templateUrl : 'js/app/views/contract/contract-charging.html',
  4. navigatioData : null,
  5. redirectUrl : 'auth/login',
  6. canAccess : function()
  7. {
  8. return this.app.user.isLoggedIn();
  9. },
  10. create : function( p )
  11. {
  12. this.container = this.app.UI.getContentContainer();
  13. const $container = $( this.container ),
  14. app = this.app,
  15. members = [],
  16. groupId = p.get( 'groupId' ),
  17. profileIdsWithActiveContract = [],
  18. self = this;
  19. function getMemberById( mId )
  20. {
  21. let m = null;
  22. for ( let mi = 0; mi < members.length; mi++ )
  23. {
  24. if ( members[ mi ].id == mId )
  25. {
  26. m = members[ mi ];
  27. break;
  28. }
  29. }
  30. return m;
  31. }
  32. this.render();
  33. app.rpc.call(
  34. 'Team',
  35. 'getDetails',
  36. {
  37. teamId : groupId,
  38. includeMembers: true
  39. },
  40. function( res )
  41. {
  42. if ( res && res.hasOwnProperty( 'data' ) && res.data.hasOwnProperty( 'members' ) )
  43. {
  44. let m;
  45. for ( let mi = 0; mi < res.data.members.length; mi++ )
  46. {
  47. m = self.createInstance( 'UserProfile', res.data.members[ mi ] );
  48. m.contextGroupId = p.get( 'groupId' );
  49. members.push( m );
  50. }
  51. app.rpc.call(
  52. 'Contract',
  53. 'getList',
  54. {
  55. teamId : groupId,
  56. state : 'active'
  57. },
  58. function( res ) {
  59. if (res && res.hasOwnProperty('data') && res.data.hasOwnProperty('contractData')) {
  60. const cs = res.data.contractData;
  61. for (let ci = 0; ci < cs.length; ci++) {
  62. profileIdsWithActiveContract[cs[ci]['profile_id']] = 1;
  63. }
  64. }
  65. app.rpc.call(
  66. 'Contract',
  67. 'getUnchargedProfileIds',
  68. {
  69. teamId: groupId
  70. },
  71. function (res) {
  72. let unchargedItems = [],
  73. memberIdsInList = [];
  74. if (res && res.hasOwnProperty('data') && res.data.hasOwnProperty('unchargedProfileIds')) {
  75. const up = res.data.unchargedProfileIds;
  76. for (let upi = 0; upi < up.length; upi++) {
  77. memberIdsInList.push(+up[upi].profile_id);
  78. unchargedItems.push({
  79. member: getMemberById(up[upi].profile_id),
  80. count: up[upi].cnt,
  81. hasActiveContract: profileIdsWithActiveContract.hasOwnProperty(up[upi].profile_id)
  82. });
  83. }
  84. }
  85. for (let mi = 0; mi < members.length; mi++) {
  86. if (-1 === memberIdsInList.indexOf(+members[mi].id)) {
  87. unchargedItems.push({
  88. member: members[mi],
  89. count: 0,
  90. hasActiveContract: -1 !== profileIdsWithActiveContract.indexOf(+members[mi].id)
  91. });
  92. }
  93. }
  94. let st = self.createComponent(
  95. 'contract-uncharged-member-data-table',
  96. $container.find('[f-id="container-contract-uncharged-member-table"]').first().get(0),
  97. {
  98. unchargedItems: unchargedItems,
  99. groupId: groupId
  100. }
  101. );
  102. $container.find('.sk-loading').toggleClass('sk-loading');
  103. }.bind(this)
  104. );
  105. }
  106. );
  107. }
  108. }
  109. );
  110. },
  111. destroy : function()
  112. {
  113. }
  114. };
  115. export { ContractCharging };