Przeglądaj źródła

feat(wise-cost-util): 新增根据定额生成安装增加费的方法

lishihao 3 lat temu
rodzic
commit
e88a55cc10

+ 3 - 1
wise-cost-util/package.json

@@ -25,6 +25,7 @@
     "@types/lodash": "^4.14.168",
     "@types/mocha": "^8.0.4",
     "@types/ms": "^0.7.31",
+    "@types/uuid": "8.3.0",
     "@typescript-eslint/eslint-plugin": "^4.4.1",
     "@typescript-eslint/parser": "^4.4.1",
     "chai": "^4.2.0",
@@ -50,6 +51,7 @@
   "dependencies": {
     "@sc/util": "^1.0.7",
     "lodash": "^4.17.21",
-    "evaluator.js": "^3.2.3"
+    "evaluator.js": "^3.2.3",
+    "uuid": "8.3.1"
   }
 }

+ 1 - 0
wise-cost-util/src/index.ts

@@ -5,3 +5,4 @@ export * from './cptLib';
 export * from './material';
 export * from './process';
 export * from './threeInOneProcess';
+export * from './rationInst';

+ 38 - 0
wise-cost-util/src/rationInst.ts

@@ -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 {};