rpt_archive.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. ];
  19. const getStageId = function(type) {
  20. const bType = BusinessType.find(x => { return x.type === type; });
  21. return bType ? bType.stageId : null;
  22. };
  23. const getBusinessType = function(stageId) {
  24. const sid = parseInt(stageId);
  25. if (sid > 0) return 'stage';
  26. const bType = BusinessType.find(x => { return x.stageId === sid; });
  27. return bType ? bType.type : 'other';
  28. };
  29. // { payment_safe: -100, budget: -200, change: -300, ... }
  30. const BusinessStageId = (function(businessType) {
  31. const result = {};
  32. for (const bt of businessType) {
  33. result[bt.type] = bt.stageId;
  34. }
  35. return result;
  36. })(BusinessType);
  37. module.exports = {
  38. BusinessType,
  39. getStageId,
  40. getBusinessType,
  41. BusinessStageId,
  42. };