Просмотр исходного кода

feat: 导入工程量清单,导入单价和合价

vian 4 лет назад
Родитель
Сommit
2f7bef95d4

+ 36 - 6
web/building_saas/main/js/views/importBills.js

@@ -42,9 +42,9 @@ const importBills = (function () {
     //获取列字段对应
     function getColMapping(type) {
         if (type === 0) {   //工程量清单
-            return { code: 0, name: 1, unit: 2, quantity: 4 };
+            return { code: 0, name: 1, unit: 2, quantity: 4, unitPrice: 5  };
         } else {    //清单示例表
-            return { code: 0, name: 1, unit: 2, quantity: 3 };
+            return { code: 0, name: 1, unit: 2, quantity: 3, unitPrice: 4 };
         }
     }
     function isGCLHead(dataRow, nextDataRow) {
@@ -76,7 +76,6 @@ const importBills = (function () {
     //提取工程量清单数据
     //层级由depth确定,表格里最顶层depth为0(表头里一清单),表格内容里数据的depth为空格数+1
     function extractGCLDatas(sheetData, colMapping) {
-        //let colMapping = {code: 0, name: 1, unit: 2, quantity: 4};
         let dataTable = sheetData.data.dataTable,
             rowCount = sheetData.rowCount;
         let rst = [];
@@ -108,7 +107,8 @@ const importBills = (function () {
             let code = dataTable[row][colMapping.code] ? dataTable[row][colMapping.code].value : null,
                 name = dataTable[row][colMapping.name] ? _deNR(dataTable[row][colMapping.name].value) : null,
                 unit = dataTable[row][colMapping.unit] ? dataTable[row][colMapping.unit].value : null,
-                quantity = dataTable[row][colMapping.quantity] ? dataTable[row][colMapping.quantity].value : null;
+                quantity = dataTable[row][colMapping.quantity] ? dataTable[row][colMapping.quantity].value : null,
+                unitPrice = dataTable[row][colMapping.unitPrice] ? dataTable[row][colMapping.unitPrice].value : null;
             if (!code && !name || /合计/.test(code)) {   //过滤掉同时没有编号和名称的、过滤合计行
                 continue;
             }
@@ -132,6 +132,20 @@ const importBills = (function () {
                 depth: depth,
                 unitPriceAnalysis: 1,
             };
+            if (+unitPrice && +quantity) {
+                unitPrice = scMathUtil.roundForObj(unitPrice, decimalObj.bills.unitPrice);
+                const totalPrice = scMathUtil.roundForObj(unitPrice * +quantity, decimalObj.bills.totalPrice);
+                data.fees = [
+                    {
+                        fieldName: "common",
+                        tenderTotalFee: totalPrice,
+                        tenderUnitFee: unitPrice,
+                        totalFee: totalPrice,
+                        unitFee: unitPrice,
+                    }
+                ];
+                data.calcFlag = treeNodeCalcFlag.customUnitPrice;
+            }
             //获取data的父节点链,成为兄弟节点,只能在父链里找前兄弟(不能跨父链)
             let parents = getParents(lastData);
             let preData = findLast(parents, x => x.depth === depth);
@@ -179,7 +193,7 @@ const importBills = (function () {
     }
 
     // 示例列映射
-    const slColMap = { code: 0, name: 1, unit: 2, quantity: 3 };
+    const slColMap = { code: 0, name: 1, unit: 2, quantity: 3, unitPrice: 4 };
 
     function isValidGCLExRow(rowData) {
         if (rowData[0] && /编制[::]/.test(rowData[0].value)) {
@@ -230,6 +244,7 @@ const importBills = (function () {
                     [slColMap.name]: { value: rowData[slColMap.name] && rowData[slColMap.name].value || null },
                     [slColMap.unit]: { value: rowData[slColMap.unit] && rowData[slColMap.unit].value || null },
                     [slColMap.quantity]: { value: rowData[slColMap.quantity] && rowData[slColMap.quantity].value || null },
+                    [slColMap.unitPrice]: { value: rowData[slColMap.unitPrice] && rowData[slColMap.unitPrice].value || null },
                 };
                 rst.data.dataTable.push(cellData);
             }
@@ -248,7 +263,8 @@ const importBills = (function () {
             let code = dataTable[row][slColMap.code] && dataTable[row][slColMap.code].value ? String(dataTable[row][slColMap.code].value).trim() : null,
                 name = dataTable[row][slColMap.name] ? _deNR(dataTable[row][slColMap.name].value) : null,
                 unit = dataTable[row][slColMap.unit] ? dataTable[row][slColMap.unit].value : null,
-                quantity = dataTable[row][slColMap.quantity] ? dataTable[row][slColMap.quantity].value : null;
+                quantity = dataTable[row][slColMap.quantity] ? dataTable[row][slColMap.quantity].value : null,
+                unitPrice = dataTable[row][slColMap.unitPrice] ? dataTable[row][slColMap.unitPrice].value : null;
             if (!code) {    //没有编号的数据,名称必须为:清单 第xx章,认为新的表根节点
                 const reg = /清单\s+第[^章]+章/;
                 //if (name && /清单 第\d+章/.test(name)) {
@@ -280,6 +296,20 @@ const importBills = (function () {
                     NextSiblingID: -1,
                     unitPriceAnalysis: 1
                 };
+                if (+unitPrice && +quantity) {
+                    unitPrice = scMathUtil.roundForObj(unitPrice, decimalObj.bills.unitPrice);
+                    const totalPrice = scMathUtil.roundForObj(unitPrice * +quantity, decimalObj.bills.totalPrice);
+                    data.fees = [
+                        {
+                            fieldName: "common",
+                            tenderTotalFee: totalPrice,
+                            tenderUnitFee: unitPrice,
+                            totalFee: totalPrice,
+                            unitFee: unitPrice,
+                        }
+                    ];
+                    data.calcFlag = treeNodeCalcFlag.customUnitPrice;
+                }
                 let lastData = rst[rst.length - 1];
                 let parents = getParents(lastData);
                 //某数据编号为此数据的前缀,则某数据为此数据的父节点

+ 3 - 0
web/building_saas/main/js/views/project_view.js

@@ -3213,6 +3213,9 @@ function doAfterImportPosition(positionData){
             node.source = projectObj.project.Bills.tree.nodes['id_' + node.getID()];
             node.data = node.source.data;
             node.sourceType = projectObj.project.Bills.getSourceType();
+            if (node.data.fees) {
+                node.data.feesIndex = getFeeIndex(node.data.fees);
+            }
         }
         ProjectController.syncDisplayNewNodes(projectObj.mainController, newNodes);
     }