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

导出暂估、评标等材料适应新结构

zhongzewei 6 лет назад
Родитель
Сommit
de3c48b4b8

+ 72 - 30
web/building_saas/main/js/models/exportStandardInterface.js

@@ -794,7 +794,7 @@ const XMLStandard = (function () {
         function DifferentiaGljDetail(adjustType, source) {
             let attrs = [
                 //getGljCode(source.id)
-                {name: '关联材料号', value: source.code, minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true},
+                {name: '关联材料号', value: exportKind === _config.EXPORT_KIND.Tender ? source.relCode : '', minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true},
                 {name: '名称', value: source.name, minLen: 1, maxLen: 255, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true},
                 {name: '规格', value: source.specs, maxLen: 255, whiteSpace: _config.WHITE_SPACE.COLLAPSE},
                 {name: '单位', value: source.unit, minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true},
@@ -821,7 +821,7 @@ const XMLStandard = (function () {
         function ExponentialGljDetail(adjustType, source) {
             let attrs = [
                 // getGljCode(source.id)
-                {name: '关联材料号', value: source.code, minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true},
+                {name: '关联材料号', value: exportKind === _config.EXPORT_KIND.Tender ? source.relCode : '', minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true},
                 {name: '名称', value: source.name, minLen: 1, maxLen: 255, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true},
                 {name: '规格', value: source.specs, maxLen: 255, whiteSpace: _config.WHITE_SPACE.COLLAPSE},
                 {name: '变值权重B', value: adjustType === _config.ADJUST_TYPE.coe ? source.varWeight : '0', type: _config.TYPE.DECIMAL, required: true},
@@ -891,20 +891,20 @@ const XMLStandard = (function () {
             XML_EXPORT_BASE.Element.call(this, '暂估价材料表', []);
         }
         //材料明细定义
-        function MaterialDetail(parentName, source) {
+        function MaterialDetail(source) {
             let attrs = [
-                {name: '序号', value: parentName === 'evalEstimateMaterial' ? source.orgCode : source.serialNo, minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true},
-                {name: '关联材料号', value: source.code, minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE},
+                {name: '序号', value: source.seq, minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true},
+                {name: '关联材料号', value: exportKind === _config.EXPORT_KIND.Tender ? source.relCode : '', minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE},
                 {name: '材料名称', value: source.name, minLen: 1, maxLen: 255, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true},
                 {name: '规格型号', value: source.specs, maxLen: 255},
                 {name: '计量单位', value: source.unit, minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true},
                 {name: '数量', value: exportKind === _config.EXPORT_KIND.Tender ? source.quantity : '0', type: _config.TYPE.DECIMAL},
                 {name: '单价', value: source.marketPrice, type: _config.TYPE.DECIMAL},
                 {name: '合价', value: exportKind === _config.EXPORT_KIND.Tender ? source.totalPrice : '0', type: _config.TYPE.NUM2},
-                {name: '产地', value: source.originPlace, maxLen: 255},
-                {name: '厂家', value: source.vender, maxLen: 255},
-                {name: '品牌', value: source.brand, maxLen: 255},
-                {name: '质量等级', value: source.qualityGrace, maxLen: 255},
+                {name: '产地', value: exportKind === _config.EXPORT_KIND.Tender ? source.originPlace : '', maxLen: 255},
+                {name: '厂家', value: exportKind === _config.EXPORT_KIND.Tender ? source.vender : '', maxLen: 255},
+                {name: '品牌', value: exportKind === _config.EXPORT_KIND.Tender ? source.brand : '', maxLen: 255},
+                {name: '质量等级', value: exportKind === _config.EXPORT_KIND.Tender ? source.qualityGrace : '', maxLen: 255},
                 {name: '备注', value: source.remark, maxLen: 255},
             ];
             XML_EXPORT_BASE.Element.call(this, '材料明细', attrs);
@@ -979,7 +979,6 @@ const XMLStandard = (function () {
         async function loadProject(projectData) {
             // 标记自检提示的开始(一次性多出多个文件类型,会导出多次)
             _failList.push(_config.HINT_START);
-            console.log(projectData);
             //标段
             let project = new Project({
                 basicInformation: projectData.property.basicInformation,
@@ -1023,6 +1022,7 @@ const XMLStandard = (function () {
             }
             //主要清单汇总、评审材料汇总 排在后面
             project.children = [...project.children.slice(2), mainBillsSummaryEle, appraisalSummary];
+            console.log(project);
             return [{
                 data: project,
                 exportKind: exportKind,
@@ -1142,17 +1142,21 @@ const XMLStandard = (function () {
                 if (exportKind === _config.EXPORT_KIND.Tender) {
                     let adjustType = tenderData.property.gljAdjustType || _config.ADJUST_TYPE.info;
                     //承包人材料差额法表
-                    let diffGljs = materialAdjustObj.getPirceInfoDatas(tenderDetail.projectGLJ.datas.gljList,tenderDetail.contractor_list.datas);
+                    let diffGljs = materialAdjustObj.getPirceInfoDatas(tenderDetail.projectGLJ.datas.gljList, tenderDetail.contractor_list.datas);
                     if (diffGljs.length) {
                         let diffP = new DifferentiaGlj();
-                        diffGljs.forEach(data => diffP.children.push(new DifferentiaGljDetail(adjustType, data)));
+                        diffGljs.forEach(data => {
+                            const relGLJ = _util.getRelGLJ(allGljs, data.projectGLJID);
+                            data.relCode = relGLJ ? relGLJ.code : '';
+                            diffP.children.push(new DifferentiaGljDetail(adjustType, data))
+                        });
                         tender.children.push(diffP);
                     }
                     //承包人材料指数法表
                     let engineeringCostNode = tenderDetail.Bills.tree.roots.find(node => node.getFlag() === fixedFlag.ENGINEERINGCOST);
                     if (engineeringCostNode) {
                         let ecTotalFee = _util.getFee(engineeringCostNode.data.fees, 'common.totalFee');
-                        let exponentialGljs = materialAdjustObj.getPriceCoeDatas(tenderDetail.projectGLJ.datas.gljList,tenderDetail.contractor_list.datas,ecTotalFee);
+                        let exponentialGljs = materialAdjustObj.getPriceCoeDatas(tenderDetail.projectGLJ.datas.gljList, tenderDetail.contractor_list.datas, ecTotalFee);
                         if (exponentialGljs.length) {
                             // 变值权重B累加
                             let totalVarWeight = exponentialGljs.reduce((acc, cur) => acc += cur.varWeight || 0, 0);
@@ -1160,6 +1164,8 @@ const XMLStandard = (function () {
                             let fixedWeight = adjustType === _config.ADJUST_TYPE.coe ? 1 - totalVarWeight : '1';
                             let exP = new ExponentialGlj(fixedWeight);
                             exponentialGljs.forEach(data => {
+                                const relGLJ = _util.getRelGLJ(allGljs, data.projectGLJID);
+                                data.relCode = relGLJ ? relGLJ.code : '';
                                 exP.children.push(new ExponentialGljDetail(adjustType, data));
                             });
                             tender.children.push(exP);
@@ -1900,6 +1906,8 @@ const XMLStandard = (function () {
             let gljList = detail.projectGLJ.datas.gljList;
             let evalBidSeq = 1,    //评标序号
                 evalEstSeq = 1;    //暂估序号
+            // 人材机提取数据映射 id-数据映射
+            const allGLJMapping = {};
             if (gljList.length > 0) {
                 //创建人材机汇总节点
                 let gljSummary = new GljSummary();
@@ -1929,6 +1937,7 @@ const XMLStandard = (function () {
                     '5': '400', //为“商品砼”、商品砂浆”时,取“400”。
                     '6': '400'
                 };
+                // 人材机汇总
                 for (let glj of allGljs) {
                     // 企业管理费、利润、一般风险费不导出
                     if (skipGLJTypes.includes(glj.type)) {
@@ -1974,6 +1983,7 @@ const XMLStandard = (function () {
                         brand: glj.brand,
                         remark: glj.remark
                     };
+                    allGLJMapping[glj.id] = gljSource;
                     let gljEle = new Glj(gljSource);
                     //人材机代码唯一
                     _util.checkUnique(curTenderEle.constraints.gljCode, gljSource.code, '人材机代码', gljSource.orgCode);
@@ -1994,26 +2004,58 @@ const XMLStandard = (function () {
                         }
                     }
                     gljSummary.children.push(gljEle);
-                    gljSource.totalPrice = scMathUtil.roundForObj(gljSource.quantity * gljSource.marketPrice,
-                        detail.projectInfo.property.decimal.bills.totalPrice);
-                    //评标和暂估材料表下的材料明细中的人材机代码,要求单位工程内唯一,由于人材机汇总也有这个限制,所以
-                    // 这里不再处理
-                    if (glj.is_eval_material) { //评标
-                        gljSource.serialNo = evalBidSeq++;
-                        evalBidMaterial.children.push(new MaterialDetail('evalBidMaterial', gljSource));
-                        //给建设项目下的评审材料汇总设置明细数据,这里需要检测代码(编号)唯一性,因为是汇总所有单位工程的,要求所有单位工程内评审材料代码唯一
-                        appraisalSummary.children.push(new AppraisalDetail(gljSource));
-                        //_util.checkUnique(curTenderEle.constraints.appraisalDetailCode, gljSource.code, '评审材料明细代码', gljSource.orgCode);
-                        _util.checkUnique(curTenderEle.constraints.detailCode, gljSource.code, '材料明细关联材料号', gljSource.orgCode);
-                    }
-                    if (glj.is_evaluate) {  //暂估
-                        gljSource.serialNo = evalEstSeq++;
-                        evalEstimateMaterial.children.push(new MaterialDetail('evalEstimateMaterial', gljSource));
-                        _util.checkUnique(curTenderEle.constraints.detailCode, gljSource.code, '材料明细关联材料号', gljSource.orgCode);
-                    }
                 }
+                // 评标材料
+                const bidEvaluationDetail = loadMaterialDetail(detail.bid_evaluation_list.datas);
+                evalBidMaterial.children.push(...bidEvaluationDetail);
+                // 给建设项目下的评审材料汇总设置明细数据 //code name specs unit marketPrice
+                const appraisalSummaryDetail = bidEvaluationDetail.map(ele => {
+                    const attrObj = _util.getPlainAttrs(ele);
+                    const src = {
+                        code: attrObj['关联材料号'],
+                        name: attrObj['材料名称'],
+                        specs: attrObj['规格型号'],
+                        unit: attrObj['计量单位'],
+                        marketPrice: attrObj['单价']
+                    };
+                    return new AppraisalDetail(src);
+                });
+                appraisalSummary.children.push(...appraisalSummaryDetail);
+                // 暂估材料
+                const evaluationDetail = loadMaterialDetail(detail.evaluate_list.datas);
+                evalEstimateMaterial.children.push(...evaluationDetail);
                 return {gljSummary, evalBidMaterial, evalEstimateMaterial};
             }
+            // 加载材料明细
+            // todo configMaterialObj.getEvaluateMaterialDatas
+            function loadMaterialDetail(datas) {
+                return datas.map(data => {
+                    const relGLJSrc = allGLJMapping[data.projectGLJID];
+                    const quantity = relGLJSrc ? relGLJSrc.quantity : data.quantity;
+                    const marketPrice = relGLJSrc ? relGLJSrc.marketPrice : data.marketPrice;
+                    const originPlace = relGLJSrc ? relGLJSrc.originPlace : '';
+                    const vender = relGLJSrc ? relGLJSrc.vender : '';
+                    const brand = relGLJSrc ? relGLJSrc.brand : '';
+                    const qualityGrace = relGLJSrc ? relGLJSrc.qualityGrace : '';
+                    const src = {
+                        seq: data.seq,
+                        relCode: relGLJSrc ? relGLJSrc.code : '',
+                        name: data.name,
+                        specs: data.specs,
+                        unit: data.unit,
+                        quantity: quantity,
+                        marketPrice: marketPrice,
+                        totalPrice: scMathUtil.roundForObj(quantity * marketPrice, detail.projectInfo.property.decimal.bills.totalPrice),
+                        originPlace: originPlace,
+                        vender: vender,
+                        brand: brand,
+                        qualityGrace: qualityGrace,
+                        remark: data.remark
+                    };
+                    _util.checkUnique(curTenderEle.constraints.detailCode, src.relCode, '材料明细关联材料号', src.relCode);
+                    return new MaterialDetail(src);
+                });
+            }
         }
         /*
          * 加载清单综合单价计算程序

+ 16 - 1
web/building_saas/main/js/models/exportStdInterfaceBase.js

@@ -314,6 +314,16 @@ const XML_EXPORT_BASE = (() => {
         return typeof v !== 'undefined' && v !== null && v !== '';
     }
     /*
+    * 将节点属性数据(attr数组)转换成简单key-value数据
+    * @param  {Object}ele 元素节点数据Element实例
+    * @return {Object}
+    * */
+    function getPlainAttrs(ele) {
+        const obj = {};
+        ele.attrs.forEach(attr => obj[attr.name] = attr.value);
+        return obj;
+    }
+    /*
     * 从fees数组中获取相关费用
     * @param  {Array}fees 费用数组
     *         {String}feeFields 费用字段
@@ -352,7 +362,10 @@ const XML_EXPORT_BASE = (() => {
         }
         return '';
     }
-
+    // 获取关联材料
+    function getRelGLJ(allGLJs, gljId) {
+        return allGLJs.find(glj => glj.id === gljId);
+    }
     // 随机生成机器信息码:CPU信息;硬盘序列号;mac地址;
     // 保存在localStorage中
     function generateHardwareId() {
@@ -729,7 +742,9 @@ const XML_EXPORT_BASE = (() => {
         hasValue,
         setTimeoutSync,
         getFee,
+        getPlainAttrs,
         getValueByKey,
+        getRelGLJ,
         generateHardwareId,
         arrayToObj,
         validDepth,