rpt_archive.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Mai
  6. * @date
  7. * @version
  8. */
  9. const BusinessType = [
  10. { stageId: -100, type: 'payment_safe' },
  11. { stageId: -200, type: 'budget' },
  12. { stageId: -300, type: 'change' },
  13. { stageId: -301, type: 'change_plan' },
  14. { stageId: -302, type: 'change_project' },
  15. { stageId: -303, type: 'change_apply' },
  16. { stageId: -400, type: 'advance' },
  17. { stageId: -500, type: 'material' },
  18. { stageId: -600, type: 'contract' },
  19. { stageId: -700, type: 'phase_pay' },
  20. ];
  21. const getStageId = function(type) {
  22. const bType = BusinessType.find(x => { return x.type === type; });
  23. return bType ? bType.stageId : null;
  24. };
  25. const getBusinessType = function(stageId) {
  26. const sid = parseInt(stageId);
  27. if (sid > 0) return 'stage';
  28. const bType = BusinessType.find(x => { return x.stageId === sid; });
  29. return bType ? bType.type : 'other';
  30. };
  31. // { payment_safe: -100, budget: -200, change: -300, ... }
  32. const BusinessStageId = (function(businessType) {
  33. const result = {};
  34. for (const bt of businessType) {
  35. result[bt.type] = bt.stageId;
  36. }
  37. return result;
  38. })(BusinessType);
  39. module.exports = {
  40. BusinessType,
  41. getStageId,
  42. getBusinessType,
  43. BusinessStageId,
  44. };