rationInst.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { ICptRation, IInstallationFee, IRationInstall, IStdRation, IRation } from '@sc/types';
  2. import { find } from 'lodash';
  3. import { v1 } from 'uuid';
  4. export const getRationInstallFee = (
  5. libRation: IStdRation | ICptRation | IRation,
  6. installFee: IInstallationFee
  7. ): IRationInstall[] => {
  8. const rationInstalls: IRationInstall[] = [];
  9. if (libRation.rationInstList && installFee) {
  10. for (const ri of libRation.rationInstList) {
  11. const feeItem = find(installFee.installFeeItems, { ID: ri.feeItemId });
  12. const section = find(installFee.installSections, { ID: ri.sectionId });
  13. if (feeItem && section) {
  14. const newRationInstall: IRationInstall = {
  15. ID: v1(),
  16. feeItemID: feeItem.ID,
  17. sectionID: section.ID,
  18. itemName: feeItem.feeItem,
  19. sectionName: section.name,
  20. feeRuleID: '',
  21. unifiedSetting: true,
  22. };
  23. if (feeItem.isCalc && section.feeRuleID && section.feeRuleID !== '') {
  24. // 勾选记取时并且有规则ID时才读取
  25. const feeRule = find(installFee.feeRules, { ID: section.feeRuleID });
  26. if (feeRule) {
  27. newRationInstall.feeRuleID = feeRule.ID;
  28. }
  29. }
  30. rationInstalls.push(newRationInstall);
  31. }
  32. }
  33. }
  34. return rationInstalls;
  35. };
  36. export default {};