|
|
@@ -0,0 +1,38 @@
|
|
|
+import { ICptRation, IInstallationFee, IRationInstall, IStdRation, IRation } from '@sc/types';
|
|
|
+import { find } from 'lodash';
|
|
|
+import { v1 } from 'uuid';
|
|
|
+
|
|
|
+export const getRationInstallFee = (
|
|
|
+ libRation: IStdRation | ICptRation | IRation,
|
|
|
+ installFee: IInstallationFee
|
|
|
+): IRationInstall[] => {
|
|
|
+ const rationInstalls: IRationInstall[] = [];
|
|
|
+ if (libRation.rationInstList && installFee) {
|
|
|
+ for (const ri of libRation.rationInstList) {
|
|
|
+ const feeItem = find(installFee.installFeeItems, { ID: ri.feeItemId });
|
|
|
+ const section = find(installFee.installSections, { ID: ri.sectionId });
|
|
|
+ if (feeItem && section) {
|
|
|
+ const newRationInstall: IRationInstall = {
|
|
|
+ ID: v1(),
|
|
|
+ feeItemID: feeItem.ID,
|
|
|
+ sectionID: section.ID,
|
|
|
+ itemName: feeItem.feeItem,
|
|
|
+ sectionName: section.name,
|
|
|
+ feeRuleID: '',
|
|
|
+ unifiedSetting: true,
|
|
|
+ };
|
|
|
+
|
|
|
+ if (feeItem.isCalc && section.feeRuleID && section.feeRuleID !== '') {
|
|
|
+ // 勾选记取时并且有规则ID时才读取
|
|
|
+ const feeRule = find(installFee.feeRules, { ID: section.feeRuleID });
|
|
|
+ if (feeRule) {
|
|
|
+ newRationInstall.feeRuleID = feeRule.ID;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ rationInstalls.push(newRationInstall);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return rationInstalls;
|
|
|
+};
|
|
|
+export default {};
|