|
|
@@ -124,6 +124,9 @@ INTERFACE_IMPORT = (() => {
|
|
|
}
|
|
|
tender.bills.push(bill);
|
|
|
}
|
|
|
+ // 山东的 formula 还得调整
|
|
|
+ // setupFormula(tender.bills);
|
|
|
+
|
|
|
const BidEvaluationMainMaterial = arrayValue(EprjInfo, ['BidEvaluationMainMaterial']);
|
|
|
for (let b of BidEvaluationMainMaterial) {
|
|
|
tender.bidEvaluationList.push(setUpBidEvaluation(b))
|
|
|
@@ -131,8 +134,7 @@ INTERFACE_IMPORT = (() => {
|
|
|
|
|
|
return tender;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
function setupBills(item) {
|
|
|
let bill = {
|
|
|
code: item._ListCode,
|
|
|
@@ -142,8 +144,16 @@ INTERFACE_IMPORT = (() => {
|
|
|
remark: item._Remarks,
|
|
|
jobContentText: item._Content,
|
|
|
specialProvisional: '',
|
|
|
+ formulaCode: item._FormulaCode,
|
|
|
+ qtyFormula: item._QtyFormula,
|
|
|
children: []
|
|
|
}
|
|
|
+ if (bill.qtyFormula && bill.qtyFormula !== '') {
|
|
|
+ let formula = getValue(item, ['CostComposition', 'Formula', '_Formulas']);
|
|
|
+ if (formula !== undefined && formula !== null && formula !== '') {
|
|
|
+ bill.calcBase = formula; // 这个formula在后期还要处理的
|
|
|
+ }
|
|
|
+ }
|
|
|
if (item._ProvisionalType == '0') bill.specialProvisional = '材料暂估';
|
|
|
if (item._ProvisionalType == '1') bill.specialProvisional = '工程设备';
|
|
|
if (item._ProvisionalType == '2') bill.specialProvisional = '专业工程';
|
|
|
@@ -192,9 +202,60 @@ INTERFACE_IMPORT = (() => {
|
|
|
};
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ async function handleAfterImport(importData) {
|
|
|
+ function setupFormula(bills) {
|
|
|
+ const cacheObj = {};
|
|
|
+ const calcBills = [];
|
|
|
+ function _transform(calc) {
|
|
|
+ let rst = calc, tmpCalc = calc;
|
|
|
+ let calcKeys = [], calcValues = [];
|
|
|
+ let preIdx = tmpCalc.indexOf('{');
|
|
|
+ while (preIdx >= 0) {
|
|
|
+ let rearIdx = tmpCalc.indexOf('}');
|
|
|
+ if (rearIdx > preIdx) {
|
|
|
+ let fnStr = tmpCalc.substring(preIdx + 1, rearIdx);
|
|
|
+ if (cacheObj[fnStr]) {
|
|
|
+ calcKeys.push(`{${fnStr}}`);
|
|
|
+ calcValues.push(`@${cacheObj[fnStr].ID}`);
|
|
|
+ }
|
|
|
+ tmpCalc = tmpCalc.substr(rearIdx + 1);
|
|
|
+ preIdx = tmpCalc.indexOf('{');
|
|
|
+ } else {
|
|
|
+ //有异常了
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (calcKeys.length > 0) {
|
|
|
+ calcKeys.forEach((key, index)=> {
|
|
|
+ rst = rst.replace(key, calcValues[index]);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return rst;
|
|
|
+ }
|
|
|
+ //1. 先把有formulaCode的清单cache起来
|
|
|
+ //2. 顺带过滤出有calcBase的清单
|
|
|
+ for (let bill of bills) {
|
|
|
+ if (typeof bill.formulaCode === 'string' && bill.formulaCode.indexOf('F') === 0) {
|
|
|
+ cacheObj[bill.formulaCode] = bill;
|
|
|
+ }
|
|
|
+ if (typeof bill.calcBase === 'string' && bill.calcBase.length > 0) {
|
|
|
+ calcBills.push(bill);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //3. Action!
|
|
|
+ for (let calcBill of calcBills) {
|
|
|
+ calcBill.calcBase = _transform(calcBill.calcBase);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ importData.tenders.forEach((tender, index) => {
|
|
|
+ setupFormula(tender.bills);
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
return {
|
|
|
- entry
|
|
|
+ entry,
|
|
|
+ handleAfterImport,
|
|
|
};
|
|
|
|
|
|
})();
|