Jelajahi Sumber

基本信息与文件类型相关

zhongzewei 7 tahun lalu
induk
melakukan
b4c2159649

+ 2 - 1
modules/pm/controllers/pm_controller.js

@@ -715,7 +715,8 @@ module.exports = {
     },
     getBasicInfo: async function(req, res) {
         try {
-            let infoLib = await pm_facade.getBasicInfo(req.session.sessionCompilation._id);
+            let data = JSON.parse(req.body.data);
+            let infoLib = await pm_facade.getBasicInfo(req.session.sessionCompilation._id, data.fileKind);
             callback(req, res, 0, 'success', infoLib ? infoLib.info : []);
         } catch (err) {
             console.log(err);

+ 18 - 3
modules/pm/facade/pm_facade.js

@@ -1070,7 +1070,8 @@ async function changeFile(datas,userID,fileID,name,from,type){//from 费率或
 
 }
 
-async function getBasicInfo(compilationID) {
+//获取费用定额绑定的基本信息库数据
+async function getBasicInfo(compilationID, fileKind = null) {
     let compilation = await compilationModel.findOne({_id: mongoose.Types.ObjectId(compilationID)});
     if (!compilation) {
         return null;
@@ -1089,6 +1090,20 @@ async function getBasicInfo(compilationID) {
         return null;
     }
     let infoLib = await basicInfoModel.findOne({ID: engineering.info_lib[0].id});
+    //提取文件类型中需要的数据 (投标项目可能不需要招标的一些信息)
+    if (fileKind && infoLib && infoLib.info && infoLib.info.length) {
+        let strMap = {
+            1: 'tender',    //投标
+            2: 'bid',       //招标
+            3: 'control'    //控制价
+        };
+        let needfulData = infoLib.info.filter(data => !data.fileKind || data.fileKind === strMap[fileKind]);
+        needfulData.forEach(nData => {
+            let needfulSub = nData.items.filter(sData => !sData.fileKind || sData.fileKind === strMap[fileKind]);
+            nData.items = needfulSub;
+        });
+        infoLib.info = needfulData;
+    }
     return infoLib;
 }
 
@@ -1157,7 +1172,7 @@ async function getProjectByGranularity(tenderID, granularity, userID, versionNam
     let product = await productModel.findOne({});
     let company = product.company || '珠海纵横创新软件有限公司',
         version = product.version || '';
-    constructionProject._doc.softInfo = new Buffer(`${company};${versionName};${version};${userID}`).toString('base64');
+    constructionProject._doc.softInfo = `${company};${versionName};${version};${userID}`;
     return constructionProject;
 }
 
@@ -1262,7 +1277,7 @@ async function importProject(importObj, userID, compilationID) {
     //给建设项目设置一些数据
     async function setupConstruct(data) {
         //更新基本信息, 按照key匹配
-        let infoLib = await getBasicInfo(data.compilation);
+        let infoLib = await getBasicInfo(data.compilation, data.property.fileKind);
         if (infoLib) {
             //标准基本信息库的数据打平
             let flatDatas = [];

+ 1 - 0
modules/pm/models/project_model.js

@@ -835,6 +835,7 @@ ProjectsDAO.prototype.getConstructionProperty = async function (projectID) {
     return constructionProject.property;
 };
 
+//获取建设项目的基本信息
 ProjectsDAO.prototype.getBasicInfo = async function (projectID) {
     //获取建设项目
     let constructionProject = await pmFacade.getConstructionProject(projectID);

+ 32 - 15
web/building_saas/main/js/models/exportStandardInterface.js

@@ -47,6 +47,7 @@ const XMLStandard = (function () {
     const FILE_KIND = {
         '1': '投标',
         '2': '招标',
+        '3': '控制价'
     };
     //计税方法
     const TAX_TYPE = {
@@ -58,17 +59,29 @@ const XMLStandard = (function () {
     function isDef(v) {
         return typeof v !== 'undefined' && v !== null;
     }
-    return function (userID, granularity) {
-        //导出粒度
-        this.GRANULARITY = {
-            PROJECT: 1,         //导出建设项目
-            ENGINEERING: 2,     //导出单项工程
-            TENDER: 3           //导出单位工程
-        };
+    //导出粒度
+    const GRANULARITY = {
+        PROJECT: 1,         //导出建设项目
+        ENGINEERING: 2,     //导出单项工程
+        TENDER: 3           //导出单位工程
+    };
+    //导出的文件类型选项
+    const ExportKind = {
+        Tender: 1,  //投标
+        Bid: 2,     //招标
+        Control: 3  //控制价
+    };
+    return function (userID, granularity, exportKind) {
         //默认导出建设项目
         if (!granularity || ![1, 2, 3].includes(granularity)) {
-            granularity = this.GRANULARITY.PROJECT;
+            granularity = GRANULARITY.PROJECT;
         }
+        this.granularity = granularity;
+        //默认导出招标文件
+        if (!exportKind || ![1, 2, 3].includes(exportKind)) {
+            exportKind = ExportKind.Bid;
+        }
+        this.exportKind = exportKind;
         /*
          * 检查
          * 创建节点时检查节点的数据
@@ -229,12 +242,13 @@ const XMLStandard = (function () {
         }
         //招标信息定义
         function BiddingInfo(source) {
+            //控制总价: 如果文件类型是“控制价”,则导出建设项目的工程造价;如果是“招标”、“投标”,则取0
             let attrs = [
-                {name: '招标代理机构', value: getValueByKey(source.basicInformation, 'tenderingAgency')},
+                {name: '招标代理机构', value: getValueByKey(source.basicInformation, 'agency')},
                 {name: '造价工程师', value: getValueByKey(source.basicInformation, 'tenderCostEngineer'), required: true},
                 {name: '造价工程师注册证号', value: getValueByKey(source.basicInformation, 'tenderCostEngineerNo'), required: true},
                 {name: '招标工期', value: getValueByKey(source.basicInformation, 'tenderPeriod'), required: true, type: TYPE.INT},
-                {name: '控制总价', value: source.summaryInfo.engineeringCost, required: true, type: TYPE.NUM2},
+                {name: '控制总价', value: exportKind === ExportKind.Control ? source.summaryInfo.engineeringCost : '0', required: true, type: TYPE.NUM2},
             ];
             element.call(this, '招标信息', attrs);
         }
@@ -370,7 +384,8 @@ const XMLStandard = (function () {
                 {name: '费率', value: source.feeRate},
                 {name: '金额', value: getFee(source.fees, 'common.totalFee'), type: TYPE.NUM2},
                 {name: '其中暂估价', value: getFee(source.fees, 'estimate.totalFee'), type: TYPE.NUM2},
-                {name: '费用类别', value: source.feeType, type: TYPE.INT, required: true, enumeration: ['1100', '1200', '1204', '1300', '800', '900', '1800', '1']},
+                {name: '费用类别', value: source.feeType, type: TYPE.INT, required: true,
+                    enumeration: ['1100', '1200', '1204', '1300', '800', '900', '1800', '1']},
                 {name: '备注', value: source.remark},
             ];
             element.call(this, '计价程序费用行', attrs);
@@ -980,7 +995,7 @@ const XMLStandard = (function () {
             let project = new Project({
                 basicInformation: projectData.property.basicInformation,
                 name: projectData.name,
-                fileKind: projectData.property.fileKind ? FILE_KIND[projectData.property.fileKind] : '',
+                fileKind: FILE_KIND[exportKind],
                 taxType: projectData.property.taxType ? TAX_TYPE[projectData.property.taxType] : ''
             });
             curProjectEle = project;
@@ -990,9 +1005,11 @@ const XMLStandard = (function () {
             //招标信息
             let biddingInfo = new BiddingInfo({basicInformation: projectData.property.basicInformation, summaryInfo: projectData.summaryInfo[projectData.ID]});
             projectInfo.children.push(biddingInfo);
-            //投标信息
-            let bidInfo = new BidInfo({basicInformation: projectData.property.basicInformation, summaryInfo: projectData.summaryInfo[projectData.ID]});
-            projectInfo.children.push(bidInfo);
+            //投标信息 导出类型为投标时,才导出
+            if (exportKind === ExportKind.Tender) {
+                let bidInfo = new BidInfo({basicInformation: projectData.property.basicInformation, summaryInfo: projectData.summaryInfo[projectData.ID]});
+                projectInfo.children.push(bidInfo);
+            }
             //编制说明
             let compilationIll = new CompilationIllustration({compilationIllustration: projectData.property.compilationIllustration});
             project.children.push(compilationIll);

+ 70 - 38
web/building_saas/pm/js/pm_newMain.js

@@ -14,7 +14,10 @@ let isSaving = false;
 let projectProperty = [];
 let fileDelObj = null;
 let curStep = 1; //当前在第几步
-let infoData = null; //建设项目基本信息数据
+let infoData = null; //建设项目基本信息数据 (完整)
+//需要的建设项目基本信息 (根据文件类型,因为需要切换文件类型获取不同的基本信息
+//为了减少请求,infoData获取完整的基本信息数据,needfulInfoData标记当前文件类型所需基本信息数据)
+let needfulInfoData = null;
 let featureData = null; //工程特征数据
 let projectType = {
     folder: 'Folder',
@@ -1627,8 +1630,8 @@ $(document).ready(function() {
         if (!validRequiredData($('#projInfoStep'))) {
             return;
         }
-        if (infoData && Array.isArray(infoData)) {
-            updateRequiredData($('#projInfoStep'), infoData);
+        if (needfulInfoData && Array.isArray(needfulInfoData)) {
+            updateRequiredData($('#projInfoStep'), needfulInfoData);
         }
         AddProject();
     });
@@ -1662,13 +1665,16 @@ $(document).ready(function() {
         let requiredData = null;
         if (!infoData) {
             try {
+                let fileKind = $('input[name="fileKind"]:checked').val();
                 infoData = await ajaxPost('/pm/api/getBasicInfo', {user_id: userID});
+                //第一次默认是投标
+                needfulInfoData = getNeedfulBasicInfo(infoData, fileKind);
                 console.log(infoData);
             } catch (err) {
                 $('#add-project-dialog').modal('hide');
             }
         }
-        requiredData = getRequired([], infoData);
+        requiredData = getRequired([], needfulInfoData);
         if (requiredData.length > 0) {
             $('#add-proj-next').show();
         } else {
@@ -1684,8 +1690,24 @@ $(document).ready(function() {
         $('#addProjOk').show();
         $('#projInfoStep').show();
         $('#project-required-warn').show();
-        showRequiredInfo($('#projInfoStep'), infoData);
+        showRequiredInfo($('#projInfoStep'), needfulInfoData);
     }
+    //新建建设项目-文件类型选择 (影响到基本信息数据)
+    $('input[name="fileKind"]').click(function () {
+        if (infoData && infoData.length) {
+            let fileKind = $(this).val();
+            needfulInfoData = getNeedfulBasicInfo(infoData, fileKind);
+        }
+        let requiredData = getRequired([], needfulInfoData);
+        if (requiredData.length > 0) {
+            $('#addProjOk').hide();
+            $('#add-proj-next').show();
+        } else {
+            $('#projInfoStep').empty();
+            $('#add-proj-next').hide();
+            $('#addProjOk').show();
+        }
+    });
 
     //新建建设项目、新建单项工程、新建文件夹、重命名弹窗隐藏事件
     function bindModalsHidden(projDialog, engDialog, folderDialog, renameDialog){
@@ -1698,6 +1720,9 @@ $(document).ready(function() {
         });
         projDialog.on('show.bs.modal', function () {
             infoData = null;
+            needfulInfoData = null;
+            $('#add-proj-prev').hide();
+            $('#add-proj-next').hide();
             showProjFirstStep();
         });
         engDialog.on('hidden.bs.modal', function () {
@@ -1895,6 +1920,7 @@ $(document).ready(function() {
         //clear info
         curStep = 1; //当前在第几步
         infoData = null; //建设项目基本信息数据
+        needfulInfoData = null;
         featureData = null; //工程特征数据
         $('#poj-name-info').hide();
         $('#eng-name-info').hide();
@@ -1927,6 +1953,14 @@ $(document).ready(function() {
             $('#tender-name')[0].focus();
         }, 300);
     });
+    //新建单位工程-文件类型选择变换(影响到基本信息数据)
+    $('input[name="fileKind-tender"]').click(function () {
+        if (infoData && infoData.length) {
+            let fileKind = $(this).val();
+            needfulInfoData = getNeedfulBasicInfo(infoData, fileKind);
+            $('#infoStep').empty(); //清空设置的基本信息必填数据
+        }
+    });
     //新建单位工程-下一步
     $('#add-tender-next').click(async function() {
         if (curStep === 1) {
@@ -1979,7 +2013,7 @@ $(document).ready(function() {
                 return false;
             }
             let path = getAddPath();
-            let infoRequired = getRequired([], infoData);
+            let infoRequired = getRequired([], needfulInfoData);
             let featureRequired = getRequired([], featureData);
             if (path === addPath.p_e_t && infoRequired.length > 0) {
                 showInfoStep();
@@ -2036,7 +2070,9 @@ $(document).ready(function() {
         $('#add-tender-cancel').show();
         if (!infoData) {
             try {
+                let fileKind = $('input[name="fileKind-tender"]:checked').val();
                 infoData = await ajaxPost('/pm/api/getBasicInfo', {user_id: userID});
+                needfulInfoData = getNeedfulBasicInfo(infoData, fileKind);
             } catch (err) {
                 $('#add-tender-dialog').modal('hide');
             }
@@ -2052,7 +2088,7 @@ $(document).ready(function() {
                 $('#add-tender-dialog').modal('hide');
             }
         }
-        let infoRequired = getRequired([], infoData),
+        let infoRequired = getRequired([], needfulInfoData),
             featureRequired = getRequired([], featureData),
             path = getAddPath();
         if (path === addPath.p_e_t && infoRequired.length > 0 || featureRequired.length > 0) {
@@ -2075,7 +2111,7 @@ $(document).ready(function() {
             $('#add-tender-next').hide();
             $('#add-tender-confirm').show();
         }
-        showRequiredInfo($('#infoStep'), infoData);
+        showRequiredInfo($('#infoStep'), needfulInfoData);
     }
     //显示新建单位工程-工厂特征内容
     function showFeatureStep() {
@@ -2175,8 +2211,8 @@ $(document).ready(function() {
         if (!validRequiredData($('#featureStep'))) {
             return;
         }
-        if (infoData && Array.isArray(infoData)) {
-            updateRequiredData($('#infoStep'), infoData);
+        if (needfulInfoData && Array.isArray(needfulInfoData)) {
+            updateRequiredData($('#infoStep'), needfulInfoData);
         }
         if (featureData && Array.isArray(featureData)) {
             updateRequiredData($('#featureStep'), featureData);
@@ -2421,6 +2457,22 @@ function changeFeeRate(engLib) {
         $("#tender-fee-rate").children("option").first().val($('#tender-name').val());
     }
 }
+
+//根据文件类型筛选新的基本信息数据
+function getNeedfulBasicInfo(info, fileKind) {
+    let strMap = {
+        1: 'tender',    //投标
+        2: 'bid',       //招标
+        3: 'control'    //控制价
+    };
+    let needfulData = info.filter(data => !data.fileKind || data.fileKind === strMap[fileKind]);
+    needfulData.forEach(nData => {
+        let needfulSub = nData.items.filter(sData => !sData.fileKind || sData.fileKind === strMap[fileKind]);
+        nData.items = needfulSub;
+    });
+    return needfulData;
+}
+
 function getRequired(rst, datas) {
     if (!datas) {
         return rst;
@@ -2444,7 +2496,12 @@ async function changeFeature() {
     let feeName = $('#tender-feeStandard').val();
     featureData = await ajaxPost('/pm/api/getProjectFeature',
         {user_id: userID, valuationID: valuation, engineeringName: engineeringName, feeName: feeName});
-    let infoRequired = getRequired([], infoData),
+    updateAddState(needfulInfoData, featureData);
+}
+
+//更新当前新建单位工程是否需要下一步
+function updateAddState(needfulInfoData, featureData) {
+    let infoRequired = getRequired([], needfulInfoData),
         featureRequired = getRequired([], featureData),
         path = getAddPath();
     if (path === addPath.p_e_t && infoRequired.length > 0 || featureRequired.length > 0) {
@@ -2543,31 +2600,6 @@ function getWorkBookWidth(){
     return workBookWidth = $(window).width() - $('.pm-side').width() - 90;
 }
 
-/*function prepareInitialTimer(title, content) {
-    $('#progress .modal-title').text(title);
-    $('#progress .modal-body h5').text(content);
-    $('#progressBar').css('width', `0%`);
-    let outer = setInterval(function () {
-        let curWidth = parseInt($('#progressBar')[0].style.width.replace('%', ''));
-        curWidth = parseInt(curWidth + 2);
-        $('#progressBar').css('width', `${curWidth}%`);
-        if (curWidth >= 80) {
-            clearInterval(outer);
-        }
-    }, 100);
-    let inner = setInterval(function () {
-        let curWidth = parseFloat($('#progressBar')[0].style.width.replace('%', ''));
-        if (curWidth >= 80) {
-            curWidth = parseFloat(curWidth + 0.1);
-            $('#progressBar').css('width', `${curWidth}%`);
-            if (curWidth >= 95) {
-                clearInterval(inner);
-            }
-        }
-    }, 500);
-    return {outer, inner};
-}*/
-
 function initProjects(callback) {
     GetAllProjectData(function (datas) {
         //设置工程专业
@@ -2678,7 +2710,7 @@ function AddProject() {
      (3)、当前定位在建设项目,新建建设项目为其后兄弟。
      (4)、当前定位在单项工程或单位工程,新建项目为当前所属建设项目的后兄弟。
      * */
-    let property = {basicInformation: infoData ? infoData : [],
+    let property = {basicInformation: needfulInfoData ? needfulInfoData : [],
         fileKind: fileKind,
         taxType: taxType,
         valuation: valuation,
@@ -2795,7 +2827,7 @@ function AddTenderItems(selected, projName, engName, tenderName, property, callb
             }
             let fileKind = $('input[name="fileKind-tender"]:checked').val();
             let updateProjs = GetUpdateData(pre, parent, next, projName, {
-                basicInformation: infoData ? infoData : [],
+                basicInformation: needfulInfoData ? needfulInfoData : [],
                 fileKind: parseInt(fileKind), taxType: curTaxType, valuationType: curValutionType, valuation: curValuation, valuationName: curValuationName},
                 projID, {updateType: 'new', projectType: projectType.project});
             let updateEng = {updateType: 'new', updateData: {ID: engID, ParentID: projID, NextSiblingID: -1, name: engName, projType: projectType.engineering}};