'use strict'; /** * * * @author Mai * @date * @version */ const BusinessType = [ { stageId: -100, type: 'payment_safe' }, { stageId: -200, type: 'budget' }, { stageId: -300, type: 'change' }, { stageId: -301, type: 'change_plan' }, { stageId: -302, type: 'change_project' }, { stageId: -303, type: 'change_apply' }, { stageId: -400, type: 'advance' }, { stageId: -500, type: 'material' }, ]; const getStageId = function(type) { const bType = BusinessType.find(x => { return x.type === type; }); return bType ? bType.stageId : null; }; const getBusinessType = function(stageId) { const sid = parseInt(stageId); if (sid > 0) return 'stage'; const bType = BusinessType.find(x => { return x.stageId === sid; }); return bType ? bType.type : 'other'; }; // { payment_safe: -100, budget: -200, change: -300, ... } const BusinessStageId = (function(businessType) { const result = {}; for (const bt of businessType) { result[bt.type] = bt.stageId; } return result; })(BusinessType); module.exports = { BusinessType, getStageId, getBusinessType, BusinessStageId, };